UNPKG

swap-lock-registry

Version:

A CLI tool to swap the registry URL in the lock file without having to remove it

52 lines (51 loc) 1.4 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const yargs = require("yargs"); const trait_1 = require("./trait"); const utils_1 = require("./utils"); const options = yargs .usage('swap-lock-registry -u https://registry.npmjs.com [lock-files...]') .option('u', { alias: 'url', describe: 'The registry url', type: 'string', demandOption: true, }) .option('i', { alias: 'ignore', describe: 'List of package name patterns to ignore, ex: @types/*,lodash*', type: 'string', demandOption: false, default: '', }) .option('y', { alias: 'yarn', describe: 'Whether the files are Yarn lock files', type: 'boolean', demandOption: false, default: false, }) .option('p', { alias: 'parallel', describe: 'Whether the trait the files in parallel.', type: 'boolean', demandOption: false, default: false, }) .option('a', { alias: 'all', describe: 'Update all packages even registry is already replaced.', type: 'boolean', demandOption: false, default: false, }).argv; (0, trait_1.traitFiles)(options._, { url: (0, utils_1.trimString)(options.u, '/'), ignore: options.i .split(',') .map((str) => new RegExp(`^${str.replace(/\*/g, '.*')}$`, 'g')), yarn: options.y, parallel: options.p, ignoreReplaced: !options.a, });