Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function checkForUpdates(packageObj) {
ncu.run({
// Always specify the path to the package file
packageData: JSON.stringify({dependencies: packageObj}),
// Any command-line option can be specified here.
// These are set by default:
logLevel: 'error',
greatest: true,
silent: true,
jsonUpgraded: true
}).then((upgraded) => {
console.log('\nTo upgrade:');
//, upgraded);
let keys = Object.keys(upgraded);
keys.forEach(key => console.log(`${key} ${packageObj[key]} → ${upgraded[key]}`));
});
}
//https://github.com/tjunnone/npm-check-updates
const ncu = require('npm-check-updates')
const fs = require('fs')
ncu.run({
packageFile: 'package.json',
silent: true,
jsonUpgraded: true,
jsonAll: true
// upgrade: true,
// upgradeAll: true
}).then((upgraded) => {
console.log('dependencies to upgrade:', upgraded);
const data = JSON.stringify(upgraded).replace(/,/g, ",\n").replace(/{/, '{\n').replace(/}/, '\n}')
fs.writeFileSync('upgrade.js', `"UPDATE DATA: ${new Date()}" \n` + data)
});
#!/usr/bin/env babel-node
/**
* This script allows you to upgrade all of the @ciscospark dependencies
* to their latest version.
*/
const ncu = require('npm-check-updates');
ncu.run({
// Always specify the path to the package file
packageFile: 'package.json',
// Any command-line option can be specified here.
// These are set by default:
filter: /^@(ciscospark|webex).*$/,
upgrade: true
}).then(() => {
console.log('@ciscospark dependencies upgraded');
});
gulp.task('checkNpmDependencies', function (done) {
gutil.log('This can take a minute...');
var reportFileName = './npm_dependencies_report.md';
ncu.run({
packageFile: 'package.json',
'error-level': 1 // we don't want to fail CI... we write a report file
}).then(function (upgraded) {
var tmpl = '# NPM DependencyCheck Report for <%- name %>\nThe following dependencies are out-of-date:\n\n<% _.forEach(upgraded, function(version, dependency) { %>* <%- dependency %>: <%- currentDependencies[dependency]%> -> <%- version%>\n<% }); %>';
return _.template(tmpl)(_.merge({
upgraded: upgraded
}, getPackageInformation()));
}).then(function (report) {
return q.nfcall(fs.writeFile, reportFileName, report);
}).then(function () {
gutil.log(gutil.colors.green('Report saved to ' + reportFileName));
}).catch(done);
});
const checkModules = (type) => {
return ncu.run({
packageManager: type
})
.then((upgraded) => {
const keys = Object.keys(upgraded);
if (keys.length === 0) {
console.log('none');
} else {
const table = new Table({
head: [`${type} name`, 'latest version']
});
Object.keys(upgraded).forEach((name) => {
table.push([name, upgraded[name]]);
});
async function ncuRunUpdate(packageVersionInfo: PackageVersionInformationResult) {
console.log("Update "+packageVersionInfo.framework.keyedType +'/' + packageVersionInfo.framework.directory);
await ncu.run({
packageFile: path.resolve('..', 'frameworks', packageVersionInfo.framework.keyedType, packageVersionInfo.framework.directory, 'package.json'),
upgrade: true
});
}
function updateBlog(done) {
ncu.run({
packageFile: 'blog/templates/_package.json',
jsonUpgraded: false,
upgrade: true,
upgradeAll: true
}).then(function () {
console.log('Upgrated blog project');
done();
}).catch(done);
},
function updateEvents(done) {
return through.obj(function(file, codec, cb) {
let relativePath = path.relative(process.cwd(), file.path);
ncu.run({
packageFile: relativePath,
packageManager: packageManager,
})
.then(function(toUpgrade) {
let dependenciesStr = Object.keys(toUpgrade)
.map((key) => {
return `${key}: ${toUpgrade[key]}\n`;
})
.join('');
if (dependenciesStr.length !== 0) {
gulputil.log(gulputil.colors.yellow(
`Dependencies needed to update:\n${dependenciesStr}\n` +
`Run: 'gulp update-${packageManager}-deps', then '${packageManager} ` +
`install' to update dependencies.\n`));
}