This repository has been archived by the owner on Jan 4, 2024. It is now read-only.
forked from lerna/lerna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.js
74 lines (68 loc) · 2.24 KB
/
command.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"use strict";
const { filterOptions } = require("@lerna/filter-options");
/**
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module
*/
exports.command = "add <pkg> [globs..]";
exports.describe = "Add a single dependency to matched packages";
exports.builder = (yargs) => {
yargs
.positional("pkg", {
describe: "Package name to add as a dependency",
type: "string",
})
.positional("globs", {
describe: "Optional package directory globs to match",
type: "array",
})
.options({
D: {
group: "Command Options:",
type: "boolean",
alias: "dev",
describe: "Save to devDependencies",
},
E: {
group: "Command Options:",
type: "boolean",
alias: "exact",
describe: "Save version exactly",
},
P: {
group: "Command Options:",
type: "boolean",
alias: "peer",
describe: "Save to peerDependencies",
},
registry: {
group: "Command Options:",
describe: "Use the specified registry for all npm client operations.",
type: "string",
requiresArg: true,
},
"no-bootstrap": {
group: "Command Options:",
describe: "Do not automatically chain `lerna bootstrap` after changes are made.",
type: "boolean",
},
bootstrap: {
// proxy for --no-bootstrap
hidden: true,
type: "boolean",
},
})
.example(
"$0 add module-1 packages/prefix-*",
"Adds the module-1 package to the packages in the 'prefix-' prefixed folders"
)
.example("$0 add module-1 --scope=module-2", "Install module-1 to module-2")
.example("$0 add module-1 --scope=module-2 --dev", "Install module-1 to module-2 in devDependencies")
.example("$0 add module-1 --scope=module-2 --peer", "Install module-1 to module-2 in peerDependencies")
.example("$0 add module-1", "Install module-1 in all modules except module-1")
.example("$0 add module-1 --no-bootstrap", "Skip automatic `lerna bootstrap`")
.example("$0 add babel-core", "Install babel-core in all modules");
return filterOptions(yargs);
};
exports.handler = function handler(argv) {
return require(".")(argv);
};