varlock 0.0.15 → 0.1.0
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 +1 -1
- package/dist/auto-load.js +3 -3
- package/dist/{chunk-XTPPJ3UK.js → chunk-7L3IF2MK.js} +15 -22
- package/dist/chunk-7L3IF2MK.js.map +1 -0
- package/dist/{chunk-LYSRVOTA.js → chunk-DTNPJJH4.js} +3 -3
- package/dist/{chunk-LYSRVOTA.js.map → chunk-DTNPJJH4.js.map} +1 -1
- package/dist/{chunk-WTAZCEL6.js → chunk-GY623P3W.js} +4 -4
- package/dist/{chunk-WTAZCEL6.js.map → chunk-GY623P3W.js.map} +1 -1
- package/dist/{chunk-OLZUI45U.js → chunk-LIIRL4NK.js} +4 -4
- package/dist/{chunk-OLZUI45U.js.map → chunk-LIIRL4NK.js.map} +1 -1
- package/dist/{chunk-WMCJKFEN.js → chunk-MITVWKKH.js} +4 -4
- package/dist/{chunk-WMCJKFEN.js.map → chunk-MITVWKKH.js.map} +1 -1
- package/dist/{chunk-IWQ4BDSW.js → chunk-MLIGQWID.js} +1497 -573
- package/dist/chunk-MLIGQWID.js.map +1 -0
- package/dist/{chunk-UPLR6H2O.js → chunk-NGDIT6C3.js} +33 -14
- package/dist/chunk-NGDIT6C3.js.map +1 -0
- package/dist/{chunk-IH74UIYN.js → chunk-NMJ5YL5I.js} +4 -4
- package/dist/{chunk-IH74UIYN.js.map → chunk-NMJ5YL5I.js.map} +1 -1
- package/dist/{chunk-LBV2UW3I.js → chunk-QT5E2RY6.js} +3 -3
- package/dist/chunk-QT5E2RY6.js.map +1 -0
- package/dist/cli/cli-executable.js +77 -48
- package/dist/cli/cli-executable.js.map +1 -1
- package/dist/dotenv-compat.js +3 -3
- package/dist/{env-DLUhFCnC.d.ts → env-graph-eF0B8G0j.d.ts} +210 -55
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -3
- package/dist/init.command-ASK74XBV.js +8 -0
- package/dist/{init.command-YZ23U7SF.js.map → init.command-ASK74XBV.js.map} +1 -1
- package/dist/lib/exec-sync-varlock.js +1 -1
- package/dist/load.command-VUKBSBEV.js +8 -0
- package/dist/{load.command-NVMWXLOK.js.map → load.command-VUKBSBEV.js.map} +1 -1
- package/dist/plugin-lib.d.ts +9 -0
- package/dist/plugin-lib.js +3 -0
- package/dist/plugin-lib.js.map +1 -0
- package/dist/run.command-XQ64Z2TN.js +8 -0
- package/dist/{run.command-CXMAPHO7.js.map → run.command-XQ64Z2TN.js.map} +1 -1
- package/dist/runtime/env.d.ts +28 -1
- package/dist/telemetry.command-HHZVBFC7.js +8 -0
- package/dist/{telemetry.command-3DVW7H2K.js.map → telemetry.command-HHZVBFC7.js.map} +1 -1
- package/package.json +17 -10
- package/dist/chunk-EPKIAPPA.js +0 -146
- package/dist/chunk-EPKIAPPA.js.map +0 -1
- package/dist/chunk-IWQ4BDSW.js.map +0 -1
- package/dist/chunk-LBV2UW3I.js.map +0 -1
- package/dist/chunk-UPLR6H2O.js.map +0 -1
- package/dist/chunk-XTPPJ3UK.js.map +0 -1
- package/dist/init.command-YZ23U7SF.js +0 -8
- package/dist/load.command-NVMWXLOK.js +0 -8
- package/dist/login.command-W4DP7RUO.js +0 -8
- package/dist/login.command-W4DP7RUO.js.map +0 -1
- package/dist/run.command-CXMAPHO7.js +0 -8
- package/dist/telemetry.command-3DVW7H2K.js +0 -8
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
import { ansis_default, gracefulExit, my_dash_default, getItemSummary, joinAndCompact, loadEnvGraph } from './chunk-
|
|
1
|
+
import { ansis_default, VarlockError, gracefulExit, my_dash_default, getItemSummary, joinAndCompact, loadEnvGraph } from './chunk-MLIGQWID.js';
|
|
2
2
|
import { __name } from './chunk-XN24GZXQ.js';
|
|
3
3
|
|
|
4
4
|
// src/cli/helpers/error-checks.ts
|
|
5
|
+
function showErrorLocationDetails(err) {
|
|
6
|
+
if (!(err instanceof VarlockError) || !err.location) return;
|
|
7
|
+
const errLoc = err.location;
|
|
8
|
+
const errPreview = [
|
|
9
|
+
errLoc.lineStr,
|
|
10
|
+
`${ansis_default.gray("-".repeat(errLoc.colNumber - 1))}${ansis_default.red("^")}`
|
|
11
|
+
].join("\n");
|
|
12
|
+
console.log("");
|
|
13
|
+
console.log(`\u{1F4C2} ${errLoc.id}:${errLoc.lineNumber}:${errLoc.colNumber}`);
|
|
14
|
+
console.log(errPreview);
|
|
15
|
+
}
|
|
16
|
+
__name(showErrorLocationDetails, "showErrorLocationDetails");
|
|
5
17
|
function checkForSchemaErrors(envGraph) {
|
|
6
18
|
for (const source of envGraph.sortedDataSources) {
|
|
7
19
|
if (source.loadingError) {
|
|
8
20
|
console.log(`\u{1F6A8} Error encountered while loading ${source.label}
|
|
9
21
|
`);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.log(
|
|
18
|
-
|
|
19
|
-
} else {
|
|
20
|
-
console.log(source.loadingError.message);
|
|
22
|
+
console.log(source.loadingError.message);
|
|
23
|
+
showErrorLocationDetails(source.loadingError);
|
|
24
|
+
return gracefulExit(1);
|
|
25
|
+
}
|
|
26
|
+
if (source.schemaErrors.length) {
|
|
27
|
+
console.log(`\u{1F6A8} Error(s) encountered in ${source.label}`);
|
|
28
|
+
for (const schemaErr of source.schemaErrors) {
|
|
29
|
+
console.log(`- ${schemaErr.message}`);
|
|
30
|
+
showErrorLocationDetails(schemaErr);
|
|
21
31
|
}
|
|
22
32
|
return gracefulExit(1);
|
|
23
33
|
}
|
|
@@ -38,6 +48,15 @@ var InvalidEnvError = class extends Error {
|
|
|
38
48
|
}
|
|
39
49
|
};
|
|
40
50
|
function checkForConfigErrors(envGraph, opts) {
|
|
51
|
+
for (const source of envGraph.sortedDataSources) {
|
|
52
|
+
if (source.resolutionErrors.length) {
|
|
53
|
+
console.log(`\u{1F6A8} Root decorator error(s) in ${source.label}`);
|
|
54
|
+
for (const err of source.resolutionErrors) {
|
|
55
|
+
console.log(`- ${err.message}`);
|
|
56
|
+
showErrorLocationDetails(err);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
41
60
|
const failingItems = my_dash_default.filter(my_dash_default.values(envGraph.configSchema), (item) => item.validationState === "error");
|
|
42
61
|
if (failingItems.length > 0) {
|
|
43
62
|
console.error(`
|
|
@@ -77,5 +96,5 @@ async function loadVarlockEnvGraph(opts) {
|
|
|
77
96
|
__name(loadVarlockEnvGraph, "loadVarlockEnvGraph");
|
|
78
97
|
|
|
79
98
|
export { InvalidEnvError, checkForConfigErrors, checkForSchemaErrors, loadVarlockEnvGraph };
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
99
|
+
//# sourceMappingURL=chunk-NGDIT6C3.js.map
|
|
100
|
+
//# sourceMappingURL=chunk-NGDIT6C3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/helpers/error-checks.ts","../src/lib/load-graph.ts"],"names":[],"mappings":";;;;AAQA,SAAS,yBAAyB,GAAA,EAAY;AAC5C,EAAA,IAAI,EAAE,GAAA,YAAe,YAAA,CAAA,IAAiB,CAAC,IAAI,QAAA,EAAU;AACrD,EAAA,MAAM,SAAS,GAAA,CAAI,QAAA;AACnB,EAAA,MAAM,UAAA,GAAa;AAAA,IACjB,MAAA,CAAO,OAAA;AAAA,IACP,CAAA,EAAG,aAAA,CAAM,IAAA,CAAK,GAAA,CAAI,OAAO,MAAA,CAAO,SAAA,GAAY,CAAC,CAAC,CAAC,CAAA,EAAG,aAAA,CAAM,GAAA,CAAI,GAAG,CAAC,CAAA;AAAA,GAClE,CAAE,KAAK,IAAI,CAAA;AAEX,EAAA,OAAA,CAAQ,IAAI,EAAE,CAAA;AACd,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,UAAA,EAAM,MAAA,CAAO,EAAE,CAAA,CAAA,EAAI,OAAO,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M;AACd,MAAA,OAAA,CAAQ,MAAM,cAAA,CAAe;AAAA,QAC3B,cAAA;AAAA,QACA,aAAA,CAAM,MAAA,CAAO,IAAA,CAAK,oCAAoC;AAAA,OACvD,CAAC,CAAA;AACF,MAAA,OAAA,CAAQ,KAAA,EAAM;AACd,MAAA,MAAM,UAAA,GAAa,eAAA,CAAE,MAAA,CAAO,eAAA,CAAE,MAAA,CAAO,QAAA,CAAS,YAAY,CAAA,EAAG,CAAC,CAAA,KAAkB,CAAC,CAAC,EAAE,OAAO,CAAA;AAC3F,MAAA,eAAA,CAAE,IAAA,CAAK,UAAA,EAAY,CAAC,IAAA,KAAqB;AACvC,QAAA,OAAA,CAAQ,KAAA,CAAM,cAAA,CAAe,IAAI,CAAC,CAAA;AAAA,MACpC,CAAC,CAAA;AAAA,IACH;AAEA,IAAA,MAAM,IAAI,eAAA,EAAgB;AAAA,EAC5B;AACF;AA3CgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA;;;AChEhB,eAAsB,oBAAoB,IAAA,EAEvC;AACD,EAAA,MAAM,QAAA,GAAW,MAAM,YAAA,CAAa;AAAA,IAClC,GAAG,IAAA;AAAA,IACH,SAAA,gCAAkB,EAAA,KAAO;AAAA,IAEzB,CAAA,EAFW,WAAA;AAAA,GAGZ,CAAA;AAED,EAAA,OAAO,QAAA;AACT;AAXsB,MAAA,CAAA,mBAAA,EAAA,qBAAA,CAAA","file":"chunk-NGDIT6C3.js","sourcesContent":["import ansis from 'ansis';\nimport { gracefulExit } from 'exit-hook';\nimport _ from '@env-spec/utils/my-dash';\nimport { EnvGraph, ConfigItem } from '../../../env-graph';\nimport { getItemSummary, joinAndCompact } from '../../lib/formatting';\nimport { VarlockError } from '../../../env-graph/lib/errors';\n\n\nfunction showErrorLocationDetails(err: Error) {\n if (!(err instanceof VarlockError) || !err.location) return;\n const errLoc = err.location;\n const errPreview = [\n errLoc.lineStr,\n `${ansis.gray('-'.repeat(errLoc.colNumber - 1))}${ansis.red('^')}`,\n ].join('\\n');\n\n console.log('');\n console.log(`📂 ${errLoc.id}:${errLoc.lineNumber}:${errLoc.colNumber}`);\n console.log(errPreview);\n}\n\nexport function checkForSchemaErrors(envGraph: EnvGraph) {\n // first we check for loading/parse errors - some cases we may want to let it fail silently?\n for (const source of envGraph.sortedDataSources) {\n // do we care about loading errors from disabled sources?\n // if (source.disabled) continue;\n\n // TODO: use a formatting helper to show the error - which will include location/stack/etc appropriately\n if (source.loadingError) {\n console.log(`🚨 Error encountered while loading ${source.label}\\n`);\n\n console.log(source.loadingError.message);\n showErrorLocationDetails(source.loadingError);\n return gracefulExit(1);\n }\n // TODO: unify this with the above!\n if (source.schemaErrors.length) {\n console.log(`🚨 Error(s) encountered in ${source.label}`);\n\n for (const schemaErr of source.schemaErrors) {\n console.log(`- ${schemaErr.message}`);\n showErrorLocationDetails(schemaErr);\n }\n return gracefulExit(1);\n }\n }\n\n // now we check for any schema errors - where something about how things are wired up is invalid\n // NOTE - we should not have run any resolution yet\n // TODO: make sure we are calling this before attempting to resolve values\n // const failingItems = _.filter(_.values(envGraph.configSchema), (item) => item.validationState === 'error');\n // if (failingItems.length > 0) {\n // throw new CliExitError('Schema is currently invalid');\n // }\n}\n\n\nexport class InvalidEnvError extends Error {\n constructor() {\n super('Resolved config/env did not pass validation');\n }\n getFormattedOutput() {\n return `\\n💥 ${ansis.red(this.message)} 💥\\n`;\n }\n}\n\nexport function checkForConfigErrors(envGraph: EnvGraph, opts?: {\n showAll?: boolean\n}) {\n // check for root decorator \"execution\"\n for (const source of envGraph.sortedDataSources) {\n if (source.resolutionErrors.length) {\n console.log(`🚨 Root decorator error(s) in ${source.label}`);\n\n for (const err of source.resolutionErrors) {\n console.log(`- ${err.message}`);\n showErrorLocationDetails(err);\n }\n }\n }\n\n\n\n const failingItems = _.filter(_.values(envGraph.configSchema), (item: ConfigItem) => item.validationState === 'error');\n\n // TODO: use service.isValid?\n if (failingItems.length > 0) {\n console.error(`\\n🚨 🚨 🚨 ${ansis.bold.underline('Configuration is currently invalid ')} 🚨 🚨 🚨\\n`);\n console.error('Invalid items:\\n');\n\n _.each(failingItems, (item: ConfigItem) => {\n console.error(getItemSummary(item));\n console.error();\n });\n if (opts?.showAll) {\n console.error();\n console.error(joinAndCompact([\n 'Valid items:',\n ansis.italic.gray('(remove `--show-all` flag to hide)'),\n ]));\n console.error();\n const validItems = _.filter(_.values(envGraph.configSchema), (i: ConfigItem) => !!i.isValid);\n _.each(validItems, (item: ConfigItem) => {\n console.error(getItemSummary(item));\n });\n }\n\n throw new InvalidEnvError();\n }\n}\n","import { loadEnvGraph } from '../../env-graph';\n\nexport async function loadVarlockEnvGraph(opts?: {\n currentEnvFallback?: string,\n}) {\n const envGraph = await loadEnvGraph({\n ...opts,\n afterInit: async (_g) => {\n // TODO: register varlock resolver\n },\n });\n\n return envGraph;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { patchGlobalResponse } from './chunk-OM3JCP4E.js';
|
|
1
2
|
import { patchGlobalServerResponse } from './chunk-7JMYT62X.js';
|
|
2
|
-
import { execSyncVarlock } from './chunk-
|
|
3
|
+
import { execSyncVarlock } from './chunk-QT5E2RY6.js';
|
|
3
4
|
import { patchGlobalConsole } from './chunk-C5BEZMSO.js';
|
|
4
|
-
import { patchGlobalResponse } from './chunk-OM3JCP4E.js';
|
|
5
5
|
import { initVarlockEnv } from './chunk-2SPIWTVE.js';
|
|
6
6
|
|
|
7
7
|
// src/auto-load.ts
|
|
@@ -14,5 +14,5 @@ initVarlockEnv();
|
|
|
14
14
|
patchGlobalConsole();
|
|
15
15
|
patchGlobalServerResponse();
|
|
16
16
|
patchGlobalResponse();
|
|
17
|
-
//# sourceMappingURL=chunk-
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
17
|
+
//# sourceMappingURL=chunk-NMJ5YL5I.js.map
|
|
18
|
+
//# sourceMappingURL=chunk-NMJ5YL5I.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auto-load.ts"],"names":[],"mappings":";;;;;;;AAaA,IAAM,UAAA,GAAa,gBAAgB,yBAAA,EAA2B;AAAA,EAC5D,WAAA,EAAa,IAAA;AAAA,EACb,eAAA,EAAiB;AACnB,CAAC,CAAA;AACD,OAAA,CAAQ,IAAI,aAAA,GAAgB,UAAA;AAG5B,cAAA,EAAe;AAEf,kBAAA,EAAmB;AACnB,yBAAA,EAA0B;AAC1B,mBAAA,EAAoB","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/auto-load.ts"],"names":[],"mappings":";;;;;;;AAaA,IAAM,UAAA,GAAa,gBAAgB,yBAAA,EAA2B;AAAA,EAC5D,WAAA,EAAa,IAAA;AAAA,EACb,eAAA,EAAiB;AACnB,CAAC,CAAA;AACD,OAAA,CAAQ,IAAI,aAAA,GAAgB,UAAA;AAG5B,cAAA,EAAe;AAEf,kBAAA,EAAmB;AACnB,yBAAA,EAA0B;AAC1B,mBAAA,EAAoB","file":"chunk-NMJ5YL5I.js","sourcesContent":["import { execSyncVarlock } from './lib/exec-sync-varlock';\n\nimport { initVarlockEnv } from './runtime/env';\nimport { patchGlobalConsole } from './runtime/patch-console';\nimport { patchGlobalServerResponse } from './runtime/patch-server-response';\nimport { patchGlobalResponse } from './runtime/patch-response';\n\n// The varlock loading process uses async calls, but we need this to run synchronously.\n// because even with top level await, we run into hoisting issues where things happen out of order\n// so we call out to the CLI using execSync\n// this also isolates the varlock loading process from the end user process\n\n\nconst execResult = execSyncVarlock('load --format json-full', {\n exitOnError: true,\n showLogsOnError: true,\n});\nprocess.env.__VARLOCK_ENV = execResult;\n\n// initialize varlock and patch globals as necessary\ninitVarlockEnv();\n// these will be no-ops if these are disabled by settings\npatchGlobalConsole();\npatchGlobalServerResponse();\npatchGlobalResponse();\n\n"]}
|
|
@@ -7,7 +7,7 @@ function execSyncVarlock(command, opts) {
|
|
|
7
7
|
try {
|
|
8
8
|
try {
|
|
9
9
|
const result = execSync(`varlock ${command}`, {
|
|
10
|
-
...opts,
|
|
10
|
+
...opts?.env && { env: opts.env },
|
|
11
11
|
stdio: "pipe"
|
|
12
12
|
});
|
|
13
13
|
return result.toString();
|
|
@@ -52,5 +52,5 @@ function execSyncVarlock(command, opts) {
|
|
|
52
52
|
__name(execSyncVarlock, "execSyncVarlock");
|
|
53
53
|
|
|
54
54
|
export { execSyncVarlock };
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-QT5E2RY6.js.map
|
|
56
|
+
//# sourceMappingURL=chunk-QT5E2RY6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/exec-sync-varlock.ts"],"names":[],"mappings":";;;;;AAcO,SAAS,eAAA,CACd,SACA,IAAA,EAIA;AACA,EAAA,IAAI;AAIF,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,QAAA,CAAS,CAAA,QAAA,EAAW,OAAO,CAAA,CAAA,EAAI;AAAA,QAC5C,GAAG,IAAA,EAAM,GAAA,IAAO,EAAE,GAAA,EAAK,KAAK,GAAA,EAAI;AAAA,QAChC,KAAA,EAAO;AAAA,OACR,CAAA;AACD,MAAA,OAAO,OAAO,QAAA,EAAS;AAAA,IACzB,SAAS,GAAA,EAAK;AAEZ,MAAA,IAAK,GAAA,CAAY,MAAA,KAAW,GAAA,EAAK,MAAM,GAAA;AAAA,IACzC;AAKA,IAAA,IAAI,UAAA,GAAa,QAAQ,GAAA,EAAI;AAC7B,IAAA,OAAO,UAAA,EAAY;AACjB,MAAA,MAAM,eAAA,GAAkB,IAAA,CAAK,IAAA,CAAK,UAAA,EAAY,gBAAgB,MAAM,CAAA;AACpE,MAAA,IAAI,EAAA,CAAG,UAAA,CAAW,eAAe,CAAA,EAAG;AAClC,QAAA,MAAM,mBAAA,GAAsB,IAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,SAAS,CAAA;AAChE,QAAA,IAAI,EAAA,CAAG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\nimport { execSync } from 'node:child_process';\n\n// weird tsup issue using `typeof execSync` from node:child_process\n// see https://github.com/egoist/tsup/issues/1367\nimport type { execSync as execSyncType } from 'child_process';\n\n/**\n * small helper to call execSync and call the varlock cli\n *\n * when end user runs via a package manager, it will inject node_modules/.bin into PATH\n * but otherwise we may need to try to find that path ourselves\n */\nexport function execSyncVarlock(\n command: string,\n opts?: (Parameters<typeof execSyncType>[1] & {\n exitOnError?: boolean,\n showLogsOnError?: boolean,\n }),\n) {\n try {\n // in most cases, user will be running via their package manager\n // and a package.json script (ie `pnpm run start`)\n // which will inject node_modules/.bin into PATH\n try {\n const result = execSync(`varlock ${command}`, {\n ...opts?.env && { env: opts.env },\n stdio: 'pipe',\n });\n return result.toString();\n } catch (err) {\n // code 127 means not found\n if ((err as any).status !== 127) throw err;\n }\n\n // if varlock was not found, it either means it is not installed\n // or we must find the path to node_modules/.bin ourselves\n // so we'll walk up the directory tree looking for it\n let currentDir = process.cwd();\n while (currentDir) {\n const possibleBinPath = path.join(currentDir, 'node_modules', '.bin');\n if (fs.existsSync(possibleBinPath)) {\n const possibleVarlockPath = path.join(possibleBinPath, 'varlock');\n if (fs.existsSync(possibleVarlockPath)) {\n const result = execSync(`${possibleVarlockPath} ${command}`, {\n ...opts,\n stdio: 'pipe',\n });\n // const commandArgs = command.split(' ').filter(Boolean);\n // const result = execFileSync(possibleVarlockPath, commandArgs, opts);\n return result.toString();\n } else {\n throw new Error('Unable to find varlock executable');\n }\n }\n // when we reach the root, it will stop\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) break;\n currentDir = path.dirname(currentDir);\n }\n throw new Error('Unable to find varlock executable');\n } catch (err) {\n const errAny = err as any;\n if (opts?.showLogsOnError) {\n /* eslint-disable no-console */\n if (errAny.stdout) console.log(errAny.stdout.toString());\n if (errAny.stderr) console.error(errAny.stderr.toString());\n\n if (!errAny.stdout && !errAny.stderr) {\n console.error(errAny);\n }\n }\n if (opts?.exitOnError) {\n process.exit((err as any).status ?? 1);\n }\n throw err;\n }\n}\n"]}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { commandSpec } from '../chunk-
|
|
3
|
-
import {
|
|
4
|
-
import { commandSpec as commandSpec$
|
|
1
|
+
import { commandSpec as commandSpec$4 } from '../chunk-LIIRL4NK.js';
|
|
2
|
+
import { commandSpec } from '../chunk-GY623P3W.js';
|
|
3
|
+
import { CliExitError, fmt } from '../chunk-DTNPJJH4.js';
|
|
4
|
+
import { commandSpec as commandSpec$1 } from '../chunk-7L3IF2MK.js';
|
|
5
|
+
import { commandSpec as commandSpec$2 } from '../chunk-MITVWKKH.js';
|
|
5
6
|
import { commandSpec as commandSpec$3 } from '../chunk-RZT65DRA.js';
|
|
6
|
-
import { commandSpec as commandSpec$4 } from '../chunk-OLZUI45U.js';
|
|
7
|
-
import { CliExitError, fmt } from '../chunk-LYSRVOTA.js';
|
|
8
7
|
import { cli } from '../chunk-33ROL4J5.js';
|
|
9
|
-
import { InvalidEnvError } from '../chunk-
|
|
10
|
-
import { ansis_default, gracefulExit,
|
|
8
|
+
import { InvalidEnvError } from '../chunk-NGDIT6C3.js';
|
|
9
|
+
import { ansis_default, gracefulExit, asyncExitHook } from '../chunk-MLIGQWID.js';
|
|
11
10
|
import '../chunk-FGMXIEFA.js';
|
|
12
11
|
import { __commonJS, __name, __toESM } from '../chunk-XN24GZXQ.js';
|
|
13
12
|
import os2 from 'os';
|
|
@@ -17,9 +16,9 @@ import fs, { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
|
17
16
|
import Debug from 'debug';
|
|
18
17
|
import process2 from 'process';
|
|
19
18
|
|
|
20
|
-
// ../../node_modules/.pnpm/ci-info@4.3.
|
|
19
|
+
// ../../node_modules/.pnpm/ci-info@4.3.1/node_modules/ci-info/vendors.json
|
|
21
20
|
var require_vendors = __commonJS({
|
|
22
|
-
"../../node_modules/.pnpm/ci-info@4.3.
|
|
21
|
+
"../../node_modules/.pnpm/ci-info@4.3.1/node_modules/ci-info/vendors.json"(exports, module) {
|
|
23
22
|
module.exports = [
|
|
24
23
|
{
|
|
25
24
|
name: "Agola CI",
|
|
@@ -381,9 +380,9 @@ var require_vendors = __commonJS({
|
|
|
381
380
|
}
|
|
382
381
|
});
|
|
383
382
|
|
|
384
|
-
// ../../node_modules/.pnpm/ci-info@4.3.
|
|
383
|
+
// ../../node_modules/.pnpm/ci-info@4.3.1/node_modules/ci-info/index.js
|
|
385
384
|
var require_ci_info = __commonJS({
|
|
386
|
-
"../../node_modules/.pnpm/ci-info@4.3.
|
|
385
|
+
"../../node_modules/.pnpm/ci-info@4.3.1/node_modules/ci-info/index.js"(exports) {
|
|
387
386
|
var vendors = require_vendors();
|
|
388
387
|
var env = process.env;
|
|
389
388
|
Object.defineProperty(exports, "_vendors", {
|
|
@@ -394,19 +393,21 @@ var require_ci_info = __commonJS({
|
|
|
394
393
|
exports.name = null;
|
|
395
394
|
exports.isPR = null;
|
|
396
395
|
exports.id = null;
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
if (env.CI !== "false") {
|
|
397
|
+
vendors.forEach(function(vendor) {
|
|
398
|
+
const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
|
|
399
|
+
const isCI2 = envs.every(function(obj) {
|
|
400
|
+
return checkEnv(obj);
|
|
401
|
+
});
|
|
402
|
+
exports[vendor.constant] = isCI2;
|
|
403
|
+
if (!isCI2) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
exports.name = vendor.name;
|
|
407
|
+
exports.isPR = checkPR(vendor);
|
|
408
|
+
exports.id = vendor.constant;
|
|
401
409
|
});
|
|
402
|
-
|
|
403
|
-
if (!isCI2) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
exports.name = vendor.name;
|
|
407
|
-
exports.isPR = checkPR(vendor);
|
|
408
|
-
exports.id = vendor.constant;
|
|
409
|
-
});
|
|
410
|
+
}
|
|
410
411
|
exports.isCI = !!(env.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
|
|
411
412
|
(env.BUILD_ID || // Jenkins, Cloudbees
|
|
412
413
|
env.BUILD_NUMBER || // Jenkins, TeamCity
|
|
@@ -493,13 +494,46 @@ function hasDockerCGroup() {
|
|
|
493
494
|
}
|
|
494
495
|
}
|
|
495
496
|
__name(hasDockerCGroup, "hasDockerCGroup");
|
|
496
|
-
function
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
function hasDockerMountInfo() {
|
|
498
|
+
try {
|
|
499
|
+
return fs.readFileSync("/proc/self/mountinfo", "utf8").includes("/docker/containers/");
|
|
500
|
+
} catch {
|
|
501
|
+
return false;
|
|
499
502
|
}
|
|
503
|
+
}
|
|
504
|
+
__name(hasDockerMountInfo, "hasDockerMountInfo");
|
|
505
|
+
function isDocker() {
|
|
506
|
+
isDockerCached ??= hasDockerEnv() || hasDockerCGroup() || hasDockerMountInfo();
|
|
500
507
|
return isDockerCached;
|
|
501
508
|
}
|
|
502
509
|
__name(isDocker, "isDocker");
|
|
510
|
+
var isDockerCached2;
|
|
511
|
+
function hasDockerEnv2() {
|
|
512
|
+
try {
|
|
513
|
+
fs.statSync("/.dockerenv");
|
|
514
|
+
return true;
|
|
515
|
+
} catch {
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
__name(hasDockerEnv2, "hasDockerEnv");
|
|
520
|
+
function hasDockerCGroup2() {
|
|
521
|
+
try {
|
|
522
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
523
|
+
} catch {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
__name(hasDockerCGroup2, "hasDockerCGroup");
|
|
528
|
+
function isDocker2() {
|
|
529
|
+
if (isDockerCached2 === void 0) {
|
|
530
|
+
isDockerCached2 = hasDockerEnv2() || hasDockerCGroup2();
|
|
531
|
+
}
|
|
532
|
+
return isDockerCached2;
|
|
533
|
+
}
|
|
534
|
+
__name(isDocker2, "isDocker");
|
|
535
|
+
|
|
536
|
+
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
503
537
|
var cachedResult;
|
|
504
538
|
var hasContainerEnv = /* @__PURE__ */ __name(() => {
|
|
505
539
|
try {
|
|
@@ -511,7 +545,7 @@ var hasContainerEnv = /* @__PURE__ */ __name(() => {
|
|
|
511
545
|
}, "hasContainerEnv");
|
|
512
546
|
function isInsideContainer() {
|
|
513
547
|
if (cachedResult === void 0) {
|
|
514
|
-
cachedResult = hasContainerEnv() ||
|
|
548
|
+
cachedResult = hasContainerEnv() || isDocker2();
|
|
515
549
|
}
|
|
516
550
|
return cachedResult;
|
|
517
551
|
}
|
|
@@ -538,7 +572,14 @@ var is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
|
538
572
|
|
|
539
573
|
// package.json
|
|
540
574
|
var package_default = {
|
|
541
|
-
version: "0.0
|
|
575
|
+
version: "0.1.0"};
|
|
576
|
+
|
|
577
|
+
// src/config.ts
|
|
578
|
+
var CONFIG = {
|
|
579
|
+
// varlock.dev app
|
|
580
|
+
POSTHOG_API_KEY: "phc_bfzH97VIta8yQa8HrsgmitqS6rTydjMISs0m8aqJTnq",
|
|
581
|
+
POSTHOG_HOST: "https://ph.varlock.dev"
|
|
582
|
+
};
|
|
542
583
|
|
|
543
584
|
// src/cli/helpers/telemetry.ts
|
|
544
585
|
var debug = Debug("varlock:telemetry");
|
|
@@ -712,10 +753,10 @@ __name(trackCommand, "trackCommand");
|
|
|
712
753
|
|
|
713
754
|
// src/cli/cli-executable.ts
|
|
714
755
|
var versionId = package_default.version;
|
|
715
|
-
function buildLazyCommand(
|
|
716
|
-
const commandName =
|
|
756
|
+
function buildLazyCommand(commandSpec6, loadCommandFn) {
|
|
757
|
+
const commandName = commandSpec6.name;
|
|
717
758
|
return {
|
|
718
|
-
...
|
|
759
|
+
...commandSpec6,
|
|
719
760
|
run: /* @__PURE__ */ __name(async (...args) => {
|
|
720
761
|
await trackCommand(commandName, { command: commandName });
|
|
721
762
|
const commandSpecAndFn = await loadCommandFn();
|
|
@@ -725,12 +766,11 @@ function buildLazyCommand(commandSpec7, loadCommandFn) {
|
|
|
725
766
|
}
|
|
726
767
|
__name(buildLazyCommand, "buildLazyCommand");
|
|
727
768
|
var subCommands = /* @__PURE__ */ new Map();
|
|
728
|
-
subCommands.set("init", buildLazyCommand(commandSpec, async () => await import('../init.command-
|
|
729
|
-
subCommands.set("load", buildLazyCommand(commandSpec$1, async () => await import('../load.command-
|
|
730
|
-
subCommands.set("run", buildLazyCommand(commandSpec$2, async () => await import('../run.command-
|
|
769
|
+
subCommands.set("init", buildLazyCommand(commandSpec, async () => await import('../init.command-ASK74XBV.js')));
|
|
770
|
+
subCommands.set("load", buildLazyCommand(commandSpec$1, async () => await import('../load.command-VUKBSBEV.js')));
|
|
771
|
+
subCommands.set("run", buildLazyCommand(commandSpec$2, async () => await import('../run.command-XQ64Z2TN.js')));
|
|
731
772
|
subCommands.set("help", buildLazyCommand(commandSpec$3, async () => await import('../help.command-B7VWA53B.js')));
|
|
732
|
-
subCommands.set("telemetry", buildLazyCommand(commandSpec$4, async () => await import('../telemetry.command-
|
|
733
|
-
subCommands.set("login", buildLazyCommand(commandSpec$5, async () => await import('../login.command-W4DP7RUO.js')));
|
|
773
|
+
subCommands.set("telemetry", buildLazyCommand(commandSpec$4, async () => await import('../telemetry.command-HHZVBFC7.js')));
|
|
734
774
|
(/* @__PURE__ */ __name(async function go() {
|
|
735
775
|
try {
|
|
736
776
|
let args = process.argv.slice(2);
|
|
@@ -765,17 +805,6 @@ subCommands.set("login", buildLazyCommand(commandSpec$5, async () => await impor
|
|
|
765
805
|
gracefulExit(1);
|
|
766
806
|
} else if (error instanceof CliExitError || error instanceof InvalidEnvError) {
|
|
767
807
|
console.error(error.getFormattedOutput());
|
|
768
|
-
} else if (error instanceof EnvSourceParseError) {
|
|
769
|
-
console.error(`\u{1F6A8} Error encountered while loading ${error.location.path}`);
|
|
770
|
-
console.error(error.message);
|
|
771
|
-
const errLoc = error.location;
|
|
772
|
-
const errPreview = [
|
|
773
|
-
errLoc.lineStr,
|
|
774
|
-
`${ansis_default.gray("-".repeat(errLoc.colNumber - 1))}${ansis_default.red("^")}`
|
|
775
|
-
].join("\n");
|
|
776
|
-
console.error("Error parsing .env file");
|
|
777
|
-
console.error(fmt.filePath(`${errLoc.path}:${errLoc.lineNumber}:${errLoc.colNumber}`));
|
|
778
|
-
console.error(errPreview);
|
|
779
808
|
gracefulExit(1);
|
|
780
809
|
} else {
|
|
781
810
|
throw error;
|