@vltpkg/cli-sdk 0.0.0-3 → 0.0.0-31
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/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 +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 +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/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 +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 +75 -10
- 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 +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 +3 -2
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +43 -15
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +24 -3
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +27 -3
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/list.d.ts +1 -1
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +150 -42
- 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 +2 -3
- 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 +239 -0
- package/dist/esm/commands/publish.js.map +1 -0
- package/dist/esm/commands/query.d.ts +1 -1
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +171 -32
- 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 +13 -1
- package/dist/esm/commands/uninstall.d.ts.map +1 -1
- package/dist/esm/commands/uninstall.js +12 -1
- 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/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 +117 -10
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +203 -31
- 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 +126 -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 +33 -14
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +214 -65
- 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 +63 -33
- 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/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 +7 -33
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +51 -349
- 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 +73 -45
- 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 -14
- package/dist/esm/commands/gui.js.map +0 -1
- 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
package/dist/esm/index.js
CHANGED
|
@@ -1,36 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
|
-
import { error } from '@vltpkg/error-cause';
|
|
1
|
+
import { format } from 'node:util';
|
|
2
|
+
import { asRootError } from '@vltpkg/output/error';
|
|
10
3
|
import { loadPackageJson } from 'package-json-from-dist';
|
|
4
|
+
import { getSortedCliOptions, getSortedKeys, } from "./config/definition.js";
|
|
11
5
|
import { Config } from "./config/index.js";
|
|
12
|
-
import { outputCommand, stdout } from "./output.js";
|
|
6
|
+
import { outputCommand, stderr, stdout } from "./output.js";
|
|
7
|
+
import { indent } from "./print-err.js";
|
|
8
|
+
import { loadCommand } from "./load-command.js";
|
|
13
9
|
const { version } = loadPackageJson(import.meta.filename, process.env.__VLT_INTERNAL_CLI_PACKAGE_JSON);
|
|
14
|
-
const
|
|
10
|
+
const loadVlt = async (cwd, argv) => {
|
|
15
11
|
try {
|
|
16
|
-
return
|
|
17
|
-
/* c8 ignore start - should not be possible, just a failsafe */
|
|
12
|
+
return await Config.load(cwd, argv);
|
|
18
13
|
}
|
|
19
14
|
catch (e) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
const err = asRootError(e, { code: 'JACKSPEAK' });
|
|
16
|
+
const { found, path, wanted, name } = err.cause;
|
|
17
|
+
const isConfigFile = typeof path === 'string';
|
|
18
|
+
const msg = isConfigFile ?
|
|
19
|
+
`Problem in Config File ${path}`
|
|
20
|
+
: 'Invalid Option Flag';
|
|
21
|
+
const validOptions = wanted ? undefined
|
|
22
|
+
: isConfigFile ? getSortedKeys()
|
|
23
|
+
: getSortedCliOptions();
|
|
24
|
+
stderr(msg);
|
|
25
|
+
stderr(err.message);
|
|
26
|
+
if (name)
|
|
27
|
+
stderr(indent(`Field: ${format(name)}`));
|
|
28
|
+
if (found) {
|
|
29
|
+
stderr(indent(`Found: ${isConfigFile ? JSON.stringify(found) : format(found)}`));
|
|
30
|
+
}
|
|
31
|
+
if (wanted)
|
|
32
|
+
stderr(indent(`Wanted: ${format(wanted)}`));
|
|
33
|
+
if (validOptions) {
|
|
34
|
+
stderr(indent('Valid Options:'));
|
|
35
|
+
stderr(indent(validOptions.join('\n'), 4));
|
|
36
|
+
}
|
|
37
|
+
stderr(indent(`Run 'vlt help' for more information about available options.`));
|
|
38
|
+
return process.exit(process.exitCode || 1);
|
|
24
39
|
}
|
|
25
|
-
/* c8 ignore stop */
|
|
26
40
|
};
|
|
27
41
|
const run = async () => {
|
|
28
42
|
const start = Date.now();
|
|
29
|
-
const
|
|
43
|
+
const cwd = process.cwd();
|
|
44
|
+
const vlt = await loadVlt(cwd, process.argv);
|
|
30
45
|
if (vlt.get('version')) {
|
|
31
46
|
return stdout(version);
|
|
32
47
|
}
|
|
33
|
-
const cwd = process.cwd();
|
|
34
48
|
const { monorepo } = vlt.options;
|
|
35
49
|
// Infer the workspace by being in that directory.
|
|
36
50
|
if (vlt.get('workspace') === undefined) {
|
|
@@ -40,6 +54,18 @@ const run = async () => {
|
|
|
40
54
|
vlt.options.workspace = [ws.path];
|
|
41
55
|
}
|
|
42
56
|
}
|
|
57
|
+
if (vlt.command !== 'init' &&
|
|
58
|
+
(vlt.get('workspace') || vlt.get('workspace-group')) &&
|
|
59
|
+
![...(monorepo?.values() ?? [])].length) {
|
|
60
|
+
stderr(`Error: No matching workspaces found. Make sure the vlt.json config contains the correct workspaces.`);
|
|
61
|
+
if (vlt.get('workspace')) {
|
|
62
|
+
stderr(indent(`Workspace: ${format(vlt.get('workspace'))}`));
|
|
63
|
+
}
|
|
64
|
+
if (vlt.get('workspace-group')) {
|
|
65
|
+
stderr(indent(`Workspace Group: ${format(vlt.get('workspace-group'))}`));
|
|
66
|
+
}
|
|
67
|
+
return process.exit(process.exitCode || 1);
|
|
68
|
+
}
|
|
43
69
|
const command = await loadCommand(vlt.command);
|
|
44
70
|
await outputCommand(command, vlt, { start });
|
|
45
71
|
};
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EACL,mBAAmB,EACnB,aAAa,GACd,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAQ/C,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CACjC,MAAM,CAAC,IAAI,CAAC,QAAQ,EACpB,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAG5C,CAAA;AAED,MAAM,OAAO,GAAG,KAAK,EAAE,GAAW,EAAE,IAAc,EAAE,EAAE;IACpD,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,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AI,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,cAAc,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC9D,CAAC;QACD,IAAI,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC/B,MAAM,CACJ,MAAM,CACJ,oBAAoB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,EAAE,CACzD,CACF,CAAA;QACH,CAAC;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC,CAAA;AAED,eAAe,GAAG,CAAA","sourcesContent":["import { format } from 'node:util'\nimport { asRootError } from '@vltpkg/output/error'\nimport { loadPackageJson } from 'package-json-from-dist'\nimport {\n getSortedCliOptions,\n getSortedKeys,\n} from './config/definition.ts'\nimport { Config } from './config/index.ts'\nimport { outputCommand, stderr, stdout } from './output.ts'\nimport { indent } from './print-err.ts'\nimport { loadCommand } from './load-command.ts'\n\nexport type {\n Command,\n CommandFn,\n CommandUsage,\n} from './load-command.ts'\n\nconst { version } = loadPackageJson(\n import.meta.filename,\n process.env.__VLT_INTERNAL_CLI_PACKAGE_JSON,\n) as {\n version: string\n}\n\nconst loadVlt = async (cwd: string, argv: string[]) => {\n try {\n return await Config.load(cwd, argv)\n } catch (e) {\n const err = asRootError(e, { code: 'JACKSPEAK' })\n const { found, path, wanted, name } = err.cause\n const isConfigFile = typeof path === 'string'\n const msg =\n isConfigFile ?\n `Problem in Config File ${path}`\n : 'Invalid Option Flag'\n const validOptions =\n wanted ? undefined\n : isConfigFile ? getSortedKeys()\n : getSortedCliOptions()\n stderr(msg)\n stderr(err.message)\n if (name) stderr(indent(`Field: ${format(name)}`))\n if (found) {\n stderr(\n indent(\n `Found: ${isConfigFile ? JSON.stringify(found) : format(found)}`,\n ),\n )\n }\n if (wanted) stderr(indent(`Wanted: ${format(wanted)}`))\n if (validOptions) {\n stderr(indent('Valid Options:'))\n stderr(indent(validOptions.join('\\n'), 4))\n }\n stderr(\n indent(\n `Run 'vlt help' for more information about available options.`,\n ),\n )\n return process.exit(process.exitCode || 1)\n }\n}\n\nconst run = async () => {\n const start = Date.now()\n const cwd = process.cwd()\n const vlt = await loadVlt(cwd, process.argv)\n\n if (vlt.get('version')) {\n return stdout(version)\n }\n\n const { monorepo } = vlt.options\n\n // Infer the workspace by being in that directory.\n if (vlt.get('workspace') === undefined) {\n const ws = monorepo?.get(cwd)\n if (ws) {\n vlt.values.workspace = [ws.path]\n vlt.options.workspace = [ws.path]\n }\n }\n\n if (\n vlt.command !== 'init' &&\n (vlt.get('workspace') || vlt.get('workspace-group')) &&\n ![...(monorepo?.values() ?? [])].length\n ) {\n stderr(\n `Error: No matching workspaces found. Make sure the vlt.json config contains the correct workspaces.`,\n )\n if (vlt.get('workspace')) {\n stderr(indent(`Workspace: ${format(vlt.get('workspace'))}`))\n }\n if (vlt.get('workspace-group')) {\n stderr(\n indent(\n `Workspace Group: ${format(vlt.get('workspace-group'))}`,\n ),\n )\n }\n return process.exit(process.exitCode || 1)\n }\n\n const command = await loadCommand(vlt.command)\n await outputCommand(command, vlt, { start })\n}\n\nexport default run\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Jack } from 'jackspeak';
|
|
2
|
+
import type { Commands, LoadedConfig } from './config/index.ts';
|
|
3
|
+
import type { Views } from './view.ts';
|
|
4
|
+
export type CommandUsage = () => Jack;
|
|
5
|
+
/**
|
|
6
|
+
* A command function that may return a result of `T`.
|
|
7
|
+
* If the result is `undefined`, no final output will be displayed by default.
|
|
8
|
+
*/
|
|
9
|
+
export type CommandFn<T = unknown> = (conf: LoadedConfig) => Promise<T>;
|
|
10
|
+
export type Command<T> = {
|
|
11
|
+
command: CommandFn<T>;
|
|
12
|
+
usage: CommandUsage;
|
|
13
|
+
views: Views<T>;
|
|
14
|
+
};
|
|
15
|
+
export declare const loadCommand: <T>(command: Commands[keyof Commands] | undefined) => Promise<Command<T>>;
|
|
16
|
+
//# sourceMappingURL=load-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-command.d.ts","sourceRoot":"","sources":["../../src/load-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAA;AAErC;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,CACnC,IAAI,EAAE,YAAY,KACf,OAAO,CAAC,CAAC,CAAC,CAAA;AAEf,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACvB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IACrB,KAAK,EAAE,YAAY,CAAA;IACnB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,WAAW,GAAU,CAAC,WACxB,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,SAAS,KAC5C,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CASpB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { error } from '@vltpkg/error-cause';
|
|
10
|
+
export const loadCommand = async (command) => {
|
|
11
|
+
try {
|
|
12
|
+
return (await import(__rewriteRelativeImportExtension(`./commands/${command}.ts`)));
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
throw error('Could not load command', {
|
|
16
|
+
found: command,
|
|
17
|
+
cause: e,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=load-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-command.js","sourceRoot":"","sources":["../../src/load-command.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAqB3C,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,OAA6C,EACxB,EAAE;IACvB,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,MAAM,kCAAC,cAAc,OAAO,KAAK,EAAC,CAAe,CAAA;IACjE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,KAAK,CAAC,wBAAwB,EAAE;YACpC,KAAK,EAAE,OAAO;YACd,KAAK,EAAE,CAAC;SACT,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { Jack } from 'jackspeak'\nimport type { Commands, LoadedConfig } from './config/index.ts'\nimport type { Views } from './view.ts'\n\nexport type CommandUsage = () => Jack\n\n/**\n * A command function that may return a result of `T`.\n * If the result is `undefined`, no final output will be displayed by default.\n */\nexport type CommandFn<T = unknown> = (\n conf: LoadedConfig,\n) => Promise<T>\n\nexport type Command<T> = {\n command: CommandFn<T>\n usage: CommandUsage\n views: Views<T>\n}\n\nexport const loadCommand = async <T>(\n command: Commands[keyof Commands] | undefined,\n): Promise<Command<T>> => {\n try {\n return (await import(`./commands/${command}.ts`)) as Command<T>\n } catch (e) {\n throw error('Could not load command', {\n found: command,\n cause: e,\n })\n }\n}\n"]}
|
package/dist/esm/output.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
+
import { styleText as utilStyleText } from 'node:util';
|
|
1
2
|
import type { LoadedConfig } from './config/index.ts';
|
|
2
3
|
import type { Command } from './index.ts';
|
|
3
4
|
import type { View, Views } from './view.ts';
|
|
4
5
|
export declare const stdout: (...args: unknown[]) => void;
|
|
5
6
|
export declare const stderr: (...args: unknown[]) => void;
|
|
7
|
+
type StyleTextFn = (format: Parameters<typeof utilStyleText>[0], s: string) => string;
|
|
8
|
+
export declare let styleTextStdout: StyleTextFn;
|
|
9
|
+
export declare let styleTextStderr: StyleTextFn;
|
|
6
10
|
export declare const getView: <T>(conf: LoadedConfig, views?: Views<T>) => View<T>;
|
|
7
|
-
|
|
8
|
-
* If the view is a View class, then instantiate and start it.
|
|
9
|
-
* If it's a view function, then just define the onDone method.
|
|
10
|
-
*/
|
|
11
|
-
export declare const startView: <T>(conf: LoadedConfig, views?: Views<T>, { start }?: {
|
|
12
|
-
start: number;
|
|
13
|
-
}) => {
|
|
14
|
-
onDone: (result: T) => Promise<string | undefined> | string | undefined;
|
|
15
|
-
onError?: (err: unknown) => void;
|
|
16
|
-
};
|
|
11
|
+
export type OnDone<T> = (result: T) => Promise<unknown>;
|
|
17
12
|
/**
|
|
18
13
|
* Main export. Run the command appropriately, displaying output using
|
|
19
14
|
* the user-requested view, or the default if the user requested a view
|
|
@@ -22,4 +17,5 @@ export declare const startView: <T>(conf: LoadedConfig, views?: Views<T>, { star
|
|
|
22
17
|
export declare const outputCommand: <T>(cliCommand: Command<T>, conf: LoadedConfig, { start }?: {
|
|
23
18
|
start: number;
|
|
24
19
|
}) => Promise<void>;
|
|
20
|
+
export {};
|
|
25
21
|
//# sourceMappingURL=output.d.ts.map
|
package/dist/esm/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,IAAI,aAAa,EAC3B,MAAM,WAAW,CAAA;AAGlB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,OAAO,KAAK,EAAE,IAAI,EAAe,KAAK,EAAE,MAAM,WAAW,CAAA;AAWzD,eAAO,MAAM,MAAM,YAAa,OAAO,EAAE,SAAyB,CAAA;AAElE,eAAO,MAAM,MAAM,YAAa,OAAO,EAAE,SAA2B,CAAA;AAEpE,KAAK,WAAW,GAAG,CACjB,MAAM,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,EAC3C,CAAC,EAAE,MAAM,KACN,MAAM,CAAA;AASX,eAAO,IAAI,eAAe,EAAE,WAAyB,CAAA;AACrD,eAAO,IAAI,eAAe,EAAE,WAAyB,CAAA;AAKrD,eAAO,MAAM,OAAO,GAAI,CAAC,QACjB,YAAY,UACV,KAAK,CAAC,CAAC,CAAC,KACf,IAAI,CAAC,CAAC,CA2BR,CAAA;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAsCvD;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,CAAC,cACvB,OAAO,CAAC,CAAC,CAAC,QAChB,YAAY,cACP;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,kBAoD7B,CAAA"}
|
package/dist/esm/output.js
CHANGED
|
@@ -1,24 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { formatWithOptions, styleText as utilStyleText, } from 'node:util';
|
|
2
|
+
import { createSupportsColor } from 'supports-color';
|
|
3
3
|
import { defaultView } from "./config/definition.js";
|
|
4
|
-
import { printErr } from "./print-err.js";
|
|
4
|
+
import { printErr, formatOptions } from "./print-err.js";
|
|
5
5
|
import { isViewClass } from "./view.js";
|
|
6
|
-
|
|
6
|
+
const supportsColor = (stream) => {
|
|
7
|
+
const res = createSupportsColor(stream, { sniffFlags: false });
|
|
8
|
+
if (res === false)
|
|
9
|
+
return false;
|
|
10
|
+
/* c8 ignore next */
|
|
11
|
+
return res.level > 0;
|
|
12
|
+
};
|
|
7
13
|
// eslint-disable-next-line no-console
|
|
8
14
|
export const stdout = (...args) => console.log(...args);
|
|
9
15
|
// eslint-disable-next-line no-console
|
|
10
16
|
export const stderr = (...args) => console.error(...args);
|
|
17
|
+
/* c8 ignore start */
|
|
18
|
+
const styleText = (f, s) => utilStyleText(f, s, { validateStream: false });
|
|
19
|
+
/* c8 ignore stop */
|
|
20
|
+
// TODO: stop exporting mutable variables once exec output is refactored
|
|
21
|
+
/* c8 ignore start */
|
|
22
|
+
export let styleTextStdout = (_, s) => s;
|
|
23
|
+
export let styleTextStderr = (_, s) => s;
|
|
24
|
+
/* c8 ignore stop */
|
|
11
25
|
const identity = (x) => x;
|
|
12
26
|
export const getView = (conf, views) => {
|
|
13
27
|
const viewName = conf.values.view;
|
|
14
28
|
const viewFn = viewName === 'inspect' ? identity
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
|
|
19
|
-
// then set it back to the
|
|
20
|
-
// This will fall back to identity if it's also
|
|
21
|
-
|
|
29
|
+
: viewName === 'silent' ? () => undefined
|
|
30
|
+
: typeof views === 'function' ? views
|
|
31
|
+
: views && typeof views === 'object' ? views[viewName]
|
|
32
|
+
: identity;
|
|
33
|
+
// if the user specified a view that doesn't exist, then set it back to the
|
|
34
|
+
// default, and try again. This will fall back to identity if it's also
|
|
35
|
+
// missing. We also always treat 'json' as a valid view that falls back to
|
|
36
|
+
// identity. This allows the explicit use of `--view=json` to work even
|
|
37
|
+
// when the default view is `human`.
|
|
38
|
+
if (!viewFn &&
|
|
39
|
+
conf.values.view !== defaultView &&
|
|
40
|
+
conf.values.view !== 'json' &&
|
|
41
|
+
conf.values.view !== 'silent') {
|
|
22
42
|
conf.values.view = defaultView;
|
|
23
43
|
process.env.VLT_VIEW = defaultView;
|
|
24
44
|
return getView(conf, views);
|
|
@@ -29,14 +49,13 @@ export const getView = (conf, views) => {
|
|
|
29
49
|
* If the view is a View class, then instantiate and start it.
|
|
30
50
|
* If it's a view function, then just define the onDone method.
|
|
31
51
|
*/
|
|
32
|
-
|
|
52
|
+
const startView = (conf, opts, views, { start } = { start: Date.now() }) => {
|
|
33
53
|
const View = getView(conf, views);
|
|
34
|
-
const opts = { colors: conf.values.color ? chalk : undefined };
|
|
35
54
|
if (isViewClass(View)) {
|
|
36
55
|
const view = new View(opts, conf);
|
|
37
56
|
view.start();
|
|
38
57
|
return {
|
|
39
|
-
onDone(r) {
|
|
58
|
+
async onDone(r) {
|
|
40
59
|
return view.done(r, { time: Date.now() - start });
|
|
41
60
|
},
|
|
42
61
|
onError(err) {
|
|
@@ -44,20 +63,13 @@ export const startView = (conf, views, { start } = { start: Date.now() }) => {
|
|
|
44
63
|
},
|
|
45
64
|
};
|
|
46
65
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
JSON.stringify(res, null, 2)
|
|
55
|
-
: formatWithOptions({
|
|
56
|
-
colors: conf.values.color,
|
|
57
|
-
}, res);
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
}
|
|
66
|
+
return {
|
|
67
|
+
async onDone(r) {
|
|
68
|
+
if (r === undefined)
|
|
69
|
+
return;
|
|
70
|
+
return View(r, opts, conf);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
61
73
|
};
|
|
62
74
|
/**
|
|
63
75
|
* Main export. Run the command appropriately, displaying output using
|
|
@@ -66,20 +78,38 @@ export const startView = (conf, views, { start } = { start: Date.now() }) => {
|
|
|
66
78
|
*/
|
|
67
79
|
export const outputCommand = async (cliCommand, conf, { start } = { start: Date.now() }) => {
|
|
68
80
|
const { usage, views, command } = cliCommand;
|
|
69
|
-
if (conf.
|
|
81
|
+
if (conf.values.help) {
|
|
70
82
|
return stdout(usage().usage());
|
|
71
83
|
}
|
|
72
|
-
const
|
|
84
|
+
const stdoutColor = conf.values.color ?? supportsColor(process.stdout);
|
|
85
|
+
const stderrColor = conf.values.color ?? supportsColor(process.stderr);
|
|
86
|
+
/* c8 ignore start */
|
|
87
|
+
if (stdoutColor)
|
|
88
|
+
styleTextStdout = styleText;
|
|
89
|
+
if (stderrColor)
|
|
90
|
+
styleTextStderr = styleText;
|
|
91
|
+
/* c8 ignore stop */
|
|
92
|
+
const { onDone, onError } = startView(conf,
|
|
93
|
+
// assume views will always output to stdout so use color support from there
|
|
94
|
+
{ colors: stdoutColor }, views, { start });
|
|
73
95
|
try {
|
|
74
96
|
const output = await onDone(await command(conf));
|
|
75
|
-
if (output !== undefined) {
|
|
76
|
-
stdout(
|
|
97
|
+
if (output !== undefined && conf.values.view !== 'silent') {
|
|
98
|
+
stdout(conf.values.view === 'json' ?
|
|
99
|
+
JSON.stringify(output, null, 2)
|
|
100
|
+
: formatWithOptions({
|
|
101
|
+
...formatOptions,
|
|
102
|
+
colors: stdoutColor,
|
|
103
|
+
}, output));
|
|
77
104
|
}
|
|
78
105
|
}
|
|
79
106
|
catch (err) {
|
|
80
107
|
onError?.(err);
|
|
81
108
|
process.exitCode ||= 1;
|
|
82
|
-
printErr(err, usage, stderr
|
|
109
|
+
printErr(err, usage, stderr, {
|
|
110
|
+
...formatOptions,
|
|
111
|
+
colors: stderrColor,
|
|
112
|
+
});
|
|
83
113
|
process.exit(process.exitCode);
|
|
84
114
|
}
|
|
85
115
|
};
|
package/dist/esm/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,SAAS,IAAI,aAAa,GAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,aAAa,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC5C,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;IAC9D,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,KAAK,CAAA;IAC/B,oBAAoB;IACpB,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,CAAA;AACtB,CAAC,CAAA;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AAClE,sCAAsC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AAOpE,qBAAqB;AACrB,MAAM,SAAS,GAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACtC,aAAa,CAAC,CAAC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AE,MAAM,EAAE;YAC3B,GAAG,aAAa;YAChB,MAAM,EAAE,WAAW;SACpB,CAAC,CAAA;QAEF,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAChC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { WriteStream } from 'node:tty'\nimport {\n formatWithOptions,\n styleText as utilStyleText,\n} from 'node:util'\nimport { createSupportsColor } from 'supports-color'\nimport { defaultView } from './config/definition.ts'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { Command } from './index.ts'\nimport { printErr, formatOptions } from './print-err.ts'\nimport type { View, ViewOptions, Views } from './view.ts'\nimport { isViewClass } from './view.ts'\n\nconst supportsColor = (stream: WriteStream) => {\n const res = createSupportsColor(stream, { sniffFlags: false })\n if (res === false) return false\n /* c8 ignore next */\n return res.level > 0\n}\n\n// eslint-disable-next-line no-console\nexport const stdout = (...args: unknown[]) => console.log(...args)\n// eslint-disable-next-line no-console\nexport const stderr = (...args: unknown[]) => console.error(...args)\n\ntype StyleTextFn = (\n format: Parameters<typeof utilStyleText>[0],\n s: string,\n) => string\n\n/* c8 ignore start */\nconst styleText: StyleTextFn = (f, s) =>\n utilStyleText(f, s, { validateStream: false })\n/* c8 ignore stop */\n\n// TODO: stop exporting mutable variables once exec output is refactored\n/* c8 ignore start */\nexport let styleTextStdout: StyleTextFn = (_, s) => s\nexport let styleTextStderr: StyleTextFn = (_, s) => s\n/* c8 ignore stop */\n\nconst identity = <T>(x: T): T => x\n\nexport const getView = <T>(\n conf: LoadedConfig,\n views?: Views<T>,\n): View<T> => {\n const viewName = conf.values.view\n\n const viewFn =\n viewName === 'inspect' ? identity\n : viewName === 'silent' ? () => undefined\n : typeof views === 'function' ? views\n : views && typeof views === 'object' ? views[viewName]\n : identity\n\n // if the user specified a view that doesn't exist, then set it back to the\n // default, and try again. This will fall back to identity if it's also\n // missing. We also always treat 'json' as a valid view that falls back to\n // identity. This allows the explicit use of `--view=json` to work even\n // when the default view is `human`.\n if (\n !viewFn &&\n conf.values.view !== defaultView &&\n conf.values.view !== 'json' &&\n conf.values.view !== 'silent'\n ) {\n conf.values.view = defaultView\n process.env.VLT_VIEW = defaultView\n return getView(conf, views)\n }\n\n return viewFn ?? identity\n}\n\nexport type OnDone<T> = (result: T) => Promise<unknown>\n\n/**\n * If the view is a View class, then instantiate and start it.\n * If it's a view function, then just define the onDone method.\n */\nconst startView = <T>(\n conf: LoadedConfig,\n opts: ViewOptions,\n views?: Views<T>,\n { start }: { start: number } = { start: Date.now() },\n): {\n onDone: OnDone<T>\n onError?: (err: unknown) => void\n} => {\n const View = getView<T>(conf, views)\n\n if (isViewClass(View)) {\n const view = new View(opts, conf)\n view.start()\n return {\n async onDone(r) {\n return view.done(r, { time: Date.now() - start })\n },\n onError(err) {\n view.error(err)\n },\n }\n }\n\n return {\n async onDone(r) {\n if (r === undefined) return\n return View(r, opts, conf)\n },\n }\n}\n\n/**\n * Main export. Run the command appropriately, displaying output using\n * the user-requested view, or the default if the user requested a view\n * that is not defined for this command.\n */\nexport const outputCommand = async <T>(\n cliCommand: Command<T>,\n conf: LoadedConfig,\n { start }: { start: number } = { start: Date.now() },\n) => {\n const { usage, views, command } = cliCommand\n\n if (conf.values.help) {\n return stdout(usage().usage())\n }\n\n const stdoutColor =\n conf.values.color ?? supportsColor(process.stdout)\n const stderrColor =\n conf.values.color ?? supportsColor(process.stderr)\n\n /* c8 ignore start */\n if (stdoutColor) styleTextStdout = styleText\n if (stderrColor) styleTextStderr = styleText\n /* c8 ignore stop */\n\n const { onDone, onError } = startView(\n conf,\n // assume views will always output to stdout so use color support from there\n { colors: stdoutColor },\n views,\n { start },\n )\n\n try {\n const output = await onDone(await command(conf))\n if (output !== undefined && conf.values.view !== 'silent') {\n stdout(\n conf.values.view === 'json' ?\n JSON.stringify(output, null, 2)\n : formatWithOptions(\n {\n ...formatOptions,\n colors: stdoutColor,\n },\n output,\n ),\n )\n }\n } catch (err) {\n onError?.(err)\n process.exitCode ||= 1\n\n printErr(err, usage, stderr, {\n ...formatOptions,\n colors: stderrColor,\n })\n\n process.exit(process.exitCode)\n }\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { NormalizedManifest } from '@vltpkg/types';
|
|
2
|
+
import type { LoadedConfig } from './config/index.ts';
|
|
3
|
+
export type PackTarballResult = {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
tarballName: string;
|
|
8
|
+
tarballData: Buffer;
|
|
9
|
+
unpackedSize: number;
|
|
10
|
+
files: string[];
|
|
11
|
+
integrity?: string;
|
|
12
|
+
shasum?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Create a tarball from a package directory
|
|
16
|
+
* @param {NormalizedManifest} manifest - The manifest of the package to pack
|
|
17
|
+
* @param {string} dir - The directory containing the package to pack
|
|
18
|
+
* @param {LoadedConfig} [config] - The loaded configuration (for workspace/catalog resolution)
|
|
19
|
+
* @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)
|
|
20
|
+
*/
|
|
21
|
+
export declare const packTarball: (manifest: NormalizedManifest, dir: string, config: LoadedConfig) => Promise<PackTarballResult>;
|
|
22
|
+
//# sourceMappingURL=pack-tarball.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-tarball.d.ts","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAQvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAuHD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,kBAAkB,OACvB,MAAM,UACH,YAAY,KACnB,OAAO,CAAC,iBAAiB,CAsN3B,CAAA"}
|