@vltpkg/cli-sdk 1.0.0-rc.14 → 1.0.0-rc.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/list.d.ts +0 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +3 -8
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/query.d.ts +0 -1
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +3 -8
- package/dist/commands/query.js.map +1 -1
- package/dist/config/definition.d.ts +1 -13
- package/dist/config/definition.d.ts.map +1 -1
- package/dist/config/definition.js +0 -14
- package/dist/config/definition.js.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +31 -1
- package/dist/config/index.js.map +1 -1
- package/dist/custom-help.d.ts.map +1 -1
- package/dist/custom-help.js +0 -8
- package/dist/custom-help.js.map +1 -1
- package/package.json +26 -26
- package/dist/commands/serve.d.ts +0 -14
- package/dist/commands/serve.d.ts.map +0 -1
- package/dist/commands/serve.js +0 -103
- package/dist/commands/serve.js.map +0 -1
- package/dist/start-gui.d.ts +0 -10
- package/dist/start-gui.d.ts.map +0 -1
- package/dist/start-gui.js +0 -60
- package/dist/start-gui.js.map +0 -1
package/dist/commands/list.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export declare const views: {
|
|
|
9
9
|
readonly json: typeof jsonOutput;
|
|
10
10
|
readonly mermaid: typeof mermaidOutput;
|
|
11
11
|
readonly human: typeof humanReadableOutput;
|
|
12
|
-
readonly gui: ({ queryString }: ListResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").ParsedConfig) => Promise<void>;
|
|
13
12
|
};
|
|
14
13
|
export declare const command: CommandFn<ListResult>;
|
|
15
14
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,aAAa,EAEd,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,aAAa,EAEd,MAAM,eAAe,CAAA;AAMtB,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAGnB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,eAAO,MAAM,KAAK,EAAE,YAyDhB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;CAIoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CA+JzC,CAAA"}
|
package/dist/commands/list.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { actual, asNode, humanReadableOutput, jsonOutput, mermaidOutput, GraphModifier, } from '@vltpkg/graph';
|
|
2
|
-
import LZString from 'lz-string';
|
|
3
2
|
import { Query } from '@vltpkg/query';
|
|
4
3
|
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
5
4
|
import { error } from '@vltpkg/error-cause';
|
|
6
5
|
import { commandUsage } from "../config/usage.js";
|
|
7
|
-
import { startGUI } from "../start-gui.js";
|
|
8
6
|
import { createHostContextsMap } from "../query-host-contexts.js";
|
|
9
7
|
export const usage = () => commandUsage({
|
|
10
8
|
command: 'ls',
|
|
11
9
|
usage: [
|
|
12
10
|
'',
|
|
13
|
-
'[package-names...] [--view=human | json | mermaid
|
|
14
|
-
'[--scope=<query>] [--target=<query>] [--view=human | json | mermaid
|
|
11
|
+
'[package-names...] [--view=human | json | mermaid]',
|
|
12
|
+
'[--scope=<query>] [--target=<query>] [--view=human | json | mermaid]',
|
|
15
13
|
],
|
|
16
14
|
description: `List installed dependencies matching given package names or query selectors.
|
|
17
15
|
|
|
@@ -53,7 +51,7 @@ export const usage = () => commandUsage({
|
|
|
53
51
|
description: 'Query selector to filter packages using the DSS query language syntax.',
|
|
54
52
|
},
|
|
55
53
|
view: {
|
|
56
|
-
value: '[human | json | mermaid
|
|
54
|
+
value: '[human | json | mermaid]',
|
|
57
55
|
description: 'Output format. Defaults to human-readable or json if no tty.',
|
|
58
56
|
},
|
|
59
57
|
},
|
|
@@ -62,9 +60,6 @@ export const views = {
|
|
|
62
60
|
json: jsonOutput,
|
|
63
61
|
mermaid: mermaidOutput,
|
|
64
62
|
human: humanReadableOutput,
|
|
65
|
-
gui: async ({ queryString }, _, conf) => {
|
|
66
|
-
await startGUI(conf, `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`);
|
|
67
|
-
},
|
|
68
63
|
};
|
|
69
64
|
export const command = async (conf) => {
|
|
70
65
|
const modifiers = GraphModifier.maybeLoad(conf.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAajE,MAAM,CAAC,MAAM,KAAK,G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QAC/B,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC;QAClB,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,UAAU;QACrB,eAAe;QACf,YAAY;KACb,CAAC,CAAA;IACF,MAAM,KAAK,GACT,WAAW;QACX,oBAAoB;QACpB,CAAC,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAA;IACpE,MAAM,EACJ,KAAK,EACL,KAAK,EACL,SAAS,EAAE,oBAAoB,GAChC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACxB,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KACrD,CAAC,CAAA;IAEF,OAAO;QACL,SAAS,EACP,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACpB,IAAI,GAAG,CAAC,oBAAoB,CAAC;YAC/B,CAAC,CAAC,SAAS;QACb,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,CACpB,iBAAiB,IAAI,qBAAqB,CAC3C;QACD,WAAW,EACT,WAAW;YACX,CAAC,KAAK,CAAC,CAAC;gBACN,sBAAsB;gBACtB,yBAAyB;gBAC3B,CAAC,CAAC,4BAA4B,CAAC;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n actual,\n asNode,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n GraphModifier,\n} from '@vltpkg/graph'\nimport LZString from 'lz-string'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport { startGUI } from '../start-gui.ts'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n Graph,\n} from '@vltpkg/graph'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { NodeLike } from '@vltpkg/types'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ls',\n usage: [\n '',\n '[package-names...] [--view=human | json | mermaid | gui]',\n '[--scope=<query>] [--target=<query>] [--view=human | json | mermaid | gui]',\n ],\n description: `List installed dependencies matching given package names or query selectors.\n\n Package names provided as positional arguments will be used to filter\n the results to show only dependencies with those names.\n\n The --scope and --target options accepts DSS query selectors to filter\n packages. Using --scope, you can specify which packages to treat as the\n top-level items in the output graph. The --target option allows you to\n filter what dependencies to include in the output. Using both options\n allows you to render subgraphs of the dependency graph.\n\n Defaults to listing direct dependencies of a project and any configured\n workspace.`,\n examples: {\n '': {\n description:\n 'List direct dependencies of the current project / workspace',\n },\n 'foo bar baz': {\n description: `List all dependencies named 'foo', 'bar', or 'baz'`,\n },\n '--scope=\":root > #dependency-name\"': {\n description:\n 'Defines a direct dependency as the output top-level scope',\n },\n '--target=\"*\"': {\n description: 'List all dependencies using a query selector',\n },\n '--target=\":workspace > *:peer\"': {\n description: 'List all peer dependencies of all workspaces',\n },\n },\n options: {\n scope: {\n value: '<query>',\n description:\n 'Query selector to select top-level packages using the DSS query language syntax.',\n },\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using the DSS query language syntax.',\n },\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/${LZString.compressToEncodedURIComponent(queryString)}/overview`,\n )\n },\n} as const satisfies Views<ListResult>\n\nexport const command: CommandFn<ListResult> = async conf => {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.maybeRead(\n conf.options.projectRoot,\n )\n let graph: Graph | undefined\n let securityArchive: SecurityArchive | undefined\n\n // optionally load the cwd graph if we found a package.json file\n if (mainManifest) {\n graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: true,\n })\n securityArchive = await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n }\n\n // Validate positional arguments - only allow package names, not direct queries\n for (const arg of conf.positionals) {\n if (!/^[@\\w-]/.test(arg)) {\n throw error(\n `Direct queries are not supported as positional arguments. Use package names only.`,\n {\n code: 'EUSAGE',\n cause: `Argument '${arg}' appears to be a query syntax. Only package names are allowed as positional arguments.`,\n },\n )\n }\n }\n\n // retrieve default values and set up host contexts\n const positionalQueryString = conf.positionals\n .map(k => `#${k.replace(/\\//, '\\\\/')}`)\n .join(', ')\n const targetQueryString = conf.get('target')\n const scopeQueryString = conf.get('scope')\n const queryString = targetQueryString || positionalQueryString\n const projectQueryString = ':workspace, :project > *'\n const selectImporters: string[] = []\n const hostContexts = await createHostContextsMap(conf)\n const importers = new Set<Node>()\n const scopeIDs: DepID[] = []\n\n // handle --scope option to add scope nodes as importers\n let scopeNodes\n if (scopeQueryString) {\n // run scope query to get all matching nodes\n /* c8 ignore start */\n const edges = graph?.edges ?? new Set()\n const nodes =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers = graph?.importers ?? new Set()\n /* c8 ignore stop */\n const scopeQuery = new Query({\n nodes,\n edges,\n importers,\n securityArchive,\n hostContexts,\n })\n const { nodes: resultNodes } = await scopeQuery.search(\n scopeQueryString,\n {\n signal: new AbortController().signal,\n },\n )\n scopeNodes = resultNodes\n }\n\n if (scopeQueryString && scopeNodes) {\n // Add all scope nodes to importers Set (treat them as top-level items)\n for (const queryNode of scopeNodes) {\n importers.add(asNode(queryNode))\n }\n } else if ('workspace' in conf.values) {\n // if in a workspace environment, select only the specified\n // workspaces as top-level items\n if (monorepo && graph) {\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 scopeIDs.push(workspace.id)\n }\n }\n }\n }\n\n // build a default query string to use in the target search\n const selectImportersQueryString = selectImporters.join(', ')\n const defaultProjectQueryString =\n (\n graph &&\n selectImporters.length &&\n selectImporters.length < graph.importers.size\n ) ?\n selectImportersQueryString\n : projectQueryString\n const defaultLocalScopeQueryString = ':host(local) :root > *'\n\n // retrieve the selected nodes and edges\n /* c8 ignore start */\n const edges_ = graph?.edges ?? new Set()\n const nodes_ =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers_ =\n importers.size === 0 && graph ?\n new Set([graph.mainImporter])\n : importers\n /* c8 ignore stop */\n const q = new Query({\n nodes: nodes_,\n edges: edges_,\n importers: importers_,\n securityArchive,\n hostContexts,\n })\n const query =\n queryString ||\n /* c8 ignore next */\n (graph ? defaultProjectQueryString : defaultLocalScopeQueryString)\n const {\n edges,\n nodes,\n importers: queryResultImporters,\n } = await q.search(query, {\n signal: new AbortController().signal,\n scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,\n })\n\n return {\n importers:\n importers.size === 0 ?\n new Set(queryResultImporters)\n : importers,\n edges,\n nodes,\n highlightSelection: !!(\n targetQueryString || positionalQueryString\n ),\n queryString:\n queryString ||\n (graph ?\n /* c8 ignore next 2 */\n defaultProjectQueryString\n : defaultLocalScopeQueryString),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAA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GAAG,EAAY,CAAA;IACvB,MAAM,UAAU,GACd,SAAS,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;QAC7B,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC;QAClB,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,UAAU;QACrB,eAAe;QACf,YAAY;KACb,CAAC,CAAA;IACF,MAAM,KAAK,GACT,WAAW;QACX,oBAAoB;QACpB,CAAC,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAA;IACpE,MAAM,EACJ,KAAK,EACL,KAAK,EACL,SAAS,EAAE,oBAAoB,GAChC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACxB,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KACrD,CAAC,CAAA;IAEF,OAAO;QACL,SAAS,EACP,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACpB,IAAI,GAAG,CAAC,oBAAoB,CAAC;YAC/B,CAAC,CAAC,SAAS;QACb,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,CACpB,iBAAiB,IAAI,qBAAqB,CAC3C;QACD,WAAW,EACT,WAAW;YACX,CAAC,KAAK,CAAC,CAAC;gBACN,sBAAsB;gBACtB,yBAAyB;gBAC3B,CAAC,CAAC,4BAA4B,CAAC;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n actual,\n asNode,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n GraphModifier,\n} from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n Graph,\n} from '@vltpkg/graph'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { NodeLike } from '@vltpkg/types'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ls',\n usage: [\n '',\n '[package-names...] [--view=human | json | mermaid]',\n '[--scope=<query>] [--target=<query>] [--view=human | json | mermaid]',\n ],\n description: `List installed dependencies matching given package names or query selectors.\n\n Package names provided as positional arguments will be used to filter\n the results to show only dependencies with those names.\n\n The --scope and --target options accepts DSS query selectors to filter\n packages. Using --scope, you can specify which packages to treat as the\n top-level items in the output graph. The --target option allows you to\n filter what dependencies to include in the output. Using both options\n allows you to render subgraphs of the dependency graph.\n\n Defaults to listing direct dependencies of a project and any configured\n workspace.`,\n examples: {\n '': {\n description:\n 'List direct dependencies of the current project / workspace',\n },\n 'foo bar baz': {\n description: `List all dependencies named 'foo', 'bar', or 'baz'`,\n },\n '--scope=\":root > #dependency-name\"': {\n description:\n 'Defines a direct dependency as the output top-level scope',\n },\n '--target=\"*\"': {\n description: 'List all dependencies using a query selector',\n },\n '--target=\":workspace > *:peer\"': {\n description: 'List all peer dependencies of all workspaces',\n },\n },\n options: {\n scope: {\n value: '<query>',\n description:\n 'Query selector to select top-level packages using the DSS query language syntax.',\n },\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using the DSS query language syntax.',\n },\n view: {\n value: '[human | json | mermaid]',\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} as const satisfies Views<ListResult>\n\nexport const command: CommandFn<ListResult> = async conf => {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.maybeRead(\n conf.options.projectRoot,\n )\n let graph: Graph | undefined\n let securityArchive: SecurityArchive | undefined\n\n // optionally load the cwd graph if we found a package.json file\n if (mainManifest) {\n graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: true,\n })\n securityArchive = await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n }\n\n // Validate positional arguments - only allow package names, not direct queries\n for (const arg of conf.positionals) {\n if (!/^[@\\w-]/.test(arg)) {\n throw error(\n `Direct queries are not supported as positional arguments. Use package names only.`,\n {\n code: 'EUSAGE',\n cause: `Argument '${arg}' appears to be a query syntax. Only package names are allowed as positional arguments.`,\n },\n )\n }\n }\n\n // retrieve default values and set up host contexts\n const positionalQueryString = conf.positionals\n .map(k => `#${k.replace(/\\//, '\\\\/')}`)\n .join(', ')\n const targetQueryString = conf.get('target')\n const scopeQueryString = conf.get('scope')\n const queryString = targetQueryString || positionalQueryString\n const projectQueryString = ':workspace, :project > *'\n const selectImporters: string[] = []\n const hostContexts = await createHostContextsMap(conf)\n const importers = new Set<Node>()\n const scopeIDs: DepID[] = []\n\n // handle --scope option to add scope nodes as importers\n let scopeNodes\n if (scopeQueryString) {\n // run scope query to get all matching nodes\n /* c8 ignore start */\n const edges = graph?.edges ?? new Set()\n const nodes =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers = graph?.importers ?? new Set()\n /* c8 ignore stop */\n const scopeQuery = new Query({\n nodes,\n edges,\n importers,\n securityArchive,\n hostContexts,\n })\n const { nodes: resultNodes } = await scopeQuery.search(\n scopeQueryString,\n {\n signal: new AbortController().signal,\n },\n )\n scopeNodes = resultNodes\n }\n\n if (scopeQueryString && scopeNodes) {\n // Add all scope nodes to importers Set (treat them as top-level items)\n for (const queryNode of scopeNodes) {\n importers.add(asNode(queryNode))\n }\n } else if ('workspace' in conf.values) {\n // if in a workspace environment, select only the specified\n // workspaces as top-level items\n if (monorepo && graph) {\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 scopeIDs.push(workspace.id)\n }\n }\n }\n }\n\n // build a default query string to use in the target search\n const selectImportersQueryString = selectImporters.join(', ')\n const defaultProjectQueryString =\n (\n graph &&\n selectImporters.length &&\n selectImporters.length < graph.importers.size\n ) ?\n selectImportersQueryString\n : projectQueryString\n const defaultLocalScopeQueryString = ':host(local) :root > *'\n\n // retrieve the selected nodes and edges\n /* c8 ignore start */\n const edges_ = graph?.edges ?? new Set()\n const nodes_ =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers_ =\n importers.size === 0 && graph ?\n new Set([graph.mainImporter])\n : importers\n /* c8 ignore stop */\n const q = new Query({\n nodes: nodes_,\n edges: edges_,\n importers: importers_,\n securityArchive,\n hostContexts,\n })\n const query =\n queryString ||\n /* c8 ignore next */\n (graph ? defaultProjectQueryString : defaultLocalScopeQueryString)\n const {\n edges,\n nodes,\n importers: queryResultImporters,\n } = await q.search(query, {\n signal: new AbortController().signal,\n scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,\n })\n\n return {\n importers:\n importers.size === 0 ?\n new Set(queryResultImporters)\n : importers,\n edges,\n nodes,\n highlightSelection: !!(\n targetQueryString || positionalQueryString\n ),\n queryString:\n queryString ||\n (graph ?\n /* c8 ignore next 2 */\n defaultProjectQueryString\n : defaultLocalScopeQueryString),\n }\n}\n"]}
|
package/dist/commands/query.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export declare const views: {
|
|
|
9
9
|
readonly json: typeof jsonOutput;
|
|
10
10
|
readonly mermaid: typeof mermaidOutput;
|
|
11
11
|
readonly human: typeof humanReadableOutput;
|
|
12
|
-
readonly gui: ({ queryString }: QueryResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.ts").ParsedConfig) => Promise<void>;
|
|
13
12
|
};
|
|
14
13
|
export declare const command: CommandFn<QueryResult>;
|
|
15
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,aAAa,EAEd,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,UAAU,EACV,aAAa,EAEd,MAAM,eAAe,CAAA;AAMtB,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAGnB,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YA4EhB,CAAA;AAEJ,KAAK,WAAW,GAAG,eAAe,GAChC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAqBpD,eAAO,MAAM,KAAK;;;;CAIqB,CAAA;AAEvC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAqI1C,CAAA"}
|
package/dist/commands/query.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { actual, asNode, humanReadableOutput, jsonOutput, mermaidOutput, GraphModifier, } from '@vltpkg/graph';
|
|
2
2
|
import { error } from '@vltpkg/error-cause';
|
|
3
|
-
import LZString from 'lz-string';
|
|
4
3
|
import { Query } from '@vltpkg/query';
|
|
5
4
|
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
6
|
-
import { startGUI } from "../start-gui.js";
|
|
7
5
|
import { commandUsage } from "../config/usage.js";
|
|
8
6
|
import { createHostContextsMap } from "../query-host-contexts.js";
|
|
9
7
|
export const usage = () => commandUsage({
|
|
10
8
|
command: 'query',
|
|
11
9
|
usage: [
|
|
12
10
|
'',
|
|
13
|
-
'<query> --view=<human | json | mermaid
|
|
11
|
+
'<query> --view=<human | json | mermaid>',
|
|
14
12
|
'<query> --expect-results=<comparison string>',
|
|
15
|
-
'--target=<query> --view=<human | json | mermaid
|
|
13
|
+
'--target=<query> --view=<human | json | mermaid>',
|
|
16
14
|
],
|
|
17
15
|
description: `List installed dependencies matching the provided query.
|
|
18
16
|
|
|
@@ -68,7 +66,7 @@ export const usage = () => commandUsage({
|
|
|
68
66
|
description: 'Query selector to filter packages using DSS syntax.',
|
|
69
67
|
},
|
|
70
68
|
view: {
|
|
71
|
-
value: '[human | json | mermaid
|
|
69
|
+
value: '[human | json | mermaid]',
|
|
72
70
|
description: 'Output format. Defaults to human-readable or json if no tty.',
|
|
73
71
|
},
|
|
74
72
|
},
|
|
@@ -96,9 +94,6 @@ export const views = {
|
|
|
96
94
|
json: jsonOutput,
|
|
97
95
|
mermaid: mermaidOutput,
|
|
98
96
|
human: humanReadableOutput,
|
|
99
|
-
gui: async ({ queryString }, _, conf) => {
|
|
100
|
-
await startGUI(conf, `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`);
|
|
101
|
-
},
|
|
102
97
|
};
|
|
103
98
|
export const command = async (conf) => {
|
|
104
99
|
const modifiers = GraphModifier.maybeLoad(conf.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;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AAK,EACL,SAAS,EAAE,oBAAoB,GAChC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACxB,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KACrD,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC,4BAA4B,EAAE;YACxC,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EACP,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACpB,IAAI,GAAG,CAAC,oBAAoB,CAAC;YAC/B,CAAC,CAAC,SAAS;QACb,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,CACpB,iBAAiB,IAAI,qBAAqB,CAC3C;QACD,WAAW,EACT,WAAW;YACX,CAAC,KAAK,CAAC,CAAC;gBACN,yBAAyB;gBAC3B,CAAC,CAAC,4BAA4B,CAAC;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n actual,\n asNode,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n GraphModifier,\n} from '@vltpkg/graph'\nimport { error } from '@vltpkg/error-cause'\nimport LZString from 'lz-string'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { startGUI } from '../start-gui.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n Graph,\n} from '@vltpkg/graph'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { EdgeLike, NodeLike } from '@vltpkg/types'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { LoadedConfig } from '../config/index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'query',\n usage: [\n '',\n '<query> --view=<human | json | mermaid | gui>',\n '<query> --expect-results=<comparison string>',\n '--target=<query> --view=<human | json | mermaid | gui>',\n ],\n description: `List installed dependencies matching the provided query.\n\n The vlt Dependency Selector Syntax is a CSS-like query language that\n allows you to filter installed dependencies using a variety of metadata\n in the form of CSS-like attributes, pseudo selectors & combinators.\n\n The --scope and --target options accepts DSS query selectors to filter\n packages. Using --scope, you can specify which packages to treat as the\n top-level items in the output graph. The --target option can be used as\n an alternative to positional arguments, it allows you to filter what\n dependencies to include in the output. Using both options allows you to\n render subgraphs of the dependency graph.\n\n Defaults to listing all dependencies of the project root and workspaces.`,\n\n examples: {\n [`'#foo'`]: {\n description: 'Query dependencies declared as \"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 [`'*:license(copyleft) --expect-results=0'`]: {\n description: 'Errors if a copyleft licensed package is found',\n },\n '--scope=\":root > #dependency-name\"': {\n description:\n 'Defines a direct dependency as the output top-level scope',\n },\n [`'--target=\"*\"'`]: {\n description: 'Query all dependencies using the target option',\n },\n [`'--target=\":workspace > *:peer\"'`]: {\n description:\n 'Query all peer dependencies of workspaces using target option',\n },\n },\n options: {\n 'expect-results': {\n value: '[number | string]',\n description:\n 'Sets an expected number of resulting items. Errors if the number of resulting items does not match the set value. Accepts a specific numeric value or a string value starting with either \">\", \"<\", \">=\" or \"<=\" followed by a numeric value to be compared.',\n },\n scope: {\n value: '<query>',\n description:\n 'Query selector to select top-level packages using the DSS query language syntax.',\n },\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using DSS syntax.',\n },\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\nconst validateExpectedResult = (\n conf: LoadedConfig,\n edges: EdgeLike[],\n): boolean => {\n const expectResults = conf.values['expect-results']\n if (expectResults?.startsWith('>=')) {\n return edges.length >= parseInt(expectResults.slice(2).trim(), 10)\n } else if (expectResults?.startsWith('<=')) {\n return edges.length <= parseInt(expectResults.slice(2).trim(), 10)\n } else if (expectResults?.startsWith('>')) {\n return edges.length > parseInt(expectResults.slice(1).trim(), 10)\n } else if (expectResults?.startsWith('<')) {\n return edges.length < parseInt(expectResults.slice(1).trim(), 10)\n } else if (expectResults) {\n return edges.length === parseInt(expectResults.trim(), 10)\n }\n return true\n}\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/${LZString.compressToEncodedURIComponent(queryString)}/overview`,\n )\n },\n} as const satisfies Views<QueryResult>\n\nexport const command: CommandFn<QueryResult> = async conf => {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.maybeRead(\n conf.options.projectRoot,\n )\n let graph: Graph | undefined\n let securityArchive: SecurityArchive | undefined\n\n // optionally load the cwd graph if we found a package.json file\n if (mainManifest) {\n graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: true,\n })\n securityArchive = await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n }\n\n // retrieve default values and set up host contexts\n const defaultProjectQueryString = '*'\n const defaultLocalScopeQueryString = ':host(local) *'\n const positionalQueryString = conf.positionals[0]\n const targetQueryString = conf.get('target')\n const scopeQueryString = conf.get('scope')\n const queryString = targetQueryString || positionalQueryString\n const hostContexts = await createHostContextsMap(conf)\n const importers = new Set<Node>()\n const scopeIDs: DepID[] = []\n\n // Handle --scope option to add scope nodes as importers\n let scopeNodes\n if (scopeQueryString) {\n // Run scope query to get all matching nodes\n /* c8 ignore start */\n const edges = graph?.edges ?? new Set()\n const nodes =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers = graph?.importers ?? new Set()\n /* c8 ignore stop */\n const scopeQuery = new Query({\n edges,\n nodes,\n importers,\n securityArchive,\n hostContexts,\n })\n const { nodes: resultNodes } = await scopeQuery.search(\n scopeQueryString,\n {\n signal: new AbortController().signal,\n },\n )\n scopeNodes = resultNodes\n }\n\n if (scopeQueryString && scopeNodes) {\n // Add all scope nodes to importers Set (treat them as top-level items)\n for (const queryNode of scopeNodes) {\n importers.add(asNode(queryNode))\n }\n } else if ('workspace' in conf.values) {\n // if in a workspace environment, select only the specified\n // workspaces as top-level items\n if (monorepo && graph) {\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 scopeIDs.push(workspace.id)\n }\n }\n }\n }\n\n // retrieve the selected nodes and edges\n const edges_ = graph?.edges ?? new Set()\n const nodes_ =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers_ =\n importers.size === 0 && graph ?\n new Set([graph.mainImporter])\n : importers\n const q = new Query({\n edges: edges_,\n nodes: nodes_,\n importers: importers_,\n securityArchive,\n hostContexts,\n })\n const query =\n queryString ||\n (graph ? defaultProjectQueryString : defaultLocalScopeQueryString)\n const {\n edges,\n nodes,\n importers: queryResultImporters,\n } = await q.search(query, {\n signal: new AbortController().signal,\n scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,\n })\n\n if (!validateExpectedResult(conf, edges)) {\n throw error('Unexpected number of items', {\n found: edges.length,\n wanted: conf.values['expect-results'],\n })\n }\n\n return {\n importers:\n importers.size === 0 ?\n new Set(queryResultImporters)\n : importers,\n edges,\n nodes,\n highlightSelection: !!(\n targetQueryString || positionalQueryString\n ),\n queryString:\n queryString ||\n (graph ?\n defaultProjectQueryString\n : defaultLocalScopeQueryString),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAcjE,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE;QACL,EAAE;QACF,yCAAyC;QACzC,8CAA8C;QAC9C,kDAAkD;KACnD;IACD,WAAW,EAAE;;;;;;;;;;;;;+EAa8D;IAE3E,QAAQ,EAAE;QACR,CAAC,QAAQ,CAAC,EAAE;YACV,WAAW,EAAE,sCAAsC;SACpD;QACD,CAAC,wBAAwB,CAAC,EAAE;YAC1B,WAAW,EAAE,2CAA2C;SACzD;QACD,CAAC,uCAAuC,CAAC,EAAE;YACzC,WAAW,EACT,6DAA6D;SAChE;QACD,CAAC,qBAAqB,CAAC,EAAE;YACvB,WAAW,EACT,mDAAmD;SACtD;QACD,CAAC,0CAA0C,CAAC,EAAE;YAC5C,WAAW,EAAE,gDAAgD;SAC9D;QACD,oCAAoC,EAAE;YACpC,WAAW,EACT,2DAA2D;SAC9D;QACD,CAAC,gBAAgB,CAAC,EAAE;YAClB,WA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K,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAA;IACpE,MAAM,EACJ,KAAK,EACL,KAAK,EACL,SAAS,EAAE,oBAAoB,GAChC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACxB,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KACrD,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC,4BAA4B,EAAE;YACxC,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EACP,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACpB,IAAI,GAAG,CAAC,oBAAoB,CAAC;YAC/B,CAAC,CAAC,SAAS;QACb,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,CACpB,iBAAiB,IAAI,qBAAqB,CAC3C;QACD,WAAW,EACT,WAAW;YACX,CAAC,KAAK,CAAC,CAAC;gBACN,yBAAyB;gBAC3B,CAAC,CAAC,4BAA4B,CAAC;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n actual,\n asNode,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n GraphModifier,\n} from '@vltpkg/graph'\nimport { error } from '@vltpkg/error-cause'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { commandUsage } from '../config/usage.ts'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n Graph,\n} from '@vltpkg/graph'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { EdgeLike, NodeLike } from '@vltpkg/types'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { LoadedConfig } from '../config/index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'query',\n usage: [\n '',\n '<query> --view=<human | json | mermaid>',\n '<query> --expect-results=<comparison string>',\n '--target=<query> --view=<human | json | mermaid>',\n ],\n description: `List installed dependencies matching the provided query.\n\n The vlt Dependency Selector Syntax is a CSS-like query language that\n allows you to filter installed dependencies using a variety of metadata\n in the form of CSS-like attributes, pseudo selectors & combinators.\n\n The --scope and --target options accepts DSS query selectors to filter\n packages. Using --scope, you can specify which packages to treat as the\n top-level items in the output graph. The --target option can be used as\n an alternative to positional arguments, it allows you to filter what\n dependencies to include in the output. Using both options allows you to\n render subgraphs of the dependency graph.\n\n Defaults to listing all dependencies of the project root and workspaces.`,\n\n examples: {\n [`'#foo'`]: {\n description: 'Query dependencies declared as \"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 [`'*:license(copyleft) --expect-results=0'`]: {\n description: 'Errors if a copyleft licensed package is found',\n },\n '--scope=\":root > #dependency-name\"': {\n description:\n 'Defines a direct dependency as the output top-level scope',\n },\n [`'--target=\"*\"'`]: {\n description: 'Query all dependencies using the target option',\n },\n [`'--target=\":workspace > *:peer\"'`]: {\n description:\n 'Query all peer dependencies of workspaces using target option',\n },\n },\n options: {\n 'expect-results': {\n value: '[number | string]',\n description:\n 'Sets an expected number of resulting items. Errors if the number of resulting items does not match the set value. Accepts a specific numeric value or a string value starting with either \">\", \"<\", \">=\" or \"<=\" followed by a numeric value to be compared.',\n },\n scope: {\n value: '<query>',\n description:\n 'Query selector to select top-level packages using the DSS query language syntax.',\n },\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using DSS syntax.',\n },\n view: {\n value: '[human | json | mermaid]',\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\nconst validateExpectedResult = (\n conf: LoadedConfig,\n edges: EdgeLike[],\n): boolean => {\n const expectResults = conf.values['expect-results']\n if (expectResults?.startsWith('>=')) {\n return edges.length >= parseInt(expectResults.slice(2).trim(), 10)\n } else if (expectResults?.startsWith('<=')) {\n return edges.length <= parseInt(expectResults.slice(2).trim(), 10)\n } else if (expectResults?.startsWith('>')) {\n return edges.length > parseInt(expectResults.slice(1).trim(), 10)\n } else if (expectResults?.startsWith('<')) {\n return edges.length < parseInt(expectResults.slice(1).trim(), 10)\n } else if (expectResults) {\n return edges.length === parseInt(expectResults.trim(), 10)\n }\n return true\n}\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n} as const satisfies Views<QueryResult>\n\nexport const command: CommandFn<QueryResult> = async conf => {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.maybeRead(\n conf.options.projectRoot,\n )\n let graph: Graph | undefined\n let securityArchive: SecurityArchive | undefined\n\n // optionally load the cwd graph if we found a package.json file\n if (mainManifest) {\n graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: true,\n })\n securityArchive = await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n }\n\n // retrieve default values and set up host contexts\n const defaultProjectQueryString = '*'\n const defaultLocalScopeQueryString = ':host(local) *'\n const positionalQueryString = conf.positionals[0]\n const targetQueryString = conf.get('target')\n const scopeQueryString = conf.get('scope')\n const queryString = targetQueryString || positionalQueryString\n const hostContexts = await createHostContextsMap(conf)\n const importers = new Set<Node>()\n const scopeIDs: DepID[] = []\n\n // Handle --scope option to add scope nodes as importers\n let scopeNodes\n if (scopeQueryString) {\n // Run scope query to get all matching nodes\n /* c8 ignore start */\n const edges = graph?.edges ?? new Set()\n const nodes =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers = graph?.importers ?? new Set()\n /* c8 ignore stop */\n const scopeQuery = new Query({\n edges,\n nodes,\n importers,\n securityArchive,\n hostContexts,\n })\n const { nodes: resultNodes } = await scopeQuery.search(\n scopeQueryString,\n {\n signal: new AbortController().signal,\n },\n )\n scopeNodes = resultNodes\n }\n\n if (scopeQueryString && scopeNodes) {\n // Add all scope nodes to importers Set (treat them as top-level items)\n for (const queryNode of scopeNodes) {\n importers.add(asNode(queryNode))\n }\n } else if ('workspace' in conf.values) {\n // if in a workspace environment, select only the specified\n // workspaces as top-level items\n if (monorepo && graph) {\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 scopeIDs.push(workspace.id)\n }\n }\n }\n }\n\n // retrieve the selected nodes and edges\n const edges_ = graph?.edges ?? new Set()\n const nodes_ =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers_ =\n importers.size === 0 && graph ?\n new Set([graph.mainImporter])\n : importers\n const q = new Query({\n edges: edges_,\n nodes: nodes_,\n importers: importers_,\n securityArchive,\n hostContexts,\n })\n const query =\n queryString ||\n (graph ? defaultProjectQueryString : defaultLocalScopeQueryString)\n const {\n edges,\n nodes,\n importers: queryResultImporters,\n } = await q.search(query, {\n signal: new AbortController().signal,\n scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,\n })\n\n if (!validateExpectedResult(conf, edges)) {\n throw error('Unexpected number of items', {\n found: edges.length,\n wanted: conf.values['expect-results'],\n })\n }\n\n return {\n importers:\n importers.size === 0 ?\n new Set(queryResultImporters)\n : importers,\n edges,\n nodes,\n highlightSelection: !!(\n targetQueryString || positionalQueryString\n ),\n queryString:\n queryString ||\n (graph ?\n defaultProjectQueryString\n : defaultLocalScopeQueryString),\n }\n}\n"]}
|
|
@@ -15,7 +15,6 @@ export declare const commands: {
|
|
|
15
15
|
readonly r: "run";
|
|
16
16
|
readonly 'run-script': "run";
|
|
17
17
|
readonly rx: "run-exec";
|
|
18
|
-
readonly s: "serve";
|
|
19
18
|
readonly x: "exec";
|
|
20
19
|
readonly xl: "exec-local";
|
|
21
20
|
readonly h: "help";
|
|
@@ -42,7 +41,6 @@ export declare const commands: {
|
|
|
42
41
|
readonly query: "query";
|
|
43
42
|
readonly 'run-exec': "run-exec";
|
|
44
43
|
readonly run: "run";
|
|
45
|
-
readonly serve: "serve";
|
|
46
44
|
readonly token: "token";
|
|
47
45
|
readonly uninstall: "uninstall";
|
|
48
46
|
readonly update: "update";
|
|
@@ -286,7 +284,7 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
286
284
|
hint: string;
|
|
287
285
|
default: string;
|
|
288
286
|
description: string;
|
|
289
|
-
validOptions: readonly ["human", "json", "mermaid", "
|
|
287
|
+
validOptions: readonly ["human", "json", "mermaid", "inspect", "silent"];
|
|
290
288
|
};
|
|
291
289
|
} & {
|
|
292
290
|
view: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
@@ -367,19 +365,9 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
367
365
|
hint: string;
|
|
368
366
|
description: string;
|
|
369
367
|
};
|
|
370
|
-
port: {
|
|
371
|
-
hint: string;
|
|
372
|
-
description: string;
|
|
373
|
-
};
|
|
374
|
-
'registry-port': {
|
|
375
|
-
hint: string;
|
|
376
|
-
description: string;
|
|
377
|
-
};
|
|
378
368
|
} & {
|
|
379
369
|
otp: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
380
370
|
'publish-directory': import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
381
|
-
port: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
382
|
-
'registry-port': import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
383
371
|
} & {
|
|
384
372
|
yes: {
|
|
385
373
|
short: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAOd,CAAA;AAEV,eAAO,MAAM,aAAa,cAKjB,CAAA;
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAOd,CAAA;AAEV,eAAO,MAAM,aAAa,cAKjB,CAAA;AAoDT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGX,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,cAAc,uBAW1B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAA;AAEtC,eAAO,MAAM,UAAU,OACjB,MAAM,KACT,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,SACkC,CAAA;AAKhE;;GAEG;AACH,eAAO,MAAM,YAAY,iGAMf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,MAAO,MAAM,KAAG,CAAC,IAAI,WACN,CAAA;AAwCzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAgPH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8NP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8EvB,CAAA;AAEJ,eAAO,MAAM,mBAAmB,gBAS/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
|
|
@@ -36,7 +36,6 @@ const canonicalCommands = {
|
|
|
36
36
|
query: 'query',
|
|
37
37
|
'run-exec': 'run-exec',
|
|
38
38
|
run: 'run',
|
|
39
|
-
serve: 'serve',
|
|
40
39
|
token: 'token',
|
|
41
40
|
uninstall: 'uninstall',
|
|
42
41
|
update: 'update',
|
|
@@ -56,7 +55,6 @@ const aliases = {
|
|
|
56
55
|
r: 'run',
|
|
57
56
|
'run-script': 'run',
|
|
58
57
|
rx: 'run-exec',
|
|
59
|
-
s: 'serve',
|
|
60
58
|
x: 'exec',
|
|
61
59
|
xl: 'exec-local',
|
|
62
60
|
h: 'help',
|
|
@@ -511,9 +509,6 @@ export const definition = j
|
|
|
511
509
|
consumption.
|
|
512
510
|
- json: Parseable JSON output for machines.
|
|
513
511
|
- inspect: Output results with \`util.inspect\`.
|
|
514
|
-
- gui: Start a local web server and opens a browser to
|
|
515
|
-
explore the results. (Only relevant for certain
|
|
516
|
-
commands.)
|
|
517
512
|
- mermaid: Output mermaid diagramming syntax. (Only
|
|
518
513
|
relevant for certain commands.)
|
|
519
514
|
- silent: Suppress all output to stdout.
|
|
@@ -526,7 +521,6 @@ export const definition = j
|
|
|
526
521
|
'human',
|
|
527
522
|
'json',
|
|
528
523
|
'mermaid',
|
|
529
|
-
'gui',
|
|
530
524
|
'inspect',
|
|
531
525
|
'silent',
|
|
532
526
|
],
|
|
@@ -619,14 +613,6 @@ export const definition = j
|
|
|
619
613
|
description: `Directory to use for pack and publish operations instead of the current directory.
|
|
620
614
|
The directory must exist and nothing will be copied to it.`,
|
|
621
615
|
},
|
|
622
|
-
port: {
|
|
623
|
-
hint: 'number',
|
|
624
|
-
description: `Port for the browser-based UI server when using vlt serve command (default: 8000).`,
|
|
625
|
-
},
|
|
626
|
-
'registry-port': {
|
|
627
|
-
hint: 'number',
|
|
628
|
-
description: `Port for the VSR registry when using vlt serve command (default: 1337).`,
|
|
629
|
-
},
|
|
630
616
|
})
|
|
631
617
|
.flag({
|
|
632
618
|
yes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW;AACtB,uCAAuC;AACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO;IAC5B,6DAA6D;IAC7D,sDAAsD;IACxD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;QACxB,6BAA6B;QAC/B,CAAC,CAAC,MAAM,CAAA;AAEV,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,eAAe;QAC1C,CAAC,CAAC,IAAI,CAAC,CAAA;AAET,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IAC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2BAA2B;KACzC;IACD,GAAG,EAAE;QACH,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,oCAAoC;KAClD;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA;IAChC,OAAO,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,CAAoB,EAAE,EAAE;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,oBAAoB;QACpB,IAAI,CAAC,GAAG;YAAE,MAAM,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,EAAE,CAAA;QAC3C,OAAO,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView =\n // If stdout is a TTY, use human output\n process.stdout.isTTY ? 'human'\n // If its not a TTY but is a CI environment, use human output\n // TODO: make a better view option for CI environments\n : process.env.CI ? 'human'\n // Otherwise, use json output\n : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n bugs: 'bugs',\n build: 'build',\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n docs: 'docs',\n exec: 'exec',\n 'exec-local': 'exec-local',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n serve: 'serve',\n token: 'token',\n uninstall: 'uninstall',\n update: 'update',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'update',\n p: 'pkg',\n pub: 'publish',\n q: 'query',\n b: 'build',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n s: 'serve',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n libc: {\n description: `Override the libc family to use as the selector when choosing\n packages based on their \\`libc\\` value (e.g. glibc, musl).\n By default, this is auto-detected on Linux systems.`,\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 description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n hint: 'query',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n hint: 'query',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n 'if-present': {\n description: `When running scripts across multiple packages,\n only include packages that have the script.\n\n If this is not set, then the run will fail if any\n packages do not have the script.\n\n This will default to true if --scope, --workspace,\n --workspace-group, or --recursive is set. Otherwise,\n it will default to false.`,\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'all | user | project',\n description: `Specify which configuration to show or operate on when running\n \\`vlt config\\` commands. For read operations (get, pick, list):\n \\`all\\` shows merged configuration from both user and project\n files (default). For write operations (set, delete, edit):\n defaults to \\`project\\`. \\`user\\` shows/modifies only user-level\n configuration, \\`project\\` shows/modifies only project-level\n configuration.`,\n validOptions: ['all', 'user', 'project'] as const,\n default: 'all',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard browser-based UI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n 'lockfile-only': {\n description:\n 'Only update the lockfile (vlt-lock.json) and package.json files, skip all node_modules operations including package extraction and filesystem changes.',\n },\n })\n .opt({\n 'allow-scripts': {\n hint: 'query',\n description: `Filter which packages are allowed to run lifecycle scripts using DSS query syntax.\n When provided, only packages matching the query will execute their\n install, preinstall, postinstall, prepare, preprepare, and postprepare scripts.\n Defaults to ':not(*)' which means no scripts will be run.\n \n Example: --allow-scripts=\":root > *, #my-package\"\n Runs scripts only for direct dependencies of the current project and any occurrences\n of a specific dependency with the name \"my-package\" anywhere in the dependency graph.`,\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n The directory must exist and nothing will be copied to it.`,\n },\n port: {\n hint: 'number',\n description: `Port for the browser-based UI server when using vlt serve command (default: 8000).`,\n },\n 'registry-port': {\n hint: 'number',\n description: `Port for the VSR registry when using vlt serve command (default: 1337).`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n all: {\n short: 'a',\n description: 'Show all commands, bins, and flags',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;A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AG,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView =\n // If stdout is a TTY, use human output\n process.stdout.isTTY ? 'human'\n // If its not a TTY but is a CI environment, use human output\n // TODO: make a better view option for CI environments\n : process.env.CI ? 'human'\n // Otherwise, use json output\n : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n bugs: 'bugs',\n build: 'build',\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n docs: 'docs',\n exec: 'exec',\n 'exec-local': 'exec-local',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n update: 'update',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'update',\n p: 'pkg',\n pub: 'publish',\n q: 'query',\n b: 'build',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n libc: {\n description: `Override the libc family to use as the selector when choosing\n packages based on their \\`libc\\` value (e.g. glibc, musl).\n By default, this is auto-detected on Linux systems.`,\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 description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n hint: 'query',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n hint: 'query',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n 'if-present': {\n description: `When running scripts across multiple packages,\n only include packages that have the script.\n\n If this is not set, then the run will fail if any\n packages do not have the script.\n\n This will default to true if --scope, --workspace,\n --workspace-group, or --recursive is set. Otherwise,\n it will default to false.`,\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'all | user | project',\n description: `Specify which configuration to show or operate on when running\n \\`vlt config\\` commands. For read operations (get, pick, list):\n \\`all\\` shows merged configuration from both user and project\n files (default). For write operations (set, delete, edit):\n defaults to \\`project\\`. \\`user\\` shows/modifies only user-level\n configuration, \\`project\\` shows/modifies only project-level\n configuration.`,\n validOptions: ['all', 'user', 'project'] as const,\n default: 'all',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard browser-based UI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n 'lockfile-only': {\n description:\n 'Only update the lockfile (vlt-lock.json) and package.json files, skip all node_modules operations including package extraction and filesystem changes.',\n },\n })\n .opt({\n 'allow-scripts': {\n hint: 'query',\n description: `Filter which packages are allowed to run lifecycle scripts using DSS query syntax.\n When provided, only packages matching the query will execute their\n install, preinstall, postinstall, prepare, preprepare, and postprepare scripts.\n Defaults to ':not(*)' which means no scripts will be run.\n \n Example: --allow-scripts=\":root > *, #my-package\"\n Runs scripts only for direct dependencies of the current project and any occurrences\n of a specific dependency with the name \"my-package\" anywhere in the dependency graph.`,\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n The directory must exist and nothing will be copied to it.`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n all: {\n short: 'a',\n description: 'Show all commands, bins, and flags',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAM/C,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAG7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,EACL,QAAQ,EACR,UAAU,EAEV,aAAa,EACb,YAAY,EACb,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,YAAY,EACZ,KAAK,QAAQ,GACd,CAAA;AAED,eAAO,MAAM,cAAc,eAA2C,CAAA;AAEtE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AACjD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAwBjD,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG;IACnD,OAAO,CAAC,EAAE;SACP,CAAC,IAAI,MAAM,QAAQ,CAAC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,IAAI,CAAC;IAgBrC;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BrC;;;OAGG;WACU,IAAI,CACf,WAAW,SAAgB,EAC3B,IAAI,WAAe;IACnB;;;OAGG;IACH,MAAM,UAAQ,GACb,OAAO,CAAC,YAAY,CAAC;CAOzB;AAKD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAClC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IACvC,MAAM,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAA;IACzC,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,CAAA"}
|
package/dist/config/index.js
CHANGED
|
@@ -281,10 +281,40 @@ export class Config {
|
|
|
281
281
|
});
|
|
282
282
|
}
|
|
283
283
|
const { command, ...values } = recordsToPairs(c);
|
|
284
|
+
// Validate registries keys don't contain reserved ~ character
|
|
285
|
+
const registries = c.registries;
|
|
286
|
+
if (registries && typeof registries === 'object') {
|
|
287
|
+
const registriesObj = Array.isArray(registries) ?
|
|
288
|
+
reducePairs(registries)
|
|
289
|
+
: registries;
|
|
290
|
+
for (const key of Object.keys(registriesObj)) {
|
|
291
|
+
if (key === '' || key.includes('~')) {
|
|
292
|
+
throw error('Reserved character found in registries name', {
|
|
293
|
+
path: file,
|
|
294
|
+
found: key,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
284
299
|
if (command) {
|
|
285
300
|
for (const [c, opts] of Object.entries(command)) {
|
|
286
301
|
const cmd = getCommand(c);
|
|
287
|
-
if (cmd) {
|
|
302
|
+
if (cmd && opts && typeof opts === 'object') {
|
|
303
|
+
// Validate registries in command-specific config
|
|
304
|
+
const cmdRegistries = opts.registries;
|
|
305
|
+
if (cmdRegistries && typeof cmdRegistries === 'object') {
|
|
306
|
+
const cmdRegistriesObj = Array.isArray(cmdRegistries) ?
|
|
307
|
+
reducePairs(cmdRegistries)
|
|
308
|
+
: cmdRegistries;
|
|
309
|
+
for (const key of Object.keys(cmdRegistriesObj)) {
|
|
310
|
+
if (key === '' || key.includes('~')) {
|
|
311
|
+
throw error('Reserved character found in registries name', {
|
|
312
|
+
path: file,
|
|
313
|
+
found: key,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
288
318
|
this.commandValues[cmd] = merge(this.commandValues[cmd] ?? {}, opts);
|
|
289
319
|
}
|
|
290
320
|
}
|
package/dist/config/index.js.map
CHANGED
|
@@ -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,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,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,aAAa,CAAC,CAAA;IAChC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO,CAA0B;IAExC;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CACf,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAC3B,IAAI,GAAG,OAAO,CAAC,IAAI;IACnB;;;OAGG;IACH,MAAM,GAAG,KAAK;QAEd,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,OAAO,CAAA;QAChD,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;QAC7C,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,cAAc,EAAE,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAiB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAqB,EAAE,CAChD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["/**\n * Module that handles all vlt configuration needs\n *\n * Project-level configs are set in a `vlt.json` file in the local project\n * if present. This will override the user-level configs in the appropriate\n * XDG config path.\n *\n * Command-specific configuration can be specified by putting options in a\n * field in the `command` object. For example:\n *\n * ```json\n * {\n * \"registry\": \"https://registry.npmjs.org/\",\n * \"command\": {\n * \"publish\": {\n * \"registry\": \"http://registry.internal\"\n * }\n * }\n * }\n * ```\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { PackageJson } from '@vltpkg/package-json'\nimport { resetCaches } from '@vltpkg/dep-id'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport {\n assertRecordStringString,\n assertRecordStringT,\n isRecordStringString,\n} from '@vltpkg/types'\nimport type { Validator, WhichConfig } from '@vltpkg/vlt-json'\nimport { find, load, reload, save } from '@vltpkg/vlt-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport type { Jack, OptionsResults, Unwrap } from 'jackspeak'\nimport { readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport { PathScurry } from 'path-scurry'\nimport type { Commands, RecordField } from './definition.ts'\nimport {\n commands,\n definition,\n getCommand,\n isRecordField,\n recordFields,\n} from './definition.ts'\nimport { merge } from './merge.ts'\nexport {\n commands,\n definition,\n isRecordField,\n recordFields,\n type Commands,\n}\n\nexport const kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport type RecordPairs = Record<string, unknown>\nexport type RecordString = Record<string, string>\n\n// turn a set of pairs into a Record object.\n// if a kv pair doesn't have a = character, set to `''`\nconst reducePairs = <T extends string[]>(\n pairs: T,\n): RecordString | T => {\n const record: RecordString = {}\n for (const kv of pairs) {\n const eq = kv.indexOf('=')\n if (eq === -1) record[kv] = ''\n else {\n const key = kv.substring(0, eq)\n const val = kv.substring(eq + 1)\n record[key] = val\n }\n }\n return record\n}\n\nconst isRecordFieldValue = (k: string, v: unknown): v is string[] =>\n Array.isArray(v) &&\n recordFields.includes(k as (typeof recordFields)[number])\n\nexport type PairsAsRecords = ConfigOptionsNoExtras & {\n command?: {\n [k in keyof Commands]?: ConfigOptionsNoExtras\n }\n}\n\nexport const pairsToRecords = (\n obj:\n | NonNullable<ConfigFileData>\n | OptionsResults<ConfigDefinitions>,\n): PairsAsRecords => {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n Object.fromEntries(\n Object.entries(v).map(([k, v]) => [\n k,\n pairsToRecords(v as NonNullable<ConfigFileData>),\n ]),\n )\n : isRecordFieldValue(k, v) ? reducePairs(v)\n : v,\n ]),\n // hard cast because TS can't see through the entries/fromEntries\n ) as unknown as PairsAsRecords\n}\n\nexport const recordsToPairs = (obj: RecordPairs): RecordPairs => {\n return Object.fromEntries(\n Object.entries(obj)\n .filter(\n ([k]) =>\n !(\n k === 'scurry' ||\n k === 'packageJson' ||\n k === 'monorepo' ||\n k === 'projectRoot' ||\n k === 'packageInfo'\n ),\n )\n .map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n recordsToPairs(v as RecordPairs)\n : (\n !v ||\n typeof v !== 'object' ||\n Array.isArray(v) ||\n !isRecordField(k)\n ) ?\n v\n : Object.entries(v).map(([k, v]) => `${k}=${v}`),\n ]),\n )\n}\n\nconst kRecord = Symbol('parsed key=value record')\n\nexport type ConfigDataNoCommand = {\n [k in keyof OptionsResults<ConfigDefinitions>]?: OptionsResults<ConfigDefinitions>[k]\n}\n\n/**\n * Config data can be any options, and also a 'command' field which\n * contains command names and override options for that command.\n */\nexport type ConfigData = ConfigDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigDataNoCommand\n }\n}\n\nexport type ConfigFileDataNoCommand = {\n [k in keyof ConfigDataNoCommand]: k extends (\n OptListKeys<ConfigDataNoCommand>\n ) ?\n RecordString | string[]\n : ConfigDataNoCommand[k]\n}\n\n/**\n * Config data as it appears in the config field of the vlt.json, with kv pair\n * lists stored as `Record<string, string>` and\n */\nexport type ConfigFileData = ConfigFileDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigFileDataNoCommand\n }\n}\n\nexport type ConfigOptionsNoExtras = {\n [k in keyof OptionsResults<ConfigDefinitions>]: k extends (\n RecordField\n ) ?\n RecordString\n : k extends 'command' ? never\n : OptionsResults<ConfigDefinitions>[k]\n}\n\nexport type ConfigOptions = ConfigOptionsNoExtras &\n Pick<SpecOptions, 'catalog' | 'catalogs'> & {\n packageJson: PackageJson\n scurry: PathScurry\n projectRoot: string\n monorepo?: Monorepo\n packageInfo: PackageInfoClient\n }\n\n/**\n * The base config definition set as a type\n */\nexport type ConfigDefinitions = Unwrap<typeof definition>\n\nexport type StringListKeys<O> = {\n [k in keyof O]: O[k] extends string[] | undefined ? k : never\n}\nexport type OptListKeys<O> = Exclude<\n StringListKeys<O>[keyof StringListKeys<O>],\n undefined\n>\n\n/**\n * Class that handles configuration for vlt.\n *\n * Call {@link Config.load} to get one of these.\n */\nexport class Config {\n /**\n * The {@link https://npmjs.com/jackspeak | JackSpeak} object\n * representing vlt's configuration\n */\n jack: Jack<ConfigDefinitions>\n\n /**\n * Parsed values in effect\n */\n values?: OptionsResults<ConfigDefinitions>\n\n /**\n * Command-specific config values\n */\n commandValues: {\n [cmd in Commands[keyof Commands]]?: ConfigData\n } = {}\n\n /**\n * A flattened object of the parsed configuration\n */\n get options(): ConfigOptions {\n if (this.#options) return this.#options\n const scurry = new PathScurry(this.projectRoot)\n const packageJson = new PackageJson()\n const asRecords = pairsToRecords(this.parse().values)\n const extras = {\n projectRoot: this.projectRoot,\n scurry,\n packageJson,\n monorepo: Monorepo.maybeLoad(this.projectRoot, {\n scurry,\n packageJson,\n load: {\n paths: asRecords.workspace,\n groups: asRecords['workspace-group'],\n },\n }),\n catalog: load<Record<string, string>>(\n 'catalog',\n assertRecordStringString,\n ),\n catalogs: load<Record<string, Record<string, string>>>(\n 'catalogs',\n o =>\n assertRecordStringT(\n o,\n isRecordStringString,\n 'Record<string, Record<string, string>>',\n ),\n ),\n }\n\n const options: Omit<ConfigOptions, 'packageInfo'> = Object.assign(\n asRecords,\n extras,\n )\n\n this.#options = Object.assign(options, {\n packageInfo: new PackageInfoClient(options),\n [kCustomInspect]() {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([k]) =>\n k !== 'monorepo' &&\n k !== 'scurry' &&\n k !== 'packageJson' &&\n k !== 'packageInfo',\n ),\n )\n },\n })\n return this.#options\n }\n\n /**\n * Reset the options value, optionally setting a new project root\n * to recalculate the options.\n */\n resetOptions(projectRoot: string = process.cwd()) {\n this.projectRoot = projectRoot\n this.#options = undefined\n resetCaches()\n }\n\n // memoized options() getter value\n #options?: ConfigOptions\n\n /**\n * positional arguments to the vlt process\n */\n positionals?: string[]\n\n /**\n * Original arguments used for parsing (stored for reload purposes)\n * @internal\n */\n #originalArgs?: string[]\n\n /**\n * The root of the project where a vlt.json, vlt.json,\n * package.json, or .git was found. Not necessarily the `process.cwd()`,\n * though that is the default location.\n *\n * Never walks up as far as `$HOME`. So for example, if a project is in\n * `~/projects/xyz`, then the highest dir it will check is `~/projects`\n */\n projectRoot: string\n\n /**\n * `Record<alias, canonical name>` to dereference command aliases.\n */\n commands: Commands\n\n /**\n * Which command name to use for overriding with command-specific values,\n * determined from the argv when parse() is called.\n */\n command?: Commands[keyof Commands]\n\n constructor(\n jack: Jack<ConfigDefinitions> = definition,\n projectRoot = process.cwd(),\n ) {\n this.projectRoot = projectRoot\n this.commands = commands\n this.jack = jack\n }\n\n /**\n * Parse the arguments and set configuration and positionals accordingly.\n */\n parse(args: string[] = process.argv): this & ParsedConfig {\n if (isParsed(this)) return this\n\n // Store the original args for potential reload\n this.#originalArgs = [...args]\n\n this.jack.loadEnvDefaults()\n const p = this.jack.parseRaw(args)\n\n const fallback = getCommand(p.values['fallback-command'])\n this.command = getCommand(p.positionals[0])\n\n const cmdOrFallback = this.command ?? fallback\n const cmdSpecific =\n cmdOrFallback && this.commandValues[cmdOrFallback]\n if (cmdSpecific) {\n this.jack.setConfigValues(recordsToPairs(cmdSpecific))\n }\n\n // ok, applied cmd-specific defaults, do rest of the parse\n this.jack.applyDefaults(p)\n this.jack.writeEnv(p)\n\n if (this.command) p.positionals.shift()\n else this.command = getCommand(p.values['fallback-command'])\n\n Object.assign(this, p)\n\n /* c8 ignore start - unpossible */\n if (!isParsed(this)) throw error('failed to parse config')\n /* c8 ignore stop */\n\n return this\n }\n\n /**\n * Get a `key=value` list option value as an object.\n *\n * For example, a list option with a vlaue of `['key=value', 'xyz=as=df' ]`\n * would be returned as `{key: 'value', xyz: 'as=df'}`\n *\n * Results are memoized, so subsequent calls for the same key will return the\n * same object. If new strings are added to the list, then the memoized value\n * is *not* updated, so only use once configurations have been fully loaded.\n *\n * If the config value is not set at all, an empty object is returned.\n */\n getRecord(k: OptListKeys<ConfigData>): RecordString {\n const pairs = this.get(k) as\n | (string[] & { [kRecord]?: RecordString })\n | undefined\n if (!pairs) return {}\n if (pairs[kRecord]) return pairs[kRecord]\n const kv = pairs.reduce((kv: RecordString, pair) => {\n const eq = pair.indexOf('=')\n if (eq === -1) return kv\n const key = pair.substring(0, eq)\n const val = pair.substring(eq + 1)\n kv[key] = val\n return kv\n }, {})\n Object.assign(pairs, { [kRecord]: kv })\n return kv\n }\n\n /**\n * Get a configuration value.\n *\n * Note: `key=value` pair configs are returned as a string array. To get them\n * as an object, use {@link Config#getRecord}.\n */\n get<K extends keyof OptionsResults<ConfigDefinitions>>(\n k: K,\n ): OptionsResults<ConfigDefinitions>[K] {\n /* c8 ignore next -- impossible but TS doesn't know that */\n return (this.values ?? this.parse().values)[k]\n }\n\n /**\n * Write the config values to the user or project config file.\n */\n async writeConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n save('config', pairsToRecords(values), which)\n await this.#reloadConfig()\n }\n\n /**\n * Fold in the provided fields with the existing properties\n * in the config file.\n */\n async addConfigToFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n return this.writeConfigFile(\n which,\n merge((await this.#maybeLoadConfigFile(which)) ?? {}, values),\n )\n }\n\n // called in this weird bound way so that it can be used by the\n // vlt-json config loading module.\n #validator: Validator<ConfigFileData> = function (\n this: Config,\n c: unknown,\n file: string,\n ) {\n this.#validateConfig(c, file)\n }.bind(this)\n\n #validateConfig(\n c: unknown,\n file: string,\n ): asserts c is ConfigFileData {\n if (!c || typeof c !== 'object' || Array.isArray(c)) {\n throw error('invalid config, expected object', {\n path: file,\n found: c,\n wanted: 'ConfigFileData',\n })\n }\n\n const { command, ...values } = recordsToPairs(c as RecordPairs)\n if (command) {\n for (const [c, opts] of Object.entries(command)) {\n const cmd = getCommand(c)\n if (cmd) {\n this.commandValues[cmd] = merge<ConfigData>(\n this.commandValues[cmd] ?? ({} as ConfigData),\n opts as ConfigData,\n )\n }\n }\n }\n this.jack.setConfigValues(values, file)\n }\n\n /**\n * if the file exists, parse and load it. returns object if data was\n * loaded, or undefined if not.\n */\n async #maybeLoadConfigFile(whichConfig: WhichConfig) {\n return load('config', this.#validator, whichConfig)\n }\n\n /**\n * Deletes the specified config fields from the named file\n * Returns `true` if anything was changed.\n */\n async deleteConfigKeys(\n this: LoadedConfig,\n which: WhichConfig,\n fields: string[],\n ) {\n const data = await this.#maybeLoadConfigFile(which)\n if (!data) return false\n let didSomething = false\n for (const f of fields) {\n const [key, ...sk] = f.split('.') as [\n h: string,\n ...rest: string[],\n ]\n const subs = sk.join('.')\n const k = key as keyof ConfigDefinitions\n const v = data[k]\n if (v === undefined) continue\n if (subs && v && typeof v === 'object') {\n if (Array.isArray(v)) {\n const i = v.findIndex(subvalue =>\n subvalue.startsWith(`${subs}=`),\n )\n if (i !== -1) {\n if (v.length === 1) delete data[k]\n else v.splice(i, 1)\n didSomething = true\n }\n } else {\n if (v[subs] !== undefined) {\n delete v[subs]\n if (Object.keys(v).length === 0) delete data[k]\n didSomething = true\n }\n }\n } else {\n didSomething = true\n delete data[k]\n }\n }\n if (didSomething) await this.writeConfigFile(which, data)\n return didSomething\n }\n\n /**\n * Edit the user or project configuration file.\n *\n * If the file isn't present, then it starts with `{}` so the user has\n * something to work with.\n *\n * If the result is not valid, or no config settings are contained in the\n * file after editing, then it's restored to what it was before, which might\n * mean deleting the file.\n */\n async editConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n edit: (file: string) => Promise<void> | void,\n ) {\n // load the file as a backup\n // call the edit function\n // reload it\n const file = find(which)\n const backup = await readFile(file, 'utf8').catch(() => undefined)\n if (!backup) {\n await writeFile(\n file,\n JSON.stringify({ config: {} }, null, 2) + '\\n',\n )\n }\n let valid = false\n try {\n await edit(file)\n // force it to reload the file and validate it again\n // if this fails, we roll back.\n const result = reload('config', which)\n save('config', result ?? {}, which)\n valid = true\n } finally {\n if (!valid) {\n // TODO: maybe write the file to a re-edit backup location?\n // then you could do `vlt config edit retry` or something.\n if (backup) {\n await writeFile(file, backup)\n reload(which)\n } else {\n await rm(file, { force: true })\n }\n }\n }\n }\n\n /**\n * Find the local config file and load both it and the user-level config in\n * the XDG config home.\n */\n async loadConfigFile(): Promise<this> {\n await this.#maybeLoadConfigFile('user')\n this.projectRoot = dirname(find('project', this.projectRoot))\n await this.#maybeLoadConfigFile('project')\n return this\n }\n\n /**\n * Clear cached config values to force re-reading from updated files.\n * @internal\n */\n async #reloadConfig() {\n // Clear the memoized options to force recalculation\n this.#options = undefined\n }\n\n /**\n * Force a complete reload of config files from disk.\n * This clears all caches and re-reads config files.\n * Useful for long-running processes that need to pick up config changes.\n */\n async reloadFromDisk(): Promise<void> {\n // Clear the memoized options to force recalculation\n this.#options = undefined\n\n // Clear the parsed state to force re-parsing\n // This is crucial because parse() returns early if already parsed\n this.values = undefined\n this.positionals = undefined\n this.command = undefined\n\n // Clear vlt-json caches for both user and project configs\n // This ensures that the next time config files are read, they'll be re-read from disk\n const { unload } = await import('@vltpkg/vlt-json')\n unload('user')\n unload('project')\n\n // Force reload of config files by calling the load methods again\n // This will re-read the files and re-apply them to the jack parser\n await this.#maybeLoadConfigFile('user')\n await this.#maybeLoadConfigFile('project')\n\n // Re-parse to pick up the updated config values using the original arguments\n this.parse(this.#originalArgs)\n }\n\n /**\n * cache of the loaded config\n */\n static #loaded: LoadedConfig | undefined\n\n /**\n * Load the configuration and return a Promise to a\n * {@link Config} object\n */\n static async load(\n projectRoot = process.cwd(),\n argv = process.argv,\n /**\n * only used in tests, resets the memoization\n * @internal\n */\n reload = false,\n ): Promise<LoadedConfig> {\n if (this.#loaded && !reload) return this.#loaded\n const a = new Config(definition, projectRoot)\n const b = await a.loadConfigFile()\n this.#loaded = b.parse(argv) as LoadedConfig\n return this.#loaded\n }\n}\n\nconst isParsed = (c: Config): c is ParsedConfig =>\n !!(c.values && c.positionals && c.command)\n\nexport type ParsedConfig = Config & {\n command: NonNullable<Config['command']>\n values: OptionsResults<ConfigDefinitions>\n positionals: string[]\n}\n\n/**\n * A fully loaded {@link Config} object\n */\nexport type LoadedConfig = ParsedConfig\n"]}
|
|
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,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,YAAY,GAEb,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAKtE,4CAA4C;AAC5C,uDAAuD;AACvD,MAAM,WAAW,GAAG,CAClB,KAAQ,EACU,EAAE;IACpB,MAA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,IAAI,CAAC,OAAO,CAAA;QAChD,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;QAC7C,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,cAAc,EAAE,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAiB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAqB,EAAE,CAChD,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA","sourcesContent":["/**\n * Module that handles all vlt configuration needs\n *\n * Project-level configs are set in a `vlt.json` file in the local project\n * if present. This will override the user-level configs in the appropriate\n * XDG config path.\n *\n * Command-specific configuration can be specified by putting options in a\n * field in the `command` object. For example:\n *\n * ```json\n * {\n * \"registry\": \"https://registry.npmjs.org/\",\n * \"command\": {\n * \"publish\": {\n * \"registry\": \"http://registry.internal\"\n * }\n * }\n * }\n * ```\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { PackageJson } from '@vltpkg/package-json'\nimport { resetCaches } from '@vltpkg/dep-id'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport {\n assertRecordStringString,\n assertRecordStringT,\n isRecordStringString,\n} from '@vltpkg/types'\nimport type { Validator, WhichConfig } from '@vltpkg/vlt-json'\nimport { find, load, reload, save } from '@vltpkg/vlt-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport type { Jack, OptionsResults, Unwrap } from 'jackspeak'\nimport { readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport { PathScurry } from 'path-scurry'\nimport type { Commands, RecordField } from './definition.ts'\nimport {\n commands,\n definition,\n getCommand,\n isRecordField,\n recordFields,\n} from './definition.ts'\nimport { merge } from './merge.ts'\nexport {\n commands,\n definition,\n isRecordField,\n recordFields,\n type Commands,\n}\n\nexport const kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport type RecordPairs = Record<string, unknown>\nexport type RecordString = Record<string, string>\n\n// turn a set of pairs into a Record object.\n// if a kv pair doesn't have a = character, set to `''`\nconst reducePairs = <T extends string[]>(\n pairs: T,\n): RecordString | T => {\n const record: RecordString = {}\n for (const kv of pairs) {\n const eq = kv.indexOf('=')\n if (eq === -1) record[kv] = ''\n else {\n const key = kv.substring(0, eq)\n const val = kv.substring(eq + 1)\n record[key] = val\n }\n }\n return record\n}\n\nconst isRecordFieldValue = (k: string, v: unknown): v is string[] =>\n Array.isArray(v) &&\n recordFields.includes(k as (typeof recordFields)[number])\n\nexport type PairsAsRecords = ConfigOptionsNoExtras & {\n command?: {\n [k in keyof Commands]?: ConfigOptionsNoExtras\n }\n}\n\nexport const pairsToRecords = (\n obj:\n | NonNullable<ConfigFileData>\n | OptionsResults<ConfigDefinitions>,\n): PairsAsRecords => {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n Object.fromEntries(\n Object.entries(v).map(([k, v]) => [\n k,\n pairsToRecords(v as NonNullable<ConfigFileData>),\n ]),\n )\n : isRecordFieldValue(k, v) ? reducePairs(v)\n : v,\n ]),\n // hard cast because TS can't see through the entries/fromEntries\n ) as unknown as PairsAsRecords\n}\n\nexport const recordsToPairs = (obj: RecordPairs): RecordPairs => {\n return Object.fromEntries(\n Object.entries(obj)\n .filter(\n ([k]) =>\n !(\n k === 'scurry' ||\n k === 'packageJson' ||\n k === 'monorepo' ||\n k === 'projectRoot' ||\n k === 'packageInfo'\n ),\n )\n .map(([k, v]) => [\n k,\n k === 'command' && v && typeof v === 'object' ?\n recordsToPairs(v as RecordPairs)\n : (\n !v ||\n typeof v !== 'object' ||\n Array.isArray(v) ||\n !isRecordField(k)\n ) ?\n v\n : Object.entries(v).map(([k, v]) => `${k}=${v}`),\n ]),\n )\n}\n\nconst kRecord = Symbol('parsed key=value record')\n\nexport type ConfigDataNoCommand = {\n [k in keyof OptionsResults<ConfigDefinitions>]?: OptionsResults<ConfigDefinitions>[k]\n}\n\n/**\n * Config data can be any options, and also a 'command' field which\n * contains command names and override options for that command.\n */\nexport type ConfigData = ConfigDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigDataNoCommand\n }\n}\n\nexport type ConfigFileDataNoCommand = {\n [k in keyof ConfigDataNoCommand]: k extends (\n OptListKeys<ConfigDataNoCommand>\n ) ?\n RecordString | string[]\n : ConfigDataNoCommand[k]\n}\n\n/**\n * Config data as it appears in the config field of the vlt.json, with kv pair\n * lists stored as `Record<string, string>` and\n */\nexport type ConfigFileData = ConfigFileDataNoCommand & {\n command?: {\n [k in keyof Commands]?: ConfigFileDataNoCommand\n }\n}\n\nexport type ConfigOptionsNoExtras = {\n [k in keyof OptionsResults<ConfigDefinitions>]: k extends (\n RecordField\n ) ?\n RecordString\n : k extends 'command' ? never\n : OptionsResults<ConfigDefinitions>[k]\n}\n\nexport type ConfigOptions = ConfigOptionsNoExtras &\n Pick<SpecOptions, 'catalog' | 'catalogs'> & {\n packageJson: PackageJson\n scurry: PathScurry\n projectRoot: string\n monorepo?: Monorepo\n packageInfo: PackageInfoClient\n }\n\n/**\n * The base config definition set as a type\n */\nexport type ConfigDefinitions = Unwrap<typeof definition>\n\nexport type StringListKeys<O> = {\n [k in keyof O]: O[k] extends string[] | undefined ? k : never\n}\nexport type OptListKeys<O> = Exclude<\n StringListKeys<O>[keyof StringListKeys<O>],\n undefined\n>\n\n/**\n * Class that handles configuration for vlt.\n *\n * Call {@link Config.load} to get one of these.\n */\nexport class Config {\n /**\n * The {@link https://npmjs.com/jackspeak | JackSpeak} object\n * representing vlt's configuration\n */\n jack: Jack<ConfigDefinitions>\n\n /**\n * Parsed values in effect\n */\n values?: OptionsResults<ConfigDefinitions>\n\n /**\n * Command-specific config values\n */\n commandValues: {\n [cmd in Commands[keyof Commands]]?: ConfigData\n } = {}\n\n /**\n * A flattened object of the parsed configuration\n */\n get options(): ConfigOptions {\n if (this.#options) return this.#options\n const scurry = new PathScurry(this.projectRoot)\n const packageJson = new PackageJson()\n const asRecords = pairsToRecords(this.parse().values)\n const extras = {\n projectRoot: this.projectRoot,\n scurry,\n packageJson,\n monorepo: Monorepo.maybeLoad(this.projectRoot, {\n scurry,\n packageJson,\n load: {\n paths: asRecords.workspace,\n groups: asRecords['workspace-group'],\n },\n }),\n catalog: load<Record<string, string>>(\n 'catalog',\n assertRecordStringString,\n ),\n catalogs: load<Record<string, Record<string, string>>>(\n 'catalogs',\n o =>\n assertRecordStringT(\n o,\n isRecordStringString,\n 'Record<string, Record<string, string>>',\n ),\n ),\n }\n\n const options: Omit<ConfigOptions, 'packageInfo'> = Object.assign(\n asRecords,\n extras,\n )\n\n this.#options = Object.assign(options, {\n packageInfo: new PackageInfoClient(options),\n [kCustomInspect]() {\n return Object.fromEntries(\n Object.entries(options).filter(\n ([k]) =>\n k !== 'monorepo' &&\n k !== 'scurry' &&\n k !== 'packageJson' &&\n k !== 'packageInfo',\n ),\n )\n },\n })\n return this.#options\n }\n\n /**\n * Reset the options value, optionally setting a new project root\n * to recalculate the options.\n */\n resetOptions(projectRoot: string = process.cwd()) {\n this.projectRoot = projectRoot\n this.#options = undefined\n resetCaches()\n }\n\n // memoized options() getter value\n #options?: ConfigOptions\n\n /**\n * positional arguments to the vlt process\n */\n positionals?: string[]\n\n /**\n * Original arguments used for parsing (stored for reload purposes)\n * @internal\n */\n #originalArgs?: string[]\n\n /**\n * The root of the project where a vlt.json, vlt.json,\n * package.json, or .git was found. Not necessarily the `process.cwd()`,\n * though that is the default location.\n *\n * Never walks up as far as `$HOME`. So for example, if a project is in\n * `~/projects/xyz`, then the highest dir it will check is `~/projects`\n */\n projectRoot: string\n\n /**\n * `Record<alias, canonical name>` to dereference command aliases.\n */\n commands: Commands\n\n /**\n * Which command name to use for overriding with command-specific values,\n * determined from the argv when parse() is called.\n */\n command?: Commands[keyof Commands]\n\n constructor(\n jack: Jack<ConfigDefinitions> = definition,\n projectRoot = process.cwd(),\n ) {\n this.projectRoot = projectRoot\n this.commands = commands\n this.jack = jack\n }\n\n /**\n * Parse the arguments and set configuration and positionals accordingly.\n */\n parse(args: string[] = process.argv): this & ParsedConfig {\n if (isParsed(this)) return this\n\n // Store the original args for potential reload\n this.#originalArgs = [...args]\n\n this.jack.loadEnvDefaults()\n const p = this.jack.parseRaw(args)\n\n const fallback = getCommand(p.values['fallback-command'])\n this.command = getCommand(p.positionals[0])\n\n const cmdOrFallback = this.command ?? fallback\n const cmdSpecific =\n cmdOrFallback && this.commandValues[cmdOrFallback]\n if (cmdSpecific) {\n this.jack.setConfigValues(recordsToPairs(cmdSpecific))\n }\n\n // ok, applied cmd-specific defaults, do rest of the parse\n this.jack.applyDefaults(p)\n this.jack.writeEnv(p)\n\n if (this.command) p.positionals.shift()\n else this.command = getCommand(p.values['fallback-command'])\n\n Object.assign(this, p)\n\n /* c8 ignore start - unpossible */\n if (!isParsed(this)) throw error('failed to parse config')\n /* c8 ignore stop */\n\n return this\n }\n\n /**\n * Get a `key=value` list option value as an object.\n *\n * For example, a list option with a vlaue of `['key=value', 'xyz=as=df' ]`\n * would be returned as `{key: 'value', xyz: 'as=df'}`\n *\n * Results are memoized, so subsequent calls for the same key will return the\n * same object. If new strings are added to the list, then the memoized value\n * is *not* updated, so only use once configurations have been fully loaded.\n *\n * If the config value is not set at all, an empty object is returned.\n */\n getRecord(k: OptListKeys<ConfigData>): RecordString {\n const pairs = this.get(k) as\n | (string[] & { [kRecord]?: RecordString })\n | undefined\n if (!pairs) return {}\n if (pairs[kRecord]) return pairs[kRecord]\n const kv = pairs.reduce((kv: RecordString, pair) => {\n const eq = pair.indexOf('=')\n if (eq === -1) return kv\n const key = pair.substring(0, eq)\n const val = pair.substring(eq + 1)\n kv[key] = val\n return kv\n }, {})\n Object.assign(pairs, { [kRecord]: kv })\n return kv\n }\n\n /**\n * Get a configuration value.\n *\n * Note: `key=value` pair configs are returned as a string array. To get them\n * as an object, use {@link Config#getRecord}.\n */\n get<K extends keyof OptionsResults<ConfigDefinitions>>(\n k: K,\n ): OptionsResults<ConfigDefinitions>[K] {\n /* c8 ignore next -- impossible but TS doesn't know that */\n return (this.values ?? this.parse().values)[k]\n }\n\n /**\n * Write the config values to the user or project config file.\n */\n async writeConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n save('config', pairsToRecords(values), which)\n await this.#reloadConfig()\n }\n\n /**\n * Fold in the provided fields with the existing properties\n * in the config file.\n */\n async addConfigToFile(\n this: LoadedConfig,\n which: WhichConfig,\n values: NonNullable<ConfigFileData>,\n ) {\n return this.writeConfigFile(\n which,\n merge((await this.#maybeLoadConfigFile(which)) ?? {}, values),\n )\n }\n\n // called in this weird bound way so that it can be used by the\n // vlt-json config loading module.\n #validator: Validator<ConfigFileData> = function (\n this: Config,\n c: unknown,\n file: string,\n ) {\n this.#validateConfig(c, file)\n }.bind(this)\n\n #validateConfig(\n c: unknown,\n file: string,\n ): asserts c is ConfigFileData {\n if (!c || typeof c !== 'object' || Array.isArray(c)) {\n throw error('invalid config, expected object', {\n path: file,\n found: c,\n wanted: 'ConfigFileData',\n })\n }\n\n const { command, ...values } = recordsToPairs(c as RecordPairs)\n\n // Validate registries keys don't contain reserved ~ character\n const registries = (c as RecordPairs).registries\n if (registries && typeof registries === 'object') {\n const registriesObj =\n Array.isArray(registries) ?\n reducePairs(registries)\n : registries\n for (const key of Object.keys(registriesObj)) {\n if (key === '' || key.includes('~')) {\n throw error('Reserved character found in registries name', {\n path: file,\n found: key,\n })\n }\n }\n }\n\n if (command) {\n for (const [c, opts] of Object.entries(command)) {\n const cmd = getCommand(c)\n if (cmd && opts && typeof opts === 'object') {\n // Validate registries in command-specific config\n const cmdRegistries = (opts as RecordPairs).registries\n if (cmdRegistries && typeof cmdRegistries === 'object') {\n const cmdRegistriesObj =\n Array.isArray(cmdRegistries) ?\n reducePairs(cmdRegistries)\n : cmdRegistries\n for (const key of Object.keys(cmdRegistriesObj)) {\n if (key === '' || key.includes('~')) {\n throw error(\n 'Reserved character found in registries name',\n {\n path: file,\n found: key,\n },\n )\n }\n }\n }\n\n this.commandValues[cmd] = merge<ConfigData>(\n this.commandValues[cmd] ?? ({} as ConfigData),\n opts as ConfigData,\n )\n }\n }\n }\n this.jack.setConfigValues(values, file)\n }\n\n /**\n * if the file exists, parse and load it. returns object if data was\n * loaded, or undefined if not.\n */\n async #maybeLoadConfigFile(whichConfig: WhichConfig) {\n return load('config', this.#validator, whichConfig)\n }\n\n /**\n * Deletes the specified config fields from the named file\n * Returns `true` if anything was changed.\n */\n async deleteConfigKeys(\n this: LoadedConfig,\n which: WhichConfig,\n fields: string[],\n ) {\n const data = await this.#maybeLoadConfigFile(which)\n if (!data) return false\n let didSomething = false\n for (const f of fields) {\n const [key, ...sk] = f.split('.') as [\n h: string,\n ...rest: string[],\n ]\n const subs = sk.join('.')\n const k = key as keyof ConfigDefinitions\n const v = data[k]\n if (v === undefined) continue\n if (subs && v && typeof v === 'object') {\n if (Array.isArray(v)) {\n const i = v.findIndex(subvalue =>\n subvalue.startsWith(`${subs}=`),\n )\n if (i !== -1) {\n if (v.length === 1) delete data[k]\n else v.splice(i, 1)\n didSomething = true\n }\n } else {\n if (v[subs] !== undefined) {\n delete v[subs]\n if (Object.keys(v).length === 0) delete data[k]\n didSomething = true\n }\n }\n } else {\n didSomething = true\n delete data[k]\n }\n }\n if (didSomething) await this.writeConfigFile(which, data)\n return didSomething\n }\n\n /**\n * Edit the user or project configuration file.\n *\n * If the file isn't present, then it starts with `{}` so the user has\n * something to work with.\n *\n * If the result is not valid, or no config settings are contained in the\n * file after editing, then it's restored to what it was before, which might\n * mean deleting the file.\n */\n async editConfigFile(\n this: LoadedConfig,\n which: WhichConfig,\n edit: (file: string) => Promise<void> | void,\n ) {\n // load the file as a backup\n // call the edit function\n // reload it\n const file = find(which)\n const backup = await readFile(file, 'utf8').catch(() => undefined)\n if (!backup) {\n await writeFile(\n file,\n JSON.stringify({ config: {} }, null, 2) + '\\n',\n )\n }\n let valid = false\n try {\n await edit(file)\n // force it to reload the file and validate it again\n // if this fails, we roll back.\n const result = reload('config', which)\n save('config', result ?? {}, which)\n valid = true\n } finally {\n if (!valid) {\n // TODO: maybe write the file to a re-edit backup location?\n // then you could do `vlt config edit retry` or something.\n if (backup) {\n await writeFile(file, backup)\n reload(which)\n } else {\n await rm(file, { force: true })\n }\n }\n }\n }\n\n /**\n * Find the local config file and load both it and the user-level config in\n * the XDG config home.\n */\n async loadConfigFile(): Promise<this> {\n await this.#maybeLoadConfigFile('user')\n this.projectRoot = dirname(find('project', this.projectRoot))\n await this.#maybeLoadConfigFile('project')\n return this\n }\n\n /**\n * Clear cached config values to force re-reading from updated files.\n * @internal\n */\n async #reloadConfig() {\n // Clear the memoized options to force recalculation\n this.#options = undefined\n }\n\n /**\n * Force a complete reload of config files from disk.\n * This clears all caches and re-reads config files.\n * Useful for long-running processes that need to pick up config changes.\n */\n async reloadFromDisk(): Promise<void> {\n // Clear the memoized options to force recalculation\n this.#options = undefined\n\n // Clear the parsed state to force re-parsing\n // This is crucial because parse() returns early if already parsed\n this.values = undefined\n this.positionals = undefined\n this.command = undefined\n\n // Clear vlt-json caches for both user and project configs\n // This ensures that the next time config files are read, they'll be re-read from disk\n const { unload } = await import('@vltpkg/vlt-json')\n unload('user')\n unload('project')\n\n // Force reload of config files by calling the load methods again\n // This will re-read the files and re-apply them to the jack parser\n await this.#maybeLoadConfigFile('user')\n await this.#maybeLoadConfigFile('project')\n\n // Re-parse to pick up the updated config values using the original arguments\n this.parse(this.#originalArgs)\n }\n\n /**\n * cache of the loaded config\n */\n static #loaded: LoadedConfig | undefined\n\n /**\n * Load the configuration and return a Promise to a\n * {@link Config} object\n */\n static async load(\n projectRoot = process.cwd(),\n argv = process.argv,\n /**\n * only used in tests, resets the memoization\n * @internal\n */\n reload = false,\n ): Promise<LoadedConfig> {\n if (this.#loaded && !reload) return this.#loaded\n const a = new Config(definition, projectRoot)\n const b = await a.loadConfigFile()\n this.#loaded = b.parse(argv) as LoadedConfig\n return this.#loaded\n }\n}\n\nconst isParsed = (c: Config): c is ParsedConfig =>\n !!(c.values && c.positionals && c.command)\n\nexport type ParsedConfig = Config & {\n command: NonNullable<Config['command']>\n values: OptionsResults<ConfigDefinitions>\n positionals: string[]\n}\n\n/**\n * A fully loaded {@link Config} object\n */\nexport type LoadedConfig = ParsedConfig\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-help.d.ts","sourceRoot":"","sources":["../src/custom-help.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-help.d.ts","sourceRoot":"","sources":["../src/custom-help.ts"],"names":[],"mappings":"AA0PA;;GAEG;AACH,eAAO,MAAM,mBAAmB,wBAAqB,MAiDpD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,wBAAqB,MA8HjD,CAAA"}
|
package/dist/custom-help.js
CHANGED
|
@@ -192,14 +192,6 @@ const allCommands = [
|
|
|
192
192
|
desc: 'Run a script &/or fallback to executing a binary',
|
|
193
193
|
showByDefault: false,
|
|
194
194
|
},
|
|
195
|
-
{
|
|
196
|
-
name: 'serve',
|
|
197
|
-
aliases: ['s'],
|
|
198
|
-
args: '',
|
|
199
|
-
desc: 'Start a local package registry server',
|
|
200
|
-
showByDefault: true,
|
|
201
|
-
defaultOrder: 9,
|
|
202
|
-
},
|
|
203
195
|
{
|
|
204
196
|
name: 'token',
|
|
205
197
|
aliases: [],
|
package/dist/custom-help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-help.js","sourceRoot":"","sources":["../src/custom-help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,M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EAAE,WAAW,CAAC;;EAE3C,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC;;EAErB,eAAe;;EAEf,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC;;WAElB,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC;WACvB,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC;;EAEjC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;;EAElB,YAAY;;sBAEQ,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC;uBAClB,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC;;EAE/C,CAAC,CAAC,KAAK,EAAE,+EAA+E,CAAC,EAAE,CAAA;AAC7F,CAAC,CAAA","sourcesContent":["import { loadPackageJson } from 'package-json-from-dist'\nimport chalk from 'chalk'\n\nconst { version } = loadPackageJson(\n import.meta.filename,\n process.env.__VLT_INTERNAL_CLI_PACKAGE_JSON,\n) as {\n version: string\n}\n\n// Custom yellow color: #FFE15D\nconst customYellow = chalk.hex('#FFE15D')\n\ntype StylerFn = (style: string | string[], text: string) => string\n\nconst makeStyler = (colors: boolean): StylerFn => {\n if (!colors) return (_, s) => s\n\n return (style: string | string[], text: string): string => {\n const styles = Array.isArray(style) ? style : [style]\n let styledText = text\n\n for (const s of styles) {\n switch (s) {\n case 'yellow':\n case 'yellowBright':\n styledText = customYellow(styledText)\n break\n case 'bold':\n styledText = chalk.bold(styledText)\n break\n case 'dim':\n styledText = chalk.dim(styledText)\n break\n case 'dark':\n styledText = chalk.gray(styledText)\n break\n case 'cyan':\n styledText = chalk.cyan(styledText)\n break\n case 'green':\n styledText = chalk.green(styledText)\n break\n default:\n // Fallback to chalk's built-in colors\n if (\n s in chalk &&\n typeof chalk[s as keyof typeof chalk] === 'function'\n ) {\n styledText = (\n chalk[s as keyof typeof chalk] as (\n text: string,\n ) => string\n )(styledText)\n }\n break\n }\n }\n\n return styledText\n }\n}\n\n// Single source of truth for all commands with metadata\nconst allCommands = [\n {\n name: 'build',\n aliases: ['b'],\n args: '<selector>',\n desc: 'Build packages with lifecycle scripts',\n showByDefault: true,\n defaultOrder: 4,\n },\n {\n name: 'cache',\n aliases: [],\n args: '[add|ls|info|clean|delete|delete-before|delete-all]',\n desc: 'Manage the package cache',\n showByDefault: false,\n },\n {\n name: 'ci',\n aliases: [],\n args: '',\n desc: 'Clean install (frozen lockfile)',\n showByDefault: false,\n },\n {\n name: 'config',\n aliases: [],\n args: '[get|pick|list|set|delete|edit|location]',\n desc: 'Get or set configuration',\n showByDefault: false,\n },\n {\n name: 'docs',\n aliases: [],\n args: '',\n desc: 'Open the docs of the current project',\n showByDefault: false,\n },\n {\n name: 'exec',\n aliases: ['x'],\n args: '<executable>',\n desc: 'Execute a package bin',\n showByDefault: true,\n defaultOrder: 6,\n },\n {\n name: 'exec-cache',\n aliases: ['xc'],\n args: '[ls|delete|info|install]',\n desc: 'Manage the exec cache',\n showByDefault: false,\n },\n {\n name: 'exec-local',\n aliases: ['xl'],\n args: '<command>',\n desc: 'Execute a local package bin',\n showByDefault: false,\n },\n {\n name: 'help',\n aliases: ['h', '?'],\n args: '[<command>]',\n desc: 'Show help for a command',\n showByDefault: false,\n },\n {\n name: 'init',\n aliases: [],\n args: '',\n desc: 'Initialize a new project',\n showByDefault: true,\n defaultOrder: 1,\n },\n {\n name: 'install',\n aliases: ['i', 'add'],\n args: '[<package>...]',\n desc: 'Install dependencies',\n showByDefault: true,\n defaultOrder: 2,\n },\n {\n name: 'list',\n aliases: ['ls'],\n args: '',\n desc: 'List installed packages',\n showByDefault: false,\n },\n {\n name: 'login',\n aliases: [],\n args: '',\n desc: 'Authenticate with a registry',\n showByDefault: false,\n },\n {\n name: 'logout',\n aliases: [],\n args: '',\n desc: 'Log out from a registry',\n showByDefault: false,\n },\n {\n name: 'pack',\n aliases: [],\n args: '',\n desc: 'Create a tarball from a package',\n showByDefault: false,\n },\n {\n name: 'pkg',\n aliases: ['p'],\n args: '<command>',\n desc: 'Manage package metadata',\n showByDefault: true,\n defaultOrder: 7,\n },\n {\n name: 'publish',\n aliases: ['pub'],\n args: '',\n desc: 'Publish package to registry',\n showByDefault: true,\n defaultOrder: 8,\n },\n {\n name: 'query',\n aliases: ['q'],\n args: '<selector>',\n desc: 'Query for packages in the project',\n showByDefault: true,\n defaultOrder: 3,\n },\n {\n name: 'run',\n aliases: ['r'],\n args: '<script>',\n desc: 'Run a script defined in package.json',\n showByDefault: true,\n defaultOrder: 5,\n },\n {\n name: 'run-exec',\n aliases: ['rx'],\n args: '<script>',\n desc: 'Run a script &/or fallback to executing a binary',\n showByDefault: false,\n },\n {\n name: 'serve',\n aliases: ['s'],\n args: '',\n desc: 'Start a local package registry server',\n showByDefault: true,\n defaultOrder: 9,\n },\n {\n name: 'token',\n aliases: [],\n args: '[add|rm]',\n desc: 'Manage authentication tokens',\n showByDefault: false,\n },\n {\n name: 'uninstall',\n aliases: ['rm'],\n args: '[<package>...]',\n desc: 'Remove dependencies',\n showByDefault: false,\n },\n {\n name: 'update',\n aliases: ['u'],\n args: '',\n desc: 'Update package versions to latest in-range',\n showByDefault: false,\n },\n {\n name: 'version',\n aliases: [],\n args: '<increment>',\n desc: 'Bump package version',\n showByDefault: false,\n },\n {\n name: 'whoami',\n aliases: [],\n args: '',\n desc: 'Display the current user',\n showByDefault: false,\n },\n]\n\n/**\n * Generates the custom default help output for vlt\n */\nexport const generateDefaultHelp = (colors = false): string => {\n const s = makeStyler(colors)\n\n // Get default commands and sort by defaultOrder\n const defaultCommands = allCommands\n .filter(cmd => cmd.showByDefault)\n .sort((a, b) => (a.defaultOrder || 0) - (b.defaultOrder || 0))\n\n // Generate commands with tighter alias spacing but proper table structure\n const commandsSection = defaultCommands\n .map(cmd => {\n // Tighter alias column (5 chars to accommodate space after comma) - only show first alias\n const firstAlias = cmd.aliases.length > 0 ? cmd.aliases[0] : ''\n const aliasColumn =\n firstAlias ? (firstAlias + ', ').padEnd(5) : ' '\n // Consistent name column (10 chars)\n const nameColumn = cmd.name.padEnd(10)\n // Consistent args column (14 chars)\n const argsColumn = cmd.args.padEnd(16)\n\n return ` ${s('dim', aliasColumn)}${s(['yellow', 'bold'], nameColumn)}${s('dim', argsColumn)}${cmd.desc}`\n })\n .join('\\n')\n\n return `${s(['bold'], '⚡️ vlt')} ${s('dim', '/vōlt/')} next-gen package management ${s('dim', `v${version}`)}\n\n${s('bold', 'USAGE')}\n\n ${s('bold', 'vlt')} ${s('dim', '<command>')}\n\n${s('bold', 'COMMON COMMANDS')}\n\n${commandsSection}\n \n${s('bold', 'COMPANION BINS')}\n\n ${s('bold', 'vlr')} ${s('dim', 'eq. vlt run')}\n ${s('bold', 'vlx')} ${s('dim', 'eq. vlt exec')}\n \n${s('bold', 'COMMON FLAGS')}\n\n ${s('green', '-v, --version')} Log the cli version\n ${s('green', '-a, --all')} List all commands, bins & flags\n\nLearn more: https://${s('bold', 'vlt.sh')}\nGet support: https://${s('bold', 'vlt.community')}\n\n${s('dim', `This is not the full usage information, run \\`vlt -a\\` for more.`)}\n`\n}\n\n/**\n * Generates the full help output with all commands when --all flag is used\n */\nexport const generateFullHelp = (colors = false): string => {\n const s = makeStyler(colors)\n\n // Use all commands sorted alphabetically\n const commands = [...allCommands].sort((a, b) =>\n a.name.localeCompare(b.name),\n )\n\n // Define only globally applicable flags (alphabetically sorted by long name)\n const flags = [\n {\n shorts: ['a'],\n long: 'all',\n args: '',\n desc: 'Show all commands, bins, and flags',\n },\n {\n shorts: ['c'],\n long: 'color',\n args: '',\n desc: 'Enable color output',\n },\n {\n shorts: ['h'],\n long: 'help',\n args: '',\n desc: 'Print helpful information',\n },\n {\n shorts: [],\n long: 'no-color',\n args: '',\n desc: 'Disable color output',\n },\n {\n shorts: [],\n long: 'registry',\n args: '<url>',\n desc: 'Override default registry',\n },\n {\n shorts: ['v'],\n long: 'version',\n args: '',\n desc: 'Print the version',\n },\n {\n shorts: ['y'],\n long: 'yes',\n args: '',\n desc: 'Automatically accept prompts',\n },\n ]\n\n // Generate commands section with letter grouping spacing\n let commandsSection = ''\n let lastFirstLetter = ''\n\n commands.forEach((cmd, index) => {\n const firstLetter = cmd.name[0]?.toLowerCase() || ''\n\n // Add extra spacing between different letter groups\n if (firstLetter !== lastFirstLetter && index > 0) {\n commandsSection += '\\n'\n }\n\n // Fixed width columns for proper alignment with space after comma\n const aliasColumn =\n cmd.aliases.length > 0 ?\n (cmd.aliases.join(', ') + ', ').padEnd(9)\n : ' '\n const nameColumn = cmd.name.padEnd(12)\n // Truncate args if longer than 16 chars and add ellipsis\n const truncatedArgs =\n cmd.args.length > 16 ?\n cmd.args.substring(0, 13) + '...'\n : cmd.args\n const argsColumn = truncatedArgs.padEnd(16)\n\n commandsSection += `${s('dim', aliasColumn)}${s(['yellow', 'bold'], nameColumn)}${s('dim', argsColumn)}${cmd.desc}`\n\n if (index < commands.length - 1) {\n commandsSection += '\\n'\n }\n\n lastFirstLetter = firstLetter\n })\n\n // Generate flags section with same structure as commands\n const flagsSection = flags\n .map(f => {\n // Match command structure: alias column, name column, args column, description\n const aliasColumn =\n f.shorts.length > 0 ?\n ('-' + f.shorts.join(', -') + ', ').padEnd(7)\n : ' '\n const nameColumn = ('--' + f.long).padEnd(12)\n const argsColumn = (f.args || '').padEnd(17)\n\n return ` ${s('dim', aliasColumn)}${s('green', nameColumn)}${s('dim', argsColumn)}${f.desc}`\n })\n .join('\\n')\n\n return `${s(['bold'], '⚡️ vlt')} ${s('dim', '/vōlt/')} ${s('dim', '- next-gen package management')} ${s('dim', `v${version}`)}\n\n${s('bold', 'USAGE')}\n\n ${s('bold', 'vlt')} ${s('dim', '<command>')}\n\n${s('bold', 'COMMANDS')}\n\n${commandsSection}\n\n${s('bold', 'COMPANION BINS')}\n\n vlr ${s('dim', 'eq. vlt run')}\n vlx ${s('dim', 'eq. vlt exec')}\n\n${s('bold', 'FLAGS')}\n\n${flagsSection}\n\nLearn more: https://${s('bold', 'vlt.sh')}\nGet support: https://${s('bold', 'vlt.community')}\n\n${s('dim', `Run \\`vlt help <command>\\` for detailed information about a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,IAAI,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC;;EAE3C,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC;;EAErB,eAAe;;EAEf,CAAC,CAAC,MAAM,EAAE,gBAAgB,CAAC;;WAElB,CAAC,CAAC,KAAK,EAAE,aAAa,CAAC;WACvB,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC;;EAEjC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;;EAElB,YAAY;;sBAEQ,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC;uBAClB,CAAC,CAAC,MAAM,EAAE,eAAe,CAAC;;EAE/C,CAAC,CAAC,KAAK,EAAE,+EAA+E,CAAC,EAAE,CAAA;AAC7F,CAAC,CAAA","sourcesContent":["import { loadPackageJson } from 'package-json-from-dist'\nimport chalk from 'chalk'\n\nconst { version } = loadPackageJson(\n import.meta.filename,\n process.env.__VLT_INTERNAL_CLI_PACKAGE_JSON,\n) as {\n version: string\n}\n\n// Custom yellow color: #FFE15D\nconst customYellow = chalk.hex('#FFE15D')\n\ntype StylerFn = (style: string | string[], text: string) => string\n\nconst makeStyler = (colors: boolean): StylerFn => {\n if (!colors) return (_, s) => s\n\n return (style: string | string[], text: string): string => {\n const styles = Array.isArray(style) ? style : [style]\n let styledText = text\n\n for (const s of styles) {\n switch (s) {\n case 'yellow':\n case 'yellowBright':\n styledText = customYellow(styledText)\n break\n case 'bold':\n styledText = chalk.bold(styledText)\n break\n case 'dim':\n styledText = chalk.dim(styledText)\n break\n case 'dark':\n styledText = chalk.gray(styledText)\n break\n case 'cyan':\n styledText = chalk.cyan(styledText)\n break\n case 'green':\n styledText = chalk.green(styledText)\n break\n default:\n // Fallback to chalk's built-in colors\n if (\n s in chalk &&\n typeof chalk[s as keyof typeof chalk] === 'function'\n ) {\n styledText = (\n chalk[s as keyof typeof chalk] as (\n text: string,\n ) => string\n )(styledText)\n }\n break\n }\n }\n\n return styledText\n }\n}\n\n// Single source of truth for all commands with metadata\nconst allCommands = [\n {\n name: 'build',\n aliases: ['b'],\n args: '<selector>',\n desc: 'Build packages with lifecycle scripts',\n showByDefault: true,\n defaultOrder: 4,\n },\n {\n name: 'cache',\n aliases: [],\n args: '[add|ls|info|clean|delete|delete-before|delete-all]',\n desc: 'Manage the package cache',\n showByDefault: false,\n },\n {\n name: 'ci',\n aliases: [],\n args: '',\n desc: 'Clean install (frozen lockfile)',\n showByDefault: false,\n },\n {\n name: 'config',\n aliases: [],\n args: '[get|pick|list|set|delete|edit|location]',\n desc: 'Get or set configuration',\n showByDefault: false,\n },\n {\n name: 'docs',\n aliases: [],\n args: '',\n desc: 'Open the docs of the current project',\n showByDefault: false,\n },\n {\n name: 'exec',\n aliases: ['x'],\n args: '<executable>',\n desc: 'Execute a package bin',\n showByDefault: true,\n defaultOrder: 6,\n },\n {\n name: 'exec-cache',\n aliases: ['xc'],\n args: '[ls|delete|info|install]',\n desc: 'Manage the exec cache',\n showByDefault: false,\n },\n {\n name: 'exec-local',\n aliases: ['xl'],\n args: '<command>',\n desc: 'Execute a local package bin',\n showByDefault: false,\n },\n {\n name: 'help',\n aliases: ['h', '?'],\n args: '[<command>]',\n desc: 'Show help for a command',\n showByDefault: false,\n },\n {\n name: 'init',\n aliases: [],\n args: '',\n desc: 'Initialize a new project',\n showByDefault: true,\n defaultOrder: 1,\n },\n {\n name: 'install',\n aliases: ['i', 'add'],\n args: '[<package>...]',\n desc: 'Install dependencies',\n showByDefault: true,\n defaultOrder: 2,\n },\n {\n name: 'list',\n aliases: ['ls'],\n args: '',\n desc: 'List installed packages',\n showByDefault: false,\n },\n {\n name: 'login',\n aliases: [],\n args: '',\n desc: 'Authenticate with a registry',\n showByDefault: false,\n },\n {\n name: 'logout',\n aliases: [],\n args: '',\n desc: 'Log out from a registry',\n showByDefault: false,\n },\n {\n name: 'pack',\n aliases: [],\n args: '',\n desc: 'Create a tarball from a package',\n showByDefault: false,\n },\n {\n name: 'pkg',\n aliases: ['p'],\n args: '<command>',\n desc: 'Manage package metadata',\n showByDefault: true,\n defaultOrder: 7,\n },\n {\n name: 'publish',\n aliases: ['pub'],\n args: '',\n desc: 'Publish package to registry',\n showByDefault: true,\n defaultOrder: 8,\n },\n {\n name: 'query',\n aliases: ['q'],\n args: '<selector>',\n desc: 'Query for packages in the project',\n showByDefault: true,\n defaultOrder: 3,\n },\n {\n name: 'run',\n aliases: ['r'],\n args: '<script>',\n desc: 'Run a script defined in package.json',\n showByDefault: true,\n defaultOrder: 5,\n },\n {\n name: 'run-exec',\n aliases: ['rx'],\n args: '<script>',\n desc: 'Run a script &/or fallback to executing a binary',\n showByDefault: false,\n },\n {\n name: 'token',\n aliases: [],\n args: '[add|rm]',\n desc: 'Manage authentication tokens',\n showByDefault: false,\n },\n {\n name: 'uninstall',\n aliases: ['rm'],\n args: '[<package>...]',\n desc: 'Remove dependencies',\n showByDefault: false,\n },\n {\n name: 'update',\n aliases: ['u'],\n args: '',\n desc: 'Update package versions to latest in-range',\n showByDefault: false,\n },\n {\n name: 'version',\n aliases: [],\n args: '<increment>',\n desc: 'Bump package version',\n showByDefault: false,\n },\n {\n name: 'whoami',\n aliases: [],\n args: '',\n desc: 'Display the current user',\n showByDefault: false,\n },\n]\n\n/**\n * Generates the custom default help output for vlt\n */\nexport const generateDefaultHelp = (colors = false): string => {\n const s = makeStyler(colors)\n\n // Get default commands and sort by defaultOrder\n const defaultCommands = allCommands\n .filter(cmd => cmd.showByDefault)\n .sort((a, b) => (a.defaultOrder || 0) - (b.defaultOrder || 0))\n\n // Generate commands with tighter alias spacing but proper table structure\n const commandsSection = defaultCommands\n .map(cmd => {\n // Tighter alias column (5 chars to accommodate space after comma) - only show first alias\n const firstAlias = cmd.aliases.length > 0 ? cmd.aliases[0] : ''\n const aliasColumn =\n firstAlias ? (firstAlias + ', ').padEnd(5) : ' '\n // Consistent name column (10 chars)\n const nameColumn = cmd.name.padEnd(10)\n // Consistent args column (14 chars)\n const argsColumn = cmd.args.padEnd(16)\n\n return ` ${s('dim', aliasColumn)}${s(['yellow', 'bold'], nameColumn)}${s('dim', argsColumn)}${cmd.desc}`\n })\n .join('\\n')\n\n return `${s(['bold'], '⚡️ vlt')} ${s('dim', '/vōlt/')} next-gen package management ${s('dim', `v${version}`)}\n\n${s('bold', 'USAGE')}\n\n ${s('bold', 'vlt')} ${s('dim', '<command>')}\n\n${s('bold', 'COMMON COMMANDS')}\n\n${commandsSection}\n \n${s('bold', 'COMPANION BINS')}\n\n ${s('bold', 'vlr')} ${s('dim', 'eq. vlt run')}\n ${s('bold', 'vlx')} ${s('dim', 'eq. vlt exec')}\n \n${s('bold', 'COMMON FLAGS')}\n\n ${s('green', '-v, --version')} Log the cli version\n ${s('green', '-a, --all')} List all commands, bins & flags\n\nLearn more: https://${s('bold', 'vlt.sh')}\nGet support: https://${s('bold', 'vlt.community')}\n\n${s('dim', `This is not the full usage information, run \\`vlt -a\\` for more.`)}\n`\n}\n\n/**\n * Generates the full help output with all commands when --all flag is used\n */\nexport const generateFullHelp = (colors = false): string => {\n const s = makeStyler(colors)\n\n // Use all commands sorted alphabetically\n const commands = [...allCommands].sort((a, b) =>\n a.name.localeCompare(b.name),\n )\n\n // Define only globally applicable flags (alphabetically sorted by long name)\n const flags = [\n {\n shorts: ['a'],\n long: 'all',\n args: '',\n desc: 'Show all commands, bins, and flags',\n },\n {\n shorts: ['c'],\n long: 'color',\n args: '',\n desc: 'Enable color output',\n },\n {\n shorts: ['h'],\n long: 'help',\n args: '',\n desc: 'Print helpful information',\n },\n {\n shorts: [],\n long: 'no-color',\n args: '',\n desc: 'Disable color output',\n },\n {\n shorts: [],\n long: 'registry',\n args: '<url>',\n desc: 'Override default registry',\n },\n {\n shorts: ['v'],\n long: 'version',\n args: '',\n desc: 'Print the version',\n },\n {\n shorts: ['y'],\n long: 'yes',\n args: '',\n desc: 'Automatically accept prompts',\n },\n ]\n\n // Generate commands section with letter grouping spacing\n let commandsSection = ''\n let lastFirstLetter = ''\n\n commands.forEach((cmd, index) => {\n const firstLetter = cmd.name[0]?.toLowerCase() || ''\n\n // Add extra spacing between different letter groups\n if (firstLetter !== lastFirstLetter && index > 0) {\n commandsSection += '\\n'\n }\n\n // Fixed width columns for proper alignment with space after comma\n const aliasColumn =\n cmd.aliases.length > 0 ?\n (cmd.aliases.join(', ') + ', ').padEnd(9)\n : ' '\n const nameColumn = cmd.name.padEnd(12)\n // Truncate args if longer than 16 chars and add ellipsis\n const truncatedArgs =\n cmd.args.length > 16 ?\n cmd.args.substring(0, 13) + '...'\n : cmd.args\n const argsColumn = truncatedArgs.padEnd(16)\n\n commandsSection += `${s('dim', aliasColumn)}${s(['yellow', 'bold'], nameColumn)}${s('dim', argsColumn)}${cmd.desc}`\n\n if (index < commands.length - 1) {\n commandsSection += '\\n'\n }\n\n lastFirstLetter = firstLetter\n })\n\n // Generate flags section with same structure as commands\n const flagsSection = flags\n .map(f => {\n // Match command structure: alias column, name column, args column, description\n const aliasColumn =\n f.shorts.length > 0 ?\n ('-' + f.shorts.join(', -') + ', ').padEnd(7)\n : ' '\n const nameColumn = ('--' + f.long).padEnd(12)\n const argsColumn = (f.args || '').padEnd(17)\n\n return ` ${s('dim', aliasColumn)}${s('green', nameColumn)}${s('dim', argsColumn)}${f.desc}`\n })\n .join('\\n')\n\n return `${s(['bold'], '⚡️ vlt')} ${s('dim', '/vōlt/')} ${s('dim', '- next-gen package management')} ${s('dim', `v${version}`)}\n\n${s('bold', 'USAGE')}\n\n ${s('bold', 'vlt')} ${s('dim', '<command>')}\n\n${s('bold', 'COMMANDS')}\n\n${commandsSection}\n\n${s('bold', 'COMPANION BINS')}\n\n vlr ${s('dim', 'eq. vlt run')}\n vlx ${s('dim', 'eq. vlt exec')}\n\n${s('bold', 'FLAGS')}\n\n${flagsSection}\n\nLearn more: https://${s('bold', 'vlt.sh')}\nGet support: https://${s('bold', 'vlt.community')}\n\n${s('dim', `Run \\`vlt help <command>\\` for detailed information about a specific command.`)}`\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/cli-sdk",
|
|
3
3
|
"description": "The source for the vlt CLI",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.15",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -28,31 +28,31 @@
|
|
|
28
28
|
"ssri": "^13.0.0",
|
|
29
29
|
"supports-color": "^10.2.2",
|
|
30
30
|
"tar": "^7.5.2",
|
|
31
|
-
"@vltpkg/
|
|
32
|
-
"@vltpkg/
|
|
33
|
-
"@vltpkg/
|
|
34
|
-
"@vltpkg/error-cause": "1.0.0-rc.
|
|
35
|
-
"@vltpkg/
|
|
36
|
-
"@vltpkg/
|
|
37
|
-
"@vltpkg/
|
|
38
|
-
"@vltpkg/
|
|
39
|
-
"@vltpkg/
|
|
40
|
-
"@vltpkg/package-
|
|
41
|
-
"@vltpkg/package-
|
|
42
|
-
"@vltpkg/promise-spawn": "1.0.0-rc.
|
|
43
|
-
"@vltpkg/query": "1.0.0-rc.
|
|
44
|
-
"@vltpkg/registry-client": "1.0.0-rc.
|
|
45
|
-
"@vltpkg/
|
|
46
|
-
"@vltpkg/
|
|
47
|
-
"@vltpkg/security-archive": "1.0.0-rc.
|
|
48
|
-
"@vltpkg/server": "1.0.0-rc.
|
|
49
|
-
"@vltpkg/
|
|
50
|
-
"@vltpkg/
|
|
51
|
-
"@vltpkg/
|
|
52
|
-
"@vltpkg/
|
|
53
|
-
"@vltpkg/
|
|
54
|
-
"@vltpkg/
|
|
55
|
-
"@vltpkg/
|
|
31
|
+
"@vltpkg/config": "1.0.0-rc.15",
|
|
32
|
+
"@vltpkg/dep-id": "1.0.0-rc.15",
|
|
33
|
+
"@vltpkg/dot-prop": "1.0.0-rc.15",
|
|
34
|
+
"@vltpkg/error-cause": "1.0.0-rc.15",
|
|
35
|
+
"@vltpkg/git": "1.0.0-rc.15",
|
|
36
|
+
"@vltpkg/graph-run": "1.0.0-rc.15",
|
|
37
|
+
"@vltpkg/graph": "1.0.0-rc.15",
|
|
38
|
+
"@vltpkg/init": "1.0.0-rc.15",
|
|
39
|
+
"@vltpkg/output": "1.0.0-rc.15",
|
|
40
|
+
"@vltpkg/package-info": "1.0.0-rc.15",
|
|
41
|
+
"@vltpkg/package-json": "1.0.0-rc.15",
|
|
42
|
+
"@vltpkg/promise-spawn": "1.0.0-rc.15",
|
|
43
|
+
"@vltpkg/query": "1.0.0-rc.15",
|
|
44
|
+
"@vltpkg/registry-client": "1.0.0-rc.15",
|
|
45
|
+
"@vltpkg/run": "1.0.0-rc.15",
|
|
46
|
+
"@vltpkg/rollback-remove": "1.0.0-rc.15",
|
|
47
|
+
"@vltpkg/security-archive": "1.0.0-rc.15",
|
|
48
|
+
"@vltpkg/server": "1.0.0-rc.15",
|
|
49
|
+
"@vltpkg/spec": "1.0.0-rc.15",
|
|
50
|
+
"@vltpkg/types": "1.0.0-rc.15",
|
|
51
|
+
"@vltpkg/url-open": "1.0.0-rc.15",
|
|
52
|
+
"@vltpkg/vlt-json": "1.0.0-rc.15",
|
|
53
|
+
"@vltpkg/vlx": "1.0.0-rc.15",
|
|
54
|
+
"@vltpkg/xdg": "1.0.0-rc.15",
|
|
55
|
+
"@vltpkg/workspaces": "1.0.0-rc.15"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@eslint/js": "^9.39.1",
|
package/dist/commands/serve.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
-
export declare const usage: CommandUsage;
|
|
3
|
-
export type ServeResult = {
|
|
4
|
-
guiPort: number;
|
|
5
|
-
registryPort: number;
|
|
6
|
-
uiURL: string;
|
|
7
|
-
registryURL: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const views: {
|
|
10
|
-
readonly human: (result: ServeResult) => void;
|
|
11
|
-
readonly json: (result: ServeResult) => ServeResult;
|
|
12
|
-
};
|
|
13
|
-
export declare const command: CommandFn<ServeResult>;
|
|
14
|
-
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAyBhB,CAAA;AAEJ,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,KAAK;6BACA,WAAW;4BAcZ,WAAW;CACW,CAAA;AAEvC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAuE1C,CAAA"}
|
package/dist/commands/serve.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { onExit } from 'signal-exit';
|
|
2
|
-
import { error } from '@vltpkg/error-cause';
|
|
3
|
-
import { exec, execFG } from '@vltpkg/run';
|
|
4
|
-
import * as vlx from '@vltpkg/vlx';
|
|
5
|
-
import { ExecCommand } from "../exec-command.js";
|
|
6
|
-
import { commandUsage } from "../config/usage.js";
|
|
7
|
-
import { stdout, styleTextStdout } from "../output.js";
|
|
8
|
-
import { startGUI } from "../start-gui.js";
|
|
9
|
-
export const usage = () => commandUsage({
|
|
10
|
-
command: 'serve',
|
|
11
|
-
usage: '',
|
|
12
|
-
description: `Start a local development server that runs both the browser-based
|
|
13
|
-
UI server and the VSR (vlt serverless registry) registry instance.
|
|
14
|
-
|
|
15
|
-
The UI server will start first on port 8000 (or the next
|
|
16
|
-
available port), and then the VSR registry will start on
|
|
17
|
-
port 1337.
|
|
18
|
-
|
|
19
|
-
This allows you to develop and test the full vlt ecosystem
|
|
20
|
-
locally, including package publishing and installation from
|
|
21
|
-
your local registry.`,
|
|
22
|
-
options: {
|
|
23
|
-
port: {
|
|
24
|
-
value: '<number>',
|
|
25
|
-
description: 'Port for the broser-based UI server (default: 8000)',
|
|
26
|
-
},
|
|
27
|
-
'registry-port': {
|
|
28
|
-
value: '<number>',
|
|
29
|
-
description: 'Port for the VSR registry (default: 1337)',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
export const views = {
|
|
34
|
-
human: (result) => {
|
|
35
|
-
stdout('');
|
|
36
|
-
stdout(styleTextStdout(['bgWhiteBright', 'black', 'bold'], ' vlt serve running '));
|
|
37
|
-
stdout('');
|
|
38
|
-
stdout(`UI Server: ${result.uiURL}`);
|
|
39
|
-
stdout(`VSR Registry: ${result.registryURL}`);
|
|
40
|
-
stdout('');
|
|
41
|
-
stdout('Press Ctrl+C to stop both servers');
|
|
42
|
-
},
|
|
43
|
-
json: (result) => result,
|
|
44
|
-
};
|
|
45
|
-
export const command = async (conf) => {
|
|
46
|
-
const registryPort = Number(conf.get('registry-port') ?? 1337);
|
|
47
|
-
// Start the GUI server first
|
|
48
|
-
stdout('Starting UI server...');
|
|
49
|
-
const server = await startGUI(conf);
|
|
50
|
-
const actualGuiPort = server.port;
|
|
51
|
-
if (!actualGuiPort) {
|
|
52
|
-
throw error('missing ui server port');
|
|
53
|
-
}
|
|
54
|
-
// Start the VSR registry with the GUI server port
|
|
55
|
-
stdout('Starting VSR registry...');
|
|
56
|
-
// Prepare environment for VSR registry
|
|
57
|
-
const registryEnv = {
|
|
58
|
-
ARG_DAEMON: 'true',
|
|
59
|
-
DAEMON_START_SERVER: 'false',
|
|
60
|
-
DAEMON_PORT: String(actualGuiPort),
|
|
61
|
-
DAEMON_URL: `http://localhost:${actualGuiPort}`,
|
|
62
|
-
};
|
|
63
|
-
// runs the exec command internally
|
|
64
|
-
/* c8 ignore start */
|
|
65
|
-
const allowScripts = conf.get('allow-scripts') ?
|
|
66
|
-
String(conf.get('allow-scripts'))
|
|
67
|
-
: ':not(*)';
|
|
68
|
-
/* c8 ignore stop */
|
|
69
|
-
const arg0 = await vlx.resolve(['@vltpkg/vsr'], {
|
|
70
|
-
...conf.options,
|
|
71
|
-
query: undefined,
|
|
72
|
-
allowScripts,
|
|
73
|
-
}, async () => 'y');
|
|
74
|
-
if (arg0) {
|
|
75
|
-
conf.positionals[0] = arg0;
|
|
76
|
-
}
|
|
77
|
-
delete conf.options['script-shell'];
|
|
78
|
-
const ex = new ExecCommand(conf, exec, execFG);
|
|
79
|
-
ex.env = registryEnv;
|
|
80
|
-
await ex.run();
|
|
81
|
-
// Handle process termination
|
|
82
|
-
/* c8 ignore start */
|
|
83
|
-
const cleanup = () => {
|
|
84
|
-
stdout('\nShutting down servers...');
|
|
85
|
-
try {
|
|
86
|
-
void server.close();
|
|
87
|
-
stdout('UI server stopped');
|
|
88
|
-
}
|
|
89
|
-
catch { }
|
|
90
|
-
};
|
|
91
|
-
onExit(cleanup);
|
|
92
|
-
/* c8 ignore stop */
|
|
93
|
-
// Return the server information
|
|
94
|
-
const result = {
|
|
95
|
-
guiPort: actualGuiPort,
|
|
96
|
-
registryPort,
|
|
97
|
-
uiURL: `http://localhost:${actualGuiPort}`,
|
|
98
|
-
registryURL: `http://localhost:${registryPort}`,
|
|
99
|
-
};
|
|
100
|
-
// This return will never be reached due to the infinite promise above
|
|
101
|
-
return result;
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=serve.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AA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6B;IAC7B,qBAAqB;IACrB,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,CAAC,4BAA4B,CAAC,CAAA;QACpC,IAAI,CAAC;YACH,KAAK,MAAM,CAAC,KAAK,EAAE,CAAA;YACnB,MAAM,CAAC,mBAAmB,CAAC,CAAA;QAC7B,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC,CAAA;IACD,MAAM,CAAC,OAAO,CAAC,CAAA;IACf,oBAAoB;IAEpB,gCAAgC;IAChC,MAAM,MAAM,GAAgB;QAC1B,OAAO,EAAE,aAAa;QACtB,YAAY;QACZ,KAAK,EAAE,oBAAoB,aAAa,EAAE;QAC1C,WAAW,EAAE,oBAAoB,YAAY,EAAE;KAChD,CAAA;IAED,sEAAsE;IACtE,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { onExit } from 'signal-exit'\nimport { error } from '@vltpkg/error-cause'\nimport { exec, execFG } from '@vltpkg/run'\nimport * as vlx from '@vltpkg/vlx'\nimport { ExecCommand } from '../exec-command.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport { stdout, styleTextStdout } from '../output.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'serve',\n usage: '',\n description: `Start a local development server that runs both the browser-based\n UI server and the VSR (vlt serverless registry) registry instance.\n\n The UI server will start first on port 8000 (or the next\n available port), and then the VSR registry will start on\n port 1337.\n\n This allows you to develop and test the full vlt ecosystem\n locally, including package publishing and installation from\n your local registry.`,\n options: {\n port: {\n value: '<number>',\n description:\n 'Port for the broser-based UI server (default: 8000)',\n },\n 'registry-port': {\n value: '<number>',\n description: 'Port for the VSR registry (default: 1337)',\n },\n },\n })\n\nexport type ServeResult = {\n guiPort: number\n registryPort: number\n uiURL: string\n registryURL: string\n}\n\nexport const views = {\n human: (result: ServeResult) => {\n stdout('')\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ' vlt serve running ',\n ),\n )\n stdout('')\n stdout(`UI Server: ${result.uiURL}`)\n stdout(`VSR Registry: ${result.registryURL}`)\n stdout('')\n stdout('Press Ctrl+C to stop both servers')\n },\n json: (result: ServeResult) => result,\n} as const satisfies Views<ServeResult>\n\nexport const command: CommandFn<ServeResult> = async (\n conf: LoadedConfig,\n) => {\n const registryPort = Number(conf.get('registry-port') ?? 1337)\n\n // Start the GUI server first\n stdout('Starting UI server...')\n const server = await startGUI(conf)\n const actualGuiPort = server.port\n\n if (!actualGuiPort) {\n throw error('missing ui server port')\n }\n\n // Start the VSR registry with the GUI server port\n stdout('Starting VSR registry...')\n\n // Prepare environment for VSR registry\n const registryEnv = {\n ARG_DAEMON: 'true',\n DAEMON_START_SERVER: 'false',\n DAEMON_PORT: String(actualGuiPort),\n DAEMON_URL: `http://localhost:${actualGuiPort}`,\n }\n\n // runs the exec command internally\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const arg0 = await vlx.resolve(\n ['@vltpkg/vsr'],\n {\n ...conf.options,\n query: undefined,\n allowScripts,\n },\n async () => 'y',\n )\n if (arg0) {\n conf.positionals[0] = arg0\n }\n delete conf.options['script-shell']\n const ex = new ExecCommand(conf, exec, execFG)\n ex.env = registryEnv\n await ex.run()\n\n // Handle process termination\n /* c8 ignore start */\n const cleanup = () => {\n stdout('\\nShutting down servers...')\n try {\n void server.close()\n stdout('UI server stopped')\n } catch {}\n }\n onExit(cleanup)\n /* c8 ignore stop */\n\n // Return the server information\n const result: ServeResult = {\n guiPort: actualGuiPort,\n registryPort,\n uiURL: `http://localhost:${actualGuiPort}`,\n registryURL: `http://localhost:${registryPort}`,\n }\n\n // This return will never be reached due to the infinite promise above\n return result\n}\n"]}
|
package/dist/start-gui.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PathScurry } from 'path-scurry';
|
|
2
|
-
import type { LoadedConfig } from './config/index.ts';
|
|
3
|
-
export declare const getDefaultStartingRoute: (options: {
|
|
4
|
-
queryString?: string;
|
|
5
|
-
startingRoute?: string;
|
|
6
|
-
projectRoot: string;
|
|
7
|
-
scurry: PathScurry;
|
|
8
|
-
}) => Promise<string>;
|
|
9
|
-
export declare const startGUI: (conf: LoadedConfig, startingRoute?: string) => Promise<import("@vltpkg/server").VltServer>;
|
|
10
|
-
//# sourceMappingURL=start-gui.d.ts.map
|
package/dist/start-gui.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start-gui.d.ts","sourceRoot":"","sources":["../src/start-gui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,eAAO,MAAM,uBAAuB,YAAmB;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,UAAU,CAAA;CACnB,oBAcA,CAAA;AAaD,eAAO,MAAM,QAAQ,SACb,YAAY,kBACF,MAAM,gDA0CvB,CAAA"}
|
package/dist/start-gui.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import LZString from 'lz-string';
|
|
3
|
-
import { createServer } from '@vltpkg/server';
|
|
4
|
-
import { urlOpen } from '@vltpkg/url-open';
|
|
5
|
-
import { stdout } from "./output.js";
|
|
6
|
-
export const getDefaultStartingRoute = async (options) => {
|
|
7
|
-
const { queryString = ':root', startingRoute, projectRoot, scurry, } = options;
|
|
8
|
-
if (startingRoute)
|
|
9
|
-
return startingRoute;
|
|
10
|
-
const stat = await scurry.lstat(`${projectRoot}/package.json`);
|
|
11
|
-
const res = stat?.isFile() && !stat.isSymbolicLink() ?
|
|
12
|
-
`/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`
|
|
13
|
-
: '/dashboard';
|
|
14
|
-
return res;
|
|
15
|
-
};
|
|
16
|
-
const getAssetsDir = () => {
|
|
17
|
-
/* c8 ignore start */
|
|
18
|
-
if (process.env.__VLT_INTERNAL_GUI_ASSETS_DIR) {
|
|
19
|
-
return resolve(import.meta.dirname, process.env.__VLT_INTERNAL_GUI_ASSETS_DIR);
|
|
20
|
-
}
|
|
21
|
-
/* c8 ignore stop */
|
|
22
|
-
};
|
|
23
|
-
export const startGUI = async (conf, startingRoute) => {
|
|
24
|
-
/* c8 ignore start */
|
|
25
|
-
const allowScripts = conf.get('allow-scripts') ?
|
|
26
|
-
String(conf.get('allow-scripts'))
|
|
27
|
-
: ':not(*)';
|
|
28
|
-
/* c8 ignore stop */
|
|
29
|
-
const server = createServer({
|
|
30
|
-
...conf.options,
|
|
31
|
-
assetsDir: getAssetsDir(),
|
|
32
|
-
loadedConfig: conf,
|
|
33
|
-
allowScripts,
|
|
34
|
-
});
|
|
35
|
-
server.on('needConfigUpdate', async (dir) => {
|
|
36
|
-
conf.resetOptions(dir);
|
|
37
|
-
const listeningServer = server;
|
|
38
|
-
listeningServer.updateOptions({ ...conf.options, allowScripts });
|
|
39
|
-
await conf
|
|
40
|
-
.reloadFromDisk()
|
|
41
|
-
.then(() => {
|
|
42
|
-
listeningServer.updateOptions({
|
|
43
|
-
...conf.options,
|
|
44
|
-
allowScripts,
|
|
45
|
-
});
|
|
46
|
-
})
|
|
47
|
-
.catch(() => { });
|
|
48
|
-
});
|
|
49
|
-
const { projectRoot, scurry } = conf.options;
|
|
50
|
-
await server.start();
|
|
51
|
-
stdout(`⚡️ vlt UI running at ${server.address()}`);
|
|
52
|
-
void urlOpen(server.address(await getDefaultStartingRoute({
|
|
53
|
-
queryString: conf.values.target,
|
|
54
|
-
startingRoute,
|
|
55
|
-
projectRoot,
|
|
56
|
-
scurry,
|
|
57
|
-
})));
|
|
58
|
-
return server;
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=start-gui.js.map
|
package/dist/start-gui.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start-gui.js","sourceRoot":"","sources":["../src/start-gui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,OAK7C,EAAE,EAAE;IACH,MAAM,EACJ,WAAW,GAAG,OAAO,EACrB,aAAa,EACb,WAAW,EACX,MAAM,GACP,GAAG,OAAO,CAAA;IACX,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;IACvC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,eAAe,CAAC,CAAA;IAC9D,MAAM,GAAG,GACP,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACxC,YAAY,QAAQ,CAAC,6BAA6B,CAAC,WAAW,CAAC,WAAW;QAC5E,CAAC,CAAC,YAAY,CAAA;IAChB,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,qBAAqB;IACrB,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;QAC9C,OAAO,OAAO,CACZ,MAAM,CAAC,IAAI,CAAC,OAAO,EACnB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAC1C,CAAA;IACH,CAAC;IACD,oBAAoB;AACtB,CAAC,CA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Aa;QACb,WAAW;QACX,MAAM;KACP,CAAC,CACH,CACF,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { resolve } from 'node:path'\nimport LZString from 'lz-string'\nimport { createServer } from '@vltpkg/server'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { stdout } from './output.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { VltServerListening } from '@vltpkg/server'\n\nexport const getDefaultStartingRoute = async (options: {\n queryString?: string\n startingRoute?: string\n projectRoot: string\n scurry: PathScurry\n}) => {\n const {\n queryString = ':root',\n startingRoute,\n projectRoot,\n scurry,\n } = options\n if (startingRoute) return startingRoute\n const stat = await scurry.lstat(`${projectRoot}/package.json`)\n const res =\n stat?.isFile() && !stat.isSymbolicLink() ?\n `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`\n : '/dashboard'\n return res\n}\n\nconst getAssetsDir = () => {\n /* c8 ignore start */\n if (process.env.__VLT_INTERNAL_GUI_ASSETS_DIR) {\n return resolve(\n import.meta.dirname,\n process.env.__VLT_INTERNAL_GUI_ASSETS_DIR,\n )\n }\n /* c8 ignore stop */\n}\n\nexport const startGUI = async (\n conf: LoadedConfig,\n startingRoute?: string,\n) => {\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const server = createServer({\n ...conf.options,\n assetsDir: getAssetsDir(),\n loadedConfig: conf,\n allowScripts,\n })\n server.on('needConfigUpdate', async dir => {\n conf.resetOptions(dir)\n const listeningServer = server as VltServerListening\n listeningServer.updateOptions({ ...conf.options, allowScripts })\n await conf\n .reloadFromDisk()\n .then(() => {\n listeningServer.updateOptions({\n ...conf.options,\n allowScripts,\n })\n })\n .catch(() => {})\n })\n const { projectRoot, scurry } = conf.options\n await server.start()\n stdout(`⚡️ vlt UI running at ${server.address()}`)\n void urlOpen(\n server.address(\n await getDefaultStartingRoute({\n queryString: conf.values.target,\n startingRoute,\n projectRoot,\n scurry,\n }),\n ),\n )\n return server\n}\n"]}
|