@vltpkg/cli-sdk 0.0.0-14 → 0.0.0-15

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.
@@ -246,6 +246,7 @@ const add = async (conf, specs, view) => {
246
246
  ...conf.options,
247
247
  integrity,
248
248
  staleWhileRevalidate: false,
249
+ query: undefined,
249
250
  });
250
251
  view?.stdout('+', spec, r.resolved);
251
252
  });
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/commands/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,WAAW,MAAM,cAAc,CAAA;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAStC,IAAI,IAAe,CAAA;AACnB,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,YAAY,OAAoB,EAAE,IAAkB;QAClD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpB,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAe;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAA2B;IAC3C,KAAK,EAAE,SAAS;CACjB,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,6BAA6B;IAE1C,WAAW,EAAE;QAC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AK;SAC5B,CAAC;aACD,IAAI,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;YACd,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAA;YACjC,MAAM,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACjD,GAAG,IAAI,CAAC,OAAO;gBACf,SAAS;gBACT,oBAAoB,EAAE,KAAK;aAC5B,CAAC,CAAA;YACF,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;QAEJ,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAClB,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { CacheEntry } from '@vltpkg/registry-client'\nimport { Spec } from '@vltpkg/spec'\nimport { mkdir, rm } from 'node:fs/promises'\nimport prettyBytes from 'pretty-bytes'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stderr, stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type CacheMap = Record<\n string,\n ReturnType<CacheEntry['toJSON']>\n>\n\nexport type CacheSubcommands = keyof (typeof usageDef)['subcommands']\n\nlet view: CacheView\nexport class CacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | CacheMap> = {\n human: CacheView,\n}\n\nconst usageDef = {\n command: 'cache',\n usage: '<command> [flags]',\n description: 'Work with vlt cache folders',\n\n subcommands: {\n add: {\n usage: '<package-spec> [<package-spec>...]',\n description: `Resolve the referenced package identifiers and ensure they\n are cached.`,\n },\n\n ls: {\n usage: '[<key>...]',\n description: `Show cache entries. If no keys are provided, then a list of\n available keys will be printed. If one or more keys are\n provided, then details will be shown for the specified\n items.`,\n },\n\n info: {\n usage: '<key>',\n description: `Print metadata details for the specified cache key to\n stderr, and the response body to stdout.`,\n },\n\n clean: {\n usage: '[<key>...]',\n description: `Purge expired cache entries. If one or more keys are\n provided, then only those cache entries will be\n considered.`,\n },\n\n delete: {\n usage: '<key> [<key>...]',\n description: `Purge items explicitly, whether expired or not. If one or\n more keys are provided, then only those cache entries will\n be considered.`,\n },\n\n 'delete-before': {\n usage: '<date>',\n description: `Purge all cache items from before a given date. Date can be\n provided in any format that JavaScript can parse.`,\n },\n\n 'delete-all': {\n usage: '',\n description: `Delete the entire cache folder to make vlt slower.`,\n },\n },\n examples: {\n 'vlt cache ls https://registry.npmjs.org/typescript': {\n description: `Show cache metadata for a given registry URL`,\n },\n 'vlt cache add eslint@latest': {\n description: `Add a given package specifier to the cache by fetching\n its resolved value.`,\n },\n 'vlt cache info https://registry.npmjs.org/eslint/-/eslint-9.25.1.tgz > eslint.tgz':\n {\n description: `Print the cache metadata to stderr, and write the tarball\n on stdout, redirecting to a file.`,\n },\n 'vlt cache delete-before 2025-01-01': {\n description: 'Delete all entries created before Jan 1, 2025',\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<void | CacheMap> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'info':\n return info(conf, args, view)\n\n case 'add':\n return add(conf, args, view)\n\n case 'clean':\n return clean(conf, args, view)\n\n case 'delete':\n return deleteKeys(conf, args, view)\n\n case 'delete-before':\n return deleteBefore(conf, args, view)\n\n case 'delete-all':\n return deleteAll(conf, args, view)\n\n default: {\n throw error('Unrecognized cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: Object.keys(usageDef.subcommands),\n })\n }\n }\n}\n\nconst ls = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n): Promise<CacheMap> =>\n keys.length ?\n await fetchKeys(\n conf,\n keys,\n (entry: CacheEntry, key: string) => {\n view?.stdout(\n key.includes(' ') ? JSON.stringify(key) : key,\n entry,\n )\n return true\n },\n view,\n )\n : await fetchAll(conf, (_, key) => {\n view?.stdout(key.includes(' ') ? JSON.stringify(key) : key)\n return true\n })\n\nconst info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n): Promise<void> => {\n const [key] = keys\n if (keys.length !== 1 || !key) {\n throw error('Must provide exactly one cache key', {\n code: 'EUSAGE',\n })\n }\n await fetchKeys(\n conf,\n [key],\n (entry: CacheEntry, key: string) => {\n stderr(\n /* c8 ignore next */\n key.includes(' ') ? JSON.stringify(key) : key,\n entry,\n )\n if (entry.isJSON) {\n stdout(JSON.stringify(entry.body, null, 2))\n /* c8 ignore start - annoying to test, corrupts TAP output */\n } else {\n process.stdout.write(entry.body as Buffer)\n }\n /* c8 ignore stop */\n return true\n },\n view,\n )\n}\n\nconst fetchAll = async (\n conf: LoadedConfig,\n test: (entry: CacheEntry, key: string, val: Buffer) => boolean,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n const map: CacheMap = {}\n for await (const [key, val] of cache) {\n const entry = CacheEntry.decode(val)\n if (!test(entry, key, val)) continue\n map[key] = entry.toJSON()\n }\n return map\n}\n\nconst fetchKeys = async (\n conf: LoadedConfig,\n keys: string[],\n test: (entry: CacheEntry, key: string, buf: Buffer) => boolean,\n view?: CacheView,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n const map: CacheMap = {}\n const results: [string, Buffer | undefined][] = await Promise.all(\n keys.map(async key => {\n return [key, await cache.fetch(key)]\n }),\n )\n for (const [key, val] of results) {\n if (!val) {\n view?.stdout('Not found:', key)\n } else {\n const entry = CacheEntry.decode(val)\n if (!test(entry, key, val)) continue\n map[key] = entry.toJSON()\n }\n }\n\n return map\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n test: (entry: CacheEntry) => boolean,\n view?: CacheView,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n\n let count = 0\n let size = 0\n const testAction = (\n entry: CacheEntry,\n key: string,\n val: Buffer,\n ) => {\n if (!test(entry)) {\n return false\n }\n count++\n const s = val.byteLength + key.length\n cache.delete(key, true, entry.integrity)\n const k = key.includes(' ') ? JSON.stringify(key) : key\n view?.stdout('-', k, s)\n size += s\n return true\n }\n\n const map = await (keys.length ?\n fetchKeys(conf, keys, testAction, view)\n : fetchAll(conf, testAction))\n\n const pb = prettyBytes(size, { binary: true })\n\n const s = count === 1 ? '' : 's'\n await cache.promise()\n view?.stdout(`Removed ${count} item${s} totalling ${pb}`)\n return map\n}\n\nconst clean = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n) => deleteEntries(conf, keys, entry => !entry.valid, view)\n\nconst deleteBefore = async (\n conf: LoadedConfig,\n args: string[],\n view?: CacheView,\n) => {\n if (!args.length) {\n throw error('Must provide a date to delete before', {\n code: 'EUSAGE',\n })\n }\n const now = new Date()\n const before = new Date(args.join(' '))\n if (before >= now) {\n throw error('Cannot delete cache entries from the future', {\n code: 'EUSAGE',\n found: before,\n })\n }\n return deleteEntries(\n conf,\n [],\n entry => !!entry.date && entry.date < before,\n view,\n )\n}\n\nconst deleteKeys = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n) => {\n if (!keys.length) {\n throw error('Must provide cache keys to delete', {\n code: 'EUSAGE',\n })\n }\n return deleteEntries(conf, keys, () => true, view)\n}\n\nconst deleteAll = async (\n conf: LoadedConfig,\n _: string[],\n view?: CacheView,\n) => {\n const { cache } = conf.options.packageInfo.registryClient\n await rm(cache.path(), { recursive: true, force: true })\n await mkdir(cache.path(), { recursive: true })\n view?.stdout('Deleted all cache entries.')\n}\n\nconst add = async (\n conf: LoadedConfig,\n specs: string[],\n view?: CacheView,\n) => {\n if (!specs.length) {\n throw error('Must provide specs to add to the cache', {\n code: 'EUSAGE',\n })\n }\n const { packageInfo } = conf.options\n const promises: Promise<void>[] = []\n\n for (const spec of specs) {\n const p = packageInfo\n .resolve(Spec.parseArgs(spec, conf.options), {\n staleWhileRevalidate: false,\n })\n .then(async r => {\n const { resolved, integrity } = r\n await packageInfo.registryClient.request(resolved, {\n ...conf.options,\n integrity,\n staleWhileRevalidate: false,\n })\n view?.stdout('+', spec, r.resolved)\n })\n\n promises.push(p)\n }\n\n await Promise.all(promises)\n}\n"]}
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/commands/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,WAAW,MAAM,cAAc,CAAA;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAStC,IAAI,IAAe,CAAA;AACnB,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,YAAY,OAAoB,EAAE,IAAkB;QAClD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpB,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAe;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAA2B;IAC3C,KAAK,EAAE,SAAS;CACjB,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,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AC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE;YAC3C,oBAAoB,EAAE,KAAK;SAC5B,CAAC;aACD,IAAI,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;YACd,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAA;YACjC,MAAM,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACjD,GAAG,IAAI,CAAC,OAAO;gBACf,SAAS;gBACT,oBAAoB,EAAE,KAAK;gBAC3B,KAAK,EAAE,SAAS;aACjB,CAAC,CAAA;YACF,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;QAEJ,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAClB,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { CacheEntry } from '@vltpkg/registry-client'\nimport { Spec } from '@vltpkg/spec'\nimport { mkdir, rm } from 'node:fs/promises'\nimport prettyBytes from 'pretty-bytes'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stderr, stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type CacheMap = Record<\n string,\n ReturnType<CacheEntry['toJSON']>\n>\n\nexport type CacheSubcommands = keyof (typeof usageDef)['subcommands']\n\nlet view: CacheView\nexport class CacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | CacheMap> = {\n human: CacheView,\n}\n\nconst usageDef = {\n command: 'cache',\n usage: '<command> [flags]',\n description: 'Work with vlt cache folders',\n\n subcommands: {\n add: {\n usage: '<package-spec> [<package-spec>...]',\n description: `Resolve the referenced package identifiers and ensure they\n are cached.`,\n },\n\n ls: {\n usage: '[<key>...]',\n description: `Show cache entries. If no keys are provided, then a list of\n available keys will be printed. If one or more keys are\n provided, then details will be shown for the specified\n items.`,\n },\n\n info: {\n usage: '<key>',\n description: `Print metadata details for the specified cache key to\n stderr, and the response body to stdout.`,\n },\n\n clean: {\n usage: '[<key>...]',\n description: `Purge expired cache entries. If one or more keys are\n provided, then only those cache entries will be\n considered.`,\n },\n\n delete: {\n usage: '<key> [<key>...]',\n description: `Purge items explicitly, whether expired or not. If one or\n more keys are provided, then only those cache entries will\n be considered.`,\n },\n\n 'delete-before': {\n usage: '<date>',\n description: `Purge all cache items from before a given date. Date can be\n provided in any format that JavaScript can parse.`,\n },\n\n 'delete-all': {\n usage: '',\n description: `Delete the entire cache folder to make vlt slower.`,\n },\n },\n examples: {\n 'vlt cache ls https://registry.npmjs.org/typescript': {\n description: `Show cache metadata for a given registry URL`,\n },\n 'vlt cache add eslint@latest': {\n description: `Add a given package specifier to the cache by fetching\n its resolved value.`,\n },\n 'vlt cache info https://registry.npmjs.org/eslint/-/eslint-9.25.1.tgz > eslint.tgz':\n {\n description: `Print the cache metadata to stderr, and write the tarball\n on stdout, redirecting to a file.`,\n },\n 'vlt cache delete-before 2025-01-01': {\n description: 'Delete all entries created before Jan 1, 2025',\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<void | CacheMap> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'info':\n return info(conf, args, view)\n\n case 'add':\n return add(conf, args, view)\n\n case 'clean':\n return clean(conf, args, view)\n\n case 'delete':\n return deleteKeys(conf, args, view)\n\n case 'delete-before':\n return deleteBefore(conf, args, view)\n\n case 'delete-all':\n return deleteAll(conf, args, view)\n\n default: {\n throw error('Unrecognized cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: Object.keys(usageDef.subcommands),\n })\n }\n }\n}\n\nconst ls = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n): Promise<CacheMap> =>\n keys.length ?\n await fetchKeys(\n conf,\n keys,\n (entry: CacheEntry, key: string) => {\n view?.stdout(\n key.includes(' ') ? JSON.stringify(key) : key,\n entry,\n )\n return true\n },\n view,\n )\n : await fetchAll(conf, (_, key) => {\n view?.stdout(key.includes(' ') ? JSON.stringify(key) : key)\n return true\n })\n\nconst info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n): Promise<void> => {\n const [key] = keys\n if (keys.length !== 1 || !key) {\n throw error('Must provide exactly one cache key', {\n code: 'EUSAGE',\n })\n }\n await fetchKeys(\n conf,\n [key],\n (entry: CacheEntry, key: string) => {\n stderr(\n /* c8 ignore next */\n key.includes(' ') ? JSON.stringify(key) : key,\n entry,\n )\n if (entry.isJSON) {\n stdout(JSON.stringify(entry.body, null, 2))\n /* c8 ignore start - annoying to test, corrupts TAP output */\n } else {\n process.stdout.write(entry.body as Buffer)\n }\n /* c8 ignore stop */\n return true\n },\n view,\n )\n}\n\nconst fetchAll = async (\n conf: LoadedConfig,\n test: (entry: CacheEntry, key: string, val: Buffer) => boolean,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n const map: CacheMap = {}\n for await (const [key, val] of cache) {\n const entry = CacheEntry.decode(val)\n if (!test(entry, key, val)) continue\n map[key] = entry.toJSON()\n }\n return map\n}\n\nconst fetchKeys = async (\n conf: LoadedConfig,\n keys: string[],\n test: (entry: CacheEntry, key: string, buf: Buffer) => boolean,\n view?: CacheView,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n const map: CacheMap = {}\n const results: [string, Buffer | undefined][] = await Promise.all(\n keys.map(async key => {\n return [key, await cache.fetch(key)]\n }),\n )\n for (const [key, val] of results) {\n if (!val) {\n view?.stdout('Not found:', key)\n } else {\n const entry = CacheEntry.decode(val)\n if (!test(entry, key, val)) continue\n map[key] = entry.toJSON()\n }\n }\n\n return map\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n test: (entry: CacheEntry) => boolean,\n view?: CacheView,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n\n let count = 0\n let size = 0\n const testAction = (\n entry: CacheEntry,\n key: string,\n val: Buffer,\n ) => {\n if (!test(entry)) {\n return false\n }\n count++\n const s = val.byteLength + key.length\n cache.delete(key, true, entry.integrity)\n const k = key.includes(' ') ? JSON.stringify(key) : key\n view?.stdout('-', k, s)\n size += s\n return true\n }\n\n const map = await (keys.length ?\n fetchKeys(conf, keys, testAction, view)\n : fetchAll(conf, testAction))\n\n const pb = prettyBytes(size, { binary: true })\n\n const s = count === 1 ? '' : 's'\n await cache.promise()\n view?.stdout(`Removed ${count} item${s} totalling ${pb}`)\n return map\n}\n\nconst clean = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n) => deleteEntries(conf, keys, entry => !entry.valid, view)\n\nconst deleteBefore = async (\n conf: LoadedConfig,\n args: string[],\n view?: CacheView,\n) => {\n if (!args.length) {\n throw error('Must provide a date to delete before', {\n code: 'EUSAGE',\n })\n }\n const now = new Date()\n const before = new Date(args.join(' '))\n if (before >= now) {\n throw error('Cannot delete cache entries from the future', {\n code: 'EUSAGE',\n found: before,\n })\n }\n return deleteEntries(\n conf,\n [],\n entry => !!entry.date && entry.date < before,\n view,\n )\n}\n\nconst deleteKeys = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n) => {\n if (!keys.length) {\n throw error('Must provide cache keys to delete', {\n code: 'EUSAGE',\n })\n }\n return deleteEntries(conf, keys, () => true, view)\n}\n\nconst deleteAll = async (\n conf: LoadedConfig,\n _: string[],\n view?: CacheView,\n) => {\n const { cache } = conf.options.packageInfo.registryClient\n await rm(cache.path(), { recursive: true, force: true })\n await mkdir(cache.path(), { recursive: true })\n view?.stdout('Deleted all cache entries.')\n}\n\nconst add = async (\n conf: LoadedConfig,\n specs: string[],\n view?: CacheView,\n) => {\n if (!specs.length) {\n throw error('Must provide specs to add to the cache', {\n code: 'EUSAGE',\n })\n }\n const { packageInfo } = conf.options\n const promises: Promise<void>[] = []\n\n for (const spec of specs) {\n const p = packageInfo\n .resolve(Spec.parseArgs(spec, conf.options), {\n staleWhileRevalidate: false,\n })\n .then(async r => {\n const { resolved, integrity } = r\n await packageInfo.registryClient.request(resolved, {\n ...conf.options,\n integrity,\n staleWhileRevalidate: false,\n query: undefined,\n })\n view?.stdout('+', spec, r.resolved)\n })\n\n promises.push(p)\n }\n\n await Promise.all(promises)\n}\n"]}
@@ -88,7 +88,10 @@ const install = async (conf, keys, view) => {
88
88
  });
89
89
  }
90
90
  return Promise.all(keys.map(async (key) => {
91
- const info = await vlx.install(key, conf.options);
91
+ const info = await vlx.install(key, {
92
+ ...conf.options,
93
+ query: undefined,
94
+ });
92
95
  view?.stdout(info);
93
96
  return info.path;
94
97
  }));
@@ -107,7 +110,10 @@ const ls = async (_conf, args, view) => {
107
110
  const info = async (conf, keys, view) => {
108
111
  const results = [];
109
112
  for await (const key of keys.length ? keys : vlx.list()) {
110
- const info = vlx.info(key, conf.options);
113
+ const info = vlx.info(key, {
114
+ ...conf.options,
115
+ query: undefined,
116
+ });
111
117
  results.push(info);
112
118
  view?.stdout(info);
113
119
  }
@@ -115,7 +121,10 @@ const info = async (conf, keys, view) => {
115
121
  };
116
122
  const deleteEntries = async (conf, keys, view) => {
117
123
  const remover = new RollbackRemove();
118
- const removed = (await vlx.delete(keys, remover, conf.options)).map(path => {
124
+ const removed = (await vlx.delete(keys, remover, {
125
+ ...conf.options,
126
+ query: undefined,
127
+ })).map(path => {
119
128
  view?.stdout(`- ${basename(path)}`);
120
129
  return path;
121
130
  });
@@ -1 +1 @@
1
- {"version":3,"file":"exec-cache.js","sourceRoot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;IACpB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,KAAK,EACzB,IAAkB,EAClB,IAAc,EACd,IAAoB,EACD,EAAE;IACrB,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAA;IACpC,MAAM,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CACjE,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC,CACF,CAAA;IACD,OAAO,CAAC,OAAO,EAAE,CAAA;IACjB,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { VlxInfo } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { basename } from 'node:path'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type ExecCacheSubcommands =\n keyof (typeof usageDef)['subcommands']\n\nlet view: ExecCacheView\nexport class ExecCacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | string[] | VlxInfo[]> = {\n human: ExecCacheView,\n}\n\nconst usageDef = {\n command: 'exec-cache',\n usage: '<command> [flags]',\n description: 'Work with vlt exec-cache folders',\n\n subcommands: {\n ls: {\n usage: '',\n description: `Show previously installed packages used for \\`vlt exec\\`.\n Key provided can be either the package name, or the full\n key.`,\n },\n\n delete: {\n usage: '[<key>...]',\n description: `Delete previously installed packages used for\n \\`vlt exec\\`. If no keys are provided, then all entries\n will be deleted.`,\n },\n\n info: {\n usage: '<key>',\n description: `Show extended information about a given \\`vlt exec\\`\n installation.`,\n },\n\n install: {\n usage: '<spec>...',\n description: `Install the specified package(s) in the \\`vlt exec\\`\n central cache location. Metadata info about each\n installation will be printed.`,\n },\n },\n\n examples: {\n ls: {\n description: `Show all the keys for the installations in the \\`vlt exec\\`\n cache.`,\n },\n 'delete typescript': {\n description: `Delete all versions of typescript installed for vlt exec`,\n },\n 'info typescript-695bf962': {\n description: `Show extended info about a specific version of typescript`,\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<\n string[] | VlxInfo[]\n> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'info':\n return info(conf, args, view)\n\n case 'install':\n return install(conf, args, view)\n\n case 'delete':\n return deleteEntries(conf, args, view)\n\n default: {\n throw error('Unrecognized exec-cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: Object.keys(usageDef.subcommands),\n })\n }\n }\n}\n\nconst install = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n if (!keys.length) {\n throw error('Must supply a package spec to install', {\n code: 'EUSAGE',\n })\n }\n return Promise.all(\n keys.map(async key => {\n const info = await vlx.install(key, conf.options)\n view?.stdout(info)\n return info.path\n }),\n )\n}\n\nconst ls = async (\n _conf: LoadedConfig,\n args: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const results: string[] = []\n for await (const path of vlx.list()) {\n const key = basename(path)\n if (args.length && !args.some(a => key.includes(a))) continue\n results.push(key)\n view?.stdout(key)\n }\n return results\n}\n\nconst info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<VlxInfo[]> => {\n const results: VlxInfo[] = []\n for await (const key of keys.length ? keys : vlx.list()) {\n const info = vlx.info(key, conf.options)\n results.push(info)\n view?.stdout(info)\n }\n return results\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const remover = new RollbackRemove()\n const removed = (await vlx.delete(keys, remover, conf.options)).map(\n path => {\n view?.stdout(`- ${basename(path)}`)\n return path\n },\n )\n remover.confirm()\n return removed\n}\n"]}
1
+ {"version":3,"file":"exec-cache.js","sourceRoot":"","sources":["../../../src/commands/exec-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAKtC,IAAI,IAAmB,CAAA;AACvB,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YAAY,OAAoB,EAAE,IAAkB;QAClD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpB,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAe;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAuC;IACvD,KAAK,EAAE,aAAa;CACrB,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,kCAAkC;IAE/C,WAAW,EAAE;QACX,EAAE,EAAE;YACF,KAAK,EAAE,EAAE;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IAAoB,EACA,EAAE;IACtB,MAAM,OAAO,GAAc,EAAE,CAAA;IAC7B,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QACxD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE;YACzB,GAAG,IAAI,CAAC,OAAO;YACf,KAAK,EAAE,SAAS;SACjB,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,KAAK,EACzB,IAAkB,EAClB,IAAc,EACd,IAAoB,EACD,EAAE;IACrB,MAAM,OAAO,GAAG,IAAI,cAAc,EAAE,CAAA;IACpC,MAAM,OAAO,GAAG,CACd,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE;QAC9B,GAAG,IAAI,CAAC,OAAO;QACf,KAAK,EAAE,SAAS;KACjB,CAAC,CACH,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,OAAO,EAAE,CAAA;IACjB,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { VlxInfo } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { basename } from 'node:path'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type ExecCacheSubcommands =\n keyof (typeof usageDef)['subcommands']\n\nlet view: ExecCacheView\nexport class ExecCacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | string[] | VlxInfo[]> = {\n human: ExecCacheView,\n}\n\nconst usageDef = {\n command: 'exec-cache',\n usage: '<command> [flags]',\n description: 'Work with vlt exec-cache folders',\n\n subcommands: {\n ls: {\n usage: '',\n description: `Show previously installed packages used for \\`vlt exec\\`.\n Key provided can be either the package name, or the full\n key.`,\n },\n\n delete: {\n usage: '[<key>...]',\n description: `Delete previously installed packages used for\n \\`vlt exec\\`. If no keys are provided, then all entries\n will be deleted.`,\n },\n\n info: {\n usage: '<key>',\n description: `Show extended information about a given \\`vlt exec\\`\n installation.`,\n },\n\n install: {\n usage: '<spec>...',\n description: `Install the specified package(s) in the \\`vlt exec\\`\n central cache location. Metadata info about each\n installation will be printed.`,\n },\n },\n\n examples: {\n ls: {\n description: `Show all the keys for the installations in the \\`vlt exec\\`\n cache.`,\n },\n 'delete typescript': {\n description: `Delete all versions of typescript installed for vlt exec`,\n },\n 'info typescript-695bf962': {\n description: `Show extended info about a specific version of typescript`,\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<\n string[] | VlxInfo[]\n> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'info':\n return info(conf, args, view)\n\n case 'install':\n return install(conf, args, view)\n\n case 'delete':\n return deleteEntries(conf, args, view)\n\n default: {\n throw error('Unrecognized exec-cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: Object.keys(usageDef.subcommands),\n })\n }\n }\n}\n\nconst install = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n if (!keys.length) {\n throw error('Must supply a package spec to install', {\n code: 'EUSAGE',\n })\n }\n return Promise.all(\n keys.map(async key => {\n const info = await vlx.install(key, {\n ...conf.options,\n query: undefined,\n })\n view?.stdout(info)\n return info.path\n }),\n )\n}\n\nconst ls = async (\n _conf: LoadedConfig,\n args: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const results: string[] = []\n for await (const path of vlx.list()) {\n const key = basename(path)\n if (args.length && !args.some(a => key.includes(a))) continue\n results.push(key)\n view?.stdout(key)\n }\n return results\n}\n\nconst info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<VlxInfo[]> => {\n const results: VlxInfo[] = []\n for await (const key of keys.length ? keys : vlx.list()) {\n const info = vlx.info(key, {\n ...conf.options,\n query: undefined,\n })\n results.push(info)\n view?.stdout(info)\n }\n return results\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const remover = new RollbackRemove()\n const removed = (\n await vlx.delete(keys, remover, {\n ...conf.options,\n query: undefined,\n })\n ).map(path => {\n view?.stdout(`- ${basename(path)}`)\n return path\n })\n remover.confirm()\n return removed\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAoDhB,CAAA;AAGJ,eAAO,MAAM,UAAU,SAAU,MAAM,WAC2B,CAAA;AAElE,eAAO,MAAM,QAAQ,EAAE,QAyBtB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAUzC,CAAA"}
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAoDhB,CAAA;AAGJ,eAAO,MAAM,UAAU,SAAU,MAAM,WAC2B,CAAA;AAElE,eAAO,MAAM,QAAQ,EAAE,QAyBtB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAazC,CAAA"}
@@ -68,7 +68,10 @@ Is this ok? (y) `);
68
68
  return response;
69
69
  };
70
70
  export const command = async (conf) => {
71
- const arg0 = await vlx.resolve(conf.positionals, conf.options, promptFn);
71
+ const arg0 = await vlx.resolve(conf.positionals, {
72
+ ...conf.options,
73
+ query: undefined,
74
+ }, promptFn);
72
75
  if (arg0)
73
76
  conf.positionals[0] = arg0;
74
77
  // now we have arg0! let's gooooo!!
@@ -1 +1 @@
1
- {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE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iBACY,CACd,CAAA;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACrB,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE;IACzD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAC5B,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,OAAO,EACZ,QAAQ,CACT,CAAA;IACD,IAAI,IAAI;QAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IACpC,mCAAmC;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,OAAO,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { exec, execFG } from '@vltpkg/run'\nimport type { PromptFn } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { homedir } from 'node:os'\nimport { createInterface } from 'node:readline/promises'\nimport { commandUsage } from '../config/usage.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { styleTextStdout } from '../output.ts'\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec',\n usage: '[--package=<pkg>] [command...]',\n description: `Run a command defined by a package, installing it\n if necessary.\n\n If the package specifier is provided explicitly via the\n \\`--package\\` config, then that is what will be used. If\n a satisfying instance of the named package exists in the\n local \\`node_mnodules\\` folder, then that will be used.\n\n If \\`--package\\` is not set, then vlt will attempt to infer\n the package to be installed if necessary, in the following\n manner:\n\n - If the first argument is an executable found in the\n \\`node_modules/.bin\\` folder (ie, provided by an\n installed direct dependency), then that will be used.\n The search stops, and nothing will be installed.\n - Otherwise, vlt attempts to resolve the first argument\n as if it was a \\`--package\\` option, and then swap it\n out with the \"default\" executable provided by that\n package.\n\n The \"default\" executable provided by a package is:\n\n - If the package provides a single executable string in the\n \\`bin\\` field, then that is the executable to use.\n - Otherwise, if there is a \\`bin\\` with the same name\n as the package (or just the portion after the \\`/\\` in\n the case of scoped packages), then that will be used.\n\n If the appropriate excutable cannot be determined, then\n an error will be raised.\n\n At no point will \\`vlt exec\\` change the locally installed\n dependencies. Any installs it performs is done in vlt's XDG\n data directory.\n `,\n examples: {\n '--package typescript@5 tsc': {\n description: 'Run tsc provided by typescript version 5',\n },\n 'eslint src/file.js': {\n description: 'Run the default bin provided by eslint',\n },\n 'eslint@9.24 src/file.js': {\n description:\n 'Run the default bin provided by eslint version 9.24',\n },\n },\n })\n\nconst HOME = homedir()\nexport const prettyPath = (path: string) =>\n path.startsWith(HOME) ? `~${path.substring(HOME.length)}` : path\n\nexport const promptFn: PromptFn = async (\n pkgSpec,\n path,\n resolution,\n) => {\n const response = await createInterface(\n process.stdin,\n process.stdout,\n ).question(\n `About to install: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n String(pkgSpec),\n )}\nfrom: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n resolution,\n )}\ninto: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n prettyPath(path),\n )}\nIs this ok? (y) `,\n )\n process.stdin.pause()\n return response\n}\n\nexport const command: CommandFn<ExecResult> = async conf => {\n const arg0 = await vlx.resolve(\n conf.positionals,\n conf.options,\n promptFn,\n )\n if (arg0) conf.positionals[0] = arg0\n // now we have arg0! let's gooooo!!\n delete conf.options['script-shell']\n return await new ExecCommand(conf, exec, execFG).run()\n}\n"]}
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,E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CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,EAClC,UAAU,CACX;QACG,eAAe,CACjB,CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,EAClC,UAAU,CAAC,IAAI,CAAC,CACjB;iBACY,CACd,CAAA;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACrB,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE;IACzD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAC5B,IAAI,CAAC,WAAW,EAChB;QACE,GAAG,IAAI,CAAC,OAAO;QACf,KAAK,EAAE,SAAS;KACjB,EACD,QAAQ,CACT,CAAA;IACD,IAAI,IAAI;QAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IACpC,mCAAmC;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,OAAO,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { exec, execFG } from '@vltpkg/run'\nimport type { PromptFn } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { homedir } from 'node:os'\nimport { createInterface } from 'node:readline/promises'\nimport { commandUsage } from '../config/usage.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { styleTextStdout } from '../output.ts'\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec',\n usage: '[--package=<pkg>] [command...]',\n description: `Run a command defined by a package, installing it\n if necessary.\n\n If the package specifier is provided explicitly via the\n \\`--package\\` config, then that is what will be used. If\n a satisfying instance of the named package exists in the\n local \\`node_mnodules\\` folder, then that will be used.\n\n If \\`--package\\` is not set, then vlt will attempt to infer\n the package to be installed if necessary, in the following\n manner:\n\n - If the first argument is an executable found in the\n \\`node_modules/.bin\\` folder (ie, provided by an\n installed direct dependency), then that will be used.\n The search stops, and nothing will be installed.\n - Otherwise, vlt attempts to resolve the first argument\n as if it was a \\`--package\\` option, and then swap it\n out with the \"default\" executable provided by that\n package.\n\n The \"default\" executable provided by a package is:\n\n - If the package provides a single executable string in the\n \\`bin\\` field, then that is the executable to use.\n - Otherwise, if there is a \\`bin\\` with the same name\n as the package (or just the portion after the \\`/\\` in\n the case of scoped packages), then that will be used.\n\n If the appropriate excutable cannot be determined, then\n an error will be raised.\n\n At no point will \\`vlt exec\\` change the locally installed\n dependencies. Any installs it performs is done in vlt's XDG\n data directory.\n `,\n examples: {\n '--package typescript@5 tsc': {\n description: 'Run tsc provided by typescript version 5',\n },\n 'eslint src/file.js': {\n description: 'Run the default bin provided by eslint',\n },\n 'eslint@9.24 src/file.js': {\n description:\n 'Run the default bin provided by eslint version 9.24',\n },\n },\n })\n\nconst HOME = homedir()\nexport const prettyPath = (path: string) =>\n path.startsWith(HOME) ? `~${path.substring(HOME.length)}` : path\n\nexport const promptFn: PromptFn = async (\n pkgSpec,\n path,\n resolution,\n) => {\n const response = await createInterface(\n process.stdin,\n process.stdout,\n ).question(\n `About to install: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n String(pkgSpec),\n )}\nfrom: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n resolution,\n )}\ninto: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n prettyPath(path),\n )}\nIs this ok? (y) `,\n )\n process.stdin.pause()\n return response\n}\n\nexport const command: CommandFn<ExecResult> = async conf => {\n const arg0 = await vlx.resolve(\n conf.positionals,\n {\n ...conf.options,\n query: undefined,\n },\n promptFn,\n )\n if (arg0) conf.positionals[0] = arg0\n // now we have arg0! let's gooooo!!\n delete conf.options['script-shell']\n return await new ExecCommand(conf, exec, execFG).run()\n}\n"]}
@@ -194,6 +194,13 @@ export declare const definition: import("jackspeak").Jack<{
194
194
  } & {
195
195
  workspace: import("jackspeak").ConfigOption<"string", true, readonly string[] | undefined>;
196
196
  'workspace-group': import("jackspeak").ConfigOption<"string", true, readonly string[] | undefined>;
197
+ } & {
198
+ query: {
199
+ short: string;
200
+ description: string;
201
+ };
202
+ } & {
203
+ query: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
197
204
  } & {
198
205
  recursive: {
199
206
  short: string;
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAA0C,CAAA;AAElE,eAAO,MAAM,aAAa,cAKjB,CAAA;AA0CT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGX,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,cAAc,uBAW1B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAA;AAEtC,eAAO,MAAM,UAAU,OACjB,MAAM,KACT,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,SACkC,CAAA;AAKhE;;GAEG;AACH,eAAO,MAAM,YAAY,iGAMf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,MAAO,MAAM,KAAG,CAAC,IAAI,WACN,CAAA;AAwCzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA2OH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
@@ -366,6 +366,12 @@ export const definition = j
366
366
  description: `Specify named workspace group names to load and operate on
367
367
  when doing recursive operations on workspaces.`,
368
368
  },
369
+ })
370
+ .opt({
371
+ query: {
372
+ short: 'q',
373
+ description: `Set to filter the results of an operation by a query.`,
374
+ },
369
375
  })
370
376
  .flag({
371
377
  recursive: {
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;AAElE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,eAAe;QAC1C,CAAC,CAAC,IAAI,CAAC,CAAA;AAET,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,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;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,U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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 = process.stdout.isTTY ? 'human' : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n 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 pkg: 'pkg',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n 'exec-cache': 'exec-cache',\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`,\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 .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\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 ] 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 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,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;AAElE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,eAAe;QAC1C,CAAC,CAAC,IAAI,CAAC,CAAA;AAET,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,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;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,UAAU;IACtB,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,YAAY;IAC1B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IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,EAAE,CAAA;QAC3C,OAAO,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView = process.stdout.isTTY ? 'human' : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n 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 pkg: 'pkg',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n 'exec-cache': 'exec-cache',\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`,\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 query: {\n short: 'q',\n description: `Set to filter the results of an operation by a query.`,\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\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 ] 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 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"]}
@@ -24,7 +24,7 @@ export declare class ExecCommand<B extends RunnerBG, F extends RunnerFG> {
24
24
  args: string[];
25
25
  monorepo?: Monorepo;
26
26
  /** how many places are we doing things in? */
27
- spaces: number;
27
+ spaces?: number;
28
28
  conf: LoadedConfig;
29
29
  projectRoot: string;
30
30
  view: 'human' | 'json' | 'inspect';
@@ -1 +1 @@
1
- {"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACV,IAAI,EACJ,MAAM,EACN,WAAW,EACX,GAAG,EACH,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,aAAa,CAAA;AAEpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,MAAM,MAAM,QAAQ,GAAG,OAAO,IAAI,GAAG,OAAO,GAAG,GAAG,OAAO,OAAO,CAAA;AAChE,MAAM,MAAM,QAAQ,GAAG,OAAO,MAAM,GAAG,OAAO,SAAS,GAAG,OAAO,KAAK,CAAA;AACtE,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,CAAA;AACrE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACtD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC9C,MAAM,MAAM,c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,EAAE,QAAQ,CAAA;IACnB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,YAAY,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;gBAEtB,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IAiB5C,WAAW,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE;IAIpD,OAAO,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAIpC,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IA8FhC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS;IA0B5C,gBAAgB,IAAI,MAAM;IAU1B,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,KAAK,IAAI,aAAa,GAAG,SAAS;IAoBlC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,EAAE,EAAE,SAAS,GAAG,aAAa;IAclE,YAAY,IAAI,SAAS;IAKzB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,cAAc;CAKjE"}
@@ -4,6 +4,8 @@
4
4
  */
5
5
  import { error } from '@vltpkg/error-cause';
6
6
  import { isErrorWithCause } from '@vltpkg/types';
7
+ import { Query } from '@vltpkg/query';
8
+ import { actual } from '@vltpkg/graph';
7
9
  import { isRunResult } from '@vltpkg/run';
8
10
  import { Monorepo } from '@vltpkg/workspaces';
9
11
  import { ansiToAnsi } from 'ansi-to-pre';
@@ -67,14 +69,6 @@ export class ExecCommand {
67
69
  const { projectRoot, positionals: [arg0, ...args], } = conf;
68
70
  this.arg0 = arg0;
69
71
  this.args = args;
70
- const paths = conf.get('workspace');
71
- const groups = conf.get('workspace-group');
72
- const recursive = conf.get('recursive');
73
- this.monorepo =
74
- paths?.length || groups?.length || recursive ?
75
- Monorepo.load(projectRoot, { load: { paths, groups } })
76
- : undefined;
77
- this.spaces = this.monorepo?.size ?? 1;
78
72
  this.projectRoot = projectRoot;
79
73
  }
80
74
  hasMonorepo() {
@@ -84,6 +78,50 @@ export class ExecCommand {
84
78
  return !!this.arg0;
85
79
  }
86
80
  async run() {
81
+ const { conf } = this;
82
+ const queryString = conf.get('query');
83
+ // query takes precedence over workspaces or groups
84
+ if (queryString) {
85
+ const graph = actual.load({
86
+ ...conf.options,
87
+ mainManifest: conf.options.packageJson.read(this.projectRoot),
88
+ monorepo: Monorepo.load(this.projectRoot),
89
+ loadManifests: false,
90
+ });
91
+ const query = new Query({
92
+ graph,
93
+ specOptions: conf.options,
94
+ securityArchive: undefined,
95
+ });
96
+ const { nodes } = await query.search(queryString, {
97
+ signal: new AbortController().signal,
98
+ });
99
+ const importerPaths = nodes
100
+ .filter(n => n.importer)
101
+ .map(n => n.location)
102
+ .filter(v => v !== undefined);
103
+ this.monorepo =
104
+ importerPaths.length ?
105
+ Monorepo.load(this.projectRoot, {
106
+ load: {
107
+ paths: importerPaths,
108
+ },
109
+ })
110
+ : undefined;
111
+ this.spaces = this.monorepo?.size ?? 0;
112
+ }
113
+ else {
114
+ const paths = conf.get('workspace');
115
+ const groups = conf.get('workspace-group');
116
+ const recursive = conf.get('recursive');
117
+ this.monorepo =
118
+ paths?.length || groups?.length || recursive ?
119
+ Monorepo.load(this.projectRoot, {
120
+ load: { paths, groups },
121
+ })
122
+ : undefined;
123
+ this.spaces = this.monorepo?.size ?? 1;
124
+ }
87
125
  if (this.spaces === 1) {
88
126
  const arg = this.fgArg();
89
127
  if (!arg)
@@ -1 +1 @@
1
- {"version":3,"file":"exec-command.js","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EA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,CAAC;IACD,sDAAsD;IAEtD,WAAW;QACT,MAAM,KAAK,CACT,wDAAwD,CACzD,CAAA;IACH,CAAC;CACF","sourcesContent":["/**\n * impl for `vlt run`, `vlt run-exec`, `vlt exec-local`, `vlt exec`\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { isErrorWithCause } from '@vltpkg/types'\nimport type {\n exec,\n execFG,\n ExecOptions,\n run,\n runExec,\n runExecFG,\n RunExecOptions,\n runFG,\n RunFGResult,\n RunOptions,\n RunResult,\n} from '@vltpkg/run'\nimport { isRunResult } from '@vltpkg/run'\nimport type { Workspace } from '@vltpkg/workspaces'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { ansiToAnsi } from 'ansi-to-pre'\nimport type { LoadedConfig } from './config/index.ts'\nimport { stderr, stdout, styleTextStdout } from './output.ts'\nimport type { Views } from './view.ts'\n\nexport type RunnerBG = typeof exec | typeof run | typeof runExec\nexport type RunnerFG = typeof execFG | typeof runExecFG | typeof runFG\nexport type RunnerOptions = ExecOptions & RunExecOptions & RunOptions\nexport type MultiRunResult = Record<string, RunResult>\nexport type ScriptSet = Record<string, string>\nexport type MultiScriptSet = Record<string, ScriptSet>\nexport type ExecResult =\n | RunFGResult\n | MultiRunResult\n | ScriptSet\n | MultiScriptSet\n\nconst isScriptSet = (o: unknown): o is ScriptSet => {\n if (!o || typeof o !== 'object') return false\n for (const v of Object.values(o)) {\n if (typeof v !== 'string') return false\n }\n return true\n}\n\nconst isMultiScriptSet = (\n o: ExecResult,\n): o is Record<string, ScriptSet> => {\n for (const v of Object.values(o)) {\n if (!isScriptSet(v)) return false\n }\n return true\n}\n\nconst isSingleSuccess = (\n o: RunResult,\n): o is RunResult & { status: 0; signal: null } =>\n o.signal === null && o.status === 0\n\nconst setExitCode = (result: RunResult) => {\n /* c8 ignore next */\n process.exitCode = process.exitCode || (result.status ?? 1)\n}\n\nexport const views = {\n // run results for single or multiple will be printed along the way.\n human: result => {\n if (isScriptSet(result)) stdout('Scripts available:', result)\n else if (isMultiScriptSet(result)) {\n stdout('Scripts available:')\n for (const [wsPath, scripts] of Object.entries(result)) {\n stdout(wsPath, scripts)\n }\n }\n },\n json: result =>\n isRunResult(result) && isSingleSuccess(result) ?\n undefined\n : result,\n} as const satisfies Views<ExecResult>\n\nexport class ExecCommand<B extends RunnerBG, F extends RunnerFG> {\n bg: B\n fg: F\n arg0?: string\n args: string[]\n monorepo?: Monorepo\n /** how many places are we doing things in? */\n spaces: number\n conf: LoadedConfig\n projectRoot: string\n view: 'human' | 'json' | 'inspect'\n\n constructor(conf: LoadedConfig, bg: B, fg: F) {\n this.conf = conf\n this.bg = bg\n this.fg = fg\n this.view =\n conf.values.view === 'json' ? 'json'\n : conf.values.view === 'inspect' ? 'inspect'\n : 'human'\n const {\n projectRoot,\n positionals: [arg0, ...args],\n } = conf\n this.arg0 = arg0\n this.args = args\n\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(projectRoot, { load: { paths, groups } })\n : undefined\n this.spaces = this.monorepo?.size ?? 1\n this.projectRoot = projectRoot\n }\n\n hasMonorepo(): this is this & { monorepo: Monorepo } {\n return !!this.monorepo\n }\n\n hasArg0(): this is this & { arg0: string } {\n return !!this.arg0\n }\n\n async run(): Promise<ExecResult> {\n if (this.spaces === 1) {\n const arg = this.fgArg()\n if (!arg) return this.noArgsSingle()\n const result = await this.fg(arg)\n if (isRunResult(result)) {\n setExitCode(result)\n }\n return result\n }\n if (!this.hasMonorepo() || this.spaces === 0) {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.monorepo?.load().paths() ?? [])],\n })\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false\n const resultMap = await this.monorepo.run(async ws => {\n const result = await this.bg(this.bgArg(ws)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(ws, er.cause)\n }\n failed = true\n throw er\n },\n )\n if (!failed) this.printResult(ws, result)\n return result\n })\n\n const results: Record<string, RunResult> = {}\n for (const [ws, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[ws.path] = result\n }\n return results\n }\n\n printResult(ws: Workspace, result: RunResult) {\n // non-human results just get printed at the end\n if (this.view !== 'human') return\n\n if (result.status === 0 && result.signal === null) {\n stdout(ws.path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ws.path + ' failure',\n ),\n {\n status: result.status,\n signal: result.signal,\n },\n )\n /* c8 ignore start */\n if (result.stderr) stderr(ansiToAnsi(result.stderr))\n if (result.stdout) stdout(ansiToAnsi(result.stdout))\n /* c8 ignore stop */\n setExitCode(result)\n }\n }\n\n /* c8 ignore start - env specific */\n interactiveShell(): string {\n return (\n process.env.SHELL ??\n this.conf.get('script-shell') ??\n (process.platform === 'win32' ? 'cmd.exe' : '/bin/sh')\n )\n }\n /* c8 ignore stop */\n\n // overridden by 'vlt run' which returns undefined\n defaultArg0(): string | undefined {\n return this.interactiveShell()\n }\n\n fgArg(): RunnerOptions | undefined {\n const ws = this.monorepo?.values().next().value\n const cwd = ws?.fullpath ?? this.projectRoot\n const arg0 = this.arg0 ?? this.defaultArg0()\n\n // return undefined so noArgsSingle will be called instead\n if (typeof arg0 !== 'string') return\n\n return {\n cwd,\n /* c8 ignore next - already guarded */\n arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, ws: Workspace): RunnerOptions {\n return {\n cwd: ws.fullpath,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing: true,\n arg0: this.arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell': this.conf.get('script-shell'),\n }\n }\n\n /* c8 ignore start - not used, only here to override */\n noArgsSingle(): ScriptSet {\n throw error('Failed to determine interactive shell to spawn')\n }\n /* c8 ignore stop - not used, only here to override */\n\n noArgsMulti(this: this & { monorepo: Monorepo }): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\n }\n}\n"]}
1
+ {"version":3,"file":"exec-command.js","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAchD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAe7D,MAAM,WAAW,GAAG,CAAC,CAAU,EAAkB,EAAE;IACjD,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7C,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;IACzC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,gBAAgB,GAAG,CACvB,CAAa,EACmB,EAAE;IAClC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CA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C;IAED,KAAK,CAAgC,EAAa;QAChD,OAAO;YACL,GAAG,EAAE,EAAE,CAAC,QAAQ;YAChB,UAAU,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;YAClC,aAAa,EAAE,IAAI;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW;YACvC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;SAC9C,CAAA;IACH,CAAC;IAED,uDAAuD;IACvD,YAAY;QACV,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAA;IAC/D,CAAC;IACD,sDAAsD;IAEtD,WAAW;QACT,MAAM,KAAK,CACT,wDAAwD,CACzD,CAAA;IACH,CAAC;CACF","sourcesContent":["/**\n * impl for `vlt run`, `vlt run-exec`, `vlt exec-local`, `vlt exec`\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { isErrorWithCause } from '@vltpkg/types'\nimport type {\n exec,\n execFG,\n ExecOptions,\n run,\n runExec,\n runExecFG,\n RunExecOptions,\n runFG,\n RunFGResult,\n RunOptions,\n RunResult,\n} from '@vltpkg/run'\nimport { Query } from '@vltpkg/query'\nimport { actual } from '@vltpkg/graph'\nimport { isRunResult } from '@vltpkg/run'\nimport type { Workspace } from '@vltpkg/workspaces'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { ansiToAnsi } from 'ansi-to-pre'\nimport type { LoadedConfig } from './config/index.ts'\nimport { stderr, stdout, styleTextStdout } from './output.ts'\nimport type { Views } from './view.ts'\n\nexport type RunnerBG = typeof exec | typeof run | typeof runExec\nexport type RunnerFG = typeof execFG | typeof runExecFG | typeof runFG\nexport type RunnerOptions = ExecOptions & RunExecOptions & RunOptions\nexport type MultiRunResult = Record<string, RunResult>\nexport type ScriptSet = Record<string, string>\nexport type MultiScriptSet = Record<string, ScriptSet>\nexport type ExecResult =\n | RunFGResult\n | MultiRunResult\n | ScriptSet\n | MultiScriptSet\n\nconst isScriptSet = (o: unknown): o is ScriptSet => {\n if (!o || typeof o !== 'object') return false\n for (const v of Object.values(o)) {\n if (typeof v !== 'string') return false\n }\n return true\n}\n\nconst isMultiScriptSet = (\n o: ExecResult,\n): o is Record<string, ScriptSet> => {\n for (const v of Object.values(o)) {\n if (!isScriptSet(v)) return false\n }\n return true\n}\n\nconst isSingleSuccess = (\n o: RunResult,\n): o is RunResult & { status: 0; signal: null } =>\n o.signal === null && o.status === 0\n\nconst setExitCode = (result: RunResult) => {\n /* c8 ignore next */\n process.exitCode = process.exitCode || (result.status ?? 1)\n}\n\nexport const views = {\n // run results for single or multiple will be printed along the way.\n human: result => {\n if (isScriptSet(result)) stdout('Scripts available:', result)\n else if (isMultiScriptSet(result)) {\n stdout('Scripts available:')\n for (const [wsPath, scripts] of Object.entries(result)) {\n stdout(wsPath, scripts)\n }\n }\n },\n json: result =>\n isRunResult(result) && isSingleSuccess(result) ?\n undefined\n : result,\n} as const satisfies Views<ExecResult>\n\nexport class ExecCommand<B extends RunnerBG, F extends RunnerFG> {\n bg: B\n fg: F\n arg0?: string\n args: string[]\n monorepo?: Monorepo\n /** how many places are we doing things in? */\n spaces?: number\n conf: LoadedConfig\n projectRoot: string\n view: 'human' | 'json' | 'inspect'\n\n constructor(conf: LoadedConfig, bg: B, fg: F) {\n this.conf = conf\n this.bg = bg\n this.fg = fg\n this.view =\n conf.values.view === 'json' ? 'json'\n : conf.values.view === 'inspect' ? 'inspect'\n : 'human'\n const {\n projectRoot,\n positionals: [arg0, ...args],\n } = conf\n this.arg0 = arg0\n this.args = args\n this.projectRoot = projectRoot\n }\n\n hasMonorepo(): this is this & { monorepo: Monorepo } {\n return !!this.monorepo\n }\n\n hasArg0(): this is this & { arg0: string } {\n return !!this.arg0\n }\n\n async run(): Promise<ExecResult> {\n const { conf } = this\n\n const queryString = conf.get('query')\n // query takes precedence over workspaces or groups\n if (queryString) {\n const graph = actual.load({\n ...conf.options,\n mainManifest: conf.options.packageJson.read(this.projectRoot),\n monorepo: Monorepo.load(this.projectRoot),\n loadManifests: false,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive: undefined,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n const importerPaths = nodes\n .filter(n => n.importer)\n .map(n => n.location)\n .filter(v => v !== undefined)\n this.monorepo =\n importerPaths.length ?\n Monorepo.load(this.projectRoot, {\n load: {\n paths: importerPaths,\n },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 0\n } else {\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n this.monorepo =\n paths?.length || groups?.length || recursive ?\n Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 1\n }\n\n if (this.spaces === 1) {\n const arg = this.fgArg()\n if (!arg) return this.noArgsSingle()\n const result = await this.fg(arg)\n if (isRunResult(result)) {\n setExitCode(result)\n }\n return result\n }\n\n if (!this.hasMonorepo() || this.spaces === 0) {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.monorepo?.load().paths() ?? [])],\n })\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false\n const resultMap = await this.monorepo.run(async ws => {\n const result = await this.bg(this.bgArg(ws)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(ws, er.cause)\n }\n failed = true\n throw er\n },\n )\n if (!failed) this.printResult(ws, result)\n return result\n })\n\n const results: Record<string, RunResult> = {}\n for (const [ws, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[ws.path] = result\n }\n return results\n }\n\n printResult(ws: Workspace, result: RunResult) {\n // non-human results just get printed at the end\n if (this.view !== 'human') return\n\n if (result.status === 0 && result.signal === null) {\n stdout(ws.path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ws.path + ' failure',\n ),\n {\n status: result.status,\n signal: result.signal,\n },\n )\n /* c8 ignore start */\n if (result.stderr) stderr(ansiToAnsi(result.stderr))\n if (result.stdout) stdout(ansiToAnsi(result.stdout))\n /* c8 ignore stop */\n setExitCode(result)\n }\n }\n\n /* c8 ignore start - env specific */\n interactiveShell(): string {\n return (\n process.env.SHELL ??\n this.conf.get('script-shell') ??\n (process.platform === 'win32' ? 'cmd.exe' : '/bin/sh')\n )\n }\n /* c8 ignore stop */\n\n // overridden by 'vlt run' which returns undefined\n defaultArg0(): string | undefined {\n return this.interactiveShell()\n }\n\n fgArg(): RunnerOptions | undefined {\n const ws = this.monorepo?.values().next().value\n const cwd = ws?.fullpath ?? this.projectRoot\n const arg0 = this.arg0 ?? this.defaultArg0()\n\n // return undefined so noArgsSingle will be called instead\n if (typeof arg0 !== 'string') return\n\n return {\n cwd,\n /* c8 ignore next - already guarded */\n arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, ws: Workspace): RunnerOptions {\n return {\n cwd: ws.fullpath,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing: true,\n arg0: this.arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell': this.conf.get('script-shell'),\n }\n }\n\n /* c8 ignore start - not used, only here to override */\n noArgsSingle(): ScriptSet {\n throw error('Failed to determine interactive shell to spawn')\n }\n /* c8 ignore stop - not used, only here to override */\n\n noArgsMulti(this: this & { monorepo: Monorepo }): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\n }\n}\n"]}
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-14",
4
+ "version": "0.0.0-15",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -33,27 +33,27 @@
33
33
  "react": "^18.3.1",
34
34
  "react-devtools-core": "^4.28.5",
35
35
  "supports-color": "^10.0.0",
36
- "@vltpkg/dot-prop": "0.0.0-14",
37
- "@vltpkg/dep-id": "0.0.0-14",
38
- "@vltpkg/graph": "0.0.0-14",
39
- "@vltpkg/init": "0.0.0-14",
40
- "@vltpkg/output": "0.0.0-14",
41
- "@vltpkg/error-cause": "0.0.0-14",
42
- "@vltpkg/package-info": "0.0.0-14",
43
- "@vltpkg/package-json": "0.0.0-14",
44
- "@vltpkg/query": "0.0.0-14",
45
- "@vltpkg/rollback-remove": "0.0.0-14",
46
- "@vltpkg/registry-client": "0.0.0-14",
47
- "@vltpkg/server": "0.0.0-14",
48
- "@vltpkg/run": "0.0.0-14",
49
- "@vltpkg/security-archive": "0.0.0-14",
50
- "@vltpkg/url-open": "0.0.0-14",
51
- "@vltpkg/vlx": "0.0.0-14",
52
- "@vltpkg/vlt-json": "0.0.0-14",
53
- "@vltpkg/spec": "0.0.0-14",
54
- "@vltpkg/types": "0.0.0-14",
55
- "@vltpkg/workspaces": "0.0.0-14",
56
- "@vltpkg/xdg": "0.0.0-14"
36
+ "@vltpkg/dep-id": "0.0.0-15",
37
+ "@vltpkg/error-cause": "0.0.0-15",
38
+ "@vltpkg/dot-prop": "0.0.0-15",
39
+ "@vltpkg/graph": "0.0.0-15",
40
+ "@vltpkg/output": "0.0.0-15",
41
+ "@vltpkg/init": "0.0.0-15",
42
+ "@vltpkg/package-json": "0.0.0-15",
43
+ "@vltpkg/package-info": "0.0.0-15",
44
+ "@vltpkg/query": "0.0.0-15",
45
+ "@vltpkg/registry-client": "0.0.0-15",
46
+ "@vltpkg/run": "0.0.0-15",
47
+ "@vltpkg/security-archive": "0.0.0-15",
48
+ "@vltpkg/server": "0.0.0-15",
49
+ "@vltpkg/rollback-remove": "0.0.0-15",
50
+ "@vltpkg/spec": "0.0.0-15",
51
+ "@vltpkg/url-open": "0.0.0-15",
52
+ "@vltpkg/vlt-json": "0.0.0-15",
53
+ "@vltpkg/xdg": "0.0.0-15",
54
+ "@vltpkg/vlx": "0.0.0-15",
55
+ "@vltpkg/types": "0.0.0-15",
56
+ "@vltpkg/workspaces": "0.0.0-15"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@eslint/js": "^9.28.0",