@vltpkg/cli-sdk 0.0.0-22 → 0.0.0-24

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":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAiFzC,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAMvD,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
1
+ {"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAkFzC,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAKvD,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
@@ -2,7 +2,6 @@ import { emitter } from '@vltpkg/output';
2
2
  import { Box, render, Text } from 'ink';
3
3
  import Spinner from 'ink-spinner';
4
4
  import { createElement as $, Fragment, useEffect, useState, } from 'react';
5
- import { stdout } from "../../output.js";
6
5
  import { ViewClass } from "../../view.js";
7
6
  import { asError } from '@vltpkg/types';
8
7
  const GraphStep = ({ text, step }) => {
@@ -14,7 +13,7 @@ const GraphStep = ({ text, step }) => {
14
13
  }
15
14
  return $(Text, { color: 'green' }, text, ' ✓');
16
15
  };
17
- const App = () => {
16
+ const App = ({ trailer }) => {
18
17
  const [requests, setRequests] = useState(0);
19
18
  const [steps, setSteps] = useState({
20
19
  build: {
@@ -48,7 +47,7 @@ const App = () => {
48
47
  return $(Fragment, null, $(Box, null, ...['build', 'actual', 'reify'].map((step, idx, list) => {
49
48
  const separator = idx === list.length - 1 ? '' : ' > ';
50
49
  return $(Text, { key: step }, $(GraphStep, { text: step, step: steps[step] }), $(Text, { color: 'gray' }, separator));
51
- })), requests > 0 ? $(Text, null, `${requests} requests`) : null);
50
+ })), requests > 0 ? $(Text, null, `${requests} requests`) : null, trailer ? $(Text, null, trailer) : null);
52
51
  };
53
52
  export class InstallReporter extends ViewClass {
54
53
  #instance = null;
@@ -56,8 +55,7 @@ export class InstallReporter extends ViewClass {
56
55
  this.#instance = render($(App));
57
56
  }
58
57
  async done(_result, { time }) {
59
- await this.#instance?.waitUntilExit();
60
- stdout(`Done in ${time}ms`);
58
+ this.#instance?.rerender($(App, { trailer: `Done in ${time}ms` }));
61
59
  return undefined;
62
60
  }
63
61
  error(err) {
@@ -1 +1 @@
1
- {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAMvC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAgC,EAAE,EAAE;IACjE,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE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CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAgB,EAAE,EAAE,IAAI,EAAoB;QACrD,MAAM,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,CAAA;QACrC,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,CAAA;QAC3B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,GAAY;QAChB,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACvC,CAAC;CACF","sourcesContent":["import { emitter } from '@vltpkg/output'\nimport type { Events } from '@vltpkg/output'\nimport { Box, render, Text } from 'ink'\nimport type { Instance } from 'ink'\nimport Spinner from 'ink-spinner'\nimport {\n createElement as $,\n Fragment,\n useEffect,\n useState,\n} from 'react'\nimport { stdout } from '../../output.ts'\nimport { ViewClass } from '../../view.ts'\nimport { asError } from '@vltpkg/types'\n\ntype Step = {\n state: 'waiting' | 'in_progress' | 'completed'\n}\n\nconst GraphStep = ({ text, step }: { text: string; step: Step }) => {\n if (step.state === 'waiting') {\n return $(Text, { color: 'gray' }, text)\n }\n if (step.state === 'in_progress') {\n return $(\n Text,\n { color: 'yellow' },\n text + ' ',\n $(Spinner, { type: 'dots' }),\n )\n }\n return $(Text, { color: 'green' }, text, ' ✓')\n}\n\nconst App = () => {\n const [requests, setRequests] = useState(0)\n\n const [steps, setSteps] = useState<\n Record<Events['graphStep']['step'], Step>\n >({\n build: {\n state: 'waiting',\n },\n actual: {\n state: 'waiting',\n },\n reify: {\n state: 'waiting',\n },\n })\n\n useEffect(() => {\n const update = () => setRequests(p => p + 1)\n emitter.on('request', update)\n return () => emitter.off('request', update)\n }, [])\n\n useEffect(() => {\n const update = ({ step, state }: Events['graphStep']) => {\n setSteps(p => ({\n ...p,\n [step]: {\n ...p[step],\n state: state === 'start' ? 'in_progress' : 'completed',\n },\n }))\n }\n emitter.on('graphStep', update)\n return () => emitter.off('graphStep', update)\n }, [])\n\n return $(\n Fragment,\n null,\n $(\n Box,\n null,\n ...(['build', 'actual', 'reify'] as const).map(\n (step, idx, list) => {\n const separator = idx === list.length - 1 ? '' : ' > '\n return $(\n Text,\n { key: step },\n $(GraphStep, { text: step, step: steps[step] }),\n $(Text, { color: 'gray' }, separator),\n )\n },\n ),\n ),\n requests > 0 ? $(Text, null, `${requests} requests`) : null,\n )\n}\n\nexport class InstallReporter extends ViewClass {\n #instance: Instance | null = null\n\n start() {\n this.#instance = render($(App))\n }\n\n async done(_result: unknown, { time }: { time: number }) {\n await this.#instance?.waitUntilExit()\n stdout(`Done in ${time}ms`)\n return undefined\n }\n\n error(err: unknown) {\n this.#instance?.unmount(asError(err))\n }\n}\n"]}
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAMvC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAgC,EAAE,EAAE;IACjE,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,IAAI,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC;QACjC,OAAO,CAAC,CACN,IAAI,EACJ,EAAE,KAAK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AAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAgB,EAAE,EAAE,IAAI,EAAoB;QACrD,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI,EAAE,CAAC,CAAC,CAAA;QAClE,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,GAAY;QAChB,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACvC,CAAC;CACF","sourcesContent":["import { emitter } from '@vltpkg/output'\nimport type { Events } from '@vltpkg/output'\nimport { Box, render, Text } from 'ink'\nimport type { Instance } from 'ink'\nimport Spinner from 'ink-spinner'\nimport {\n createElement as $,\n Fragment,\n useEffect,\n useState,\n} from 'react'\nimport { ViewClass } from '../../view.ts'\nimport { asError } from '@vltpkg/types'\n\ntype Step = {\n state: 'waiting' | 'in_progress' | 'completed'\n}\n\nconst GraphStep = ({ text, step }: { text: string; step: Step }) => {\n if (step.state === 'waiting') {\n return $(Text, { color: 'gray' }, text)\n }\n if (step.state === 'in_progress') {\n return $(\n Text,\n { color: 'yellow' },\n text + ' ',\n $(Spinner, { type: 'dots' }),\n )\n }\n return $(Text, { color: 'green' }, text, ' ✓')\n}\n\nconst App = ({ trailer }: { trailer?: string }) => {\n const [requests, setRequests] = useState(0)\n\n const [steps, setSteps] = useState<\n Record<Events['graphStep']['step'], Step>\n >({\n build: {\n state: 'waiting',\n },\n actual: {\n state: 'waiting',\n },\n reify: {\n state: 'waiting',\n },\n })\n\n useEffect(() => {\n const update = () => setRequests(p => p + 1)\n emitter.on('request', update)\n return () => emitter.off('request', update)\n }, [])\n\n useEffect(() => {\n const update = ({ step, state }: Events['graphStep']) => {\n setSteps(p => ({\n ...p,\n [step]: {\n ...p[step],\n state: state === 'start' ? 'in_progress' : 'completed',\n },\n }))\n }\n emitter.on('graphStep', update)\n return () => emitter.off('graphStep', update)\n }, [])\n\n return $(\n Fragment,\n null,\n $(\n Box,\n null,\n ...(['build', 'actual', 'reify'] as const).map(\n (step, idx, list) => {\n const separator = idx === list.length - 1 ? '' : ' > '\n return $(\n Text,\n { key: step },\n $(GraphStep, { text: step, step: steps[step] }),\n $(Text, { color: 'gray' }, separator),\n )\n },\n ),\n ),\n requests > 0 ? $(Text, null, `${requests} requests`) : null,\n trailer ? $(Text, null, trailer) : null,\n )\n}\n\nexport class InstallReporter extends ViewClass {\n #instance: Instance | null = null\n\n start() {\n this.#instance = render($(App))\n }\n\n async done(_result: unknown, { time }: { time: number }) {\n this.#instance?.rerender($(App, { trailer: `Done in ${time}ms` }))\n return undefined\n }\n\n error(err: unknown) {\n this.#instance?.unmount(asError(err))\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { CommandFn, CommandUsage } from '../index.ts';
2
2
  export declare const views: {
3
- readonly human: (results_: unknown, _: import("../view.ts").ViewOptions, config: import("../config/index.ts").ParsedConfig) => string;
3
+ readonly human: (results: unknown, _: import("../view.ts").ViewOptions, config: import("../config/index.ts").ParsedConfig) => string;
4
4
  };
5
5
  export declare const usage: CommandUsage;
6
6
  export declare const command: CommandFn;
@@ -1 +1 @@
1
- {"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAmB1D,eAAO,MAAM,KAAK;;CAmBQ,CAAA;AAE1B,eAAO,MAAM,KAAK,EAAE,YAoChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SA8FrB,CAAA"}
1
+ {"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAU1D,eAAO,MAAM,KAAK;;CAgBQ,CAAA;AAE1B,eAAO,MAAM,KAAK,EAAE,YAoChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAsFrB,CAAA"}
@@ -8,20 +8,19 @@ import { views as initViews } from "./init.js";
8
8
  import { actual, GraphModifier } from '@vltpkg/graph';
9
9
  import { Query } from '@vltpkg/query';
10
10
  import { SecurityArchive } from '@vltpkg/security-archive';
11
- const json = (results) => JSON.stringify(results, null, 2);
12
11
  export const views = {
13
- human: (results_, _, config) => {
14
- const results = results_;
12
+ human: (results, _, config) => {
15
13
  // `vlt pkg init` is an alias for `vlt init`
16
14
  // use the same output handling
17
15
  if (config.positionals[0] === 'init') {
18
16
  return initViews.human(results);
19
17
  }
20
- return (Array.isArray(results) ?
21
- typeof results[0] === 'string' ?
22
- results.join('\n')
23
- : json(results)
24
- : json(results));
18
+ // When `get` is run with a single arg and it returns a string,
19
+ // just print items separated by newlines
20
+ if (Array.isArray(results) && typeof results[0] === 'string') {
21
+ return results.join('\n');
22
+ }
23
+ return JSON.stringify(results, null, 2);
25
24
  },
26
25
  };
27
26
  export const usage = () => commandUsage({
@@ -64,72 +63,83 @@ export const command = async (conf) => {
64
63
  if (sub === 'init') {
65
64
  return await init({ cwd: process.cwd() });
66
65
  }
67
- const pkg = conf.options.packageJson;
68
- // Handle --scope option to get multiple manifests
69
- const scopeQueryString = conf.get('scope');
70
- let manifests;
71
- if (scopeQueryString) {
72
- const modifiers = GraphModifier.maybeLoad(conf.options);
73
- const monorepo = conf.options.monorepo;
74
- const mainManifest = conf.options.packageJson.read(conf.options.projectRoot);
66
+ assert(sub, error('pkg command requires a subcommand', {
67
+ code: 'EUSAGE',
68
+ validOptions: ['get', 'pick', 'set', 'rm', 'init'],
69
+ }));
70
+ const { options, projectRoot } = conf;
71
+ const queryString = conf.get('scope');
72
+ const paths = conf.get('workspace');
73
+ const groups = conf.get('workspace-group');
74
+ const recursive = conf.get('recursive');
75
+ const locations = [];
76
+ let single = null;
77
+ if (queryString) {
78
+ const modifiers = GraphModifier.maybeLoad(options);
75
79
  const graph = actual.load({
76
- ...conf.options,
77
- mainManifest,
80
+ ...options,
81
+ mainManifest: options.packageJson.read(projectRoot),
78
82
  modifiers,
79
- monorepo,
83
+ monorepo: options.monorepo,
80
84
  loadManifests: false,
81
85
  });
82
- const securityArchive = Query.hasSecuritySelectors(scopeQueryString) ?
86
+ const securityArchive = Query.hasSecuritySelectors(queryString) ?
83
87
  await SecurityArchive.start({
84
88
  graph,
85
- specOptions: conf.options,
89
+ specOptions: options,
86
90
  })
87
91
  : undefined;
88
92
  const query = new Query({
89
93
  graph,
90
- specOptions: conf.options,
94
+ specOptions: options,
91
95
  securityArchive,
92
96
  });
93
- const { nodes } = await query.search(scopeQueryString, {
97
+ const { nodes } = await query.search(queryString, {
94
98
  signal: new AbortController().signal,
95
99
  });
96
- // collects the paths of the nodes selected using --scope
97
- const scopePaths = nodes
98
- .filter((n) => n.location !== undefined)
99
- .map(n => resolve(conf.options.projectRoot, n.location));
100
- // reads multiple manifests for each selected scope
101
- manifests = scopePaths.map(location => ({
102
- manifest: pkg.read(location),
103
- location,
104
- }));
105
- if (manifests.length === 0) {
106
- throw error('No matching package found using scope', {
107
- found: scopeQueryString,
108
- });
100
+ for (const node of nodes) {
101
+ const { location } = node.toJSON();
102
+ assert(location, error(`node ${node.id} has no location`, {
103
+ found: node,
104
+ }));
105
+ locations.push(resolve(projectRoot, location));
106
+ }
107
+ }
108
+ else if (paths?.length || groups?.length || recursive) {
109
+ for (const workspace of options.monorepo ?? []) {
110
+ locations.push(workspace.fullpath);
109
111
  }
110
112
  }
111
113
  else {
112
- // Single manifest mode
113
- const location = pkg.find() ?? conf.projectRoot;
114
- manifests = [
115
- {
116
- manifest: pkg.read(location),
117
- location,
118
- },
119
- ];
114
+ single = options.packageJson.find(process.cwd()) ?? projectRoot;
115
+ }
116
+ if (single) {
117
+ return commandSingle(single, sub, args, conf);
120
118
  }
119
+ assert(locations.length > 0, error('No matching package found using scope', {
120
+ found: queryString || 'workspace selection',
121
+ }));
122
+ const results = [];
123
+ for (const location of locations) {
124
+ results.push(await commandSingle(location, sub, args, conf));
125
+ }
126
+ return results;
127
+ };
128
+ const commandSingle = async (location, sub, args, conf) => {
129
+ const pkg = conf.options.packageJson;
130
+ const manifest = pkg.read(location);
121
131
  switch (sub) {
122
132
  case 'get':
123
- return get(manifests, args);
133
+ return get(manifest, args);
124
134
  case 'pick':
125
- return pick(manifests, args);
135
+ return pick(manifest, args);
126
136
  case 'set':
127
- return set(manifests, pkg, args);
137
+ return set(manifest, location, pkg, args);
128
138
  case 'rm':
129
139
  case 'remove':
130
140
  case 'unset':
131
141
  case 'delete':
132
- return rm(manifests, pkg, args);
142
+ return rm(manifest, location, pkg, args);
133
143
  default: {
134
144
  throw error('Unrecognized pkg command', {
135
145
  code: 'EUSAGE',
@@ -139,85 +149,42 @@ export const command = async (conf) => {
139
149
  }
140
150
  }
141
151
  };
142
- const get = (manifests, args) => {
152
+ const get = (manifest, args) => {
143
153
  const noArg = () => error('get requires not more than 1 argument. use `pick` to get more than 1.', { code: 'EUSAGE' }, noArg);
144
- if (args.length !== 1) {
145
- if (args.length > 1) {
146
- throw noArg();
147
- }
148
- return pick(manifests, args);
154
+ if (args.length === 1) {
155
+ const [key] = args;
156
+ assert(key, noArg());
157
+ return dotProp.get(manifest, key);
149
158
  }
150
- assert(args[0] != null, noArg());
151
- const [key] = args;
152
- if (manifests.length === 1) {
153
- const [firstManifest] = manifests;
154
- if (!firstManifest?.manifest) {
155
- /* c8 ignore start */
156
- throw error('No manifest found', firstManifest?.location ?
157
- { path: firstManifest.location }
158
- : {});
159
- /* c8 ignore stop */
160
- }
161
- return dotProp.get(firstManifest.manifest, key);
162
- }
163
- return manifests.map(manifest => dotProp.get(manifest.manifest, key));
159
+ assert(args.length === 0, noArg());
160
+ return pick(manifest, args);
164
161
  };
165
- const pick = (manifests, args) => {
166
- if (manifests.length === 1) {
167
- const [firstManifest] = manifests;
168
- /* c8 ignore start */
169
- if (!firstManifest?.manifest) {
170
- throw error('No manifest found', firstManifest?.location ?
171
- { path: firstManifest.location }
172
- : {});
173
- }
174
- /* c8 ignore stop */
175
- const { manifest } = firstManifest;
176
- return args.length ?
177
- args.reduce((acc, key) => dotProp.set(acc, key, dotProp.get(manifest, key)), {})
178
- : manifest;
179
- }
180
- // Multiple manifests - return results keyed by location
181
- return manifests.map(manifest => args.length ?
182
- args.reduce((acc, key) => dotProp.set(acc, key, dotProp.get(manifest.manifest, key)), {})
183
- : manifest.manifest);
162
+ const pick = (manifest, args) => {
163
+ return args.length ?
164
+ args.reduce((acc, key) => dotProp.set(acc, key, dotProp.get(manifest, key)), {})
165
+ : manifest;
184
166
  };
185
- const set = (manifests, pkg, args) => {
186
- if (args.length < 1) {
187
- throw error('set requires arguments', { code: 'EUSAGE' });
188
- }
189
- for (const { manifest, location } of manifests) {
190
- const res = args.reduce((acc, p) => {
191
- const index = p.indexOf('=');
192
- if (index === -1) {
193
- throw error('set arguments must contain `=`', {
194
- code: 'EUSAGE',
195
- });
196
- }
197
- return dotProp.set(acc, p.substring(0, index), p.substring(index + 1));
198
- }, manifest);
199
- pkg.write(location, res);
200
- }
167
+ const set = (manifest, location, pkg, args) => {
168
+ assert(args.length >= 1, error('set requires arguments', { code: 'EUSAGE' }));
169
+ const res = args.reduce((acc, p) => {
170
+ const index = p.indexOf('=');
171
+ assert(index !== -1, error('set arguments must contain `=`', {
172
+ code: 'EUSAGE',
173
+ }));
174
+ return dotProp.set(acc, p.substring(0, index), p.substring(index + 1));
175
+ }, manifest);
176
+ pkg.write(location, res);
201
177
  };
202
- const rm = (manifests, pkg, args) => {
203
- if (args.length < 1) {
204
- throw error('rm requires arguments', { code: 'EUSAGE' });
205
- }
206
- const results = [];
207
- for (const { manifest, location } of manifests) {
208
- const res = args.reduce((acc, key) => {
209
- dotProp.del(acc, key);
210
- return acc;
211
- }, manifest);
212
- pkg.write(location, res);
213
- results.push({
214
- manifest: res,
215
- location,
216
- });
217
- }
218
- if (manifests.length === 1) {
219
- return results[0];
220
- }
221
- return results;
178
+ const rm = (manifest, location, pkg, args) => {
179
+ assert(args.length >= 1, error('rm requires arguments', { code: 'EUSAGE' }));
180
+ const res = args.reduce((acc, key) => {
181
+ dotProp.del(acc, key);
182
+ return acc;
183
+ }, manifest);
184
+ pkg.write(location, res);
185
+ return {
186
+ manifest: res,
187
+ location,
188
+ };
222
189
  };
223
190
  //# sourceMappingURL=pkg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAQ1D,MAAM,IAAI,GAAG,CACX,OAAsD,EACtD,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAErC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAEQ,CAAA;QACxB,4CAA4C;QAC5C,+BAA+B;QAC/B,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,MAA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,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACnC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;YACrB,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,QAAQ,CAAC,CAAA;QAEZ,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;QACxB,OAAO,CAAC,IAAI,CAAC;YACX,QAAQ,EAAE,GAAG;YACb,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { resolve } from 'node:path'\nimport * as dotProp from '@vltpkg/dot-prop'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport assert from 'node:assert'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { init } from '@vltpkg/init'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { Views } from '../view.ts'\nimport { views as initViews } from './init.ts'\nimport { actual, GraphModifier } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport type { QueryResponseNode } from '@vltpkg/query'\n\ntype ManifestWithLocation = {\n manifest: NormalizedManifest\n location: string\n}\n\nconst json = (\n results: ManifestWithLocation[] | ManifestWithLocation,\n) => JSON.stringify(results, null, 2)\n\nexport const views = {\n human: (results_, _, config) => {\n const results = results_ as\n | ManifestWithLocation[]\n | ManifestWithLocation\n // `vlt pkg init` is an alias for `vlt init`\n // use the same output handling\n if (config.positionals[0] === 'init') {\n return initViews.human(results as InitFileResults)\n }\n\n return (\n Array.isArray(results) ?\n typeof results[0] === 'string' ?\n (results as unknown as string[]).join('\\n')\n : json(results)\n : json(results)\n )\n },\n} as const satisfies Views\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pkg',\n usage: '[<command>] [<args>]',\n description: 'Get or manipulate package.json values',\n subcommands: {\n get: {\n usage: '[<key>]',\n description: 'Get a single value',\n },\n init: {\n usage: '',\n description:\n 'Initialize a new package.json file in the current directory',\n },\n pick: {\n usage: '[<key> [<key> ...]]',\n description: 'Get multiple values or the entire package',\n },\n set: {\n usage: '<key>=<value> [<key>=<value> ...]',\n description: 'Set one or more key value pairs',\n },\n delete: {\n usage: '<key> [<key> ...]',\n description: 'Delete one or more keys from the package',\n },\n },\n examples: {\n 'set \"array[1].key=value\"': {\n description: 'Set a value on an object inside an array',\n },\n 'set \"array[]=value\"': {\n description: 'Append a value to an array',\n },\n },\n })\n\nexport const command: CommandFn = async conf => {\n const [sub, ...args] = conf.positionals\n if (sub === 'init') {\n return await init({ cwd: process.cwd() })\n }\n\n const pkg = conf.options.packageJson\n\n // Handle --scope option to get multiple manifests\n const scopeQueryString = conf.get('scope')\n let manifests: ManifestWithLocation[]\n\n if (scopeQueryString) {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: false,\n })\n\n const securityArchive =\n Query.hasSecuritySelectors(scopeQueryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n\n const { nodes } = await query.search(scopeQueryString, {\n signal: new AbortController().signal,\n })\n\n // collects the paths of the nodes selected using --scope\n const scopePaths = nodes\n .filter(\n (n): n is QueryResponseNode & { location: string } =>\n n.location !== undefined,\n )\n .map(n => resolve(conf.options.projectRoot, n.location))\n\n // reads multiple manifests for each selected scope\n manifests = scopePaths.map(location => ({\n manifest: pkg.read(location),\n location,\n }))\n\n if (manifests.length === 0) {\n throw error('No matching package found using scope', {\n found: scopeQueryString,\n })\n }\n } else {\n // Single manifest mode\n const location = pkg.find() ?? conf.projectRoot\n manifests = [\n {\n manifest: pkg.read(location),\n location,\n },\n ]\n }\n\n switch (sub) {\n case 'get':\n return get(manifests, args)\n case 'pick':\n return pick(manifests, args)\n case 'set':\n return set(manifests, pkg, args)\n case 'rm':\n case 'remove':\n case 'unset':\n case 'delete':\n return rm(manifests, pkg, args)\n default: {\n throw error('Unrecognized pkg command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['get', 'set', 'rm'],\n })\n }\n }\n}\n\nconst get = (manifests: ManifestWithLocation[], args: string[]) => {\n const noArg = () =>\n error(\n 'get requires not more than 1 argument. use `pick` to get more than 1.',\n { code: 'EUSAGE' },\n noArg,\n )\n if (args.length !== 1) {\n if (args.length > 1) {\n throw noArg()\n }\n return pick(manifests, args)\n }\n assert(args[0] != null, noArg())\n\n const [key] = args\n\n if (manifests.length === 1) {\n const [firstManifest] = manifests\n if (!firstManifest?.manifest) {\n /* c8 ignore start */\n throw error(\n 'No manifest found',\n firstManifest?.location ?\n { path: firstManifest.location }\n : {},\n )\n /* c8 ignore stop */\n }\n return dotProp.get(firstManifest.manifest, key)\n }\n\n return manifests.map(manifest =>\n dotProp.get(manifest.manifest, key),\n )\n}\n\nconst pick = (manifests: ManifestWithLocation[], args: string[]) => {\n if (manifests.length === 1) {\n const [firstManifest] = manifests\n /* c8 ignore start */\n if (!firstManifest?.manifest) {\n throw error(\n 'No manifest found',\n firstManifest?.location ?\n { path: firstManifest.location }\n : {},\n )\n }\n /* c8 ignore stop */\n const { manifest } = firstManifest\n return args.length ?\n args.reduce(\n (acc, key) =>\n dotProp.set(acc, key, dotProp.get(manifest, key)),\n {},\n )\n : manifest\n }\n\n // Multiple manifests - return results keyed by location\n return manifests.map(manifest =>\n args.length ?\n args.reduce(\n (acc, key) =>\n dotProp.set(acc, key, dotProp.get(manifest.manifest, key)),\n {},\n )\n : manifest.manifest,\n )\n}\n\nconst set = (\n manifests: ManifestWithLocation[],\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('set requires arguments', { code: 'EUSAGE' })\n }\n\n for (const { manifest, location } of manifests) {\n const res = args.reduce((acc, p) => {\n const index = p.indexOf('=')\n if (index === -1) {\n throw error('set arguments must contain `=`', {\n code: 'EUSAGE',\n })\n }\n return dotProp.set(\n acc,\n p.substring(0, index),\n p.substring(index + 1),\n )\n }, manifest)\n\n pkg.write(location, res)\n }\n}\n\nconst rm = (\n manifests: ManifestWithLocation[],\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('rm requires arguments', { code: 'EUSAGE' })\n }\n\n const results: ManifestWithLocation[] = []\n\n for (const { manifest, location } of manifests) {\n const res = args.reduce((acc, key) => {\n dotProp.del(acc, key)\n return acc\n }, manifest)\n\n pkg.write(location, res)\n results.push({\n manifest: res,\n location,\n })\n }\n\n if (manifests.length === 1) {\n return results[0]\n }\n return results\n}\n"]}
1
+ {"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,MAAM,CA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GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAE5B,MAAM,CACJ,KAAK,KAAK,CAAC,CAAC,EACZ,KAAK,CAAC,gCAAgC,EAAE;YACtC,IAAI,EAAE,QAAQ;SACf,CAAC,CACH,CAAA;QAED,OAAO,OAAO,CAAC,GAAG,CAChB,GAAG,EACH,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EACrB,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CACvB,CAAA;IACH,CAAC,EAAE,QAAQ,CAAC,CAAA;IAEZ,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,EAAE,GAAG,CACT,QAA4B,EAC5B,QAAgB,EAChB,GAAgB,EAChB,IAAc,EACd,EAAE;IACF,MAAM,CACJ,IAAI,CAAC,MAAM,IAAI,CAAC,EAChB,KAAK,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CACnD,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACrB,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,QAAQ,CAAC,CAAA;IAEZ,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAExB,OAAO;QACL,QAAQ,EAAE,GAAG;QACb,QAAQ;KACT,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { resolve } from 'node:path'\nimport * as dotProp from '@vltpkg/dot-prop'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport assert from 'node:assert'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { init } from '@vltpkg/init'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { Views } from '../view.ts'\nimport { views as initViews } from './init.ts'\nimport { actual, GraphModifier } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\n\nexport const views = {\n human: (results, _, config) => {\n // `vlt pkg init` is an alias for `vlt init`\n // use the same output handling\n if (config.positionals[0] === 'init') {\n return initViews.human(results as InitFileResults)\n }\n\n // When `get` is run with a single arg and it returns a string,\n // just print items separated by newlines\n if (Array.isArray(results) && typeof results[0] === 'string') {\n return results.join('\\n')\n }\n\n return JSON.stringify(results, null, 2)\n },\n} as const satisfies Views\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pkg',\n usage: '[<command>] [<args>]',\n description: 'Get or manipulate package.json values',\n subcommands: {\n get: {\n usage: '[<key>]',\n description: 'Get a single value',\n },\n init: {\n usage: '',\n description:\n 'Initialize a new package.json file in the current directory',\n },\n pick: {\n usage: '[<key> [<key> ...]]',\n description: 'Get multiple values or the entire package',\n },\n set: {\n usage: '<key>=<value> [<key>=<value> ...]',\n description: 'Set one or more key value pairs',\n },\n delete: {\n usage: '<key> [<key> ...]',\n description: 'Delete one or more keys from the package',\n },\n },\n examples: {\n 'set \"array[1].key=value\"': {\n description: 'Set a value on an object inside an array',\n },\n 'set \"array[]=value\"': {\n description: 'Append a value to an array',\n },\n },\n })\n\nexport const command: CommandFn = async conf => {\n const [sub, ...args] = conf.positionals\n if (sub === 'init') {\n return await init({ cwd: process.cwd() })\n }\n\n assert(\n sub,\n error('pkg command requires a subcommand', {\n code: 'EUSAGE',\n validOptions: ['get', 'pick', 'set', 'rm', 'init'],\n }),\n )\n\n const { options, projectRoot } = conf\n const queryString = conf.get('scope')\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n\n const locations: string[] = []\n let single: string | null = null\n\n if (queryString) {\n const modifiers = GraphModifier.maybeLoad(options)\n const graph = actual.load({\n ...options,\n mainManifest: options.packageJson.read(projectRoot),\n modifiers,\n monorepo: options.monorepo,\n loadManifests: false,\n })\n\n const securityArchive =\n Query.hasSecuritySelectors(queryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: options,\n })\n : undefined\n\n const query = new Query({\n graph,\n specOptions: options,\n securityArchive,\n })\n\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n\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 locations.push(resolve(projectRoot, location))\n }\n } else if (paths?.length || groups?.length || recursive) {\n for (const workspace of options.monorepo ?? []) {\n locations.push(workspace.fullpath)\n }\n } else {\n single = options.packageJson.find(process.cwd()) ?? projectRoot\n }\n\n if (single) {\n return commandSingle(single, sub, args, conf)\n }\n\n assert(\n locations.length > 0,\n error('No matching package found using scope', {\n found: queryString || 'workspace selection',\n }),\n )\n\n const results: unknown[] = []\n for (const location of locations) {\n results.push(await commandSingle(location, sub, args, conf))\n }\n\n return results\n}\n\nconst commandSingle = async (\n location: string,\n sub: string,\n args: string[],\n conf: LoadedConfig,\n) => {\n const pkg = conf.options.packageJson\n const manifest = pkg.read(location)\n\n switch (sub) {\n case 'get':\n return get(manifest, args)\n case 'pick':\n return pick(manifest, args)\n case 'set':\n return set(manifest, location, pkg, args)\n case 'rm':\n case 'remove':\n case 'unset':\n case 'delete':\n return rm(manifest, location, pkg, args)\n default: {\n throw error('Unrecognized pkg command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['get', 'set', 'rm'],\n })\n }\n }\n}\n\nconst get = (manifest: NormalizedManifest, args: string[]) => {\n const noArg = () =>\n error(\n 'get requires not more than 1 argument. use `pick` to get more than 1.',\n { code: 'EUSAGE' },\n noArg,\n )\n\n if (args.length === 1) {\n const [key] = args\n assert(key, noArg())\n return dotProp.get(manifest, key)\n }\n\n assert(args.length === 0, noArg())\n return pick(manifest, args)\n}\n\nconst pick = (manifest: NormalizedManifest, args: string[]) => {\n return args.length ?\n args.reduce(\n (acc, key) =>\n dotProp.set(acc, key, dotProp.get(manifest, key)),\n {},\n )\n : manifest\n}\n\nconst set = (\n manifest: NormalizedManifest,\n location: string,\n pkg: PackageJson,\n args: string[],\n) => {\n assert(\n args.length >= 1,\n error('set requires arguments', { code: 'EUSAGE' }),\n )\n\n const res = args.reduce((acc, p) => {\n const index = p.indexOf('=')\n\n assert(\n index !== -1,\n error('set arguments must contain `=`', {\n code: 'EUSAGE',\n }),\n )\n\n return dotProp.set(\n acc,\n p.substring(0, index),\n p.substring(index + 1),\n )\n }, manifest)\n\n pkg.write(location, res)\n}\n\nconst rm = (\n manifest: NormalizedManifest,\n location: string,\n pkg: PackageJson,\n args: string[],\n) => {\n assert(\n args.length >= 1,\n error('rm requires arguments', { code: 'EUSAGE' }),\n )\n\n const res = args.reduce((acc, key) => {\n dotProp.del(acc, key)\n return acc\n }, manifest)\n\n pkg.write(location, res)\n\n return {\n manifest: res,\n location,\n }\n}\n"]}
@@ -211,6 +211,12 @@ export declare const definition: import("jackspeak").Jack<{
211
211
  } & {
212
212
  scope: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
213
213
  target: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
214
+ } & {
215
+ 'if-present': {
216
+ description: string;
217
+ };
218
+ } & {
219
+ 'if-present': import("jackspeak").ConfigOption<"boolean", false, undefined>;
214
220
  } & {
215
221
  recursive: {
216
222
  short: string;
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAOd,CAAA;AAEV,eAAO,MAAM,aAAa,cAKjB,CAAA;AA+CT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;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W1B,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA4NP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyDvB,CAAA;AAEJ,eAAO,MAAM,mBAAmB,gBAS/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
@@ -388,6 +388,19 @@ export const definition = j
388
388
  short: 't',
389
389
  description: 'Set to select packages using a DSS Query selector.',
390
390
  },
391
+ })
392
+ .flag({
393
+ 'if-present': {
394
+ description: `When running scripts across multiple packages,
395
+ only include packages that have the script.
396
+
397
+ If this is not set, then the run will fail if any
398
+ packages do not have the script.
399
+
400
+ This will default to true if --scope, --workspace,
401
+ --workspace-group, or --recursive is set. Otherwise,
402
+ it will default to false.`,
403
+ },
391
404
  })
392
405
  .flag({
393
406
  recursive: {
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources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AE;+EAC4D;KAC1E;CACF,CAAC;KAED,IAAI,CAAC;IACJ,GAAG,EAAE;QACH,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,+CAA+C;KAC7D;IACD,OAAO,EAAE;QACP,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,mBAAmB;KACjC;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,2BAA2B;KACzC;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA;IAChC,OAAO,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,CAAoB,EAAE,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 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,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,CAAC;QAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,eAAe;QAC1C,CAAC,CAAC,IAAI,CAAC,CAAA;AAET,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,YAAY;IAC1B,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO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MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView =\n // If stdout is a TTY, use human output\n process.stdout.isTTY ? 'human'\n // If its not a TTY but is a CI environment, use human output\n // TODO: make a better view option for CI environments\n : process.env.CI ? 'human'\n // Otherwise, use json output\n : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n exec: 'exec',\n 'exec-local': 'exec-local',\n gui: 'gui',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n update: 'update',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'uninstall',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n conf: 'config',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n 'node-version': {\n hint: 'version',\n description: `Node version to use when choosing packages based on\n their \\`engines.node\\` value.`,\n default: process.version,\n },\n })\n\n .flag({\n 'git-shallow': {\n description: `Set to force \\`--depth=1\\` on all git clone actions.\n When set explicitly to false with --no-git-shallow,\n then \\`--depth=1\\` will not be used.\n\n When not set explicitly, \\`--depth=1\\` will be used for\n git hosts known to support this behavior.`,\n },\n })\n .num({\n 'fetch-retries': {\n hint: 'n',\n description: `Number of retries to perform when encountering network\n errors or likely-transient errors from git hosts.`,\n default: 3,\n },\n 'fetch-retry-factor': {\n hint: 'n',\n description: `The exponential backoff factor to use when retrying\n requests due to network issues.`,\n default: 2,\n },\n 'fetch-retry-mintimeout': {\n hint: 'n',\n description: `Number of milliseconds before starting first retry`,\n default: 0,\n },\n 'fetch-retry-maxtimeout': {\n hint: 'n',\n description: `Maximum number of milliseconds between two retries`,\n default: 30_000,\n },\n 'stale-while-revalidate-factor': {\n hint: 'n',\n default: 60,\n description: `If the server does not serve a \\`stale-while-revalidate\\`\n value in the \\`cache-control\\` header, then this multiplier\n is applied to the \\`max-age\\` or \\`s-maxage\\` values.\n\n By default, this is \\`60\\`, so for example a response that\n is cacheable for 5 minutes will allow a stale response\n while revalidating for up to 5 hours.\n\n If the server *does* provide a \\`stale-while-revalidate\\`\n value, then that is always used.\n\n Set to 0 to prevent any \\`stale-while-revalidate\\` behavior\n unless explicitly allowed by the server's \\`cache-control\\`\n header.\n `,\n },\n })\n\n .opt({\n identity: {\n short: 'i',\n validate: (v: unknown) =>\n typeof v === 'string' && /^[a-z0-9]*$/.test(v),\n hint: 'name',\n default: '',\n description: `Provide a string to define an identity for storing auth\n information when logging into registries.\n\n Authentication tokens will be stored in the XDG data\n directory, in \\`vlt/auth/$\\{identity}/keychain.json\\`.\n\n If no identity is provided, then the default \\`''\\` will\n be used, storing the file at \\`vlt/auth/keychain.json\\`.\n\n May only contain lowercase alphanumeric characters.\n `,\n },\n })\n\n .optList({\n workspace: {\n hint: 'ws',\n short: 'w',\n description: `Set to limit the spaces being worked on when working on\n workspaces.\n\n Can be paths or glob patterns matching paths.\n\n Specifying workspaces by package.json name is not\n supported.`,\n },\n 'workspace-group': {\n short: 'g',\n description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n 'if-present': {\n description: `When running scripts across multiple packages,\n only include packages that have the script.\n\n If this is not set, then the run will fail if any\n packages do not have the script.\n\n This will default to true if --scope, --workspace,\n --workspace-group, or --recursive is set. Otherwise,\n it will default to false.`,\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'user | project',\n description: `Specify whether to operate on user-level or project-level\n configuration files when running \\`vlt config\\` commands.`,\n validOptions: ['user', 'project'] as const,\n default: 'project',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard GUI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n The directory must exist and nothing will be copied to it.`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EACV,IAAI,EACJ,MAAM,EACN,WAAW,EACX,GAAG,EACH,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,aAAa,CAAA;AAMpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAOrD,MAAM,MAAM,QAAQ,GAAG,OAAO,IAAI,GAAG,OAAO,GAAG,GAAG,OAAO,OAAO,CAAA;AAChE,MAAM,MAAM,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;;CAeoB,CAAA;AAEtC,KAAK,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEzD,qBAAa,WAAW,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,QAAQ;;IAC7D,EAAE,EAAE,CAAC,CAAA;IACL,EAAE,EAAE,CAAC,CAAA;IACL,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,EAAE,CAAA;IAId,IAAI,EAAE,YAAY,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,eAAe,0BAKb;gBAEU,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IAmB5C,OAAO,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAIpC,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IAoHhC,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;IAkBlC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa;IAehE,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"}
@@ -31,7 +31,7 @@ const isMultiScriptSet = (o) => {
31
31
  const isSingleSuccess = (o) => o.signal === null && o.status === 0;
32
32
  const setExitCode = (result) => {
33
33
  /* c8 ignore next */
34
- process.exitCode = process.exitCode || (result.status ?? 1);
34
+ process.exitCode ||= result.status ?? 1;
35
35
  };
36
36
  export const views = {
37
37
  // run results for single or multiple will be printed along the way.
@@ -56,6 +56,7 @@ export class ExecCommand {
56
56
  args;
57
57
  #monorepo;
58
58
  #nodes;
59
+ #defaultIgnoreMissing = false;
59
60
  conf;
60
61
  projectRoot;
61
62
  view;
@@ -86,8 +87,12 @@ export class ExecCommand {
86
87
  async run() {
87
88
  const { conf } = this;
88
89
  const queryString = conf.get('scope');
90
+ const paths = conf.get('workspace');
91
+ const groups = conf.get('workspace-group');
92
+ const recursive = conf.get('recursive');
89
93
  // scope takes precedence over workspaces or groups
90
94
  if (queryString) {
95
+ this.#defaultIgnoreMissing = true;
91
96
  const graph = actual.load({
92
97
  ...conf.options,
93
98
  mainManifest: conf.options.packageJson.read(this.projectRoot),
@@ -111,16 +116,11 @@ export class ExecCommand {
111
116
  this.#nodes.push(location);
112
117
  }
113
118
  }
114
- else {
115
- const paths = conf.get('workspace');
116
- const groups = conf.get('workspace-group');
117
- const recursive = conf.get('recursive');
118
- this.#monorepo =
119
- paths?.length || groups?.length || recursive ?
120
- Monorepo.load(this.projectRoot, {
121
- load: { paths, groups },
122
- })
123
- : undefined;
119
+ else if (paths?.length || groups?.length || recursive) {
120
+ this.#defaultIgnoreMissing = true;
121
+ this.#monorepo = Monorepo.load(this.projectRoot, {
122
+ load: { paths, groups },
123
+ });
124
124
  }
125
125
  if (this.#targetCount() === 1) {
126
126
  const arg = this.fgArg();
@@ -158,6 +158,11 @@ export class ExecCommand {
158
158
  failed = true;
159
159
  throw er;
160
160
  });
161
+ // If we are allowed to ignore missing commands, then command might be
162
+ // an emptry string. If so, we don't print anything and return null to
163
+ // be filtered out later.
164
+ if (!result.command)
165
+ return null;
161
166
  if (!failed)
162
167
  this.printResult(label, result);
163
168
  return result;
@@ -166,15 +171,15 @@ export class ExecCommand {
166
171
  if (this.#nodes) {
167
172
  for (const { label, cwd } of this.getTargets()) {
168
173
  const result = await runInDir(cwd, label);
169
- resultMap.set(label, result);
174
+ if (result)
175
+ resultMap.set(label, result);
170
176
  }
171
177
  }
172
178
  else if (this.#monorepo) {
173
- const wsResultMap = await this.#monorepo.run(async (ws) => {
174
- return runInDir(ws.fullpath, ws.path);
175
- });
179
+ const wsResultMap = await this.#monorepo.run(ws => runInDir(ws.fullpath, ws.path));
176
180
  for (const [ws, result] of wsResultMap) {
177
- resultMap.set(ws.path, result);
181
+ if (result)
182
+ resultMap.set(ws.path, result);
178
183
  }
179
184
  }
180
185
  const results = {};
@@ -236,7 +241,6 @@ export class ExecCommand {
236
241
  return;
237
242
  return {
238
243
  cwd,
239
- /* c8 ignore next - already guarded */
240
244
  arg0,
241
245
  args: this.args,
242
246
  projectRoot: this.projectRoot,
@@ -248,7 +252,7 @@ export class ExecCommand {
248
252
  return {
249
253
  cwd,
250
254
  acceptFail: !this.conf.get('bail'),
251
- ignoreMissing: true,
255
+ ignoreMissing: this.conf.get('if-present') ?? this.#defaultIgnoreMissing,
252
256
  arg0: this.arg0,
253
257
  args: this.args,
254
258
  projectRoot: this.projectRoot,
@@ -1 +1 @@
1
- {"version":3,"file":"exec-command.js","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAehD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7D,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,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QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;gBAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;gBAC/C,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,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
+ {"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;AA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AAwD,CACzD,CAAA;IACH,CAAC;IAED,UAAU;QAKR,MAAM,OAAO,GAAG,EAAE,CAAA;QAClB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;gBAC7D,MAAM,KAAK;gBACT,oBAAoB;gBACpB,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;gBAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;gBAC/C,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,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 ||= result.status ?? 1\n}\n\nexport const views = {\n // run results for single or multiple will be printed along the way.\n human: result => {\n if (isScriptSet(result)) stdout('Scripts available:', result)\n else if (isMultiScriptSet(result)) {\n stdout('Scripts available:')\n for (const [path, scripts] of Object.entries(result)) {\n stdout(path, scripts)\n }\n }\n },\n json: result =>\n isRunResult(result) && isSingleSuccess(result) ?\n undefined\n : result,\n} as const satisfies Views<ExecResult>\n\ntype ViewValues = 'human' | 'json' | 'inspect' | 'silent'\n\nexport class ExecCommand<B extends RunnerBG, F extends RunnerFG> {\n bg: B\n fg: F\n arg0?: string\n args: string[]\n #monorepo?: Monorepo\n #nodes?: string[]\n #defaultIgnoreMissing = false\n conf: LoadedConfig\n projectRoot: string\n view: ViewValues\n validViewValues = new Map<string, ViewValues>([\n ['human', 'human'],\n ['json', 'json'],\n ['inspect', 'inspect'],\n ['silent', 'silent'],\n ])\n\n constructor(conf: LoadedConfig, bg: B, fg: F) {\n this.conf = conf\n this.bg = bg\n this.fg = fg\n this.view = this.validViewValues.get(conf.values.view) ?? 'human'\n const {\n projectRoot,\n positionals: [arg0, ...args],\n } = conf\n this.arg0 = arg0\n this.args = args\n this.projectRoot = projectRoot\n }\n\n #targetCount(): number {\n if (this.#nodes) return this.#nodes.length\n return this.#monorepo?.size ?? 1\n }\n\n hasArg0(): this is this & { arg0: string } {\n return !!this.arg0\n }\n\n async run(): Promise<ExecResult> {\n const { conf } = this\n\n const queryString = conf.get('scope')\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n\n // scope takes precedence over workspaces or groups\n if (queryString) {\n this.#defaultIgnoreMissing = true\n const graph = actual.load({\n ...conf.options,\n mainManifest: conf.options.packageJson.read(this.projectRoot),\n monorepo: Monorepo.load(this.projectRoot),\n loadManifests: false,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive: undefined,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n this.#nodes = []\n for (const node of nodes) {\n const { location } = node.toJSON()\n assert(\n location,\n error(`node ${node.id} has no location`, {\n found: node,\n }),\n )\n this.#nodes.push(location)\n }\n } else if (paths?.length || groups?.length || recursive) {\n this.#defaultIgnoreMissing = true\n this.#monorepo = Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n }\n\n if (this.#targetCount() === 1) {\n const arg = this.fgArg()\n if (!arg) return this.noArgsSingle()\n const result = await this.fg(arg)\n if (isRunResult(result)) {\n setExitCode(result)\n }\n return result\n }\n\n if (this.#targetCount() === 0) {\n if (queryString) {\n throw error('no matching nodes found for query', {\n found: queryString,\n })\n } else {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.#monorepo?.load().paths() ?? [])],\n })\n }\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false as boolean\n const runInDir = async (cwd: string, label: string) => {\n const result = await this.bg(this.bgArg(cwd)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(label, er.cause)\n }\n failed = true\n throw er\n },\n )\n // If we are allowed to ignore missing commands, then command might be\n // an emptry string. If so, we don't print anything and return null to\n // be filtered out later.\n if (!result.command) return null\n if (!failed) this.printResult(label, result)\n return result\n }\n\n const resultMap = new Map<string, SpawnResultStdioStrings>()\n if (this.#nodes) {\n for (const { label, cwd } of this.getTargets()) {\n const result = await runInDir(cwd, label)\n if (result) resultMap.set(label, result)\n }\n } else if (this.#monorepo) {\n const wsResultMap = await this.#monorepo.run(ws =>\n runInDir(ws.fullpath, ws.path),\n )\n for (const [ws, result] of wsResultMap) {\n if (result) resultMap.set(ws.path, result)\n }\n }\n\n const results: Record<string, RunResult> = {}\n for (const [path, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[path] = result\n }\n return results\n }\n\n printResult(path: string, result: RunResult) {\n // non-human results just get printed at the end\n if (this.view !== 'human') return\n\n if (result.status === 0 && result.signal === null) {\n stdout(path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n path + ' failure',\n ),\n {\n status: result.status,\n signal: result.signal,\n },\n )\n /* c8 ignore start */\n if (result.stderr) stderr(ansiToAnsi(result.stderr))\n if (result.stdout) stdout(ansiToAnsi(result.stdout))\n /* c8 ignore stop */\n setExitCode(result)\n }\n }\n\n /* c8 ignore start - env specific */\n interactiveShell(): string {\n return (\n process.env.SHELL ??\n this.conf.get('script-shell') ??\n (process.platform === 'win32' ? 'cmd.exe' : '/bin/sh')\n )\n }\n /* c8 ignore stop */\n\n // overridden by 'vlt run' which returns undefined\n defaultArg0(): string | undefined {\n return this.interactiveShell()\n }\n\n getCwd(): string {\n if (this.#nodes) {\n const [first] = this.#nodes\n assert(first, error('no nodes found'))\n return resolve(this.projectRoot, first)\n }\n return (\n this.#monorepo?.values().next().value?.fullpath ??\n this.projectRoot\n )\n }\n\n fgArg(): RunnerOptions | undefined {\n const cwd = this.getCwd()\n const arg0 = this.arg0 ?? this.defaultArg0()\n\n // return undefined so noArgsSingle will be called instead\n if (typeof arg0 !== 'string') return\n\n return {\n cwd,\n arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.conf.options.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, cwd: string): RunnerOptions {\n return {\n cwd,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing:\n this.conf.get('if-present') ?? this.#defaultIgnoreMissing,\n arg0: this.arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.conf.options.packageJson,\n 'script-shell': this.conf.get('script-shell'),\n }\n }\n\n /* c8 ignore start - not used, only here to override */\n noArgsSingle(): ScriptSet {\n throw error('Failed to determine interactive shell to spawn')\n }\n /* c8 ignore stop - not used, only here to override */\n\n noArgsMulti(): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\n }\n\n getTargets(): {\n label: string\n cwd: string\n manifest: NormalizedManifest\n }[] {\n const targets = []\n if (this.#nodes) {\n for (const location of this.#nodes) {\n const manifest = this.conf.options.packageJson.read(location)\n const label =\n /* c8 ignore next */\n location.startsWith('./') ? location.slice(2) : location\n const cwd = resolve(this.projectRoot, location)\n targets.push({ label, cwd, manifest })\n }\n } else if (this.#monorepo) {\n this.#monorepo.runSync(ws => {\n targets.push({\n label: ws.path,\n cwd: ws.fullpath,\n manifest: ws.manifest,\n })\n })\n }\n return targets\n }\n}\n"]}
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-22",
4
+ "version": "0.0.0-24",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -24,57 +24,57 @@
24
24
  "dependencies": {
25
25
  "ansi-to-pre": "^1.0.6",
26
26
  "graph-run": "^1.1.0",
27
- "ink": "^6.0.0",
27
+ "ink": "^6.2.2",
28
28
  "ink-spinner": "^5.0.0",
29
29
  "jackspeak": "^4.1.1",
30
30
  "lz-string": "^1.5.0",
31
- "minimatch": "^10.0.1",
31
+ "minimatch": "^10.0.3",
32
32
  "package-json-from-dist": "^1.0.1",
33
33
  "path-scurry": "^2.0.0",
34
- "pretty-bytes": "^6.1.1",
35
- "react": "^19.0.0",
36
- "react-dom": "^19.0.0",
34
+ "pretty-bytes": "^7.0.1",
35
+ "react": "^19.1.1",
37
36
  "react-devtools-core": "^4.28.5",
37
+ "react-dom": "^19.1.1",
38
38
  "ssri": "^12.0.0",
39
- "supports-color": "^10.0.0",
39
+ "supports-color": "^10.2.0",
40
40
  "tar": "^7.4.3",
41
- "@vltpkg/dep-id": "0.0.0-22",
42
- "@vltpkg/config": "0.0.0-22",
43
- "@vltpkg/dot-prop": "0.0.0-22",
44
- "@vltpkg/error-cause": "0.0.0-22",
45
- "@vltpkg/git": "0.0.0-22",
46
- "@vltpkg/init": "0.0.0-22",
47
- "@vltpkg/graph": "0.0.0-22",
48
- "@vltpkg/output": "0.0.0-22",
49
- "@vltpkg/package-json": "0.0.0-22",
50
- "@vltpkg/package-info": "0.0.0-22",
51
- "@vltpkg/registry-client": "0.0.0-22",
52
- "@vltpkg/rollback-remove": "0.0.0-22",
53
- "@vltpkg/query": "0.0.0-22",
54
- "@vltpkg/promise-spawn": "0.0.0-22",
55
- "@vltpkg/run": "0.0.0-22",
56
- "@vltpkg/security-archive": "0.0.0-22",
57
- "@vltpkg/server": "0.0.0-22",
58
- "@vltpkg/spec": "0.0.0-22",
59
- "@vltpkg/types": "0.0.0-22",
60
- "@vltpkg/url-open": "0.0.0-22",
61
- "@vltpkg/vlt-json": "0.0.0-22",
62
- "@vltpkg/vlx": "0.0.0-22",
63
- "@vltpkg/workspaces": "0.0.0-22",
64
- "@vltpkg/xdg": "0.0.0-22"
41
+ "@vltpkg/config": "0.0.0-24",
42
+ "@vltpkg/dot-prop": "0.0.0-24",
43
+ "@vltpkg/error-cause": "0.0.0-24",
44
+ "@vltpkg/graph": "0.0.0-24",
45
+ "@vltpkg/dep-id": "0.0.0-24",
46
+ "@vltpkg/git": "0.0.0-24",
47
+ "@vltpkg/package-info": "0.0.0-24",
48
+ "@vltpkg/output": "0.0.0-24",
49
+ "@vltpkg/init": "0.0.0-24",
50
+ "@vltpkg/package-json": "0.0.0-24",
51
+ "@vltpkg/promise-spawn": "0.0.0-24",
52
+ "@vltpkg/query": "0.0.0-24",
53
+ "@vltpkg/registry-client": "0.0.0-24",
54
+ "@vltpkg/rollback-remove": "0.0.0-24",
55
+ "@vltpkg/security-archive": "0.0.0-24",
56
+ "@vltpkg/server": "0.0.0-24",
57
+ "@vltpkg/run": "0.0.0-24",
58
+ "@vltpkg/url-open": "0.0.0-24",
59
+ "@vltpkg/spec": "0.0.0-24",
60
+ "@vltpkg/vlx": "0.0.0-24",
61
+ "@vltpkg/types": "0.0.0-24",
62
+ "@vltpkg/vlt-json": "0.0.0-24",
63
+ "@vltpkg/xdg": "0.0.0-24",
64
+ "@vltpkg/workspaces": "0.0.0-24"
65
65
  },
66
66
  "devDependencies": {
67
- "@eslint/js": "^9.28.0",
68
- "@types/node": "^22.15.29",
69
- "@types/react": "^19.0.0",
67
+ "@eslint/js": "^9.34.0",
68
+ "@types/node": "^22.17.2",
69
+ "@types/react": "^19.1.11",
70
70
  "@types/ssri": "^7.1.5",
71
- "eslint": "^9.28.0",
72
- "prettier": "^3.6.0",
71
+ "eslint": "^9.34.0",
72
+ "prettier": "^3.6.2",
73
73
  "tap": "^21.1.0",
74
74
  "tshy": "^3.0.2",
75
75
  "typedoc": "~0.27.9",
76
76
  "typescript": "5.7.3",
77
- "typescript-eslint": "^8.33.1"
77
+ "typescript-eslint": "^8.40.0"
78
78
  },
79
79
  "license": "BSD-2-Clause-Patent",
80
80
  "engines": {