varlock 0.3.0 → 0.4.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.
Files changed (65) hide show
  1. package/README.md +23 -10
  2. package/dist/chunk-3U2C5ACW.js +48 -0
  3. package/dist/chunk-3U2C5ACW.js.map +1 -0
  4. package/dist/{chunk-MXZI2FC6.js → chunk-6SS4YD2I.js} +5 -5
  5. package/dist/{chunk-MXZI2FC6.js.map → chunk-6SS4YD2I.js.map} +1 -1
  6. package/dist/{chunk-26ICEAKS.js → chunk-AHEBZW37.js} +9 -8
  7. package/dist/chunk-AHEBZW37.js.map +1 -0
  8. package/dist/{chunk-IG5PPVD7.js → chunk-BGPQX6XO.js} +6 -6
  9. package/dist/{chunk-IG5PPVD7.js.map → chunk-BGPQX6XO.js.map} +1 -1
  10. package/dist/{chunk-MHIFZAPA.js → chunk-CBWJHW3M.js} +7 -7
  11. package/dist/{chunk-MHIFZAPA.js.map → chunk-CBWJHW3M.js.map} +1 -1
  12. package/dist/{chunk-JDMZWNQA.js → chunk-HS2NN4VF.js} +7 -7
  13. package/dist/chunk-HS2NN4VF.js.map +1 -0
  14. package/dist/chunk-I4RYFNPM.js +22 -0
  15. package/dist/chunk-I4RYFNPM.js.map +1 -0
  16. package/dist/{chunk-GEJNYKR4.js → chunk-MBYYRBL6.js} +3 -3
  17. package/dist/{chunk-GEJNYKR4.js.map → chunk-MBYYRBL6.js.map} +1 -1
  18. package/dist/{chunk-VQ5I7WMP.js → chunk-NWY5IIPW.js} +3 -3
  19. package/dist/{chunk-VQ5I7WMP.js.map → chunk-NWY5IIPW.js.map} +1 -1
  20. package/dist/{chunk-WDC5CEKD.js → chunk-ONSMSCMG.js} +5 -5
  21. package/dist/{chunk-WDC5CEKD.js.map → chunk-ONSMSCMG.js.map} +1 -1
  22. package/dist/{chunk-TLXFVH7P.js → chunk-P7WVEZYA.js} +4 -4
  23. package/dist/{chunk-TLXFVH7P.js.map → chunk-P7WVEZYA.js.map} +1 -1
  24. package/dist/{chunk-WZW7QS6M.js → chunk-PCRIVT4T.js} +342 -32
  25. package/dist/chunk-PCRIVT4T.js.map +1 -0
  26. package/dist/{chunk-KKPD7AYU.js → chunk-PIOJV2A7.js} +4 -4
  27. package/dist/{chunk-KKPD7AYU.js.map → chunk-PIOJV2A7.js.map} +1 -1
  28. package/dist/{chunk-LZ52O5WU.js → chunk-RQDMJMKL.js} +14 -23
  29. package/dist/chunk-RQDMJMKL.js.map +1 -0
  30. package/dist/cli/cli-executable.js +33 -25
  31. package/dist/cli/cli-executable.js.map +1 -1
  32. package/dist/config-item-K7KWEJD2.js +5 -0
  33. package/dist/{config-item-2AL7WF23.js.map → config-item-K7KWEJD2.js.map} +1 -1
  34. package/dist/{env-graph-C8s2oqOJ.d.ts → env-graph-COORmJlH.d.ts} +59 -0
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +6 -4
  37. package/dist/index.js.map +1 -1
  38. package/dist/init.command-SZPMB525.js +12 -0
  39. package/dist/{init.command-J4HZL3PB.js.map → init.command-SZPMB525.js.map} +1 -1
  40. package/dist/load.command-XSOTCSGA.js +11 -0
  41. package/dist/{load.command-6DAP7LEX.js.map → load.command-XSOTCSGA.js.map} +1 -1
  42. package/dist/plugin-lib.d.ts +2 -2
  43. package/dist/printenv.command-4HWCHHCY.js +12 -0
  44. package/dist/{printenv.command-7B7SZ2EF.js.map → printenv.command-4HWCHHCY.js.map} +1 -1
  45. package/dist/run.command-DIN6XVLO.js +12 -0
  46. package/dist/{run.command-HVV6XXDR.js.map → run.command-DIN6XVLO.js.map} +1 -1
  47. package/dist/runtime/env.d.ts +1 -1
  48. package/dist/scan.command-4J64EB4Z.js +13 -0
  49. package/dist/{scan.command-Q33VJOPD.js.map → scan.command-4J64EB4Z.js.map} +1 -1
  50. package/dist/telemetry.command-44NGPRGQ.js +11 -0
  51. package/dist/{telemetry.command-HOJDUCKG.js.map → telemetry.command-44NGPRGQ.js.map} +1 -1
  52. package/dist/typegen.command-7BE3K6PU.js +12 -0
  53. package/dist/typegen.command-7BE3K6PU.js.map +1 -0
  54. package/package.json +13 -12
  55. package/dist/chunk-26ICEAKS.js.map +0 -1
  56. package/dist/chunk-JDMZWNQA.js.map +0 -1
  57. package/dist/chunk-LZ52O5WU.js.map +0 -1
  58. package/dist/chunk-WZW7QS6M.js.map +0 -1
  59. package/dist/config-item-2AL7WF23.js +0 -5
  60. package/dist/init.command-J4HZL3PB.js +0 -12
  61. package/dist/load.command-6DAP7LEX.js +0 -11
  62. package/dist/printenv.command-7B7SZ2EF.js +0 -12
  63. package/dist/run.command-HVV6XXDR.js +0 -12
  64. package/dist/scan.command-Q33VJOPD.js +0 -13
  65. package/dist/telemetry.command-HOJDUCKG.js +0 -11
