@aikidosec/safe-chain 0.0.4-connect-timeout-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +257 -0
- package/bin/aikido-bun.js +14 -0
- package/bin/aikido-bunx.js +14 -0
- package/bin/aikido-npm.js +14 -0
- package/bin/aikido-npx.js +14 -0
- package/bin/aikido-pip.js +20 -0
- package/bin/aikido-pip3.js +21 -0
- package/bin/aikido-pnpm.js +14 -0
- package/bin/aikido-pnpx.js +14 -0
- package/bin/aikido-python.js +30 -0
- package/bin/aikido-python3.js +30 -0
- package/bin/aikido-uv.js +16 -0
- package/bin/aikido-yarn.js +14 -0
- package/bin/safe-chain.js +190 -0
- package/docs/banner.svg +151 -0
- package/docs/npm-to-binary-migration.md +89 -0
- package/docs/safe-package-manager-demo.gif +0 -0
- package/docs/safe-package-manager-demo.png +0 -0
- package/docs/shell-integration.md +149 -0
- package/package.json +68 -0
- package/src/api/aikido.js +54 -0
- package/src/api/npmApi.js +71 -0
- package/src/config/cliArguments.js +138 -0
- package/src/config/configFile.js +192 -0
- package/src/config/environmentVariables.js +7 -0
- package/src/config/settings.js +100 -0
- package/src/environment/environment.js +14 -0
- package/src/environment/userInteraction.js +122 -0
- package/src/main.js +104 -0
- package/src/packagemanager/_shared/matchesCommand.js +18 -0
- package/src/packagemanager/bun/createBunPackageManager.js +53 -0
- package/src/packagemanager/currentPackageManager.js +72 -0
- package/src/packagemanager/npm/createPackageManager.js +72 -0
- package/src/packagemanager/npm/dependencyScanner/commandArgumentScanner.js +74 -0
- package/src/packagemanager/npm/dependencyScanner/nullScanner.js +9 -0
- package/src/packagemanager/npm/parsing/parsePackagesFromInstallArgs.js +144 -0
- package/src/packagemanager/npm/runNpmCommand.js +25 -0
- package/src/packagemanager/npm/utils/abbrevs-generated.js +359 -0
- package/src/packagemanager/npm/utils/cmd-list.js +174 -0
- package/src/packagemanager/npm/utils/npmCommands.js +34 -0
- package/src/packagemanager/npx/createPackageManager.js +15 -0
- package/src/packagemanager/npx/dependencyScanner/commandArgumentScanner.js +43 -0
- package/src/packagemanager/npx/parsing/parsePackagesFromArguments.js +130 -0
- package/src/packagemanager/npx/runNpxCommand.js +25 -0
- package/src/packagemanager/pip/createPackageManager.js +21 -0
- package/src/packagemanager/pip/pipSettings.js +30 -0
- package/src/packagemanager/pip/runPipCommand.js +175 -0
- package/src/packagemanager/pnpm/createPackageManager.js +57 -0
- package/src/packagemanager/pnpm/dependencyScanner/commandArgumentScanner.js +35 -0
- package/src/packagemanager/pnpm/parsing/parsePackagesFromArguments.js +109 -0
- package/src/packagemanager/pnpm/runPnpmCommand.js +36 -0
- package/src/packagemanager/uv/createUvPackageManager.js +18 -0
- package/src/packagemanager/uv/runUvCommand.js +71 -0
- package/src/packagemanager/yarn/createPackageManager.js +41 -0
- package/src/packagemanager/yarn/dependencyScanner/commandArgumentScanner.js +35 -0
- package/src/packagemanager/yarn/parsing/parsePackagesFromArguments.js +128 -0
- package/src/packagemanager/yarn/runYarnCommand.js +41 -0
- package/src/registryProxy/certBundle.js +95 -0
- package/src/registryProxy/certUtils.js +128 -0
- package/src/registryProxy/http-utils.js +17 -0
- package/src/registryProxy/interceptors/createInterceptorForEcoSystem.js +25 -0
- package/src/registryProxy/interceptors/interceptorBuilder.js +140 -0
- package/src/registryProxy/interceptors/npm/modifyNpmInfo.js +177 -0
- package/src/registryProxy/interceptors/npm/npmInterceptor.js +47 -0
- package/src/registryProxy/interceptors/npm/parseNpmPackageUrl.js +43 -0
- package/src/registryProxy/interceptors/pipInterceptor.js +115 -0
- package/src/registryProxy/mitmRequestHandler.js +231 -0
- package/src/registryProxy/plainHttpProxy.js +95 -0
- package/src/registryProxy/registryProxy.js +184 -0
- package/src/registryProxy/tunnelRequestHandler.js +180 -0
- package/src/scanning/audit/index.js +129 -0
- package/src/scanning/index.js +82 -0
- package/src/scanning/malwareDatabase.js +131 -0
- package/src/shell-integration/helpers.js +213 -0
- package/src/shell-integration/path-wrappers/templates/unix-wrapper.template.sh +22 -0
- package/src/shell-integration/path-wrappers/templates/windows-wrapper.template.cmd +24 -0
- package/src/shell-integration/setup-ci.js +170 -0
- package/src/shell-integration/setup.js +127 -0
- package/src/shell-integration/shellDetection.js +37 -0
- package/src/shell-integration/startup-scripts/include-python/init-fish.fish +94 -0
- package/src/shell-integration/startup-scripts/include-python/init-posix.sh +81 -0
- package/src/shell-integration/startup-scripts/include-python/init-pwsh.ps1 +115 -0
- package/src/shell-integration/startup-scripts/init-fish.fish +71 -0
- package/src/shell-integration/startup-scripts/init-posix.sh +58 -0
- package/src/shell-integration/startup-scripts/init-pwsh.ps1 +92 -0
- package/src/shell-integration/supported-shells/bash.js +134 -0
- package/src/shell-integration/supported-shells/fish.js +77 -0
- package/src/shell-integration/supported-shells/powershell.js +73 -0
- package/src/shell-integration/supported-shells/windowsPowershell.js +73 -0
- package/src/shell-integration/supported-shells/zsh.js +74 -0
- package/src/shell-integration/teardown.js +64 -0
- package/src/utils/safeSpawn.js +137 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
// This was ran with the abbrev package to generate the abbrevs object below
|
|
2
|
+
// console.log(abbrev(commands.concat(Object.keys(aliases))));
|
|
3
|
+
/** @type {Record<string, string>} */
|
|
4
|
+
export const abbrevs = {
|
|
5
|
+
ac: "access",
|
|
6
|
+
acc: "access",
|
|
7
|
+
acce: "access",
|
|
8
|
+
acces: "access",
|
|
9
|
+
access: "access",
|
|
10
|
+
add: "add",
|
|
11
|
+
"add-": "add-user",
|
|
12
|
+
"add-u": "add-user",
|
|
13
|
+
"add-us": "add-user",
|
|
14
|
+
"add-use": "add-user",
|
|
15
|
+
"add-user": "add-user",
|
|
16
|
+
addu: "adduser",
|
|
17
|
+
addus: "adduser",
|
|
18
|
+
adduse: "adduser",
|
|
19
|
+
adduser: "adduser",
|
|
20
|
+
aud: "audit",
|
|
21
|
+
audi: "audit",
|
|
22
|
+
audit: "audit",
|
|
23
|
+
aut: "author",
|
|
24
|
+
auth: "author",
|
|
25
|
+
autho: "author",
|
|
26
|
+
author: "author",
|
|
27
|
+
b: "bugs",
|
|
28
|
+
bu: "bugs",
|
|
29
|
+
bug: "bugs",
|
|
30
|
+
bugs: "bugs",
|
|
31
|
+
c: "c",
|
|
32
|
+
ca: "cache",
|
|
33
|
+
cac: "cache",
|
|
34
|
+
cach: "cache",
|
|
35
|
+
cache: "cache",
|
|
36
|
+
ci: "ci",
|
|
37
|
+
cit: "cit",
|
|
38
|
+
"clean-install": "clean-install",
|
|
39
|
+
"clean-install-": "clean-install-test",
|
|
40
|
+
"clean-install-t": "clean-install-test",
|
|
41
|
+
"clean-install-te": "clean-install-test",
|
|
42
|
+
"clean-install-tes": "clean-install-test",
|
|
43
|
+
"clean-install-test": "clean-install-test",
|
|
44
|
+
com: "completion",
|
|
45
|
+
comp: "completion",
|
|
46
|
+
compl: "completion",
|
|
47
|
+
comple: "completion",
|
|
48
|
+
complet: "completion",
|
|
49
|
+
completi: "completion",
|
|
50
|
+
completio: "completion",
|
|
51
|
+
completion: "completion",
|
|
52
|
+
con: "config",
|
|
53
|
+
conf: "config",
|
|
54
|
+
confi: "config",
|
|
55
|
+
config: "config",
|
|
56
|
+
cr: "create",
|
|
57
|
+
cre: "create",
|
|
58
|
+
crea: "create",
|
|
59
|
+
creat: "create",
|
|
60
|
+
create: "create",
|
|
61
|
+
dd: "ddp",
|
|
62
|
+
ddp: "ddp",
|
|
63
|
+
ded: "dedupe",
|
|
64
|
+
dedu: "dedupe",
|
|
65
|
+
dedup: "dedupe",
|
|
66
|
+
dedupe: "dedupe",
|
|
67
|
+
dep: "deprecate",
|
|
68
|
+
depr: "deprecate",
|
|
69
|
+
depre: "deprecate",
|
|
70
|
+
deprec: "deprecate",
|
|
71
|
+
depreca: "deprecate",
|
|
72
|
+
deprecat: "deprecate",
|
|
73
|
+
deprecate: "deprecate",
|
|
74
|
+
dif: "diff",
|
|
75
|
+
diff: "diff",
|
|
76
|
+
"dist-tag": "dist-tag",
|
|
77
|
+
"dist-tags": "dist-tags",
|
|
78
|
+
docs: "docs",
|
|
79
|
+
doct: "doctor",
|
|
80
|
+
docto: "doctor",
|
|
81
|
+
doctor: "doctor",
|
|
82
|
+
ed: "edit",
|
|
83
|
+
edi: "edit",
|
|
84
|
+
edit: "edit",
|
|
85
|
+
exe: "exec",
|
|
86
|
+
exec: "exec",
|
|
87
|
+
expla: "explain",
|
|
88
|
+
explai: "explain",
|
|
89
|
+
explain: "explain",
|
|
90
|
+
explo: "explore",
|
|
91
|
+
explor: "explore",
|
|
92
|
+
explore: "explore",
|
|
93
|
+
find: "find",
|
|
94
|
+
"find-": "find-dupes",
|
|
95
|
+
"find-d": "find-dupes",
|
|
96
|
+
"find-du": "find-dupes",
|
|
97
|
+
"find-dup": "find-dupes",
|
|
98
|
+
"find-dupe": "find-dupes",
|
|
99
|
+
"find-dupes": "find-dupes",
|
|
100
|
+
fu: "fund",
|
|
101
|
+
fun: "fund",
|
|
102
|
+
fund: "fund",
|
|
103
|
+
g: "get",
|
|
104
|
+
ge: "get",
|
|
105
|
+
get: "get",
|
|
106
|
+
help: "help",
|
|
107
|
+
"help-": "help-search",
|
|
108
|
+
"help-s": "help-search",
|
|
109
|
+
"help-se": "help-search",
|
|
110
|
+
"help-sea": "help-search",
|
|
111
|
+
"help-sear": "help-search",
|
|
112
|
+
"help-searc": "help-search",
|
|
113
|
+
"help-search": "help-search",
|
|
114
|
+
hl: "hlep",
|
|
115
|
+
hle: "hlep",
|
|
116
|
+
hlep: "hlep",
|
|
117
|
+
ho: "home",
|
|
118
|
+
hom: "home",
|
|
119
|
+
home: "home",
|
|
120
|
+
i: "i",
|
|
121
|
+
ic: "ic",
|
|
122
|
+
in: "in",
|
|
123
|
+
inf: "info",
|
|
124
|
+
info: "info",
|
|
125
|
+
ini: "init",
|
|
126
|
+
init: "init",
|
|
127
|
+
inn: "innit",
|
|
128
|
+
inni: "innit",
|
|
129
|
+
innit: "innit",
|
|
130
|
+
ins: "ins",
|
|
131
|
+
inst: "inst",
|
|
132
|
+
insta: "insta",
|
|
133
|
+
instal: "instal",
|
|
134
|
+
install: "install",
|
|
135
|
+
"install-ci": "install-ci-test",
|
|
136
|
+
"install-ci-": "install-ci-test",
|
|
137
|
+
"install-ci-t": "install-ci-test",
|
|
138
|
+
"install-ci-te": "install-ci-test",
|
|
139
|
+
"install-ci-tes": "install-ci-test",
|
|
140
|
+
"install-ci-test": "install-ci-test",
|
|
141
|
+
"install-cl": "install-clean",
|
|
142
|
+
"install-cle": "install-clean",
|
|
143
|
+
"install-clea": "install-clean",
|
|
144
|
+
"install-clean": "install-clean",
|
|
145
|
+
"install-t": "install-test",
|
|
146
|
+
"install-te": "install-test",
|
|
147
|
+
"install-tes": "install-test",
|
|
148
|
+
"install-test": "install-test",
|
|
149
|
+
isnt: "isnt",
|
|
150
|
+
isnta: "isnta",
|
|
151
|
+
isntal: "isntal",
|
|
152
|
+
isntall: "isntall",
|
|
153
|
+
"isntall-": "isntall-clean",
|
|
154
|
+
"isntall-c": "isntall-clean",
|
|
155
|
+
"isntall-cl": "isntall-clean",
|
|
156
|
+
"isntall-cle": "isntall-clean",
|
|
157
|
+
"isntall-clea": "isntall-clean",
|
|
158
|
+
"isntall-clean": "isntall-clean",
|
|
159
|
+
iss: "issues",
|
|
160
|
+
issu: "issues",
|
|
161
|
+
issue: "issues",
|
|
162
|
+
issues: "issues",
|
|
163
|
+
it: "it",
|
|
164
|
+
la: "la",
|
|
165
|
+
lin: "link",
|
|
166
|
+
link: "link",
|
|
167
|
+
lis: "list",
|
|
168
|
+
list: "list",
|
|
169
|
+
ll: "ll",
|
|
170
|
+
ln: "ln",
|
|
171
|
+
logi: "login",
|
|
172
|
+
login: "login",
|
|
173
|
+
logo: "logout",
|
|
174
|
+
logou: "logout",
|
|
175
|
+
logout: "logout",
|
|
176
|
+
ls: "ls",
|
|
177
|
+
og: "ogr",
|
|
178
|
+
ogr: "ogr",
|
|
179
|
+
or: "org",
|
|
180
|
+
org: "org",
|
|
181
|
+
ou: "outdated",
|
|
182
|
+
out: "outdated",
|
|
183
|
+
outd: "outdated",
|
|
184
|
+
outda: "outdated",
|
|
185
|
+
outdat: "outdated",
|
|
186
|
+
outdate: "outdated",
|
|
187
|
+
outdated: "outdated",
|
|
188
|
+
ow: "owner",
|
|
189
|
+
own: "owner",
|
|
190
|
+
owne: "owner",
|
|
191
|
+
owner: "owner",
|
|
192
|
+
pa: "pack",
|
|
193
|
+
pac: "pack",
|
|
194
|
+
pack: "pack",
|
|
195
|
+
pi: "ping",
|
|
196
|
+
pin: "ping",
|
|
197
|
+
ping: "ping",
|
|
198
|
+
pk: "pkg",
|
|
199
|
+
pkg: "pkg",
|
|
200
|
+
pre: "prefix",
|
|
201
|
+
pref: "prefix",
|
|
202
|
+
prefi: "prefix",
|
|
203
|
+
prefix: "prefix",
|
|
204
|
+
pro: "profile",
|
|
205
|
+
prof: "profile",
|
|
206
|
+
profi: "profile",
|
|
207
|
+
profil: "profile",
|
|
208
|
+
profile: "profile",
|
|
209
|
+
pru: "prune",
|
|
210
|
+
prun: "prune",
|
|
211
|
+
prune: "prune",
|
|
212
|
+
pu: "publish",
|
|
213
|
+
pub: "publish",
|
|
214
|
+
publ: "publish",
|
|
215
|
+
publi: "publish",
|
|
216
|
+
publis: "publish",
|
|
217
|
+
publish: "publish",
|
|
218
|
+
q: "query",
|
|
219
|
+
qu: "query",
|
|
220
|
+
que: "query",
|
|
221
|
+
quer: "query",
|
|
222
|
+
query: "query",
|
|
223
|
+
r: "r",
|
|
224
|
+
rb: "rb",
|
|
225
|
+
reb: "rebuild",
|
|
226
|
+
rebu: "rebuild",
|
|
227
|
+
rebui: "rebuild",
|
|
228
|
+
rebuil: "rebuild",
|
|
229
|
+
rebuild: "rebuild",
|
|
230
|
+
rem: "remove",
|
|
231
|
+
remo: "remove",
|
|
232
|
+
remov: "remove",
|
|
233
|
+
remove: "remove",
|
|
234
|
+
rep: "repo",
|
|
235
|
+
repo: "repo",
|
|
236
|
+
res: "restart",
|
|
237
|
+
rest: "restart",
|
|
238
|
+
resta: "restart",
|
|
239
|
+
restar: "restart",
|
|
240
|
+
restart: "restart",
|
|
241
|
+
rm: "rm",
|
|
242
|
+
ro: "root",
|
|
243
|
+
roo: "root",
|
|
244
|
+
root: "root",
|
|
245
|
+
rum: "rum",
|
|
246
|
+
run: "run",
|
|
247
|
+
"run-": "run-script",
|
|
248
|
+
"run-s": "run-script",
|
|
249
|
+
"run-sc": "run-script",
|
|
250
|
+
"run-scr": "run-script",
|
|
251
|
+
"run-scri": "run-script",
|
|
252
|
+
"run-scrip": "run-script",
|
|
253
|
+
"run-script": "run-script",
|
|
254
|
+
s: "s",
|
|
255
|
+
sb: "sbom",
|
|
256
|
+
sbo: "sbom",
|
|
257
|
+
sbom: "sbom",
|
|
258
|
+
se: "se",
|
|
259
|
+
sea: "search",
|
|
260
|
+
sear: "search",
|
|
261
|
+
searc: "search",
|
|
262
|
+
search: "search",
|
|
263
|
+
set: "set",
|
|
264
|
+
sho: "show",
|
|
265
|
+
show: "show",
|
|
266
|
+
shr: "shrinkwrap",
|
|
267
|
+
shri: "shrinkwrap",
|
|
268
|
+
shrin: "shrinkwrap",
|
|
269
|
+
shrink: "shrinkwrap",
|
|
270
|
+
shrinkw: "shrinkwrap",
|
|
271
|
+
shrinkwr: "shrinkwrap",
|
|
272
|
+
shrinkwra: "shrinkwrap",
|
|
273
|
+
shrinkwrap: "shrinkwrap",
|
|
274
|
+
si: "sit",
|
|
275
|
+
sit: "sit",
|
|
276
|
+
star: "star",
|
|
277
|
+
stars: "stars",
|
|
278
|
+
start: "start",
|
|
279
|
+
sto: "stop",
|
|
280
|
+
stop: "stop",
|
|
281
|
+
t: "t",
|
|
282
|
+
tea: "team",
|
|
283
|
+
team: "team",
|
|
284
|
+
tes: "test",
|
|
285
|
+
test: "test",
|
|
286
|
+
to: "token",
|
|
287
|
+
tok: "token",
|
|
288
|
+
toke: "token",
|
|
289
|
+
token: "token",
|
|
290
|
+
ts: "tst",
|
|
291
|
+
tst: "tst",
|
|
292
|
+
ud: "udpate",
|
|
293
|
+
udp: "udpate",
|
|
294
|
+
udpa: "udpate",
|
|
295
|
+
udpat: "udpate",
|
|
296
|
+
udpate: "udpate",
|
|
297
|
+
un: "un",
|
|
298
|
+
und: "undeprecate",
|
|
299
|
+
unde: "undeprecate",
|
|
300
|
+
undep: "undeprecate",
|
|
301
|
+
undepr: "undeprecate",
|
|
302
|
+
undepre: "undeprecate",
|
|
303
|
+
undeprec: "undeprecate",
|
|
304
|
+
undepreca: "undeprecate",
|
|
305
|
+
undeprecat: "undeprecate",
|
|
306
|
+
undeprecate: "undeprecate",
|
|
307
|
+
uni: "uninstall",
|
|
308
|
+
unin: "uninstall",
|
|
309
|
+
unins: "uninstall",
|
|
310
|
+
uninst: "uninstall",
|
|
311
|
+
uninsta: "uninstall",
|
|
312
|
+
uninstal: "uninstall",
|
|
313
|
+
uninstall: "uninstall",
|
|
314
|
+
unl: "unlink",
|
|
315
|
+
unli: "unlink",
|
|
316
|
+
unlin: "unlink",
|
|
317
|
+
unlink: "unlink",
|
|
318
|
+
unp: "unpublish",
|
|
319
|
+
unpu: "unpublish",
|
|
320
|
+
unpub: "unpublish",
|
|
321
|
+
unpubl: "unpublish",
|
|
322
|
+
unpubli: "unpublish",
|
|
323
|
+
unpublis: "unpublish",
|
|
324
|
+
unpublish: "unpublish",
|
|
325
|
+
uns: "unstar",
|
|
326
|
+
unst: "unstar",
|
|
327
|
+
unsta: "unstar",
|
|
328
|
+
unstar: "unstar",
|
|
329
|
+
up: "up",
|
|
330
|
+
upd: "update",
|
|
331
|
+
upda: "update",
|
|
332
|
+
updat: "update",
|
|
333
|
+
update: "update",
|
|
334
|
+
upg: "upgrade",
|
|
335
|
+
upgr: "upgrade",
|
|
336
|
+
upgra: "upgrade",
|
|
337
|
+
upgrad: "upgrade",
|
|
338
|
+
upgrade: "upgrade",
|
|
339
|
+
ur: "urn",
|
|
340
|
+
urn: "urn",
|
|
341
|
+
v: "v",
|
|
342
|
+
veri: "verison",
|
|
343
|
+
veris: "verison",
|
|
344
|
+
veriso: "verison",
|
|
345
|
+
verison: "verison",
|
|
346
|
+
vers: "version",
|
|
347
|
+
versi: "version",
|
|
348
|
+
versio: "version",
|
|
349
|
+
version: "version",
|
|
350
|
+
vi: "view",
|
|
351
|
+
vie: "view",
|
|
352
|
+
view: "view",
|
|
353
|
+
who: "whoami",
|
|
354
|
+
whoa: "whoami",
|
|
355
|
+
whoam: "whoami",
|
|
356
|
+
whoami: "whoami",
|
|
357
|
+
why: "why",
|
|
358
|
+
x: "x",
|
|
359
|
+
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
// Based on https://github.com/npm/cli/blob/latest/lib/utils/cmd-list.js
|
|
2
|
+
|
|
3
|
+
import { abbrevs } from "./abbrevs-generated.js";
|
|
4
|
+
|
|
5
|
+
const commands = [
|
|
6
|
+
"access",
|
|
7
|
+
"adduser",
|
|
8
|
+
"audit",
|
|
9
|
+
"bugs",
|
|
10
|
+
"cache",
|
|
11
|
+
"ci",
|
|
12
|
+
"completion",
|
|
13
|
+
"config",
|
|
14
|
+
"dedupe",
|
|
15
|
+
"deprecate",
|
|
16
|
+
"diff",
|
|
17
|
+
"dist-tag",
|
|
18
|
+
"docs",
|
|
19
|
+
"doctor",
|
|
20
|
+
"edit",
|
|
21
|
+
"exec",
|
|
22
|
+
"explain",
|
|
23
|
+
"explore",
|
|
24
|
+
"find-dupes",
|
|
25
|
+
"fund",
|
|
26
|
+
"get",
|
|
27
|
+
"help",
|
|
28
|
+
"help-search",
|
|
29
|
+
"init",
|
|
30
|
+
"install",
|
|
31
|
+
"install-ci-test",
|
|
32
|
+
"install-test",
|
|
33
|
+
"link",
|
|
34
|
+
"ll",
|
|
35
|
+
"login",
|
|
36
|
+
"logout",
|
|
37
|
+
"ls",
|
|
38
|
+
"org",
|
|
39
|
+
"outdated",
|
|
40
|
+
"owner",
|
|
41
|
+
"pack",
|
|
42
|
+
"ping",
|
|
43
|
+
"pkg",
|
|
44
|
+
"prefix",
|
|
45
|
+
"profile",
|
|
46
|
+
"prune",
|
|
47
|
+
"publish",
|
|
48
|
+
"query",
|
|
49
|
+
"rebuild",
|
|
50
|
+
"repo",
|
|
51
|
+
"restart",
|
|
52
|
+
"root",
|
|
53
|
+
"run",
|
|
54
|
+
"sbom",
|
|
55
|
+
"search",
|
|
56
|
+
"set",
|
|
57
|
+
"shrinkwrap",
|
|
58
|
+
"star",
|
|
59
|
+
"stars",
|
|
60
|
+
"start",
|
|
61
|
+
"stop",
|
|
62
|
+
"team",
|
|
63
|
+
"test",
|
|
64
|
+
"token",
|
|
65
|
+
"undeprecate",
|
|
66
|
+
"uninstall",
|
|
67
|
+
"unpublish",
|
|
68
|
+
"unstar",
|
|
69
|
+
"update",
|
|
70
|
+
"version",
|
|
71
|
+
"view",
|
|
72
|
+
"whoami",
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
// These must resolve to an entry in commands
|
|
76
|
+
/** @type {Record<string, string>} */
|
|
77
|
+
const aliases = {
|
|
78
|
+
// aliases
|
|
79
|
+
author: "owner",
|
|
80
|
+
home: "docs",
|
|
81
|
+
issues: "bugs",
|
|
82
|
+
info: "view",
|
|
83
|
+
show: "view",
|
|
84
|
+
find: "search",
|
|
85
|
+
add: "install",
|
|
86
|
+
unlink: "uninstall",
|
|
87
|
+
remove: "uninstall",
|
|
88
|
+
rm: "uninstall",
|
|
89
|
+
r: "uninstall",
|
|
90
|
+
|
|
91
|
+
// short names for common things
|
|
92
|
+
un: "uninstall",
|
|
93
|
+
rb: "rebuild",
|
|
94
|
+
list: "ls",
|
|
95
|
+
ln: "link",
|
|
96
|
+
create: "init",
|
|
97
|
+
i: "install",
|
|
98
|
+
it: "install-test",
|
|
99
|
+
cit: "install-ci-test",
|
|
100
|
+
up: "update",
|
|
101
|
+
c: "config",
|
|
102
|
+
s: "search",
|
|
103
|
+
se: "search",
|
|
104
|
+
tst: "test",
|
|
105
|
+
t: "test",
|
|
106
|
+
ddp: "dedupe",
|
|
107
|
+
v: "view",
|
|
108
|
+
"run-script": "run",
|
|
109
|
+
"clean-install": "ci",
|
|
110
|
+
"clean-install-test": "install-ci-test",
|
|
111
|
+
x: "exec",
|
|
112
|
+
why: "explain",
|
|
113
|
+
la: "ll",
|
|
114
|
+
verison: "version",
|
|
115
|
+
ic: "ci",
|
|
116
|
+
|
|
117
|
+
// typos
|
|
118
|
+
innit: "init",
|
|
119
|
+
// manually abbrev so that install-test doesn't make insta stop working
|
|
120
|
+
in: "install",
|
|
121
|
+
ins: "install",
|
|
122
|
+
inst: "install",
|
|
123
|
+
insta: "install",
|
|
124
|
+
instal: "install",
|
|
125
|
+
isnt: "install",
|
|
126
|
+
isnta: "install",
|
|
127
|
+
isntal: "install",
|
|
128
|
+
isntall: "install",
|
|
129
|
+
"install-clean": "ci",
|
|
130
|
+
"isntall-clean": "ci",
|
|
131
|
+
hlep: "help",
|
|
132
|
+
"dist-tags": "dist-tag",
|
|
133
|
+
upgrade: "update",
|
|
134
|
+
udpate: "update",
|
|
135
|
+
rum: "run",
|
|
136
|
+
sit: "install-ci-test",
|
|
137
|
+
urn: "run",
|
|
138
|
+
ogr: "org",
|
|
139
|
+
"add-user": "adduser",
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} c
|
|
144
|
+
* @returns {string | undefined}
|
|
145
|
+
*/
|
|
146
|
+
export function deref(c) {
|
|
147
|
+
if (!c) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Translate camelCase to snake-case (i.e. installTest to install-test)
|
|
152
|
+
if (c.match(/[A-Z]/)) {
|
|
153
|
+
c = c.replace(/([A-Z])/g, (m) => "-" + m.toLowerCase());
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// if they asked for something exactly we are done
|
|
157
|
+
if (commands.includes(c)) {
|
|
158
|
+
return c;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// if they asked for a direct alias
|
|
162
|
+
if (aliases[c]) {
|
|
163
|
+
return aliases[c];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// first deref the abbrev, if there is one
|
|
167
|
+
// then resolve any aliases
|
|
168
|
+
// so `npm install-cl` will resolve to `install-clean` then to `ci`
|
|
169
|
+
let a = abbrevs[c];
|
|
170
|
+
while (aliases[a]) {
|
|
171
|
+
a = aliases[a];
|
|
172
|
+
}
|
|
173
|
+
return a;
|
|
174
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { deref } from "./cmd-list.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string[]} args
|
|
5
|
+
* @returns {string | null}
|
|
6
|
+
*/
|
|
7
|
+
export function getNpmCommandForArgs(args) {
|
|
8
|
+
if (args.length === 0) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const argCommand = deref(args[0]);
|
|
13
|
+
if (!argCommand) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return argCommand;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string[]} args
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export function hasDryRunArg(args) {
|
|
25
|
+
return args.some((arg) => arg === "--dry-run");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const npmInstallCommand = "install";
|
|
29
|
+
export const npmCiCommand = "ci";
|
|
30
|
+
export const npmInstallTestCommand = "install-test";
|
|
31
|
+
export const npmInstallCiTestCommand = "install-ci-test";
|
|
32
|
+
export const npmUpdateCommand = "update";
|
|
33
|
+
export const npmAuditCommand = "audit";
|
|
34
|
+
export const npmExecCommand = "exec";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { commandArgumentScanner } from "./dependencyScanner/commandArgumentScanner.js";
|
|
2
|
+
import { runNpx } from "./runNpxCommand.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @returns {import("../currentPackageManager.js").PackageManager}
|
|
6
|
+
*/
|
|
7
|
+
export function createNpxPackageManager() {
|
|
8
|
+
const scanner = commandArgumentScanner();
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
runCommand: runNpx,
|
|
12
|
+
isSupportedCommand: (args) => scanner.shouldScan(args),
|
|
13
|
+
getDependencyUpdatesForCommand: (args) => scanner.scan(args),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolvePackageVersion } from "../../../api/npmApi.js";
|
|
2
|
+
import { parsePackagesFromArguments } from "../parsing/parsePackagesFromArguments.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @returns {import("../../npm/dependencyScanner/commandArgumentScanner.js").CommandArgumentScanner}
|
|
6
|
+
*/
|
|
7
|
+
export function commandArgumentScanner() {
|
|
8
|
+
return {
|
|
9
|
+
scan: (args) => scanDependencies(args),
|
|
10
|
+
shouldScan: () => true, // all npx commands need to be scanned, npx doesn't have dry-run
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {string[]} args
|
|
16
|
+
* @returns {Promise<import("../../npm/dependencyScanner/commandArgumentScanner.js").ScanResult[]>}
|
|
17
|
+
*/
|
|
18
|
+
function scanDependencies(args) {
|
|
19
|
+
return checkChangesFromArgs(args);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {string[]} args
|
|
24
|
+
* @returns {Promise<import("../../npm/dependencyScanner/commandArgumentScanner.js").ScanResult[]>}
|
|
25
|
+
*/
|
|
26
|
+
export async function checkChangesFromArgs(args) {
|
|
27
|
+
const changes = [];
|
|
28
|
+
const packageUpdates = parsePackagesFromArguments(args);
|
|
29
|
+
|
|
30
|
+
for (const packageUpdate of packageUpdates) {
|
|
31
|
+
var exactVersion = await resolvePackageVersion(
|
|
32
|
+
packageUpdate.name,
|
|
33
|
+
packageUpdate.version
|
|
34
|
+
);
|
|
35
|
+
if (exactVersion) {
|
|
36
|
+
packageUpdate.version = exactVersion;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
changes.push({ ...packageUpdate, type: "add" });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return changes;
|
|
43
|
+
}
|