Merge pull request #825 from ing-bank/fix/providenceDashboard
Fix/providence dashboard
This commit is contained in:
commit
4cf829a874
6 changed files with 70 additions and 21 deletions
|
|
@ -304,14 +304,17 @@ class PBoard extends DecorateMixin(LitElement) {
|
|||
const refSearch = `_${ref.replace('#', '_')}_`;
|
||||
activeRepos.forEach(dep => {
|
||||
const depSearch = `_${dep.replace('#', '_')}_`;
|
||||
const found = this.__resultFiles[activeAnalyzer].find(
|
||||
({ fileName }) => fileName.includes(refSearch) && fileName.includes(depSearch),
|
||||
);
|
||||
const found = this.__resultFiles[activeAnalyzer].find(({ fileName }) => {
|
||||
return (
|
||||
fileName.includes(encodeURIComponent(refSearch)) &&
|
||||
fileName.includes(encodeURIComponent(depSearch))
|
||||
);
|
||||
});
|
||||
if (found) {
|
||||
jsonResultsActiveFilter.push(found.content);
|
||||
} else {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(`No result output json for ${refSearch} and ${depSearch}`);
|
||||
console.info(`No result output json for ${refSearch} and ${depSearch}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ const { LogService } = require('../../src/program/services/LogService.js');
|
|||
|
||||
// eslint-disable-next-line import/no-dynamic-require
|
||||
const providenceConf = require(`${pathLib.join(process.cwd(), 'providence.conf.js')}`);
|
||||
|
||||
let outputFilePaths;
|
||||
try {
|
||||
outputFilePaths = fs.readdirSync(ReportService.outputPath);
|
||||
|
|
@ -38,23 +39,42 @@ outputFilePaths.forEach(fileName => {
|
|||
}
|
||||
});
|
||||
|
||||
function getPackageJson(projectPath) {
|
||||
let pkgJson;
|
||||
try {
|
||||
const file = pathLib.resolve(projectPath, 'package.json');
|
||||
pkgJson = JSON.parse(fs.readFileSync(file, 'utf8'));
|
||||
} catch (_) {
|
||||
// eslint-disable-next-line no-empty
|
||||
}
|
||||
return pkgJson;
|
||||
}
|
||||
|
||||
function transformToProjectNames(collections) {
|
||||
const res = {};
|
||||
// eslint-disable-next-line array-callback-return
|
||||
Object.entries(collections).map(([key, val]) => {
|
||||
res[key] = val.map(c => pathLib.basename(c));
|
||||
res[key] = val.map(c => {
|
||||
const pkg = getPackageJson(c);
|
||||
return pkg && pkg.name;
|
||||
});
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
const pathFromServerRootToHere = `/${pathLib.relative(process.cwd(), __dirname)}`;
|
||||
|
||||
// Needed for dev purposes (we call it from ./packages/providence-analytics/ instead of ./)
|
||||
// Allows es-dev-server to find the right moduleDirs
|
||||
const fromPackageRoot = process.argv.includes('--serve-from-package-root');
|
||||
const moduleRoot = fromPackageRoot ? pathLib.resolve(process.cwd(), '../../') : process.cwd();
|
||||
|
||||
const config = createConfig({
|
||||
port: 8080,
|
||||
// appIndex: './dashboard/index.html',
|
||||
// rootDir: process.cwd(),
|
||||
appIndex: pathLib.resolve(__dirname, 'index.html'),
|
||||
rootDir: moduleRoot,
|
||||
nodeResolve: true,
|
||||
// moduleDirs: pathLib.resolve(process.cwd(), 'node_modules'),
|
||||
moduleDirs: pathLib.resolve(moduleRoot, 'node_modules'),
|
||||
watch: false,
|
||||
open: true,
|
||||
middlewares: [
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@
|
|||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"dashboard": "node ./dashboard/src/server.js",
|
||||
"dashboard": "node ./dashboard/src/server.js --serve-from-package-root",
|
||||
"match-lion-imports": "npm run providence analyze match-imports --search-target-collection @lion-targets --reference-collection @lion-references",
|
||||
"providence": "node --max-old-space-size=8192 ./src/cli/index.js",
|
||||
"test:node": "mocha './test-node/**/*.test.js'",
|
||||
"test:node:e2e": "mocha './test-node/program/**/*.e2e.js' --timeout 60000",
|
||||
|
|
|
|||
|
|
@ -1,13 +1,41 @@
|
|||
const pathLib = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
// This file is read by dashboard and cli and needs to be present under process.cwd()
|
||||
// It mainly serves as an example and it allows to run the dashboard locally
|
||||
// from within this repo.
|
||||
|
||||
/**
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function getAllLionScopedPackagePaths() {
|
||||
const rootPath = pathLib.resolve(__dirname, '../../packages');
|
||||
const filesAndDirs = fs.readdirSync(rootPath);
|
||||
const packages = filesAndDirs.filter(f => {
|
||||
const filePath = pathLib.join(rootPath, f);
|
||||
if (fs.lstatSync(filePath).isDirectory()) {
|
||||
let pkgJson;
|
||||
try {
|
||||
pkgJson = JSON.parse(fs.readFileSync(pathLib.resolve(filePath, './package.json')));
|
||||
// eslint-disable-next-line no-empty
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
return pkgJson.name && pkgJson.name.startsWith('@lion/');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return packages.map(p => pathLib.join(rootPath, p));
|
||||
}
|
||||
|
||||
const lionScopedPackagePaths = getAllLionScopedPackagePaths();
|
||||
|
||||
const providenceConfig = {
|
||||
metaConfig: {
|
||||
categoryConfig: [
|
||||
{
|
||||
// This is the name found in package.json
|
||||
project: 'lion-based-ui',
|
||||
project: '@lion/overlays',
|
||||
majorVersion: 1,
|
||||
// These conditions will be run on overy filePath
|
||||
categories: {
|
||||
|
|
@ -25,20 +53,16 @@ const providenceConfig = {
|
|||
],
|
||||
},
|
||||
// By predefening groups, we can do a query for programs/collections...
|
||||
// Select via " providence analyze -t 'exampleCollection' "
|
||||
// Select via " providence analyze --search-target-collection 'exampleCollection' "
|
||||
searchTargetCollections: {
|
||||
exampleCollection: [
|
||||
'./providence-input-data/search-targets/example-project-a',
|
||||
'./providence-input-data/search-targets/example-project-b',
|
||||
],
|
||||
'@lion-targets': lionScopedPackagePaths,
|
||||
// ...
|
||||
},
|
||||
referenceCollections: {
|
||||
// Our products
|
||||
'lion-based-ui': [
|
||||
'./providence-input-data/references/lion-based-ui',
|
||||
'./providence-input-data/references/lion-based-ui-labs',
|
||||
],
|
||||
// Usually the references are different from the targets.
|
||||
// In this demo file, we test @lion usage amongst itself
|
||||
// Select via " providence analyze --reference-collection 'exampleCollection' "
|
||||
'@lion-references': lionScopedPackagePaths,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ async function cli({ cwd, addProjectDependencyPaths } = {}) {
|
|||
let regexSearchOptions;
|
||||
|
||||
const externalConfig = InputDataService.getExternalConfig();
|
||||
console.log('externalConfig', externalConfig);
|
||||
|
||||
async function getQueryInputData(
|
||||
/* eslint-disable no-shadow */
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ class InputDataService {
|
|||
try {
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
return require(`${process.cwd()}/providence.conf.js`);
|
||||
} catch (_) {
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue