@vltpkg/cli-sdk 0.0.0-19 → 0.0.0-20

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,EAAE,YAWhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGe,CAAA;AAEjC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,CASpC,CAAA"}
1
+ {"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,EAAE,YAWhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGe,CAAA;AAEjC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,CAUpC,CAAA"}
@@ -20,6 +20,7 @@ export const command = async (conf) => {
20
20
  const ciOptions = {
21
21
  ...conf.options,
22
22
  expectLockfile: true,
23
+ frozenLockfile: true,
23
24
  cleanInstall: true,
24
25
  };
25
26
  const { graph } = await install(ciOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"ci.js","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;kEAGiD;IAC9D,QAAQ,EAAE;QACR,EAAE,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE;KACnD;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,eAAe;CACS,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAqB,KAAK,EAAC,IAAI,EAAC,EAAE;IACpD,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI,CAAC,OAAO;QACf,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;KACnB,CAAA;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { install } from '@vltpkg/graph'\nimport type { Views } from '../view.ts'\nimport { InstallReporter } from './install/reporter.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ci',\n usage: '',\n description: `Clean install from lockfile. Deletes node_modules and installs \n dependencies exactly as specified in vlt-lock.json. This is \n similar to running 'vlt install --expect-lockfile' but performs \n a clean install by removing node_modules first.`,\n examples: {\n '': { description: 'Clean install from lockfile' },\n },\n })\n\nexport const views = {\n json: g => g.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<Graph>\n\nexport const command: CommandFn<Graph> = async conf => {\n const ciOptions = {\n ...conf.options,\n expectLockfile: true,\n cleanInstall: true,\n }\n\n const { graph } = await install(ciOptions)\n return graph\n}\n"]}
