Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add more logging #2052

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions webapp/packages/core-cli/bin/validate-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const currentPackage = JSON.parse(fs.readFileSync(currentPackagePath, 'utf8'));
// Keep track of the dependencies that were found in the source files
const dependencies = new Set();
const devDependencies = new Set();
let isSuccess = true;

const sourceFilesIterator = glob.globIterateSync('**/*.{ts,tsx,scss,css}', { cwd: currentPackageSrcPath });
const importRegex = /(import|export) ((type |)([\w,\s]*?)(\{[\w\s\n,]*?\}|) from |)['"]((@[\w-]*\/[\w-]*)|([^\\.].*?))(\/.*)*['"]/g;
Expand Down Expand Up @@ -84,6 +85,8 @@ for (const sideEffect of sideEffects) {
}
}

console.log('Analyzing dependencies...');

const newDependencies = [...dependencies].sort(sortDependencies);

logUnmetAndExtraDependencies('dependencies', newDependencies, currentPackage.dependencies);
Expand All @@ -108,6 +111,10 @@ currentPackage.devDependencies = [...devDependencies].sort(sortDependencies).red
currentPackage.devDependencies,
);

if (isSuccess) {
console.log('All dependencies are valid');
}

// Write the updated `package.json`
fs.writeFileSync(currentPackagePath, JSON.stringify(currentPackage, null, 2) + '\n', 'utf8');

Expand Down Expand Up @@ -152,9 +159,11 @@ function logUnmetAndExtraDependencies(key, newDependencies, current) {

if (unmetDependencies.length > 0) {
console.warn(`Unmet ${key} found:`, unmetDependencies);
isSuccess = false;
}

if (extraDependencies.length > 0) {
console.warn(`Extra ${key} found:`, extraDependencies);
isSuccess = false;
}
}