@vltpkg/cli-sdk 0.0.0-9 ā 1.0.0-rc.10
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/dist/esm/commands/bugs.d.ts +18 -0
- package/dist/esm/commands/bugs.d.ts.map +1 -0
- package/dist/esm/commands/bugs.js +164 -0
- package/dist/esm/commands/bugs.js.map +1 -0
- package/dist/esm/commands/build.d.ts +25 -0
- package/dist/esm/commands/build.d.ts.map +1 -0
- package/dist/esm/commands/build.js +102 -0
- package/dist/esm/commands/build.js.map +1 -0
- package/dist/esm/commands/cache.d.ts +18 -0
- package/dist/esm/commands/cache.d.ts.map +1 -1
- package/dist/esm/commands/cache.js +48 -2
- package/dist/esm/commands/cache.js.map +1 -1
- package/dist/esm/commands/ci.d.ts +11 -0
- package/dist/esm/commands/ci.d.ts.map +1 -0
- package/dist/esm/commands/ci.js +32 -0
- package/dist/esm/commands/ci.js.map +1 -0
- package/dist/esm/commands/config.d.ts +3 -2
- package/dist/esm/commands/config.d.ts.map +1 -1
- package/dist/esm/commands/config.js +372 -101
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/docs.d.ts +18 -0
- package/dist/esm/commands/docs.d.ts.map +1 -0
- package/dist/esm/commands/docs.js +154 -0
- package/dist/esm/commands/docs.js.map +1 -0
- 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 +146 -0
- package/dist/esm/commands/exec-cache.js.map +1 -0
- package/dist/esm/commands/exec-local.d.ts +1 -0
- package/dist/esm/commands/exec-local.d.ts.map +1 -1
- package/dist/esm/commands/exec-local.js +2 -0
- package/dist/esm/commands/exec-local.js.map +1 -1
- package/dist/esm/commands/exec.d.ts +6 -1
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +79 -5
- package/dist/esm/commands/exec.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 +32 -3
- package/dist/esm/commands/help.js.map +1 -1
- package/dist/esm/commands/init.d.ts +3 -3
- 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 +3 -2
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +42 -15
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +21 -3
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +29 -4
- 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 +149 -49
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pack.d.ts +32 -0
- package/dist/esm/commands/pack.d.ts.map +1 -0
- package/dist/esm/commands/pack.js +147 -0
- package/dist/esm/commands/pack.js.map +1 -0
- package/dist/esm/commands/pkg.d.ts +1 -2
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js +123 -38
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/publish.d.ts +22 -0
- package/dist/esm/commands/publish.d.ts.map +1 -0
- package/dist/esm/commands/publish.js +245 -0
- package/dist/esm/commands/publish.js.map +1 -0
- package/dist/esm/commands/query.d.ts +2 -3
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +132 -38
- 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/serve.d.ts +14 -0
- package/dist/esm/commands/serve.d.ts.map +1 -0
- package/dist/esm/commands/serve.js +103 -0
- package/dist/esm/commands/serve.js.map +1 -0
- package/dist/esm/commands/uninstall.d.ts +8 -2
- package/dist/esm/commands/uninstall.d.ts.map +1 -1
- package/dist/esm/commands/uninstall.js +10 -5
- package/dist/esm/commands/uninstall.js.map +1 -1
- package/dist/esm/commands/update.d.ts +14 -0
- package/dist/esm/commands/update.d.ts.map +1 -0
- package/dist/esm/commands/update.js +41 -0
- package/dist/esm/commands/update.js.map +1 -0
- package/dist/esm/commands/version.d.ts +26 -0
- package/dist/esm/commands/version.d.ts.map +1 -0
- package/dist/esm/commands/version.js +226 -0
- package/dist/esm/commands/version.js.map +1 -0
- package/dist/esm/config/definition.d.ts +119 -15
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +186 -37
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/config/index.d.ts +41 -37
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +109 -172
- 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/custom-help.d.ts +9 -0
- package/dist/esm/custom-help.d.ts.map +1 -0
- package/dist/esm/custom-help.js +400 -0
- package/dist/esm/custom-help.js.map +1 -0
- package/dist/esm/exec-command.d.ts +33 -14
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +213 -64
- 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 +45 -19
- 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 -11
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +64 -27
- 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 +249 -0
- package/dist/esm/pack-tarball.js.map +1 -0
- package/dist/esm/parse-add-remove-args.d.ts +9 -2
- package/dist/esm/parse-add-remove-args.d.ts.map +1 -1
- package/dist/esm/parse-add-remove-args.js +43 -10
- package/dist/esm/parse-add-remove-args.js.map +1 -1
- package/dist/esm/print-err.d.ts +9 -2
- package/dist/esm/print-err.d.ts.map +1 -1
- package/dist/esm/print-err.js +130 -46
- package/dist/esm/print-err.js.map +1 -1
- package/dist/esm/query-host-contexts.d.ts +16 -0
- package/dist/esm/query-host-contexts.d.ts.map +1 -0
- package/dist/esm/query-host-contexts.js +135 -0
- package/dist/esm/query-host-contexts.js.map +1 -0
- package/dist/esm/start-gui.d.ts +1 -0
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +28 -8
- 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 +1 -1
- package/dist/esm/view.js.map +1 -1
- package/package.json +55 -41
- package/dist/esm/commands/gui.d.ts +0 -6
- package/dist/esm/commands/gui.d.ts.map +0 -1
- package/dist/esm/commands/gui.js +0 -13
- package/dist/esm/commands/gui.js.map +0 -1
|
@@ -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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EAAE,EAAE;YACzC,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,YAAY,CAAC,CAAA;IAC/C,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAA;AAChC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../load-command.ts'\nimport { loadCommand } from '../load-command.ts'\nimport { getCommand } from '../config/definition.ts'\nimport {\n generateDefaultHelp,\n generateFullHelp,\n} from '../custom-help.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 // Check for color support (prefer explicit config, fall back to TTY detection)\n const colors = conf.values.color ?? process.stdout.isTTY\n\n // Use full custom help if --all flag is set\n if (conf.values.all) {\n return generateFullHelp(colors)\n }\n return generateDefaultHelp(colors)\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,8 +1,8 @@
|
|
|
1
|
-
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
1
|
import type { InitFileResults } from '@vltpkg/init';
|
|
2
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
3
|
export declare const usage: CommandUsage;
|
|
4
4
|
export declare const views: {
|
|
5
|
-
readonly human: (results: InitFileResults
|
|
5
|
+
readonly human: (results: InitFileResults | InitFileResults[]) => string;
|
|
6
6
|
};
|
|
7
|
-
export declare const command: CommandFn<InitFileResults>;
|
|
7
|
+
export declare const command: CommandFn<InitFileResults | InitFileResults[]>;
|
|
8
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,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAKjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,EAAE;IACT,WAAW,EAAE,0DAA0D;CACxE,CAAC,CAAA;AAEJ,kDAAkD;AAClD,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,OAA4C,EAAE,EAAE;QACtD,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,wEAAwE;QACxE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,IA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C;oBACzB,UAAU,CAAC,QAAQ,GAAG,WAAW,CAAA;gBACnC,CAAC;qBAAM,CAAC;oBACN,mDAAmD;oBACnD,iDAAiD;oBACjD,IAAI,OAAO,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;wBAC5C,UAAU,CAAC,QAAQ,GAAG;4BACpB,UAAU,CAAC,QAAQ;4BACnB,GAAG,WAAW;yBACf,CAAA;oBACH,CAAC;yBAAM,CAAC;wBACN,gDAAgD;wBAChD,UAAU,CAAC,QAAQ,GAAG;4BACpB,GAAG,UAAU,CAAC,QAAQ;4BACtB,GAAG,WAAW;yBACf,CAAA;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YACD,wDAAwD;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,10 +1,11 @@
|
|
|
1
1
|
import { ViewClass } from '../../view.ts';
|
|
2
|
+
import type { InstallResult } from '../install.ts';
|
|
2
3
|
export declare class InstallReporter extends ViewClass {
|
|
3
4
|
#private;
|
|
4
5
|
start(): void;
|
|
5
|
-
done(_result:
|
|
6
|
+
done(_result: InstallResult, { time }: {
|
|
6
7
|
time: number;
|
|
7
|
-
}): undefined
|
|
8
|
+
}): Promise<undefined>;
|
|
8
9
|
error(err: unknown): void;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAqGlD,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAe7D,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { emitter } from '@vltpkg/output';
|
|
2
2
|
import { Box, render, Text } from 'ink';
|
|
3
3
|
import Spinner from 'ink-spinner';
|
|
4
|
-
import { createElement as $, Fragment,
|
|
5
|
-
import { stdout } from "../../output.js";
|
|
4
|
+
import { createElement as $, Fragment, useEffect, useState, } from 'react';
|
|
6
5
|
import { ViewClass } from "../../view.js";
|
|
7
|
-
import { asError } from '@vltpkg/
|
|
6
|
+
import { asError } from '@vltpkg/types';
|
|
7
|
+
const labels = {
|
|
8
|
+
build: 'resolving dependencies',
|
|
9
|
+
actual: '',
|
|
10
|
+
reify: 'extracting files',
|
|
11
|
+
};
|
|
8
12
|
const GraphStep = ({ text, step }) => {
|
|
9
13
|
if (step.state === 'waiting') {
|
|
10
14
|
return $(Text, { color: 'gray' }, text);
|
|
11
15
|
}
|
|
12
16
|
if (step.state === 'in_progress') {
|
|
13
|
-
return $(Text, { color: 'yellow' }, text, $(Spinner, { type: 'dots' }));
|
|
17
|
+
return $(Text, { color: 'yellow' }, text + ' ', $(Spinner, { type: 'dots' }));
|
|
14
18
|
}
|
|
15
19
|
return $(Text, { color: 'green' }, text, ' ā');
|
|
16
20
|
};
|
|
17
|
-
const App = () => {
|
|
21
|
+
const App = ({ trailer }) => {
|
|
18
22
|
const [requests, setRequests] = useState(0);
|
|
23
|
+
const [cacheHit, setCacheHit] = useState(0);
|
|
19
24
|
const [steps, setSteps] = useState({
|
|
20
25
|
build: {
|
|
21
26
|
state: 'waiting',
|
|
@@ -27,12 +32,19 @@ const App = () => {
|
|
|
27
32
|
state: 'waiting',
|
|
28
33
|
},
|
|
29
34
|
});
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const updateRequests = ({ state }) => {
|
|
37
|
+
if (state === 'start') {
|
|
38
|
+
setRequests(p => p + 1);
|
|
39
|
+
}
|
|
40
|
+
else if (state === 'cache' || state === 'stale') {
|
|
41
|
+
setCacheHit(p => p + 1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
emitter.on('request', updateRequests);
|
|
45
|
+
return () => emitter.off('request', updateRequests);
|
|
34
46
|
}, []);
|
|
35
|
-
|
|
47
|
+
useEffect(() => {
|
|
36
48
|
const update = ({ step, state }) => {
|
|
37
49
|
setSteps(p => ({
|
|
38
50
|
...p,
|
|
@@ -47,17 +59,32 @@ const App = () => {
|
|
|
47
59
|
}, []);
|
|
48
60
|
return $(Fragment, null, $(Box, null, ...['build', 'actual', 'reify'].map((step, idx, list) => {
|
|
49
61
|
const separator = idx === list.length - 1 ? '' : ' > ';
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
const label = labels[step];
|
|
63
|
+
if (!label)
|
|
64
|
+
return null;
|
|
65
|
+
return $(Text, { key: step }, $(GraphStep, { text: label, step: steps[step] }), $(Text, { color: 'gray' }, separator));
|
|
66
|
+
})), cacheHit > 0 ?
|
|
67
|
+
$(Text, null, `${cacheHit} cache hit${cacheHit > 1 ? 's' : ''}`)
|
|
68
|
+
: null, requests > 0 ?
|
|
69
|
+
$(Text, null, `${requests} request${requests > 1 ? 's' : ''}`)
|
|
70
|
+
: null, trailer ? $(Text, null, trailer) : null);
|
|
52
71
|
};
|
|
53
72
|
export class InstallReporter extends ViewClass {
|
|
54
73
|
#instance = null;
|
|
55
74
|
start() {
|
|
56
75
|
this.#instance = render($(App));
|
|
57
76
|
}
|
|
58
|
-
done(_result, { time }) {
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
async done(_result, { time }) {
|
|
78
|
+
let out = `Done in ${time}ms`;
|
|
79
|
+
// prints a very complete message explaining users the next steps
|
|
80
|
+
// in case there are packages to be built
|
|
81
|
+
if (_result.buildQueue?.length) {
|
|
82
|
+
out += `\n\nš¦ ${_result.buildQueue.length} packages have install scripts defined & were not fully built\n`;
|
|
83
|
+
out += 'š Run `vlt query :scripts` to list them\n';
|
|
84
|
+
out +=
|
|
85
|
+
'šØ Run `vlt build` to run all required scripts to build installed packages.\n';
|
|
86
|
+
}
|
|
87
|
+
this.#instance?.rerender($(App, { trailer: out }));
|
|
61
88
|
return undefined;
|
|
62
89
|
}
|
|
63
90
|
error(err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,
|
|
1
|
+
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAOvC,MAAM,MAAM,GAAgD;IAC1D,KAAK,EAAE,wBAAwB;IAC/B,MAAM,EAAE,EAAE;IACV,KAAK,EAAE,kBAAkB;CAC1B,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAgC,EAAE,EAAE;IACjE,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC;QACjC,OAAO,CAAC,CACN,IAAI,EACJ,EAAE,KAAK,EAAE,QAAQ,E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IAED,KAAK,CAAC,GAAY;QAChB,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACvC,CAAC;CACF","sourcesContent":["import { emitter } from '@vltpkg/output'\nimport type { Events } from '@vltpkg/output'\nimport { Box, render, Text } from 'ink'\nimport type { Instance } from 'ink'\nimport Spinner from 'ink-spinner'\nimport {\n createElement as $,\n Fragment,\n useEffect,\n useState,\n} from 'react'\nimport { ViewClass } from '../../view.ts'\nimport { asError } from '@vltpkg/types'\nimport type { InstallResult } from '../install.ts'\n\ntype Step = {\n state: 'waiting' | 'in_progress' | 'completed'\n}\n\nconst labels: Record<Events['graphStep']['step'], string> = {\n build: 'resolving dependencies',\n actual: '',\n reify: 'extracting files',\n}\n\nconst GraphStep = ({ text, step }: { text: string; step: Step }) => {\n if (step.state === 'waiting') {\n return $(Text, { color: 'gray' }, text)\n }\n if (step.state === 'in_progress') {\n return $(\n Text,\n { color: 'yellow' },\n text + ' ',\n $(Spinner, { type: 'dots' }),\n )\n }\n return $(Text, { color: 'green' }, text, ' ā')\n}\n\nconst App = ({ trailer }: { trailer?: string }) => {\n const [requests, setRequests] = useState(0)\n const [cacheHit, setCacheHit] = useState(0)\n\n const [steps, setSteps] = useState<\n Record<Events['graphStep']['step'], Step>\n >({\n build: {\n state: 'waiting',\n },\n actual: {\n state: 'waiting',\n },\n reify: {\n state: 'waiting',\n },\n })\n\n useEffect(() => {\n const updateRequests = ({ state }: Events['request']) => {\n if (state === 'start') {\n setRequests(p => p + 1)\n } else if (state === 'cache' || state === 'stale') {\n setCacheHit(p => p + 1)\n }\n }\n emitter.on('request', updateRequests)\n return () => emitter.off('request', updateRequests)\n }, [])\n\n useEffect(() => {\n const update = ({ step, state }: Events['graphStep']) => {\n setSteps(p => ({\n ...p,\n [step]: {\n ...p[step],\n state: state === 'start' ? 'in_progress' : 'completed',\n },\n }))\n }\n emitter.on('graphStep', update)\n return () => emitter.off('graphStep', update)\n }, [])\n\n return $(\n Fragment,\n null,\n $(\n Box,\n null,\n ...(['build', 'actual', 'reify'] as const).map(\n (step, idx, list) => {\n const separator = idx === list.length - 1 ? '' : ' > '\n const label = labels[step]\n if (!label) return null\n return $(\n Text,\n { key: step },\n $(GraphStep, { text: label, step: steps[step] }),\n $(Text, { color: 'gray' }, separator),\n )\n },\n ),\n ),\n cacheHit > 0 ?\n $(Text, null, `${cacheHit} cache hit${cacheHit > 1 ? 's' : ''}`)\n : null,\n requests > 0 ?\n $(Text, null, `${requests} request${requests > 1 ? 's' : ''}`)\n : null,\n trailer ? $(Text, null, trailer) : null,\n )\n}\n\nexport class InstallReporter extends ViewClass {\n #instance: Instance | null = null\n\n start() {\n this.#instance = render($(App))\n }\n\n async done(_result: InstallResult, { time }: { time: number }) {\n let out = `Done in ${time}ms`\n\n // prints a very complete message explaining users the next steps\n // in case there are packages to be built\n if (_result.buildQueue?.length) {\n out += `\\n\\nš¦ ${_result.buildQueue.length} packages have install scripts defined & were not fully built\\n`\n out += 'š Run `vlt query :scripts` to list them\\n'\n out +=\n 'šØ Run `vlt build` to run all required scripts to build installed packages.\\n'\n }\n this.#instance?.rerender($(App, { trailer: out }))\n return undefined\n }\n\n error(err: unknown) {\n this.#instance?.unmount(asError(err))\n }\n}\n"]}
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
import { InstallReporter } from './install/reporter.ts';
|
|
2
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
1
3
|
import type { Graph } from '@vltpkg/graph';
|
|
2
4
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The resulting object of an install operation. To be used by the view impl.
|
|
7
|
+
*/
|
|
8
|
+
export type InstallResult = {
|
|
9
|
+
/**
|
|
10
|
+
* A queue of package IDs that need to be built after the install is complete.
|
|
11
|
+
*/
|
|
12
|
+
buildQueue?: DepID[];
|
|
13
|
+
/**
|
|
14
|
+
* The resulting graph structure at the end of an install.
|
|
15
|
+
*/
|
|
16
|
+
graph: Graph;
|
|
17
|
+
};
|
|
4
18
|
export declare const usage: CommandUsage;
|
|
5
19
|
export declare const views: {
|
|
6
|
-
readonly json: (
|
|
20
|
+
readonly json: (i: InstallResult) => {
|
|
21
|
+
graph: import("@vltpkg/graph").LockfileData;
|
|
22
|
+
buildQueue?: DepID[] | undefined;
|
|
23
|
+
message?: string | undefined;
|
|
24
|
+
};
|
|
7
25
|
readonly human: typeof InstallReporter;
|
|
8
26
|
};
|
|
9
|
-
export declare const command: CommandFn<
|
|
27
|
+
export declare const command: CommandFn<InstallResult>;
|
|
10
28
|
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;;;;;CAWuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CA0B5C,CAAA"}
|
|
@@ -9,13 +9,38 @@ export const usage = () => commandUsage({
|
|
|
9
9
|
vlt-lock.json appropriately.`,
|
|
10
10
|
});
|
|
11
11
|
export const views = {
|
|
12
|
-
json:
|
|
12
|
+
json: i => ({
|
|
13
|
+
...(i.buildQueue?.length ?
|
|
14
|
+
{
|
|
15
|
+
buildQueue: i.buildQueue,
|
|
16
|
+
message: `${i.buildQueue.length} packages that will need to be built, run "vlt build" to complete the install.`,
|
|
17
|
+
}
|
|
18
|
+
: null),
|
|
19
|
+
graph: i.graph.toJSON(),
|
|
20
|
+
}),
|
|
13
21
|
human: InstallReporter,
|
|
14
22
|
};
|
|
15
23
|
export const command = async (conf) => {
|
|
24
|
+
// TODO: we should probably throw an error if the user
|
|
25
|
+
// tries to install using either view=mermaid or view=gui
|
|
16
26
|
const monorepo = conf.options.monorepo;
|
|
17
|
-
const
|
|
18
|
-
const {
|
|
19
|
-
|
|
27
|
+
const scurry = conf.options.scurry;
|
|
28
|
+
const { add } = parseAddArgs(conf, scurry, monorepo);
|
|
29
|
+
const frozenLockfile = conf.options['frozen-lockfile'];
|
|
30
|
+
const expectLockfile = conf.options['expect-lockfile'];
|
|
31
|
+
const lockfileOnly = conf.options['lockfile-only'];
|
|
32
|
+
/* c8 ignore start */
|
|
33
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
34
|
+
String(conf.get('allow-scripts'))
|
|
35
|
+
: ':not(*)';
|
|
36
|
+
/* c8 ignore stop */
|
|
37
|
+
const { buildQueue, graph } = await install({
|
|
38
|
+
...conf.options,
|
|
39
|
+
frozenLockfile,
|
|
40
|
+
expectLockfile,
|
|
41
|
+
allowScripts,
|
|
42
|
+
lockfileOnly,
|
|
43
|
+
}, add);
|
|
44
|
+
return { buildQueue, graph };
|
|
20
45
|
};
|
|
21
46
|
//# sourceMappingURL=install.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAo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BAAqB;IACrB,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CACzC;QACE,GAAG,IAAI,CAAC,OAAO;QACf,cAAc;QACd,cAAc;QACd,YAAY;QACZ,YAAY;KACb,EACD,GAAG,CACJ,CAAA;IACD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport { install } from '@vltpkg/graph'\nimport { parseAddArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { Graph } from '@vltpkg/graph'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\n/**\n * The resulting object of an install operation. To be used by the view impl.\n */\nexport type InstallResult = {\n /**\n * A queue of package IDs that need to be built after the install is complete.\n */\n buildQueue?: DepID[]\n /**\n * The resulting graph structure at the end of an install.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install',\n usage: '[packages ...]',\n description: `Install the specified packages, updating package.json and\n vlt-lock.json appropriately.`,\n })\n\nexport const views = {\n json: i => ({\n ...(i.buildQueue?.length ?\n {\n buildQueue: i.buildQueue,\n message: `${i.buildQueue.length} packages that will need to be built, run \"vlt build\" to complete the install.`,\n }\n : null),\n graph: i.graph.toJSON(),\n }),\n human: InstallReporter,\n} as const satisfies Views<InstallResult>\n\nexport const command: CommandFn<InstallResult> = async conf => {\n // TODO: we should probably throw an error if the user\n // tries to install using either view=mermaid or view=gui\n const monorepo = conf.options.monorepo\n const scurry = conf.options.scurry\n const { add } = parseAddArgs(conf, scurry, monorepo)\n const frozenLockfile = conf.options['frozen-lockfile']\n const expectLockfile = conf.options['expect-lockfile']\n const lockfileOnly = conf.options['lockfile-only']\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { buildQueue, graph } = await install(\n {\n ...conf.options,\n frozenLockfile,\n expectLockfile,\n allowScripts,\n lockfileOnly,\n },\n add,\n )\n return { buildQueue, graph }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HumanReadableOutputGraph, JSONOutputGraph, MermaidOutputGraph } from '@vltpkg/graph';
|
|
2
1
|
import { humanReadableOutput, jsonOutput, mermaidOutput } from '@vltpkg/graph';
|
|
2
|
+
import type { HumanReadableOutputGraph, JSONOutputGraph, MermaidOutputGraph } from '@vltpkg/graph';
|
|
3
3
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
4
4
|
export declare const usage: CommandUsage;
|
|
5
5
|
export type ListResult = JSONOutputGraph & MermaidOutputGraph & HumanReadableOutputGraph & {
|
|
@@ -9,7 +9,7 @@ export declare const views: {
|
|
|
9
9
|
readonly json: typeof jsonOutput;
|
|
10
10
|
readonly mermaid: typeof mermaidOutput;
|
|
11
11
|
readonly human: typeof humanReadableOutput;
|
|
12
|
-
readonly gui: ({ queryString }: ListResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").
|
|
12
|
+
readonly gui: ({ queryString }: ListResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").ParsedConfig) => Promise<void>;
|
|
13
13
|
};
|
|
14
14
|
export declare const command: CommandFn<ListResult>;
|
|
15
15
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,aAAa,EAEd,MAAM,eAAe,CAAA;AAQtB,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAGnB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,eAAO,MAAM,KAAK,EAAE,YAyDhB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CA+JzC,CAAA"}
|