You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/npm/package-update-script.js

44 lines
1.2 KiB

const glob = require('glob');
var path = require('path');
const childProcess = require('child_process');
const { program } = require('commander');
program.version('0.0.1');
program.option('-pr, --prerelease', 'whether version is prerelease');
program.option('-rg, --registry <registry>', 'target npm server registry');
program.parse(process.argv);
const packages = (process.argv[3] || 'abp').split(',').join('|');
const check = (pkgJsonPath) => {
try {
return childProcess
.execSync(
`ncu "/^@(${packages}).*$/" --packageFile ${pkgJsonPath} -u${
program.prerelease ? ' --target greatest' : ' --target patch'
}${program.registry ? ` --registry ${program.registry}` : ''}`
)
.toString();
} catch (error) {
console.log('exec error: ' + error.message);
process.exit(error.status);
}
};
const folder = process.argv[2] || '.';
glob(folder + '/**/package.json', {}, (er, files) => {
files.forEach((file) => {
if (
file.includes('node_modules') ||
file.includes('ng-packs/dist') ||
file.includes('wwwroot') ||
file.includes('bin/Debug')
) {
return;
}
console.log(check(file));
});
});