chore(providence-analytics): add match-import example content

This commit is contained in:
Thijs Louisse 2020-07-21 23:50:26 +02:00
parent 12b6608516
commit b781160919
3 changed files with 37 additions and 12 deletions

View file

@ -20,6 +20,7 @@
],
"scripts": {
"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",

View file

@ -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,
},
};

View file

@ -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;
}
}