vlt 0.0.0-3 → 0.0.0-4
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/README.md +2 -1
- package/package.json +17 -10
- package/postinstall.cjs +56 -0
- package/vlix +25 -0
- package/vlr +25 -0
- package/vlrx +25 -0
- package/vlt +25 -0
- package/vlx +25 -0
- package/cache-unzip-src-unzip.js +0 -7896
- package/cache-unzip-src-unzip.js.map +0 -7
- package/chunk-227OF2U2.js +0 -1183
- package/chunk-227OF2U2.js.map +0 -7
- package/chunk-3HXIYJS2.js +0 -54
- package/chunk-3HXIYJS2.js.map +0 -7
- package/chunk-AA6MVXJX.js +0 -19823
- package/chunk-AA6MVXJX.js.map +0 -7
- package/chunk-BCK4ZGNG.js +0 -41
- package/chunk-BCK4ZGNG.js.map +0 -7
- package/chunk-DH36SF3E.js +0 -35
- package/chunk-DH36SF3E.js.map +0 -7
- package/chunk-FNKWJ7AZ.js +0 -1379
- package/chunk-FNKWJ7AZ.js.map +0 -7
- package/chunk-H77UDCL3.js +0 -9820
- package/chunk-H77UDCL3.js.map +0 -7
- package/chunk-HL76E44L.js +0 -73
- package/chunk-HL76E44L.js.map +0 -7
- package/chunk-IN7DEH7F.js +0 -44
- package/chunk-IN7DEH7F.js.map +0 -7
- package/chunk-JLP2QDXQ.js +0 -1137
- package/chunk-JLP2QDXQ.js.map +0 -7
- package/chunk-JMGSFQ32.js +0 -969
- package/chunk-JMGSFQ32.js.map +0 -7
- package/chunk-JQRUGUZ3.js +0 -512
- package/chunk-JQRUGUZ3.js.map +0 -7
- package/chunk-K2BYYPM7.js +0 -8656
- package/chunk-K2BYYPM7.js.map +0 -7
- package/chunk-LNUDEBGP.js +0 -2071
- package/chunk-LNUDEBGP.js.map +0 -7
- package/chunk-MV5ZQ3LW.js +0 -1105
- package/chunk-MV5ZQ3LW.js.map +0 -7
- package/chunk-O7CDQZDW.js +0 -5234
- package/chunk-O7CDQZDW.js.map +0 -7
- package/chunk-OFW7MWFP.js +0 -82
- package/chunk-OFW7MWFP.js.map +0 -7
- package/chunk-PGDJ2ZZ6.js +0 -4810
- package/chunk-PGDJ2ZZ6.js.map +0 -7
- package/chunk-POVPHE2F.js +0 -1864
- package/chunk-POVPHE2F.js.map +0 -7
- package/chunk-PTVPYZHU.js +0 -72
- package/chunk-PTVPYZHU.js.map +0 -7
- package/chunk-SXBMMXTY.js +0 -11837
- package/chunk-SXBMMXTY.js.map +0 -7
- package/chunk-UZZ72UON.js +0 -152
- package/chunk-UZZ72UON.js.map +0 -7
- package/chunk-V7KRP7IO.js +0 -481
- package/chunk-V7KRP7IO.js.map +0 -7
- package/chunk-WVNUD273.js +0 -83
- package/chunk-WVNUD273.js.map +0 -7
- package/chunk-WYPE3MV4.js +0 -62
- package/chunk-WYPE3MV4.js.map +0 -7
- package/chunk-ZRNJWPYC.js +0 -37
- package/chunk-ZRNJWPYC.js.map +0 -7
- package/cli-package.json +0 -107
- package/config-3QQHUYLI.js +0 -179
- package/config-3QQHUYLI.js.map +0 -7
- package/devtools-5BBQJTDW.js +0 -16682
- package/devtools-5BBQJTDW.js.map +0 -7
- package/exec-C6GK336U.js +0 -50
- package/exec-C6GK336U.js.map +0 -7
- package/gui-IQ4M4K5X.js +0 -46
- package/gui-IQ4M4K5X.js.map +0 -7
- package/gui-assets/favicon.ico +0 -0
- package/gui-assets/fonts/geist-mono.ttf +0 -0
- package/gui-assets/fonts/inter.ttf +0 -0
- package/gui-assets/images/folder.png +0 -0
- package/gui-assets/index.html +0 -34
- package/gui-assets/index.js +0 -1549
- package/gui-assets/index.js.map +0 -7
- package/gui-assets/main.css +0 -1
- package/help-R6TSKVEA.js +0 -25
- package/help-R6TSKVEA.js.map +0 -7
- package/init-UTJGYULC.js +0 -25
- package/init-UTJGYULC.js.map +0 -7
- package/install-5XDTGLAU.js +0 -56
- package/install-5XDTGLAU.js.map +0 -7
- package/install-exec-VMPN3JE7.js +0 -28
- package/install-exec-VMPN3JE7.js.map +0 -7
- package/list-Q7IANZ3I.js +0 -129
- package/list-Q7IANZ3I.js.map +0 -7
- package/login-VHJEIRVU.js +0 -36
- package/login-VHJEIRVU.js.map +0 -7
- package/logout-5KMCSSR4.js +0 -36
- package/logout-5KMCSSR4.js.map +0 -7
- package/pkg-WYFDWETL.js +0 -364
- package/pkg-WYFDWETL.js.map +0 -7
- package/query-KP4F5D2Y.js +0 -117
- package/query-KP4F5D2Y.js.map +0 -7
- package/registry-client-package.json +0 -85
- package/reporter-LFGXWL6N.js +0 -18
- package/reporter-LFGXWL6N.js.map +0 -7
- package/rollback-remove-src-remove.js +0 -7398
- package/rollback-remove-src-remove.js.map +0 -7
- package/run-XNDZH72D.js +0 -68
- package/run-XNDZH72D.js.map +0 -7
- package/run-exec-NXA33NXJ.js +0 -41
- package/run-exec-NXA33NXJ.js.map +0 -7
- package/source-JWPG6PR3.js +0 -33
- package/source-JWPG6PR3.js.map +0 -7
- package/token-6IJNGEMI.js +0 -86
- package/token-6IJNGEMI.js.map +0 -7
- package/uninstall-MI7NFD27.js +0 -45
- package/uninstall-MI7NFD27.js.map +0 -7
- package/vlix.js +0 -25
- package/vlix.js.map +0 -7
- package/vlr.js +0 -25
- package/vlr.js.map +0 -7
- package/vlrx.js +0 -25
- package/vlrx.js.map +0 -7
- package/vlt.js +0 -24
- package/vlt.js.map +0 -7
- package/vlx.js +0 -25
- package/vlx.js.map +0 -7
- package/whoami-3IEXJF3U.js +0 -46
- package/whoami-3IEXJF3U.js.map +0 -7
- package/yoga.wasm +0 -0
package/chunk-UZZ72UON.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
var global = globalThis;
|
|
2
|
-
import {Buffer} from "node:buffer";
|
|
3
|
-
import {setImmediate, clearImmediate} from "node:timers";
|
|
4
|
-
import {createRequire as _vlt_createRequire} from 'node:module';
|
|
5
|
-
var require = _vlt_createRequire(import.meta.filename);
|
|
6
|
-
import {
|
|
7
|
-
source_default
|
|
8
|
-
} from "./chunk-JQRUGUZ3.js";
|
|
9
|
-
import {
|
|
10
|
-
isErrorRoot
|
|
11
|
-
} from "./chunk-ZRNJWPYC.js";
|
|
12
|
-
import {
|
|
13
|
-
defaultView
|
|
14
|
-
} from "./chunk-LNUDEBGP.js";
|
|
15
|
-
|
|
16
|
-
// ../../src/vlt/src/view.ts
|
|
17
|
-
var ViewClass = class {
|
|
18
|
-
options;
|
|
19
|
-
config;
|
|
20
|
-
constructor(options, config) {
|
|
21
|
-
this.options = options;
|
|
22
|
-
this.config = config;
|
|
23
|
-
}
|
|
24
|
-
// TODO: maybe have start() return a flag to say "i got this, do not
|
|
25
|
-
// run the command", for example to have the gui just open a web browser
|
|
26
|
-
// to the page relevant to a given thing, rather than computing it twice
|
|
27
|
-
start() {
|
|
28
|
-
}
|
|
29
|
-
done(_result, _opts) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
error(_err) {
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var isViewClass = (view) => typeof view === "function" && "prototype" in view && view.prototype instanceof ViewClass;
|
|
36
|
-
|
|
37
|
-
// ../../src/vlt/src/output.ts
|
|
38
|
-
import { formatWithOptions } from "node:util";
|
|
39
|
-
|
|
40
|
-
// ../../src/vlt/src/print-err.ts
|
|
41
|
-
var printErr = (err, usage, stderr2) => {
|
|
42
|
-
if (!isErrorRoot(err)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (isErrorRoot(err) && print(err, usage, stderr2)) return;
|
|
46
|
-
stderr2(err);
|
|
47
|
-
};
|
|
48
|
-
var print = (err, usage, stderr2) => {
|
|
49
|
-
switch (err.cause.code) {
|
|
50
|
-
case "EUSAGE": {
|
|
51
|
-
stderr2(usage().usage());
|
|
52
|
-
stderr2(`Error: ${err.message}`);
|
|
53
|
-
if (err.cause.found) {
|
|
54
|
-
stderr2(` Found: ${err.cause.found}`);
|
|
55
|
-
}
|
|
56
|
-
if (err.cause.validOptions) {
|
|
57
|
-
stderr2(
|
|
58
|
-
` Valid options: ${err.cause.validOptions.join(", ")}`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
case "ERESOLVE": {
|
|
64
|
-
stderr2(`Resolve Error: ${err.message}`);
|
|
65
|
-
const { url, from, response, spec } = err.cause;
|
|
66
|
-
if (url) {
|
|
67
|
-
stderr2(` While fetching: ${url}`);
|
|
68
|
-
}
|
|
69
|
-
if (spec) {
|
|
70
|
-
stderr2(` To satisfy: ${spec}`);
|
|
71
|
-
}
|
|
72
|
-
if (from) {
|
|
73
|
-
stderr2(` From: ${from}`);
|
|
74
|
-
}
|
|
75
|
-
if (response) {
|
|
76
|
-
stderr2("Response:", response);
|
|
77
|
-
}
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// ../../src/vlt/src/output.ts
|
|
85
|
-
var stdout = (...args) => console.log(...args);
|
|
86
|
-
var stderr = (...args) => console.error(...args);
|
|
87
|
-
var identity = (x) => x;
|
|
88
|
-
var getView = (conf, views) => {
|
|
89
|
-
const viewName = conf.values.view;
|
|
90
|
-
const viewFn = viewName === "inspect" ? identity : typeof views === "function" ? views : views && typeof views === "object" ? views[viewName] : identity;
|
|
91
|
-
if (!viewFn && conf.values.view !== defaultView) {
|
|
92
|
-
conf.values.view = defaultView;
|
|
93
|
-
process.env.VLT_VIEW = defaultView;
|
|
94
|
-
return getView(conf, views);
|
|
95
|
-
}
|
|
96
|
-
return viewFn ?? identity;
|
|
97
|
-
};
|
|
98
|
-
var startView = (conf, views, { start } = { start: Date.now() }) => {
|
|
99
|
-
const View = getView(conf, views);
|
|
100
|
-
const opts = { colors: conf.values.color ? source_default : void 0 };
|
|
101
|
-
if (isViewClass(View)) {
|
|
102
|
-
const view = new View(opts, conf);
|
|
103
|
-
view.start();
|
|
104
|
-
return {
|
|
105
|
-
onDone(r) {
|
|
106
|
-
return view.done(r, { time: Date.now() - start });
|
|
107
|
-
},
|
|
108
|
-
onError(err) {
|
|
109
|
-
view.error(err);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
} else {
|
|
113
|
-
return {
|
|
114
|
-
async onDone(r) {
|
|
115
|
-
if (r === void 0 && r !== null) return;
|
|
116
|
-
const res = await View(r, opts, conf);
|
|
117
|
-
return conf.values.view === "json" ? JSON.stringify(res, null, 2) : formatWithOptions(
|
|
118
|
-
{
|
|
119
|
-
colors: conf.values.color
|
|
120
|
-
},
|
|
121
|
-
res
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
var outputCommand = async (cliCommand, conf, { start } = { start: Date.now() }) => {
|
|
128
|
-
const { usage, views, command } = cliCommand;
|
|
129
|
-
if (conf.get("help")) {
|
|
130
|
-
return stdout(usage().usage());
|
|
131
|
-
}
|
|
132
|
-
const { onDone, onError } = startView(conf, views, { start });
|
|
133
|
-
try {
|
|
134
|
-
const output = await onDone(await command(conf));
|
|
135
|
-
if (output !== void 0) {
|
|
136
|
-
stdout(output);
|
|
137
|
-
}
|
|
138
|
-
} catch (err) {
|
|
139
|
-
onError?.(err);
|
|
140
|
-
process.exitCode ||= 1;
|
|
141
|
-
printErr(err, usage, stderr);
|
|
142
|
-
process.exit(process.exitCode);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export {
|
|
147
|
-
ViewClass,
|
|
148
|
-
stdout,
|
|
149
|
-
stderr,
|
|
150
|
-
outputCommand
|
|
151
|
-
};
|
|
152
|
-
//# sourceMappingURL=chunk-UZZ72UON.js.map
|
package/chunk-UZZ72UON.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/vlt/src/view.ts", "../../../src/vlt/src/output.ts", "../../../src/vlt/src/print-err.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ChalkInstance } from 'chalk'\nimport type { LoadedConfig } from './config/index.ts'\n\nexport type ViewOptions = { colors?: ChalkInstance }\n\n/**\n * The base class for all View classes\n *\n * Do not override the constructor, just provide start/done/error methods.\n *\n * These classes should be used as one or more of the exported views for\n * commands that need to know when the processing starts, handle errors in\n * various ways, etc. Fancy stuff.\n *\n * For simple use cases, usually better to create a {@link ViewFn} instead.\n */\nexport class ViewClass<T = unknown> {\n options: ViewOptions\n config: LoadedConfig\n\n constructor(options: ViewOptions, config: LoadedConfig) {\n this.options = options\n this.config = config\n }\n\n // TODO: maybe have start() return a flag to say \"i got this, do not\n // run the command\", for example to have the gui just open a web browser\n // to the page relevant to a given thing, rather than computing it twice\n start() {}\n done(_result: T, _opts: { time: number }): undefined | string {\n return\n }\n error(_err: unknown) {}\n}\n\nexport type ViewFn<T = unknown> = (\n result: T,\n options: ViewOptions,\n conf: LoadedConfig,\n) => unknown\n\nexport type View<T = unknown> = ViewFn<T> | typeof ViewClass<T>\n\nexport const isViewClass = <T = unknown>(\n view: View<T>,\n): view is typeof ViewClass<T> =>\n typeof view === 'function' &&\n 'prototype' in view &&\n view.prototype instanceof ViewClass\n\nexport type Views<T = unknown> = View<T> | Record<string, View<T>>\n", "import chalk from 'chalk'\nimport { formatWithOptions } from 'node:util'\nimport { defaultView } from './config/definition.ts'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { Command } from './index.ts'\nimport { printErr } from './print-err.ts'\nimport { isViewClass } from './view.ts'\nimport type { View, Views } from './view.ts'\n\n// TODO: make these have log levels etc\n// eslint-disable-next-line no-console\nexport const stdout = (...args: unknown[]) => console.log(...args)\n// eslint-disable-next-line no-console\nexport const stderr = (...args: unknown[]) => console.error(...args)\n\nconst identity = <T>(x: T): T => x\nexport const getView = <T>(\n conf: LoadedConfig,\n views?: Views<T>,\n): View<T> => {\n const viewName = conf.values.view\n\n const viewFn =\n viewName === 'inspect' ? identity\n : typeof views === 'function' ? views\n : views && typeof views === 'object' ? views[viewName]\n : identity\n\n // if the user specified a view that doesn't exist,\n // then set it back to the default, and try again.\n // This will fall back to identity if it's also missing.\n if (!viewFn && conf.values.view !== defaultView) {\n conf.values.view = defaultView\n process.env.VLT_VIEW = defaultView\n return getView(conf, views)\n }\n\n return viewFn ?? identity\n}\n\n/**\n * If the view is a View class, then instantiate and start it.\n * If it's a view function, then just define the onDone method.\n */\nexport const startView = <T>(\n conf: LoadedConfig,\n views?: Views<T>,\n { start }: { start: number } = { start: Date.now() },\n): {\n onDone: (\n result: T,\n ) => Promise<string | undefined> | string | undefined\n onError?: (err: unknown) => void\n} => {\n const View = getView<T>(conf, views)\n const opts = { colors: conf.values.color ? chalk : undefined }\n if (isViewClass(View)) {\n const view = new View(opts, conf)\n view.start()\n return {\n onDone(r) {\n return view.done(r, { time: Date.now() - start })\n },\n onError(err) {\n view.error(err)\n },\n }\n } else {\n return {\n async onDone(r): Promise<string | undefined> {\n if (r === undefined && r !== null) return\n const res = await View(r, opts, conf)\n return conf.values.view === 'json' ?\n JSON.stringify(res, null, 2)\n : formatWithOptions(\n {\n colors: conf.values.color,\n },\n res,\n )\n },\n }\n }\n}\n\n/**\n * Main export. Run the command appropriately, displaying output using\n * the user-requested view, or the default if the user requested a view\n * that is not defined for this command.\n */\nexport const outputCommand = async <T>(\n cliCommand: Command<T>,\n conf: LoadedConfig,\n { start }: { start: number } = { start: Date.now() },\n) => {\n const { usage, views, command } = cliCommand\n if (conf.get('help')) {\n return stdout(usage().usage())\n }\n const { onDone, onError } = startView(conf, views, { start })\n\n try {\n const output = await onDone(await command(conf))\n if (output !== undefined) {\n stdout(output)\n }\n } catch (err) {\n onError?.(err)\n process.exitCode ||= 1\n\n printErr(err, usage, stderr)\n\n process.exit(process.exitCode)\n }\n}\n", "import { isErrorRoot } from '@vltpkg/error-cause'\nimport type { ErrorWithCauseObject } from '@vltpkg/error-cause'\nimport type { CommandUsage } from './index.ts'\nimport type { Spec } from '@vltpkg/spec'\n\n// returns true if error was printed nicely already\nexport const printErr = (\n err: unknown,\n usage: CommandUsage,\n stderr: (...a: unknown[]) => void,\n) => {\n if (!isErrorRoot(err)) {\n // TODO: print _something_ here, but we're in weird broken territory\n // don't just dump it and flood the terminal, though, maybe sniff for code\n // message, stack, etc?\n return\n }\n if (isErrorRoot(err) && print(err, usage, stderr)) return\n stderr(err)\n}\n\nconst print = (\n err: ErrorWithCauseObject,\n usage: CommandUsage,\n stderr: (...a: unknown[]) => void,\n): boolean => {\n switch (err.cause.code) {\n case 'EUSAGE': {\n stderr(usage().usage())\n stderr(`Error: ${err.message}`)\n if (err.cause.found) {\n stderr(` Found: ${err.cause.found}`)\n }\n if (err.cause.validOptions) {\n stderr(\n ` Valid options: ${err.cause.validOptions.join(', ')}`,\n )\n }\n return true\n }\n\n case 'ERESOLVE': {\n stderr(`Resolve Error: ${err.message}`)\n const { url, from, response, spec } = err.cause\n if (url) {\n stderr(` While fetching: ${url}`)\n }\n if (spec) {\n stderr(` To satisfy: ${spec as string | Spec}`)\n }\n if (from) {\n stderr(` From: ${from}`)\n }\n if (response) {\n stderr('Response:', response)\n }\n return true\n }\n }\n\n return false\n}\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["stderr"]
|
|
7
|
-
}
|
package/chunk-V7KRP7IO.js
DELETED
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
var global = globalThis;
|
|
2
|
-
import {Buffer} from "node:buffer";
|
|
3
|
-
import {setImmediate, clearImmediate} from "node:timers";
|
|
4
|
-
import {createRequire as _vlt_createRequire} from 'node:module';
|
|
5
|
-
var require = _vlt_createRequire(import.meta.filename);
|
|
6
|
-
import {
|
|
7
|
-
Monorepo,
|
|
8
|
-
walkUp
|
|
9
|
-
} from "./chunk-JMGSFQ32.js";
|
|
10
|
-
import {
|
|
11
|
-
PathScurry
|
|
12
|
-
} from "./chunk-O7CDQZDW.js";
|
|
13
|
-
import {
|
|
14
|
-
PackageJson,
|
|
15
|
-
kIndent,
|
|
16
|
-
kNewline,
|
|
17
|
-
parse,
|
|
18
|
-
stringify
|
|
19
|
-
} from "./chunk-POVPHE2F.js";
|
|
20
|
-
import {
|
|
21
|
-
error
|
|
22
|
-
} from "./chunk-ZRNJWPYC.js";
|
|
23
|
-
import {
|
|
24
|
-
XDG,
|
|
25
|
-
commands,
|
|
26
|
-
definition,
|
|
27
|
-
getCommand,
|
|
28
|
-
isRecordField,
|
|
29
|
-
recordFields
|
|
30
|
-
} from "./chunk-LNUDEBGP.js";
|
|
31
|
-
|
|
32
|
-
// ../../src/vlt/src/config/index.ts
|
|
33
|
-
import { readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
34
|
-
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
35
|
-
import { homedir } from "node:os";
|
|
36
|
-
import { dirname, resolve } from "node:path";
|
|
37
|
-
|
|
38
|
-
// ../../src/vlt/src/config/merge.ts
|
|
39
|
-
var merge = (base, add) => Object.fromEntries(
|
|
40
|
-
Object.entries(base).map(([k, v]) => [
|
|
41
|
-
k,
|
|
42
|
-
add[k] === void 0 ? v : Array.isArray(v) && Array.isArray(add[k]) ? [.../* @__PURE__ */ new Set([...v, ...add[k]])] : Array.isArray(v) || Array.isArray(add[k]) ? add[k] : !!v && typeof v === "object" && !!add[k] && typeof add[k] === "object" ? merge(v, add[k]) : add[k]
|
|
43
|
-
]).concat(
|
|
44
|
-
// already merged together if existing, so just get new additions
|
|
45
|
-
Object.entries(add).filter(([k]) => base[k] === void 0)
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
// ../../src/vlt/src/config/index.ts
|
|
50
|
-
var reducePairs = (pairs) => {
|
|
51
|
-
const record = {};
|
|
52
|
-
for (const kv of pairs) {
|
|
53
|
-
const eq = kv.indexOf("=");
|
|
54
|
-
if (eq === -1) record[kv] = "";
|
|
55
|
-
else {
|
|
56
|
-
const key = kv.substring(0, eq);
|
|
57
|
-
const val = kv.substring(eq + 1);
|
|
58
|
-
record[key] = val;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return record;
|
|
62
|
-
};
|
|
63
|
-
var isRecordFieldValue = (k, v) => Array.isArray(v) && recordFields.includes(k);
|
|
64
|
-
var pairsToRecords = (obj) => {
|
|
65
|
-
return Object.fromEntries(
|
|
66
|
-
Object.entries(obj).map(([k, v]) => [
|
|
67
|
-
k,
|
|
68
|
-
k === "command" && v && typeof v === "object" ? Object.fromEntries(
|
|
69
|
-
Object.entries(v).map(([k2, v2]) => [
|
|
70
|
-
k2,
|
|
71
|
-
pairsToRecords(v2)
|
|
72
|
-
])
|
|
73
|
-
) : isRecordFieldValue(k, v) ? reducePairs(v) : v
|
|
74
|
-
])
|
|
75
|
-
// hard cast because TS can't see through the entries/fromEntries
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
var recordsToPairs = (obj) => {
|
|
79
|
-
return Object.fromEntries(
|
|
80
|
-
Object.entries(obj).filter(
|
|
81
|
-
([k]) => !(k === "scurry" || k === "packageJson" || k === "monorepo" || k === "projectRoot")
|
|
82
|
-
).map(([k, v]) => [
|
|
83
|
-
k,
|
|
84
|
-
k === "command" && v && typeof v === "object" ? recordsToPairs(v) : !v || typeof v !== "object" || Array.isArray(v) || !isRecordField(k) ? v : Object.entries(v).map(([k2, v2]) => `${k2}=${v2}`)
|
|
85
|
-
])
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
var kRecord = Symbol("parsed key=value record");
|
|
89
|
-
var exists = (f) => lstat(f).then(
|
|
90
|
-
() => true,
|
|
91
|
-
() => false
|
|
92
|
-
);
|
|
93
|
-
var home = homedir();
|
|
94
|
-
var xdg = new XDG("vlt");
|
|
95
|
-
var Config = class _Config {
|
|
96
|
-
/**
|
|
97
|
-
* The {@link https://npmjs.com/jackspeak | JackSpeak} object
|
|
98
|
-
* representing vlt's configuration
|
|
99
|
-
*/
|
|
100
|
-
jack;
|
|
101
|
-
stringifyOptions = { [kIndent]: " ", [kNewline]: "\n" };
|
|
102
|
-
configFiles = {};
|
|
103
|
-
/**
|
|
104
|
-
* Parsed values in effect
|
|
105
|
-
*/
|
|
106
|
-
values;
|
|
107
|
-
/**
|
|
108
|
-
* Command-specific config values
|
|
109
|
-
*/
|
|
110
|
-
commandValues = {};
|
|
111
|
-
/**
|
|
112
|
-
* A flattened object of the parsed configuration
|
|
113
|
-
*/
|
|
114
|
-
get options() {
|
|
115
|
-
if (this.#options) return this.#options;
|
|
116
|
-
const scurry = new PathScurry(this.projectRoot);
|
|
117
|
-
const packageJson = new PackageJson();
|
|
118
|
-
this.#options = Object.assign(
|
|
119
|
-
pairsToRecords(this.parse().values),
|
|
120
|
-
{
|
|
121
|
-
projectRoot: this.projectRoot,
|
|
122
|
-
scurry,
|
|
123
|
-
packageJson,
|
|
124
|
-
monorepo: Monorepo.maybeLoad(this.projectRoot, {
|
|
125
|
-
scurry,
|
|
126
|
-
packageJson
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
return this.#options;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Reset the options value, optionally setting a new project root
|
|
134
|
-
* to recalculate the options.
|
|
135
|
-
*/
|
|
136
|
-
resetOptions(projectRoot = process.cwd()) {
|
|
137
|
-
this.projectRoot = projectRoot;
|
|
138
|
-
this.#options = void 0;
|
|
139
|
-
}
|
|
140
|
-
// memoized options() getter value
|
|
141
|
-
#options;
|
|
142
|
-
/**
|
|
143
|
-
* positional arguments to the vlt process
|
|
144
|
-
*/
|
|
145
|
-
positionals;
|
|
146
|
-
/**
|
|
147
|
-
* The root of the project where a vlt.json, vlt-workspaces.json,
|
|
148
|
-
* package.json, or .git was found. Not necessarily the `process.cwd()`,
|
|
149
|
-
* though that is the default location.
|
|
150
|
-
*
|
|
151
|
-
* Never walks up as far as `$HOME`. So for example, if a project is in
|
|
152
|
-
* `~/projects/xyz`, then the highest dir it will check is `~/projects`
|
|
153
|
-
*/
|
|
154
|
-
projectRoot;
|
|
155
|
-
/**
|
|
156
|
-
* `Record<alias, canonical name>` to dereference command aliases.
|
|
157
|
-
*/
|
|
158
|
-
commands;
|
|
159
|
-
/**
|
|
160
|
-
* Which command name to use for overriding with command-specific values,
|
|
161
|
-
* determined from the argv when parse() is called.
|
|
162
|
-
*/
|
|
163
|
-
command;
|
|
164
|
-
constructor(jack = definition, projectRoot = process.cwd()) {
|
|
165
|
-
this.projectRoot = projectRoot;
|
|
166
|
-
this.commands = commands;
|
|
167
|
-
this.jack = jack;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Parse the arguments and set configuration and positionals accordingly.
|
|
171
|
-
*/
|
|
172
|
-
parse(args = process.argv) {
|
|
173
|
-
if (isParsed(this)) return this;
|
|
174
|
-
this.jack.loadEnvDefaults();
|
|
175
|
-
const p = this.jack.parseRaw(args);
|
|
176
|
-
const fallback = getCommand(p.values["fallback-command"]);
|
|
177
|
-
this.command = getCommand(p.positionals[0]);
|
|
178
|
-
const cmdOrFallback = this.command ?? fallback;
|
|
179
|
-
const cmdSpecific = cmdOrFallback && this.commandValues[cmdOrFallback];
|
|
180
|
-
if (cmdSpecific) {
|
|
181
|
-
this.jack.setConfigValues(recordsToPairs(cmdSpecific));
|
|
182
|
-
}
|
|
183
|
-
this.jack.applyDefaults(p);
|
|
184
|
-
this.jack.writeEnv(p);
|
|
185
|
-
if (this.command) p.positionals.shift();
|
|
186
|
-
else this.command = getCommand(p.values["fallback-command"]);
|
|
187
|
-
Object.assign(this, p);
|
|
188
|
-
if (!isParsed(this)) throw error("failed to parse config");
|
|
189
|
-
return this;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Get a `key=value` list option value as an object.
|
|
193
|
-
*
|
|
194
|
-
* For example, a list option with a vlaue of `['key=value', 'xyz=as=df' ]`
|
|
195
|
-
* would be returned as `{key: 'value', xyz: 'as=df'}`
|
|
196
|
-
*
|
|
197
|
-
* Results are memoized, so subsequent calls for the same key will return the
|
|
198
|
-
* same object. If new strings are added to the list, then the memoized value
|
|
199
|
-
* is *not* updated, so only use once configurations have been fully loaded.
|
|
200
|
-
*
|
|
201
|
-
* If the config value is not set at all, an empty object is returned.
|
|
202
|
-
*/
|
|
203
|
-
getRecord(k) {
|
|
204
|
-
const pairs = this.get(k);
|
|
205
|
-
if (!pairs) return {};
|
|
206
|
-
if (pairs[kRecord]) return pairs[kRecord];
|
|
207
|
-
const kv = pairs.reduce((kv2, pair) => {
|
|
208
|
-
const eq = pair.indexOf("=");
|
|
209
|
-
if (eq === -1) return kv2;
|
|
210
|
-
const key = pair.substring(0, eq);
|
|
211
|
-
const val = pair.substring(eq + 1);
|
|
212
|
-
kv2[key] = val;
|
|
213
|
-
return kv2;
|
|
214
|
-
}, {});
|
|
215
|
-
Object.assign(pairs, { [kRecord]: kv });
|
|
216
|
-
return kv;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Get a configuration value.
|
|
220
|
-
*
|
|
221
|
-
* Note: `key=value` pair configs are returned as a string array. To get them
|
|
222
|
-
* as an object, use {@link Config#getRecord}.
|
|
223
|
-
*/
|
|
224
|
-
get(k) {
|
|
225
|
-
return (this.values ?? this.parse().values)[k];
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Write the config values to the user or project config file.
|
|
229
|
-
*/
|
|
230
|
-
async writeConfigFile(which, values) {
|
|
231
|
-
const f = this.getFilename(which);
|
|
232
|
-
await mkdir(dirname(f), { recursive: true });
|
|
233
|
-
const vals = Object.assign(
|
|
234
|
-
pairsToRecords(values),
|
|
235
|
-
this.stringifyOptions
|
|
236
|
-
);
|
|
237
|
-
await writeFile(f, stringify(vals));
|
|
238
|
-
this.configFiles[f] = vals;
|
|
239
|
-
return values;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Fold in the provided fields with the existing properties
|
|
243
|
-
* in the config file.
|
|
244
|
-
*/
|
|
245
|
-
async addConfigToFile(which, values) {
|
|
246
|
-
const f = this.getFilename(which);
|
|
247
|
-
return this.writeConfigFile(
|
|
248
|
-
which,
|
|
249
|
-
merge(await this.#maybeLoadConfigFile(f) ?? {}, values)
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* if the file exists, parse and load it. returns object if data was
|
|
254
|
-
* loaded, or undefined if not.
|
|
255
|
-
*/
|
|
256
|
-
async #maybeLoadConfigFile(file) {
|
|
257
|
-
const result = await this.#readConfigFile(file);
|
|
258
|
-
if (result) {
|
|
259
|
-
try {
|
|
260
|
-
const { command, ...values } = recordsToPairs(result);
|
|
261
|
-
if (command) {
|
|
262
|
-
for (const [c, opts] of Object.entries(command)) {
|
|
263
|
-
const cmd = getCommand(c);
|
|
264
|
-
if (cmd) {
|
|
265
|
-
this.commandValues[cmd] = merge(
|
|
266
|
-
this.commandValues[cmd] ?? {},
|
|
267
|
-
opts
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
this.jack.setConfigValues(values, file);
|
|
273
|
-
return result;
|
|
274
|
-
} catch (er) {
|
|
275
|
-
throw error("failed to load config values from file", {
|
|
276
|
-
path: file,
|
|
277
|
-
cause: er
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
async #readConfigFile(file) {
|
|
283
|
-
if (this.configFiles[file]) return this.configFiles[file];
|
|
284
|
-
const data = await readFile(file, "utf8").catch(() => {
|
|
285
|
-
});
|
|
286
|
-
if (!data) return void 0;
|
|
287
|
-
let result;
|
|
288
|
-
try {
|
|
289
|
-
result = parse(data);
|
|
290
|
-
if (result && typeof result === "object") {
|
|
291
|
-
if (result[kIndent] !== void 0)
|
|
292
|
-
this.stringifyOptions[kIndent] = result[kIndent];
|
|
293
|
-
if (result[kNewline] !== void 0)
|
|
294
|
-
this.stringifyOptions[kNewline] = result[kNewline];
|
|
295
|
-
}
|
|
296
|
-
} catch (er) {
|
|
297
|
-
throw error("failed to parse vlt config file", {
|
|
298
|
-
path: file,
|
|
299
|
-
cause: er
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
this.configFiles[file] = result;
|
|
303
|
-
return result;
|
|
304
|
-
}
|
|
305
|
-
getFilename(which = "project") {
|
|
306
|
-
return which === "user" ? xdg.config("vlt.json") : resolve(this.projectRoot, "vlt.json");
|
|
307
|
-
}
|
|
308
|
-
async deleteConfigKeys(which, fields) {
|
|
309
|
-
const file = this.getFilename(which);
|
|
310
|
-
const data = await this.#maybeLoadConfigFile(file);
|
|
311
|
-
if (!data) {
|
|
312
|
-
rmSync(file, { force: true });
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
let didSomething = false;
|
|
316
|
-
for (const f of fields) {
|
|
317
|
-
const [key, ...sk] = f.split(".");
|
|
318
|
-
const subs = sk.join(".");
|
|
319
|
-
const k = key;
|
|
320
|
-
const v = data[k];
|
|
321
|
-
if (v === void 0) continue;
|
|
322
|
-
if (subs && v && typeof v === "object") {
|
|
323
|
-
if (Array.isArray(v)) {
|
|
324
|
-
const i = v.findIndex(
|
|
325
|
-
(subvalue) => subvalue.startsWith(`${subs}=`)
|
|
326
|
-
);
|
|
327
|
-
if (i !== -1) {
|
|
328
|
-
v.splice(i, 1);
|
|
329
|
-
if (v.length === 0) delete data[k];
|
|
330
|
-
didSomething = true;
|
|
331
|
-
}
|
|
332
|
-
} else {
|
|
333
|
-
if (v[subs] !== void 0) {
|
|
334
|
-
delete v[subs];
|
|
335
|
-
if (Object.keys(v).length === 0) delete data[k];
|
|
336
|
-
didSomething = true;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
} else {
|
|
340
|
-
didSomething = true;
|
|
341
|
-
delete data[k];
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
const d = stringify(data);
|
|
345
|
-
if (d.trim() === "{}") {
|
|
346
|
-
rmSync(file, { force: true });
|
|
347
|
-
} else {
|
|
348
|
-
writeFileSync(file, stringify(data));
|
|
349
|
-
}
|
|
350
|
-
return didSomething;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Edit the user or project configuration file.
|
|
354
|
-
*
|
|
355
|
-
* If the file isn't present, then it starts with `{}` so the user has
|
|
356
|
-
* something to work with.
|
|
357
|
-
*
|
|
358
|
-
* If the result is not valid, or no config settings are contained in the
|
|
359
|
-
* file after editing, then it's restored to what it was before, which might
|
|
360
|
-
* mean deleting the file.
|
|
361
|
-
*/
|
|
362
|
-
async editConfigFile(which, edit) {
|
|
363
|
-
const file = this.getFilename(which);
|
|
364
|
-
const backup = this.configFiles[file];
|
|
365
|
-
if (!backup) {
|
|
366
|
-
writeFileSync(file, "{\n\n}\n");
|
|
367
|
-
}
|
|
368
|
-
let valid = false;
|
|
369
|
-
try {
|
|
370
|
-
await edit(file);
|
|
371
|
-
const res = parse(readFileSync(file, "utf8"));
|
|
372
|
-
if (!res || typeof res !== "object" || Array.isArray(res)) {
|
|
373
|
-
throw error("Invalid configuration, expected object", {
|
|
374
|
-
path: file,
|
|
375
|
-
found: res
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
if (Object.keys(res).length === 0) {
|
|
379
|
-
delete this.configFiles[file];
|
|
380
|
-
rmSync(file, { force: true });
|
|
381
|
-
} else {
|
|
382
|
-
this.jack.setConfigValues(recordsToPairs(res));
|
|
383
|
-
this.configFiles[file] = res;
|
|
384
|
-
}
|
|
385
|
-
valid = true;
|
|
386
|
-
} finally {
|
|
387
|
-
if (!valid) {
|
|
388
|
-
if (backup) {
|
|
389
|
-
writeFileSync(file, stringify(backup));
|
|
390
|
-
} else {
|
|
391
|
-
rmSync(file, { force: true });
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Find the local config file and load both it and the user-level config in
|
|
398
|
-
* the XDG config home.
|
|
399
|
-
*
|
|
400
|
-
* Note: if working in a workspaces monorepo, then the vlt.json file MUST
|
|
401
|
-
* be in the same folder as the vlt-workspaces.json file, because we stop
|
|
402
|
-
* looking when we find either one.
|
|
403
|
-
*/
|
|
404
|
-
async loadConfigFile() {
|
|
405
|
-
const userConfig = xdg.config("vlt.json");
|
|
406
|
-
await this.#maybeLoadConfigFile(userConfig);
|
|
407
|
-
let lastKnownRoot = resolve(this.projectRoot);
|
|
408
|
-
for (const dir of walkUp(this.projectRoot)) {
|
|
409
|
-
if (dir === home) break;
|
|
410
|
-
const projectConfig = resolve(dir, "vlt.json");
|
|
411
|
-
if (projectConfig === userConfig) break;
|
|
412
|
-
if (await exists(projectConfig) && await this.#maybeLoadConfigFile(projectConfig)) {
|
|
413
|
-
lastKnownRoot = dir;
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
const [hasPackage, hasModules, hasWorkspaces, hasGit] = await Promise.all([
|
|
417
|
-
exists(resolve(dir, "package.json")),
|
|
418
|
-
exists(resolve(dir, "node_modules")),
|
|
419
|
-
exists(resolve(dir, "vlt-workspaces.json")),
|
|
420
|
-
exists(resolve(dir, ".git"))
|
|
421
|
-
]);
|
|
422
|
-
if (hasPackage || hasModules || hasWorkspaces) {
|
|
423
|
-
lastKnownRoot = dir;
|
|
424
|
-
}
|
|
425
|
-
if (hasWorkspaces || hasGit) {
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
this.projectRoot = lastKnownRoot;
|
|
430
|
-
return this;
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Determine whether we should use colors in the output. Update
|
|
434
|
-
* chalk appropriately.
|
|
435
|
-
*
|
|
436
|
-
* Implicitly calls this.parse() if it not parsed already.
|
|
437
|
-
*/
|
|
438
|
-
async loadColor() {
|
|
439
|
-
const c = this.get("color");
|
|
440
|
-
const chalk = (await import("./source-JWPG6PR3.js")).default;
|
|
441
|
-
let color;
|
|
442
|
-
if (process.env.NO_COLOR !== "1" && (c === true || c === void 0 && chalk.level > 0)) {
|
|
443
|
-
color = true;
|
|
444
|
-
chalk.level = Math.max(chalk.level, 1);
|
|
445
|
-
process.env.FORCE_COLOR = String(chalk.level);
|
|
446
|
-
delete process.env.NO_COLOR;
|
|
447
|
-
} else {
|
|
448
|
-
color = false;
|
|
449
|
-
chalk.level = 0;
|
|
450
|
-
process.env.FORCE_COLOR = "0";
|
|
451
|
-
process.env.NO_COLOR = "1";
|
|
452
|
-
}
|
|
453
|
-
const { values = this.parse().values } = this;
|
|
454
|
-
values.color = color;
|
|
455
|
-
return this;
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* cache of the loaded config
|
|
459
|
-
*/
|
|
460
|
-
static #loaded;
|
|
461
|
-
/**
|
|
462
|
-
* Load the configuration and return a Promise to a
|
|
463
|
-
* {@link Config} object
|
|
464
|
-
*/
|
|
465
|
-
static async load(projectRoot = process.cwd(), argv = process.argv, reload = false) {
|
|
466
|
-
if (this.#loaded && !reload) return this.#loaded;
|
|
467
|
-
const a = new _Config(definition, projectRoot);
|
|
468
|
-
const b = await a.loadConfigFile();
|
|
469
|
-
const c = await b.parse(argv).loadColor();
|
|
470
|
-
this.#loaded = c;
|
|
471
|
-
return this.#loaded;
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
var isParsed = (c) => !!(c.values && c.positionals && c.command);
|
|
475
|
-
|
|
476
|
-
export {
|
|
477
|
-
pairsToRecords,
|
|
478
|
-
recordsToPairs,
|
|
479
|
-
Config
|
|
480
|
-
};
|
|
481
|
-
//# sourceMappingURL=chunk-V7KRP7IO.js.map
|