@vltpkg/cli-sdk 0.0.0-29 → 0.0.0-30
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/list.d.ts +1 -1
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +67 -36
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pack.d.ts.map +1 -1
- package/dist/esm/commands/pack.js +17 -8
- package/dist/esm/commands/pack.js.map +1 -1
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js +39 -23
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/publish.d.ts.map +1 -1
- package/dist/esm/commands/publish.js +17 -8
- package/dist/esm/commands/publish.js.map +1 -1
- 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 +62 -36
- package/dist/esm/commands/query.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 +97 -0
- package/dist/esm/commands/serve.js.map +1 -0
- package/dist/esm/commands/version.d.ts.map +1 -1
- package/dist/esm/commands/version.js +21 -15
- package/dist/esm/commands/version.js.map +1 -1
- package/dist/esm/config/definition.d.ts +11 -1
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +10 -2
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/exec-command.d.ts +1 -0
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +21 -8
- package/dist/esm/exec-command.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.map +1 -1
- package/dist/esm/start-gui.js +10 -3
- package/dist/esm/start-gui.js.map +1 -1
- package/package.json +26 -25
- 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
|
@@ -23,7 +23,6 @@ export declare const commands: {
|
|
|
23
23
|
readonly config: "config";
|
|
24
24
|
readonly exec: "exec";
|
|
25
25
|
readonly 'exec-local': "exec-local";
|
|
26
|
-
readonly gui: "gui";
|
|
27
26
|
readonly help: "help";
|
|
28
27
|
readonly init: "init";
|
|
29
28
|
readonly install: "install";
|
|
@@ -36,6 +35,7 @@ export declare const commands: {
|
|
|
36
35
|
readonly query: "query";
|
|
37
36
|
readonly 'run-exec': "run-exec";
|
|
38
37
|
readonly run: "run";
|
|
38
|
+
readonly serve: "serve";
|
|
39
39
|
readonly token: "token";
|
|
40
40
|
readonly uninstall: "uninstall";
|
|
41
41
|
readonly update: "update";
|
|
@@ -344,9 +344,19 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
344
344
|
hint: string;
|
|
345
345
|
description: string;
|
|
346
346
|
};
|
|
347
|
+
port: {
|
|
348
|
+
hint: string;
|
|
349
|
+
description: string;
|
|
350
|
+
};
|
|
351
|
+
'registry-port': {
|
|
352
|
+
hint: string;
|
|
353
|
+
description: string;
|
|
354
|
+
};
|
|
347
355
|
} & {
|
|
348
356
|
otp: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
349
357
|
'publish-directory': import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
358
|
+
port: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
359
|
+
'registry-port': import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
350
360
|
} & {
|
|
351
361
|
yes: {
|
|
352
362
|
short: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,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,GAAG,OAAO,QAAQ,CAAA;AAEtC,eAAO,MAAM,UAAU,OACjB,MAAM,KACT,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,SACkC,CAAA;AAKhE;;GAEG;AACH,eAAO,MAAM,YAAY,iGAMf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,MAAO,MAAM,KAAG,CAAC,IAAI,WACN,CAAA;AAwCzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA2OH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA4NP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiEvB,CAAA;AAEJ,eAAO,MAAM,mBAAmB,gBAS/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
|
|
@@ -20,7 +20,6 @@ const canonicalCommands = {
|
|
|
20
20
|
config: 'config',
|
|
21
21
|
exec: 'exec',
|
|
22
22
|
'exec-local': 'exec-local',
|
|
23
|
-
gui: 'gui',
|
|
24
23
|
help: 'help',
|
|
25
24
|
init: 'init',
|
|
26
25
|
install: 'install',
|
|
@@ -34,6 +33,7 @@ const canonicalCommands = {
|
|
|
34
33
|
query: 'query',
|
|
35
34
|
'run-exec': 'run-exec',
|
|
36
35
|
run: 'run',
|
|
36
|
+
serve: 'serve',
|
|
37
37
|
token: 'token',
|
|
38
38
|
uninstall: 'uninstall',
|
|
39
39
|
update: 'update',
|
|
@@ -517,7 +517,7 @@ export const definition = j
|
|
|
517
517
|
.optList({
|
|
518
518
|
'dashboard-root': {
|
|
519
519
|
hint: 'path',
|
|
520
|
-
description: `The root directory to use for the dashboard
|
|
520
|
+
description: `The root directory to use for the dashboard browser-based UI.
|
|
521
521
|
If not set, the user home directory is used.`,
|
|
522
522
|
},
|
|
523
523
|
})
|
|
@@ -585,6 +585,14 @@ export const definition = j
|
|
|
585
585
|
description: `Directory to use for pack and publish operations instead of the current directory.
|
|
586
586
|
The directory must exist and nothing will be copied to it.`,
|
|
587
587
|
},
|
|
588
|
+
port: {
|
|
589
|
+
hint: 'number',
|
|
590
|
+
description: `Port for the browser-based UI server when using vlt serve command (default: 8000).`,
|
|
591
|
+
},
|
|
592
|
+
'registry-port': {
|
|
593
|
+
hint: 'number',
|
|
594
|
+
description: `Port for the VSR registry when using vlt serve command (default: 1337).`,
|
|
595
|
+
},
|
|
588
596
|
})
|
|
589
597
|
.flag({
|
|
590
598
|
yes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW;AACtB,uCAAuC;AACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;IAC5B,6DAA6D;IAC7D,sDAAsD;IACxD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;QACxB,6BAA6B;QAC/B,CAAC,CAAC,MAAM,CAAA;AAEV,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GA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;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,oBAAoB;QACpB,IAAI,CAAC,GAAG;YAAE,MAAM,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,EAAE,CAAA;QAC3C,OAAO,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView =\n // If stdout is a TTY, use human output\n process.stdout.isTTY ? 'human'\n // If its not a TTY but is a CI environment, use human output\n // TODO: make a better view option for CI environments\n : process.env.CI ? 'human'\n // Otherwise, use json output\n : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n exec: 'exec',\n 'exec-local': 'exec-local',\n gui: 'gui',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n update: 'update',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'uninstall',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n conf: 'config',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n 'node-version': {\n hint: 'version',\n description: `Node version to use when choosing packages based on\n their \\`engines.node\\` value.`,\n default: process.version,\n },\n })\n\n .flag({\n 'git-shallow': {\n description: `Set to force \\`--depth=1\\` on all git clone actions.\n When set explicitly to false with --no-git-shallow,\n then \\`--depth=1\\` will not be used.\n\n When not set explicitly, \\`--depth=1\\` will be used for\n git hosts known to support this behavior.`,\n },\n })\n .num({\n 'fetch-retries': {\n hint: 'n',\n description: `Number of retries to perform when encountering network\n errors or likely-transient errors from git hosts.`,\n default: 3,\n },\n 'fetch-retry-factor': {\n hint: 'n',\n description: `The exponential backoff factor to use when retrying\n requests due to network issues.`,\n default: 2,\n },\n 'fetch-retry-mintimeout': {\n hint: 'n',\n description: `Number of milliseconds before starting first retry`,\n default: 0,\n },\n 'fetch-retry-maxtimeout': {\n hint: 'n',\n description: `Maximum number of milliseconds between two retries`,\n default: 30_000,\n },\n 'stale-while-revalidate-factor': {\n hint: 'n',\n default: 60,\n description: `If the server does not serve a \\`stale-while-revalidate\\`\n value in the \\`cache-control\\` header, then this multiplier\n is applied to the \\`max-age\\` or \\`s-maxage\\` values.\n\n By default, this is \\`60\\`, so for example a response that\n is cacheable for 5 minutes will allow a stale response\n while revalidating for up to 5 hours.\n\n If the server *does* provide a \\`stale-while-revalidate\\`\n value, then that is always used.\n\n Set to 0 to prevent any \\`stale-while-revalidate\\` behavior\n unless explicitly allowed by the server's \\`cache-control\\`\n header.\n `,\n },\n })\n\n .opt({\n identity: {\n short: 'i',\n validate: (v: unknown) =>\n typeof v === 'string' && /^[a-z0-9]*$/.test(v),\n hint: 'name',\n default: '',\n description: `Provide a string to define an identity for storing auth\n information when logging into registries.\n\n Authentication tokens will be stored in the XDG data\n directory, in \\`vlt/auth/$\\{identity}/keychain.json\\`.\n\n If no identity is provided, then the default \\`''\\` will\n be used, storing the file at \\`vlt/auth/keychain.json\\`.\n\n May only contain lowercase alphanumeric characters.\n `,\n },\n })\n\n .optList({\n workspace: {\n hint: 'ws',\n short: 'w',\n description: `Set to limit the spaces being worked on when working on\n workspaces.\n\n Can be paths or glob patterns matching paths.\n\n Specifying workspaces by package.json name is not\n supported.`,\n },\n 'workspace-group': {\n short: 'g',\n description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n 'if-present': {\n description: `When running scripts across multiple packages,\n only include packages that have the script.\n\n If this is not set, then the run will fail if any\n packages do not have the script.\n\n This will default to true if --scope, --workspace,\n --workspace-group, or --recursive is set. Otherwise,\n it will default to false.`,\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'user | project',\n description: `Specify whether to operate on user-level or project-level\n configuration files when running \\`vlt config\\` commands.`,\n validOptions: ['user', 'project'] as const,\n default: 'project',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard GUI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n The directory must exist and nothing will be copied to it.`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts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C,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView =\n // If stdout is a TTY, use human output\n process.stdout.isTTY ? 'human'\n // If its not a TTY but is a CI environment, use human output\n // TODO: make a better view option for CI environments\n : process.env.CI ? 'human'\n // Otherwise, use json output\n : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n exec: 'exec',\n 'exec-local': 'exec-local',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n serve: 'serve',\n token: 'token',\n uninstall: 'uninstall',\n update: 'update',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'uninstall',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n conf: 'config',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n 'node-version': {\n hint: 'version',\n description: `Node version to use when choosing packages based on\n their \\`engines.node\\` value.`,\n default: process.version,\n },\n })\n\n .flag({\n 'git-shallow': {\n description: `Set to force \\`--depth=1\\` on all git clone actions.\n When set explicitly to false with --no-git-shallow,\n then \\`--depth=1\\` will not be used.\n\n When not set explicitly, \\`--depth=1\\` will be used for\n git hosts known to support this behavior.`,\n },\n })\n .num({\n 'fetch-retries': {\n hint: 'n',\n description: `Number of retries to perform when encountering network\n errors or likely-transient errors from git hosts.`,\n default: 3,\n },\n 'fetch-retry-factor': {\n hint: 'n',\n description: `The exponential backoff factor to use when retrying\n requests due to network issues.`,\n default: 2,\n },\n 'fetch-retry-mintimeout': {\n hint: 'n',\n description: `Number of milliseconds before starting first retry`,\n default: 0,\n },\n 'fetch-retry-maxtimeout': {\n hint: 'n',\n description: `Maximum number of milliseconds between two retries`,\n default: 30_000,\n },\n 'stale-while-revalidate-factor': {\n hint: 'n',\n default: 60,\n description: `If the server does not serve a \\`stale-while-revalidate\\`\n value in the \\`cache-control\\` header, then this multiplier\n is applied to the \\`max-age\\` or \\`s-maxage\\` values.\n\n By default, this is \\`60\\`, so for example a response that\n is cacheable for 5 minutes will allow a stale response\n while revalidating for up to 5 hours.\n\n If the server *does* provide a \\`stale-while-revalidate\\`\n value, then that is always used.\n\n Set to 0 to prevent any \\`stale-while-revalidate\\` behavior\n unless explicitly allowed by the server's \\`cache-control\\`\n header.\n `,\n },\n })\n\n .opt({\n identity: {\n short: 'i',\n validate: (v: unknown) =>\n typeof v === 'string' && /^[a-z0-9]*$/.test(v),\n hint: 'name',\n default: '',\n description: `Provide a string to define an identity for storing auth\n information when logging into registries.\n\n Authentication tokens will be stored in the XDG data\n directory, in \\`vlt/auth/$\\{identity}/keychain.json\\`.\n\n If no identity is provided, then the default \\`''\\` will\n be used, storing the file at \\`vlt/auth/keychain.json\\`.\n\n May only contain lowercase alphanumeric characters.\n `,\n },\n })\n\n .optList({\n workspace: {\n hint: 'ws',\n short: 'w',\n description: `Set to limit the spaces being worked on when working on\n workspaces.\n\n Can be paths or glob patterns matching paths.\n\n Specifying workspaces by package.json name is not\n supported.`,\n },\n 'workspace-group': {\n short: 'g',\n description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n 'if-present': {\n description: `When running scripts across multiple packages,\n only include packages that have the script.\n\n If this is not set, then the run will fail if any\n packages do not have the script.\n\n This will default to true if --scope, --workspace,\n --workspace-group, or --recursive is set. Otherwise,\n it will default to false.`,\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'user | project',\n description: `Specify whether to operate on user-level or project-level\n configuration files when running \\`vlt config\\` commands.`,\n validOptions: ['user', 'project'] as const,\n default: 'project',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard browser-based UI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n The directory must exist and nothing will be copied to it.`,\n },\n port: {\n hint: 'number',\n description: `Port for the browser-based UI server when using vlt serve command (default: 8000).`,\n },\n 'registry-port': {\n hint: 'number',\n description: `Port for the VSR registry when using vlt serve command (default: 1337).`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EACV,IAAI,EACJ,MAAM,EACN,WAAW,EACX,GAAG,EACH,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,aAAa,CAAA;AAMpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,O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IAAI,EAAE,UAAU,CAAA;IAChB,eAAe,0BAKb;gBAEU,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IAmB5C,OAAO,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAIpC,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IA+HhC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IA0B3C,gBAAgB,IAAI,MAAM;IAU1B,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,MAAM,IAAI,MAAM;IAYhB,KAAK,IAAI,aAAa,GAAG,SAAS;IAmBlC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa;IAgBhE,YAAY,IAAI,SAAS;IAKzB,WAAW,IAAI,cAAc;IAM7B,UAAU,IAAI;QACZ,KAAK,EAAE,MAAM,CAAA;QACb,GAAG,EAAE,MAAM,CAAA;QACX,QAAQ,EAAE,kBAAkB,CAAA;KAC7B,EAAE;CAsBJ"}
|
package/dist/esm/exec-command.js
CHANGED
|
@@ -12,6 +12,7 @@ import { ansiToAnsi } from 'ansi-to-pre';
|
|
|
12
12
|
import { stderr, stdout, styleTextStdout } from "./output.js";
|
|
13
13
|
import assert from 'node:assert';
|
|
14
14
|
import { resolve } from 'node:path';
|
|
15
|
+
import { createHostContextsMap } from "./query-host-contexts.js";
|
|
15
16
|
const isScriptSet = (o) => {
|
|
16
17
|
if (!o || typeof o !== 'object')
|
|
17
18
|
return false;
|
|
@@ -54,6 +55,7 @@ export class ExecCommand {
|
|
|
54
55
|
fg;
|
|
55
56
|
arg0;
|
|
56
57
|
args;
|
|
58
|
+
env;
|
|
57
59
|
#monorepo;
|
|
58
60
|
#nodes;
|
|
59
61
|
#defaultIgnoreMissing = false;
|
|
@@ -93,16 +95,25 @@ export class ExecCommand {
|
|
|
93
95
|
// scope takes precedence over workspaces or groups
|
|
94
96
|
if (queryString) {
|
|
95
97
|
this.#defaultIgnoreMissing = true;
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const mainManifest = conf.options.packageJson.maybeRead(this.projectRoot);
|
|
99
|
+
let graph;
|
|
100
|
+
if (mainManifest) {
|
|
101
|
+
graph = actual.load({
|
|
102
|
+
...conf.options,
|
|
103
|
+
mainManifest,
|
|
104
|
+
monorepo: Monorepo.load(this.projectRoot),
|
|
105
|
+
loadManifests: false,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const hostContexts = await createHostContextsMap(conf);
|
|
102
109
|
const query = new Query({
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
/* c8 ignore start */
|
|
111
|
+
nodes: graph ? new Set(graph.nodes.values()) : new Set(),
|
|
112
|
+
edges: graph?.edges ?? new Set(),
|
|
113
|
+
importers: graph?.importers ?? new Set(),
|
|
114
|
+
/* c8 ignore stop */
|
|
105
115
|
securityArchive: undefined,
|
|
116
|
+
hostContexts,
|
|
106
117
|
});
|
|
107
118
|
const { nodes } = await query.search(queryString, {
|
|
108
119
|
signal: new AbortController().signal,
|
|
@@ -243,6 +254,7 @@ export class ExecCommand {
|
|
|
243
254
|
cwd,
|
|
244
255
|
arg0,
|
|
245
256
|
args: this.args,
|
|
257
|
+
env: this.env,
|
|
246
258
|
projectRoot: this.projectRoot,
|
|
247
259
|
packageJson: this.conf.options.packageJson,
|
|
248
260
|
'script-shell': this.arg0 ? this.conf.get('script-shell') : false,
|
|
@@ -255,6 +267,7 @@ export class ExecCommand {
|
|
|
255
267
|
ignoreMissing: this.conf.get('if-present') ?? this.#defaultIgnoreMissing,
|
|
256
268
|
arg0: this.arg0,
|
|
257
269
|
args: this.args,
|
|
270
|
+
env: this.env,
|
|
258
271
|
projectRoot: this.projectRoot,
|
|
259
272
|
packageJson: this.conf.options.packageJson,
|
|
260
273
|
'script-shell': this.conf.get('script-shell'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-command.js","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAehD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7D,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAcnC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAkB,EAAE;IACjD,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7C,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;IACzC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CACvB,CAAa,EACmB,EAAE;IAClC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAA;IACnC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC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,OAAO,CAAC,EAAE,CAAC,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK,EAAE,EAAE,CAAC,IAAI;oBACd,GAAG,EAAE,EAAE,CAAC,QAAQ;oBAChB,QAAQ,EAAE,EAAE,CAAC,QAAQ;iBACtB,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["/**\n * impl for `vlt run`, `vlt run-exec`, `vlt exec-local`, `vlt exec`\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { isErrorWithCause } from '@vltpkg/types'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type {\n exec,\n execFG,\n ExecOptions,\n run,\n runExec,\n runExecFG,\n RunExecOptions,\n runFG,\n RunFGResult,\n RunOptions,\n RunResult,\n} from '@vltpkg/run'\nimport { Query } from '@vltpkg/query'\nimport { actual } from '@vltpkg/graph'\nimport { isRunResult } from '@vltpkg/run'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { ansiToAnsi } from 'ansi-to-pre'\nimport type { LoadedConfig } from './config/index.ts'\nimport { stderr, stdout, styleTextStdout } from './output.ts'\nimport type { Views } from './view.ts'\nimport type { SpawnResultStdioStrings } from '@vltpkg/promise-spawn'\nimport assert from 'node:assert'\nimport { resolve } from 'node:path'\n\nexport type RunnerBG = typeof exec | typeof run | typeof runExec\nexport type RunnerFG = typeof execFG | typeof runExecFG | typeof runFG\nexport type RunnerOptions = ExecOptions & RunExecOptions & RunOptions\nexport type MultiRunResult = Record<string, RunResult>\nexport type ScriptSet = Record<string, string>\nexport type MultiScriptSet = Record<string, ScriptSet>\nexport type ExecResult =\n | RunFGResult\n | MultiRunResult\n | ScriptSet\n | MultiScriptSet\n\nconst isScriptSet = (o: unknown): o is ScriptSet => {\n if (!o || typeof o !== 'object') return false\n for (const v of Object.values(o)) {\n if (typeof v !== 'string') return false\n }\n return true\n}\n\nconst isMultiScriptSet = (\n o: ExecResult,\n): o is Record<string, ScriptSet> => {\n for (const v of Object.values(o)) {\n if (!isScriptSet(v)) return false\n }\n return true\n}\n\nconst isSingleSuccess = (\n o: RunResult,\n): o is RunResult & { status: 0; signal: null } =>\n o.signal === null && o.status === 0\n\nconst setExitCode = (result: RunResult) => {\n /* c8 ignore next */\n process.exitCode ||= result.status ?? 1\n}\n\nexport const views = {\n // run results for single or multiple will be printed along the way.\n human: result => {\n if (isScriptSet(result)) stdout('Scripts available:', result)\n else if (isMultiScriptSet(result)) {\n stdout('Scripts available:')\n for (const [path, scripts] of Object.entries(result)) {\n stdout(path, scripts)\n }\n }\n },\n json: result =>\n isRunResult(result) && isSingleSuccess(result) ?\n undefined\n : result,\n} as const satisfies Views<ExecResult>\n\ntype ViewValues = 'human' | 'json' | 'inspect' | 'silent'\n\nexport class ExecCommand<B extends RunnerBG, F extends RunnerFG> {\n bg: B\n fg: F\n arg0?: string\n args: string[]\n #monorepo?: Monorepo\n #nodes?: string[]\n #defaultIgnoreMissing = false\n conf: LoadedConfig\n projectRoot: string\n view: ViewValues\n validViewValues = new Map<string, ViewValues>([\n ['human', 'human'],\n ['json', 'json'],\n ['inspect', 'inspect'],\n ['silent', 'silent'],\n ])\n\n constructor(conf: LoadedConfig, bg: B, fg: F) {\n this.conf = conf\n this.bg = bg\n this.fg = fg\n this.view = this.validViewValues.get(conf.values.view) ?? 'human'\n const {\n projectRoot,\n positionals: [arg0, ...args],\n } = conf\n this.arg0 = arg0\n this.args = args\n this.projectRoot = projectRoot\n }\n\n #targetCount(): number {\n if (this.#nodes) return this.#nodes.length\n return this.#monorepo?.size ?? 1\n }\n\n hasArg0(): this is this & { arg0: string } {\n return !!this.arg0\n }\n\n async run(): Promise<ExecResult> {\n const { conf } = this\n\n const queryString = conf.get('scope')\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n\n // scope takes precedence over workspaces or groups\n if (queryString) {\n this.#defaultIgnoreMissing = true\n const graph = actual.load({\n ...conf.options,\n mainManifest: conf.options.packageJson.read(this.projectRoot),\n monorepo: Monorepo.load(this.projectRoot),\n loadManifests: false,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive: undefined,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n this.#nodes = []\n for (const node of nodes) {\n const { location } = node.toJSON()\n assert(\n location,\n error(`node ${node.id} has no location`, {\n found: node,\n }),\n )\n this.#nodes.push(location)\n }\n } else if (paths?.length || groups?.length || recursive) {\n this.#defaultIgnoreMissing = true\n this.#monorepo = Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n }\n\n if (this.#targetCount() === 1) {\n const arg = this.fgArg()\n if (!arg) return this.noArgsSingle()\n const result = await this.fg(arg)\n if (isRunResult(result)) {\n setExitCode(result)\n }\n return result\n }\n\n if (this.#targetCount() === 0) {\n if (queryString) {\n throw error('no matching nodes found for query', {\n found: queryString,\n })\n } else {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.#monorepo?.load().paths() ?? [])],\n })\n }\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false as boolean\n const runInDir = async (cwd: string, label: string) => {\n const result = await this.bg(this.bgArg(cwd)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(label, er.cause)\n }\n failed = true\n throw er\n },\n )\n // If we are allowed to ignore missing commands, then command might be\n // an emptry string. If so, we don't print anything and return null to\n // be filtered out later.\n if (!result.command) return null\n if (!failed) this.printResult(label, result)\n return result\n }\n\n const resultMap = new Map<string, SpawnResultStdioStrings>()\n if (this.#nodes) {\n for (const { label, cwd } of this.getTargets()) {\n const result = await runInDir(cwd, label)\n if (result) resultMap.set(label, result)\n }\n } else if (this.#monorepo) {\n const wsResultMap = await this.#monorepo.run(ws =>\n runInDir(ws.fullpath, ws.path),\n )\n for (const [ws, result] of wsResultMap) {\n if (result) resultMap.set(ws.path, result)\n }\n }\n\n const results: Record<string, RunResult> = {}\n for (const [path, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[path] = result\n }\n return results\n }\n\n printResult(path: string, result: RunResult) {\n // non-human results just get printed at the end\n if (this.view !== 'human') return\n\n if (result.status === 0 && result.signal === null) {\n stdout(path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n path + ' failure',\n ),\n {\n status: result.status,\n signal: result.signal,\n },\n )\n /* c8 ignore start */\n if (result.stderr) stderr(ansiToAnsi(result.stderr))\n if (result.stdout) stdout(ansiToAnsi(result.stdout))\n /* c8 ignore stop */\n setExitCode(result)\n }\n }\n\n /* c8 ignore start - env specific */\n interactiveShell(): string {\n return (\n process.env.SHELL ??\n this.conf.get('script-shell') ??\n (process.platform === 'win32' ? 'cmd.exe' : '/bin/sh')\n )\n }\n /* c8 ignore stop */\n\n // overridden by 'vlt run' which returns undefined\n defaultArg0(): string | undefined {\n return this.interactiveShell()\n }\n\n getCwd(): string {\n if (this.#nodes) {\n const [first] = this.#nodes\n assert(first, error('no nodes found'))\n return resolve(this.projectRoot, first)\n }\n return (\n this.#monorepo?.values().next().value?.fullpath ??\n this.projectRoot\n )\n }\n\n fgArg(): RunnerOptions | undefined {\n const cwd = this.getCwd()\n const arg0 = this.arg0 ?? this.defaultArg0()\n\n // return undefined so noArgsSingle will be called instead\n if (typeof arg0 !== 'string') return\n\n return {\n cwd,\n arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.conf.options.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, cwd: string): RunnerOptions {\n return {\n cwd,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing:\n this.conf.get('if-present') ?? this.#defaultIgnoreMissing,\n arg0: this.arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.conf.options.packageJson,\n 'script-shell': this.conf.get('script-shell'),\n }\n }\n\n /* c8 ignore start - not used, only here to override */\n noArgsSingle(): ScriptSet {\n throw error('Failed to determine interactive shell to spawn')\n }\n /* c8 ignore stop - not used, only here to override */\n\n noArgsMulti(): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\n }\n\n getTargets(): {\n label: string\n cwd: string\n manifest: NormalizedManifest\n }[] {\n const targets = []\n if (this.#nodes) {\n for (const location of this.#nodes) {\n const manifest = this.conf.options.packageJson.read(location)\n const label =\n /* c8 ignore next */\n location.startsWith('./') ? location.slice(2) : location\n const cwd = resolve(this.projectRoot, location)\n targets.push({ label, cwd, manifest })\n }\n } else if (this.#monorepo) {\n this.#monorepo.runSync(ws => {\n targets.push({\n label: ws.path,\n cwd: ws.fullpath,\n manifest: ws.manifest,\n })\n })\n }\n return targets\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"exec-command.js","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAehD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7D,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAchE,MAAM,WAAW,GAAG,CAA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AAC,CAAA;QACJ,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["/**\n * impl for `vlt run`, `vlt run-exec`, `vlt exec-local`, `vlt exec`\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { isErrorWithCause } from '@vltpkg/types'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type {\n exec,\n execFG,\n ExecOptions,\n run,\n runExec,\n runExecFG,\n RunExecOptions,\n runFG,\n RunFGResult,\n RunOptions,\n RunResult,\n} from '@vltpkg/run'\nimport { Query } from '@vltpkg/query'\nimport { actual } from '@vltpkg/graph'\nimport { isRunResult } from '@vltpkg/run'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { ansiToAnsi } from 'ansi-to-pre'\nimport type { LoadedConfig } from './config/index.ts'\nimport { stderr, stdout, styleTextStdout } from './output.ts'\nimport type { Views } from './view.ts'\nimport type { SpawnResultStdioStrings } from '@vltpkg/promise-spawn'\nimport assert from 'node:assert'\nimport { resolve } from 'node:path'\nimport { createHostContextsMap } from './query-host-contexts.ts'\n\nexport type RunnerBG = typeof exec | typeof run | typeof runExec\nexport type RunnerFG = typeof execFG | typeof runExecFG | typeof runFG\nexport type RunnerOptions = ExecOptions & RunExecOptions & RunOptions\nexport type MultiRunResult = Record<string, RunResult>\nexport type ScriptSet = Record<string, string>\nexport type MultiScriptSet = Record<string, ScriptSet>\nexport type ExecResult =\n | RunFGResult\n | MultiRunResult\n | ScriptSet\n | MultiScriptSet\n\nconst isScriptSet = (o: unknown): o is ScriptSet => {\n if (!o || typeof o !== 'object') return false\n for (const v of Object.values(o)) {\n if (typeof v !== 'string') return false\n }\n return true\n}\n\nconst isMultiScriptSet = (\n o: ExecResult,\n): o is Record<string, ScriptSet> => {\n for (const v of Object.values(o)) {\n if (!isScriptSet(v)) return false\n }\n return true\n}\n\nconst isSingleSuccess = (\n o: RunResult,\n): o is RunResult & { status: 0; signal: null } =>\n o.signal === null && o.status === 0\n\nconst setExitCode = (result: RunResult) => {\n /* c8 ignore next */\n process.exitCode ||= result.status ?? 1\n}\n\nexport const views = {\n // run results for single or multiple will be printed along the way.\n human: result => {\n if (isScriptSet(result)) stdout('Scripts available:', result)\n else if (isMultiScriptSet(result)) {\n stdout('Scripts available:')\n for (const [path, scripts] of Object.entries(result)) {\n stdout(path, scripts)\n }\n }\n },\n json: result =>\n isRunResult(result) && isSingleSuccess(result) ?\n undefined\n : result,\n} as const satisfies Views<ExecResult>\n\ntype ViewValues = 'human' | 'json' | 'inspect' | 'silent'\n\nexport class ExecCommand<B extends RunnerBG, F extends RunnerFG> {\n bg: B\n fg: F\n arg0?: string\n args: string[]\n env?: NodeJS.ProcessEnv\n #monorepo?: Monorepo\n #nodes?: string[]\n #defaultIgnoreMissing = false\n conf: LoadedConfig\n projectRoot: string\n view: ViewValues\n validViewValues = new Map<string, ViewValues>([\n ['human', 'human'],\n ['json', 'json'],\n ['inspect', 'inspect'],\n ['silent', 'silent'],\n ])\n\n constructor(conf: LoadedConfig, bg: B, fg: F) {\n this.conf = conf\n this.bg = bg\n this.fg = fg\n this.view = this.validViewValues.get(conf.values.view) ?? 'human'\n const {\n projectRoot,\n positionals: [arg0, ...args],\n } = conf\n this.arg0 = arg0\n this.args = args\n this.projectRoot = projectRoot\n }\n\n #targetCount(): number {\n if (this.#nodes) return this.#nodes.length\n return this.#monorepo?.size ?? 1\n }\n\n hasArg0(): this is this & { arg0: string } {\n return !!this.arg0\n }\n\n async run(): Promise<ExecResult> {\n const { conf } = this\n\n const queryString = conf.get('scope')\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n\n // scope takes precedence over workspaces or groups\n if (queryString) {\n this.#defaultIgnoreMissing = true\n const mainManifest = conf.options.packageJson.maybeRead(\n this.projectRoot,\n )\n let graph\n if (mainManifest) {\n graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo: Monorepo.load(this.projectRoot),\n loadManifests: false,\n })\n }\n const hostContexts = await createHostContextsMap(conf)\n const query = new Query({\n /* c8 ignore start */\n nodes: graph ? new Set(graph.nodes.values()) : new Set(),\n edges: graph?.edges ?? new Set(),\n importers: graph?.importers ?? new Set(),\n /* c8 ignore stop */\n securityArchive: undefined,\n hostContexts,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n this.#nodes = []\n for (const node of nodes) {\n const { location } = node.toJSON()\n assert(\n location,\n error(`node ${node.id} has no location`, {\n found: node,\n }),\n )\n this.#nodes.push(location)\n }\n } else if (paths?.length || groups?.length || recursive) {\n this.#defaultIgnoreMissing = true\n this.#monorepo = Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n }\n\n if (this.#targetCount() === 1) {\n const arg = this.fgArg()\n if (!arg) return this.noArgsSingle()\n const result = await this.fg(arg)\n if (isRunResult(result)) {\n setExitCode(result)\n }\n return result\n }\n\n if (this.#targetCount() === 0) {\n if (queryString) {\n throw error('no matching nodes found for query', {\n found: queryString,\n })\n } else {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.#monorepo?.load().paths() ?? [])],\n })\n }\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false as boolean\n const runInDir = async (cwd: string, label: string) => {\n const result = await this.bg(this.bgArg(cwd)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(label, er.cause)\n }\n failed = true\n throw er\n },\n )\n // If we are allowed to ignore missing commands, then command might be\n // an emptry string. If so, we don't print anything and return null to\n // be filtered out later.\n if (!result.command) return null\n if (!failed) this.printResult(label, result)\n return result\n }\n\n const resultMap = new Map<string, SpawnResultStdioStrings>()\n if (this.#nodes) {\n for (const { label, cwd } of this.getTargets()) {\n const result = await runInDir(cwd, label)\n if (result) resultMap.set(label, result)\n }\n } else if (this.#monorepo) {\n const wsResultMap = await this.#monorepo.run(ws =>\n runInDir(ws.fullpath, ws.path),\n )\n for (const [ws, result] of wsResultMap) {\n if (result) resultMap.set(ws.path, result)\n }\n }\n\n const results: Record<string, RunResult> = {}\n for (const [path, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[path] = result\n }\n return results\n }\n\n printResult(path: string, result: RunResult) {\n // non-human results just get printed at the end\n if (this.view !== 'human') return\n\n if (result.status === 0 && result.signal === null) {\n stdout(path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n path + ' failure',\n ),\n {\n status: result.status,\n signal: result.signal,\n },\n )\n /* c8 ignore start */\n if (result.stderr) stderr(ansiToAnsi(result.stderr))\n if (result.stdout) stdout(ansiToAnsi(result.stdout))\n /* c8 ignore stop */\n setExitCode(result)\n }\n }\n\n /* c8 ignore start - env specific */\n interactiveShell(): string {\n return (\n process.env.SHELL ??\n this.conf.get('script-shell') ??\n (process.platform === 'win32' ? 'cmd.exe' : '/bin/sh')\n )\n }\n /* c8 ignore stop */\n\n // overridden by 'vlt run' which returns undefined\n defaultArg0(): string | undefined {\n return this.interactiveShell()\n }\n\n getCwd(): string {\n if (this.#nodes) {\n const [first] = this.#nodes\n assert(first, error('no nodes found'))\n return resolve(this.projectRoot, first)\n }\n return (\n this.#monorepo?.values().next().value?.fullpath ??\n this.projectRoot\n )\n }\n\n fgArg(): RunnerOptions | undefined {\n const cwd = this.getCwd()\n const arg0 = this.arg0 ?? this.defaultArg0()\n\n // return undefined so noArgsSingle will be called instead\n if (typeof arg0 !== 'string') return\n\n return {\n cwd,\n arg0,\n args: this.args,\n env: this.env,\n projectRoot: this.projectRoot,\n packageJson: this.conf.options.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, cwd: string): RunnerOptions {\n return {\n cwd,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing:\n this.conf.get('if-present') ?? this.#defaultIgnoreMissing,\n arg0: this.arg0,\n args: this.args,\n env: this.env,\n projectRoot: this.projectRoot,\n packageJson: this.conf.options.packageJson,\n 'script-shell': this.conf.get('script-shell'),\n }\n }\n\n /* c8 ignore start - not used, only here to override */\n noArgsSingle(): ScriptSet {\n throw error('Failed to determine interactive shell to spawn')\n }\n /* c8 ignore stop - not used, only here to override */\n\n noArgsMulti(): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\n }\n\n getTargets(): {\n label: string\n cwd: string\n manifest: NormalizedManifest\n }[] {\n const targets = []\n if (this.#nodes) {\n for (const location of this.#nodes) {\n const manifest = this.conf.options.packageJson.read(location)\n const label =\n /* c8 ignore next */\n location.startsWith('./') ? location.slice(2) : location\n const cwd = resolve(this.projectRoot, location)\n targets.push({ label, cwd, manifest })\n }\n } else if (this.#monorepo) {\n this.#monorepo.runSync(ws => {\n targets.push({\n label: ws.path,\n cwd: ws.fullpath,\n manifest: ws.manifest,\n })\n })\n }\n return targets\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
2
|
+
import type { EdgeLike, NodeLike } from '@vltpkg/types';
|
|
3
|
+
import type { LoadedConfig } from './config/index.ts';
|
|
4
|
+
export type HostContextsMapResult = {
|
|
5
|
+
initialEdges: EdgeLike[];
|
|
6
|
+
initialNodes: NodeLike[];
|
|
7
|
+
edges: EdgeLike[];
|
|
8
|
+
nodes: NodeLike[];
|
|
9
|
+
securityArchive: SecurityArchive;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Map of host context functions that can be used by the :host
|
|
13
|
+
* pseudo selector to dynamically load graphs from different sources.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createHostContextsMap: (conf: LoadedConfig) => Promise<Map<string, () => Promise<HostContextsMapResult>>>;
|
|
16
|
+
//# sourceMappingURL=query-host-contexts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-host-contexts.d.ts","sourceRoot":"","sources":["../../src/query-host-contexts.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,QAAQ,EAAE,CAAA;IACxB,YAAY,EAAE,QAAQ,EAAE,CAAA;IACxB,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,eAAe,EAAE,eAAe,CAAA;CACjC,CAAA;AA8CD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,SAC1B,YAAY,KACjB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAiH3D,CAAA"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { parse, posix } from 'node:path';
|
|
3
|
+
import { getProjectData, readProjectFolders, reloadConfig, } from '@vltpkg/server';
|
|
4
|
+
import { actual, createVirtualRoot } from '@vltpkg/graph';
|
|
5
|
+
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
6
|
+
import { error } from '@vltpkg/error-cause';
|
|
7
|
+
// In restricted environments (like locked-down Codespaces),
|
|
8
|
+
// homedir() might fail. Fall back to parent directory.
|
|
9
|
+
let foundHome;
|
|
10
|
+
try {
|
|
11
|
+
foundHome = posix.format(parse(homedir()));
|
|
12
|
+
/* c8 ignore next 3 */
|
|
13
|
+
}
|
|
14
|
+
catch { }
|
|
15
|
+
const home = foundHome ?? posix.dirname(posix.format(parse(process.cwd())));
|
|
16
|
+
/**
|
|
17
|
+
* Generates possible project keys for a given folder.
|
|
18
|
+
*/
|
|
19
|
+
const getPossibleProjectKeys = (folder, scurry) => {
|
|
20
|
+
const relativePath = posix.relative(scurry.cwd.fullpathPosix(), folder.fullpathPosix());
|
|
21
|
+
const absolutePath = folder.fullpathPosix();
|
|
22
|
+
const homeRelativePath = posix.relative(scurry.resolvePosix(home), folder.fullpathPosix());
|
|
23
|
+
const dotRelativeKey = relativePath === '' ? 'file:.' : `file:./${relativePath}`;
|
|
24
|
+
const relativeKey = `file:${relativePath}`;
|
|
25
|
+
const absoluteKey = `file:${absolutePath}`;
|
|
26
|
+
const homeRelativeKey = `file:~/${homeRelativePath}`;
|
|
27
|
+
const keys = [
|
|
28
|
+
relativeKey,
|
|
29
|
+
dotRelativeKey,
|
|
30
|
+
absoluteKey,
|
|
31
|
+
homeRelativeKey,
|
|
32
|
+
`${relativeKey}/`,
|
|
33
|
+
`${dotRelativeKey}/`,
|
|
34
|
+
`${absoluteKey}/`,
|
|
35
|
+
`${homeRelativeKey}/`,
|
|
36
|
+
];
|
|
37
|
+
return new Set(keys);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Map of host context functions that can be used by the :host
|
|
41
|
+
* pseudo selector to dynamically load graphs from different sources.
|
|
42
|
+
*/
|
|
43
|
+
export const createHostContextsMap = async (conf) => {
|
|
44
|
+
const hostContexts = new Map();
|
|
45
|
+
// Read all project folders from the configured paths
|
|
46
|
+
const { scurry } = conf.options;
|
|
47
|
+
const projectFolders = await readProjectFolders({
|
|
48
|
+
scurry,
|
|
49
|
+
userDefinedProjectPaths: conf.options['dashboard-root'] ?? [],
|
|
50
|
+
});
|
|
51
|
+
for (const folder of projectFolders) {
|
|
52
|
+
const retrieveProjectGraph = async () => {
|
|
53
|
+
const initialEdges = [];
|
|
54
|
+
const initialNodes = [];
|
|
55
|
+
const config = await reloadConfig(folder.fullpath());
|
|
56
|
+
// load each individual graph
|
|
57
|
+
const graph = actual.load({
|
|
58
|
+
...config.options,
|
|
59
|
+
projectRoot: folder.fullpath(),
|
|
60
|
+
skipLoadingNodesOnModifiersChange: false,
|
|
61
|
+
});
|
|
62
|
+
initialEdges.push(...graph.edges);
|
|
63
|
+
initialNodes.push(...graph.nodes.values());
|
|
64
|
+
// Initialize security archive with all loaded nodes
|
|
65
|
+
const securityArchive = await SecurityArchive.start({
|
|
66
|
+
nodes: initialNodes,
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
initialEdges,
|
|
70
|
+
initialNodes,
|
|
71
|
+
edges: [],
|
|
72
|
+
nodes: [graph.mainImporter],
|
|
73
|
+
securityArchive,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
// add multiple keys for each project folder
|
|
77
|
+
for (const path of getPossibleProjectKeys(folder, scurry)) {
|
|
78
|
+
if (!hostContexts.has(path)) {
|
|
79
|
+
hostContexts.set(path, retrieveProjectGraph);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Define local context - loads graphs from all projects in user's project paths
|
|
84
|
+
hostContexts.set('local', async () => {
|
|
85
|
+
// Load graphs from each project folder
|
|
86
|
+
const initialEdges = [];
|
|
87
|
+
const initialNodes = [];
|
|
88
|
+
const mainImporters = [];
|
|
89
|
+
for (const folder of projectFolders) {
|
|
90
|
+
try {
|
|
91
|
+
const config = await reloadConfig(folder.fullpath());
|
|
92
|
+
const projectInfo = getProjectData({
|
|
93
|
+
packageJson: config.options.packageJson,
|
|
94
|
+
scurry: config.options.scurry,
|
|
95
|
+
}, folder);
|
|
96
|
+
// only include projects that are vlt-installed
|
|
97
|
+
if (!projectInfo.vltInstalled) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
// load each individual graph
|
|
101
|
+
const graph = actual.load({
|
|
102
|
+
...config.options,
|
|
103
|
+
projectRoot: folder.fullpath(),
|
|
104
|
+
skipLoadingNodesOnModifiersChange: false,
|
|
105
|
+
});
|
|
106
|
+
initialEdges.push(...graph.edges);
|
|
107
|
+
initialNodes.push(...graph.nodes.values());
|
|
108
|
+
mainImporters.push(graph.mainImporter);
|
|
109
|
+
}
|
|
110
|
+
catch (_error) {
|
|
111
|
+
// Skip projects that fail to load
|
|
112
|
+
// This might happen for projects without proper package.json
|
|
113
|
+
// or other loading issues
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Initialize security archive with all loaded nodes
|
|
118
|
+
const securityArchive = await SecurityArchive.start({
|
|
119
|
+
nodes: initialNodes,
|
|
120
|
+
});
|
|
121
|
+
const virtualRoot = createVirtualRoot('local', conf.options, mainImporters);
|
|
122
|
+
if (!virtualRoot) {
|
|
123
|
+
throw error('Failed to create virtual root for local context');
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
initialEdges,
|
|
127
|
+
initialNodes,
|
|
128
|
+
edges: [],
|
|
129
|
+
nodes: [virtualRoot],
|
|
130
|
+
securityArchive,
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
return hostContexts;
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=query-host-contexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-host-contexts.js","sourceRoot":"","sources":["../../src/query-host-contexts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,YAAY,GACb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAa3C,4DAA4D;AAC5D,uDAAuD;AACvD,IAAI,SAAS,CAAA;AACb,IAAI,CAAC;IACH,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IAC1C,sBAAsB;AACxB,CAAC;AAAC,MAAM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CAAC,KAAK,CAAC;YAClD,KAAK,EAAE,YAAY;SACpB,CAAC,CAAA;QAEF,MAAM,WAAW,GAAG,iBAAiB,CACnC,OAAO,EACP,IAAI,CAAC,OAAO,EACZ,aAAa,CACd,CAAA;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,KAAK,CAAC,iDAAiD,CAAC,CAAA;QAChE,CAAC;QAED,OAAO;YACL,YAAY;YACZ,YAAY;YACZ,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,eAAe;SAChB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA","sourcesContent":["import { homedir } from 'node:os'\nimport { parse, posix } from 'node:path'\nimport {\n getProjectData,\n readProjectFolders,\n reloadConfig,\n} from '@vltpkg/server'\nimport { actual, createVirtualRoot } from '@vltpkg/graph'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { error } from '@vltpkg/error-cause'\nimport type { PathBase, PathScurry } from 'path-scurry'\nimport type { EdgeLike, NodeLike } from '@vltpkg/types'\nimport type { LoadedConfig } from './config/index.ts'\n\nexport type HostContextsMapResult = {\n initialEdges: EdgeLike[]\n initialNodes: NodeLike[]\n edges: EdgeLike[]\n nodes: NodeLike[]\n securityArchive: SecurityArchive\n}\n\n// In restricted environments (like locked-down Codespaces),\n// homedir() might fail. Fall back to parent directory.\nlet foundHome\ntry {\n foundHome = posix.format(parse(homedir()))\n /* c8 ignore next 3 */\n} catch {}\nconst home =\n foundHome ?? posix.dirname(posix.format(parse(process.cwd())))\n\n/**\n * Generates possible project keys for a given folder.\n */\nconst getPossibleProjectKeys = (\n folder: PathBase,\n scurry: PathScurry,\n): Set<string> => {\n const relativePath = posix.relative(\n scurry.cwd.fullpathPosix(),\n folder.fullpathPosix(),\n )\n const absolutePath = folder.fullpathPosix()\n const homeRelativePath = posix.relative(\n scurry.resolvePosix(home),\n folder.fullpathPosix(),\n )\n const dotRelativeKey =\n relativePath === '' ? 'file:.' : `file:./${relativePath}`\n const relativeKey = `file:${relativePath}`\n const absoluteKey = `file:${absolutePath}`\n const homeRelativeKey = `file:~/${homeRelativePath}`\n const keys = [\n relativeKey,\n dotRelativeKey,\n absoluteKey,\n homeRelativeKey,\n `${relativeKey}/`,\n `${dotRelativeKey}/`,\n `${absoluteKey}/`,\n `${homeRelativeKey}/`,\n ]\n return new Set(keys)\n}\n\n/**\n * Creates a Map of host context functions that can be used by the :host\n * pseudo selector to dynamically load graphs from different sources.\n */\nexport const createHostContextsMap = async (\n conf: LoadedConfig,\n): Promise<Map<string, () => Promise<HostContextsMapResult>>> => {\n const hostContexts = new Map<\n string,\n () => Promise<HostContextsMapResult>\n >()\n // Read all project folders from the configured paths\n const { scurry } = conf.options\n const projectFolders = await readProjectFolders({\n scurry,\n userDefinedProjectPaths: conf.options['dashboard-root'] ?? [],\n })\n\n for (const folder of projectFolders) {\n const retrieveProjectGraph = async () => {\n const initialEdges: EdgeLike[] = []\n const initialNodes: NodeLike[] = []\n const config = await reloadConfig(folder.fullpath())\n\n // load each individual graph\n const graph = actual.load({\n ...config.options,\n projectRoot: folder.fullpath(),\n skipLoadingNodesOnModifiersChange: false,\n })\n initialEdges.push(...graph.edges)\n initialNodes.push(...graph.nodes.values())\n\n // Initialize security archive with all loaded nodes\n const securityArchive = await SecurityArchive.start({\n nodes: initialNodes,\n })\n\n return {\n initialEdges,\n initialNodes,\n edges: [],\n nodes: [graph.mainImporter],\n securityArchive,\n }\n }\n\n // add multiple keys for each project folder\n for (const path of getPossibleProjectKeys(folder, scurry)) {\n if (!hostContexts.has(path)) {\n hostContexts.set(path, retrieveProjectGraph)\n }\n }\n }\n\n // Define local context - loads graphs from all projects in user's project paths\n hostContexts.set('local', async () => {\n // Load graphs from each project folder\n const initialEdges: EdgeLike[] = []\n const initialNodes: NodeLike[] = []\n const mainImporters: NodeLike[] = []\n for (const folder of projectFolders) {\n try {\n const config = await reloadConfig(folder.fullpath())\n const projectInfo = getProjectData(\n {\n packageJson: config.options.packageJson,\n scurry: config.options.scurry,\n },\n folder,\n )\n\n // only include projects that are vlt-installed\n if (!projectInfo.vltInstalled) {\n continue\n }\n\n // load each individual graph\n const graph = actual.load({\n ...config.options,\n projectRoot: folder.fullpath(),\n skipLoadingNodesOnModifiersChange: false,\n })\n initialEdges.push(...graph.edges)\n initialNodes.push(...graph.nodes.values())\n mainImporters.push(graph.mainImporter)\n } catch (_error) {\n // Skip projects that fail to load\n // This might happen for projects without proper package.json\n // or other loading issues\n continue\n }\n }\n\n // Initialize security archive with all loaded nodes\n const securityArchive = await SecurityArchive.start({\n nodes: initialNodes,\n })\n\n const virtualRoot = createVirtualRoot(\n 'local',\n conf.options,\n mainImporters,\n )\n\n if (!virtualRoot) {\n throw error('Failed to create virtual root for local context')\n }\n\n return {\n initialEdges,\n initialNodes,\n edges: [],\n nodes: [virtualRoot],\n securityArchive,\n }\n })\n\n return hostContexts\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-gui.d.ts","sourceRoot":"","sources":["../../src/start-gui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,eAAO,MAAM,uBAAuB,YAAmB;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,UAAU,CAAA;CACnB,oBAYA,CAAA;AAaD,eAAO,MAAM,QAAQ,SACb,YAAY,kBACF,MAAM,
|
|
1
|
+
{"version":3,"file":"start-gui.d.ts","sourceRoot":"","sources":["../../src/start-gui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,eAAO,MAAM,uBAAuB,YAAmB;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,UAAU,CAAA;CACnB,oBAYA,CAAA;AAaD,eAAO,MAAM,QAAQ,SACb,YAAY,kBACF,MAAM,gDAgCvB,CAAA"}
|