@vltpkg/cli-sdk 0.0.0-10
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/LICENSE +15 -0
- package/README.md +23 -0
- package/dist/esm/commands/cache.d.ts +65 -0
- package/dist/esm/commands/cache.d.ts.map +1 -0
- package/dist/esm/commands/cache.js +256 -0
- package/dist/esm/commands/cache.js.map +1 -0
- package/dist/esm/commands/config.d.ts +5 -0
- package/dist/esm/commands/config.d.ts.map +1 -0
- package/dist/esm/commands/config.js +153 -0
- package/dist/esm/commands/config.js.map +1 -0
- package/dist/esm/commands/exec-cache.d.ts +49 -0
- package/dist/esm/commands/exec-cache.d.ts.map +1 -0
- package/dist/esm/commands/exec-cache.js +125 -0
- package/dist/esm/commands/exec-cache.js.map +1 -0
- package/dist/esm/commands/exec-local.d.ts +6 -0
- package/dist/esm/commands/exec-local.d.ts.map +1 -0
- package/dist/esm/commands/exec-local.js +24 -0
- package/dist/esm/commands/exec-local.js.map +1 -0
- package/dist/esm/commands/exec.d.ts +9 -0
- package/dist/esm/commands/exec.d.ts.map +1 -0
- package/dist/esm/commands/exec.js +78 -0
- package/dist/esm/commands/exec.js.map +1 -0
- package/dist/esm/commands/gui.d.ts +6 -0
- package/dist/esm/commands/gui.d.ts.map +1 -0
- package/dist/esm/commands/gui.js +13 -0
- package/dist/esm/commands/gui.js.map +1 -0
- package/dist/esm/commands/help.d.ts +4 -0
- package/dist/esm/commands/help.d.ts.map +1 -0
- package/dist/esm/commands/help.js +10 -0
- package/dist/esm/commands/help.js.map +1 -0
- package/dist/esm/commands/init.d.ts +8 -0
- package/dist/esm/commands/init.d.ts.map +1 -0
- package/dist/esm/commands/init.js +25 -0
- package/dist/esm/commands/init.js.map +1 -0
- package/dist/esm/commands/install/reporter.d.ts +10 -0
- package/dist/esm/commands/install/reporter.d.ts.map +1 -0
- package/dist/esm/commands/install/reporter.js +67 -0
- package/dist/esm/commands/install/reporter.js.map +1 -0
- package/dist/esm/commands/install.d.ts +10 -0
- package/dist/esm/commands/install.d.ts.map +1 -0
- package/dist/esm/commands/install.js +21 -0
- package/dist/esm/commands/install.js.map +1 -0
- package/dist/esm/commands/list.d.ts +15 -0
- package/dist/esm/commands/list.d.ts.map +1 -0
- package/dist/esm/commands/list.js +109 -0
- package/dist/esm/commands/list.js.map +1 -0
- package/dist/esm/commands/login.d.ts +4 -0
- package/dist/esm/commands/login.d.ts.map +1 -0
- package/dist/esm/commands/login.js +13 -0
- package/dist/esm/commands/login.js.map +1 -0
- package/dist/esm/commands/logout.d.ts +4 -0
- package/dist/esm/commands/logout.d.ts.map +1 -0
- package/dist/esm/commands/logout.js +13 -0
- package/dist/esm/commands/logout.js.map +1 -0
- package/dist/esm/commands/pkg.d.ts +7 -0
- package/dist/esm/commands/pkg.d.ts.map +1 -0
- package/dist/esm/commands/pkg.js +123 -0
- package/dist/esm/commands/pkg.js.map +1 -0
- package/dist/esm/commands/query.d.ts +16 -0
- package/dist/esm/commands/query.d.ts.map +1 -0
- package/dist/esm/commands/query.js +124 -0
- package/dist/esm/commands/query.js.map +1 -0
- package/dist/esm/commands/run-exec.d.ts +6 -0
- package/dist/esm/commands/run-exec.d.ts.map +1 -0
- package/dist/esm/commands/run-exec.js +14 -0
- package/dist/esm/commands/run-exec.js.map +1 -0
- package/dist/esm/commands/run.d.ts +6 -0
- package/dist/esm/commands/run.d.ts.map +1 -0
- package/dist/esm/commands/run.js +37 -0
- package/dist/esm/commands/run.js.map +1 -0
- package/dist/esm/commands/token.d.ts +4 -0
- package/dist/esm/commands/token.d.ts.map +1 -0
- package/dist/esm/commands/token.js +30 -0
- package/dist/esm/commands/token.js.map +1 -0
- package/dist/esm/commands/uninstall.d.ts +10 -0
- package/dist/esm/commands/uninstall.d.ts.map +1 -0
- package/dist/esm/commands/uninstall.js +21 -0
- package/dist/esm/commands/uninstall.js.map +1 -0
- package/dist/esm/commands/whoami.d.ts +13 -0
- package/dist/esm/commands/whoami.d.ts.map +1 -0
- package/dist/esm/commands/whoami.js +19 -0
- package/dist/esm/commands/whoami.js.map +1 -0
- package/dist/esm/config/definition.d.ts +306 -0
- package/dist/esm/config/definition.d.ts.map +1 -0
- package/dist/esm/config/definition.js +517 -0
- package/dist/esm/config/definition.js.map +1 -0
- package/dist/esm/config/index.d.ts +206 -0
- package/dist/esm/config/index.d.ts.map +1 -0
- package/dist/esm/config/index.js +489 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/config/merge.d.ts +2 -0
- package/dist/esm/config/merge.d.ts.map +1 -0
- package/dist/esm/config/merge.js +23 -0
- package/dist/esm/config/merge.js.map +1 -0
- package/dist/esm/config/usage.d.ts +19 -0
- package/dist/esm/config/usage.d.ts.map +1 -0
- package/dist/esm/config/usage.js +40 -0
- package/dist/esm/config/usage.js.map +1 -0
- package/dist/esm/exec-command.d.ts +51 -0
- package/dist/esm/exec-command.d.ts.map +1 -0
- package/dist/esm/exec-command.js +199 -0
- package/dist/esm/exec-command.js.map +1 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +47 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/output.d.ts +21 -0
- package/dist/esm/output.d.ts.map +1 -0
- package/dist/esm/output.js +121 -0
- package/dist/esm/output.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parse-add-remove-args.d.ts +22 -0
- package/dist/esm/parse-add-remove-args.d.ts.map +1 -0
- package/dist/esm/parse-add-remove-args.js +71 -0
- package/dist/esm/parse-add-remove-args.js.map +1 -0
- package/dist/esm/print-err.d.ts +7 -0
- package/dist/esm/print-err.d.ts.map +1 -0
- package/dist/esm/print-err.js +115 -0
- package/dist/esm/print-err.js.map +1 -0
- package/dist/esm/read-password.d.ts +8 -0
- package/dist/esm/read-password.d.ts.map +1 -0
- package/dist/esm/read-password.js +33 -0
- package/dist/esm/read-password.js.map +1 -0
- package/dist/esm/start-gui.d.ts +9 -0
- package/dist/esm/start-gui.d.ts.map +1 -0
- package/dist/esm/start-gui.js +40 -0
- package/dist/esm/start-gui.js.map +1 -0
- package/dist/esm/view.d.ts +30 -0
- package/dist/esm/view.d.ts.map +1 -0
- package/dist/esm/view.js +31 -0
- package/dist/esm/view.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { actual, humanReadableOutput, jsonOutput, mermaidOutput, } from '@vltpkg/graph';
|
|
2
|
+
import { Query } from '@vltpkg/query';
|
|
3
|
+
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
4
|
+
import { commandUsage } from "../config/usage.js";
|
|
5
|
+
import { startGUI } from "../start-gui.js";
|
|
6
|
+
export const usage = () => commandUsage({
|
|
7
|
+
command: 'ls',
|
|
8
|
+
usage: [
|
|
9
|
+
'',
|
|
10
|
+
'[query | specs] [--view=human | json | mermaid | gui]',
|
|
11
|
+
],
|
|
12
|
+
description: `List installed dependencies matching given package names or resulting
|
|
13
|
+
packages from matching a given Dependency Selector Syntax query if one
|
|
14
|
+
is provided.
|
|
15
|
+
|
|
16
|
+
The vlt Dependency Selector Syntax is a CSS-like query language that
|
|
17
|
+
allows you to filter installed dependencies using a variety of metadata
|
|
18
|
+
in the form of CSS-like attributes, pseudo selectors & combinators.
|
|
19
|
+
|
|
20
|
+
Defaults to listing direct dependencies of a project and any configured
|
|
21
|
+
workspace.`,
|
|
22
|
+
examples: {
|
|
23
|
+
'': {
|
|
24
|
+
description: 'List direct dependencies of the current project / workspace',
|
|
25
|
+
},
|
|
26
|
+
'"*"': {
|
|
27
|
+
description: 'List all dependencies for the current project / workspace',
|
|
28
|
+
},
|
|
29
|
+
'foo bar baz': {
|
|
30
|
+
description: `List all dependencies named 'foo', 'bar', or 'baz'`,
|
|
31
|
+
},
|
|
32
|
+
[`'[name="@scoped/package"] > *'`]: {
|
|
33
|
+
description: 'Lists direct dependencies of a specific package',
|
|
34
|
+
},
|
|
35
|
+
[`'*:workspace > *:peer'`]: {
|
|
36
|
+
description: 'List all peer dependencies of all workspaces',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
options: {
|
|
40
|
+
view: {
|
|
41
|
+
value: '[human | json | mermaid | gui]',
|
|
42
|
+
description: 'Output format. Defaults to human-readable or json if no tty.',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
export const views = {
|
|
47
|
+
json: jsonOutput,
|
|
48
|
+
mermaid: mermaidOutput,
|
|
49
|
+
human: humanReadableOutput,
|
|
50
|
+
gui: async ({ queryString }, _, conf) => {
|
|
51
|
+
await startGUI(conf, '/explore?query=' + encodeURIComponent(queryString));
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
export const command = async (conf) => {
|
|
55
|
+
const monorepo = conf.options.monorepo;
|
|
56
|
+
const mainManifest = conf.options.packageJson.read(conf.options.projectRoot);
|
|
57
|
+
const graph = actual.load({
|
|
58
|
+
...conf.options,
|
|
59
|
+
mainManifest,
|
|
60
|
+
monorepo,
|
|
61
|
+
loadManifests: true,
|
|
62
|
+
});
|
|
63
|
+
const queryString = conf.positionals
|
|
64
|
+
.map(k => (/^[@\w-]/.test(k) ? `#${k.replace(/\//, '\\/')}` : k))
|
|
65
|
+
.join(', ');
|
|
66
|
+
const securityArchive = Query.hasSecuritySelectors(queryString) ?
|
|
67
|
+
await SecurityArchive.start({
|
|
68
|
+
graph,
|
|
69
|
+
specOptions: conf.options,
|
|
70
|
+
})
|
|
71
|
+
: undefined;
|
|
72
|
+
const query = new Query({
|
|
73
|
+
graph,
|
|
74
|
+
specOptions: conf.options,
|
|
75
|
+
securityArchive,
|
|
76
|
+
});
|
|
77
|
+
const projectQueryString = ':project, :project > *';
|
|
78
|
+
const selectImporters = [];
|
|
79
|
+
const importers = new Set();
|
|
80
|
+
if (monorepo) {
|
|
81
|
+
for (const workspace of monorepo.filter(conf.values)) {
|
|
82
|
+
const w = graph.nodes.get(workspace.id);
|
|
83
|
+
if (w) {
|
|
84
|
+
importers.add(w);
|
|
85
|
+
selectImporters.push(`[name="${w.name}"]`);
|
|
86
|
+
selectImporters.push(`[name="${w.name}"] > *`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (importers.size === 0) {
|
|
91
|
+
for (const importer of graph.importers) {
|
|
92
|
+
importers.add(importer);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const selectImportersQueryString = selectImporters.join(', ');
|
|
96
|
+
const defaultQueryString = (selectImporters.length &&
|
|
97
|
+
selectImporters.length < graph.importers.size) ?
|
|
98
|
+
selectImportersQueryString
|
|
99
|
+
: projectQueryString;
|
|
100
|
+
const { edges, nodes } = await query.search(queryString || defaultQueryString);
|
|
101
|
+
return {
|
|
102
|
+
importers,
|
|
103
|
+
edges,
|
|
104
|
+
nodes,
|
|
105
|
+
queryString: queryString || defaultQueryString,
|
|
106
|
+
highlightSelection: !!queryString,
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE;QACL,EAAE;QACF,uDAAuD;KACxD;IACD,WAAW,EAAE;;;;;;;;;iBASA;IACb,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,WAAW,EACT,6D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e,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7D,MAAM,kBAAkB,GACtB,CACE,eAAe,CAAC,MAAM;QACtB,eAAe,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAC9C,CAAC,CAAC;QACD,0BAA0B;QAC5B,CAAC,CAAC,kBAAkB,CAAA;IAEtB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,MAAM,CACzC,WAAW,IAAI,kBAAkB,CAClC,CAAA;IAED,OAAO;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,WAAW,EAAE,WAAW,IAAI,kBAAkB;QAC9C,kBAAkB,EAAE,CAAC,CAAC,WAAW;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport {\n actual,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n} from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ls',\n usage: [\n '',\n '[query | specs] [--view=human | json | mermaid | gui]',\n ],\n description: `List installed dependencies matching given package names or resulting\n packages from matching a given Dependency Selector Syntax query if one\n is provided.\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 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 '\"*\"': {\n description:\n 'List all dependencies for the current project / workspace',\n },\n 'foo bar baz': {\n description: `List all dependencies named 'foo', 'bar', or 'baz'`,\n },\n [`'[name=\"@scoped/package\"] > *'`]: {\n description:\n 'Lists direct dependencies of a specific package',\n },\n [`'*:workspace > *:peer'`]: {\n description: 'List all peer dependencies of all workspaces',\n },\n },\n options: {\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\nexport type ListResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI(\n conf,\n '/explore?query=' + encodeURIComponent(queryString),\n )\n },\n} as const satisfies Views<ListResult>\n\nexport const command: CommandFn<ListResult> = async conf => {\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo,\n loadManifests: true,\n })\n\n const queryString = conf.positionals\n .map(k => (/^[@\\w-]/.test(k) ? `#${k.replace(/\\//, '\\\\/')}` : k))\n .join(', ')\n const securityArchive =\n Query.hasSecuritySelectors(queryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n const projectQueryString = ':project, :project > *'\n const selectImporters: string[] = []\n\n const importers = new Set<Node>()\n if (monorepo) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) {\n importers.add(w)\n selectImporters.push(`[name=\"${w.name}\"]`)\n selectImporters.push(`[name=\"${w.name}\"] > *`)\n }\n }\n }\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n\n const selectImportersQueryString = selectImporters.join(', ')\n const defaultQueryString =\n (\n selectImporters.length &&\n selectImporters.length < graph.importers.size\n ) ?\n selectImportersQueryString\n : projectQueryString\n\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n )\n\n return {\n importers,\n edges,\n nodes,\n queryString: queryString || defaultQueryString,\n highlightSelection: !!queryString,\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,IAAI,CAGnC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RegistryClient } from '@vltpkg/registry-client';
|
|
2
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
export const usage = () => commandUsage({
|
|
4
|
+
command: 'login',
|
|
5
|
+
usage: [''],
|
|
6
|
+
description: `Authenticate against a registry, and store the token in
|
|
7
|
+
the appropriate config file for later use.`,
|
|
8
|
+
});
|
|
9
|
+
export const command = async (conf) => {
|
|
10
|
+
const rc = new RegistryClient(conf.options);
|
|
11
|
+
await rc.login(conf.options.registry);
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,WAAW,EAAE;6DAC4C;CAC1D,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAoB,KAAK,EAAC,IAAI,EAAC,EAAE;IACnD,MAAM,EAAE,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;AACvC,CAAC,CAAA","sourcesContent":["import { RegistryClient } from '@vltpkg/registry-client'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'login',\n usage: [''],\n description: `Authenticate against a registry, and store the token in\n the appropriate config file for later use.`,\n })\n\nexport const command: CommandFn<void> = async conf => {\n const rc = new RegistryClient(conf.options)\n await rc.login(conf.options.registry)\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/commands/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,IAAI,CAGnC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RegistryClient } from '@vltpkg/registry-client';
|
|
2
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
export const usage = () => commandUsage({
|
|
4
|
+
command: 'logout',
|
|
5
|
+
usage: [''],
|
|
6
|
+
description: `Log out of the default registry, deleting the token from
|
|
7
|
+
the local keychain, as well as destroying it on the server.`,
|
|
8
|
+
});
|
|
9
|
+
export const command = async (conf) => {
|
|
10
|
+
const rc = new RegistryClient(conf.options);
|
|
11
|
+
await rc.logout(conf.options.registry);
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,WAAW,EAAE;8EAC6D;CAC3E,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAoB,KAAK,EAAC,IAAI,EAAC,EAAE;IACnD,MAAM,EAAE,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC3C,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import { RegistryClient } from '@vltpkg/registry-client'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'logout',\n usage: [''],\n description: `Log out of the default registry, deleting the token from\n the local keychain, as well as destroying it on the server.`,\n })\n\nexport const command: CommandFn<void> = async conf => {\n const rc = new RegistryClient(conf.options)\n await rc.logout(conf.options.registry)\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
export declare const views: {
|
|
3
|
+
readonly human: (results: unknown, options: import("../view.ts").ViewOptions, config: import("../config/index.ts").ParsedConfig) => unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare const usage: CommandUsage;
|
|
6
|
+
export declare const command: CommandFn;
|
|
7
|
+
//# sourceMappingURL=pkg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM1D,eAAO,MAAM,KAAK;;CAmBQ,CAAA;AAE1B,eAAO,MAAM,KAAK,EAAE,YAoChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SA6BrB,CAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as dotProp from '@vltpkg/dot-prop';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import assert from 'node:assert';
|
|
4
|
+
import { commandUsage } from "../config/usage.js";
|
|
5
|
+
import { init } from '@vltpkg/init';
|
|
6
|
+
import { views as initViews } from "./init.js";
|
|
7
|
+
export const views = {
|
|
8
|
+
human: (results, options, config) => {
|
|
9
|
+
// `vlt pkg init` is an alias for `vlt init`
|
|
10
|
+
// use the same output handling
|
|
11
|
+
if (config.positionals[0] === 'init') {
|
|
12
|
+
return initViews.human(results, options, config);
|
|
13
|
+
}
|
|
14
|
+
return results && typeof results === 'object' ?
|
|
15
|
+
Object.fromEntries(Object.entries(results).filter(([k]) => typeof k !== 'symbol'))
|
|
16
|
+
: results;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const usage = () => commandUsage({
|
|
20
|
+
command: 'pkg',
|
|
21
|
+
usage: '[<command>] [<args>]',
|
|
22
|
+
description: 'Get or manipulate package.json values',
|
|
23
|
+
subcommands: {
|
|
24
|
+
get: {
|
|
25
|
+
usage: '[<key>]',
|
|
26
|
+
description: 'Get a single value',
|
|
27
|
+
},
|
|
28
|
+
init: {
|
|
29
|
+
usage: '',
|
|
30
|
+
description: 'Initialize a new package.json file in the current directory',
|
|
31
|
+
},
|
|
32
|
+
pick: {
|
|
33
|
+
usage: '[<key> [<key> ...]]',
|
|
34
|
+
description: 'Get multiple values or the entire package',
|
|
35
|
+
},
|
|
36
|
+
set: {
|
|
37
|
+
usage: '<key>=<value> [<key>=<value> ...]',
|
|
38
|
+
description: 'Set one or more key value pairs',
|
|
39
|
+
},
|
|
40
|
+
delete: {
|
|
41
|
+
usage: '<key> [<key> ...]',
|
|
42
|
+
description: 'Delete one or more keys from the package',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
examples: {
|
|
46
|
+
'set "array[1].key=value"': {
|
|
47
|
+
description: 'Set a value on an object inside an array',
|
|
48
|
+
},
|
|
49
|
+
'set "array[]=value"': {
|
|
50
|
+
description: 'Append a value to an array',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
export const command = async (conf) => {
|
|
55
|
+
const [sub, ...args] = conf.positionals;
|
|
56
|
+
if (sub === 'init') {
|
|
57
|
+
return await init({ cwd: process.cwd() });
|
|
58
|
+
}
|
|
59
|
+
const pkg = conf.options.packageJson;
|
|
60
|
+
const mani = pkg.read(conf.projectRoot);
|
|
61
|
+
switch (sub) {
|
|
62
|
+
case 'get':
|
|
63
|
+
return get(mani, args);
|
|
64
|
+
case 'pick':
|
|
65
|
+
return pick(mani, args);
|
|
66
|
+
case 'set':
|
|
67
|
+
return set(conf, mani, pkg, args);
|
|
68
|
+
case 'rm':
|
|
69
|
+
case 'remove':
|
|
70
|
+
case 'unset':
|
|
71
|
+
case 'delete':
|
|
72
|
+
return rm(conf, mani, pkg, args);
|
|
73
|
+
default: {
|
|
74
|
+
throw error('Unrecognized pkg command', {
|
|
75
|
+
code: 'EUSAGE',
|
|
76
|
+
found: sub,
|
|
77
|
+
validOptions: ['get', 'set', 'rm'],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const get = (mani, args) => {
|
|
83
|
+
const noArg = () => error('get requires not more than 1 argument. use `pick` to get more than 1.', { code: 'EUSAGE' }, noArg);
|
|
84
|
+
if (args.length !== 1) {
|
|
85
|
+
if (args.length > 1) {
|
|
86
|
+
throw noArg();
|
|
87
|
+
}
|
|
88
|
+
return pick(mani, args);
|
|
89
|
+
}
|
|
90
|
+
assert(args[0], noArg());
|
|
91
|
+
return dotProp.get(mani, args[0]);
|
|
92
|
+
};
|
|
93
|
+
const pick = (mani, args) => {
|
|
94
|
+
return args.length ?
|
|
95
|
+
args.reduce((acc, key) => dotProp.set(acc, key, dotProp.get(mani, key)), {})
|
|
96
|
+
: mani;
|
|
97
|
+
};
|
|
98
|
+
const set = (conf, mani, pkg, args) => {
|
|
99
|
+
if (args.length < 1) {
|
|
100
|
+
throw error('set requires arguments', { code: 'EUSAGE' });
|
|
101
|
+
}
|
|
102
|
+
const res = args.reduce((acc, p) => {
|
|
103
|
+
const index = p.indexOf('=');
|
|
104
|
+
if (index === -1) {
|
|
105
|
+
throw error('set arguments must contain `=`', {
|
|
106
|
+
code: 'EUSAGE',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return dotProp.set(acc, p.substring(0, index), p.substring(index + 1));
|
|
110
|
+
}, mani);
|
|
111
|
+
pkg.write(conf.projectRoot, res);
|
|
112
|
+
};
|
|
113
|
+
const rm = (conf, mani, pkg, args) => {
|
|
114
|
+
if (args.length < 1) {
|
|
115
|
+
throw error('rm requires arguments', { code: 'EUSAGE' });
|
|
116
|
+
}
|
|
117
|
+
const res = args.reduce((acc, key) => {
|
|
118
|
+
dotProp.del(acc, key);
|
|
119
|
+
return acc;
|
|
120
|
+
}, mani);
|
|
121
|
+
pkg.write(conf.projectRoot, res);
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=pkg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAE9C,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAA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EAAE,QAAQ;aACf,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAChB,GAAG,EACH,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EACrB,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CACvB,CAAA;IACH,CAAC,EAAE,IAAI,CAAC,CAAA;IAER,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC,CAAA;AAED,MAAM,EAAE,GAAG,CACT,IAAkB,EAClB,IAAc,EACd,GAAgB,EAChB,IAAc,EACd,EAAE;IACF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACnC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;QACrB,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,IAAI,CAAC,CAAA;IAER,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC,CAAA","sourcesContent":["import * as dotProp from '@vltpkg/dot-prop'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { Manifest } from '@vltpkg/types'\nimport assert from 'node:assert'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { init } from '@vltpkg/init'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { Views } from '../view.ts'\nimport { views as initViews } from './init.ts'\n\nexport const views = {\n human: (results, options, config) => {\n // `vlt pkg init` is an alias for `vlt init`\n // use the same output handling\n if (config.positionals[0] === 'init') {\n return initViews.human(\n results as InitFileResults,\n options,\n config,\n )\n }\n return results && typeof results === 'object' ?\n Object.fromEntries(\n Object.entries(results).filter(\n ([k]) => typeof k !== 'symbol',\n ),\n )\n : results\n },\n} as const satisfies Views\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pkg',\n usage: '[<command>] [<args>]',\n description: 'Get or manipulate package.json values',\n subcommands: {\n get: {\n usage: '[<key>]',\n description: 'Get a single value',\n },\n init: {\n usage: '',\n description:\n 'Initialize a new package.json file in the current directory',\n },\n pick: {\n usage: '[<key> [<key> ...]]',\n description: 'Get multiple values or the entire package',\n },\n set: {\n usage: '<key>=<value> [<key>=<value> ...]',\n description: 'Set one or more key value pairs',\n },\n delete: {\n usage: '<key> [<key> ...]',\n description: 'Delete one or more keys from the package',\n },\n },\n examples: {\n 'set \"array[1].key=value\"': {\n description: 'Set a value on an object inside an array',\n },\n 'set \"array[]=value\"': {\n description: 'Append a value to an array',\n },\n },\n })\n\nexport const command: CommandFn = async conf => {\n const [sub, ...args] = conf.positionals\n if (sub === 'init') {\n return await init({ cwd: process.cwd() })\n }\n\n const pkg = conf.options.packageJson\n const mani = pkg.read(conf.projectRoot)\n\n switch (sub) {\n case 'get':\n return get(mani, args)\n case 'pick':\n return pick(mani, args)\n case 'set':\n return set(conf, mani, pkg, args)\n case 'rm':\n case 'remove':\n case 'unset':\n case 'delete':\n return rm(conf, mani, pkg, args)\n default: {\n throw error('Unrecognized pkg command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['get', 'set', 'rm'],\n })\n }\n }\n}\n\nconst get = (mani: Manifest, args: string[]) => {\n const noArg = () =>\n error(\n 'get requires not more than 1 argument. use `pick` to get more than 1.',\n { code: 'EUSAGE' },\n noArg,\n )\n if (args.length !== 1) {\n if (args.length > 1) {\n throw noArg()\n }\n return pick(mani, args)\n }\n assert(args[0], noArg())\n return dotProp.get(mani, args[0])\n}\n\nconst pick = (mani: Manifest, args: string[]) => {\n return args.length ?\n args.reduce(\n (acc, key) => dotProp.set(acc, key, dotProp.get(mani, key)),\n {},\n )\n : mani\n}\n\nconst set = (\n conf: LoadedConfig,\n mani: Manifest,\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('set requires arguments', { code: 'EUSAGE' })\n }\n\n const res = args.reduce((acc, p) => {\n const index = p.indexOf('=')\n if (index === -1) {\n throw error('set arguments must contain `=`', {\n code: 'EUSAGE',\n })\n }\n return dotProp.set(\n acc,\n p.substring(0, index),\n p.substring(index + 1),\n )\n }, mani)\n\n pkg.write(conf.projectRoot, res)\n}\n\nconst rm = (\n conf: LoadedConfig,\n mani: Manifest,\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('rm requires arguments', { code: 'EUSAGE' })\n }\n\n const res = args.reduce((acc, key) => {\n dotProp.del(acc, key)\n return acc\n }, mani)\n\n pkg.write(conf.projectRoot, res)\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HumanReadableOutputGraph, JSONOutputGraph, MermaidOutputGraph } from '@vltpkg/graph';
|
|
2
|
+
import { humanReadableOutput, jsonOutput, mermaidOutput } from '@vltpkg/graph';
|
|
3
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
4
|
+
export declare const usage: CommandUsage;
|
|
5
|
+
type QueryResult = JSONOutputGraph & MermaidOutputGraph & HumanReadableOutputGraph & {
|
|
6
|
+
queryString: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const views: {
|
|
9
|
+
readonly json: typeof jsonOutput;
|
|
10
|
+
readonly mermaid: typeof mermaidOutput;
|
|
11
|
+
readonly human: typeof humanReadableOutput;
|
|
12
|
+
readonly gui: ({ queryString }: QueryResult, _: import("../view.ts").ViewOptions, conf: import("../config/index.js").ParsedConfig) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export declare const command: CommandFn<QueryResult>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AAKtB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK1D,eAAO,MAAM,KAAK,EAAE,YA4ChB,CAAA;AAEJ,KAAK,WAAW,GAAG,eAAe,GAChC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAqBpD,eAAO,MAAM,KAAK;;;;;CAUqB,CAAA;AAEvC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CA0D1C,CAAA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { actual, humanReadableOutput, jsonOutput, mermaidOutput, } from '@vltpkg/graph';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import { Query } from '@vltpkg/query';
|
|
4
|
+
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
5
|
+
import { commandUsage } from "../config/usage.js";
|
|
6
|
+
import { startGUI } from "../start-gui.js";
|
|
7
|
+
export const usage = () => commandUsage({
|
|
8
|
+
command: 'query',
|
|
9
|
+
usage: [
|
|
10
|
+
'',
|
|
11
|
+
'<query> --view=<human | json | mermaid | gui>',
|
|
12
|
+
'<query> --expect-results=<comparison string>',
|
|
13
|
+
],
|
|
14
|
+
description: `List installed dependencies matching the provided query.
|
|
15
|
+
|
|
16
|
+
The vlt Dependency Selector Syntax is a CSS-like query language that
|
|
17
|
+
allows you to filter installed dependencies using a variety of metadata
|
|
18
|
+
in the form of CSS-like attributes, pseudo selectors & combinators.`,
|
|
19
|
+
examples: {
|
|
20
|
+
[`'#foo'`]: {
|
|
21
|
+
description: 'Query dependencies declared as "foo"',
|
|
22
|
+
},
|
|
23
|
+
[`'*:workspace > *:peer'`]: {
|
|
24
|
+
description: 'Query all peer dependencies of workspaces',
|
|
25
|
+
},
|
|
26
|
+
[`':project > *:attr(scripts, [build])'`]: {
|
|
27
|
+
description: 'Query all direct project dependencies with a "build" script',
|
|
28
|
+
},
|
|
29
|
+
[`'[name^="@vltpkg"]'`]: {
|
|
30
|
+
description: 'Query packages with names starting with "@vltpkg"',
|
|
31
|
+
},
|
|
32
|
+
[`'*:license(copyleft) --expect-results=0'`]: {
|
|
33
|
+
description: 'Errors if a copyleft licensed package is found',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
options: {
|
|
37
|
+
'expect-results': {
|
|
38
|
+
value: '[number | string]',
|
|
39
|
+
description: '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.',
|
|
40
|
+
},
|
|
41
|
+
view: {
|
|
42
|
+
value: '[human | json | mermaid | gui]',
|
|
43
|
+
description: 'Output format. Defaults to human-readable or json if no tty.',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
const validateExpectedResult = (conf, edges) => {
|
|
48
|
+
const expectResults = conf.values['expect-results'];
|
|
49
|
+
if (expectResults?.startsWith('>=')) {
|
|
50
|
+
return edges.length >= parseInt(expectResults.slice(2).trim(), 10);
|
|
51
|
+
}
|
|
52
|
+
else if (expectResults?.startsWith('<=')) {
|
|
53
|
+
return edges.length <= parseInt(expectResults.slice(2).trim(), 10);
|
|
54
|
+
}
|
|
55
|
+
else if (expectResults?.startsWith('>')) {
|
|
56
|
+
return edges.length > parseInt(expectResults.slice(1).trim(), 10);
|
|
57
|
+
}
|
|
58
|
+
else if (expectResults?.startsWith('<')) {
|
|
59
|
+
return edges.length < parseInt(expectResults.slice(1).trim(), 10);
|
|
60
|
+
}
|
|
61
|
+
else if (expectResults) {
|
|
62
|
+
return edges.length === parseInt(expectResults.trim(), 10);
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
export const views = {
|
|
67
|
+
json: jsonOutput,
|
|
68
|
+
mermaid: mermaidOutput,
|
|
69
|
+
human: humanReadableOutput,
|
|
70
|
+
gui: async ({ queryString }, _, conf) => {
|
|
71
|
+
await startGUI(conf, '/explore?query=' + encodeURIComponent(queryString));
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
export const command = async (conf) => {
|
|
75
|
+
const monorepo = conf.options.monorepo;
|
|
76
|
+
const mainManifest = conf.options.packageJson.read(conf.options.projectRoot);
|
|
77
|
+
const graph = actual.load({
|
|
78
|
+
...conf.options,
|
|
79
|
+
mainManifest,
|
|
80
|
+
monorepo,
|
|
81
|
+
loadManifests: true,
|
|
82
|
+
});
|
|
83
|
+
const defaultQueryString = '*';
|
|
84
|
+
const queryString = conf.positionals[0];
|
|
85
|
+
const securityArchive = queryString && Query.hasSecuritySelectors(queryString) ?
|
|
86
|
+
await SecurityArchive.start({
|
|
87
|
+
graph,
|
|
88
|
+
specOptions: conf.options,
|
|
89
|
+
})
|
|
90
|
+
: undefined;
|
|
91
|
+
const query = new Query({
|
|
92
|
+
graph,
|
|
93
|
+
specOptions: conf.options,
|
|
94
|
+
securityArchive,
|
|
95
|
+
});
|
|
96
|
+
const { edges, nodes } = await query.search(queryString || defaultQueryString);
|
|
97
|
+
const importers = new Set();
|
|
98
|
+
if (monorepo) {
|
|
99
|
+
for (const workspace of monorepo.filter(conf.values)) {
|
|
100
|
+
const w = graph.nodes.get(workspace.id);
|
|
101
|
+
if (w)
|
|
102
|
+
importers.add(w);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (importers.size === 0) {
|
|
106
|
+
for (const importer of graph.importers) {
|
|
107
|
+
importers.add(importer);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!validateExpectedResult(conf, edges)) {
|
|
111
|
+
throw error('Unexpected number of items', {
|
|
112
|
+
found: edges.length,
|
|
113
|
+
wanted: conf.values['expect-results'],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
importers,
|
|
118
|
+
edges,
|
|
119
|
+
nodes,
|
|
120
|
+
highlightSelection: !!queryString,
|
|
121
|
+
queryString: queryString || defaultQueryString,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/commands/query.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,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;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAI1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE;QACL,EAAE;QACF,+CAA+C;QAC/C,8CAA8C;KAC/C;IACD,WAAW,EAAE;;;;2EAI0D;IACvE,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;YA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AChB,CAAC,CAAA;IAEF,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,MAAM,CACzC,WAAW,IAAI,kBAAkB,CAClC,CAAA;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,EAAQ,CAAA;IACjC,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,GAAqB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;YACzD,IAAI,CAAC;gBAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,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;QACT,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,WAAW;QACjC,WAAW,EAAE,WAAW,IAAI,kBAAkB;KAC/C,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type {\n EdgeLike,\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport {\n actual,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n} from '@vltpkg/graph'\nimport { error } from '@vltpkg/error-cause'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { Views } from '../view.ts'\nimport type { LoadedConfig } from '../config/index.js'\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 ],\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 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 },\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 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?query=' + encodeURIComponent(queryString),\n )\n },\n} as const satisfies Views<QueryResult>\n\nexport const command: CommandFn<QueryResult> = async conf => {\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo,\n loadManifests: true,\n })\n\n const defaultQueryString = '*'\n const queryString = conf.positionals[0]\n const securityArchive =\n queryString && Query.hasSecuritySelectors(queryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n )\n\n const importers = new Set<Node>()\n if (monorepo) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) importers.add(w)\n }\n }\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n\n 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 edges,\n nodes,\n highlightSelection: !!queryString,\n queryString: queryString || defaultQueryString,\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecResult } from '../exec-command.ts';
|
|
2
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
+
export { views } from '../exec-command.ts';
|
|
4
|
+
export declare const usage: CommandUsage;
|
|
5
|
+
export declare const command: CommandFn<ExecResult>;
|
|
6
|
+
//# sourceMappingURL=run-exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-exec.d.ts","sourceRoot":"","sources":["../../../src/commands/run-exec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAQhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CACa,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { runExec, runExecFG } from '@vltpkg/run';
|
|
2
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
import { ExecCommand } from "../exec-command.js";
|
|
4
|
+
export { views } from "../exec-command.js";
|
|
5
|
+
export const usage = () => commandUsage({
|
|
6
|
+
command: 'run-exec',
|
|
7
|
+
usage: '[command ...]',
|
|
8
|
+
description: `If the first argument is a defined script in package.json, then this is
|
|
9
|
+
equivalent to \`vlt run\`.
|
|
10
|
+
|
|
11
|
+
If not, then this is equivalent to \`vlt exec\`.`,
|
|
12
|
+
});
|
|
13
|
+
export const command = async (conf) => await new ExecCommand(conf, runExec, runExecFG).run();
|
|
14
|
+
//# sourceMappingURL=run-exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-exec.js","sourceRoot":"","sources":["../../../src/commands/run-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE;;;mEAGkD;CAChE,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE,CACzD,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,GAAG,EAAE,CAAA","sourcesContent":["import { runExec, runExecFG } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'run-exec',\n usage: '[command ...]',\n description: `If the first argument is a defined script in package.json, then this is\n equivalent to \\`vlt run\\`.\n\n If not, then this is equivalent to \\`vlt exec\\`.`,\n })\n\nexport const command: CommandFn<ExecResult> = async conf =>\n await new ExecCommand(conf, runExec, runExecFG).run()\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ExecResult } from '../exec-command.ts';
|
|
2
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
+
export { views } from '../exec-command.ts';
|
|
4
|
+
export declare const usage: CommandUsage;
|
|
5
|
+
export declare const command: CommandFn<ExecResult>;
|
|
6
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAQhB,CAAA;AA8BJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CACR,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { run, runFG } from '@vltpkg/run';
|
|
2
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
import { ExecCommand } from "../exec-command.js";
|
|
4
|
+
export { views } from "../exec-command.js";
|
|
5
|
+
export const usage = () => commandUsage({
|
|
6
|
+
command: 'run',
|
|
7
|
+
usage: '<script> [args ...]',
|
|
8
|
+
description: `Run a script defined in 'package.json', passing along any extra
|
|
9
|
+
arguments. Note that vlt config values must be specified *before*
|
|
10
|
+
the script name, because everything after that is handed off to
|
|
11
|
+
the script process.`,
|
|
12
|
+
});
|
|
13
|
+
class RunCommand extends ExecCommand {
|
|
14
|
+
constructor(conf) {
|
|
15
|
+
super(conf, run, runFG);
|
|
16
|
+
}
|
|
17
|
+
// do not provide the interactive shell arg, just do nothing
|
|
18
|
+
// so that it falls back up to the noArgsSingle() method
|
|
19
|
+
defaultArg0() { }
|
|
20
|
+
noArgsSingle() {
|
|
21
|
+
// called when there's no arg0, with a single workspace or root
|
|
22
|
+
const ws = this.monorepo?.values().next().value;
|
|
23
|
+
const cwd = ws?.fullpath ?? this.projectRoot;
|
|
24
|
+
const { scripts = {} } = this.conf.options.packageJson.read(cwd);
|
|
25
|
+
return scripts;
|
|
26
|
+
}
|
|
27
|
+
noArgsMulti() {
|
|
28
|
+
const scriptSet = {};
|
|
29
|
+
for (const [ws, scripts] of this.monorepo.runSync(({ manifest: { scripts } }) => scripts)) {
|
|
30
|
+
if (scripts)
|
|
31
|
+
scriptSet[ws.path] = scripts;
|
|
32
|
+
}
|
|
33
|
+
return scriptSet;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const command = async (conf) => await new RunCommand(conf).run();
|
|
37
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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gBAAE,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;QAC3C,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE,CACzD,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA","sourcesContent":["import { run, runFG } from '@vltpkg/run'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type {\n ExecResult,\n MultiScriptSet,\n ScriptSet,\n} from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'run',\n usage: '<script> [args ...]',\n description: `Run a script defined in 'package.json', passing along any extra\n arguments. Note that vlt config values must be specified *before*\n the script name, because everything after that is handed off to\n the script process.`,\n })\n\nclass RunCommand extends ExecCommand<typeof run, typeof runFG> {\n constructor(conf: LoadedConfig) {\n super(conf, run, runFG)\n }\n\n // do not provide the interactive shell arg, just do nothing\n // so that it falls back up to the noArgsSingle() method\n defaultArg0(): undefined {}\n\n noArgsSingle(): ScriptSet {\n // called when there's no arg0, with a single workspace or root\n const ws = this.monorepo?.values().next().value\n const cwd = ws?.fullpath ?? this.projectRoot\n const { scripts = {} } = this.conf.options.packageJson.read(cwd)\n return scripts\n }\n\n noArgsMulti(this: this & { monorepo: Monorepo }): MultiScriptSet {\n const scriptSet: MultiScriptSet = {}\n for (const [ws, scripts] of this.monorepo.runSync(\n ({ manifest: { scripts } }) => scripts,\n )) {\n if (scripts) scriptSet[ws.path] = scripts\n }\n return scriptSet\n }\n}\n\nexport const command: CommandFn<ExecResult> = async conf =>\n await new RunCommand(conf).run()\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/commands/token.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAKhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,IAAI,CAyBnC,CAAA"}
|