@vltpkg/cli-sdk 0.0.0-2 → 0.0.0-21
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/README.md +3 -0
- package/dist/esm/commands/cache.d.ts +65 -0
- package/dist/esm/commands/cache.d.ts.map +1 -0
- package/dist/esm/commands/cache.js +257 -0
- package/dist/esm/commands/cache.js.map +1 -0
- package/dist/esm/commands/ci.d.ts +10 -0
- package/dist/esm/commands/ci.d.ts.map +1 -0
- package/dist/esm/commands/ci.js +29 -0
- package/dist/esm/commands/ci.js.map +1 -0
- package/dist/esm/commands/config.d.ts.map +1 -1
- package/dist/esm/commands/config.js +2 -52
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/exec-cache.d.ts +49 -0
- package/dist/esm/commands/exec-cache.d.ts.map +1 -0
- package/dist/esm/commands/exec-cache.js +134 -0
- package/dist/esm/commands/exec-cache.js.map +1 -0
- package/dist/esm/commands/exec-local.d.ts +6 -0
- package/dist/esm/commands/exec-local.d.ts.map +1 -0
- package/dist/esm/commands/exec-local.js +24 -0
- package/dist/esm/commands/exec-local.js.map +1 -0
- package/dist/esm/commands/exec.d.ts +4 -0
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +69 -10
- package/dist/esm/commands/exec.js.map +1 -1
- package/dist/esm/commands/gui.d.ts.map +1 -1
- package/dist/esm/commands/gui.js +1 -2
- package/dist/esm/commands/gui.js.map +1 -1
- package/dist/esm/commands/help.d.ts +1 -1
- package/dist/esm/commands/help.d.ts.map +1 -1
- package/dist/esm/commands/help.js +25 -3
- package/dist/esm/commands/help.js.map +1 -1
- package/dist/esm/commands/init.d.ts +4 -5
- package/dist/esm/commands/init.d.ts.map +1 -1
- package/dist/esm/commands/init.js +95 -9
- package/dist/esm/commands/init.js.map +1 -1
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +2 -1
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +5 -2
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +7 -1
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/list.d.ts +2 -2
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +108 -31
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pack.d.ts +20 -0
- package/dist/esm/commands/pack.d.ts.map +1 -0
- package/dist/esm/commands/pack.js +81 -0
- package/dist/esm/commands/pack.js.map +1 -0
- package/dist/esm/commands/pkg.d.ts +2 -3
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js +136 -34
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/publish.d.ts +21 -0
- package/dist/esm/commands/publish.d.ts.map +1 -0
- package/dist/esm/commands/publish.js +169 -0
- package/dist/esm/commands/publish.js.map +1 -0
- package/dist/esm/commands/query.d.ts +2 -2
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +134 -21
- package/dist/esm/commands/query.js.map +1 -1
- package/dist/esm/commands/run-exec.d.ts +1 -0
- package/dist/esm/commands/run-exec.d.ts.map +1 -1
- package/dist/esm/commands/run-exec.js +1 -0
- package/dist/esm/commands/run-exec.js.map +1 -1
- package/dist/esm/commands/run.d.ts +1 -0
- package/dist/esm/commands/run.d.ts.map +1 -1
- package/dist/esm/commands/run.js +13 -16
- package/dist/esm/commands/run.js.map +1 -1
- package/dist/esm/commands/uninstall.d.ts +7 -1
- package/dist/esm/commands/uninstall.d.ts.map +1 -1
- package/dist/esm/commands/uninstall.js +7 -1
- package/dist/esm/commands/uninstall.js.map +1 -1
- package/dist/esm/commands/update.d.ts +10 -0
- package/dist/esm/commands/update.d.ts.map +1 -0
- package/dist/esm/commands/update.js +25 -0
- package/dist/esm/commands/update.js.map +1 -0
- package/dist/esm/commands/version.d.ts +22 -0
- package/dist/esm/commands/version.d.ts.map +1 -0
- package/dist/esm/commands/version.js +151 -0
- package/dist/esm/commands/version.js.map +1 -0
- package/dist/esm/commands/whoami.d.ts +4 -2
- package/dist/esm/commands/whoami.d.ts.map +1 -1
- package/dist/esm/commands/whoami.js +1 -1
- package/dist/esm/commands/whoami.js.map +1 -1
- package/dist/esm/config/definition.d.ts +85 -7
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +152 -23
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/config/index.d.ts +46 -40
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +124 -176
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/config/merge.d.ts +3 -1
- package/dist/esm/config/merge.d.ts.map +1 -1
- package/dist/esm/config/merge.js +11 -6
- package/dist/esm/config/merge.js.map +1 -1
- package/dist/esm/config/usage.d.ts +3 -2
- package/dist/esm/config/usage.d.ts.map +1 -1
- package/dist/esm/config/usage.js.map +1 -1
- package/dist/esm/exec-command.d.ts +32 -14
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +195 -63
- package/dist/esm/exec-command.js.map +1 -1
- package/dist/esm/index.d.ts +1 -14
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +46 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/load-command.d.ts +16 -0
- package/dist/esm/load-command.d.ts.map +1 -0
- package/dist/esm/load-command.js +21 -0
- package/dist/esm/load-command.js.map +1 -0
- package/dist/esm/output.d.ts +6 -10
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +62 -32
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/pack-tarball.d.ts +22 -0
- package/dist/esm/pack-tarball.d.ts.map +1 -0
- package/dist/esm/pack-tarball.js +247 -0
- package/dist/esm/pack-tarball.js.map +1 -0
- package/dist/esm/parse-add-remove-args.d.ts +1 -1
- package/dist/esm/parse-add-remove-args.d.ts.map +1 -1
- package/dist/esm/parse-add-remove-args.js +1 -1
- package/dist/esm/parse-add-remove-args.js.map +1 -1
- package/dist/esm/print-err.d.ts +12 -1
- package/dist/esm/print-err.d.ts.map +1 -1
- package/dist/esm/print-err.js +157 -26
- package/dist/esm/print-err.js.map +1 -1
- package/dist/esm/start-gui.d.ts +7 -33
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +33 -347
- package/dist/esm/start-gui.js.map +1 -1
- package/dist/esm/view.d.ts +2 -3
- package/dist/esm/view.d.ts.map +1 -1
- package/dist/esm/view.js.map +1 -1
- package/package.json +69 -44
- package/dist/esm/commands/install-exec.d.ts +0 -4
- package/dist/esm/commands/install-exec.d.ts.map +0 -1
- package/dist/esm/commands/install-exec.js +0 -13
- package/dist/esm/commands/install-exec.js.map +0 -1
- package/dist/esm/ignored-homedir-folder-names.d.ts +0 -7
- package/dist/esm/ignored-homedir-folder-names.d.ts.map +0 -1
- package/dist/esm/ignored-homedir-folder-names.js +0 -35
- package/dist/esm/ignored-homedir-folder-names.js.map +0 -1
- package/dist/esm/project-info.d.ts +0 -32
- package/dist/esm/project-info.d.ts.map +0 -1
- package/dist/esm/project-info.js +0 -90
- package/dist/esm/project-info.js.map +0 -1
- package/dist/esm/read-project-folders.d.ts +0 -27
- package/dist/esm/read-project-folders.d.ts.map +0 -1
- package/dist/esm/read-project-folders.js +0 -66
- package/dist/esm/read-project-folders.js.map +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
3
|
+
import * as vlx from '@vltpkg/vlx';
|
|
4
|
+
import { basename } from 'node:path';
|
|
5
|
+
import { commandUsage } from "../config/usage.js";
|
|
6
|
+
import { stdout } from "../output.js";
|
|
7
|
+
import { ViewClass } from "../view.js";
|
|
8
|
+
let view;
|
|
9
|
+
export class ExecCacheView extends ViewClass {
|
|
10
|
+
constructor(options, conf) {
|
|
11
|
+
super(options, conf);
|
|
12
|
+
view = this;
|
|
13
|
+
}
|
|
14
|
+
stdout(...args) {
|
|
15
|
+
stdout(...args);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const views = {
|
|
19
|
+
human: ExecCacheView,
|
|
20
|
+
};
|
|
21
|
+
const usageDef = {
|
|
22
|
+
command: 'exec-cache',
|
|
23
|
+
usage: '<command> [flags]',
|
|
24
|
+
description: 'Work with vlt exec-cache folders',
|
|
25
|
+
subcommands: {
|
|
26
|
+
ls: {
|
|
27
|
+
usage: '',
|
|
28
|
+
description: `Show previously installed packages used for \`vlt exec\`.
|
|
29
|
+
Key provided can be either the package name, or the full
|
|
30
|
+
key.`,
|
|
31
|
+
},
|
|
32
|
+
delete: {
|
|
33
|
+
usage: '[<key>...]',
|
|
34
|
+
description: `Delete previously installed packages used for
|
|
35
|
+
\`vlt exec\`. If no keys are provided, then all entries
|
|
36
|
+
will be deleted.`,
|
|
37
|
+
},
|
|
38
|
+
info: {
|
|
39
|
+
usage: '<key>',
|
|
40
|
+
description: `Show extended information about a given \`vlt exec\`
|
|
41
|
+
installation.`,
|
|
42
|
+
},
|
|
43
|
+
install: {
|
|
44
|
+
usage: '<spec>...',
|
|
45
|
+
description: `Install the specified package(s) in the \`vlt exec\`
|
|
46
|
+
central cache location. Metadata info about each
|
|
47
|
+
installation will be printed.`,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
examples: {
|
|
51
|
+
ls: {
|
|
52
|
+
description: `Show all the keys for the installations in the \`vlt exec\`
|
|
53
|
+
cache.`,
|
|
54
|
+
},
|
|
55
|
+
'delete typescript': {
|
|
56
|
+
description: `Delete all versions of typescript installed for vlt exec`,
|
|
57
|
+
},
|
|
58
|
+
'info typescript-695bf962': {
|
|
59
|
+
description: `Show extended info about a specific version of typescript`,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const usage = () => commandUsage(usageDef);
|
|
64
|
+
export const command = async (conf) => {
|
|
65
|
+
const [sub, ...args] = conf.positionals;
|
|
66
|
+
switch (sub) {
|
|
67
|
+
case 'ls':
|
|
68
|
+
return ls(conf, args, view);
|
|
69
|
+
case 'info':
|
|
70
|
+
return info(conf, args, view);
|
|
71
|
+
case 'install':
|
|
72
|
+
return install(conf, args, view);
|
|
73
|
+
case 'delete':
|
|
74
|
+
return deleteEntries(conf, args, view);
|
|
75
|
+
default: {
|
|
76
|
+
throw error('Unrecognized exec-cache command', {
|
|
77
|
+
code: 'EUSAGE',
|
|
78
|
+
found: sub,
|
|
79
|
+
validOptions: Object.keys(usageDef.subcommands),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const install = async (conf, keys, view) => {
|
|
85
|
+
if (!keys.length) {
|
|
86
|
+
throw error('Must supply a package spec to install', {
|
|
87
|
+
code: 'EUSAGE',
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return Promise.all(keys.map(async (key) => {
|
|
91
|
+
const info = await vlx.install(key, {
|
|
92
|
+
...conf.options,
|
|
93
|
+
query: undefined,
|
|
94
|
+
});
|
|
95
|
+
view?.stdout(info);
|
|
96
|
+
return info.path;
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
const ls = async (_conf, args, view) => {
|
|
100
|
+
const results = [];
|
|
101
|
+
for await (const path of vlx.list()) {
|
|
102
|
+
const key = basename(path);
|
|
103
|
+
if (args.length && !args.some(a => key.includes(a)))
|
|
104
|
+
continue;
|
|
105
|
+
results.push(key);
|
|
106
|
+
view?.stdout(key);
|
|
107
|
+
}
|
|
108
|
+
return results;
|
|
109
|
+
};
|
|
110
|
+
const info = async (conf, keys, view) => {
|
|
111
|
+
const results = [];
|
|
112
|
+
for await (const key of keys.length ? keys : vlx.list()) {
|
|
113
|
+
const info = vlx.info(key, {
|
|
114
|
+
...conf.options,
|
|
115
|
+
query: undefined,
|
|
116
|
+
});
|
|
117
|
+
results.push(info);
|
|
118
|
+
view?.stdout(info);
|
|
119
|
+
}
|
|
120
|
+
return results;
|
|
121
|
+
};
|
|
122
|
+
const deleteEntries = async (conf, keys, view) => {
|
|
123
|
+
const remover = new RollbackRemove();
|
|
124
|
+
const removed = (await vlx.delete(keys, remover, {
|
|
125
|
+
...conf.options,
|
|
126
|
+
query: undefined,
|
|
127
|
+
})).map(path => {
|
|
128
|
+
view?.stdout(`- ${basename(path)}`);
|
|
129
|
+
return path;
|
|
130
|
+
});
|
|
131
|
+
remover.confirm();
|
|
132
|
+
return removed;
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=exec-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-cache.js","sourceRoot":"","sources":["../../../src/commands/exec-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAKtC,IAAI,IAAmB,CAAA;AACvB,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YAAY,OAAoB,EAAE,IAAkB;QAClD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpB,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAe;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAuC;IACvD,KAAK,EAAE,aAAa;CACrB,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,YAAY;IAC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ACnB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,KAAK,EAChB,IAAkB,EAClB,IAAc,EACd,IAAoB,EACA,EAAE;IACtB,MAAM,OAAO,GAAc,EAAE,CAAA;IAC7B,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QACxD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE;YACzB,GAAG,IAAI,CAAC,OAAO;YACf,KAAK,EAAE,SAAS;SACjB,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,KAAK,EACzB,IAAkB,EAClB,IAAc,EACd,IAAoB,EACD,EAAE;IACrB,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAA;IACpC,MAAM,OAAO,GAAG,CACd,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE;QAC9B,GAAG,IAAI,CAAC,OAAO;QACf,KAAK,EAAE,SAAS;KACjB,CAAC,CACH,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,OAAO,EAAE,CAAA;IACjB,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { VlxInfo } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { basename } from 'node:path'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type ExecCacheSubcommands =\n keyof (typeof usageDef)['subcommands']\n\nlet view: ExecCacheView\nexport class ExecCacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | string[] | VlxInfo[]> = {\n human: ExecCacheView,\n}\n\nconst usageDef = {\n command: 'exec-cache',\n usage: '<command> [flags]',\n description: 'Work with vlt exec-cache folders',\n\n subcommands: {\n ls: {\n usage: '',\n description: `Show previously installed packages used for \\`vlt exec\\`.\n Key provided can be either the package name, or the full\n key.`,\n },\n\n delete: {\n usage: '[<key>...]',\n description: `Delete previously installed packages used for\n \\`vlt exec\\`. If no keys are provided, then all entries\n will be deleted.`,\n },\n\n info: {\n usage: '<key>',\n description: `Show extended information about a given \\`vlt exec\\`\n installation.`,\n },\n\n install: {\n usage: '<spec>...',\n description: `Install the specified package(s) in the \\`vlt exec\\`\n central cache location. Metadata info about each\n installation will be printed.`,\n },\n },\n\n examples: {\n ls: {\n description: `Show all the keys for the installations in the \\`vlt exec\\`\n cache.`,\n },\n 'delete typescript': {\n description: `Delete all versions of typescript installed for vlt exec`,\n },\n 'info typescript-695bf962': {\n description: `Show extended info about a specific version of typescript`,\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<\n string[] | VlxInfo[]\n> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'info':\n return info(conf, args, view)\n\n case 'install':\n return install(conf, args, view)\n\n case 'delete':\n return deleteEntries(conf, args, view)\n\n default: {\n throw error('Unrecognized exec-cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: Object.keys(usageDef.subcommands),\n })\n }\n }\n}\n\nconst install = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n if (!keys.length) {\n throw error('Must supply a package spec to install', {\n code: 'EUSAGE',\n })\n }\n return Promise.all(\n keys.map(async key => {\n const info = await vlx.install(key, {\n ...conf.options,\n query: undefined,\n })\n view?.stdout(info)\n return info.path\n }),\n )\n}\n\nconst ls = async (\n _conf: LoadedConfig,\n args: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const results: string[] = []\n for await (const path of vlx.list()) {\n const key = basename(path)\n if (args.length && !args.some(a => key.includes(a))) continue\n results.push(key)\n view?.stdout(key)\n }\n return results\n}\n\nconst info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<VlxInfo[]> => {\n const results: VlxInfo[] = []\n for await (const key of keys.length ? keys : vlx.list()) {\n const info = vlx.info(key, {\n ...conf.options,\n query: undefined,\n })\n results.push(info)\n view?.stdout(info)\n }\n return results\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const remover = new RollbackRemove()\n const removed = (\n await vlx.delete(keys, remover, {\n ...conf.options,\n query: undefined,\n })\n ).map(path => {\n view?.stdout(`- ${basename(path)}`)\n return path\n })\n remover.confirm()\n return removed\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecResult } from '../exec-command.ts';
|
|
2
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
+
export { views } from '../exec-command.ts';
|
|
4
|
+
export declare const usage: CommandUsage;
|
|
5
|
+
export declare const command: CommandFn<ExecResult>;
|
|
6
|
+
//# sourceMappingURL=exec-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-local.d.ts","sourceRoot":"","sources":["../../../src/commands/exec-local.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAehB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAGzC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { exec, execFG } from '@vltpkg/run';
|
|
2
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
import { ExecCommand } from "../exec-command.js";
|
|
4
|
+
export { views } from "../exec-command.js";
|
|
5
|
+
export const usage = () => commandUsage({
|
|
6
|
+
command: 'exec-local',
|
|
7
|
+
usage: '[command]',
|
|
8
|
+
description: `Run an arbitrary command, with the local installed packages
|
|
9
|
+
first in the PATH. Ie, this will run your locally installed
|
|
10
|
+
package bins.
|
|
11
|
+
|
|
12
|
+
If no command is provided, then a shell is spawned in the
|
|
13
|
+
current working directory, with the locally installed package
|
|
14
|
+
bins first in the PATH.
|
|
15
|
+
|
|
16
|
+
Note that any vlt configs must be specified *before* the
|
|
17
|
+
command, as the remainder of the command line options are
|
|
18
|
+
provided to the exec process.`,
|
|
19
|
+
});
|
|
20
|
+
export const command = async (conf) => {
|
|
21
|
+
delete conf.options['script-shell'];
|
|
22
|
+
return await new ExecCommand(conf, exec, execFG).run();
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=exec-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-local.js","sourceRoot":"","sources":["../../../src/commands/exec-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE;;;;;;;;;;gDAU+B;CAC7C,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE;IACzD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,OAAO,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { exec, execFG } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec-local',\n usage: '[command]',\n description: `Run an arbitrary command, with the local installed packages\n first in the PATH. Ie, this will run your locally installed\n package bins.\n\n If no command is provided, then a shell is spawned in the\n current working directory, with the locally installed package\n bins first in the PATH.\n\n Note that any vlt configs must be specified *before* the\n command, as the remainder of the command line options are\n provided to the exec process.`,\n })\n\nexport const command: CommandFn<ExecResult> = async conf => {\n delete conf.options['script-shell']\n return await new ExecCommand(conf, exec, execFG).run()\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { PromptFn } from '@vltpkg/vlx';
|
|
1
2
|
import type { ExecResult } from '../exec-command.ts';
|
|
2
3
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
4
|
+
export { views } from '../exec-command.ts';
|
|
3
5
|
export declare const usage: CommandUsage;
|
|
6
|
+
export declare const prettyPath: (path: string) => string;
|
|
7
|
+
export declare const promptFn: PromptFn;
|
|
4
8
|
export declare const command: CommandFn<ExecResult>;
|
|
5
9
|
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAoDhB,CAAA;AAGJ,eAAO,MAAM,UAAU,SAAU,MAAM,WAC2B,CAAA;AAElE,eAAO,MAAM,QAAQ,EAAE,QAyBtB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAazC,CAAA"}
|
|
@@ -1,22 +1,81 @@
|
|
|
1
1
|
import { exec, execFG } from '@vltpkg/run';
|
|
2
|
+
import * as vlx from '@vltpkg/vlx';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { createInterface } from 'node:readline/promises';
|
|
2
5
|
import { commandUsage } from "../config/usage.js";
|
|
3
6
|
import { ExecCommand } from "../exec-command.js";
|
|
7
|
+
import { styleTextStdout } from "../output.js";
|
|
8
|
+
export { views } from "../exec-command.js";
|
|
4
9
|
export const usage = () => commandUsage({
|
|
5
10
|
command: 'exec',
|
|
6
|
-
usage: '[command]',
|
|
7
|
-
description: `Run
|
|
8
|
-
|
|
9
|
-
package bins.
|
|
11
|
+
usage: '[--package=<pkg>] [command...]',
|
|
12
|
+
description: `Run a command defined by a package, installing it
|
|
13
|
+
if necessary.
|
|
10
14
|
|
|
11
|
-
If
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
If the package specifier is provided explicitly via the
|
|
16
|
+
\`--package\` config, then that is what will be used. If
|
|
17
|
+
a satisfying instance of the named package exists in the
|
|
18
|
+
local \`node_mnodules\` folder, then that will be used.
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
If \`--package\` is not set, then vlt will attempt to infer
|
|
21
|
+
the package to be installed if necessary, in the following
|
|
22
|
+
manner:
|
|
23
|
+
|
|
24
|
+
- If the first argument is an executable found in the
|
|
25
|
+
\`node_modules/.bin\` folder (ie, provided by an
|
|
26
|
+
installed direct dependency), then that will be used.
|
|
27
|
+
The search stops, and nothing will be installed.
|
|
28
|
+
- Otherwise, vlt attempts to resolve the first argument
|
|
29
|
+
as if it was a \`--package\` option, and then swap it
|
|
30
|
+
out with the "default" executable provided by that
|
|
31
|
+
package.
|
|
32
|
+
|
|
33
|
+
The "default" executable provided by a package is:
|
|
34
|
+
|
|
35
|
+
- If the package provides a single executable string in the
|
|
36
|
+
\`bin\` field, then that is the executable to use.
|
|
37
|
+
- Otherwise, if there is a \`bin\` with the same name
|
|
38
|
+
as the package (or just the portion after the \`/\` in
|
|
39
|
+
the case of scoped packages), then that will be used.
|
|
40
|
+
|
|
41
|
+
If the appropriate excutable cannot be determined, then
|
|
42
|
+
an error will be raised.
|
|
43
|
+
|
|
44
|
+
At no point will \`vlt exec\` change the locally installed
|
|
45
|
+
dependencies. Any installs it performs is done in vlt's XDG
|
|
46
|
+
data directory.
|
|
47
|
+
`,
|
|
48
|
+
examples: {
|
|
49
|
+
'--package typescript@5 tsc': {
|
|
50
|
+
description: 'Run tsc provided by typescript version 5',
|
|
51
|
+
},
|
|
52
|
+
'eslint src/file.js': {
|
|
53
|
+
description: 'Run the default bin provided by eslint',
|
|
54
|
+
},
|
|
55
|
+
'eslint@9.24 src/file.js': {
|
|
56
|
+
description: 'Run the default bin provided by eslint version 9.24',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
18
59
|
});
|
|
60
|
+
const HOME = homedir();
|
|
61
|
+
export const prettyPath = (path) => path.startsWith(HOME) ? `~${path.substring(HOME.length)}` : path;
|
|
62
|
+
export const promptFn = async (pkgSpec, path, resolution) => {
|
|
63
|
+
const response = await createInterface(process.stdin, process.stdout).question(`About to install: ${styleTextStdout(['bgWhiteBright', 'black', 'bold'], String(pkgSpec))}
|
|
64
|
+
from: ${styleTextStdout(['bgWhiteBright', 'black', 'bold'], resolution)}
|
|
65
|
+
into: ${styleTextStdout(['bgWhiteBright', 'black', 'bold'], prettyPath(path))}
|
|
66
|
+
Is this ok? (y) `);
|
|
67
|
+
process.stdin.pause();
|
|
68
|
+
return response;
|
|
69
|
+
};
|
|
19
70
|
export const command = async (conf) => {
|
|
71
|
+
const arg0 = await vlx.resolve(conf.positionals, {
|
|
72
|
+
...conf.options,
|
|
73
|
+
query: undefined,
|
|
74
|
+
}, promptFn);
|
|
75
|
+
if (arg0)
|
|
76
|
+
conf.positionals[0] = arg0;
|
|
77
|
+
// now we have arg0! let's gooooo!!
|
|
78
|
+
delete conf.options['script-shell'];
|
|
20
79
|
return await new ExecCommand(conf, exec, execFG).run();
|
|
21
80
|
};
|
|
22
81
|
//# sourceMappingURL=exec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EA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AAU,CACX;QACG,eAAe,CACjB,CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,EAClC,UAAU,CAAC,IAAI,CAAC,CACjB;iBACY,CACd,CAAA;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACrB,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE;IACzD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAC5B,IAAI,CAAC,WAAW,EAChB;QACE,GAAG,IAAI,CAAC,OAAO;QACf,KAAK,EAAE,SAAS;KACjB,EACD,QAAQ,CACT,CAAA;IACD,IAAI,IAAI;QAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IACpC,mCAAmC;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,OAAO,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { exec, execFG } from '@vltpkg/run'\nimport type { PromptFn } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { homedir } from 'node:os'\nimport { createInterface } from 'node:readline/promises'\nimport { commandUsage } from '../config/usage.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { styleTextStdout } from '../output.ts'\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec',\n usage: '[--package=<pkg>] [command...]',\n description: `Run a command defined by a package, installing it\n if necessary.\n\n If the package specifier is provided explicitly via the\n \\`--package\\` config, then that is what will be used. If\n a satisfying instance of the named package exists in the\n local \\`node_mnodules\\` folder, then that will be used.\n\n If \\`--package\\` is not set, then vlt will attempt to infer\n the package to be installed if necessary, in the following\n manner:\n\n - If the first argument is an executable found in the\n \\`node_modules/.bin\\` folder (ie, provided by an\n installed direct dependency), then that will be used.\n The search stops, and nothing will be installed.\n - Otherwise, vlt attempts to resolve the first argument\n as if it was a \\`--package\\` option, and then swap it\n out with the \"default\" executable provided by that\n package.\n\n The \"default\" executable provided by a package is:\n\n - If the package provides a single executable string in the\n \\`bin\\` field, then that is the executable to use.\n - Otherwise, if there is a \\`bin\\` with the same name\n as the package (or just the portion after the \\`/\\` in\n the case of scoped packages), then that will be used.\n\n If the appropriate excutable cannot be determined, then\n an error will be raised.\n\n At no point will \\`vlt exec\\` change the locally installed\n dependencies. Any installs it performs is done in vlt's XDG\n data directory.\n `,\n examples: {\n '--package typescript@5 tsc': {\n description: 'Run tsc provided by typescript version 5',\n },\n 'eslint src/file.js': {\n description: 'Run the default bin provided by eslint',\n },\n 'eslint@9.24 src/file.js': {\n description:\n 'Run the default bin provided by eslint version 9.24',\n },\n },\n })\n\nconst HOME = homedir()\nexport const prettyPath = (path: string) =>\n path.startsWith(HOME) ? `~${path.substring(HOME.length)}` : path\n\nexport const promptFn: PromptFn = async (\n pkgSpec,\n path,\n resolution,\n) => {\n const response = await createInterface(\n process.stdin,\n process.stdout,\n ).question(\n `About to install: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n String(pkgSpec),\n )}\nfrom: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n resolution,\n )}\ninto: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n prettyPath(path),\n )}\nIs this ok? (y) `,\n )\n process.stdin.pause()\n return response\n}\n\nexport const command: CommandFn<ExecResult> = async conf => {\n const arg0 = await vlx.resolve(\n conf.positionals,\n {\n ...conf.options,\n query: undefined,\n },\n promptFn,\n )\n if (arg0) conf.positionals[0] = arg0\n // now we have arg0! let's gooooo!!\n delete conf.options['script-shell']\n return await new ExecCommand(conf, exec, execFG).run()\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gui.d.ts","sourceRoot":"","sources":["../../../src/commands/gui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGxC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"gui.d.ts","sourceRoot":"","sources":["../../../src/commands/gui.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAGxC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,IAAI,CAE9B,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAKhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAA4B,CAAA"}
|
package/dist/esm/commands/gui.js
CHANGED
|
@@ -2,8 +2,7 @@ import { commandUsage } from "../config/usage.js";
|
|
|
2
2
|
import { startGUI } from "../start-gui.js";
|
|
3
3
|
// this command is only a view, it doesn't actually do anything at this time
|
|
4
4
|
export const views = async (_, __, conf) => {
|
|
5
|
-
await startGUI(
|
|
6
|
-
return '';
|
|
5
|
+
await startGUI(conf);
|
|
7
6
|
};
|
|
8
7
|
export const usage = () => commandUsage({
|
|
9
8
|
command: 'gui',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gui.js","sourceRoot":"","sources":["../../../src/commands/gui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,KAAK,GAAiB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IACvD,MAAM,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"gui.js","sourceRoot":"","sources":["../../../src/commands/gui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,KAAK,GAAiB,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;IACvD,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;AACtB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,gDAAgD;CAC9D,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAc,KAAK,IAAI,EAAE,CAAC,IAAI,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { ViewFn } from '../view.ts'\n\n// this command is only a view, it doesn't actually do anything at this time\nexport const views: ViewFn<null> = async (_, __, conf) => {\n await startGUI(conf)\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'gui',\n usage: '',\n description: 'Launch a graphical user interface in a browser',\n })\n\nexport const command: CommandFn = async () => null\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIjE,eAAO,MAAM,KAAK,EAAE,YAWhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,MAAM,CAmBrC,CAAA"}
|
|
@@ -1,10 +1,32 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
1
2
|
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
import { loadCommand } from "../load-command.js";
|
|
4
|
+
import { getCommand } from "../config/definition.js";
|
|
2
5
|
export const usage = () => commandUsage({
|
|
3
6
|
command: 'help',
|
|
4
|
-
usage: '',
|
|
5
|
-
description: 'Print the full help output for the CLI',
|
|
7
|
+
usage: '[<command>]',
|
|
8
|
+
description: 'Print the full help output for the CLI, or help for a specific command',
|
|
9
|
+
examples: {
|
|
10
|
+
'': { description: 'Show general CLI help' },
|
|
11
|
+
install: { description: 'Show help for the install command' },
|
|
12
|
+
run: { description: 'Show help for the run command' },
|
|
13
|
+
},
|
|
6
14
|
});
|
|
7
15
|
export const command = async (conf) => {
|
|
8
|
-
|
|
16
|
+
// If no positional arguments, show general help
|
|
17
|
+
if (conf.positionals.length === 0) {
|
|
18
|
+
return conf.jack.usage();
|
|
19
|
+
}
|
|
20
|
+
// Get the command name from the first positional argument
|
|
21
|
+
const cmdName = conf.positionals[0];
|
|
22
|
+
const canonicalCmd = getCommand(cmdName);
|
|
23
|
+
if (!canonicalCmd) {
|
|
24
|
+
throw error(`Unknown command: ${cmdName}`, {
|
|
25
|
+
found: cmdName,
|
|
26
|
+
code: 'EUSAGE',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const command = await loadCommand(canonicalCmd);
|
|
30
|
+
return command.usage().usage();
|
|
9
31
|
};
|
|
10
32
|
//# sourceMappingURL=help.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/commands/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EA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CommandFn, CommandUsage } from '../load-command.ts'\nimport { loadCommand } from '../load-command.ts'\nimport { getCommand } from '../config/definition.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'help',\n usage: '[<command>]',\n description:\n 'Print the full help output for the CLI, or help for a specific command',\n examples: {\n '': { description: 'Show general CLI help' },\n install: { description: 'Show help for the install command' },\n run: { description: 'Show help for the run command' },\n },\n })\n\nexport const command: CommandFn<string> = async conf => {\n // If no positional arguments, show general help\n if (conf.positionals.length === 0) {\n return conf.jack.usage()\n }\n\n // Get the command name from the first positional argument\n const cmdName = conf.positionals[0]\n const canonicalCmd = getCommand(cmdName)\n\n if (!canonicalCmd) {\n throw error(`Unknown command: ${cmdName}`, {\n found: cmdName,\n code: 'EUSAGE',\n })\n }\n\n const command = await loadCommand(canonicalCmd)\n return command.usage().usage()\n}\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
1
|
import type { InitFileResults } from '@vltpkg/init';
|
|
3
|
-
import type {
|
|
2
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
4
3
|
export declare const usage: CommandUsage;
|
|
5
|
-
export declare const views:
|
|
6
|
-
human:
|
|
4
|
+
export declare const views: {
|
|
5
|
+
readonly human: (results: InitFileResults | InitFileResults[]) => string;
|
|
7
6
|
};
|
|
8
|
-
export declare const command: CommandFn<InitFileResults>;
|
|
7
|
+
export declare const command: CommandFn<InitFileResults | InitFileResults[]>;
|
|
9
8
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,eAAO,MAAM,KAAK,EAAE,YAKhB,CAAA;AAGJ,eAAO,MAAM,KAAK;8BACC,eAAe,GAAG,eAAe,EAAE;CAsBX,CAAA;AAE3C,eAAO,MAAM,OAAO,EAAE,SAAS,CAC7B,eAAe,GAAG,eAAe,EAAE,CAoFpC,CAAA"}
|
|
@@ -1,25 +1,111 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mkdirSync } from 'node:fs';
|
|
2
|
+
import { relative, resolve } from 'node:path';
|
|
3
|
+
import { minimatch } from 'minimatch';
|
|
2
4
|
import { init } from '@vltpkg/init';
|
|
5
|
+
import { load, save } from '@vltpkg/vlt-json';
|
|
6
|
+
import { assertWSConfig, asWSConfig } from '@vltpkg/workspaces';
|
|
7
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
8
|
export const usage = () => commandUsage({
|
|
4
9
|
command: 'init',
|
|
5
10
|
usage: '',
|
|
6
11
|
description: `Create a new package.json file in the current directory.`,
|
|
7
12
|
});
|
|
13
|
+
// TODO: colorize the JSON if config.options.color
|
|
8
14
|
export const views = {
|
|
9
|
-
human: (results
|
|
15
|
+
human: (results) => {
|
|
10
16
|
const output = [];
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
// if results is an array, it means multiple workspaces were initialized
|
|
18
|
+
if (Array.isArray(results)) {
|
|
19
|
+
for (const result of results) {
|
|
20
|
+
for (const [type, { path }] of Object.entries(result)) {
|
|
21
|
+
output.push(`Wrote ${type} to ${path}:`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// otherwise, it's a single result
|
|
27
|
+
for (const [type, { path, data }] of Object.entries(results)) {
|
|
28
|
+
output.push(`Wrote ${type} to ${path}:
|
|
14
29
|
|
|
15
|
-
${JSON.stringify(data, null, 2)}
|
|
16
|
-
|
|
30
|
+
${JSON.stringify(data, null, 2)}`);
|
|
31
|
+
}
|
|
17
32
|
}
|
|
18
|
-
output.push(
|
|
33
|
+
output.push(`\nModify/add properties using \`vlt pkg\`. For example:
|
|
19
34
|
|
|
20
35
|
vlt pkg set "description=My new project"`);
|
|
21
36
|
return output.join('\n');
|
|
22
37
|
},
|
|
23
38
|
};
|
|
24
|
-
export const command = async () =>
|
|
39
|
+
export const command = async (conf) => {
|
|
40
|
+
if (conf.values.workspace?.length) {
|
|
41
|
+
const workspacesConfig = load('workspaces', assertWSConfig);
|
|
42
|
+
const parsedWSConfig = asWSConfig(workspacesConfig ?? {});
|
|
43
|
+
const results = [];
|
|
44
|
+
const addToConfig = [];
|
|
45
|
+
// create a new package.json file for every workspace
|
|
46
|
+
// defined as cli --workspace options
|
|
47
|
+
for (const workspace of conf.values.workspace) {
|
|
48
|
+
// cwd is the resolved location of the workspace
|
|
49
|
+
const cwd = resolve(conf.options.projectRoot, workspace);
|
|
50
|
+
// create the folder in case it's missing
|
|
51
|
+
mkdirSync(cwd, { recursive: true });
|
|
52
|
+
// run the initialization script and collect results
|
|
53
|
+
results.push(await init({ cwd }));
|
|
54
|
+
// Check if this workspace path is covered by existing workspace patterns
|
|
55
|
+
const isMatched = Object.values(parsedWSConfig).some((patterns) => {
|
|
56
|
+
return patterns.some(pattern => minimatch(workspace, pattern));
|
|
57
|
+
});
|
|
58
|
+
// When a workspace is not matched we track it for insertion later
|
|
59
|
+
if (!isMatched) {
|
|
60
|
+
addToConfig.push(relative(conf.options.projectRoot, cwd).replace(/\\/g, '/'));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// if there are workspaces that were not matched by existing
|
|
64
|
+
// patterns, we add them to the workspaces config
|
|
65
|
+
if (addToConfig.length > 0) {
|
|
66
|
+
let workspaces = workspacesConfig;
|
|
67
|
+
// if the original workspaces config is a string, we'll need
|
|
68
|
+
// to convert it to an array in order to append the recently
|
|
69
|
+
// added workspaces
|
|
70
|
+
if (typeof workspacesConfig === 'string') {
|
|
71
|
+
workspaces = [workspacesConfig, ...addToConfig];
|
|
72
|
+
}
|
|
73
|
+
else if (Array.isArray(workspacesConfig)) {
|
|
74
|
+
// if the original workspaces config is an array, we simply
|
|
75
|
+
// append the missing items to it
|
|
76
|
+
workspaces = [...workspacesConfig, ...addToConfig];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// otherwise we assume it's an Record<string, string[]> object
|
|
80
|
+
// and we'll add the new workspaces to the `packages` keys
|
|
81
|
+
workspaces = (workspacesConfig ?? {});
|
|
82
|
+
// if the `packages` key is not being used
|
|
83
|
+
if (!workspaces.packages) {
|
|
84
|
+
workspaces.packages = addToConfig;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// if the `packages` key is defined as a string, we
|
|
88
|
+
// convert it to an array to append the new items
|
|
89
|
+
if (typeof workspaces.packages === 'string') {
|
|
90
|
+
workspaces.packages = [
|
|
91
|
+
workspaces.packages,
|
|
92
|
+
...addToConfig,
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// if it is, we simply append the new workspaces
|
|
97
|
+
workspaces.packages = [
|
|
98
|
+
...workspaces.packages,
|
|
99
|
+
...addToConfig,
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// finally, we add the new workspaces to the config file
|
|
105
|
+
save('workspaces', workspaces);
|
|
106
|
+
}
|
|
107
|
+
return results;
|
|
108
|
+
}
|
|
109
|
+
return init({ cwd: process.cwd() });
|
|
110
|
+
};
|
|
25
111
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,QAAQ,E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YACxD,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;QAChC,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,OAAO,IAAI,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AACrC,CAAC,CAAA","sourcesContent":["import { mkdirSync } from 'node:fs'\nimport { relative, resolve } from 'node:path'\nimport { minimatch } from 'minimatch'\nimport { init } from '@vltpkg/init'\nimport { load, save } from '@vltpkg/vlt-json'\nimport { assertWSConfig, asWSConfig } from '@vltpkg/workspaces'\nimport { commandUsage } from '../config/usage.ts'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'init',\n usage: '',\n description: `Create a new package.json file in the current directory.`,\n })\n\n// TODO: colorize the JSON if config.options.color\nexport const views = {\n human: (results: InitFileResults | InitFileResults[]) => {\n const output: string[] = []\n // if results is an array, it means multiple workspaces were initialized\n if (Array.isArray(results)) {\n for (const result of results) {\n for (const [type, { path }] of Object.entries(result)) {\n output.push(`Wrote ${type} to ${path}:`)\n }\n }\n } else {\n // otherwise, it's a single result\n for (const [type, { path, data }] of Object.entries(results)) {\n output.push(`Wrote ${type} to ${path}:\n\n${JSON.stringify(data, null, 2)}`)\n }\n }\n output.push(`\\nModify/add properties using \\`vlt pkg\\`. For example:\n\n vlt pkg set \"description=My new project\"`)\n return output.join('\\n')\n },\n} as const satisfies Views<InitFileResults>\n\nexport const command: CommandFn<\n InitFileResults | InitFileResults[]\n> = async conf => {\n if (conf.values.workspace?.length) {\n const workspacesConfig = load('workspaces', assertWSConfig)\n const parsedWSConfig = asWSConfig(workspacesConfig ?? {})\n const results: InitFileResults[] = []\n const addToConfig: string[] = []\n\n // create a new package.json file for every workspace\n // defined as cli --workspace options\n for (const workspace of conf.values.workspace) {\n // cwd is the resolved location of the workspace\n const cwd = resolve(conf.options.projectRoot, workspace)\n\n // create the folder in case it's missing\n mkdirSync(cwd, { recursive: true })\n\n // run the initialization script and collect results\n results.push(await init({ cwd }))\n\n // Check if this workspace path is covered by existing workspace patterns\n const isMatched = Object.values(parsedWSConfig).some(\n (patterns: string[]) => {\n return patterns.some(pattern =>\n minimatch(workspace, pattern),\n )\n },\n )\n\n // When a workspace is not matched we track it for insertion later\n if (!isMatched) {\n addToConfig.push(\n relative(conf.options.projectRoot, cwd).replace(/\\\\/g, '/'),\n )\n }\n }\n\n // if there are workspaces that were not matched by existing\n // patterns, we add them to the workspaces config\n if (addToConfig.length > 0) {\n let workspaces = workspacesConfig\n // if the original workspaces config is a string, we'll need\n // to convert it to an array in order to append the recently\n // added workspaces\n if (typeof workspacesConfig === 'string') {\n workspaces = [workspacesConfig, ...addToConfig]\n } else if (Array.isArray(workspacesConfig)) {\n // if the original workspaces config is an array, we simply\n // append the missing items to it\n workspaces = [...workspacesConfig, ...addToConfig]\n } else {\n // otherwise we assume it's an Record<string, string[]> object\n // and we'll add the new workspaces to the `packages` keys\n workspaces = (workspacesConfig ?? {}) as Record<\n string,\n string[]\n >\n // if the `packages` key is not being used\n if (!workspaces.packages) {\n workspaces.packages = addToConfig\n } else {\n // if the `packages` key is defined as a string, we\n // convert it to an array to append the new items\n if (typeof workspaces.packages === 'string') {\n workspaces.packages = [\n workspaces.packages,\n ...addToConfig,\n ]\n } else {\n // if it is, we simply append the new workspaces\n workspaces.packages = [\n ...workspaces.packages,\n ...addToConfig,\n ]\n }\n }\n }\n // finally, we add the new workspaces to the config file\n save('workspaces', workspaces)\n }\n return results\n }\n\n return init({ cwd: process.cwd() })\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAiFzC,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIL,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAMjD,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
|
|
@@ -4,6 +4,7 @@ import Spinner from 'ink-spinner';
|
|
|
4
4
|
import { createElement as $, Fragment, useLayoutEffect, useState, } from 'react';
|
|
5
5
|
import { stdout } from "../../output.js";
|
|
6
6
|
import { ViewClass } from "../../view.js";
|
|
7
|
+
import { asError } from '@vltpkg/types';
|
|
7
8
|
const GraphStep = ({ text, step }) => {
|
|
8
9
|
if (step.state === 'waiting') {
|
|
9
10
|
return $(Text, { color: 'gray' }, text);
|
|
@@ -60,7 +61,7 @@ export class InstallReporter extends ViewClass {
|
|
|
60
61
|
return undefined;
|
|
61
62
|
}
|
|
62
63
|
error(err) {
|
|
63
|
-
this.#instance?.unmount(err);
|
|
64
|
+
this.#instance?.unmount(asError(err));
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
//# sourceMappingURL=reporter.js.map
|