@vltpkg/cli-sdk 1.0.0-rc.8 → 1.0.1
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/commands/access.d.ts +23 -0
- package/dist/commands/access.js +251 -0
- package/dist/{esm/commands → commands}/bugs.d.ts +0 -1
- package/dist/{esm/commands → commands}/bugs.js +0 -1
- package/dist/{esm/commands → commands}/build.d.ts +1 -1
- package/dist/{esm/commands → commands}/build.js +1 -1
- package/dist/{esm/commands → commands}/cache.d.ts +1 -1
- package/dist/{esm/commands → commands}/cache.js +1 -1
- package/dist/{esm/commands → commands}/ci.d.ts +1 -1
- package/dist/{esm/commands → commands}/ci.js +12 -3
- package/dist/{esm/commands → commands}/config.d.ts +0 -1
- package/dist/{esm/commands → commands}/config.js +6 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.js +103 -0
- package/dist/commands/deprecate.d.ts +14 -0
- package/dist/commands/deprecate.js +142 -0
- package/dist/commands/dist-tag.d.ts +22 -0
- package/dist/commands/dist-tag.js +179 -0
- package/dist/{esm/commands → commands}/docs.d.ts +0 -1
- package/dist/{esm/commands → commands}/docs.js +0 -1
- package/dist/{esm/commands → commands}/exec-cache.d.ts +1 -1
- package/dist/{esm/commands → commands}/exec-cache.js +1 -1
- package/dist/{esm/commands/run-exec.d.ts → commands/exec-local.d.ts} +0 -1
- package/dist/{esm/commands → commands}/exec-local.js +23 -1
- package/dist/{esm/commands → commands}/exec.d.ts +1 -1
- package/dist/{esm/commands → commands}/exec.js +85 -10
- package/dist/{esm/commands → commands}/help.d.ts +0 -1
- package/dist/{esm/commands → commands}/help.js +5 -1
- package/dist/{esm/commands → commands}/init.d.ts +0 -1
- package/dist/{esm/commands → commands}/init.js +31 -10
- package/dist/{esm/commands → commands}/install/reporter.d.ts +0 -1
- package/dist/{esm/commands → commands}/install/reporter.js +0 -1
- package/dist/{esm/commands → commands}/install.d.ts +22 -3
- package/dist/commands/install.js +152 -0
- package/dist/{esm/commands → commands}/list.d.ts +5 -2
- package/dist/{esm/commands → commands}/list.js +9 -10
- package/dist/{esm/commands → commands}/login.d.ts +0 -1
- package/dist/commands/login.js +35 -0
- package/dist/{esm/commands → commands}/logout.d.ts +1 -1
- package/dist/commands/logout.js +27 -0
- package/dist/{esm/commands → commands}/pack.d.ts +1 -1
- package/dist/{esm/commands → commands}/pack.js +91 -32
- package/dist/commands/ping.d.ts +18 -0
- package/dist/commands/ping.js +117 -0
- package/dist/{esm/commands → commands}/pkg.d.ts +0 -1
- package/dist/{esm/commands → commands}/pkg.js +27 -1
- package/dist/commands/profile.d.ts +14 -0
- package/dist/commands/profile.js +106 -0
- package/dist/{esm/commands → commands}/publish.d.ts +2 -2
- package/dist/{esm/commands → commands}/publish.js +70 -16
- package/dist/{esm/commands → commands}/query.d.ts +5 -2
- package/dist/{esm/commands → commands}/query.js +54 -11
- package/dist/commands/registry.d.ts +26 -0
- package/dist/commands/registry.js +99 -0
- package/dist/commands/repo.d.ts +17 -0
- package/dist/commands/repo.js +157 -0
- package/dist/{esm/commands/exec-local.d.ts → commands/run-exec.d.ts} +1 -1
- package/dist/commands/run-exec.js +41 -0
- package/dist/{esm/commands → commands}/run.d.ts +0 -1
- package/dist/{esm/commands → commands}/run.js +27 -1
- package/dist/commands/setup.d.ts +25 -0
- package/dist/commands/setup.js +142 -0
- package/dist/commands/token.d.ts +32 -0
- package/dist/commands/token.js +193 -0
- package/dist/{esm/commands → commands}/uninstall.d.ts +1 -1
- package/dist/{esm/commands → commands}/uninstall.js +15 -1
- package/dist/commands/unpublish.d.ts +16 -0
- package/dist/commands/unpublish.js +203 -0
- package/dist/{esm/commands → commands}/update.d.ts +1 -1
- package/dist/{esm/commands → commands}/update.js +7 -1
- package/dist/{esm/commands → commands}/version.d.ts +0 -1
- package/dist/{esm/commands → commands}/version.js +27 -1
- package/dist/commands/view.d.ts +23 -0
- package/dist/commands/view.js +335 -0
- package/dist/{esm/commands → commands}/whoami.d.ts +1 -1
- package/dist/commands/whoami.js +33 -0
- package/dist/{esm/config → config}/definition.d.ts +72 -19
- package/dist/{esm/config → config}/definition.js +157 -50
- package/dist/{esm/config → config}/index.d.ts +0 -1
- package/dist/{esm/config → config}/index.js +43 -2
- package/dist/{esm/config → config}/merge.d.ts +0 -1
- package/dist/{esm/config → config}/merge.js +0 -1
- package/dist/{esm/config → config}/usage.d.ts +0 -1
- package/dist/{esm/config → config}/usage.js +0 -1
- package/dist/{esm/custom-help.d.ts → custom-help.d.ts} +0 -1
- package/dist/{esm/custom-help.js → custom-help.js} +95 -120
- package/dist/{esm/exec-command.d.ts → exec-command.d.ts} +0 -1
- package/dist/{esm/exec-command.js → exec-command.js} +14 -8
- package/dist/{esm/index.d.ts → index.d.ts} +0 -1
- package/dist/{esm/index.js → index.js} +5 -2
- package/dist/{esm/load-command.d.ts → load-command.d.ts} +6 -1
- package/dist/{esm/load-command.js → load-command.js} +0 -1
- package/dist/mermaid-image-view.d.ts +18 -0
- package/dist/mermaid-image-view.js +36 -0
- package/dist/{esm/output.d.ts → output.d.ts} +2 -2
- package/dist/{esm/output.js → output.js} +70 -3
- package/dist/{esm/pack-tarball.d.ts → pack-tarball.d.ts} +15 -1
- package/dist/{esm/pack-tarball.js → pack-tarball.js} +133 -91
- package/dist/{esm/parse-add-remove-args.d.ts → parse-add-remove-args.d.ts} +0 -1
- package/dist/{esm/parse-add-remove-args.js → parse-add-remove-args.js} +65 -12
- package/dist/{esm/print-err.d.ts → print-err.d.ts} +0 -1
- package/dist/{esm/print-err.js → print-err.js} +28 -4
- package/dist/query-diff-files.d.ts +17 -0
- package/dist/query-diff-files.js +63 -0
- package/dist/{esm/query-host-contexts.d.ts → query-host-contexts.d.ts} +0 -1
- package/dist/{esm/query-host-contexts.js → query-host-contexts.js} +8 -7
- package/dist/{esm/read-password.d.ts → read-password.d.ts} +0 -1
- package/dist/{esm/read-password.js → read-password.js} +0 -1
- package/dist/read-project-folders.d.ts +17 -0
- package/dist/read-project-folders.js +100 -0
- package/dist/registry-error-message.d.ts +2 -0
- package/dist/registry-error-message.js +29 -0
- package/dist/reload-config.d.ts +2 -0
- package/dist/reload-config.js +11 -0
- package/dist/render-mermaid.d.ts +22 -0
- package/dist/render-mermaid.js +68 -0
- package/dist/require-registry.d.ts +48 -0
- package/dist/require-registry.js +122 -0
- package/dist/select-registry.d.ts +23 -0
- package/dist/select-registry.js +40 -0
- package/dist/telemetry.d.ts +58 -0
- package/dist/telemetry.js +170 -0
- package/dist/verbose-log.d.ts +31 -0
- package/dist/verbose-log.js +62 -0
- package/dist/{esm/view.d.ts → view.d.ts} +0 -1
- package/dist/{esm/view.js → view.js} +1 -2
- package/package.json +75 -82
- package/dist/esm/commands/bugs.d.ts.map +0 -1
- package/dist/esm/commands/bugs.js.map +0 -1
- package/dist/esm/commands/build.d.ts.map +0 -1
- package/dist/esm/commands/build.js.map +0 -1
- package/dist/esm/commands/cache.d.ts.map +0 -1
- package/dist/esm/commands/cache.js.map +0 -1
- package/dist/esm/commands/ci.d.ts.map +0 -1
- package/dist/esm/commands/ci.js.map +0 -1
- package/dist/esm/commands/config.d.ts.map +0 -1
- package/dist/esm/commands/config.js.map +0 -1
- package/dist/esm/commands/docs.d.ts.map +0 -1
- package/dist/esm/commands/docs.js.map +0 -1
- package/dist/esm/commands/exec-cache.d.ts.map +0 -1
- package/dist/esm/commands/exec-cache.js.map +0 -1
- package/dist/esm/commands/exec-local.d.ts.map +0 -1
- package/dist/esm/commands/exec-local.js.map +0 -1
- package/dist/esm/commands/exec.d.ts.map +0 -1
- package/dist/esm/commands/exec.js.map +0 -1
- package/dist/esm/commands/help.d.ts.map +0 -1
- package/dist/esm/commands/help.js.map +0 -1
- package/dist/esm/commands/init.d.ts.map +0 -1
- package/dist/esm/commands/init.js.map +0 -1
- package/dist/esm/commands/install/reporter.d.ts.map +0 -1
- package/dist/esm/commands/install/reporter.js.map +0 -1
- package/dist/esm/commands/install.d.ts.map +0 -1
- package/dist/esm/commands/install.js +0 -46
- package/dist/esm/commands/install.js.map +0 -1
- package/dist/esm/commands/list.d.ts.map +0 -1
- package/dist/esm/commands/list.js.map +0 -1
- package/dist/esm/commands/login.d.ts.map +0 -1
- package/dist/esm/commands/login.js +0 -13
- package/dist/esm/commands/login.js.map +0 -1
- package/dist/esm/commands/logout.d.ts.map +0 -1
- package/dist/esm/commands/logout.js +0 -13
- package/dist/esm/commands/logout.js.map +0 -1
- package/dist/esm/commands/pack.d.ts.map +0 -1
- package/dist/esm/commands/pack.js.map +0 -1
- package/dist/esm/commands/pkg.d.ts.map +0 -1
- package/dist/esm/commands/pkg.js.map +0 -1
- package/dist/esm/commands/publish.d.ts.map +0 -1
- package/dist/esm/commands/publish.js.map +0 -1
- package/dist/esm/commands/query.d.ts.map +0 -1
- package/dist/esm/commands/query.js.map +0 -1
- package/dist/esm/commands/run-exec.d.ts.map +0 -1
- package/dist/esm/commands/run-exec.js +0 -14
- package/dist/esm/commands/run-exec.js.map +0 -1
- package/dist/esm/commands/run.d.ts.map +0 -1
- package/dist/esm/commands/run.js.map +0 -1
- package/dist/esm/commands/serve.d.ts +0 -14
- package/dist/esm/commands/serve.d.ts.map +0 -1
- package/dist/esm/commands/serve.js +0 -103
- package/dist/esm/commands/serve.js.map +0 -1
- package/dist/esm/commands/token.d.ts +0 -4
- package/dist/esm/commands/token.d.ts.map +0 -1
- package/dist/esm/commands/token.js +0 -30
- package/dist/esm/commands/token.js.map +0 -1
- package/dist/esm/commands/uninstall.d.ts.map +0 -1
- package/dist/esm/commands/uninstall.js.map +0 -1
- package/dist/esm/commands/update.d.ts.map +0 -1
- package/dist/esm/commands/update.js.map +0 -1
- package/dist/esm/commands/version.d.ts.map +0 -1
- package/dist/esm/commands/version.js.map +0 -1
- package/dist/esm/commands/whoami.d.ts.map +0 -1
- package/dist/esm/commands/whoami.js +0 -19
- package/dist/esm/commands/whoami.js.map +0 -1
- package/dist/esm/config/definition.d.ts.map +0 -1
- package/dist/esm/config/definition.js.map +0 -1
- package/dist/esm/config/index.d.ts.map +0 -1
- package/dist/esm/config/index.js.map +0 -1
- package/dist/esm/config/merge.d.ts.map +0 -1
- package/dist/esm/config/merge.js.map +0 -1
- package/dist/esm/config/usage.d.ts.map +0 -1
- package/dist/esm/config/usage.js.map +0 -1
- package/dist/esm/custom-help.d.ts.map +0 -1
- package/dist/esm/custom-help.js.map +0 -1
- package/dist/esm/exec-command.d.ts.map +0 -1
- package/dist/esm/exec-command.js.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/load-command.d.ts.map +0 -1
- package/dist/esm/load-command.js.map +0 -1
- package/dist/esm/output.d.ts.map +0 -1
- package/dist/esm/output.js.map +0 -1
- package/dist/esm/pack-tarball.d.ts.map +0 -1
- package/dist/esm/pack-tarball.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/parse-add-remove-args.d.ts.map +0 -1
- package/dist/esm/parse-add-remove-args.js.map +0 -1
- package/dist/esm/print-err.d.ts.map +0 -1
- package/dist/esm/print-err.js.map +0 -1
- package/dist/esm/query-host-contexts.d.ts.map +0 -1
- package/dist/esm/query-host-contexts.js.map +0 -1
- package/dist/esm/read-password.d.ts.map +0 -1
- package/dist/esm/read-password.js.map +0 -1
- package/dist/esm/start-gui.d.ts +0 -10
- package/dist/esm/start-gui.d.ts.map +0 -1
- package/dist/esm/start-gui.js +0 -60
- package/dist/esm/start-gui.js.map +0 -1
- package/dist/esm/view.d.ts.map +0 -1
- package/dist/esm/view.js.map +0 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anonymized telemetry for the vlt CLI.
|
|
3
|
+
*
|
|
4
|
+
* - Sends anonymous, non-PII events to PostHog.
|
|
5
|
+
* - Generates a random UUID on first run, stored in XDG data dir.
|
|
6
|
+
* - Respects opt-out via `DO_NOT_TRACK=1`, `VLT_TELEMETRY=0`,
|
|
7
|
+
* or the `--telemetry=false` config flag.
|
|
8
|
+
* - Flush is awaited with a timeout cap so it never blocks CLI exit for long.
|
|
9
|
+
* - Fails silently on any network or runtime error.
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { randomUUID } from 'node:crypto';
|
|
13
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { createRequire } from 'node:module';
|
|
15
|
+
import { XDG } from '@vltpkg/xdg';
|
|
16
|
+
const POSTHOG_API_KEY = 'phc_k9xCAgC6sPIBLb5UhjhnGWpt1mos0hLV4mmEhZTGPpO';
|
|
17
|
+
const POSTHOG_HOST = 'https://us.i.posthog.com';
|
|
18
|
+
/** Timeout (ms) we wait for PostHog to flush before giving up. */
|
|
19
|
+
const SHUTDOWN_TIMEOUT_MS = 2_000;
|
|
20
|
+
const xdg = new XDG('vlt');
|
|
21
|
+
/**
|
|
22
|
+
* Check whether telemetry is disabled via environment variables.
|
|
23
|
+
*
|
|
24
|
+
* - `DO_NOT_TRACK=1` — https://consoledonottrack.com/
|
|
25
|
+
* - `VLT_TELEMETRY=0`
|
|
26
|
+
*/
|
|
27
|
+
export const isOptedOut = () => process.env.DO_NOT_TRACK === '1' ||
|
|
28
|
+
process.env.VLT_TELEMETRY === '0';
|
|
29
|
+
/**
|
|
30
|
+
* Return (or create) a stable anonymous distinct ID.
|
|
31
|
+
* Stored at `<XDG_DATA_HOME>/vlt/telemetry-id`.
|
|
32
|
+
*/
|
|
33
|
+
const getAnonymousId = () => {
|
|
34
|
+
const dir = xdg.data();
|
|
35
|
+
const file = xdg.data('telemetry-id');
|
|
36
|
+
try {
|
|
37
|
+
const existing = readFileSync(file, 'utf8').trim();
|
|
38
|
+
if (existing)
|
|
39
|
+
return existing;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// file doesn't exist yet — create it below
|
|
43
|
+
}
|
|
44
|
+
const id = randomUUID();
|
|
45
|
+
try {
|
|
46
|
+
mkdirSync(dir, { recursive: true });
|
|
47
|
+
writeFileSync(file, id + '\n');
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// best-effort — if we can't persist, just use a transient id
|
|
51
|
+
}
|
|
52
|
+
return id;
|
|
53
|
+
};
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// PostHog client — lazily initialised
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
let _posthog;
|
|
58
|
+
let _initFailed = false;
|
|
59
|
+
const getClient = () => {
|
|
60
|
+
if (_posthog)
|
|
61
|
+
return _posthog;
|
|
62
|
+
if (_initFailed)
|
|
63
|
+
return undefined;
|
|
64
|
+
try {
|
|
65
|
+
// Dynamic import would be async; posthog-node also ships a
|
|
66
|
+
// synchronous constructor, so we use createRequire to keep
|
|
67
|
+
// the hot-path synchronous in this ESM package.
|
|
68
|
+
const req = createRequire(import.meta.url);
|
|
69
|
+
const { PostHog } = req('posthog-node');
|
|
70
|
+
_posthog = new PostHog(POSTHOG_API_KEY, {
|
|
71
|
+
host: POSTHOG_HOST,
|
|
72
|
+
// Buffer up to 20 events and flush every 10 s — but we always
|
|
73
|
+
// call shutdown at the end so this is just a safety net.
|
|
74
|
+
flushAt: 20,
|
|
75
|
+
flushInterval: 10_000,
|
|
76
|
+
});
|
|
77
|
+
return _posthog;
|
|
78
|
+
/* c8 ignore next 4 */
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
_initFailed = true;
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Capture a `cli_command` event.
|
|
87
|
+
*/
|
|
88
|
+
export const trackCommand = (ev, telemetryFlag) => {
|
|
89
|
+
if (telemetryFlag === false || isOptedOut())
|
|
90
|
+
return;
|
|
91
|
+
const ph = getClient();
|
|
92
|
+
if (!ph)
|
|
93
|
+
return;
|
|
94
|
+
try {
|
|
95
|
+
ph.capture({
|
|
96
|
+
distinctId: getAnonymousId(),
|
|
97
|
+
event: 'cli_command',
|
|
98
|
+
properties: { ...ev },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// fail silently
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Capture a `cli_install` event.
|
|
107
|
+
*/
|
|
108
|
+
export const trackInstall = (ev, telemetryFlag) => {
|
|
109
|
+
if (telemetryFlag === false || isOptedOut())
|
|
110
|
+
return;
|
|
111
|
+
const ph = getClient();
|
|
112
|
+
if (!ph)
|
|
113
|
+
return;
|
|
114
|
+
try {
|
|
115
|
+
ph.capture({
|
|
116
|
+
distinctId: getAnonymousId(),
|
|
117
|
+
event: 'cli_install',
|
|
118
|
+
properties: { ...ev },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// fail silently
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Capture a `cli_error` event.
|
|
127
|
+
*/
|
|
128
|
+
export const trackError = (ev, telemetryFlag) => {
|
|
129
|
+
if (telemetryFlag === false || isOptedOut())
|
|
130
|
+
return;
|
|
131
|
+
const ph = getClient();
|
|
132
|
+
if (!ph)
|
|
133
|
+
return;
|
|
134
|
+
try {
|
|
135
|
+
ph.capture({
|
|
136
|
+
distinctId: getAnonymousId(),
|
|
137
|
+
event: 'cli_error',
|
|
138
|
+
properties: { ...ev },
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// fail silently
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Flush pending events. Returns a promise that resolves once flushing
|
|
147
|
+
* completes **or** when `SHUTDOWN_TIMEOUT_MS` elapses — whichever
|
|
148
|
+
* comes first. Never rejects.
|
|
149
|
+
*
|
|
150
|
+
* The safety-net timer is unreffed so it cannot keep the process alive
|
|
151
|
+
* on its own — if the caller does not `await` this, Node will still
|
|
152
|
+
* exit promptly once all other handles are drained.
|
|
153
|
+
*/
|
|
154
|
+
export const flush = () => {
|
|
155
|
+
const ph = _posthog;
|
|
156
|
+
if (!ph)
|
|
157
|
+
return Promise.resolve();
|
|
158
|
+
// Clear the reference so no further events are captured and
|
|
159
|
+
// PostHog's internal timers can be garbage-collected.
|
|
160
|
+
_posthog = undefined;
|
|
161
|
+
return Promise.race([
|
|
162
|
+
ph.shutdown().catch(() => { }),
|
|
163
|
+
new Promise(r => {
|
|
164
|
+
const t = setTimeout(r, SHUTDOWN_TIMEOUT_MS);
|
|
165
|
+
// Unref so this timer alone won't keep the process alive.
|
|
166
|
+
if (typeof t === 'object' && 'unref' in t)
|
|
167
|
+
t.unref();
|
|
168
|
+
}),
|
|
169
|
+
]);
|
|
170
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Events } from '@vltpkg/output';
|
|
2
|
+
/**
|
|
3
|
+
* Diagnostic logging levels, ordered from least to most verbose.
|
|
4
|
+
* Mirrors the `loglevel` option in the config definition.
|
|
5
|
+
*/
|
|
6
|
+
export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'verbose' | 'debug';
|
|
7
|
+
/** True when the given level should emit per-request logging. */
|
|
8
|
+
export declare const isVerbose: (level: LogLevel) => boolean;
|
|
9
|
+
/** The subset of `styleText` color names this module applies. */
|
|
10
|
+
export type StyleColor = 'green' | 'red' | 'gray';
|
|
11
|
+
/**
|
|
12
|
+
* Minimal signature compatible with the `styleText` helpers exported by
|
|
13
|
+
* `./output.ts` (which accept a wider set of format names). Defaults to an
|
|
14
|
+
* identity function so this module can be tested without color support.
|
|
15
|
+
*/
|
|
16
|
+
export type StyleFn = (format: StyleColor, s: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Format a single `request` event into a human-readable log line.
|
|
19
|
+
* Exported for testing.
|
|
20
|
+
*/
|
|
21
|
+
export declare const formatRequestEvent: (event: Events["request"], style?: StyleFn) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Subscribe to registry request events and stream them to `write` when
|
|
24
|
+
* the configured `level` is `verbose` or higher. The `start` event is only
|
|
25
|
+
* logged at `debug` level to avoid duplicate lines (each network request
|
|
26
|
+
* also emits a `complete`/`304` line with its status and duration).
|
|
27
|
+
*
|
|
28
|
+
* Returns a cleanup function that detaches the subscription. When `level`
|
|
29
|
+
* is below `verbose`, nothing is subscribed and the cleanup is a no-op.
|
|
30
|
+
*/
|
|
31
|
+
export declare const startRequestLog: (level: LogLevel, write: (line: string) => void, style?: StyleFn) => (() => void);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { emitter } from '@vltpkg/output';
|
|
2
|
+
const rank = {
|
|
3
|
+
silent: 0,
|
|
4
|
+
error: 1,
|
|
5
|
+
warn: 2,
|
|
6
|
+
info: 3,
|
|
7
|
+
verbose: 4,
|
|
8
|
+
debug: 5,
|
|
9
|
+
};
|
|
10
|
+
/** True when the given level should emit per-request logging. */
|
|
11
|
+
export const isVerbose = (level) => rank[level] >= rank.verbose;
|
|
12
|
+
const isDebug = (level) => rank[level] >= rank.debug;
|
|
13
|
+
const identityStyle = (_f, s) => s;
|
|
14
|
+
const tagStyle = (state, statusCode) => {
|
|
15
|
+
switch (state) {
|
|
16
|
+
case 'cache':
|
|
17
|
+
case 'stale':
|
|
18
|
+
case '304':
|
|
19
|
+
return 'green';
|
|
20
|
+
case 'start':
|
|
21
|
+
return 'gray';
|
|
22
|
+
case 'complete':
|
|
23
|
+
return statusCode !== undefined && statusCode >= 400 ?
|
|
24
|
+
'red'
|
|
25
|
+
: 'green';
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Format a single `request` event into a human-readable log line.
|
|
30
|
+
* Exported for testing.
|
|
31
|
+
*/
|
|
32
|
+
export const formatRequestEvent = (event, style = identityStyle) => {
|
|
33
|
+
const { url, state, method = 'GET', statusCode, durationMs } = event;
|
|
34
|
+
// For completed network requests show the status code rather than the
|
|
35
|
+
// literal word "complete"; everything else shows the cache/fetch state.
|
|
36
|
+
const tag = state === 'complete' ? String(statusCode ?? '') : state;
|
|
37
|
+
const duration = durationMs === undefined ? '' : (style('gray', ` (${durationMs}ms)`));
|
|
38
|
+
return `${style(tagStyle(state, statusCode), tag.padEnd(8))} ${method} ${String(url)}${duration}`;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Subscribe to registry request events and stream them to `write` when
|
|
42
|
+
* the configured `level` is `verbose` or higher. The `start` event is only
|
|
43
|
+
* logged at `debug` level to avoid duplicate lines (each network request
|
|
44
|
+
* also emits a `complete`/`304` line with its status and duration).
|
|
45
|
+
*
|
|
46
|
+
* Returns a cleanup function that detaches the subscription. When `level`
|
|
47
|
+
* is below `verbose`, nothing is subscribed and the cleanup is a no-op.
|
|
48
|
+
*/
|
|
49
|
+
export const startRequestLog = (level, write, style = identityStyle) => {
|
|
50
|
+
if (!isVerbose(level))
|
|
51
|
+
return () => { };
|
|
52
|
+
const debug = isDebug(level);
|
|
53
|
+
const handler = (event) => {
|
|
54
|
+
// At verbose level, skip the `start` event so each request produces a
|
|
55
|
+
// single completion line; at debug level, show it too.
|
|
56
|
+
if (event.state === 'start' && !debug)
|
|
57
|
+
return;
|
|
58
|
+
write(formatRequestEvent(event, style));
|
|
59
|
+
};
|
|
60
|
+
emitter.on('request', handler);
|
|
61
|
+
return () => emitter.off('request', handler);
|
|
62
|
+
};
|
|
@@ -27,4 +27,3 @@ export type ViewFn<T = unknown> = (result: T, options: ViewOptions, conf: Loaded
|
|
|
27
27
|
export type View<T = unknown> = ViewFn<T> | typeof ViewClass<T>;
|
|
28
28
|
export declare const isViewClass: <T = unknown>(view: View<T>) => view is typeof ViewClass<T>;
|
|
29
29
|
export type Views<T = unknown> = View<T> | Record<string, View<T>>;
|
|
30
|
-
//# sourceMappingURL=view.d.ts.map
|
|
@@ -17,7 +17,7 @@ export class ViewClass {
|
|
|
17
17
|
this.config = config;
|
|
18
18
|
}
|
|
19
19
|
// TODO: maybe have start() return a flag to say "i got this, do not
|
|
20
|
-
// run the command", for example to
|
|
20
|
+
// run the command", for example to just open a web browser
|
|
21
21
|
// to the page relevant to a given thing, rather than computing it twice
|
|
22
22
|
start() { }
|
|
23
23
|
async done(_result, _opts) {
|
|
@@ -28,4 +28,3 @@ export class ViewClass {
|
|
|
28
28
|
export const isViewClass = (view) => typeof view === 'function' &&
|
|
29
29
|
'prototype' in view &&
|
|
30
30
|
view.prototype instanceof ViewClass;
|
|
31
|
-
//# sourceMappingURL=view.js.map
|
package/package.json
CHANGED
|
@@ -1,120 +1,117 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/cli-sdk",
|
|
3
3
|
"description": "The source for the vlt CLI",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
8
8
|
"directory": "src/cli-sdk"
|
|
9
9
|
},
|
|
10
|
-
"author":
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"dialects": [
|
|
15
|
-
"esm"
|
|
16
|
-
],
|
|
17
|
-
"exports": {
|
|
18
|
-
"./package.json": "./package.json",
|
|
19
|
-
".": "./src/index.ts",
|
|
20
|
-
"./config": "./src/config/index.ts",
|
|
21
|
-
"./definition": "./src/config/definition.ts",
|
|
22
|
-
"./view": "./src/view.ts"
|
|
23
|
-
}
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "vlt technology inc.",
|
|
12
|
+
"email": "support@vlt.sh",
|
|
13
|
+
"url": "http://vlt.sh"
|
|
24
14
|
},
|
|
25
15
|
"dependencies": {
|
|
16
|
+
"@resvg/resvg-wasm": "^2.6.2",
|
|
17
|
+
"@vltpkg/config": "1.0.1",
|
|
18
|
+
"@vltpkg/dep-id": "1.0.1",
|
|
19
|
+
"@vltpkg/dot-prop": "1.0.1",
|
|
20
|
+
"@vltpkg/error-cause": "1.0.1",
|
|
21
|
+
"@vltpkg/git": "1.0.1",
|
|
22
|
+
"@vltpkg/graph": "1.0.1",
|
|
23
|
+
"@vltpkg/graph-run": "1.0.1",
|
|
24
|
+
"@vltpkg/init": "1.0.1",
|
|
25
|
+
"@vltpkg/output": "1.0.1",
|
|
26
|
+
"@vltpkg/package-info": "1.0.1",
|
|
27
|
+
"@vltpkg/package-json": "1.0.1",
|
|
28
|
+
"@vltpkg/promise-spawn": "1.0.1",
|
|
29
|
+
"@vltpkg/query": "1.0.1",
|
|
30
|
+
"@vltpkg/registry-client": "1.0.1",
|
|
31
|
+
"@vltpkg/rollback-remove": "1.0.1",
|
|
32
|
+
"@vltpkg/run": "1.0.1",
|
|
33
|
+
"@vltpkg/security-archive": "1.0.1",
|
|
34
|
+
"@vltpkg/spec": "1.0.1",
|
|
35
|
+
"@vltpkg/types": "1.0.1",
|
|
36
|
+
"@vltpkg/url-open": "1.0.1",
|
|
37
|
+
"@vltpkg/vlt-json": "1.0.1",
|
|
38
|
+
"@vltpkg/vlx": "1.0.1",
|
|
39
|
+
"@vltpkg/workspaces": "1.0.1",
|
|
40
|
+
"@vltpkg/xdg": "1.0.1",
|
|
26
41
|
"ansi-to-pre": "^1.0.6",
|
|
42
|
+
"beautiful-mermaid": "^1.1.3",
|
|
27
43
|
"chalk": "^5.6.2",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"ink": "^6.
|
|
44
|
+
"hosted-git-info": "^9.0.2",
|
|
45
|
+
"ignore": "^7.0.5",
|
|
46
|
+
"ink": "^6.5.1",
|
|
31
47
|
"ink-spinner": "^5.0.0",
|
|
32
48
|
"jackspeak": "^4.1.1",
|
|
33
|
-
"
|
|
34
|
-
"minimatch": "^10.0.3",
|
|
49
|
+
"minimatch": "^10.1.1",
|
|
35
50
|
"package-json-from-dist": "^1.0.1",
|
|
36
|
-
"path-scurry": "^2.0.
|
|
51
|
+
"path-scurry": "^2.0.1",
|
|
37
52
|
"polite-json": "^5.0.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
53
|
+
"posthog-node": "^4.0.0",
|
|
54
|
+
"pretty-bytes": "^7.1.0",
|
|
55
|
+
"promise-call-limit": "^3.0.2",
|
|
56
|
+
"react": "^19.2.1",
|
|
40
57
|
"react-devtools-core": "^4.28.5",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"supports-color": "^10.2.0",
|
|
45
|
-
"tar": "^7.4.3",
|
|
46
|
-
"@vltpkg/config": "1.0.0-rc.8",
|
|
47
|
-
"@vltpkg/dep-id": "1.0.0-rc.8",
|
|
48
|
-
"@vltpkg/dot-prop": "1.0.0-rc.8",
|
|
49
|
-
"@vltpkg/error-cause": "1.0.0-rc.8",
|
|
50
|
-
"@vltpkg/graph": "1.0.0-rc.8",
|
|
51
|
-
"@vltpkg/git": "1.0.0-rc.8",
|
|
52
|
-
"@vltpkg/output": "1.0.0-rc.8",
|
|
53
|
-
"@vltpkg/package-info": "1.0.0-rc.8",
|
|
54
|
-
"@vltpkg/init": "1.0.0-rc.8",
|
|
55
|
-
"@vltpkg/package-json": "1.0.0-rc.8",
|
|
56
|
-
"@vltpkg/query": "1.0.0-rc.8",
|
|
57
|
-
"@vltpkg/promise-spawn": "1.0.0-rc.8",
|
|
58
|
-
"@vltpkg/registry-client": "1.0.0-rc.8",
|
|
59
|
-
"@vltpkg/rollback-remove": "1.0.0-rc.8",
|
|
60
|
-
"@vltpkg/server": "1.0.0-rc.8",
|
|
61
|
-
"@vltpkg/spec": "1.0.0-rc.8",
|
|
62
|
-
"@vltpkg/security-archive": "1.0.0-rc.8",
|
|
63
|
-
"@vltpkg/run": "1.0.0-rc.8",
|
|
64
|
-
"@vltpkg/types": "1.0.0-rc.8",
|
|
65
|
-
"@vltpkg/url-open": "1.0.0-rc.8",
|
|
66
|
-
"@vltpkg/vlx": "1.0.0-rc.8",
|
|
67
|
-
"@vltpkg/workspaces": "1.0.0-rc.8",
|
|
68
|
-
"@vltpkg/xdg": "1.0.0-rc.8",
|
|
69
|
-
"@vltpkg/vlt-json": "1.0.0-rc.8"
|
|
58
|
+
"ssri": "^13.0.0",
|
|
59
|
+
"supports-color": "^10.2.2",
|
|
60
|
+
"tar": "^7.5.2"
|
|
70
61
|
},
|
|
71
62
|
"devDependencies": {
|
|
72
|
-
"@eslint/js": "^9.
|
|
73
|
-
"@types/node": "^22.
|
|
74
|
-
"@types/react": "^
|
|
63
|
+
"@eslint/js": "^9.39.1",
|
|
64
|
+
"@types/node": "^22.19.2",
|
|
65
|
+
"@types/react": "^18.3.27",
|
|
75
66
|
"@types/ssri": "^7.1.5",
|
|
76
|
-
"eslint": "^9.
|
|
77
|
-
"prettier": "^3.
|
|
78
|
-
"tap": "^21.
|
|
79
|
-
"tshy": "^3.0.2",
|
|
67
|
+
"eslint": "^9.39.1",
|
|
68
|
+
"prettier": "^3.7.4",
|
|
69
|
+
"tap": "^21.5.0",
|
|
80
70
|
"typedoc": "~0.27.9",
|
|
81
71
|
"typescript": "5.7.3",
|
|
82
|
-
"typescript-eslint": "^8.
|
|
72
|
+
"typescript-eslint": "^8.49.0"
|
|
83
73
|
},
|
|
84
74
|
"license": "BSD-2-Clause-Patent",
|
|
85
75
|
"engines": {
|
|
86
|
-
"node": ">=22"
|
|
76
|
+
"node": ">=22.22.0"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
80
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
81
|
+
"lint": "eslint . --fix",
|
|
82
|
+
"lint:check": "eslint .",
|
|
83
|
+
"prepack": "tsc -p tsconfig.publish.json && ../../scripts/update-dist-exports.ts",
|
|
84
|
+
"snap": "tap",
|
|
85
|
+
"test": "tap",
|
|
86
|
+
"posttest": "tsc --noEmit",
|
|
87
|
+
"typecheck": "tsc --noEmit"
|
|
87
88
|
},
|
|
88
89
|
"tap": {
|
|
89
90
|
"extends": "../../tap-config.yaml"
|
|
90
91
|
},
|
|
91
92
|
"prettier": "../../.prettierrc.js",
|
|
92
|
-
"module": "./dist/
|
|
93
|
+
"module": "./dist/index.js",
|
|
93
94
|
"type": "module",
|
|
94
95
|
"exports": {
|
|
95
96
|
"./package.json": "./package.json",
|
|
96
97
|
".": {
|
|
97
98
|
"import": {
|
|
98
|
-
"
|
|
99
|
-
"default": "./dist/esm/index.js"
|
|
99
|
+
"default": "./dist/index.js"
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"./config": {
|
|
103
103
|
"import": {
|
|
104
|
-
"
|
|
105
|
-
"default": "./dist/esm/config/index.js"
|
|
104
|
+
"default": "./dist/config/index.js"
|
|
106
105
|
}
|
|
107
106
|
},
|
|
108
107
|
"./definition": {
|
|
109
108
|
"import": {
|
|
110
|
-
"
|
|
111
|
-
"default": "./dist/esm/config/definition.js"
|
|
109
|
+
"default": "./dist/config/definition.js"
|
|
112
110
|
}
|
|
113
111
|
},
|
|
114
112
|
"./view": {
|
|
115
113
|
"import": {
|
|
116
|
-
"
|
|
117
|
-
"default": "./dist/esm/view.js"
|
|
114
|
+
"default": "./dist/view.js"
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
},
|
|
@@ -124,15 +121,11 @@
|
|
|
124
121
|
"keywords": [
|
|
125
122
|
"vltpkg"
|
|
126
123
|
],
|
|
127
|
-
"
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"tshy": "tshy",
|
|
136
|
-
"typecheck": "tsc --noEmit"
|
|
137
|
-
}
|
|
138
|
-
}
|
|
124
|
+
"bugs": [
|
|
125
|
+
{
|
|
126
|
+
"type": "link",
|
|
127
|
+
"url": "https://github.com/vltpkg/vltpkg/issues"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"homepage": "https://github.com/vltpkg/vltpkg/tree/main/src/cli-sdk#readme"
|
|
131
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bugs.d.ts","sourceRoot":"","sources":["../../../src/commands/bugs.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAQ1D,eAAO,MAAM,KAAK,EAAE,YA2BhB,CAAA;AAEJ,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,qBAAqB,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb,EAAE,CAAA;AAEH,MAAM,MAAM,aAAa,GACrB,mBAAmB,GACnB,qBAAqB,CAAA;AAEzB,eAAO,MAAM,KAAK;;;CAUuB,CAAA;AAkDzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CA4F5C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bugs.js","sourceRoot":"","sources":["../../../src/commands/bugs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIjD,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,aAEzC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC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G,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IACxC,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;IACzB,iEAAiE;IACjE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,KAAK,CAAC,uBAAuB,CAAC,CAAA;IACtC,CAAC;IACD,oBAAoB;IACpB,eAAe;IACf,MAAM,OAAO,CAAC,GAAG,CAAC,CAAA;IAElB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAA;AACtB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { Spec } from '@vltpkg/spec'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { actual } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { Manifest, NormalizedManifest } from '@vltpkg/types'\nimport hostedGitInfo from 'hosted-git-info'\nconst { fromUrl: hostedGitInfoFromUrl } = hostedGitInfo as {\n fromUrl: (url: string) => { bugs?: () => string } | null\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'bugs',\n usage: ['[<spec>]', '[--target=<query>]'],\n description: `Open bug tracker for a package in a web browser.\n Reads bug tracker information from package.json or fetches\n manifest data for the specified package.`,\n options: {\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using DSS syntax.',\n },\n },\n examples: {\n '': {\n description:\n 'Open bugs for the current package (reads local package.json)',\n },\n 'abbrev@2.0.0': {\n description: 'Open bugs for a specific package version',\n },\n '--target=\":root > *\"': {\n description:\n 'List bug tracker URLs for all direct dependencies',\n },\n },\n })\n\ntype CommandResultSingle = {\n url: string\n name: string\n}\n\ntype CommandResultMultiple = {\n url: string\n name: string\n}[]\n\nexport type CommandResult =\n | CommandResultSingle\n | CommandResultMultiple\n\nexport const views = {\n human: r => {\n if (Array.isArray(r)) {\n let msg = 'Multiple package bug trackers found:\\n'\n msg += r.map(item => `• ${item.name}: ${item.url}`).join('\\n')\n return msg\n }\n return ''\n },\n json: r => r,\n} as const satisfies Views<CommandResult>\n\nconst getUrlFromManifest = (\n manifest: Manifest | NormalizedManifest,\n): string => {\n const { name, bugs, repository } = manifest\n\n if (!name) {\n throw error('No package name found')\n }\n\n let url: string | undefined\n\n // Check bugs field first\n if (bugs) {\n if (typeof bugs === 'string') {\n url = bugs\n } else if (typeof bugs === 'object') {\n if ('url' in bugs && bugs.url) {\n url = bugs.url\n } else if ('email' in bugs && bugs.email) {\n url = `mailto:${bugs.email}`\n }\n }\n }\n\n // Try repository if no bugs field\n if (!url && repository) {\n const repoUrl =\n typeof repository === 'string' ? repository\n : typeof repository === 'object' && 'url' in repository ?\n repository.url\n : /* c8 ignore next */ undefined\n\n if (repoUrl) {\n const info = hostedGitInfoFromUrl(repoUrl.replace(/^git\\+/, ''))\n if (info?.bugs && typeof info.bugs === 'function') {\n url = info.bugs()\n }\n }\n }\n\n // Fallback to vlt.io package page\n if (!url) {\n url = `https://vlt.io/explore/npm/${name}/overview`\n }\n\n return url\n}\n\nexport const command: CommandFn<CommandResult> = async conf => {\n const { projectRoot, packageJson } = conf.options\n const targetOption = conf.get('target')\n\n // Handle --target query\n if (targetOption) {\n const mainManifest = packageJson.maybeRead(projectRoot)\n if (!mainManifest) {\n throw error('No package.json found in project root', {\n path: projectRoot,\n })\n }\n\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo: conf.options.monorepo,\n loadManifests: true,\n })\n\n const securityArchive =\n Query.hasSecuritySelectors(targetOption) ?\n await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n : undefined\n\n const hostContexts = await createHostContextsMap(conf)\n const query = new Query({\n nodes: new Set(graph.nodes.values()),\n edges: graph.edges,\n importers: graph.importers,\n securityArchive,\n hostContexts,\n })\n\n const { nodes } = await query.search(targetOption, {\n signal: new AbortController().signal,\n })\n\n const results: CommandResultMultiple = []\n for (const node of nodes) {\n if (!node.manifest) continue\n const url = getUrlFromManifest(node.manifest)\n results.push({\n url,\n name: node.name /* c8 ignore next */ ?? '(unknown)',\n })\n }\n\n if (results.length === 0) {\n throw error('No packages found matching target query', {\n found: targetOption,\n })\n }\n\n // If single result, open it\n if (results.length === 1) {\n const result = results[0]\n /* c8 ignore next 3 */\n if (!result) {\n throw error('Unexpected empty result')\n }\n await urlOpen(result.url)\n return result\n }\n\n // Multiple results, return the list\n return results\n }\n\n // read the package spec from a positional argument or local package.json\n const specArg = conf.positionals[0]\n const manifest =\n conf.positionals.length === 0 ? packageJson.read(projectRoot)\n : specArg ?\n await new PackageInfoClient(conf.options).manifest(\n Spec.parseArgs(specArg, conf.options),\n )\n : /* c8 ignore next */ packageJson.read(projectRoot)\n\n const url = getUrlFromManifest(manifest)\n const { name } = manifest\n /* c8 ignore start - getUrlFromManifest already validates name */\n if (!name) {\n throw error('No package name found')\n }\n /* c8 ignore stop */\n // Open the URL\n await urlOpen(url)\n\n return { url, name }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAQ,MAAM,eAAe,CAAA;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK;6BACA,WAAW,KAAG,MAAM;4BAqBrB,WAAW;;;;;;;;;;;;;CAqBW,CAAA;AAEvC,eAAO,MAAM,KAAK,EAAE,YAsBhB,CAAA;AAWJ;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAqC1C,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[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CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACvC,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;QAC5C,MAAM,MAAM,GACV,YAAY;YACZ,gBAAgB;YAChB,oCAAoC,CAAA;QAEtC,uDAAuD;QACvD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC;YACzB,GAAG,OAAO;YACV,WAAW;YACX,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,MAAM;SACP,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,aAAa,GACjB,gBAAgB,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YACvD,KAAK,CAAC,KAAK;YACb,CAAC,CAAC,SAAS,CAAA;QACb,IAAI,aAAa,EAAE,IAAI,KAAK,oBAAoB,EAAE,CAAC;YACjD,MAAM,KAAK,CACT,4CAA4C;gBAC1C,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,EAC5D,EAAE,KAAK,EAAE,CACV,CAAA;QACH,CAAC;QACD,MAAM,KAAK,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACxC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { build } from '@vltpkg/graph'\nimport type { BuildResult, Node } from '@vltpkg/graph'\nimport { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport { isErrorWithCause } from '@vltpkg/types'\n\nexport const views = {\n human: (result: BuildResult): string => {\n const successCount = result.success.length\n const failureCount = result.failure.length\n const messages: string[] = []\n\n if (successCount > 0) {\n messages.push(\n `🔨 Built ${successCount} package${successCount === 1 ? '' : 's'} successfully.`,\n )\n } else {\n messages.push('📦 All packages are already built.')\n }\n\n if (failureCount > 0) {\n messages.push(\n `🔎 ${failureCount} optional package${/* c8 ignore next */ failureCount === 1 ? '' : 's'} failed to build.`,\n )\n }\n\n return messages.join('\\n')\n },\n json: (result: BuildResult) => {\n const successList = result.success.map(node => ({\n id: node.id,\n name: node.name,\n version: node.version,\n }))\n const failureList = result.failure.map(node => ({\n id: node.id,\n name: node.name,\n version: node.version,\n }))\n\n return {\n success: successList,\n failure: failureList,\n message:\n successList.length > 0 ?\n `Built ${successList.length} package${successList.length === 1 ? '' : 's'}.`\n : 'No packages needed building.',\n }\n },\n} as const satisfies Views<BuildResult>\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'build',\n usage: ['[query]', '[--target=<query>]'],\n description: `Build the project based on the current dependency graph.\n\n This command processes the installed packages in node_modules and runs\n any necessary build steps, such as lifecycle scripts and binary linking.\n \n The build process is idempotent and will only perform work that is\n actually needed based on the current state of the dependency graph.\n \n Use --target option or provide a query as a positional argument to filter\n packages using DSS query language syntax, otherwise it will target\n all packages with scripts (:scripts) by default.`,\n options: {\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using DSS syntax.',\n },\n },\n })\n\nconst isGraphRunError = (\n error: unknown,\n): error is Error & { code: string; node: Node } =>\n typeof error === 'object' &&\n error !== null &&\n 'code' in error &&\n error.code === 'GRAPHRUN_TRAVERSAL' &&\n 'node' in error\n\n/**\n * Build command implementation. Runs any required \"postinstall\"\n * lifecycle scripts and binary linking.\n */\nexport const command: CommandFn<BuildResult> = async conf => {\n const { options, projectRoot } = conf\n\n try {\n // Get target from option or first positional, default to all scripts\n const targetOption = conf.get('target')\n const targetPositional = conf.positionals[0]\n const target =\n targetOption ||\n targetPositional ||\n ':scripts:not(:built):not(:malware)'\n\n // Run the build process using the graph build function\n const result = await build({\n ...options,\n projectRoot,\n packageJson: options.packageJson,\n monorepo: options.monorepo,\n scurry: options.scurry,\n target,\n })\n\n return result\n } catch (cause) {\n const graphRunError =\n isErrorWithCause(cause) && isGraphRunError(cause.cause) ?\n cause.cause\n : undefined\n if (graphRunError?.code === 'GRAPHRUN_TRAVERSAL') {\n throw error(\n 'Build failed:\\n Failed to build package: ' +\n `${graphRunError.node.name}@${graphRunError.node.version}`,\n { cause },\n )\n }\n throw error('Build failed', { cause })\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoE6B,CAAA;AAE3C,eAAO,MAAM,KAAK,EAAE,YAA2C,CAAA;AAE/D,eAAO,MAAM,OAAO,E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IAAI,CAAC,OAAO;gBACf,SAAS;gBACT,oBAAoB,EAAE,KAAK;gBAC3B,KAAK,EAAE,SAAS;aACjB,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 { stderr, 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 info: {\n usage: '<key>',\n description: `Print metadata details for the specified cache key to\n stderr, and the response body to stdout.`,\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 examples: {\n 'vlt cache ls https://registry.npmjs.org/typescript': {\n description: `Show cache metadata for a given registry URL`,\n },\n 'vlt cache add eslint@latest': {\n description: `Add a given package specifier to the cache by fetching\n its resolved value.`,\n },\n 'vlt cache info https://registry.npmjs.org/eslint/-/eslint-9.25.1.tgz > eslint.tgz':\n {\n description: `Print the cache metadata to stderr, and write the tarball\n on stdout, redirecting to a file.`,\n },\n 'vlt cache delete-before 2025-01-01': {\n description: 'Delete all entries created before Jan 1, 2025',\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 'info':\n return info(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: Object.keys(usageDef.subcommands),\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 info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: CacheView,\n): Promise<void> => {\n const [key] = keys\n if (keys.length !== 1 || !key) {\n throw error('Must provide exactly one cache key', {\n code: 'EUSAGE',\n })\n }\n await fetchKeys(\n conf,\n [key],\n (entry: CacheEntry, key: string) => {\n stderr(\n /* c8 ignore next */\n key.includes(' ') ? JSON.stringify(key) : key,\n entry,\n )\n if (entry.isJSON) {\n stdout(JSON.stringify(entry.body, null, 2))\n /* c8 ignore start - annoying to test, corrupts TAP output */\n } else {\n process.stdout.write(entry.body as Buffer)\n }\n /* c8 ignore stop */\n return true\n },\n view,\n )\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 query: undefined,\n })\n view?.stdout('+', spec, r.resolved)\n })\n\n promises.push(p)\n }\n\n await Promise.all(promises)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ci.d.ts","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;AAExD,eAAO,MAAM,KAAK,EAAE,YAWhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGkB,CAAA;AAEpC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,QAAQ,CAavC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ci.js","sourceRoot":"","sources":["../../../src/commands/ci.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAOvD,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,KAAK,CAAC,MAAM,EAAE;IAC3B,KAAK,EAAE,eAAe;CACY,CAAA;AAEpC,MAAM,CAAC,MAAM,OAAO,GAAwB,KAAK,EAAC,IAAI,EAAC,EAAE;IACvD,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI,CAAC,OAAO;QACf,sEAAsE;QACtE,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,GAAG;QAC9C,cAAc,EAAE,IAAI;QACpB,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,IAAI;QAClB,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;KAC5C,CAAA;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;IAC1C,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import { install } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { InstallResult } from './install.ts'\n\nexport type CIResult = Omit<InstallResult, 'buildQueue'>\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: i => i.graph.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<CIResult>\n\nexport const command: CommandFn<CIResult> = async conf => {\n const ciOptions = {\n ...conf.options,\n // allow all scripts by default on ci (unless user specifies a filter)\n allowScripts: conf.get('allow-scripts') ?? '*',\n expectLockfile: true,\n frozenLockfile: true,\n cleanInstall: true,\n lockfileOnly: conf.options['lockfile-only'],\n }\n\n const { graph } = await install(ciOptions)\n return { graph }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,eAAO,MAAM,KAAK,EAAE,KAUM,CAAA;AAE1B,eAAO,MAAM,KAAK,EAAE,YAwDhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SA8DrB,CAAA"}
|