1
+ {"version":3,"file":"ci.js","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;kEAGiD;IAC9D,QAAQ,EAAE;QACR,EAAE,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE;KACnD;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,eAAe;CACS,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAqB,KAAK,EAAC,IAAI,EAAC,EAAE;IACpD,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI,CAAC,OAAO;QACf,cAAc,EAAE,IAAI;QACpB,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;KACnB,CAAA;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { install } from '@vltpkg/graph'\nimport type { Views } from '../view.ts'\nimport { InstallReporter } from './install/reporter.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ci',\n usage: '',\n description: `Clean install from lockfile. Deletes node_modules and installs \n dependencies exactly as specified in vlt-lock.json. This is \n similar to running 'vlt install --expect-lockfile' but performs \n a clean install by removing node_modules first.`,\n examples: {\n '': { description: 'Clean install from lockfile' },\n },\n })\n\nexport const views = {\n json: g => g.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<Graph>\n\nexport const command: CommandFn<Graph> = async conf => {\n const ciOptions = {\n ...conf.options,\n expectLockfile: true,\n frozenLockfile: true,\n cleanInstall: true,\n }\n\n const { graph } = await install(ciOptions)\n return graph\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAQhB,CAAA;AA8BJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CACR,CAAA"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAQhB,CAAA;AA2BJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CACR,CAAA"}
@@ -19,18 +19,17 @@ class RunCommand extends ExecCommand {
19
19
  defaultArg0() { }
20
20
  noArgsSingle() {
21
21
  // called when there's no arg0, with a single workspace or root
22
- const ws = this.monorepo?.values().next().value;
23
- const cwd = ws?.fullpath ?? this.projectRoot;
22
+ const cwd = this.getCwd();
24
23
  const { scripts = {} } = this.conf.options.packageJson.read(cwd);
25
24
  return scripts;
26
25
  }
27
26
  noArgsMulti() {
28
- const scriptSet = {};
29
- for (const [ws, scripts] of this.monorepo.runSync(({ manifest: { scripts } }) => scripts)) {
30
- if (scripts)
31
- scriptSet[ws.path] = scripts;
27
+ const scripts = {};
28
+ for (const { label, manifest } of this.getTargets()) {
29
+ if (manifest.scripts)
30
+ scripts[label] = manifest.scripts;
32
31
  }
33
- return scriptSet;
32
+ return scripts;
34
33
  }
35
34
  }
36
35
  export const command = async (conf) => await new RunCommand(conf).run();
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE;;;sCAGqB;CACnC,CAAC,CAAA;AAEJ,MAAM,UAAW,SAAQ,WAAqC;IAC5D,YAAY,IAAkB;QAC5B,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;IAED,4DAA4D;IAC5D,wDAAwD;IACxD,WAAW,KAAe,CAAC;IAE3B,YAAY;QACV,+DAA+D;QAC/D,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;QAC/C,MAAM,GAAG,GAAG,EAAE,EAAE,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAA;QAC5C,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAChE,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,WAAW;QACT,MAAM,SAAS,GAAmB,EAAE,CAAA;QACpC,KAAK,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAC/C,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC,OAAO,CACvC,EAAE,CAAC;YACF,IAAI,OAAO;gBAAE,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;QAC3C,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE,CACzD,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA","sourcesContent":["import { run, runFG } from '@vltpkg/run'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type {\n ExecResult,\n MultiScriptSet,\n ScriptSet,\n} from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'run',\n usage: '<script> [args ...]',\n description: `Run a script defined in 'package.json', passing along any extra\n arguments. Note that vlt config values must be specified *before*\n the script name, because everything after that is handed off to\n the script process.`,\n })\n\nclass RunCommand extends ExecCommand<typeof run, typeof runFG> {\n constructor(conf: LoadedConfig) {\n super(conf, run, runFG)\n }\n\n // do not provide the interactive shell arg, just do nothing\n // so that it falls back up to the noArgsSingle() method\n defaultArg0(): undefined {}\n\n noArgsSingle(): ScriptSet {\n // called when there's no arg0, with a single workspace or root\n const ws = this.monorepo?.values().next().value\n const cwd = ws?.fullpath ?? this.projectRoot\n const { scripts = {} } = this.conf.options.packageJson.read(cwd)\n return scripts\n }\n\n noArgsMulti(this: this & { monorepo: Monorepo }): MultiScriptSet {\n const scriptSet: MultiScriptSet = {}\n for (const [ws, scripts] of this.monorepo.runSync(\n ({ manifest: { scripts } }) => scripts,\n )) {\n if (scripts) scriptSet[ws.path] = scripts\n }\n return scriptSet\n }\n}\n\nexport const command: CommandFn<ExecResult> = async conf =>\n await new RunCommand(conf).run()\n"]}
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE;;;sCAGqB;CACnC,CAAC,CAAA;AAEJ,MAAM,UAAW,SAAQ,WAAqC;IAC5D,YAAY,IAAkB;QAC5B,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;IAED,4DAA4D;IAC5D,wDAAwD;IACxD,WAAW,KAAe,CAAC;IAE3B,YAAY;QACV,+DAA+D;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QACzB,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAChE,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,WAAW;QACT,MAAM,OAAO,GAAmB,EAAE,CAAA;QAClC,KAAK,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACpD,IAAI,QAAQ,CAAC,OAAO;gBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAA;QACzD,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE,CACzD,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA","sourcesContent":["import { run, runFG } from '@vltpkg/run'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type {\n ExecResult,\n MultiScriptSet,\n ScriptSet,\n} from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'run',\n usage: '<script> [args ...]',\n description: `Run a script defined in 'package.json', passing along any extra\n arguments. Note that vlt config values must be specified *before*\n the script name, because everything after that is handed off to\n the script process.`,\n })\n\nclass RunCommand extends ExecCommand<typeof run, typeof runFG> {\n constructor(conf: LoadedConfig) {\n super(conf, run, runFG)\n }\n\n // do not provide the interactive shell arg, just do nothing\n // so that it falls back up to the noArgsSingle() method\n defaultArg0(): undefined {}\n\n noArgsSingle(): ScriptSet {\n // called when there's no arg0, with a single workspace or root\n const cwd = this.getCwd()\n const { scripts = {} } = this.conf.options.packageJson.read(cwd)\n return scripts\n }\n\n noArgsMulti(): MultiScriptSet {\n const scripts: MultiScriptSet = {}\n for (const { label, manifest } of this.getTargets()) {\n if (manifest.scripts) scripts[label] = manifest.scripts\n }\n return scripts\n }\n}\n\nexport const command: CommandFn<ExecResult> = async conf =>\n await new RunCommand(conf).run()\n"]}
@@ -0,0 +1,10 @@
1
+ import type { Graph } from '@vltpkg/graph';
2
+ import type { CommandFn, CommandUsage } from '../index.ts';
3
+ import { InstallReporter } from './install/reporter.ts';
4
+ export declare const usage: CommandUsage;
5
+ export declare const views: {
6
+ readonly json: (g: Graph) => import("@vltpkg/graph").LockfileData;
7
+ readonly human: typeof InstallReporter;
8
+ };
9
+ export declare const command: CommandFn<Graph>;
10
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGe,CAAA;AAEjC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,CAUpC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { update } from '@vltpkg/graph';
2
+ import { error } from '@vltpkg/error-cause';
3
+ import { commandUsage } from "../config/usage.js";
4
+ import { InstallReporter } from "./install/reporter.js";
5
+ export const usage = () => commandUsage({
6
+ command: 'update',
7
+ usage: '',
8
+ description: `Update dependencies to their latest in-range versions.
9
+ Discards the lockfile and resolves dependencies from scratch.`,
10
+ });
11
+ export const views = {
12
+ json: g => g.toJSON(),
13
+ human: InstallReporter,
14
+ };
15
+ export const command = async (conf) => {
16
+ // Throw error if any arguments are provided
17
+ if (conf.positionals.length > 0) {
18
+ throw error('Arguments are not yet supported for vlt update', {
19
+ code: 'EUSAGE',
20
+ });
21
+ }
22
+ const { graph } = await update(conf.options);
23
+ return graph;
24
+ };
25
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/commands/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;gFAC+D;CAC7E,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,eAAe;CACS,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAqB,KAAK,EAAC,IAAI,EAAC,EAAE;IACpD,4CAA4C;IAC5C,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,KAAK,CAAC,gDAAgD,EAAE;YAC5D,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC5C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { update } from '@vltpkg/graph'\nimport { error } from '@vltpkg/error-cause'\nimport type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'update',\n usage: '',\n description: `Update dependencies to their latest in-range versions.\n Discards the lockfile and resolves dependencies from scratch.`,\n })\n\nexport const views = {\n json: g => g.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<Graph>\n\nexport const command: CommandFn<Graph> = async conf => {\n // Throw error if any arguments are provided\n if (conf.positionals.length > 0) {\n throw error('Arguments are not yet supported for vlt update', {\n code: 'EUSAGE',\n })\n }\n\n const { graph } = await update(conf.options)\n return graph\n}\n"]}
@@ -38,6 +38,7 @@ export declare const commands: {
38
38
  readonly run: "run";
39
39
  readonly token: "token";
40
40
  readonly uninstall: "uninstall";
41
+ readonly update: "update";
41
42
  readonly 'exec-cache': "exec-cache";
42
43
  readonly version: "version";
43
44
  readonly whoami: "whoami";
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAA0C,CAAA;AAElE,eAAO,MAAM,aAAa,cAKjB,CAAA;AA8CT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGX,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,cAAc,uBAW1B,CAAA;AAED,MAAM,MAAM,QAAQ,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DvB,CAAA;AAEJ,eAAO,MAAM,mBAAmB,gBAS/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
@@ -1,7 +1,14 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
2
  import { XDG } from '@vltpkg/xdg';
3
3
  import { jack } from 'jackspeak';
4
- export const defaultView = process.stdout.isTTY ? 'human' : 'json';
4
+ export const defaultView =
5
+ // If stdout is a TTY, use human output
6
+ process.stdout.isTTY ? 'human'
7
+ // If its not a TTY but is a CI environment, use human output
8
+ // TODO: make a better view option for CI environments
9
+ : process.env.CI ? 'human'
10
+ // Otherwise, use json output
11
+ : 'json';
5
12
  export const defaultEditor = () => process.env.EDITOR ||
6
13
  process.env.VISUAL ||
7
14
  (process.platform === 'win32' ?
@@ -29,6 +36,7 @@ const canonicalCommands = {
29
36
  run: 'run',
30
37
  token: 'token',
31
38
  uninstall: 'uninstall',
39
+ update: 'update',
32
40
  'exec-cache': 'exec-cache',
33
41
  version: 'version',
34
42
  whoami: 'whoami',
@@ -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,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;AAElE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CA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,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 = process.stdout.isTTY ? 'human' : '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 '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 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 Similar to pnpm's publishConfig.directory feature.\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"],"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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E,EAAE;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 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 Similar to pnpm's publishConfig.directory feature.\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"]}
@@ -190,6 +190,12 @@ export declare class Config {
190
190
  * the XDG config home.
191
191
  */
192
192
  loadConfigFile(): Promise<this>;
193
+ /**
194
+ * Force a complete reload of config files from disk.
195
+ * This clears all caches and re-reads config files.
196
+ * Useful for long-running processes that need to pick up config changes.
197
+ */
198
+ reloadFromDisk(): Promise<void>;
193
199
  /**
194
200
  * Load the configuration and return a Promise to a
195
201
  * {@link Config} object
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAM/C,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,QAAQ,EACR,UAAU,EAEV,aAAa,EACb,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,YAAY,EACZ,KAAK,QAAQ,GACd,CAAA;AAED,eAAO,MAAM,cAAc,eAA2C,CAAA;AAEtE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACjD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAwBjD,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG;IACnD,OAAO,CAAC,EAAE;SACP,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC,EAAE,qBAAqB;KAC9C,CAAA;CACF,CAAA;AAED,eAAO,MAAM,cAAc,QAErB,WAAW,CAAC,cAAc,CAAC,GAC3B,cAAc,CAAC,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AC,GACH,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAKvC;;OAEG;IACG,eAAe,CACnB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC;IAMrC;;;OAGG;IACG,eAAe,CACnB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,CAAC,cAAc,CAAC;IAqDrC;;;OAGG;IACG,gBAAgB,CACpB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,EAAE;IAwClB;;;;;;;;;OASG;IACG,cAAc,CAClB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAmC9C;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBrC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BrC;;;OAGG;WACU,IAAI,CACf,WAAW,SAAgB,EAC3B,IAAI,WAAe;IACnB;;;OAGG;IACH,MAAM,UAAQ,GACb,OAAO,CAAC,YAAY,CAAC;CAOzB;AAKD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAClC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IACvC,MAAM,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAA;IACzC,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,CAAA"}
@@ -152,6 +152,11 @@ export class Config {
152
152
  * positional arguments to the vlt process
153
153
  */
154
154
  positionals;
155
+ /**
156
+ * Original arguments used for parsing (stored for reload purposes)
157
+ * @internal
158
+ */
159
+ #originalArgs;
155
160
  /**
156
161
  * The root of the project where a vlt.json, vlt.json,
157
162
  * package.json, or .git was found. Not necessarily the `process.cwd()`,
@@ -181,6 +186,8 @@ export class Config {
181
186
  parse(args = process.argv) {
182
187
  if (isParsed(this))
183
188
  return this;
189
+ // Store the original args for potential reload
190
+ this.#originalArgs = [...args];
184
191
  this.jack.loadEnvDefaults();
185
192
  const p = this.jack.parseRaw(args);
186
193
  const fallback = getCommand(p.values['fallback-command']);
@@ -248,7 +255,8 @@ export class Config {
248
255
  * Write the config values to the user or project config file.
249
256
  */
250
257
  async writeConfigFile(which, values) {
251
- return save('config', pairsToRecords(values), which);
258
+ save('config', pairsToRecords(values), which);
259
+ await this.#reloadConfig();
252
260
  }
253
261
  /**
254
262
  * Fold in the provided fields with the existing properties
@@ -385,6 +393,39 @@ export class Config {
385
393
  await this.#maybeLoadConfigFile('project');
386
394
  return this;
387
395
  }
396
+ /**
397
+ * Clear cached config values to force re-reading from updated files.
398
+ * @internal
399
+ */
400
+ async #reloadConfig() {
401
+ // Clear the memoized options to force recalculation
402
+ this.#options = undefined;
403
+ }
404
+ /**
405
+ * Force a complete reload of config files from disk.
406
+ * This clears all caches and re-reads config files.
407
+ * Useful for long-running processes that need to pick up config changes.
408
+ */
409
+ async reloadFromDisk() {
410
+ // Clear the memoized options to force recalculation
411
+ this.#options = undefined;
412
+ // Clear the parsed state to force re-parsing
413
+ // This is crucial because parse() returns early if already parsed
414
+ this.values = undefined;
415
+ this.positionals = undefined;
416
+ this.command = undefined;
417
+ // Clear vlt-json caches for both user and project configs
418
+ // This ensures that the next time config files are read, they'll be re-read from disk
419
+ const { unload } = await import('@vltpkg/vlt-json');
420
+ unload('user');
421
+ unload('project');
422
+ // Force reload of config files by calling the load methods again
423
+ // This will re-read the files and re-apply them to the jack parser
424
+ await this.#maybeLoadConfigFile('user');
425
+ await this.#maybeLoadConfigFile('project');
426
+ // Re-parse to pick up the updated config values using the original arguments
427
+ this.parse(this.#originalArgs);
428
+ }
388
429
  /**
389
430
  * cache of the loaded config
390
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O,CAAC,GAAG,EAAE,EAC3B,IAAI,GAAG,OAAO,CAAC,IAAI;IACnB;;;OAGG;IACH,MAAM,GAAG,KAAK;QAEd,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,OAAO,CAAA;QAChD,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;QAC7C,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,cAAc,EAAE,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAiB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAqB,EAAE,CAChD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["/**\n * Module that handles all vlt configuration needs\n *\n * Project-level configs are set in a `vlt.json` file in the local project\n * if present. This will override the user-level configs in the appropriate\n * XDG config path.\n *\n * Command-specific configuration can be specified by putting options in a\n * field in the `command` object. For example:\n *\n * ```json\n * {\n * \"registry\": \"https://registry.npmjs.org/\",\n * \"command\": {\n * \"publish\": {\n * \"registry\": \"http://registry.internal\"\n * }\n * }\n * }\n * ```\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { PackageJson } from '@vltpkg/package-json'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport {\n assertRecordStringString,\n assertRecordStringT,\n isRecordStringString,\n} from '@vltpkg/types'\nimport type { Validator, WhichConfig } from '@vltpkg/vlt-json'\nimport { find, load, reload, save } from '@vltpkg/vlt-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport type { Jack, OptionsResults, Unwrap } from 'jackspeak'\nimport { readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport { PathScurry } from 'path-scurry'\nimport type { Commands, RecordField } from './definition.ts'\nimport {\n commands,\n definition,\n getCommand,\n isRecordField,\n recordFields,\n} from './definition.ts'\nimport { merge } from './merge.ts'\nexport {\n commands,\n definition,\n isRecordField,\n recordFields,\n type Commands,\n}\n\nexport const kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport type RecordPairs = Record<string, unknown>\nexport type RecordString = Record<string, string>\n\n// turn a set of pairs into a Record object.\n// if a kv pair doesn't have a = character, set to `''`\nconst reducePairs = <T extends string[]>(\n pairs: T,\n): RecordString | T => {\n const record: RecordString = {}\n for (const kv of pairs) {\n const eq = kv.indexOf('=')\n if (eq === -1) record[kv] = ''\n else {\n const key = kv.substring(0, eq)\n const val = kv.substring(eq + 1)\n record[key] = val\n }\n }\n return record\n}\n\nconst isRecordFieldValue = (k: string, v: unknown): v is string[] =>\n Array.isArray(v) &&\n recordFields.includes(k as (typeof recordFields)[number])\n\nexport type PairsAsRecords = ConfigOptionsNoExtras & {\n command?: {\n [k in keyof Commands]?: ConfigOptionsNoExtras\n }\n}\n\nexport const pairsToRecords = (\n obj:\n | NonNullable<ConfigFileData>\n | OptionsResults<ConfigDefinitions>,\n): PairsAsRecords => {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n Object.fromEntries(\n Object.entries(v).map(([k, v]) => [\n k,\n pairsToRecords(v as NonNullable<ConfigFileData>),\n ]),\n )\n : isRecordFieldValue(k, v) ? reducePairs(v)\n : v,\n ]),\n // hard cast because TS can't see through the entries/fromEntries\n ) as unknown as PairsAsRecords\n}\n\nexport const recordsToPairs = (obj: RecordPairs): RecordPairs => {\n return Object.fromEntries(\n Object.entries(obj)\n .filter(\n ([k]) =>\n !(\n k === 'scurry' ||\n k === 'packageJson' ||\n k === 'monorepo' ||\n k === 'projectRoot' ||\n k === 'packageInfo'\n ),\n )\n .map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n recordsToPairs(v as RecordPairs)\n : (\n !v ||\n typeof v !== 'object' ||\n Array.isArray(v) ||\n !isRecordField(k)\n ) ?\n v\n : Object.entries(v).map(([k, v]) => `${k}=${v}`),\n ]),\n )\n}\n\nconst kRecord = Symbol('parsed key=value record')\n\nexport type ConfigDataNoCommand = {\n [k in keyof OptionsResults<ConfigDefinitions>]?: OptionsResults<ConfigDefinitions>[k]\n}\n\n/**\n * Config data can be any options, and also a 'command' field which\n * contains command names and override options for that command.\n */\nexport type ConfigData = ConfigDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigDataNoCommand\n }\n}\n\nexport type ConfigFileDataNoCommand = {\n [k in keyof ConfigDataNoCommand]: k extends (\n OptListKeys<ConfigDataNoCommand>\n ) ?\n RecordString | string[]\n : ConfigDataNoCommand[k]\n}\n\n/**\n * Config data as it appears in the config field of the vlt.json, with kv pair\n * lists stored as `Record<string, string>` and\n */\nexport type ConfigFileData = ConfigFileDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigFileDataNoCommand\n }\n}\n\nexport type ConfigOptionsNoExtras = {\n [k in keyof OptionsResults<ConfigDefinitions>]: k extends (\n RecordField\n ) ?\n RecordString\n : k extends 'command' ? never\n : OptionsResults<ConfigDefinitions>[k]\n}\n\nexport type ConfigOptions = ConfigOptionsNoExtras &\n Pick<SpecOptions, 'catalog' | 'catalogs'> & {\n packageJson: PackageJson\n scurry: PathScurry\n projectRoot: string\n monorepo?: Monorepo\n packageInfo: PackageInfoClient\n }\n\n/**\n * The base config definition set as a type\n */\nexport type ConfigDefinitions = Unwrap<typeof definition>\n\nexport type StringListKeys<O> = {\n [k in keyof O]: O[k] extends string[] | undefined ? k : never\n}\nexport type OptListKeys<O> = Exclude<\n StringListKeys<O>[keyof StringListKeys<O>],\n undefined\n>\n\n/**\n * Class that handles configuration for vlt.\n *\n * Call {@link Config.load} to get one of these.\n */\nexport class Config {\n /**\n * The {@link https://npmjs.com/jackspeak | JackSpeak} object\n * representing vlt's configuration\n */\n jack: Jack<ConfigDefinitions>\n\n /**\n * Parsed values in effect\n */\n values?: OptionsResults<ConfigDefinitions>\n\n /**\n * Command-specific config values\n */\n commandValues: {\n [cmd in Commands[keyof Commands]]?: ConfigData\n } = {}\n\n /**\n * A flattened object of the parsed configuration\n */\n get options(): ConfigOptions {\n if (this.#options) return this.#options\n const scurry = new PathScurry(this.projectRoot)\n const packageJson = new PackageJson()\n const asRecords = pairsToRecords(this.parse().values)\n const extras = {\n projectRoot: this.projectRoot,\n scurry,\n packageJson,\n monorepo: Monorepo.maybeLoad(this.projectRoot, {\n scurry,\n packageJson,\n load: {\n paths: asRecords.workspace,\n groups: asRecords['workspace-group'],\n },\n }),\n catalog: load<Record<string, string>>(\n 'catalog',\n assertRecordStringString,\n ),\n catalogs: load<Record<string, Record<string, string>>>(\n 'catalogs',\n o =>\n assertRecordStringT(\n o,\n isRecordStringString,\n 'Record<string, Record<string, string>>',\n ),\n ),\n }\n\n const options: Omit<ConfigOptions, 'packageInfo'> = Object.assign(\n asRecords,\n extras,\n )\n\n this.#options = Object.assign(options, {\n packageInfo: new PackageInfoClient(options),\n [kCustomInspect]() {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([k]) =>\n k !== 'monorepo' &&\n k !== 'scurry' &&\n k !== 'packageJson' &&\n k !== 'packageInfo',\n ),\n )\n },\n })\n return this.#options\n }\n\n /**\n * Reset the options value, optionally setting a new project root\n * to recalculate the options.\n */\n resetOptions(projectRoot: string = process.cwd()) {\n this.projectRoot = projectRoot\n this.#options = undefined\n }\n\n // memoized options() getter value\n #options?: ConfigOptions\n\n /**\n * positional arguments to the vlt process\n */\n positionals?: string[]\n\n /**\n * The root of the project where a vlt.json, vlt.json,\n * package.json, or .git was found. Not necessarily the `process.cwd()`,\n * though that is the default location.\n *\n * Never walks up as far as `$HOME`. So for example, if a project is in\n * `~/projects/xyz`, then the highest dir it will check is `~/projects`\n */\n projectRoot: string\n\n /**\n * `Record<alias, canonical name>` to dereference command aliases.\n */\n commands: Commands\n\n /**\n * Which command name to use for overriding with command-specific values,\n * determined from the argv when parse() is called.\n */\n command?: Commands[keyof Commands]\n\n constructor(\n jack: Jack<ConfigDefinitions> = definition,\n projectRoot = process.cwd(),\n ) {\n this.projectRoot = projectRoot\n this.commands = commands\n this.jack = jack\n }\n\n /**\n * Parse the arguments and set configuration and positionals accordingly.\n */\n parse(args: string[] = process.argv): this & ParsedConfig {\n if (isParsed(this)) return this\n\n this.jack.loadEnvDefaults()\n const p = this.jack.parseRaw(args)\n\n const fallback = getCommand(p.values['fallback-command'])\n this.command = getCommand(p.positionals[0])\n\n const cmdOrFallback = this.command ?? fallback\n const cmdSpecific =\n cmdOrFallback && this.commandValues[cmdOrFallback]\n if (cmdSpecific) {\n this.jack.setConfigValues(recordsToPairs(cmdSpecific))\n }\n\n // ok, applied cmd-specific defaults, do rest of the parse\n this.jack.applyDefaults(p)\n this.jack.writeEnv(p)\n\n if (this.command) p.positionals.shift()\n else this.command = getCommand(p.values['fallback-command'])\n\n Object.assign(this, p)\n\n /* c8 ignore start - unpossible */\n if (!isParsed(this)) throw error('failed to parse config')\n /* c8 ignore stop */\n\n return this\n }\n\n /**\n * Get a `key=value` list option value as an object.\n *\n * For example, a list option with a vlaue of `['key=value', 'xyz=as=df' ]`\n * would be returned as `{key: 'value', xyz: 'as=df'}`\n *\n * Results are memoized, so subsequent calls for the same key will return the\n * same object. If new strings are added to the list, then the memoized value\n * is *not* updated, so only use once configurations have been fully loaded.\n *\n * If the config value is not set at all, an empty object is returned.\n */\n getRecord(k: OptListKeys<ConfigData>): RecordString {\n const pairs = this.get(k) as\n | (string[] & { [kRecord]?: RecordString })\n | undefined\n if (!pairs) return {}\n if (pairs[kRecord]) return pairs[kRecord]\n const kv = pairs.reduce((kv: RecordString, pair) => {\n const eq = pair.indexOf('=')\n if (eq === -1) return kv\n const key = pair.substring(0, eq)\n const val = pair.substring(eq + 1)\n kv[key] = val\n return kv\n }, {})\n Object.assign(pairs, { [kRecord]: kv })\n return kv\n }\n\n /**\n * Get a configuration value.\n *\n * Note: `key=value` pair configs are returned as a string array. To get them\n * as an object, use {@link Config#getRecord}.\n */\n get<K extends keyof OptionsResults<ConfigDefinitions>>(\n k: K,\n ): OptionsResults<ConfigDefinitions>[K] {\n /* c8 ignore next -- impossible but TS doesn't know that */\n return (this.values ?? this.parse().values)[k]\n }\n\n /**\n * Write the config values to the user or project config file.\n */\n async writeConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n return save('config', pairsToRecords(values), which)\n }\n\n /**\n * Fold in the provided fields with the existing properties\n * in the config file.\n */\n async addConfigToFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n return this.writeConfigFile(\n which,\n merge((await this.#maybeLoadConfigFile(which)) ?? {}, values),\n )\n }\n\n // called in this weird bound way so that it can be used by the\n // vlt-json config loading module.\n #validator: Validator<ConfigFileData> = function (\n this: Config,\n c: unknown,\n file: string,\n ) {\n this.#validateConfig(c, file)\n }.bind(this)\n\n #validateConfig(\n c: unknown,\n file: string,\n ): asserts c is ConfigFileData {\n if (!c || typeof c !== 'object' || Array.isArray(c)) {\n throw error('invalid config, expected object', {\n path: file,\n found: c,\n wanted: 'ConfigFileData',\n })\n }\n\n const { command, ...values } = recordsToPairs(c as RecordPairs)\n if (command) {\n for (const [c, opts] of Object.entries(command)) {\n const cmd = getCommand(c)\n if (cmd) {\n this.commandValues[cmd] = merge<ConfigData>(\n this.commandValues[cmd] ?? ({} as ConfigData),\n opts as ConfigData,\n )\n }\n }\n }\n this.jack.setConfigValues(values, file)\n }\n\n /**\n * if the file exists, parse and load it. returns object if data was\n * loaded, or undefined if not.\n */\n async #maybeLoadConfigFile(whichConfig: WhichConfig) {\n return load('config', this.#validator, whichConfig)\n }\n\n /**\n * Deletes the specified config fields from the named file\n * Returns `true` if anything was changed.\n */\n async deleteConfigKeys(\n this: LoadedConfig,\n which: WhichConfig,\n fields: string[],\n ) {\n const data = await this.#maybeLoadConfigFile(which)\n if (!data) return false\n let didSomething = false\n for (const f of fields) {\n const [key, ...sk] = f.split('.') as [\n h: string,\n ...rest: string[],\n ]\n const subs = sk.join('.')\n const k = key as keyof ConfigDefinitions\n const v = data[k]\n if (v === undefined) continue\n if (subs && v && typeof v === 'object') {\n if (Array.isArray(v)) {\n const i = v.findIndex(subvalue =>\n subvalue.startsWith(`${subs}=`),\n )\n if (i !== -1) {\n if (v.length === 1) delete data[k]\n else v.splice(i, 1)\n didSomething = true\n }\n } else {\n if (v[subs] !== undefined) {\n delete v[subs]\n if (Object.keys(v).length === 0) delete data[k]\n didSomething = true\n }\n }\n } else {\n didSomething = true\n delete data[k]\n }\n }\n if (didSomething) await this.writeConfigFile(which, data)\n return didSomething\n }\n\n /**\n * Edit the user or project configuration file.\n *\n * If the file isn't present, then it starts with `{}` so the user has\n * something to work with.\n *\n * If the result is not valid, or no config settings are contained in the\n * file after editing, then it's restored to what it was before, which might\n * mean deleting the file.\n */\n async editConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n edit: (file: string) => Promise<void> | void,\n ) {\n // load the file as a backup\n // call the edit function\n // reload it\n const file = find(which)\n const backup = await readFile(file, 'utf8').catch(() => undefined)\n if (!backup) {\n await writeFile(\n file,\n JSON.stringify({ config: {} }, null, 2) + '\\n',\n )\n }\n let valid = false\n try {\n await edit(file)\n // force it to reload the file and validate it again\n // if this fails, we roll back.\n const result = reload('config', which)\n save('config', result ?? {}, which)\n valid = true\n } finally {\n if (!valid) {\n // TODO: maybe write the file to a re-edit backup location?\n // then you could do `vlt config edit retry` or something.\n if (backup) {\n await writeFile(file, backup)\n reload(which)\n } else {\n await rm(file, { force: true })\n }\n }\n }\n }\n\n /**\n * Find the local config file and load both it and the user-level config in\n * the XDG config home.\n */\n async loadConfigFile(): Promise<this> {\n await this.#maybeLoadConfigFile('user')\n this.projectRoot = dirname(find('project', this.projectRoot))\n await this.#maybeLoadConfigFile('project')\n return this\n }\n\n /**\n * cache of the loaded config\n */\n static #loaded: LoadedConfig | undefined\n\n /**\n * Load the configuration and return a Promise to a\n * {@link Config} object\n */\n static async load(\n projectRoot = process.cwd(),\n argv = process.argv,\n /**\n * only used in tests, resets the memoization\n * @internal\n */\n reload = false,\n ): Promise<LoadedConfig> {\n if (this.#loaded && !reload) return this.#loaded\n const a = new Config(definition, projectRoot)\n const b = await a.loadConfigFile()\n this.#loaded = b.parse(argv) as LoadedConfig\n return this.#loaded\n }\n}\n\nconst isParsed = (c: Config): c is ParsedConfig =>\n !!(c.values && c.positionals && c.command)\n\nexport type ParsedConfig = Config & {\n command: NonNullable<Config['command']>\n values: OptionsResults<ConfigDefinitions>\n positionals: string[]\n}\n\n/**\n * A fully loaded {@link Config} object\n */\nexport type LoadedConfig = ParsedConfig\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAA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,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO,CAA0B;IAExC;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CACf,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAC3B,IAAI,GAAG,OAAO,CAAC,IAAI;IACnB;;;OAGG;IACH,MAAM,GAAG,KAAK;QAEd,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,OAAO,CAAA;QAChD,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;QAC7C,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,cAAc,EAAE,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAiB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAqB,EAAE,CAChD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["/**\n * Module that handles all vlt configuration needs\n *\n * Project-level configs are set in a `vlt.json` file in the local project\n * if present. This will override the user-level configs in the appropriate\n * XDG config path.\n *\n * Command-specific configuration can be specified by putting options in a\n * field in the `command` object. For example:\n *\n * ```json\n * {\n * \"registry\": \"https://registry.npmjs.org/\",\n * \"command\": {\n * \"publish\": {\n * \"registry\": \"http://registry.internal\"\n * }\n * }\n * }\n * ```\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { PackageJson } from '@vltpkg/package-json'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport {\n assertRecordStringString,\n assertRecordStringT,\n isRecordStringString,\n} from '@vltpkg/types'\nimport type { Validator, WhichConfig } from '@vltpkg/vlt-json'\nimport { find, load, reload, save } from '@vltpkg/vlt-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport type { Jack, OptionsResults, Unwrap } from 'jackspeak'\nimport { readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport { PathScurry } from 'path-scurry'\nimport type { Commands, RecordField } from './definition.ts'\nimport {\n commands,\n definition,\n getCommand,\n isRecordField,\n recordFields,\n} from './definition.ts'\nimport { merge } from './merge.ts'\nexport {\n commands,\n definition,\n isRecordField,\n recordFields,\n type Commands,\n}\n\nexport const kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport type RecordPairs = Record<string, unknown>\nexport type RecordString = Record<string, string>\n\n// turn a set of pairs into a Record object.\n// if a kv pair doesn't have a = character, set to `''`\nconst reducePairs = <T extends string[]>(\n pairs: T,\n): RecordString | T => {\n const record: RecordString = {}\n for (const kv of pairs) {\n const eq = kv.indexOf('=')\n if (eq === -1) record[kv] = ''\n else {\n const key = kv.substring(0, eq)\n const val = kv.substring(eq + 1)\n record[key] = val\n }\n }\n return record\n}\n\nconst isRecordFieldValue = (k: string, v: unknown): v is string[] =>\n Array.isArray(v) &&\n recordFields.includes(k as (typeof recordFields)[number])\n\nexport type PairsAsRecords = ConfigOptionsNoExtras & {\n command?: {\n [k in keyof Commands]?: ConfigOptionsNoExtras\n }\n}\n\nexport const pairsToRecords = (\n obj:\n | NonNullable<ConfigFileData>\n | OptionsResults<ConfigDefinitions>,\n): PairsAsRecords => {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n Object.fromEntries(\n Object.entries(v).map(([k, v]) => [\n k,\n pairsToRecords(v as NonNullable<ConfigFileData>),\n ]),\n )\n : isRecordFieldValue(k, v) ? reducePairs(v)\n : v,\n ]),\n // hard cast because TS can't see through the entries/fromEntries\n ) as unknown as PairsAsRecords\n}\n\nexport const recordsToPairs = (obj: RecordPairs): RecordPairs => {\n return Object.fromEntries(\n Object.entries(obj)\n .filter(\n ([k]) =>\n !(\n k === 'scurry' ||\n k === 'packageJson' ||\n k === 'monorepo' ||\n k === 'projectRoot' ||\n k === 'packageInfo'\n ),\n )\n .map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n recordsToPairs(v as RecordPairs)\n : (\n !v ||\n typeof v !== 'object' ||\n Array.isArray(v) ||\n !isRecordField(k)\n ) ?\n v\n : Object.entries(v).map(([k, v]) => `${k}=${v}`),\n ]),\n )\n}\n\nconst kRecord = Symbol('parsed key=value record')\n\nexport type ConfigDataNoCommand = {\n [k in keyof OptionsResults<ConfigDefinitions>]?: OptionsResults<ConfigDefinitions>[k]\n}\n\n/**\n * Config data can be any options, and also a 'command' field which\n * contains command names and override options for that command.\n */\nexport type ConfigData = ConfigDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigDataNoCommand\n }\n}\n\nexport type ConfigFileDataNoCommand = {\n [k in keyof ConfigDataNoCommand]: k extends (\n OptListKeys<ConfigDataNoCommand>\n ) ?\n RecordString | string[]\n : ConfigDataNoCommand[k]\n}\n\n/**\n * Config data as it appears in the config field of the vlt.json, with kv pair\n * lists stored as `Record<string, string>` and\n */\nexport type ConfigFileData = ConfigFileDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigFileDataNoCommand\n }\n}\n\nexport type ConfigOptionsNoExtras = {\n [k in keyof OptionsResults<ConfigDefinitions>]: k extends (\n RecordField\n ) ?\n RecordString\n : k extends 'command' ? never\n : OptionsResults<ConfigDefinitions>[k]\n}\n\nexport type ConfigOptions = ConfigOptionsNoExtras &\n Pick<SpecOptions, 'catalog' | 'catalogs'> & {\n packageJson: PackageJson\n scurry: PathScurry\n projectRoot: string\n monorepo?: Monorepo\n packageInfo: PackageInfoClient\n }\n\n/**\n * The base config definition set as a type\n */\nexport type ConfigDefinitions = Unwrap<typeof definition>\n\nexport type StringListKeys<O> = {\n [k in keyof O]: O[k] extends string[] | undefined ? k : never\n}\nexport type OptListKeys<O> = Exclude<\n StringListKeys<O>[keyof StringListKeys<O>],\n undefined\n>\n\n/**\n * Class that handles configuration for vlt.\n *\n * Call {@link Config.load} to get one of these.\n */\nexport class Config {\n /**\n * The {@link https://npmjs.com/jackspeak | JackSpeak} object\n * representing vlt's configuration\n */\n jack: Jack<ConfigDefinitions>\n\n /**\n * Parsed values in effect\n */\n values?: OptionsResults<ConfigDefinitions>\n\n /**\n * Command-specific config values\n */\n commandValues: {\n [cmd in Commands[keyof Commands]]?: ConfigData\n } = {}\n\n /**\n * A flattened object of the parsed configuration\n */\n get options(): ConfigOptions {\n if (this.#options) return this.#options\n const scurry = new PathScurry(this.projectRoot)\n const packageJson = new PackageJson()\n const asRecords = pairsToRecords(this.parse().values)\n const extras = {\n projectRoot: this.projectRoot,\n scurry,\n packageJson,\n monorepo: Monorepo.maybeLoad(this.projectRoot, {\n scurry,\n packageJson,\n load: {\n paths: asRecords.workspace,\n groups: asRecords['workspace-group'],\n },\n }),\n catalog: load<Record<string, string>>(\n 'catalog',\n assertRecordStringString,\n ),\n catalogs: load<Record<string, Record<string, string>>>(\n 'catalogs',\n o =>\n assertRecordStringT(\n o,\n isRecordStringString,\n 'Record<string, Record<string, string>>',\n ),\n ),\n }\n\n const options: Omit<ConfigOptions, 'packageInfo'> = Object.assign(\n asRecords,\n extras,\n )\n\n this.#options = Object.assign(options, {\n packageInfo: new PackageInfoClient(options),\n [kCustomInspect]() {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([k]) =>\n k !== 'monorepo' &&\n k !== 'scurry' &&\n k !== 'packageJson' &&\n k !== 'packageInfo',\n ),\n )\n },\n })\n return this.#options\n }\n\n /**\n * Reset the options value, optionally setting a new project root\n * to recalculate the options.\n */\n resetOptions(projectRoot: string = process.cwd()) {\n this.projectRoot = projectRoot\n this.#options = undefined\n }\n\n // memoized options() getter value\n #options?: ConfigOptions\n\n /**\n * positional arguments to the vlt process\n */\n positionals?: string[]\n\n /**\n * Original arguments used for parsing (stored for reload purposes)\n * @internal\n */\n #originalArgs?: string[]\n\n /**\n * The root of the project where a vlt.json, vlt.json,\n * package.json, or .git was found. Not necessarily the `process.cwd()`,\n * though that is the default location.\n *\n * Never walks up as far as `$HOME`. So for example, if a project is in\n * `~/projects/xyz`, then the highest dir it will check is `~/projects`\n */\n projectRoot: string\n\n /**\n * `Record<alias, canonical name>` to dereference command aliases.\n */\n commands: Commands\n\n /**\n * Which command name to use for overriding with command-specific values,\n * determined from the argv when parse() is called.\n */\n command?: Commands[keyof Commands]\n\n constructor(\n jack: Jack<ConfigDefinitions> = definition,\n projectRoot = process.cwd(),\n ) {\n this.projectRoot = projectRoot\n this.commands = commands\n this.jack = jack\n }\n\n /**\n * Parse the arguments and set configuration and positionals accordingly.\n */\n parse(args: string[] = process.argv): this & ParsedConfig {\n if (isParsed(this)) return this\n\n // Store the original args for potential reload\n this.#originalArgs = [...args]\n\n this.jack.loadEnvDefaults()\n const p = this.jack.parseRaw(args)\n\n const fallback = getCommand(p.values['fallback-command'])\n this.command = getCommand(p.positionals[0])\n\n const cmdOrFallback = this.command ?? fallback\n const cmdSpecific =\n cmdOrFallback && this.commandValues[cmdOrFallback]\n if (cmdSpecific) {\n this.jack.setConfigValues(recordsToPairs(cmdSpecific))\n }\n\n // ok, applied cmd-specific defaults, do rest of the parse\n this.jack.applyDefaults(p)\n this.jack.writeEnv(p)\n\n if (this.command) p.positionals.shift()\n else this.command = getCommand(p.values['fallback-command'])\n\n Object.assign(this, p)\n\n /* c8 ignore start - unpossible */\n if (!isParsed(this)) throw error('failed to parse config')\n /* c8 ignore stop */\n\n return this\n }\n\n /**\n * Get a `key=value` list option value as an object.\n *\n * For example, a list option with a vlaue of `['key=value', 'xyz=as=df' ]`\n * would be returned as `{key: 'value', xyz: 'as=df'}`\n *\n * Results are memoized, so subsequent calls for the same key will return the\n * same object. If new strings are added to the list, then the memoized value\n * is *not* updated, so only use once configurations have been fully loaded.\n *\n * If the config value is not set at all, an empty object is returned.\n */\n getRecord(k: OptListKeys<ConfigData>): RecordString {\n const pairs = this.get(k) as\n | (string[] & { [kRecord]?: RecordString })\n | undefined\n if (!pairs) return {}\n if (pairs[kRecord]) return pairs[kRecord]\n const kv = pairs.reduce((kv: RecordString, pair) => {\n const eq = pair.indexOf('=')\n if (eq === -1) return kv\n const key = pair.substring(0, eq)\n const val = pair.substring(eq + 1)\n kv[key] = val\n return kv\n }, {})\n Object.assign(pairs, { [kRecord]: kv })\n return kv\n }\n\n /**\n * Get a configuration value.\n *\n * Note: `key=value` pair configs are returned as a string array. To get them\n * as an object, use {@link Config#getRecord}.\n */\n get<K extends keyof OptionsResults<ConfigDefinitions>>(\n k: K,\n ): OptionsResults<ConfigDefinitions>[K] {\n /* c8 ignore next -- impossible but TS doesn't know that */\n return (this.values ?? this.parse().values)[k]\n }\n\n /**\n * Write the config values to the user or project config file.\n */\n async writeConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n save('config', pairsToRecords(values), which)\n await this.#reloadConfig()\n }\n\n /**\n * Fold in the provided fields with the existing properties\n * in the config file.\n */\n async addConfigToFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n return this.writeConfigFile(\n which,\n merge((await this.#maybeLoadConfigFile(which)) ?? {}, values),\n )\n }\n\n // called in this weird bound way so that it can be used by the\n // vlt-json config loading module.\n #validator: Validator<ConfigFileData> = function (\n this: Config,\n c: unknown,\n file: string,\n ) {\n this.#validateConfig(c, file)\n }.bind(this)\n\n #validateConfig(\n c: unknown,\n file: string,\n ): asserts c is ConfigFileData {\n if (!c || typeof c !== 'object' || Array.isArray(c)) {\n throw error('invalid config, expected object', {\n path: file,\n found: c,\n wanted: 'ConfigFileData',\n })\n }\n\n const { command, ...values } = recordsToPairs(c as RecordPairs)\n if (command) {\n for (const [c, opts] of Object.entries(command)) {\n const cmd = getCommand(c)\n if (cmd) {\n this.commandValues[cmd] = merge<ConfigData>(\n this.commandValues[cmd] ?? ({} as ConfigData),\n opts as ConfigData,\n )\n }\n }\n }\n this.jack.setConfigValues(values, file)\n }\n\n /**\n * if the file exists, parse and load it. returns object if data was\n * loaded, or undefined if not.\n */\n async #maybeLoadConfigFile(whichConfig: WhichConfig) {\n return load('config', this.#validator, whichConfig)\n }\n\n /**\n * Deletes the specified config fields from the named file\n * Returns `true` if anything was changed.\n */\n async deleteConfigKeys(\n this: LoadedConfig,\n which: WhichConfig,\n fields: string[],\n ) {\n const data = await this.#maybeLoadConfigFile(which)\n if (!data) return false\n let didSomething = false\n for (const f of fields) {\n const [key, ...sk] = f.split('.') as [\n h: string,\n ...rest: string[],\n ]\n const subs = sk.join('.')\n const k = key as keyof ConfigDefinitions\n const v = data[k]\n if (v === undefined) continue\n if (subs && v && typeof v === 'object') {\n if (Array.isArray(v)) {\n const i = v.findIndex(subvalue =>\n subvalue.startsWith(`${subs}=`),\n )\n if (i !== -1) {\n if (v.length === 1) delete data[k]\n else v.splice(i, 1)\n didSomething = true\n }\n } else {\n if (v[subs] !== undefined) {\n delete v[subs]\n if (Object.keys(v).length === 0) delete data[k]\n didSomething = true\n }\n }\n } else {\n didSomething = true\n delete data[k]\n }\n }\n if (didSomething) await this.writeConfigFile(which, data)\n return didSomething\n }\n\n /**\n * Edit the user or project configuration file.\n *\n * If the file isn't present, then it starts with `{}` so the user has\n * something to work with.\n *\n * If the result is not valid, or no config settings are contained in the\n * file after editing, then it's restored to what it was before, which might\n * mean deleting the file.\n */\n async editConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n edit: (file: string) => Promise<void> | void,\n ) {\n // load the file as a backup\n // call the edit function\n // reload it\n const file = find(which)\n const backup = await readFile(file, 'utf8').catch(() => undefined)\n if (!backup) {\n await writeFile(\n file,\n JSON.stringify({ config: {} }, null, 2) + '\\n',\n )\n }\n let valid = false\n try {\n await edit(file)\n // force it to reload the file and validate it again\n // if this fails, we roll back.\n const result = reload('config', which)\n save('config', result ?? {}, which)\n valid = true\n } finally {\n if (!valid) {\n // TODO: maybe write the file to a re-edit backup location?\n // then you could do `vlt config edit retry` or something.\n if (backup) {\n await writeFile(file, backup)\n reload(which)\n } else {\n await rm(file, { force: true })\n }\n }\n }\n }\n\n /**\n * Find the local config file and load both it and the user-level config in\n * the XDG config home.\n */\n async loadConfigFile(): Promise<this> {\n await this.#maybeLoadConfigFile('user')\n this.projectRoot = dirname(find('project', this.projectRoot))\n await this.#maybeLoadConfigFile('project')\n return this\n }\n\n /**\n * Clear cached config values to force re-reading from updated files.\n * @internal\n */\n async #reloadConfig() {\n // Clear the memoized options to force recalculation\n this.#options = undefined\n }\n\n /**\n * Force a complete reload of config files from disk.\n * This clears all caches and re-reads config files.\n * Useful for long-running processes that need to pick up config changes.\n */\n async reloadFromDisk(): Promise<void> {\n // Clear the memoized options to force recalculation\n this.#options = undefined\n\n // Clear the parsed state to force re-parsing\n // This is crucial because parse() returns early if already parsed\n this.values = undefined\n this.positionals = undefined\n this.command = undefined\n\n // Clear vlt-json caches for both user and project configs\n // This ensures that the next time config files are read, they'll be re-read from disk\n const { unload } = await import('@vltpkg/vlt-json')\n unload('user')\n unload('project')\n\n // Force reload of config files by calling the load methods again\n // This will re-read the files and re-apply them to the jack parser\n await this.#maybeLoadConfigFile('user')\n await this.#maybeLoadConfigFile('project')\n\n // Re-parse to pick up the updated config values using the original arguments\n this.parse(this.#originalArgs)\n }\n\n /**\n * cache of the loaded config\n */\n static #loaded: LoadedConfig | undefined\n\n /**\n * Load the configuration and return a Promise to a\n * {@link Config} object\n */\n static async load(\n projectRoot = process.cwd(),\n argv = process.argv,\n /**\n * only used in tests, resets the memoization\n * @internal\n */\n reload = false,\n ): Promise<LoadedConfig> {\n if (this.#loaded && !reload) return this.#loaded\n const a = new Config(definition, projectRoot)\n const b = await a.loadConfigFile()\n this.#loaded = b.parse(argv) as LoadedConfig\n return this.#loaded\n }\n}\n\nconst isParsed = (c: Config): c is ParsedConfig =>\n !!(c.values && c.positionals && c.command)\n\nexport type ParsedConfig = Config & {\n command: NonNullable<Config['command']>\n values: OptionsResults<ConfigDefinitions>\n positionals: string[]\n}\n\n/**\n * A fully loaded {@link Config} object\n */\nexport type LoadedConfig = ParsedConfig\n"]}
@@ -2,9 +2,8 @@
2
2
  * impl for `vlt run`, `vlt run-exec`, `vlt exec-local`, `vlt exec`
3
3
  * @module
4
4
  */
5
+ import type { NormalizedManifest } from '@vltpkg/types';
5
6
  import type { exec, execFG, ExecOptions, run, runExec, runExecFG, RunExecOptions, runFG, RunFGResult, RunOptions, RunResult } from '@vltpkg/run';
6
- import type { Workspace } from '@vltpkg/workspaces';
7
- import { Monorepo } from '@vltpkg/workspaces';
8
7
  import type { LoadedConfig } from './config/index.ts';
9
8
  export type RunnerBG = typeof exec | typeof run | typeof runExec;
10
9
  export type RunnerFG = typeof execFG | typeof runExecFG | typeof runFG;
@@ -19,36 +18,35 @@ export declare const views: {
19
18
  };
20
19
  type ViewValues = 'human' | 'json' | 'inspect' | 'silent';
21
20
  export declare class ExecCommand<B extends RunnerBG, F extends RunnerFG> {
21
+ #private;
22
22
  bg: B;
23
23
  fg: F;
24
24
  arg0?: string;
25
25
  args: string[];
26
- monorepo?: Monorepo;
27
- /** how many places are we doing things in? */
28
- spaces?: number;
29
26
  conf: LoadedConfig;
30
27
  projectRoot: string;
31
28
  view: ViewValues;
32
29
  validViewValues: Map<string, ViewValues>;
33
30
  constructor(conf: LoadedConfig, bg: B, fg: F);
34
- hasMonorepo(): this is this & {
35
- monorepo: Monorepo;
36
- };
37
31
  hasArg0(): this is this & {
38
32
  arg0: string;
39
33
  };
40
34
  run(): Promise<ExecResult>;
41
- printResult(ws: Workspace, result: RunResult): void;
35
+ printResult(path: string, result: RunResult): void;
42
36
  interactiveShell(): string;
43
37
  defaultArg0(): string | undefined;
38
+ getCwd(): string;
44
39
  fgArg(): RunnerOptions | undefined;
45
40
  bgArg(this: this & {
46
41
  arg0: string;
47
- }, ws: Workspace): RunnerOptions;
42
+ }, cwd: string): RunnerOptions;
48
43
  noArgsSingle(): ScriptSet;
49
- noArgsMulti(this: this & {
50
- monorepo: Monorepo;
51
- }): MultiScriptSet;
44
+ noArgsMulti(): MultiScriptSet;
45
+ getTargets(): {
46
+ label: string;
47
+ cwd: string;
48
+ manifest: NormalizedManifest;
49
+ }[];
52
50
  }
53
51
  export {};
54
52
  //# sourceMappingURL=exec-command.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,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;AAIpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,MAAM,MAAM,QAAQ,GAAG,OAAO,IAAI,GAAG,OAAO,GAAG,GAAG,OAAO,OAAO,CAAA;AAChE,MAAM,MAAM,QAAQ,GAAG,OAAO,MAAM,GAAG,OAAO,SAAS,GAAG,OAAO,KAAK,CAAA;AACtE,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,CAAA;AACrE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACtD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC9C,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACtD,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,cAAc,GACd,SAAS,GACT,cAAc,CAAA;AA6BlB,eAAO,MAAM,KAAK;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AE,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;IAgHhC,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;IAchE,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"}
@@ -10,6 +10,8 @@ import { isRunResult } from '@vltpkg/run';
10
10
  import { Monorepo } from '@vltpkg/workspaces';
11
11
  import { ansiToAnsi } from 'ansi-to-pre';
12
12
  import { stderr, stdout, styleTextStdout } from "./output.js";
13
+ import assert from 'node:assert';
14
+ import { resolve } from 'node:path';
13
15
  const isScriptSet = (o) => {
14
16
  if (!o || typeof o !== 'object')
15
17
  return false;
@@ -38,8 +40,8 @@ export const views = {
38
40
  stdout('Scripts available:', result);
39
41
  else if (isMultiScriptSet(result)) {
40
42
  stdout('Scripts available:');
41
- for (const [wsPath, scripts] of Object.entries(result)) {
42
- stdout(wsPath, scripts);
43
+ for (const [path, scripts] of Object.entries(result)) {
44
+ stdout(path, scripts);
43
45
  }
44
46
  }
45
47
  },
@@ -52,9 +54,8 @@ export class ExecCommand {
52
54
  fg;
53
55
  arg0;
54
56
  args;
55
- monorepo;
56
- /** how many places are we doing things in? */
57
- spaces;
57
+ #monorepo;
58
+ #nodes;
58
59
  conf;
59
60
  projectRoot;
60
61
  view;
@@ -74,8 +75,10 @@ export class ExecCommand {
74
75
  this.args = args;
75
76
  this.projectRoot = projectRoot;
76
77
  }
77
- hasMonorepo() {
78
- return !!this.monorepo;
78
+ #targetCount() {
79
+ if (this.#nodes)
80
+ return this.#nodes.length;
81
+ return this.#monorepo?.size ?? 1;
79
82
  }
80
83
  hasArg0() {
81
84
  return !!this.arg0;
@@ -99,33 +102,27 @@ export class ExecCommand {
99
102
  const { nodes } = await query.search(queryString, {
100
103
  signal: new AbortController().signal,
101
104
  });
102
- const importerPaths = nodes
103
- .filter(n => n.importer)
104
- .map(n => n.location)
105
- .filter(v => v !== undefined);
106
- this.monorepo =
107
- importerPaths.length ?
108
- Monorepo.load(this.projectRoot, {
109
- load: {
110
- paths: importerPaths,
111
- },
112
- })
113
- : undefined;
114
- this.spaces = this.monorepo?.size ?? 0;
105
+ this.#nodes = [];
106
+ for (const node of nodes) {
107
+ const { location } = node.toJSON();
108
+ assert(location, error(`node ${node.id} has no location`, {
109
+ found: node,
110
+ }));
111
+ this.#nodes.push(location);
112
+ }
115
113
  }
116
114
  else {
117
115
  const paths = conf.get('workspace');
118
116
  const groups = conf.get('workspace-group');
119
117
  const recursive = conf.get('recursive');
120
- this.monorepo =
118
+ this.#monorepo =
121
119
  paths?.length || groups?.length || recursive ?
122
120
  Monorepo.load(this.projectRoot, {
123
121
  load: { paths, groups },
124
122
  })
125
123
  : undefined;
126
- this.spaces = this.monorepo?.size ?? 1;
127
124
  }
128
- if (this.spaces === 1) {
125
+ if (this.#targetCount() === 1) {
129
126
  const arg = this.fgArg();
130
127
  if (!arg)
131
128
  return this.noArgsSingle();
@@ -135,48 +132,70 @@ export class ExecCommand {
135
132
  }
136
133
  return result;
137
134
  }
138
- if (!this.hasMonorepo() || this.spaces === 0) {
139
- throw error('no matching workspaces found', {
140
- /* c8 ignore next - already guarded */
141
- validOptions: [...(this.monorepo?.load().paths() ?? [])],
142
- });
135
+ if (this.#targetCount() === 0) {
136
+ if (queryString) {
137
+ throw error('no matching nodes found for query', {
138
+ found: queryString,
139
+ });
140
+ }
141
+ else {
142
+ throw error('no matching workspaces found', {
143
+ /* c8 ignore next - already guarded */
144
+ validOptions: [...(this.#monorepo?.load().paths() ?? [])],
145
+ });
146
+ }
143
147
  }
144
148
  if (!this.hasArg0()) {
145
149
  return this.noArgsMulti();
146
150
  }
147
151
  // run across workspaces
148
152
  let failed = false;
149
- const resultMap = await this.monorepo.run(async (ws) => {
150
- const result = await this.bg(this.bgArg(ws)).catch((er) => {
153
+ const runInDir = async (cwd, label) => {
154
+ const result = await this.bg(this.bgArg(cwd)).catch((er) => {
151
155
  if (isErrorWithCause(er) && isRunResult(er.cause)) {
152
- this.printResult(ws, er.cause);
156
+ this.printResult(label, er.cause);
153
157
  }
154
158
  failed = true;
155
159
  throw er;
156
160
  });
157
161
  if (!failed)
158
- this.printResult(ws, result);
162
+ this.printResult(label, result);
159
163
  return result;
160
- });
164
+ };
165
+ const resultMap = new Map();
166
+ if (this.#nodes) {
167
+ for (const { label, cwd } of this.getTargets()) {
168
+ const result = await runInDir(cwd, label);
169
+ resultMap.set(label, result);
170
+ }
171
+ }
172
+ else if (this.#monorepo) {
173
+ const wsResultMap = await this.#monorepo.run(async (ws) => {
174
+ return runInDir(ws.fullpath, ws.path);
175
+ });
176
+ for (const [ws, result] of wsResultMap) {
177
+ resultMap.set(ws.path, result);
178
+ }
179
+ }
161
180
  const results = {};
162
- for (const [ws, result] of resultMap) {
181
+ for (const [path, result] of resultMap) {
163
182
  if (result.status === 0 && result.signal === null) {
164
183
  result.stdout = '';
165
184
  result.stderr = '';
166
185
  }
167
- results[ws.path] = result;
186
+ results[path] = result;
168
187
  }
169
188
  return results;
170
189
  }
171
- printResult(ws, result) {
190
+ printResult(path, result) {
172
191
  // non-human results just get printed at the end
173
192
  if (this.view !== 'human')
174
193
  return;
175
194
  if (result.status === 0 && result.signal === null) {
176
- stdout(ws.path, 'ok');
195
+ stdout(path, 'ok');
177
196
  }
178
197
  else {
179
- stdout(styleTextStdout(['bgWhiteBright', 'black', 'bold'], ws.path + ' failure'), {
198
+ stdout(styleTextStdout(['bgWhiteBright', 'black', 'bold'], path + ' failure'), {
180
199
  status: result.status,
181
200
  signal: result.signal,
182
201
  });
@@ -200,9 +219,17 @@ export class ExecCommand {
200
219
  defaultArg0() {
201
220
  return this.interactiveShell();
202
221
  }
222
+ getCwd() {
223
+ if (this.#nodes) {
224
+ const [first] = this.#nodes;
225
+ assert(first, error('no nodes found'));
226
+ return resolve(this.projectRoot, first);
227
+ }
228
+ return (this.#monorepo?.values().next().value?.fullpath ??
229
+ this.projectRoot);
230
+ }
203
231
  fgArg() {
204
- const ws = this.monorepo?.values().next().value;
205
- const cwd = ws?.fullpath ?? this.projectRoot;
232
+ const cwd = this.getCwd();
206
233
  const arg0 = this.arg0 ?? this.defaultArg0();
207
234
  // return undefined so noArgsSingle will be called instead
208
235
  if (typeof arg0 !== 'string')
@@ -213,19 +240,19 @@ export class ExecCommand {
213
240
  arg0,
214
241
  args: this.args,
215
242
  projectRoot: this.projectRoot,
216
- packageJson: this.monorepo?.packageJson,
243
+ packageJson: this.conf.options.packageJson,
217
244
  'script-shell': this.arg0 ? this.conf.get('script-shell') : false,
218
245
  };
219
246
  }
220
- bgArg(ws) {
247
+ bgArg(cwd) {
221
248
  return {
222
- cwd: ws.fullpath,
249
+ cwd,
223
250
  acceptFail: !this.conf.get('bail'),
224
251
  ignoreMissing: true,
225
252
  arg0: this.arg0,
226
253
  args: this.args,
227
254
  projectRoot: this.projectRoot,
228
- packageJson: this.monorepo?.packageJson,
255
+ packageJson: this.conf.options.packageJson,
229
256
  'script-shell': this.conf.get('script-shell'),
230
257
  };
231
258
  }
@@ -237,5 +264,28 @@ export class ExecCommand {
237
264
  noArgsMulti() {
238
265
  throw error('Cannot spawn interactive shells in multiple workspaces');
239
266
  }
267
+ getTargets() {
268
+ const targets = [];
269
+ if (this.#nodes) {
270
+ for (const location of this.#nodes) {
271
+ const manifest = this.conf.options.packageJson.read(location);
272
+ const label =
273
+ /* c8 ignore next */
274
+ location.startsWith('./') ? location.slice(2) : location;
275
+ const cwd = resolve(this.projectRoot, location);
276
+ targets.push({ label, cwd, manifest });
277
+ }
278
+ }
279
+ else if (this.#monorepo) {
280
+ this.#monorepo.runSync(ws => {
281
+ targets.push({
282
+ label: ws.path,
283
+ cwd: ws.fullpath,
284
+ manifest: ws.manifest,
285
+ });
286
+ });
287
+ }
288
+ return targets;
289
+ }
240
290
  }
241
291
  //# sourceMappingURL=exec-command.js.map
@@ -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;AAchD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,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;AAe7D,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,KA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IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAM;QAEpC,OAAO;YACL,GAAG;YACH,sCAAsC;YACtC,IAAI;YACJ,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW;YACvC,cAAc,EACZ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK;SACpD,CAAA;IACH,CAAC;IAED,KAAK,CAAgC,EAAa;QAChD,OAAO;YACL,GAAG,EAAE,EAAE,CAAC,QAAQ;YAChB,UAAU,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;YAClC,aAAa,EAAE,IAAI;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW;YACvC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;SAC9C,CAAA;IACH,CAAC;IAED,uDAAuD;IACvD,YAAY;QACV,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAA;IAC/D,CAAC;IACD,sDAAsD;IAEtD,WAAW;QACT,MAAM,KAAK,CACT,wDAAwD,CACzD,CAAA;IACH,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 {\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 type { Workspace } from '@vltpkg/workspaces'\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'\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 = 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 [wsPath, scripts] of Object.entries(result)) {\n stdout(wsPath, 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 /** how many places are we doing things in? */\n spaces?: number\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 hasMonorepo(): this is this & { monorepo: Monorepo } {\n return !!this.monorepo\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 // scope takes precedence over workspaces or groups\n if (queryString) {\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 const importerPaths = nodes\n .filter(n => n.importer)\n .map(n => n.location)\n .filter(v => v !== undefined)\n this.monorepo =\n importerPaths.length ?\n Monorepo.load(this.projectRoot, {\n load: {\n paths: importerPaths,\n },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 0\n } else {\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n this.monorepo =\n paths?.length || groups?.length || recursive ?\n Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 1\n }\n\n if (this.spaces === 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.hasMonorepo() || this.spaces === 0) {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.monorepo?.load().paths() ?? [])],\n })\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false\n const resultMap = await this.monorepo.run(async ws => {\n const result = await this.bg(this.bgArg(ws)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(ws, er.cause)\n }\n failed = true\n throw er\n },\n )\n if (!failed) this.printResult(ws, result)\n return result\n })\n\n const results: Record<string, RunResult> = {}\n for (const [ws, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[ws.path] = result\n }\n return results\n }\n\n printResult(ws: Workspace, 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(ws.path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ws.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 fgArg(): RunnerOptions | undefined {\n const ws = this.monorepo?.values().next().value\n const cwd = ws?.fullpath ?? this.projectRoot\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 /* c8 ignore next - already guarded */\n arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, ws: Workspace): RunnerOptions {\n return {\n cwd: ws.fullpath,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing: true,\n arg0: this.arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.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(this: this & { monorepo: Monorepo }): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\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,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,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AAQ,EAAE,CAAC,CAAA;YACxC,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1B,IAAI,CAAC,SAAS,CAAC,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 = 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 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 // scope takes precedence over workspaces or groups\n if (queryString) {\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 {\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n this.#monorepo =\n paths?.length || groups?.length || recursive ?\n Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n : undefined\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 (!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 resultMap.set(label, result)\n }\n } else if (this.#monorepo) {\n const wsResultMap = await this.#monorepo.run(async ws => {\n return runInDir(ws.fullpath, ws.path)\n })\n for (const [ws, result] of wsResultMap) {\n 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 /* c8 ignore next - already guarded */\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: true,\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 +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,gDAwBvB,CAAA"}
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,gDAyBvB,CAAA"}
@@ -23,6 +23,7 @@ export const startGUI = async (conf, startingRoute) => {
23
23
  const server = createServer({
24
24
  ...conf.options,
25
25
  assetsDir: getAssetsDir(),
26
+ loadedConfig: conf,
26
27
  });
27
28
  server.on('needConfigUpdate', dir => {
28
29
  conf.resetOptions(dir);
@@ -1 +1 @@
1
- {"version":3,"file":"start-gui.js","sourceRoot":"","sources":["../../src/start-gui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,OAK7C,EAAE,EAAE;IACH,MAAM,EACJ,WAAW,GAAG,OAAO,EACrB,aAAa,EACb,WAAW,EACX,MAAM,GACP,GAAG,OAAO,CAAA;IACX,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;IACvC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,eAAe,CAAC,CAAA;IAC9D,OAAO,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QAC7C,YAAY,QAAQ,CAAC,6BAA6B,CAAC,WAAW,CAAC,WAAW;QAC5E,CAAC,CAAC,GAAG,CAAA;AACT,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,qBAAqB;IACrB,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;QAC9C,OAAO,OAAO,CACZ,MAAM,CAAC,IAAI,CAAC,OAAO,EACnB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAC1C,CAAA;IACH,CAAC;IACD,oBAAoB;AACtB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,IAAkB,EAClB,aAAsB,EACtB,EAAE;IACF,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,GAAG,IAAI,CAAC,OAAO;QACf,SAAS,EAAE,YAAY,EAAE;KAC1B,CAAC,CAAA;IACF,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,GAAG,CAAC,EAAE;QAClC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CACrB;QAAC,MAA6B,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IACF,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;IAC5C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IACpB,MAAM,CAAC,yBAAyB,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACnD,KAAK,OAAO,CACV,MAAM,CAAC,OAAO,CACZ,MAAM,uBAAuB,CAAC;QAC5B,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;QAC/B,aAAa;QACb,WAAW;QACX,MAAM;KACP,CAAC,CACH,CACF,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { resolve } from 'node:path'\nimport LZString from 'lz-string'\nimport { createServer } from '@vltpkg/server'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { stdout } from './output.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { VltServerListening } from '@vltpkg/server'\n\nexport const getDefaultStartingRoute = async (options: {\n queryString?: string\n startingRoute?: string\n projectRoot: string\n scurry: PathScurry\n}) => {\n const {\n queryString = ':root',\n startingRoute,\n projectRoot,\n scurry,\n } = options\n if (startingRoute) return startingRoute\n const stat = await scurry.lstat(`${projectRoot}/package.json`)\n return stat?.isFile() && !stat.isSymbolicLink() ?\n `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`\n : '/'\n}\n\nconst getAssetsDir = () => {\n /* c8 ignore start */\n if (process.env.__VLT_INTERNAL_GUI_ASSETS_DIR) {\n return resolve(\n import.meta.dirname,\n process.env.__VLT_INTERNAL_GUI_ASSETS_DIR,\n )\n }\n /* c8 ignore stop */\n}\n\nexport const startGUI = async (\n conf: LoadedConfig,\n startingRoute?: string,\n) => {\n const server = createServer({\n ...conf.options,\n assetsDir: getAssetsDir(),\n })\n server.on('needConfigUpdate', dir => {\n conf.resetOptions(dir)\n ;(server as VltServerListening).updateOptions(conf.options)\n })\n const { projectRoot, scurry } = conf.options\n await server.start()\n stdout(`⚡️ vlt GUI running at ${server.address()}`)\n void urlOpen(\n server.address(\n await getDefaultStartingRoute({\n queryString: conf.values.target,\n startingRoute,\n projectRoot,\n scurry,\n }),\n ),\n )\n return server\n}\n"]}
1
+ {"version":3,"file":"start-gui.js","sourceRoot":"","sources":["../../src/start-gui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,OAK7C,EAAE,EAAE;IACH,MAAM,EACJ,WAAW,GAAG,OAAO,EACrB,aAAa,EACb,WAAW,EACX,MAAM,GACP,GAAG,OAAO,CAAA;IACX,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;I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,CAAC,MAAM;QAC/B,aAAa;QACb,WAAW;QACX,MAAM;KACP,CAAC,CACH,CACF,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { resolve } from 'node:path'\nimport LZString from 'lz-string'\nimport { createServer } from '@vltpkg/server'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { stdout } from './output.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { VltServerListening } from '@vltpkg/server'\n\nexport const getDefaultStartingRoute = async (options: {\n queryString?: string\n startingRoute?: string\n projectRoot: string\n scurry: PathScurry\n}) => {\n const {\n queryString = ':root',\n startingRoute,\n projectRoot,\n scurry,\n } = options\n if (startingRoute) return startingRoute\n const stat = await scurry.lstat(`${projectRoot}/package.json`)\n return stat?.isFile() && !stat.isSymbolicLink() ?\n `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`\n : '/'\n}\n\nconst getAssetsDir = () => {\n /* c8 ignore start */\n if (process.env.__VLT_INTERNAL_GUI_ASSETS_DIR) {\n return resolve(\n import.meta.dirname,\n process.env.__VLT_INTERNAL_GUI_ASSETS_DIR,\n )\n }\n /* c8 ignore stop */\n}\n\nexport const startGUI = async (\n conf: LoadedConfig,\n startingRoute?: string,\n) => {\n const server = createServer({\n ...conf.options,\n assetsDir: getAssetsDir(),\n loadedConfig: conf,\n })\n server.on('needConfigUpdate', dir => {\n conf.resetOptions(dir)\n ;(server as VltServerListening).updateOptions(conf.options)\n })\n const { projectRoot, scurry } = conf.options\n await server.start()\n stdout(`⚡️ vlt GUI running at ${server.address()}`)\n void urlOpen(\n server.address(\n await getDefaultStartingRoute({\n queryString: conf.values.target,\n startingRoute,\n projectRoot,\n scurry,\n }),\n ),\n )\n return server\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/cli-sdk",
3
3
  "description": "The source for the vlt CLI",
4
- "version": "0.0.0-19",
4
+ "version": "0.0.0-20",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -37,29 +37,30 @@
37
37
  "ssri": "^12.0.0",
38
38
  "supports-color": "^10.0.0",
39
39
  "tar": "^7.4.3",
40
- "@vltpkg/dot-prop": "0.0.0-19",
41
- "@vltpkg/config": "0.0.0-19",
42
- "@vltpkg/dep-id": "0.0.0-19",
43
- "@vltpkg/git": "0.0.0-19",
44
- "@vltpkg/error-cause": "0.0.0-19",
45
- "@vltpkg/graph": "0.0.0-19",
46
- "@vltpkg/init": "0.0.0-19",
47
- "@vltpkg/output": "0.0.0-19",
48
- "@vltpkg/package-info": "0.0.0-19",
49
- "@vltpkg/package-json": "0.0.0-19",
50
- "@vltpkg/query": "0.0.0-19",
51
- "@vltpkg/registry-client": "0.0.0-19",
52
- "@vltpkg/rollback-remove": "0.0.0-19",
53
- "@vltpkg/run": "0.0.0-19",
54
- "@vltpkg/server": "0.0.0-19",
55
- "@vltpkg/security-archive": "0.0.0-19",
56
- "@vltpkg/spec": "0.0.0-19",
57
- "@vltpkg/types": "0.0.0-19",
58
- "@vltpkg/vlx": "0.0.0-19",
59
- "@vltpkg/url-open": "0.0.0-19",
60
- "@vltpkg/vlt-json": "0.0.0-19",
61
- "@vltpkg/workspaces": "0.0.0-19",
62
- "@vltpkg/xdg": "0.0.0-19"
40
+ "@vltpkg/config": "0.0.0-20",
41
+ "@vltpkg/dep-id": "0.0.0-20",
42
+ "@vltpkg/dot-prop": "0.0.0-20",
43
+ "@vltpkg/error-cause": "0.0.0-20",
44
+ "@vltpkg/git": "0.0.0-20",
45
+ "@vltpkg/graph": "0.0.0-20",
46
+ "@vltpkg/init": "0.0.0-20",
47
+ "@vltpkg/output": "0.0.0-20",
48
+ "@vltpkg/package-info": "0.0.0-20",
49
+ "@vltpkg/package-json": "0.0.0-20",
50
+ "@vltpkg/promise-spawn": "0.0.0-20",
51
+ "@vltpkg/query": "0.0.0-20",
52
+ "@vltpkg/registry-client": "0.0.0-20",
53
+ "@vltpkg/run": "0.0.0-20",
54
+ "@vltpkg/server": "0.0.0-20",
55
+ "@vltpkg/rollback-remove": "0.0.0-20",
56
+ "@vltpkg/security-archive": "0.0.0-20",
57
+ "@vltpkg/types": "0.0.0-20",
58
+ "@vltpkg/url-open": "0.0.0-20",
59
+ "@vltpkg/vlt-json": "0.0.0-20",
60
+ "@vltpkg/vlx": "0.0.0-20",
61
+ "@vltpkg/spec": "0.0.0-20",
62
+ "@vltpkg/xdg": "0.0.0-20",
63
+ "@vltpkg/workspaces": "0.0.0-20"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@eslint/js": "^9.28.0",