@sanity/cli 4.5.0-next.9 → 4.5.0-next.91
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/_chunks-cjs/cli.js +10 -52
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/_chunks-cjs/getCliConfig.js +4 -25
- package/lib/_chunks-cjs/getCliConfig.js.map +1 -1
- package/lib/cli.js +1 -3
- package/lib/cli.js.map +1 -1
- package/lib/index.d.mts +15 -38
- package/lib/index.d.ts +15 -38
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +3 -24
- package/lib/index.mjs.map +1 -1
- package/package.json +30 -30
|
@@ -24,16 +24,13 @@ async function getCliConfig(cwd, { forked } = {}) {
|
|
|
24
24
|
require("esbuild-register/dist/node").register({ supported: { "dynamic-import": !0 } })
|
|
25
25
|
);
|
|
26
26
|
try {
|
|
27
|
-
return getSanityCliConfig(cwd, clearCache)
|
|
27
|
+
return getSanityCliConfig(cwd, clearCache);
|
|
28
28
|
} catch (err) {
|
|
29
29
|
throw err;
|
|
30
30
|
} finally {
|
|
31
31
|
unregister();
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function getCliConfigSync(cwd) {
|
|
35
|
-
return getSanityCliConfig(cwd) || getSanityJsonConfig(cwd);
|
|
36
|
-
}
|
|
37
34
|
async function getCliConfigForked(cwd) {
|
|
38
35
|
const workerPath = await cliWorker.getCliWorkerPath("getCliConfig");
|
|
39
36
|
return new Promise((resolve, reject) => {
|
|
@@ -53,34 +50,16 @@ async function getCliConfigForked(cwd) {
|
|
|
53
50
|
});
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
|
-
function getSanityJsonConfig(cwd) {
|
|
57
|
-
const configPath = path__default.default.join(cwd, "sanity.json");
|
|
58
|
-
return fs__default.default.existsSync(configPath) ? {
|
|
59
|
-
config: loadJsonConfig(configPath),
|
|
60
|
-
path: configPath,
|
|
61
|
-
version: 2
|
|
62
|
-
} : null;
|
|
63
|
-
}
|
|
64
53
|
function getSanityCliConfig(cwd, clearCache = !1) {
|
|
65
54
|
const jsConfigPath = path__default.default.join(cwd, "sanity.cli.js"), tsConfigPath = path__default.default.join(cwd, "sanity.cli.ts"), [js, ts] = [fs__default.default.existsSync(jsConfigPath), fs__default.default.existsSync(tsConfigPath)];
|
|
66
55
|
return !js && !ts ? null : !js && ts ? {
|
|
67
56
|
config: importConfig(tsConfigPath, clearCache),
|
|
68
|
-
path: tsConfigPath
|
|
69
|
-
version: 3
|
|
57
|
+
path: tsConfigPath
|
|
70
58
|
} : (js && ts && warn("Found both `sanity.cli.js` and `sanity.cli.ts` - using sanity.cli.js"), {
|
|
71
59
|
config: importConfig(jsConfigPath, clearCache),
|
|
72
|
-
path: jsConfigPath
|
|
73
|
-
version: 3
|
|
60
|
+
path: jsConfigPath
|
|
74
61
|
});
|
|
75
62
|
}
|
|
76
|
-
function loadJsonConfig(filePath) {
|
|
77
|
-
try {
|
|
78
|
-
const content = fs__default.default.readFileSync(filePath, "utf8");
|
|
79
|
-
return JSON.parse(content);
|
|
80
|
-
} catch (err) {
|
|
81
|
-
return console.error(`Error reading "${filePath}": ${err.message}`), null;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
63
|
function importConfig(filePath, clearCache) {
|
|
85
64
|
try {
|
|
86
65
|
if (clearCache) {
|
|
@@ -101,5 +80,5 @@ function warn(warning) {
|
|
|
101
80
|
exports.debug = debug;
|
|
102
81
|
exports.dynamicRequire = dynamicRequire;
|
|
103
82
|
exports.getCliConfig = getCliConfig;
|
|
104
|
-
exports.
|
|
83
|
+
exports.getSanityCliConfig = getSanityCliConfig;
|
|
105
84
|
//# sourceMappingURL=getCliConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCliConfig.js","sources":["../../src/debug.ts","../../src/util/dynamicRequire.ts","../../src/util/getCliConfig.ts"],"sourcesContent":["import debugIt from 'debug'\n\nexport const debug = debugIt('sanity:cli')\n","// Prevent webpack from bundling in webpack context,\n// use regular node require for unbundled context\n\n/* eslint-disable camelcase */\ndeclare const __webpack_require__: boolean\ndeclare const __non_webpack_require__: typeof require\n\nconst requireFunc: typeof require =\n typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require\n/* eslint-enable camelcase */\n\nexport function dynamicRequire<T = any>(request: string): T {\n const mod = requireFunc(request)\n return mod.__esModule && mod.default ? mod.default : mod\n}\n\ndynamicRequire.resolve = requireFunc.resolve\ndynamicRequire.cache = requireFunc.cache\n","/**\n * Reads the Sanity CLI config from one of the following files (in preferred order):\n * - sanity.cli.js\n * - sanity.cli.ts\n *\n * Note: There are two ways of using this:\n * a) `getCliConfig(cwd)`\n * b) `getCliConfig(cwd, {forked: true})`\n *\n * Approach a is generally a bit faster as it avoids the forking startup time, while\n * approach b could be considered \"safer\" since any side-effects of running the config\n * file will not bleed into the current CLI process directly.\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {debug} from '../debug'\nimport {type CliConfig
|
|
1
|
+
{"version":3,"file":"getCliConfig.js","sources":["../../src/debug.ts","../../src/util/dynamicRequire.ts","../../src/util/getCliConfig.ts"],"sourcesContent":["import debugIt from 'debug'\n\nexport const debug = debugIt('sanity:cli')\n","// Prevent webpack from bundling in webpack context,\n// use regular node require for unbundled context\n\n/* eslint-disable camelcase */\ndeclare const __webpack_require__: boolean\ndeclare const __non_webpack_require__: typeof require\n\nconst requireFunc: typeof require =\n typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require\n/* eslint-enable camelcase */\n\nexport function dynamicRequire<T = any>(request: string): T {\n const mod = requireFunc(request)\n return mod.__esModule && mod.default ? mod.default : mod\n}\n\ndynamicRequire.resolve = requireFunc.resolve\ndynamicRequire.cache = requireFunc.cache\n","/**\n * Reads the Sanity CLI config from one of the following files (in preferred order):\n * - sanity.cli.js\n * - sanity.cli.ts\n *\n * Note: There are two ways of using this:\n * a) `getCliConfig(cwd)`\n * b) `getCliConfig(cwd, {forked: true})`\n *\n * Approach a is generally a bit faster as it avoids the forking startup time, while\n * approach b could be considered \"safer\" since any side-effects of running the config\n * file will not bleed into the current CLI process directly.\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {debug} from '../debug'\nimport {type CliConfig} from '../types'\nimport {getCliWorkerPath} from './cliWorker'\nimport {dynamicRequire} from './dynamicRequire'\n\nexport type CliConfigResult = {config: CliConfig; path: string} | {config: null; path: string}\n\nexport async function getCliConfig(\n cwd: string,\n {forked}: {forked?: boolean} = {},\n): Promise<CliConfigResult | null> {\n let clearCache = false\n if (forked) {\n try {\n return await getCliConfigForked(cwd)\n } catch (err) {\n debug('Error in getCliConfigForked', err)\n clearCache = true\n // Intentional noop - try unforked variant\n }\n }\n\n const {unregister} = __DEV__\n ? {unregister: () => undefined}\n : // eslint-disable-next-line @typescript-eslint/no-require-imports\n require('esbuild-register/dist/node').register({supported: {'dynamic-import': true}})\n\n try {\n // If forked execution failed, we need to clear the cache to reload the env vars\n return getSanityCliConfig(cwd, clearCache)\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n\nasync function getCliConfigForked(cwd: string): Promise<CliConfigResult | null> {\n const workerPath = await getCliWorkerPath('getCliConfig')\n return new Promise((resolve, reject) => {\n const worker = new Worker(workerPath, {\n workerData: cwd,\n env: process.env,\n })\n worker.on('message', (message) => {\n if (message.type === 'config') {\n resolve(message.config)\n } else {\n const error = new Error(message.error)\n ;(error as any).type = message.errorType\n reject(new Error(message.error))\n }\n })\n worker.on('error', reject)\n worker.on('exit', (code) => {\n if (code !== 0) {\n reject(new Error(`Worker stopped with exit code ${code}`))\n }\n })\n })\n}\n\nexport function getSanityCliConfig(cwd: string, clearCache = false): CliConfigResult | null {\n const jsConfigPath = path.join(cwd, 'sanity.cli.js')\n const tsConfigPath = path.join(cwd, 'sanity.cli.ts')\n\n const [js, ts] = [fs.existsSync(jsConfigPath), fs.existsSync(tsConfigPath)]\n\n if (!js && !ts) {\n return null\n }\n\n if (!js && ts) {\n return {\n config: importConfig(tsConfigPath, clearCache),\n path: tsConfigPath,\n }\n }\n\n if (js && ts) {\n warn('Found both `sanity.cli.js` and `sanity.cli.ts` - using sanity.cli.js')\n }\n\n return {\n config: importConfig(jsConfigPath, clearCache),\n path: jsConfigPath,\n }\n}\n\nfunction importConfig(filePath: string, clearCache: boolean): CliConfig | null {\n try {\n // Clear module cache if requested (needed for env var reload)\n if (clearCache) {\n const resolvedPath = dynamicRequire.resolve(filePath)\n delete dynamicRequire.cache[resolvedPath]\n }\n\n const config = dynamicRequire<CliConfig | {default: CliConfig} | null>(filePath)\n if (config === null || typeof config !== 'object') {\n throw new Error('Module export is not a configuration object')\n }\n\n return 'default' in config ? config.default : config\n } catch (err) {\n // If attempting to import `defineCliConfig` or similar from `sanity/cli`,\n // accept the fact that it might not be installed. Instead, let the CLI\n // give a warning about the `sanity` module not being installed\n if (err.code === 'MODULE_NOT_FOUND' && err.message.includes('sanity/cli')) {\n return null\n }\n\n console.error(`Error reading \"${filePath}\": ${err.message}`)\n return null\n }\n}\n\nfunction warn(warning: string) {\n if (typeof process.send === 'function') {\n process.send({type: 'warning', warning})\n } else {\n console.warn(warning)\n }\n}\n"],"names":["debugIt","getCliWorkerPath","Worker","path","fs"],"mappings":";;;;;;AAEO,MAAM,QAAQA,iBAAAA,QAAQ,YAAY,GCKnC,cACJ,OAAO,uBAAwB,aAAa,0BAA0B;AAGjE,SAAS,eAAwB,SAAoB;AAC1D,QAAM,MAAM,YAAY,OAAO;AAC/B,SAAO,IAAI,cAAc,IAAI,UAAU,IAAI,UAAU;AACvD;AAEA,eAAe,UAAU,YAAY;AACrC,eAAe,QAAQ,YAAY;ACOnC,eAAsB,aACpB,KACA,EAAC,OAAA,IAA8B,CAAA,GACE;AACjC,MAAI,aAAa;AACjB,MAAI;AACF,QAAI;AACF,aAAO,MAAM,mBAAmB,GAAG;AAAA,IACrC,SAAS,KA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aAAa,cAAc,UAAU;AAAA,IAC7C,MAAM;AAAA,EAAA,KAIN,MAAM,MACR,KAAK,sEAAsE,GAGtE;AAAA,IACL,QAAQ,aAAa,cAAc,UAAU;AAAA,IAC7C,MAAM;AAAA,EAAA;AAEV;AAEA,SAAS,aAAa,UAAkB,YAAuC;AAC7E,MAAI;AAEF,QAAI,YAAY;AACd,YAAM,eAAe,eAAe,QAAQ,QAAQ;AACpD,aAAO,eAAe,MAAM,YAAY;AAAA,IAC1C;AAEA,UAAM,SAAS,eAAwD,QAAQ;AAC/E,QAAI,WAAW,QAAQ,OAAO,UAAW;AACvC,YAAM,IAAI,MAAM,6CAA6C;AAG/D,WAAO,aAAa,SAAS,OAAO,UAAU;AAAA,EAChD,SAAS,KAAK;AAIZ,WAAI,IAAI,SAAS,sBAAsB,IAAI,QAAQ,SAAS,YAAY,KAIxE,QAAQ,MAAM,kBAAkB,QAAQ,MAAM,IAAI,OAAO,EAAE,GACpD;AAAA,EACT;AACF;AAEA,SAAS,KAAK,SAAiB;AACzB,SAAO,QAAQ,QAAS,aAC1B,QAAQ,KAAK,EAAC,MAAM,WAAW,QAAA,CAAQ,IAEvC,QAAQ,KAAK,OAAO;AAExB;;;;;"}
|
package/lib/cli.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
require("node:fs");
|
|
4
3
|
require("node:os");
|
|
5
|
-
require("node:path");
|
|
6
4
|
require("chalk");
|
|
7
|
-
require("./_chunks-cjs/loadEnv.js");
|
|
8
5
|
var cli = require("./_chunks-cjs/cli.js");
|
|
9
6
|
require("./_chunks-cjs/getCliConfig.js");
|
|
7
|
+
require("./_chunks-cjs/loadEnv.js");
|
|
10
8
|
exports.runCli = cli.runCli;
|
|
11
9
|
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
package/lib/index.d.mts
CHANGED
|
@@ -26,20 +26,6 @@ export declare interface CliApiConfig {
|
|
|
26
26
|
dataset?: string
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export declare interface CliBaseCommandContext {
|
|
30
|
-
output: CliOutputter
|
|
31
|
-
prompt: CliPrompter
|
|
32
|
-
apiClient: CliApiClient
|
|
33
|
-
sanityMajorVersion: 2 | 3
|
|
34
|
-
cliConfigPath?: string
|
|
35
|
-
cliRoot: string
|
|
36
|
-
workDir: string
|
|
37
|
-
corePath?: string
|
|
38
|
-
chalk: typeof chalk
|
|
39
|
-
commandRunner: CliCommandRunner
|
|
40
|
-
fromInitCommand?: boolean
|
|
41
|
-
}
|
|
42
|
-
|
|
43
29
|
export declare interface CliClientOptions {
|
|
44
30
|
cwd?: string
|
|
45
31
|
projectId?: string
|
|
@@ -62,7 +48,21 @@ export declare interface CliCommandArguments<F = Record<string, unknown>> {
|
|
|
62
48
|
extraArguments: string[]
|
|
63
49
|
}
|
|
64
50
|
|
|
65
|
-
export declare
|
|
51
|
+
export declare interface CliCommandContext {
|
|
52
|
+
output: CliOutputter
|
|
53
|
+
prompt: CliPrompter
|
|
54
|
+
apiClient: CliApiClient
|
|
55
|
+
cliConfigPath?: string
|
|
56
|
+
cliRoot: string
|
|
57
|
+
workDir: string
|
|
58
|
+
corePath?: string
|
|
59
|
+
chalk: typeof chalk
|
|
60
|
+
commandRunner: CliCommandRunner
|
|
61
|
+
fromInitCommand?: boolean
|
|
62
|
+
cliConfig?: CliConfig
|
|
63
|
+
cliPackageManager: CliPackageManager
|
|
64
|
+
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
65
|
+
}
|
|
66
66
|
|
|
67
67
|
export declare interface CliCommandDefinition<F = Record<string, unknown>> {
|
|
68
68
|
name: string
|
|
@@ -141,20 +141,13 @@ export declare interface CliConfig {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
declare type CliConfigResult =
|
|
144
|
-
| {
|
|
145
|
-
config: SanityJson
|
|
146
|
-
path: string
|
|
147
|
-
version: 2
|
|
148
|
-
}
|
|
149
144
|
| {
|
|
150
145
|
config: CliConfig
|
|
151
146
|
path: string
|
|
152
|
-
version: 3
|
|
153
147
|
}
|
|
154
148
|
| {
|
|
155
149
|
config: null
|
|
156
150
|
path: string
|
|
157
|
-
version: CliMajorVersion
|
|
158
151
|
}
|
|
159
152
|
|
|
160
153
|
declare interface ClientRequirements {
|
|
@@ -169,8 +162,6 @@ declare interface ClientRequirements {
|
|
|
169
162
|
}
|
|
170
163
|
}
|
|
171
164
|
|
|
172
|
-
declare type CliMajorVersion = 2 | 3
|
|
173
|
-
|
|
174
165
|
export declare interface CliOutputter {
|
|
175
166
|
print: (...args: unknown[]) => void
|
|
176
167
|
success: (...args: unknown[]) => void
|
|
@@ -210,20 +201,6 @@ export declare interface CliUserConfig {
|
|
|
210
201
|
authType?: string
|
|
211
202
|
}
|
|
212
203
|
|
|
213
|
-
export declare interface CliV2CommandContext extends CliBaseCommandContext {
|
|
214
|
-
sanityMajorVersion: 2
|
|
215
|
-
cliConfig?: SanityJson
|
|
216
|
-
cliPackageManager?: CliPackageManager
|
|
217
|
-
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export declare interface CliV3CommandContext extends CliBaseCommandContext {
|
|
221
|
-
sanityMajorVersion: 3
|
|
222
|
-
cliConfig?: CliConfig
|
|
223
|
-
cliPackageManager: CliPackageManager
|
|
224
|
-
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
225
|
-
}
|
|
226
|
-
|
|
227
204
|
export declare interface CliYarnOptions {
|
|
228
205
|
print?: CliOutputter['print']
|
|
229
206
|
error?: CliOutputter['error']
|
package/lib/index.d.ts
CHANGED
|
@@ -26,20 +26,6 @@ export declare interface CliApiConfig {
|
|
|
26
26
|
dataset?: string
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export declare interface CliBaseCommandContext {
|
|
30
|
-
output: CliOutputter
|
|
31
|
-
prompt: CliPrompter
|
|
32
|
-
apiClient: CliApiClient
|
|
33
|
-
sanityMajorVersion: 2 | 3
|
|
34
|
-
cliConfigPath?: string
|
|
35
|
-
cliRoot: string
|
|
36
|
-
workDir: string
|
|
37
|
-
corePath?: string
|
|
38
|
-
chalk: typeof chalk
|
|
39
|
-
commandRunner: CliCommandRunner
|
|
40
|
-
fromInitCommand?: boolean
|
|
41
|
-
}
|
|
42
|
-
|
|
43
29
|
export declare interface CliClientOptions {
|
|
44
30
|
cwd?: string
|
|
45
31
|
projectId?: string
|
|
@@ -62,7 +48,21 @@ export declare interface CliCommandArguments<F = Record<string, unknown>> {
|
|
|
62
48
|
extraArguments: string[]
|
|
63
49
|
}
|
|
64
50
|
|
|
65
|
-
export declare
|
|
51
|
+
export declare interface CliCommandContext {
|
|
52
|
+
output: CliOutputter
|
|
53
|
+
prompt: CliPrompter
|
|
54
|
+
apiClient: CliApiClient
|
|
55
|
+
cliConfigPath?: string
|
|
56
|
+
cliRoot: string
|
|
57
|
+
workDir: string
|
|
58
|
+
corePath?: string
|
|
59
|
+
chalk: typeof chalk
|
|
60
|
+
commandRunner: CliCommandRunner
|
|
61
|
+
fromInitCommand?: boolean
|
|
62
|
+
cliConfig?: CliConfig
|
|
63
|
+
cliPackageManager: CliPackageManager
|
|
64
|
+
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
65
|
+
}
|
|
66
66
|
|
|
67
67
|
export declare interface CliCommandDefinition<F = Record<string, unknown>> {
|
|
68
68
|
name: string
|
|
@@ -141,20 +141,13 @@ export declare interface CliConfig {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
declare type CliConfigResult =
|
|
144
|
-
| {
|
|
145
|
-
config: SanityJson
|
|
146
|
-
path: string
|
|
147
|
-
version: 2
|
|
148
|
-
}
|
|
149
144
|
| {
|
|
150
145
|
config: CliConfig
|
|
151
146
|
path: string
|
|
152
|
-
version: 3
|
|
153
147
|
}
|
|
154
148
|
| {
|
|
155
149
|
config: null
|
|
156
150
|
path: string
|
|
157
|
-
version: CliMajorVersion
|
|
158
151
|
}
|
|
159
152
|
|
|
160
153
|
declare interface ClientRequirements {
|
|
@@ -169,8 +162,6 @@ declare interface ClientRequirements {
|
|
|
169
162
|
}
|
|
170
163
|
}
|
|
171
164
|
|
|
172
|
-
declare type CliMajorVersion = 2 | 3
|
|
173
|
-
|
|
174
165
|
export declare interface CliOutputter {
|
|
175
166
|
print: (...args: unknown[]) => void
|
|
176
167
|
success: (...args: unknown[]) => void
|
|
@@ -210,20 +201,6 @@ export declare interface CliUserConfig {
|
|
|
210
201
|
authType?: string
|
|
211
202
|
}
|
|
212
203
|
|
|
213
|
-
export declare interface CliV2CommandContext extends CliBaseCommandContext {
|
|
214
|
-
sanityMajorVersion: 2
|
|
215
|
-
cliConfig?: SanityJson
|
|
216
|
-
cliPackageManager?: CliPackageManager
|
|
217
|
-
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export declare interface CliV3CommandContext extends CliBaseCommandContext {
|
|
221
|
-
sanityMajorVersion: 3
|
|
222
|
-
cliConfig?: CliConfig
|
|
223
|
-
cliPackageManager: CliPackageManager
|
|
224
|
-
telemetry: TelemetryLogger<TelemetryUserProperties>
|
|
225
|
-
}
|
|
226
|
-
|
|
227
204
|
export declare interface CliYarnOptions {
|
|
228
205
|
print?: CliOutputter['print']
|
|
229
206
|
error?: CliOutputter['error']
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ function getCliClientImpl(options = {}) {
|
|
|
14
14
|
} = options;
|
|
15
15
|
if (projectId && dataset)
|
|
16
16
|
return client.createClient({ projectId, dataset, apiVersion, useCdn, token });
|
|
17
|
-
const rootDir = loadEnv.resolveRootDir(cwd), { config } = getCliConfig.
|
|
17
|
+
const rootDir = loadEnv.resolveRootDir(cwd), { config } = getCliConfig.getSanityCliConfig(rootDir) || {};
|
|
18
18
|
if (!config)
|
|
19
19
|
throw new Error("Unable to resolve CLI configuration");
|
|
20
20
|
const apiConfig = config?.api || {};
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/cliClient.ts","../src/config.ts"],"sourcesContent":["import {createClient, type SanityClient} from '@sanity/client'\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/cliClient.ts","../src/config.ts"],"sourcesContent":["import {createClient, type SanityClient} from '@sanity/client'\n\nimport {getSanityCliConfig} from './util/getCliConfig'\nimport {resolveRootDir} from './util/resolveRootDir'\n\nexport interface CliClientOptions {\n cwd?: string\n\n projectId?: string\n dataset?: string\n useCdn?: boolean\n token?: string\n apiVersion?: string\n}\n\ninterface GetCliClient {\n (options?: CliClientOptions): SanityClient\n /**\n * @internal\n * @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules\n * @returns A token to use when constructing a client without a `token` explicitly defined, or undefined\n */\n __internal__getToken: () => string | undefined\n}\n\nfunction getCliClientImpl(options: CliClientOptions = {}): SanityClient {\n if (typeof process !== 'object') {\n throw new Error('getCliClient() should only be called from node.js scripts')\n }\n\n const {\n cwd = process.env.SANITY_BASE_PATH || process.cwd(),\n useCdn = false,\n apiVersion = '2022-06-06',\n projectId,\n dataset,\n token = getCliClient.__internal__getToken(),\n } = options\n\n if (projectId && dataset) {\n return createClient({projectId, dataset, apiVersion, useCdn, token})\n }\n\n const rootDir = resolveRootDir(cwd)\n const {config} = getSanityCliConfig(rootDir) || {}\n if (!config) {\n throw new Error('Unable to resolve CLI configuration')\n }\n\n const apiConfig = config?.api || {}\n if (!apiConfig.projectId || !apiConfig.dataset) {\n throw new Error('Unable to resolve project ID/dataset from CLI configuration')\n }\n\n return createClient({\n projectId: apiConfig.projectId,\n dataset: apiConfig.dataset,\n apiVersion,\n useCdn,\n token,\n })\n}\n\n/* eslint-disable camelcase */\ngetCliClientImpl.__internal__getToken = (): string | undefined => undefined\n/* eslint-enable camelcase */\n\n/** @internal */\nexport const getCliClient: GetCliClient = getCliClientImpl\n","import {type CliConfig} from './types'\n\n/** @beta */\nexport function defineCliConfig(config: CliConfig): CliConfig {\n return config\n}\n\n/**\n * @deprecated Use `defineCliConfig` instead\n * @beta\n */\nexport function createCliConfig(config: CliConfig): CliConfig {\n return config\n}\n"],"names":["createClient","resolveRootDir","getSanityCliConfig"],"mappings":";;;AAyBA,SAAS,iBAAiB,UAA4B,IAAkB;AACtE,MAAI,OAAO,WAAY;AACrB,UAAM,IAAI,MAAM,2DAA2D;AAG7E,QAAM;AAAA,IACJ,MAAM,QAAQ,IAAI,oBAAoB,QAAQ,IAAA;AAAA,IAC9C,SAAS;AAAA,IACT,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,QAAQ,aAAa,qBAAA;AAAA,EAAqB,IACxC;AAEJ,MAAI,aAAa;AACf,WAAOA,OAAAA,aAAa,EAAC,WAAW,SAAS,YAAY,QAAQ,OAAM;AAGrE,QAAM,UAAUC,QAAAA,eAAe,GAAG,GAC5B,EAAC,WAAUC,aAAAA,mBAAmB,OAAO,KAAK,CAAA;AAChD,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAM,YAAY,QAAQ,OAAO,CAAA;AACjC,MAAI,CAAC,UAAU,aAAa,CAAC,UAAU;AACrC,UAAM,IAAI,MAAM,6DAA6D;AAG/E,SAAOF,oBAAa;AAAA,IAClB,WAAW,UAAU;AAAA,IACrB,SAAS,UAAU;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AACH;AAGA,iBAAiB,uBAAuB,MAAuB;AAAA;AAIxD,MAAM,eAA6B;ACjEnC,SAAS,gBAAgB,QAA8B;AAC5D,SAAO;AACT;AAMO,SAAS,gBAAgB,QAA8B;AAC5D,SAAO;AACT;;;;;"}
|
package/lib/index.mjs
CHANGED
|
@@ -13,37 +13,16 @@ function dynamicRequire(request) {
|
|
|
13
13
|
}
|
|
14
14
|
dynamicRequire.resolve = requireFunc.resolve;
|
|
15
15
|
dynamicRequire.cache = requireFunc.cache;
|
|
16
|
-
function getCliConfigSync(cwd) {
|
|
17
|
-
return getSanityCliConfig(cwd) || getSanityJsonConfig(cwd);
|
|
18
|
-
}
|
|
19
|
-
function getSanityJsonConfig(cwd) {
|
|
20
|
-
const configPath = path.join(cwd, "sanity.json");
|
|
21
|
-
return fs.existsSync(configPath) ? {
|
|
22
|
-
config: loadJsonConfig(configPath),
|
|
23
|
-
path: configPath,
|
|
24
|
-
version: 2
|
|
25
|
-
} : null;
|
|
26
|
-
}
|
|
27
16
|
function getSanityCliConfig(cwd, clearCache = !1) {
|
|
28
17
|
const jsConfigPath = path.join(cwd, "sanity.cli.js"), tsConfigPath = path.join(cwd, "sanity.cli.ts"), [js, ts] = [fs.existsSync(jsConfigPath), fs.existsSync(tsConfigPath)];
|
|
29
18
|
return !js && !ts ? null : !js && ts ? {
|
|
30
19
|
config: importConfig(tsConfigPath, clearCache),
|
|
31
|
-
path: tsConfigPath
|
|
32
|
-
version: 3
|
|
20
|
+
path: tsConfigPath
|
|
33
21
|
} : (js && ts && warn("Found both `sanity.cli.js` and `sanity.cli.ts` - using sanity.cli.js"), {
|
|
34
22
|
config: importConfig(jsConfigPath, clearCache),
|
|
35
|
-
path: jsConfigPath
|
|
36
|
-
version: 3
|
|
23
|
+
path: jsConfigPath
|
|
37
24
|
});
|
|
38
25
|
}
|
|
39
|
-
function loadJsonConfig(filePath) {
|
|
40
|
-
try {
|
|
41
|
-
const content = fs.readFileSync(filePath, "utf8");
|
|
42
|
-
return JSON.parse(content);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
return console.error(`Error reading "${filePath}": ${err.message}`), null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
26
|
function importConfig(filePath, clearCache) {
|
|
48
27
|
try {
|
|
49
28
|
if (clearCache) {
|
|
@@ -106,7 +85,7 @@ function getCliClientImpl(options = {}) {
|
|
|
106
85
|
} = options;
|
|
107
86
|
if (projectId && dataset)
|
|
108
87
|
return createClient({ projectId, dataset, apiVersion, useCdn, token });
|
|
109
|
-
const rootDir = resolveRootDir(cwd), { config } =
|
|
88
|
+
const rootDir = resolveRootDir(cwd), { config } = getSanityCliConfig(rootDir) || {};
|
|
110
89
|
if (!config)
|
|
111
90
|
throw new Error("Unable to resolve CLI configuration");
|
|
112
91
|
const apiConfig = config?.api || {};
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/debug.ts","../src/util/dynamicRequire.ts","../src/util/getCliConfig.ts","../src/util/resolveRootDir.ts","../src/cliClient.ts","../src/config.ts","../../../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js","../../../../node_modules/.pnpm/dotenv-expand@9.0.0/node_modules/dotenv-expand/lib/main.js","../src/util/loadEnv.ts"],"sourcesContent":["import debugIt from 'debug'\n\nexport const debug = debugIt('sanity:cli')\n","// Prevent webpack from bundling in webpack context,\n// use regular node require for unbundled context\n\n/* eslint-disable camelcase */\ndeclare const __webpack_require__: boolean\ndeclare const __non_webpack_require__: typeof require\n\nconst requireFunc: typeof require =\n typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require\n/* eslint-enable camelcase */\n\nexport function dynamicRequire<T = any>(request: string): T {\n const mod = requireFunc(request)\n return mod.__esModule && mod.default ? mod.default : mod\n}\n\ndynamicRequire.resolve = requireFunc.resolve\ndynamicRequire.cache = requireFunc.cache\n","/**\n * Reads the Sanity CLI config from one of the following files (in preferred order):\n * - sanity.cli.js\n * - sanity.cli.ts\n *\n * Note: There are two ways of using this:\n * a) `getCliConfig(cwd)`\n * b) `getCliConfig(cwd, {forked: true})`\n *\n * Approach a is generally a bit faster as it avoids the forking startup time, while\n * approach b could be considered \"safer\" since any side-effects of running the config\n * file will not bleed into the current CLI process directly.\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {debug} from '../debug'\nimport {type CliConfig, type SanityJson} from '../types'\nimport {getCliWorkerPath} from './cliWorker'\nimport {dynamicRequire} from './dynamicRequire'\n\nexport type CliMajorVersion = 2 | 3\n\nexport type CliConfigResult =\n | {config: SanityJson; path: string; version: 2}\n | {config: CliConfig; path: string; version: 3}\n | {config: null; path: string; version: CliMajorVersion}\n\nexport async function getCliConfig(\n cwd: string,\n {forked}: {forked?: boolean} = {},\n): Promise<CliConfigResult | null> {\n let clearCache = false\n if (forked) {\n try {\n return await getCliConfigForked(cwd)\n } catch (err) {\n debug('Error in getCliConfigForked', err)\n clearCache = true\n // Intentional noop - try unforked variant\n }\n }\n\n const {unregister} = __DEV__\n ? {unregister: () => undefined}\n : // eslint-disable-next-line @typescript-eslint/no-require-imports\n require('esbuild-register/dist/node').register({supported: {'dynamic-import': true}})\n\n try {\n // If forked execution failed, we need to clear the cache to reload the env vars\n const v3Config = getSanityCliConfig(cwd, clearCache)\n if (v3Config) {\n return v3Config\n }\n\n return getSanityJsonConfig(cwd)\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n\nexport function getCliConfigSync(cwd: string): CliConfigResult | null {\n const v3Config = getSanityCliConfig(cwd)\n return v3Config ? v3Config : getSanityJsonConfig(cwd)\n}\n\nasync function getCliConfigForked(cwd: string): Promise<CliConfigResult | null> {\n const workerPath = await getCliWorkerPath('getCliConfig')\n return new Promise((resolve, reject) => {\n const worker = new Worker(workerPath, {\n workerData: cwd,\n env: process.env,\n })\n worker.on('message', (message) => {\n if (message.type === 'config') {\n resolve(message.config)\n } else {\n const error = new Error(message.error)\n ;(error as any).type = message.errorType\n reject(new Error(message.error))\n }\n })\n worker.on('error', reject)\n worker.on('exit', (code) => {\n if (code !== 0) {\n reject(new Error(`Worker stopped with exit code ${code}`))\n }\n })\n })\n}\n\nfunction getSanityJsonConfig(cwd: string): CliConfigResult | null {\n const configPath = path.join(cwd, 'sanity.json')\n\n if (!fs.existsSync(configPath)) {\n return null\n }\n\n return {\n config: loadJsonConfig(configPath),\n path: configPath,\n version: 2,\n }\n}\n\nfunction getSanityCliConfig(cwd: string, clearCache = false): CliConfigResult | null {\n const jsConfigPath = path.join(cwd, 'sanity.cli.js')\n const tsConfigPath = path.join(cwd, 'sanity.cli.ts')\n\n const [js, ts] = [fs.existsSync(jsConfigPath), fs.existsSync(tsConfigPath)]\n\n if (!js && !ts) {\n return null\n }\n\n if (!js && ts) {\n return {\n config: importConfig(tsConfigPath, clearCache),\n path: tsConfigPath,\n version: 3,\n }\n }\n\n if (js && ts) {\n warn('Found both `sanity.cli.js` and `sanity.cli.ts` - using sanity.cli.js')\n }\n\n return {\n config: importConfig(jsConfigPath, clearCache),\n path: jsConfigPath,\n version: 3,\n }\n}\n\nfunction loadJsonConfig(filePath: string): SanityJson | null {\n try {\n const content = fs.readFileSync(filePath, 'utf8')\n return JSON.parse(content)\n } catch (err) {\n console.error(`Error reading \"${filePath}\": ${err.message}`)\n return null\n }\n}\n\nfunction importConfig(filePath: string, clearCache: boolean): CliConfig | null {\n try {\n // Clear module cache if requested (needed for env var reload)\n if (clearCache) {\n const resolvedPath = dynamicRequire.resolve(filePath)\n delete dynamicRequire.cache[resolvedPath]\n }\n\n const config = dynamicRequire<CliConfig | {default: CliConfig} | null>(filePath)\n if (config === null || typeof config !== 'object') {\n throw new Error('Module export is not a configuration object')\n }\n\n return 'default' in config ? config.default : config\n } catch (err) {\n // If attempting to import `defineCliConfig` or similar from `sanity/cli`,\n // accept the fact that it might not be installed. Instead, let the CLI\n // give a warning about the `sanity` module not being installed\n if (err.code === 'MODULE_NOT_FOUND' && err.message.includes('sanity/cli')) {\n return null\n }\n\n console.error(`Error reading \"${filePath}\": ${err.message}`)\n return null\n }\n}\n\nfunction warn(warning: string) {\n if (typeof process.send === 'function') {\n process.send({type: 'warning', warning})\n } else {\n console.warn(warning)\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {debug} from '../debug'\n\n/**\n * Resolve project root directory, falling back to cwd if it cannot be found\n */\nexport function resolveRootDir(cwd: string): string {\n try {\n return resolveProjectRoot(cwd) || cwd\n } catch (err) {\n throw new Error(`Error occurred trying to resolve project root:\\n${err.message}`)\n }\n}\n\nfunction hasSanityConfig(basePath: string, configName: string): boolean {\n const buildConfigs = [\n fileExists(path.join(basePath, `${configName}.js`)),\n fileExists(path.join(basePath, `${configName}.ts`)),\n isSanityV2StudioRoot(basePath),\n ]\n\n return buildConfigs.some(Boolean)\n}\n\nfunction resolveProjectRoot(basePath: string, iterations = 0): string | false {\n const configName = 'sanity.config'\n if (hasSanityConfig(basePath, configName)) {\n return basePath\n }\n\n const parentDir = path.resolve(basePath, '..')\n if (parentDir === basePath || iterations > 30) {\n // Reached root (or max depth), give up\n return false\n }\n\n return resolveProjectRoot(parentDir, iterations + 1)\n}\n\nfunction isSanityV2StudioRoot(basePath: string): boolean {\n try {\n const content = fs.readFileSync(path.join(basePath, 'sanity.json'), 'utf8')\n const sanityJson = JSON.parse(content)\n const isRoot = Boolean(sanityJson?.root)\n if (isRoot) {\n debug('Found Sanity v2 studio root at %s', basePath)\n }\n return isRoot\n } catch (err) {\n return false\n }\n}\n\nfunction fileExists(filePath: string): boolean {\n return fs.existsSync(filePath)\n}\n","import {createClient, type SanityClient} from '@sanity/client'\n\nimport {getCliConfigSync} from './util/getCliConfig'\nimport {resolveRootDir} from './util/resolveRootDir'\n\nexport interface CliClientOptions {\n cwd?: string\n\n projectId?: string\n dataset?: string\n useCdn?: boolean\n token?: string\n apiVersion?: string\n}\n\ninterface GetCliClient {\n (options?: CliClientOptions): SanityClient\n /**\n * @internal\n * @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules\n * @returns A token to use when constructing a client without a `token` explicitly defined, or undefined\n */\n __internal__getToken: () => string | undefined\n}\n\nfunction getCliClientImpl(options: CliClientOptions = {}): SanityClient {\n if (typeof process !== 'object') {\n throw new Error('getCliClient() should only be called from node.js scripts')\n }\n\n const {\n cwd = process.env.SANITY_BASE_PATH || process.cwd(),\n useCdn = false,\n apiVersion = '2022-06-06',\n projectId,\n dataset,\n token = getCliClient.__internal__getToken(),\n } = options\n\n if (projectId && dataset) {\n return createClient({projectId, dataset, apiVersion, useCdn, token})\n }\n\n const rootDir = resolveRootDir(cwd)\n const {config} = getCliConfigSync(rootDir) || {}\n if (!config) {\n throw new Error('Unable to resolve CLI configuration')\n }\n\n const apiConfig = config?.api || {}\n if (!apiConfig.projectId || !apiConfig.dataset) {\n throw new Error('Unable to resolve project ID/dataset from CLI configuration')\n }\n\n return createClient({\n projectId: apiConfig.projectId,\n dataset: apiConfig.dataset,\n apiVersion,\n useCdn,\n token,\n })\n}\n\n/* eslint-disable camelcase */\ngetCliClientImpl.__internal__getToken = (): string | undefined => undefined\n/* eslint-enable camelcase */\n\n/** @internal */\nexport const getCliClient: GetCliClient = getCliClientImpl\n","import {type CliConfig} from './types'\n\n/** @beta */\nexport function defineCliConfig(config: CliConfig): CliConfig {\n return config\n}\n\n/**\n * @deprecated Use `defineCliConfig` instead\n * @beta\n */\nexport function createCliConfig(config: CliConfig): CliConfig {\n return config\n}\n","const fs = require('fs')\nconst path = require('path')\nconst os = require('os')\nconst crypto = require('crypto')\nconst packageJson = require('../package.json')\n\nconst version = packageJson.version\n\nconst LINE = /(?:^|^)\\s*(?:export\\s+)?([\\w.-]+)(?:\\s*=\\s*?|:\\s+?)(\\s*'(?:\\\\'|[^'])*'|\\s*\"(?:\\\\\"|[^\"])*\"|\\s*`(?:\\\\`|[^`])*`|[^#\\r\\n]+)?\\s*(?:#.*)?(?:$|$)/mg\n\n// Parse src into an Object\nfunction parse (src) {\n const obj = {}\n\n // Convert buffer to string\n let lines = src.toString()\n\n // Convert line breaks to same format\n lines = lines.replace(/\\r\\n?/mg, '\\n')\n\n let match\n while ((match = LINE.exec(lines)) != null) {\n const key = match[1]\n\n // Default undefined or null to empty string\n let value = (match[2] || '')\n\n // Remove whitespace\n value = value.trim()\n\n // Check if double quoted\n const maybeQuote = value[0]\n\n // Remove surrounding quotes\n value = value.replace(/^(['\"`])([\\s\\S]*)\\1$/mg, '$2')\n\n // Expand newlines if double quoted\n if (maybeQuote === '\"') {\n value = value.replace(/\\\\n/g, '\\n')\n value = value.replace(/\\\\r/g, '\\r')\n }\n\n // Add to object\n obj[key] = value\n }\n\n return obj\n}\n\nfunction _parseVault (options) {\n options = options || {}\n\n const vaultPath = _vaultPath(options)\n options.path = vaultPath // parse .env.vault\n const result = DotenvModule.configDotenv(options)\n if (!result.parsed) {\n const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)\n err.code = 'MISSING_DATA'\n throw err\n }\n\n // handle scenario for comma separated keys - for use with key rotation\n // example: DOTENV_KEY=\"dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod\"\n const keys = _dotenvKey(options).split(',')\n const length = keys.length\n\n let decrypted\n for (let i = 0; i < length; i++) {\n try {\n // Get full key\n const key = keys[i].trim()\n\n // Get instructions for decrypt\n const attrs = _instructions(result, key)\n\n // Decrypt\n decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)\n\n break\n } catch (error) {\n // last key\n if (i + 1 >= length) {\n throw error\n }\n // try next key\n }\n }\n\n // Parse decrypted .env string\n return DotenvModule.parse(decrypted)\n}\n\nfunction _warn (message) {\n console.log(`[dotenv@${version}][WARN] ${message}`)\n}\n\nfunction _debug (message) {\n console.log(`[dotenv@${version}][DEBUG] ${message}`)\n}\n\nfunction _log (message) {\n console.log(`[dotenv@${version}] ${message}`)\n}\n\nfunction _dotenvKey (options) {\n // prioritize developer directly setting options.DOTENV_KEY\n if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {\n return options.DOTENV_KEY\n }\n\n // secondary infra already contains a DOTENV_KEY environment variable\n if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {\n return process.env.DOTENV_KEY\n }\n\n // fallback to empty string\n return ''\n}\n\nfunction _instructions (result, dotenvKey) {\n // Parse DOTENV_KEY. Format is a URI\n let uri\n try {\n uri = new URL(dotenvKey)\n } catch (error) {\n if (error.code === 'ERR_INVALID_URL') {\n 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')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n throw error\n }\n\n // Get decrypt key\n const key = uri.password\n if (!key) {\n const err = new Error('INVALID_DOTENV_KEY: Missing key part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get environment\n const environment = uri.searchParams.get('environment')\n if (!environment) {\n const err = new Error('INVALID_DOTENV_KEY: Missing environment part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get ciphertext payload\n const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`\n const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION\n if (!ciphertext) {\n const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)\n err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'\n throw err\n }\n\n return { ciphertext, key }\n}\n\nfunction _vaultPath (options) {\n let possibleVaultPath = null\n\n if (options && options.path && options.path.length > 0) {\n if (Array.isArray(options.path)) {\n for (const filepath of options.path) {\n if (fs.existsSync(filepath)) {\n possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`\n }\n }\n } else {\n possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`\n }\n } else {\n possibleVaultPath = path.resolve(process.cwd(), '.env.vault')\n }\n\n if (fs.existsSync(possibleVaultPath)) {\n return possibleVaultPath\n }\n\n return null\n}\n\nfunction _resolveHome (envPath) {\n return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath\n}\n\nfunction _configVault (options) {\n const debug = Boolean(options && options.debug)\n const quiet = options && 'quiet' in options ? options.quiet : true\n\n if (debug || !quiet) {\n _log('Loading env from encrypted .env.vault')\n }\n\n const parsed = DotenvModule._parseVault(options)\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsed, options)\n\n return { parsed }\n}\n\nfunction configDotenv (options) {\n const dotenvPath = path.resolve(process.cwd(), '.env')\n let encoding = 'utf8'\n const debug = Boolean(options && options.debug)\n const quiet = options && 'quiet' in options ? options.quiet : true\n\n if (options && options.encoding) {\n encoding = options.encoding\n } else {\n if (debug) {\n _debug('No encoding is specified. UTF-8 is used by default')\n }\n }\n\n let optionPaths = [dotenvPath] // default, look for .env\n if (options && options.path) {\n if (!Array.isArray(options.path)) {\n optionPaths = [_resolveHome(options.path)]\n } else {\n optionPaths = [] // reset default\n for (const filepath of options.path) {\n optionPaths.push(_resolveHome(filepath))\n }\n }\n }\n\n // Build the parsed data in a temporary object (because we need to return it). Once we have the final\n // parsed data, we will combine it with process.env (or options.processEnv if provided).\n let lastError\n const parsedAll = {}\n for (const path of optionPaths) {\n try {\n // Specifying an encoding returns a string instead of a buffer\n const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))\n\n DotenvModule.populate(parsedAll, parsed, options)\n } catch (e) {\n if (debug) {\n _debug(`Failed to load ${path} ${e.message}`)\n }\n lastError = e\n }\n }\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsedAll, options)\n\n if (debug || !quiet) {\n const keysCount = Object.keys(parsedAll).length\n const shortPaths = []\n for (const filePath of optionPaths) {\n try {\n const relative = path.relative(process.cwd(), filePath)\n shortPaths.push(relative)\n } catch (e) {\n if (debug) {\n _debug(`Failed to load ${filePath} ${e.message}`)\n }\n lastError = e\n }\n }\n\n _log(`injecting env (${keysCount}) from ${shortPaths.join(',')}`)\n }\n\n if (lastError) {\n return { parsed: parsedAll, error: lastError }\n } else {\n return { parsed: parsedAll }\n }\n}\n\n// Populates process.env from .env file\nfunction config (options) {\n // fallback to original dotenv if DOTENV_KEY is not set\n if (_dotenvKey(options).length === 0) {\n return DotenvModule.configDotenv(options)\n }\n\n const vaultPath = _vaultPath(options)\n\n // dotenvKey exists but .env.vault file does not exist\n if (!vaultPath) {\n _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)\n\n return DotenvModule.configDotenv(options)\n }\n\n return DotenvModule._configVault(options)\n}\n\nfunction decrypt (encrypted, keyStr) {\n const key = Buffer.from(keyStr.slice(-64), 'hex')\n let ciphertext = Buffer.from(encrypted, 'base64')\n\n const nonce = ciphertext.subarray(0, 12)\n const authTag = ciphertext.subarray(-16)\n ciphertext = ciphertext.subarray(12, -16)\n\n try {\n const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)\n aesgcm.setAuthTag(authTag)\n return `${aesgcm.update(ciphertext)}${aesgcm.final()}`\n } catch (error) {\n const isRange = error instanceof RangeError\n const invalidKeyLength = error.message === 'Invalid key length'\n const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'\n\n if (isRange || invalidKeyLength) {\n const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n } else if (decryptionFailed) {\n const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')\n err.code = 'DECRYPTION_FAILED'\n throw err\n } else {\n throw error\n }\n }\n}\n\n// Populate process.env with parsed values\nfunction populate (processEnv, parsed, options = {}) {\n const debug = Boolean(options && options.debug)\n const override = Boolean(options && options.override)\n\n if (typeof parsed !== 'object') {\n const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')\n err.code = 'OBJECT_REQUIRED'\n throw err\n }\n\n // Set process.env\n for (const key of Object.keys(parsed)) {\n if (Object.prototype.hasOwnProperty.call(processEnv, key)) {\n if (override === true) {\n processEnv[key] = parsed[key]\n }\n\n if (debug) {\n if (override === true) {\n _debug(`\"${key}\" is already defined and WAS overwritten`)\n } else {\n _debug(`\"${key}\" is already defined and was NOT overwritten`)\n }\n }\n } else {\n processEnv[key] = parsed[key]\n }\n }\n}\n\nconst DotenvModule = {\n configDotenv,\n _configVault,\n _parseVault,\n config,\n decrypt,\n parse,\n populate\n}\n\nmodule.exports.configDotenv = DotenvModule.configDotenv\nmodule.exports._configVault = DotenvModule._configVault\nmodule.exports._parseVault = DotenvModule._parseVault\nmodule.exports.config = DotenvModule.config\nmodule.exports.decrypt = DotenvModule.decrypt\nmodule.exports.parse = DotenvModule.parse\nmodule.exports.populate = DotenvModule.populate\n\nmodule.exports = DotenvModule\n","'use strict'\n\nfunction _interpolate (envValue, environment, config) {\n const matches = envValue.match(/(.?\\${*[\\w]*(?::-[\\w/]*)?}*)/g) || []\n\n return matches.reduce(function (newEnv, match, index) {\n const parts = /(.?)\\${*([\\w]*(?::-[\\w/]*)?)?}*/g.exec(match)\n if (!parts || parts.length === 0) {\n return newEnv\n }\n\n const prefix = parts[1]\n\n let value, replacePart\n\n if (prefix === '\\\\') {\n replacePart = parts[0]\n value = replacePart.replace('\\\\$', '$')\n } else {\n const keyParts = parts[2].split(':-')\n const key = keyParts[0]\n replacePart = parts[0].substring(prefix.length)\n // process.env value 'wins' over .env file's value\n value = Object.prototype.hasOwnProperty.call(environment, key)\n ? environment[key]\n : (config.parsed[key] || keyParts[1] || '')\n\n // If the value is found, remove nested expansions.\n if (keyParts.length > 1 && value) {\n const replaceNested = matches[index + 1]\n matches[index + 1] = ''\n\n newEnv = newEnv.replace(replaceNested, '')\n }\n // Resolve recursive interpolations\n value = _interpolate(value, environment, config)\n }\n\n return newEnv.replace(replacePart, value)\n }, envValue)\n}\n\nfunction expand (config) {\n // if ignoring process.env, use a blank object\n const environment = config.ignoreProcessEnv ? {} : process.env\n\n for (const configKey in config.parsed) {\n const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey]\n\n config.parsed[configKey] = _interpolate(value, environment, config)\n }\n\n for (const processKey in config.parsed) {\n environment[processKey] = config.parsed[processKey]\n }\n\n return config\n}\n\nmodule.exports.expand = expand\n","/**\n * This is an \"inlined\" version of Vite's `loadEnv` function,\n * simplified somewhat to only support our use case.\n *\n * Ideally we'd just use `loadEnv` from Vite, but importing it\n * causes bundling issues due to node APIs and downstream dependencies.\n *\n * Vite is MIT licensed, copyright (c) Yuxi (Evan) You and Vite contributors.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport {parse} from 'dotenv'\nimport {expand} from 'dotenv-expand'\n\nexport function loadEnv(\n mode: string,\n envDir: string,\n prefixes: string[] = ['VITE_'],\n): Record<string, string> {\n if (mode === 'local') {\n throw new Error(\n `\"local\" cannot be used as a mode name because it conflicts with ` +\n `the .local postfix for .env files.`,\n )\n }\n\n const env: Record<string, string> = {}\n const envFiles = [\n /** default file */ `.env`,\n /** local file */ `.env.local`,\n /** mode file */ `.env.${mode}`,\n /** mode local file */ `.env.${mode}.local`,\n ]\n\n const parsed = Object.fromEntries(\n envFiles.flatMap((file) => {\n const envPath = lookupFile(envDir, [file], {\n rootDir: envDir,\n })\n if (!envPath) return []\n return Object.entries(parse(fs.readFileSync(envPath)))\n }),\n )\n\n // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this\n if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {\n process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV\n }\n // support BROWSER and BROWSER_ARGS env variables\n if (parsed.BROWSER && process.env.BROWSER === undefined) {\n process.env.BROWSER = parsed.BROWSER\n }\n if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === undefined) {\n process.env.BROWSER_ARGS = parsed.BROWSER_ARGS\n }\n\n try {\n // let environment variables use each other\n expand({parsed})\n } catch (e) {\n // custom error handling until https://github.com/motdotla/dotenv-expand/issues/65 is fixed upstream\n // check for message \"TypeError: Cannot read properties of undefined (reading 'split')\"\n if (e.message.includes('split')) {\n throw new Error('dotenv-expand failed to expand env vars. Maybe you need to escape `$`?')\n }\n throw e\n }\n\n // only keys that start with prefix are exposed to client\n for (const [key, value] of Object.entries(parsed)) {\n if (prefixes.some((prefix) => key.startsWith(prefix))) {\n env[key] = value\n }\n }\n\n // check if there are actual env variables starting with VITE_*\n // these are typically provided inline and should be prioritized\n for (const key in process.env) {\n if (prefixes.some((prefix) => key.startsWith(prefix))) {\n env[key] = process.env[key] as string\n }\n }\n\n return env\n}\n\nfunction lookupFile(\n dir: string,\n formats: string[],\n options?: {\n rootDir?: string\n },\n): string | undefined {\n for (const format of formats) {\n const fullPath = path.join(dir, format)\n if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {\n return fullPath\n }\n }\n const parentDir = path.dirname(dir)\n if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {\n return lookupFile(parentDir, formats, options)\n }\n\n return undefined\n}\n"],"names":["fs","path","version","debug","mainModule","parse","expand"],"mappings":";;;;;;;;AAEO,MAAM,QAAQ,QAAQ,YAAY,GCKnC,cACJ,OAAO,uBAAwB,aAAa,0BAA0B;AAGjE,SAAS,eAAwB,SAAoB;AAC1D,QAAM,MAAM,YAAY,OAAO;AAC/B,SAAO,IAAI,cAAc,IAAI,UAAU,IAAI,UAAU;AACvD;AAEA,eAAe,UAAU,YAAY;AACrC,eAAe,QAAQ,YAAY;AC+C5B,SAAS,iBAAiB,KAAqC;AAEpE,SADiB,mBAAmB,GAAG,KACV,oBAAoB,GAAG;AACtD;AA2BA,SAAS,oBAAoB,KAAqC;AAChE,QAAM,aAAa,KAAK,KAAK,KAAK,aAAa;AAE/C,SAAK,GAAG,WAAW,UAAU,IAItB;AAAA,IACL,QAAQ,eAAe,UAAU;AAAA,IACjC,MAAM;AAAA,IACN,SAAS;AAAA,EAAA,IANF;AAQX;AAEA,SAAS,mBAAmB,KAAa,aAAa,IAA+B;AACnF,QAAM,eAAe,KAAK,KAAK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_google_ignoreList":[6,7]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/debug.ts","../src/util/dynamicRequire.ts","../src/util/getCliConfig.ts","../src/util/resolveRootDir.ts","../src/cliClient.ts","../src/config.ts","../../../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js","../../../../node_modules/.pnpm/dotenv-expand@9.0.0/node_modules/dotenv-expand/lib/main.js","../src/util/loadEnv.ts"],"sourcesContent":["import debugIt from 'debug'\n\nexport const debug = debugIt('sanity:cli')\n","// Prevent webpack from bundling in webpack context,\n// use regular node require for unbundled context\n\n/* eslint-disable camelcase */\ndeclare const __webpack_require__: boolean\ndeclare const __non_webpack_require__: typeof require\n\nconst requireFunc: typeof require =\n typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require\n/* eslint-enable camelcase */\n\nexport function dynamicRequire<T = any>(request: string): T {\n const mod = requireFunc(request)\n return mod.__esModule && mod.default ? mod.default : mod\n}\n\ndynamicRequire.resolve = requireFunc.resolve\ndynamicRequire.cache = requireFunc.cache\n","/**\n * Reads the Sanity CLI config from one of the following files (in preferred order):\n * - sanity.cli.js\n * - sanity.cli.ts\n *\n * Note: There are two ways of using this:\n * a) `getCliConfig(cwd)`\n * b) `getCliConfig(cwd, {forked: true})`\n *\n * Approach a is generally a bit faster as it avoids the forking startup time, while\n * approach b could be considered \"safer\" since any side-effects of running the config\n * file will not bleed into the current CLI process directly.\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport {Worker} from 'node:worker_threads'\n\nimport {debug} from '../debug'\nimport {type CliConfig} from '../types'\nimport {getCliWorkerPath} from './cliWorker'\nimport {dynamicRequire} from './dynamicRequire'\n\nexport type CliConfigResult = {config: CliConfig; path: string} | {config: null; path: string}\n\nexport async function getCliConfig(\n cwd: string,\n {forked}: {forked?: boolean} = {},\n): Promise<CliConfigResult | null> {\n let clearCache = false\n if (forked) {\n try {\n return await getCliConfigForked(cwd)\n } catch (err) {\n debug('Error in getCliConfigForked', err)\n clearCache = true\n // Intentional noop - try unforked variant\n }\n }\n\n const {unregister} = __DEV__\n ? {unregister: () => undefined}\n : // eslint-disable-next-line @typescript-eslint/no-require-imports\n require('esbuild-register/dist/node').register({supported: {'dynamic-import': true}})\n\n try {\n // If forked execution failed, we need to clear the cache to reload the env vars\n return getSanityCliConfig(cwd, clearCache)\n } catch (err) {\n throw err\n } finally {\n unregister()\n }\n}\n\nasync function getCliConfigForked(cwd: string): Promise<CliConfigResult | null> {\n const workerPath = await getCliWorkerPath('getCliConfig')\n return new Promise((resolve, reject) => {\n const worker = new Worker(workerPath, {\n workerData: cwd,\n env: process.env,\n })\n worker.on('message', (message) => {\n if (message.type === 'config') {\n resolve(message.config)\n } else {\n const error = new Error(message.error)\n ;(error as any).type = message.errorType\n reject(new Error(message.error))\n }\n })\n worker.on('error', reject)\n worker.on('exit', (code) => {\n if (code !== 0) {\n reject(new Error(`Worker stopped with exit code ${code}`))\n }\n })\n })\n}\n\nexport function getSanityCliConfig(cwd: string, clearCache = false): CliConfigResult | null {\n const jsConfigPath = path.join(cwd, 'sanity.cli.js')\n const tsConfigPath = path.join(cwd, 'sanity.cli.ts')\n\n const [js, ts] = [fs.existsSync(jsConfigPath), fs.existsSync(tsConfigPath)]\n\n if (!js && !ts) {\n return null\n }\n\n if (!js && ts) {\n return {\n config: importConfig(tsConfigPath, clearCache),\n path: tsConfigPath,\n }\n }\n\n if (js && ts) {\n warn('Found both `sanity.cli.js` and `sanity.cli.ts` - using sanity.cli.js')\n }\n\n return {\n config: importConfig(jsConfigPath, clearCache),\n path: jsConfigPath,\n }\n}\n\nfunction importConfig(filePath: string, clearCache: boolean): CliConfig | null {\n try {\n // Clear module cache if requested (needed for env var reload)\n if (clearCache) {\n const resolvedPath = dynamicRequire.resolve(filePath)\n delete dynamicRequire.cache[resolvedPath]\n }\n\n const config = dynamicRequire<CliConfig | {default: CliConfig} | null>(filePath)\n if (config === null || typeof config !== 'object') {\n throw new Error('Module export is not a configuration object')\n }\n\n return 'default' in config ? config.default : config\n } catch (err) {\n // If attempting to import `defineCliConfig` or similar from `sanity/cli`,\n // accept the fact that it might not be installed. Instead, let the CLI\n // give a warning about the `sanity` module not being installed\n if (err.code === 'MODULE_NOT_FOUND' && err.message.includes('sanity/cli')) {\n return null\n }\n\n console.error(`Error reading \"${filePath}\": ${err.message}`)\n return null\n }\n}\n\nfunction warn(warning: string) {\n if (typeof process.send === 'function') {\n process.send({type: 'warning', warning})\n } else {\n console.warn(warning)\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport {debug} from '../debug'\n\n/**\n * Resolve project root directory, falling back to cwd if it cannot be found\n */\nexport function resolveRootDir(cwd: string): string {\n try {\n return resolveProjectRoot(cwd) || cwd\n } catch (err) {\n throw new Error(`Error occurred trying to resolve project root:\\n${err.message}`)\n }\n}\n\nfunction hasSanityConfig(basePath: string, configName: string): boolean {\n const buildConfigs = [\n fileExists(path.join(basePath, `${configName}.js`)),\n fileExists(path.join(basePath, `${configName}.ts`)),\n isSanityV2StudioRoot(basePath),\n ]\n\n return buildConfigs.some(Boolean)\n}\n\nfunction resolveProjectRoot(basePath: string, iterations = 0): string | false {\n const configName = 'sanity.config'\n if (hasSanityConfig(basePath, configName)) {\n return basePath\n }\n\n const parentDir = path.resolve(basePath, '..')\n if (parentDir === basePath || iterations > 30) {\n // Reached root (or max depth), give up\n return false\n }\n\n return resolveProjectRoot(parentDir, iterations + 1)\n}\n\nfunction isSanityV2StudioRoot(basePath: string): boolean {\n try {\n const content = fs.readFileSync(path.join(basePath, 'sanity.json'), 'utf8')\n const sanityJson = JSON.parse(content)\n const isRoot = Boolean(sanityJson?.root)\n if (isRoot) {\n debug('Found Sanity v2 studio root at %s', basePath)\n }\n return isRoot\n } catch (err) {\n return false\n }\n}\n\nfunction fileExists(filePath: string): boolean {\n return fs.existsSync(filePath)\n}\n","import {createClient, type SanityClient} from '@sanity/client'\n\nimport {getSanityCliConfig} from './util/getCliConfig'\nimport {resolveRootDir} from './util/resolveRootDir'\n\nexport interface CliClientOptions {\n cwd?: string\n\n projectId?: string\n dataset?: string\n useCdn?: boolean\n token?: string\n apiVersion?: string\n}\n\ninterface GetCliClient {\n (options?: CliClientOptions): SanityClient\n /**\n * @internal\n * @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules\n * @returns A token to use when constructing a client without a `token` explicitly defined, or undefined\n */\n __internal__getToken: () => string | undefined\n}\n\nfunction getCliClientImpl(options: CliClientOptions = {}): SanityClient {\n if (typeof process !== 'object') {\n throw new Error('getCliClient() should only be called from node.js scripts')\n }\n\n const {\n cwd = process.env.SANITY_BASE_PATH || process.cwd(),\n useCdn = false,\n apiVersion = '2022-06-06',\n projectId,\n dataset,\n token = getCliClient.__internal__getToken(),\n } = options\n\n if (projectId && dataset) {\n return createClient({projectId, dataset, apiVersion, useCdn, token})\n }\n\n const rootDir = resolveRootDir(cwd)\n const {config} = getSanityCliConfig(rootDir) || {}\n if (!config) {\n throw new Error('Unable to resolve CLI configuration')\n }\n\n const apiConfig = config?.api || {}\n if (!apiConfig.projectId || !apiConfig.dataset) {\n throw new Error('Unable to resolve project ID/dataset from CLI configuration')\n }\n\n return createClient({\n projectId: apiConfig.projectId,\n dataset: apiConfig.dataset,\n apiVersion,\n useCdn,\n token,\n })\n}\n\n/* eslint-disable camelcase */\ngetCliClientImpl.__internal__getToken = (): string | undefined => undefined\n/* eslint-enable camelcase */\n\n/** @internal */\nexport const getCliClient: GetCliClient = getCliClientImpl\n","import {type CliConfig} from './types'\n\n/** @beta */\nexport function defineCliConfig(config: CliConfig): CliConfig {\n return config\n}\n\n/**\n * @deprecated Use `defineCliConfig` instead\n * @beta\n */\nexport function createCliConfig(config: CliConfig): CliConfig {\n return config\n}\n","const fs = require('fs')\nconst path = require('path')\nconst os = require('os')\nconst crypto = require('crypto')\nconst packageJson = require('../package.json')\n\nconst version = packageJson.version\n\nconst LINE = /(?:^|^)\\s*(?:export\\s+)?([\\w.-]+)(?:\\s*=\\s*?|:\\s+?)(\\s*'(?:\\\\'|[^'])*'|\\s*\"(?:\\\\\"|[^\"])*\"|\\s*`(?:\\\\`|[^`])*`|[^#\\r\\n]+)?\\s*(?:#.*)?(?:$|$)/mg\n\n// Parse src into an Object\nfunction parse (src) {\n const obj = {}\n\n // Convert buffer to string\n let lines = src.toString()\n\n // Convert line breaks to same format\n lines = lines.replace(/\\r\\n?/mg, '\\n')\n\n let match\n while ((match = LINE.exec(lines)) != null) {\n const key = match[1]\n\n // Default undefined or null to empty string\n let value = (match[2] || '')\n\n // Remove whitespace\n value = value.trim()\n\n // Check if double quoted\n const maybeQuote = value[0]\n\n // Remove surrounding quotes\n value = value.replace(/^(['\"`])([\\s\\S]*)\\1$/mg, '$2')\n\n // Expand newlines if double quoted\n if (maybeQuote === '\"') {\n value = value.replace(/\\\\n/g, '\\n')\n value = value.replace(/\\\\r/g, '\\r')\n }\n\n // Add to object\n obj[key] = value\n }\n\n return obj\n}\n\nfunction _parseVault (options) {\n options = options || {}\n\n const vaultPath = _vaultPath(options)\n options.path = vaultPath // parse .env.vault\n const result = DotenvModule.configDotenv(options)\n if (!result.parsed) {\n const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`)\n err.code = 'MISSING_DATA'\n throw err\n }\n\n // handle scenario for comma separated keys - for use with key rotation\n // example: DOTENV_KEY=\"dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod\"\n const keys = _dotenvKey(options).split(',')\n const length = keys.length\n\n let decrypted\n for (let i = 0; i < length; i++) {\n try {\n // Get full key\n const key = keys[i].trim()\n\n // Get instructions for decrypt\n const attrs = _instructions(result, key)\n\n // Decrypt\n decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key)\n\n break\n } catch (error) {\n // last key\n if (i + 1 >= length) {\n throw error\n }\n // try next key\n }\n }\n\n // Parse decrypted .env string\n return DotenvModule.parse(decrypted)\n}\n\nfunction _warn (message) {\n console.log(`[dotenv@${version}][WARN] ${message}`)\n}\n\nfunction _debug (message) {\n console.log(`[dotenv@${version}][DEBUG] ${message}`)\n}\n\nfunction _log (message) {\n console.log(`[dotenv@${version}] ${message}`)\n}\n\nfunction _dotenvKey (options) {\n // prioritize developer directly setting options.DOTENV_KEY\n if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {\n return options.DOTENV_KEY\n }\n\n // secondary infra already contains a DOTENV_KEY environment variable\n if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {\n return process.env.DOTENV_KEY\n }\n\n // fallback to empty string\n return ''\n}\n\nfunction _instructions (result, dotenvKey) {\n // Parse DOTENV_KEY. Format is a URI\n let uri\n try {\n uri = new URL(dotenvKey)\n } catch (error) {\n if (error.code === 'ERR_INVALID_URL') {\n 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')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n throw error\n }\n\n // Get decrypt key\n const key = uri.password\n if (!key) {\n const err = new Error('INVALID_DOTENV_KEY: Missing key part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get environment\n const environment = uri.searchParams.get('environment')\n if (!environment) {\n const err = new Error('INVALID_DOTENV_KEY: Missing environment part')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n }\n\n // Get ciphertext payload\n const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`\n const ciphertext = result.parsed[environmentKey] // DOTENV_VAULT_PRODUCTION\n if (!ciphertext) {\n const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`)\n err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'\n throw err\n }\n\n return { ciphertext, key }\n}\n\nfunction _vaultPath (options) {\n let possibleVaultPath = null\n\n if (options && options.path && options.path.length > 0) {\n if (Array.isArray(options.path)) {\n for (const filepath of options.path) {\n if (fs.existsSync(filepath)) {\n possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`\n }\n }\n } else {\n possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`\n }\n } else {\n possibleVaultPath = path.resolve(process.cwd(), '.env.vault')\n }\n\n if (fs.existsSync(possibleVaultPath)) {\n return possibleVaultPath\n }\n\n return null\n}\n\nfunction _resolveHome (envPath) {\n return envPath[0] === '~' ? path.join(os.homedir(), envPath.slice(1)) : envPath\n}\n\nfunction _configVault (options) {\n const debug = Boolean(options && options.debug)\n const quiet = options && 'quiet' in options ? options.quiet : true\n\n if (debug || !quiet) {\n _log('Loading env from encrypted .env.vault')\n }\n\n const parsed = DotenvModule._parseVault(options)\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsed, options)\n\n return { parsed }\n}\n\nfunction configDotenv (options) {\n const dotenvPath = path.resolve(process.cwd(), '.env')\n let encoding = 'utf8'\n const debug = Boolean(options && options.debug)\n const quiet = options && 'quiet' in options ? options.quiet : true\n\n if (options && options.encoding) {\n encoding = options.encoding\n } else {\n if (debug) {\n _debug('No encoding is specified. UTF-8 is used by default')\n }\n }\n\n let optionPaths = [dotenvPath] // default, look for .env\n if (options && options.path) {\n if (!Array.isArray(options.path)) {\n optionPaths = [_resolveHome(options.path)]\n } else {\n optionPaths = [] // reset default\n for (const filepath of options.path) {\n optionPaths.push(_resolveHome(filepath))\n }\n }\n }\n\n // Build the parsed data in a temporary object (because we need to return it). Once we have the final\n // parsed data, we will combine it with process.env (or options.processEnv if provided).\n let lastError\n const parsedAll = {}\n for (const path of optionPaths) {\n try {\n // Specifying an encoding returns a string instead of a buffer\n const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))\n\n DotenvModule.populate(parsedAll, parsed, options)\n } catch (e) {\n if (debug) {\n _debug(`Failed to load ${path} ${e.message}`)\n }\n lastError = e\n }\n }\n\n let processEnv = process.env\n if (options && options.processEnv != null) {\n processEnv = options.processEnv\n }\n\n DotenvModule.populate(processEnv, parsedAll, options)\n\n if (debug || !quiet) {\n const keysCount = Object.keys(parsedAll).length\n const shortPaths = []\n for (const filePath of optionPaths) {\n try {\n const relative = path.relative(process.cwd(), filePath)\n shortPaths.push(relative)\n } catch (e) {\n if (debug) {\n _debug(`Failed to load ${filePath} ${e.message}`)\n }\n lastError = e\n }\n }\n\n _log(`injecting env (${keysCount}) from ${shortPaths.join(',')}`)\n }\n\n if (lastError) {\n return { parsed: parsedAll, error: lastError }\n } else {\n return { parsed: parsedAll }\n }\n}\n\n// Populates process.env from .env file\nfunction config (options) {\n // fallback to original dotenv if DOTENV_KEY is not set\n if (_dotenvKey(options).length === 0) {\n return DotenvModule.configDotenv(options)\n }\n\n const vaultPath = _vaultPath(options)\n\n // dotenvKey exists but .env.vault file does not exist\n if (!vaultPath) {\n _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`)\n\n return DotenvModule.configDotenv(options)\n }\n\n return DotenvModule._configVault(options)\n}\n\nfunction decrypt (encrypted, keyStr) {\n const key = Buffer.from(keyStr.slice(-64), 'hex')\n let ciphertext = Buffer.from(encrypted, 'base64')\n\n const nonce = ciphertext.subarray(0, 12)\n const authTag = ciphertext.subarray(-16)\n ciphertext = ciphertext.subarray(12, -16)\n\n try {\n const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)\n aesgcm.setAuthTag(authTag)\n return `${aesgcm.update(ciphertext)}${aesgcm.final()}`\n } catch (error) {\n const isRange = error instanceof RangeError\n const invalidKeyLength = error.message === 'Invalid key length'\n const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'\n\n if (isRange || invalidKeyLength) {\n const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)')\n err.code = 'INVALID_DOTENV_KEY'\n throw err\n } else if (decryptionFailed) {\n const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY')\n err.code = 'DECRYPTION_FAILED'\n throw err\n } else {\n throw error\n }\n }\n}\n\n// Populate process.env with parsed values\nfunction populate (processEnv, parsed, options = {}) {\n const debug = Boolean(options && options.debug)\n const override = Boolean(options && options.override)\n\n if (typeof parsed !== 'object') {\n const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate')\n err.code = 'OBJECT_REQUIRED'\n throw err\n }\n\n // Set process.env\n for (const key of Object.keys(parsed)) {\n if (Object.prototype.hasOwnProperty.call(processEnv, key)) {\n if (override === true) {\n processEnv[key] = parsed[key]\n }\n\n if (debug) {\n if (override === true) {\n _debug(`\"${key}\" is already defined and WAS overwritten`)\n } else {\n _debug(`\"${key}\" is already defined and was NOT overwritten`)\n }\n }\n } else {\n processEnv[key] = parsed[key]\n }\n }\n}\n\nconst DotenvModule = {\n configDotenv,\n _configVault,\n _parseVault,\n config,\n decrypt,\n parse,\n populate\n}\n\nmodule.exports.configDotenv = DotenvModule.configDotenv\nmodule.exports._configVault = DotenvModule._configVault\nmodule.exports._parseVault = DotenvModule._parseVault\nmodule.exports.config = DotenvModule.config\nmodule.exports.decrypt = DotenvModule.decrypt\nmodule.exports.parse = DotenvModule.parse\nmodule.exports.populate = DotenvModule.populate\n\nmodule.exports = DotenvModule\n","'use strict'\n\nfunction _interpolate (envValue, environment, config) {\n const matches = envValue.match(/(.?\\${*[\\w]*(?::-[\\w/]*)?}*)/g) || []\n\n return matches.reduce(function (newEnv, match, index) {\n const parts = /(.?)\\${*([\\w]*(?::-[\\w/]*)?)?}*/g.exec(match)\n if (!parts || parts.length === 0) {\n return newEnv\n }\n\n const prefix = parts[1]\n\n let value, replacePart\n\n if (prefix === '\\\\') {\n replacePart = parts[0]\n value = replacePart.replace('\\\\$', '$')\n } else {\n const keyParts = parts[2].split(':-')\n const key = keyParts[0]\n replacePart = parts[0].substring(prefix.length)\n // process.env value 'wins' over .env file's value\n value = Object.prototype.hasOwnProperty.call(environment, key)\n ? environment[key]\n : (config.parsed[key] || keyParts[1] || '')\n\n // If the value is found, remove nested expansions.\n if (keyParts.length > 1 && value) {\n const replaceNested = matches[index + 1]\n matches[index + 1] = ''\n\n newEnv = newEnv.replace(replaceNested, '')\n }\n // Resolve recursive interpolations\n value = _interpolate(value, environment, config)\n }\n\n return newEnv.replace(replacePart, value)\n }, envValue)\n}\n\nfunction expand (config) {\n // if ignoring process.env, use a blank object\n const environment = config.ignoreProcessEnv ? {} : process.env\n\n for (const configKey in config.parsed) {\n const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey]\n\n config.parsed[configKey] = _interpolate(value, environment, config)\n }\n\n for (const processKey in config.parsed) {\n environment[processKey] = config.parsed[processKey]\n }\n\n return config\n}\n\nmodule.exports.expand = expand\n","/**\n * This is an \"inlined\" version of Vite's `loadEnv` function,\n * simplified somewhat to only support our use case.\n *\n * Ideally we'd just use `loadEnv` from Vite, but importing it\n * causes bundling issues due to node APIs and downstream dependencies.\n *\n * Vite is MIT licensed, copyright (c) Yuxi (Evan) You and Vite contributors.\n */\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport {parse} from 'dotenv'\nimport {expand} from 'dotenv-expand'\n\nexport function loadEnv(\n mode: string,\n envDir: string,\n prefixes: string[] = ['VITE_'],\n): Record<string, string> {\n if (mode === 'local') {\n throw new Error(\n `\"local\" cannot be used as a mode name because it conflicts with ` +\n `the .local postfix for .env files.`,\n )\n }\n\n const env: Record<string, string> = {}\n const envFiles = [\n /** default file */ `.env`,\n /** local file */ `.env.local`,\n /** mode file */ `.env.${mode}`,\n /** mode local file */ `.env.${mode}.local`,\n ]\n\n const parsed = Object.fromEntries(\n envFiles.flatMap((file) => {\n const envPath = lookupFile(envDir, [file], {\n rootDir: envDir,\n })\n if (!envPath) return []\n return Object.entries(parse(fs.readFileSync(envPath)))\n }),\n )\n\n // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this\n if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {\n process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV\n }\n // support BROWSER and BROWSER_ARGS env variables\n if (parsed.BROWSER && process.env.BROWSER === undefined) {\n process.env.BROWSER = parsed.BROWSER\n }\n if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === undefined) {\n process.env.BROWSER_ARGS = parsed.BROWSER_ARGS\n }\n\n try {\n // let environment variables use each other\n expand({parsed})\n } catch (e) {\n // custom error handling until https://github.com/motdotla/dotenv-expand/issues/65 is fixed upstream\n // check for message \"TypeError: Cannot read properties of undefined (reading 'split')\"\n if (e.message.includes('split')) {\n throw new Error('dotenv-expand failed to expand env vars. Maybe you need to escape `$`?')\n }\n throw e\n }\n\n // only keys that start with prefix are exposed to client\n for (const [key, value] of Object.entries(parsed)) {\n if (prefixes.some((prefix) => key.startsWith(prefix))) {\n env[key] = value\n }\n }\n\n // check if there are actual env variables starting with VITE_*\n // these are typically provided inline and should be prioritized\n for (const key in process.env) {\n if (prefixes.some((prefix) => key.startsWith(prefix))) {\n env[key] = process.env[key] as string\n }\n }\n\n return env\n}\n\nfunction lookupFile(\n dir: string,\n formats: string[],\n options?: {\n rootDir?: string\n },\n): string | undefined {\n for (const format of formats) {\n const fullPath = path.join(dir, format)\n if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {\n return fullPath\n }\n }\n const parentDir = path.dirname(dir)\n if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {\n return lookupFile(parentDir, formats, options)\n }\n\n return undefined\n}\n"],"names":["fs","path","version","debug","mainModule","parse","expand"],"mappings":";;;;;;;;AAEO,MAAM,QAAQ,QAAQ,YAAY,GCKnC,cACJ,OAAO,uBAAwB,aAAa,0BAA0B;AAGjE,SAAS,eAAwB,SAAoB;AAC1D,QAAM,MAAM,YAAY,OAAO;AAC/B,SAAO,IAAI,cAAc,IAAI,UAAU,IAAI,UAAU;AACvD;AAEA,eAAe,UAAU,YAAY;AACrC,eAAe,QAAQ,YAAY;AC8D5B,SAAS,mBAAmB,KAAa,aAAa,IAA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