@sanity/cli 3.60.0 → 3.61.1-manifests.18

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/lib/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createClient } from "@sanity/client";
2
- import fs$1 from "node:fs";
3
- import path$1 from "node:path";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
4
  import debugIt from "debug";
5
5
  import require$$0 from "fs";
6
6
  import require$$1 from "path";
@@ -16,15 +16,15 @@ function getCliConfigSync(cwd) {
16
16
  return getSanityCliConfig(cwd) || getSanityJsonConfig(cwd);
17
17
  }
18
18
  function getSanityJsonConfig(cwd) {
19
- const configPath = path$1.join(cwd, "sanity.json");
20
- return fs$1.existsSync(configPath) ? {
19
+ const configPath = path.join(cwd, "sanity.json");
20
+ return fs.existsSync(configPath) ? {
21
21
  config: loadJsonConfig(configPath),
22
22
  path: configPath,
23
23
  version: 2
24
24
  } : null;
25
25
  }
26
26
  function getSanityCliConfig(cwd) {
27
- const jsConfigPath = path$1.join(cwd, "sanity.cli.js"), tsConfigPath = path$1.join(cwd, "sanity.cli.ts"), [js, ts] = [fs$1.existsSync(jsConfigPath), fs$1.existsSync(tsConfigPath)];
27
+ const jsConfigPath = path.join(cwd, "sanity.cli.js"), tsConfigPath = path.join(cwd, "sanity.cli.ts"), [js, ts] = [fs.existsSync(jsConfigPath), fs.existsSync(tsConfigPath)];
28
28
  return !js && !ts ? null : !js && ts ? {
29
29
  config: importConfig(tsConfigPath),
30
30
  path: tsConfigPath,
@@ -37,7 +37,7 @@ function getSanityCliConfig(cwd) {
37
37
  }
38
38
  function loadJsonConfig(filePath) {
39
39
  try {
40
- const content = fs$1.readFileSync(filePath, "utf8");
40
+ const content = fs.readFileSync(filePath, "utf8");
41
41
  return JSON.parse(content);
42
42
  } catch (err) {
43
43
  return console.error(`Error reading "${filePath}": ${err.message}`), null;
@@ -45,10 +45,10 @@ function loadJsonConfig(filePath) {
45
45
  }
46
46
  function importConfig(filePath) {
47
47
  try {
48
- const config2 = dynamicRequire(filePath);
49
- if (config2 === null || typeof config2 != "object")
48
+ const config = dynamicRequire(filePath);
49
+ if (config === null || typeof config != "object")
50
50
  throw new Error("Module export is not a configuration object");
51
- return "default" in config2 ? config2.default : config2;
51
+ return "default" in config ? config.default : config;
52
52
  } catch (err) {
53
53
  return err.code === "MODULE_NOT_FOUND" && err.message.includes("sanity/cli") || console.error(`Error reading "${filePath}": ${err.message}`), null;
54
54
  }
@@ -67,27 +67,27 @@ ${err.message}`);
67
67
  }
68
68
  function hasStudioConfig(basePath) {
69
69
  return [
70
- fileExists(path$1.join(basePath, "sanity.config.js")),
71
- fileExists(path$1.join(basePath, "sanity.config.ts")),
70
+ fileExists(path.join(basePath, "sanity.config.js")),
71
+ fileExists(path.join(basePath, "sanity.config.ts")),
72
72
  isSanityV2StudioRoot(basePath)
73
73
  ].some(Boolean);
74
74
  }
75
75
  function resolveProjectRoot(basePath, iterations = 0) {
76
76
  if (hasStudioConfig(basePath))
77
77
  return basePath;
78
- const parentDir = path$1.resolve(basePath, "..");
78
+ const parentDir = path.resolve(basePath, "..");
79
79
  return parentDir === basePath || iterations > 30 ? !1 : resolveProjectRoot(parentDir, iterations + 1);
80
80
  }
81
81
  function isSanityV2StudioRoot(basePath) {
82
82
  try {
83
- const content = fs$1.readFileSync(path$1.join(basePath, "sanity.json"), "utf8"), isRoot = !!JSON.parse(content)?.root;
83
+ const content = fs.readFileSync(path.join(basePath, "sanity.json"), "utf8"), isRoot = !!JSON.parse(content)?.root;
84
84
  return isRoot && debug("Found Sanity v2 studio root at %s", basePath), isRoot;
85
85
  } catch {
86
86
  return !1;
87
87
  }
88
88
  }
89
89
  function fileExists(filePath) {
90
- return fs$1.existsSync(filePath);
90
+ return fs.existsSync(filePath);
91
91
  }
92
92
  function getCliClient(options = {}) {
93
93
  if (typeof process != "object")
@@ -103,10 +103,10 @@ function getCliClient(options = {}) {
103
103
  } = options;
104
104
  if (projectId && dataset)
105
105
  return createClient({ projectId, dataset, apiVersion, useCdn, token });
106
- const rootDir = resolveRootDir(cwd), { config: config2 } = getCliConfigSync(rootDir) || {};
107
- if (!config2)
106
+ const rootDir = resolveRootDir(cwd), { config } = getCliConfigSync(rootDir) || {};
107
+ if (!config)
108
108
  throw new Error("Unable to resolve CLI configuration");
109
- const apiConfig = config2?.api || {};
109
+ const apiConfig = config?.api || {};
110
110
  if (!apiConfig.projectId || !apiConfig.dataset)
111
111
  throw new Error("Unable to resolve project ID/dataset from CLI configuration");
112
112
  return createClient({
@@ -119,13 +119,13 @@ function getCliClient(options = {}) {
119
119
  }
120
120
  getCliClient.__internal__getToken = () => {
121
121
  };
122
- function defineCliConfig(config2) {
123
- return config2;
122
+ function defineCliConfig(config) {
123
+ return config;
124
124
  }
125
- function createCliConfig(config2) {
126
- return config2;
125
+ function createCliConfig(config) {
126
+ return config;
127
127
  }
128
- var main$1 = { exports: {} }, name = "dotenv", version$1 = "16.4.5", description = "Loads environment variables from .env file", main = "lib/main.js", types = "lib/main.d.ts", exports = {
128
+ var main$2 = { exports: {} }, name = "dotenv", version = "16.4.5", description = "Loads environment variables from .env file", main$1 = "lib/main.js", types = "lib/main.d.ts", exports = {
129
129
  ".": {
130
130
  types: "./lib/main.d.ts",
131
131
  require: "./lib/main.js",
@@ -175,9 +175,9 @@ var main$1 = { exports: {} }, name = "dotenv", version$1 = "16.4.5", description
175
175
  fs: !1
176
176
  }, require$$4 = {
177
177
  name,
178
- version: version$1,
178
+ version,
179
179
  description,
180
- main,
180
+ main: main$1,
181
181
  types,
182
182
  exports,
183
183
  scripts,
@@ -189,214 +189,217 @@ var main$1 = { exports: {} }, name = "dotenv", version$1 = "16.4.5", description
189
189
  devDependencies,
190
190
  engines,
191
191
  browser
192
- };
193
- const fs = require$$0, path = require$$1, os = require$$2, crypto = require$$3, packageJson = require$$4, version = packageJson.version, LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
194
- function parse(src) {
195
- const obj = {};
196
- let lines = src.toString();
197
- lines = lines.replace(/\r\n?/mg, `
192
+ }, hasRequiredMain$1;
193
+ function requireMain$1() {
194
+ if (hasRequiredMain$1) return main$2.exports;
195
+ hasRequiredMain$1 = 1;
196
+ const fs2 = require$$0, path2 = require$$1, os = require$$2, crypto = require$$3, version2 = require$$4.version, LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
197
+ function parse(src) {
198
+ const obj = {};
199
+ let lines = src.toString();
200
+ lines = lines.replace(/\r\n?/mg, `
198
201
  `);
199
- let match;
200
- for (; (match = LINE.exec(lines)) != null; ) {
201
- const key = match[1];
202
- let value = match[2] || "";
203
- value = value.trim();
204
- const maybeQuote = value[0];
205
- value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), maybeQuote === '"' && (value = value.replace(/\\n/g, `
202
+ let match;
203
+ for (; (match = LINE.exec(lines)) != null; ) {
204
+ const key = match[1];
205
+ let value = match[2] || "";
206
+ value = value.trim();
207
+ const maybeQuote = value[0];
208
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2"), maybeQuote === '"' && (value = value.replace(/\\n/g, `
206
209
  `), value = value.replace(/\\r/g, "\r")), obj[key] = value;
210
+ }
211
+ return obj;
207
212
  }
208
- return obj;
209
- }
210
- function _parseVault(options) {
211
- const vaultPath = _vaultPath(options), result = DotenvModule.configDotenv({ path: vaultPath });
212
- if (!result.parsed) {
213
- const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
214
- throw err.code = "MISSING_DATA", err;
213
+ function _parseVault(options) {
214
+ const vaultPath = _vaultPath(options), result = DotenvModule.configDotenv({ path: vaultPath });
215
+ if (!result.parsed) {
216
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
217
+ throw err.code = "MISSING_DATA", err;
218
+ }
219
+ const keys = _dotenvKey(options).split(","), length = keys.length;
220
+ let decrypted;
221
+ for (let i = 0; i < length; i++)
222
+ try {
223
+ const key = keys[i].trim(), attrs = _instructions(result, key);
224
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
225
+ break;
226
+ } catch (error) {
227
+ if (i + 1 >= length)
228
+ throw error;
229
+ }
230
+ return DotenvModule.parse(decrypted);
231
+ }
232
+ function _log(message) {
233
+ console.log(`[dotenv@${version2}][INFO] ${message}`);
215
234
  }
216
- const keys = _dotenvKey(options).split(","), length = keys.length;
217
- let decrypted;
218
- for (let i = 0; i < length; i++)
235
+ function _warn(message) {
236
+ console.log(`[dotenv@${version2}][WARN] ${message}`);
237
+ }
238
+ function _debug(message) {
239
+ console.log(`[dotenv@${version2}][DEBUG] ${message}`);
240
+ }
241
+ function _dotenvKey(options) {
242
+ return options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0 ? options.DOTENV_KEY : process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0 ? process.env.DOTENV_KEY : "";
243
+ }
244
+ function _instructions(result, dotenvKey) {
245
+ let uri;
219
246
  try {
220
- const key = keys[i].trim(), attrs = _instructions(result, key);
221
- decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
222
- break;
247
+ uri = new URL(dotenvKey);
223
248
  } catch (error) {
224
- if (i + 1 >= length)
225
- throw error;
249
+ if (error.code === "ERR_INVALID_URL") {
250
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
251
+ throw err.code = "INVALID_DOTENV_KEY", err;
252
+ }
253
+ throw error;
226
254
  }
227
- return DotenvModule.parse(decrypted);
228
- }
229
- function _log(message) {
230
- console.log(`[dotenv@${version}][INFO] ${message}`);
231
- }
232
- function _warn(message) {
233
- console.log(`[dotenv@${version}][WARN] ${message}`);
234
- }
235
- function _debug(message) {
236
- console.log(`[dotenv@${version}][DEBUG] ${message}`);
237
- }
238
- function _dotenvKey(options) {
239
- return options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0 ? options.DOTENV_KEY : process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0 ? process.env.DOTENV_KEY : "";
240
- }
241
- function _instructions(result, dotenvKey) {
242
- let uri;
243
- try {
244
- uri = new URL(dotenvKey);
245
- } catch (error) {
246
- if (error.code === "ERR_INVALID_URL") {
247
- const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
255
+ const key = uri.password;
256
+ if (!key) {
257
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
248
258
  throw err.code = "INVALID_DOTENV_KEY", err;
249
259
  }
250
- throw error;
260
+ const environment = uri.searchParams.get("environment");
261
+ if (!environment) {
262
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
263
+ throw err.code = "INVALID_DOTENV_KEY", err;
264
+ }
265
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`, ciphertext = result.parsed[environmentKey];
266
+ if (!ciphertext) {
267
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
268
+ throw err.code = "NOT_FOUND_DOTENV_ENVIRONMENT", err;
269
+ }
270
+ return { ciphertext, key };
251
271
  }
252
- const key = uri.password;
253
- if (!key) {
254
- const err = new Error("INVALID_DOTENV_KEY: Missing key part");
255
- throw err.code = "INVALID_DOTENV_KEY", err;
272
+ function _vaultPath(options) {
273
+ let possibleVaultPath = null;
274
+ if (options && options.path && options.path.length > 0)
275
+ if (Array.isArray(options.path))
276
+ for (const filepath of options.path)
277
+ fs2.existsSync(filepath) && (possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`);
278
+ else
279
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
280
+ else
281
+ possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
282
+ return fs2.existsSync(possibleVaultPath) ? possibleVaultPath : null;
256
283
  }
257
- const environment = uri.searchParams.get("environment");
258
- if (!environment) {
259
- const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
260
- throw err.code = "INVALID_DOTENV_KEY", err;
284
+ function _resolveHome(envPath) {
285
+ return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
261
286
  }
262
- const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`, ciphertext = result.parsed[environmentKey];
263
- if (!ciphertext) {
264
- const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
265
- throw err.code = "NOT_FOUND_DOTENV_ENVIRONMENT", err;
287
+ function _configVault(options) {
288
+ _log("Loading env from encrypted .env.vault");
289
+ const parsed = DotenvModule._parseVault(options);
290
+ let processEnv = process.env;
291
+ return options && options.processEnv != null && (processEnv = options.processEnv), DotenvModule.populate(processEnv, parsed, options), { parsed };
266
292
  }
267
- return { ciphertext, key };
268
- }
269
- function _vaultPath(options) {
270
- let possibleVaultPath = null;
271
- if (options && options.path && options.path.length > 0)
272
- if (Array.isArray(options.path))
273
- for (const filepath of options.path)
274
- fs.existsSync(filepath) && (possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`);
275
- else
276
- possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
277
- else
278
- possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
279
- return fs.existsSync(possibleVaultPath) ? possibleVaultPath : null;
280
- }
281
- function _resolveHome(envPath) {
282
- return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
283
- }
284
- function _configVault(options) {
285
- _log("Loading env from encrypted .env.vault");
286
- const parsed = DotenvModule._parseVault(options);
287
- let processEnv = process.env;
288
- return options && options.processEnv != null && (processEnv = options.processEnv), DotenvModule.populate(processEnv, parsed, options), { parsed };
289
- }
290
- function configDotenv(options) {
291
- const dotenvPath = path.resolve(process.cwd(), ".env");
292
- let encoding = "utf8";
293
- const debug2 = !!(options && options.debug);
294
- options && options.encoding ? encoding = options.encoding : debug2 && _debug("No encoding is specified. UTF-8 is used by default");
295
- let optionPaths = [dotenvPath];
296
- if (options && options.path)
297
- if (!Array.isArray(options.path))
298
- optionPaths = [_resolveHome(options.path)];
299
- else {
300
- optionPaths = [];
301
- for (const filepath of options.path)
302
- optionPaths.push(_resolveHome(filepath));
303
- }
304
- let lastError;
305
- const parsedAll = {};
306
- for (const path2 of optionPaths)
293
+ function configDotenv(options) {
294
+ const dotenvPath = path2.resolve(process.cwd(), ".env");
295
+ let encoding = "utf8";
296
+ const debug2 = !!(options && options.debug);
297
+ options && options.encoding ? encoding = options.encoding : debug2 && _debug("No encoding is specified. UTF-8 is used by default");
298
+ let optionPaths = [dotenvPath];
299
+ if (options && options.path)
300
+ if (!Array.isArray(options.path))
301
+ optionPaths = [_resolveHome(options.path)];
302
+ else {
303
+ optionPaths = [];
304
+ for (const filepath of options.path)
305
+ optionPaths.push(_resolveHome(filepath));
306
+ }
307
+ let lastError;
308
+ const parsedAll = {};
309
+ for (const path3 of optionPaths)
310
+ try {
311
+ const parsed = DotenvModule.parse(fs2.readFileSync(path3, { encoding }));
312
+ DotenvModule.populate(parsedAll, parsed, options);
313
+ } catch (e) {
314
+ debug2 && _debug(`Failed to load ${path3} ${e.message}`), lastError = e;
315
+ }
316
+ let processEnv = process.env;
317
+ return options && options.processEnv != null && (processEnv = options.processEnv), DotenvModule.populate(processEnv, parsedAll, options), lastError ? { parsed: parsedAll, error: lastError } : { parsed: parsedAll };
318
+ }
319
+ function config(options) {
320
+ if (_dotenvKey(options).length === 0)
321
+ return DotenvModule.configDotenv(options);
322
+ const vaultPath = _vaultPath(options);
323
+ return vaultPath ? DotenvModule._configVault(options) : (_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`), DotenvModule.configDotenv(options));
324
+ }
325
+ function decrypt(encrypted, keyStr) {
326
+ const key = Buffer.from(keyStr.slice(-64), "hex");
327
+ let ciphertext = Buffer.from(encrypted, "base64");
328
+ const nonce = ciphertext.subarray(0, 12), authTag = ciphertext.subarray(-16);
329
+ ciphertext = ciphertext.subarray(12, -16);
307
330
  try {
308
- const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
309
- DotenvModule.populate(parsedAll, parsed, options);
310
- } catch (e) {
311
- debug2 && _debug(`Failed to load ${path2} ${e.message}`), lastError = e;
331
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
332
+ return aesgcm.setAuthTag(authTag), `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
333
+ } catch (error) {
334
+ const isRange = error instanceof RangeError, invalidKeyLength = error.message === "Invalid key length", decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
335
+ if (isRange || invalidKeyLength) {
336
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
337
+ throw err.code = "INVALID_DOTENV_KEY", err;
338
+ } else if (decryptionFailed) {
339
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
340
+ throw err.code = "DECRYPTION_FAILED", err;
341
+ } else
342
+ throw error;
312
343
  }
313
- let processEnv = process.env;
314
- return options && options.processEnv != null && (processEnv = options.processEnv), DotenvModule.populate(processEnv, parsedAll, options), lastError ? { parsed: parsedAll, error: lastError } : { parsed: parsedAll };
315
- }
316
- function config(options) {
317
- if (_dotenvKey(options).length === 0)
318
- return DotenvModule.configDotenv(options);
319
- const vaultPath = _vaultPath(options);
320
- return vaultPath ? DotenvModule._configVault(options) : (_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`), DotenvModule.configDotenv(options));
321
- }
322
- function decrypt(encrypted, keyStr) {
323
- const key = Buffer.from(keyStr.slice(-64), "hex");
324
- let ciphertext = Buffer.from(encrypted, "base64");
325
- const nonce = ciphertext.subarray(0, 12), authTag = ciphertext.subarray(-16);
326
- ciphertext = ciphertext.subarray(12, -16);
327
- try {
328
- const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
329
- return aesgcm.setAuthTag(authTag), `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
330
- } catch (error) {
331
- const isRange = error instanceof RangeError, invalidKeyLength = error.message === "Invalid key length", decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
332
- if (isRange || invalidKeyLength) {
333
- const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
334
- throw err.code = "INVALID_DOTENV_KEY", err;
335
- } else if (decryptionFailed) {
336
- const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
337
- throw err.code = "DECRYPTION_FAILED", err;
338
- } else
339
- throw error;
340
344
  }
341
- }
342
- function populate(processEnv, parsed, options = {}) {
343
- const debug2 = !!(options && options.debug), override = !!(options && options.override);
344
- if (typeof parsed != "object") {
345
- const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
346
- throw err.code = "OBJECT_REQUIRED", err;
345
+ function populate(processEnv, parsed, options = {}) {
346
+ const debug2 = !!(options && options.debug), override = !!(options && options.override);
347
+ if (typeof parsed != "object") {
348
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
349
+ throw err.code = "OBJECT_REQUIRED", err;
350
+ }
351
+ for (const key of Object.keys(parsed))
352
+ Object.prototype.hasOwnProperty.call(processEnv, key) ? (override === !0 && (processEnv[key] = parsed[key]), debug2 && _debug(override === !0 ? `"${key}" is already defined and WAS overwritten` : `"${key}" is already defined and was NOT overwritten`)) : processEnv[key] = parsed[key];
347
353
  }
348
- for (const key of Object.keys(parsed))
349
- Object.prototype.hasOwnProperty.call(processEnv, key) ? (override === !0 && (processEnv[key] = parsed[key]), debug2 && _debug(override === !0 ? `"${key}" is already defined and WAS overwritten` : `"${key}" is already defined and was NOT overwritten`)) : processEnv[key] = parsed[key];
350
- }
351
- const DotenvModule = {
352
- configDotenv,
353
- _configVault,
354
- _parseVault,
355
- config,
356
- decrypt,
357
- parse,
358
- populate
359
- };
360
- main$1.exports.configDotenv = DotenvModule.configDotenv;
361
- main$1.exports._configVault = DotenvModule._configVault;
362
- main$1.exports._parseVault = DotenvModule._parseVault;
363
- main$1.exports.config = DotenvModule.config;
364
- main$1.exports.decrypt = DotenvModule.decrypt;
365
- var parse_1 = main$1.exports.parse = DotenvModule.parse;
366
- main$1.exports.populate = DotenvModule.populate;
367
- main$1.exports = DotenvModule;
368
- function _interpolate(envValue, environment, config2) {
369
- const matches = envValue.match(/(.?\${*[\w]*(?::-[\w/]*)?}*)/g) || [];
370
- return matches.reduce(function(newEnv, match, index) {
371
- const parts = /(.?)\${*([\w]*(?::-[\w/]*)?)?}*/g.exec(match);
372
- if (!parts || parts.length === 0)
373
- return newEnv;
374
- const prefix = parts[1];
375
- let value, replacePart;
376
- if (prefix === "\\")
377
- replacePart = parts[0], value = replacePart.replace("\\$", "$");
378
- else {
379
- const keyParts = parts[2].split(":-"), key = keyParts[0];
380
- if (replacePart = parts[0].substring(prefix.length), value = Object.prototype.hasOwnProperty.call(environment, key) ? environment[key] : config2.parsed[key] || keyParts[1] || "", keyParts.length > 1 && value) {
381
- const replaceNested = matches[index + 1];
382
- matches[index + 1] = "", newEnv = newEnv.replace(replaceNested, "");
354
+ const DotenvModule = {
355
+ configDotenv,
356
+ _configVault,
357
+ _parseVault,
358
+ config,
359
+ decrypt,
360
+ parse,
361
+ populate
362
+ };
363
+ return main$2.exports.configDotenv = DotenvModule.configDotenv, main$2.exports._configVault = DotenvModule._configVault, main$2.exports._parseVault = DotenvModule._parseVault, main$2.exports.config = DotenvModule.config, main$2.exports.decrypt = DotenvModule.decrypt, main$2.exports.parse = DotenvModule.parse, main$2.exports.populate = DotenvModule.populate, main$2.exports = DotenvModule, main$2.exports;
364
+ }
365
+ var mainExports$1 = requireMain$1(), main = {}, hasRequiredMain;
366
+ function requireMain() {
367
+ if (hasRequiredMain) return main;
368
+ hasRequiredMain = 1;
369
+ function _interpolate(envValue, environment, config) {
370
+ const matches = envValue.match(/(.?\${*[\w]*(?::-[\w/]*)?}*)/g) || [];
371
+ return matches.reduce(function(newEnv, match, index) {
372
+ const parts = /(.?)\${*([\w]*(?::-[\w/]*)?)?}*/g.exec(match);
373
+ if (!parts || parts.length === 0)
374
+ return newEnv;
375
+ const prefix = parts[1];
376
+ let value, replacePart;
377
+ if (prefix === "\\")
378
+ replacePart = parts[0], value = replacePart.replace("\\$", "$");
379
+ else {
380
+ const keyParts = parts[2].split(":-"), key = keyParts[0];
381
+ if (replacePart = parts[0].substring(prefix.length), value = Object.prototype.hasOwnProperty.call(environment, key) ? environment[key] : config.parsed[key] || keyParts[1] || "", keyParts.length > 1 && value) {
382
+ const replaceNested = matches[index + 1];
383
+ matches[index + 1] = "", newEnv = newEnv.replace(replaceNested, "");
384
+ }
385
+ value = _interpolate(value, environment, config);
383
386
  }
384
- value = _interpolate(value, environment, config2);
387
+ return newEnv.replace(replacePart, value);
388
+ }, envValue);
389
+ }
390
+ function expand(config) {
391
+ const environment = config.ignoreProcessEnv ? {} : process.env;
392
+ for (const configKey in config.parsed) {
393
+ const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey];
394
+ config.parsed[configKey] = _interpolate(value, environment, config);
385
395
  }
386
- return newEnv.replace(replacePart, value);
387
- }, envValue);
388
- }
389
- function expand(config2) {
390
- const environment = config2.ignoreProcessEnv ? {} : process.env;
391
- for (const configKey in config2.parsed) {
392
- const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config2.parsed[configKey];
393
- config2.parsed[configKey] = _interpolate(value, environment, config2);
396
+ for (const processKey in config.parsed)
397
+ environment[processKey] = config.parsed[processKey];
398
+ return config;
394
399
  }
395
- for (const processKey in config2.parsed)
396
- environment[processKey] = config2.parsed[processKey];
397
- return config2;
400
+ return main.expand = expand, main;
398
401
  }
399
- var expand_1 = expand;
402
+ var mainExports = requireMain();
400
403
  function loadEnv(mode, envDir, prefixes = ["VITE_"]) {
401
404
  if (mode === "local")
402
405
  throw new Error(
@@ -416,12 +419,12 @@ function loadEnv(mode, envDir, prefixes = ["VITE_"]) {
416
419
  const envPath = lookupFile(envDir, [file], {
417
420
  rootDir: envDir
418
421
  });
419
- return envPath ? Object.entries(parse_1(fs$1.readFileSync(envPath))) : [];
422
+ return envPath ? Object.entries(mainExports$1.parse(fs.readFileSync(envPath))) : [];
420
423
  })
421
424
  );
422
425
  parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0 && (process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV), parsed.BROWSER && process.env.BROWSER === void 0 && (process.env.BROWSER = parsed.BROWSER), parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0 && (process.env.BROWSER_ARGS = parsed.BROWSER_ARGS);
423
426
  try {
424
- expand_1({ parsed });
427
+ mainExports.expand({ parsed });
425
428
  } catch (e) {
426
429
  throw e.message.includes("split") ? new Error("dotenv-expand failed to expand env vars. Maybe you need to escape `$`?") : e;
427
430
  }
@@ -433,11 +436,11 @@ function loadEnv(mode, envDir, prefixes = ["VITE_"]) {
433
436
  }
434
437
  function lookupFile(dir, formats, options) {
435
438
  for (const format of formats) {
436
- const fullPath = path$1.join(dir, format);
437
- if (fs$1.existsSync(fullPath) && fs$1.statSync(fullPath).isFile())
439
+ const fullPath = path.join(dir, format);
440
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile())
438
441
  return fullPath;
439
442
  }
440
- const parentDir = path$1.dirname(dir);
443
+ const parentDir = path.dirname(dir);
441
444
  if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir)))
442
445
  return lookupFile(parentDir, formats, options);
443
446
  }