@vltpkg/cli-sdk 0.0.0-6 → 0.0.0-8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/commands/config.js +1 -1
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +6 -6
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pkg.js +1 -1
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +6 -6
- package/dist/esm/commands/query.js.map +1 -1
- package/dist/esm/config/definition.d.ts +6 -0
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +19 -0
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/config/index.js +4 -4
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +44 -28
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { spawnSync } from 'child_process';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { definition, isRecordField, pairsToRecords, recordsToPairs, } from "../config/index.js";
|
|
4
4
|
import { commandUsage } from "../config/usage.js";
|
|
5
5
|
export const usage = () => commandUsage({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,S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GAAG,KAAK,EAAE,IAAkB,EAAE,EAAE;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,KAAK,CAAC,yCAAyC,EAAE;YACrD,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,IAAI,CAAC,eAAe,CACxB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAClB,cAAc,CACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACtD,CACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { spawnSync } from 'node:child_process'\nimport {\n definition,\n isRecordField,\n pairsToRecords,\n recordsToPairs,\n} from '../config/index.ts'\nimport type {\n ConfigDefinitions,\n LoadedConfig,\n RecordPairs,\n} from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'config',\n usage: '<command> [flags]',\n description: 'Work with vlt configuration',\n\n subcommands: {\n get: {\n usage: '<key> [<key> ...]',\n description: 'Print the named config value',\n },\n\n list: {\n description:\n 'Print all configuration settings currently in effect',\n },\n\n set: {\n usage:\n '<key>=<value> [<key>=<value> ...] [--config=<user | project>]',\n description: `Set config values. By default, these are\n written to the project config file, \\`vlt.json\\`\n in the root of the project. To set things for all\n projects, run with \\`--config=user\\``,\n },\n\n del: {\n usage: '<key> [<key> ...] [--config=<user | project>]',\n description: `Delete the named config fields. If no values remain in\n the config file, delete the file as well. By default,\n operates on the \\`vlt.json\\` file in the root of the\n current project. To delete a config field from the user\n config file, specify \\`--config=user\\`.`,\n },\n\n edit: {\n usage: '[--config=<user | project>]',\n description: 'Edit the configuration file',\n },\n\n help: {\n usage: '[field ...]',\n description: `Get information about a config field, or show a list\n of known config field names.`,\n },\n },\n })\n\nexport const command: CommandFn<\n string | number | boolean | void | string[] | RecordPairs\n> = async conf => {\n const sub = conf.positionals[0]\n switch (sub) {\n case 'set':\n return set(conf)\n\n case 'get':\n return get(conf)\n\n case 'ls':\n case 'list':\n return list(conf)\n\n case 'edit':\n return edit(conf)\n\n case 'help':\n return help(conf)\n\n case 'del':\n return del(conf)\n\n default: {\n throw error('Unrecognized config command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['set', 'get', 'list', 'edit', 'help', 'del'],\n })\n }\n }\n}\n\nconst help = (conf: LoadedConfig) => {\n const j = definition.toJSON()\n const fields = conf.positionals.slice(1)\n if (!fields.length) {\n return [\n 'Specify one or more options to see information:',\n ...Object.keys(j)\n .sort((a, b) => a.localeCompare(b, 'en'))\n .map(c => ` ${c}`),\n ].join('\\n')\n }\n\n // TODO: some kind of fuzzy search?\n const res: string[] = []\n for (const f of fields) {\n const def = j[f]\n if (!def) {\n res.push(`unknown config field: ${f}`)\n } else {\n const hint = def.hint ? `=<${def.hint}>` : ''\n const type =\n isRecordField(f) ?\n 'Record<string, string>'\n : def.type + (def.multiple ? '[]' : '')\n\n res.push(`--${f}${hint}`)\n res.push(` type: ${type}`)\n if (def.default) {\n res.push(` default: ${JSON.stringify(def.default)}`)\n }\n if (def.description) {\n res.push(def.description)\n }\n }\n }\n return res.join('\\n')\n}\n\nconst list = (conf: LoadedConfig) => {\n return recordsToPairs(conf.options)\n}\n\nconst del = async (conf: LoadedConfig) => {\n const fields = conf.positionals.slice(1)\n if (!fields.length) {\n throw error('At least one key is required', {\n code: 'EUSAGE',\n })\n }\n await conf.deleteConfigKeys(conf.get('config'), fields)\n}\n\nconst get = async (conf: LoadedConfig) => {\n const keys = conf.positionals.slice(1)\n const k = keys[0]\n if (!k || keys.length > 1) {\n throw error('Exactly one key is required', {\n code: 'EUSAGE',\n })\n }\n return conf.get(k as keyof ConfigDefinitions)\n}\n\nconst edit = async (conf: LoadedConfig) => {\n const [command, ...args] = conf.get('editor').split(' ')\n if (!command) {\n throw error(`editor is empty`)\n }\n await conf.editConfigFile(conf.get('config'), file => {\n args.push(file)\n const res = spawnSync(command, args, {\n stdio: 'inherit',\n })\n if (res.status !== 0) {\n throw error(`${command} command failed`, {\n ...res,\n command,\n args,\n })\n }\n })\n}\n\nconst set = async (conf: LoadedConfig) => {\n const pairs = conf.positionals.slice(1)\n if (!pairs.length) {\n throw error('At least one key=value pair is required', {\n code: 'EUSAGE',\n })\n }\n await conf.addConfigToFile(\n conf.get('config'),\n pairsToRecords(\n conf.jack.parseRaw(pairs.map(kv => `--${kv}`)).values,\n ),\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAkChB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAkChB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAmEzC,CAAA"}
|
|
@@ -53,12 +53,12 @@ export const command = async (conf) => {
|
|
|
53
53
|
const queryString = conf.positionals
|
|
54
54
|
.map(k => (/^[@\w-]/.test(k) ? `#${k.replace(/\//, '\\/')}` : k))
|
|
55
55
|
.join(', ');
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const securityArchive = Query.hasSecuritySelectors(queryString) ?
|
|
57
|
+
await SecurityArchive.start({
|
|
58
|
+
graph,
|
|
59
|
+
specOptions: conf.options,
|
|
60
|
+
})
|
|
61
|
+
: undefined;
|
|
62
62
|
const query = new Query({
|
|
63
63
|
graph,
|
|
64
64
|
specOptions: conf.options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,MAAM,CAAC,MAA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QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,WAAW,EAAE,WAAW,IAAI,kBAAkB;QAC9C,kBAAkB,EAAE,CAAC,CAAC,WAAW;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport {\n actual,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n} from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ls',\n usage: ['', '<query> --view=[human | json | mermaid | gui]'],\n description: `List installed dependencies matching the provided query.\n Defaults to listing direct dependencies of a project and\n any configured workspace.`,\n examples: {\n '': {\n description:\n 'List direct dependencies of the current project / workspace',\n },\n '*': {\n description:\n 'List all dependencies for the current project / workspace',\n },\n 'foo bar baz': {\n description: `List all dependencies named 'foo', 'bar', or 'baz'`,\n },\n [`'[name=\"@scoped/package\"] > *'`]: {\n description:\n 'Lists direct dependencies of a specific package',\n },\n [`'*.workspace > *.peer'`]: {\n description: 'List all peer dependencies of all workspaces',\n },\n },\n options: {\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\nexport type ListResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI(\n conf,\n '/explore?query=' + encodeURIComponent(queryString),\n )\n },\n} as const satisfies Views<ListResult>\n\nexport const command: CommandFn<ListResult> = async conf => {\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo,\n loadManifests: true,\n })\n\n const queryString = conf.positionals\n .map(k => (/^[@\\w-]/.test(k) ? `#${k.replace(/\\//, '\\\\/')}` : k))\n .join(', ')\n const securityArchive =\n Query.hasSecuritySelectors(queryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n const projectQueryString = ':project, :project > *'\n const selectImporters: string[] = []\n\n const importers = new Set<Node>()\n if (monorepo) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) {\n importers.add(w)\n selectImporters.push(`[name=\"${w.name}\"]`)\n selectImporters.push(`[name=\"${w.name}\"] > *`)\n }\n }\n }\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n\n const selectImportersQueryString = selectImporters.join(', ')\n const defaultQueryString =\n (\n selectImporters.length &&\n selectImporters.length < graph.importers.size\n ) ?\n selectImportersQueryString\n : projectQueryString\n\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n )\n\n return {\n importers,\n edges,\n nodes,\n queryString: queryString || defaultQueryString,\n highlightSelection: !!queryString,\n }\n}\n"]}
|
package/dist/esm/commands/pkg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as dotProp from '@vltpkg/dot-prop';
|
|
2
2
|
import { error } from '@vltpkg/error-cause';
|
|
3
|
-
import assert from 'assert';
|
|
3
|
+
import assert from 'node:assert';
|
|
4
4
|
import { commandUsage } from "../config/usage.js";
|
|
5
5
|
import { init } from '@vltpkg/init';
|
|
6
6
|
import { views as initViews } from "./init.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;A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C,CAAA;IAC3D,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC5B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM,KAAK,CAAC,gCAAgC,EAAE;gBAC5C,IAAI,EAAE,QAAQ;aACf,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAChB,GAAG,EACH,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EACrB,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CACvB,CAAA;IACH,CAAC,EAAE,IAAI,CAAC,CAAA;IAER,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,MAAM,EAAE,GAAG,CACT,IAAkB,EAClB,IAAc,EACd,GAAgB,EAChB,IAAc,EACd,EAAE;IACF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACrB,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,IAAI,CAAC,CAAA;IAER,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC,CAAA","sourcesContent":["import * as dotProp from '@vltpkg/dot-prop'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { Manifest } from '@vltpkg/types'\nimport assert from 'node:assert'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { init } from '@vltpkg/init'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { ViewFn, Views } from '../view.ts'\nimport { views as initViews } from './init.ts'\n\nexport const views: Views & { human: ViewFn } = {\n human: (results, options, config) => {\n // `vlt pkg init` is an alias for `vlt init`\n // use the same output handling\n if (config.positionals[0] === 'init') {\n return initViews.human(\n results as InitFileResults,\n options,\n config,\n )\n }\n return results\n },\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pkg',\n usage: '[<command>] [<args>]',\n description: 'Get or manipulate package.json values',\n subcommands: {\n get: {\n usage: '[<key>]',\n description: 'Get a single value',\n },\n init: {\n usage: '',\n description:\n 'Initialize a new package.json file in the current directory',\n },\n pick: {\n usage: '[<key> [<key> ...]]',\n description: 'Get multiple values or the entire package',\n },\n set: {\n usage: '<key>=<value> [<key>=<value> ...]',\n description: 'Set one or more key value pairs',\n },\n delete: {\n usage: '<key> [<key> ...]',\n description: 'Delete one or more keys from the package',\n },\n },\n examples: {\n 'set \"array[1].key=value\"': {\n description: 'Set a value on an object inside an array',\n },\n 'set \"array[]=value\"': {\n description: 'Append a value to an array',\n },\n },\n })\n\nexport const command: CommandFn = async conf => {\n const [sub, ...args] = conf.positionals\n if (sub === 'init') {\n return await init({ cwd: process.cwd() })\n }\n\n const pkg = conf.options.packageJson\n const mani = pkg.read(conf.projectRoot)\n\n switch (sub) {\n case 'get':\n return get(mani, args)\n case 'pick':\n return pick(mani, args)\n case 'set':\n return set(conf, mani, pkg, args)\n case 'rm':\n case 'remove':\n case 'unset':\n case 'delete':\n return rm(conf, mani, pkg, args)\n default: {\n throw error('Unrecognized pkg command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['get', 'set', 'rm'],\n })\n }\n }\n}\n\nconst get = (mani: Manifest, args: string[]) => {\n const noArg = () =>\n error(\n 'get requires not more than 1 argument. use `pick` to get more than 1.',\n { code: 'EUSAGE' },\n noArg,\n )\n if (args.length !== 1) {\n if (args.length > 1) {\n throw noArg()\n }\n return pick(mani, args)\n }\n assert(args[0], noArg())\n return dotProp.get(mani, args[0])\n}\n\nconst pick = (mani: Manifest, args: string[]) => {\n return args.length ?\n args.reduce(\n (acc, key) => dotProp.set(acc, key, dotProp.get(mani, key)),\n {},\n )\n : mani\n}\n\nconst set = (\n conf: LoadedConfig,\n mani: Manifest,\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('set requires arguments', { code: 'EUSAGE' })\n }\n\n const res = args.reduce((acc, p) => {\n const index = p.indexOf('=')\n if (index === -1) {\n throw error('set arguments must contain `=`', {\n code: 'EUSAGE',\n })\n }\n return dotProp.set(\n acc,\n p.substring(0, index),\n p.substring(index + 1),\n )\n }, mani)\n\n pkg.write(conf.projectRoot, res)\n}\n\nconst rm = (\n conf: LoadedConfig,\n mani: Manifest,\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('rm requires arguments', { code: 'EUSAGE' })\n }\n\n const res = args.reduce((acc, key) => {\n dotProp.del(acc, key)\n return acc\n }, mani)\n\n pkg.write(conf.projectRoot, res)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YA6BhB,CAAA;AAEJ,KAAK,WAAW,GAAG,eAAe,GAChC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUqB,CAAA;AAEvC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YA6BhB,CAAA;AAEJ,KAAK,WAAW,GAAG,eAAe,GAChC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUqB,CAAA;AAEvC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAmD1C,CAAA"}
|
|
@@ -47,12 +47,12 @@ export const command = async (conf) => {
|
|
|
47
47
|
});
|
|
48
48
|
const defaultQueryString = '*';
|
|
49
49
|
const queryString = conf.positionals[0];
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
const securityArchive = queryString && Query.hasSecuritySelectors(queryString) ?
|
|
51
|
+
await SecurityArchive.start({
|
|
52
|
+
graph,
|
|
53
|
+
specOptions: conf.options,
|
|
54
|
+
})
|
|
55
|
+
: undefined;
|
|
56
56
|
const query = new Query({
|
|
57
57
|
graph,
|
|
58
58
|
specOptions: conf.options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/commands/query.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB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AK,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,MAAM,CACzC,WAAW,IAAI,kBAAkB,CAClC,CAAA;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,EAAQ,CAAA;IACjC,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,GAAqB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;YACzD,IAAI,CAAC;gBAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,OAAO;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,WAAW;QACjC,WAAW,EAAE,WAAW,IAAI,kBAAkB;KAC/C,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport {\n actual,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n} from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'query',\n usage: ['', '<query> --view=[human | json | mermaid | gui]'],\n description:\n 'List installed dependencies matching the provided query.',\n examples: {\n [`'#foo'`]: {\n description: 'Query packages with the name \"foo\"',\n },\n [`'*.workspace > *.peer'`]: {\n description: 'Query all peer dependencies of workspaces',\n },\n [`':project > *:attr(scripts, [build])'`]: {\n description:\n 'Query all direct project dependencies with a \"build\" script',\n },\n [`'[name^=\"@vltpkg\"]'`]: {\n description:\n 'Query packages with names starting with \"@vltpkg\"',\n },\n },\n options: {\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\ntype QueryResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI(\n conf,\n '/explore?query=' + encodeURIComponent(queryString),\n )\n },\n} as const satisfies Views<QueryResult>\n\nexport const command: CommandFn<QueryResult> = async conf => {\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo,\n loadManifests: true,\n })\n\n const defaultQueryString = '*'\n const queryString = conf.positionals[0]\n const securityArchive =\n queryString && Query.hasSecuritySelectors(queryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n )\n\n const importers = new Set<Node>()\n if (monorepo) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) importers.add(w)\n }\n }\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n\n return {\n importers,\n edges,\n nodes,\n highlightSelection: !!queryString,\n queryString: queryString || defaultQueryString,\n }\n}\n"]}
|
|
@@ -151,11 +151,17 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
151
151
|
description: string;
|
|
152
152
|
default: number;
|
|
153
153
|
};
|
|
154
|
+
'stale-while-revalidate-factor': {
|
|
155
|
+
hint: string;
|
|
156
|
+
default: number;
|
|
157
|
+
description: string;
|
|
158
|
+
};
|
|
154
159
|
} & {
|
|
155
160
|
'fetch-retries': import("jackspeak").ConfigOption<"number", false, readonly number[] | undefined>;
|
|
156
161
|
'fetch-retry-factor': import("jackspeak").ConfigOption<"number", false, readonly number[] | undefined>;
|
|
157
162
|
'fetch-retry-mintimeout': import("jackspeak").ConfigOption<"number", false, readonly number[] | undefined>;
|
|
158
163
|
'fetch-retry-maxtimeout': import("jackspeak").ConfigOption<"number", false, readonly number[] | undefined>;
|
|
164
|
+
'stale-while-revalidate-factor': import("jackspeak").ConfigOption<"number", false, readonly number[] | undefined>;
|
|
159
165
|
} & {
|
|
160
166
|
identity: {
|
|
161
167
|
short: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,QAA0C,CAAA;AAuClE;;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,+EAKf,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
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,QAA0C,CAAA;AAuClE;;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,+EAKf,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAwNH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyMvB,CAAA"}
|
|
@@ -282,6 +282,25 @@ export const definition = j
|
|
|
282
282
|
description: `Maximum number of milliseconds between two retries`,
|
|
283
283
|
default: 30_000,
|
|
284
284
|
},
|
|
285
|
+
'stale-while-revalidate-factor': {
|
|
286
|
+
hint: 'n',
|
|
287
|
+
default: 60,
|
|
288
|
+
description: `If the server does not serve a \`stale-while-revalidate\`
|
|
289
|
+
value in the \`cache-control\` header, then this multiplier
|
|
290
|
+
is applied to the \`max-age\` or \`s-maxage\` values.
|
|
291
|
+
|
|
292
|
+
By default, this is \`60\`, so for example a response that
|
|
293
|
+
is cacheable for 5 minutes will allow a stale response
|
|
294
|
+
while revalidating for up to 5 hours.
|
|
295
|
+
|
|
296
|
+
If the server *does* provide a \`stale-while-revalidate\`
|
|
297
|
+
value, then that is always used.
|
|
298
|
+
|
|
299
|
+
Set to 0 to prevent any \`stale-while-revalidate\` behavior
|
|
300
|
+
unless explicitly allowed by the server's \`cache-control\`
|
|
301
|
+
header.
|
|
302
|
+
`,
|
|
303
|
+
},
|
|
285
304
|
})
|
|
286
305
|
.opt({
|
|
287
306
|
identity: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,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,iBAAiB,GAAG;IACxB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,cAAc;IAC9B,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,MAAM,EAAE,QAAQ;CACR,CAAA;AAEV,MAAM,OAAO,GAAG;IACd,CAAC,EAAE,SAAS;IACZ,GAAG,EAAE,SAAS;IACd,EAAE,EAAE,WAAW;IACf,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,KAAK;IACR,YAAY,EAA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ACX,KAAK,EAAE,GAAG;QACV,WAAW,EAAE;;;wEAGqD;KACnE;CACF,CAAC;KAED,IAAI,CAAC;IACJ,OAAO,EAAE;QACP,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,mBAAmB;KACjC;CACF,CAAC;KAED,IAAI,CAAC;IACJ,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,2BAA2B;KACzC;CACF,CAAC,CAAA","sourcesContent":["import { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView = process.stdout.isTTY ? 'human' : 'json'\n\nconst canonicalCommands = {\n config: 'config',\n exec: 'exec',\n gui: 'gui',\n help: 'help',\n init: 'init',\n 'install-exec': 'install-exec',\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 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 h: 'help',\n '?': 'help',\n conf: 'config',\n ix: 'install-exec',\n ls: 'list',\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] 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',\n 'install-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 '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 })\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:\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi'),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`\n (either as lifecycle scripts or explicitly with\n \\`vlt run\\`) and \\`vlt exec\\`.\n\n If not set, defaults to \\`/bin/sh\\` on POSIX systems,\n and \\`cmd.exe\\` on Windows.\n\n When no argument is provided to \\`vlt exec\\`, the \\`SHELL\\`\n environment variable takes precedence if set.`,\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 install-exec\\`, this allows you to\n explicitly set the package to search for bins. If not\n provided, then vlt will interpret the first argument as\n the package, and 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 .flag({\n version: {\n short: 'v',\n description: 'Print the version',\n },\n })\n\n .flag({\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n"]}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAG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kBAAkB,EAAE;QAClB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE;;;;;;2BAMQ;QACrB,OAAO,EAAE,MAAM;QACf,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;KAC7C;CACF,CAAC;KAED,GAAG,CAAC;IACH,OAAO,EAAE;QACP,IAAI,EAAE,GAAG;QACT,WAAW,EAAE;;;4EAGyD;KACvE;CACF,CAAC;KAED,GAAG,CAAC;IACH,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,WAAW;QACpB,WAAW,EAAE;;;;;;;;;;;;;;;;;;OAkBZ;QACD,YAAY,EAAE;YACZ,OAAO;YACP,MAAM;YACN,SAAS;YACT,KAAK;YACL,SAAS;SACD;KACX;CACF,CAAC;KAED,OAAO,CAAC;IACP,gBAAgB,EAAE;QAChB,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE;iEAC8C;KAC5D;CACF,CAAC;KAED,IAAI,CAAC;IACJ,UAAU,EAAE;QACV,KAAK,EAAE,GAAG;QACV,WAAW,EAAE;oCACiB;KAC/B;IACD,eAAe,EAAE;QACf,KAAK,EAAE,GAAG;QACV,WAAW,EAAE;yCACsB;KACpC;IACD,WAAW,EAAE;QACX,WAAW,EAAE;qCACkB;KAChC;IACD,WAAW,EAAE;QACX,KAAK,EAAE,GAAG;QACV,WAAW,EAAE;;;wEAGqD;KACnE;CACF,CAAC;KAED,IAAI,CAAC;IACJ,OAAO,EAAE;QACP,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,mBAAmB;KACjC;CACF,CAAC;KAED,IAAI,CAAC;IACJ,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,2BAA2B;KACzC;CACF,CAAC,CAAA","sourcesContent":["import { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView = process.stdout.isTTY ? 'human' : 'json'\n\nconst canonicalCommands = {\n config: 'config',\n exec: 'exec',\n gui: 'gui',\n help: 'help',\n init: 'init',\n 'install-exec': 'install-exec',\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 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 h: 'help',\n '?': 'help',\n conf: 'config',\n ix: 'install-exec',\n ls: 'list',\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] 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',\n 'install-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 '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:\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi'),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`\n (either as lifecycle scripts or explicitly with\n \\`vlt run\\`) and \\`vlt exec\\`.\n\n If not set, defaults to \\`/bin/sh\\` on POSIX systems,\n and \\`cmd.exe\\` on Windows.\n\n When no argument is provided to \\`vlt exec\\`, the \\`SHELL\\`\n environment variable takes precedence if set.`,\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 install-exec\\`, this allows you to\n explicitly set the package to search for bins. If not\n provided, then vlt will interpret the first argument as\n the package, and 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 .flag({\n version: {\n short: 'v',\n description: 'Print the version',\n },\n })\n\n .flag({\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n"]}
|
package/dist/esm/config/index.js
CHANGED
|
@@ -25,10 +25,10 @@ import { PackageInfoClient } from '@vltpkg/package-info';
|
|
|
25
25
|
import { PackageJson } from '@vltpkg/package-json';
|
|
26
26
|
import { Monorepo } from '@vltpkg/workspaces';
|
|
27
27
|
import { XDG } from '@vltpkg/xdg';
|
|
28
|
-
import { readFileSync, rmSync, writeFileSync } from 'fs';
|
|
29
|
-
import { lstat, mkdir, readFile, writeFile } from 'fs/promises';
|
|
30
|
-
import { homedir } from 'os';
|
|
31
|
-
import { dirname, resolve } from 'path';
|
|
28
|
+
import { readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
29
|
+
import { lstat, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
30
|
+
import { homedir } from 'node:os';
|
|
31
|
+
import { dirname, resolve } from 'node:path';
|
|
32
32
|
import { PathScurry } from 'path-scurry';
|
|
33
33
|
import { parse as jsonParse, stringify as jsonStringify, kIndent, kNewline, } from 'polite-json';
|
|
34
34
|
import { walkUp } from 'walk-up-path';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EACL,KAAK,IAAI,SAAS,EAClB,SAAS,IAAI,aAAa,EAC1B,OAAO,EACP,QAAQ,GACT,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EACL,QA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Q,GAAG,CAAC,CAAS,EAAqB,EAAE,CAChD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["/**\n * Module that handles all vlt configuration needs\n *\n * Project-level configs are set in a `vlt.json` file in the local project\n * if present. This will override the user-level configs in the appropriate\n * XDG config path.\n *\n * Command-specific configuration can be specified by putting options in a\n * field in the `command` object. For example:\n *\n * ```json\n * {\n * \"registry\": \"https://registry.npmjs.org/\",\n * \"command\": {\n * \"publish\": {\n * \"registry\": \"http://registry.internal\"\n * }\n * }\n * }\n * ```\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { PackageJson } from '@vltpkg/package-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { XDG } from '@vltpkg/xdg'\nimport { readFileSync, rmSync, writeFileSync } from 'fs'\nimport { lstat, mkdir, readFile, writeFile } from 'fs/promises'\nimport type { Jack, OptionsResults, Unwrap } from 'jackspeak'\nimport { homedir } from 'os'\nimport { dirname, resolve } from 'path'\nimport { PathScurry } from 'path-scurry'\nimport type { JSONResult } from 'polite-json'\nimport {\n parse as jsonParse,\n stringify as jsonStringify,\n kIndent,\n kNewline,\n} from 'polite-json'\nimport { walkUp } from 'walk-up-path'\nimport type { Commands, RecordField } from './definition.ts'\nimport {\n commands,\n definition,\n getCommand,\n isRecordField,\n recordFields,\n} from './definition.ts'\nimport { merge } from './merge.ts'\nexport {\n commands,\n definition,\n isRecordField,\n recordFields,\n type Commands,\n}\n\nexport type RecordPairs = Record<string, unknown>\nexport type RecordString = Record<string, string>\nexport type ConfigFiles = Record<string, ConfigFileData>\n\n// turn a set of pairs into a Record object.\n// if a kv pair doesn't have a = character, set to `''`\nconst reducePairs = <T extends string[]>(\n pairs: T,\n): RecordString | T => {\n const record: RecordString = {}\n for (const kv of pairs) {\n const eq = kv.indexOf('=')\n if (eq === -1) record[kv] = ''\n else {\n const key = kv.substring(0, eq)\n const val = kv.substring(eq + 1)\n record[key] = val\n }\n }\n return record\n}\n\nconst isRecordFieldValue = (k: string, v: unknown): v is string[] =>\n Array.isArray(v) &&\n recordFields.includes(k as (typeof recordFields)[number])\n\nexport type PairsAsRecords = Omit<\n ConfigOptions,\n | 'projectRoot'\n | 'scurry'\n | 'packageJson'\n | 'monorepo'\n | 'packageInfo'\n> & {\n command?: Record<string, ConfigOptions>\n}\n\nexport const pairsToRecords = (\n obj: ConfigFileData,\n): PairsAsRecords => {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n Object.fromEntries(\n Object.entries(v).map(([k, v]) => [\n k,\n pairsToRecords(v as ConfigFileData),\n ]),\n )\n : isRecordFieldValue(k, v) ? reducePairs(v)\n : v,\n ]),\n // hard cast because TS can't see through the entries/fromEntries\n ) as unknown as PairsAsRecords\n}\n\nexport const recordsToPairs = (obj: RecordPairs): RecordPairs => {\n return Object.fromEntries(\n Object.entries(obj)\n .filter(\n ([k]) =>\n !(\n k === 'scurry' ||\n k === 'packageJson' ||\n k === 'monorepo' ||\n k === 'projectRoot' ||\n k === 'packageInfo'\n ),\n )\n .map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n recordsToPairs(v as RecordPairs)\n : (\n !v ||\n typeof v !== 'object' ||\n Array.isArray(v) ||\n !isRecordField(k)\n ) ?\n v\n : Object.entries(v).map(([k, v]) => `${k}=${v}`),\n ]),\n )\n}\n\nconst kRecord = Symbol('parsed key=value record')\nconst exists = (f: string) =>\n lstat(f).then(\n () => true,\n () => false,\n )\n\nconst home = homedir()\nconst xdg = new XDG('vlt')\n\n/**\n * Config data can be any options, and also a 'command' field which\n * contains command names and override options for that command.\n */\nexport type ConfigData = OptionsResults<ConfigDefinitions> & {\n command?: Record<string, OptionsResults<ConfigDefinitions>>\n}\n\n/**\n * Config data as it appears in config files, with kv pair lists\n * stored as `Record<string, string>`.\n */\nexport type ConfigFileData = {\n [k in keyof ConfigData]?: k extends OptListKeys<ConfigData> ?\n RecordString | string[]\n : k extends 'command' ? ConfigFiles\n : ConfigData[k]\n}\n\nexport type ConfigOptions = {\n [k in keyof ConfigData]: k extends RecordField ? RecordString\n : k extends 'command' ? never\n : ConfigData[k]\n} & {\n packageJson: PackageJson\n scurry: PathScurry\n projectRoot: string\n monorepo?: Monorepo\n packageInfo: PackageInfoClient\n}\n\n/**\n * The base config definition set as a type\n */\nexport type ConfigDefinitions = Unwrap<typeof definition>\n\nexport type StringListKeys<O> = {\n [k in keyof O]: O[k] extends string[] | undefined ? k : never\n}\nexport type OptListKeys<O> = Exclude<\n StringListKeys<O>[keyof StringListKeys<O>],\n undefined\n>\n\n/**\n * Class that handles configuration for vlt.\n *\n * Call {@link Config.load} to get one of these.\n */\nexport class Config {\n /**\n * The {@link https://npmjs.com/jackspeak | JackSpeak} object\n * representing vlt's configuration\n */\n jack: Jack<ConfigDefinitions>\n\n stringifyOptions: {\n [kIndent]: string\n [kNewline]: string\n } = { [kIndent]: ' ', [kNewline]: '\\n' }\n\n configFiles: ConfigFiles = {}\n\n /**\n * Parsed values in effect\n */\n values?: OptionsResults<ConfigDefinitions>\n\n /**\n * Command-specific config values\n */\n commandValues: {\n [cmd in Commands[keyof Commands]]?: ConfigData\n } = {}\n\n /**\n * A flattened object of the parsed configuration\n */\n get options(): ConfigOptions {\n if (this.#options) return this.#options\n const scurry = new PathScurry(this.projectRoot)\n const packageJson = new PackageJson()\n const asRecords = pairsToRecords(this.parse().values)\n const extras = {\n projectRoot: this.projectRoot,\n scurry,\n packageJson,\n monorepo: Monorepo.maybeLoad(this.projectRoot, {\n scurry,\n packageJson,\n }),\n }\n const options: Omit<ConfigOptions, 'packageInfo'> = Object.assign(\n asRecords,\n extras,\n )\n this.#options = Object.assign(options, {\n packageInfo: new PackageInfoClient(options),\n })\n return this.#options\n }\n\n /**\n * Reset the options value, optionally setting a new project root\n * to recalculate the options.\n */\n resetOptions(projectRoot: string = process.cwd()) {\n this.projectRoot = projectRoot\n this.#options = undefined\n }\n\n // memoized options() getter value\n #options?: ConfigOptions\n\n /**\n * positional arguments to the vlt process\n */\n positionals?: string[]\n\n /**\n * The root of the project where a vlt.json, vlt-workspaces.json,\n * package.json, or .git was found. Not necessarily the `process.cwd()`,\n * though that is the default location.\n *\n * Never walks up as far as `$HOME`. So for example, if a project is in\n * `~/projects/xyz`, then the highest dir it will check is `~/projects`\n */\n projectRoot: string\n\n /**\n * `Record<alias, canonical name>` to dereference command aliases.\n */\n commands: Commands\n\n /**\n * Which command name to use for overriding with command-specific values,\n * determined from the argv when parse() is called.\n */\n command?: Commands[keyof Commands]\n\n constructor(\n jack: Jack<ConfigDefinitions> = definition,\n projectRoot = process.cwd(),\n ) {\n this.projectRoot = projectRoot\n this.commands = commands\n this.jack = jack\n }\n\n /**\n * Parse the arguments and set configuration and positionals accordingly.\n */\n parse(args: string[] = process.argv): this & ParsedConfig {\n if (isParsed(this)) return this\n\n this.jack.loadEnvDefaults()\n const p = this.jack.parseRaw(args)\n\n const fallback = getCommand(p.values['fallback-command'])\n this.command = getCommand(p.positionals[0])\n\n const cmdOrFallback = this.command ?? fallback\n const cmdSpecific =\n cmdOrFallback && this.commandValues[cmdOrFallback]\n if (cmdSpecific) {\n this.jack.setConfigValues(recordsToPairs(cmdSpecific))\n }\n\n // ok, applied cmd-specific defaults, do rest of the parse\n this.jack.applyDefaults(p)\n this.jack.writeEnv(p)\n\n if (this.command) p.positionals.shift()\n else this.command = getCommand(p.values['fallback-command'])\n\n Object.assign(this, p)\n\n /* c8 ignore start - unpossible */\n if (!isParsed(this)) throw error('failed to parse config')\n /* c8 ignore stop */\n\n return this\n }\n\n /**\n * Get a `key=value` list option value as an object.\n *\n * For example, a list option with a vlaue of `['key=value', 'xyz=as=df' ]`\n * would be returned as `{key: 'value', xyz: 'as=df'}`\n *\n * Results are memoized, so subsequent calls for the same key will return the\n * same object. If new strings are added to the list, then the memoized value\n * is *not* updated, so only use once configurations have been fully loaded.\n *\n * If the config value is not set at all, an empty object is returned.\n */\n getRecord(k: OptListKeys<ConfigData>): RecordString {\n const pairs = this.get(k) as\n | (string[] & { [kRecord]?: RecordString })\n | undefined\n if (!pairs) return {}\n if (pairs[kRecord]) return pairs[kRecord]\n const kv = pairs.reduce((kv: RecordString, pair) => {\n const eq = pair.indexOf('=')\n if (eq === -1) return kv\n const key = pair.substring(0, eq)\n const val = pair.substring(eq + 1)\n kv[key] = val\n return kv\n }, {})\n Object.assign(pairs, { [kRecord]: kv })\n return kv\n }\n\n /**\n * Get a configuration value.\n *\n * Note: `key=value` pair configs are returned as a string array. To get them\n * as an object, use {@link Config#getRecord}.\n */\n get<K extends keyof OptionsResults<ConfigDefinitions>>(\n k: K,\n ): OptionsResults<ConfigDefinitions>[K] {\n /* c8 ignore next -- impossible but TS doesn't know that */\n return (this.values ?? this.parse().values)[k]\n }\n\n /**\n * Write the config values to the user or project config file.\n */\n async writeConfigFile(\n which: 'project' | 'user',\n values: ConfigFileData,\n ) {\n const f = this.getFilename(which)\n await mkdir(dirname(f), { recursive: true })\n const vals = Object.assign(\n pairsToRecords(values),\n this.stringifyOptions,\n )\n await writeFile(f, jsonStringify(vals))\n this.configFiles[f] = vals\n return values\n }\n\n /**\n * Fold in the provided fields with the existing properties\n * in the config file.\n */\n async addConfigToFile(\n which: 'project' | 'user',\n values: ConfigFileData,\n ) {\n const f = this.getFilename(which)\n return this.writeConfigFile(\n which,\n merge((await this.#maybeLoadConfigFile(f)) ?? {}, values),\n )\n }\n\n /**\n * if the file exists, parse and load it. returns object if data was\n * loaded, or undefined if not.\n */\n async #maybeLoadConfigFile(\n file: string,\n ): Promise<ConfigFileData | undefined> {\n const result = await this.#readConfigFile(file)\n\n if (result) {\n try {\n const { command, ...values } = recordsToPairs(result)\n if (command) {\n for (const [c, opts] of Object.entries(command)) {\n const cmd = getCommand(c)\n if (cmd) {\n this.commandValues[cmd] = merge<ConfigData>(\n this.commandValues[cmd] ?? ({} as ConfigData),\n opts as ConfigData,\n )\n }\n }\n }\n this.jack.setConfigValues(values, file)\n return result\n } catch (er) {\n throw error('failed to load config values from file', {\n path: file,\n cause: er,\n })\n }\n }\n }\n\n async #readConfigFile(\n file: string,\n ): Promise<ConfigFileData | undefined> {\n if (this.configFiles[file]) return this.configFiles[file]\n const data = await readFile(file, 'utf8').catch(() => {})\n if (!data) return undefined\n let result: JSONResult\n try {\n result = jsonParse(data)\n if (result && typeof result === 'object') {\n if (result[kIndent] !== undefined)\n this.stringifyOptions[kIndent] = result[kIndent]\n if (result[kNewline] !== undefined)\n this.stringifyOptions[kNewline] = result[kNewline]\n }\n } catch (er) {\n throw error('failed to parse vlt config file', {\n path: file,\n cause: er,\n })\n }\n this.configFiles[file] = result as ConfigFileData\n return result as ConfigFileData\n }\n\n getFilename(which: 'project' | 'user' = 'project'): string {\n return which === 'user' ?\n xdg.config('vlt.json')\n : resolve(this.projectRoot, 'vlt.json')\n }\n\n async deleteConfigKeys(\n which: 'project' | 'user',\n fields: string[],\n ) {\n const file = this.getFilename(which)\n const data = await this.#maybeLoadConfigFile(file)\n if (!data) {\n rmSync(file, { force: true })\n return false\n }\n let didSomething = false\n for (const f of fields) {\n const [key, ...sk] = f.split('.') as [\n h: string,\n ...rest: string[],\n ]\n const subs = sk.join('.')\n const k = key as keyof ConfigDefinitions\n const v = data[k]\n if (v === undefined) continue\n if (subs && v && typeof v === 'object') {\n if (Array.isArray(v)) {\n const i = v.findIndex(subvalue =>\n subvalue.startsWith(`${subs}=`),\n )\n if (i !== -1) {\n v.splice(i, 1)\n if (v.length === 0) delete data[k]\n didSomething = true\n }\n } else {\n if (v[subs] !== undefined) {\n delete v[subs]\n if (Object.keys(v).length === 0) delete data[k]\n didSomething = true\n }\n }\n } else {\n didSomething = true\n delete data[k]\n }\n }\n const d = jsonStringify(data)\n if (d.trim() === '{}') {\n rmSync(file, { force: true })\n } else {\n writeFileSync(file, jsonStringify(data))\n }\n return didSomething\n }\n\n /**\n * Edit the user or project configuration file.\n *\n * If the file isn't present, then it starts with `{}` so the user has\n * something to work with.\n *\n * If the result is not valid, or no config settings are contained in the\n * file after editing, then it's restored to what it was before, which might\n * mean deleting the file.\n */\n async editConfigFile(\n which: 'project' | 'user',\n edit: (file: string) => Promise<void> | void,\n ) {\n const file = this.getFilename(which)\n const backup = this.configFiles[file]\n if (!backup) {\n writeFileSync(file, '{\\n\\n}\\n')\n }\n let valid = false\n try {\n await edit(file)\n const res = jsonParse(readFileSync(file, 'utf8'))\n if (!res || typeof res !== 'object' || Array.isArray(res)) {\n throw error('Invalid configuration, expected object', {\n path: file,\n found: res,\n })\n }\n if (Object.keys(res).length === 0) {\n // nothing there, remove file\n delete this.configFiles[file]\n rmSync(file, { force: true })\n } else {\n this.jack.setConfigValues(recordsToPairs(res))\n this.configFiles[file] = res as ConfigFileData\n }\n valid = true\n } finally {\n if (!valid) {\n if (backup) {\n writeFileSync(file, jsonStringify(backup))\n } else {\n rmSync(file, { force: true })\n }\n }\n }\n }\n\n /**\n * Find the local config file and load both it and the user-level config in\n * the XDG config home.\n *\n * Note: if working in a workspaces monorepo, then the vlt.json file MUST\n * be in the same folder as the vlt-workspaces.json file, because we stop\n * looking when we find either one.\n */\n async loadConfigFile(): Promise<this> {\n const userConfig = xdg.config('vlt.json')\n await this.#maybeLoadConfigFile(userConfig)\n\n let lastKnownRoot = resolve(this.projectRoot)\n for (const dir of walkUp(this.projectRoot)) {\n // don't look in ~\n if (dir === home) break\n\n // finding a project config file stops the search\n const projectConfig = resolve(dir, 'vlt.json')\n if (projectConfig === userConfig) break\n if (\n (await exists(projectConfig)) &&\n (await this.#maybeLoadConfigFile(projectConfig))\n ) {\n lastKnownRoot = dir\n break\n }\n\n // stat existence of these files\n const [hasPackage, hasModules, hasWorkspaces, hasGit] =\n await Promise.all([\n exists(resolve(dir, 'package.json')),\n exists(resolve(dir, 'node_modules')),\n exists(resolve(dir, 'vlt-workspaces.json')),\n exists(resolve(dir, '.git')),\n ])\n\n // treat these as potential roots\n if (hasPackage || hasModules || hasWorkspaces) {\n lastKnownRoot = dir\n }\n\n // define backstops\n if (hasWorkspaces || hasGit) {\n break\n }\n }\n this.projectRoot = lastKnownRoot\n return this\n }\n\n /**\n * Determine whether we should use colors in the output. Update\n * chalk appropriately.\n *\n * Implicitly calls this.parse() if it not parsed already.\n */\n async loadColor(): Promise<this & LoadedConfig> {\n const c = this.get('color')\n const chalk = (await import('chalk')).default\n let color: boolean\n if (\n process.env.NO_COLOR !== '1' &&\n (c === true || (c === undefined && chalk.level > 0))\n ) {\n color = true\n chalk.level = Math.max(chalk.level, 1) as 0 | 1 | 2 | 3\n process.env.FORCE_COLOR = String(chalk.level)\n delete process.env.NO_COLOR\n } else {\n color = false\n chalk.level = 0\n process.env.FORCE_COLOR = '0'\n process.env.NO_COLOR = '1'\n }\n const { values = this.parse().values } = this\n ;(values as ConfigData & { color: boolean }).color = color\n return this as this & LoadedConfig\n }\n\n /**\n * cache of the loaded config\n */\n static #loaded: LoadedConfig | undefined\n\n /**\n * Load the configuration and return a Promise to a\n * {@link Config} object\n */\n static async load(\n projectRoot = process.cwd(),\n argv = process.argv,\n /**\n * only used in tests, resets the memoization\n * @internal\n */\n reload = false,\n ): Promise<LoadedConfig> {\n if (this.#loaded && !reload) return this.#loaded\n const a = new Config(definition, projectRoot)\n const b = await a.loadConfigFile()\n const c = await b.parse(argv).loadColor()\n this.#loaded = c as LoadedConfig\n return this.#loaded\n }\n}\n\nconst isParsed = (c: Config): c is ParsedConfig =>\n !!(c.values && c.positionals && c.command)\n\nexport type ParsedConfig = Config & {\n command: NonNullable<Config['command']>\n values: OptionsResults<ConfigDefinitions>\n positionals: string[]\n}\n\n/**\n * A fully loaded {@link Config} object\n */\nexport type LoadedConfig = ParsedConfig & {\n get(k: 'color'): boolean\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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G,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,IAAI,CAC5C;QAAC,MAA0C,CAAC,KAAK,GAAG,KAAK,CAAA;QAC1D,OAAO,IAA2B,CAAA;IACpC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO,CAA0B;IAExC;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CACf,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAC3B,IAAI,GAAG,OAAO,CAAC,IAAI;IACnB;;;OAGG;IACH,MAAM,GAAG,KAAK;QAEd,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,OAAO,CAAA;QAChD,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;QAC7C,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,cAAc,EAAE,CAAA;QAClC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAA;QACzC,IAAI,CAAC,OAAO,GAAG,CAAiB,CAAA;QAChC,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAqB,EAAE,CAChD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["/**\n * Module that handles all vlt configuration needs\n *\n * Project-level configs are set in a `vlt.json` file in the local project\n * if present. This will override the user-level configs in the appropriate\n * XDG config path.\n *\n * Command-specific configuration can be specified by putting options in a\n * field in the `command` object. For example:\n *\n * ```json\n * {\n * \"registry\": \"https://registry.npmjs.org/\",\n * \"command\": {\n * \"publish\": {\n * \"registry\": \"http://registry.internal\"\n * }\n * }\n * }\n * ```\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { PackageJson } from '@vltpkg/package-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { XDG } from '@vltpkg/xdg'\nimport { readFileSync, rmSync, writeFileSync } from 'node:fs'\nimport { lstat, mkdir, readFile, writeFile } from 'node:fs/promises'\nimport type { Jack, OptionsResults, Unwrap } from 'jackspeak'\nimport { homedir } from 'node:os'\nimport { dirname, resolve } from 'node:path'\nimport { PathScurry } from 'path-scurry'\nimport type { JSONResult } from 'polite-json'\nimport {\n parse as jsonParse,\n stringify as jsonStringify,\n kIndent,\n kNewline,\n} from 'polite-json'\nimport { walkUp } from 'walk-up-path'\nimport type { Commands, RecordField } from './definition.ts'\nimport {\n commands,\n definition,\n getCommand,\n isRecordField,\n recordFields,\n} from './definition.ts'\nimport { merge } from './merge.ts'\nexport {\n commands,\n definition,\n isRecordField,\n recordFields,\n type Commands,\n}\n\nexport type RecordPairs = Record<string, unknown>\nexport type RecordString = Record<string, string>\nexport type ConfigFiles = Record<string, ConfigFileData>\n\n// turn a set of pairs into a Record object.\n// if a kv pair doesn't have a = character, set to `''`\nconst reducePairs = <T extends string[]>(\n pairs: T,\n): RecordString | T => {\n const record: RecordString = {}\n for (const kv of pairs) {\n const eq = kv.indexOf('=')\n if (eq === -1) record[kv] = ''\n else {\n const key = kv.substring(0, eq)\n const val = kv.substring(eq + 1)\n record[key] = val\n }\n }\n return record\n}\n\nconst isRecordFieldValue = (k: string, v: unknown): v is string[] =>\n Array.isArray(v) &&\n recordFields.includes(k as (typeof recordFields)[number])\n\nexport type PairsAsRecords = Omit<\n ConfigOptions,\n | 'projectRoot'\n | 'scurry'\n | 'packageJson'\n | 'monorepo'\n | 'packageInfo'\n> & {\n command?: Record<string, ConfigOptions>\n}\n\nexport const pairsToRecords = (\n obj: ConfigFileData,\n): PairsAsRecords => {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n Object.fromEntries(\n Object.entries(v).map(([k, v]) => [\n k,\n pairsToRecords(v as ConfigFileData),\n ]),\n )\n : isRecordFieldValue(k, v) ? reducePairs(v)\n : v,\n ]),\n // hard cast because TS can't see through the entries/fromEntries\n ) as unknown as PairsAsRecords\n}\n\nexport const recordsToPairs = (obj: RecordPairs): RecordPairs => {\n return Object.fromEntries(\n Object.entries(obj)\n .filter(\n ([k]) =>\n !(\n k === 'scurry' ||\n k === 'packageJson' ||\n k === 'monorepo' ||\n k === 'projectRoot' ||\n k === 'packageInfo'\n ),\n )\n .map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n recordsToPairs(v as RecordPairs)\n : (\n !v ||\n typeof v !== 'object' ||\n Array.isArray(v) ||\n !isRecordField(k)\n ) ?\n v\n : Object.entries(v).map(([k, v]) => `${k}=${v}`),\n ]),\n )\n}\n\nconst kRecord = Symbol('parsed key=value record')\nconst exists = (f: string) =>\n lstat(f).then(\n () => true,\n () => false,\n )\n\nconst home = homedir()\nconst xdg = new XDG('vlt')\n\n/**\n * Config data can be any options, and also a 'command' field which\n * contains command names and override options for that command.\n */\nexport type ConfigData = OptionsResults<ConfigDefinitions> & {\n command?: Record<string, OptionsResults<ConfigDefinitions>>\n}\n\n/**\n * Config data as it appears in config files, with kv pair lists\n * stored as `Record<string, string>`.\n */\nexport type ConfigFileData = {\n [k in keyof ConfigData]?: k extends OptListKeys<ConfigData> ?\n RecordString | string[]\n : k extends 'command' ? ConfigFiles\n : ConfigData[k]\n}\n\nexport type ConfigOptions = {\n [k in keyof ConfigData]: k extends RecordField ? RecordString\n : k extends 'command' ? never\n : ConfigData[k]\n} & {\n packageJson: PackageJson\n scurry: PathScurry\n projectRoot: string\n monorepo?: Monorepo\n packageInfo: PackageInfoClient\n}\n\n/**\n * The base config definition set as a type\n */\nexport type ConfigDefinitions = Unwrap<typeof definition>\n\nexport type StringListKeys<O> = {\n [k in keyof O]: O[k] extends string[] | undefined ? k : never\n}\nexport type OptListKeys<O> = Exclude<\n StringListKeys<O>[keyof StringListKeys<O>],\n undefined\n>\n\n/**\n * Class that handles configuration for vlt.\n *\n * Call {@link Config.load} to get one of these.\n */\nexport class Config {\n /**\n * The {@link https://npmjs.com/jackspeak | JackSpeak} object\n * representing vlt's configuration\n */\n jack: Jack<ConfigDefinitions>\n\n stringifyOptions: {\n [kIndent]: string\n [kNewline]: string\n } = { [kIndent]: ' ', [kNewline]: '\\n' }\n\n configFiles: ConfigFiles = {}\n\n /**\n * Parsed values in effect\n */\n values?: OptionsResults<ConfigDefinitions>\n\n /**\n * Command-specific config values\n */\n commandValues: {\n [cmd in Commands[keyof Commands]]?: ConfigData\n } = {}\n\n /**\n * A flattened object of the parsed configuration\n */\n get options(): ConfigOptions {\n if (this.#options) return this.#options\n const scurry = new PathScurry(this.projectRoot)\n const packageJson = new PackageJson()\n const asRecords = pairsToRecords(this.parse().values)\n const extras = {\n projectRoot: this.projectRoot,\n scurry,\n packageJson,\n monorepo: Monorepo.maybeLoad(this.projectRoot, {\n scurry,\n packageJson,\n }),\n }\n const options: Omit<ConfigOptions, 'packageInfo'> = Object.assign(\n asRecords,\n extras,\n )\n this.#options = Object.assign(options, {\n packageInfo: new PackageInfoClient(options),\n })\n return this.#options\n }\n\n /**\n * Reset the options value, optionally setting a new project root\n * to recalculate the options.\n */\n resetOptions(projectRoot: string = process.cwd()) {\n this.projectRoot = projectRoot\n this.#options = undefined\n }\n\n // memoized options() getter value\n #options?: ConfigOptions\n\n /**\n * positional arguments to the vlt process\n */\n positionals?: string[]\n\n /**\n * The root of the project where a vlt.json, vlt-workspaces.json,\n * package.json, or .git was found. Not necessarily the `process.cwd()`,\n * though that is the default location.\n *\n * Never walks up as far as `$HOME`. So for example, if a project is in\n * `~/projects/xyz`, then the highest dir it will check is `~/projects`\n */\n projectRoot: string\n\n /**\n * `Record<alias, canonical name>` to dereference command aliases.\n */\n commands: Commands\n\n /**\n * Which command name to use for overriding with command-specific values,\n * determined from the argv when parse() is called.\n */\n command?: Commands[keyof Commands]\n\n constructor(\n jack: Jack<ConfigDefinitions> = definition,\n projectRoot = process.cwd(),\n ) {\n this.projectRoot = projectRoot\n this.commands = commands\n this.jack = jack\n }\n\n /**\n * Parse the arguments and set configuration and positionals accordingly.\n */\n parse(args: string[] = process.argv): this & ParsedConfig {\n if (isParsed(this)) return this\n\n this.jack.loadEnvDefaults()\n const p = this.jack.parseRaw(args)\n\n const fallback = getCommand(p.values['fallback-command'])\n this.command = getCommand(p.positionals[0])\n\n const cmdOrFallback = this.command ?? fallback\n const cmdSpecific =\n cmdOrFallback && this.commandValues[cmdOrFallback]\n if (cmdSpecific) {\n this.jack.setConfigValues(recordsToPairs(cmdSpecific))\n }\n\n // ok, applied cmd-specific defaults, do rest of the parse\n this.jack.applyDefaults(p)\n this.jack.writeEnv(p)\n\n if (this.command) p.positionals.shift()\n else this.command = getCommand(p.values['fallback-command'])\n\n Object.assign(this, p)\n\n /* c8 ignore start - unpossible */\n if (!isParsed(this)) throw error('failed to parse config')\n /* c8 ignore stop */\n\n return this\n }\n\n /**\n * Get a `key=value` list option value as an object.\n *\n * For example, a list option with a vlaue of `['key=value', 'xyz=as=df' ]`\n * would be returned as `{key: 'value', xyz: 'as=df'}`\n *\n * Results are memoized, so subsequent calls for the same key will return the\n * same object. If new strings are added to the list, then the memoized value\n * is *not* updated, so only use once configurations have been fully loaded.\n *\n * If the config value is not set at all, an empty object is returned.\n */\n getRecord(k: OptListKeys<ConfigData>): RecordString {\n const pairs = this.get(k) as\n | (string[] & { [kRecord]?: RecordString })\n | undefined\n if (!pairs) return {}\n if (pairs[kRecord]) return pairs[kRecord]\n const kv = pairs.reduce((kv: RecordString, pair) => {\n const eq = pair.indexOf('=')\n if (eq === -1) return kv\n const key = pair.substring(0, eq)\n const val = pair.substring(eq + 1)\n kv[key] = val\n return kv\n }, {})\n Object.assign(pairs, { [kRecord]: kv })\n return kv\n }\n\n /**\n * Get a configuration value.\n *\n * Note: `key=value` pair configs are returned as a string array. To get them\n * as an object, use {@link Config#getRecord}.\n */\n get<K extends keyof OptionsResults<ConfigDefinitions>>(\n k: K,\n ): OptionsResults<ConfigDefinitions>[K] {\n /* c8 ignore next -- impossible but TS doesn't know that */\n return (this.values ?? this.parse().values)[k]\n }\n\n /**\n * Write the config values to the user or project config file.\n */\n async writeConfigFile(\n which: 'project' | 'user',\n values: ConfigFileData,\n ) {\n const f = this.getFilename(which)\n await mkdir(dirname(f), { recursive: true })\n const vals = Object.assign(\n pairsToRecords(values),\n this.stringifyOptions,\n )\n await writeFile(f, jsonStringify(vals))\n this.configFiles[f] = vals\n return values\n }\n\n /**\n * Fold in the provided fields with the existing properties\n * in the config file.\n */\n async addConfigToFile(\n which: 'project' | 'user',\n values: ConfigFileData,\n ) {\n const f = this.getFilename(which)\n return this.writeConfigFile(\n which,\n merge((await this.#maybeLoadConfigFile(f)) ?? {}, values),\n )\n }\n\n /**\n * if the file exists, parse and load it. returns object if data was\n * loaded, or undefined if not.\n */\n async #maybeLoadConfigFile(\n file: string,\n ): Promise<ConfigFileData | undefined> {\n const result = await this.#readConfigFile(file)\n\n if (result) {\n try {\n const { command, ...values } = recordsToPairs(result)\n if (command) {\n for (const [c, opts] of Object.entries(command)) {\n const cmd = getCommand(c)\n if (cmd) {\n this.commandValues[cmd] = merge<ConfigData>(\n this.commandValues[cmd] ?? ({} as ConfigData),\n opts as ConfigData,\n )\n }\n }\n }\n this.jack.setConfigValues(values, file)\n return result\n } catch (er) {\n throw error('failed to load config values from file', {\n path: file,\n cause: er,\n })\n }\n }\n }\n\n async #readConfigFile(\n file: string,\n ): Promise<ConfigFileData | undefined> {\n if (this.configFiles[file]) return this.configFiles[file]\n const data = await readFile(file, 'utf8').catch(() => {})\n if (!data) return undefined\n let result: JSONResult\n try {\n result = jsonParse(data)\n if (result && typeof result === 'object') {\n if (result[kIndent] !== undefined)\n this.stringifyOptions[kIndent] = result[kIndent]\n if (result[kNewline] !== undefined)\n this.stringifyOptions[kNewline] = result[kNewline]\n }\n } catch (er) {\n throw error('failed to parse vlt config file', {\n path: file,\n cause: er,\n })\n }\n this.configFiles[file] = result as ConfigFileData\n return result as ConfigFileData\n }\n\n getFilename(which: 'project' | 'user' = 'project'): string {\n return which === 'user' ?\n xdg.config('vlt.json')\n : resolve(this.projectRoot, 'vlt.json')\n }\n\n async deleteConfigKeys(\n which: 'project' | 'user',\n fields: string[],\n ) {\n const file = this.getFilename(which)\n const data = await this.#maybeLoadConfigFile(file)\n if (!data) {\n rmSync(file, { force: true })\n return false\n }\n let didSomething = false\n for (const f of fields) {\n const [key, ...sk] = f.split('.') as [\n h: string,\n ...rest: string[],\n ]\n const subs = sk.join('.')\n const k = key as keyof ConfigDefinitions\n const v = data[k]\n if (v === undefined) continue\n if (subs && v && typeof v === 'object') {\n if (Array.isArray(v)) {\n const i = v.findIndex(subvalue =>\n subvalue.startsWith(`${subs}=`),\n )\n if (i !== -1) {\n v.splice(i, 1)\n if (v.length === 0) delete data[k]\n didSomething = true\n }\n } else {\n if (v[subs] !== undefined) {\n delete v[subs]\n if (Object.keys(v).length === 0) delete data[k]\n didSomething = true\n }\n }\n } else {\n didSomething = true\n delete data[k]\n }\n }\n const d = jsonStringify(data)\n if (d.trim() === '{}') {\n rmSync(file, { force: true })\n } else {\n writeFileSync(file, jsonStringify(data))\n }\n return didSomething\n }\n\n /**\n * Edit the user or project configuration file.\n *\n * If the file isn't present, then it starts with `{}` so the user has\n * something to work with.\n *\n * If the result is not valid, or no config settings are contained in the\n * file after editing, then it's restored to what it was before, which might\n * mean deleting the file.\n */\n async editConfigFile(\n which: 'project' | 'user',\n edit: (file: string) => Promise<void> | void,\n ) {\n const file = this.getFilename(which)\n const backup = this.configFiles[file]\n if (!backup) {\n writeFileSync(file, '{\\n\\n}\\n')\n }\n let valid = false\n try {\n await edit(file)\n const res = jsonParse(readFileSync(file, 'utf8'))\n if (!res || typeof res !== 'object' || Array.isArray(res)) {\n throw error('Invalid configuration, expected object', {\n path: file,\n found: res,\n })\n }\n if (Object.keys(res).length === 0) {\n // nothing there, remove file\n delete this.configFiles[file]\n rmSync(file, { force: true })\n } else {\n this.jack.setConfigValues(recordsToPairs(res))\n this.configFiles[file] = res as ConfigFileData\n }\n valid = true\n } finally {\n if (!valid) {\n if (backup) {\n writeFileSync(file, jsonStringify(backup))\n } else {\n rmSync(file, { force: true })\n }\n }\n }\n }\n\n /**\n * Find the local config file and load both it and the user-level config in\n * the XDG config home.\n *\n * Note: if working in a workspaces monorepo, then the vlt.json file MUST\n * be in the same folder as the vlt-workspaces.json file, because we stop\n * looking when we find either one.\n */\n async loadConfigFile(): Promise<this> {\n const userConfig = xdg.config('vlt.json')\n await this.#maybeLoadConfigFile(userConfig)\n\n let lastKnownRoot = resolve(this.projectRoot)\n for (const dir of walkUp(this.projectRoot)) {\n // don't look in ~\n if (dir === home) break\n\n // finding a project config file stops the search\n const projectConfig = resolve(dir, 'vlt.json')\n if (projectConfig === userConfig) break\n if (\n (await exists(projectConfig)) &&\n (await this.#maybeLoadConfigFile(projectConfig))\n ) {\n lastKnownRoot = dir\n break\n }\n\n // stat existence of these files\n const [hasPackage, hasModules, hasWorkspaces, hasGit] =\n await Promise.all([\n exists(resolve(dir, 'package.json')),\n exists(resolve(dir, 'node_modules')),\n exists(resolve(dir, 'vlt-workspaces.json')),\n exists(resolve(dir, '.git')),\n ])\n\n // treat these as potential roots\n if (hasPackage || hasModules || hasWorkspaces) {\n lastKnownRoot = dir\n }\n\n // define backstops\n if (hasWorkspaces || hasGit) {\n break\n }\n }\n this.projectRoot = lastKnownRoot\n return this\n }\n\n /**\n * Determine whether we should use colors in the output. Update\n * chalk appropriately.\n *\n * Implicitly calls this.parse() if it not parsed already.\n */\n async loadColor(): Promise<this & LoadedConfig> {\n const c = this.get('color')\n const chalk = (await import('chalk')).default\n let color: boolean\n if (\n process.env.NO_COLOR !== '1' &&\n (c === true || (c === undefined && chalk.level > 0))\n ) {\n color = true\n chalk.level = Math.max(chalk.level, 1) as 0 | 1 | 2 | 3\n process.env.FORCE_COLOR = String(chalk.level)\n delete process.env.NO_COLOR\n } else {\n color = false\n chalk.level = 0\n process.env.FORCE_COLOR = '0'\n process.env.NO_COLOR = '1'\n }\n const { values = this.parse().values } = this\n ;(values as ConfigData & { color: boolean }).color = color\n return this as this & LoadedConfig\n }\n\n /**\n * cache of the loaded config\n */\n static #loaded: LoadedConfig | undefined\n\n /**\n * Load the configuration and return a Promise to a\n * {@link Config} object\n */\n static async load(\n projectRoot = process.cwd(),\n argv = process.argv,\n /**\n * only used in tests, resets the memoization\n * @internal\n */\n reload = false,\n ): Promise<LoadedConfig> {\n if (this.#loaded && !reload) return this.#loaded\n const a = new Config(definition, projectRoot)\n const b = await a.loadConfigFile()\n const c = await b.parse(argv).loadColor()\n this.#loaded = c as LoadedConfig\n return this.#loaded\n }\n}\n\nconst isParsed = (c: Config): c is ParsedConfig =>\n !!(c.values && c.positionals && c.command)\n\nexport type ParsedConfig = Config & {\n command: NonNullable<Config['command']>\n values: OptionsResults<ConfigDefinitions>\n positionals: string[]\n}\n\n/**\n * A fully loaded {@link Config} object\n */\nexport type LoadedConfig = ParsedConfig & {\n get(k: 'color'): boolean\n}\n"]}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,KAAK,EAAY,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAG/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEtC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,KAAK,EAAY,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAG/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAA;AAErC;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,CACnC,IAAI,EAAE,YAAY,KACf,OAAO,CAAC,CAAC,CAAC,CAAA;AAEf,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACvB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;IACrB,KAAK,EAAE,YAAY,CAAA;IACnB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;CAChB,CAAA;AAwBD,QAAA,MAAM,GAAG,qBAsBR,CAAA;AAED,eAAe,GAAG,CAAA"}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAmBnD,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,CACjC,MAAM,CAAC,IAAI,CAAC,QAAQ,EACpB,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAG5C,CAAA;AAED,MAAM,WAAW,GAAG,KAAK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AAG,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC,CAAA;AAED,eAAe,GAAG,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { Jack } from 'jackspeak'\nimport { loadPackageJson } from 'package-json-from-dist'\nimport type { Commands, LoadedConfig } from './config/index.ts'\nimport { Config } from './config/index.ts'\nimport { outputCommand, stdout } from './output.ts'\nimport type { Views } from './view.ts'\n\nexport type CommandUsage = () => Jack\n\n/**\n * A command function that may return a result of `T`.\n * If the result is `undefined`, no final output will be displayed by default.\n */\nexport type CommandFn<T = unknown> = (\n conf: LoadedConfig,\n) => Promise<T>\n\nexport type Command<T> = {\n command: CommandFn<T>\n usage: CommandUsage\n views: Views<T>\n}\n\nconst { version } = loadPackageJson(\n import.meta.filename,\n process.env.__VLT_INTERNAL_CLI_PACKAGE_JSON,\n) as {\n version: string\n}\n\nconst loadCommand = async <T>(\n command: Commands[keyof Commands] | undefined,\n): Promise<Command<T>> => {\n try {\n return (await import(`./commands/${command}.ts`)) as Command<T>\n /* c8 ignore start - should not be possible, just a failsafe */\n } catch (e) {\n throw error('Could not load command', {\n found: command,\n cause: e,\n })\n }\n /* c8 ignore stop */\n}\n\nconst run = async () => {\n const start = Date.now()\n const vlt = await Config.load(process.cwd(), process.argv)\n\n if (vlt.get('version')) {\n return stdout(version)\n }\n\n const cwd = process.cwd()\n const { monorepo } = vlt.options\n\n // Infer the workspace by being in that directory.\n if (vlt.get('workspace') === undefined) {\n const ws = monorepo?.get(cwd)\n if (ws) {\n vlt.values.workspace = [ws.path]\n vlt.options.workspace = [ws.path]\n }\n }\n\n const command = await loadCommand(vlt.command)\n await outputCommand(command, vlt, { start })\n}\n\nexport default run\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/cli-sdk",
|
|
3
3
|
"description": "The source for the vlt CLI",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-8",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
|
-
"directory": "src/
|
|
8
|
+
"directory": "src/cli-sdk"
|
|
9
9
|
},
|
|
10
10
|
"tshy": {
|
|
11
11
|
"selfLink": false,
|
|
@@ -15,51 +15,49 @@
|
|
|
15
15
|
],
|
|
16
16
|
"exports": {
|
|
17
17
|
"./package.json": "./package.json",
|
|
18
|
-
".": "./src/index.ts"
|
|
18
|
+
".": "./src/index.ts",
|
|
19
|
+
"./config": "./src/config/index.ts",
|
|
20
|
+
"./definition": "./src/config/definition.ts",
|
|
21
|
+
"./view": "./src/view.ts"
|
|
19
22
|
}
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"ansi-to-pre": "^1.0.5",
|
|
23
26
|
"chalk": "^5.3.0",
|
|
24
|
-
"ink": "^5.
|
|
27
|
+
"ink": "^5.2.0",
|
|
25
28
|
"ink-spinner": "^5.0.0",
|
|
26
29
|
"jackspeak": "^4.0.3",
|
|
27
30
|
"package-json-from-dist": "^1.0.0",
|
|
28
31
|
"path-scurry": "^2.0.0",
|
|
29
32
|
"polite-json": "^5.0.0",
|
|
30
|
-
"promise-call-limit": "^3.0.2",
|
|
31
33
|
"react": "^18.3.1",
|
|
32
34
|
"react-devtools-core": "^4.28.5",
|
|
33
|
-
"serve-handler": "^6.1.5",
|
|
34
35
|
"walk-up-path": "^4.0.0",
|
|
35
|
-
"@vltpkg/
|
|
36
|
-
"@vltpkg/
|
|
37
|
-
"@vltpkg/error-cause": "0.0.0-
|
|
38
|
-
"@vltpkg/
|
|
39
|
-
"@vltpkg/
|
|
40
|
-
"@vltpkg/
|
|
41
|
-
"@vltpkg/
|
|
42
|
-
"@vltpkg/
|
|
43
|
-
"@vltpkg/
|
|
44
|
-
"@vltpkg/
|
|
45
|
-
"@vltpkg/
|
|
46
|
-
"@vltpkg/
|
|
47
|
-
"@vltpkg/
|
|
48
|
-
"@vltpkg/
|
|
49
|
-
"@vltpkg/
|
|
50
|
-
"@vltpkg/
|
|
51
|
-
"@vltpkg/
|
|
52
|
-
"@vltpkg/
|
|
53
|
-
"@vltpkg/
|
|
54
|
-
"@vltpkg/xdg": "0.0.0-6",
|
|
55
|
-
"@vltpkg/workspaces": "0.0.0-6"
|
|
36
|
+
"@vltpkg/dep-id": "0.0.0-8",
|
|
37
|
+
"@vltpkg/dot-prop": "0.0.0-8",
|
|
38
|
+
"@vltpkg/error-cause": "0.0.0-8",
|
|
39
|
+
"@vltpkg/init": "0.0.0-8",
|
|
40
|
+
"@vltpkg/output": "0.0.0-8",
|
|
41
|
+
"@vltpkg/package-info": "0.0.0-8",
|
|
42
|
+
"@vltpkg/graph": "0.0.0-8",
|
|
43
|
+
"@vltpkg/package-json": "0.0.0-8",
|
|
44
|
+
"@vltpkg/query": "0.0.0-8",
|
|
45
|
+
"@vltpkg/promise-spawn": "0.0.0-8",
|
|
46
|
+
"@vltpkg/registry-client": "0.0.0-8",
|
|
47
|
+
"@vltpkg/run": "0.0.0-8",
|
|
48
|
+
"@vltpkg/security-archive": "0.0.0-8",
|
|
49
|
+
"@vltpkg/spec": "0.0.0-8",
|
|
50
|
+
"@vltpkg/server": "0.0.0-8",
|
|
51
|
+
"@vltpkg/types": "0.0.0-8",
|
|
52
|
+
"@vltpkg/url-open": "0.0.0-8",
|
|
53
|
+
"@vltpkg/workspaces": "0.0.0-8",
|
|
54
|
+
"@vltpkg/xdg": "0.0.0-8"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@eslint/js": "^9.20.0",
|
|
59
58
|
"@types/eslint__js": "^8.42.3",
|
|
60
59
|
"@types/node": "^22.13.1",
|
|
61
60
|
"@types/react": "^18.3.18",
|
|
62
|
-
"@types/serve-handler": "^6.1.4",
|
|
63
61
|
"eslint": "^9.20.0",
|
|
64
62
|
"prettier": "^3.4.2",
|
|
65
63
|
"tap": "^21.1.0",
|
|
@@ -85,6 +83,24 @@
|
|
|
85
83
|
"types": "./dist/esm/index.d.ts",
|
|
86
84
|
"default": "./dist/esm/index.js"
|
|
87
85
|
}
|
|
86
|
+
},
|
|
87
|
+
"./config": {
|
|
88
|
+
"import": {
|
|
89
|
+
"types": "./dist/esm/config/index.d.ts",
|
|
90
|
+
"default": "./dist/esm/config/index.js"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"./definition": {
|
|
94
|
+
"import": {
|
|
95
|
+
"types": "./dist/esm/config/definition.d.ts",
|
|
96
|
+
"default": "./dist/esm/config/definition.js"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"./view": {
|
|
100
|
+
"import": {
|
|
101
|
+
"types": "./dist/esm/view.d.ts",
|
|
102
|
+
"default": "./dist/esm/view.js"
|
|
103
|
+
}
|
|
88
104
|
}
|
|
89
105
|
},
|
|
90
106
|
"files": [
|