varlock 0.0.8 → 0.0.9

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.
Files changed (69) hide show
  1. package/dist/auto-load.js +5 -6
  2. package/dist/{chunk-SHQHITWV.js → chunk-2CM4YUFY.js} +49 -19
  3. package/dist/chunk-2CM4YUFY.js.map +1 -0
  4. package/dist/{chunk-BM3UAHAH.js → chunk-4CE75BSX.js} +5 -5
  5. package/dist/{chunk-BM3UAHAH.js.map → chunk-4CE75BSX.js.map} +1 -1
  6. package/dist/{chunk-H5PNRKYP.js → chunk-4WMY2EW3.js} +5 -5
  7. package/dist/{chunk-H5PNRKYP.js.map → chunk-4WMY2EW3.js.map} +1 -1
  8. package/dist/{chunk-7OHVYEDG.js → chunk-CYYLAV42.js} +3 -4
  9. package/dist/chunk-CYYLAV42.js.map +1 -0
  10. package/dist/{chunk-P74HB2II.js → chunk-ELJZUQX3.js} +4 -5
  11. package/dist/chunk-ELJZUQX3.js.map +1 -0
  12. package/dist/{chunk-5B7JZEDE.js → chunk-FLO6F7B6.js} +3 -4
  13. package/dist/chunk-FLO6F7B6.js.map +1 -0
  14. package/dist/{chunk-GYHC6Y7D.js → chunk-FYLMYWUF.js} +3 -3
  15. package/dist/{chunk-GYHC6Y7D.js.map → chunk-FYLMYWUF.js.map} +1 -1
  16. package/dist/{chunk-YK4SATSE.js → chunk-GWQT5VGW.js} +4 -4
  17. package/dist/{chunk-YK4SATSE.js.map → chunk-GWQT5VGW.js.map} +1 -1
  18. package/dist/{chunk-PQPGBNGV.js → chunk-KCX4NC7Q.js} +5 -5
  19. package/dist/{chunk-PQPGBNGV.js.map → chunk-KCX4NC7Q.js.map} +1 -1
  20. package/dist/{chunk-6FFRZOIK.js → chunk-LS6F7BSZ.js} +4 -4
  21. package/dist/{chunk-6FFRZOIK.js.map → chunk-LS6F7BSZ.js.map} +1 -1
  22. package/dist/{chunk-UFPWQAFZ.js → chunk-PB7RWVE6.js} +3 -3
  23. package/dist/chunk-PB7RWVE6.js.map +1 -0
  24. package/dist/chunk-WYJDUDC4.js +14 -0
  25. package/dist/{chunk-CQHOPN6M.js.map → chunk-WYJDUDC4.js.map} +1 -1
  26. package/dist/chunk-ZUG7BEY5.js +17 -0
  27. package/dist/chunk-ZUG7BEY5.js.map +1 -0
  28. package/dist/{chunk-Y2RFMQ5X.js → chunk-ZW2T4C6A.js} +83 -23
  29. package/dist/chunk-ZW2T4C6A.js.map +1 -0
  30. package/dist/cli/cli-executable.js +15 -15
  31. package/dist/cli/cli-executable.js.map +1 -1
  32. package/dist/dotenv-compat.js +5 -6
  33. package/dist/env-KH4bPru7.d.ts +356 -0
  34. package/dist/index.d.ts +14 -5
  35. package/dist/index.js +8 -9
  36. package/dist/index.js.map +1 -1
  37. package/dist/init.command-ZRQOE2OK.js +9 -0
  38. package/dist/{init.command-L4HF4372.js.map → init.command-ZRQOE2OK.js.map} +1 -1
  39. package/dist/load.command-YBN3BW6U.js +9 -0
  40. package/dist/{load.command-VHNPXTDI.js.map → load.command-YBN3BW6U.js.map} +1 -1
  41. package/dist/login.command-F5AWKZKA.js +8 -0
  42. package/dist/{login.command-OIQBNMNZ.js.map → login.command-F5AWKZKA.js.map} +1 -1
  43. package/dist/run.command-WWJ6ZE26.js +9 -0
  44. package/dist/{run.command-2OE432A5.js.map → run.command-WWJ6ZE26.js.map} +1 -1
  45. package/dist/runtime/env.d.ts +3 -1
  46. package/dist/runtime/env.js +1 -1
  47. package/dist/runtime/patch-console.js +2 -3
  48. package/dist/runtime/patch-response.js +2 -3
  49. package/dist/runtime/patch-server-response.js +2 -3
  50. package/dist/telemetry.command-IS2JLIZM.js +8 -0
  51. package/dist/{telemetry.command-MYQU7FPB.js.map → telemetry.command-IS2JLIZM.js.map} +1 -1
  52. package/package.json +1 -2
  53. package/dist/chunk-5B7JZEDE.js.map +0 -1
  54. package/dist/chunk-7OHVYEDG.js.map +0 -1
  55. package/dist/chunk-CQHOPN6M.js +0 -14
  56. package/dist/chunk-LZ45SLAI.js +0 -12
  57. package/dist/chunk-LZ45SLAI.js.map +0 -1
  58. package/dist/chunk-MPS3IXAW.js +0 -70
  59. package/dist/chunk-MPS3IXAW.js.map +0 -1
  60. package/dist/chunk-P74HB2II.js.map +0 -1
  61. package/dist/chunk-SHQHITWV.js.map +0 -1
  62. package/dist/chunk-UFPWQAFZ.js.map +0 -1
  63. package/dist/chunk-Y2RFMQ5X.js.map +0 -1
  64. package/dist/env-k8iRuXIH.d.ts +0 -42
  65. package/dist/init.command-L4HF4372.js +0 -9
  66. package/dist/load.command-VHNPXTDI.js +0 -9
  67. package/dist/login.command-OIQBNMNZ.js +0 -8
  68. package/dist/run.command-2OE432A5.js +0 -9
  69. package/dist/telemetry.command-MYQU7FPB.js +0 -8
