How to use npm-check-updates - 10 common examples

To help you get started, we’ve selected a few npm-check-updates examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cognizant-CDE-Australia / generator-confit / config / check-update / checkForUpdates.js View on Github external
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]}`));
  });
}
github JsAaron / xut.js / build / ncu.package.js View on Github external
//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)
});
github webex / react-widgets / scripts / utils / update.js View on Github external
#!/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');
});
github th0r / npm-upgrade / src / commands / check.js View on Github external
fetchRemoteDb();

  const depsGroupsToCheck = _.filter(DEPS_GROUPS, ({name}) => !!opts[name]);
  const depsGroupsToCheckStr = (depsGroupsToCheck.length === DEPS_GROUPS.length) ?
    '' : `${toSentence(_.map(depsGroupsToCheck, ({name}) => strong(name)))} `;
  const filteredWith = filter ? `filtered with ${strong(filter)} ` : '';

  console.log(
    `Checking for outdated ${depsGroupsToCheckStr}dependencies ${filteredWith}for "${strong(packageFile)}"...`
  );

  const ncuDepGroups = DEPS_GROUPS
    .filter(({name}) => opts[name])
    .map(({ncuValue}) => ncuValue)
    .join(',');
  const currentVersions = ncu.getCurrentDependencies(packageJson, {dep: ncuDepGroups});
  const latestVersions = await ncu.queryVersions(currentVersions, {versionTarget: 'latest'});
  let upgradedVersions = ncu.upgradeDependencies(currentVersions, latestVersions);

  // Filtering modules that have to be updated
  upgradedVersions = _.pickBy(
    upgradedVersions,
    (newVersion, moduleName) => filterModuleName(moduleName)
  );

  if (_.isEmpty(upgradedVersions)) {
    return console.log(success('All dependencies are up-to-date!'));
  }

  // Getting the list of ignored modules
  const config = new Config();
  config.ignore = config.ignore || {};
github th0r / npm-upgrade / src / commands / check.js View on Github external
const depsGroupsToCheck = _.filter(DEPS_GROUPS, ({name}) => !!opts[name]);
  const depsGroupsToCheckStr = (depsGroupsToCheck.length === DEPS_GROUPS.length) ?
    '' : `${toSentence(_.map(depsGroupsToCheck, ({name}) => strong(name)))} `;
  const filteredWith = filter ? `filtered with ${strong(filter)} ` : '';

  console.log(
    `Checking for outdated ${depsGroupsToCheckStr}dependencies ${filteredWith}for "${strong(packageFile)}"...`
  );

  const ncuDepGroups = DEPS_GROUPS
    .filter(({name}) => opts[name])
    .map(({ncuValue}) => ncuValue)
    .join(',');
  const currentVersions = ncu.getCurrentDependencies(packageJson, {dep: ncuDepGroups});
  const latestVersions = await ncu.queryVersions(currentVersions, {versionTarget: 'latest'});
  let upgradedVersions = ncu.upgradeDependencies(currentVersions, latestVersions);

  // Filtering modules that have to be updated
  upgradedVersions = _.pickBy(
    upgradedVersions,
    (newVersion, moduleName) => filterModuleName(moduleName)
  );

  if (_.isEmpty(upgradedVersions)) {
    return console.log(success('All dependencies are up-to-date!'));
  }

  // Getting the list of ignored modules
  const config = new Config();
  config.ignore = config.ignore || {};
github th0r / npm-upgrade / src / commands / check.js View on Github external
const depsGroupsToCheck = _.filter(DEPS_GROUPS, ({name}) => !!opts[name]);
  const depsGroupsToCheckStr = (depsGroupsToCheck.length === DEPS_GROUPS.length) ?
    '' : `${toSentence(_.map(depsGroupsToCheck, ({name}) => strong(name)))} `;
  const filteredWith = filter ? `filtered with ${strong(filter)} ` : '';

  console.log(
    `Checking for outdated ${depsGroupsToCheckStr}dependencies ${filteredWith}for "${strong(packageFile)}"...`
  );

  const ncuDepGroups = DEPS_GROUPS
    .filter(({name}) => opts[name])
    .map(({ncuValue}) => ncuValue)
    .join(',');
  const currentVersions = ncu.getCurrentDependencies(packageJson, {dep: ncuDepGroups});
  const latestVersions = await ncu.queryVersions(currentVersions, {versionTarget: 'latest'});
  let upgradedVersions = ncu.upgradeDependencies(currentVersions, latestVersions);

  // Filtering modules that have to be updated
  upgradedVersions = _.pickBy(
    upgradedVersions,
    (newVersion, moduleName) => filterModuleName(moduleName)
  );

  if (_.isEmpty(upgradedVersions)) {
    return console.log(success('All dependencies are up-to-date!'));
  }

  // Getting the list of ignored modules
  const config = new Config();
  config.ignore = config.ignore || {};

  // Making arrays of outdated modules
github th0r / npm-upgrade / src / commands / check.js View on Github external
}

  const updatedModules = [];
  let isUpdateFinished = false;
  while (modulesToUpdate.length && !isUpdateFinished) {
    const outdatedModule = modulesToUpdate.shift();
    const {name, from, to} = outdatedModule;
    let {changelogUrl, homepage} = outdatedModule;

    // Adds new line
    console.log('');

    const answer = await askUser({
      type: 'list',
      message: `${changelogUrl === undefined ? 'U' : 'So, u'}pdate "${name}" in package.json ` +
      `from ${from} to ${colorizeDiff(from, to)}?`,
      choices: _.compact([
        {name: 'Yes', value: true},
        {name: 'No', value: false},
        // Don't show this option if we couldn't find module's changelog url
        (changelogUrl !== null) &&
        {name: 'Show changelog', value: 'changelog'},
        // Show this if we haven't found changelog
        (changelogUrl === null && homepage !== null) &&
        {name: 'Open homepage', value: 'homepage'},
        {name: 'Ignore', value: 'ignore'},
        {name: 'Finish update process', value: 'finish'}
      ]),
      // Automatically setting cursor to "Open homepage" after we haven't found changelog
      default: (changelogUrl === null && homepage === undefined) ? 2 : 0
    });
github scenarioo / scenarioo-js / build / dependencyCheck.js View on Github external
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);

});
github codeBelt / slush-project / slush / tasks / testingBuildSystem / audit / tools / tasks / auditScripts.js View on Github external
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]]);
                });
github krausest / js-framework-benchmark / webdriver-ts / src / updateFrameworks.ts View on Github external
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
    });
}

npm-check-updates

Find newer versions of dependencies than what your package.json allows

Apache-2.0
Latest version published 10 days ago

Package Health Score

95 / 100
Full package analysis