varlock 0.1.6 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-QYL63H5X.js → chunk-4CRDKWAU.js} +97 -7
- package/dist/chunk-4CRDKWAU.js.map +1 -0
- package/dist/{chunk-4LIQGKEE.js → chunk-H5IG4ZVM.js} +13 -8
- package/dist/chunk-H5IG4ZVM.js.map +1 -0
- package/dist/{chunk-N6YMZ3HA.js → chunk-NA4YDM42.js} +34 -8
- package/dist/chunk-NA4YDM42.js.map +1 -0
- package/dist/{chunk-ARMP7LS5.js → chunk-NDWB3TT5.js} +3 -3
- package/dist/{chunk-ARMP7LS5.js.map → chunk-NDWB3TT5.js.map} +1 -1
- package/dist/{chunk-6Z6JYESC.js → chunk-NHA2P5AV.js} +30 -6
- package/dist/chunk-NHA2P5AV.js.map +1 -0
- package/dist/{chunk-OOBWRTIS.js → chunk-OKNWYS57.js} +161 -112
- package/dist/chunk-OKNWYS57.js.map +1 -0
- package/dist/{chunk-N4HZJLL3.js → chunk-ZLM3MCYF.js} +16 -5
- package/dist/chunk-ZLM3MCYF.js.map +1 -0
- package/dist/cli/cli-executable.js +12 -12
- package/dist/cli/cli-executable.js.map +1 -1
- package/dist/{env-graph-eF0B8G0j.d.ts → env-graph-BZwrHQbb.d.ts} +0 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -2
- package/dist/init.command-GNLFBWYF.js +8 -0
- package/dist/{init.command-RZ3LEK7W.js.map → init.command-GNLFBWYF.js.map} +1 -1
- package/dist/load.command-WR5QCE6M.js +8 -0
- package/dist/{load.command-6Z3QLGY2.js.map → load.command-WR5QCE6M.js.map} +1 -1
- package/dist/plugin-lib.d.ts +2 -2
- package/dist/run.command-GXQTDDDP.js +9 -0
- package/dist/{run.command-DSZSZMCY.js.map → run.command-GXQTDDDP.js.map} +1 -1
- package/dist/runtime/env.d.ts +1 -1
- package/dist/telemetry.command-ZFW55RLH.js +8 -0
- package/dist/{telemetry.command-XKHQ3QFE.js.map → telemetry.command-ZFW55RLH.js.map} +1 -1
- package/package.json +2 -2
- package/dist/chunk-4LIQGKEE.js.map +0 -1
- package/dist/chunk-6Z6JYESC.js.map +0 -1
- package/dist/chunk-N4HZJLL3.js.map +0 -1
- package/dist/chunk-N6YMZ3HA.js.map +0 -1
- package/dist/chunk-OOBWRTIS.js.map +0 -1
- package/dist/chunk-QYL63H5X.js.map +0 -1
- package/dist/init.command-RZ3LEK7W.js +0 -8
- package/dist/load.command-6Z3QLGY2.js +0 -8
- package/dist/run.command-DSZSZMCY.js +0 -9
- package/dist/telemetry.command-XKHQ3QFE.js +0 -8
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { redactString } from './chunk-FGMXIEFA.js';
|
|
2
2
|
import { __commonJS, __name, __toESM } from './chunk-XN24GZXQ.js';
|
|
3
3
|
import process2 from 'process';
|
|
4
|
-
import { exec } from 'child_process';
|
|
5
|
-
import { promisify } from 'util';
|
|
6
4
|
import fs, { accessSync } from 'fs';
|
|
7
5
|
import fs2, { access } from 'fs/promises';
|
|
6
|
+
import os from 'os';
|
|
8
7
|
import path2 from 'path';
|
|
9
8
|
import { ParsedEnvSpecFunctionCall, ParsedEnvSpecStaticValue, ParsedEnvSpecFunctionArgs, ParsedEnvSpecKeyValuePair, parseEnvSpecDotEnvFile } from '@env-spec/parser';
|
|
10
|
-
import
|
|
9
|
+
import { exec } from 'child_process';
|
|
10
|
+
import { promisify } from 'util';
|
|
11
11
|
import crypto from 'crypto';
|
|
12
12
|
import https from 'https';
|
|
13
13
|
import semver from 'semver';
|
|
@@ -1097,30 +1097,6 @@ async function tryCatch(tryFn, catchFn) {
|
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
1099
|
__name(tryCatch, "tryCatch");
|
|
1100
|
-
var asyncExec = promisify(exec);
|
|
1101
|
-
|
|
1102
|
-
// ../utils/src/git-utils.ts
|
|
1103
|
-
async function checkIsFileGitIgnored(path4, warnIfNotGitRepo = false) {
|
|
1104
|
-
try {
|
|
1105
|
-
await asyncExec(`git check-ignore ${path4} -q`);
|
|
1106
|
-
return true;
|
|
1107
|
-
} catch (err) {
|
|
1108
|
-
const stderr = err.stderr;
|
|
1109
|
-
if (err.status === 127 || stderr.includes("not found") || stderr.includes("not recognized")) {
|
|
1110
|
-
return void 0;
|
|
1111
|
-
}
|
|
1112
|
-
if (err.code === "ENOENT") return void 0;
|
|
1113
|
-
if (stderr === "") return false;
|
|
1114
|
-
if (stderr.includes("not a git repository")) {
|
|
1115
|
-
if (warnIfNotGitRepo) {
|
|
1116
|
-
console.log("\u{1F536} Your code is not currently in a git repository - run `git init` to initialize a new repo.");
|
|
1117
|
-
}
|
|
1118
|
-
return false;
|
|
1119
|
-
}
|
|
1120
|
-
throw err;
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
__name(checkIsFileGitIgnored, "checkIsFileGitIgnored");
|
|
1124
1100
|
async function pathExists(p) {
|
|
1125
1101
|
try {
|
|
1126
1102
|
await access(p);
|
|
@@ -1713,6 +1689,10 @@ var builtInItemDecorators = [
|
|
|
1713
1689
|
{
|
|
1714
1690
|
name: "sensitive"
|
|
1715
1691
|
},
|
|
1692
|
+
{
|
|
1693
|
+
name: "public",
|
|
1694
|
+
incompatibleWith: ["sensitive"]
|
|
1695
|
+
},
|
|
1716
1696
|
{
|
|
1717
1697
|
name: "type",
|
|
1718
1698
|
useFnArgsResolver: true
|
|
@@ -2976,17 +2956,19 @@ var ConfigItem = class {
|
|
|
2976
2956
|
async processSensitive() {
|
|
2977
2957
|
const sensitiveFromDataType = this.dataType?.isSensitive;
|
|
2978
2958
|
for (const def of this.defs) {
|
|
2979
|
-
const
|
|
2959
|
+
const sensitiveDecs = def.itemDef.decorators?.filter((d) => d.name === "sensitive" || d.name === "public") || [];
|
|
2960
|
+
const sensitiveDec = sensitiveDecs[0];
|
|
2980
2961
|
if (sensitiveDec) {
|
|
2962
|
+
const usingPublic = sensitiveDec.name === "public";
|
|
2981
2963
|
const sensitiveDecValue = await sensitiveDec.resolve();
|
|
2982
2964
|
if (sensitiveDec.schemaErrors.length) {
|
|
2983
2965
|
return;
|
|
2984
2966
|
}
|
|
2985
2967
|
if (![true, false, void 0].includes(sensitiveDecValue)) {
|
|
2986
|
-
throw new SchemaError("@sensitive must resolve to a boolean or undefined");
|
|
2968
|
+
throw new SchemaError("@sensitive/@public must resolve to a boolean or undefined");
|
|
2987
2969
|
}
|
|
2988
2970
|
if (sensitiveDecValue !== void 0) {
|
|
2989
|
-
this._isSensitive = sensitiveDecValue;
|
|
2971
|
+
this._isSensitive = usingPublic ? !sensitiveDecValue : sensitiveDecValue;
|
|
2990
2972
|
return;
|
|
2991
2973
|
}
|
|
2992
2974
|
}
|
|
@@ -3301,7 +3283,7 @@ async function registerPluginInGraph(graph, plugin, pluginDecorator) {
|
|
|
3301
3283
|
}
|
|
3302
3284
|
__name(registerPluginInGraph, "registerPluginInGraph");
|
|
3303
3285
|
async function downloadPlugin(url) {
|
|
3304
|
-
const
|
|
3286
|
+
const exec2 = promisify(exec);
|
|
3305
3287
|
const cacheDir = path2.join(os.homedir(), ".varlock", "plugins-cache");
|
|
3306
3288
|
const indexPath = path2.join(cacheDir, "index.json");
|
|
3307
3289
|
await fs2.mkdir(cacheDir, { recursive: true });
|
|
@@ -3332,7 +3314,7 @@ async function downloadPlugin(url) {
|
|
|
3332
3314
|
});
|
|
3333
3315
|
const tmpExtractDir = path2.join(cacheDir, `tmp-extract-${crypto.randomBytes(8).toString("hex")}`);
|
|
3334
3316
|
await fs2.mkdir(tmpExtractDir);
|
|
3335
|
-
await
|
|
3317
|
+
await exec2(`tar -xzf ${tmpTgz} -C ${tmpExtractDir}`);
|
|
3336
3318
|
let pkgJsonPath = path2.join(tmpExtractDir, "package", "package.json");
|
|
3337
3319
|
let pluginRoot = path2.join(tmpExtractDir, "package");
|
|
3338
3320
|
if (!await fs2.stat(pkgJsonPath).then(() => true, () => false)) {
|
|
@@ -3594,19 +3576,27 @@ var EnvGraphDataSource4 = class {
|
|
|
3594
3576
|
this._loadingError = new Error("Cannot use both @currentEnv and @envFlag decorators");
|
|
3595
3577
|
}
|
|
3596
3578
|
let envFlagItemKey;
|
|
3579
|
+
let skipCurrentEnvProcessing = false;
|
|
3597
3580
|
if (currentEnvDec) {
|
|
3598
|
-
|
|
3599
|
-
if (
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3581
|
+
const parsedValue = currentEnvDec.parsedDecorator.value;
|
|
3582
|
+
if (parsedValue instanceof ParsedEnvSpecFunctionCall && parsedValue.name === "ref") {
|
|
3583
|
+
const args = parsedValue.simplifiedArgs;
|
|
3584
|
+
if (Array.isArray(args) && args.length > 0 && typeof args[0] === "string") {
|
|
3585
|
+
envFlagItemKey = args[0];
|
|
3586
|
+
if (this.isPartialImport && !this.importKeys?.includes(envFlagItemKey)) {
|
|
3587
|
+
skipCurrentEnvProcessing = true;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3604
3590
|
}
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3591
|
+
if (!skipCurrentEnvProcessing) {
|
|
3592
|
+
await currentEnvDec.process();
|
|
3593
|
+
if (!currentEnvDec.decValueResolver) {
|
|
3594
|
+
throw new Error("No resolver found for @currentEnv decorator");
|
|
3595
|
+
}
|
|
3596
|
+
if (currentEnvDec.decValueResolver.fnName !== "ref") {
|
|
3597
|
+
throw new Error("Expected @currentEnv decorator to be set to direct reference - ie `$APP_ENV`");
|
|
3598
|
+
}
|
|
3608
3599
|
}
|
|
3609
|
-
envFlagItemKey = refArgValue;
|
|
3610
3600
|
} else if (envFlagDec) {
|
|
3611
3601
|
await envFlagDec.process();
|
|
3612
3602
|
if (!envFlagDec.decValueResolver) throw new Error("@envFlag resolver not set");
|
|
@@ -3631,74 +3621,112 @@ var EnvGraphDataSource4 = class {
|
|
|
3631
3621
|
const importDecs = this.getRootDecFns("import");
|
|
3632
3622
|
if (importDecs.length) {
|
|
3633
3623
|
for (const importDec of importDecs) {
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
}
|
|
3644
|
-
const fullImportPath = path2.resolve(this.fullPath, "..", importPath);
|
|
3645
|
-
const fileName = path2.basename(fullImportPath);
|
|
3646
|
-
if (this.graph.virtualImports) {
|
|
3647
|
-
if (importPath.endsWith("/")) {
|
|
3648
|
-
if (!Object.keys(this.graph.virtualImports).some((p) => p.startsWith(fullImportPath))) {
|
|
3649
|
-
this._loadingError = new Error(`Virtual directory import ${fullImportPath} not found`);
|
|
3650
|
-
return;
|
|
3651
|
-
}
|
|
3652
|
-
await this.addChild(new DirectoryDataSource(fullImportPath), {
|
|
3653
|
-
isImport: true,
|
|
3654
|
-
importKeys
|
|
3655
|
-
});
|
|
3656
|
-
} else {
|
|
3657
|
-
if (!this.graph.virtualImports[fullImportPath]) {
|
|
3658
|
-
this._loadingError = new Error(`Virtual import ${fullImportPath} not found`);
|
|
3659
|
-
return;
|
|
3624
|
+
try {
|
|
3625
|
+
await importDec.process();
|
|
3626
|
+
if (importDec.decValueResolver?.objArgs?.enabled) {
|
|
3627
|
+
const enabledResolver = importDec.decValueResolver.objArgs.enabled;
|
|
3628
|
+
const enabledDeps = enabledResolver.deps;
|
|
3629
|
+
for (const depKey of enabledDeps) {
|
|
3630
|
+
const depItem = this.graph.configSchema[depKey];
|
|
3631
|
+
if (!depItem) {
|
|
3632
|
+
throw new Error(`@import enabled parameter depends on non-existent item: ${depKey}`);
|
|
3660
3633
|
}
|
|
3661
|
-
|
|
3662
|
-
overrideContents: this.graph.virtualImports[fullImportPath]
|
|
3663
|
-
});
|
|
3664
|
-
await this.addChild(source, { isImport: true, importKeys });
|
|
3634
|
+
await depItem.earlyResolve();
|
|
3665
3635
|
}
|
|
3666
|
-
}
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3636
|
+
}
|
|
3637
|
+
const importArgs = await importDec.resolve();
|
|
3638
|
+
const importPath = importArgs.arr[0];
|
|
3639
|
+
const importKeys = importArgs.arr.slice(1);
|
|
3640
|
+
if (!importKeys.every(my_dash_default.isString)) {
|
|
3641
|
+
throw new Error("expected @import keys to all be strings");
|
|
3642
|
+
}
|
|
3643
|
+
let fullImportPath;
|
|
3644
|
+
if (importPath.startsWith("./") || importPath.startsWith("../")) {
|
|
3645
|
+
if (!(this instanceof FileBasedDataSource)) {
|
|
3646
|
+
throw new Error("@import of files can only be used from a file-based data source");
|
|
3672
3647
|
}
|
|
3673
|
-
|
|
3674
|
-
|
|
3648
|
+
fullImportPath = path2.resolve(this.fullPath, "..", importPath);
|
|
3649
|
+
} else if (importPath.startsWith("~/") || importPath === "~") {
|
|
3650
|
+
fullImportPath = path2.join(os.homedir(), importPath.slice(1));
|
|
3651
|
+
} else if (importPath.startsWith("/")) {
|
|
3652
|
+
fullImportPath = importPath;
|
|
3653
|
+
}
|
|
3654
|
+
const enabledValue = importArgs.obj.enabled ?? true;
|
|
3655
|
+
if (!my_dash_default.isBoolean(enabledValue)) {
|
|
3656
|
+
throw new Error("expected @import enabled parameter to be a boolean");
|
|
3657
|
+
}
|
|
3658
|
+
if (!enabledValue) continue;
|
|
3659
|
+
const allowMissing = importArgs.obj.allowMissing ?? false;
|
|
3660
|
+
if (!my_dash_default.isBoolean(allowMissing)) {
|
|
3661
|
+
throw new Error("expected @import allowMissing parameter to be a boolean");
|
|
3662
|
+
}
|
|
3663
|
+
if (fullImportPath) {
|
|
3664
|
+
const fileName = path2.basename(fullImportPath);
|
|
3665
|
+
if (this.graph.virtualImports) {
|
|
3666
|
+
if (importPath.endsWith("/")) {
|
|
3667
|
+
const dirExists = Object.keys(this.graph.virtualImports).some((p) => p.startsWith(fullImportPath));
|
|
3668
|
+
if (!dirExists && allowMissing) continue;
|
|
3669
|
+
if (!dirExists) {
|
|
3670
|
+
this._loadingError = new Error(`Virtual directory import ${fullImportPath} not found`);
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3675
3673
|
await this.addChild(new DirectoryDataSource(fullImportPath), {
|
|
3676
3674
|
isImport: true,
|
|
3677
3675
|
importKeys
|
|
3678
3676
|
});
|
|
3679
3677
|
} else {
|
|
3680
|
-
|
|
3681
|
-
|
|
3678
|
+
const fileExists = this.graph.virtualImports[fullImportPath];
|
|
3679
|
+
if (!fileExists && allowMissing) continue;
|
|
3680
|
+
if (!fileExists) {
|
|
3681
|
+
this._loadingError = new Error(`Virtual import ${fullImportPath} not found`);
|
|
3682
|
+
return;
|
|
3683
|
+
}
|
|
3684
|
+
const source = new DotEnvFileDataSource(fullImportPath, {
|
|
3685
|
+
overrideContents: this.graph.virtualImports[fullImportPath]
|
|
3686
|
+
});
|
|
3687
|
+
await this.addChild(source, { isImport: true, importKeys });
|
|
3682
3688
|
}
|
|
3683
3689
|
} else {
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
this._loadingError = new Error(
|
|
3690
|
+
const fsStat = await tryCatch(async () => fs2.stat(fullImportPath), (_err) => {
|
|
3691
|
+
});
|
|
3692
|
+
if (!fsStat && allowMissing) continue;
|
|
3693
|
+
if (!fsStat) {
|
|
3694
|
+
this._loadingError = new Error(`Import path does not exist: ${fullImportPath}`);
|
|
3689
3695
|
return;
|
|
3690
3696
|
}
|
|
3691
|
-
|
|
3697
|
+
if (importPath.endsWith("/")) {
|
|
3698
|
+
if (fsStat.isDirectory()) {
|
|
3699
|
+
await this.addChild(new DirectoryDataSource(fullImportPath), {
|
|
3700
|
+
isImport: true,
|
|
3701
|
+
importKeys
|
|
3702
|
+
});
|
|
3703
|
+
} else {
|
|
3704
|
+
this._loadingError = new Error(`Imported path ending with "/" is not a directory: ${fullImportPath}`);
|
|
3705
|
+
return;
|
|
3706
|
+
}
|
|
3707
|
+
} else {
|
|
3708
|
+
if (fsStat.isDirectory()) {
|
|
3709
|
+
this._loadingError = new Error('Imported path is a directory, add trailing "/" to import');
|
|
3710
|
+
return;
|
|
3711
|
+
} else if (!fileName.startsWith(".env.")) {
|
|
3712
|
+
this._loadingError = new Error("imported file must be a .env.* file");
|
|
3713
|
+
return;
|
|
3714
|
+
}
|
|
3715
|
+
await this.addChild(new DotEnvFileDataSource(fullImportPath), { isImport: true, importKeys });
|
|
3716
|
+
}
|
|
3692
3717
|
}
|
|
3718
|
+
} else if (importPath.startsWith("http://") || importPath.startsWith("https://")) {
|
|
3719
|
+
this._loadingError = new Error("http imports not supported yet");
|
|
3720
|
+
return;
|
|
3721
|
+
} else if (importPath.startsWith("npm:")) {
|
|
3722
|
+
this._loadingError = new Error("npm imports not supported yet");
|
|
3723
|
+
return;
|
|
3724
|
+
} else {
|
|
3725
|
+
this._loadingError = new Error("unsupported import type");
|
|
3726
|
+
return;
|
|
3693
3727
|
}
|
|
3694
|
-
}
|
|
3695
|
-
this._loadingError =
|
|
3696
|
-
return;
|
|
3697
|
-
} else if (importPath.startsWith("npm:")) {
|
|
3698
|
-
this._loadingError = new Error("npm imports not supported yet");
|
|
3699
|
-
return;
|
|
3700
|
-
} else {
|
|
3701
|
-
this._loadingError = new Error("unsupported import type");
|
|
3728
|
+
} catch (err) {
|
|
3729
|
+
this._loadingError = err;
|
|
3702
3730
|
return;
|
|
3703
3731
|
}
|
|
3704
3732
|
}
|
|
@@ -3758,7 +3786,6 @@ var FileBasedDataSource = class extends EnvGraphDataSource4 {
|
|
|
3758
3786
|
static {
|
|
3759
3787
|
__name(this, "FileBasedDataSource");
|
|
3760
3788
|
}
|
|
3761
|
-
isGitIgnored;
|
|
3762
3789
|
fullPath;
|
|
3763
3790
|
fileName;
|
|
3764
3791
|
rawContents;
|
|
@@ -3782,7 +3809,6 @@ var FileBasedDataSource = class extends EnvGraphDataSource4 {
|
|
|
3782
3809
|
this.relativePath = path2.relative(process.cwd(), fullPath);
|
|
3783
3810
|
if (opts?.overrideContents) {
|
|
3784
3811
|
this.rawContents = opts.overrideContents;
|
|
3785
|
-
this.isGitIgnored = opts.overrideGitIgnored;
|
|
3786
3812
|
}
|
|
3787
3813
|
if (this.fileName.startsWith(".env")) {
|
|
3788
3814
|
const fileNameParts = this.fileName.substring(1).split(".");
|
|
@@ -3813,7 +3839,6 @@ var FileBasedDataSource = class extends EnvGraphDataSource4 {
|
|
|
3813
3839
|
this._loadingError = new Error(`File does not exist: ${this.fullPath}`);
|
|
3814
3840
|
return;
|
|
3815
3841
|
}
|
|
3816
|
-
this.isGitIgnored = await checkIsFileGitIgnored(this.fullPath);
|
|
3817
3842
|
this.rawContents = await fs2.readFile(this.fullPath, "utf8");
|
|
3818
3843
|
}
|
|
3819
3844
|
if (this.rawContents) await this._parseContents();
|
|
@@ -3894,25 +3919,49 @@ var DirectoryDataSource = class extends EnvGraphDataSource4 {
|
|
|
3894
3919
|
this.schemaDataSource = this.children[this.children.length - 1];
|
|
3895
3920
|
}
|
|
3896
3921
|
await this.addAutoLoadedFile(".env.local");
|
|
3897
|
-
|
|
3922
|
+
let currentEnv;
|
|
3923
|
+
if (this.schemaDataSource?._envFlagKey) {
|
|
3924
|
+
const envFlagKey = this.schemaDataSource._envFlagKey;
|
|
3925
|
+
if (this.isPartialImport && !this.importKeys?.includes(envFlagKey)) {
|
|
3926
|
+
this._loadingError = new Error(
|
|
3927
|
+
`Imported directory has @currentEnv set to $${envFlagKey}, but "${envFlagKey}" is not included in the import list. Add "${envFlagKey}" to the @import() arguments.`
|
|
3928
|
+
);
|
|
3929
|
+
return;
|
|
3930
|
+
}
|
|
3931
|
+
const envFlagItem = this.graph.configSchema[envFlagKey];
|
|
3932
|
+
if (envFlagItem) {
|
|
3933
|
+
if (!envFlagItem.resolvedValue) await envFlagItem.earlyResolve();
|
|
3934
|
+
currentEnv = envFlagItem.resolvedValue?.toString();
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
currentEnv ||= (await this.resolveCurrentEnv())?.toString() || this.envFlagValue?.toString();
|
|
3898
3938
|
if (currentEnv) {
|
|
3899
3939
|
await this.addAutoLoadedFile(`.env.${currentEnv}`);
|
|
3900
3940
|
await this.addAutoLoadedFile(`.env.${currentEnv}.local`);
|
|
3901
3941
|
}
|
|
3902
3942
|
}
|
|
3903
3943
|
};
|
|
3904
|
-
|
|
3905
|
-
// src/env-graph/lib/loader.ts
|
|
3906
3944
|
async function loadEnvGraph(opts) {
|
|
3907
3945
|
const graph = new EnvGraph2();
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3946
|
+
if (opts?.entryFilePath) {
|
|
3947
|
+
const resolvedPath = path2.resolve(opts.entryFilePath);
|
|
3948
|
+
if (opts.entryFilePath.endsWith("/") || opts.entryFilePath.endsWith(path2.sep)) {
|
|
3949
|
+
graph.basePath = resolvedPath;
|
|
3950
|
+
if (opts?.afterInit) await opts.afterInit(graph);
|
|
3951
|
+
if (opts?.currentEnvFallback) graph.envFlagFallback = opts.currentEnvFallback;
|
|
3952
|
+
await graph.setRootDataSource(new DirectoryDataSource(resolvedPath));
|
|
3953
|
+
} else {
|
|
3954
|
+
graph.basePath = path2.dirname(resolvedPath);
|
|
3955
|
+
if (opts?.afterInit) await opts.afterInit(graph);
|
|
3956
|
+
if (opts?.currentEnvFallback) graph.envFlagFallback = opts.currentEnvFallback;
|
|
3957
|
+
await graph.setRootDataSource(new DotEnvFileDataSource(resolvedPath));
|
|
3958
|
+
}
|
|
3959
|
+
} else {
|
|
3960
|
+
graph.basePath = opts?.basePath ?? process.cwd();
|
|
3961
|
+
if (opts?.afterInit) await opts.afterInit(graph);
|
|
3962
|
+
if (opts?.currentEnvFallback) graph.envFlagFallback = opts.currentEnvFallback;
|
|
3963
|
+
await graph.setRootDataSource(new DirectoryDataSource(graph.basePath));
|
|
3914
3964
|
}
|
|
3915
|
-
await graph.setRootDataSource(new DirectoryDataSource(graph.basePath));
|
|
3916
3965
|
await graph.finishLoad();
|
|
3917
3966
|
return graph;
|
|
3918
3967
|
}
|
|
@@ -4007,6 +4056,6 @@ function getItemSummary(item) {
|
|
|
4007
4056
|
__name(getItemSummary, "getItemSummary");
|
|
4008
4057
|
//! these are probably not relevant anymore, or needs to move to a plugin layer?
|
|
4009
4058
|
|
|
4010
|
-
export { CoercionError, ConfigLoadError, DotEnvFileDataSource, EnvGraph2 as EnvGraph, FileBasedDataSource, ResolutionError, SchemaError, ValidationError, VarlockError, ansis_default, asyncExitHook,
|
|
4011
|
-
//# sourceMappingURL=chunk-
|
|
4012
|
-
//# sourceMappingURL=chunk-
|
|
4059
|
+
export { CoercionError, ConfigLoadError, DotEnvFileDataSource, EnvGraph2 as EnvGraph, FileBasedDataSource, ResolutionError, SchemaError, ValidationError, VarlockError, ansis_default, asyncExitHook, getItemSummary, gracefulExit, joinAndCompact, loadEnvGraph, my_dash_default, pathExists, pathExistsSync, tryCatch };
|
|
4060
|
+
//# sourceMappingURL=chunk-OKNWYS57.js.map
|
|
4061
|
+
//# sourceMappingURL=chunk-OKNWYS57.js.map
|