@vltpkg/cli-sdk 0.0.0-18 → 0.0.0-19
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/ci.d.ts +10 -0
- package/dist/esm/commands/ci.d.ts.map +1 -0
- package/dist/esm/commands/ci.js +28 -0
- package/dist/esm/commands/ci.js.map +1 -0
- package/dist/esm/commands/config.d.ts.map +1 -1
- package/dist/esm/commands/config.js +2 -163
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +7 -1
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/config/definition.d.ts +10 -1
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +9 -0
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/exec-command.d.ts +4 -1
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +7 -4
- package/dist/esm/exec-command.js.map +1 -1
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +7 -5
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/pack-tarball.d.ts +3 -3
- package/dist/esm/pack-tarball.d.ts.map +1 -1
- package/dist/esm/pack-tarball.js +3 -3
- package/dist/esm/pack-tarball.js.map +1 -1
- package/package.json +24 -23
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Graph } from '@vltpkg/graph';
|
|
2
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
+
import { InstallReporter } from './install/reporter.ts';
|
|
4
|
+
export declare const usage: CommandUsage;
|
|
5
|
+
export declare const views: {
|
|
6
|
+
readonly json: (g: Graph) => import("@vltpkg/graph").LockfileData;
|
|
7
|
+
readonly human: typeof InstallReporter;
|
|
8
|
+
};
|
|
9
|
+
export declare const command: CommandFn<Graph>;
|
|
10
|
+
//# sourceMappingURL=ci.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,EAAE,YAWhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGe,CAAA;AAEjC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,CASpC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { commandUsage } from "../config/usage.js";
|
|
2
|
+
import { install } from '@vltpkg/graph';
|
|
3
|
+
import { InstallReporter } from "./install/reporter.js";
|
|
4
|
+
export const usage = () => commandUsage({
|
|
5
|
+
command: 'ci',
|
|
6
|
+
usage: '',
|
|
7
|
+
description: `Clean install from lockfile. Deletes node_modules and installs
|
|
8
|
+
dependencies exactly as specified in vlt-lock.json. This is
|
|
9
|
+
similar to running 'vlt install --expect-lockfile' but performs
|
|
10
|
+
a clean install by removing node_modules first.`,
|
|
11
|
+
examples: {
|
|
12
|
+
'': { description: 'Clean install from lockfile' },
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
export const views = {
|
|
16
|
+
json: g => g.toJSON(),
|
|
17
|
+
human: InstallReporter,
|
|
18
|
+
};
|
|
19
|
+
export const command = async (conf) => {
|
|
20
|
+
const ciOptions = {
|
|
21
|
+
...conf.options,
|
|
22
|
+
expectLockfile: true,
|
|
23
|
+
cleanInstall: true,
|
|
24
|
+
};
|
|
25
|
+
const { graph } = await install(ciOptions);
|
|
26
|
+
return graph;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=ci.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci.js","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;kEAGiD;IAC9D,QAAQ,EAAE;QACR,EAAE,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE;KACnD;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,eAAe;CACS,CAAA;AAEjC,MAAM,CAAC,MAAM,OAAO,GAAqB,KAAK,EAAC,IAAI,EAAC,EAAE;IACpD,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI,CAAC,OAAO;QACf,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;KACnB,CAAA;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { install } from '@vltpkg/graph'\nimport type { Views } from '../view.ts'\nimport { InstallReporter } from './install/reporter.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ci',\n usage: '',\n description: `Clean install from lockfile. Deletes node_modules and installs \n dependencies exactly as specified in vlt-lock.json. This is \n similar to running 'vlt install --expect-lockfile' but performs \n a clean install by removing node_modules first.`,\n examples: {\n '': { description: 'Clean install from lockfile' },\n },\n })\n\nexport const views = {\n json: g => g.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<Graph>\n\nexport const command: CommandFn<Graph> = async conf => {\n const ciOptions = {\n ...conf.options,\n expectLockfile: true,\n cleanInstall: true,\n }\n\n const { graph } = await install(ciOptions)\n return graph\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YA8ChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAC7B,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,WAAW,CA+B1D,CAAA"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import * as dotProp from '@vltpkg/dot-prop';
|
|
3
|
-
import { asRootError } from '@vltpkg/output/error';
|
|
4
|
-
import { isObject } from '@vltpkg/types';
|
|
5
|
-
import { spawnSync } from 'node:child_process';
|
|
6
|
-
import { getSortedKeys } from "../config/definition.js";
|
|
7
|
-
import { definition, isRecordField, pairsToRecords, recordsToPairs, } from "../config/index.js";
|
|
8
2
|
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
import { isRecordField, definition } from "../config/index.js";
|
|
4
|
+
import { get, set, edit, list, del } from '@vltpkg/config';
|
|
9
5
|
export const usage = () => commandUsage({
|
|
10
6
|
command: 'config',
|
|
11
7
|
usage: '<command> [flags]',
|
|
@@ -104,161 +100,4 @@ const help = (conf) => {
|
|
|
104
100
|
}
|
|
105
101
|
return res.join('\n');
|
|
106
102
|
};
|
|
107
|
-
const list = (conf) => {
|
|
108
|
-
return recordsToPairs(conf.options);
|
|
109
|
-
};
|
|
110
|
-
const del = async (conf) => {
|
|
111
|
-
const fields = conf.positionals.slice(1);
|
|
112
|
-
if (!fields.length) {
|
|
113
|
-
throw error('At least one key is required', {
|
|
114
|
-
code: 'EUSAGE',
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
await conf.deleteConfigKeys(conf.get('config'), fields);
|
|
118
|
-
};
|
|
119
|
-
const get = async (conf) => {
|
|
120
|
-
const keys = conf.positionals.slice(1);
|
|
121
|
-
const k = keys[0];
|
|
122
|
-
if (!k || keys.length > 1) {
|
|
123
|
-
throw error('Exactly one key is required', {
|
|
124
|
-
code: 'EUSAGE',
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
// check if this is a dot-prop path into a record field, in which case
|
|
128
|
-
// we need to get the record first and then use dot-prop to get the value
|
|
129
|
-
if (k.includes('.')) {
|
|
130
|
-
const [field, ...rest] = k.split('.');
|
|
131
|
-
const subKey = rest.join('.');
|
|
132
|
-
if (!field || !subKey) {
|
|
133
|
-
throw error('Could not read property', {
|
|
134
|
-
found: k,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
// we'd need a type assertion helper from jackspeak definition
|
|
138
|
-
// options in order to cast the field to a known name type
|
|
139
|
-
// @ts-expect-error @typescript-eslint/no-unsafe-argument
|
|
140
|
-
const record = conf.getRecord(field);
|
|
141
|
-
return dotProp.get(record, subKey);
|
|
142
|
-
}
|
|
143
|
-
// otherwise just get the value directly from the config getter
|
|
144
|
-
return isRecordField(k) ?
|
|
145
|
-
conf.getRecord(k)
|
|
146
|
-
: conf.get(k);
|
|
147
|
-
};
|
|
148
|
-
const edit = async (conf) => {
|
|
149
|
-
const [command, ...args] = conf.get('editor').split(' ');
|
|
150
|
-
if (!command) {
|
|
151
|
-
throw error(`editor is empty`);
|
|
152
|
-
}
|
|
153
|
-
await conf.editConfigFile(conf.get('config'), file => {
|
|
154
|
-
args.push(file);
|
|
155
|
-
const res = spawnSync(command, args, {
|
|
156
|
-
stdio: 'inherit',
|
|
157
|
-
});
|
|
158
|
-
if (res.status !== 0) {
|
|
159
|
-
throw error(`${command} command failed`, {
|
|
160
|
-
...res,
|
|
161
|
-
command,
|
|
162
|
-
args,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
const set = async (conf) => {
|
|
168
|
-
const pairs = conf.positionals.slice(1);
|
|
169
|
-
if (!pairs.length) {
|
|
170
|
-
// Create an empty config file
|
|
171
|
-
await conf.addConfigToFile(conf.get('config'), {});
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const which = conf.get('config');
|
|
175
|
-
// separate dot-prop paths from simple keys for different handling
|
|
176
|
-
// any keys that include a dot (.) will be treated as dotPropPairs
|
|
177
|
-
// other keys/value pairs are handled as simplePairs
|
|
178
|
-
const dotPropPairs = [];
|
|
179
|
-
const simplePairs = [];
|
|
180
|
-
for (const pair of pairs) {
|
|
181
|
-
const eq = pair.indexOf('=');
|
|
182
|
-
if (eq === -1) {
|
|
183
|
-
throw error('Set arguments must contain `=`', {
|
|
184
|
-
code: 'EUSAGE',
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const key = pair.substring(0, eq);
|
|
188
|
-
const value = pair.substring(eq + 1);
|
|
189
|
-
if (key.includes('.')) {
|
|
190
|
-
const [field, ...rest] = key.split('.');
|
|
191
|
-
const subKey = rest.join('.');
|
|
192
|
-
if (field && subKey) {
|
|
193
|
-
dotPropPairs.push({ key, field, subKey, value });
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
throw error('Could not read property', {
|
|
197
|
-
found: pair,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
simplePairs.push(pair);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// Handle keys that consists of a single name (e.g., `--foo`)
|
|
206
|
-
// so that it doesn't need the dot-prop logic to handle values
|
|
207
|
-
if (simplePairs.length > 0) {
|
|
208
|
-
try {
|
|
209
|
-
const parsed = conf.jack.parseRaw(simplePairs.map(kv => `--${kv}`)).values;
|
|
210
|
-
await conf.addConfigToFile(which, pairsToRecords(parsed));
|
|
211
|
-
}
|
|
212
|
-
catch (err) {
|
|
213
|
-
handleSetError(simplePairs, err);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// Handle dot-prop paths for record fields
|
|
217
|
-
if (dotPropPairs.length > 0) {
|
|
218
|
-
for (const { field, subKey, value } of dotPropPairs) {
|
|
219
|
-
if (isRecordField(field)) {
|
|
220
|
-
// For record fields, we add entries in the format field=key=value
|
|
221
|
-
const recordPair = `${field}=${subKey}=${value}`;
|
|
222
|
-
try {
|
|
223
|
-
const parsed = conf.jack.parseRaw([
|
|
224
|
-
`--${recordPair}`,
|
|
225
|
-
]).values;
|
|
226
|
-
await conf.addConfigToFile(which, pairsToRecords(parsed));
|
|
227
|
-
/* c8 ignore start */
|
|
228
|
-
}
|
|
229
|
-
catch (err) {
|
|
230
|
-
handleSetError([recordPair], err);
|
|
231
|
-
}
|
|
232
|
-
/* c8 ignore end */
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
const handleSetError = (simplePairs, err) => {
|
|
238
|
-
const { name, found, validOptions } = asRootError(err).cause;
|
|
239
|
-
// when a boolean gets a value, it throw a parse error
|
|
240
|
-
if (isObject(found) &&
|
|
241
|
-
typeof found.name === 'string' &&
|
|
242
|
-
typeof found.value === 'string') {
|
|
243
|
-
const { name, value } = found;
|
|
244
|
-
throw error(`Boolean flag must be "${name}" or "no-${name}", not a value`, {
|
|
245
|
-
code: 'ECONFIG',
|
|
246
|
-
name,
|
|
247
|
-
found: `${name}=${value}`,
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
if (Array.isArray(validOptions)) {
|
|
251
|
-
throw error(`Invalid value provided for ${name}`, {
|
|
252
|
-
code: 'ECONFIG',
|
|
253
|
-
found,
|
|
254
|
-
validOptions,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
// an unknown property
|
|
258
|
-
throw error('Invalid config keys', {
|
|
259
|
-
code: 'ECONFIG',
|
|
260
|
-
found: simplePairs.map(kv => kv.split('=')[0]),
|
|
261
|
-
validOptions: getSortedKeys(),
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
103
|
//# 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,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EACL,UAAU,EACV,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAQjD,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;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AAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,YAAY,EAAE,aAAa,EAAE;KAC9B,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport * as dotProp from '@vltpkg/dot-prop'\nimport { asRootError } from '@vltpkg/output/error'\nimport { isObject } from '@vltpkg/types'\nimport { spawnSync } from 'node:child_process'\nimport { getSortedKeys } from '../config/definition.ts'\nimport {\n definition,\n isRecordField,\n pairsToRecords,\n recordsToPairs,\n} from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type {\n ConfigDefinitions,\n LoadedConfig,\n RecordPairs,\n} 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\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\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 // check if this is a dot-prop path into a record field, in which case\n // we need to get the record first and then use dot-prop to get the value\n if (k.includes('.')) {\n const [field, ...rest] = k.split('.')\n const subKey = rest.join('.')\n\n if (!field || !subKey) {\n throw error('Could not read property', {\n found: k,\n })\n }\n\n // we'd need a type assertion helper from jackspeak definition\n // options in order to cast the field to a known name type\n // @ts-expect-error @typescript-eslint/no-unsafe-argument\n const record = conf.getRecord(field)\n\n return dotProp.get(record, subKey) as\n | string\n | number\n | boolean\n | string[]\n | undefined\n }\n\n // otherwise just get the value directly from the config getter\n return isRecordField(k) ?\n conf.getRecord(k)\n : 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 // Create an empty config file\n await conf.addConfigToFile(conf.get('config'), {})\n return\n }\n\n const which = conf.get('config')\n\n // separate dot-prop paths from simple keys for different handling\n // any keys that include a dot (.) will be treated as dotPropPairs\n // other keys/value pairs are handled as simplePairs\n const dotPropPairs: {\n key: string\n field: string\n subKey: string\n value: string\n }[] = []\n const simplePairs: string[] = []\n\n for (const pair of pairs) {\n const eq = pair.indexOf('=')\n if (eq === -1) {\n throw error('Set arguments must contain `=`', {\n code: 'EUSAGE',\n })\n }\n\n const key = pair.substring(0, eq)\n const value = pair.substring(eq + 1)\n if (key.includes('.')) {\n const [field, ...rest] = key.split('.')\n const subKey = rest.join('.')\n if (field && subKey) {\n dotPropPairs.push({ key, field, subKey, value })\n } else {\n throw error('Could not read property', {\n found: pair,\n })\n }\n } else {\n simplePairs.push(pair)\n }\n }\n\n // Handle keys that consists of a single name (e.g., `--foo`)\n // so that it doesn't need the dot-prop logic to handle values\n if (simplePairs.length > 0) {\n try {\n const parsed = conf.jack.parseRaw(\n simplePairs.map(kv => `--${kv}`),\n ).values\n await conf.addConfigToFile(which, pairsToRecords(parsed))\n } catch (err) {\n handleSetError(simplePairs, err)\n }\n }\n\n // Handle dot-prop paths for record fields\n if (dotPropPairs.length > 0) {\n for (const { field, subKey, value } of dotPropPairs) {\n if (isRecordField(field)) {\n // For record fields, we add entries in the format field=key=value\n const recordPair = `${field}=${subKey}=${value}`\n try {\n const parsed = conf.jack.parseRaw([\n `--${recordPair}`,\n ]).values\n await conf.addConfigToFile(which, pairsToRecords(parsed))\n /* c8 ignore start */\n } catch (err) {\n handleSetError([recordPair], err)\n }\n /* c8 ignore end */\n }\n }\n }\n}\n\nconst handleSetError = (simplePairs: string[], err: unknown) => {\n const { name, found, validOptions } = asRootError(err).cause\n // when a boolean gets a value, it throw a parse error\n if (\n isObject(found) &&\n typeof found.name === 'string' &&\n typeof found.value === 'string'\n ) {\n const { name, value } = found\n throw error(\n `Boolean flag must be \"${name}\" or \"no-${name}\", not a value`,\n {\n code: 'ECONFIG',\n name,\n found: `${name}=${value}`,\n },\n )\n }\n if (Array.isArray(validOptions)) {\n throw error(`Invalid value provided for ${name}`, {\n code: 'ECONFIG',\n found,\n validOptions,\n })\n }\n // an unknown property\n throw error('Invalid config keys', {\n code: 'ECONFIG',\n found: simplePairs.map(kv => kv.split('=')[0]),\n validOptions: getSortedKeys(),\n })\n}\n"]}
|
|
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;SAC5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A;YAC3B,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;gBAChB,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YACvD,CAAC;YACD,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;gBACpB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YAC3B,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGe,CAAA;AAEjC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGe,CAAA;AAEjC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,KAAK,CAcpC,CAAA"}
|
|
@@ -15,7 +15,13 @@ export const views = {
|
|
|
15
15
|
export const command = async (conf) => {
|
|
16
16
|
const monorepo = conf.options.monorepo;
|
|
17
17
|
const { add } = parseAddArgs(conf, monorepo);
|
|
18
|
-
const
|
|
18
|
+
const frozenLockfile = conf.options['frozen-lockfile'];
|
|
19
|
+
const expectLockfile = conf.options['expect-lockfile'];
|
|
20
|
+
const { graph } = await install({
|
|
21
|
+
...conf.options,
|
|
22
|
+
frozenLockfile,
|
|
23
|
+
expectLockfile,
|
|
24
|
+
}, add);
|
|
19
25
|
return graph;
|
|
20
26
|
};
|
|
21
27
|
//# sourceMappingURL=install.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE;+CAC8B;CAC5C,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,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GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IACtD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAC7B;QACE,GAAG,IAAI,CAAC,OAAO;QACf,cAAc;QACd,cAAc;KACf,EACD,GAAG,CACJ,CAAA;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { install } from '@vltpkg/graph'\nimport { parseAddArgs } from '../parse-add-remove-args.ts'\nimport type { Views } from '../view.ts'\nimport { InstallReporter } from './install/reporter.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install',\n usage: '[packages ...]',\n description: `Install the specified packages, updating package.json and\n vlt-lock.json appropriately.`,\n })\n\nexport const views = {\n json: g => g.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<Graph>\n\nexport const command: CommandFn<Graph> = async conf => {\n const monorepo = conf.options.monorepo\n const { add } = parseAddArgs(conf, monorepo)\n const frozenLockfile = conf.options['frozen-lockfile']\n const expectLockfile = conf.options['expect-lockfile']\n const { graph } = await install(\n {\n ...conf.options,\n frozenLockfile,\n expectLockfile,\n },\n add,\n )\n return graph\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,M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ACrB,CAAC,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CACvB,CAAA;QACH,CAAC,EAAE,QAAQ,CAAC,CAAA;QAEZ,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAC1B,CAAC;AACH,CAAC,CAAA;AAED,MAAM,EAAE,GAAG,CACT,KAAmB,EACnB,SAAiC,EACjC,GAAgB,EAChB,IAAc,EACd,EAAE;IACF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,CAAC,uBAAuB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1D,CAAC;IAED,MAAM,OAAO,GAA2B,EAAE,CAAA;IAE1C,KAAK,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,SAAS,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YACnC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;YACrB,OAAO,GAAG,CAAA;QACZ,CAAC,EAAE,QAAQ,CAAC,CAAA;QAEZ,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;QACxB,OAAO,CAAC,IAAI,CAAC;YACX,QAAQ,EAAE,GAAG;YACb,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { resolve } from 'node:path'\nimport * as dotProp from '@vltpkg/dot-prop'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { Manifest } from '@vltpkg/types'\nimport assert from 'node:assert'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { init } from '@vltpkg/init'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { Views } from '../view.ts'\nimport { views as initViews } from './init.ts'\nimport { actual, GraphModifier } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport type { Monorepo as _Monorepo } from '@vltpkg/workspaces'\nimport type { QueryResponseNode } from '@vltpkg/query'\n\ntype ManifestWithLocation = {\n manifest: Manifest\n location: string\n}\n\nconst json = (\n results: ManifestWithLocation[] | ManifestWithLocation,\n) => JSON.stringify(results, null, 2)\n\nexport const views = {\n human: (_results, _options, config) => {\n const results = _results as\n | ManifestWithLocation[]\n | ManifestWithLocation\n // `vlt pkg init` is an alias for `vlt init`\n // use the same output handling\n if (config.positionals[0] === 'init') {\n return initViews.human(results as InitFileResults)\n }\n\n return (\n Array.isArray(results) ?\n typeof results[0] === 'string' ?\n (results as unknown as string[]).join('\\n')\n : json(results)\n : json(results)\n )\n },\n} as const satisfies Views\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pkg',\n usage: '[<command>] [<args>]',\n description: 'Get or manipulate package.json values',\n subcommands: {\n get: {\n usage: '[<key>]',\n description: 'Get a single value',\n },\n init: {\n usage: '',\n description:\n 'Initialize a new package.json file in the current directory',\n },\n pick: {\n usage: '[<key> [<key> ...]]',\n description: 'Get multiple values or the entire package',\n },\n set: {\n usage: '<key>=<value> [<key>=<value> ...]',\n description: 'Set one or more key value pairs',\n },\n delete: {\n usage: '<key> [<key> ...]',\n description: 'Delete one or more keys from the package',\n },\n },\n examples: {\n 'set \"array[1].key=value\"': {\n description: 'Set a value on an object inside an array',\n },\n 'set \"array[]=value\"': {\n description: 'Append a value to an array',\n },\n },\n })\n\nexport const command: CommandFn = async conf => {\n const [sub, ...args] = conf.positionals\n if (sub === 'init') {\n return await init({ cwd: process.cwd() })\n }\n\n const pkg = conf.options.packageJson\n\n // Handle --scope option to get multiple manifests\n const scopeQueryString = conf.get('scope')\n let manifests: ManifestWithLocation[]\n\n if (scopeQueryString) {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: false,\n })\n\n const securityArchive =\n Query.hasSecuritySelectors(scopeQueryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n\n const { nodes } = await query.search(scopeQueryString, {\n signal: new AbortController().signal,\n })\n\n // collects the paths of the nodes selected using --scope\n const scopePaths = nodes\n .filter(\n (n): n is QueryResponseNode & { location: string } =>\n n.location !== undefined,\n )\n .map(n => resolve(conf.options.projectRoot, n.location))\n\n // reads multiple manifests for each selected scope\n manifests = scopePaths.map(location => ({\n manifest: pkg.read(location),\n location,\n }))\n\n if (manifests.length === 0) {\n throw error('No matching package found using scope', {\n found: scopeQueryString,\n })\n }\n } else {\n // Single manifest mode\n const location = pkg.find() ?? conf.projectRoot\n manifests = [\n {\n manifest: pkg.read(location),\n location,\n },\n ]\n }\n\n switch (sub) {\n case 'get':\n return get(manifests, args)\n case 'pick':\n return pick(manifests, args)\n case 'set':\n return set(conf, manifests, pkg, args)\n case 'rm':\n case 'remove':\n case 'unset':\n case 'delete':\n return rm(conf, manifests, pkg, args)\n default: {\n throw error('Unrecognized pkg command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['get', 'set', 'rm'],\n })\n }\n }\n}\n\nconst get = (manifests: ManifestWithLocation[], args: string[]) => {\n const noArg = () =>\n error(\n 'get requires not more than 1 argument. use `pick` to get more than 1.',\n { code: 'EUSAGE' },\n noArg,\n )\n if (args.length !== 1) {\n if (args.length > 1) {\n throw noArg()\n }\n return pick(manifests, args)\n }\n assert(args[0] != null, noArg())\n\n const [key] = args\n\n if (manifests.length === 1) {\n const [firstManifest] = manifests\n if (!firstManifest?.manifest) {\n /* c8 ignore start */\n throw error(\n 'No manifest found',\n firstManifest?.location ?\n { path: firstManifest.location }\n : {},\n )\n /* c8 ignore stop */\n }\n return dotProp.get(firstManifest.manifest, key)\n }\n\n return manifests.map(manifest =>\n dotProp.get(manifest.manifest, key),\n )\n}\n\nconst pick = (manifests: ManifestWithLocation[], args: string[]) => {\n if (manifests.length === 1) {\n const [firstManifest] = manifests\n /* c8 ignore start */\n if (!firstManifest?.manifest) {\n throw error(\n 'No manifest found',\n firstManifest?.location ?\n { path: firstManifest.location }\n : {},\n )\n }\n /* c8 ignore stop */\n const { manifest } = firstManifest\n return args.length ?\n args.reduce(\n (acc, key) =>\n dotProp.set(acc, key, dotProp.get(manifest, key)),\n {},\n )\n : manifest\n }\n\n // Multiple manifests - return results keyed by location\n return manifests.map(manifest =>\n args.length ?\n args.reduce(\n (acc, key) =>\n dotProp.set(acc, key, dotProp.get(manifest.manifest, key)),\n {},\n )\n : manifest.manifest,\n )\n}\n\nconst set = (\n _conf: LoadedConfig,\n manifests: ManifestWithLocation[],\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('set requires arguments', { code: 'EUSAGE' })\n }\n\n for (const { manifest, location } of manifests) {\n const res = args.reduce((acc, p) => {\n const index = p.indexOf('=')\n if (index === -1) {\n throw error('set arguments must contain `=`', {\n code: 'EUSAGE',\n })\n }\n return dotProp.set(\n acc,\n p.substring(0, index),\n p.substring(index + 1),\n )\n }, manifest)\n\n pkg.write(location, res)\n }\n}\n\nconst rm = (\n _conf: LoadedConfig,\n manifests: ManifestWithLocation[],\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('rm requires arguments', { code: 'EUSAGE' })\n }\n\n const results: ManifestWithLocation[] = []\n\n for (const { manifest, location } of manifests) {\n const res = args.reduce((acc, key) => {\n dotProp.del(acc, key)\n return acc\n }, manifest)\n\n pkg.write(location, res)\n results.push({\n manifest: res,\n location,\n })\n }\n\n if (manifests.length === 1) {\n return results[0]\n }\n return results\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pkg.js","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG3C,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGnC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAS1D,MAAM,IAAI,GAAG,CACX,OAAsD,EACtD,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAErC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE;QACpC,MAAM,OAAO,GAAG,QAEQ,CAAA;QACxB,4CAA4C;QAC5C,+BAA+B;QAC/B,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;YACrC,OAAO,SAAS,CAAC,KAAK,CAAC,OAA0B,CAAC,CAAA;QACpD,CAAC;QAED,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACtB,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC;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C,CAAA;QAEZ,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;QACxB,OAAO,CAAC,IAAI,CAAC;YACX,QAAQ,EAAE,GAAG;YACb,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { resolve } from 'node:path'\nimport * as dotProp from '@vltpkg/dot-prop'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport assert from 'node:assert'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { init } from '@vltpkg/init'\nimport type { InitFileResults } from '@vltpkg/init'\nimport type { Views } from '../view.ts'\nimport { views as initViews } from './init.ts'\nimport { actual, GraphModifier } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport type { Monorepo as _Monorepo } from '@vltpkg/workspaces'\nimport type { QueryResponseNode } from '@vltpkg/query'\n\ntype ManifestWithLocation = {\n manifest: NormalizedManifest\n location: string\n}\n\nconst json = (\n results: ManifestWithLocation[] | ManifestWithLocation,\n) => JSON.stringify(results, null, 2)\n\nexport const views = {\n human: (_results, _options, config) => {\n const results = _results as\n | ManifestWithLocation[]\n | ManifestWithLocation\n // `vlt pkg init` is an alias for `vlt init`\n // use the same output handling\n if (config.positionals[0] === 'init') {\n return initViews.human(results as InitFileResults)\n }\n\n return (\n Array.isArray(results) ?\n typeof results[0] === 'string' ?\n (results as unknown as string[]).join('\\n')\n : json(results)\n : json(results)\n )\n },\n} as const satisfies Views\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'pkg',\n usage: '[<command>] [<args>]',\n description: 'Get or manipulate package.json values',\n subcommands: {\n get: {\n usage: '[<key>]',\n description: 'Get a single value',\n },\n init: {\n usage: '',\n description:\n 'Initialize a new package.json file in the current directory',\n },\n pick: {\n usage: '[<key> [<key> ...]]',\n description: 'Get multiple values or the entire package',\n },\n set: {\n usage: '<key>=<value> [<key>=<value> ...]',\n description: 'Set one or more key value pairs',\n },\n delete: {\n usage: '<key> [<key> ...]',\n description: 'Delete one or more keys from the package',\n },\n },\n examples: {\n 'set \"array[1].key=value\"': {\n description: 'Set a value on an object inside an array',\n },\n 'set \"array[]=value\"': {\n description: 'Append a value to an array',\n },\n },\n })\n\nexport const command: CommandFn = async conf => {\n const [sub, ...args] = conf.positionals\n if (sub === 'init') {\n return await init({ cwd: process.cwd() })\n }\n\n const pkg = conf.options.packageJson\n\n // Handle --scope option to get multiple manifests\n const scopeQueryString = conf.get('scope')\n let manifests: ManifestWithLocation[]\n\n if (scopeQueryString) {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: false,\n })\n\n const securityArchive =\n Query.hasSecuritySelectors(scopeQueryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n\n const { nodes } = await query.search(scopeQueryString, {\n signal: new AbortController().signal,\n })\n\n // collects the paths of the nodes selected using --scope\n const scopePaths = nodes\n .filter(\n (n): n is QueryResponseNode & { location: string } =>\n n.location !== undefined,\n )\n .map(n => resolve(conf.options.projectRoot, n.location))\n\n // reads multiple manifests for each selected scope\n manifests = scopePaths.map(location => ({\n manifest: pkg.read(location),\n location,\n }))\n\n if (manifests.length === 0) {\n throw error('No matching package found using scope', {\n found: scopeQueryString,\n })\n }\n } else {\n // Single manifest mode\n const location = pkg.find() ?? conf.projectRoot\n manifests = [\n {\n manifest: pkg.read(location),\n location,\n },\n ]\n }\n\n switch (sub) {\n case 'get':\n return get(manifests, args)\n case 'pick':\n return pick(manifests, args)\n case 'set':\n return set(conf, manifests, pkg, args)\n case 'rm':\n case 'remove':\n case 'unset':\n case 'delete':\n return rm(conf, manifests, pkg, args)\n default: {\n throw error('Unrecognized pkg command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['get', 'set', 'rm'],\n })\n }\n }\n}\n\nconst get = (manifests: ManifestWithLocation[], args: string[]) => {\n const noArg = () =>\n error(\n 'get requires not more than 1 argument. use `pick` to get more than 1.',\n { code: 'EUSAGE' },\n noArg,\n )\n if (args.length !== 1) {\n if (args.length > 1) {\n throw noArg()\n }\n return pick(manifests, args)\n }\n assert(args[0] != null, noArg())\n\n const [key] = args\n\n if (manifests.length === 1) {\n const [firstManifest] = manifests\n if (!firstManifest?.manifest) {\n /* c8 ignore start */\n throw error(\n 'No manifest found',\n firstManifest?.location ?\n { path: firstManifest.location }\n : {},\n )\n /* c8 ignore stop */\n }\n return dotProp.get(firstManifest.manifest, key)\n }\n\n return manifests.map(manifest =>\n dotProp.get(manifest.manifest, key),\n )\n}\n\nconst pick = (manifests: ManifestWithLocation[], args: string[]) => {\n if (manifests.length === 1) {\n const [firstManifest] = manifests\n /* c8 ignore start */\n if (!firstManifest?.manifest) {\n throw error(\n 'No manifest found',\n firstManifest?.location ?\n { path: firstManifest.location }\n : {},\n )\n }\n /* c8 ignore stop */\n const { manifest } = firstManifest\n return args.length ?\n args.reduce(\n (acc, key) =>\n dotProp.set(acc, key, dotProp.get(manifest, key)),\n {},\n )\n : manifest\n }\n\n // Multiple manifests - return results keyed by location\n return manifests.map(manifest =>\n args.length ?\n args.reduce(\n (acc, key) =>\n dotProp.set(acc, key, dotProp.get(manifest.manifest, key)),\n {},\n )\n : manifest.manifest,\n )\n}\n\nconst set = (\n _conf: LoadedConfig,\n manifests: ManifestWithLocation[],\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('set requires arguments', { code: 'EUSAGE' })\n }\n\n for (const { manifest, location } of manifests) {\n const res = args.reduce((acc, p) => {\n const index = p.indexOf('=')\n if (index === -1) {\n throw error('set arguments must contain `=`', {\n code: 'EUSAGE',\n })\n }\n return dotProp.set(\n acc,\n p.substring(0, index),\n p.substring(index + 1),\n )\n }, manifest)\n\n pkg.write(location, res)\n }\n}\n\nconst rm = (\n _conf: LoadedConfig,\n manifests: ManifestWithLocation[],\n pkg: PackageJson,\n args: string[],\n) => {\n if (args.length < 1) {\n throw error('rm requires arguments', { code: 'EUSAGE' })\n }\n\n const results: ManifestWithLocation[] = []\n\n for (const { manifest, location } of manifests) {\n const res = args.reduce((acc, key) => {\n dotProp.del(acc, key)\n return acc\n }, manifest)\n\n pkg.write(location, res)\n results.push({\n manifest: res,\n location,\n })\n }\n\n if (manifests.length === 1) {\n return results[0]\n }\n return results\n}\n"]}
|
|
@@ -19,6 +19,7 @@ export declare const commands: {
|
|
|
19
19
|
readonly ls: "list";
|
|
20
20
|
readonly xc: "exec-cache";
|
|
21
21
|
readonly cache: "cache";
|
|
22
|
+
readonly ci: "ci";
|
|
22
23
|
readonly config: "config";
|
|
23
24
|
readonly exec: "exec";
|
|
24
25
|
readonly 'exec-local': "exec-local";
|
|
@@ -266,7 +267,7 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
266
267
|
hint: string;
|
|
267
268
|
default: string;
|
|
268
269
|
description: string;
|
|
269
|
-
validOptions: readonly ["human", "json", "mermaid", "gui", "inspect"];
|
|
270
|
+
validOptions: readonly ["human", "json", "mermaid", "gui", "inspect", "silent"];
|
|
270
271
|
};
|
|
271
272
|
} & {
|
|
272
273
|
view: import("jackspeak").ConfigOption<"string", false, readonly string[] | undefined>;
|
|
@@ -310,8 +311,16 @@ export declare const definition: import("jackspeak").Jack<{
|
|
|
310
311
|
'dry-run': {
|
|
311
312
|
description: string;
|
|
312
313
|
};
|
|
314
|
+
'expect-lockfile': {
|
|
315
|
+
description: string;
|
|
316
|
+
};
|
|
317
|
+
'frozen-lockfile': {
|
|
318
|
+
description: string;
|
|
319
|
+
};
|
|
313
320
|
} & {
|
|
314
321
|
'dry-run': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
322
|
+
'expect-lockfile': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
323
|
+
'frozen-lockfile': import("jackspeak").ConfigOption<"boolean", false, undefined>;
|
|
315
324
|
} & {
|
|
316
325
|
access: {
|
|
317
326
|
description: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAA0C,CAAA;AAElE,eAAO,MAAM,aAAa,cAKjB,CAAA;
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,QAA0C,CAAA;AAElE,eAAO,MAAM,aAAa,cAKjB,CAAA;AA8CT;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGX,CAAA;AAEV;;GAEG;AACH,eAAO,MAAM,cAAc,uBAW1B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAA;AAEtC,eAAO,MAAM,UAAU,OACjB,MAAM,KACT,QAAQ,CAAC,MAAM,QAAQ,CAAC,GAAG,SACkC,CAAA;AAKhE;;GAEG;AACH,eAAO,MAAM,YAAY,iGAMf,CAAA;AAEV,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,aAAa,MAAO,MAAM,KAAG,CAAC,IAAI,WACN,CAAA;AAwCzC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA2OH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8MP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DvB,CAAA;AAEJ,eAAO,MAAM,mBAAmB,gBAS/B,CAAA;AAED,eAAO,MAAM,aAAa,gBAC2C,CAAA"}
|
|
@@ -9,6 +9,7 @@ export const defaultEditor = () => process.env.EDITOR ||
|
|
|
9
9
|
: 'vi');
|
|
10
10
|
const canonicalCommands = {
|
|
11
11
|
cache: 'cache',
|
|
12
|
+
ci: 'ci',
|
|
12
13
|
config: 'config',
|
|
13
14
|
exec: 'exec',
|
|
14
15
|
'exec-local': 'exec-local',
|
|
@@ -476,6 +477,7 @@ export const definition = j
|
|
|
476
477
|
commands.)
|
|
477
478
|
- mermaid: Output mermaid diagramming syntax. (Only
|
|
478
479
|
relevant for certain commands.)
|
|
480
|
+
- silent: Suppress all output to stdout.
|
|
479
481
|
|
|
480
482
|
If the requested view format is not supported for the
|
|
481
483
|
current command, or if no option is provided, then it
|
|
@@ -487,6 +489,7 @@ export const definition = j
|
|
|
487
489
|
'mermaid',
|
|
488
490
|
'gui',
|
|
489
491
|
'inspect',
|
|
492
|
+
'silent',
|
|
490
493
|
],
|
|
491
494
|
},
|
|
492
495
|
})
|
|
@@ -538,6 +541,12 @@ export const definition = j
|
|
|
538
541
|
'dry-run': {
|
|
539
542
|
description: 'Run command without making any changes',
|
|
540
543
|
},
|
|
544
|
+
'expect-lockfile': {
|
|
545
|
+
description: 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',
|
|
546
|
+
},
|
|
547
|
+
'frozen-lockfile': {
|
|
548
|
+
description: 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',
|
|
549
|
+
},
|
|
541
550
|
})
|
|
542
551
|
.opt({
|
|
543
552
|
access: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAA;AAElE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM;IAClB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;QAC7B,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,eAAe;QAC1C,CAAC,CAAC,IAAI,CAAC,CAAA;AAET,MAAM,iBAAiB,GAAG;IACxB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,YAAY;IAC1B,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,IAAI;IACR,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,UAAU;IACtB,GAAG,EAAE,KAAK;IACV,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;QACV,WAAW,EAAE,+CAA+C;KAC7D;IACD,OAAO,EAAE;QACP,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,mBAAmB;KACjC;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,2BAA2B;KACzC;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA;IAChC,OAAO,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,CAAoB,EAAE,EAAE;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,oBAAoB;QACpB,IAAI,CAAC,GAAG;YAAE,MAAM,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,EAAE,CAAA;QAC3C,OAAO,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView = process.stdout.isTTY ? 'human' : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n config: 'config',\n exec: 'exec',\n 'exec-local': 'exec-local',\n gui: 'gui',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'uninstall',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n conf: 'config',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n 'node-version': {\n hint: 'version',\n description: `Node version to use when choosing packages based on\n their \\`engines.node\\` value.`,\n default: process.version,\n },\n })\n\n .flag({\n 'git-shallow': {\n description: `Set to force \\`--depth=1\\` on all git clone actions.\n When set explicitly to false with --no-git-shallow,\n then \\`--depth=1\\` will not be used.\n\n When not set explicitly, \\`--depth=1\\` will be used for\n git hosts known to support this behavior.`,\n },\n })\n .num({\n 'fetch-retries': {\n hint: 'n',\n description: `Number of retries to perform when encountering network\n errors or likely-transient errors from git hosts.`,\n default: 3,\n },\n 'fetch-retry-factor': {\n hint: 'n',\n description: `The exponential backoff factor to use when retrying\n requests due to network issues.`,\n default: 2,\n },\n 'fetch-retry-mintimeout': {\n hint: 'n',\n description: `Number of milliseconds before starting first retry`,\n default: 0,\n },\n 'fetch-retry-maxtimeout': {\n hint: 'n',\n description: `Maximum number of milliseconds between two retries`,\n default: 30_000,\n },\n 'stale-while-revalidate-factor': {\n hint: 'n',\n default: 60,\n description: `If the server does not serve a \\`stale-while-revalidate\\`\n value in the \\`cache-control\\` header, then this multiplier\n is applied to the \\`max-age\\` or \\`s-maxage\\` values.\n\n By default, this is \\`60\\`, so for example a response that\n is cacheable for 5 minutes will allow a stale response\n while revalidating for up to 5 hours.\n\n If the server *does* provide a \\`stale-while-revalidate\\`\n value, then that is always used.\n\n Set to 0 to prevent any \\`stale-while-revalidate\\` behavior\n unless explicitly allowed by the server's \\`cache-control\\`\n header.\n `,\n },\n })\n\n .opt({\n identity: {\n short: 'i',\n validate: (v: unknown) =>\n typeof v === 'string' && /^[a-z0-9]*$/.test(v),\n hint: 'name',\n default: '',\n description: `Provide a string to define an identity for storing auth\n information when logging into registries.\n\n Authentication tokens will be stored in the XDG data\n directory, in \\`vlt/auth/$\\{identity}/keychain.json\\`.\n\n If no identity is provided, then the default \\`''\\` will\n be used, storing the file at \\`vlt/auth/keychain.json\\`.\n\n May only contain lowercase alphanumeric characters.\n `,\n },\n })\n\n .optList({\n workspace: {\n hint: 'ws',\n short: 'w',\n description: `Set to limit the spaces being worked on when working on\n workspaces.\n\n Can be paths or glob patterns matching paths.\n\n Specifying workspaces by package.json name is not\n supported.`,\n },\n 'workspace-group': {\n short: 'g',\n description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'user | project',\n description: `Specify whether to operate on user-level or project-level\n configuration files when running \\`vlt config\\` commands.`,\n validOptions: ['user', 'project'] as const,\n default: 'project',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard GUI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n Similar to pnpm's publishConfig.directory feature.\n The directory must exist and nothing will be copied to it.`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../../src/config/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,C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,WAAW,EAAE,2BAA2B;KACzC;CACF,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,EAAE,CAAA;IAChC,OAAO,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,CAAoB,EAAE,EAAE;QAClD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,oBAAoB;QACpB,IAAI,CAAC,GAAG;YAAE,MAAM,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC,EAAE,CAAA;QAC3C,OAAO,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { XDG } from '@vltpkg/xdg'\nimport { jack } from 'jackspeak'\n\nexport const defaultView = process.stdout.isTTY ? 'human' : 'json'\n\nexport const defaultEditor = () =>\n process.env.EDITOR ||\n process.env.VISUAL ||\n (process.platform === 'win32' ?\n `${process.env.SYSTEMROOT}\\\\notepad.exe`\n : 'vi')\n\nconst canonicalCommands = {\n cache: 'cache',\n ci: 'ci',\n config: 'config',\n exec: 'exec',\n 'exec-local': 'exec-local',\n gui: 'gui',\n help: 'help',\n init: 'init',\n install: 'install',\n login: 'login',\n logout: 'logout',\n list: 'list',\n ls: 'ls',\n pack: 'pack',\n pkg: 'pkg',\n publish: 'publish',\n query: 'query',\n 'run-exec': 'run-exec',\n run: 'run',\n token: 'token',\n uninstall: 'uninstall',\n 'exec-cache': 'exec-cache',\n version: 'version',\n whoami: 'whoami',\n} as const\n\nconst aliases = {\n i: 'install',\n add: 'install',\n rm: 'uninstall',\n u: 'uninstall',\n r: 'run',\n 'run-script': 'run',\n rx: 'run-exec',\n x: 'exec',\n xl: 'exec-local',\n h: 'help',\n '?': 'help',\n conf: 'config',\n ls: 'list',\n xc: 'exec-cache',\n} as const\n\n/**\n * Command aliases mapped to their canonical names\n */\nexport const commands = {\n ...canonicalCommands,\n ...aliases,\n} as const\n\n/**\n * Canonical command names mapped to an array of its aliases\n */\nexport const commandAliases = Object.entries(aliases).reduce(\n (acc, [alias, canonical]) => {\n const commandAliases = acc.get(canonical)\n if (commandAliases) {\n commandAliases.push(alias)\n } else {\n acc.set(canonical, [alias])\n }\n return acc\n },\n new Map<string, string[]>(),\n)\n\nexport type Commands = typeof commands\n\nexport const getCommand = (\n s?: string,\n): Commands[keyof Commands] | undefined =>\n s && s in commands ? commands[s as keyof Commands] : undefined\n\nconst xdg = new XDG('vlt')\nconst cacheDir = xdg.cache()\n\n/**\n * Fields that are parsed as a set of key=value pairs\n */\nexport const recordFields = [\n 'git-hosts',\n 'registries',\n 'git-host-archives',\n 'scope-registries',\n 'jsr-registries',\n] as const\n\nexport type RecordField = (typeof recordFields)[number]\n\nexport const isRecordField = (s: string): s is RecordField =>\n recordFields.includes(s as RecordField)\n\nconst stopParsingCommands: Commands[keyof Commands][] = [\n 'run',\n 'run-exec',\n 'exec-local',\n 'exec',\n]\n\nlet stopParsing: boolean | undefined = undefined\n\nconst j = jack({\n envPrefix: 'VLT',\n allowPositionals: true,\n usage: `vlt [<options>] [<cmd> [<args> ...]]`,\n stopAtPositionalTest: arg => {\n if (stopParsing) return true\n const a = arg as keyof Commands\n // we stop parsing AFTER the thing, so you can do\n // vlt run --vlt --configs scriptName --args --for --script\n // or\n // vlt exec --vlt --configs command --args --for --command\n if (stopParsingCommands.includes(commands[a])) {\n stopParsing = true\n }\n return false\n },\n})\n .heading('vlt')\n .description(\n `More documentation available at <https://docs.vlt.sh>`,\n )\n .heading('Subcommands')\n\nj.description(Object.keys(canonicalCommands).join(', '), {\n pre: true,\n}).description(\n 'Run `vlt <cmd> --help` for more information about a specific command',\n)\n\nexport const definition = j\n /**\n * Definition of all configuration values used by vlt.\n */\n .heading('Configuration')\n .description(\n `If a \\`vlt.json\\` file is present in the root of the current project,\n then that will be used as a source of configuration information.\n\n Next, the \\`vlt.json\\` file in the XDG specified config directory\n will be checked, and loaded for any fields not set in the local project.\n\n Object type values will be merged together. Set a field to \\`null\\` in\n the JSON configuration to explicitly remove it.\n\n Command-specific fields may be set in a nested \\`command\\` object that\n overrides any options defined at the top level.\n `,\n )\n\n .flag({\n color: {\n short: 'c',\n description: 'Use colors (Default for TTY)',\n },\n 'no-color': {\n short: 'C',\n description: 'Do not use colors (Default for non-TTY)',\n },\n })\n\n .opt({\n registry: {\n hint: 'url',\n default: 'https://registry.npmjs.org/',\n description: `Sets the registry for fetching packages, when no registry\n is explicitly set on a specifier.\n\n For example, \\`express@latest\\` will be resolved by looking\n up the metadata from this registry.\n\n Note that alias specifiers starting with \\`npm:\\` will\n still map to \\`https://registry.npmjs.org/\\` if this is\n changed, unless the a new mapping is created via the\n \\`--registries\\` option.\n `,\n },\n })\n\n .optList({\n registries: {\n hint: 'name=url',\n description: `Specify named registry hosts by their prefix. To set the\n default registry used for non-namespaced specifiers,\n use the \\`--registry\\` option.\n\n Prefixes can be used as a package alias. For example:\n\n \\`\\`\\`\n vlt --registries loc=http://reg.local install foo@loc:foo@1.x\n \\`\\`\\`\n\n By default, the public npm registry is registered to the\n \\`npm:\\` prefix. It is not recommended to change this\n mapping in most cases.\n `,\n },\n\n 'scope-registries': {\n hint: '@scope=url',\n description: `Map package name scopes to registry URLs.\n\n For example,\n \\`--scope-registries @acme=https://registry.acme/\\`\n would tell vlt to fetch any packages named\n \\`@acme/...\\` from the \\`https://registry.acme/\\`\n registry.\n\n Note: this way of specifying registries is more ambiguous,\n compared with using the \\`--registries\\` field and explicit\n prefixes, because instead of failing when the configuration\n is absent, it will instead attempt to fetch from the\n default registry.\n\n By comparison, using\n \\`--registries acme=https://registry.acme/\\` and then\n specifying dependencies such as \\`\"foo\": \"acme:foo@1.x\"\\`\n means that regardless of the name, the package will be\n fetched from the explicitly named registry, or fail if\n no registry is defined with that name.\n\n However, custom registry aliases are not supported by other\n package managers.`,\n },\n\n 'jsr-registries': {\n hint: 'name=url',\n description: `Map alias names to JSR.io registry urls.\n\n For example,\n \\`--jsr-registries acme=https://jsr.acme.io/\\` would\n tell vlt to fetch any packages with the \\`acme:\\` registry\n prefix from the \\`https://jsr.acme.io/\\` registry, using\n the \"npm Compatibility\" translation. So for example,\n the package \\`acme:@foo/bar\\` would fetch the\n \\`@jsr/foo__bar\\` package from the \\`jsr.acme.io\\`\n registry.\n\n By default the \\`jsr\\` alias is always mapped to\n \\`https://npm.jsr.io/\\`, so existing \\`jsr:\\` packages will\n be fetched from the public \\`jsr\\` registry appropriately.\n `,\n },\n\n 'git-hosts': {\n hint: `name=template`,\n short: 'G',\n description: `Map a shorthand name to a git remote URL template.\n\n The \\`template\\` may contain placeholders, which will be\n swapped with the relevant values.\n\n \\`$1\\`, \\`$2\\`, etc. are replaced with the appropriate\n n-th path portion. For example, \\`github:user/project\\`\n would replace the \\`$1\\` in the template with \\`user\\`,\n and \\`$2\\` with \\`project\\`.`,\n },\n\n 'git-host-archives': {\n hint: `name=template`,\n short: 'A',\n description: `Similar to the \\`--git-host <name>=<template>\\` option,\n this option can define a template string that will be\n expanded to provide the URL to download a pre-built\n tarball of the git repository.\n\n In addition to the n-th path portion expansions performed\n by \\`--git-host\\`, this field will also expand the\n string \\`$committish\\` in the template, replacing it with\n the resolved git committish value to be fetched.`,\n },\n })\n\n .opt({\n cache: {\n hint: 'path',\n description: `\n Location of the vlt on-disk cache. Defaults to the platform-specific\n directory recommended by the XDG specification.\n `,\n default: cacheDir,\n },\n tag: {\n description: `Default \\`dist-tag\\` to install or publish`,\n default: 'latest',\n },\n before: {\n hint: 'date',\n description: `Do not install any packages published after this date`,\n },\n os: {\n description: `The operating system to use as the selector when choosing\n packages based on their \\`os\\` value.`,\n default: process.platform,\n },\n arch: {\n description: `CPU architecture to use as the selector when choosing\n packages based on their \\`cpu\\` value.`,\n default: process.arch,\n },\n 'node-version': {\n hint: 'version',\n description: `Node version to use when choosing packages based on\n their \\`engines.node\\` value.`,\n default: process.version,\n },\n })\n\n .flag({\n 'git-shallow': {\n description: `Set to force \\`--depth=1\\` on all git clone actions.\n When set explicitly to false with --no-git-shallow,\n then \\`--depth=1\\` will not be used.\n\n When not set explicitly, \\`--depth=1\\` will be used for\n git hosts known to support this behavior.`,\n },\n })\n .num({\n 'fetch-retries': {\n hint: 'n',\n description: `Number of retries to perform when encountering network\n errors or likely-transient errors from git hosts.`,\n default: 3,\n },\n 'fetch-retry-factor': {\n hint: 'n',\n description: `The exponential backoff factor to use when retrying\n requests due to network issues.`,\n default: 2,\n },\n 'fetch-retry-mintimeout': {\n hint: 'n',\n description: `Number of milliseconds before starting first retry`,\n default: 0,\n },\n 'fetch-retry-maxtimeout': {\n hint: 'n',\n description: `Maximum number of milliseconds between two retries`,\n default: 30_000,\n },\n 'stale-while-revalidate-factor': {\n hint: 'n',\n default: 60,\n description: `If the server does not serve a \\`stale-while-revalidate\\`\n value in the \\`cache-control\\` header, then this multiplier\n is applied to the \\`max-age\\` or \\`s-maxage\\` values.\n\n By default, this is \\`60\\`, so for example a response that\n is cacheable for 5 minutes will allow a stale response\n while revalidating for up to 5 hours.\n\n If the server *does* provide a \\`stale-while-revalidate\\`\n value, then that is always used.\n\n Set to 0 to prevent any \\`stale-while-revalidate\\` behavior\n unless explicitly allowed by the server's \\`cache-control\\`\n header.\n `,\n },\n })\n\n .opt({\n identity: {\n short: 'i',\n validate: (v: unknown) =>\n typeof v === 'string' && /^[a-z0-9]*$/.test(v),\n hint: 'name',\n default: '',\n description: `Provide a string to define an identity for storing auth\n information when logging into registries.\n\n Authentication tokens will be stored in the XDG data\n directory, in \\`vlt/auth/$\\{identity}/keychain.json\\`.\n\n If no identity is provided, then the default \\`''\\` will\n be used, storing the file at \\`vlt/auth/keychain.json\\`.\n\n May only contain lowercase alphanumeric characters.\n `,\n },\n })\n\n .optList({\n workspace: {\n hint: 'ws',\n short: 'w',\n description: `Set to limit the spaces being worked on when working on\n workspaces.\n\n Can be paths or glob patterns matching paths.\n\n Specifying workspaces by package.json name is not\n supported.`,\n },\n 'workspace-group': {\n short: 'g',\n description: `Specify named workspace group names to load and operate on\n when doing recursive operations on workspaces.`,\n },\n })\n\n .opt({\n scope: {\n short: 's',\n description:\n 'Set to filter the scope of an operation using a DSS Query.',\n },\n target: {\n short: 't',\n description:\n 'Set to select packages using a DSS Query selector.',\n },\n })\n\n .flag({\n recursive: {\n short: 'r',\n description: `Run an operation across multiple workspaces.\n\n No effect when used in non-monorepo projects.\n\n Implied by setting --workspace or --workspace-group. If\n not set, then the action is run on the project root.`,\n },\n\n bail: {\n short: 'b',\n description: `When running scripts across multiple workspaces, stop\n on the first failure.`,\n default: true,\n },\n\n 'no-bail': {\n short: 'B',\n description: `When running scripts across multiple workspaces, continue\n on failure, running the script for all workspaces.`,\n },\n })\n\n .opt({\n config: {\n hint: 'user | project',\n description: `Specify whether to operate on user-level or project-level\n configuration files when running \\`vlt config\\` commands.`,\n validOptions: ['user', 'project'] as const,\n default: 'project',\n },\n\n editor: {\n hint: 'program',\n description: `The blocking editor to use for \\`vlt config edit\\` and\n any other cases where a file should be opened for\n editing.\n\n Defaults to the \\`EDITOR\\` or \\`VISUAL\\` env if set, or\n \\`notepad.exe\\` on Windows, or \\`vi\\` elsewhere.`,\n default: defaultEditor(),\n },\n\n 'script-shell': {\n hint: 'program',\n description: `The shell to use when executing \\`package.json#scripts\\`.\n\n For \\`vlt exec\\` and \\`vlt exec-local\\`, this is never set,\n meaning that command arguments are run exactly as provided.\n\n For \\`vlt run\\` (and other things that run lifecycle\n scripts in \\`package.json#scripts\\`), the entire command\n with all arguments is provided as a single string, meaning\n that some value must be provided for shell interpretation,\n and so for these contexts, the \\`script-shell\\` value will\n default to \\`/bin/sh\\` on POSIX systems or \\`cmd.exe\\` on\n Windows.\n `,\n },\n\n 'fallback-command': {\n hint: 'command',\n description: `The command to run when the first argument doesn't\n match any known commands.\n\n For pnpm-style behavior, set this to 'run-exec'. e.g:\n \\`\\`\\`\n vlt config set fallback-command=run-exec\n \\`\\`\\``,\n default: 'help',\n validOptions: Object.keys(canonicalCommands),\n },\n })\n\n .opt({\n package: {\n hint: 'p',\n description: `When running \\`vlt exec\\`, this allows you to explicitly\n set the package to search for bins. If not provided, then\n vlt will interpret the first argument as the package, and\n attempt to run the default executable.`,\n },\n })\n\n .opt({\n view: {\n hint: 'output',\n default: defaultView,\n description: `Configures the output format for commands.\n\n Defaults to \\`human\\` if stdout is a TTY, or \\`json\\`\n if it is not.\n\n - human: Maximally ergonomic output reporting for human\n consumption.\n - json: Parseable JSON output for machines.\n - inspect: Output results with \\`util.inspect\\`.\n - gui: Start a local web server and opens a browser to\n explore the results. (Only relevant for certain\n commands.)\n - mermaid: Output mermaid diagramming syntax. (Only\n relevant for certain commands.)\n - silent: Suppress all output to stdout.\n\n If the requested view format is not supported for the\n current command, or if no option is provided, then it\n will fall back to the default.\n `,\n validOptions: [\n 'human',\n 'json',\n 'mermaid',\n 'gui',\n 'inspect',\n 'silent',\n ] as const,\n },\n })\n\n .optList({\n 'dashboard-root': {\n hint: 'path',\n description: `The root directory to use for the dashboard GUI.\n If not set, the user home directory is used.`,\n },\n })\n\n .flag({\n 'save-dev': {\n short: 'D',\n description: `Save installed packages to a package.json file as\n devDependencies`,\n },\n 'save-optional': {\n short: 'O',\n description: `Save installed packages to a package.json file as\n optionalDependencies`,\n },\n 'save-peer': {\n description: `Save installed packages to a package.json file as\n peerDependencies`,\n },\n 'save-prod': {\n short: 'P',\n description: `Save installed packages into dependencies specifically.\n This is useful if a package already exists in\n devDependencies or optionalDependencies, but you want to\n move it to be a non-optional production dependency.`,\n },\n })\n\n .opt({\n 'expect-results': {\n hint: 'value',\n validate: (v: unknown) =>\n typeof v === 'string' && /^([<>]=?)?[0-9]+$/.test(v),\n description: `When running \\`vlt query\\`, this option allows you to\n set a expected number of resulting items.\n\n Accepted values are numbers and strings.\n\n Strings starting with \\`>\\`, \\`<\\`, \\`>=\\` or \\`<=\\`\n followed by a number can be used to check if the result\n is greater than or less than a specific number.`,\n },\n })\n\n .flag({\n 'dry-run': {\n description: 'Run command without making any changes',\n },\n 'expect-lockfile': {\n description:\n 'Fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.',\n },\n 'frozen-lockfile': {\n description:\n 'Fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications.',\n },\n })\n .opt({\n access: {\n description: 'Set the access level of the package',\n validOptions: ['public', 'restricted'] as const,\n default: 'public',\n },\n })\n .opt({\n otp: {\n description: `Provide an OTP to use when publishing a package.`,\n },\n 'publish-directory': {\n hint: 'path',\n description: `Directory to use for pack and publish operations instead of the current directory.\n Similar to pnpm's publishConfig.directory feature.\n The directory must exist and nothing will be copied to it.`,\n },\n })\n\n .flag({\n yes: {\n short: 'y',\n description: `Automatically accept any confirmation prompts`,\n },\n version: {\n short: 'v',\n description: 'Print the version',\n },\n help: {\n short: 'h',\n description: 'Print helpful information',\n },\n })\n\nexport const getSortedCliOptions = () => {\n const defs = definition.toJSON()\n return getSortedKeys().map((k: keyof typeof defs) => {\n const def = defs[k]\n /* c8 ignore next */\n if (!def) throw error('invalid key found', { found: k })\n if (def.type === 'boolean') return `--${k}`\n return `--${k}=<${def.hint ?? k}>`\n })\n}\n\nexport const getSortedKeys = () =>\n Object.keys(definition.toJSON()).sort((a, b) => a.localeCompare(b))\n"]}
|
|
@@ -17,6 +17,7 @@ export declare const views: {
|
|
|
17
17
|
readonly human: (result: ExecResult) => void;
|
|
18
18
|
readonly json: (result: ExecResult) => ExecResult | undefined;
|
|
19
19
|
};
|
|
20
|
+
type ViewValues = 'human' | 'json' | 'inspect' | 'silent';
|
|
20
21
|
export declare class ExecCommand<B extends RunnerBG, F extends RunnerFG> {
|
|
21
22
|
bg: B;
|
|
22
23
|
fg: F;
|
|
@@ -27,7 +28,8 @@ export declare class ExecCommand<B extends RunnerBG, F extends RunnerFG> {
|
|
|
27
28
|
spaces?: number;
|
|
28
29
|
conf: LoadedConfig;
|
|
29
30
|
projectRoot: string;
|
|
30
|
-
view:
|
|
31
|
+
view: ViewValues;
|
|
32
|
+
validViewValues: Map<string, ViewValues>;
|
|
31
33
|
constructor(conf: LoadedConfig, bg: B, fg: F);
|
|
32
34
|
hasMonorepo(): this is this & {
|
|
33
35
|
monorepo: Monorepo;
|
|
@@ -48,4 +50,5 @@ export declare class ExecCommand<B extends RunnerBG, F extends RunnerFG> {
|
|
|
48
50
|
monorepo: Monorepo;
|
|
49
51
|
}): MultiScriptSet;
|
|
50
52
|
}
|
|
53
|
+
export {};
|
|
51
54
|
//# sourceMappingURL=exec-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-command.d.ts","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACV,IAAI,EACJ,MAAM,EACN,WAAW,EACX,GAAG,EACH,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACV,MAAM,aAAa,CAAA;AAIpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAIrD,MAAM,MAAM,QAAQ,GAAG,OAAO,IAAI,GAAG,OAAO,GAAG,GAAG,OAAO,OAAO,CAAA;AAChE,MAAM,MAAM,QA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,OAAO,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAIpC,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;IA8FhC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS;IA0B5C,gBAAgB,IAAI,MAAM;IAU1B,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,KAAK,IAAI,aAAa,GAAG,SAAS;IAoBlC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,EAAE,EAAE,SAAS,GAAG,aAAa;IAclE,YAAY,IAAI,SAAS;IAKzB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,GAAG,cAAc;CAKjE"}
|
package/dist/esm/exec-command.js
CHANGED
|
@@ -58,14 +58,17 @@ export class ExecCommand {
|
|
|
58
58
|
conf;
|
|
59
59
|
projectRoot;
|
|
60
60
|
view;
|
|
61
|
+
validViewValues = new Map([
|
|
62
|
+
['human', 'human'],
|
|
63
|
+
['json', 'json'],
|
|
64
|
+
['inspect', 'inspect'],
|
|
65
|
+
['silent', 'silent'],
|
|
66
|
+
]);
|
|
61
67
|
constructor(conf, bg, fg) {
|
|
62
68
|
this.conf = conf;
|
|
63
69
|
this.bg = bg;
|
|
64
70
|
this.fg = fg;
|
|
65
|
-
this.view =
|
|
66
|
-
conf.values.view === 'json' ? 'json'
|
|
67
|
-
: conf.values.view === 'inspect' ? 'inspect'
|
|
68
|
-
: 'human';
|
|
71
|
+
this.view = this.validViewValues.get(conf.values.view) ?? 'human';
|
|
69
72
|
const { projectRoot, positionals: [arg0, ...args], } = conf;
|
|
70
73
|
this.arg0 = arg0;
|
|
71
74
|
this.args = args;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-command.js","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AA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AW,EAAE,IAAI,CAAC,QAAQ,EAAE,WAAW;YACvC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;SAC9C,CAAA;IACH,CAAC;IAED,uDAAuD;IACvD,YAAY;QACV,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAA;IAC/D,CAAC;IACD,sDAAsD;IAEtD,WAAW;QACT,MAAM,KAAK,CACT,wDAAwD,CACzD,CAAA;IACH,CAAC;CACF","sourcesContent":["/**\n * impl for `vlt run`, `vlt run-exec`, `vlt exec-local`, `vlt exec`\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { isErrorWithCause } from '@vltpkg/types'\nimport type {\n exec,\n execFG,\n ExecOptions,\n run,\n runExec,\n runExecFG,\n RunExecOptions,\n runFG,\n RunFGResult,\n RunOptions,\n RunResult,\n} from '@vltpkg/run'\nimport { Query } from '@vltpkg/query'\nimport { actual } from '@vltpkg/graph'\nimport { isRunResult } from '@vltpkg/run'\nimport type { Workspace } from '@vltpkg/workspaces'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { ansiToAnsi } from 'ansi-to-pre'\nimport type { LoadedConfig } from './config/index.ts'\nimport { stderr, stdout, styleTextStdout } from './output.ts'\nimport type { Views } from './view.ts'\n\nexport type RunnerBG = typeof exec | typeof run | typeof runExec\nexport type RunnerFG = typeof execFG | typeof runExecFG | typeof runFG\nexport type RunnerOptions = ExecOptions & RunExecOptions & RunOptions\nexport type MultiRunResult = Record<string, RunResult>\nexport type ScriptSet = Record<string, string>\nexport type MultiScriptSet = Record<string, ScriptSet>\nexport type ExecResult =\n | RunFGResult\n | MultiRunResult\n | ScriptSet\n | MultiScriptSet\n\nconst isScriptSet = (o: unknown): o is ScriptSet => {\n if (!o || typeof o !== 'object') return false\n for (const v of Object.values(o)) {\n if (typeof v !== 'string') return false\n }\n return true\n}\n\nconst isMultiScriptSet = (\n o: ExecResult,\n): o is Record<string, ScriptSet> => {\n for (const v of Object.values(o)) {\n if (!isScriptSet(v)) return false\n }\n return true\n}\n\nconst isSingleSuccess = (\n o: RunResult,\n): o is RunResult & { status: 0; signal: null } =>\n o.signal === null && o.status === 0\n\nconst setExitCode = (result: RunResult) => {\n /* c8 ignore next */\n process.exitCode = process.exitCode || (result.status ?? 1)\n}\n\nexport const views = {\n // run results for single or multiple will be printed along the way.\n human: result => {\n if (isScriptSet(result)) stdout('Scripts available:', result)\n else if (isMultiScriptSet(result)) {\n stdout('Scripts available:')\n for (const [wsPath, scripts] of Object.entries(result)) {\n stdout(wsPath, scripts)\n }\n }\n },\n json: result =>\n isRunResult(result) && isSingleSuccess(result) ?\n undefined\n : result,\n} as const satisfies Views<ExecResult>\n\nexport class ExecCommand<B extends RunnerBG, F extends RunnerFG> {\n bg: B\n fg: F\n arg0?: string\n args: string[]\n monorepo?: Monorepo\n /** how many places are we doing things in? */\n spaces?: number\n conf: LoadedConfig\n projectRoot: string\n view: 'human' | 'json' | 'inspect'\n\n constructor(conf: LoadedConfig, bg: B, fg: F) {\n this.conf = conf\n this.bg = bg\n this.fg = fg\n this.view =\n conf.values.view === 'json' ? 'json'\n : conf.values.view === 'inspect' ? 'inspect'\n : 'human'\n const {\n projectRoot,\n positionals: [arg0, ...args],\n } = conf\n this.arg0 = arg0\n this.args = args\n this.projectRoot = projectRoot\n }\n\n hasMonorepo(): this is this & { monorepo: Monorepo } {\n return !!this.monorepo\n }\n\n hasArg0(): this is this & { arg0: string } {\n return !!this.arg0\n }\n\n async run(): Promise<ExecResult> {\n const { conf } = this\n\n const queryString = conf.get('scope')\n // scope takes precedence over workspaces or groups\n if (queryString) {\n const graph = actual.load({\n ...conf.options,\n mainManifest: conf.options.packageJson.read(this.projectRoot),\n monorepo: Monorepo.load(this.projectRoot),\n loadManifests: false,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive: undefined,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n const importerPaths = nodes\n .filter(n => n.importer)\n .map(n => n.location)\n .filter(v => v !== undefined)\n this.monorepo =\n importerPaths.length ?\n Monorepo.load(this.projectRoot, {\n load: {\n paths: importerPaths,\n },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 0\n } else {\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n this.monorepo =\n paths?.length || groups?.length || recursive ?\n Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 1\n }\n\n if (this.spaces === 1) {\n const arg = this.fgArg()\n if (!arg) return this.noArgsSingle()\n const result = await this.fg(arg)\n if (isRunResult(result)) {\n setExitCode(result)\n }\n return result\n }\n\n if (!this.hasMonorepo() || this.spaces === 0) {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.monorepo?.load().paths() ?? [])],\n })\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false\n const resultMap = await this.monorepo.run(async ws => {\n const result = await this.bg(this.bgArg(ws)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(ws, er.cause)\n }\n failed = true\n throw er\n },\n )\n if (!failed) this.printResult(ws, result)\n return result\n })\n\n const results: Record<string, RunResult> = {}\n for (const [ws, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[ws.path] = result\n }\n return results\n }\n\n printResult(ws: Workspace, result: RunResult) {\n // non-human results just get printed at the end\n if (this.view !== 'human') return\n\n if (result.status === 0 && result.signal === null) {\n stdout(ws.path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ws.path + ' failure',\n ),\n {\n status: result.status,\n signal: result.signal,\n },\n )\n /* c8 ignore start */\n if (result.stderr) stderr(ansiToAnsi(result.stderr))\n if (result.stdout) stdout(ansiToAnsi(result.stdout))\n /* c8 ignore stop */\n setExitCode(result)\n }\n }\n\n /* c8 ignore start - env specific */\n interactiveShell(): string {\n return (\n process.env.SHELL ??\n this.conf.get('script-shell') ??\n (process.platform === 'win32' ? 'cmd.exe' : '/bin/sh')\n )\n }\n /* c8 ignore stop */\n\n // overridden by 'vlt run' which returns undefined\n defaultArg0(): string | undefined {\n return this.interactiveShell()\n }\n\n fgArg(): RunnerOptions | undefined {\n const ws = this.monorepo?.values().next().value\n const cwd = ws?.fullpath ?? this.projectRoot\n const arg0 = this.arg0 ?? this.defaultArg0()\n\n // return undefined so noArgsSingle will be called instead\n if (typeof arg0 !== 'string') return\n\n return {\n cwd,\n /* c8 ignore next - already guarded */\n arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, ws: Workspace): RunnerOptions {\n return {\n cwd: ws.fullpath,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing: true,\n arg0: this.arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell': this.conf.get('script-shell'),\n }\n }\n\n /* c8 ignore start - not used, only here to override */\n noArgsSingle(): ScriptSet {\n throw error('Failed to determine interactive shell to spawn')\n }\n /* c8 ignore stop - not used, only here to override */\n\n noArgsMulti(this: this & { monorepo: Monorepo }): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"exec-command.js","sourceRoot":"","sources":["../../src/exec-command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAchD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE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;IAED,uDAAuD;IACvD,YAAY;QACV,MAAM,KAAK,CAAC,gDAAgD,CAAC,CAAA;IAC/D,CAAC;IACD,sDAAsD;IAEtD,WAAW;QACT,MAAM,KAAK,CACT,wDAAwD,CACzD,CAAA;IACH,CAAC;CACF","sourcesContent":["/**\n * impl for `vlt run`, `vlt run-exec`, `vlt exec-local`, `vlt exec`\n * @module\n */\n\nimport { error } from '@vltpkg/error-cause'\nimport { isErrorWithCause } from '@vltpkg/types'\nimport type {\n exec,\n execFG,\n ExecOptions,\n run,\n runExec,\n runExecFG,\n RunExecOptions,\n runFG,\n RunFGResult,\n RunOptions,\n RunResult,\n} from '@vltpkg/run'\nimport { Query } from '@vltpkg/query'\nimport { actual } from '@vltpkg/graph'\nimport { isRunResult } from '@vltpkg/run'\nimport type { Workspace } from '@vltpkg/workspaces'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { ansiToAnsi } from 'ansi-to-pre'\nimport type { LoadedConfig } from './config/index.ts'\nimport { stderr, stdout, styleTextStdout } from './output.ts'\nimport type { Views } from './view.ts'\n\nexport type RunnerBG = typeof exec | typeof run | typeof runExec\nexport type RunnerFG = typeof execFG | typeof runExecFG | typeof runFG\nexport type RunnerOptions = ExecOptions & RunExecOptions & RunOptions\nexport type MultiRunResult = Record<string, RunResult>\nexport type ScriptSet = Record<string, string>\nexport type MultiScriptSet = Record<string, ScriptSet>\nexport type ExecResult =\n | RunFGResult\n | MultiRunResult\n | ScriptSet\n | MultiScriptSet\n\nconst isScriptSet = (o: unknown): o is ScriptSet => {\n if (!o || typeof o !== 'object') return false\n for (const v of Object.values(o)) {\n if (typeof v !== 'string') return false\n }\n return true\n}\n\nconst isMultiScriptSet = (\n o: ExecResult,\n): o is Record<string, ScriptSet> => {\n for (const v of Object.values(o)) {\n if (!isScriptSet(v)) return false\n }\n return true\n}\n\nconst isSingleSuccess = (\n o: RunResult,\n): o is RunResult & { status: 0; signal: null } =>\n o.signal === null && o.status === 0\n\nconst setExitCode = (result: RunResult) => {\n /* c8 ignore next */\n process.exitCode = process.exitCode || (result.status ?? 1)\n}\n\nexport const views = {\n // run results for single or multiple will be printed along the way.\n human: result => {\n if (isScriptSet(result)) stdout('Scripts available:', result)\n else if (isMultiScriptSet(result)) {\n stdout('Scripts available:')\n for (const [wsPath, scripts] of Object.entries(result)) {\n stdout(wsPath, scripts)\n }\n }\n },\n json: result =>\n isRunResult(result) && isSingleSuccess(result) ?\n undefined\n : result,\n} as const satisfies Views<ExecResult>\n\ntype ViewValues = 'human' | 'json' | 'inspect' | 'silent'\n\nexport class ExecCommand<B extends RunnerBG, F extends RunnerFG> {\n bg: B\n fg: F\n arg0?: string\n args: string[]\n monorepo?: Monorepo\n /** how many places are we doing things in? */\n spaces?: number\n conf: LoadedConfig\n projectRoot: string\n view: ViewValues\n validViewValues = new Map<string, ViewValues>([\n ['human', 'human'],\n ['json', 'json'],\n ['inspect', 'inspect'],\n ['silent', 'silent'],\n ])\n\n constructor(conf: LoadedConfig, bg: B, fg: F) {\n this.conf = conf\n this.bg = bg\n this.fg = fg\n this.view = this.validViewValues.get(conf.values.view) ?? 'human'\n const {\n projectRoot,\n positionals: [arg0, ...args],\n } = conf\n this.arg0 = arg0\n this.args = args\n this.projectRoot = projectRoot\n }\n\n hasMonorepo(): this is this & { monorepo: Monorepo } {\n return !!this.monorepo\n }\n\n hasArg0(): this is this & { arg0: string } {\n return !!this.arg0\n }\n\n async run(): Promise<ExecResult> {\n const { conf } = this\n\n const queryString = conf.get('scope')\n // scope takes precedence over workspaces or groups\n if (queryString) {\n const graph = actual.load({\n ...conf.options,\n mainManifest: conf.options.packageJson.read(this.projectRoot),\n monorepo: Monorepo.load(this.projectRoot),\n loadManifests: false,\n })\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive: undefined,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n const importerPaths = nodes\n .filter(n => n.importer)\n .map(n => n.location)\n .filter(v => v !== undefined)\n this.monorepo =\n importerPaths.length ?\n Monorepo.load(this.projectRoot, {\n load: {\n paths: importerPaths,\n },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 0\n } else {\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n this.monorepo =\n paths?.length || groups?.length || recursive ?\n Monorepo.load(this.projectRoot, {\n load: { paths, groups },\n })\n : undefined\n this.spaces = this.monorepo?.size ?? 1\n }\n\n if (this.spaces === 1) {\n const arg = this.fgArg()\n if (!arg) return this.noArgsSingle()\n const result = await this.fg(arg)\n if (isRunResult(result)) {\n setExitCode(result)\n }\n return result\n }\n\n if (!this.hasMonorepo() || this.spaces === 0) {\n throw error('no matching workspaces found', {\n /* c8 ignore next - already guarded */\n validOptions: [...(this.monorepo?.load().paths() ?? [])],\n })\n }\n\n if (!this.hasArg0()) {\n return this.noArgsMulti()\n }\n\n // run across workspaces\n let failed = false\n const resultMap = await this.monorepo.run(async ws => {\n const result = await this.bg(this.bgArg(ws)).catch(\n (er: unknown) => {\n if (isErrorWithCause(er) && isRunResult(er.cause)) {\n this.printResult(ws, er.cause)\n }\n failed = true\n throw er\n },\n )\n if (!failed) this.printResult(ws, result)\n return result\n })\n\n const results: Record<string, RunResult> = {}\n for (const [ws, result] of resultMap) {\n if (result.status === 0 && result.signal === null) {\n result.stdout = ''\n result.stderr = ''\n }\n results[ws.path] = result\n }\n return results\n }\n\n printResult(ws: Workspace, result: RunResult) {\n // non-human results just get printed at the end\n if (this.view !== 'human') return\n\n if (result.status === 0 && result.signal === null) {\n stdout(ws.path, 'ok')\n } else {\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ws.path + ' failure',\n ),\n {\n status: result.status,\n signal: result.signal,\n },\n )\n /* c8 ignore start */\n if (result.stderr) stderr(ansiToAnsi(result.stderr))\n if (result.stdout) stdout(ansiToAnsi(result.stdout))\n /* c8 ignore stop */\n setExitCode(result)\n }\n }\n\n /* c8 ignore start - env specific */\n interactiveShell(): string {\n return (\n process.env.SHELL ??\n this.conf.get('script-shell') ??\n (process.platform === 'win32' ? 'cmd.exe' : '/bin/sh')\n )\n }\n /* c8 ignore stop */\n\n // overridden by 'vlt run' which returns undefined\n defaultArg0(): string | undefined {\n return this.interactiveShell()\n }\n\n fgArg(): RunnerOptions | undefined {\n const ws = this.monorepo?.values().next().value\n const cwd = ws?.fullpath ?? this.projectRoot\n const arg0 = this.arg0 ?? this.defaultArg0()\n\n // return undefined so noArgsSingle will be called instead\n if (typeof arg0 !== 'string') return\n\n return {\n cwd,\n /* c8 ignore next - already guarded */\n arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell':\n this.arg0 ? this.conf.get('script-shell') : false,\n }\n }\n\n bgArg(this: this & { arg0: string }, ws: Workspace): RunnerOptions {\n return {\n cwd: ws.fullpath,\n acceptFail: !this.conf.get('bail'),\n ignoreMissing: true,\n arg0: this.arg0,\n args: this.args,\n projectRoot: this.projectRoot,\n packageJson: this.monorepo?.packageJson,\n 'script-shell': this.conf.get('script-shell'),\n }\n }\n\n /* c8 ignore start - not used, only here to override */\n noArgsSingle(): ScriptSet {\n throw error('Failed to determine interactive shell to spawn')\n }\n /* c8 ignore stop - not used, only here to override */\n\n noArgsMulti(this: this & { monorepo: Monorepo }): MultiScriptSet {\n throw error(\n 'Cannot spawn interactive shells in multiple workspaces',\n )\n }\n}\n"]}
|
package/dist/esm/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,SAAS,IAAI,aAAa,EAC3B,MAAM,WAAW,CAAA;AAGlB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,OAAO,KAAK,EAAE,IAAI,EAAe,KAAK,EAAE,MAAM,WAAW,CAAA;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CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GACjC,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,CAAA;AAsC5B;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAU,CAAC,cACvB,OAAO,CAAC,CAAC,CAAC,QAChB,YAAY,cACP;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,kBAoD7B,CAAA"}
|
package/dist/esm/output.js
CHANGED
|
@@ -26,9 +26,10 @@ const identity = (x) => x;
|
|
|
26
26
|
export const getView = (conf, views) => {
|
|
27
27
|
const viewName = conf.values.view;
|
|
28
28
|
const viewFn = viewName === 'inspect' ? identity
|
|
29
|
-
:
|
|
30
|
-
:
|
|
31
|
-
:
|
|
29
|
+
: viewName === 'silent' ? () => undefined
|
|
30
|
+
: typeof views === 'function' ? views
|
|
31
|
+
: views && typeof views === 'object' ? views[viewName]
|
|
32
|
+
: identity;
|
|
32
33
|
// if the user specified a view that doesn't exist, then set it back to the
|
|
33
34
|
// default, and try again. This will fall back to identity if it's also
|
|
34
35
|
// missing. We also always treat 'json' as a valid view that falls back to
|
|
@@ -36,7 +37,8 @@ export const getView = (conf, views) => {
|
|
|
36
37
|
// when the default view is `human`.
|
|
37
38
|
if (!viewFn &&
|
|
38
39
|
conf.values.view !== defaultView &&
|
|
39
|
-
conf.values.view !== 'json'
|
|
40
|
+
conf.values.view !== 'json' &&
|
|
41
|
+
conf.values.view !== 'silent') {
|
|
40
42
|
conf.values.view = defaultView;
|
|
41
43
|
process.env.VLT_VIEW = defaultView;
|
|
42
44
|
return getView(conf, views);
|
|
@@ -92,7 +94,7 @@ export const outputCommand = async (cliCommand, conf, { start } = { start: Date.
|
|
|
92
94
|
{ colors: stdoutColor }, views, { start });
|
|
93
95
|
try {
|
|
94
96
|
const output = await onDone(await command(conf));
|
|
95
|
-
if (output !== undefined) {
|
|
97
|
+
if (output !== undefined && conf.values.view !== 'silent') {
|
|
96
98
|
stdout(conf.values.view === 'json' ?
|
|
97
99
|
JSON.stringify(output, null, 2)
|
|
98
100
|
: formatWithOptions({
|
package/dist/esm/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/output.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,SAAS,IAAI,aAAa,GAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,aAAa,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC5C,MAAM,GAAG,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;IAC9D,IAAI,GAAG,KAAK,KAAK;QAAE,OAAO,KAAK,CAAA;IAC/B,oBAAoB;IACpB,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,CAAA;AACtB,CAAC,CAAA;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AAClE,sCAAsC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AAOpE,qBAAqB;AACrB,MAAM,SAAS,GAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACtC,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAA;AAChD,oBAAoB;AAEpB,wEAAwE;AACxE,qB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I,EAAE,CAAC,CAAC;gBACjC,CAAC,CAAC,iBAAiB,CACf;oBACE,GAAG,aAAa;oBAChB,MAAM,EAAE,WAAW;iBACpB,EACD,MAAM,CACP,CACJ,CAAA;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,CAAC,GAAG,CAAC,CAAA;QACd,OAAO,CAAC,QAAQ,KAAK,CAAC,CAAA;QAEtB,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE;YAC3B,GAAG,aAAa;YAChB,MAAM,EAAE,WAAW;SACpB,CAAC,CAAA;QAEF,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IAChC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { WriteStream } from 'node:tty'\nimport {\n formatWithOptions,\n styleText as utilStyleText,\n} from 'node:util'\nimport { createSupportsColor } from 'supports-color'\nimport { defaultView } from './config/definition.ts'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { Command } from './index.ts'\nimport { printErr, formatOptions } from './print-err.ts'\nimport type { View, ViewOptions, Views } from './view.ts'\nimport { isViewClass } from './view.ts'\n\nconst supportsColor = (stream: WriteStream) => {\n const res = createSupportsColor(stream, { sniffFlags: false })\n if (res === false) return false\n /* c8 ignore next */\n return res.level > 0\n}\n\n// eslint-disable-next-line no-console\nexport const stdout = (...args: unknown[]) => console.log(...args)\n// eslint-disable-next-line no-console\nexport const stderr = (...args: unknown[]) => console.error(...args)\n\ntype StyleTextFn = (\n format: Parameters<typeof utilStyleText>[0],\n s: string,\n) => string\n\n/* c8 ignore start */\nconst styleText: StyleTextFn = (f, s) =>\n utilStyleText(f, s, { validateStream: false })\n/* c8 ignore stop */\n\n// TODO: stop exporting mutable variables once exec output is refactored\n/* c8 ignore start */\nexport let styleTextStdout: StyleTextFn = (_, s) => s\nexport let styleTextStderr: StyleTextFn = (_, s) => s\n/* c8 ignore stop */\n\nconst identity = <T>(x: T): T => x\n\nexport const getView = <T>(\n conf: LoadedConfig,\n views?: Views<T>,\n): View<T> => {\n const viewName = conf.values.view\n\n const viewFn =\n viewName === 'inspect' ? identity\n : viewName === 'silent' ? () => undefined\n : typeof views === 'function' ? views\n : views && typeof views === 'object' ? views[viewName]\n : identity\n\n // if the user specified a view that doesn't exist, then set it back to the\n // default, and try again. This will fall back to identity if it's also\n // missing. We also always treat 'json' as a valid view that falls back to\n // identity. This allows the explicit use of `--view=json` to work even\n // when the default view is `human`.\n if (\n !viewFn &&\n conf.values.view !== defaultView &&\n conf.values.view !== 'json' &&\n conf.values.view !== 'silent'\n ) {\n conf.values.view = defaultView\n process.env.VLT_VIEW = defaultView\n return getView(conf, views)\n }\n\n return viewFn ?? identity\n}\n\nexport type OnDone<T> =\n | ((result: T) => Promise<unknown>)\n | ((result: T) => unknown)\n\n/**\n * If the view is a View class, then instantiate and start it.\n * If it's a view function, then just define the onDone method.\n */\nconst startView = <T>(\n conf: LoadedConfig,\n opts: ViewOptions,\n views?: Views<T>,\n { start }: { start: number } = { start: Date.now() },\n): {\n onDone: OnDone<T>\n onError?: (err: unknown) => void\n} => {\n const View = getView<T>(conf, views)\n\n if (isViewClass(View)) {\n const view = new View(opts, conf)\n view.start()\n return {\n onDone(r) {\n return view.done(r, { time: Date.now() - start })\n },\n onError(err) {\n view.error(err)\n },\n }\n }\n\n return {\n async onDone(r) {\n if (r === undefined) return\n return View(r, opts, conf)\n },\n }\n}\n\n/**\n * Main export. Run the command appropriately, displaying output using\n * the user-requested view, or the default if the user requested a view\n * that is not defined for this command.\n */\nexport const outputCommand = async <T>(\n cliCommand: Command<T>,\n conf: LoadedConfig,\n { start }: { start: number } = { start: Date.now() },\n) => {\n const { usage, views, command } = cliCommand\n\n if (conf.values.help) {\n return stdout(usage().usage())\n }\n\n const stdoutColor =\n conf.values.color ?? supportsColor(process.stdout)\n const stderrColor =\n conf.values.color ?? supportsColor(process.stderr)\n\n /* c8 ignore start */\n if (stdoutColor) styleTextStdout = styleText\n if (stderrColor) styleTextStderr = styleText\n /* c8 ignore stop */\n\n const { onDone, onError } = startView(\n conf,\n // assume views will always output to stdout so use color support from there\n { colors: stdoutColor },\n views,\n { start },\n )\n\n try {\n const output = await onDone(await command(conf))\n if (output !== undefined && conf.values.view !== 'silent') {\n stdout(\n conf.values.view === 'json' ?\n JSON.stringify(output, null, 2)\n : formatWithOptions(\n {\n ...formatOptions,\n colors: stdoutColor,\n },\n output,\n ),\n )\n }\n } catch (err) {\n onError?.(err)\n process.exitCode ||= 1\n\n printErr(err, usage, stderr, {\n ...formatOptions,\n colors: stderrColor,\n })\n\n process.exit(process.exitCode)\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NormalizedManifest } from '@vltpkg/types';
|
|
2
2
|
import type { LoadedConfig } from './config/index.ts';
|
|
3
3
|
export type PackTarballResult = {
|
|
4
4
|
name: string;
|
|
@@ -13,10 +13,10 @@ export type PackTarballResult = {
|
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Create a tarball from a package directory
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {NormalizedManifest} manifest - The manifest of the package to pack
|
|
17
17
|
* @param {string} dir - The directory containing the package to pack
|
|
18
18
|
* @param {LoadedConfig} [config] - The loaded configuration (for workspace/catalog resolution)
|
|
19
19
|
* @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)
|
|
20
20
|
*/
|
|
21
|
-
export declare const packTarball: (manifest:
|
|
21
|
+
export declare const packTarball: (manifest: NormalizedManifest, dir: string, config: LoadedConfig) => Promise<PackTarballResult>;
|
|
22
22
|
//# sourceMappingURL=pack-tarball.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack-tarball.d.ts","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pack-tarball.d.ts","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAQvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAuHD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,kBAAkB,OACvB,MAAM,UACH,YAAY,KACnB,OAAO,CAAC,iBAAiB,CAsN3B,CAAA"}
|
package/dist/esm/pack-tarball.js
CHANGED
|
@@ -8,9 +8,9 @@ import { Spec } from '@vltpkg/spec';
|
|
|
8
8
|
import { join } from 'node:path';
|
|
9
9
|
/**
|
|
10
10
|
* Replace workspace: and catalog: specs with actual versions
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {NormalizedManifest} manifest_ - The manifest to process
|
|
12
12
|
* @param {LoadedConfig} config - The loaded configuration containing project root, monorepo, and catalog data
|
|
13
|
-
* @returns {
|
|
13
|
+
* @returns {NormalizedManifest} The manifest with replaced specs
|
|
14
14
|
*/
|
|
15
15
|
const replaceWorkspaceAndCatalogSpecs = (manifest_, config) => {
|
|
16
16
|
// Create a deep copy of the manifest to avoid modifying the original
|
|
@@ -82,7 +82,7 @@ const replaceWorkspaceAndCatalogSpecs = (manifest_, config) => {
|
|
|
82
82
|
};
|
|
83
83
|
/**
|
|
84
84
|
* Create a tarball from a package directory
|
|
85
|
-
* @param {
|
|
85
|
+
* @param {NormalizedManifest} manifest - The manifest of the package to pack
|
|
86
86
|
* @param {string} dir - The directory containing the package to pack
|
|
87
87
|
* @param {LoadedConfig} [config] - The loaded configuration (for workspace/catalog resolution)
|
|
88
88
|
* @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack-tarball.js","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAchC;;;;;GAKG;AACH,MAAM,+BAA+B,GAAG,CACtC,SAAmB,EACnB,MAAoB,EACV,EAAE;IACZ,qEAAqE;IACrE,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;IAE3C,sDAAsD;IACtD,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,CAAA;IAEhE,2BAA2B;IAC3B,MAAM,QAAQ,GAAG;QACf,cAAc;QACd,iBAAiB;QACjB,sBAAsB;QACtB,kBAAkB;KACV,CAAA;IAEV,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC9B,oBAAoB;QACpB,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,K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,SAAS;YACT,MAAM;SACP,CAAA;IACH,CAAC;YAAS,CAAC;QACT,0DAA0D;QAC1D,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACrD,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { Manifest } from '@vltpkg/types'\nimport { create as tarCreate, list as tarList } from 'tar'\nimport { minimatch } from 'minimatch'\nimport { error } from '@vltpkg/error-cause'\nimport * as ssri from 'ssri'\nimport assert from 'node:assert'\nimport { existsSync, statSync } from 'node:fs'\nimport { Spec } from '@vltpkg/spec'\nimport type { LoadedConfig } from './config/index.ts'\nimport { join } from 'node:path'\n\nexport type PackTarballResult = {\n name: string\n version: string\n filename: string\n tarballName: string\n tarballData: Buffer\n unpackedSize: number\n files: string[]\n integrity?: string\n shasum?: string\n}\n\n/**\n * Replace workspace: and catalog: specs with actual versions\n * @param {Manifest} manifest_ - The manifest to process\n * @param {LoadedConfig} config - The loaded configuration containing project root, monorepo, and catalog data\n * @returns {Manifest} The manifest with replaced specs\n */\nconst replaceWorkspaceAndCatalogSpecs = (\n manifest_: Manifest,\n config: LoadedConfig,\n): Manifest => {\n // Create a deep copy of the manifest to avoid modifying the original\n const manifest = structuredClone(manifest_)\n\n // Get workspace and catalog configuration from config\n const { monorepo, catalog = {}, catalogs = {} } = config.options\n\n // Process dependency types\n const depTypes = [\n 'dependencies',\n 'devDependencies',\n 'optionalDependencies',\n 'peerDependencies',\n ] as const\n\n for (const depType of depTypes) {\n const deps = manifest[depType]\n /* c8 ignore next */\n if (!deps || typeof deps !== 'object') continue\n\n const depsObj = deps as Record<string, unknown>\n for (const [depName, depSpec] of Object.entries(depsObj)) {\n /* c8 ignore next */\n if (typeof depSpec !== 'string') continue\n\n const spec = Spec.parse(`${depName}@${depSpec}`, {\n catalog,\n catalogs,\n })\n\n switch (spec.type) {\n case 'workspace': {\n assert(\n monorepo,\n error(`No workspace configuration found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspaceName = spec.workspace\n assert(\n workspaceName,\n error(`No workspace name found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspace = monorepo.get(workspaceName)\n assert(\n workspace,\n error(`Workspace '${workspaceName}' not found`, {\n found: workspaceName,\n validOptions: Array.from(monorepo.keys()),\n }),\n )\n\n const actualVersion = workspace.manifest.version\n assert(\n actualVersion,\n error(\n `No version found for workspace '${workspaceName}'`,\n {\n found: workspaceName,\n wanted: 'package version',\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n\n case 'catalog': {\n const catalogName = spec.catalog || ''\n const targetCatalog =\n catalogName ? catalogs[catalogName] : catalog\n assert(\n targetCatalog,\n error(`Catalog '${catalogName}' not found`, {\n found: catalogName,\n validOptions: Object.keys(catalogs),\n }),\n )\n\n const actualVersion = targetCatalog[depName]\n assert(\n actualVersion,\n error(\n `Package '${depName}' not found in catalog '${catalogName || 'default'}'`,\n {\n found: depName,\n validOptions: Object.keys(targetCatalog),\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n }\n }\n }\n\n return manifest\n}\n\n/**\n * Create a tarball from a package directory\n * @param {Manifest} manifest - The manifest of the package to pack\n * @param {string} dir - The directory containing the package to pack\n * @param {LoadedConfig} [config] - The loaded configuration (for workspace/catalog resolution)\n * @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)\n */\nexport const packTarball = async (\n manifest: Manifest,\n dir: string,\n config: LoadedConfig,\n): Promise<PackTarballResult> => {\n let packDir = dir\n\n // Check if publishDirectory is configured\n const publishDirectory = config.get('publish-directory')\n if (publishDirectory) {\n // Validate that the publish directory exists and is a directory\n assert(\n existsSync(publishDirectory),\n error(`Publish directory does not exist: ${publishDirectory}`, {\n found: publishDirectory,\n }),\n )\n assert(\n statSync(publishDirectory).isDirectory(),\n error(\n `Publish directory is not a directory: ${publishDirectory}`,\n {\n found: publishDirectory,\n wanted: 'directory',\n },\n ),\n )\n if (existsSync(join(publishDirectory, 'package.json'))) {\n manifest = config.options.packageJson.read(publishDirectory)\n }\n packDir = publishDirectory\n }\n\n assert(\n manifest.name && manifest.version,\n error('Package must have a name and version'),\n )\n\n const processedManifest = replaceWorkspaceAndCatalogSpecs(\n manifest,\n config,\n )\n\n const filename = `${manifest.name.replace('@', '').replace('/', '-')}-${manifest.version}.tgz`\n const tarballName = `${manifest.name}-${manifest.version}.tgz`\n\n try {\n config.options.packageJson.write(packDir, processedManifest)\n\n const tarballData = await tarCreate(\n {\n cwd: packDir,\n gzip: true,\n portable: true,\n prefix: 'package/',\n filter: (path: string) => {\n // Normalize path - remove leading './'\n const normalizedPath = path.replace(/^\\.\\//, '')\n\n // Always include root directory\n if (path === '.' || normalizedPath === '') {\n return true\n }\n\n // Always exclude certain files/directories\n const alwaysExcludePatterns = [\n /^\\.?\\/?\\.git(\\/|$)/,\n /^\\.?\\/?node_modules(\\/|$)/,\n /^\\.?\\/?\\.nyc_output(\\/|$)/,\n /^\\.?\\/?coverage(\\/|$)/,\n /^\\.?\\/?\\.DS_Store$/,\n /^\\.?\\/?\\.npmrc$/,\n /^\\.?\\/?package-lock\\.json$/,\n /^\\.?\\/?yarn\\.lock$/,\n /^\\.?\\/?pnpm-lock\\.yaml$/,\n /^\\.?\\/?bun\\.lockb$/,\n /^\\.?\\/?bun\\.lock$/,\n /^\\.?\\/?vlt-lock\\.json$/,\n /~$/,\n /\\.swp$/,\n ]\n\n if (\n alwaysExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return false\n }\n\n // Always include certain files\n const alwaysIncludePatterns = [\n /^README(\\..*)?$/i,\n /^CHANGELOG(\\..*)?$/i,\n /^HISTORY(\\..*)?$/i,\n /^LICENSE(\\..*)?$/i,\n /^LICENCE(\\..*)?$/i,\n ]\n\n if (\n alwaysIncludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return true\n }\n\n // Always include package.json\n if (normalizedPath === 'package.json') {\n return true\n }\n\n // If files field is specified in package.json, use it for inclusion\n const manifestWithFiles = manifest as Manifest & {\n files?: string[]\n }\n if (\n manifestWithFiles.files &&\n Array.isArray(manifestWithFiles.files)\n ) {\n // Empty files array means exclude everything except always-included files\n if (manifestWithFiles.files.length === 0) {\n return false\n }\n return manifestWithFiles.files.some((pattern: string) => {\n if (pattern.endsWith('/')) {\n const dirName = pattern.slice(0, -1)\n const globPattern = pattern.replace(/\\/$/, '/**')\n const matchesDir = normalizedPath === dirName\n const matchesContents = minimatch(\n normalizedPath,\n globPattern,\n {\n dot: true,\n },\n )\n return matchesDir || matchesContents\n }\n\n // File pattern: check direct match and if this path is a directory that could contain the pattern\n const directMatch = minimatch(normalizedPath, pattern, {\n dot: true,\n })\n // Check if this path is a directory that could contain the pattern\n const isParentDir =\n pattern.includes('/') &&\n pattern.startsWith(normalizedPath + '/')\n return directMatch || isParentDir\n })\n }\n\n // Default behavior when no files field - exclude common development files\n const defaultExcludePatterns = [\n /^\\.?\\/?\\.vscode(\\/|$)/,\n /^\\.?\\/?\\.idea(\\/|$)/,\n /^\\.?\\/?\\.gitignore$/,\n /^\\.?\\/?\\.npmignore$/,\n /^\\.?\\/?\\.editorconfig$/,\n ]\n\n return !defaultExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n },\n },\n ['.'],\n ).concat()\n\n let unpackedSize = 0\n const files: string[] = []\n await new Promise<void>((resolve, reject) => {\n const stream = tarList({\n onentry: entry => {\n if (entry.type === 'File') {\n unpackedSize += entry.size\n // Remove the package/ prefix for cleaner file listing\n const cleanPath = entry.path.replace(/^[^/]+\\//, '')\n if (cleanPath) {\n // Skip empty paths\n files.push(cleanPath)\n }\n }\n },\n })\n stream\n .on('end', () => resolve())\n .on('error', reject)\n .write(tarballData)\n stream.end()\n })\n\n const integrityMap = ssri.fromData(tarballData, {\n algorithms: [...new Set(['sha1', 'sha512'])],\n })\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const integrity = integrityMap.sha512?.[0]?.toString()\n // @ts-expect-error -- types from DT are missing hexDigest\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n const shasum = integrityMap.sha1?.[0]?.hexDigest() as\n | string\n | undefined\n\n return {\n name: manifest.name,\n version: manifest.version,\n filename,\n tarballName,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n }\n } finally {\n // Restore the original package.json to the pack directory\n config.options.packageJson.write(packDir, manifest)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pack-tarball.js","sourceRoot":"","sources":["../../src/pack-tarball.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,KAAK,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAchC;;;;;GAKG;AACH,MAAM,+BAA+B,GAAG,CACtC,SAA6B,EAC7B,MAAoB,EACA,EAAE;IACtB,qEAAqE;IACrE,MAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;IAE3C,sDAAsD;IACtD,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC,OAAO,CAAA;IAEhE,2BAA2B;IAC3B,MAAM,QAAQ,GAAG;QACf,cAAc;QACd,iBAAiB;QACjB,sBAAsB;QACtB,kBAAkB;KACV,CAAA;IAEV,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,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AAC,OAAO;YACzB,QAAQ;YACR,WAAW;YACX,WAAW;YACX,YAAY;YACZ,KAAK;YACL,SAAS;YACT,MAAM;SACP,CAAA;IACH,CAAC;YAAS,CAAC;QACT,0DAA0D;QAC1D,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACrD,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { NormalizedManifest } from '@vltpkg/types'\nimport { create as tarCreate, list as tarList } from 'tar'\nimport { minimatch } from 'minimatch'\nimport { error } from '@vltpkg/error-cause'\nimport * as ssri from 'ssri'\nimport assert from 'node:assert'\nimport { existsSync, statSync } from 'node:fs'\nimport { Spec } from '@vltpkg/spec'\nimport type { LoadedConfig } from './config/index.ts'\nimport { join } from 'node:path'\n\nexport type PackTarballResult = {\n name: string\n version: string\n filename: string\n tarballName: string\n tarballData: Buffer\n unpackedSize: number\n files: string[]\n integrity?: string\n shasum?: string\n}\n\n/**\n * Replace workspace: and catalog: specs with actual versions\n * @param {NormalizedManifest} manifest_ - The manifest to process\n * @param {LoadedConfig} config - The loaded configuration containing project root, monorepo, and catalog data\n * @returns {NormalizedManifest} The manifest with replaced specs\n */\nconst replaceWorkspaceAndCatalogSpecs = (\n manifest_: NormalizedManifest,\n config: LoadedConfig,\n): NormalizedManifest => {\n // Create a deep copy of the manifest to avoid modifying the original\n const manifest = structuredClone(manifest_)\n\n // Get workspace and catalog configuration from config\n const { monorepo, catalog = {}, catalogs = {} } = config.options\n\n // Process dependency types\n const depTypes = [\n 'dependencies',\n 'devDependencies',\n 'optionalDependencies',\n 'peerDependencies',\n ] as const\n\n for (const depType of depTypes) {\n const deps = manifest[depType]\n /* c8 ignore next */\n if (!deps || typeof deps !== 'object') continue\n\n const depsObj = deps as Record<string, unknown>\n for (const [depName, depSpec] of Object.entries(depsObj)) {\n /* c8 ignore next */\n if (typeof depSpec !== 'string') continue\n\n const spec = Spec.parse(`${depName}@${depSpec}`, {\n catalog,\n catalogs,\n })\n\n switch (spec.type) {\n case 'workspace': {\n assert(\n monorepo,\n error(`No workspace configuration found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspaceName = spec.workspace\n assert(\n workspaceName,\n error(`No workspace name found for ${depName}`, {\n found: depName,\n }),\n )\n\n const workspace = monorepo.get(workspaceName)\n assert(\n workspace,\n error(`Workspace '${workspaceName}' not found`, {\n found: workspaceName,\n validOptions: Array.from(monorepo.keys()),\n }),\n )\n\n const actualVersion = workspace.manifest.version\n assert(\n actualVersion,\n error(\n `No version found for workspace '${workspaceName}'`,\n {\n found: workspaceName,\n wanted: 'package version',\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n\n case 'catalog': {\n const catalogName = spec.catalog || ''\n const targetCatalog =\n catalogName ? catalogs[catalogName] : catalog\n assert(\n targetCatalog,\n error(`Catalog '${catalogName}' not found`, {\n found: catalogName,\n validOptions: Object.keys(catalogs),\n }),\n )\n\n const actualVersion = targetCatalog[depName]\n assert(\n actualVersion,\n error(\n `Package '${depName}' not found in catalog '${catalogName || 'default'}'`,\n {\n found: depName,\n validOptions: Object.keys(targetCatalog),\n },\n ),\n )\n\n depsObj[depName] = actualVersion\n\n break\n }\n }\n }\n }\n\n return manifest\n}\n\n/**\n * Create a tarball from a package directory\n * @param {NormalizedManifest} manifest - The manifest of the package to pack\n * @param {string} dir - The directory containing the package to pack\n * @param {LoadedConfig} [config] - The loaded configuration (for workspace/catalog resolution)\n * @returns {Promise<PackTarballResult>} The manifest, filename, and tarball data (unless dry run)\n */\nexport const packTarball = async (\n manifest: NormalizedManifest,\n dir: string,\n config: LoadedConfig,\n): Promise<PackTarballResult> => {\n let packDir = dir\n\n // Check if publishDirectory is configured\n const publishDirectory = config.get('publish-directory')\n if (publishDirectory) {\n // Validate that the publish directory exists and is a directory\n assert(\n existsSync(publishDirectory),\n error(`Publish directory does not exist: ${publishDirectory}`, {\n found: publishDirectory,\n }),\n )\n assert(\n statSync(publishDirectory).isDirectory(),\n error(\n `Publish directory is not a directory: ${publishDirectory}`,\n {\n found: publishDirectory,\n wanted: 'directory',\n },\n ),\n )\n if (existsSync(join(publishDirectory, 'package.json'))) {\n manifest = config.options.packageJson.read(publishDirectory)\n }\n packDir = publishDirectory\n }\n\n assert(\n manifest.name && manifest.version,\n error('Package must have a name and version'),\n )\n\n const processedManifest = replaceWorkspaceAndCatalogSpecs(\n manifest,\n config,\n )\n\n const filename = `${manifest.name.replace('@', '').replace('/', '-')}-${manifest.version}.tgz`\n const tarballName = `${manifest.name}-${manifest.version}.tgz`\n\n try {\n config.options.packageJson.write(packDir, processedManifest)\n\n const tarballData = await tarCreate(\n {\n cwd: packDir,\n gzip: true,\n portable: true,\n prefix: 'package/',\n filter: (path: string) => {\n // Normalize path - remove leading './'\n const normalizedPath = path.replace(/^\\.\\//, '')\n\n // Always include root directory\n if (path === '.' || normalizedPath === '') {\n return true\n }\n\n // Always exclude certain files/directories\n const alwaysExcludePatterns = [\n /^\\.?\\/?\\.git(\\/|$)/,\n /^\\.?\\/?node_modules(\\/|$)/,\n /^\\.?\\/?\\.nyc_output(\\/|$)/,\n /^\\.?\\/?coverage(\\/|$)/,\n /^\\.?\\/?\\.DS_Store$/,\n /^\\.?\\/?\\.npmrc$/,\n /^\\.?\\/?package-lock\\.json$/,\n /^\\.?\\/?yarn\\.lock$/,\n /^\\.?\\/?pnpm-lock\\.yaml$/,\n /^\\.?\\/?bun\\.lockb$/,\n /^\\.?\\/?bun\\.lock$/,\n /^\\.?\\/?vlt-lock\\.json$/,\n /~$/,\n /\\.swp$/,\n ]\n\n if (\n alwaysExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return false\n }\n\n // Always include certain files\n const alwaysIncludePatterns = [\n /^README(\\..*)?$/i,\n /^CHANGELOG(\\..*)?$/i,\n /^HISTORY(\\..*)?$/i,\n /^LICENSE(\\..*)?$/i,\n /^LICENCE(\\..*)?$/i,\n ]\n\n if (\n alwaysIncludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n ) {\n return true\n }\n\n // Always include package.json\n if (normalizedPath === 'package.json') {\n return true\n }\n\n // If files field is specified in package.json, use it for inclusion\n const manifestWithFiles = manifest as NormalizedManifest & {\n files?: string[]\n }\n if (\n manifestWithFiles.files &&\n Array.isArray(manifestWithFiles.files)\n ) {\n // Empty files array means exclude everything except always-included files\n if (manifestWithFiles.files.length === 0) {\n return false\n }\n return manifestWithFiles.files.some((pattern: string) => {\n if (pattern.endsWith('/')) {\n const dirName = pattern.slice(0, -1)\n const globPattern = pattern.replace(/\\/$/, '/**')\n const matchesDir = normalizedPath === dirName\n const matchesContents = minimatch(\n normalizedPath,\n globPattern,\n {\n dot: true,\n },\n )\n return matchesDir || matchesContents\n }\n\n // File pattern: check direct match and if this path is a directory that could contain the pattern\n const directMatch = minimatch(normalizedPath, pattern, {\n dot: true,\n })\n // Check if this path is a directory that could contain the pattern\n const isParentDir =\n pattern.includes('/') &&\n pattern.startsWith(normalizedPath + '/')\n return directMatch || isParentDir\n })\n }\n\n // Default behavior when no files field - exclude common development files\n const defaultExcludePatterns = [\n /^\\.?\\/?\\.vscode(\\/|$)/,\n /^\\.?\\/?\\.idea(\\/|$)/,\n /^\\.?\\/?\\.gitignore$/,\n /^\\.?\\/?\\.npmignore$/,\n /^\\.?\\/?\\.editorconfig$/,\n ]\n\n return !defaultExcludePatterns.some(pattern =>\n pattern.test(normalizedPath),\n )\n },\n },\n ['.'],\n ).concat()\n\n let unpackedSize = 0\n const files: string[] = []\n await new Promise<void>((resolve, reject) => {\n const stream = tarList({\n onentry: entry => {\n if (entry.type === 'File') {\n unpackedSize += entry.size\n // Remove the package/ prefix for cleaner file listing\n const cleanPath = entry.path.replace(/^[^/]+\\//, '')\n if (cleanPath) {\n // Skip empty paths\n files.push(cleanPath)\n }\n }\n },\n })\n stream\n .on('end', () => resolve())\n .on('error', reject)\n .write(tarballData)\n stream.end()\n })\n\n const integrityMap = ssri.fromData(tarballData, {\n algorithms: [...new Set(['sha1', 'sha512'])],\n })\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n const integrity = integrityMap.sha512?.[0]?.toString()\n // @ts-expect-error -- types from DT are missing hexDigest\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n const shasum = integrityMap.sha1?.[0]?.hexDigest() as\n | string\n | undefined\n\n return {\n name: manifest.name,\n version: manifest.version,\n filename,\n tarballName,\n tarballData,\n unpackedSize,\n files,\n integrity,\n shasum,\n }\n } finally {\n // Restore the original package.json to the pack directory\n config.options.packageJson.write(packDir, manifest)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/cli-sdk",
|
|
3
3
|
"description": "The source for the vlt CLI",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-19",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -37,28 +37,29 @@
|
|
|
37
37
|
"ssri": "^12.0.0",
|
|
38
38
|
"supports-color": "^10.0.0",
|
|
39
39
|
"tar": "^7.4.3",
|
|
40
|
-
"@vltpkg/
|
|
41
|
-
"@vltpkg/
|
|
42
|
-
"@vltpkg/
|
|
43
|
-
"@vltpkg/
|
|
44
|
-
"@vltpkg/
|
|
45
|
-
"@vltpkg/
|
|
46
|
-
"@vltpkg/
|
|
47
|
-
"@vltpkg/
|
|
48
|
-
"@vltpkg/
|
|
49
|
-
"@vltpkg/
|
|
50
|
-
"@vltpkg/
|
|
51
|
-
"@vltpkg/
|
|
52
|
-
"@vltpkg/
|
|
53
|
-
"@vltpkg/
|
|
54
|
-
"@vltpkg/server": "0.0.0-
|
|
55
|
-
"@vltpkg/
|
|
56
|
-
"@vltpkg/spec": "0.0.0-
|
|
57
|
-
"@vltpkg/
|
|
58
|
-
"@vltpkg/vlx": "0.0.0-
|
|
59
|
-
"@vltpkg/
|
|
60
|
-
"@vltpkg/
|
|
61
|
-
"@vltpkg/workspaces": "0.0.0-
|
|
40
|
+
"@vltpkg/dot-prop": "0.0.0-19",
|
|
41
|
+
"@vltpkg/config": "0.0.0-19",
|
|
42
|
+
"@vltpkg/dep-id": "0.0.0-19",
|
|
43
|
+
"@vltpkg/git": "0.0.0-19",
|
|
44
|
+
"@vltpkg/error-cause": "0.0.0-19",
|
|
45
|
+
"@vltpkg/graph": "0.0.0-19",
|
|
46
|
+
"@vltpkg/init": "0.0.0-19",
|
|
47
|
+
"@vltpkg/output": "0.0.0-19",
|
|
48
|
+
"@vltpkg/package-info": "0.0.0-19",
|
|
49
|
+
"@vltpkg/package-json": "0.0.0-19",
|
|
50
|
+
"@vltpkg/query": "0.0.0-19",
|
|
51
|
+
"@vltpkg/registry-client": "0.0.0-19",
|
|
52
|
+
"@vltpkg/rollback-remove": "0.0.0-19",
|
|
53
|
+
"@vltpkg/run": "0.0.0-19",
|
|
54
|
+
"@vltpkg/server": "0.0.0-19",
|
|
55
|
+
"@vltpkg/security-archive": "0.0.0-19",
|
|
56
|
+
"@vltpkg/spec": "0.0.0-19",
|
|
57
|
+
"@vltpkg/types": "0.0.0-19",
|
|
58
|
+
"@vltpkg/vlx": "0.0.0-19",
|
|
59
|
+
"@vltpkg/url-open": "0.0.0-19",
|
|
60
|
+
"@vltpkg/vlt-json": "0.0.0-19",
|
|
61
|
+
"@vltpkg/workspaces": "0.0.0-19",
|
|
62
|
+
"@vltpkg/xdg": "0.0.0-19"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@eslint/js": "^9.28.0",
|