varlock 0.0.0 → 0.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/README.md +46 -0
- package/bin/cli.js +2 -0
- package/dist/auto-load.d.ts +2 -0
- package/dist/auto-load.js +11 -0
- package/dist/auto-load.js.map +1 -0
- package/dist/chunk-33ROL4J5.js +1013 -0
- package/dist/chunk-33ROL4J5.js.map +1 -0
- package/dist/chunk-35HGPX6I.js +98 -0
- package/dist/chunk-35HGPX6I.js.map +1 -0
- package/dist/chunk-7UQXFWKN.js +82 -0
- package/dist/chunk-7UQXFWKN.js.map +1 -0
- package/dist/chunk-B4UBSMSZ.js +142 -0
- package/dist/chunk-B4UBSMSZ.js.map +1 -0
- package/dist/chunk-BRP5MZU6.js +70 -0
- package/dist/chunk-BRP5MZU6.js.map +1 -0
- package/dist/chunk-BS3AGAHF.js +53 -0
- package/dist/chunk-BS3AGAHF.js.map +1 -0
- package/dist/chunk-CPA2D42B.js +146 -0
- package/dist/chunk-CPA2D42B.js.map +1 -0
- package/dist/chunk-DAZNZPLN.js +675 -0
- package/dist/chunk-DAZNZPLN.js.map +1 -0
- package/dist/chunk-EMPXU5TW.js +681 -0
- package/dist/chunk-EMPXU5TW.js.map +1 -0
- package/dist/chunk-HZADDTO5.js +2310 -0
- package/dist/chunk-HZADDTO5.js.map +1 -0
- package/dist/chunk-LQZ6ICSS.js +21 -0
- package/dist/chunk-LQZ6ICSS.js.map +1 -0
- package/dist/chunk-NZDUC7Q3.js +69 -0
- package/dist/chunk-NZDUC7Q3.js.map +1 -0
- package/dist/chunk-QCC3P7BT.js +39 -0
- package/dist/chunk-QCC3P7BT.js.map +1 -0
- package/dist/chunk-QTYVZQSF.js +225 -0
- package/dist/chunk-QTYVZQSF.js.map +1 -0
- package/dist/chunk-R53MTEAM.js +32 -0
- package/dist/chunk-R53MTEAM.js.map +1 -0
- package/dist/chunk-RCHPHIHX.js +15 -0
- package/dist/chunk-RCHPHIHX.js.map +1 -0
- package/dist/chunk-XN24GZXQ.js +35 -0
- package/dist/chunk-XN24GZXQ.js.map +1 -0
- package/dist/cli/cli-executable.d.ts +2 -0
- package/dist/cli/cli-executable.js +206 -0
- package/dist/cli/cli-executable.js.map +1 -0
- package/dist/doctor.command-N5JAIXRM.js +6 -0
- package/dist/doctor.command-N5JAIXRM.js.map +1 -0
- package/dist/dotenv-compat.d.ts +2 -0
- package/dist/dotenv-compat.js +11 -0
- package/dist/dotenv-compat.js.map +1 -0
- package/dist/en-US-TSGNDI2P.js +22 -0
- package/dist/en-US-TSGNDI2P.js.map +1 -0
- package/dist/encrypt.command-VGJABHNK.js +6 -0
- package/dist/encrypt.command-VGJABHNK.js.map +1 -0
- package/dist/help.command-YZDL2VEQ.js +5 -0
- package/dist/help.command-YZDL2VEQ.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/init.command-7BSALNL5.js +10 -0
- package/dist/init.command-7BSALNL5.js.map +1 -0
- package/dist/ja-JP-UBPCQAAD.js +22 -0
- package/dist/ja-JP-UBPCQAAD.js.map +1 -0
- package/dist/load.command-4MJR5J43.js +9 -0
- package/dist/load.command-4MJR5J43.js.map +1 -0
- package/dist/login.command-22RUZJLR.js +7 -0
- package/dist/login.command-22RUZJLR.js.map +1 -0
- package/dist/opt-out.command-Y4KUQ6PQ.js +5 -0
- package/dist/opt-out.command-Y4KUQ6PQ.js.map +1 -0
- package/dist/run.command-ASKXIWBC.js +9 -0
- package/dist/run.command-ASKXIWBC.js.map +1 -0
- package/package.json +50 -3
- package/notes.md +0 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { define } from './chunk-33ROL4J5.js';
|
|
2
|
+
import { __name } from './chunk-XN24GZXQ.js';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
|
|
8
|
+
var commandSpec = define({
|
|
9
|
+
name: "opt-out",
|
|
10
|
+
description: "Opt out of anonymous usage analytics"
|
|
11
|
+
});
|
|
12
|
+
var commandFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
13
|
+
const configDir = join(homedir(), ".varlock");
|
|
14
|
+
const configPath = join(configDir, "config.json");
|
|
15
|
+
try {
|
|
16
|
+
if (!existsSync(configDir)) {
|
|
17
|
+
await mkdir(configDir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
let config = {};
|
|
20
|
+
if (existsSync(configPath)) {
|
|
21
|
+
const configContent = await readFile(configPath, "utf-8");
|
|
22
|
+
config = JSON.parse(configContent);
|
|
23
|
+
}
|
|
24
|
+
config = {
|
|
25
|
+
...config,
|
|
26
|
+
analytics_opt_out: true
|
|
27
|
+
};
|
|
28
|
+
await writeFile(configPath, JSON.stringify(config, null, 2));
|
|
29
|
+
console.log("\u2705 Successfully opted out of anonymous usage analytics");
|
|
30
|
+
console.log("This setting is stored in:", configPath);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Failed to opt out of analytics:", error);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}, "commandFn");
|
|
36
|
+
|
|
37
|
+
export { commandFn, commandSpec };
|
|
38
|
+
//# sourceMappingURL=chunk-QCC3P7BT.js.map
|
|
39
|
+
//# sourceMappingURL=chunk-QCC3P7BT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/opt-out.command.ts"],"names":[],"mappings":";;;;;;;AAQO,IAAM,cAAc,MAAO,CAAA;AAAA,EAChC,IAAM,EAAA,SAAA;AAAA,EACN,WAAa,EAAA;AACf,CAAC;AAEY,IAAA,SAAA,iCAA6D,GAAQ,KAAA;AAChF,EAAA,MAAM,SAAY,GAAA,IAAA,CAAK,OAAQ,EAAA,EAAG,UAAU,CAAA;AAC5C,EAAM,MAAA,UAAA,GAAa,IAAK,CAAA,SAAA,EAAW,aAAa,CAAA;AAEhD,EAAI,IAAA;AAEF,IAAI,IAAA,CAAC,UAAW,CAAA,SAAS,CAAG,EAAA;AAC1B,MAAA,MAAM,KAAM,CAAA,SAAA,EAAW,EAAE,SAAA,EAAW,MAAM,CAAA;AAAA;AAI5C,IAAA,IAAI,SAAS,EAAC;AACd,IAAI,IAAA,UAAA,CAAW,UAAU,CAAG,EAAA;AAC1B,MAAA,MAAM,aAAgB,GAAA,MAAM,QAAS,CAAA,UAAA,EAAY,OAAO,CAAA;AACxD,MAAS,MAAA,GAAA,IAAA,CAAK,MAAM,aAAa,CAAA;AAAA;AAInC,IAAS,MAAA,GAAA;AAAA,MACP,GAAG,MAAA;AAAA,MACH,iBAAmB,EAAA;AAAA,KACrB;AAGA,IAAA,MAAM,UAAU,UAAY,EAAA,IAAA,CAAK,UAAU,MAAQ,EAAA,IAAA,EAAM,CAAC,CAAC,CAAA;AAE3D,IAAA,OAAA,CAAQ,IAAI,4DAAuD,CAAA;AACnE,IAAQ,OAAA,CAAA,GAAA,CAAI,8BAA8B,UAAU,CAAA;AAAA,WAC7C,KAAO,EAAA;AACd,IAAQ,OAAA,CAAA,KAAA,CAAM,mCAAmC,KAAK,CAAA;AACtD,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB,CAhCmE,EAAA,WAAA","file":"chunk-QCC3P7BT.js","sourcesContent":["import { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport { mkdir, writeFile, readFile } from 'node:fs/promises';\nimport { existsSync } from 'node:fs';\nimport { define } from 'gunshi';\nimport { TypedGunshiCommandFn } from '../helpers/gunshi-type-utils';\n\n\nexport const commandSpec = define({\n name: 'opt-out',\n description: 'Opt out of anonymous usage analytics',\n});\n\nexport const commandFn: TypedGunshiCommandFn<typeof commandSpec> = async (ctx) => {\n const configDir = join(homedir(), '.varlock');\n const configPath = join(configDir, 'config.json');\n\n try {\n // Create .varlock directory if it doesn't exist\n if (!existsSync(configDir)) {\n await mkdir(configDir, { recursive: true });\n }\n\n // Read existing config if it exists\n let config = {};\n if (existsSync(configPath)) {\n const configContent = await readFile(configPath, 'utf-8');\n config = JSON.parse(configContent);\n }\n\n // Update config with opt-out setting\n config = {\n ...config,\n analytics_opt_out: true,\n };\n\n // Write updated config\n await writeFile(configPath, JSON.stringify(config, null, 2));\n\n console.log('✅ Successfully opted out of anonymous usage analytics');\n console.log('This setting is stored in:', configPath);\n } catch (error) {\n console.error('Failed to opt out of analytics:', error);\n process.exit(1);\n }\n};\n"]}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { my_dash_default, loadEnvGraph } from './chunk-HZADDTO5.js';
|
|
2
|
+
import { ansis_default } from './chunk-7UQXFWKN.js';
|
|
3
|
+
import { __name } from './chunk-XN24GZXQ.js';
|
|
4
|
+
|
|
5
|
+
// src/lib/redaction-helpers.ts
|
|
6
|
+
var UNMASK_STR = "\u{1F441}";
|
|
7
|
+
function redactString(valStr, mode, hideLength = true) {
|
|
8
|
+
if (!valStr) return valStr;
|
|
9
|
+
const hiddenLength = hideLength ? 5 : valStr.length - 2;
|
|
10
|
+
const hiddenStr = "\u2592".repeat(hiddenLength);
|
|
11
|
+
if (mode === "show_last_2") {
|
|
12
|
+
return `${hiddenStr}${valStr.substring(valStr.length - 2, valStr.length)}`;
|
|
13
|
+
} else if (mode === "show_first_last") {
|
|
14
|
+
return `${valStr.substring(0, 1)}${hiddenStr}${valStr.substring(valStr.length - 1, valStr.length)}`;
|
|
15
|
+
} else {
|
|
16
|
+
return `${valStr.substring(0, 2)}${hiddenStr}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
__name(redactString, "redactString");
|
|
20
|
+
var sensitiveSecretsMap = {};
|
|
21
|
+
var redactorFindReplace;
|
|
22
|
+
function resetRedactionMap(graph) {
|
|
23
|
+
sensitiveSecretsMap = {};
|
|
24
|
+
for (const itemKey in graph.configSchema) {
|
|
25
|
+
const item = graph.configSchema[itemKey];
|
|
26
|
+
if (item.isSensitive && item.resolvedValue && my_dash_default.isString(item.resolvedValue)) {
|
|
27
|
+
const redacted = redactString(item.resolvedValue);
|
|
28
|
+
if (redacted) sensitiveSecretsMap[item.resolvedValue] = redacted;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const findRegex = new RegExp(
|
|
32
|
+
[
|
|
33
|
+
`(${UNMASK_STR} )?`,
|
|
34
|
+
"(",
|
|
35
|
+
Object.keys(sensitiveSecretsMap).map((s) => s.replace(/[()[\]{}*+?^$|#.,/\\\s-]/g, "\\$&")).sort((a, b) => b.length - a.length).join("|"),
|
|
36
|
+
")",
|
|
37
|
+
`( ${UNMASK_STR})?`
|
|
38
|
+
].join(""),
|
|
39
|
+
"g"
|
|
40
|
+
);
|
|
41
|
+
const replaceFn = /* @__PURE__ */ __name((match, pre, val, post) => {
|
|
42
|
+
if (pre && post) return match;
|
|
43
|
+
return sensitiveSecretsMap[val];
|
|
44
|
+
}, "replaceFn");
|
|
45
|
+
redactorFindReplace = { find: findRegex, replace: replaceFn };
|
|
46
|
+
}
|
|
47
|
+
__name(resetRedactionMap, "resetRedactionMap");
|
|
48
|
+
var CONSOLE_METHODS = ["trace", "debug", "info", "log", "info", "warn", "error"];
|
|
49
|
+
var VarlockRedactor = {
|
|
50
|
+
/**
|
|
51
|
+
* Redacts senstive config values from any string/array/object/etc
|
|
52
|
+
*
|
|
53
|
+
* NOTE - must be used only after varlock has loaded config
|
|
54
|
+
* */
|
|
55
|
+
redactSensitiveConfig(o) {
|
|
56
|
+
if (!redactorFindReplace) return o;
|
|
57
|
+
if (!o) return o;
|
|
58
|
+
if (Array.isArray(o)) {
|
|
59
|
+
return o.map(VarlockRedactor.redactSensitiveConfig);
|
|
60
|
+
}
|
|
61
|
+
if (o && typeof o === "object" && Object.getPrototypeOf(o) === Object.prototype) {
|
|
62
|
+
try {
|
|
63
|
+
return JSON.parse(VarlockRedactor.redactSensitiveConfig(JSON.stringify(o)));
|
|
64
|
+
} catch (err) {
|
|
65
|
+
return o;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const type = typeof o;
|
|
69
|
+
if (type === "string" || type === "object" && Object.prototype.toString.call(o) === "[object String]") {
|
|
70
|
+
return o.replaceAll(redactorFindReplace.find, redactorFindReplace.replace);
|
|
71
|
+
}
|
|
72
|
+
return o;
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* utility to unmask a secret/sensitive value when logging to the console
|
|
76
|
+
* currently this only works on a single secret, not objects or aggregated strings
|
|
77
|
+
* */
|
|
78
|
+
unredact(secretStr) {
|
|
79
|
+
if (!globalThis._varlockOrigWriteToConsoleFn) return secretStr;
|
|
80
|
+
return `${UNMASK_STR} ${secretStr} ${UNMASK_STR}`;
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* patches global console methods to redact sensitive config
|
|
84
|
+
*
|
|
85
|
+
* NOTE - this may not be 100% foolproof depending on the platform
|
|
86
|
+
* */
|
|
87
|
+
patchConsole() {
|
|
88
|
+
if (!redactorFindReplace) return;
|
|
89
|
+
const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === "kWriteToConsole");
|
|
90
|
+
globalThis._varlockOrigWriteToConsoleFn ||= globalThis.console[kWriteToConsoleSymbol];
|
|
91
|
+
globalThis.console[kWriteToConsoleSymbol] = function() {
|
|
92
|
+
globalThis._varlockOrigWriteToConsoleFn.apply(this, [
|
|
93
|
+
arguments[0],
|
|
94
|
+
VarlockRedactor.redactSensitiveConfig(arguments[1]),
|
|
95
|
+
arguments[2]
|
|
96
|
+
]);
|
|
97
|
+
};
|
|
98
|
+
if (
|
|
99
|
+
// !console.log.toString().includes('[native code]') &&
|
|
100
|
+
!console.log._varlockPatchedFn
|
|
101
|
+
) {
|
|
102
|
+
for (const logMethodName of CONSOLE_METHODS) {
|
|
103
|
+
const originalLogMethod = globalThis.console[logMethodName];
|
|
104
|
+
const patchedFn = /* @__PURE__ */ __name(function() {
|
|
105
|
+
originalLogMethod.apply(this, Array.from(arguments).map(VarlockRedactor.redactSensitiveConfig));
|
|
106
|
+
}, "patchedFn");
|
|
107
|
+
patchedFn._varlockPatchedFn = true;
|
|
108
|
+
globalThis.console[logMethodName] = patchedFn;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* restore's original global console methods to stop redacting secrets
|
|
114
|
+
*
|
|
115
|
+
* (only needed during local development when switching settings on/off in a process that does not reload)
|
|
116
|
+
* */
|
|
117
|
+
unpatchConsole() {
|
|
118
|
+
if (!globalThis._varlockOrigWriteToConsoleFn) return;
|
|
119
|
+
const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === "kWriteToConsole");
|
|
120
|
+
globalThis.console[kWriteToConsoleSymbol] = globalThis._varlockOrigWriteToConsoleFn;
|
|
121
|
+
delete globalThis._varlockOrigWriteToConsoleFn;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/lib/formatting.ts
|
|
126
|
+
function applyMods(str, mods) {
|
|
127
|
+
if (!mods) return str;
|
|
128
|
+
if (my_dash_default.isArray(mods)) {
|
|
129
|
+
let modStr = str;
|
|
130
|
+
mods.forEach((mod) => {
|
|
131
|
+
modStr = ansis_default[mod](modStr);
|
|
132
|
+
});
|
|
133
|
+
return modStr;
|
|
134
|
+
}
|
|
135
|
+
return ansis_default[mods](str);
|
|
136
|
+
}
|
|
137
|
+
__name(applyMods, "applyMods");
|
|
138
|
+
function formattedValue(val, showType = false) {
|
|
139
|
+
let strVal = "";
|
|
140
|
+
let strType = "";
|
|
141
|
+
let mods;
|
|
142
|
+
if (my_dash_default.isBoolean(val)) {
|
|
143
|
+
strVal = val.toString();
|
|
144
|
+
mods = ["yellow", "italic"];
|
|
145
|
+
strType = "boolean";
|
|
146
|
+
} else if (my_dash_default.isNumber(val)) {
|
|
147
|
+
strVal = val.toString();
|
|
148
|
+
mods = "yellow";
|
|
149
|
+
strType = "number";
|
|
150
|
+
} else if (my_dash_default.isString(val)) {
|
|
151
|
+
strVal = `"${val}"`;
|
|
152
|
+
strType = "string";
|
|
153
|
+
} else if (my_dash_default.isPlainObject(val)) {
|
|
154
|
+
strVal = JSON.stringify(val);
|
|
155
|
+
strType = "object";
|
|
156
|
+
} else if (val === null) {
|
|
157
|
+
strVal = "null";
|
|
158
|
+
mods = "gray";
|
|
159
|
+
} else if (val === void 0) {
|
|
160
|
+
strVal = "undefined";
|
|
161
|
+
mods = "gray";
|
|
162
|
+
}
|
|
163
|
+
return [
|
|
164
|
+
applyMods(strVal, mods),
|
|
165
|
+
showType && strType ? ansis_default.gray(` (${strType})`) : ""
|
|
166
|
+
].join("");
|
|
167
|
+
}
|
|
168
|
+
__name(formattedValue, "formattedValue");
|
|
169
|
+
function joinAndCompact(strings, joinChar = " ") {
|
|
170
|
+
return strings.filter((s) => (
|
|
171
|
+
// we'll not filter out empty strings - because it's useful to just add newlines
|
|
172
|
+
s !== void 0 && s !== null && s !== false
|
|
173
|
+
)).join(joinChar);
|
|
174
|
+
}
|
|
175
|
+
__name(joinAndCompact, "joinAndCompact");
|
|
176
|
+
var VALIDATION_STATE_COLORS = {
|
|
177
|
+
error: "red",
|
|
178
|
+
warn: "yellow",
|
|
179
|
+
valid: "cyan"
|
|
180
|
+
};
|
|
181
|
+
function getItemSummary(item) {
|
|
182
|
+
const summary = [];
|
|
183
|
+
const itemErrors = item.errors;
|
|
184
|
+
const icon = itemErrors.length ? itemErrors[0].icon : "\u2705";
|
|
185
|
+
const isSensitive = item.isSensitive;
|
|
186
|
+
const isRequired = item.isRequired;
|
|
187
|
+
summary.push(joinAndCompact([
|
|
188
|
+
icon,
|
|
189
|
+
ansis_default[VALIDATION_STATE_COLORS[item.validationState]](item.key) + (isRequired ? ansis_default.magenta("*") : ""),
|
|
190
|
+
// ansis.gray(`[type = ${item.type.typeLabel}]`),
|
|
191
|
+
isSensitive && ` \u{1F510}${ansis_default.gray.italic("sensitive")}`
|
|
192
|
+
// item.useAt ? ansis.gray.italic(`(${item.useAt?.join(', ')})`) : undefined,
|
|
193
|
+
]));
|
|
194
|
+
let valAsStr = formattedValue(item.resolvedValue, false);
|
|
195
|
+
if (isSensitive && item.resolvedValue && my_dash_default.isString(item.resolvedValue)) {
|
|
196
|
+
valAsStr = redactString(item.resolvedValue);
|
|
197
|
+
}
|
|
198
|
+
summary.push(joinAndCompact([
|
|
199
|
+
ansis_default.gray(" \u2514"),
|
|
200
|
+
valAsStr,
|
|
201
|
+
item.isCoerced && ansis_default.gray.italic("< coerced from ") + (isSensitive ? formattedValue(item.resolvedRawValue) : formattedValue(item.resolvedRawValue, false))
|
|
202
|
+
]));
|
|
203
|
+
itemErrors?.forEach((err) => {
|
|
204
|
+
summary.push(ansis_default[err.isWarning ? "yellow" : "red"](` - ${err.isWarning ? "[WARNING] " : ""}${err.message}`));
|
|
205
|
+
if (err.tip) {
|
|
206
|
+
summary.push(...err.tip.split("\n").map((line) => ` ${line}`));
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
return summary.join("\n");
|
|
210
|
+
}
|
|
211
|
+
__name(getItemSummary, "getItemSummary");
|
|
212
|
+
|
|
213
|
+
// src/lib/load-graph.ts
|
|
214
|
+
async function loadVarlockEnvGraph() {
|
|
215
|
+
const envGraph = await loadEnvGraph({
|
|
216
|
+
afterInit: /* @__PURE__ */ __name(async (g) => {
|
|
217
|
+
}, "afterInit")
|
|
218
|
+
});
|
|
219
|
+
return envGraph;
|
|
220
|
+
}
|
|
221
|
+
__name(loadVarlockEnvGraph, "loadVarlockEnvGraph");
|
|
222
|
+
|
|
223
|
+
export { VarlockRedactor, getItemSummary, joinAndCompact, loadVarlockEnvGraph, resetRedactionMap };
|
|
224
|
+
//# sourceMappingURL=chunk-QTYVZQSF.js.map
|
|
225
|
+
//# sourceMappingURL=chunk-QTYVZQSF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/red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AAA;AAK/G,IAAA,IAAI,IAAI,GAAK,EAAA;AACX,MAAA,OAAA,CAAQ,IAAK,CAAA,GAAG,GAAI,CAAA,GAAA,CAAI,KAAM,CAAA,IAAI,CAAE,CAAA,GAAA,CAAI,CAAC,IAAA,KAAS,CAAQ,KAAA,EAAA,IAAI,EAAE,CAAC,CAAA;AAAA;AACnE,GACD,CAAA;AAQD,EAAO,OAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAC1B;AAxDgB,MAAA,CAAA,cAAA,EAAA,gBAAA,CAAA;;;ACzFhB,eAAsB,mBAAsB,GAAA;AAC1C,EAAM,MAAA,QAAA,GAAW,MAAM,YAAa,CAAA;AAAA,IAClC,SAAA,gCAAkB,CAAM,KAAA;AAAA,KAAb,EAAA,WAAA;AAAA,GAGZ,CAAA;AAED,EAAO,OAAA,QAAA;AACT;AARsB,MAAA,CAAA,mBAAA,EAAA,qBAAA,CAAA","file":"chunk-QTYVZQSF.js","sourcesContent":["import { EnvGraph } from '@env-spec/env-graph';\nimport _ from '@env-spec/utils/my-dash';\n\nconst UNMASK_STR = '👁';\n\nexport type RedactMode = 'show_first_2' | 'show_last_2' | 'show_first_last';\n\n/**\n * utility to mask/redact a string, for example transforming \"hello\" into \"he▒▒▒\"\n * this function just redacts _any_ string passed in\n *\n * To redact sensitive parts of a larger object/string, use redactSensitiveConfig\n * */\nexport function redactString(valStr: string | undefined, mode?: RedactMode, hideLength = true) {\n if (!valStr) return valStr;\n\n const hiddenLength = hideLength ? 5 : valStr.length - 2;\n const hiddenStr = '▒'.repeat(hiddenLength);\n\n if (mode === 'show_last_2') {\n return `${hiddenStr}${valStr.substring(valStr.length - 2, valStr.length)}`;\n } else if (mode === 'show_first_last') {\n return `${valStr.substring(0, 1)}${hiddenStr}${valStr.substring(valStr.length - 1, valStr.length)}`;\n } else { // 'show_first_2' - also default\n return `${valStr.substring(0, 2)}${hiddenStr}`;\n }\n}\n\n\n/** key value lookup of sensitive values to their redacted version */\nlet sensitiveSecretsMap: Record<string, string> = {};\n\ntype ReplaceFn = (match: string, pre: string, val: string, post: string) => string;\nlet redactorFindReplace: undefined | { find: RegExp, replace: ReplaceFn };\n\nexport function resetRedactionMap(graph: EnvGraph) {\n // reset map of { [sensitive] => redacted }\n sensitiveSecretsMap = {};\n for (const itemKey in graph.configSchema) {\n const item = graph.configSchema[itemKey];\n if (item.isSensitive && item.resolvedValue && _.isString(item.resolvedValue)) {\n // TODO: we want to respect masking settings from the schema (once added)\n const redacted = redactString(item.resolvedValue);\n if (redacted) sensitiveSecretsMap[item.resolvedValue] = redacted;\n }\n }\n\n // reset find/replace regex+fn used for redacting secrets in strings\n const findRegex = new RegExp(\n [\n `(${UNMASK_STR} )?`,\n '(',\n Object.keys(sensitiveSecretsMap)\n // Escape special characters\n .map((s) => s.replace(/[()[\\]{}*+?^$|#.,/\\\\\\s-]/g, '\\\\$&'))\n // Sort for maximal munch\n .sort((a, b) => b.length - a.length)\n .join('|'),\n ')',\n `( ${UNMASK_STR})?`,\n ].join(''),\n 'g',\n );\n\n const replaceFn: ReplaceFn = (match, pre, val, post) => {\n // the pre and post matches only will be populated if they were present\n // and they are used to unmask the secret - so we do not want to replace in this case\n if (pre && post) return match;\n return sensitiveSecretsMap[val];\n };\n redactorFindReplace = { find: findRegex, replace: replaceFn };\n}\n\n\nconst CONSOLE_METHODS = ['trace', 'debug', 'info', 'log', 'info', 'warn', 'error'];\n\n// While the module itself acts as a singleton to hold the current map of redacted values\n// we expose only the below const to end users\n\n/** singleton wrapper for varlock's redaction utilities */\nexport const VarlockRedactor = {\n /**\n * Redacts senstive config values from any string/array/object/etc\n *\n * NOTE - must be used only after varlock has loaded config\n * */\n redactSensitiveConfig(o: any): any {\n if (!redactorFindReplace) return o;\n if (!o) return o;\n\n // TODO: handle more cases?\n // we can probably redact safely from a few other datatypes - like set,map,etc?\n // objects are a bit tougher\n if (Array.isArray(o)) {\n return o.map(VarlockRedactor.redactSensitiveConfig);\n }\n // try to redact if it's a plain object - not necessarily great for perf...\n if (o && typeof (o) === 'object' && Object.getPrototypeOf(o) === Object.prototype) {\n try {\n return JSON.parse(VarlockRedactor.redactSensitiveConfig(JSON.stringify(o)));\n } catch (err) {\n return o;\n }\n }\n\n const type = typeof o;\n if (type === 'string' || (type === 'object' && Object.prototype.toString.call(o) === '[object String]')) {\n return (o as string).replaceAll(redactorFindReplace.find, redactorFindReplace.replace);\n }\n\n return o;\n },\n\n /**\n * utility to unmask a secret/sensitive value when logging to the console\n * currently this only works on a single secret, not objects or aggregated strings\n * */\n unredact(secretStr: string) {\n // if redaction not enabled, we just return the secret itself\n if (!(globalThis as any)._varlockOrigWriteToConsoleFn) return secretStr;\n // otherwise we add some wrapper characters which will be removed by the patched console behaviour\n return `${UNMASK_STR} ${secretStr} ${UNMASK_STR}`;\n },\n\n /**\n * patches global console methods to redact sensitive config\n *\n * NOTE - this may not be 100% foolproof depending on the platform\n * */\n patchConsole() {\n /* eslint-disable no-console, prefer-rest-params */\n if (!redactorFindReplace) return;\n\n // our method of patching involves replacing an internal node method which may not be called if console.log itself has also been patched\n // for example AWS lambdas patches this to write the logs to a file which then is pushed to the rest of their system\n\n // so first we'll just patch the internal method do deal with normal stdout/stderr logs -------------------------------------\n\n // we need the internal symbol name to access the internal method\n const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === 'kWriteToConsole');\n\n // @ts-ignore\n (globalThis as any)._varlockOrigWriteToConsoleFn ||= globalThis.console[kWriteToConsoleSymbol];\n // @ts-ignore\n globalThis.console[kWriteToConsoleSymbol] = function () {\n (globalThis as any)._varlockOrigWriteToConsoleFn.apply(this, [\n arguments[0],\n VarlockRedactor.redactSensitiveConfig(arguments[1]),\n arguments[2],\n ]);\n };\n\n // and now we'll wrap console.log (and the other methods) if it looks like they have been patched already ------------------\n // NOTE - this will not fully redact from everything since we can't safely reach deep into objects\n // ideally we would only turn this when the above method does not work, but it's not trivial to detect when it that is the case\n // so we'll turn it on all the time for now...\n if (\n // !console.log.toString().includes('[native code]') &&\n !(console.log as any)._varlockPatchedFn\n ) {\n for (const logMethodName of CONSOLE_METHODS) {\n // @ts-ignore\n const originalLogMethod = globalThis.console[logMethodName];\n\n const patchedFn = function () {\n // @ts-ignore\n originalLogMethod.apply(this, Array.from(arguments).map(VarlockRedactor.redactSensitiveConfig));\n };\n patchedFn._varlockPatchedFn = true;\n\n // @ts-ignore\n globalThis.console[logMethodName] = patchedFn;\n }\n }\n },\n\n /**\n * restore's original global console methods to stop redacting secrets\n *\n * (only needed during local development when switching settings on/off in a process that does not reload)\n * */\n unpatchConsole() {\n // we'll only care about the normal case where console.log has NOT been patched by something else... (see above)\n if (!(globalThis as any)._varlockOrigWriteToConsoleFn) return;\n\n const kWriteToConsoleSymbol = Object.getOwnPropertySymbols(globalThis.console).find((s) => s.description === 'kWriteToConsole');\n // @ts-ignore\n globalThis.console[kWriteToConsoleSymbol] = (globalThis as any)._varlockOrigWriteToConsoleFn;\n delete (globalThis as any)._varlockOrigWriteToConsoleFn;\n },\n};\n","import ansis, { AnsiColors, AnsiStyles } from 'ansis';\nimport _ from '@env-spec/utils/my-dash';\n\nimport { ConfigItem } from '../../../env-graph/src/lib/config-item';\nimport { VarlockError } from '../../../env-graph/src/lib/errors';\nimport { redactString } from './redaction-helpers';\n\ntype ColorMod = AnsiStyles | AnsiColors;\ntype ColorMods = ColorMod | Array<ColorMod>;\n\nfunction applyMods(str: string, mods?: ColorMods) {\n if (!mods) return str;\n if (_.isArray(mods)) {\n let modStr = str;\n mods.forEach((mod) => {\n modStr = ansis[mod](modStr);\n });\n return modStr;\n }\n return ansis[mods](str);\n}\n\nexport function formattedValue(val: any, showType = false) {\n let strVal: string = '';\n let strType: string = '';\n let mods: ColorMods | undefined;\n if (_.isBoolean(val)) {\n strVal = val.toString();\n mods = ['yellow', 'italic'];\n strType = 'boolean';\n } else if (_.isNumber(val)) {\n strVal = val.toString();\n mods = 'yellow';\n strType = 'number';\n } else if (_.isString(val)) {\n strVal = `\"${val}\"`;\n strType = 'string';\n } else if (_.isPlainObject(val)) {\n // TODO: can definitely make this better...\n strVal = JSON.stringify(val);\n strType = 'object';\n } else if (val === null) {\n strVal = 'null';\n mods = 'gray';\n } else if (val === undefined) {\n strVal = 'undefined';\n mods = 'gray';\n }\n return [\n applyMods(strVal, mods),\n showType && strType ? ansis.gray(` (${strType})`) : '',\n ].join('');\n}\n\n\nexport function formatError(err: VarlockError) {\n let whenStr = '';\n if (err.type === 'SchemaError') {\n whenStr += 'during schema initialization';\n }\n if (err.type === 'ValidationError') {\n whenStr += 'during validation';\n }\n if (err.type === 'CoercionError') {\n whenStr += 'during coercion';\n }\n if (err.type === 'ResolutionError') {\n whenStr += 'during resolution';\n }\n\n let errStr = `${err.icon} ${err.message}`;\n if (err.isUnexpected) {\n errStr += ansis.gray.italic(`\\n (unexpected error${whenStr ? ` ${whenStr}` : ''})`);\n if ('stack' in err) errStr += err.stack;\n }\n return errStr;\n}\n\nexport function joinAndCompact(strings: Array<string | number | boolean | undefined | null | false>, joinChar = ' ') {\n return strings.filter((s) => (\n // we'll not filter out empty strings - because it's useful to just add newlines\n s !== undefined && s !== null && s !== false\n )).join(joinChar);\n}\n\nconst VALIDATION_STATE_COLORS = {\n error: 'red',\n warn: 'yellow',\n valid: 'cyan',\n} as const;\n\nexport function getItemSummary(item: ConfigItem) {\n const summary: Array<string> = [];\n const itemErrors = item.errors;\n const icon = itemErrors.length ? itemErrors[0].icon : '✅';\n const isSensitive = item.isSensitive;\n const isRequired = item.isRequired;\n summary.push(joinAndCompact([\n icon,\n ansis[VALIDATION_STATE_COLORS[item.validationState]](item.key) + (isRequired ? ansis.magenta('*') : ''),\n\n // ansis.gray(`[type = ${item.type.typeLabel}]`),\n isSensitive && ` 🔐${ansis.gray.italic('sensitive')}`,\n\n // item.useAt ? ansis.gray.italic(`(${item.useAt?.join(', ')})`) : undefined,\n ]));\n\n let valAsStr = formattedValue(item.resolvedValue, false);\n if (isSensitive && item.resolvedValue && _.isString(item.resolvedValue)) {\n valAsStr = redactString(item.resolvedValue)!;\n }\n\n summary.push(joinAndCompact([\n ansis.gray(' └'),\n valAsStr,\n item.isCoerced && (\n ansis.gray.italic('< coerced from ')\n + (isSensitive ? formattedValue(item.resolvedRawValue) : formattedValue(item.resolvedRawValue, false))\n ),\n ]));\n\n // if (item.overrides?.length) {\n // const activeOverride = item.overrides[0];\n // let overrideNote = ansis.gray.italic('value set via override: ');\n // overrideNote += ansis.gray(activeOverride.sourceType);\n // if (activeOverride.sourceLabel) overrideNote += ansis.gray(` - ${activeOverride.sourceLabel}`);\n // summary.push(` ${overrideNote}`);\n // }\n\n itemErrors?.forEach((err) => {\n summary.push(ansis[err.isWarning ? 'yellow' : 'red'](` - ${err.isWarning ? '[WARNING] ' : ''}${err.message}`));\n\n // TODO: standardize here how we show parse error locations and stack info?\n\n // summary.push(...err.cleanedStack || '');\n if (err.tip) {\n summary.push(...err.tip.split('\\n').map((line) => ` ${line}`));\n }\n });\n\n // NO OBJECT/CHILDREN FOR NOW\n // for (const childItem of _.values(item.children)) {\n // const childSummary = getItemSummary(childItem);\n // summary.push(childSummary.split('\\n').map((l) => ` ${l}`).join('\\n'));\n // }\n\n return summary.join('\\n');\n}\n","import { loadEnvGraph } from '@env-spec/env-graph';\n\nexport async function loadVarlockEnvGraph() {\n const envGraph = await loadEnvGraph({\n afterInit: async (g) => {\n // TODO: register varlock resolver\n },\n });\n\n return envGraph;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { define } from './chunk-33ROL4J5.js';
|
|
2
|
+
import { loadEnvGraph } from './chunk-HZADDTO5.js';
|
|
3
|
+
import { __name } from './chunk-XN24GZXQ.js';
|
|
4
|
+
|
|
5
|
+
// src/cli/helpers/install-detection.ts
|
|
6
|
+
function isBundledSEA() {
|
|
7
|
+
try {
|
|
8
|
+
return false;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
__name(isBundledSEA, "isBundledSEA");
|
|
14
|
+
|
|
15
|
+
// src/cli/commands/doctor.command.ts
|
|
16
|
+
var commandSpec = define({
|
|
17
|
+
name: "doctor",
|
|
18
|
+
description: "Debug and diagnose issues with your env file(s) and system",
|
|
19
|
+
args: {}
|
|
20
|
+
});
|
|
21
|
+
var commandFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
22
|
+
console.log("");
|
|
23
|
+
await console.log("\u{1F9D9} Scanning for issues... \u2728");
|
|
24
|
+
console.log("Bundled SEA?", isBundledSEA());
|
|
25
|
+
const envGraph = await loadEnvGraph();
|
|
26
|
+
await envGraph.resolveEnvValues();
|
|
27
|
+
envGraph.getResolvedEnvObject();
|
|
28
|
+
}, "commandFn");
|
|
29
|
+
|
|
30
|
+
export { commandFn, commandSpec };
|
|
31
|
+
//# sourceMappingURL=chunk-R53MTEAM.js.map
|
|
32
|
+
//# sourceMappingURL=chunk-R53MTEAM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/helpers/install-detection.ts","../src/cli/commands/doctor.command.ts"],"names":[],"mappings":";;;;;AACO,SAAS,YAAe,GAAA;AAC7B,EAAI,IAAA;AACF,IAAO,OAAA,KAAA;AAAA,WACA,CAAG,EAAA;AACV,IAAO,OAAA,KAAA;AAAA;AAEX;AANgB,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA;;;ACIT,IAAM,cAAc,MAAO,CAAA;AAAA,EAChC,IAAM,EAAA,QAAA;AAAA,EACN,WAAa,EAAA,4DAAA;AAAA,EACb,MAAM;AACR,CAAC;AAEY,IAAA,SAAA,iCAA6D,GAAQ,KAAA;AAChF,EAAA,OAAA,CAAQ,IAAI,EAAE,CAAA;AACd,EAAM,MAAA,OAAA,CAAQ,IAAI,yCAA6B,CAAA;AAE/C,EAAQ,OAAA,CAAA,GAAA,CAAI,cAAgB,EAAA,YAAA,EAAc,CAAA;AAE1C,EAAM,MAAA,QAAA,GAAW,MAAM,YAAa,EAAA;AACpC,EAAA,MAAM,SAAS,gBAAiB,EAAA;AAChC,EAAoB,SAAS,oBAAqB;AAIpD,CAZmE,EAAA,WAAA","file":"chunk-R53MTEAM.js","sourcesContent":["\nexport function isBundledSEA() {\n try {\n return __VARLOCK_SEA_BUILD__;\n } catch (e) {\n return false;\n }\n}\n","import { define } from 'gunshi';\nimport { loadEnvGraph } from '@env-spec/env-graph';\nimport { isBundledSEA } from '../helpers/install-detection';\nimport { TypedGunshiCommandFn } from '../helpers/gunshi-type-utils';\n\nexport const commandSpec = define({\n name: 'doctor',\n description: 'Debug and diagnose issues with your env file(s) and system',\n args: {},\n});\n\nexport const commandFn: TypedGunshiCommandFn<typeof commandSpec> = async (ctx) => {\n console.log('');\n await console.log('🧙 Scanning for issues... ✨');\n\n console.log('Bundled SEA?', isBundledSEA());\n\n const envGraph = await loadEnvGraph();\n await envGraph.resolveEnvValues();\n const resolvedEnv = envGraph.getResolvedEnvObject();\n\n // TODO: Mac app checks\n // - installed, running, logged in, set up (keys exist), locked/unlocked state\n};\n\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { define } from './chunk-33ROL4J5.js';
|
|
2
|
+
import { __name } from './chunk-XN24GZXQ.js';
|
|
3
|
+
|
|
4
|
+
// src/cli/commands/help.command.ts
|
|
5
|
+
var commandSpec = define({
|
|
6
|
+
name: "help",
|
|
7
|
+
description: "Show help info for varlock",
|
|
8
|
+
args: {}
|
|
9
|
+
});
|
|
10
|
+
var commandFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
11
|
+
}, "commandFn");
|
|
12
|
+
|
|
13
|
+
export { commandFn, commandSpec };
|
|
14
|
+
//# sourceMappingURL=chunk-RCHPHIHX.js.map
|
|
15
|
+
//# sourceMappingURL=chunk-RCHPHIHX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/help.command.ts"],"names":[],"mappings":";;;;AAGO,IAAM,cAAc,MAAO,CAAA;AAAA,EAChC,IAAM,EAAA,MAAA;AAAA,EACN,WAAa,EAAA,4BAAA;AAAA,EACb,MAAM;AACR,CAAC;AAEY,IAAA,SAAA,iCAA6D,GAAQ,KAAA;AAElF,CAFmE,EAAA,WAAA","file":"chunk-RCHPHIHX.js","sourcesContent":["import { define } from 'gunshi';\nimport { TypedGunshiCommandFn } from '../helpers/gunshi-type-utils';\n\nexport const commandSpec = define({\n name: 'help',\n description: 'Show help info for varlock',\n args: {},\n});\n\nexport const commandFn: TypedGunshiCommandFn<typeof commandSpec> = async (ctx) => {\n // no-op - we'll trigger help from main entry point\n};\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __glob = (map) => (path) => {
|
|
9
|
+
var fn = map[path];
|
|
10
|
+
if (fn) return fn();
|
|
11
|
+
throw new Error("Module not found in bundle: " + path);
|
|
12
|
+
};
|
|
13
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
export { __commonJS, __glob, __name, __toESM };
|
|
34
|
+
//# sourceMappingURL=chunk-XN24GZXQ.js.map
|
|
35
|
+
//# sourceMappingURL=chunk-XN24GZXQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-XN24GZXQ.js"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { commandSpec as commandSpec$2 } from '../chunk-35HGPX6I.js';
|
|
2
|
+
import { commandSpec as commandSpec$3 } from '../chunk-B4UBSMSZ.js';
|
|
3
|
+
import { commandSpec as commandSpec$4 } from '../chunk-R53MTEAM.js';
|
|
4
|
+
import { commandSpec as commandSpec$5 } from '../chunk-RCHPHIHX.js';
|
|
5
|
+
import { commandSpec as commandSpec$6 } from '../chunk-QCC3P7BT.js';
|
|
6
|
+
import { CONFIG, commandSpec as commandSpec$7 } from '../chunk-CPA2D42B.js';
|
|
7
|
+
import { CliExitError, commandSpec } from '../chunk-EMPXU5TW.js';
|
|
8
|
+
import '../chunk-DAZNZPLN.js';
|
|
9
|
+
import { fmt } from '../chunk-LQZ6ICSS.js';
|
|
10
|
+
import { commandSpec as commandSpec$1 } from '../chunk-BRP5MZU6.js';
|
|
11
|
+
import { InvalidEnvError } from '../chunk-NZDUC7Q3.js';
|
|
12
|
+
import { cli } from '../chunk-33ROL4J5.js';
|
|
13
|
+
import '../chunk-QTYVZQSF.js';
|
|
14
|
+
import { EnvSourceParseError } from '../chunk-HZADDTO5.js';
|
|
15
|
+
import { ansis_default } from '../chunk-7UQXFWKN.js';
|
|
16
|
+
import { __name } from '../chunk-XN24GZXQ.js';
|
|
17
|
+
import { homedir } from 'os';
|
|
18
|
+
import { join } from 'path';
|
|
19
|
+
import { readFile } from 'fs/promises';
|
|
20
|
+
import { existsSync } from 'fs';
|
|
21
|
+
|
|
22
|
+
var VARLOCK_BANNER = [
|
|
23
|
+
"",
|
|
24
|
+
" \u2588\u2588\u2592 \u2588\u2593 \u2584\u2584\u2584 \u2588\u2588\u2580\u2588\u2588\u2588 \u2588\u2588\u2593 \u2592\u2588\u2588\u2588\u2588\u2588 \u2584\u2588\u2588\u2588\u2588\u2584 \u2588\u2588 \u2584\u2588\u2580",
|
|
25
|
+
" \u2593\u2588\u2588\u2591 \u2588\u2592\u2592\u2588\u2588\u2588\u2588\u2584 \u2593\u2588\u2588 \u2592 \u2588\u2588\u2592\u2593\u2588\u2588\u2592 \u2592\u2588\u2588\u2592 \u2588\u2588\u2592\u2592\u2588\u2588\u2580 \u2580\u2588 \u2588\u2588\u2584\u2588\u2592 ",
|
|
26
|
+
" \u2593\u2588\u2588 \u2588\u2592\u2591\u2592\u2588\u2588 \u2580\u2588\u2584 \u2593\u2588\u2588 \u2591\u2584\u2588 \u2592\u2592\u2588\u2588\u2591 \u2592\u2588\u2588\u2591 \u2588\u2588\u2592\u2592\u2588\u2588 \u2584 \u2593\u2588\u2588\u2588\u2584\u2591 ",
|
|
27
|
+
" \u2592\u2588\u2588 \u2588\u2591\u2591\u2591\u2588\u2588\u2584\u2584\u2584\u2584\u2588\u2588 \u2592\u2588\u2588\u2580\u2580\u2588\u2584 \u2592\u2588\u2588\u2591 \u2592\u2588\u2588 \u2588\u2588\u2591\u2592\u2588\u2588\u2584 \u2584\u2588\u2588\u2592\u2593\u2588\u2588 \u2588\u2584 ",
|
|
28
|
+
" \u2592\u2580\u2588\u2591 \u2593\u2588 \u2593\u2588\u2588\u2592\u2591\u2588\u2588\u2593 \u2592\u2588\u2588\u2592\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2592\u2591 \u2588\u2588\u2588\u2588\u2588\u2592\u2591\u2592 \u2588\u2588\u2588\u2588\u2580 \u2591\u2592\u2588\u2588\u2592 \u2588\u2584",
|
|
29
|
+
" \u2591 \u2590\u2591 \u2592\u2592 \u2593\u2592\u2588\u2591\u2591 \u2592\u2593 \u2591\u2592\u2593\u2591\u2591 \u2592\u2591\u2593 \u2591\u2591 \u2592\u2591\u2592\u2591\u2592\u2591 \u2591 \u2591\u2592 \u2592 \u2591\u2592 \u2592\u2592 \u2593\u2592",
|
|
30
|
+
" \u2591 \u2591\u2591 \u2592 \u2592\u2592 \u2591 \u2591\u2592 \u2591 \u2592\u2591\u2591 \u2591 \u2592 \u2591 \u2591 \u2592 \u2592\u2591 \u2591 \u2592 \u2591 \u2591\u2592 \u2592\u2591",
|
|
31
|
+
" \u2591\u2591 \u2591 \u2592 \u2591\u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2592 \u2591 \u2591 \u2591\u2591 \u2591 ",
|
|
32
|
+
" \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 \u2591 "
|
|
33
|
+
// ' ░ ░ ',
|
|
34
|
+
].join("\n");
|
|
35
|
+
var VARLOCK_BANNER_COLOR = VARLOCK_BANNER.replaceAll(/([▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐▔▕▖▗▘▙▚▛▜▝▞▟]+)/g, (m) => ansis_default.hex("#DD0000")(m)).replaceAll(/([▓░▒]+)/g, (m) => ansis_default.blue(m));
|
|
36
|
+
async function checkIsOptedOut() {
|
|
37
|
+
if (process.env.PH_OPT_OUT === "true") {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
const configPath = join(homedir(), ".varlock", "config.json");
|
|
41
|
+
if (existsSync(configPath)) {
|
|
42
|
+
try {
|
|
43
|
+
const configContent = await readFile(configPath, "utf-8");
|
|
44
|
+
const config = JSON.parse(configContent);
|
|
45
|
+
return config.analytics_opt_out === true;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.debug("Failed to read analytics config:", error);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
__name(checkIsOptedOut, "checkIsOptedOut");
|
|
53
|
+
var DEBUG_PH = !!process.env.DEBUG_PH;
|
|
54
|
+
var isOptedOut = await checkIsOptedOut();
|
|
55
|
+
if (DEBUG_PH) console.log("posthog opted out: ", isOptedOut);
|
|
56
|
+
async function posthogCapture(event, properties) {
|
|
57
|
+
if (isOptedOut) return;
|
|
58
|
+
const payload = {
|
|
59
|
+
api_key: CONFIG.POSTHOG_API_KEY,
|
|
60
|
+
event,
|
|
61
|
+
properties: {
|
|
62
|
+
$process_person_profile: false,
|
|
63
|
+
...properties
|
|
64
|
+
},
|
|
65
|
+
distinct_id: "anonymous"
|
|
66
|
+
};
|
|
67
|
+
const res = await fetch(`${CONFIG.POSTHOG_HOST}/i/v0/e/`, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
body: JSON.stringify(payload),
|
|
70
|
+
headers: {
|
|
71
|
+
"Content-Type": "application/json"
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (DEBUG_PH) console.log("res", await res.text());
|
|
75
|
+
}
|
|
76
|
+
__name(posthogCapture, "posthogCapture");
|
|
77
|
+
async function trackCommand(command, properties) {
|
|
78
|
+
await posthogCapture("cli_command_executed", {
|
|
79
|
+
command,
|
|
80
|
+
...properties
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
__name(trackCommand, "trackCommand");
|
|
84
|
+
|
|
85
|
+
// package.json
|
|
86
|
+
var package_default = {
|
|
87
|
+
name: "varlock",
|
|
88
|
+
version: "0.0.1",
|
|
89
|
+
description: "",
|
|
90
|
+
main: "index.js",
|
|
91
|
+
type: "module",
|
|
92
|
+
author: "dmno-dev",
|
|
93
|
+
license: "MIT",
|
|
94
|
+
scripts: {
|
|
95
|
+
build: "tsup",
|
|
96
|
+
"build:sea": "tsup --config tsup-sea.config.ts",
|
|
97
|
+
dev: "tsup",
|
|
98
|
+
test: "vitest",
|
|
99
|
+
lint: "eslint .",
|
|
100
|
+
"lint:fix": "pnpm run lint --fix"
|
|
101
|
+
},
|
|
102
|
+
keywords: [],
|
|
103
|
+
files: [
|
|
104
|
+
"/bin",
|
|
105
|
+
"/dist"
|
|
106
|
+
],
|
|
107
|
+
bin: {
|
|
108
|
+
varlock: "./bin/cli.js"
|
|
109
|
+
},
|
|
110
|
+
exports: {
|
|
111
|
+
".": "./dist/index.js",
|
|
112
|
+
"./auto-load": "./dist/auto-load.js",
|
|
113
|
+
"./config": "./dist/dotenv-compat.js",
|
|
114
|
+
"./config.js": "./dist/dotenv-compat.js"
|
|
115
|
+
},
|
|
116
|
+
dependencies: {
|
|
117
|
+
"@env-spec/parser": "workspace:*",
|
|
118
|
+
debug: "catalog:",
|
|
119
|
+
execa: "^9.5.2",
|
|
120
|
+
which: "^5.0.0"
|
|
121
|
+
},
|
|
122
|
+
devDependencies: {
|
|
123
|
+
"@clack/core": "^0.5.0",
|
|
124
|
+
"@clack/prompts": "^0.11.0",
|
|
125
|
+
"@env-spec/env-graph": "workspace:*",
|
|
126
|
+
"@env-spec/utils": "workspace:*",
|
|
127
|
+
"@sindresorhus/is": "catalog:",
|
|
128
|
+
"@types/debug": "catalog:",
|
|
129
|
+
"@types/node": "catalog:",
|
|
130
|
+
"@types/which": "^3.0.4",
|
|
131
|
+
"@yao-pkg/pkg": "^6.4.1",
|
|
132
|
+
ansis: "catalog:",
|
|
133
|
+
gunshi: "^0.26.3",
|
|
134
|
+
"is-unicode-supported": "^2.1.0",
|
|
135
|
+
outdent: "^0.8.0",
|
|
136
|
+
tsup: "catalog:",
|
|
137
|
+
vitest: "catalog:"
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// src/cli/cli-executable.ts
|
|
142
|
+
var mainCommand = {
|
|
143
|
+
run: /* @__PURE__ */ __name(() => {
|
|
144
|
+
console.log("Use one of the sub-commands...");
|
|
145
|
+
}, "run")
|
|
146
|
+
};
|
|
147
|
+
function buildLazyCommand(commandSpec9, loadCommandFn) {
|
|
148
|
+
const commandName = commandSpec9.name;
|
|
149
|
+
return {
|
|
150
|
+
...commandSpec9,
|
|
151
|
+
run: /* @__PURE__ */ __name(async (...args) => {
|
|
152
|
+
await trackCommand(commandName, { command: commandName });
|
|
153
|
+
const commandSpecAndFn = await loadCommandFn();
|
|
154
|
+
return commandSpecAndFn.commandFn(...args);
|
|
155
|
+
}, "run")
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
__name(buildLazyCommand, "buildLazyCommand");
|
|
159
|
+
var subCommands = /* @__PURE__ */ new Map();
|
|
160
|
+
subCommands.set("init", buildLazyCommand(commandSpec, async () => await import('../init.command-7BSALNL5.js')));
|
|
161
|
+
subCommands.set("load", buildLazyCommand(commandSpec$1, async () => await import('../load.command-4MJR5J43.js')));
|
|
162
|
+
subCommands.set("run", buildLazyCommand(commandSpec$2, async () => await import('../run.command-ASKXIWBC.js')));
|
|
163
|
+
subCommands.set("encrypt", buildLazyCommand(commandSpec$3, async () => await import('../encrypt.command-VGJABHNK.js')));
|
|
164
|
+
subCommands.set("doctor", buildLazyCommand(commandSpec$4, async () => await import('../doctor.command-N5JAIXRM.js')));
|
|
165
|
+
subCommands.set("help", buildLazyCommand(commandSpec$5, async () => await import('../help.command-YZDL2VEQ.js')));
|
|
166
|
+
subCommands.set("opt-out", buildLazyCommand(commandSpec$6, async () => await import('../opt-out.command-Y4KUQ6PQ.js')));
|
|
167
|
+
subCommands.set("login", buildLazyCommand(commandSpec$7, async () => await import('../login.command-22RUZJLR.js')));
|
|
168
|
+
(/* @__PURE__ */ __name(async function go() {
|
|
169
|
+
try {
|
|
170
|
+
let args = process.argv.slice(2);
|
|
171
|
+
if (args[0] === "help") args = ["--help"];
|
|
172
|
+
if (false) ;
|
|
173
|
+
await cli(args, mainCommand, {
|
|
174
|
+
name: "varlock",
|
|
175
|
+
description: "Encrypt and protect your env vars",
|
|
176
|
+
version: package_default.version,
|
|
177
|
+
subCommands,
|
|
178
|
+
renderHeader: /* @__PURE__ */ __name(async (ctx) => {
|
|
179
|
+
if (ctx.name) return "";
|
|
180
|
+
return VARLOCK_BANNER_COLOR;
|
|
181
|
+
}, "renderHeader")
|
|
182
|
+
});
|
|
183
|
+
process.exit(0);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if (error instanceof CliExitError || error instanceof InvalidEnvError) {
|
|
186
|
+
console.error(error.getFormattedOutput());
|
|
187
|
+
} else if (error instanceof EnvSourceParseError) {
|
|
188
|
+
console.log(`\u{1F6A8} Error encountered while loading ${error.location.path}`);
|
|
189
|
+
console.log(error.message);
|
|
190
|
+
const errLoc = error.location;
|
|
191
|
+
const errPreview = [
|
|
192
|
+
errLoc.lineStr,
|
|
193
|
+
`${ansis_default.gray("-".repeat(errLoc.colNumber - 1))}${ansis_default.red("^")}`
|
|
194
|
+
].join("\n");
|
|
195
|
+
console.log("Error parsing .env file");
|
|
196
|
+
console.log(fmt.filePath(`${errLoc.path}:${errLoc.lineNumber}:${errLoc.colNumber}`));
|
|
197
|
+
console.log(errPreview);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
} else {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
}, "go"))();
|
|
205
|
+
//# sourceMappingURL=cli-executable.js.map
|
|
206
|
+
//# sourceMappingURL=cli-executable.js.map
|