@vltpkg/cli-sdk 0.0.0-30 → 0.0.0-31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/commands/build.d.ts +25 -0
- package/dist/esm/commands/build.d.ts.map +1 -0
- package/dist/esm/commands/build.js +102 -0
- package/dist/esm/commands/build.js.map +1 -0
- package/dist/esm/commands/ci.d.ts +5 -4
- package/dist/esm/commands/ci.d.ts.map +1 -1
- package/dist/esm/commands/ci.js +6 -3
- package/dist/esm/commands/ci.js.map +1 -1
- package/dist/esm/commands/config.d.ts +3 -2
- package/dist/esm/commands/config.d.ts.map +1 -1
- package/dist/esm/commands/config.js +379 -58
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/exec-cache.js +12 -0
- package/dist/esm/commands/exec-cache.js.map +1 -1
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +6 -0
- package/dist/esm/commands/exec.js.map +1 -1
- package/dist/esm/commands/install/reporter.d.ts +2 -1
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +35 -6
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +21 -3
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +21 -3
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/serve.d.ts.map +1 -1
- package/dist/esm/commands/serve.js +6 -0
- package/dist/esm/commands/serve.js.map +1 -1
- package/dist/esm/commands/uninstall.d.ts +8 -2
- package/dist/esm/commands/uninstall.d.ts.map +1 -1
- package/dist/esm/commands/uninstall.js +8 -3
- package/dist/esm/commands/uninstall.js.map +1 -1
- package/dist/esm/commands/update.d.ts +7 -3
- package/dist/esm/commands/update.d.ts.map +1 -1
- package/dist/esm/commands/update.js +19 -3
- package/dist/esm/commands/update.js.map +1 -1
- package/dist/esm/config/definition.d.ts +15 -2
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +29 -6
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +11 -2
- package/dist/esm/start-gui.js.map +1 -1
- package/package.json +25 -25
|
@@ -1,103 +1,424 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import * as dotProp from '@vltpkg/dot-prop';
|
|
1
3
|
import { error } from '@vltpkg/error-cause';
|
|
2
4
|
import { commandUsage } from "../config/usage.js";
|
|
3
|
-
import { isRecordField, definition } from "../config/index.js";
|
|
4
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
|
+
};
|
|
5
17
|
export const usage = () => commandUsage({
|
|
6
18
|
command: 'config',
|
|
7
|
-
usage: '<command> [
|
|
8
|
-
description: '
|
|
19
|
+
usage: '[<command>] [<args>]',
|
|
20
|
+
description: 'Get or manipulate vlt configuration values',
|
|
9
21
|
subcommands: {
|
|
10
22
|
get: {
|
|
11
|
-
usage: '<key> [
|
|
12
|
-
description: '
|
|
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.',
|
|
13
29
|
},
|
|
14
30
|
list: {
|
|
15
|
-
|
|
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.',
|
|
16
33
|
},
|
|
17
34
|
set: {
|
|
18
|
-
usage: '<key>=<value> [<key>=<value> ...] [--config=<user | project>]',
|
|
19
|
-
description: `Set config values. By default, these are
|
|
35
|
+
usage: '<key>=<value> [<key>=<value> ...] [--config=<all | user | project>]',
|
|
36
|
+
description: `Set config values. By default (or with --config=all), these are
|
|
20
37
|
written to the project config file, \`vlt.json\`
|
|
21
38
|
in the root of the project. To set things for all
|
|
22
|
-
projects, run with \`--config=user
|
|
39
|
+
projects, run with \`--config=user\`.`,
|
|
23
40
|
},
|
|
24
|
-
|
|
25
|
-
usage: '<key> [<key> ...] [--config=<user | project>]',
|
|
41
|
+
delete: {
|
|
42
|
+
usage: '<key> [<key> ...] [--config=<all | user | project>]',
|
|
26
43
|
description: `Delete the named config fields. If no values remain in
|
|
27
|
-
the config file, delete the file as well. By default
|
|
28
|
-
operates on the \`vlt.json\` file in
|
|
29
|
-
current project. To delete a config field from
|
|
30
|
-
config file, specify \`--config=user\`.`,
|
|
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\`.`,
|
|
31
48
|
},
|
|
32
49
|
edit: {
|
|
33
|
-
usage: '[--config=<user | project>]',
|
|
34
|
-
description: 'Edit the configuration file',
|
|
50
|
+
usage: '[--config=<all | user | project>]',
|
|
51
|
+
description: 'Edit the configuration file. By default (or with --config=all), edits the project config file.',
|
|
35
52
|
},
|
|
36
|
-
|
|
37
|
-
usage: '[
|
|
38
|
-
description:
|
|
39
|
-
of known config field names.`,
|
|
53
|
+
location: {
|
|
54
|
+
usage: '[--config=<user | project>]',
|
|
55
|
+
description: 'Show the file path of the configuration file. Defaults to project config.',
|
|
40
56
|
},
|
|
41
57
|
},
|
|
42
58
|
});
|
|
43
59
|
export const command = async (conf) => {
|
|
44
|
-
const sub = conf.positionals
|
|
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
|
+
}));
|
|
45
73
|
switch (sub) {
|
|
46
74
|
case 'set':
|
|
47
|
-
return
|
|
75
|
+
return configSet(conf);
|
|
48
76
|
case 'get':
|
|
49
|
-
return
|
|
77
|
+
return configGet(conf);
|
|
78
|
+
case 'pick':
|
|
79
|
+
return configPick(conf);
|
|
50
80
|
case 'ls':
|
|
51
81
|
case 'list':
|
|
52
|
-
return
|
|
82
|
+
return configList(conf);
|
|
53
83
|
case 'edit':
|
|
54
|
-
return
|
|
55
|
-
case '
|
|
56
|
-
return
|
|
84
|
+
return configEdit(conf);
|
|
85
|
+
case 'location':
|
|
86
|
+
return configLocation(conf);
|
|
57
87
|
case 'del':
|
|
58
|
-
|
|
88
|
+
case 'delete':
|
|
89
|
+
case 'rm':
|
|
90
|
+
case 'remove':
|
|
91
|
+
case 'unset':
|
|
92
|
+
return configDelete(conf);
|
|
59
93
|
default: {
|
|
60
94
|
throw error('Unrecognized config command', {
|
|
61
95
|
code: 'EUSAGE',
|
|
62
96
|
found: sub,
|
|
63
|
-
validOptions: [
|
|
97
|
+
validOptions: [
|
|
98
|
+
'get',
|
|
99
|
+
'pick',
|
|
100
|
+
'set',
|
|
101
|
+
'delete',
|
|
102
|
+
'list',
|
|
103
|
+
'edit',
|
|
104
|
+
'location',
|
|
105
|
+
],
|
|
64
106
|
});
|
|
65
107
|
}
|
|
66
108
|
}
|
|
67
109
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
}
|
|
85
230
|
}
|
|
86
231
|
else {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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]';
|
|
95
243
|
}
|
|
96
|
-
|
|
97
|
-
|
|
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;
|
|
98
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;
|
|
99
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;
|
|
100
407
|
}
|
|
101
|
-
|
|
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;
|
|
102
423
|
};
|
|
103
424
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAI1D,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,6BAA6B;IAE1C,WAAW,EAAE;QACX,GAAG,EAAE;YACH,KAAK,EAAE,mBAAmB;YAC1B,WAAW,EAAE,8BAA8B;SAC5C;QAED,IAAI,EAAE;YACJ,WAAW,EACT,sDAAsD;SACzD;QAED,GAAG,EAAE;YACH,KAAK,EACH,+DAA+D;YACjE,WAAW,EAAE;;;2DAGsC;SACpD;QAED,GAAG,EAAE;YACH,KAAK,EAAE,+CAA+C;YACtD,WAAW,EAAE;;;;8DAIyC;SACvD;QAED,IAAI,EAAE;YACJ,KAAK,EAAE,6BAA6B;YACpC,WAAW,EAAE,6BA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,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport { isRecordField, definition } from '../config/index.ts'\nimport { get, set, edit, list, del } from '@vltpkg/config'\nimport type { LoadedConfig, RecordPairs } from '../config/index.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'config',\n usage: '<command> [flags]',\n description: 'Work with vlt configuration',\n\n subcommands: {\n get: {\n usage: '<key> [<key> ...]',\n description: 'Print the named config value',\n },\n\n list: {\n description:\n 'Print all configuration settings currently in effect',\n },\n\n set: {\n usage:\n '<key>=<value> [<key>=<value> ...] [--config=<user | project>]',\n description: `Set config values. By default, these are\n written to the project config file, \\`vlt.json\\`\n in the root of the project. To set things for all\n projects, run with \\`--config=user\\``,\n },\n\n del: {\n usage: '<key> [<key> ...] [--config=<user | project>]',\n description: `Delete the named config fields. If no values remain in\n the config file, delete the file as well. By default,\n operates on the \\`vlt.json\\` file in the root of the\n current project. To delete a config field from the user\n config file, specify \\`--config=user\\`.`,\n },\n\n edit: {\n usage: '[--config=<user | project>]',\n description: 'Edit the configuration file',\n },\n\n help: {\n usage: '[field ...]',\n description: `Get information about a config field, or show a list\n of known config field names.`,\n },\n },\n })\n\nexport const command: CommandFn<\n string | number | boolean | void | string[] | RecordPairs\n> = async conf => {\n const sub = conf.positionals[0]\n switch (sub) {\n case 'set':\n return set(conf)\n\n case 'get':\n return get(conf)\n\n case 'ls':\n case 'list':\n return list(conf)\n\n case 'edit':\n return edit(conf)\n\n case 'help':\n return help(conf)\n\n case 'del':\n return del(conf)\n\n default: {\n throw error('Unrecognized config command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['set', 'get', 'list', 'edit', 'help', 'del'],\n })\n }\n }\n}\n\nconst help = (conf: LoadedConfig) => {\n const j = definition.toJSON()\n const fields = conf.positionals.slice(1)\n if (!fields.length) {\n return [\n 'Specify one or more options to see information:',\n ...Object.keys(j)\n .sort((a, b) => a.localeCompare(b, 'en'))\n .map(c => ` ${c}`),\n ].join('\\n')\n }\n\n // TODO: some kind of fuzzy search?\n const res: string[] = []\n for (const f of fields) {\n const def = j[f]\n if (!def) {\n res.push(`unknown config field: ${f}`)\n } else {\n const hint = def.hint ? `=<${def.hint}>` : ''\n const type =\n isRecordField(f) ?\n 'Record<string, string>'\n : def.type + (def.multiple ? '[]' : '')\n\n res.push(`--${f}${hint}`)\n res.push(` type: ${type}`)\n if (def.default) {\n res.push(` default: ${JSON.stringify(def.default)}`)\n }\n if (def.description) {\n res.push(def.description)\n }\n }\n }\n return res.join('\\n')\n}\n"]}
|
|
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,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC7D,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3B,CAAC;QAED,uFAAuF;QACvF,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE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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"]}
|
|
@@ -87,10 +87,14 @@ const install = async (conf, keys, view) => {
|
|
|
87
87
|
code: 'EUSAGE',
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
91
|
+
String(conf.get('allow-scripts'))
|
|
92
|
+
: ':not(*)';
|
|
90
93
|
return Promise.all(keys.map(async (key) => {
|
|
91
94
|
const info = await vlx.install(key, {
|
|
92
95
|
...conf.options,
|
|
93
96
|
query: undefined,
|
|
97
|
+
allowScripts,
|
|
94
98
|
});
|
|
95
99
|
view?.stdout(info);
|
|
96
100
|
return info.path;
|
|
@@ -108,11 +112,15 @@ const ls = async (_conf, args, view) => {
|
|
|
108
112
|
return results;
|
|
109
113
|
};
|
|
110
114
|
const info = async (conf, keys, view) => {
|
|
115
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
116
|
+
String(conf.get('allow-scripts'))
|
|
117
|
+
: ':not(*)';
|
|
111
118
|
const results = [];
|
|
112
119
|
for await (const key of keys.length ? keys : vlx.list()) {
|
|
113
120
|
const info = vlx.info(key, {
|
|
114
121
|
...conf.options,
|
|
115
122
|
query: undefined,
|
|
123
|
+
allowScripts,
|
|
116
124
|
});
|
|
117
125
|
results.push(info);
|
|
118
126
|
view?.stdout(info);
|
|
@@ -120,10 +128,14 @@ const info = async (conf, keys, view) => {
|
|
|
120
128
|
return results;
|
|
121
129
|
};
|
|
122
130
|
const deleteEntries = async (conf, keys, view) => {
|
|
131
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
132
|
+
String(conf.get('allow-scripts'))
|
|
133
|
+
: ':not(*)';
|
|
123
134
|
const remover = new RollbackRemove();
|
|
124
135
|
const removed = (await vlx.delete(keys, remover, {
|
|
125
136
|
...conf.options,
|
|
126
137
|
query: undefined,
|
|
138
|
+
allowScripts,
|
|
127
139
|
})).map(path => {
|
|
128
140
|
view?.stdout(`- ${basename(path)}`);
|
|
129
141
|
return path;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-cache.js","sourceRoot":"","sources":["../../../src/commands/exec-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAKtC,IAAI,IAAmB,CAAA;AACvB,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YAAY,OAAoB,EAAE,IAAkB;QAClD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpB,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAe;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAuC;IACvD,KAAK,EAAE,aAAa;CACrB,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,kCAAkC;IAE/C,WAAW,EAAE;QACX,EAAE,EAAE;YACF,KAAK,EAAE,EAAE;YACT,WAAW,EAAE;;yBAEM;SACpB;QAED,MAAM,EAAE;YACN,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE;;qCAEkB;SAChC;QAED,IAAI,EAAE;YACJ,KAAK,EAAE,OAAO;YACd,WAAW,EAAE;kCACe;SAC7B;QAED,OAAO,EAAE;YACP,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE;;kDA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IAAI,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,OAAO,EAAE,CAAA;IACjB,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { VlxInfo } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { basename } from 'node:path'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type ExecCacheSubcommands =\n keyof (typeof usageDef)['subcommands']\n\nlet view: ExecCacheView\nexport class ExecCacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | string[] | VlxInfo[]> = {\n human: ExecCacheView,\n}\n\nconst usageDef = {\n command: 'exec-cache',\n usage: '<command> [flags]',\n description: 'Work with vlt exec-cache folders',\n\n subcommands: {\n ls: {\n usage: '',\n description: `Show previously installed packages used for \\`vlt exec\\`.\n Key provided can be either the package name, or the full\n key.`,\n },\n\n delete: {\n usage: '[<key>...]',\n description: `Delete previously installed packages used for\n \\`vlt exec\\`. If no keys are provided, then all entries\n will be deleted.`,\n },\n\n info: {\n usage: '<key>',\n description: `Show extended information about a given \\`vlt exec\\`\n installation.`,\n },\n\n install: {\n usage: '<spec>...',\n description: `Install the specified package(s) in the \\`vlt exec\\`\n central cache location. Metadata info about each\n installation will be printed.`,\n },\n },\n\n examples: {\n ls: {\n description: `Show all the keys for the installations in the \\`vlt exec\\`\n cache.`,\n },\n 'delete typescript': {\n description: `Delete all versions of typescript installed for vlt exec`,\n },\n 'info typescript-695bf962': {\n description: `Show extended info about a specific version of typescript`,\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<\n string[] | VlxInfo[]\n> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'info':\n return info(conf, args, view)\n\n case 'install':\n return install(conf, args, view)\n\n case 'delete':\n return deleteEntries(conf, args, view)\n\n default: {\n throw error('Unrecognized exec-cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: Object.keys(usageDef.subcommands),\n })\n }\n }\n}\n\nconst install = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n if (!keys.length) {\n throw error('Must supply a package spec to install', {\n code: 'EUSAGE',\n })\n }\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n return Promise.all(\n keys.map(async key => {\n const info = await vlx.install(key, {\n ...conf.options,\n query: undefined,\n allowScripts,\n })\n view?.stdout(info)\n return info.path\n }),\n )\n}\n\nconst ls = async (\n _conf: LoadedConfig,\n args: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const results: string[] = []\n for await (const path of vlx.list()) {\n const key = basename(path)\n if (args.length && !args.some(a => key.includes(a))) continue\n results.push(key)\n view?.stdout(key)\n }\n return results\n}\n\nconst info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<VlxInfo[]> => {\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n const results: VlxInfo[] = []\n for await (const key of keys.length ? keys : vlx.list()) {\n const info = vlx.info(key, {\n ...conf.options,\n query: undefined,\n allowScripts,\n })\n results.push(info)\n view?.stdout(info)\n }\n return results\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n const remover = new RollbackRemove()\n const removed = (\n await vlx.delete(keys, remover, {\n ...conf.options,\n query: undefined,\n allowScripts,\n })\n ).map(path => {\n view?.stdout(`- ${basename(path)}`)\n return path\n })\n remover.confirm()\n return removed\n}\n"]}
|