-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
126 lines (110 loc) · 4.33 KB
/
index.ts
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { hideBin } from "yargs/helpers";
import yargs from "yargs/yargs";
import { CommandProcessor } from "./core/CommandProcessor";
const app = new CommandProcessor();
async function perform() {
const args = await yargs(
hideBin(process.argv)
)
.command("link [package]", "Links a new package", (yargs) => {
return yargs
.positional("package", {
type: "string",
describe: "The package to be linked. If none is given, will link try creating a link to the current package.",
requiresArg: false
})
.option("global", {
alias: "g",
type: "boolean",
describe: "If it's a global operation",
requiresArg: false
})
})
.command("unlink [package]", "Unlinks an existing package", (yargs) => {
return yargs
.positional("package", {
type: "string",
describe: "The package to be unlinked. If none is given, will try to globally unlink the current package.",
requiresArg: false
})
.option("global", {
alias: "g",
type: "boolean",
describe: "If it's a global operation",
requiresArg: false
})
.option("force", {
alias: "f",
type: "boolean",
describe: "Will force deleting the symlink from the original package manager folder.",
requiresArg: false
});
})
.command("reset-global-links", "Will delete all existing global links.\nWARNING: this may break entire applications if used incorrectly.", (yargs) => {
return yargs
.option("onlyBroken", {
type: "boolean",
alias: ["b", "only-broken"],
default: false,
describe: "Will delete only broken symlinks."
});
})
.command("mklink [pattern]", "Creates links for a given glob pattern.", (yargs) => {
return yargs
.positional("pattern", {
type: "string",
requiresArg: true,
describe: "The glob pattern to find for directories with projects to be linked."
})
.option("depth", {
type: "number",
alias: ["d"],
requiresArg: false,
describe: "The depth to search for folder by using the pattern."
})
})
.command("global-hook [action]", "Installs a global hook into yarn / npm. It will act like a `postinstall` lifecycle event.", (yargs) => {
return yargs
.positional("action", {
type: "string",
choices: ["install", "uninstall"]
});
})
.command("*", "Will try to link all linked packages", (yargs) => {
return yargs
.option("ignoreGlobalLinks", {
alias: ["ignore-global", "ignore-global-links", "igl"],
type: "boolean",
describe: "If can ignore all global links",
requiresArg: false,
default: false
})
.option("ignoreFileLinks", {
alias: ["ignore-file", "ignore-file-links", "ifl"],
type: "boolean",
describe: "If can ignore all \"file:\" links",
requiresArg: false,
default: false
});
})
.option("verbose", {
alias: "v",
type: "boolean",
describe: "Enables verbose logging",
requiresArg: false
})
.option("headless", {
type: "boolean",
describe: "Enables headless mode",
default: false
})
.global(["verbose", "headless"])
.parse();
const cmd = args._[0];
app.setOptions({
verbose: args.verbose,
headless: args.headless
});
app.process(cmd as string, args);
}
perform();