@vltpkg/cli-sdk 1.0.0-rc.2 → 1.0.0-rc.22
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/package.json +66 -83
- package/dist/esm/commands/build.d.ts +0 -25
- package/dist/esm/commands/build.d.ts.map +0 -1
- package/dist/esm/commands/build.js +0 -102
- package/dist/esm/commands/build.js.map +0 -1
- package/dist/esm/commands/cache.d.ts +0 -65
- package/dist/esm/commands/cache.d.ts.map +0 -1
- package/dist/esm/commands/cache.js +0 -257
- package/dist/esm/commands/cache.js.map +0 -1
- package/dist/esm/commands/ci.d.ts +0 -11
- package/dist/esm/commands/ci.d.ts.map +0 -1
- package/dist/esm/commands/ci.js +0 -32
- package/dist/esm/commands/ci.js.map +0 -1
- package/dist/esm/commands/config.d.ts +0 -6
- package/dist/esm/commands/config.d.ts.map +0 -1
- package/dist/esm/commands/config.js +0 -424
- package/dist/esm/commands/config.js.map +0 -1
- package/dist/esm/commands/docs.d.ts +0 -18
- package/dist/esm/commands/docs.d.ts.map +0 -1
- package/dist/esm/commands/docs.js +0 -154
- package/dist/esm/commands/docs.js.map +0 -1
- package/dist/esm/commands/exec-cache.d.ts +0 -49
- package/dist/esm/commands/exec-cache.d.ts.map +0 -1
- package/dist/esm/commands/exec-cache.js +0 -146
- package/dist/esm/commands/exec-cache.js.map +0 -1
- package/dist/esm/commands/exec-local.d.ts +0 -6
- package/dist/esm/commands/exec-local.d.ts.map +0 -1
- package/dist/esm/commands/exec-local.js +0 -24
- package/dist/esm/commands/exec-local.js.map +0 -1
- package/dist/esm/commands/exec.d.ts +0 -9
- package/dist/esm/commands/exec.d.ts.map +0 -1
- package/dist/esm/commands/exec.js +0 -87
- package/dist/esm/commands/exec.js.map +0 -1
- package/dist/esm/commands/help.d.ts +0 -4
- package/dist/esm/commands/help.d.ts.map +0 -1
- package/dist/esm/commands/help.js +0 -39
- package/dist/esm/commands/help.js.map +0 -1
- package/dist/esm/commands/init.d.ts +0 -8
- package/dist/esm/commands/init.d.ts.map +0 -1
- package/dist/esm/commands/init.js +0 -111
- package/dist/esm/commands/init.js.map +0 -1
- package/dist/esm/commands/install/reporter.d.ts +0 -11
- package/dist/esm/commands/install/reporter.d.ts.map +0 -1
- package/dist/esm/commands/install/reporter.js +0 -94
- package/dist/esm/commands/install/reporter.js.map +0 -1
- package/dist/esm/commands/install.d.ts +0 -28
- package/dist/esm/commands/install.d.ts.map +0 -1
- package/dist/esm/commands/install.js +0 -45
- package/dist/esm/commands/install.js.map +0 -1
- package/dist/esm/commands/list.d.ts +0 -15
- package/dist/esm/commands/list.d.ts.map +0 -1
- package/dist/esm/commands/list.js +0 -199
- package/dist/esm/commands/list.js.map +0 -1
- package/dist/esm/commands/login.d.ts +0 -4
- package/dist/esm/commands/login.d.ts.map +0 -1
- package/dist/esm/commands/login.js +0 -13
- package/dist/esm/commands/login.js.map +0 -1
- package/dist/esm/commands/logout.d.ts +0 -4
- package/dist/esm/commands/logout.d.ts.map +0 -1
- package/dist/esm/commands/logout.js +0 -13
- package/dist/esm/commands/logout.js.map +0 -1
- package/dist/esm/commands/pack.d.ts +0 -32
- package/dist/esm/commands/pack.d.ts.map +0 -1
- package/dist/esm/commands/pack.js +0 -147
- package/dist/esm/commands/pack.js.map +0 -1
- package/dist/esm/commands/pkg.d.ts +0 -7
- package/dist/esm/commands/pkg.d.ts.map +0 -1
- package/dist/esm/commands/pkg.js +0 -206
- package/dist/esm/commands/pkg.js.map +0 -1
- package/dist/esm/commands/publish.d.ts +0 -22
- package/dist/esm/commands/publish.d.ts.map +0 -1
- package/dist/esm/commands/publish.js +0 -245
- package/dist/esm/commands/publish.js.map +0 -1
- package/dist/esm/commands/query.d.ts +0 -16
- package/dist/esm/commands/query.d.ts.map +0 -1
- package/dist/esm/commands/query.js +0 -214
- package/dist/esm/commands/query.js.map +0 -1
- package/dist/esm/commands/run-exec.d.ts +0 -6
- package/dist/esm/commands/run-exec.d.ts.map +0 -1
- package/dist/esm/commands/run-exec.js +0 -14
- package/dist/esm/commands/run-exec.js.map +0 -1
- package/dist/esm/commands/run.d.ts +0 -6
- package/dist/esm/commands/run.d.ts.map +0 -1
- package/dist/esm/commands/run.js +0 -36
- package/dist/esm/commands/run.js.map +0 -1
- package/dist/esm/commands/serve.d.ts +0 -14
- package/dist/esm/commands/serve.d.ts.map +0 -1
- package/dist/esm/commands/serve.js +0 -103
- package/dist/esm/commands/serve.js.map +0 -1
- package/dist/esm/commands/token.d.ts +0 -4
- package/dist/esm/commands/token.d.ts.map +0 -1
- package/dist/esm/commands/token.js +0 -30
- package/dist/esm/commands/token.js.map +0 -1
- package/dist/esm/commands/uninstall.d.ts +0 -16
- package/dist/esm/commands/uninstall.d.ts.map +0 -1
- package/dist/esm/commands/uninstall.js +0 -26
- package/dist/esm/commands/uninstall.js.map +0 -1
- package/dist/esm/commands/update.d.ts +0 -14
- package/dist/esm/commands/update.d.ts.map +0 -1
- package/dist/esm/commands/update.js +0 -41
- package/dist/esm/commands/update.js.map +0 -1
- package/dist/esm/commands/version.d.ts +0 -26
- package/dist/esm/commands/version.d.ts.map +0 -1
- package/dist/esm/commands/version.js +0 -226
- package/dist/esm/commands/version.js.map +0 -1
- package/dist/esm/commands/whoami.d.ts +0 -13
- package/dist/esm/commands/whoami.d.ts.map +0 -1
- package/dist/esm/commands/whoami.js +0 -19
- package/dist/esm/commands/whoami.js.map +0 -1
- package/dist/esm/config/definition.d.ts +0 -404
- package/dist/esm/config/definition.d.ts.map +0 -1
- package/dist/esm/config/definition.js +0 -657
- package/dist/esm/config/definition.js.map +0 -1
- package/dist/esm/config/index.d.ts +0 -219
- package/dist/esm/config/index.d.ts.map +0 -1
- package/dist/esm/config/index.js +0 -454
- package/dist/esm/config/index.js.map +0 -1
- package/dist/esm/config/merge.d.ts +0 -4
- package/dist/esm/config/merge.d.ts.map +0 -1
- package/dist/esm/config/merge.js +0 -28
- package/dist/esm/config/merge.js.map +0 -1
- package/dist/esm/config/usage.d.ts +0 -19
- package/dist/esm/config/usage.d.ts.map +0 -1
- package/dist/esm/config/usage.js +0 -40
- package/dist/esm/config/usage.js.map +0 -1
- package/dist/esm/custom-help.d.ts +0 -9
- package/dist/esm/custom-help.d.ts.map +0 -1
- package/dist/esm/custom-help.js +0 -400
- package/dist/esm/custom-help.js.map +0 -1
- package/dist/esm/exec-command.d.ts +0 -53
- package/dist/esm/exec-command.d.ts.map +0 -1
- package/dist/esm/exec-command.js +0 -308
- package/dist/esm/exec-command.js.map +0 -1
- package/dist/esm/index.d.ts +0 -4
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -73
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/load-command.d.ts +0 -16
- package/dist/esm/load-command.d.ts.map +0 -1
- package/dist/esm/load-command.js +0 -21
- package/dist/esm/load-command.js.map +0 -1
- package/dist/esm/output.d.ts +0 -21
- package/dist/esm/output.d.ts.map +0 -1
- package/dist/esm/output.js +0 -126
- package/dist/esm/output.js.map +0 -1
- package/dist/esm/pack-tarball.d.ts +0 -22
- package/dist/esm/pack-tarball.d.ts.map +0 -1
- package/dist/esm/pack-tarball.js +0 -249
- package/dist/esm/pack-tarball.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/parse-add-remove-args.d.ts +0 -22
- package/dist/esm/parse-add-remove-args.d.ts.map +0 -1
- package/dist/esm/parse-add-remove-args.js +0 -71
- package/dist/esm/parse-add-remove-args.js.map +0 -1
- package/dist/esm/print-err.d.ts +0 -14
- package/dist/esm/print-err.d.ts.map +0 -1
- package/dist/esm/print-err.js +0 -178
- package/dist/esm/print-err.js.map +0 -1
- package/dist/esm/query-host-contexts.d.ts +0 -16
- package/dist/esm/query-host-contexts.d.ts.map +0 -1
- package/dist/esm/query-host-contexts.js +0 -135
- package/dist/esm/query-host-contexts.js.map +0 -1
- package/dist/esm/read-password.d.ts +0 -8
- package/dist/esm/read-password.d.ts.map +0 -1
- package/dist/esm/read-password.js +0 -33
- package/dist/esm/read-password.js.map +0 -1
- package/dist/esm/start-gui.d.ts +0 -10
- package/dist/esm/start-gui.d.ts.map +0 -1
- package/dist/esm/start-gui.js +0 -60
- package/dist/esm/start-gui.js.map +0 -1
- package/dist/esm/view.d.ts +0 -30
- package/dist/esm/view.d.ts.map +0 -1
- package/dist/esm/view.js +0 -31
- package/dist/esm/view.js.map +0 -1
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import * as dotProp from '@vltpkg/dot-prop';
|
|
3
|
-
import { error } from '@vltpkg/error-cause';
|
|
4
|
-
import { commandUsage } from "../config/usage.js";
|
|
5
|
-
import { get, set, edit, list, del } from '@vltpkg/config';
|
|
6
|
-
import { load, find } from '@vltpkg/vlt-json';
|
|
7
|
-
export const views = {
|
|
8
|
-
human: results => {
|
|
9
|
-
// Handle string arrays (like list output)
|
|
10
|
-
if (Array.isArray(results) && typeof results[0] === 'string') {
|
|
11
|
-
return results.join('\n');
|
|
12
|
-
}
|
|
13
|
-
// For all other values (primitives, objects, arrays), use JSON formatting like vlt pkg
|
|
14
|
-
return JSON.stringify(results, null, 2);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
export const usage = () => commandUsage({
|
|
18
|
-
command: 'config',
|
|
19
|
-
usage: '[<command>] [<args>]',
|
|
20
|
-
description: 'Get or manipulate vlt configuration values',
|
|
21
|
-
subcommands: {
|
|
22
|
-
get: {
|
|
23
|
-
usage: '[<key>] [--config=<all | user | project>]',
|
|
24
|
-
description: 'Get a single config value. Use --config to specify which config to read from.',
|
|
25
|
-
},
|
|
26
|
-
pick: {
|
|
27
|
-
usage: '[<key> [<key> ...]] [--config=<all | user | project>]',
|
|
28
|
-
description: 'Get multiple config values or all configuration. Use --config to specify which config to read from.',
|
|
29
|
-
},
|
|
30
|
-
list: {
|
|
31
|
-
usage: '[--config=<all | user | project>]',
|
|
32
|
-
description: 'Print configuration settings. --config=all shows merged config (default), --config=user shows only user config, --config=project shows only project config.',
|
|
33
|
-
},
|
|
34
|
-
set: {
|
|
35
|
-
usage: '<key>=<value> [<key>=<value> ...] [--config=<all | user | project>]',
|
|
36
|
-
description: `Set config values. By default (or with --config=all), these are
|
|
37
|
-
written to the project config file, \`vlt.json\`
|
|
38
|
-
in the root of the project. To set things for all
|
|
39
|
-
projects, run with \`--config=user\`.`,
|
|
40
|
-
},
|
|
41
|
-
delete: {
|
|
42
|
-
usage: '<key> [<key> ...] [--config=<all | user | project>]',
|
|
43
|
-
description: `Delete the named config fields. If no values remain in
|
|
44
|
-
the config file, delete the file as well. By default
|
|
45
|
-
(or with --config=all), operates on the \`vlt.json\` file in
|
|
46
|
-
the root of the current project. To delete a config field from
|
|
47
|
-
the user config file, specify \`--config=user\`.`,
|
|
48
|
-
},
|
|
49
|
-
edit: {
|
|
50
|
-
usage: '[--config=<all | user | project>]',
|
|
51
|
-
description: 'Edit the configuration file. By default (or with --config=all), edits the project config file.',
|
|
52
|
-
},
|
|
53
|
-
location: {
|
|
54
|
-
usage: '[--config=<user | project>]',
|
|
55
|
-
description: 'Show the file path of the configuration file. Defaults to project config.',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
export const command = async (conf) => {
|
|
60
|
-
const [sub] = conf.positionals;
|
|
61
|
-
assert(sub, error('config command requires a subcommand', {
|
|
62
|
-
code: 'EUSAGE',
|
|
63
|
-
validOptions: [
|
|
64
|
-
'get',
|
|
65
|
-
'pick',
|
|
66
|
-
'set',
|
|
67
|
-
'delete',
|
|
68
|
-
'list',
|
|
69
|
-
'edit',
|
|
70
|
-
'location',
|
|
71
|
-
],
|
|
72
|
-
}));
|
|
73
|
-
switch (sub) {
|
|
74
|
-
case 'set':
|
|
75
|
-
return configSet(conf);
|
|
76
|
-
case 'get':
|
|
77
|
-
return configGet(conf);
|
|
78
|
-
case 'pick':
|
|
79
|
-
return configPick(conf);
|
|
80
|
-
case 'ls':
|
|
81
|
-
case 'list':
|
|
82
|
-
return configList(conf);
|
|
83
|
-
case 'edit':
|
|
84
|
-
return configEdit(conf);
|
|
85
|
-
case 'location':
|
|
86
|
-
return configLocation(conf);
|
|
87
|
-
case 'del':
|
|
88
|
-
case 'delete':
|
|
89
|
-
case 'rm':
|
|
90
|
-
case 'remove':
|
|
91
|
-
case 'unset':
|
|
92
|
-
return configDelete(conf);
|
|
93
|
-
default: {
|
|
94
|
-
throw error('Unrecognized config command', {
|
|
95
|
-
code: 'EUSAGE',
|
|
96
|
-
found: sub,
|
|
97
|
-
validOptions: [
|
|
98
|
-
'get',
|
|
99
|
-
'pick',
|
|
100
|
-
'set',
|
|
101
|
-
'delete',
|
|
102
|
-
'list',
|
|
103
|
-
'edit',
|
|
104
|
-
'location',
|
|
105
|
-
],
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
// Enhanced get function that supports multiple keys (falls back to pick behavior)
|
|
111
|
-
const configGet = async (conf) => {
|
|
112
|
-
const keys = conf.positionals.slice(1);
|
|
113
|
-
const configOption = conf.get('config');
|
|
114
|
-
// If no keys provided, show all config (like pkg get with no args)
|
|
115
|
-
if (keys.length === 0) {
|
|
116
|
-
return configPick(conf);
|
|
117
|
-
}
|
|
118
|
-
// If exactly one key, get the value based on --config option
|
|
119
|
-
if (keys.length === 1) {
|
|
120
|
-
const key = keys[0];
|
|
121
|
-
if (!key) {
|
|
122
|
-
throw error('Key is required', { code: 'EUSAGE' });
|
|
123
|
-
}
|
|
124
|
-
switch (configOption) {
|
|
125
|
-
case 'all': {
|
|
126
|
-
// Default behavior - get from merged/consolidated config (like original get function)
|
|
127
|
-
const result = await get(conf);
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
case 'user': {
|
|
131
|
-
return getUserConfigValue(key);
|
|
132
|
-
}
|
|
133
|
-
case 'project': {
|
|
134
|
-
return getProjectConfigValue(key);
|
|
135
|
-
}
|
|
136
|
-
default: {
|
|
137
|
-
// Fallback to merged config
|
|
138
|
-
const result = await get(conf);
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
// Multiple keys: use pick behavior
|
|
144
|
-
return configPick(conf);
|
|
145
|
-
};
|
|
146
|
-
// New pick function for getting multiple config values (like vlt pkg pick)
|
|
147
|
-
const configPick = async (conf) => {
|
|
148
|
-
const keys = conf.positionals.slice(1);
|
|
149
|
-
const configOption = conf.get('config');
|
|
150
|
-
// If no keys provided, return entire config object based on --config option (like vlt pkg pick)
|
|
151
|
-
if (keys.length === 0) {
|
|
152
|
-
switch (configOption) {
|
|
153
|
-
case 'all':
|
|
154
|
-
// For 'all', return the merged config as a serializable object
|
|
155
|
-
return getSerializableConfig(conf);
|
|
156
|
-
case 'user': {
|
|
157
|
-
// Return entire user config object
|
|
158
|
-
const userConfig = getUserConfigObject();
|
|
159
|
-
return userConfig /* c8 ignore next */ ?? {};
|
|
160
|
-
}
|
|
161
|
-
case 'project': {
|
|
162
|
-
// Return entire project config object
|
|
163
|
-
const projectConfig = getProjectConfigObject();
|
|
164
|
-
return projectConfig /* c8 ignore next */ ?? {};
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
// Multiple keys: build an object with the requested keys (like vlt pkg pick)
|
|
169
|
-
const result = {};
|
|
170
|
-
for (const key of keys) {
|
|
171
|
-
if (!key) /* c8 ignore next */
|
|
172
|
-
continue;
|
|
173
|
-
switch (configOption) {
|
|
174
|
-
case 'all':
|
|
175
|
-
// Get from merged config (default behavior)
|
|
176
|
-
result[key] = await get(Object.assign(Object.create(Object.getPrototypeOf(conf)), conf, {
|
|
177
|
-
positionals: ['get', key],
|
|
178
|
-
}));
|
|
179
|
-
break;
|
|
180
|
-
case 'user':
|
|
181
|
-
result[key] = getUserConfigValue(key);
|
|
182
|
-
break;
|
|
183
|
-
case 'project':
|
|
184
|
-
result[key] = getProjectConfigValue(key);
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return result;
|
|
189
|
-
};
|
|
190
|
-
// Enhanced list function that respects --config option
|
|
191
|
-
const configList = (conf) => {
|
|
192
|
-
const configOption = conf.get('config');
|
|
193
|
-
switch (configOption) {
|
|
194
|
-
case 'all':
|
|
195
|
-
// Default behavior - show merged config
|
|
196
|
-
return list(conf);
|
|
197
|
-
case 'user':
|
|
198
|
-
// Show only user config
|
|
199
|
-
return getUserConfigList();
|
|
200
|
-
case 'project':
|
|
201
|
-
// Show only project config
|
|
202
|
-
return getProjectConfigList();
|
|
203
|
-
default:
|
|
204
|
-
// Fallback to merged config
|
|
205
|
-
return list(conf);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
// Convert RecordPairs to string array in key=value format
|
|
209
|
-
const configToStringArray = (config) => {
|
|
210
|
-
const result = [];
|
|
211
|
-
for (const [key, value] of Object.entries(config)) {
|
|
212
|
-
if (value === undefined || value === null) {
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
if (Array.isArray(value)) {
|
|
216
|
-
// Handle array values (like registries)
|
|
217
|
-
for (const item of value) {
|
|
218
|
-
if (typeof item === 'string') {
|
|
219
|
-
result.push(`${key}=${item}`);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
else if (typeof value === 'object') {
|
|
224
|
-
// Handle object values
|
|
225
|
-
for (const [subKey, subValue] of Object.entries(value)) {
|
|
226
|
-
if (subValue !== undefined && subValue !== null) {
|
|
227
|
-
result.push(`${key}.${subKey}=${String(subValue)}`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
// Handle primitive values
|
|
233
|
-
let stringValue;
|
|
234
|
-
if (typeof value === 'string') {
|
|
235
|
-
stringValue = value;
|
|
236
|
-
}
|
|
237
|
-
else if (typeof value === 'number' ||
|
|
238
|
-
typeof value === 'boolean') {
|
|
239
|
-
stringValue = String(value);
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
stringValue = '[object]';
|
|
243
|
-
}
|
|
244
|
-
result.push(`${key}=${stringValue}`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return result.sort();
|
|
248
|
-
};
|
|
249
|
-
// Get user config as key=value pairs
|
|
250
|
-
const getUserConfigList = () => {
|
|
251
|
-
try {
|
|
252
|
-
const userConfig = load('config', (x, file) => {
|
|
253
|
-
if (x !== null &&
|
|
254
|
-
typeof x === 'object' &&
|
|
255
|
-
!Array.isArray(x)) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
throw new Error(`Invalid config in ${file}`);
|
|
259
|
-
}, 'user');
|
|
260
|
-
if (!userConfig)
|
|
261
|
-
return /* c8 ignore next */ [];
|
|
262
|
-
return configToStringArray(userConfig);
|
|
263
|
-
}
|
|
264
|
-
catch (_err) {
|
|
265
|
-
return [];
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
// Get project config as key=value pairs
|
|
269
|
-
const getProjectConfigList = () => {
|
|
270
|
-
try {
|
|
271
|
-
const projectConfig = load('config', (x, file) => {
|
|
272
|
-
if (x !== null &&
|
|
273
|
-
typeof x === 'object' &&
|
|
274
|
-
!Array.isArray(x)) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
throw new Error(`Invalid config in ${file}`);
|
|
278
|
-
}, 'project');
|
|
279
|
-
if (!projectConfig)
|
|
280
|
-
return /* c8 ignore next */ [];
|
|
281
|
-
return configToStringArray(projectConfig);
|
|
282
|
-
}
|
|
283
|
-
catch (_err) {
|
|
284
|
-
return [];
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
// Get the entire user config object
|
|
288
|
-
const getUserConfigObject = () => {
|
|
289
|
-
try {
|
|
290
|
-
const userConfig = load('config', (x, file) => {
|
|
291
|
-
if (x !== null &&
|
|
292
|
-
typeof x === 'object' &&
|
|
293
|
-
!Array.isArray(x)) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
throw new Error(`Invalid config in ${file}`);
|
|
297
|
-
}, 'user');
|
|
298
|
-
if (!userConfig || typeof userConfig !== 'object')
|
|
299
|
-
/* c8 ignore next */
|
|
300
|
-
return;
|
|
301
|
-
return userConfig;
|
|
302
|
-
}
|
|
303
|
-
catch (_err) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
// Get a specific value from user config
|
|
308
|
-
const getUserConfigValue = (key) => {
|
|
309
|
-
const userConfig = getUserConfigObject();
|
|
310
|
-
if (!userConfig)
|
|
311
|
-
return;
|
|
312
|
-
// Use dotProp.get like vlt pkg get does
|
|
313
|
-
return dotProp.get(userConfig, key);
|
|
314
|
-
};
|
|
315
|
-
// Get the entire project config object
|
|
316
|
-
const getProjectConfigObject = () => {
|
|
317
|
-
try {
|
|
318
|
-
const projectConfig = load('config', (x, file) => {
|
|
319
|
-
if (x !== null &&
|
|
320
|
-
typeof x === 'object' &&
|
|
321
|
-
!Array.isArray(x)) {
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
throw new Error(`Invalid config in ${file}`);
|
|
325
|
-
}, 'project');
|
|
326
|
-
if (!projectConfig || typeof projectConfig !== 'object')
|
|
327
|
-
/* c8 ignore next */
|
|
328
|
-
return;
|
|
329
|
-
return projectConfig;
|
|
330
|
-
}
|
|
331
|
-
catch (_err) {
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
// Get a specific value from project config
|
|
336
|
-
const getProjectConfigValue = (key) => {
|
|
337
|
-
const projectConfig = getProjectConfigObject();
|
|
338
|
-
if (!projectConfig)
|
|
339
|
-
return;
|
|
340
|
-
// Use dotProp.get like vlt pkg get does
|
|
341
|
-
return dotProp.get(projectConfig, key);
|
|
342
|
-
};
|
|
343
|
-
// Helper function to get the effective config option for write operations
|
|
344
|
-
const getWriteConfigOption = (conf) => {
|
|
345
|
-
const configOption = conf.get('config');
|
|
346
|
-
if (configOption === 'all') {
|
|
347
|
-
// For write operations, 'all' defaults to 'project'
|
|
348
|
-
return 'project';
|
|
349
|
-
}
|
|
350
|
-
return configOption;
|
|
351
|
-
};
|
|
352
|
-
// Wrapper for set command that handles --config option appropriately
|
|
353
|
-
const configSet = async (conf) => {
|
|
354
|
-
const effectiveConfig = getWriteConfigOption(conf);
|
|
355
|
-
// Temporarily modify the config value for the set operation
|
|
356
|
-
const originalGet = conf.get;
|
|
357
|
-
conf.get = ((key) => {
|
|
358
|
-
if (key === 'config') {
|
|
359
|
-
return effectiveConfig;
|
|
360
|
-
}
|
|
361
|
-
return originalGet.call(conf, key);
|
|
362
|
-
});
|
|
363
|
-
try {
|
|
364
|
-
return await set(conf);
|
|
365
|
-
}
|
|
366
|
-
finally {
|
|
367
|
-
// Restore the original get method
|
|
368
|
-
conf.get = originalGet;
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
// Wrapper for delete command that handles --config option appropriately
|
|
372
|
-
const configDelete = async (conf) => {
|
|
373
|
-
const effectiveConfig = getWriteConfigOption(conf);
|
|
374
|
-
// Temporarily modify the config value for the delete operation
|
|
375
|
-
const originalGet = conf.get;
|
|
376
|
-
conf.get = ((key) => {
|
|
377
|
-
if (key === 'config') {
|
|
378
|
-
return effectiveConfig;
|
|
379
|
-
}
|
|
380
|
-
return originalGet.call(conf, key);
|
|
381
|
-
});
|
|
382
|
-
try {
|
|
383
|
-
return await del(conf);
|
|
384
|
-
}
|
|
385
|
-
finally {
|
|
386
|
-
// Restore the original get method
|
|
387
|
-
conf.get = originalGet;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
// Wrapper for edit command that handles --config option appropriately
|
|
391
|
-
const configEdit = async (conf) => {
|
|
392
|
-
const effectiveConfig = getWriteConfigOption(conf);
|
|
393
|
-
// Temporarily modify the config value for the edit operation
|
|
394
|
-
const originalGet = conf.get;
|
|
395
|
-
conf.get = ((key) => {
|
|
396
|
-
if (key === 'config') {
|
|
397
|
-
return effectiveConfig;
|
|
398
|
-
}
|
|
399
|
-
return originalGet.call(conf, key);
|
|
400
|
-
});
|
|
401
|
-
try {
|
|
402
|
-
return await edit(conf);
|
|
403
|
-
}
|
|
404
|
-
finally {
|
|
405
|
-
// Restore the original get method
|
|
406
|
-
conf.get = originalGet;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
// Get a serializable config object from LoadedConfig (without circular references)
|
|
410
|
-
const getSerializableConfig = (conf) => {
|
|
411
|
-
// Use the list function which calls recordsToPairs to get a clean config object
|
|
412
|
-
return list(conf);
|
|
413
|
-
};
|
|
414
|
-
// Location command that shows config file paths
|
|
415
|
-
const configLocation = (conf) => {
|
|
416
|
-
const configOption = conf.get('config');
|
|
417
|
-
// For location command, default to 'project' when 'all' is specified
|
|
418
|
-
// since there's no single "all" file to show
|
|
419
|
-
const effectiveConfig = configOption === 'all' ? 'project' : configOption;
|
|
420
|
-
// Get the config file path
|
|
421
|
-
const configPath = find(effectiveConfig);
|
|
422
|
-
return configPath;
|
|
423
|
-
};
|
|
424
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAQ7C,MAAM,CAAC,MAAM,KAAK,GAAU;IAC1B,KAAK,EAAE,OAAO,CAAC,EAAE;QACf,0CAA0C;QAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,C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,MAAM,eAAe,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;IAElD,6DAA6D;IAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAA;IAC5B,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE;QAC1B,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;YACrB,OAAO,eAAe,CAAA;QACxB,CAAC;QACD,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,GAAU,CAAC,CAAA;IAC3C,CAAC,CAAuB,CAAA;IAExB,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;YAAS,CAAC;QACT,kCAAkC;QAClC,IAAI,CAAC,GAAG,GAAG,WAAW,CAAA;IACxB,CAAC;AACH,CAAC,CAAA;AAED,mFAAmF;AACnF,MAAM,qBAAqB,GAAG,CAC5B,IAAkB,EACO,EAAE;IAC3B,gFAAgF;IAChF,OAAO,IAAI,CAAC,IAAI,CAA4B,CAAA;AAC9C,CAAC,CAAA;AAED,gDAAgD;AAChD,MAAM,cAAc,GAAG,CAAC,IAAkB,EAAU,EAAE;IACpD,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAiB,CAAA;IAEvD,qEAAqE;IACrE,6CAA6C;IAC7C,MAAM,eAAe,GACnB,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAA;IAEnD,2BAA2B;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,CAAA;IAExC,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA","sourcesContent":["import assert from 'node:assert'\nimport * as dotProp from '@vltpkg/dot-prop'\nimport { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport { get, set, edit, list, del } from '@vltpkg/config'\nimport { load, find } from '@vltpkg/vlt-json'\nimport type { LoadedConfig, RecordPairs } from '../config/index.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\n// Type for the CLI config option (includes 'all' for merged config)\ntype ConfigOption = 'all' | 'user' | 'project'\n\nexport const views: Views = {\n human: results => {\n // Handle string arrays (like list output)\n if (Array.isArray(results) && typeof results[0] === 'string') {\n return results.join('\\n')\n }\n\n // For all other values (primitives, objects, arrays), use JSON formatting like vlt pkg\n return JSON.stringify(results, null, 2)\n },\n} as const satisfies Views\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'config',\n usage: '[<command>] [<args>]',\n description: 'Get or manipulate vlt configuration values',\n\n subcommands: {\n get: {\n usage: '[<key>] [--config=<all | user | project>]',\n description:\n 'Get a single config value. Use --config to specify which config to read from.',\n },\n\n pick: {\n usage:\n '[<key> [<key> ...]] [--config=<all | user | project>]',\n description:\n 'Get multiple config values or all configuration. Use --config to specify which config to read from.',\n },\n\n list: {\n usage: '[--config=<all | user | project>]',\n description:\n 'Print configuration settings. --config=all shows merged config (default), --config=user shows only user config, --config=project shows only project config.',\n },\n\n set: {\n usage:\n '<key>=<value> [<key>=<value> ...] [--config=<all | user | project>]',\n description: `Set config values. By default (or with --config=all), these are\n written to the project config file, \\`vlt.json\\`\n in the root of the project. To set things for all\n projects, run with \\`--config=user\\`.`,\n },\n\n delete: {\n usage: '<key> [<key> ...] [--config=<all | user | project>]',\n description: `Delete the named config fields. If no values remain in\n the config file, delete the file as well. By default\n (or with --config=all), operates on the \\`vlt.json\\` file in\n the root of the current project. To delete a config field from\n the user config file, specify \\`--config=user\\`.`,\n },\n\n edit: {\n usage: '[--config=<all | user | project>]',\n description:\n 'Edit the configuration file. By default (or with --config=all), edits the project config file.',\n },\n\n location: {\n usage: '[--config=<user | project>]',\n description:\n 'Show the file path of the configuration file. Defaults to project config.',\n },\n },\n })\n\nexport const command: CommandFn = async conf => {\n const [sub] = conf.positionals\n\n assert(\n sub,\n error('config command requires a subcommand', {\n code: 'EUSAGE',\n validOptions: [\n 'get',\n 'pick',\n 'set',\n 'delete',\n 'list',\n 'edit',\n 'location',\n ],\n }),\n )\n\n switch (sub) {\n case 'set':\n return configSet(conf)\n\n case 'get':\n return configGet(conf)\n\n case 'pick':\n return configPick(conf)\n\n case 'ls':\n case 'list':\n return configList(conf)\n\n case 'edit':\n return configEdit(conf)\n\n case 'location':\n return configLocation(conf)\n\n case 'del':\n case 'delete':\n case 'rm':\n case 'remove':\n case 'unset':\n return configDelete(conf)\n\n default: {\n throw error('Unrecognized config command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: [\n 'get',\n 'pick',\n 'set',\n 'delete',\n 'list',\n 'edit',\n 'location',\n ],\n })\n }\n }\n}\n\n// Enhanced get function that supports multiple keys (falls back to pick behavior)\nconst configGet = async (conf: LoadedConfig): Promise<unknown> => {\n const keys = conf.positionals.slice(1)\n const configOption = conf.get('config') as ConfigOption\n\n // If no keys provided, show all config (like pkg get with no args)\n if (keys.length === 0) {\n return configPick(conf)\n }\n\n // If exactly one key, get the value based on --config option\n if (keys.length === 1) {\n const key = keys[0]\n if (!key) {\n throw error('Key is required', { code: 'EUSAGE' })\n }\n\n switch (configOption) {\n case 'all': {\n // Default behavior - get from merged/consolidated config (like original get function)\n const result = await get(conf)\n return result\n }\n case 'user': {\n return getUserConfigValue(key)\n }\n case 'project': {\n return getProjectConfigValue(key)\n }\n default: {\n // Fallback to merged config\n const result = await get(conf)\n return result\n }\n }\n }\n\n // Multiple keys: use pick behavior\n return configPick(conf)\n}\n\n// New pick function for getting multiple config values (like vlt pkg pick)\nconst configPick = async (conf: LoadedConfig) => {\n const keys = conf.positionals.slice(1)\n const configOption = conf.get('config') as ConfigOption\n\n // If no keys provided, return entire config object based on --config option (like vlt pkg pick)\n if (keys.length === 0) {\n switch (configOption) {\n case 'all':\n // For 'all', return the merged config as a serializable object\n return getSerializableConfig(conf)\n\n case 'user': {\n // Return entire user config object\n const userConfig = getUserConfigObject()\n return userConfig /* c8 ignore next */ ?? {}\n }\n\n case 'project': {\n // Return entire project config object\n const projectConfig = getProjectConfigObject()\n return projectConfig /* c8 ignore next */ ?? {}\n }\n }\n }\n\n // Multiple keys: build an object with the requested keys (like vlt pkg pick)\n const result: Record<string, unknown> = {}\n\n for (const key of keys) {\n if (!key) /* c8 ignore next */ continue\n\n switch (configOption) {\n case 'all':\n // Get from merged config (default behavior)\n result[key] = await get(\n Object.assign(\n Object.create(Object.getPrototypeOf(conf) as object),\n conf,\n {\n positionals: ['get', key],\n },\n ) as LoadedConfig,\n )\n break\n\n case 'user':\n result[key] = getUserConfigValue(key)\n break\n\n case 'project':\n result[key] = getProjectConfigValue(key)\n break\n }\n }\n\n return result\n}\n\n// Enhanced list function that respects --config option\nconst configList = (conf: LoadedConfig) => {\n const configOption = conf.get('config') as ConfigOption\n\n switch (configOption) {\n case 'all':\n // Default behavior - show merged config\n return list(conf)\n\n case 'user':\n // Show only user config\n return getUserConfigList()\n\n case 'project':\n // Show only project config\n return getProjectConfigList()\n\n default:\n // Fallback to merged config\n return list(conf)\n }\n}\n\n// Convert RecordPairs to string array in key=value format\nconst configToStringArray = (config: RecordPairs): string[] => {\n const result: string[] = []\n\n for (const [key, value] of Object.entries(config)) {\n if (value === undefined || value === null) {\n continue\n }\n\n if (Array.isArray(value)) {\n // Handle array values (like registries)\n for (const item of value) {\n if (typeof item === 'string') {\n result.push(`${key}=${item}`)\n }\n }\n } else if (typeof value === 'object') {\n // Handle object values\n for (const [subKey, subValue] of Object.entries(value)) {\n if (subValue !== undefined && subValue !== null) {\n result.push(`${key}.${subKey}=${String(subValue)}`)\n }\n }\n } else {\n // Handle primitive values\n let stringValue: string\n if (typeof value === 'string') {\n stringValue = value\n } else if (\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n stringValue = String(value)\n } else {\n stringValue = '[object]'\n }\n result.push(`${key}=${stringValue}`)\n }\n }\n\n return result.sort()\n}\n\n// Get user config as key=value pairs\nconst getUserConfigList = (): string[] => {\n try {\n const userConfig = load(\n 'config',\n (x: unknown, file: string): asserts x is RecordPairs => {\n if (\n x !== null &&\n typeof x === 'object' &&\n !Array.isArray(x)\n ) {\n return\n }\n throw new Error(`Invalid config in ${file}`)\n },\n 'user',\n )\n\n if (!userConfig) return /* c8 ignore next */ []\n\n return configToStringArray(userConfig)\n } catch (_err) {\n return []\n }\n}\n\n// Get project config as key=value pairs\nconst getProjectConfigList = (): string[] => {\n try {\n const projectConfig = load(\n 'config',\n (x: unknown, file: string): asserts x is RecordPairs => {\n if (\n x !== null &&\n typeof x === 'object' &&\n !Array.isArray(x)\n ) {\n return\n }\n throw new Error(`Invalid config in ${file}`)\n },\n 'project',\n )\n\n if (!projectConfig) return /* c8 ignore next */ []\n\n return configToStringArray(projectConfig)\n } catch (_err) {\n return []\n }\n}\n\n// Get the entire user config object\nconst getUserConfigObject = ():\n | Record<string, unknown>\n | undefined => {\n try {\n const userConfig = load(\n 'config',\n (x: unknown, file: string): asserts x is RecordPairs => {\n if (\n x !== null &&\n typeof x === 'object' &&\n !Array.isArray(x)\n ) {\n return\n }\n throw new Error(`Invalid config in ${file}`)\n },\n 'user',\n )\n\n if (!userConfig || typeof userConfig !== 'object')\n /* c8 ignore next */\n return\n\n return userConfig as Record<string, unknown>\n } catch (_err) {\n return\n }\n}\n\n// Get a specific value from user config\nconst getUserConfigValue = (key: string): unknown => {\n const userConfig = getUserConfigObject()\n if (!userConfig) return\n\n // Use dotProp.get like vlt pkg get does\n return dotProp.get(userConfig as Record<PropertyKey, unknown>, key)\n}\n\n// Get the entire project config object\nconst getProjectConfigObject = ():\n | Record<string, unknown>\n | undefined => {\n try {\n const projectConfig = load(\n 'config',\n (x: unknown, file: string): asserts x is RecordPairs => {\n if (\n x !== null &&\n typeof x === 'object' &&\n !Array.isArray(x)\n ) {\n return\n }\n throw new Error(`Invalid config in ${file}`)\n },\n 'project',\n )\n\n if (!projectConfig || typeof projectConfig !== 'object')\n /* c8 ignore next */\n return\n\n return projectConfig as Record<string, unknown>\n } catch (_err) {\n return\n }\n}\n\n// Get a specific value from project config\nconst getProjectConfigValue = (key: string): unknown => {\n const projectConfig = getProjectConfigObject()\n if (!projectConfig) return\n\n // Use dotProp.get like vlt pkg get does\n return dotProp.get(\n projectConfig as Record<PropertyKey, unknown>,\n key,\n )\n}\n\n// Helper function to get the effective config option for write operations\nconst getWriteConfigOption = (\n conf: LoadedConfig,\n): 'user' | 'project' => {\n const configOption = conf.get('config') as ConfigOption\n\n if (configOption === 'all') {\n // For write operations, 'all' defaults to 'project'\n return 'project'\n }\n\n return configOption\n}\n\n// Wrapper for set command that handles --config option appropriately\nconst configSet = async (conf: LoadedConfig) => {\n const effectiveConfig = getWriteConfigOption(conf)\n\n // Temporarily modify the config value for the set operation\n const originalGet = conf.get\n conf.get = ((key: string) => {\n if (key === 'config') {\n return effectiveConfig\n }\n return originalGet.call(conf, key as any)\n }) as typeof originalGet\n\n try {\n return await set(conf)\n } finally {\n // Restore the original get method\n conf.get = originalGet\n }\n}\n\n// Wrapper for delete command that handles --config option appropriately\nconst configDelete = async (conf: LoadedConfig) => {\n const effectiveConfig = getWriteConfigOption(conf)\n\n // Temporarily modify the config value for the delete operation\n const originalGet = conf.get\n conf.get = ((key: string) => {\n if (key === 'config') {\n return effectiveConfig\n }\n return originalGet.call(conf, key as any)\n }) as typeof originalGet\n\n try {\n return await del(conf)\n } finally {\n // Restore the original get method\n conf.get = originalGet\n }\n}\n\n// Wrapper for edit command that handles --config option appropriately\nconst configEdit = async (conf: LoadedConfig) => {\n const effectiveConfig = getWriteConfigOption(conf)\n\n // Temporarily modify the config value for the edit operation\n const originalGet = conf.get\n conf.get = ((key: string) => {\n if (key === 'config') {\n return effectiveConfig\n }\n return originalGet.call(conf, key as any)\n }) as typeof originalGet\n\n try {\n return await edit(conf)\n } finally {\n // Restore the original get method\n conf.get = originalGet\n }\n}\n\n// Get a serializable config object from LoadedConfig (without circular references)\nconst getSerializableConfig = (\n conf: LoadedConfig,\n): Record<string, unknown> => {\n // Use the list function which calls recordsToPairs to get a clean config object\n return list(conf) as Record<string, unknown>\n}\n\n// Location command that shows config file paths\nconst configLocation = (conf: LoadedConfig): string => {\n const configOption = conf.get('config') as ConfigOption\n\n // For location command, default to 'project' when 'all' is specified\n // since there's no single \"all\" file to show\n const effectiveConfig =\n configOption === 'all' ? 'project' : configOption\n\n // Get the config file path\n const configPath = find(effectiveConfig)\n\n return configPath\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
-
export declare const usage: CommandUsage;
|
|
3
|
-
type CommandResultSingle = {
|
|
4
|
-
url: string;
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
type CommandResultMultiple = {
|
|
8
|
-
url: string;
|
|
9
|
-
name: string;
|
|
10
|
-
}[];
|
|
11
|
-
export type CommandResult = CommandResultSingle | CommandResultMultiple;
|
|
12
|
-
export declare const views: {
|
|
13
|
-
readonly human: (r: CommandResult) => string;
|
|
14
|
-
readonly json: (r: CommandResult) => CommandResult;
|
|
15
|
-
};
|
|
16
|
-
export declare const command: CommandFn<CommandResult>;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../src/commands/docs.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQ1D,eAAO,MAAM,KAAK,EAAE,YA2BhB,CAAA;AAEJ,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,EAAE,CAAA;AAEH,MAAM,MAAM,aAAa,GACrB,mBAAmB,GACnB,qBAAqB,CAAA;AAEzB,eAAO,MAAM,KAAK;;;CAUuB,CAAA;AA0CzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CA4F5C,CAAA"}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
3
|
-
import { Spec } from '@vltpkg/spec';
|
|
4
|
-
import { urlOpen } from '@vltpkg/url-open';
|
|
5
|
-
import { actual } from '@vltpkg/graph';
|
|
6
|
-
import { Query } from '@vltpkg/query';
|
|
7
|
-
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
8
|
-
import { createHostContextsMap } from "../query-host-contexts.js";
|
|
9
|
-
import { commandUsage } from "../config/usage.js";
|
|
10
|
-
import hostedGitInfo from 'hosted-git-info';
|
|
11
|
-
const { fromUrl: hostedGitInfoFromUrl } = hostedGitInfo;
|
|
12
|
-
export const usage = () => commandUsage({
|
|
13
|
-
command: 'docs',
|
|
14
|
-
usage: ['[<spec>]', '[--target=<query>]'],
|
|
15
|
-
description: `Open documentation for a package in a web browser.
|
|
16
|
-
Reads repository information from package.json or fetches
|
|
17
|
-
manifest data for the specified package.`,
|
|
18
|
-
options: {
|
|
19
|
-
target: {
|
|
20
|
-
value: '<query>',
|
|
21
|
-
description: 'Query selector to filter packages using DSS syntax.',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
examples: {
|
|
25
|
-
'': {
|
|
26
|
-
description: 'Open docs for the current package (reads local package.json)',
|
|
27
|
-
},
|
|
28
|
-
'abbrev@2.0.0': {
|
|
29
|
-
description: 'Open docs for a specific package version',
|
|
30
|
-
},
|
|
31
|
-
'--target=":root > *"': {
|
|
32
|
-
description: 'List documentation URLs for all direct dependencies',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
export const views = {
|
|
37
|
-
human: r => {
|
|
38
|
-
if (Array.isArray(r)) {
|
|
39
|
-
let msg = 'Multiple package docs found:\n';
|
|
40
|
-
msg += r.map(item => `• ${item.name}: ${item.url}`).join('\n');
|
|
41
|
-
return msg;
|
|
42
|
-
}
|
|
43
|
-
return '';
|
|
44
|
-
},
|
|
45
|
-
json: r => r,
|
|
46
|
-
};
|
|
47
|
-
const getUrlFromManifest = (manifest) => {
|
|
48
|
-
const { name, homepage, repository } = manifest;
|
|
49
|
-
if (!name) {
|
|
50
|
-
throw error('No package name found');
|
|
51
|
-
}
|
|
52
|
-
// Extract repository URL
|
|
53
|
-
let url;
|
|
54
|
-
if (homepage) {
|
|
55
|
-
url = homepage;
|
|
56
|
-
}
|
|
57
|
-
else if (repository) {
|
|
58
|
-
const repoUrl = typeof repository === 'string' ? repository
|
|
59
|
-
: typeof repository === 'object' && 'url' in repository ?
|
|
60
|
-
repository.url
|
|
61
|
-
: /* c8 ignore next */ undefined;
|
|
62
|
-
if (repoUrl) {
|
|
63
|
-
// Try to get hosted git info
|
|
64
|
-
const info = hostedGitInfoFromUrl(repoUrl.replace(/^git\+/, ''));
|
|
65
|
-
if (info?.docs && typeof info.docs === 'function') {
|
|
66
|
-
url = info.docs();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Fallback to npmjs.com package page
|
|
71
|
-
if (!url) {
|
|
72
|
-
url = `https://www.npmjs.com/package/${name}`;
|
|
73
|
-
}
|
|
74
|
-
return url;
|
|
75
|
-
};
|
|
76
|
-
export const command = async (conf) => {
|
|
77
|
-
const { projectRoot, packageJson } = conf.options;
|
|
78
|
-
const targetOption = conf.get('target');
|
|
79
|
-
// Handle --target query
|
|
80
|
-
if (targetOption) {
|
|
81
|
-
const mainManifest = packageJson.maybeRead(projectRoot);
|
|
82
|
-
if (!mainManifest) {
|
|
83
|
-
throw error('No package.json found in project root', {
|
|
84
|
-
path: projectRoot,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
const graph = actual.load({
|
|
88
|
-
...conf.options,
|
|
89
|
-
mainManifest,
|
|
90
|
-
monorepo: conf.options.monorepo,
|
|
91
|
-
loadManifests: true,
|
|
92
|
-
});
|
|
93
|
-
const securityArchive = Query.hasSecuritySelectors(targetOption) ?
|
|
94
|
-
await SecurityArchive.start({
|
|
95
|
-
nodes: [...graph.nodes.values()],
|
|
96
|
-
})
|
|
97
|
-
: undefined;
|
|
98
|
-
const hostContexts = await createHostContextsMap(conf);
|
|
99
|
-
const query = new Query({
|
|
100
|
-
nodes: new Set(graph.nodes.values()),
|
|
101
|
-
edges: graph.edges,
|
|
102
|
-
importers: graph.importers,
|
|
103
|
-
securityArchive,
|
|
104
|
-
hostContexts,
|
|
105
|
-
});
|
|
106
|
-
const { nodes } = await query.search(targetOption, {
|
|
107
|
-
signal: new AbortController().signal,
|
|
108
|
-
});
|
|
109
|
-
const results = [];
|
|
110
|
-
for (const node of nodes) {
|
|
111
|
-
if (!node.manifest)
|
|
112
|
-
continue;
|
|
113
|
-
const url = getUrlFromManifest(node.manifest);
|
|
114
|
-
results.push({
|
|
115
|
-
url,
|
|
116
|
-
name: node.name /* c8 ignore next */ ?? '(unknown)',
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
if (results.length === 0) {
|
|
120
|
-
throw error('No packages found matching target query', {
|
|
121
|
-
found: targetOption,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
// If single result, open it
|
|
125
|
-
if (results.length === 1) {
|
|
126
|
-
const result = results[0];
|
|
127
|
-
/* c8 ignore next 3 */
|
|
128
|
-
if (!result) {
|
|
129
|
-
throw error('Unexpected empty result');
|
|
130
|
-
}
|
|
131
|
-
await urlOpen(result.url);
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
// Multiple results, return the list
|
|
135
|
-
return results;
|
|
136
|
-
}
|
|
137
|
-
// read the package spec from a positional argument or local package.json
|
|
138
|
-
const specArg = conf.positionals[0];
|
|
139
|
-
const manifest = conf.positionals.length === 0 ? packageJson.read(projectRoot)
|
|
140
|
-
: specArg ?
|
|
141
|
-
await new PackageInfoClient(conf.options).manifest(Spec.parseArgs(specArg, conf.options))
|
|
142
|
-
: /* c8 ignore next */ packageJson.read(projectRoot);
|
|
143
|
-
const url = getUrlFromManifest(manifest);
|
|
144
|
-
const { name } = manifest;
|
|
145
|
-
/* c8 ignore start - getUrlFromManifest already validates name */
|
|
146
|
-
if (!name) {
|
|
147
|
-
throw error('No package name found');
|
|
148
|
-
}
|
|
149
|
-
/* c8 ignore stop */
|
|
150
|
-
// Open the URL
|
|
151
|
-
await urlOpen(url);
|
|
152
|
-
return { url, name };
|
|
153
|
-
};
|
|
154
|
-
//# sourceMappingURL=docs.js.map
|