@vltpkg/cli-sdk 0.0.0-7 → 0.0.0-9
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/cache.d.ts +47 -0
- package/dist/esm/commands/cache.d.ts.map +1 -0
- package/dist/esm/commands/cache.js +211 -0
- package/dist/esm/commands/cache.js.map +1 -0
- package/dist/esm/commands/exec-local.d.ts +5 -0
- package/dist/esm/commands/exec-local.d.ts.map +1 -0
- package/dist/esm/commands/exec-local.js +22 -0
- package/dist/esm/commands/exec-local.js.map +1 -0
- package/dist/esm/commands/exec.d.ts +1 -2
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +6 -15
- package/dist/esm/commands/exec.js.map +1 -1
- package/dist/esm/commands/init.d.ts +2 -3
- package/dist/esm/commands/init.d.ts.map +1 -1
- package/dist/esm/commands/init.js.map +1 -1
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +2 -1
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +5 -2
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +2 -4
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pkg.d.ts +3 -3
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/query.d.ts +2 -1
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +39 -4
- package/dist/esm/commands/query.js.map +1 -1
- package/dist/esm/commands/uninstall.d.ts +5 -2
- package/dist/esm/commands/uninstall.d.ts.map +1 -1
- package/dist/esm/commands/uninstall.js.map +1 -1
- package/dist/esm/commands/whoami.d.ts +4 -2
- package/dist/esm/commands/whoami.d.ts.map +1 -1
- package/dist/esm/commands/whoami.js +1 -1
- package/dist/esm/commands/whoami.js.map +1 -1
- package/dist/esm/config/definition.d.ts +17 -2
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +41 -7
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/config/index.d.ts +1 -0
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +7 -0
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/config/usage.d.ts +3 -2
- package/dist/esm/config/usage.d.ts.map +1 -1
- package/dist/esm/config/usage.js.map +1 -1
- package/dist/esm/exec-command.js +2 -2
- package/dist/esm/exec-command.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/output.d.ts +2 -1
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +20 -19
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/parse-add-remove-args.d.ts +1 -1
- package/dist/esm/parse-add-remove-args.d.ts.map +1 -1
- package/dist/esm/parse-add-remove-args.js +1 -1
- package/dist/esm/parse-add-remove-args.js.map +1 -1
- package/dist/esm/print-err.d.ts +5 -1
- package/dist/esm/print-err.d.ts.map +1 -1
- package/dist/esm/print-err.js +68 -21
- package/dist/esm/print-err.js.map +1 -1
- package/dist/esm/view.d.ts +1 -1
- package/dist/esm/view.d.ts.map +1 -1
- package/dist/esm/view.js.map +1 -1
- package/package.json +23 -21
- package/dist/esm/commands/install-exec.d.ts +0 -4
- package/dist/esm/commands/install-exec.d.ts.map +0 -1
- package/dist/esm/commands/install-exec.js +0 -13
- package/dist/esm/commands/install-exec.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CacheEntry } from '@vltpkg/registry-client';
|
|
2
|
+
import type { LoadedConfig } from '../config/index.ts';
|
|
3
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
4
|
+
import type { ViewOptions, Views } from '../view.ts';
|
|
5
|
+
import { ViewClass } from '../view.ts';
|
|
6
|
+
export type CacheMap = Record<string, ReturnType<CacheEntry['toJSON']>>;
|
|
7
|
+
export type CacheSubcommands = keyof (typeof usageDef)['subcommands'];
|
|
8
|
+
export declare class CacheView extends ViewClass {
|
|
9
|
+
constructor(options: ViewOptions, conf: LoadedConfig);
|
|
10
|
+
stdout(...args: unknown[]): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const views: Views<void | CacheMap>;
|
|
13
|
+
declare const usageDef: {
|
|
14
|
+
readonly command: "cache";
|
|
15
|
+
readonly usage: "<command> [flags]";
|
|
16
|
+
readonly description: "Work with vlt cache folders";
|
|
17
|
+
readonly subcommands: {
|
|
18
|
+
readonly add: {
|
|
19
|
+
readonly usage: "<package-spec> [<package-spec>...]";
|
|
20
|
+
readonly description: "Resolve the referenced package identifiers and ensure they\n are cached.";
|
|
21
|
+
};
|
|
22
|
+
readonly ls: {
|
|
23
|
+
readonly usage: "[<key>...]";
|
|
24
|
+
readonly description: "Show cache entries. If no keys are provided, then a list of\n available keys will be printed. If one or more keys are\n provided, then details will be shown for the specified\n items.";
|
|
25
|
+
};
|
|
26
|
+
readonly clean: {
|
|
27
|
+
readonly usage: "[<key>...]";
|
|
28
|
+
readonly description: "Purge expired cache entries. If one or more keys are\n provided, then only those cache entries will be\n considered.";
|
|
29
|
+
};
|
|
30
|
+
readonly delete: {
|
|
31
|
+
readonly usage: "<key> [<key>...]";
|
|
32
|
+
readonly description: "Purge items explicitly, whether expired or not. If one or\n more keys are provided, then only those cache entries will\n be considered.";
|
|
33
|
+
};
|
|
34
|
+
readonly 'delete-before': {
|
|
35
|
+
readonly usage: "<date>";
|
|
36
|
+
readonly description: "Purge all cache items from before a given date. Date can be\n provided in any format that JavaScript can parse.";
|
|
37
|
+
};
|
|
38
|
+
readonly 'delete-all': {
|
|
39
|
+
readonly usage: "";
|
|
40
|
+
readonly description: "Delete the entire cache folder to make vlt slower.";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const usage: CommandUsage;
|
|
45
|
+
export declare const command: CommandFn<void | CacheMap>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/commands/cache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAC3B,MAAM,EACN,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CACjC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAA;AAGrE,qBAAa,SAAU,SAAQ,SAAS;gBAC1B,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY;IAIpD,MAAM,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE;CAG1B;AAED,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,IAAI,GAAG,QAAQ,CAExC,CAAA;AAED,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C6B,CAAA;AAE3C,eAAO,MAAM,KAAK,EAAE,YAA2C,CAAA;AAE/D,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,IAAI,GAAG,QAAQ,CA6B9C,CAAA"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { CacheEntry } from '@vltpkg/registry-client';
|
|
3
|
+
import { Spec } from '@vltpkg/spec';
|
|
4
|
+
import { mkdir, rm } from 'node:fs/promises';
|
|
5
|
+
import prettyBytes from 'pretty-bytes';
|
|
6
|
+
import { commandUsage } from "../config/usage.js";
|
|
7
|
+
import { stdout } from "../output.js";
|
|
8
|
+
import { ViewClass } from "../view.js";
|
|
9
|
+
let view;
|
|
10
|
+
export class CacheView extends ViewClass {
|
|
11
|
+
constructor(options, conf) {
|
|
12
|
+
super(options, conf);
|
|
13
|
+
view = this;
|
|
14
|
+
}
|
|
15
|
+
stdout(...args) {
|
|
16
|
+
stdout(...args);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const views = {
|
|
20
|
+
human: CacheView,
|
|
21
|
+
};
|
|
22
|
+
const usageDef = {
|
|
23
|
+
command: 'cache',
|
|
24
|
+
usage: '<command> [flags]',
|
|
25
|
+
description: 'Work with vlt cache folders',
|
|
26
|
+
subcommands: {
|
|
27
|
+
add: {
|
|
28
|
+
usage: '<package-spec> [<package-spec>...]',
|
|
29
|
+
description: `Resolve the referenced package identifiers and ensure they
|
|
30
|
+
are cached.`,
|
|
31
|
+
},
|
|
32
|
+
ls: {
|
|
33
|
+
usage: '[<key>...]',
|
|
34
|
+
description: `Show cache entries. If no keys are provided, then a list of
|
|
35
|
+
available keys will be printed. If one or more keys are
|
|
36
|
+
provided, then details will be shown for the specified
|
|
37
|
+
items.`,
|
|
38
|
+
},
|
|
39
|
+
clean: {
|
|
40
|
+
usage: '[<key>...]',
|
|
41
|
+
description: `Purge expired cache entries. If one or more keys are
|
|
42
|
+
provided, then only those cache entries will be
|
|
43
|
+
considered.`,
|
|
44
|
+
},
|
|
45
|
+
delete: {
|
|
46
|
+
usage: '<key> [<key>...]',
|
|
47
|
+
description: `Purge items explicitly, whether expired or not. If one or
|
|
48
|
+
more keys are provided, then only those cache entries will
|
|
49
|
+
be considered.`,
|
|
50
|
+
},
|
|
51
|
+
'delete-before': {
|
|
52
|
+
usage: '<date>',
|
|
53
|
+
description: `Purge all cache items from before a given date. Date can be
|
|
54
|
+
provided in any format that JavaScript can parse.`,
|
|
55
|
+
},
|
|
56
|
+
'delete-all': {
|
|
57
|
+
usage: '',
|
|
58
|
+
description: `Delete the entire cache folder to make vlt slower.`,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
export const usage = () => commandUsage(usageDef);
|
|
63
|
+
export const command = async (conf) => {
|
|
64
|
+
const [sub, ...args] = conf.positionals;
|
|
65
|
+
switch (sub) {
|
|
66
|
+
case 'ls':
|
|
67
|
+
return ls(conf, args, view);
|
|
68
|
+
case 'add':
|
|
69
|
+
return add(conf, args, view);
|
|
70
|
+
case 'clean':
|
|
71
|
+
return clean(conf, args, view);
|
|
72
|
+
case 'delete':
|
|
73
|
+
return deleteKeys(conf, args, view);
|
|
74
|
+
case 'delete-before':
|
|
75
|
+
return deleteBefore(conf, args, view);
|
|
76
|
+
case 'delete-all':
|
|
77
|
+
return deleteAll(conf, args, view);
|
|
78
|
+
default: {
|
|
79
|
+
throw error('Unrecognized cache command', {
|
|
80
|
+
code: 'EUSAGE',
|
|
81
|
+
found: sub,
|
|
82
|
+
validOptions: ['ls', 'add', 'clean'],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const ls = async (conf, keys, view) => keys.length ?
|
|
88
|
+
await fetchKeys(conf, keys, (entry, key) => {
|
|
89
|
+
view?.stdout(key.includes(' ') ? JSON.stringify(key) : key, entry);
|
|
90
|
+
return true;
|
|
91
|
+
}, view)
|
|
92
|
+
: await fetchAll(conf, (_, key) => {
|
|
93
|
+
view?.stdout(key.includes(' ') ? JSON.stringify(key) : key);
|
|
94
|
+
return true;
|
|
95
|
+
});
|
|
96
|
+
const fetchAll = async (conf, test) => {
|
|
97
|
+
const rc = conf.options.packageInfo.registryClient;
|
|
98
|
+
const { cache } = rc;
|
|
99
|
+
const map = {};
|
|
100
|
+
for await (const [key, val] of cache) {
|
|
101
|
+
const entry = CacheEntry.decode(val);
|
|
102
|
+
if (!test(entry, key, val))
|
|
103
|
+
continue;
|
|
104
|
+
map[key] = entry.toJSON();
|
|
105
|
+
}
|
|
106
|
+
return map;
|
|
107
|
+
};
|
|
108
|
+
const fetchKeys = async (conf, keys, test, view) => {
|
|
109
|
+
const rc = conf.options.packageInfo.registryClient;
|
|
110
|
+
const { cache } = rc;
|
|
111
|
+
const map = {};
|
|
112
|
+
const results = await Promise.all(keys.map(async (key) => {
|
|
113
|
+
return [key, await cache.fetch(key)];
|
|
114
|
+
}));
|
|
115
|
+
for (const [key, val] of results) {
|
|
116
|
+
if (!val) {
|
|
117
|
+
view?.stdout('Not found:', key);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const entry = CacheEntry.decode(val);
|
|
121
|
+
if (!test(entry, key, val))
|
|
122
|
+
continue;
|
|
123
|
+
map[key] = entry.toJSON();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return map;
|
|
127
|
+
};
|
|
128
|
+
const deleteEntries = async (conf, keys, test, view) => {
|
|
129
|
+
const rc = conf.options.packageInfo.registryClient;
|
|
130
|
+
const { cache } = rc;
|
|
131
|
+
let count = 0;
|
|
132
|
+
let size = 0;
|
|
133
|
+
const testAction = (entry, key, val) => {
|
|
134
|
+
if (!test(entry)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
count++;
|
|
138
|
+
const s = val.byteLength + key.length;
|
|
139
|
+
cache.delete(key, true, entry.integrity);
|
|
140
|
+
const k = key.includes(' ') ? JSON.stringify(key) : key;
|
|
141
|
+
view?.stdout('-', k, s);
|
|
142
|
+
size += s;
|
|
143
|
+
return true;
|
|
144
|
+
};
|
|
145
|
+
const map = await (keys.length ?
|
|
146
|
+
fetchKeys(conf, keys, testAction, view)
|
|
147
|
+
: fetchAll(conf, testAction));
|
|
148
|
+
const pb = prettyBytes(size, { binary: true });
|
|
149
|
+
const s = count === 1 ? '' : 's';
|
|
150
|
+
await cache.promise();
|
|
151
|
+
view?.stdout(`Removed ${count} item${s} totalling ${pb}`);
|
|
152
|
+
return map;
|
|
153
|
+
};
|
|
154
|
+
const clean = async (conf, keys, view) => deleteEntries(conf, keys, entry => !entry.valid, view);
|
|
155
|
+
const deleteBefore = async (conf, args, view) => {
|
|
156
|
+
if (!args.length) {
|
|
157
|
+
throw error('Must provide a date to delete before', {
|
|
158
|
+
code: 'EUSAGE',
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const now = new Date();
|
|
162
|
+
const before = new Date(args.join(' '));
|
|
163
|
+
if (before >= now) {
|
|
164
|
+
throw error('Cannot delete cache entries from the future', {
|
|
165
|
+
code: 'EUSAGE',
|
|
166
|
+
found: before,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return deleteEntries(conf, [], entry => !!entry.date && entry.date < before, view);
|
|
170
|
+
};
|
|
171
|
+
const deleteKeys = async (conf, keys, view) => {
|
|
172
|
+
if (!keys.length) {
|
|
173
|
+
throw error('Must provide cache keys to delete', {
|
|
174
|
+
code: 'EUSAGE',
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return deleteEntries(conf, keys, () => true, view);
|
|
178
|
+
};
|
|
179
|
+
const deleteAll = async (conf, _, view) => {
|
|
180
|
+
const { cache } = conf.options.packageInfo.registryClient;
|
|
181
|
+
await rm(cache.path(), { recursive: true, force: true });
|
|
182
|
+
await mkdir(cache.path(), { recursive: true });
|
|
183
|
+
view?.stdout('Deleted all cache entries.');
|
|
184
|
+
};
|
|
185
|
+
const add = async (conf, specs, view) => {
|
|
186
|
+
if (!specs.length) {
|
|
187
|
+
throw error('Must provide specs to add to the cache', {
|
|
188
|
+
code: 'EUSAGE',
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
const { packageInfo } = conf.options;
|
|
192
|
+
const promises = [];
|
|
193
|
+
for (const spec of specs) {
|
|
194
|
+
const p = packageInfo
|
|
195
|
+
.resolve(Spec.parseArgs(spec, conf.options), {
|
|
196
|
+
staleWhileRevalidate: false,
|
|
197
|
+
})
|
|
198
|
+
.then(async (r) => {
|
|
199
|
+
const { resolved, integrity } = r;
|
|
200
|
+
await packageInfo.registryClient.request(resolved, {
|
|
201
|
+
...conf.options,
|
|
202
|
+
integrity,
|
|
203
|
+
staleWhileRevalidate: false,
|
|
204
|
+
});
|
|
205
|
+
view?.stdout('+', spec, r.resolved);
|
|
206
|
+
});
|
|
207
|
+
promises.push(p);
|
|
208
|
+
}
|
|
209
|
+
await Promise.all(promises);
|
|
210
|
+
};
|
|
211
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/commands/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,WAAW,MAAM,cAAc,CAAA;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAStC,IAAI,IAAe,CAAA;AACnB,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,YAAY,OAAoB,EAAE,IAAkB;QAClD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpB,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAe;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAA2B;IAC3C,KAAK,EAAE,SAAS;CACjB,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,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C,oBAAoB,EAAE,KAAK;SAC5B,CAAC;aACD,IAAI,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;YACd,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAA;YACjC,MAAM,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACjD,GAAG,IAAI,CAAC,OAAO;gBACf,SAAS;gBACT,oBAAoB,EAAE,KAAK;aAC5B,CAAC,CAAA;YACF,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAA;QACrC,CAAC,CAAC,CAAA;QAEJ,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAClB,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { CacheEntry } from '@vltpkg/registry-client'\nimport { Spec } from '@vltpkg/spec'\nimport { mkdir, rm } from 'node:fs/promises'\nimport prettyBytes from 'pretty-bytes'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type CacheMap = Record<\n string,\n ReturnType<CacheEntry['toJSON']>\n>\n\nexport type CacheSubcommands = keyof (typeof usageDef)['subcommands']\n\nlet view: CacheView\nexport class CacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | CacheMap> = {\n human: CacheView,\n}\n\nconst usageDef = {\n command: 'cache',\n usage: '<command> [flags]',\n description: 'Work with vlt cache folders',\n\n subcommands: {\n add: {\n usage: '<package-spec> [<package-spec>...]',\n description: `Resolve the referenced package identifiers and ensure they\n are cached.`,\n },\n\n ls: {\n usage: '[<key>...]',\n description: `Show cache entries. If no keys are provided, then a list of\n available keys will be printed. If one or more keys are\n provided, then details will be shown for the specified\n items.`,\n },\n\n clean: {\n usage: '[<key>...]',\n description: `Purge expired cache entries. If one or more keys are\n provided, then only those cache entries will be\n considered.`,\n },\n\n delete: {\n usage: '<key> [<key>...]',\n description: `Purge items explicitly, whether expired or not. If one or\n more keys are provided, then only those cache entries will\n be considered.`,\n },\n\n 'delete-before': {\n usage: '<date>',\n description: `Purge all cache items from before a given date. Date can be\n provided in any format that JavaScript can parse.`,\n },\n\n 'delete-all': {\n usage: '',\n description: `Delete the entire cache folder to make vlt slower.`,\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<void | CacheMap> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'add':\n return add(conf, args, view)\n\n case 'clean':\n return clean(conf, args, view)\n\n case 'delete':\n return deleteKeys(conf, args, view)\n\n case 'delete-before':\n return deleteBefore(conf, args, view)\n\n case 'delete-all':\n return deleteAll(conf, args, view)\n\n default: {\n throw error('Unrecognized cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: ['ls', 'add', 'clean'],\n })\n }\n }\n}\n\nconst ls = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n): Promise<CacheMap> =>\n keys.length ?\n await fetchKeys(\n conf,\n keys,\n (entry: CacheEntry, key: string) => {\n view?.stdout(\n key.includes(' ') ? JSON.stringify(key) : key,\n entry,\n )\n return true\n },\n view,\n )\n : await fetchAll(conf, (_, key) => {\n view?.stdout(key.includes(' ') ? JSON.stringify(key) : key)\n return true\n })\n\nconst fetchAll = async (\n conf: LoadedConfig,\n test: (entry: CacheEntry, key: string, val: Buffer) => boolean,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n const map: CacheMap = {}\n for await (const [key, val] of cache) {\n const entry = CacheEntry.decode(val)\n if (!test(entry, key, val)) continue\n map[key] = entry.toJSON()\n }\n return map\n}\n\nconst fetchKeys = async (\n conf: LoadedConfig,\n keys: string[],\n test: (entry: CacheEntry, key: string, buf: Buffer) => boolean,\n view?: CacheView,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n const map: CacheMap = {}\n const results: [string, Buffer | undefined][] = await Promise.all(\n keys.map(async key => {\n return [key, await cache.fetch(key)]\n }),\n )\n for (const [key, val] of results) {\n if (!val) {\n view?.stdout('Not found:', key)\n } else {\n const entry = CacheEntry.decode(val)\n if (!test(entry, key, val)) continue\n map[key] = entry.toJSON()\n }\n }\n\n return map\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n test: (entry: CacheEntry) => boolean,\n view?: CacheView,\n) => {\n const rc = conf.options.packageInfo.registryClient\n const { cache } = rc\n\n let count = 0\n let size = 0\n const testAction = (\n entry: CacheEntry,\n key: string,\n val: Buffer,\n ) => {\n if (!test(entry)) {\n return false\n }\n count++\n const s = val.byteLength + key.length\n cache.delete(key, true, entry.integrity)\n const k = key.includes(' ') ? JSON.stringify(key) : key\n view?.stdout('-', k, s)\n size += s\n return true\n }\n\n const map = await (keys.length ?\n fetchKeys(conf, keys, testAction, view)\n : fetchAll(conf, testAction))\n\n const pb = prettyBytes(size, { binary: true })\n\n const s = count === 1 ? '' : 's'\n await cache.promise()\n view?.stdout(`Removed ${count} item${s} totalling ${pb}`)\n return map\n}\n\nconst clean = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n) => deleteEntries(conf, keys, entry => !entry.valid, view)\n\nconst deleteBefore = async (\n conf: LoadedConfig,\n args: string[],\n view?: CacheView,\n) => {\n if (!args.length) {\n throw error('Must provide a date to delete before', {\n code: 'EUSAGE',\n })\n }\n const now = new Date()\n const before = new Date(args.join(' '))\n if (before >= now) {\n throw error('Cannot delete cache entries from the future', {\n code: 'EUSAGE',\n found: before,\n })\n }\n return deleteEntries(\n conf,\n [],\n entry => !!entry.date && entry.date < before,\n view,\n )\n}\n\nconst deleteKeys = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n) => {\n if (!keys.length) {\n throw error('Must provide cache keys to delete', {\n code: 'EUSAGE',\n })\n }\n return deleteEntries(conf, keys, () => true, view)\n}\n\nconst deleteAll = async (\n conf: LoadedConfig,\n _: string[],\n view?: CacheView,\n) => {\n const { cache } = conf.options.packageInfo.registryClient\n await rm(cache.path(), { recursive: true, force: true })\n await mkdir(cache.path(), { recursive: true })\n view?.stdout('Deleted all cache entries.')\n}\n\nconst add = async (\n conf: LoadedConfig,\n specs: string[],\n view?: CacheView,\n) => {\n if (!specs.length) {\n throw error('Must provide specs to add to the cache', {\n code: 'EUSAGE',\n })\n }\n const { packageInfo } = conf.options\n const promises: Promise<void>[] = []\n\n for (const spec of specs) {\n const p = packageInfo\n .resolve(Spec.parseArgs(spec, conf.options), {\n staleWhileRevalidate: false,\n })\n .then(async r => {\n const { resolved, integrity } = r\n await packageInfo.registryClient.request(resolved, {\n ...conf.options,\n integrity,\n staleWhileRevalidate: false,\n })\n view?.stdout('+', spec, r.resolved)\n })\n\n promises.push(p)\n }\n\n await Promise.all(promises)\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-local.d.ts","sourceRoot":"","sources":["../../../src/commands/exec-local.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAehB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAEzC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { exec, execFG } from '@vltpkg/run';
|
|
2
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
import { ExecCommand } from "../exec-command.js";
|
|
4
|
+
export const usage = () => commandUsage({
|
|
5
|
+
command: 'exec-local',
|
|
6
|
+
usage: '[command]',
|
|
7
|
+
description: `Run an arbitrary command, with the local installed packages
|
|
8
|
+
first in the PATH. Ie, this will run your locally installed
|
|
9
|
+
package bins.
|
|
10
|
+
|
|
11
|
+
If no command is provided, then a shell is spawned in the
|
|
12
|
+
current working directory, with the locally installed package
|
|
13
|
+
bins first in the PATH.
|
|
14
|
+
|
|
15
|
+
Note that any vlt configs must be specified *before* the
|
|
16
|
+
command, as the remainder of the command line options are
|
|
17
|
+
provided to the exec process.`,
|
|
18
|
+
});
|
|
19
|
+
export const command = async (conf) => {
|
|
20
|
+
return await new ExecCommand(conf, exec, execFG).run();
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=exec-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-local.js","sourceRoot":"","sources":["../../../src/commands/exec-local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,WAAW;IAClB,WAAW,EAAE;;;;;;;;;;gDAU+B;CAC7C,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE;IACzD,OAAO,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { exec, execFG } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec-local',\n usage: '[command]',\n description: `Run an arbitrary command, with the local installed packages\n first in the PATH. Ie, this will run your locally installed\n package bins.\n\n If no command is provided, then a shell is spawned in the\n current working directory, with the locally installed package\n bins first in the PATH.\n\n Note that any vlt configs must be specified *before* the\n command, as the remainder of the command line options are\n provided to the exec process.`,\n })\n\nexport const command: CommandFn<ExecResult> = async conf => {\n return await new ExecCommand(conf, exec, execFG).run()\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ExecResult } from '../exec-command.ts';
|
|
2
1
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
2
|
export declare const usage: CommandUsage;
|
|
4
|
-
export declare const command: CommandFn<
|
|
3
|
+
export declare const command: CommandFn<string>;
|
|
5
4
|
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,MAAM,CAKrC,CAAA"}
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import { exec, execFG } from '@vltpkg/run';
|
|
2
1
|
import { commandUsage } from "../config/usage.js";
|
|
3
|
-
import { ExecCommand } from "../exec-command.js";
|
|
4
2
|
export const usage = () => commandUsage({
|
|
5
3
|
command: 'exec',
|
|
6
|
-
usage: '[command]',
|
|
7
|
-
description:
|
|
8
|
-
first in the PATH. Ie, this will run your locally installed
|
|
9
|
-
package bins.
|
|
10
|
-
|
|
11
|
-
If no command is provided, then a shell is spawned in the
|
|
12
|
-
current working directory, with the locally installed package
|
|
13
|
-
bins first in the PATH.
|
|
14
|
-
|
|
15
|
-
Note that any vlt configs must be specified *before* the
|
|
16
|
-
command, as the remainder of the command line options are
|
|
17
|
-
provided to the exec process.`,
|
|
4
|
+
usage: '[--package=<pkg>] [command...]',
|
|
5
|
+
description: 'Run a command defined by a package, installing it if necessary',
|
|
18
6
|
});
|
|
19
7
|
export const command = async (conf) => {
|
|
20
|
-
return
|
|
8
|
+
return [
|
|
9
|
+
'TODO: exec-local, but install if not present',
|
|
10
|
+
...conf.positionals,
|
|
11
|
+
].join('\n');
|
|
21
12
|
};
|
|
22
13
|
//# sourceMappingURL=exec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGjD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,gCAAgC;IACvC,WAAW,EACT,gEAAgE;CACnE,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAAsB,KAAK,EAAC,IAAI,EAAC,EAAE;IACrD,OAAO;QACL,8CAA8C;QAC9C,GAAG,IAAI,CAAC,WAAW;KACpB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec',\n usage: '[--package=<pkg>] [command...]',\n description:\n 'Run a command defined by a package, installing it if necessary',\n })\n\nexport const command: CommandFn<string> = async conf => {\n return [\n 'TODO: exec-local, but install if not present',\n ...conf.positionals,\n ].join('\\n')\n}\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
2
|
import type { InitFileResults } from '@vltpkg/init';
|
|
3
|
-
import type { ViewFn, Views } from '../view.ts';
|
|
4
3
|
export declare const usage: CommandUsage;
|
|
5
|
-
export declare const views:
|
|
6
|
-
human:
|
|
4
|
+
export declare const views: {
|
|
5
|
+
readonly human: (results: InitFileResults, _options: import("../view.ts").ViewOptions, _config: import("../config/index.ts").LoadedConfig) => string;
|
|
7
6
|
};
|
|
8
7
|
export declare const command: CommandFn<InitFileResults>;
|
|
9
8
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAGnD,eAAO,MAAM,KAAK,EAAE,YAKhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;CAeyB,CAAA;AAE3C,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,eAAe,CACX,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA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AE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA","sourcesContent":["import { 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'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'init',\n usage: '',\n description: `Create a new package.json file in the current directory.`,\n })\n\nexport const views = {\n human: (results, _options, _config) => {\n const output: string[] = []\n // TODO: colorize the JSON if config.options.color\n for (const [type, { path, data }] of Object.entries(results)) {\n output.push(`Wrote ${type} to ${path}:\n\n${JSON.stringify(data, null, 2)}\n`)\n }\n output.push(`Modify/add properties using \\`vlt pkg\\`. For example:\n\n vlt pkg set \"description=My new project\"`)\n return output.join('\\n')\n },\n} as const satisfies Views<InitFileResults>\n\nexport const command: CommandFn<InitFileResults> = async () =>\n await init({ cwd: process.cwd() })\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAiFzC,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIL,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAMjD,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
|
|
@@ -4,6 +4,7 @@ import Spinner from 'ink-spinner';
|
|
|
4
4
|
import { createElement as $, Fragment, useLayoutEffect, useState, } from 'react';
|
|
5
5
|
import { stdout } from "../../output.js";
|
|
6
6
|
import { ViewClass } from "../../view.js";
|
|
7
|
+
import { asError } from '@vltpkg/error-cause';
|
|
7
8
|
const GraphStep = ({ text, step }) => {
|
|
8
9
|
if (step.state === 'waiting') {
|
|
9
10
|
return $(Text, { color: 'gray' }, text);
|
|
@@ -60,7 +61,7 @@ export class InstallReporter extends ViewClass {
|
|
|
60
61
|
return undefined;
|
|
61
62
|
}
|
|
62
63
|
error(err) {
|
|
63
|
-
this.#instance?.unmount(err);
|
|
64
|
+
this.#instance?.unmount(asError(err));
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
//# sourceMappingURL=reporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,eAAe,EACf,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAEvC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EACL,aAAa,IAAI,CAAC,EAClB,QAAQ,EACR,eAAe,EACf,QAAQ,GACT,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,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AG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAC5D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5C,SAAS,GAAoB,IAAI,CAAA;IAEjC,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACjC,CAAC;IAED,IAAI,CAAC,OAAgB,EAAE,EAAE,IAAI,EAAoB;QAC/C,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAA;QACzB,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,CAAA;QAC3B,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,GAAY;QAChB,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACvC,CAAC;CACF","sourcesContent":["import { emitter } from '@vltpkg/output'\nimport type { Events } from '@vltpkg/output'\nimport { Box, render, Text } from 'ink'\nimport type { Instance } from 'ink'\nimport Spinner from 'ink-spinner'\nimport {\n createElement as $,\n Fragment,\n useLayoutEffect,\n useState,\n} from 'react'\nimport { stdout } from '../../output.ts'\nimport { ViewClass } from '../../view.ts'\nimport { asError } from '@vltpkg/error-cause'\n\ntype Step = {\n state: 'waiting' | 'in_progress' | 'completed'\n}\n\nconst GraphStep = ({ text, step }: { text: string; step: Step }) => {\n if (step.state === 'waiting') {\n return $(Text, { color: 'gray' }, text)\n }\n if (step.state === 'in_progress') {\n return $(\n Text,\n { color: 'yellow' },\n text,\n $(Spinner, { type: 'dots' }),\n )\n }\n return $(Text, { color: 'green' }, text, ' ✓')\n}\n\nconst App = () => {\n const [requests, setRequests] = useState(0)\n\n const [steps, setSteps] = useState<\n Record<Events['graphStep']['step'], Step>\n >({\n build: {\n state: 'waiting',\n },\n actual: {\n state: 'waiting',\n },\n reify: {\n state: 'waiting',\n },\n })\n\n useLayoutEffect(() => {\n const update = () => setRequests(p => p + 1)\n emitter.on('request', update)\n return () => emitter.off('request', update)\n }, [])\n\n useLayoutEffect(() => {\n const update = ({ step, state }: Events['graphStep']) => {\n setSteps(p => ({\n ...p,\n [step]: {\n ...p[step],\n state: state === 'start' ? 'in_progress' : 'completed',\n },\n }))\n }\n emitter.on('graphStep', update)\n return () => emitter.off('graphStep', update)\n }, [])\n\n return $(\n Fragment,\n null,\n $(\n Box,\n null,\n ...(['build', 'actual', 'reify'] as const).map(\n (step, idx, list) => {\n const separator = idx === list.length - 1 ? '' : ' > '\n return $(\n Text,\n { key: step },\n $(GraphStep, { text: step, step: steps[step] }),\n $(Text, { color: 'gray' }, separator),\n )\n },\n ),\n ),\n requests > 0 ? $(Text, null, `${requests} requests`) : null,\n )\n}\n\nexport class InstallReporter extends ViewClass {\n #instance: Instance | null = null\n\n start() {\n this.#instance = render($(App))\n }\n\n done(_result: unknown, { time }: { time: number }) {\n this.#instance?.unmount()\n stdout(`Done in ${time}ms`)\n return undefined\n }\n\n error(err: unknown) {\n this.#instance?.unmount(asError(err))\n }\n}\n"]}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Graph } from '@vltpkg/graph';
|
|
2
2
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
-
import
|
|
3
|
+
import { InstallReporter } from './install/reporter.ts';
|
|
4
4
|
export declare const usage: CommandUsage;
|
|
5
|
-
export declare const views:
|
|
5
|
+
export declare const views: {
|
|
6
|
+
readonly json: (g: Graph) => import("@vltpkg/graph").LockfileData;
|
|
7
|
+
readonly human: typeof InstallReporter;
|
|
8
|
+
};
|
|
6
9
|
export declare const command: CommandFn<Graph>;
|
|
7
10
|
//# sourceMappingURL=install.d.ts.map
|
|
@@ -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;
|
|
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,CAKpC,CAAA"}
|
|
@@ -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,
|
|
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,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,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IACtC,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC5C,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;IAClD,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 { graph } = await install(conf.options, add)\n return graph\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAkChB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAEnB,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,mBAAmB,EACnB,UAAU,EACV,aAAa,EACd,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAkChB,CAAA;AAEJ,MAAM,MAAM,UAAU,GAAG,eAAe,GACtC,kBAAkB,GAClB,wBAAwB,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpD,eAAO,MAAM,KAAK;;;;;CAUoB,CAAA;AAEtC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAmEzC,CAAA"}
|
|
@@ -13,7 +13,7 @@ export const usage = () => commandUsage({
|
|
|
13
13
|
'': {
|
|
14
14
|
description: 'List direct dependencies of the current project / workspace',
|
|
15
15
|
},
|
|
16
|
-
'*': {
|
|
16
|
+
'"*"': {
|
|
17
17
|
description: 'List all dependencies for the current project / workspace',
|
|
18
18
|
},
|
|
19
19
|
'foo bar baz': {
|
|
@@ -53,14 +53,12 @@ export const command = async (conf) => {
|
|
|
53
53
|
const queryString = conf.positionals
|
|
54
54
|
.map(k => (/^[@\w-]/.test(k) ? `#${k.replace(/\//, '\\/')}` : k))
|
|
55
55
|
.join(', ');
|
|
56
|
-
const
|
|
56
|
+
const securityArchive = Query.hasSecuritySelectors(queryString) ?
|
|
57
57
|
await SecurityArchive.start({
|
|
58
58
|
graph,
|
|
59
59
|
specOptions: conf.options,
|
|
60
60
|
})
|
|
61
61
|
: undefined;
|
|
62
|
-
/* c8 ignore next */
|
|
63
|
-
const securityArchive = archive?.ok ? archive : undefined;
|
|
64
62
|
const query = new Query({
|
|
65
63
|
graph,
|
|
66
64
|
specOptions: conf.options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,CAAC,EAAE,EAAE,+CAA+C,CAAC;IAC5D,WAAW,EAAE;;4CAE2B;IACxC,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,WAAW,EACT,6DAA6D;SAChE;QACD,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAMA,O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,CAAC,EAAE,CAAC,CAAA;YACzD,IAAI,CAAC,EAAE,CAAC;gBACN,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;gBAChB,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC,CAAA;gBAC1C,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAA;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,MAAM,0BAA0B,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7D,MAAM,kBAAkB,GACtB,CACE,eAAe,CAAC,MAAM;QACtB,eAAe,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAC9C,CAAC,CAAC;QACD,0BAA0B;QAC5B,CAAC,CAAC,kBAAkB,CAAA;IAEtB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,MAAM,CACzC,WAAW,IAAI,kBAAkB,CAClC,CAAA;IAED,OAAO;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,WAAW,EAAE,WAAW,IAAI,kBAAkB;QAC9C,kBAAkB,EAAE,CAAC,CAAC,WAAW;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport {\n actual,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n} from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'ls',\n usage: ['', '<query> --view=[human | json | mermaid | gui]'],\n description: `List installed dependencies matching the provided query.\n Defaults to listing direct dependencies of a project and\n any configured workspace.`,\n examples: {\n '': {\n description:\n 'List direct dependencies of the current project / workspace',\n },\n '\"*\"': {\n description:\n 'List all dependencies for the current project / workspace',\n },\n 'foo bar baz': {\n description: `List all dependencies named 'foo', 'bar', or 'baz'`,\n },\n [`'[name=\"@scoped/package\"] > *'`]: {\n description:\n 'Lists direct dependencies of a specific package',\n },\n [`'*.workspace > *.peer'`]: {\n description: 'List all peer dependencies of all workspaces',\n },\n },\n options: {\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\nexport type ListResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI(\n conf,\n '/explore?query=' + encodeURIComponent(queryString),\n )\n },\n} as const satisfies Views<ListResult>\n\nexport const command: CommandFn<ListResult> = async conf => {\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo,\n loadManifests: true,\n })\n\n const queryString = conf.positionals\n .map(k => (/^[@\\w-]/.test(k) ? `#${k.replace(/\\//, '\\\\/')}` : k))\n .join(', ')\n const securityArchive =\n Query.hasSecuritySelectors(queryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n const projectQueryString = ':project, :project > *'\n const selectImporters: string[] = []\n\n const importers = new Set<Node>()\n if (monorepo) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) {\n importers.add(w)\n selectImporters.push(`[name=\"${w.name}\"]`)\n selectImporters.push(`[name=\"${w.name}\"] > *`)\n }\n }\n }\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n\n const selectImportersQueryString = selectImporters.join(', ')\n const defaultQueryString =\n (\n selectImporters.length &&\n selectImporters.length < graph.importers.size\n ) ?\n selectImportersQueryString\n : projectQueryString\n\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n )\n\n return {\n importers,\n edges,\n nodes,\n queryString: queryString || defaultQueryString,\n highlightSelection: !!queryString,\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { LoadedConfig } from '../config/index.ts';
|
|
1
2
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
human: ViewFn;
|
|
3
|
+
export declare const views: {
|
|
4
|
+
readonly human: (results: unknown, options: import("../view.ts").ViewOptions, config: LoadedConfig) => unknown;
|
|
5
5
|
};
|
|
6
6
|
export declare const usage: CommandUsage;
|
|
7
7
|
export declare const command: CommandFn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/pkg.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM1D,eAAO,MAAM,KAAK;;CAaQ,CAAA;AAE1B,eAAO,MAAM,KAAK,EAAE,YAoChB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SA6BrB,CAAA"}
|