@vltpkg/cli-sdk 0.0.0-9 → 1.0.0-rc.2
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/cache.d.ts +18 -0
- package/dist/esm/commands/cache.d.ts.map +1 -1
- package/dist/esm/commands/cache.js +48 -2
- package/dist/esm/commands/cache.js.map +1 -1
- package/dist/esm/commands/ci.d.ts +11 -0
- package/dist/esm/commands/ci.d.ts.map +1 -0
- package/dist/esm/commands/ci.js +32 -0
- package/dist/esm/commands/ci.js.map +1 -0
- 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 +372 -101
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/docs.d.ts +18 -0
- package/dist/esm/commands/docs.d.ts.map +1 -0
- package/dist/esm/commands/docs.js +154 -0
- package/dist/esm/commands/docs.js.map +1 -0
- package/dist/esm/commands/exec-cache.d.ts +49 -0
- package/dist/esm/commands/exec-cache.d.ts.map +1 -0
- package/dist/esm/commands/exec-cache.js +146 -0
- package/dist/esm/commands/exec-cache.js.map +1 -0
- package/dist/esm/commands/exec-local.d.ts +1 -0
- package/dist/esm/commands/exec-local.d.ts.map +1 -1
- package/dist/esm/commands/exec-local.js +2 -0
- package/dist/esm/commands/exec-local.js.map +1 -1
- package/dist/esm/commands/exec.d.ts +6 -1
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +79 -5
- package/dist/esm/commands/exec.js.map +1 -1
- package/dist/esm/commands/help.d.ts +1 -1
- package/dist/esm/commands/help.d.ts.map +1 -1
- package/dist/esm/commands/help.js +32 -3
- package/dist/esm/commands/help.js.map +1 -1
- package/dist/esm/commands/init.d.ts +3 -3
- package/dist/esm/commands/init.d.ts.map +1 -1
- package/dist/esm/commands/init.js +95 -9
- package/dist/esm/commands/init.js.map +1 -1
- package/dist/esm/commands/install/reporter.d.ts +3 -2
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +42 -15
- 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 +27 -3
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/list.d.ts +2 -2
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +149 -49
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pack.d.ts +32 -0
- package/dist/esm/commands/pack.d.ts.map +1 -0
- package/dist/esm/commands/pack.js +147 -0
- package/dist/esm/commands/pack.js.map +1 -0
- package/dist/esm/commands/pkg.d.ts +1 -2
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js +123 -38
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/publish.d.ts +22 -0
- package/dist/esm/commands/publish.d.ts.map +1 -0
- package/dist/esm/commands/publish.js +245 -0
- package/dist/esm/commands/publish.js.map +1 -0
- package/dist/esm/commands/query.d.ts +2 -3
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +132 -38
- package/dist/esm/commands/query.js.map +1 -1
- package/dist/esm/commands/run-exec.d.ts +1 -0
- package/dist/esm/commands/run-exec.d.ts.map +1 -1
- package/dist/esm/commands/run-exec.js +1 -0
- package/dist/esm/commands/run-exec.js.map +1 -1
- package/dist/esm/commands/run.d.ts +1 -0
- package/dist/esm/commands/run.d.ts.map +1 -1
- package/dist/esm/commands/run.js +13 -16
- package/dist/esm/commands/run.js.map +1 -1
- package/dist/esm/commands/serve.d.ts +14 -0
- package/dist/esm/commands/serve.d.ts.map +1 -0
- package/dist/esm/commands/serve.js +103 -0
- package/dist/esm/commands/serve.js.map +1 -0
- 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 +14 -0
- package/dist/esm/commands/update.d.ts.map +1 -0
- package/dist/esm/commands/update.js +41 -0
- package/dist/esm/commands/update.js.map +1 -0
- package/dist/esm/commands/version.d.ts +26 -0
- package/dist/esm/commands/version.d.ts.map +1 -0
- package/dist/esm/commands/version.js +226 -0
- package/dist/esm/commands/version.js.map +1 -0
- package/dist/esm/config/definition.d.ts +118 -15
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +185 -37
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/config/index.d.ts +41 -37
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +109 -172
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/config/merge.d.ts +3 -1
- package/dist/esm/config/merge.d.ts.map +1 -1
- package/dist/esm/config/merge.js +11 -6
- package/dist/esm/config/merge.js.map +1 -1
- package/dist/esm/custom-help.d.ts +9 -0
- package/dist/esm/custom-help.d.ts.map +1 -0
- package/dist/esm/custom-help.js +400 -0
- package/dist/esm/custom-help.js.map +1 -0
- package/dist/esm/exec-command.d.ts +33 -14
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +213 -64
- package/dist/esm/exec-command.js.map +1 -1
- package/dist/esm/index.d.ts +1 -14
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +45 -19
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/load-command.d.ts +16 -0
- package/dist/esm/load-command.d.ts.map +1 -0
- package/dist/esm/load-command.js +21 -0
- package/dist/esm/load-command.js.map +1 -0
- package/dist/esm/output.d.ts +6 -11
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +64 -27
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/pack-tarball.d.ts +22 -0
- package/dist/esm/pack-tarball.d.ts.map +1 -0
- package/dist/esm/pack-tarball.js +249 -0
- package/dist/esm/pack-tarball.js.map +1 -0
- package/dist/esm/print-err.d.ts +9 -2
- package/dist/esm/print-err.d.ts.map +1 -1
- package/dist/esm/print-err.js +130 -46
- package/dist/esm/print-err.js.map +1 -1
- package/dist/esm/query-host-contexts.d.ts +16 -0
- package/dist/esm/query-host-contexts.d.ts.map +1 -0
- package/dist/esm/query-host-contexts.js +135 -0
- package/dist/esm/query-host-contexts.js.map +1 -0
- package/dist/esm/start-gui.d.ts +1 -0
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +28 -8
- package/dist/esm/start-gui.js.map +1 -1
- package/dist/esm/view.d.ts +2 -3
- package/dist/esm/view.d.ts.map +1 -1
- package/dist/esm/view.js +1 -1
- package/dist/esm/view.js.map +1 -1
- package/package.json +51 -37
- package/dist/esm/commands/gui.d.ts +0 -6
- package/dist/esm/commands/gui.d.ts.map +0 -1
- package/dist/esm/commands/gui.js +0 -13
- package/dist/esm/commands/gui.js.map +0 -1
|
@@ -1,153 +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
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { definition, isRecordField, pairsToRecords, recordsToPairs, } from "../config/index.js";
|
|
4
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
|
+
};
|
|
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
|
-
res.push(`--${f}${hint}`);
|
|
92
|
-
res.push(` type: ${type}`);
|
|
93
|
-
if (def.default) {
|
|
94
|
-
res.push(` default: ${JSON.stringify(def.default)}`);
|
|
232
|
+
// Handle primitive values
|
|
233
|
+
let stringValue;
|
|
234
|
+
if (typeof value === 'string') {
|
|
235
|
+
stringValue = value;
|
|
95
236
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
237
|
+
else if (typeof value === 'number' ||
|
|
238
|
+
typeof value === 'boolean') {
|
|
239
|
+
stringValue = String(value);
|
|
98
240
|
}
|
|
241
|
+
else {
|
|
242
|
+
stringValue = '[object]';
|
|
243
|
+
}
|
|
244
|
+
result.push(`${key}=${stringValue}`);
|
|
99
245
|
}
|
|
100
246
|
}
|
|
101
|
-
return
|
|
247
|
+
return result.sort();
|
|
102
248
|
};
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
}
|
|
105
267
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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 [];
|
|
112
285
|
}
|
|
113
|
-
await conf.deleteConfigKeys(conf.get('config'), fields);
|
|
114
286
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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;
|
|
141
379
|
}
|
|
380
|
+
return originalGet.call(conf, key);
|
|
142
381
|
});
|
|
382
|
+
try {
|
|
383
|
+
return await del(conf);
|
|
384
|
+
}
|
|
385
|
+
finally {
|
|
386
|
+
// Restore the original get method
|
|
387
|
+
conf.get = originalGet;
|
|
388
|
+
}
|
|
143
389
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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;
|
|
150
407
|
}
|
|
151
|
-
|
|
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;
|
|
152
423
|
};
|
|
153
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,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EACL,UAAU,EACV,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAA;AAM3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,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,6BAA6B;SAC3C;QAED,IAAI,EAAE;YAC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M,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAChC,CAAC;IACD,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,EAAE;QACnD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACf,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE;YACnC,KAAK,EAAE,SAAS;SACjB,CAAC,CAAA;QACF,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,KAAK,CAAC,GAAG,OAAO,iBAAiB,EAAE;gBACvC,GAAG,GAAG;gBACN,OAAO;gBACP,IAAI;aACL,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,GAAG,GAAG,KAAK,EAAE,IAAkB,EAAE,EAAE;IACvC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,KAAK,CAAC,yCAAyC,EAAE;YACrD,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,IAAI,CAAC,eAAe,CACxB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAClB,cAAc,CACZ,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CACtD,CACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { spawnSync } from 'node:child_process'\nimport {\n definition,\n isRecordField,\n pairsToRecords,\n recordsToPairs,\n} from '../config/index.ts'\nimport type {\n ConfigDefinitions,\n LoadedConfig,\n RecordPairs,\n} from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'config',\n usage: '<command> [flags]',\n description: 'Work with vlt configuration',\n\n subcommands: {\n get: {\n usage: '<key> [<key> ...]',\n description: 'Print the named config value',\n },\n\n list: {\n description:\n 'Print all configuration settings currently in effect',\n },\n\n set: {\n usage:\n '<key>=<value> [<key>=<value> ...] [--config=<user | project>]',\n description: `Set config values. By default, these are\n written to the project config file, \\`vlt.json\\`\n in the root of the project. To set things for all\n projects, run with \\`--config=user\\``,\n },\n\n del: {\n usage: '<key> [<key> ...] [--config=<user | project>]',\n description: `Delete the named config fields. If no values remain in\n the config file, delete the file as well. By default,\n operates on the \\`vlt.json\\` file in the root of the\n current project. To delete a config field from the user\n config file, specify \\`--config=user\\`.`,\n },\n\n edit: {\n usage: '[--config=<user | project>]',\n description: 'Edit the configuration file',\n },\n\n help: {\n usage: '[field ...]',\n description: `Get information about a config field, or show a list\n of known config field names.`,\n },\n },\n })\n\nexport const command: CommandFn<\n string | number | boolean | void | string[] | RecordPairs\n> = async conf => {\n const sub = conf.positionals[0]\n switch (sub) {\n case 'set':\n return set(conf)\n\n case 'get':\n return get(conf)\n\n case 'ls':\n case 'list':\n return list(conf)\n\n case 'edit':\n return edit(conf)\n\n case 'help':\n return help(conf)\n\n case 'del':\n return del(conf)\n\n default: {\n throw error('Unrecognized config command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['set', 'get', 'list', 'edit', 'help', 'del'],\n })\n }\n }\n}\n\nconst help = (conf: LoadedConfig) => {\n const j = definition.toJSON()\n const fields = conf.positionals.slice(1)\n if (!fields.length) {\n return [\n 'Specify one or more options to see information:',\n ...Object.keys(j)\n .sort((a, b) => a.localeCompare(b, 'en'))\n .map(c => ` ${c}`),\n ].join('\\n')\n }\n\n // TODO: some kind of fuzzy search?\n const res: string[] = []\n for (const f of fields) {\n const def = j[f]\n if (!def) {\n res.push(`unknown config field: ${f}`)\n } else {\n const hint = def.hint ? `=<${def.hint}>` : ''\n const type =\n isRecordField(f) ?\n 'Record<string, string>'\n : def.type + (def.multiple ? '[]' : '')\n\n res.push(`--${f}${hint}`)\n res.push(` type: ${type}`)\n if (def.default) {\n res.push(` default: ${JSON.stringify(def.default)}`)\n }\n if (def.description) {\n res.push(def.description)\n }\n }\n }\n return res.join('\\n')\n}\n\nconst list = (conf: LoadedConfig) => {\n return recordsToPairs(conf.options)\n}\n\nconst del = async (conf: LoadedConfig) => {\n const fields = conf.positionals.slice(1)\n if (!fields.length) {\n throw error('At least one key is required', {\n code: 'EUSAGE',\n })\n }\n await conf.deleteConfigKeys(conf.get('config'), fields)\n}\n\nconst get = async (conf: LoadedConfig) => {\n const keys = conf.positionals.slice(1)\n const k = keys[0]\n if (!k || keys.length > 1) {\n throw error('Exactly one key is required', {\n code: 'EUSAGE',\n })\n }\n return conf.get(k as keyof ConfigDefinitions)\n}\n\nconst edit = async (conf: LoadedConfig) => {\n const [command, ...args] = conf.get('editor').split(' ')\n if (!command) {\n throw error(`editor is empty`)\n }\n await conf.editConfigFile(conf.get('config'), file => {\n args.push(file)\n const res = spawnSync(command, args, {\n stdio: 'inherit',\n })\n if (res.status !== 0) {\n throw error(`${command} command failed`, {\n ...res,\n command,\n args,\n })\n }\n })\n}\n\nconst set = async (conf: LoadedConfig) => {\n const pairs = conf.positionals.slice(1)\n if (!pairs.length) {\n throw error('At least one key=value pair is required', {\n code: 'EUSAGE',\n })\n }\n await conf.addConfigToFile(\n conf.get('config'),\n pairsToRecords(\n conf.jack.parseRaw(pairs.map(kv => `--${kv}`)).values,\n ),\n )\n}\n"]}
|
|
1
|
+
{"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,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C,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"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|