@prisma/composer-cli 0.39.0-dev.7 → 0.39.0-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-converge-CVlo9uw2-BZDypKX6.mjs +88 -0
- package/dist/app-converge-CVlo9uw2-BZDypKX6.mjs.map +1 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs +254 -0
- package/dist/composer-config-QKdY85G--CEXrb2Uc.mjs.map +1 -0
- package/dist/{validate-environment-XwVDifWN-BdYUHyVF.mjs → deploy-Br1yvLe3.mjs} +204 -1010
- package/dist/deploy-Br1yvLe3.mjs.map +1 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs +256 -0
- package/dist/dev-converge-messages-DML4rTz7-B6uxtpZG.mjs.map +1 -0
- package/dist/dev-converge-worker.d.mts +1 -0
- package/dist/dev-converge-worker.mjs +143 -0
- package/dist/dev-converge-worker.mjs.map +1 -0
- package/dist/{dev-current-gQnmjB4V-DrQ4Zzbl.mjs → dev-current-ByY2RrbK-Cni2T65J.mjs} +12 -18
- package/dist/dev-current-ByY2RrbK-Cni2T65J.mjs.map +1 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs +43 -0
- package/dist/dev-environment-name-6eEr5PW8-CCY7WNWz.mjs.map +1 -0
- package/dist/{dist-CRSv_9L8.mjs → dist-C0OGaDnj.mjs} +4 -3
- package/dist/{dist-CRSv_9L8.mjs.map → dist-C0OGaDnj.mjs.map} +1 -1
- package/dist/errors-CVYwN2km.mjs +93 -0
- package/dist/errors-CVYwN2km.mjs.map +1 -0
- package/dist/{execute-deploy-destroy-DKbsBkqK-D8pniqZg.mjs → execute-deploy-destroy-D1jnaYqU-L5pBQMUx.mjs} +245 -244
- package/dist/execute-deploy-destroy-D1jnaYqU-L5pBQMUx.mjs.map +1 -0
- package/dist/{execute-dev-DVCWURmI-D91UZq1o.mjs → execute-dev-BP0Shlpd-C6-D196L.mjs} +422 -166
- package/dist/execute-dev-BP0Shlpd-C6-D196L.mjs.map +1 -0
- package/dist/{execute-dev-current-Dt_9srY2-D8mAcSv4.mjs → execute-dev-current-B792f_1m-7ZE6ulr0.mjs} +9 -6
- package/dist/{execute-dev-current-Dt_9srY2-D8mAcSv4.mjs.map → execute-dev-current-B792f_1m-7ZE6ulr0.mjs.map} +1 -1
- package/dist/{family-D52hWFMF-FfSJ5SN2.d.mts → family-DfwviKFj-CS1L-EvS.d.mts} +171 -69
- package/dist/family-DfwviKFj-CS1L-EvS.d.mts.map +1 -0
- package/dist/family.d.mts +1 -1
- package/dist/family.mjs +87 -137
- package/dist/family.mjs.map +1 -1
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs +58 -0
- package/dist/internal-error-Dfur7Zqt-B8J8e7ac.mjs.map +1 -0
- package/dist/{list-deployed-CIaiiV_l.mjs → list-deployed-bMQ8GJVV.mjs} +5 -4
- package/dist/{list-deployed-CIaiiV_l.mjs.map → list-deployed-bMQ8GJVV.mjs.map} +1 -1
- package/dist/local-target-CZzICh5R.mjs +34 -0
- package/dist/local-target-CZzICh5R.mjs.map +1 -0
- package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs +56 -0
- package/dist/preflight-transport-2d6iIchu-ArIJUY1L.mjs.map +1 -0
- package/dist/{redaction-CjMYXtGp-CYefSG9A.mjs → redaction-DY6eDC12-BrK1aSN5.mjs} +17 -256
- package/dist/redaction-DY6eDC12-BrK1aSN5.mjs.map +1 -0
- package/dist/result-CttmabB6.mjs +91 -0
- package/dist/result-CttmabB6.mjs.map +1 -0
- package/dist/rolldown-runtime-C7HZzL1F.mjs +26 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs +287 -0
- package/dist/steps-BZXNqW6U-BM2Aa8Bp.mjs.map +1 -0
- package/dist/testing.d.mts +2 -42
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +2 -5
- package/dist/testing.mjs.map +1 -1
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs +983 -0
- package/dist/validate-environment-DCZiNSlR-idVge-kq.mjs.map +1 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs +15 -0
- package/dist/value-reads-change-text-DcRCv7Zy-Ca8m3bal.mjs.map +1 -0
- package/package.json +7 -7
- package/src/exports/dev-converge-worker.ts +2 -0
- package/src/exports/testing.ts +1 -4
- package/dist/app-configuration-file-Bbfq5PR3-CYdGtitc.mjs +0 -137
- package/dist/app-configuration-file-Bbfq5PR3-CYdGtitc.mjs.map +0 -1
- package/dist/dev-current-gQnmjB4V-DrQ4Zzbl.mjs.map +0 -1
- package/dist/dev-environment-name-6eEr5PW8-kDiScOL8.mjs +0 -71
- package/dist/dev-environment-name-6eEr5PW8-kDiScOL8.mjs.map +0 -1
- package/dist/execute-deploy-destroy-DKbsBkqK-D8pniqZg.mjs.map +0 -1
- package/dist/execute-dev-DVCWURmI-D91UZq1o.mjs.map +0 -1
- package/dist/family-D52hWFMF-FfSJ5SN2.d.mts.map +0 -1
- package/dist/generate-dev-stack-BEpqJ3AH-B7o7JyER.mjs +0 -100
- package/dist/generate-dev-stack-BEpqJ3AH-B7o7JyER.mjs.map +0 -1
- package/dist/redaction-CjMYXtGp-CYefSG9A.mjs.map +0 -1
- package/dist/result-DlBttLS8.mjs +0 -234
- package/dist/result-DlBttLS8.mjs.map +0 -1
- package/dist/run-alchemy-BlYyc4Oh-BnFv0AaY.mjs +0 -302
- package/dist/run-alchemy-BlYyc4Oh-BnFv0AaY.mjs.map +0 -1
- package/dist/validate-environment-XwVDifWN-BdYUHyVF.mjs.map +0 -1
|
@@ -0,0 +1,983 @@
|
|
|
1
|
+
import { n as __require, t as __commonJSMin } from "./rolldown-runtime-C7HZzL1F.mjs";
|
|
2
|
+
import { n as configFileMissing, r as entryMissing, t as checkComposerConfig } from "./composer-config-QKdY85G--CEXrb2Uc.mjs";
|
|
3
|
+
import { t as InternalError } from "./internal-error-Dfur7Zqt-B8J8e7ac.mjs";
|
|
4
|
+
import { a as loadEntry, c as GraphCheckError, d as assertAppName, l as Load, m as describeKind, p as secretsKeys } from "./deploy-Br1yvLe3.mjs";
|
|
5
|
+
import { t as CliStructuredError } from "./errors-CVYwN2km.mjs";
|
|
6
|
+
import { l as valuesUnderSecretsKeys, r as credentialLookingValues, t as SecretRedaction } from "./redaction-DY6eDC12-BrK1aSN5.mjs";
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { spawnSync } from "node:child_process";
|
|
10
|
+
//#region ../../../node_modules/dotenv-flow/node_modules/dotenv/package.json
|
|
11
|
+
var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
12
|
+
module.exports = {
|
|
13
|
+
"name": "dotenv",
|
|
14
|
+
"version": "16.6.1",
|
|
15
|
+
"description": "Loads environment variables from .env file",
|
|
16
|
+
"main": "lib/main.js",
|
|
17
|
+
"types": "lib/main.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./lib/main.d.ts",
|
|
21
|
+
"require": "./lib/main.js",
|
|
22
|
+
"default": "./lib/main.js"
|
|
23
|
+
},
|
|
24
|
+
"./config": "./config.js",
|
|
25
|
+
"./config.js": "./config.js",
|
|
26
|
+
"./lib/env-options": "./lib/env-options.js",
|
|
27
|
+
"./lib/env-options.js": "./lib/env-options.js",
|
|
28
|
+
"./lib/cli-options": "./lib/cli-options.js",
|
|
29
|
+
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
34
|
+
"lint": "standard",
|
|
35
|
+
"pretest": "npm run lint && npm run dts-check",
|
|
36
|
+
"test": "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
37
|
+
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
38
|
+
"prerelease": "npm test",
|
|
39
|
+
"release": "standard-version"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git://github.com/motdotla/dotenv.git"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/motdotla/dotenv#readme",
|
|
46
|
+
"funding": "https://dotenvx.com",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"dotenv",
|
|
49
|
+
"env",
|
|
50
|
+
".env",
|
|
51
|
+
"environment",
|
|
52
|
+
"variables",
|
|
53
|
+
"config",
|
|
54
|
+
"settings"
|
|
55
|
+
],
|
|
56
|
+
"readmeFilename": "README.md",
|
|
57
|
+
"license": "BSD-2-Clause",
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^18.11.3",
|
|
60
|
+
"decache": "^4.6.2",
|
|
61
|
+
"sinon": "^14.0.1",
|
|
62
|
+
"standard": "^17.0.0",
|
|
63
|
+
"standard-version": "^9.5.0",
|
|
64
|
+
"tap": "^19.2.0",
|
|
65
|
+
"typescript": "^4.8.4"
|
|
66
|
+
},
|
|
67
|
+
"engines": { "node": ">=12" },
|
|
68
|
+
"browser": { "fs": false }
|
|
69
|
+
};
|
|
70
|
+
}));
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region ../../../node_modules/dotenv-flow/node_modules/dotenv/lib/main.js
|
|
73
|
+
var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
74
|
+
const fs$2 = __require("fs");
|
|
75
|
+
const path$1 = __require("path");
|
|
76
|
+
const os = __require("os");
|
|
77
|
+
const crypto = __require("crypto");
|
|
78
|
+
const version = require_package$1().version;
|
|
79
|
+
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
80
|
+
function parse(src) {
|
|
81
|
+
const obj = {};
|
|
82
|
+
let lines = src.toString();
|
|
83
|
+
lines = lines.replace(/\r\n?/gm, "\n");
|
|
84
|
+
let match;
|
|
85
|
+
while ((match = LINE.exec(lines)) != null) {
|
|
86
|
+
const key = match[1];
|
|
87
|
+
let value = match[2] || "";
|
|
88
|
+
value = value.trim();
|
|
89
|
+
const maybeQuote = value[0];
|
|
90
|
+
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
91
|
+
if (maybeQuote === "\"") {
|
|
92
|
+
value = value.replace(/\\n/g, "\n");
|
|
93
|
+
value = value.replace(/\\r/g, "\r");
|
|
94
|
+
}
|
|
95
|
+
obj[key] = value;
|
|
96
|
+
}
|
|
97
|
+
return obj;
|
|
98
|
+
}
|
|
99
|
+
function _parseVault(options) {
|
|
100
|
+
options = options || {};
|
|
101
|
+
const vaultPath = _vaultPath(options);
|
|
102
|
+
options.path = vaultPath;
|
|
103
|
+
const result = DotenvModule.configDotenv(options);
|
|
104
|
+
if (!result.parsed) {
|
|
105
|
+
const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
106
|
+
err.code = "MISSING_DATA";
|
|
107
|
+
throw err;
|
|
108
|
+
}
|
|
109
|
+
const keys = _dotenvKey(options).split(",");
|
|
110
|
+
const length = keys.length;
|
|
111
|
+
let decrypted;
|
|
112
|
+
for (let i = 0; i < length; i++) try {
|
|
113
|
+
const attrs = _instructions(result, keys[i].trim());
|
|
114
|
+
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
115
|
+
break;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (i + 1 >= length) throw error;
|
|
118
|
+
}
|
|
119
|
+
return DotenvModule.parse(decrypted);
|
|
120
|
+
}
|
|
121
|
+
function _warn(message) {
|
|
122
|
+
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
123
|
+
}
|
|
124
|
+
function _debug(message) {
|
|
125
|
+
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
126
|
+
}
|
|
127
|
+
function _log(message) {
|
|
128
|
+
console.log(`[dotenv@${version}] ${message}`);
|
|
129
|
+
}
|
|
130
|
+
function _dotenvKey(options) {
|
|
131
|
+
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) return options.DOTENV_KEY;
|
|
132
|
+
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
|
|
133
|
+
return "";
|
|
134
|
+
}
|
|
135
|
+
function _instructions(result, dotenvKey) {
|
|
136
|
+
let uri;
|
|
137
|
+
try {
|
|
138
|
+
uri = new URL(dotenvKey);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (error.code === "ERR_INVALID_URL") {
|
|
141
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
142
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
143
|
+
throw err;
|
|
144
|
+
}
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
const key = uri.password;
|
|
148
|
+
if (!key) {
|
|
149
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
150
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
const environment = uri.searchParams.get("environment");
|
|
154
|
+
if (!environment) {
|
|
155
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
156
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
160
|
+
const ciphertext = result.parsed[environmentKey];
|
|
161
|
+
if (!ciphertext) {
|
|
162
|
+
const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
163
|
+
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
164
|
+
throw err;
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
ciphertext,
|
|
168
|
+
key
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function _vaultPath(options) {
|
|
172
|
+
let possibleVaultPath = null;
|
|
173
|
+
if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
|
|
174
|
+
for (const filepath of options.path) if (fs$2.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
175
|
+
} else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
176
|
+
else possibleVaultPath = path$1.resolve(process.cwd(), ".env.vault");
|
|
177
|
+
if (fs$2.existsSync(possibleVaultPath)) return possibleVaultPath;
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
function _resolveHome(envPath) {
|
|
181
|
+
return envPath[0] === "~" ? path$1.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
182
|
+
}
|
|
183
|
+
function _configVault(options) {
|
|
184
|
+
const debug = Boolean(options && options.debug);
|
|
185
|
+
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
186
|
+
if (debug || !quiet) _log("Loading env from encrypted .env.vault");
|
|
187
|
+
const parsed = DotenvModule._parseVault(options);
|
|
188
|
+
let processEnv = process.env;
|
|
189
|
+
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
190
|
+
DotenvModule.populate(processEnv, parsed, options);
|
|
191
|
+
return { parsed };
|
|
192
|
+
}
|
|
193
|
+
function configDotenv(options) {
|
|
194
|
+
const dotenvPath = path$1.resolve(process.cwd(), ".env");
|
|
195
|
+
let encoding = "utf8";
|
|
196
|
+
const debug = Boolean(options && options.debug);
|
|
197
|
+
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
198
|
+
if (options && options.encoding) encoding = options.encoding;
|
|
199
|
+
else if (debug) _debug("No encoding is specified. UTF-8 is used by default");
|
|
200
|
+
let optionPaths = [dotenvPath];
|
|
201
|
+
if (options && options.path) if (!Array.isArray(options.path)) optionPaths = [_resolveHome(options.path)];
|
|
202
|
+
else {
|
|
203
|
+
optionPaths = [];
|
|
204
|
+
for (const filepath of options.path) optionPaths.push(_resolveHome(filepath));
|
|
205
|
+
}
|
|
206
|
+
let lastError;
|
|
207
|
+
const parsedAll = {};
|
|
208
|
+
for (const path of optionPaths) try {
|
|
209
|
+
const parsed = DotenvModule.parse(fs$2.readFileSync(path, { encoding }));
|
|
210
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
if (debug) _debug(`Failed to load ${path} ${e.message}`);
|
|
213
|
+
lastError = e;
|
|
214
|
+
}
|
|
215
|
+
let processEnv = process.env;
|
|
216
|
+
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
217
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
|
218
|
+
if (debug || !quiet) {
|
|
219
|
+
const keysCount = Object.keys(parsedAll).length;
|
|
220
|
+
const shortPaths = [];
|
|
221
|
+
for (const filePath of optionPaths) try {
|
|
222
|
+
const relative = path$1.relative(process.cwd(), filePath);
|
|
223
|
+
shortPaths.push(relative);
|
|
224
|
+
} catch (e) {
|
|
225
|
+
if (debug) _debug(`Failed to load ${filePath} ${e.message}`);
|
|
226
|
+
lastError = e;
|
|
227
|
+
}
|
|
228
|
+
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
|
|
229
|
+
}
|
|
230
|
+
if (lastError) return {
|
|
231
|
+
parsed: parsedAll,
|
|
232
|
+
error: lastError
|
|
233
|
+
};
|
|
234
|
+
else return { parsed: parsedAll };
|
|
235
|
+
}
|
|
236
|
+
function config(options) {
|
|
237
|
+
if (_dotenvKey(options).length === 0) return DotenvModule.configDotenv(options);
|
|
238
|
+
const vaultPath = _vaultPath(options);
|
|
239
|
+
if (!vaultPath) {
|
|
240
|
+
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
241
|
+
return DotenvModule.configDotenv(options);
|
|
242
|
+
}
|
|
243
|
+
return DotenvModule._configVault(options);
|
|
244
|
+
}
|
|
245
|
+
function decrypt(encrypted, keyStr) {
|
|
246
|
+
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
247
|
+
let ciphertext = Buffer.from(encrypted, "base64");
|
|
248
|
+
const nonce = ciphertext.subarray(0, 12);
|
|
249
|
+
const authTag = ciphertext.subarray(-16);
|
|
250
|
+
ciphertext = ciphertext.subarray(12, -16);
|
|
251
|
+
try {
|
|
252
|
+
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
253
|
+
aesgcm.setAuthTag(authTag);
|
|
254
|
+
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
255
|
+
} catch (error) {
|
|
256
|
+
const isRange = error instanceof RangeError;
|
|
257
|
+
const invalidKeyLength = error.message === "Invalid key length";
|
|
258
|
+
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
259
|
+
if (isRange || invalidKeyLength) {
|
|
260
|
+
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
261
|
+
err.code = "INVALID_DOTENV_KEY";
|
|
262
|
+
throw err;
|
|
263
|
+
} else if (decryptionFailed) {
|
|
264
|
+
const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
265
|
+
err.code = "DECRYPTION_FAILED";
|
|
266
|
+
throw err;
|
|
267
|
+
} else throw error;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function populate(processEnv, parsed, options = {}) {
|
|
271
|
+
const debug = Boolean(options && options.debug);
|
|
272
|
+
const override = Boolean(options && options.override);
|
|
273
|
+
if (typeof parsed !== "object") {
|
|
274
|
+
const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
275
|
+
err.code = "OBJECT_REQUIRED";
|
|
276
|
+
throw err;
|
|
277
|
+
}
|
|
278
|
+
for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
279
|
+
if (override === true) processEnv[key] = parsed[key];
|
|
280
|
+
if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
|
|
281
|
+
else _debug(`"${key}" is already defined and was NOT overwritten`);
|
|
282
|
+
} else processEnv[key] = parsed[key];
|
|
283
|
+
}
|
|
284
|
+
const DotenvModule = {
|
|
285
|
+
configDotenv,
|
|
286
|
+
_configVault,
|
|
287
|
+
_parseVault,
|
|
288
|
+
config,
|
|
289
|
+
decrypt,
|
|
290
|
+
parse,
|
|
291
|
+
populate
|
|
292
|
+
};
|
|
293
|
+
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
294
|
+
module.exports._configVault = DotenvModule._configVault;
|
|
295
|
+
module.exports._parseVault = DotenvModule._parseVault;
|
|
296
|
+
module.exports.config = DotenvModule.config;
|
|
297
|
+
module.exports.decrypt = DotenvModule.decrypt;
|
|
298
|
+
module.exports.parse = DotenvModule.parse;
|
|
299
|
+
module.exports.populate = DotenvModule.populate;
|
|
300
|
+
module.exports = DotenvModule;
|
|
301
|
+
}));
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region ../../../node_modules/dotenv-flow/package.json
|
|
304
|
+
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
305
|
+
module.exports = {
|
|
306
|
+
"name": "dotenv-flow",
|
|
307
|
+
"version": "4.1.0",
|
|
308
|
+
"description": "Loads environment variables from `.env.[development|test|production][.local]` files",
|
|
309
|
+
"keywords": [
|
|
310
|
+
"dotenv",
|
|
311
|
+
"node_env",
|
|
312
|
+
"development",
|
|
313
|
+
"test",
|
|
314
|
+
"production",
|
|
315
|
+
"local",
|
|
316
|
+
"env",
|
|
317
|
+
"environment",
|
|
318
|
+
"variables"
|
|
319
|
+
],
|
|
320
|
+
"homepage": "https://github.com/kerimdzhanov/dotenv-flow#readme",
|
|
321
|
+
"repository": {
|
|
322
|
+
"type": "git",
|
|
323
|
+
"url": "git+https://github.com/kerimdzhanov/dotenv-flow.git"
|
|
324
|
+
},
|
|
325
|
+
"bugs": { "url": "https://github.com/kerimdzhanov/dotenv-flow/issues" },
|
|
326
|
+
"main": "lib/dotenv-flow.js",
|
|
327
|
+
"types": "lib/dotenv-flow.d.ts",
|
|
328
|
+
"exports": {
|
|
329
|
+
".": "./lib/dotenv-flow.js",
|
|
330
|
+
"./config": {
|
|
331
|
+
"require": "./config.js",
|
|
332
|
+
"node": "./config.js"
|
|
333
|
+
},
|
|
334
|
+
"./package.json": "./package.json"
|
|
335
|
+
},
|
|
336
|
+
"files": [
|
|
337
|
+
"lib/cli-options.js",
|
|
338
|
+
"lib/dotenv-flow.d.ts",
|
|
339
|
+
"lib/env-options.js",
|
|
340
|
+
"config.d.ts",
|
|
341
|
+
"config.js"
|
|
342
|
+
],
|
|
343
|
+
"dependencies": { "dotenv": "^16.0.0" },
|
|
344
|
+
"devDependencies": {
|
|
345
|
+
"@types/node": "^20.6.2",
|
|
346
|
+
"chai": "^4.3.7",
|
|
347
|
+
"conventional-changelog-cli": "^2.0.35",
|
|
348
|
+
"mocha": "^10.2.0",
|
|
349
|
+
"sinon": "^15.2.0",
|
|
350
|
+
"sinon-chai": "^3.7.0",
|
|
351
|
+
"tmp": "^0.2.1",
|
|
352
|
+
"typescript": "^5.2.2"
|
|
353
|
+
},
|
|
354
|
+
"engines": { "node": ">= 12.0.0" },
|
|
355
|
+
"scripts": {
|
|
356
|
+
"test": "yarn run test:unit && yarn run test:integration && yarn run test:types",
|
|
357
|
+
"test:unit": "mocha -r mocha.conf.js test/unit/*.spec.js",
|
|
358
|
+
"test:integration": "mocha -r mocha.conf.js test/integration/*.spec.{m,}js",
|
|
359
|
+
"test:types": "tsc",
|
|
360
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
|
361
|
+
},
|
|
362
|
+
"author": "Dan Kerimdzhanov",
|
|
363
|
+
"license": "MIT"
|
|
364
|
+
};
|
|
365
|
+
}));
|
|
366
|
+
(/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
367
|
+
const fs$1 = __require("fs");
|
|
368
|
+
const p = __require("path");
|
|
369
|
+
const dotenv = require_main();
|
|
370
|
+
const { version } = require_package();
|
|
371
|
+
const DEFAULT_PATTERN = ".env[.node_env][.local]";
|
|
372
|
+
const LOCAL_PLACEHOLDER_REGEX = /\[(\W*\blocal\b\W*)]/g;
|
|
373
|
+
const NODE_ENV_PLACEHOLDER_REGEX = /\[(\W*\b)node_env(\b\W*)]/g;
|
|
374
|
+
/**
|
|
375
|
+
* Compose a filename from a given `patten`.
|
|
376
|
+
*
|
|
377
|
+
* @param {string} pattern
|
|
378
|
+
* @param {object} [options]
|
|
379
|
+
* @param {boolean} [options.local]
|
|
380
|
+
* @param {string} [options.node_env]
|
|
381
|
+
* @return {string} filename
|
|
382
|
+
*/
|
|
383
|
+
function composeFilename(pattern, options) {
|
|
384
|
+
let filename = pattern;
|
|
385
|
+
filename = filename.replace(LOCAL_PLACEHOLDER_REGEX, options && options.local ? "$1" : "");
|
|
386
|
+
filename = filename.replace(NODE_ENV_PLACEHOLDER_REGEX, options && options.node_env ? `$1${options.node_env}$2` : "");
|
|
387
|
+
return filename;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Returns a list of existing `.env*` filenames depending on the given `options`.
|
|
391
|
+
*
|
|
392
|
+
* The resulting list is ordered by the env files'
|
|
393
|
+
* variables overwriting priority from lowest to highest.
|
|
394
|
+
*
|
|
395
|
+
* This can also be referenced as "env files' environment cascade"
|
|
396
|
+
* or "order of ascending priority."
|
|
397
|
+
*
|
|
398
|
+
* ⚠️ Note that the `.env.local` file is not listed for "test" environment,
|
|
399
|
+
* since normally you expect tests to produce the same results for everyone.
|
|
400
|
+
*
|
|
401
|
+
* @param {object} [options] - `.env*` files listing options
|
|
402
|
+
* @param {string} [options.node_env] - node environment (development/test/production/etc.)
|
|
403
|
+
* @param {string} [options.path] - path to the working directory (default: `process.cwd()`)
|
|
404
|
+
* @param {string} [options.pattern] - `.env*` files' naming convention pattern
|
|
405
|
+
* (default: ".env[.node_env][.local]")
|
|
406
|
+
* @param {boolean} [options.debug] - turn on debug messages
|
|
407
|
+
* @return {string[]}
|
|
408
|
+
*/
|
|
409
|
+
function listFiles(options = {}) {
|
|
410
|
+
options.debug && debug("listing effective `.env*` files…");
|
|
411
|
+
const { node_env, path = process.cwd(), pattern = DEFAULT_PATTERN } = options;
|
|
412
|
+
const hasLocalPlaceholder = LOCAL_PLACEHOLDER_REGEX.test(pattern);
|
|
413
|
+
const filenames = {};
|
|
414
|
+
if (pattern === DEFAULT_PATTERN) filenames[".env.defaults"] = ".env.defaults";
|
|
415
|
+
filenames[".env"] = composeFilename(pattern);
|
|
416
|
+
if (hasLocalPlaceholder) {
|
|
417
|
+
const envlocal = composeFilename(pattern, { local: true });
|
|
418
|
+
if (node_env !== "test") filenames[".env.local"] = envlocal;
|
|
419
|
+
else if (options.debug && fs$1.existsSync(p.resolve(path, envlocal))) debug("[!] note that `%s` is being skipped for \"test\" environment", envlocal);
|
|
420
|
+
}
|
|
421
|
+
if (node_env && NODE_ENV_PLACEHOLDER_REGEX.test(pattern)) {
|
|
422
|
+
filenames[".env.node_env"] = composeFilename(pattern, { node_env });
|
|
423
|
+
if (hasLocalPlaceholder) filenames[".env.node_env.local"] = composeFilename(pattern, {
|
|
424
|
+
node_env,
|
|
425
|
+
local: true
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
return [
|
|
429
|
+
".env.defaults",
|
|
430
|
+
".env",
|
|
431
|
+
".env.local",
|
|
432
|
+
".env.node_env",
|
|
433
|
+
".env.node_env.local"
|
|
434
|
+
].reduce((list, basename) => {
|
|
435
|
+
if (!filenames[basename]) return list;
|
|
436
|
+
const filename = p.resolve(path, filenames[basename]);
|
|
437
|
+
if (fs$1.existsSync(filename)) {
|
|
438
|
+
options.debug && debug(">> %s", filename);
|
|
439
|
+
list.push(filename);
|
|
440
|
+
}
|
|
441
|
+
return list;
|
|
442
|
+
}, []);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Parses a given file or a list of files.
|
|
446
|
+
*
|
|
447
|
+
* When a list of filenames is given, the files will be parsed and merged in the same order as given.
|
|
448
|
+
*
|
|
449
|
+
* @param {string|string[]} filenames - filename or a list of filenames to parse and merge
|
|
450
|
+
* @param {{ encoding?: string, debug?: boolean }} [options] - parse options
|
|
451
|
+
* @return {Object<string, string>} the resulting map of `{ env_var: value }` as an object
|
|
452
|
+
*/
|
|
453
|
+
function parse(filenames, options = {}) {
|
|
454
|
+
if (typeof filenames === "string") {
|
|
455
|
+
options.debug && debug("parsing \"%s\"…", filenames);
|
|
456
|
+
const parsed = dotenv.parse(fs$1.readFileSync(filenames, options.encoding && { encoding: options.encoding }));
|
|
457
|
+
if (options.debug) Object.keys(parsed).forEach((varname) => debug(">> %s", varname));
|
|
458
|
+
return parsed;
|
|
459
|
+
}
|
|
460
|
+
return filenames.reduce((result, filename) => {
|
|
461
|
+
const parsed = parse(filename, options);
|
|
462
|
+
if (options.debug) Object.keys(parsed).filter((varname) => result.hasOwnProperty(varname)).forEach((varname) => debug("`%s` is being overwritten by merge from \"%s\"", varname, filename));
|
|
463
|
+
return Object.assign(result, parsed);
|
|
464
|
+
}, {});
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Parses variables defined in given file(s) and assigns them to `process.env`.
|
|
468
|
+
*
|
|
469
|
+
* Variables that are already defined in `process.env` will not be overwritten,
|
|
470
|
+
* thus giving a higher priority to environment variables predefined by the shell.
|
|
471
|
+
*
|
|
472
|
+
* If the loading is successful, an object with `parsed` property is returned.
|
|
473
|
+
* The `parsed` property contains parsed variables' `key => value` pairs merged in order using
|
|
474
|
+
* the "overwrite merge" strategy.
|
|
475
|
+
*
|
|
476
|
+
* If parsing fails for any of the given files, `process.env` is being left untouched,
|
|
477
|
+
* and an object with `error` property is returned.
|
|
478
|
+
* The `error` property, if present, references to the occurred error.
|
|
479
|
+
*
|
|
480
|
+
* @param {string|string[]} filenames - filename or a list of filenames to parse and merge
|
|
481
|
+
* @param {object} [options] - file loading options
|
|
482
|
+
* @param {string} [options.encoding="utf8"] - encoding of `.env*` files
|
|
483
|
+
* @param {boolean} [options.debug=false] - turn on debug messages
|
|
484
|
+
* @param {boolean} [options.silent=false] - suppress console errors and warnings
|
|
485
|
+
* @return {{ error: Error } | { parsed: Object<string, string> }}
|
|
486
|
+
*/
|
|
487
|
+
function load(filenames, options = {}) {
|
|
488
|
+
try {
|
|
489
|
+
const parsed = parse(filenames, {
|
|
490
|
+
encoding: options.encoding,
|
|
491
|
+
debug: options.debug
|
|
492
|
+
});
|
|
493
|
+
options.debug && debug("safe-merging parsed environment variables into `process.env`…");
|
|
494
|
+
for (const varname of Object.keys(parsed)) if (!process.env.hasOwnProperty(varname)) {
|
|
495
|
+
options.debug && debug(">> process.env.%s", varname);
|
|
496
|
+
process.env[varname] = parsed[varname];
|
|
497
|
+
} else if (options.debug && process.env[varname] !== parsed[varname]) debug("environment variable `%s` is predefined and not being overwritten", varname);
|
|
498
|
+
return { parsed };
|
|
499
|
+
} catch (error) {
|
|
500
|
+
return failure(error, options);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Unload variables defined in a given file(s) from `process.env`.
|
|
505
|
+
*
|
|
506
|
+
* This function can gracefully resolve the following issue:
|
|
507
|
+
*
|
|
508
|
+
* In some cases, the original "dotenv" library can be used by one of the dependent npm modules.
|
|
509
|
+
* It causes calling the original `dotenv.config()` that loads the `.env` file from your project before you can call `dotenv-flow.config()`.
|
|
510
|
+
* Such cases break `.env*` files priority because the previously loaded environment variables are treated as shell-defined thus having a higher priority.
|
|
511
|
+
*
|
|
512
|
+
* Unloading the previously loaded `.env` file can be activated when using the `dotenv-flow.config()` with the `purge_dotenv` option set to `true`.
|
|
513
|
+
*
|
|
514
|
+
* @param {string|string[]} filenames - filename or a list of filenames to unload
|
|
515
|
+
* @param {object} [options] - `fs.readFileSync` options
|
|
516
|
+
*/
|
|
517
|
+
function unload(filenames, options = {}) {
|
|
518
|
+
const parsed = parse(filenames, options);
|
|
519
|
+
Object.keys(parsed).forEach((key) => {
|
|
520
|
+
if (process.env[key] === parsed[key]) delete process.env[key];
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Returns effective (computed) `node_env`.
|
|
525
|
+
*
|
|
526
|
+
* @param {object} [options]
|
|
527
|
+
* @param {string} [options.node_env]
|
|
528
|
+
* @param {string} [options.default_node_env]
|
|
529
|
+
* @param {boolean} [options.debug]
|
|
530
|
+
* @return {string|undefined} node_env
|
|
531
|
+
*/
|
|
532
|
+
function getEffectiveNodeEnv(options = {}) {
|
|
533
|
+
if (options.node_env) {
|
|
534
|
+
options.debug && debug(`operating in "${options.node_env}" environment (set by \`options.node_env\`)`);
|
|
535
|
+
return options.node_env;
|
|
536
|
+
}
|
|
537
|
+
if (process.env.NODE_ENV) {
|
|
538
|
+
options.debug && debug(`operating in "${process.env.NODE_ENV}" environment (as per \`process.env.NODE_ENV\`)`);
|
|
539
|
+
return process.env.NODE_ENV;
|
|
540
|
+
}
|
|
541
|
+
if (options.default_node_env) {
|
|
542
|
+
options.debug && debug(`operating in "${options.default_node_env}" environment (taken from \`options.default_node_env\`)`);
|
|
543
|
+
return options.default_node_env;
|
|
544
|
+
}
|
|
545
|
+
options.debug && debug("operating in \"no environment\" mode (no environment-related options are set)");
|
|
546
|
+
}
|
|
547
|
+
const CONFIG_OPTION_KEYS = [
|
|
548
|
+
"node_env",
|
|
549
|
+
"default_node_env",
|
|
550
|
+
"path",
|
|
551
|
+
"pattern",
|
|
552
|
+
"files",
|
|
553
|
+
"encoding",
|
|
554
|
+
"purge_dotenv",
|
|
555
|
+
"silent"
|
|
556
|
+
];
|
|
557
|
+
/**
|
|
558
|
+
* "dotenv-flow" initialization function (API entry point).
|
|
559
|
+
*
|
|
560
|
+
* Allows configuring dotenv-flow programmatically.
|
|
561
|
+
*
|
|
562
|
+
* @param {object} [options] - configuration options
|
|
563
|
+
* @param {string} [options.node_env=process.env.NODE_ENV] - node environment (development/test/production/etc.)
|
|
564
|
+
* @param {string} [options.default_node_env] - the default node environment
|
|
565
|
+
* @param {string} [options.path=process.cwd()] - path to `.env*` files directory
|
|
566
|
+
* @param {string} [options.pattern=".env[.node_env][.local]"] - `.env*` files' naming convention pattern
|
|
567
|
+
* @param {string[]} [options.files] - an explicit list of `.env*` files to load (note that `options.[default_]node_env` and `options.pattern` are ignored in this case)
|
|
568
|
+
* @param {string} [options.encoding="utf8"] - encoding of `.env*` files
|
|
569
|
+
* @param {boolean} [options.purge_dotenv=false] - perform the `.env` file {@link unload}
|
|
570
|
+
* @param {boolean} [options.debug=false] - turn on detailed logging to help debug why certain variables are not being set as you expect
|
|
571
|
+
* @param {boolean} [options.silent=false] - suppress all kinds of warnings including ".env*" files' loading errors
|
|
572
|
+
* @return {{ parsed?: object, error?: Error }} with a `parsed` key containing the loaded content or an `error` key with an error that is occurred
|
|
573
|
+
*/
|
|
574
|
+
function config(options = {}) {
|
|
575
|
+
if (options.debug) {
|
|
576
|
+
debug("initializing…");
|
|
577
|
+
CONFIG_OPTION_KEYS.filter((key) => key in options).forEach((key) => debug(`| options.${key} =`, options[key]));
|
|
578
|
+
}
|
|
579
|
+
const { path = process.cwd(), pattern = DEFAULT_PATTERN } = options;
|
|
580
|
+
if (options.purge_dotenv) {
|
|
581
|
+
options.debug && debug("`options.purge_dotenv` is enabled, unloading potentially pre-loaded `.env`…");
|
|
582
|
+
const dotenvFile = p.resolve(path, ".env");
|
|
583
|
+
try {
|
|
584
|
+
fs$1.existsSync(dotenvFile) && unload(dotenvFile, { encoding: options.encoding });
|
|
585
|
+
} catch (error) {
|
|
586
|
+
!options.silent && warn("unloading failed: ", error);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
try {
|
|
590
|
+
let filenames;
|
|
591
|
+
if (options.files) {
|
|
592
|
+
options.debug && debug("using explicit list of `.env*` files: %s…", options.files.join(", "));
|
|
593
|
+
filenames = options.files.reduce((list, basename) => {
|
|
594
|
+
const filename = p.resolve(path, basename);
|
|
595
|
+
if (fs$1.existsSync(filename)) list.push(filename);
|
|
596
|
+
else if (options.debug) debug(">> %s does not exist, skipping…", filename);
|
|
597
|
+
return list;
|
|
598
|
+
}, []);
|
|
599
|
+
} else {
|
|
600
|
+
const node_env = getEffectiveNodeEnv(options);
|
|
601
|
+
filenames = listFiles({
|
|
602
|
+
node_env,
|
|
603
|
+
path,
|
|
604
|
+
pattern,
|
|
605
|
+
debug: options.debug
|
|
606
|
+
});
|
|
607
|
+
if (filenames.length === 0) {
|
|
608
|
+
const _pattern = node_env ? pattern.replace(NODE_ENV_PLACEHOLDER_REGEX, `[$1${node_env}$2]`) : pattern;
|
|
609
|
+
return failure(/* @__PURE__ */ new Error(`no ".env*" files matching pattern "${_pattern}" in "${path}" dir`), options);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const result = load(filenames, {
|
|
613
|
+
encoding: options.encoding,
|
|
614
|
+
debug: options.debug,
|
|
615
|
+
silent: options.silent
|
|
616
|
+
});
|
|
617
|
+
options.debug && debug("initialization completed.");
|
|
618
|
+
return result;
|
|
619
|
+
} catch (error) {
|
|
620
|
+
return failure(error, options);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function failure(error, options) {
|
|
624
|
+
if (!options.silent) warn(`".env*" files loading failed: ${error.message || error}`);
|
|
625
|
+
return { error };
|
|
626
|
+
}
|
|
627
|
+
function warn(message, error) {
|
|
628
|
+
if (error) message += ": %s";
|
|
629
|
+
console.warn(`[dotenv-flow@${version}]: ${message}`, error);
|
|
630
|
+
}
|
|
631
|
+
function debug(message, ...values) {
|
|
632
|
+
console.debug(`[dotenv-flow@${version}]: ${message}`, ...values);
|
|
633
|
+
}
|
|
634
|
+
module.exports = {
|
|
635
|
+
DEFAULT_PATTERN,
|
|
636
|
+
listFiles,
|
|
637
|
+
parse,
|
|
638
|
+
load,
|
|
639
|
+
unload,
|
|
640
|
+
config
|
|
641
|
+
};
|
|
642
|
+
})))();
|
|
643
|
+
/** Reads the process environment when called: every variable whose value is a string. The default for both `config` and `secrets`. */
|
|
644
|
+
function environmentVariables() {
|
|
645
|
+
return () => {
|
|
646
|
+
const values = {};
|
|
647
|
+
for (const [name, value] of Object.entries(process.env)) if (typeof value === "string") values[name] = value;
|
|
648
|
+
return values;
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region ../../0-framework/3-tooling/assemble/dist/index.mjs
|
|
653
|
+
/**
|
|
654
|
+
* A user-facing assembly failure, structured at origin (base-type rule 6):
|
|
655
|
+
* a `CliStructuredError` whose code names which way assembly went wrong.
|
|
656
|
+
* This package's second consumer is the programmatic deploy API, not just
|
|
657
|
+
* the CLI — hosts branch on `error.code`, the CLI renders the envelope.
|
|
658
|
+
*/
|
|
659
|
+
var AssembleError = class extends CliStructuredError {
|
|
660
|
+
constructor(code, summary, options) {
|
|
661
|
+
super(code, summary, options);
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
/**
|
|
665
|
+
* The registry route for one service's build: extension by
|
|
666
|
+
* `build.extension`, node descriptor by `build.type`, kind must be "build".
|
|
667
|
+
* The CLI's coverage validation reports the same misses earlier with the
|
|
668
|
+
* config fix; these errors are the backstop for programmatic callers.
|
|
669
|
+
*/
|
|
670
|
+
function buildDescriptorAssemble(config, node, address, cwd, report) {
|
|
671
|
+
const { extension, type } = node.build;
|
|
672
|
+
const extensionDescriptor = config.extensions.find((candidate) => candidate.id === extension);
|
|
673
|
+
if (extensionDescriptor === void 0) throw new AssembleError("ASSEMBLE.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by service "${node.name}"'s build).`, { fix: "Add it to `extensions` in the `composer` section of prisma.config.ts." });
|
|
674
|
+
const nodeDescriptor = extensionDescriptor.nodes[type];
|
|
675
|
+
if (nodeDescriptor === void 0) throw new AssembleError("ASSEMBLE.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for build type "${type}".`, { why: `Known types: ${Object.keys(extensionDescriptor.nodes).join(", ")}.` });
|
|
676
|
+
if (nodeDescriptor.kind !== "build") throw new AssembleError("ASSEMBLE.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for type "${type}" is a "${nodeDescriptor.kind}" descriptor.`, { why: "Assembling a service build needs a \"build\" descriptor." });
|
|
677
|
+
return nodeDescriptor.assemble({
|
|
678
|
+
build: node.build,
|
|
679
|
+
address,
|
|
680
|
+
cwd,
|
|
681
|
+
report
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* The dev server a service's build descriptor declares, or `undefined` when it
|
|
686
|
+
* declares none — including when the registry route misses, which the
|
|
687
|
+
* assemble that follows reports with its own pinned error.
|
|
688
|
+
*/
|
|
689
|
+
async function buildDescriptorServe(config, node, address) {
|
|
690
|
+
const { extension, type } = node.build;
|
|
691
|
+
const nodeDescriptor = config.extensions.find((candidate) => candidate.id === extension)?.nodes[type];
|
|
692
|
+
if (nodeDescriptor?.kind !== "build" || nodeDescriptor.serve === void 0) return void 0;
|
|
693
|
+
try {
|
|
694
|
+
return await nodeDescriptor.serve({
|
|
695
|
+
build: node.build,
|
|
696
|
+
address
|
|
697
|
+
});
|
|
698
|
+
} catch (error) {
|
|
699
|
+
if (CliStructuredError.is(error)) throw error;
|
|
700
|
+
throw new CliStructuredError("DEV.DEV_SERVER_UNAVAILABLE", `service "${address}" cannot run its dev server: ${error instanceof Error ? error.message : String(error)}`, {
|
|
701
|
+
meta: { address },
|
|
702
|
+
cause: error
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
async function assembleServices(graph, config, cwd, run, onEvent, options = {}) {
|
|
707
|
+
const runAssembler = run ?? ((node, address, nodeCwd, report) => buildDescriptorAssemble(config, node, address, nodeCwd, report));
|
|
708
|
+
const serviceNodes = graph.nodes.filter((n) => n.node.kind === "service");
|
|
709
|
+
if (serviceNodes.length === 0) throw new AssembleError("ASSEMBLE.SERVICE_MISSING", "The loaded graph has no service to assemble.");
|
|
710
|
+
const bundles = {};
|
|
711
|
+
const devServers = {};
|
|
712
|
+
for (const { id, node } of serviceNodes) {
|
|
713
|
+
if (options.devServers === true) {
|
|
714
|
+
const server = await buildDescriptorServe(config, node, id);
|
|
715
|
+
if (server !== void 0) {
|
|
716
|
+
devServers[id] = server;
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
onEvent?.({
|
|
721
|
+
kind: "service-started",
|
|
722
|
+
address: id
|
|
723
|
+
});
|
|
724
|
+
const data = {};
|
|
725
|
+
let artifact;
|
|
726
|
+
try {
|
|
727
|
+
artifact = await runAssembler(node, id, cwd, (reported) => Object.assign(data, reported));
|
|
728
|
+
} catch (error) {
|
|
729
|
+
if (CliStructuredError.is(error)) throw error;
|
|
730
|
+
throw new AssembleError("ASSEMBLE.BUILD_FAILED", error instanceof Error ? error.message : String(error), {
|
|
731
|
+
meta: { address: id },
|
|
732
|
+
cause: error
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
bundles[id] = artifact;
|
|
736
|
+
onEvent?.({
|
|
737
|
+
kind: "service-assembled",
|
|
738
|
+
address: id,
|
|
739
|
+
data
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
return {
|
|
743
|
+
bundles,
|
|
744
|
+
devServers
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region ../../0-framework/3-tooling/cli/dist/validate-environment-DCZiNSlR.mjs
|
|
749
|
+
function adapterInvalid(list, index, input, summary, fix) {
|
|
750
|
+
return new CliStructuredError("CONFIG.ADAPTER_INVALID", summary, {
|
|
751
|
+
fix,
|
|
752
|
+
where: { path: input.configFile },
|
|
753
|
+
meta: { field: `${list}[${index}]` }
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
function isValues(value) {
|
|
757
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
758
|
+
}
|
|
759
|
+
function isText(values) {
|
|
760
|
+
return Object.values(values).every((value) => typeof value === "string");
|
|
761
|
+
}
|
|
762
|
+
async function readAdapters(list, adapters, input) {
|
|
763
|
+
const adapterInput = Object.freeze({
|
|
764
|
+
environment: input.environment,
|
|
765
|
+
configDirectory: path.dirname(input.configFile)
|
|
766
|
+
});
|
|
767
|
+
const merged = Object.create(null);
|
|
768
|
+
for (const [index, adapter] of adapters.entries()) {
|
|
769
|
+
const field = `composer.${list}[${index}]`;
|
|
770
|
+
let values;
|
|
771
|
+
try {
|
|
772
|
+
values = await adapter(adapterInput);
|
|
773
|
+
} catch (thrown) {
|
|
774
|
+
throw new CliStructuredError("CONFIG.ADAPTER_FAILED", `\`${field}\` failed to read the values for the environment "${input.environment}".`, {
|
|
775
|
+
why: `It threw: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
776
|
+
fix: `Fix the adapter, or remove it from \`composer.${list}\` in prisma.config.ts.`,
|
|
777
|
+
where: { path: input.configFile },
|
|
778
|
+
meta: { field: `${list}[${index}]` },
|
|
779
|
+
cause: thrown
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
if (typeof values === "function") throw adapterInvalid(list, index, input, `\`${field}\` returned a function, not an object of values.`, "An adapter factory was put in the list instead of the adapter it makes: write `dotenv()`, not `dotenv`.");
|
|
783
|
+
if (!isValues(values)) throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(values)}, not an object of values.`, "Return an object whose keys are the names of the values, e.g. `{ EMAIL_FROM: 'shop@example.com' }`.");
|
|
784
|
+
for (const [key, value] of Object.entries(values)) {
|
|
785
|
+
if (value === void 0) continue;
|
|
786
|
+
if (list === "secrets" && typeof value !== "string") throw adapterInvalid(list, index, input, `\`${field}\` returned ${describeKind(value)} for "${key}", but a secret is text.`, "Return the secret as a string. A platform variable holds text.");
|
|
787
|
+
merged[key] = value;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return Object.freeze(merged);
|
|
791
|
+
}
|
|
792
|
+
/** Calls the section's `config` adapters (default `[environmentVariables()]`) and merges what they return: the app configuration. */
|
|
793
|
+
function readAppConfiguration(section, input) {
|
|
794
|
+
return readAdapters("config", section.config ?? [environmentVariables()], input);
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Calls the section's `secrets` adapters (default `[environmentVariables()]`) and merges what they
|
|
798
|
+
* return: the app secrets. Every value must be text. A value is a known secret only once the graph
|
|
799
|
+
* names it, so this adds none.
|
|
800
|
+
*/
|
|
801
|
+
async function readAppSecrets(section, input) {
|
|
802
|
+
const merged = await readAdapters("secrets", section.secrets ?? [environmentVariables()], input);
|
|
803
|
+
if (!isText(merged)) throw new InternalError("readAdapters admitted a secret that is not text");
|
|
804
|
+
return merged;
|
|
805
|
+
}
|
|
806
|
+
function lookup(extensions, extension, type, expectedKind, what) {
|
|
807
|
+
const ext = extensions.get(extension);
|
|
808
|
+
if (ext === void 0) throw new CliStructuredError("CONFIG.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by ${what}).`, {
|
|
809
|
+
fix: "Add it to `extensions` in the `composer` section of prisma.config.ts (import its /control entry and list its descriptor).",
|
|
810
|
+
meta: {
|
|
811
|
+
extension,
|
|
812
|
+
type
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
const descriptor = ext.nodes[type];
|
|
816
|
+
if (descriptor === void 0) throw new CliStructuredError("CONFIG.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for node type "${type}" (needed by ${what}).`, {
|
|
817
|
+
why: `Known types: ${Object.keys(ext.nodes).join(", ")}.`,
|
|
818
|
+
meta: {
|
|
819
|
+
extension,
|
|
820
|
+
type
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
if (descriptor.kind !== expectedKind) throw new CliStructuredError("CONFIG.DESCRIPTOR_KIND_MISMATCH", `Extension "${extension}"'s descriptor for node type "${type}" is a "${descriptor.kind}" descriptor — ${what} needs a "${expectedKind}" descriptor.`, { meta: {
|
|
824
|
+
extension,
|
|
825
|
+
type,
|
|
826
|
+
kind: descriptor.kind
|
|
827
|
+
} });
|
|
828
|
+
}
|
|
829
|
+
/** Throws a structured CONFIG.* error on the first uncovered `(extension, type)`; silent when the config covers the whole graph. */
|
|
830
|
+
function validateRegistryCoverage(graph, config) {
|
|
831
|
+
const extensions = new Map(config.extensions.map((descriptor) => [descriptor.id, descriptor]));
|
|
832
|
+
for (const { id, node } of graph.nodes) {
|
|
833
|
+
if (node.kind === "resource") {
|
|
834
|
+
lookup(extensions, node.extension, node.type, "resource", `resource node "${id}"`);
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
if (node.kind !== "service") continue;
|
|
838
|
+
lookup(extensions, node.extension, node.type, "service", `service node "${id}"`);
|
|
839
|
+
lookup(extensions, node.build.extension, node.build.type, "build", `service node "${id}"'s build descriptor`);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* The shared prefix of `deploy`/`destroy`/`dev` (deploy-cli.md § The
|
|
844
|
+
* pipeline; local-dev spec § 6): entry load, Load,
|
|
845
|
+
* registry coverage validation, name resolution, assemble. Deploy and dev
|
|
846
|
+
* diverge after this — deploy resolves containers/preflight/stack file
|
|
847
|
+
* against the hosted providers, dev against the local ones — so everything
|
|
848
|
+
* up to and including assemble lives here once, consumed verbatim by both
|
|
849
|
+
* `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
|
|
850
|
+
* cannot drift.
|
|
851
|
+
*/
|
|
852
|
+
const NO_SECRETS = Object.freeze({});
|
|
853
|
+
function configError(findings, file) {
|
|
854
|
+
const [first] = findings;
|
|
855
|
+
return new CliStructuredError(first.code, first.summary, {
|
|
856
|
+
...first.why === void 0 ? {} : { why: first.why },
|
|
857
|
+
fix: first.fix,
|
|
858
|
+
where: { path: first.where ?? file },
|
|
859
|
+
meta: {
|
|
860
|
+
...first.field === void 0 ? {} : { field: first.field },
|
|
861
|
+
findings
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* Refuses a caller's config with the same findings, in the same order, as the CLI's section validator.
|
|
867
|
+
* The error is the first finding and carries all of them in `meta.findings`. Returns the config with `file` resolved against `cwd`.
|
|
868
|
+
*/
|
|
869
|
+
function checkConfigSource(source, cwd) {
|
|
870
|
+
const file = path.resolve(cwd, source.file);
|
|
871
|
+
if (!fs.existsSync(file)) throw configError([configFileMissing(file)], file);
|
|
872
|
+
const checked = checkComposerConfig(source.value, file);
|
|
873
|
+
if (!checked.ok) throw configError(checked.findings, file);
|
|
874
|
+
return {
|
|
875
|
+
value: checked.value,
|
|
876
|
+
file
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Resolves the entry module. An override (`--entry`, or an operation's `entry` input) resolves
|
|
881
|
+
* against `cwd`; the section's `entry` resolves against the directory of the file that declares it,
|
|
882
|
+
* as the CLI engine resolves path fields in prisma.config.ts.
|
|
883
|
+
*/
|
|
884
|
+
function resolveEntryPath(override, source, cwd) {
|
|
885
|
+
if (override !== void 0) return {
|
|
886
|
+
path: path.resolve(cwd, override),
|
|
887
|
+
fix: `Check the \`--entry\` path (the \`entry\` input when calling @prisma/composer/control) "${override}". It is relative to the current directory, ${cwd}.`
|
|
888
|
+
};
|
|
889
|
+
const configured = source.value.entry;
|
|
890
|
+
if (configured === void 0) throw configError([entryMissing], source.file);
|
|
891
|
+
return {
|
|
892
|
+
path: path.resolve(path.dirname(source.file), configured),
|
|
893
|
+
fix: `Check \`entry: "${configured}"\` in ${source.file}. It is relative to that file's directory.`
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* The pipeline's front — entry load and name resolution —
|
|
898
|
+
* WITHOUT Load, coverage, or assemble. `log` needs only who the app is (its
|
|
899
|
+
* config and resolved name) to reach the already-running local instance; it
|
|
900
|
+
* neither builds nor provisions, so it must not require the user's built
|
|
901
|
+
* output the way the full pipeline does.
|
|
902
|
+
*/
|
|
903
|
+
async function resolveAppIdentity(entry, overrideName, cwd, config) {
|
|
904
|
+
const checked = checkConfigSource(config, cwd);
|
|
905
|
+
const { value } = checked;
|
|
906
|
+
const resolved = resolveEntryPath(entry, checked, cwd);
|
|
907
|
+
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
908
|
+
const name = overrideName ?? entryModule.root.name;
|
|
909
|
+
if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
|
|
910
|
+
assertAppName(name);
|
|
911
|
+
return {
|
|
912
|
+
config: value,
|
|
913
|
+
name
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Runs entry load, name resolution, Load, registry coverage, and assemble — steps 1–5 of `run()`. `onAssembleError`, when
|
|
918
|
+
* given, lets a caller decorate an assemble failure with command-specific
|
|
919
|
+
* guidance (destroy's "build first" hint) without this shared step knowing
|
|
920
|
+
* about any one command.
|
|
921
|
+
*/
|
|
922
|
+
async function runPipeline(entry, overrideName, environment, cwd, source, deps = {}, onAssembleError) {
|
|
923
|
+
const configSource = checkConfigSource(source, cwd);
|
|
924
|
+
const config = configSource.value;
|
|
925
|
+
const resolved = resolveEntryPath(entry, configSource, cwd);
|
|
926
|
+
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
927
|
+
const name = overrideName ?? entryModule.root.name;
|
|
928
|
+
if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
|
|
929
|
+
const redaction = deps.redaction ?? new SecretRedaction(process.env);
|
|
930
|
+
const adapterInput = {
|
|
931
|
+
environment,
|
|
932
|
+
configFile: configSource.file
|
|
933
|
+
};
|
|
934
|
+
const secrets = deps.readSecrets === true ? await readAppSecrets(config, adapterInput) : NO_SECRETS;
|
|
935
|
+
const configuration = await readAppConfiguration(config, adapterInput);
|
|
936
|
+
redaction.addCredentialLookingValues(credentialLookingValues(configuration));
|
|
937
|
+
const graph = Load(entryModule.root, {
|
|
938
|
+
id: name,
|
|
939
|
+
environment: { name: environment },
|
|
940
|
+
configuration
|
|
941
|
+
});
|
|
942
|
+
redaction.addKnownSecrets(valuesUnderSecretsKeys(configuration, secrets, secretsKeys(graph)));
|
|
943
|
+
checkGraph(graph, config.extensions);
|
|
944
|
+
validateRegistryCoverage(graph, config);
|
|
945
|
+
deps.onEvent?.({ kind: "loaded" });
|
|
946
|
+
let assembled;
|
|
947
|
+
try {
|
|
948
|
+
assembled = await assembleServices(graph, config, cwd, deps.runAssembler, deps.onEvent, { devServers: deps.devServers === true });
|
|
949
|
+
} catch (error) {
|
|
950
|
+
if (onAssembleError !== void 0 && error instanceof Error) throw onAssembleError(error);
|
|
951
|
+
throw error;
|
|
952
|
+
}
|
|
953
|
+
return {
|
|
954
|
+
configSource,
|
|
955
|
+
entryModule,
|
|
956
|
+
graph,
|
|
957
|
+
name,
|
|
958
|
+
assembled,
|
|
959
|
+
configuration,
|
|
960
|
+
secrets
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function checkGraph(graph, extensions) {
|
|
964
|
+
for (const extension of extensions) try {
|
|
965
|
+
extension.checkGraph?.(graph);
|
|
966
|
+
} catch (error) {
|
|
967
|
+
if (error instanceof GraphCheckError) throw new GraphCheckError(error.message, { extension: extension.id });
|
|
968
|
+
throw error;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
/** Letters, digits, `-` and `_`, starting with a letter or digit: always a valid git ref, so no `git` is needed to check it. */
|
|
972
|
+
const PLAIN_ENVIRONMENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
973
|
+
/** An environment name must be a valid git ref (deploy-cli.md) — checked via `git check-ref-format`, never silently normalized. Runs before anything platform-specific. */
|
|
974
|
+
function validateEnvironmentName(environment, spawn = spawnSync) {
|
|
975
|
+
if (PLAIN_ENVIRONMENT_NAME.test(environment)) return;
|
|
976
|
+
const result = spawn("git", ["check-ref-format", `refs/heads/${environment}`], { stdio: "ignore" });
|
|
977
|
+
if (result.error) throw new CliStructuredError("DEPLOY.ENVIRONMENT_UNVALIDATABLE", `git is required to validate --environment "${environment}" (git check-ref-format): ${result.error.message}.`, { cause: result.error });
|
|
978
|
+
if (result.status !== 0) throw new CliStructuredError("DEPLOY.ENVIRONMENT_INVALID", `Invalid --environment "${environment}": must be a valid git ref name (git check-ref-format rejected "refs/heads/${environment}").`);
|
|
979
|
+
}
|
|
980
|
+
//#endregion
|
|
981
|
+
export { validateEnvironmentName as i, resolveAppIdentity as n, runPipeline as r, checkConfigSource as t };
|
|
982
|
+
|
|
983
|
+
//# sourceMappingURL=validate-environment-DCZiNSlR-idVge-kq.mjs.map
|