@@ -1,5 +1,5 @@
1
- import { ansis_default, gracefulExit, getItemSummary, joinAndCompact } from './chunk-VQ5I7WMP.js';
2
- import { VarlockError, my_dash_default } from './chunk-WZW7QS6M.js';
1
+ import { ansis_default, gracefulExit, getItemSummary, joinAndCompact } from './chunk-NWY5IIPW.js';
2
+ import { VarlockError, my_dash_default } from './chunk-PCRIVT4T.js';
3
3
  import { __name } from './chunk-6PEHRAEP.js';
4
4
 
5
5
  // src/cli/helpers/error-checks.ts
@@ -104,5 +104,5 @@ function checkForConfigErrors(envGraph, opts) {
104
104
  __name(checkForConfigErrors, "checkForConfigErrors");
105
105
 
106
106
  export { InvalidEnvError, checkForConfigErrors, checkForNoEnvFiles, checkForSchemaErrors };
107
- //# sourceMappingURL=chunk-TLXFVH7P.js.map
108
- //# sourceMappingURL=chunk-TLXFVH7P.js.map
107
+ //# sourceMappingURL=chunk-P7WVEZYA.js.map
108
+ //# sourceMappingURL=chunk-P7WVEZYA.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/helpers/error-checks.ts"],"names":[],"mappings":";;;;;AAQA,SAAS,yBAAyB,GAAA,EAAY;AAC5C,EAAA,IAAI,EAAE,GAAA,YAAe,YAAA,CAAA,IAAiB,CAA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AAA,CAAQ,KAAA,EAAM;AAAA,IAChB,CAAC,CAAA;AACD,IAAA,IAAI,MAAM,OAAA,EAAS;AACjB,MAAA,OAAA,CAAQ,KAAA,EAAM;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,aAAa,QAAA,CAAS,gBAAA,CACzB,GAAA,CAAI,CAAC,MAAM,QAAA,CAAS,YAAA,CAAa,CAAC,CAAC,EACnC,MAAA,CAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAA;AAC5B,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;AApDgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA","file":"chunk-TLXFVH7P.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 checkForNoEnvFiles(envGraph: EnvGraph) {\n if (Object.keys(envGraph.configSchema).length === 0) {\n console.error('🚨 No .env or .env.schema files found\\n');\n console.error('Run `varlock init` to create a .env.schema file, or use `--path` to specify a file or directory.');\n return gracefulExit(1);\n }\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 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\n // For plugin loading errors, show the full stack trace since it's usually\n // a runtime error from executing the plugin code\n if (source.loadingError.stack && !(source.loadingError instanceof VarlockError)) {\n console.log(`\\n${ansis.dim('Stack trace:')}`);\n console.log(ansis.dim(source.loadingError.stack));\n }\n\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 if (err instanceof VarlockError && err.tip) {\n for (const line of err.tip.split('\\n')) {\n console.log(` ${line}`);\n }\n }\n showErrorLocationDetails(err);\n }\n }\n }\n\n\n\n const failingItems = envGraph.sortedConfigKeys\n .map((k) => envGraph.configSchema[k])\n .filter((item) => 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 = envGraph.sortedConfigKeys\n .map((k) => envGraph.configSchema[k])\n .filter((i) => !!i.isValid);\n _.each(validItems, (item: ConfigItem) => {\n console.error(getItemSummary(item));\n });\n }\n\n throw new InvalidEnvError();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/cli/helpers/error-checks.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,UAAU,CAAA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B,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;AApDgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA","file":"chunk-P7WVEZYA.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 checkForNoEnvFiles(envGraph: EnvGraph) {\n if (Object.keys(envGraph.configSchema).length === 0) {\n console.error('🚨 No .env or .env.schema files found\\n');\n console.error('Run `varlock init` to create a .env.schema file, or use `--path` to specify a file or directory.');\n return gracefulExit(1);\n }\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 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\n // For plugin loading errors, show the full stack trace since it's usually\n // a runtime error from executing the plugin code\n if (source.loadingError.stack && !(source.loadingError instanceof VarlockError)) {\n console.log(`\\n${ansis.dim('Stack trace:')}`);\n console.log(ansis.dim(source.loadingError.stack));\n }\n\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 if (err instanceof VarlockError && err.tip) {\n for (const line of err.tip.split('\\n')) {\n console.log(` ${line}`);\n }\n }\n showErrorLocationDetails(err);\n }\n }\n }\n\n\n\n const failingItems = envGraph.sortedConfigKeys\n .map((k) => envGraph.configSchema[k])\n .filter((item) => 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 = envGraph.sortedConfigKeys\n .map((k) => envGraph.configSchema[k])\n .filter((i) => !!i.isValid);\n _.each(validItems, (item: ConfigItem) => {\n console.error(getItemSummary(item));\n });\n }\n\n throw new InvalidEnvError();\n }\n}\n"]}
@@ -1,13 +1,16 @@
1
1
  import { createDebug } from './chunk-QZ6HBRJC.js';
2
2
  import { __commonJS, __name, __toESM } from './chunk-6PEHRAEP.js';
3
- import path from 'path';
3
+ import path, { join } from 'path';
4
4
  import fs, { access } from 'fs/promises';
5
5
  import os from 'os';
6
- import fs3, { accessSync } from 'fs';
6
+ import fs3, { accessSync, existsSync } from 'fs';
7
7
  import { exec } from 'child_process';
8
8
  import { promisify } from 'util';
9
+ import { createRequire } from 'module';
10
+ import { pathToFileURL } from 'url';
9
11
  import crypto from 'crypto';
10
12
  import https from 'https';
13
+ import vm from 'vm';
11
14
 
12
15
  // ../../node_modules/.bun/semver@7.7.4/node_modules/semver/internal/constants.js
13
16
  var require_constants = __commonJS({
@@ -8021,6 +8024,18 @@ __name(pathExistsSync, "pathExistsSync");
8021
8024
 
8022
8025
  // src/env-graph/lib/plugins.ts
8023
8026
  var import_semver = __toESM(require_semver2(), 1);
8027
+ function getUserVarlockDir() {
8028
+ const home = os.homedir();
8029
+ if (process.env.XDG_CONFIG_HOME) {
8030
+ return join(process.env.XDG_CONFIG_HOME, "varlock");
8031
+ }
8032
+ const legacyDir = join(home, ".varlock");
8033
+ if (existsSync(legacyDir)) {
8034
+ return legacyDir;
8035
+ }
8036
+ return join(home, ".config", "varlock");
8037
+ }
8038
+ __name(getUserVarlockDir, "getUserVarlockDir");
8024
8039
 
8025
8040
  // src/env-graph/lib/error-location.ts
8026
8041
  function getErrorLocation(source, parserNode) {
@@ -8301,10 +8316,10 @@ var builtInRootDecorators = [
8301
8316
  throw new SchemaError("@setValuesBulk expects only one positional argument - the data resolver");
8302
8317
  }
8303
8318
  if (argsVal.objArgs) {
8304
- const validOptions = /* @__PURE__ */ new Set(["format", "createMissing"]);
8319
+ const validOptions = /* @__PURE__ */ new Set(["format", "createMissing", "enabled"]);
8305
8320
  for (const key of Object.keys(argsVal.objArgs)) {
8306
8321
  if (!validOptions.has(key)) {
8307
- throw new SchemaError(`@setValuesBulk: unknown option "${key}". Valid options: format, createMissing`);
8322
+ throw new SchemaError(`@setValuesBulk: unknown option "${key}". Valid options: format, createMissing, enabled`);
8308
8323
  }
8309
8324
  }
8310
8325
  const formatResolver = argsVal.objArgs.format;
@@ -8330,6 +8345,15 @@ var builtInRootDecorators = [
8330
8345
  },
8331
8346
  async execute(processedData) {
8332
8347
  const { graph, dataSource, argsResolver } = processedData;
8348
+ const enabledResolver = argsResolver.objArgs?.enabled;
8349
+ if (enabledResolver !== void 0) {
8350
+ const enabledValue = await enabledResolver.resolve();
8351
+ if (!my_dash_default.isBoolean(enabledValue)) {
8352
+ dataSource._loadingError = new SchemaError("@setValuesBulk: enabled must be a boolean");
8353
+ return;
8354
+ }
8355
+ if (!enabledValue) return;
8356
+ }
8333
8357
  const resolved = await argsResolver.resolve();
8334
8358
  const dataString = resolved.arr[0];
8335
8359
  const format = resolved.obj?.format;
@@ -8353,7 +8377,7 @@ var builtInRootDecorators = [
8353
8377
  dataSource._loadingError = err instanceof SchemaError ? err : new SchemaError(err);
8354
8378
  return;
8355
8379
  }
8356
- const { ConfigItem: ConfigItem3 } = await import('./config-item-2AL7WF23.js');
8380
+ const { ConfigItem: ConfigItem2 } = await import('./config-item-K7KWEJD2.js');
8357
8381
  for (const [key, entry] of Object.entries(entries)) {
8358
8382
  const existsInSchema = key in graph.configSchema;
8359
8383
  if (!existsInSchema && !createMissing) {
@@ -8369,7 +8393,7 @@ var builtInRootDecorators = [
8369
8393
  };
8370
8394
  }
8371
8395
  if (!existsInSchema && createMissing) {
8372
- const newItem = new ConfigItem3(graph, key);
8396
+ const newItem = new ConfigItem2(graph, key);
8373
8397
  graph.configSchema[key] = newItem;
8374
8398
  await newItem.process();
8375
8399
  }
@@ -9568,6 +9592,53 @@ __name(convertParsedValueToResolvers, "convertParsedValueToResolvers");
9568
9592
 
9569
9593
  // src/env-graph/lib/plugins.ts
9570
9594
  var importedPluginModulePaths = /* @__PURE__ */ new Set();
9595
+ function isSEABuild() {
9596
+ try {
9597
+ return false;
9598
+ } catch {
9599
+ return false;
9600
+ }
9601
+ }
9602
+ __name(isSEABuild, "isSEABuild");
9603
+ async function loadPluginModuleInSEA(filePath) {
9604
+ const code = fs3.readFileSync(filePath, "utf-8");
9605
+ const fileUrl = pathToFileURL(filePath).href;
9606
+ const pluginDir = path.dirname(filePath);
9607
+ const pluginRequire = createRequire(filePath);
9608
+ let transformed = code.replace(
9609
+ /^import\s+(\w+)\s*,\s*(\{[^}]+\})\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9610
+ 'const $1 = __plugin_require__("$3"); const $2 = $1;'
9611
+ ).replace(
9612
+ /^import\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9613
+ 'const $1 = __plugin_require__("$2");'
9614
+ ).replace(
9615
+ /^import\s+(\{[^}]+\})\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9616
+ 'const $1 = __plugin_require__("$2");'
9617
+ ).replace(
9618
+ /^import\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm,
9619
+ 'const $1 = __plugin_require__("$2");'
9620
+ ).replace(
9621
+ /^import\s+['"]([^'"]+)['"]\s*;?/gm,
9622
+ '__plugin_require__("$1");'
9623
+ );
9624
+ transformed = transformed.replace(/import\.meta/g, "__plugin_import_meta__");
9625
+ const wrapped = `(async () => {
9626
+ ${transformed}
9627
+ })()`;
9628
+ const context = vm.createContext(globalThis, {
9629
+ codeGeneration: { strings: true, wasm: true }
9630
+ });
9631
+ context.__plugin_require__ = pluginRequire;
9632
+ context.__plugin_import_meta__ = Object.freeze({
9633
+ url: fileUrl,
9634
+ dirname: pluginDir,
9635
+ filename: filePath
9636
+ });
9637
+ const script = new vm.Script(wrapped, { filename: filePath });
9638
+ const result = script.runInContext(context);
9639
+ await result;
9640
+ }
9641
+ __name(loadPluginModuleInSEA, "loadPluginModuleInSEA");
9571
9642
  var VarlockPlugin = class {
9572
9643
  static {
9573
9644
  __name(this, "VarlockPlugin");
@@ -9654,7 +9725,11 @@ var VarlockPlugin = class {
9654
9725
  try {
9655
9726
  if (!await pathExists(this.pluginFilePath)) throw new Error(`Plugin file not found: ${this.pluginFilePath}`);
9656
9727
  importedPluginModulePaths.add(this.pluginFilePath);
9657
- await import(this.pluginFilePath);
9728
+ if (isSEABuild()) {
9729
+ await loadPluginModuleInSEA(this.pluginFilePath);
9730
+ } else {
9731
+ await import(this.pluginFilePath);
9732
+ }
9658
9733
  } catch (err) {
9659
9734
  this.loadingError = err;
9660
9735
  }
@@ -9740,7 +9815,7 @@ async function registerPluginInGraph(graph, plugin, pluginDecorator) {
9740
9815
  __name(registerPluginInGraph, "registerPluginInGraph");
9741
9816
  async function downloadPlugin(url) {
9742
9817
  const exec2 = promisify(exec);
9743
- const cacheDir = path.join(os.homedir(), ".varlock", "plugins-cache");
9818
+ const cacheDir = path.join(getUserVarlockDir(), "plugins-cache");
9744
9819
  const indexPath = path.join(cacheDir, "index.json");
9745
9820
  await fs.mkdir(cacheDir, { recursive: true });
9746
9821
  let index = {};
@@ -9970,6 +10045,28 @@ var EnvGraphDataSource2 = class {
9970
10045
  if (importMeta) child.importMeta = importMeta;
9971
10046
  await child.finishInit();
9972
10047
  }
10048
+ /**
10049
+ * Whether this data source is environment-specific.
10050
+ * A source is env-specific if:
10051
+ * - it was auto-loaded for a specific env (e.g., `.env.production` loaded by a DirectoryDataSource)
10052
+ * - it has a conditional `@disable` decorator (e.g., `@disable=forEnv(test)`)
10053
+ * - it was conditionally imported (e.g., `@import(..., enabled=forEnv("dev"))`)
10054
+ * - any of its ancestors are env-specific
10055
+ * Used by type generation to filter out env-dependent definitions.
10056
+ *
10057
+ * Note: `applyForEnv` from filename parsing is only relevant for auto-loaded files.
10058
+ * Explicitly imported files (via `@import`) are controlled by the import mechanism,
10059
+ * not the auto-load-by-env logic, so their `applyForEnv` is ignored here.
10060
+ */
10061
+ get isEnvSpecific() {
10062
+ if (this.applyForEnv && !this.isImport) return true;
10063
+ if (this._hasConditionalDisable) return true;
10064
+ if (this.importMeta?.isConditionallyEnabled) return true;
10065
+ if (this.parent?.isEnvSpecific) return true;
10066
+ return false;
10067
+ }
10068
+ /** true when the source has a `@disable` decorator whose value is not static */
10069
+ _hasConditionalDisable;
9973
10070
  /** environment flag key (as set by @envFlag decorator) - only if set within this source */
9974
10071
  _envFlagKey;
9975
10072
  /** environment flag key getter that will follow up the parent chain */
@@ -10019,6 +10116,9 @@ var EnvGraphDataSource2 = class {
10019
10116
  return;
10020
10117
  }
10021
10118
  this._disabled = disabledVal;
10119
+ if (disabledDec.decValueResolver && !disabledDec.decValueResolver.isStatic) {
10120
+ this._hasConditionalDisable = true;
10121
+ }
10022
10122
  }
10023
10123
  if (this.disabled) return;
10024
10124
  for (const itemKey of this.importKeys || my_dash_default.keys(this.configItemDefs)) {
@@ -10083,8 +10183,8 @@ var EnvGraphDataSource2 = class {
10083
10183
  try {
10084
10184
  await importDec.process();
10085
10185
  if (importDec.decValueResolver?.objArgs?.enabled) {
10086
- const enabledResolver = importDec.decValueResolver.objArgs.enabled;
10087
- const enabledDeps = enabledResolver.deps;
10186
+ const enabledResolver2 = importDec.decValueResolver.objArgs.enabled;
10187
+ const enabledDeps = enabledResolver2.deps;
10088
10188
  for (const depKey of enabledDeps) {
10089
10189
  const depItem = this.graph.configSchema[depKey];
10090
10190
  if (!depItem) {
@@ -10115,6 +10215,8 @@ var EnvGraphDataSource2 = class {
10115
10215
  throw new Error("expected @import enabled parameter to be a boolean");
10116
10216
  }
10117
10217
  if (!enabledValue) continue;
10218
+ const enabledResolver = importDec.decValueResolver?.objArgs?.enabled;
10219
+ const isConditionallyEnabled = !!enabledResolver && !enabledResolver.isStatic;
10118
10220
  const allowMissing = importArgs.obj.allowMissing ?? false;
10119
10221
  if (!my_dash_default.isBoolean(allowMissing)) {
10120
10222
  throw new Error("expected @import allowMissing parameter to be a boolean");
@@ -10131,7 +10233,8 @@ var EnvGraphDataSource2 = class {
10131
10233
  }
10132
10234
  await this.addChild(new DirectoryDataSource(fullImportPath), {
10133
10235
  isImport: true,
10134
- importKeys
10236
+ importKeys,
10237
+ isConditionallyEnabled
10135
10238
  });
10136
10239
  } else {
10137
10240
  const fileExists = this.graph.virtualImports[fullImportPath];
@@ -10143,7 +10246,7 @@ var EnvGraphDataSource2 = class {
10143
10246
  const source = new DotEnvFileDataSource(fullImportPath, {
10144
10247
  overrideContents: this.graph.virtualImports[fullImportPath]
10145
10248
  });
10146
- await this.addChild(source, { isImport: true, importKeys });
10249
+ await this.addChild(source, { isImport: true, importKeys, isConditionallyEnabled });
10147
10250
  }
10148
10251
  } else {
10149
10252
  const fsStat = await tryCatch(async () => fs.stat(fullImportPath), (_err) => {
@@ -10157,7 +10260,8 @@ var EnvGraphDataSource2 = class {
10157
10260
  if (fsStat.isDirectory()) {
10158
10261
  await this.addChild(new DirectoryDataSource(fullImportPath), {
10159
10262
  isImport: true,
10160
- importKeys
10263
+ importKeys,
10264
+ isConditionallyEnabled
10161
10265
  });
10162
10266
  } else {
10163
10267
  this._loadingError = new Error(`Imported path ending with "/" is not a directory: ${fullImportPath}`);
@@ -10171,7 +10275,11 @@ var EnvGraphDataSource2 = class {
10171
10275
  this._loadingError = new Error("imported file must be a .env.* file");
10172
10276
  return;
10173
10277
  }
10174
- await this.addChild(new DotEnvFileDataSource(fullImportPath), { isImport: true, importKeys });
10278
+ await this.addChild(new DotEnvFileDataSource(fullImportPath), {
10279
+ isImport: true,
10280
+ importKeys,
10281
+ isConditionallyEnabled
10282
+ });
10175
10283
  }
10176
10284
  }
10177
10285
  } else if (importPath.startsWith("http://") || importPath.startsWith("https://")) {
@@ -10501,18 +10609,18 @@ async function fetchIconSvg(iconifyName, color = "808080", iconCacheFolder = "/t
10501
10609
  return colorizedSvg;
10502
10610
  }
10503
10611
  __name(fetchIconSvg, "fetchIconSvg");
10504
- async function getTsDefinitionForItem(item, indentLevel = 0) {
10612
+ async function getTsDefinitionForItem(info, indentLevel = 0) {
10505
10613
  const i = my_dash_default.times(indentLevel, () => " ").join("");
10506
10614
  const itemSrc = [];
10507
10615
  const jsDocLines = [];
10508
- jsDocLines.push(`**${item.key}**${item.isSensitive ? " \u{1F510} _sensitive_" : ""}`);
10509
- if (item.description) jsDocLines.push(...item.description.split("\n"));
10510
- const iconName = item.icon;
10616
+ jsDocLines.push(`**${info.key}**${info.isSensitive ? " \u{1F510} _sensitive_" : ""}`);
10617
+ if (info.description) jsDocLines.push(...info.description.split("\n"));
10618
+ const iconName = info.icon;
10511
10619
  if (iconName) {
10512
10620
  const iconSvg = await fetchIconSvg(iconName);
10513
10621
  if (iconSvg) jsDocLines.push(`![icon](data:image/svg+xml;utf-8,${encodeURIComponent(iconSvg)}) `);
10514
10622
  }
10515
- const docsLinks = item.docsLinks;
10623
+ const docsLinks = info.docsLinks;
10516
10624
  if (docsLinks.length) {
10517
10625
  jsDocLines.push("");
10518
10626
  docsLinks.forEach((docsEntry) => {
@@ -10530,7 +10638,7 @@ async function getTsDefinitionForItem(item, indentLevel = 0) {
10530
10638
  " */"
10531
10639
  ]);
10532
10640
  }
10533
- const dataType = item.dataType;
10641
+ const dataType = info.dataType;
10534
10642
  const dataTypeName = dataType?.name;
10535
10643
  let itemTsType = "string";
10536
10644
  if (dataType) {
@@ -10551,24 +10659,25 @@ async function getTsDefinitionForItem(item, indentLevel = 0) {
10551
10659
  }
10552
10660
  }
10553
10661
  }
10554
- const isRequired = item.isRequired && !item.isRequiredDynamic;
10555
- itemSrc.push(`${item.key}${isRequired ? "" : "?"}: ${itemTsType};`);
10662
+ const isRequired = info.isRequired && !info.isRequiredDynamic;
10663
+ itemSrc.push(`${info.key}${isRequired ? "" : "?"}: ${itemTsType};`);
10556
10664
  itemSrc.push("");
10557
10665
  return my_dash_default.map(itemSrc, (line) => `${i}${line}`);
10558
10666
  }
10559
10667
  __name(getTsDefinitionForItem, "getTsDefinitionForItem");
10560
- async function generateTsTypesSrc(graph) {
10668
+ async function generateTsTypesSrc(items) {
10561
10669
  const tsSrc = [
10562
10670
  AUTOGENERATED_FILE_BANNER,
10563
10671
  // might want to add some options to let users inject this, or somehow detect eslint, but fine for now
10564
10672
  "/* eslint-disable */",
10565
10673
  "export type CoercedEnvSchema = {"
10566
10674
  ];
10675
+ const exposedKeys = [];
10567
10676
  const exposedNonSensitiveKeys = [];
10568
- for (const itemKey of graph.sortedConfigKeys) {
10569
- const configItem = graph.configSchema[itemKey];
10570
- tsSrc.push(...await getTsDefinitionForItem(configItem, 1));
10571
- if (!configItem.isSensitive) exposedNonSensitiveKeys.push(itemKey);
10677
+ for (const info of items) {
10678
+ tsSrc.push(...await getTsDefinitionForItem(info, 1));
10679
+ exposedKeys.push(info.key);
10680
+ if (!info.isSensitive) exposedNonSensitiveKeys.push(info.key);
10572
10681
  }
10573
10682
  tsSrc.push("};\n");
10574
10683
  tsSrc.push(`
@@ -10606,7 +10715,13 @@ export type EnvSchemaAsStrings = {
10606
10715
  __name(generateTsTypesSrc, "generateTsTypesSrc");
10607
10716
  async function generateTypes(graph, lang, typesPath) {
10608
10717
  if (lang !== "ts") throw new Error(`Unsupported @generateTypes lang: ${lang}`);
10609
- const tsSrc = await generateTsTypesSrc(graph);
10718
+ const items = [];
10719
+ for (const itemKey of graph.sortedConfigKeys) {
10720
+ const configItem = graph.configSchema[itemKey];
10721
+ if (!configItem.defsForTypeGeneration.length) continue;
10722
+ items.push(await configItem.getTypeGenInfo());
10723
+ }
10724
+ const tsSrc = await generateTsTypesSrc(items);
10610
10725
  await fs3.promises.writeFile(typesPath, tsSrc, "utf-8");
10611
10726
  }
10612
10727
  __name(generateTypes, "generateTypes");
@@ -10614,7 +10729,7 @@ __name(generateTypes, "generateTypes");
10614
10729
  // src/env-graph/lib/env-graph.ts
10615
10730
  var processExists = !!globalThis.process;
10616
10731
  var originalProcessEnv = { ...processExists && process.env };
10617
- var EnvGraph3 = class {
10732
+ var EnvGraph2 = class {
10618
10733
  static {
10619
10734
  __name(this, "EnvGraph");
10620
10735
  }
@@ -10916,6 +11031,33 @@ var EnvGraph3 = class {
10916
11031
  async generateTypes(lang, outputPath) {
10917
11032
  await generateTypes(this, lang, outputPath);
10918
11033
  }
11034
+ /**
11035
+ * Resolve @generateTypes decorators and generate type files.
11036
+ * This should be called after finishLoad() but before resolveEnvValues().
11037
+ * The @generateTypes decorator args (lang, path) are static, so we can resolve them
11038
+ * without needing full env resolution. Type info is computed from non-env-specific
11039
+ * definitions only, so the output is deterministic regardless of environment.
11040
+ *
11041
+ * @param opts.ignoreAutoFalse - if true, generate types even if `auto=false` is set.
11042
+ * Used by the `varlock typegen` command to force generation.
11043
+ */
11044
+ async generateTypesIfNeeded(opts) {
11045
+ const generateTypesDecs = this.getRootDecFns("generateTypes");
11046
+ let generatedCount = 0;
11047
+ for (const generateTypesDec of generateTypesDecs) {
11048
+ const typeGenSettings = await generateTypesDec.resolve();
11049
+ if (generateTypesDec.dataSource.isImport && !typeGenSettings.obj.executeWhenImported) continue;
11050
+ if (typeGenSettings.obj.auto === false && !opts?.ignoreAutoFalse) continue;
11051
+ if (!typeGenSettings.obj.lang) throw new Error("@generateTypes - must set `lang` arg");
11052
+ if (typeGenSettings.obj.lang !== "ts") throw new Error(`@generateTypes - unsupported language: ${typeGenSettings.obj.lang}`);
11053
+ if (!typeGenSettings.obj.path) throw new Error("@generateTypes - must set `path` arg");
11054
+ if (!my_dash_default.isString(typeGenSettings.obj.path)) throw new Error("@generateTypes - `path` arg must be a string");
11055
+ const outputPath = generateTypesDec.dataSource instanceof FileBasedDataSource ? path.resolve(generateTypesDec.dataSource.fullPath, "..", typeGenSettings.obj.path) : typeGenSettings.obj.path;
11056
+ await this.generateTypes(typeGenSettings.obj.lang, outputPath);
11057
+ generatedCount++;
11058
+ }
11059
+ return generatedCount;
11060
+ }
10919
11061
  getRootDec(decoratorName) {
10920
11062
  const sources = Array.from(this.sortedDataSources).reverse();
10921
11063
  for (const s of sources) {
@@ -10968,6 +11110,14 @@ var ConfigItem = class {
10968
11110
  defs.push(...this._internalDefs);
10969
11111
  return defs;
10970
11112
  }
11113
+ /**
11114
+ * Like `defs` but filtered to exclude environment-specific data sources.
11115
+ * Used by type generation so that generated types are deterministic
11116
+ * regardless of which environment is being loaded.
11117
+ */
11118
+ get defsForTypeGeneration() {
11119
+ return this.defs.filter((def) => !def.source || !def.source.isEnvSpecific);
11120
+ }
10971
11121
  get description() {
10972
11122
  for (const def of this.defs) {
10973
11123
  if (def.itemDef.description) return def.itemDef.description;
@@ -11363,9 +11513,169 @@ var ConfigItem = class {
11363
11513
  get isValid() {
11364
11514
  return this.validationState === "valid";
11365
11515
  }
11516
+ /**
11517
+ * Compute schema-level info for type generation using only non-env-specific definitions.
11518
+ * This mirrors the logic of processRequired/processSensitive but:
11519
+ * - Uses defsForTypeGeneration (excludes env-specific sources)
11520
+ * - Returns a result object instead of mutating item state
11521
+ * - Resolves only static decorators from non-env-specific sources
11522
+ */
11523
+ async getTypeGenInfo() {
11524
+ const defs = this.defsForTypeGeneration;
11525
+ let description;
11526
+ for (const def of defs) {
11527
+ if (def.itemDef.description) {
11528
+ description = def.itemDef.description;
11529
+ break;
11530
+ }
11531
+ }
11532
+ let isRequired = true;
11533
+ let isRequiredDynamic = false;
11534
+ try {
11535
+ for (const def of defs) {
11536
+ const requiredDecs = def.itemDef.decorators?.filter((d) => d.name === "required" || d.name === "optional") || [];
11537
+ const requiredDec = requiredDecs[0];
11538
+ if (requiredDec) {
11539
+ const usingOptional = requiredDec.name === "optional";
11540
+ if (requiredDec.decValueResolver?.fnName !== "\0static") {
11541
+ isRequiredDynamic = true;
11542
+ break;
11543
+ }
11544
+ const requiredDecoratorVal = await requiredDec.resolve();
11545
+ if (requiredDec.schemaErrors.length) {
11546
+ isRequired = false;
11547
+ break;
11548
+ }
11549
+ if (![true, false, void 0].includes(requiredDecoratorVal)) break;
11550
+ if (requiredDecoratorVal !== void 0) {
11551
+ isRequired = usingOptional ? !requiredDecoratorVal : requiredDecoratorVal;
11552
+ break;
11553
+ }
11554
+ }
11555
+ const defaultRequiredDec = def.source?.getRootDec("defaultRequired");
11556
+ if (defaultRequiredDec) {
11557
+ const defaultRequiredVal = await defaultRequiredDec.resolve();
11558
+ if (my_dash_default.isBoolean(defaultRequiredVal)) {
11559
+ isRequired = defaultRequiredVal;
11560
+ break;
11561
+ } else if (defaultRequiredVal === "infer") {
11562
+ if (def.itemDef.resolver) {
11563
+ if (def.itemDef.resolver instanceof StaticValueResolver) {
11564
+ isRequired = def.itemDef.resolver.staticValue !== void 0 && def.itemDef.resolver.staticValue !== "";
11565
+ } else {
11566
+ isRequired = true;
11567
+ }
11568
+ } else {
11569
+ isRequired = false;
11570
+ }
11571
+ break;
11572
+ }
11573
+ }
11574
+ }
11575
+ } catch {
11576
+ }
11577
+ let isSensitive = true;
11578
+ const sensitiveFromDataType = this.dataType?.isSensitive;
11579
+ try {
11580
+ let foundSensitive = false;
11581
+ for (const def of defs) {
11582
+ const sensitiveDecs = def.itemDef.decorators?.filter((d) => d.name === "sensitive" || d.name === "public") || [];
11583
+ const sensitiveDec = sensitiveDecs[0];
11584
+ if (sensitiveDec) {
11585
+ const usingPublic = sensitiveDec.name === "public";
11586
+ if (sensitiveDec.decValueResolver?.fnName !== "\0static") break;
11587
+ const sensitiveDecValue = await sensitiveDec.resolve();
11588
+ if (sensitiveDec.schemaErrors.length) break;
11589
+ if (![true, false, void 0].includes(sensitiveDecValue)) break;
11590
+ if (sensitiveDecValue !== void 0) {
11591
+ isSensitive = usingPublic ? !sensitiveDecValue : sensitiveDecValue;
11592
+ foundSensitive = true;
11593
+ break;
11594
+ }
11595
+ }
11596
+ if (sensitiveFromDataType !== void 0) continue;
11597
+ const defaultSensitiveDec = def.source?.getRootDec("defaultSensitive");
11598
+ if (defaultSensitiveDec) {
11599
+ if (!defaultSensitiveDec.decValueResolver) break;
11600
+ if (defaultSensitiveDec.decValueResolver.fnName === "inferFromPrefix") {
11601
+ const prefix = defaultSensitiveDec.decValueResolver.arrArgs[0].staticValue;
11602
+ if (my_dash_default.isString(prefix)) {
11603
+ isSensitive = !this.key.startsWith(prefix);
11604
+ foundSensitive = true;
11605
+ break;
11606
+ }
11607
+ } else {
11608
+ const defaultSensitiveVal = await defaultSensitiveDec.resolve();
11609
+ if (my_dash_default.isBoolean(defaultSensitiveVal)) {
11610
+ isSensitive = defaultSensitiveVal;
11611
+ foundSensitive = true;
11612
+ break;
11613
+ }
11614
+ }
11615
+ }
11616
+ }
11617
+ if (!foundSensitive && sensitiveFromDataType !== void 0) {
11618
+ isSensitive = sensitiveFromDataType;
11619
+ }
11620
+ } catch {
11621
+ }
11622
+ let icon;
11623
+ for (const def of defs) {
11624
+ const iconDec = def.itemDef.decorators?.find((d) => d.name === "icon");
11625
+ if (iconDec) {
11626
+ try {
11627
+ icon = await iconDec.resolve();
11628
+ } catch {
11629
+ }
11630
+ break;
11631
+ }
11632
+ }
11633
+ icon ??= this.dataType?.icon;
11634
+ const docsLinks = [];
11635
+ if (this.dataType?.docsEntries) {
11636
+ for (const entry of this.dataType.docsEntries) {
11637
+ if (my_dash_default.isPlainObject(entry)) docsLinks.push(entry);
11638
+ else docsLinks.push({ url: entry });
11639
+ }
11640
+ }
11641
+ for (const def of defs) {
11642
+ const docsUrlDec = def.itemDef.decorators?.find((d) => d.name === "docsUrl");
11643
+ if (docsUrlDec) {
11644
+ try {
11645
+ const val = await docsUrlDec.resolve();
11646
+ if (val) docsLinks.push({ url: val });
11647
+ } catch {
11648
+ }
11649
+ }
11650
+ const docsFnDecs = def.itemDef.decorators?.filter((d) => d.name === "docs" && d.isFunctionCall) || [];
11651
+ for (const docsDec of docsFnDecs) {
11652
+ try {
11653
+ const decVal = await docsDec.resolve();
11654
+ if (decVal?.arr && my_dash_default.isArray(decVal.arr)) {
11655
+ if (decVal.arr.length === 1) {
11656
+ docsLinks.push({ url: decVal.arr[0] });
11657
+ } else if (decVal.arr.length === 2) {
11658
+ docsLinks.push({ url: decVal.arr[1], description: decVal.arr[0] });
11659
+ }
11660
+ }
11661
+ } catch {
11662
+ }
11663
+ }
11664
+ }
11665
+ return {
11666
+ key: this.key,
11667
+ description,
11668
+ dataType: this.dataType,
11669
+ isRequired,
11670
+ isRequiredDynamic,
11671
+ isSensitive,
11672
+ icon,
11673
+ docsLinks
11674
+ };
11675
+ }
11366
11676
  };
11367
11677
  //! these are probably not relevant anymore, or needs to move to a plugin layer?
11368
11678
 
11369
- export { CoercionError, ConfigItem, ConfigLoadError, DirectoryDataSource, DotEnvFileDataSource, EnvGraph3 as EnvGraph, FileBasedDataSource, ParsedEnvSpecStaticValue, ResolutionError, SchemaError, ValidationError, VarlockError, envSpecUpdater, my_dash_default, parseEnvSpecDotEnvFile, pathExists, pathExistsSync, tryCatch };
11370
- //# sourceMappingURL=chunk-WZW7QS6M.js.map
11371
- //# sourceMappingURL=chunk-WZW7QS6M.js.map
11679
+ export { CoercionError, ConfigItem, ConfigLoadError, DirectoryDataSource, DotEnvFileDataSource, EnvGraph2 as EnvGraph, ParsedEnvSpecStaticValue, ResolutionError, SchemaError, ValidationError, VarlockError, envSpecUpdater, getUserVarlockDir, my_dash_default, parseEnvSpecDotEnvFile, pathExists, pathExistsSync, require_semver2 as require_semver, tryCatch };
11680
+ //# sourceMappingURL=chunk-PCRIVT4T.js.map
11681
+ //# sourceMappingURL=chunk-PCRIVT4T.js.map