UNPKG

syncpack

Version:

Manage multiple package.json files, such as in Lerna Monorepos and Yarn/Pnpm Workspaces

55 lines (54 loc) 5.21 kB
#!/usr/bin/env node "use strict"; var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _a, _b, _c, _d; exports.__esModule = true; var chalk_1 = __importDefault(require("chalk")); var list_mismatches_1 = require("./commands/list-mismatches"); var constants_1 = require("./constants"); var get_config_1 = require("./lib/get-config"); var program = require("commander"); program.description("\n List dependencies which are required by multiple packages, where the version\n is not the same across every package.".replace(/^\n/, '')); program.on('--help', function () { console.log(chalk_1["default"](templateObject_1 || (templateObject_1 = __makeTemplateObject(["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack list-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list-mismatches --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list-mismatches --dev --peer\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"], ["\nExamples:\n {dim # uses defaults for resolving packages}\n syncpack list-mismatches\n {dim # uses packages defined by --source when provided}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"}\n {dim # multiple globs can be provided like this}\n syncpack list-mismatches --source {yellow \"apps/*/package.json\"} --source {yellow \"core/*/package.json\"}\n {dim # uses dependencies regular expression defined by --filter when provided}\n syncpack list-mismatches --filter {yellow \"typescript|tslint\"}\n {dim # only inspect \"devDependencies\"}\n syncpack list-mismatches --dev\n {dim # only inspect \"devDependencies\" and \"peerDependencies\"}\n syncpack list-mismatches --dev --peer\n\nResolving Packages:\n 1. If {yellow --source} globs are provided, use those.\n 2. If using Pnpm Workspaces, read {yellow packages} from {yellow pnpm-workspace.yaml} in the root of the project.\n 3. If using Yarn Workspaces, read {yellow workspaces} from {yellow package.json}.\n 4. If using Lerna, read {yellow packages} from {yellow lerna.json}.\n 5. Default to {yellow \"package.json\"} and {yellow \"packages/*/package.json\"}.\n\nReference:\n globs {blue.underline https://github.com/isaacs/node-glob#glob-primer}\n lerna.json {blue.underline https://github.com/lerna/lerna#lernajson}\n Yarn Workspaces {blue.underline https://yarnpkg.com/lang/en/docs/workspaces}\n Pnpm Workspaces {blue.underline https://pnpm.js.org/en/workspaces}\n"])))); }); (_a = (_b = (_c = (_d = program .option.apply(program, __spread(constants_1.option.source))) .option.apply(_d, __spread(constants_1.option.prod))) .option.apply(_c, __spread(constants_1.option.dev))) .option.apply(_b, __spread(constants_1.option.peer))) .option.apply(_a, __spread(constants_1.option.filter)).parse(process.argv); list_mismatches_1.listMismatchesFromDisk(get_config_1.getConfig({ dev: program.dev, filter: program.filter, peer: program.peer, prod: program.prod, source: program.source })); var templateObject_1;