1
0
Fork 0
mirror of https://github.com/shimataro/ssh-key-action.git synced 2025-06-19 22:52:10 +10:00

* first action! (#1)

This commit is contained in:
shimataro 2019-09-18 20:39:54 +09:00 committed by GitHub
parent 8deacc95b1
commit ace1e6a69a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3750 changed files with 1155519 additions and 0 deletions

13
node_modules/npm-check-updates/LICENSE generated vendored Normal file
View file

@ -0,0 +1,13 @@
Copyright 2013 Tomas Junnonen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

196
node_modules/npm-check-updates/README.md generated vendored Normal file
View file

@ -0,0 +1,196 @@
[![npm](https://badge.fury.io/js/npm-check-updates.svg)](http://badge.fury.io/js/npm-check-updates)
[![Build Status](https://travis-ci.org/tjunnone/npm-check-updates.svg?branch=master)](https://travis-ci.org/tjunnone/npm-check-updates)
> v3 released! See the [release notes](https://github.com/tjunnone/npm-check-updates/releases/tag/v3.0.0) for a description of breaking changes.
**npm-check-updates upgrades your package.json dependencies to the *latest* versions, ignoring specified versions.**
npm-check-updates maintains your existing semantic versioning *policies*, i.e., it will upgrade `"express": "^4.0.0"` to `"express": "^5.0.0"`.
npm-check-updates *only* modifies your package.json file. Run `npm install` to update your installed packages and package-lock.json.
![npm-check-updates-screenshot](https://github.com/tjunnone/npm-check-updates/blob/master/.github/screenshot.png?raw=true)
- Red = major upgrade (and all [major version zero](https://semver.org/#spec-item-4))
- Cyan = minor upgrade
- Green = patch upgrade
You may also want to consider [npm-check](https://github.com/dylang/npm-check). Similar purpose, different features.
Installation
--------------
```sh
npm install -g npm-check-updates
```
Usage
--------------
Show any new dependencies for the project in the current directory:
```sh
$ ncu
Checking package.json
[====================] 5/5 100%
express 4.12.x → 4.13.x
multer ^0.1.8 → ^1.0.1
react-bootstrap ^0.22.6 → ^0.24.0
react-a11y ^0.1.1 → ^0.2.6
webpack ~1.9.10 → ~1.10.5
Run ncu -u to upgrade package.json
```
Upgrade a project's package file:
> **Make sure your package file is in version control and all changes have been committed. This *will* overwrite your package file.**
```sh
$ ncu -u
Upgrading package.json
[====================] 1/1 100%
express 4.12.x → 4.13.x
Run npm install to install new versions.
$ npm install # update installed packages and package-lock.json
```
Check global packages:
```sh
$ ncu -g # add -u to get a one-line command for upgrading
```
You can include or exclude specific packages using the `--filter` and `--reject` options. They accept strings, comma-or-space-delimited lists, or regular expressions:
```sh
# match mocha and should packages exactly
$ ncu mocha # shorthand for ncu -f mocha (or --filter)
$ ncu one, two, three
# exclude packages
$ ncu -x nodemon # shorthand for ncu --reject nodemon
# match packages that start with "gulp-" using regex
$ ncu '/^gulp-.*$/'
# match packages that do not start with "gulp-". Note: single quotes are required
# here to avoid inadvertent bash parsing
$ ncu '/^(?!gulp-).*$/'
```
Options
--------------
--configFilePath rc config file path (default: ./)
--configFileName rc config file name (default: .ncurc.{json,yml,js})
--dep check only a specific section(s) of dependencies:
prod|dev|peer|optional|bundle (comma-delimited)
-e, --error-level set the error-level. 1: exits with error code 0 if no
errors occur. 2: exits with error code 0 if no
packages need updating (useful for continuous
integration)
-f, --filter include only package names matching the given string,
comma-or-space-delimited list, or /regex/
-g, --global check global packages instead of in the current project
-i, --interactive Enable interactive prompts for each dependency
-j, --jsonAll output new package file instead of human-readable
message
--jsonUpgraded output upgraded dependencies in json
-l, --loglevel what level of logs to report: silent, error, warn,
info, verbose, silly (default: warn)
-p, --packageManager npm or bower (default: npm)
-m, --minimal do not upgrade to newer versions that are already
satisfied by the existing version range (v2 behavior).
-n, --newest find the newest published versions available instead
of the latest stable versions
--packageData include stringified package file (use stdin instead)
--packageFile package file location (default: ./package.json)
--packageFileDir use same directory as packageFile to compare against
installed modules. See #201.
--pre include -alpha, -beta, -rc. Default: 0. Default
with --newest and --greatest: 1.
-r, --registry specify third-party NPM registry
-s, --silent don't output anything (--loglevel silent)
--semverLevel find the highest version within "major" or "minor"
-t, --greatest find the highest versions available instead of the
latest stable versions
--removeRange remove version ranges from the final package version
--timeout a global timeout in ms
-u, --upgrade overwrite package file
-x, --reject exclude packages matching the given string, comma-
delimited list, or regex
How dependency updates are determined
--------------
- Direct dependencies will be increased to the latest stable version:
- `2.0.1``2.2.0`
- `1.2``1.3`
- `0.1.0``1.0.1`
- with `--semverLevel major`
- `0.1.0``0.2.1`
- with `--semverLevel minor`
- `0.1.0``0.1.2`
- Semantic versioning policies for levels are maintained while satisfying the latest version:
- `^1.2.0``^2.0.0`
- `1.x``2.x`
- "Any version" is maintained:
- `*``*`
- "Greater than" is maintained:
- `>0.2.0``>0.3.0`
- Closed ranges are replaced with a wildcard:
- `1.0.0 < 2.0.0``^3.0.0`
Configuration Files
--------------
Use a `.ncurc.{json,yml,js}` file to specify configuration information.
You can specify file name and path using `--configFileName` and `--configFilePath`
command line options.
For example, `.ncurc.json`:
```json
{
"upgrade": true,
"filter": "express",
"reject": [
"@types/estree",
"ts-node"
]
}
```
Module Use
--------------
npm-check-updates can be required:
```js
const ncu = require('npm-check-updates');
ncu.run({
// Any command-line option can be specified here.
// These are set by default:
jsonUpgraded: true,
packageManager: 'npm',
silent: true
}).then((upgraded) => {
console.log('dependencies to upgrade:', upgraded);
});
```
Known Issues
--------------
- Windows: If npm-check-updates hangs, run `ncu --loglevel verbose` to see if it is waiting for stdin. If so, try setting the package file explicitly: `ncu -g --packageFile package.json`. See [#136](https://github.com/tjunnone/npm-check-updates/issues/136#issuecomment-155721102).
Also search the [issues page](https://github.com/tjunnone/npm-check-updates/issues).
Problems?
--------------
Please [file an issue](https://github.com/tjunnone/npm-check-updates/issues)! But always [search existing issues](https://github.com/tjunnone/npm-check-updates/issues?utf8=%E2%9C%93&q=is%3Aissue) first!

77
node_modules/npm-check-updates/bin/ncu generated vendored Executable file
View file

@ -0,0 +1,77 @@
#!/usr/bin/env node
'use strict';
const program = require('commander');
const updateNotifier = require('update-notifier');
const cint = require('cint');
const _ = require('lodash');
const rcLoader = require('rc-config-loader');
const ncu = require('../lib/npm-check-updates');
const pkg = require('../package.json');
// check if a new version of ncu is available and print an update notification
const notifier = updateNotifier({pkg});
if (notifier.update && notifier.update.latest !== pkg.version) {
notifier.notify({defer: false});
}
program
.description('[filter] is a list or regex of package names to check (all others will be ignored).')
.usage('[options] [filter]')
.option('--dep <dep>', 'check only a specific section(s) of dependencies: prod|dev|peer|optional|bundle (comma-delimited)')
.option('-e, --error-level <n>', 'set the error-level. 1: exits with error code 0 if no errors occur. 2: exits with error code 0 if no packages need updating (useful for continuous integration). Default is 1.', cint.partialAt(parseInt, 1, 10), 1)
.option('-f, --filter <matches>', 'include only package names matching the given string, comma-or-space-delimited list, or /regex/')
.option('-g, --global', 'check global packages instead of in the current project')
// program.json is set to true in programInit if any options that begin with 'json' are true
.option('-i, --interactive', 'Enable interactive prompts for each dependency')
.option('-j, --jsonAll', 'output new package file instead of human-readable message')
.option('--jsonUpgraded', 'output upgraded dependencies in json')
.option('-l, --loglevel <n>', 'what level of logs to report: silent, error, minimal, warn, info, verbose, silly (default: warn)', 'warn')
.option('-m, --minimal', 'do not upgrade newer versions that are already satisfied by the version range according to semver')
.option('-n, --newest', 'find the newest versions available instead of the latest stable versions')
.option('-p, --packageManager <name>', 'npm (default) or bower', 'npm')
.option('--packageData', 'include stringified package file (use stdin instead)')
.option('--packageFile <filename>', 'package file location (default: ./package.json)')
.option('--packageFileDir', 'use same directory as packageFile to compare against installed modules. See #201.')
.option('--pre <n>', 'Include -alpha, -beta, -rc. Default: 0. Default with --newest and --greatest: 1')
.option('-r, --registry <url>', 'specify third-party npm registry')
.option('--configFilePath <path>', 'rc config file path (default: ./)')
.option('--configFileName <path>', 'rc config file name (default: .ncurc.{json,yml,js})')
.option('-s, --silent', "don't output anything (--loglevel silent)")
.option('-t, --greatest', 'find the highest versions available instead of the latest stable versions')
.option('--timeout <ms>', 'a global timeout in ms')
.option('-u, --upgrade', 'overwrite package file')
.option('-x, --reject <matches>', 'exclude packages matching the given string, comma-or-space-delimited list, or /regex/')
.option('--semverLevel <level>', 'find the highest version within "major" or "minor"')
.option('--removeRange', 'remove version ranges from the final package version')
.option('-v, --version', pkg.version, () => {
console.log(pkg.version);
process.exit(0);
})
.option('-V', '', () => {
console.log(pkg.version);
process.exit(0);
});
program.parse(process.argv);
const rcFile = rcLoader('ncurc', {
configFileName: program.configFileName || '.ncurc',
defaultExtension: ['.json', '.yml', '.js'],
cwd: program.configFilePath || undefined
});
const rcArguments = rcFile && rcFile.config ?
_.flatten(_.map(rcFile.config, (value, name) =>
value === true ? [`--${name}`] : [`--${name}`, value]
)) : [];
const combinedArguments = process.argv.slice(0,2).concat(rcArguments).concat(process.argv.slice(2));
program.parse(combinedArguments);
program.cli = true;
program.filter = program.args.join(' ') || program.filter;
ncu.run(program);

4
node_modules/npm-check-updates/bin/npm-check-updates generated vendored Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env node
'use strict';
require('node-alias')('ncu', __dirname);

438
node_modules/npm-check-updates/lib/npm-check-updates.js generated vendored Normal file
View file

@ -0,0 +1,438 @@
//
// Dependencies
//
'use strict';
const cint = require('cint');
const path = require('path');
const findUp = require('find-up');
const _ = require('lodash');
const getstdin = require('get-stdin');
const Table = require('cli-table');
const chalk = require('chalk');
const {promisify} = require('util');
const fs = require('fs');
const vm = require('./versionmanager');
const packageManagers = require('./package-managers');
const versionUtil = require('./version-util');
const jph = require('json-parse-helpfulerror');
// maps package managers to package file names
const packageFileNames = {
npm: 'package.json',
bower: 'bower.json'
};
// maps string levels to numeric levels
const logLevels = {
silent: 0,
error: 1,
minimal: 2,
warn: 3,
info: 4,
verbose: 5,
silly: 6
};
// time to wait for stdin before printing a warning
const stdinWarningTime = 5000;
const stdinWarningMessage = `Hmmmmm... this is taking a long time. Your console is telling me to wait for input \non stdin, but maybe that is not what you want.\nTry ${chalk.cyan('winpty ncu.cmd')}, or specify a package file explicitly with ${chalk.cyan('--packageFile package.json')}. \nSee https://github.com/tjunnone/npm-check-updates/issues/136#issuecomment-155721102`;
//
// Helper functions
//
function print(options, message, loglevel, method = 'log') {
// not in json mode
// not silent
// not at a loglevel under minimum specified
if (!options.json && options.loglevel !== 'silent' && (loglevel == null || logLevels[options.loglevel] >= logLevels[loglevel])) {
console[method](message);
}
}
function programError(options, message) {
if (options.cli) {
print(options, message, null, 'error');
process.exit(1);
} else {
throw new Error(message);
}
}
function printJson(options, object) {
if (options.loglevel !== 'silent') {
console.log(JSON.stringify(object, null, 2));
}
}
/**
* Gets the name of the package file based on --packageFile or --packageManager.
*/
function getPackageFileName(options) {
return options.packageFile ? options.packageFile :
packageFileNames[options.packageManager];
}
function createDependencyTable() {
return new Table({
colAligns: ['left', 'right', 'right', 'right'],
chars: {
top: '',
'top-mid': '',
'top-left': '',
'top-right': '',
bottom: '',
'bottom-mid': '',
'bottom-left': '',
'bottom-right': '',
left: '',
'left-mid': '',
mid: '',
'mid-mid': '',
right: '',
'right-mid': '',
middle: ''
}
});
}
/**
* @param args.from
* @param args.to
*/
function toDependencyTable(args) {
const table = createDependencyTable();
const rows = Object.keys(args.to).map(dep => {
const from = args.from[dep] || '';
const to = versionUtil.colorizeDiff(args.from[dep], args.to[dep] || '');
return [dep, from, '→', to];
});
rows.forEach(row => table.push(row));
return table;
}
const readPackageFile = cint.partialAt(promisify(fs.readFile), 1, 'utf8');
const writePackageFile = promisify(fs.writeFile);
//
// Main functions
//
function analyzeGlobalPackages(options) {
print(options, 'Getting installed packages...', 'verbose');
return vm.getInstalledPackages({
cwd: options.cwd,
filter: options.filter,
global: options.global,
packageManager: options.packageManager,
prefix: options.prefix,
reject: options.reject
})
.then(globalPackages => {
print(options, 'globalPackages', 'silly');
print(options, globalPackages, 'silly');
print(options, '', 'silly');
print(options, `Fetching ${vm.getVersionTarget(options)} versions...`, 'verbose');
return vm.upgradePackageDefinitions(globalPackages, options)
.then(([upgraded, latest]) => {
print(options, latest, 'silly');
const upgradedPackageNames = Object.keys(upgraded);
const upgradePromise = printUpgrades(options, {
current: globalPackages,
upgraded,
latest,
// since an interactive upgrade of globals is not available, the numUpgraded is always all
numUpgraded: upgradedPackageNames.length,
total: upgradedPackageNames.length
});
let instruction = '[package]';
if (upgraded) {
instruction = upgradedPackageNames.map(pkg => pkg + '@' + upgraded[pkg]).join(' ');
}
if (options.json) {
// since global packages do not have a package.json, return the upgraded deps directly (no version range replacements)
printJson(options, upgraded);
} else if (instruction.length) {
print(options, '\n' + chalk.cyan('ncu') + ' itself cannot upgrade global packages. Run the following to upgrade all global packages: \n\n' + chalk.cyan('npm -g install ' + instruction) + '\n');
}
return upgradePromise;
});
});
}
function analyzeProjectDependencies(options, pkgData, pkgFile) {
let pkg;
try {
if (!pkgData) {
throw new Error('pkgData: ' + pkgData);
} else {
pkg = jph.parse(pkgData);
}
} catch (e) {
programError(options, chalk.red(`Invalid package file${pkgFile ? `: ${pkgFile}` : ' from stdin'}. Error details:\n${e.message}`));
}
const current = vm.getCurrentDependencies(pkg, options);
print(options, `Fetching ${vm.getVersionTarget(options)} versions...`, 'verbose');
return vm.upgradePackageDefinitions(current, options).then(async ([upgraded, latest]) => {
const {newPkgData, selectedNewDependencies} = await vm.upgradePackageData(pkgData, current, upgraded, latest, options);
const output = options.jsonAll ? jph.parse(newPkgData) :
options.jsonDeps ?
_.pick(jph.parse(newPkgData), 'dependencies', 'devDependencies', 'optionalDependencies') :
selectedNewDependencies;
// split the deps into satisfied and unsatisfied to display in two separate tables
const deps = Object.keys(selectedNewDependencies);
const satisfied = cint.toObject(deps, dep =>
cint.keyValue(dep, vm.isSatisfied(latest[dep], current[dep]))
);
const isSatisfied = _.propertyOf(satisfied);
const filteredUpgraded = options.minimal ? cint.filterObject(selectedNewDependencies, cint.not(isSatisfied)) : selectedNewDependencies;
const numUpgraded = Object.keys(filteredUpgraded).length;
// print
if (options.json) {
// use the selectedNewDependencies dependencies data to generate new package data
// INVARIANT: we don't need try-catch here because pkgData has already been parsed as valid JSON, and vm.upgradePackageData simply does a find-and-replace on that
printJson(options, output);
} else {
printUpgrades(options, {
current,
upgraded: filteredUpgraded,
latest,
numUpgraded,
total: Object.keys(upgraded).length
});
}
if (numUpgraded > 0) {
// if error-level is 2, immediately exit with error code
if (options.errorLevel === 2) {
programError(options, '\nDependencies not up-to-date');
}
// if there is a package file, write the new package data
// otherwise, suggest ncu -u
if (pkgFile) {
if (options.upgrade) {
// short-circuit return in order to wait for write operation, but still return the same output
return writePackageFile(pkgFile, newPkgData)
.then(() => {
print(options, `\nRun ${chalk.cyan('npm install')} to install new versions.\n`);
return output;
});
} else {
print(options, `\nRun ${chalk.cyan('ncu -u')} to upgrade ${getPackageFileName(options)}`);
}
}
}
return output;
});
}
/**
* @param {Object} options - Options from the configuration
* @param {Object} args - The arguments passed to the function.
* @param {Object} args.current - The current packages.
* @param {Object} args.upgraded - The packages that should be upgraded.
* @param {number} args.numUpgraded - The number of upgraded packages
* @param {number} args.total - The total number of all possible upgrades
*/
function printUpgrades(options, {current, upgraded, numUpgraded, total}) {
print(options, '');
// print everything is up-to-date
const smiley = chalk.green.bold(':)');
if (numUpgraded === 0 && total === 0) {
if (Object.keys(current).length === 0) {
print(options, 'No dependencies.');
} else if (options.global) {
print(options, `All global packages are up-to-date ${smiley}`);
} else {
print(options, `All dependencies match the ${vm.getVersionTarget(options)} package versions ${smiley}`);
}
} else if (numUpgraded === 0 && total > 0) {
print(options, `All dependencies match the desired package versions ${smiley}`);
}
// print table
if (numUpgraded > 0) {
const table = toDependencyTable({
from: current,
to: upgraded
});
print(options, table.toString());
}
}
//
// Program
//
/** Initializes and consolidates options from the cli. */
function initOptions(options) {
return _.assign({}, options, {
filter: options.args.join(' ') || options.filter,
// convert silent option to loglevel silent
loglevel: options.silent ? 'silent' : options.loglevel,
minimal: options.minimal === undefined ? false : options.minimal,
// default to 0, except when newest or greatest are set
pre: options.pre ? Boolean(Number(options.pre)) : options.newest || options.greatest,
// add shortcut for any keys that start with 'json'
json: _(options)
.keys()
.filter(_.partial(_.startsWith, _, 'json', 0))
.some(_.propertyOf(options))
});
}
/** Finds the package file and data.
@returns Promise [pkgFile, pkgData]
Searches as follows:
--packageData flag
--packageFile flag
--stdin
--findUp
*/
async function findPackage(options) {
let pkgData;
let pkgFile;
let stdinTimer;
print(options, 'Running in local mode...', 'verbose');
print(options, 'Finding package file data...', 'verbose');
const pkgFileName = getPackageFileName(options);
// returns: string
function getPackageDataFromFile(pkgFile, pkgFileName) {
// exit if no pkgFile to read from fs
if (pkgFile != null) {
// print a message if we are using a descendant package file
const relPathToPackage = path.resolve(pkgFile);
if (relPathToPackage !== pkgFileName) {
print(options, `${options.upgrade ? 'Upgrading' : 'Checking'} ${relPathToPackage}`);
}
} else {
programError(options, `${chalk.red(`No ${pkgFileName}`)}\n\nPlease add a ${pkgFileName} to the current directory, specify the ${chalk.cyan('--packageFile')} or ${chalk.cyan('--packageData')} options, or pipe a ${pkgFileName} to stdin.`);
}
return readPackageFile(pkgFile);
}
// get the package data from the various input possibilities
if (options.packageData) {
pkgFile = null;
pkgData = Promise.resolve(options.packageData);
} else if (options.packageFile) {
pkgFile = options.packageFile;
pkgData = getPackageDataFromFile(pkgFile, pkgFileName);
} else if (!process.stdin.isTTY) {
print(options, 'Waiting for package data on stdin...', 'verbose');
// warn the user after a while if still waiting for stdin
// this is a way to mitigate #136 where Windows unexpectedly waits for stdin
stdinTimer = setTimeout(() => {
console.log(stdinWarningMessage);
}, stdinWarningTime);
// get data from stdin
// trim stdin to account for \r\n
// clear the warning timer once stdin returns
const stdinData = await getstdin();
const data = stdinData.trim().length > 0 ? stdinData : null;
clearTimeout(stdinTimer);
// if no stdin content fall back to searching for package.json from pwd and up to root
pkgFile = data || !pkgFileName ? null : findUp.sync(pkgFileName);
pkgData = data || getPackageDataFromFile(await pkgFile, pkgFileName);
} else {
// find the closest package starting from the current working directory and going up to the root
pkgFile = pkgFileName ? findUp.sync(pkgFileName) : null;
pkgData = getPackageDataFromFile(pkgFile, pkgFileName);
}
return Promise.all([pkgData, pkgFile]);
}
/** main entry point */
async function run(options={}) {
// exit with non-zero error code when there is an unhandled promise rejection
process.on('unhandledRejection', err => {
throw err;
});
// if not executed on the command-line (i.e. executed as a node module), set some defaults
if (!options.cli) {
options = _.defaults({}, options, {
jsonUpgraded: true,
loglevel: 'silent',
packageManager: 'npm',
args: []
});
}
options = initOptions(options);
print(options, 'Initializing...', 'verbose');
if (options.packageManager === 'npm' && !options.prefix) {
options.prefix = await packageManagers.npm.defaultPrefix(options); // eslint-disable-line require-atomic-updates
}
let timeout;
let timeoutPromise = new Promise(r => r);
if (options.timeout) {
const timeoutMs = _.isString(options.timeout) ? parseInt(options.timeout, 10) : options.timeout;
timeoutPromise = new Promise((resolve, reject) => {
timeout = setTimeout(() => {
// must catch the error and reject explicitly since we are in a setTimeout
const error = `Exceeded global timeout of ${timeoutMs}ms`;
reject(error);
try {
programError(options, chalk.red(error));
} catch (e) {/* noop */}
}, timeoutMs);
});
}
async function getAnalysis() {
if (options.global) {
const analysis = await analyzeGlobalPackages(options);
clearTimeout(timeout);
return analysis;
} else {
const [pkgData, pkgFile] = await findPackage(options);
const analysis = await analyzeProjectDependencies(options, pkgData, pkgFile);
clearTimeout(timeout);
return analysis;
}
}
return await Promise.race([timeoutPromise, getAnalysis()]);
}
module.exports = _.assign({
run
}, vm);

View file

@ -0,0 +1,14 @@
To add support for another package manager, drop in a module with the following interface:
```
{
list: (npmOptions) => Promise<{ NAME: VERSION, ... }>
latest: (String pkgName) => Promise<String> version
newest: (String pkgName) => Promise<String> version
greatest: (String pkgName) => Promise<String> version
greatestMajor: (String pkgName, String currentVersion) => Promise<String> version
greatestMinor: (String pkgName, String currentVersion) => Promise<String> version
}
```
* latest and greatest are expected to reject with `'404 Not Found'` if the package is not found

View file

@ -0,0 +1,76 @@
'use strict';
const cint = require('cint');
const chalk = require('chalk');
const requireg = require('requireg');
/**
* @param args.global
* @param args.registry
* @param args.loglevel
*/
// see if the bower dependency has been installed
const bower = ({loglevel}) => {
try {
requireg.resolve('bower'); // throws an error if not installed
return requireg('bower');
} catch (e) {
if (loglevel !== 'silent') {
console.error(`Bower not installed. Please install bower using: ${chalk.cyan('npm install -g bower')}`);
}
process.exit(1);
}
};
module.exports = {
list({prefix, loglevel} = {}) {
return new Promise((resolve, reject) => {
bower({loglevel}).commands.list(null, {cwd: prefix})
.on('end', results => {
resolve(cint.mapObject(results.dependencies, (key, value) => {
return cint.keyValue(key, value.pkgMeta);
}));
})
.on('error', reject);
});
},
latest(packageName, _, {prefix, loglevel} = {}) {
return new Promise((resolve, reject) => {
bower({loglevel}).commands.info(packageName, null, {cwd: prefix})
.on('end', results => {
resolve(results.latest.version);
})
.on('error', err => {
// normalize 404
reject(/Package \S* not found|Repository not found/.test(err.message) ? '404 Not Found' : err);
});
});
},
greatest(packageName, _, {prefix, loglevel} = {}) {
return new Promise((resolve, reject) => {
bower({loglevel}).commands.info(packageName, null, {cwd: prefix})
.on('end', results => {
resolve(results.versions[0]); // bower versions returned in highest-to-lowest order.
})
.on('error', reject);
});
},
newest() {
throw new Error('Semantic versioning level "newest" is not supported for Bower');
},
greatestMajor() {
throw new Error('Semantic versioning level "major" is not supported for Bower');
},
greatestMinor() {
throw new Error('Semantic versioning level "minor" is not supported for Bower');
}
};

View file

@ -0,0 +1,5 @@
'use strict';
module.exports = {
bower: require('./bower'),
npm: require('./npm')
};

View file

@ -0,0 +1,188 @@
'use strict';
const _ = require('lodash');
const cint = require('cint');
const semver = require('semver');
const versionUtil = require('../version-util.js');
const spawn = require('spawn-please');
const pacote = require('pacote');
// needed until pacote supports full npm config compatibility
// See: https://github.com/zkat/pacote/issues/156
const npmConfig = {};
require('libnpmconfig').read().forEach((value, key) => {
// replace env ${VARS} in strings with the process.env value
npmConfig[key] = typeof value !== 'string' ?
value :
value.replace(/\${([^}]+)}/, (_, envVar) =>
process.env[envVar]
);
});
npmConfig.cache = false;
/** Parse JSON and throw an informative error on failure.
* @param result Data to be parsed
* @param data { command, packageName }
*/
function parseJson(result, data) {
let json;
// use a try-catch instead of .catch to avoid re-catching upstream errors
try {
json = JSON.parse(result);
} catch (err) {
throw new Error(`Expected JSON from "${data.command}". This could be due to npm instability${data.packageName ? ` or problems with the ${data.packageName} package` : ''}.\n\n${result}`);
}
return json;
}
/**
* @param packageName Name of the package
* @param field Field such as "versions" or "dist-tags.latest" are parsed from the pacote result (https://www.npmjs.com/package/pacote#packument)
* @Returns Promised result
*/
function view(packageName, field, currentVersion) {
if (currentVersion && (!semver.validRange(currentVersion) || versionUtil.isWildCard(currentVersion))) {
return Promise.resolve();
}
npmConfig['full-metadata'] = field === 'time';
return pacote.packument(packageName, npmConfig).then(result => {
if (field.startsWith('dist-tags.')) {
const split = field.split('.');
if (result[split[0]]) {
return result[split[0]][split[1]];
}
} else if (field === 'versions') {
return Object.keys(result[field]);
} else {
return result[field];
}
});
}
/**
* @param versions Array of all available versions
* @Returns An array of versions with the release versions filtered out
*/
function filterOutPrereleaseVersions(versions) {
return _.filter(versions, _.negate(isPre));
}
/**
* @param version
* @Returns True if the version is any kind of prerelease: alpha, beta, rc, pre
*/
function isPre(version) {
return versionUtil.getPrecision(version) === 'release';
}
/** Spawn npm requires a different command on Windows. */
function spawnNpm(args, npmOptions={}, spawnOptions={}) {
const cmd = process.platform === 'win32'? 'npm.cmd' : 'npm';
const fullArgs = [].concat(
args,
npmOptions.global ? '--global' : [],
npmOptions.prefix ? `--prefix=${npmOptions.prefix}` : [],
'--depth=0',
'--json'
);
return spawn(cmd, fullArgs, spawnOptions);
}
/** Get platform-specific default prefix to pass on to npm.
* @param options.global
* @param options.prefix
*/
function defaultPrefix(options) {
if (options && options.prefix) {
return Promise.resolve(options.prefix);
}
const cmd = process.platform === 'win32'? 'npm.cmd' : 'npm';
return spawn(cmd, ['config', 'get', 'prefix']).then(prefix => {
// FIX: for ncu -g doesn't work on homebrew or windows #146
// https://github.com/tjunnone/npm-check-updates/issues/146
return options.global && prefix.match('Cellar') ? '/usr/local' :
// Workaround: get prefix on windows for global packages
// Only needed when using npm api directly
process.platform === 'win32' && options.global && !process.env.prefix ?
`${process.env.AppData}\\npm` :
null;
});
}
module.exports = {
/**
* @options.cwd (optional)
* @options.global (optional)
* @options.prefix (optional)
*/
list(options={}) {
return spawnNpm('ls', options, options.cwd ? {cwd: options.cwd, rejectOnError: false} : {rejectOnError: false})
.then(result => {
const json = parseJson(result, {
command: 'npm ls'
});
return cint.mapObject(json.dependencies, (name, info) =>
// unmet peer dependencies have a different structure
cint.keyValue(name, info.version || (info.required && info.required.version))
);
});
},
latest(packageName, currentVersion, pre) {
return view(packageName, 'dist-tags.latest', currentVersion)
.then(version => {
// if latest is not a prerelease version, return it
// if latest is a prerelease version and --pre is specified, return it
if (!isPre(version) || pre) {
return version;
// if latest is a prerelease version and --pre is not specified, find the next
// version that is not a prerelease
} else {
return view(packageName, 'versions', currentVersion)
.then(filterOutPrereleaseVersions)
.then(_.last);
}
});
},
newest(packageName, currentVersion, pre) {
return view(packageName, 'time', currentVersion)
.then(_.keys)
.then(_.partialRight(_.pullAll, ['modified', 'created']))
.then(versions => {
return _.last(pre ? versions : filterOutPrereleaseVersions(versions));
});
},
greatest(packageName, currentVersion, pre) {
return view(packageName, 'versions', currentVersion)
.then(versions => {
return _.last(pre ? versions : filterOutPrereleaseVersions(versions));
});
},
greatestMajor(packageName, currentVersion, pre) {
return view(packageName, 'versions', currentVersion).then(versions => {
const resultVersions = pre ? versions : filterOutPrereleaseVersions(versions);
return versionUtil.findGreatestByLevel(resultVersions, currentVersion, 'major');
});
},
greatestMinor(packageName, currentVersion, pre) {
return view(packageName, 'versions', currentVersion).then(versions => {
const resultVersions = pre ? versions : filterOutPrereleaseVersions(versions);
return versionUtil.findGreatestByLevel(resultVersions, currentVersion, 'minor');
});
},
defaultPrefix
};

28
node_modules/npm-check-updates/lib/raw-promisify.js generated vendored Normal file
View file

@ -0,0 +1,28 @@
'use strict';
const _ = require('lodash');
/**
* For some reason, Promise.promisifyAll does not work on npm.commands :(
* Promise.promisifyAll(npm.commands);
* So we have to do it manually.
*/
function rawPromisify(obj) {
_.each(obj, (method, name) => {
obj[`${name}Async`] = () => {
const args = [].slice.call(arguments);
const that = this;
return new Promise((resolve, reject) => {
args.push((err, results) => {
if (err) {
reject(err);
} else {
resolve(results);
}
});
return method.apply(that, args);
});
};
});
}
module.exports = rawPromisify;

199
node_modules/npm-check-updates/lib/version-util.js generated vendored Normal file
View file

@ -0,0 +1,199 @@
'use strict';
const semverutils = require('semver-utils');
const _ = require('lodash');
const chalk = require('chalk');
const util = require('util');
const VERSION_BASE_PARTS = ['major', 'minor', 'patch'];
const VERSION_ADDED_PARTS = ['release', 'build'];
const VERSION_PARTS = [].concat(VERSION_BASE_PARTS, VERSION_ADDED_PARTS);
const VERSION_PART_DELIM = {
major: '',
minor: '.',
patch: '.',
release: '-',
build: '+'
};
const WILDCARDS = ['^', '~', '.*', '.x'];
const WILDCARDS_PURE = ['^', '~', '^*', '*', 'x', 'x.x', 'x.x.x'];
const WILDCARD_PURE_REGEX = new RegExp(`^(${WILDCARDS_PURE.join('|')
.replace(/\^/g, '\\^')
.replace(/\*/g, '\\*')})$`);
const SEMANTIC_DIRECT = new RegExp('^\\d+\\.\\d+\\.\\d+([-|+].*)*$');
/**
* Returns the number of parts in the version
*/
function numParts(version) {
const semver = semverutils.parseRange(version)[0];
if (!semver) {
throw new Error(util.format('semverutils.parseRange returned null when trying to parse "%s". This is probably a problem with the "semver-utils" dependency. Please report an issue at https://github.com/tjunnone/npm-check-updates/issues.', version));
}
return _.intersection(VERSION_PARTS, Object.keys(semver)).length;
}
/**
* Increases or decreases the given precision by the given amount, e.g. major+1 -> minor
*/
function precisionAdd(precision, n) {
if (n === 0) {
return precision;
}
const index = n === 0 ? precision :
_.includes(VERSION_BASE_PARTS, precision) ? VERSION_BASE_PARTS.indexOf(precision) + n :
_.includes(VERSION_ADDED_PARTS, precision) ? VERSION_BASE_PARTS.length + n :
null;
if (index === null) {
throw new Error(`Invalid precision: ${precision}`);
} else if (!VERSION_PARTS[index]) {
throw new Error(`Invalid precision math${arguments}`);
}
return VERSION_PARTS[index];
}
/** Joins the major, minor, patch, release, and build parts (controlled by an optional precision arg) of a semver object
* into a dot-delimited string. */
function stringify(semver, precision) {
// get a list of the parts up until (and including) the given precision
// or all of them, if no precision is specified
const parts = precision ? VERSION_PARTS.slice(0, VERSION_PARTS.indexOf(precision)+1) : VERSION_PARTS;
// pair each part with its delimiter and join together
return parts
.filter(part => {
return _.includes(VERSION_BASE_PARTS, precision) || semver[part];
})
.map(part => {
return VERSION_PART_DELIM[part] + (semver[part] || '0');
})
.join('');
}
/**
* Gets how precise this version number is (major, minor, patch, release, or build)
*/
function getPrecision(version) {
const semver = semverutils.parseRange(version)[0];
// expects VERSION_PARTS to be in correct order
return _.find(VERSION_PARTS.slice().reverse(), _.propertyOf(semver));
}
/**
* Sets the precision of a (loose) semver to the specified level: major, minor, etc.
*/
function setPrecision(version, precision) {
const semver = semverutils.parseRange(version)[0];
return stringify(semver, precision);
}
/** Adds a given wildcard (^,~,.*,.x) to a version number. Adds ^ and ~ to the beginning. Replaces everything after the
* major version number with .* or .x */
function addWildCard(version, wildcard) {
return wildcard === '^' || wildcard === '~' ?
wildcard + version :
setPrecision(version, 'major') + wildcard;
}
/** Returns true if the given string is one of the wild cards. */
function isWildCard(version) {
return WILDCARD_PURE_REGEX.test(version);
}
/** Returns true if the given digit is a wildcard for a part of a version. */
function isWildPart(versionPart) {
return versionPart === '*' || versionPart === 'x';
}
/**
* Colorize the parts of a version string (to) that are different than another (from). Assumes that the two verson strings are in the same format.
*/
function colorizeDiff(from, to) {
let leadingWildcard = '';
// separate out leading ^ or ~
if (/^[~^]/.test(to) && to[0] === from[0]) {
leadingWildcard = to[0];
to = to.slice(1);
from = from.slice(1);
}
// split into parts
const partsToColor = to.split('.');
const partsToCompare = from.split('.');
let i = _.findIndex(partsToColor, (part, i) => part !== partsToCompare[i]);
i = i >= 0 ? i : partsToColor.length;
// major = red (or any change before 1.0.0)
// minor = cyan
// patch = green
const color = i === 0 || partsToColor[0] === '0' ? 'red' :
i === 1 ? 'cyan' :
'green';
// if we are colorizing only part of the word, add a dot in the middle
const middot = i > 0 && i < partsToColor.length ? '.' : '';
return leadingWildcard +
partsToColor.slice(0,i).join('.') +
middot +
chalk[color](partsToColor.slice(i).join('.'));
}
/**
* @param versions Array of all available versions
* @param current Current version
* @param level major/minor
* @Returns String representation of the suggested version. If the current version
* is not direct then returns null
*/
function findGreatestByLevel(versions, current, level) {
if (!SEMANTIC_DIRECT.test(current)) {
return null;
}
const cur = semverutils.parse(current);
return _.chain(versions)
.map(v => {
return {
string: v,
parsed: semverutils.parse(v)
};
})
.filter(o => {
if (level === 'minor' && o.parsed.major !== cur.major) {
return false;
}
return o.parsed[level] === cur[level];
})
.map(o => {
return o.string;
})
.last()
.value();
}
module.exports = {
numParts,
stringify,
precisionAdd,
getPrecision,
setPrecision,
addWildCard,
isWildCard,
isWildPart,
colorizeDiff,
findGreatestByLevel,
VERSION_BASE_PARTS,
VERSION_ADDED_PARTS,
VERSION_PARTS,
WILDCARDS
};

496
node_modules/npm-check-updates/lib/versionmanager.js generated vendored Normal file
View file

@ -0,0 +1,496 @@
'use strict';
const semver = require('semver');
const _ = require('lodash');
const cint = require('cint');
const semverutils = require('semver-utils');
const ProgressBar = require('progress');
const versionUtil = require('./version-util.js');
const packageManagers = require('./package-managers');
const prompts = require('prompts');
// keep order for setPrecision
const DEFAULT_WILDCARD = '^';
/** Returns 'v' if the string starts with a v, otherwise returns empty string. */
function v(str) {
return str && (str[0] === 'v' || str[1] === 'v') ? 'v' : '';
}
/** Returns a new function that AND's the two functions over the provided arguments. */
function and(f, g) {
return function () {
return f.apply(this, arguments) && g.apply(this, arguments);
};
}
/**
* Upgrade an existing dependency declaration to satisfy the latest version
* @param declaration Current version declaration (e.g. "1.2.x")
* @param latestVersion Latest version (e.g "1.3.2")
* @param {Object} [options={}]
* @returns {string} The upgraded dependency declaration (e.g. "1.3.x")
*/
function upgradeDependencyDeclaration(declaration, latestVersion, options = {}) {
options.wildcard = options.wildcard || DEFAULT_WILDCARD;
// parse the latestVersion
// return original declaration if latestSemver is invalid
const latestSemver = semverutils.parseRange(latestVersion)[0];
if (!latestSemver) {
return declaration;
}
// return global versionUtil.wildcards immediately
if (options.removeRange) {
return latestVersion;
} else if (versionUtil.isWildCard(declaration)) {
return declaration;
}
// parse the declaration
// if multiple ranges, use the semver with the least number of parts
const parsedRange = _(semverutils.parseRange(declaration))
// semver-utils includes empty entries for the || and - operators. We can remove them completely
.reject({operator: '||'})
.reject({operator: '-'})
.sortBy(_.ary(_.flow(versionUtil.stringify, versionUtil.numParts), 1))
.value();
const declaredSemver = parsedRange[0];
/**
* Chooses version parts between the declared version and the latest.
* Base parts (major, minor, patch) are only included if they are in the original declaration.
* Added parts (release, build) are always included. They are only present if we are checking --greatest versions
* anyway.
*/
function chooseVersion(part) {
return versionUtil.isWildPart(declaredSemver[part]) ? declaredSemver[part] :
_.includes(versionUtil.VERSION_BASE_PARTS, part) && declaredSemver[part] ? latestSemver[part] :
_.includes(versionUtil.VERSION_ADDED_PARTS, part) ? latestSemver[part] :
undefined;
}
// create a new semver object with major, minor, patch, build, and release parts
const newSemver = cint.toObject(versionUtil.VERSION_PARTS, part =>
cint.keyValue(part, chooseVersion(part))
);
const newSemverString = versionUtil.stringify(newSemver);
const version = v(declaredSemver.semver) + newSemverString;
// determine the operator
// do not compact, because [undefined, '<'] must be differentiated from ['<']
const uniqueOperators = _(parsedRange)
.map(range => range.operator)
.uniq()
.value();
const operator = uniqueOperators[0] || '';
const hasWildCard = versionUtil.WILDCARDS.some(_.partial(_.includes, newSemverString, _, 0));
const isLessThan = uniqueOperators[0] === '<' || uniqueOperators[0] === '<=';
const isMixed = uniqueOperators.length > 1;
// convert versions with </<= or mixed operators into the preferred wildcard
// only do so if the new version does not already contain a wildcard
return !hasWildCard && (isLessThan || isMixed) ?
versionUtil.addWildCard(version, options.wildcard) :
operator + version;
}
/**
* Upgrade a dependencies collection based on latest available versions
* @param currentDependencies current dependencies collection object
* @param latestVersions latest available versions collection object
* @param {Object} [options={}]
* @returns {{}} upgraded dependency collection object
*/
function upgradeDependencies(currentDependencies, latestVersions, options = {}) {
// filter out dependencies with empty values
currentDependencies = cint.filterObject(currentDependencies, (key, value) => {
return value;
});
// get the preferred wildcard and bind it to upgradeDependencyDeclaration
const wildcard = getPreferredWildcard(currentDependencies) || DEFAULT_WILDCARD;
const upgradeDep = _.partialRight(upgradeDependencyDeclaration, {
wildcard,
removeRange: options.removeRange
});
return _(currentDependencies)
// only include packages for which a latest version was fetched
.pickBy((current, packageName) => {
return packageName in latestVersions;
})
// combine the current and latest dependency objects into a single object keyed by packageName and containing
// both versions in an array: [current, latest]
.mapValues((current, packageName) => {
const latest = latestVersions[packageName];
return [current, latest];
})
// pick the packages that are upgradeable
// we can use spread because isUpgradeable and upgradeDependencyDeclaration both take current and latest as
// arguments
.pickBy(_.spread(isUpgradeable))
.mapValues(_.spread(upgradeDep))
.value();
}
// Determines if the given version (range) should be upgraded to the latest (i.e. it is valid, it does not currently
// Return true if the version satisfies the range
const isSatisfied = semver.satisfies;
// satisfy the latest, and it is not beyond the latest)
function isUpgradeable(current, latest) {
// do not upgrade non-npm version declarations (such as git tags)
// do not upgrade versionUtil.wildcards
if (!semver.validRange(current) || versionUtil.isWildCard(current)) {
return false;
}
// remove the constraint (e.g. ^1.0.1 -> 1.0.1) to allow upgrades that satisfy the range, but are out of date
const range = semverutils.parseRange(current)[0];
if (!range) {
throw new Error(`"${current}" could not be parsed by semver-utils. This is probably a bug. Please file an issue at https://github.com/tjunnone/npm-check-updates.`);
}
const version = versionUtil.stringify(range);
// make sure it is a valid range
// not upgradeable if the latest version satisfies the current range
// not upgradeable if the specified version is newer than the latest (indicating a prerelease version)
return Boolean(semver.validRange(version)) &&
!isSatisfied(latest, version) &&
!semver.ltr(latest, version);
}
/**
* Creates a filter function from a given filter string. Supports strings, comma-or-space-delimited lists, and regexes.
*/
function packageNameFilter(filter) {
let filterPackages;
// no filter
if (!filter) {
filterPackages = _.identity;
} else if (typeof filter === 'string') {
// RegExp filter
if (filter[0] === '/' && cint.index(filter,-1) === '/') {
const regexp = new RegExp(filter.slice(1, filter.length-1));
filterPackages = regexp.test.bind(regexp);
} else {
// string filter
const packages = filter.split(/[\s,]+/);
filterPackages = _.includes.bind(_, packages);
}
} else if (Array.isArray(filter)) {
// array filter
filterPackages = _.includes.bind(_, filter);
} else if (filter instanceof RegExp) {
// raw RegExp
filterPackages = filter.test.bind(filter);
} else {
throw new Error('Invalid packages filter. Must be a RegExp, array, or comma-or-space-delimited list.');
}
// (limit the arity to 1 to avoid passing the value)
return cint.aritize(filterPackages, 1);
}
/** Creates a single filter function from an optional filter and optional reject. */
function filterAndReject(filter, reject) {
return and(
filter ? packageNameFilter(filter) : _.identity,
reject ? _.negate(packageNameFilter(reject)) : _.identity
);
}
/** Returns an 2-tuple of upgradedDependencies and their latest versions */
function upgradePackageDefinitions(currentDependencies, options) {
const versionTarget = getVersionTarget(options);
return queryVersions(currentDependencies, {
versionTarget,
registry: options.registry ? options.registry : null,
pre: options.pre,
packageManager: options.packageManager,
json: options.json,
loglevel: options.loglevel
}).then(latestVersions => {
const upgradedDependencies = upgradeDependencies(currentDependencies, latestVersions, {
removeRange: options.removeRange
});
const filteredUpgradedDependencies = _.pickBy(upgradedDependencies, (v, dep) => {
return !options.jsonUpgraded || !options.minimal || !isSatisfied(latestVersions[dep], currentDependencies[dep]);
});
return [filteredUpgradedDependencies, latestVersions];
});
}
/**
* Upgrade the dependency declarations in the package data
* @param pkgData The package.json data, as utf8 text
* @param oldDependencies Object of old dependencies {package: range}
* @param newDependencies Object of new dependencies {package: range}
* @param newVersions Object of new versions {package: version}
* @param {Object} [options={}]
* @returns {string} The updated package data, as utf8 text
* @sideeffect prompts
*/
async function upgradePackageData(pkgData, oldDependencies, newDependencies, newVersions, options = {}) {
// copy newDependencies for mutation via interactive mode
const selectedNewDependencies = Object.assign({}, newDependencies);
let newPkgData = pkgData;
for (const dependency in newDependencies) {
if (!options.minimal || !isSatisfied(newVersions[dependency], oldDependencies[dependency])) {
if (options.interactive) {
const to = versionUtil.colorizeDiff(oldDependencies[dependency], newDependencies[dependency] || '');
const response = await prompts({
type: 'confirm',
name: 'value',
message: `Do you want to upgrade: ${dependency} ${oldDependencies[dependency]}${to}?`,
initial: true
});
if (!response.value) {
// continue loop to next dependency and skip updating newPkgData
delete selectedNewDependencies[dependency];
continue;
}
}
const expression = `"${dependency}"\\s*:\\s*"${escapeRegexp(`${oldDependencies[dependency]}"`)}`;
const regExp = new RegExp(expression, 'g');
newPkgData = newPkgData.replace(regExp, `"${dependency}": "${newDependencies[dependency]}"`);
}
}
return {newPkgData, selectedNewDependencies};
}
/**
* Get the current dependencies from the package file
* @param {Object} [pkgData={}] Object with dependencies, devDependencies, peerDependencies, optionalDependencies, and/or bundleDependencies properties
* @param {Object} [options={}]
* @param options.dep
* @param options.filter
* @param options.reject
* @returns Promised {packageName: version} collection
*/
function getCurrentDependencies(pkgData = {}, options = {}) {
if (options.dep) {
const deps = (options.dep || '').split(',');
options.prod = _.includes(deps, 'prod');
options.dev = _.includes(deps, 'dev');
options.peer = _.includes(deps, 'peer');
options.optional = _.includes(deps, 'optional');
options.bundle = _.includes(deps, 'bundle');
} else {
options.prod = options.dev = options.peer = options.optional = options.bundle = true;
}
const allDependencies = cint.filterObject(_.merge({},
options.prod && pkgData.dependencies,
options.dev && pkgData.devDependencies,
options.peer && pkgData.peerDependencies,
options.optional && pkgData.optionalDependencies,
options.bundle && pkgData.bundleDependencies
), filterAndReject(options.filter, options.reject));
return allDependencies;
}
/**
* @options.cwd
* @options.filter
* @options.global
* @options.packageManager
* @options.prefix
* @options.reject
*/
function getInstalledPackages(options = {}) {
return getPackageManager(options.packageManager).list({cwd: options.cwd, prefix: options.prefix, global: options.global}).then(pkgInfoObj => {
if (!pkgInfoObj) {
throw new Error('Unable to retrieve NPM package list');
}
// filter out undefined packages or those with a wildcard
const filterFunction = filterAndReject(options.filter, options.reject);
return cint.filterObject(pkgInfoObj, (dep, version) =>
version && !versionUtil.isWildPart(version) && filterFunction(dep)
);
});
}
/**
* Get the latest or greatest versions from the NPM repository based on the version target
* @param packageMap an object whose keys are package name and values are current versions
* @param {Object} [options={}] Options. Default: { versionTarget: 'latest' }. You may also specify { versionTarget: 'greatest' }
* @returns Promised {packageName: version} collection
*/
function queryVersions(packageMap, options = {}) {
let getPackageVersion;
const packageList = Object.keys(packageMap);
const packageManager = getPackageManager(options.packageManager);
// validate options.versionTarget
options.versionTarget = options.versionTarget || 'latest';
let bar;
if (!options.json && options.loglevel !== 'silent' && packageList.length > 0) {
bar = new ProgressBar('[:bar] :current/:total :percent', {total: packageList.length, width: 20});
bar.render();
}
// determine the getPackageVersion function from options.versionTarget
switch (options.versionTarget) {
case 'latest': {
getPackageVersion = packageManager.latest;
break;
}
case 'greatest': {
getPackageVersion = packageManager.greatest;
break;
}
case 'newest': {
getPackageVersion = packageManager.newest;
break;
}
case 'major': {
getPackageVersion = packageManager.greatestMajor;
break;
}
case 'minor': {
getPackageVersion = packageManager.greatestMinor;
break;
}
default: {
const supportedVersionTargets = ['latest', 'newest', 'greatest', 'major', 'minor'];
return Promise.reject(new Error(`Unsupported versionTarget: ${options.versionTarget}. Supported version targets are: ${supportedVersionTargets.join(', ')}`));
}
}
// ignore 404 errors from getPackageVersion by having them return null instead of rejecting
function getPackageVersionProtected(dep) {
return getPackageVersion(dep, packageMap[dep], options.pre).catch(err => {
if (err && (err.message || err).toString().match(/E404|ENOTFOUND|404 Not Found/i)) {
return null;
} else {
throw err;
}
}).then(result => {
if (bar) {
bar.tick();
}
return result;
});
}
// zip up the array of versions into to a nicer object keyed by package name
function zipVersions(versionList) {
return cint.toObject(versionList, (version, i) => {
return cint.keyValue(packageList[i], version);
});
}
return Promise.all(packageList.map(getPackageVersionProtected))
.then(zipVersions)
.then(_.partialRight(_.pickBy, _.identity));
}
/**
* Given a dependencies collection, returns whether the user prefers ^, ~, .*, or .x (simply counts the greatest number
* of occurrences). Returns null if given no dependencies.
*/
function getPreferredWildcard(dependencies) {
// if there are no dependencies, return null.
if (Object.keys(dependencies).length === 0) {
return null;
}
// group the dependencies by wildcard
const groups = _.groupBy(_.values(dependencies), dep =>
_.find(versionUtil.WILDCARDS, wildcard =>
dep && dep.indexOf(wildcard) > -1
)
);
delete groups.undefined;
// convert to an array of objects that can be sorted
const arrOfGroups = cint.toArray(groups, (wildcard, instances) => ({
wildcard,
instances
}));
// reverse sort the groups so that the wildcard with the most appearances is at the head, then return it.
const sorted = _.sortBy(arrOfGroups, wildcardObject => -wildcardObject.instances.length);
return sorted.length > 0 ? sorted[0].wildcard : null;
}
function getVersionTarget(options) {
return options.semverLevel ? options.semverLevel :
options.newest ? 'newest' :
options.greatest ? 'greatest' :
'latest';
}
/**
* Initialize the version manager with the given package manager.
* @param args.global
* @param args.packageManager
*/
function getPackageManager(packageManagerNameOrObject) {
/** Get one of the preset package managers or throw an error if there is no match. */
function getPresetPackageManager(packageManagerName) {
if (!(packageManagerName in packageManagers)) {
throw new Error(`Invalid package manager: ${packageManagerName}`);
}
return packageManagers[packageManagerName];
}
return !packageManagerNameOrObject ? packageManagers.npm : // default to npm
// use present package manager if name is specified
typeof packageManagerNameOrObject === 'string' ? getPresetPackageManager(packageManagerNameOrObject) :
// use provided package manager object otherwise
packageManagerNameOrObject;
}
//
// Helper functions
//
function escapeRegexp(s) {
return s.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'); // Thanks Stack Overflow!
}
//
// API
//
module.exports = {
// used directly by npm-check-updates.js
getCurrentDependencies,
getInstalledPackages,
getVersionTarget,
isSatisfied,
upgradePackageData,
upgradePackageDefinitions,
// exposed for testing
getPreferredWildcard,
isUpgradeable,
queryVersions,
upgradeDependencies,
upgradeDependencyDeclaration
};

1
node_modules/npm-check-updates/node_modules/.bin/semver generated vendored Symbolic link
View file

@ -0,0 +1 @@
../semver/bin/semver.js

View file

@ -0,0 +1,70 @@
# changes log
## 6.2.0
* Coerce numbers to strings when passed to semver.coerce()
* Add `rtl` option to coerce from right to left
## 6.1.3
* Handle X-ranges properly in includePrerelease mode
## 6.1.2
* Do not throw when testing invalid version strings
## 6.1.1
* Add options support for semver.coerce()
* Handle undefined version passed to Range.test
## 6.1.0
* Add semver.compareBuild function
* Support `*` in semver.intersects
## 6.0
* Fix `intersects` logic.
This is technically a bug fix, but since it is also a change to behavior
that may require users updating their code, it is marked as a major
version increment.
## 5.7
* Add `minVersion` method
## 5.6
* Move boolean `loose` param to an options object, with
backwards-compatibility protection.
* Add ability to opt out of special prerelease version handling with
the `includePrerelease` option flag.
## 5.5
* Add version coercion capabilities
## 5.4
* Add intersection checking
## 5.3
* Add `minSatisfying` method
## 5.2
* Add `prerelease(v)` that returns prerelease components
## 5.1
* Add Backus-Naur for ranges
* Remove excessively cute inspection methods
## 5.0
* Remove AMD/Browserified build artifacts
* Fix ltr and gtr when using the `*` range
* Fix for range `*` with a prerelease identifier

View file

@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View file

@ -0,0 +1,443 @@
semver(1) -- The semantic versioner for npm
===========================================
## Install
```bash
npm install semver
````
## Usage
As a node module:
```js
const semver = require('semver')
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
semver.minVersion('>=1.0.0') // '1.0.0'
semver.valid(semver.coerce('v2')) // '2.0.0'
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
```
As a command-line utility:
```
$ semver -h
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter
Usage: semver [options] <version> [<version> [...]]
Prints valid versions sorted by SemVer precedence
Options:
-r --range <range>
Print versions that match the specified range.
-i --increment [<level>]
Increment a version by the specified level. Level can
be one of: major, minor, patch, premajor, preminor,
prepatch, or prerelease. Default level is 'patch'.
Only one version may be specified.
--preid <identifier>
Identifier to be used to prefix premajor, preminor,
prepatch or prerelease version increments.
-l --loose
Interpret versions and ranges loosely
-p --include-prerelease
Always include prerelease versions in range matching
-c --coerce
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no satisfying versions are found, then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
```
## Versions
A "version" is described by the `v2.0.0` specification found at
<https://semver.org/>.
A leading `"="` or `"v"` character is stripped off and ignored.
## Ranges
A `version range` is a set of `comparators` which specify versions
that satisfy the range.
A `comparator` is composed of an `operator` and a `version`. The set
of primitive `operators` is:
* `<` Less than
* `<=` Less than or equal to
* `>` Greater than
* `>=` Greater than or equal to
* `=` Equal. If no operator is specified, then equality is assumed,
so this operator is optional, but MAY be included.
For example, the comparator `>=1.2.7` would match the versions
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
or `1.1.0`.
Comparators can be joined by whitespace to form a `comparator set`,
which is satisfied by the **intersection** of all of the comparators
it includes.
A range is composed of one or more comparator sets, joined by `||`. A
version matches a range if and only if every comparator in at least
one of the `||`-separated comparator sets is satisfied by the version.
For example, the range `>=1.2.7 <1.3.0` would match the versions
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
or `1.1.0`.
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
### Prerelease Tags
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
it will only be allowed to satisfy comparator sets if at least one
comparator with the same `[major, minor, patch]` tuple also has a
prerelease tag.
For example, the range `>1.2.3-alpha.3` would be allowed to match the
version `1.2.3-alpha.7`, but it would *not* be satisfied by
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
range only accepts prerelease tags on the `1.2.3` version. The
version `3.4.5` *would* satisfy the range, because it does not have a
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
The purpose for this behavior is twofold. First, prerelease versions
frequently are updated very quickly, and contain many breaking changes
that are (by the author's design) not yet fit for public consumption.
Therefore, by default, they are excluded from range matching
semantics.
Second, a user who has opted into using a prerelease version has
clearly indicated the intent to use *that specific* set of
alpha/beta/rc versions. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the *next* set of prerelease versions.
Note that this behavior can be suppressed (treating all prerelease
versions as if they were normal versions, for the purpose of range
matching) by setting the `includePrerelease` flag on the options
object to any
[functions](https://github.com/npm/node-semver#functions) that do
range matching.
#### Prerelease Identifiers
The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
semver.inc('1.2.3', 'prerelease', 'beta')
// '1.2.4-beta.0'
```
command-line example:
```bash
$ semver 1.2.3 -i prerelease --preid beta
1.2.4-beta.0
```
Which then can be used to increment further:
```bash
$ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```
### Advanced Range Syntax
Advanced range syntax desugars to primitive comparators in
deterministic ways.
Advanced ranges may be combined in the same way as primitive
comparators using white space or `||`.
#### Hyphen Ranges `X.Y.Z - A.B.C`
Specifies an inclusive set.
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
If a partial version is provided as the first version in the inclusive
range, then the missing pieces are replaced with zeroes.
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts.
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
numeric values in the `[major, minor, patch]` tuple.
* `*` := `>=0.0.0` (Any version satisfies)
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
A partial version range is treated as an X-Range, so the special
character is in fact optional.
* `""` (empty string) := `*` := `>=0.0.0`
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
Allows patch-level changes if a minor version is specified on the
comparator. Allows minor-level changes if not.
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
Allows changes that do not modify the left-most non-zero element in the
`[major, minor, patch]` tuple. In other words, this allows patch and
minor updates for versions `1.0.0` and above, patch updates for
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
Many authors treat a `0.x` version as if the `x` were the major
"breaking-change" indicator.
Caret ranges are ideal when an author may make breaking changes
between `0.2.4` and `0.3.0` releases, which is a common practice.
However, it presumes that there will *not* be breaking changes between
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
additive (but non-breaking), according to commonly observed practices.
* `^1.2.3` := `>=1.2.3 <2.0.0`
* `^0.2.3` := `>=0.2.3 <0.3.0`
* `^0.0.3` := `>=0.0.3 <0.0.4`
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
`0.0.3` version *only* will be allowed, if they are greater than or
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
When parsing caret ranges, a missing `patch` value desugars to the
number `0`, but will allow flexibility within that value, even if the
major and minor versions are both `0`.
* `^1.2.x` := `>=1.2.0 <2.0.0`
* `^0.0.x` := `>=0.0.0 <0.1.0`
* `^0.0` := `>=0.0.0 <0.1.0`
A missing `minor` and `patch` values will desugar to zero, but also
allow flexibility within those values, even if the major version is
zero.
* `^1.x` := `>=1.0.0 <2.0.0`
* `^0.x` := `>=0.0.0 <1.0.0`
### Range Grammar
Putting all this together, here is a Backus-Naur grammar for ranges,
for the benefit of parser authors:
```bnf
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
```
## Functions
All methods and classes take a final `options` object argument. All
options in this object are `false` by default. The options supported
are:
- `loose` Be more forgiving about not-quite-valid semver strings.
(Any resulting output will always be 100% strict compliant, of
course.) For backwards compatibility reasons, if the `options`
argument is a boolean value instead of an object, it is interpreted
to be the `loose` param.
- `includePrerelease` Set to suppress the [default
behavior](https://github.com/npm/node-semver#prerelease-tags) of
excluding prerelease tagged versions from ranges unless they are
explicitly opted into.
Strict-mode Comparators and Ranges will be strict about the SemVer
strings that they parse.
* `valid(v)`: Return the parsed version, or null if it's not valid.
* `inc(v, release)`: Return the version incremented by the release
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
`prepatch`, or `prerelease`), or null if it's not valid
* `premajor` in one call will bump the version up to the next major
version and down to a prerelease of that major version.
`preminor`, and `prepatch` work the same way.
* If called from a non-prerelease version, the `prerelease` will work the
same as `prepatch`. It increments the patch version, then makes a
prerelease. If the input version is already a prerelease it simply
increments it.
* `prerelease(v)`: Returns an array of prerelease components, or null
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
* `major(v)`: Return the major version number.
* `minor(v)`: Return the minor version number.
* `patch(v)`: Return the patch version number.
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
or comparators intersect.
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
a `SemVer` object or `null`.
### Comparison
* `gt(v1, v2)`: `v1 > v2`
* `gte(v1, v2)`: `v1 >= v2`
* `lt(v1, v2)`: `v1 < v2`
* `lte(v1, v2)`: `v1 <= v2`
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
even if they're not the exact same string. You already know how to
compare strings.
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
the corresponding function above. `"==="` and `"!=="` do simple
string comparison, but are included for completeness. Throws if an
invalid comparison string is provided.
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
in descending order when passed to `Array.sort()`.
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
are equal. Sorts in ascending order if passed to `Array.sort()`.
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `diff(v1, v2)`: Returns difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
### Comparators
* `intersects(comparator)`: Return true if the comparators intersect
### Ranges
* `validRange(range)`: Return the valid range or null if it's not valid
* `satisfies(version, range)`: Return true if the version satisfies the
range.
* `maxSatisfying(versions, range)`: Return the highest version in the list
that satisfies the range, or `null` if none of them do.
* `minSatisfying(versions, range)`: Return the lowest version in the list
that satisfies the range, or `null` if none of them do.
* `minVersion(range)`: Return the lowest version that can possibly match
the given range.
* `gtr(version, range)`: Return `true` if version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if version is less than all the
versions possible in the range.
* `outside(version, range, hilo)`: Return true if the version is outside
the bounds of the range in either the high or low direction. The
`hilo` argument must be either the string `'>'` or `'<'`. (This is
the function called by `gtr` and `ltr`.)
* `intersects(range)`: Return true if any of the ranges comparators intersect
Note that, since ranges may be non-contiguous, a version might not be
greater than a range, less than a range, *or* satisfy a range! For
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
until `2.0.0`, so the version `1.2.10` would not be greater than the
range (because `2.0.1` satisfies, which is higher), nor less than the
range (since `1.2.8` satisfies, which is lower), and it also does not
satisfy the range.
If you want to know if a version satisfies or does not satisfy a
range, use the `satisfies(version, range)` function.
### Coercion
* `coerce(version, options)`: Coerces a string to semver if possible
This aims to provide a very forgiving translation of a non-semver string to
semver. It looks for the first digit in a string, and consumes all
remaining characters which satisfy at least a partial semver (e.g., `1`,
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
is not valid). The maximum length for any semver component considered for
coercion is 16 characters; longer components will be ignored
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
components are invalid (`9999999999999999.4.7.4` is likely invalid).
If the `options.rtl` flag is set, then `coerce` will return the right-most
coercible tuple that does not share an ending index with a longer coercible
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
any other overlapping SemVer tuple.
### Clean
* `clean(version)`: Clean a string to be a valid semver if possible
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
ex.
* `s.clean(' = v 2.1.5foo')`: `null`
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean(' = v 2.1.5-foo')`: `null`
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean('=v2.1.5')`: `'2.1.5'`
* `s.clean(' =v2.1.5')`: `2.1.5`
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
* `s.clean('~1.0.0')`: `null`

View file

@ -0,0 +1,174 @@
#!/usr/bin/env node
// Standalone semver comparison program.
// Exits successfully and prints matching version(s) if
// any supplied version is valid and passes all tests.
var argv = process.argv.slice(2)
var versions = []
var range = []
var inc = null
var version = require('../package.json').version
var loose = false
var includePrerelease = false
var coerce = false
var rtl = false
var identifier
var semver = require('../semver')
var reverse = false
var options = {}
main()
function main () {
if (!argv.length) return help()
while (argv.length) {
var a = argv.shift()
var indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
a = a.slice(0, indexOfEqualSign)
argv.unshift(a.slice(indexOfEqualSign + 1))
}
switch (a) {
case '-rv': case '-rev': case '--rev': case '--reverse':
reverse = true
break
case '-l': case '--loose':
loose = true
break
case '-p': case '--include-prerelease':
includePrerelease = true
break
case '-v': case '--version':
versions.push(argv.shift())
break
case '-i': case '--inc': case '--increment':
switch (argv[0]) {
case 'major': case 'minor': case 'patch': case 'prerelease':
case 'premajor': case 'preminor': case 'prepatch':
inc = argv.shift()
break
default:
inc = 'patch'
break
}
break
case '--preid':
identifier = argv.shift()
break
case '-r': case '--range':
range.push(argv.shift())
break
case '-c': case '--coerce':
coerce = true
break
case '--rtl':
rtl = true
break
case '--ltr':
rtl = false
break
case '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
break
}
}
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
versions = versions.map(function (v) {
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
}).filter(function (v) {
return semver.valid(v)
})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
for (var i = 0, l = range.length; i < l; i++) {
versions = versions.filter(function (v) {
return semver.satisfies(v, range[i], options)
})
if (!versions.length) return fail()
}
return success(versions)
}
function failInc () {
console.error('--inc can only be used on a single version with no range')
fail()
}
function fail () { process.exit(1) }
function success () {
var compare = reverse ? 'rcompare' : 'compare'
versions.sort(function (a, b) {
return semver[compare](a, b, options)
}).map(function (v) {
return semver.clean(v, options)
}).map(function (v) {
return inc ? semver.inc(v, inc, options, identifier) : v
}).forEach(function (v, i, _) { console.log(v) })
}
function help () {
console.log(['SemVer ' + version,
'',
'A JavaScript implementation of the https://semver.org/ specification',
'Copyright Isaac Z. Schlueter',
'',
'Usage: semver [options] <version> [<version> [...]]',
'Prints valid versions sorted by SemVer precedence',
'',
'Options:',
'-r --range <range>',
' Print versions that match the specified range.',
'',
'-i --increment [<level>]',
' Increment a version by the specified level. Level can',
' be one of: major, minor, patch, premajor, preminor,',
" prepatch, or prerelease. Default level is 'patch'.",
' Only one version may be specified.',
'',
'--preid <identifier>',
' Identifier to be used to prefix premajor, preminor,',
' prepatch or prerelease version increments.',
'',
'-l --loose',
' Interpret versions and ranges loosely',
'',
'-p --include-prerelease',
' Always include prerelease versions in range matching',
'',
'-c --coerce',
' Coerce a string into SemVer if possible',
' (does not imply --loose)',
'',
'--rtl',
' Coerce version strings right to left',
'',
'--ltr',
' Coerce version strings left to right (default)',
'',
'Program exits successfully if any valid version satisfies',
'all supplied ranges, and prints all satisfying versions.',
'',
'If no satisfying versions are found, then exits failure.',
'',
'Versions are printed in ascending order, so supplying',
'multiple versions to the utility will just sort them.'
].join('\n'))
}

View file

@ -0,0 +1,60 @@
{
"_from": "semver@^6.3.0",
"_id": "semver@6.3.0",
"_inBundle": false,
"_integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"_location": "/npm-check-updates/semver",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "semver@^6.3.0",
"name": "semver",
"escapedName": "semver",
"rawSpec": "^6.3.0",
"saveSpec": null,
"fetchSpec": "^6.3.0"
},
"_requiredBy": [
"/npm-check-updates"
],
"_resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"_shasum": "ee0a64c8af5e8ceea67687b133761e1becbd1d3d",
"_spec": "semver@^6.3.0",
"_where": "/home/shimataro/projects/actions/ssh-key-action/node_modules/npm-check-updates",
"bin": {
"semver": "./bin/semver.js"
},
"bugs": {
"url": "https://github.com/npm/node-semver/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "The semantic version parser used by npm.",
"devDependencies": {
"tap": "^14.3.1"
},
"files": [
"bin",
"range.bnf",
"semver.js"
],
"homepage": "https://github.com/npm/node-semver#readme",
"license": "ISC",
"main": "semver.js",
"name": "semver",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/node-semver.git"
},
"scripts": {
"postpublish": "git push origin --follow-tags",
"postversion": "npm publish",
"preversion": "npm test",
"test": "tap"
},
"tap": {
"check-coverage": true
},
"version": "6.3.0"
}

View file

@ -0,0 +1,16 @@
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | [1-9] ( [0-9] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+

File diff suppressed because it is too large Load diff

116
node_modules/npm-check-updates/package.json generated vendored Normal file
View file

@ -0,0 +1,116 @@
{
"_from": "npm-check-updates@3.1.23",
"_id": "npm-check-updates@3.1.23",
"_inBundle": false,
"_integrity": "sha512-Z2dkMdNgue6OPkQDPcAK62Qrwv+G1PaEmKrDrrSAiSP7pRD3u30xOVy1nLukS1XrJ2/zF8XTVxFe9/ubcvlcPQ==",
"_location": "/npm-check-updates",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "npm-check-updates@3.1.23",
"name": "npm-check-updates",
"escapedName": "npm-check-updates",
"rawSpec": "3.1.23",
"saveSpec": null,
"fetchSpec": "3.1.23"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-3.1.23.tgz",
"_shasum": "9f2885665b1c7327d909558bdc65913927a7de12",
"_spec": "npm-check-updates@3.1.23",
"_where": "/home/shimataro/projects/actions/ssh-key-action",
"author": {
"name": "Tomas Junnonen",
"email": "tomas1@gmail.com"
},
"bin": {
"npm-check-updates": "./bin/npm-check-updates",
"ncu": "./bin/ncu"
},
"bugs": {
"url": "https://github.com/tjunnone/npm-check-updates/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Raine Revere",
"url": "https://github.com/raineorshine"
}
],
"dependencies": {
"chalk": "^2.4.2",
"cint": "^8.2.1",
"cli-table": "^0.3.1",
"commander": "^3.0.1",
"fast-diff": "^1.2.0",
"find-up": "4.1.0",
"get-stdin": "^7.0.0",
"json-parse-helpfulerror": "^1.0.3",
"libnpmconfig": "^1.2.1",
"lodash": "^4.17.15",
"node-alias": "^1.0.4",
"pacote": "^9.5.8",
"progress": "^2.0.3",
"prompts": "^2.2.1",
"rc-config-loader": "^2.0.4",
"requireg": "^0.2.2",
"semver": "^6.3.0",
"semver-utils": "^1.1.4",
"spawn-please": "^0.3.0",
"update-notifier": "^3.0.1"
},
"deprecated": false,
"description": "Find newer versions of dependencies than what your package.json or bower.json allows",
"devDependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-string": "^1.5.0",
"chokidar-cli": "^2.0.0",
"eslint": "^6.3.0",
"mocha": "^6.2.0",
"should": "^13.2.3",
"snyk": "^1.226.1",
"tmp": "0.1.0"
},
"engines": {
"node": ">=8"
},
"files": [
"bin",
"lib"
],
"homepage": "https://github.com/tjunnone/npm-check-updates",
"keywords": [
"npm",
"bower",
"check",
"find",
"discover",
"updates",
"upgrades",
"dependencies",
"package.json",
"bower.json",
"updater",
"version",
"management",
"ncu"
],
"license": "Apache-2.0",
"main": "./lib/npm-check-updates",
"name": "npm-check-updates",
"preferGlobal": true,
"repository": {
"type": "git",
"url": "git+https://github.com/tjunnone/npm-check-updates.git"
},
"scripts": {
"lint": "eslint bin/* lib test",
"test": "npm run lint && mocha && mocha test/individual && if [ ! \"$TRAVIS\" ]; then snyk test; fi",
"watch": "chokidar \"lib/**/*.js\" -c \"npm run test\""
},
"version": "3.1.23"
}