@@ -780,7 +780,7 @@ function mapValues(obj, fn) {
780
780
  }
781
781
  __name(mapValues, "mapValues");
782
782
  function times(count, fn) {
783
- return Array.from({ length: count }, (_3, i) => fn(i));
783
+ return Array.from({ length: count }, (_4, i) => fn(i));
784
784
  }
785
785
  __name(times, "times");
786
786
  function map(array, fn) {
@@ -819,7 +819,7 @@ var _ = {
819
819
  };
820
820
  var my_dash_default = _;
821
821
 
822
- // ../env-graph/src/lib/errors.ts
822
+ // env-graph/lib/errors.ts
823
823
  var VarlockError = class extends Error {
824
824
  constructor(errOrMessage, more) {
825
825
  super(my_dash_default.isError(errOrMessage) ? errOrMessage.message : errOrMessage);
@@ -948,13 +948,13 @@ var EmptyRequiredValueError = class extends ValidationError {
948
948
  var asyncExec = promisify(exec);
949
949
 
950
950
  // ../utils/src/git-utils.ts
951
- async function checkIsFileGitIgnored(path4, warnIfNotGitRepo = false) {
951
+ async function checkIsFileGitIgnored(path5, warnIfNotGitRepo = false) {
952
952
  try {
953
- await asyncExec(`git check-ignore ${path4} -q`);
953
+ await asyncExec(`git check-ignore ${path5} -q`);
954
954
  return true;
955
955
  } catch (err) {
956
956
  const stderr = err.stderr;
957
- if (stderr.includes("command not found")) return void 0;
957
+ if (stderr.includes("not found")) return void 0;
958
958
  if (err.code === "ENOENT") return void 0;
959
959
  if (stderr === "") return false;
960
960
  if (stderr.includes("not a git repository")) {
@@ -985,7 +985,7 @@ async function tryCatch(tryFn, catchFn) {
985
985
  }
986
986
  __name(tryCatch, "tryCatch");
987
987
 
988
- // ../env-graph/src/lib/data-types.ts
988
+ // env-graph/lib/data-types.ts
989
989
  var EnvGraphDataType = class {
990
990
  constructor(def, factory) {
991
991
  this.def = def;
@@ -1333,7 +1333,7 @@ var BaseDataTypes = {
1333
1333
  md5: Md5DataType
1334
1334
  };
1335
1335
 
1336
- // ../env-graph/src/lib/simple-queue.ts
1336
+ // env-graph/lib/simple-queue.ts
1337
1337
  var SimpleQueue = class {
1338
1338
  static {
1339
1339
  __name(this, "SimpleQueue");
@@ -1371,7 +1371,7 @@ var SimpleQueue = class {
1371
1371
  }
1372
1372
  };
1373
1373
 
1374
- // ../env-graph/src/lib/resolver.ts
1374
+ // env-graph/lib/resolver.ts
1375
1375
  var execAsync = promisify(exec);
1376
1376
  var Resolver = class {
1377
1377
  constructor(fnArgs) {
@@ -1657,7 +1657,7 @@ var BaseResolvers = [
1657
1657
  RegexResolver
1658
1658
  ];
1659
1659
 
1660
- // ../env-graph/src/lib/graph-utils.ts
1660
+ // env-graph/lib/graph-utils.ts
1661
1661
  function findGraphCycles(graph) {
1662
1662
  const visited = /* @__PURE__ */ new Set();
1663
1663
  const recursionStack = /* @__PURE__ */ new Set();
@@ -1841,7 +1841,7 @@ async function generateTypes(graph, lang, outputPath) {
1841
1841
  }
1842
1842
  __name(generateTypes, "generateTypes");
1843
1843
 
1844
- // ../env-graph/src/lib/env-graph.ts
1844
+ // env-graph/lib/env-graph.ts
1845
1845
  var EnvGraph2 = class {
1846
1846
  static {
1847
1847
  __name(this, "EnvGraph");
@@ -2077,15 +2077,24 @@ var EnvGraph2 = class {
2077
2077
  }
2078
2078
  };
2079
2079
 
2080
- // ../env-graph/src/lib/config-item.ts
2080
+ // env-graph/lib/config-item.ts
2081
2081
  var ConfigItem3 = class {
2082
- constructor(envGraph, key) {
2083
- this.envGraph = envGraph;
2084
- this.key = key;
2085
- }
2086
2082
  static {
2087
2083
  __name(this, "ConfigItem");
2088
2084
  }
2085
+ // annoyingly we cannot use readonly if we want to support `erasableSyntaxOnly`
2086
+ #envGraph;
2087
+ #key;
2088
+ constructor(_envGraph, _key) {
2089
+ this.#envGraph = _envGraph;
2090
+ this.#key = _key;
2091
+ }
2092
+ get envGraph() {
2093
+ return this.#envGraph;
2094
+ }
2095
+ get key() {
2096
+ return this.#key;
2097
+ }
2089
2098
  defs = [];
2090
2099
  addDef(itemDef, source) {
2091
2100
  this.defs.unshift({ itemDef, source });
@@ -2318,7 +2327,7 @@ var ConfigItem3 = class {
2318
2327
  }
2319
2328
  };
2320
2329
 
2321
- // ../env-graph/src/lib/data-source.ts
2330
+ // env-graph/lib/data-source.ts
2322
2331
  var DATA_SOURCE_TYPES = Object.freeze({
2323
2332
  schema: {
2324
2333
  fileSuffixes: ["schema"],
@@ -2396,13 +2405,14 @@ var ProcessEnvDataSource = class _ProcessEnvDataSource extends EnvGraphDataSourc
2396
2405
  }
2397
2406
  };
2398
2407
  var EnvSourceParseError = class extends Error {
2399
- constructor(message, location) {
2400
- super(message);
2401
- this.location = location;
2402
- }
2403
2408
  static {
2404
2409
  __name(this, "EnvSourceParseError");
2405
2410
  }
2411
+ location;
2412
+ constructor(message, _location) {
2413
+ super(message);
2414
+ this.location = _location;
2415
+ }
2406
2416
  };
2407
2417
  var FileBasedDataSource = class extends EnvGraphDataSource {
2408
2418
  static {
@@ -2533,6 +2543,56 @@ var DotEnvFileDataSource = class extends FileBasedDataSource {
2533
2543
  }
2534
2544
  }
2535
2545
  };
2546
+ var SKIP_FILE_TYPES = [".md", ".d.ts"];
2547
+ async function findEnvFiles(opts) {
2548
+ const cwd = opts?.cwd || process.cwd();
2549
+ const envFiles = [];
2550
+ const filesWithinDir = await fs2.readdir(cwd);
2551
+ for (const fileName of filesWithinDir) {
2552
+ if (fileName === ".env" || fileName.startsWith(".env.")) {
2553
+ let skip = false;
2554
+ for (const fileType of SKIP_FILE_TYPES) {
2555
+ if (fileName.endsWith(fileType)) skip = true;
2556
+ }
2557
+ if (skip) continue;
2558
+ envFiles.push(path.join(cwd, fileName));
2559
+ }
2560
+ }
2561
+ return envFiles;
2562
+ }
2563
+ __name(findEnvFiles, "findEnvFiles");
2564
+
2565
+ // env-graph/lib/loader.ts
2566
+ function autoDetectBasePath() {
2567
+ const PWD = process.env.PWD;
2568
+ if (!PWD) {
2569
+ throw new Error("PWD is not set");
2570
+ }
2571
+ return PWD;
2572
+ }
2573
+ __name(autoDetectBasePath, "autoDetectBasePath");
2574
+ async function loadEnvGraph(opts) {
2575
+ const graph = new EnvGraph2();
2576
+ graph.basePath = opts?.basePath ?? autoDetectBasePath();
2577
+ if (opts?.afterInit) {
2578
+ await opts.afterInit(graph);
2579
+ }
2580
+ if (opts?.currentEnvFallback) {
2581
+ graph.envFlagValue = opts.currentEnvFallback;
2582
+ }
2583
+ const envFilePaths = await findEnvFiles({
2584
+ cwd: graph.basePath
2585
+ });
2586
+ for (const envFilePath of envFilePaths) {
2587
+ const fileDataSource = new DotEnvFileDataSource(envFilePath);
2588
+ graph.addDataSource(fileDataSource);
2589
+ await fileDataSource.finishInit();
2590
+ }
2591
+ graph.finalOverridesDataSource = new ProcessEnvDataSource();
2592
+ await graph.finishLoad();
2593
+ return graph;
2594
+ }
2595
+ __name(loadEnvGraph, "loadEnvGraph");
2536
2596
 
2537
2597
  // src/lib/formatting.ts
2538
2598
  function applyMods(str, mods) {
@@ -2715,6 +2775,6 @@ function gracefulExit(signal = 0) {
2715
2775
  __name(gracefulExit, "gracefulExit");
2716
2776
  //! these are probably not relevant anymore, or needs to move to a plugin layer?
2717
2777
 
2718
- export { CoercionError, ConfigLoadError, DotEnvFileDataSource, EnvGraph2 as EnvGraph, EnvSourceParseError, ProcessEnvDataSource, ResolutionError, SchemaError, StaticValueResolver, ValidationError, ansis_default, asyncExitHook, checkIsFileGitIgnored, getItemSummary, gracefulExit, joinAndCompact, my_dash_default };
2719
- //# sourceMappingURL=chunk-Y2RFMQ5X.js.map
2720
- //# sourceMappingURL=chunk-Y2RFMQ5X.js.map
2778
+ export { CoercionError, ConfigLoadError, DotEnvFileDataSource, EnvGraph2 as EnvGraph, EnvSourceParseError, ProcessEnvDataSource, ResolutionError, SchemaError, StaticValueResolver, ValidationError, ansis_default, asyncExitHook, checkIsFileGitIgnored, getItemSummary, gracefulExit, joinAndCompact, loadEnvGraph, my_dash_default };
2779
+ //# sourceMappingURL=chunk-ZW2T4C6A.js.map
2780
+ //# sourceMappingURL=chunk-ZW2T4C6A.js.map