@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
|
@@ -1,41 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { n as blindCast, t as InternalError } from "./internal-error-Dfur7Zqt-B8J8e7ac.mjs";
|
|
2
|
+
import { t as CliStructuredError } from "./errors-CVYwN2km.mjs";
|
|
3
3
|
import * as mod from "node:module";
|
|
4
|
-
import {
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
4
|
+
import { existsSync, statSync } from "node:fs";
|
|
7
5
|
import * as path from "node:path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
7
|
import "alchemy";
|
|
9
8
|
import "effect/Effect";
|
|
10
9
|
import "effect/Layer";
|
|
11
10
|
import * as Data from "effect/Data";
|
|
12
|
-
import "effect/Predicate";
|
|
13
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
|
-
import { spawnSync } from "node:child_process";
|
|
15
|
-
//#region \0rolldown/runtime.js
|
|
16
|
-
var __create = Object.create;
|
|
17
|
-
var __defProp = Object.defineProperty;
|
|
18
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
21
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
23
|
-
var __copyProps = (to, from, except, desc) => {
|
|
24
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
-
key = keys[i];
|
|
26
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
27
|
-
get: ((k) => from[k]).bind(null, key),
|
|
28
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return to;
|
|
32
|
-
};
|
|
33
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
34
|
-
value: mod,
|
|
35
|
-
enumerable: true
|
|
36
|
-
}) : target, mod));
|
|
37
|
-
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
38
|
-
//#endregion
|
|
11
|
+
import * as Predicate from "effect/Predicate";
|
|
39
12
|
//#region ../../0-framework/0-foundation/foundation/dist/describe-kind-Cpm_euxo.mjs
|
|
40
13
|
/** How an error names the kind of a value it did not expect, without printing the value. */
|
|
41
14
|
function describeKind(value) {
|
|
@@ -47,744 +20,6 @@ function describeKind(value) {
|
|
|
47
20
|
return `a ${typeof value}`;
|
|
48
21
|
}
|
|
49
22
|
//#endregion
|
|
50
|
-
//#region ../../../node_modules/dotenv-flow/node_modules/dotenv/package.json
|
|
51
|
-
var require_package$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
52
|
-
module.exports = {
|
|
53
|
-
"name": "dotenv",
|
|
54
|
-
"version": "16.6.1",
|
|
55
|
-
"description": "Loads environment variables from .env file",
|
|
56
|
-
"main": "lib/main.js",
|
|
57
|
-
"types": "lib/main.d.ts",
|
|
58
|
-
"exports": {
|
|
59
|
-
".": {
|
|
60
|
-
"types": "./lib/main.d.ts",
|
|
61
|
-
"require": "./lib/main.js",
|
|
62
|
-
"default": "./lib/main.js"
|
|
63
|
-
},
|
|
64
|
-
"./config": "./config.js",
|
|
65
|
-
"./config.js": "./config.js",
|
|
66
|
-
"./lib/env-options": "./lib/env-options.js",
|
|
67
|
-
"./lib/env-options.js": "./lib/env-options.js",
|
|
68
|
-
"./lib/cli-options": "./lib/cli-options.js",
|
|
69
|
-
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
70
|
-
"./package.json": "./package.json"
|
|
71
|
-
},
|
|
72
|
-
"scripts": {
|
|
73
|
-
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
74
|
-
"lint": "standard",
|
|
75
|
-
"pretest": "npm run lint && npm run dts-check",
|
|
76
|
-
"test": "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
77
|
-
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
78
|
-
"prerelease": "npm test",
|
|
79
|
-
"release": "standard-version"
|
|
80
|
-
},
|
|
81
|
-
"repository": {
|
|
82
|
-
"type": "git",
|
|
83
|
-
"url": "git://github.com/motdotla/dotenv.git"
|
|
84
|
-
},
|
|
85
|
-
"homepage": "https://github.com/motdotla/dotenv#readme",
|
|
86
|
-
"funding": "https://dotenvx.com",
|
|
87
|
-
"keywords": [
|
|
88
|
-
"dotenv",
|
|
89
|
-
"env",
|
|
90
|
-
".env",
|
|
91
|
-
"environment",
|
|
92
|
-
"variables",
|
|
93
|
-
"config",
|
|
94
|
-
"settings"
|
|
95
|
-
],
|
|
96
|
-
"readmeFilename": "README.md",
|
|
97
|
-
"license": "BSD-2-Clause",
|
|
98
|
-
"devDependencies": {
|
|
99
|
-
"@types/node": "^18.11.3",
|
|
100
|
-
"decache": "^4.6.2",
|
|
101
|
-
"sinon": "^14.0.1",
|
|
102
|
-
"standard": "^17.0.0",
|
|
103
|
-
"standard-version": "^9.5.0",
|
|
104
|
-
"tap": "^19.2.0",
|
|
105
|
-
"typescript": "^4.8.4"
|
|
106
|
-
},
|
|
107
|
-
"engines": { "node": ">=12" },
|
|
108
|
-
"browser": { "fs": false }
|
|
109
|
-
};
|
|
110
|
-
}));
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region ../../../node_modules/dotenv-flow/node_modules/dotenv/lib/main.js
|
|
113
|
-
var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
114
|
-
const fs$2 = __require("fs");
|
|
115
|
-
const path$1 = __require("path");
|
|
116
|
-
const os = __require("os");
|
|
117
|
-
const crypto = __require("crypto");
|
|
118
|
-
const version = require_package$1().version;
|
|
119
|
-
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
120
|
-
function parse(src) {
|
|
121
|
-
const obj = {};
|
|
122
|
-
let lines = src.toString();
|
|
123
|
-
lines = lines.replace(/\r\n?/gm, "\n");
|
|
124
|
-
let match;
|
|
125
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
126
|
-
const key = match[1];
|
|
127
|
-
let value = match[2] || "";
|
|
128
|
-
value = value.trim();
|
|
129
|
-
const maybeQuote = value[0];
|
|
130
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
131
|
-
if (maybeQuote === "\"") {
|
|
132
|
-
value = value.replace(/\\n/g, "\n");
|
|
133
|
-
value = value.replace(/\\r/g, "\r");
|
|
134
|
-
}
|
|
135
|
-
obj[key] = value;
|
|
136
|
-
}
|
|
137
|
-
return obj;
|
|
138
|
-
}
|
|
139
|
-
function _parseVault(options) {
|
|
140
|
-
options = options || {};
|
|
141
|
-
const vaultPath = _vaultPath(options);
|
|
142
|
-
options.path = vaultPath;
|
|
143
|
-
const result = DotenvModule.configDotenv(options);
|
|
144
|
-
if (!result.parsed) {
|
|
145
|
-
const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
146
|
-
err.code = "MISSING_DATA";
|
|
147
|
-
throw err;
|
|
148
|
-
}
|
|
149
|
-
const keys = _dotenvKey(options).split(",");
|
|
150
|
-
const length = keys.length;
|
|
151
|
-
let decrypted;
|
|
152
|
-
for (let i = 0; i < length; i++) try {
|
|
153
|
-
const attrs = _instructions(result, keys[i].trim());
|
|
154
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
155
|
-
break;
|
|
156
|
-
} catch (error) {
|
|
157
|
-
if (i + 1 >= length) throw error;
|
|
158
|
-
}
|
|
159
|
-
return DotenvModule.parse(decrypted);
|
|
160
|
-
}
|
|
161
|
-
function _warn(message) {
|
|
162
|
-
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
163
|
-
}
|
|
164
|
-
function _debug(message) {
|
|
165
|
-
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
166
|
-
}
|
|
167
|
-
function _log(message) {
|
|
168
|
-
console.log(`[dotenv@${version}] ${message}`);
|
|
169
|
-
}
|
|
170
|
-
function _dotenvKey(options) {
|
|
171
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) return options.DOTENV_KEY;
|
|
172
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
|
|
173
|
-
return "";
|
|
174
|
-
}
|
|
175
|
-
function _instructions(result, dotenvKey) {
|
|
176
|
-
let uri;
|
|
177
|
-
try {
|
|
178
|
-
uri = new URL(dotenvKey);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
if (error.code === "ERR_INVALID_URL") {
|
|
181
|
-
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");
|
|
182
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
183
|
-
throw err;
|
|
184
|
-
}
|
|
185
|
-
throw error;
|
|
186
|
-
}
|
|
187
|
-
const key = uri.password;
|
|
188
|
-
if (!key) {
|
|
189
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
190
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
191
|
-
throw err;
|
|
192
|
-
}
|
|
193
|
-
const environment = uri.searchParams.get("environment");
|
|
194
|
-
if (!environment) {
|
|
195
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
196
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
197
|
-
throw err;
|
|
198
|
-
}
|
|
199
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
200
|
-
const ciphertext = result.parsed[environmentKey];
|
|
201
|
-
if (!ciphertext) {
|
|
202
|
-
const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
203
|
-
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
204
|
-
throw err;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
ciphertext,
|
|
208
|
-
key
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
function _vaultPath(options) {
|
|
212
|
-
let possibleVaultPath = null;
|
|
213
|
-
if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
|
|
214
|
-
for (const filepath of options.path) if (fs$2.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
215
|
-
} else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
216
|
-
else possibleVaultPath = path$1.resolve(process.cwd(), ".env.vault");
|
|
217
|
-
if (fs$2.existsSync(possibleVaultPath)) return possibleVaultPath;
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
function _resolveHome(envPath) {
|
|
221
|
-
return envPath[0] === "~" ? path$1.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
222
|
-
}
|
|
223
|
-
function _configVault(options) {
|
|
224
|
-
const debug = Boolean(options && options.debug);
|
|
225
|
-
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
226
|
-
if (debug || !quiet) _log("Loading env from encrypted .env.vault");
|
|
227
|
-
const parsed = DotenvModule._parseVault(options);
|
|
228
|
-
let processEnv = process.env;
|
|
229
|
-
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
230
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
231
|
-
return { parsed };
|
|
232
|
-
}
|
|
233
|
-
function configDotenv(options) {
|
|
234
|
-
const dotenvPath = path$1.resolve(process.cwd(), ".env");
|
|
235
|
-
let encoding = "utf8";
|
|
236
|
-
const debug = Boolean(options && options.debug);
|
|
237
|
-
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
238
|
-
if (options && options.encoding) encoding = options.encoding;
|
|
239
|
-
else if (debug) _debug("No encoding is specified. UTF-8 is used by default");
|
|
240
|
-
let optionPaths = [dotenvPath];
|
|
241
|
-
if (options && options.path) if (!Array.isArray(options.path)) optionPaths = [_resolveHome(options.path)];
|
|
242
|
-
else {
|
|
243
|
-
optionPaths = [];
|
|
244
|
-
for (const filepath of options.path) optionPaths.push(_resolveHome(filepath));
|
|
245
|
-
}
|
|
246
|
-
let lastError;
|
|
247
|
-
const parsedAll = {};
|
|
248
|
-
for (const path of optionPaths) try {
|
|
249
|
-
const parsed = DotenvModule.parse(fs$2.readFileSync(path, { encoding }));
|
|
250
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
251
|
-
} catch (e) {
|
|
252
|
-
if (debug) _debug(`Failed to load ${path} ${e.message}`);
|
|
253
|
-
lastError = e;
|
|
254
|
-
}
|
|
255
|
-
let processEnv = process.env;
|
|
256
|
-
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
257
|
-
DotenvModule.populate(processEnv, parsedAll, options);
|
|
258
|
-
if (debug || !quiet) {
|
|
259
|
-
const keysCount = Object.keys(parsedAll).length;
|
|
260
|
-
const shortPaths = [];
|
|
261
|
-
for (const filePath of optionPaths) try {
|
|
262
|
-
const relative = path$1.relative(process.cwd(), filePath);
|
|
263
|
-
shortPaths.push(relative);
|
|
264
|
-
} catch (e) {
|
|
265
|
-
if (debug) _debug(`Failed to load ${filePath} ${e.message}`);
|
|
266
|
-
lastError = e;
|
|
267
|
-
}
|
|
268
|
-
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
|
|
269
|
-
}
|
|
270
|
-
if (lastError) return {
|
|
271
|
-
parsed: parsedAll,
|
|
272
|
-
error: lastError
|
|
273
|
-
};
|
|
274
|
-
else return { parsed: parsedAll };
|
|
275
|
-
}
|
|
276
|
-
function config(options) {
|
|
277
|
-
if (_dotenvKey(options).length === 0) return DotenvModule.configDotenv(options);
|
|
278
|
-
const vaultPath = _vaultPath(options);
|
|
279
|
-
if (!vaultPath) {
|
|
280
|
-
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
281
|
-
return DotenvModule.configDotenv(options);
|
|
282
|
-
}
|
|
283
|
-
return DotenvModule._configVault(options);
|
|
284
|
-
}
|
|
285
|
-
function decrypt(encrypted, keyStr) {
|
|
286
|
-
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
287
|
-
let ciphertext = Buffer.from(encrypted, "base64");
|
|
288
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
289
|
-
const authTag = ciphertext.subarray(-16);
|
|
290
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
291
|
-
try {
|
|
292
|
-
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
293
|
-
aesgcm.setAuthTag(authTag);
|
|
294
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
295
|
-
} catch (error) {
|
|
296
|
-
const isRange = error instanceof RangeError;
|
|
297
|
-
const invalidKeyLength = error.message === "Invalid key length";
|
|
298
|
-
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
299
|
-
if (isRange || invalidKeyLength) {
|
|
300
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
301
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
302
|
-
throw err;
|
|
303
|
-
} else if (decryptionFailed) {
|
|
304
|
-
const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
305
|
-
err.code = "DECRYPTION_FAILED";
|
|
306
|
-
throw err;
|
|
307
|
-
} else throw error;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
function populate(processEnv, parsed, options = {}) {
|
|
311
|
-
const debug = Boolean(options && options.debug);
|
|
312
|
-
const override = Boolean(options && options.override);
|
|
313
|
-
if (typeof parsed !== "object") {
|
|
314
|
-
const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
315
|
-
err.code = "OBJECT_REQUIRED";
|
|
316
|
-
throw err;
|
|
317
|
-
}
|
|
318
|
-
for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
319
|
-
if (override === true) processEnv[key] = parsed[key];
|
|
320
|
-
if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
|
|
321
|
-
else _debug(`"${key}" is already defined and was NOT overwritten`);
|
|
322
|
-
} else processEnv[key] = parsed[key];
|
|
323
|
-
}
|
|
324
|
-
const DotenvModule = {
|
|
325
|
-
configDotenv,
|
|
326
|
-
_configVault,
|
|
327
|
-
_parseVault,
|
|
328
|
-
config,
|
|
329
|
-
decrypt,
|
|
330
|
-
parse,
|
|
331
|
-
populate
|
|
332
|
-
};
|
|
333
|
-
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
334
|
-
module.exports._configVault = DotenvModule._configVault;
|
|
335
|
-
module.exports._parseVault = DotenvModule._parseVault;
|
|
336
|
-
module.exports.config = DotenvModule.config;
|
|
337
|
-
module.exports.decrypt = DotenvModule.decrypt;
|
|
338
|
-
module.exports.parse = DotenvModule.parse;
|
|
339
|
-
module.exports.populate = DotenvModule.populate;
|
|
340
|
-
module.exports = DotenvModule;
|
|
341
|
-
}));
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region ../../../node_modules/dotenv-flow/package.json
|
|
344
|
-
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
345
|
-
module.exports = {
|
|
346
|
-
"name": "dotenv-flow",
|
|
347
|
-
"version": "4.1.0",
|
|
348
|
-
"description": "Loads environment variables from `.env.[development|test|production][.local]` files",
|
|
349
|
-
"keywords": [
|
|
350
|
-
"dotenv",
|
|
351
|
-
"node_env",
|
|
352
|
-
"development",
|
|
353
|
-
"test",
|
|
354
|
-
"production",
|
|
355
|
-
"local",
|
|
356
|
-
"env",
|
|
357
|
-
"environment",
|
|
358
|
-
"variables"
|
|
359
|
-
],
|
|
360
|
-
"homepage": "https://github.com/kerimdzhanov/dotenv-flow#readme",
|
|
361
|
-
"repository": {
|
|
362
|
-
"type": "git",
|
|
363
|
-
"url": "git+https://github.com/kerimdzhanov/dotenv-flow.git"
|
|
364
|
-
},
|
|
365
|
-
"bugs": { "url": "https://github.com/kerimdzhanov/dotenv-flow/issues" },
|
|
366
|
-
"main": "lib/dotenv-flow.js",
|
|
367
|
-
"types": "lib/dotenv-flow.d.ts",
|
|
368
|
-
"exports": {
|
|
369
|
-
".": "./lib/dotenv-flow.js",
|
|
370
|
-
"./config": {
|
|
371
|
-
"require": "./config.js",
|
|
372
|
-
"node": "./config.js"
|
|
373
|
-
},
|
|
374
|
-
"./package.json": "./package.json"
|
|
375
|
-
},
|
|
376
|
-
"files": [
|
|
377
|
-
"lib/cli-options.js",
|
|
378
|
-
"lib/dotenv-flow.d.ts",
|
|
379
|
-
"lib/env-options.js",
|
|
380
|
-
"config.d.ts",
|
|
381
|
-
"config.js"
|
|
382
|
-
],
|
|
383
|
-
"dependencies": { "dotenv": "^16.0.0" },
|
|
384
|
-
"devDependencies": {
|
|
385
|
-
"@types/node": "^20.6.2",
|
|
386
|
-
"chai": "^4.3.7",
|
|
387
|
-
"conventional-changelog-cli": "^2.0.35",
|
|
388
|
-
"mocha": "^10.2.0",
|
|
389
|
-
"sinon": "^15.2.0",
|
|
390
|
-
"sinon-chai": "^3.7.0",
|
|
391
|
-
"tmp": "^0.2.1",
|
|
392
|
-
"typescript": "^5.2.2"
|
|
393
|
-
},
|
|
394
|
-
"engines": { "node": ">= 12.0.0" },
|
|
395
|
-
"scripts": {
|
|
396
|
-
"test": "yarn run test:unit && yarn run test:integration && yarn run test:types",
|
|
397
|
-
"test:unit": "mocha -r mocha.conf.js test/unit/*.spec.js",
|
|
398
|
-
"test:integration": "mocha -r mocha.conf.js test/integration/*.spec.{m,}js",
|
|
399
|
-
"test:types": "tsc",
|
|
400
|
-
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
|
401
|
-
},
|
|
402
|
-
"author": "Dan Kerimdzhanov",
|
|
403
|
-
"license": "MIT"
|
|
404
|
-
};
|
|
405
|
-
}));
|
|
406
|
-
(/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
407
|
-
const fs$1 = __require("fs");
|
|
408
|
-
const p = __require("path");
|
|
409
|
-
const dotenv = require_main();
|
|
410
|
-
const { version } = require_package();
|
|
411
|
-
const DEFAULT_PATTERN = ".env[.node_env][.local]";
|
|
412
|
-
const LOCAL_PLACEHOLDER_REGEX = /\[(\W*\blocal\b\W*)]/g;
|
|
413
|
-
const NODE_ENV_PLACEHOLDER_REGEX = /\[(\W*\b)node_env(\b\W*)]/g;
|
|
414
|
-
/**
|
|
415
|
-
* Compose a filename from a given `patten`.
|
|
416
|
-
*
|
|
417
|
-
* @param {string} pattern
|
|
418
|
-
* @param {object} [options]
|
|
419
|
-
* @param {boolean} [options.local]
|
|
420
|
-
* @param {string} [options.node_env]
|
|
421
|
-
* @return {string} filename
|
|
422
|
-
*/
|
|
423
|
-
function composeFilename(pattern, options) {
|
|
424
|
-
let filename = pattern;
|
|
425
|
-
filename = filename.replace(LOCAL_PLACEHOLDER_REGEX, options && options.local ? "$1" : "");
|
|
426
|
-
filename = filename.replace(NODE_ENV_PLACEHOLDER_REGEX, options && options.node_env ? `$1${options.node_env}$2` : "");
|
|
427
|
-
return filename;
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Returns a list of existing `.env*` filenames depending on the given `options`.
|
|
431
|
-
*
|
|
432
|
-
* The resulting list is ordered by the env files'
|
|
433
|
-
* variables overwriting priority from lowest to highest.
|
|
434
|
-
*
|
|
435
|
-
* This can also be referenced as "env files' environment cascade"
|
|
436
|
-
* or "order of ascending priority."
|
|
437
|
-
*
|
|
438
|
-
* ⚠️ Note that the `.env.local` file is not listed for "test" environment,
|
|
439
|
-
* since normally you expect tests to produce the same results for everyone.
|
|
440
|
-
*
|
|
441
|
-
* @param {object} [options] - `.env*` files listing options
|
|
442
|
-
* @param {string} [options.node_env] - node environment (development/test/production/etc.)
|
|
443
|
-
* @param {string} [options.path] - path to the working directory (default: `process.cwd()`)
|
|
444
|
-
* @param {string} [options.pattern] - `.env*` files' naming convention pattern
|
|
445
|
-
* (default: ".env[.node_env][.local]")
|
|
446
|
-
* @param {boolean} [options.debug] - turn on debug messages
|
|
447
|
-
* @return {string[]}
|
|
448
|
-
*/
|
|
449
|
-
function listFiles(options = {}) {
|
|
450
|
-
options.debug && debug("listing effective `.env*` files…");
|
|
451
|
-
const { node_env, path = process.cwd(), pattern = DEFAULT_PATTERN } = options;
|
|
452
|
-
const hasLocalPlaceholder = LOCAL_PLACEHOLDER_REGEX.test(pattern);
|
|
453
|
-
const filenames = {};
|
|
454
|
-
if (pattern === DEFAULT_PATTERN) filenames[".env.defaults"] = ".env.defaults";
|
|
455
|
-
filenames[".env"] = composeFilename(pattern);
|
|
456
|
-
if (hasLocalPlaceholder) {
|
|
457
|
-
const envlocal = composeFilename(pattern, { local: true });
|
|
458
|
-
if (node_env !== "test") filenames[".env.local"] = envlocal;
|
|
459
|
-
else if (options.debug && fs$1.existsSync(p.resolve(path, envlocal))) debug("[!] note that `%s` is being skipped for \"test\" environment", envlocal);
|
|
460
|
-
}
|
|
461
|
-
if (node_env && NODE_ENV_PLACEHOLDER_REGEX.test(pattern)) {
|
|
462
|
-
filenames[".env.node_env"] = composeFilename(pattern, { node_env });
|
|
463
|
-
if (hasLocalPlaceholder) filenames[".env.node_env.local"] = composeFilename(pattern, {
|
|
464
|
-
node_env,
|
|
465
|
-
local: true
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
return [
|
|
469
|
-
".env.defaults",
|
|
470
|
-
".env",
|
|
471
|
-
".env.local",
|
|
472
|
-
".env.node_env",
|
|
473
|
-
".env.node_env.local"
|
|
474
|
-
].reduce((list, basename) => {
|
|
475
|
-
if (!filenames[basename]) return list;
|
|
476
|
-
const filename = p.resolve(path, filenames[basename]);
|
|
477
|
-
if (fs$1.existsSync(filename)) {
|
|
478
|
-
options.debug && debug(">> %s", filename);
|
|
479
|
-
list.push(filename);
|
|
480
|
-
}
|
|
481
|
-
return list;
|
|
482
|
-
}, []);
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Parses a given file or a list of files.
|
|
486
|
-
*
|
|
487
|
-
* When a list of filenames is given, the files will be parsed and merged in the same order as given.
|
|
488
|
-
*
|
|
489
|
-
* @param {string|string[]} filenames - filename or a list of filenames to parse and merge
|
|
490
|
-
* @param {{ encoding?: string, debug?: boolean }} [options] - parse options
|
|
491
|
-
* @return {Object<string, string>} the resulting map of `{ env_var: value }` as an object
|
|
492
|
-
*/
|
|
493
|
-
function parse(filenames, options = {}) {
|
|
494
|
-
if (typeof filenames === "string") {
|
|
495
|
-
options.debug && debug("parsing \"%s\"…", filenames);
|
|
496
|
-
const parsed = dotenv.parse(fs$1.readFileSync(filenames, options.encoding && { encoding: options.encoding }));
|
|
497
|
-
if (options.debug) Object.keys(parsed).forEach((varname) => debug(">> %s", varname));
|
|
498
|
-
return parsed;
|
|
499
|
-
}
|
|
500
|
-
return filenames.reduce((result, filename) => {
|
|
501
|
-
const parsed = parse(filename, options);
|
|
502
|
-
if (options.debug) Object.keys(parsed).filter((varname) => result.hasOwnProperty(varname)).forEach((varname) => debug("`%s` is being overwritten by merge from \"%s\"", varname, filename));
|
|
503
|
-
return Object.assign(result, parsed);
|
|
504
|
-
}, {});
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Parses variables defined in given file(s) and assigns them to `process.env`.
|
|
508
|
-
*
|
|
509
|
-
* Variables that are already defined in `process.env` will not be overwritten,
|
|
510
|
-
* thus giving a higher priority to environment variables predefined by the shell.
|
|
511
|
-
*
|
|
512
|
-
* If the loading is successful, an object with `parsed` property is returned.
|
|
513
|
-
* The `parsed` property contains parsed variables' `key => value` pairs merged in order using
|
|
514
|
-
* the "overwrite merge" strategy.
|
|
515
|
-
*
|
|
516
|
-
* If parsing fails for any of the given files, `process.env` is being left untouched,
|
|
517
|
-
* and an object with `error` property is returned.
|
|
518
|
-
* The `error` property, if present, references to the occurred error.
|
|
519
|
-
*
|
|
520
|
-
* @param {string|string[]} filenames - filename or a list of filenames to parse and merge
|
|
521
|
-
* @param {object} [options] - file loading options
|
|
522
|
-
* @param {string} [options.encoding="utf8"] - encoding of `.env*` files
|
|
523
|
-
* @param {boolean} [options.debug=false] - turn on debug messages
|
|
524
|
-
* @param {boolean} [options.silent=false] - suppress console errors and warnings
|
|
525
|
-
* @return {{ error: Error } | { parsed: Object<string, string> }}
|
|
526
|
-
*/
|
|
527
|
-
function load(filenames, options = {}) {
|
|
528
|
-
try {
|
|
529
|
-
const parsed = parse(filenames, {
|
|
530
|
-
encoding: options.encoding,
|
|
531
|
-
debug: options.debug
|
|
532
|
-
});
|
|
533
|
-
options.debug && debug("safe-merging parsed environment variables into `process.env`…");
|
|
534
|
-
for (const varname of Object.keys(parsed)) if (!process.env.hasOwnProperty(varname)) {
|
|
535
|
-
options.debug && debug(">> process.env.%s", varname);
|
|
536
|
-
process.env[varname] = parsed[varname];
|
|
537
|
-
} else if (options.debug && process.env[varname] !== parsed[varname]) debug("environment variable `%s` is predefined and not being overwritten", varname);
|
|
538
|
-
return { parsed };
|
|
539
|
-
} catch (error) {
|
|
540
|
-
return failure(error, options);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
/**
|
|
544
|
-
* Unload variables defined in a given file(s) from `process.env`.
|
|
545
|
-
*
|
|
546
|
-
* This function can gracefully resolve the following issue:
|
|
547
|
-
*
|
|
548
|
-
* In some cases, the original "dotenv" library can be used by one of the dependent npm modules.
|
|
549
|
-
* It causes calling the original `dotenv.config()` that loads the `.env` file from your project before you can call `dotenv-flow.config()`.
|
|
550
|
-
* Such cases break `.env*` files priority because the previously loaded environment variables are treated as shell-defined thus having a higher priority.
|
|
551
|
-
*
|
|
552
|
-
* Unloading the previously loaded `.env` file can be activated when using the `dotenv-flow.config()` with the `purge_dotenv` option set to `true`.
|
|
553
|
-
*
|
|
554
|
-
* @param {string|string[]} filenames - filename or a list of filenames to unload
|
|
555
|
-
* @param {object} [options] - `fs.readFileSync` options
|
|
556
|
-
*/
|
|
557
|
-
function unload(filenames, options = {}) {
|
|
558
|
-
const parsed = parse(filenames, options);
|
|
559
|
-
Object.keys(parsed).forEach((key) => {
|
|
560
|
-
if (process.env[key] === parsed[key]) delete process.env[key];
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* Returns effective (computed) `node_env`.
|
|
565
|
-
*
|
|
566
|
-
* @param {object} [options]
|
|
567
|
-
* @param {string} [options.node_env]
|
|
568
|
-
* @param {string} [options.default_node_env]
|
|
569
|
-
* @param {boolean} [options.debug]
|
|
570
|
-
* @return {string|undefined} node_env
|
|
571
|
-
*/
|
|
572
|
-
function getEffectiveNodeEnv(options = {}) {
|
|
573
|
-
if (options.node_env) {
|
|
574
|
-
options.debug && debug(`operating in "${options.node_env}" environment (set by \`options.node_env\`)`);
|
|
575
|
-
return options.node_env;
|
|
576
|
-
}
|
|
577
|
-
if (process.env.NODE_ENV) {
|
|
578
|
-
options.debug && debug(`operating in "${process.env.NODE_ENV}" environment (as per \`process.env.NODE_ENV\`)`);
|
|
579
|
-
return process.env.NODE_ENV;
|
|
580
|
-
}
|
|
581
|
-
if (options.default_node_env) {
|
|
582
|
-
options.debug && debug(`operating in "${options.default_node_env}" environment (taken from \`options.default_node_env\`)`);
|
|
583
|
-
return options.default_node_env;
|
|
584
|
-
}
|
|
585
|
-
options.debug && debug("operating in \"no environment\" mode (no environment-related options are set)");
|
|
586
|
-
}
|
|
587
|
-
const CONFIG_OPTION_KEYS = [
|
|
588
|
-
"node_env",
|
|
589
|
-
"default_node_env",
|
|
590
|
-
"path",
|
|
591
|
-
"pattern",
|
|
592
|
-
"files",
|
|
593
|
-
"encoding",
|
|
594
|
-
"purge_dotenv",
|
|
595
|
-
"silent"
|
|
596
|
-
];
|
|
597
|
-
/**
|
|
598
|
-
* "dotenv-flow" initialization function (API entry point).
|
|
599
|
-
*
|
|
600
|
-
* Allows configuring dotenv-flow programmatically.
|
|
601
|
-
*
|
|
602
|
-
* @param {object} [options] - configuration options
|
|
603
|
-
* @param {string} [options.node_env=process.env.NODE_ENV] - node environment (development/test/production/etc.)
|
|
604
|
-
* @param {string} [options.default_node_env] - the default node environment
|
|
605
|
-
* @param {string} [options.path=process.cwd()] - path to `.env*` files directory
|
|
606
|
-
* @param {string} [options.pattern=".env[.node_env][.local]"] - `.env*` files' naming convention pattern
|
|
607
|
-
* @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)
|
|
608
|
-
* @param {string} [options.encoding="utf8"] - encoding of `.env*` files
|
|
609
|
-
* @param {boolean} [options.purge_dotenv=false] - perform the `.env` file {@link unload}
|
|
610
|
-
* @param {boolean} [options.debug=false] - turn on detailed logging to help debug why certain variables are not being set as you expect
|
|
611
|
-
* @param {boolean} [options.silent=false] - suppress all kinds of warnings including ".env*" files' loading errors
|
|
612
|
-
* @return {{ parsed?: object, error?: Error }} with a `parsed` key containing the loaded content or an `error` key with an error that is occurred
|
|
613
|
-
*/
|
|
614
|
-
function config(options = {}) {
|
|
615
|
-
if (options.debug) {
|
|
616
|
-
debug("initializing…");
|
|
617
|
-
CONFIG_OPTION_KEYS.filter((key) => key in options).forEach((key) => debug(`| options.${key} =`, options[key]));
|
|
618
|
-
}
|
|
619
|
-
const { path = process.cwd(), pattern = DEFAULT_PATTERN } = options;
|
|
620
|
-
if (options.purge_dotenv) {
|
|
621
|
-
options.debug && debug("`options.purge_dotenv` is enabled, unloading potentially pre-loaded `.env`…");
|
|
622
|
-
const dotenvFile = p.resolve(path, ".env");
|
|
623
|
-
try {
|
|
624
|
-
fs$1.existsSync(dotenvFile) && unload(dotenvFile, { encoding: options.encoding });
|
|
625
|
-
} catch (error) {
|
|
626
|
-
!options.silent && warn("unloading failed: ", error);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
try {
|
|
630
|
-
let filenames;
|
|
631
|
-
if (options.files) {
|
|
632
|
-
options.debug && debug("using explicit list of `.env*` files: %s…", options.files.join(", "));
|
|
633
|
-
filenames = options.files.reduce((list, basename) => {
|
|
634
|
-
const filename = p.resolve(path, basename);
|
|
635
|
-
if (fs$1.existsSync(filename)) list.push(filename);
|
|
636
|
-
else if (options.debug) debug(">> %s does not exist, skipping…", filename);
|
|
637
|
-
return list;
|
|
638
|
-
}, []);
|
|
639
|
-
} else {
|
|
640
|
-
const node_env = getEffectiveNodeEnv(options);
|
|
641
|
-
filenames = listFiles({
|
|
642
|
-
node_env,
|
|
643
|
-
path,
|
|
644
|
-
pattern,
|
|
645
|
-
debug: options.debug
|
|
646
|
-
});
|
|
647
|
-
if (filenames.length === 0) {
|
|
648
|
-
const _pattern = node_env ? pattern.replace(NODE_ENV_PLACEHOLDER_REGEX, `[$1${node_env}$2]`) : pattern;
|
|
649
|
-
return failure(/* @__PURE__ */ new Error(`no ".env*" files matching pattern "${_pattern}" in "${path}" dir`), options);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
const result = load(filenames, {
|
|
653
|
-
encoding: options.encoding,
|
|
654
|
-
debug: options.debug,
|
|
655
|
-
silent: options.silent
|
|
656
|
-
});
|
|
657
|
-
options.debug && debug("initialization completed.");
|
|
658
|
-
return result;
|
|
659
|
-
} catch (error) {
|
|
660
|
-
return failure(error, options);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
function failure(error, options) {
|
|
664
|
-
if (!options.silent) warn(`".env*" files loading failed: ${error.message || error}`);
|
|
665
|
-
return { error };
|
|
666
|
-
}
|
|
667
|
-
function warn(message, error) {
|
|
668
|
-
if (error) message += ": %s";
|
|
669
|
-
console.warn(`[dotenv-flow@${version}]: ${message}`, error);
|
|
670
|
-
}
|
|
671
|
-
function debug(message, ...values) {
|
|
672
|
-
console.debug(`[dotenv-flow@${version}]: ${message}`, ...values);
|
|
673
|
-
}
|
|
674
|
-
module.exports = {
|
|
675
|
-
DEFAULT_PATTERN,
|
|
676
|
-
listFiles,
|
|
677
|
-
parse,
|
|
678
|
-
load,
|
|
679
|
-
unload,
|
|
680
|
-
config
|
|
681
|
-
};
|
|
682
|
-
})))();
|
|
683
|
-
/** Reads the process environment when called: every variable whose value is a string. The default for both `config` and `secrets`. */
|
|
684
|
-
function environmentVariables() {
|
|
685
|
-
return () => {
|
|
686
|
-
const values = {};
|
|
687
|
-
for (const [name, value] of Object.entries(process.env)) if (typeof value === "string") values[name] = value;
|
|
688
|
-
return values;
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
//#endregion
|
|
692
|
-
//#region ../../0-framework/3-tooling/assemble/dist/index.mjs
|
|
693
|
-
/**
|
|
694
|
-
* A user-facing assembly failure, structured at origin (base-type rule 6):
|
|
695
|
-
* a `CliStructuredError` whose code names which way assembly went wrong.
|
|
696
|
-
* This package's second consumer is the programmatic deploy API, not just
|
|
697
|
-
* the CLI — hosts branch on `error.code`, the CLI renders the envelope.
|
|
698
|
-
*/
|
|
699
|
-
var AssembleError = class extends CliStructuredError {
|
|
700
|
-
constructor(code, summary, options) {
|
|
701
|
-
super(code, summary, options);
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
/**
|
|
705
|
-
* The registry route for one service's build: extension by
|
|
706
|
-
* `build.extension`, node descriptor by `build.type`, kind must be "build".
|
|
707
|
-
* The CLI's coverage validation reports the same misses earlier with the
|
|
708
|
-
* config fix; these errors are the backstop for programmatic callers.
|
|
709
|
-
*/
|
|
710
|
-
function buildDescriptorAssemble(config, node, address, cwd, report) {
|
|
711
|
-
const { extension, type } = node.build;
|
|
712
|
-
const extensionDescriptor = config.extensions.find((candidate) => candidate.id === extension);
|
|
713
|
-
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." });
|
|
714
|
-
const nodeDescriptor = extensionDescriptor.nodes[type];
|
|
715
|
-
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(", ")}.` });
|
|
716
|
-
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." });
|
|
717
|
-
return nodeDescriptor.assemble({
|
|
718
|
-
build: node.build,
|
|
719
|
-
address,
|
|
720
|
-
cwd,
|
|
721
|
-
report
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* The dev server a service's build descriptor declares, or `undefined` when it
|
|
726
|
-
* declares none — including when the registry route misses, which the
|
|
727
|
-
* assemble that follows reports with its own pinned error.
|
|
728
|
-
*/
|
|
729
|
-
async function buildDescriptorServe(config, node, address) {
|
|
730
|
-
const { extension, type } = node.build;
|
|
731
|
-
const nodeDescriptor = config.extensions.find((candidate) => candidate.id === extension)?.nodes[type];
|
|
732
|
-
if (nodeDescriptor?.kind !== "build" || nodeDescriptor.serve === void 0) return void 0;
|
|
733
|
-
try {
|
|
734
|
-
return await nodeDescriptor.serve({
|
|
735
|
-
build: node.build,
|
|
736
|
-
address
|
|
737
|
-
});
|
|
738
|
-
} catch (error) {
|
|
739
|
-
if (CliStructuredError.is(error)) throw error;
|
|
740
|
-
throw new CliStructuredError("DEV.DEV_SERVER_UNAVAILABLE", `service "${address}" cannot run its dev server: ${error instanceof Error ? error.message : String(error)}`, {
|
|
741
|
-
meta: { address },
|
|
742
|
-
cause: error
|
|
743
|
-
});
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
async function assembleServices(graph, config, cwd, run, onEvent, options = {}) {
|
|
747
|
-
const runAssembler = run ?? ((node, address, nodeCwd, report) => buildDescriptorAssemble(config, node, address, nodeCwd, report));
|
|
748
|
-
const serviceNodes = graph.nodes.filter((n) => n.node.kind === "service");
|
|
749
|
-
if (serviceNodes.length === 0) throw new AssembleError("ASSEMBLE.SERVICE_MISSING", "The loaded graph has no service to assemble.");
|
|
750
|
-
const bundles = {};
|
|
751
|
-
const devServers = {};
|
|
752
|
-
for (const { id, node } of serviceNodes) {
|
|
753
|
-
if (options.devServers === true) {
|
|
754
|
-
const server = await buildDescriptorServe(config, node, id);
|
|
755
|
-
if (server !== void 0) {
|
|
756
|
-
devServers[id] = server;
|
|
757
|
-
continue;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
onEvent?.({
|
|
761
|
-
kind: "service-started",
|
|
762
|
-
address: id
|
|
763
|
-
});
|
|
764
|
-
const data = {};
|
|
765
|
-
let artifact;
|
|
766
|
-
try {
|
|
767
|
-
artifact = await runAssembler(node, id, cwd, (reported) => Object.assign(data, reported));
|
|
768
|
-
} catch (error) {
|
|
769
|
-
if (CliStructuredError.is(error)) throw error;
|
|
770
|
-
throw new AssembleError("ASSEMBLE.BUILD_FAILED", error instanceof Error ? error.message : String(error), {
|
|
771
|
-
meta: { address: id },
|
|
772
|
-
cause: error
|
|
773
|
-
});
|
|
774
|
-
}
|
|
775
|
-
bundles[id] = artifact;
|
|
776
|
-
onEvent?.({
|
|
777
|
-
kind: "service-assembled",
|
|
778
|
-
address: id,
|
|
779
|
-
data
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
return {
|
|
783
|
-
bundles,
|
|
784
|
-
devServers
|
|
785
|
-
};
|
|
786
|
-
}
|
|
787
|
-
//#endregion
|
|
788
23
|
//#region ../../0-framework/0-foundation/foundation/dist/pointer-B3LgR6R4.mjs
|
|
789
24
|
/** A pointer: what a value known only at boot holds at deploy. It names the variable on the platform that the service reads at boot, and records whether that variable holds a secret. */
|
|
790
25
|
const POINTER = blindCast(Symbol.for("prisma:pointer"));
|
|
@@ -808,13 +43,14 @@ function isSecretString(value) {
|
|
|
808
43
|
return typeof value === "object" && value !== null && blindCast(value)[SECRET_BOX] === true;
|
|
809
44
|
}
|
|
810
45
|
//#endregion
|
|
811
|
-
//#region ../../0-framework/1-core/core/dist/graph-
|
|
46
|
+
//#region ../../0-framework/1-core/core/dist/graph-D2WMLL43.mjs
|
|
812
47
|
/** The reserved name of a resource's single anonymous output port. Rejected as a user-declared port name (node.ts). */
|
|
813
48
|
const RESOURCE_OUT_PORT = "$out";
|
|
814
49
|
/**
|
|
815
50
|
* Thrown by Load when the graph is malformed. Structured at origin
|
|
816
|
-
* (base-type rule 6)
|
|
817
|
-
*
|
|
51
|
+
* (base-type rule 6) under one type-level code. Not every error Load throws
|
|
52
|
+
* is one: a Load that needs a root input field an earlier Load did not read
|
|
53
|
+
* throws an error whose name is the value of `ROOT_INPUT_UNREAD_ERROR`. The `name` stays
|
|
818
54
|
* `CliStructuredError` — structural recognition depends on it.
|
|
819
55
|
*/
|
|
820
56
|
var LoadError = class extends CliStructuredError {
|
|
@@ -1249,6 +485,14 @@ function jsonInexactKind(value) {
|
|
|
1249
485
|
}
|
|
1250
486
|
return describeNotPlain(value) ?? describeKind(value);
|
|
1251
487
|
}
|
|
488
|
+
/** The `name` of the error a Load that takes what an earlier Load read fails with when it needs a root input field that Load did not read. */
|
|
489
|
+
const ROOT_INPUT_UNREAD_ERROR = "RootInputUnreadError";
|
|
490
|
+
var RootInputUnreadError = class extends Error {
|
|
491
|
+
constructor(message) {
|
|
492
|
+
super(message);
|
|
493
|
+
this.name = ROOT_INPUT_UNREAD_ERROR;
|
|
494
|
+
}
|
|
495
|
+
};
|
|
1252
496
|
const SAME_GRAPH_ADVICE = "A module body must build the same graph every time; one that reads the process environment, a file or the clock can build a different one.";
|
|
1253
497
|
function isThenable(value) {
|
|
1254
498
|
if (isValue(value)) return false;
|
|
@@ -1566,7 +810,7 @@ function resolveValues(input) {
|
|
|
1566
810
|
}
|
|
1567
811
|
if (entry.checked !== void 0) {
|
|
1568
812
|
const field = entry.checked.find((candidate) => candidate.path.join("\0") === origin.path.join("\0"));
|
|
1569
|
-
if (field === void 0) throw new
|
|
813
|
+
if (field === void 0) throw new RootInputUnreadError(`${inputFieldLabel(origin)} of root module "${origin.module}" was not read when this command started, so it has no value here. ${SAME_GRAPH_ADVICE}`);
|
|
1570
814
|
result = field.value;
|
|
1571
815
|
} else {
|
|
1572
816
|
result = readPath(validatedInputOf(entry), origin);
|
|
@@ -1611,7 +855,7 @@ function resolveValues(input) {
|
|
|
1611
855
|
kind: "input",
|
|
1612
856
|
module: rootModuleAddress(),
|
|
1613
857
|
path: field.path
|
|
1614
|
-
})} of root module "${rootModuleAddress()}" reads "${key}" from the app configuration, and ${origin.label} names "${key}" as a secret. A name is a plain value or a secret, not both: a root input field is a plain value, which \`prisma deploy\` sends to the platform as plain configuration,
|
|
858
|
+
})} of root module "${rootModuleAddress()}" reads "${key}" from the app configuration, and ${origin.label} names "${key}" as a secret. A name is a plain value or a secret, not both: a root input field is a plain value, which \`prisma deploy\` sends to the platform as plain configuration, \`prisma dev\` gives to the local services as plain configuration, and \`destroy\` writes to a file. Read the secret with ${origin.label} only, or give the plain value a different name.`);
|
|
1615
859
|
}
|
|
1616
860
|
for (const field of rootFields.values()) {
|
|
1617
861
|
const kind = "value" in field ? jsonInexactKind(field.value) : void 0;
|
|
@@ -1619,7 +863,7 @@ function resolveValues(input) {
|
|
|
1619
863
|
kind: "input",
|
|
1620
864
|
module: rootModuleAddress(),
|
|
1621
865
|
path: field.path
|
|
1622
|
-
})} of root module "${rootModuleAddress()}" holds ${kind}, which JSON cannot hold exactly. \`
|
|
866
|
+
})} of root module "${rootModuleAddress()}" holds ${kind}, which JSON cannot hold exactly. \`destroy\` hands the root's input to its second process in a JSON file, so a field the root's body passes on must hold text, a finite number, a boolean, null, or arrays and plain objects of these.`);
|
|
1623
867
|
}
|
|
1624
868
|
return { rootInput: [...rootFields.values()] };
|
|
1625
869
|
};
|
|
@@ -2193,66 +1437,8 @@ function secretsKeys(graph) {
|
|
|
2193
1437
|
function nodeAddresses(graph) {
|
|
2194
1438
|
return graph.nodes.map(({ id }) => id).sort();
|
|
2195
1439
|
}
|
|
2196
|
-
Data.TaggedError("ProviderFailure");
|
|
2197
1440
|
//#endregion
|
|
2198
|
-
//#region ../../0-framework/3-tooling/cli/dist/
|
|
2199
|
-
function adapterInvalid(list, index, input, summary, fix) {
|
|
2200
|
-
return new CliStructuredError("CONFIG.ADAPTER_INVALID", summary, {
|
|
2201
|
-
fix,
|
|
2202
|
-
where: { path: input.configFile },
|
|
2203
|
-
meta: { field: `${list}[${index}]` }
|
|
2204
|
-
});
|
|
2205
|
-
}
|
|
2206
|
-
function isValues(value) {
|
|
2207
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2208
|
-
}
|
|
2209
|
-
function isText(values) {
|
|
2210
|
-
return Object.values(values).every((value) => typeof value === "string");
|
|
2211
|
-
}
|
|
2212
|
-
async function readAdapters(list, adapters, input) {
|
|
2213
|
-
const adapterInput = Object.freeze({
|
|
2214
|
-
environment: input.environment,
|
|
2215
|
-
configDirectory: path.dirname(input.configFile)
|
|
2216
|
-
});
|
|
2217
|
-
const merged = Object.create(null);
|
|
2218
|
-
for (const [index, adapter] of adapters.entries()) {
|
|
2219
|
-
const field = `composer.${list}[${index}]`;
|
|
2220
|
-
let values;
|
|
2221
|
-
try {
|
|
2222
|
-
values = await adapter(adapterInput);
|
|
2223
|
-
} catch (thrown) {
|
|
2224
|
-
throw new CliStructuredError("CONFIG.ADAPTER_FAILED", `\`${field}\` failed to read the values for the environment "${input.environment}".`, {
|
|
2225
|
-
why: `It threw: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
2226
|
-
fix: `Fix the adapter, or remove it from \`composer.${list}\` in prisma.config.ts.`,
|
|
2227
|
-
where: { path: input.configFile },
|
|
2228
|
-
meta: { field: `${list}[${index}]` },
|
|
2229
|
-
cause: thrown
|
|
2230
|
-
});
|
|
2231
|
-
}
|
|
2232
|
-
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`.");
|
|
2233
|
-
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' }`.");
|
|
2234
|
-
for (const [key, value] of Object.entries(values)) {
|
|
2235
|
-
if (value === void 0) continue;
|
|
2236
|
-
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.");
|
|
2237
|
-
merged[key] = value;
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
return Object.freeze(merged);
|
|
2241
|
-
}
|
|
2242
|
-
/** Calls the section's `config` adapters (default `[environmentVariables()]`) and merges what they return: the app configuration. */
|
|
2243
|
-
function readAppConfiguration(section, input) {
|
|
2244
|
-
return readAdapters("config", section.config ?? [environmentVariables()], input);
|
|
2245
|
-
}
|
|
2246
|
-
/**
|
|
2247
|
-
* Calls the section's `secrets` adapters (default `[environmentVariables()]`) and merges what they
|
|
2248
|
-
* return: the app secrets. Every value must be text. A value is a known secret only once the graph
|
|
2249
|
-
* names it, so this adds none.
|
|
2250
|
-
*/
|
|
2251
|
-
async function readAppSecrets(section, input) {
|
|
2252
|
-
const merged = await readAdapters("secrets", section.secrets ?? [environmentVariables()], input);
|
|
2253
|
-
if (!isText(merged)) throw new InternalError("readAdapters admitted a secret that is not text");
|
|
2254
|
-
return merged;
|
|
2255
|
-
}
|
|
1441
|
+
//#region ../../0-framework/3-tooling/cli/dist/load-entry-CEoVBdMj.mjs
|
|
2256
1442
|
/**
|
|
2257
1443
|
* Synchronous Node resolve hook so that entry modules may import relative
|
|
2258
1444
|
* files using the specifier forms TypeScript accepts by default —
|
|
@@ -2270,8 +1456,117 @@ async function readAppSecrets(section, input) {
|
|
|
2270
1456
|
*
|
|
2271
1457
|
* Bun resolves `./x.js` and `./x` to `x.ts` natively, so the hook is a
|
|
2272
1458
|
* no-op under Bun. Nothing is registered there.
|
|
1459
|
+
*
|
|
1460
|
+
* The hook also observes, without changing anything: `recordAppFiles` uses
|
|
1461
|
+
* it to learn which app files an entry import loaded.
|
|
2273
1462
|
*/
|
|
2274
1463
|
let registered = false;
|
|
1464
|
+
let recording;
|
|
1465
|
+
/** An app file: a `file:` module outside every `node_modules` directory. */
|
|
1466
|
+
function appFile(url) {
|
|
1467
|
+
if (!url.startsWith("file:")) return void 0;
|
|
1468
|
+
const file = fileURLToPath(url);
|
|
1469
|
+
return file.split(path.sep).includes("node_modules") ? void 0 : file;
|
|
1470
|
+
}
|
|
1471
|
+
function record(url) {
|
|
1472
|
+
const file = recording === void 0 ? void 0 : appFile(url);
|
|
1473
|
+
if (file !== void 0) recording?.add(file);
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Runs `load` and returns the app files it imported: every module outside
|
|
1477
|
+
* `node_modules` that the runtime loaded for the first time while it ran,
|
|
1478
|
+
* static and dynamic imports alike. Under Node the resolve hook records them;
|
|
1479
|
+
* under Bun they are the modules `require.cache` gained, which includes ES
|
|
1480
|
+
* modules. A module already loaded before `load` started, and what only it
|
|
1481
|
+
* imports, is not recorded. Each file is also added to `recorded` as it is
|
|
1482
|
+
* found, so a caller still has them when `load` throws.
|
|
1483
|
+
*/
|
|
1484
|
+
async function recordAppFiles(load, recorded = /* @__PURE__ */ new Set()) {
|
|
1485
|
+
if (typeof process.versions.bun === "string") {
|
|
1486
|
+
const cache = mod.createRequire(import.meta.url).cache;
|
|
1487
|
+
const before = new Set(Object.keys(cache));
|
|
1488
|
+
const files = [];
|
|
1489
|
+
try {
|
|
1490
|
+
return {
|
|
1491
|
+
value: await load(),
|
|
1492
|
+
files
|
|
1493
|
+
};
|
|
1494
|
+
} finally {
|
|
1495
|
+
for (const key of Object.keys(cache)) {
|
|
1496
|
+
if (before.has(key) || !path.isAbsolute(key)) continue;
|
|
1497
|
+
if (key.split(path.sep).includes("node_modules")) continue;
|
|
1498
|
+
files.push(key);
|
|
1499
|
+
recorded.add(key);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
registerEntryResolution();
|
|
1504
|
+
const files = /* @__PURE__ */ new Set();
|
|
1505
|
+
recording = files;
|
|
1506
|
+
try {
|
|
1507
|
+
return {
|
|
1508
|
+
value: await load(),
|
|
1509
|
+
files: [...files]
|
|
1510
|
+
};
|
|
1511
|
+
} finally {
|
|
1512
|
+
recording = void 0;
|
|
1513
|
+
for (const file of files) recorded.add(file);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
/** The path of a `file:` URL, or `undefined` for one that names no local file, such as one with a host. */
|
|
1517
|
+
function pathOfFileUrl(url) {
|
|
1518
|
+
try {
|
|
1519
|
+
return fileURLToPath(url);
|
|
1520
|
+
} catch {
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* The app files an import error names: the module that could not be found, or the file that did
|
|
1526
|
+
* not parse, when the runtime says which. A module that could not be found comes with every file
|
|
1527
|
+
* the resolve hook would try for it, since the user may create any of them. A directory is never
|
|
1528
|
+
* returned: in its place come the files the hook would try inside it. Follows `cause`.
|
|
1529
|
+
*/
|
|
1530
|
+
function appFilesNamedBy(error) {
|
|
1531
|
+
const named = appPathNamedBy(error);
|
|
1532
|
+
return named === void 0 ? [] : filesFor(named);
|
|
1533
|
+
}
|
|
1534
|
+
/** Whether an import error names a directory of the app that holds an `index.ts`, which the import should have loaded. */
|
|
1535
|
+
function namesDirectoryWithIndex(error) {
|
|
1536
|
+
const named = appPathNamedBy(error);
|
|
1537
|
+
return named !== void 0 && isDirectory(named) && filesFor(named).some(existsSync);
|
|
1538
|
+
}
|
|
1539
|
+
function appPathNamedBy(error) {
|
|
1540
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1541
|
+
for (let current = error; typeof current === "object" && current !== null;) {
|
|
1542
|
+
if (visited.has(current)) break;
|
|
1543
|
+
visited.add(current);
|
|
1544
|
+
const named = fileNamedBy(current);
|
|
1545
|
+
if (named !== void 0 && !named.split(path.sep).includes("node_modules")) return path.resolve(named);
|
|
1546
|
+
current = "cause" in current ? current.cause : void 0;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
function filesFor(named) {
|
|
1550
|
+
const candidates = () => sourceCandidates(pathToFileURL(named)).map((url) => fileURLToPath(url));
|
|
1551
|
+
if (isDirectory(named)) return candidates().filter((candidate) => candidate.startsWith(named + path.sep));
|
|
1552
|
+
if (existsSync(named)) return [named];
|
|
1553
|
+
return [named, ...candidates()];
|
|
1554
|
+
}
|
|
1555
|
+
function isDirectory(file) {
|
|
1556
|
+
try {
|
|
1557
|
+
return statSync(file).isDirectory();
|
|
1558
|
+
} catch {
|
|
1559
|
+
return false;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
function fileNamedBy(error) {
|
|
1563
|
+
if ("url" in error && typeof error.url === "string" && error.url.startsWith("file:")) return pathOfFileUrl(error.url);
|
|
1564
|
+
if ("specifier" in error && typeof error.specifier === "string" && "referrer" in error && typeof error.referrer === "string" && isRelativeSpecifier(error.specifier)) {
|
|
1565
|
+
const referrer = error.referrer.startsWith("file:") ? pathOfFileUrl(error.referrer) : error.referrer;
|
|
1566
|
+
return referrer === void 0 ? void 0 : path.resolve(path.dirname(referrer), error.specifier);
|
|
1567
|
+
}
|
|
1568
|
+
if ("position" in error && typeof error.position === "object" && error.position !== null && "file" in error.position && typeof error.position.file === "string" && path.isAbsolute(error.position.file)) return error.position.file;
|
|
1569
|
+
}
|
|
2275
1570
|
/**
|
|
2276
1571
|
* Registers the resolve hook once (idempotent). Call at the start of
|
|
2277
1572
|
* `loadEntry` so every module in the entry graph benefits, including those
|
|
@@ -2283,10 +1578,16 @@ function registerEntryResolution() {
|
|
|
2283
1578
|
registered = true;
|
|
2284
1579
|
mod.registerHooks({ resolve(specifier, context, nextResolve) {
|
|
2285
1580
|
try {
|
|
2286
|
-
|
|
1581
|
+
const resolved = nextResolve(specifier, context);
|
|
1582
|
+
record(resolved.url);
|
|
1583
|
+
return resolved;
|
|
2287
1584
|
} catch (error) {
|
|
2288
1585
|
if (!isRelativeSpecifier(specifier) || context.parentURL === void 0 || !isModuleNotFoundError(error)) throw error;
|
|
2289
|
-
for (const candidate of sourceCandidates(new URL(specifier, context.parentURL))) if (existsSync(fileURLToPath(candidate)))
|
|
1586
|
+
for (const candidate of sourceCandidates(new URL(specifier, context.parentURL))) if (existsSync(fileURLToPath(candidate))) {
|
|
1587
|
+
const resolved = nextResolve(candidate.href, context);
|
|
1588
|
+
record(resolved.url);
|
|
1589
|
+
return resolved;
|
|
1590
|
+
}
|
|
2290
1591
|
throw error;
|
|
2291
1592
|
}
|
|
2292
1593
|
} });
|
|
@@ -2296,10 +1597,11 @@ function registerEntryResolution() {
|
|
|
2296
1597
|
* produce the source candidates to probe. Format-specific: `.mjs` maps only
|
|
2297
1598
|
* to `.mts`; `.cjs` maps only to `.cts`; `.js` and extensionless probe
|
|
2298
1599
|
* `.ts`, `.mts`, `.tsx` (keeping `.tsx` so the JSX diagnostic fires), then
|
|
2299
|
-
* `./index.ts`.
|
|
1600
|
+
* `./index.ts`. A URL that already has a TypeScript extension has none.
|
|
2300
1601
|
*/
|
|
2301
1602
|
function sourceCandidates(resolved) {
|
|
2302
1603
|
const href = resolved.href;
|
|
1604
|
+
if (/\.(ts|mts|cts|tsx)$/.test(href)) return [];
|
|
2303
1605
|
if (href.endsWith(".mjs")) {
|
|
2304
1606
|
const base = href.slice(0, -4);
|
|
2305
1607
|
return [new URL(`${base}.mts`)];
|
|
@@ -2317,7 +1619,7 @@ function sourceCandidates(resolved) {
|
|
|
2317
1619
|
];
|
|
2318
1620
|
}
|
|
2319
1621
|
function isRelativeSpecifier(specifier) {
|
|
2320
|
-
return specifier.startsWith("./") || specifier.startsWith("../");
|
|
1622
|
+
return specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../");
|
|
2321
1623
|
}
|
|
2322
1624
|
function isModuleNotFoundError(error) {
|
|
2323
1625
|
if (!(error instanceof Error)) return false;
|
|
@@ -2367,13 +1669,17 @@ function explainJsxLoadError(error, entryPath) {
|
|
|
2367
1669
|
* an app root built with `appRoot()`, or a module built with `module()`
|
|
2368
1670
|
* (ADR-0003).
|
|
2369
1671
|
*/
|
|
2370
|
-
/**
|
|
2371
|
-
|
|
1672
|
+
/**
|
|
1673
|
+
* `unloadableFix`, when given, says where the path came from, so a wrong path names its source.
|
|
1674
|
+
* `recorded` receives each app file the import loads, so a caller has them when it throws.
|
|
1675
|
+
*/
|
|
1676
|
+
async function loadEntry(entryArg, cwd, unloadableFix, recorded) {
|
|
2372
1677
|
registerEntryResolution();
|
|
2373
1678
|
const resolvedPath = path.resolve(cwd, entryArg);
|
|
2374
1679
|
let mod;
|
|
1680
|
+
let files;
|
|
2375
1681
|
try {
|
|
2376
|
-
mod = await import(pathToFileURL(resolvedPath).href);
|
|
1682
|
+
({value: mod, files} = await recordAppFiles(() => import(pathToFileURL(resolvedPath).href), recorded));
|
|
2377
1683
|
} catch (error) {
|
|
2378
1684
|
const explained = explainJsxLoadError(error, resolvedPath);
|
|
2379
1685
|
if (explained !== void 0) throw new CliStructuredError("COMPOSE.ENTRY_UNLOADABLE", explained.summary, {
|
|
@@ -2399,184 +1705,72 @@ async function loadEntry(entryArg, cwd, unloadableFix) {
|
|
|
2399
1705
|
});
|
|
2400
1706
|
return {
|
|
2401
1707
|
path: resolvedPath,
|
|
1708
|
+
files: [.../* @__PURE__ */ new Set([resolvedPath, ...files])],
|
|
2402
1709
|
root
|
|
2403
1710
|
};
|
|
2404
1711
|
}
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
if (ext === void 0) throw new CliStructuredError("CONFIG.EXTENSION_MISSING", `No extension "${extension}" is configured (needed by ${what}).`, {
|
|
2408
|
-
fix: "Add it to `extensions` in the `composer` section of prisma.config.ts (import its /control entry and list its descriptor).",
|
|
2409
|
-
meta: {
|
|
2410
|
-
extension,
|
|
2411
|
-
type
|
|
2412
|
-
}
|
|
2413
|
-
});
|
|
2414
|
-
const descriptor = ext.nodes[type];
|
|
2415
|
-
if (descriptor === void 0) throw new CliStructuredError("CONFIG.DESCRIPTOR_MISSING", `Extension "${extension}" has no descriptor for node type "${type}" (needed by ${what}).`, {
|
|
2416
|
-
why: `Known types: ${Object.keys(ext.nodes).join(", ")}.`,
|
|
2417
|
-
meta: {
|
|
2418
|
-
extension,
|
|
2419
|
-
type
|
|
2420
|
-
}
|
|
2421
|
-
});
|
|
2422
|
-
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: {
|
|
2423
|
-
extension,
|
|
2424
|
-
type,
|
|
2425
|
-
kind: descriptor.kind
|
|
2426
|
-
} });
|
|
2427
|
-
}
|
|
2428
|
-
/** Throws a structured CONFIG.* error on the first uncovered `(extension, type)`; silent when the config covers the whole graph. */
|
|
2429
|
-
function validateRegistryCoverage(graph, config) {
|
|
2430
|
-
const extensions = new Map(config.extensions.map((descriptor) => [descriptor.id, descriptor]));
|
|
2431
|
-
for (const { id, node } of graph.nodes) {
|
|
2432
|
-
if (node.kind === "resource") {
|
|
2433
|
-
lookup(extensions, node.extension, node.type, "resource", `resource node "${id}"`);
|
|
2434
|
-
continue;
|
|
2435
|
-
}
|
|
2436
|
-
if (node.kind !== "service") continue;
|
|
2437
|
-
lookup(extensions, node.extension, node.type, "service", `service node "${id}"`);
|
|
2438
|
-
lookup(extensions, node.build.extension, node.build.type, "build", `service node "${id}"'s build descriptor`);
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
/**
|
|
2442
|
-
* The shared prefix of `deploy`/`destroy`/`dev` (deploy-cli.md § The
|
|
2443
|
-
* pipeline; local-dev spec § 6): entry load, Load,
|
|
2444
|
-
* registry coverage validation, name resolution, assemble. Deploy and dev
|
|
2445
|
-
* diverge after this — deploy resolves containers/preflight/stack file
|
|
2446
|
-
* against the hosted providers, dev against the local ones — so everything
|
|
2447
|
-
* up to and including assemble lives here once, consumed verbatim by both
|
|
2448
|
-
* `run()` (main.ts) and `runDev()` (dev/run-dev.ts), so the two pipelines
|
|
2449
|
-
* cannot drift.
|
|
2450
|
-
*/
|
|
2451
|
-
const NO_SECRETS = Object.freeze({});
|
|
2452
|
-
function configError(findings, file) {
|
|
2453
|
-
const [first] = findings;
|
|
2454
|
-
return new CliStructuredError(first.code, first.summary, {
|
|
2455
|
-
...first.why === void 0 ? {} : { why: first.why },
|
|
2456
|
-
fix: first.fix,
|
|
2457
|
-
where: { path: first.where ?? file },
|
|
2458
|
-
meta: {
|
|
2459
|
-
...first.field === void 0 ? {} : { field: first.field },
|
|
2460
|
-
findings
|
|
2461
|
-
}
|
|
2462
|
-
});
|
|
2463
|
-
}
|
|
2464
|
-
/**
|
|
2465
|
-
* Refuses a caller's config with the same findings, in the same order, as the CLI's section validator.
|
|
2466
|
-
* The error is the first finding and carries all of them in `meta.findings`. Returns the config with `file` resolved against `cwd`.
|
|
2467
|
-
*/
|
|
2468
|
-
function checkConfigSource(source, cwd) {
|
|
2469
|
-
const file = path.resolve(cwd, source.file);
|
|
2470
|
-
if (!fs.existsSync(file)) throw configError([configFileMissing(file)], file);
|
|
2471
|
-
const checked = checkComposerConfig(source.value, file);
|
|
2472
|
-
if (!checked.ok) throw configError(checked.findings, file);
|
|
2473
|
-
return {
|
|
2474
|
-
value: checked.value,
|
|
2475
|
-
file
|
|
2476
|
-
};
|
|
2477
|
-
}
|
|
2478
|
-
/**
|
|
2479
|
-
* Resolves the entry module. An override (`--entry`, or an operation's `entry` input) resolves
|
|
2480
|
-
* against `cwd`; the section's `entry` resolves against the directory of the file that declares it,
|
|
2481
|
-
* as the CLI engine resolves path fields in prisma.config.ts.
|
|
2482
|
-
*/
|
|
2483
|
-
function resolveEntryPath(override, source, cwd) {
|
|
2484
|
-
if (override !== void 0) return {
|
|
2485
|
-
path: path.resolve(cwd, override),
|
|
2486
|
-
fix: `Check the \`--entry\` path (the \`entry\` input when calling @prisma/composer/control) "${override}". It is relative to the current directory, ${cwd}.`
|
|
2487
|
-
};
|
|
2488
|
-
const configured = source.value.entry;
|
|
2489
|
-
if (configured === void 0) throw configError([entryMissing], source.file);
|
|
2490
|
-
return {
|
|
2491
|
-
path: path.resolve(path.dirname(source.file), configured),
|
|
2492
|
-
fix: `Check \`entry: "${configured}"\` in ${source.file}. It is relative to that file's directory.`
|
|
2493
|
-
};
|
|
2494
|
-
}
|
|
2495
|
-
/**
|
|
2496
|
-
* The pipeline's front — entry load and name resolution —
|
|
2497
|
-
* WITHOUT Load, coverage, or assemble. `log` needs only who the app is (its
|
|
2498
|
-
* config and resolved name) to reach the already-running local instance; it
|
|
2499
|
-
* neither builds nor provisions, so it must not require the user's built
|
|
2500
|
-
* output the way the full pipeline does.
|
|
2501
|
-
*/
|
|
2502
|
-
async function resolveAppIdentity(entry, overrideName, cwd, config) {
|
|
2503
|
-
const checked = checkConfigSource(config, cwd);
|
|
2504
|
-
const { value } = checked;
|
|
2505
|
-
const resolved = resolveEntryPath(entry, checked, cwd);
|
|
2506
|
-
const entryModule = await loadEntry(resolved.path, cwd, resolved.fix);
|
|
2507
|
-
const name = overrideName ?? entryModule.root.name;
|
|
2508
|
-
if (name.length === 0) throw new CliStructuredError("COMPOSE.NAME_MISSING", "The root node has no name.", { fix: "Name it at authoring, or pass --name." });
|
|
2509
|
-
assertAppName(name);
|
|
2510
|
-
return {
|
|
2511
|
-
config: value,
|
|
2512
|
-
name
|
|
2513
|
-
};
|
|
2514
|
-
}
|
|
1712
|
+
//#endregion
|
|
1713
|
+
//#region ../../0-framework/1-core/core/dist/deploy.mjs
|
|
2515
1714
|
/**
|
|
2516
|
-
*
|
|
2517
|
-
*
|
|
2518
|
-
*
|
|
2519
|
-
*
|
|
1715
|
+
* Resource props as plain data that `structuredClone` copies unchanged, so two props compare by
|
|
1716
|
+
* content with `isDeepStrictEqual` even after one crossed a thread. Every object or array is
|
|
1717
|
+
* tagged by what it was, so no two different props give the same data:
|
|
1718
|
+
*
|
|
1719
|
+
* - a `Value` is described by what core knows of it: a source by its kind, pointer kind, label,
|
|
1720
|
+
* secrets key and payload; any other value only as derived, with the kind of its origin;
|
|
1721
|
+
* - a `Date`, `RegExp`, `Map` or `Set` keeps its content;
|
|
1722
|
+
* - an instance of another class keeps its class name and own enumerable fields;
|
|
1723
|
+
* - a function or symbol becomes its text;
|
|
1724
|
+
* - a reference back to an object that contains it becomes a cycle marker.
|
|
2520
1725
|
*/
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
if (
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
environment,
|
|
2531
|
-
configFile: configSource.file
|
|
2532
|
-
};
|
|
2533
|
-
const secrets = deps.readSecrets === true ? await readAppSecrets(config, adapterInput) : NO_SECRETS;
|
|
2534
|
-
const configuration = await readAppConfiguration(config, adapterInput);
|
|
2535
|
-
redaction.addCredentialLookingValues(credentialLookingValues(configuration));
|
|
2536
|
-
const graph = Load(entryModule.root, {
|
|
2537
|
-
id: name,
|
|
2538
|
-
environment: { name: environment },
|
|
2539
|
-
configuration
|
|
2540
|
-
});
|
|
2541
|
-
redaction.addKnownSecrets(valuesUnderSecretsKeys(configuration, secrets, secretsKeys(graph)));
|
|
2542
|
-
checkGraph(graph, config.extensions);
|
|
2543
|
-
validateRegistryCoverage(graph, config);
|
|
2544
|
-
deps.onEvent?.({ kind: "loaded" });
|
|
2545
|
-
let assembled;
|
|
1726
|
+
function comparableProps(props) {
|
|
1727
|
+
return asData(props, /* @__PURE__ */ new Set());
|
|
1728
|
+
}
|
|
1729
|
+
function asData(value, containing) {
|
|
1730
|
+
if (typeof value === "function") return { function: String(value) };
|
|
1731
|
+
if (typeof value === "symbol") return { symbol: String(value) };
|
|
1732
|
+
if (typeof value !== "object" || value === null) return value;
|
|
1733
|
+
if (containing.has(value)) return { cycle: true };
|
|
1734
|
+
containing.add(value);
|
|
2546
1735
|
try {
|
|
2547
|
-
|
|
2548
|
-
}
|
|
2549
|
-
|
|
2550
|
-
throw error;
|
|
1736
|
+
return objectAsData(value, (inner) => asData(inner, containing));
|
|
1737
|
+
} finally {
|
|
1738
|
+
containing.delete(value);
|
|
2551
1739
|
}
|
|
1740
|
+
}
|
|
1741
|
+
function objectAsData(value, inner) {
|
|
1742
|
+
if (isValue(value)) {
|
|
1743
|
+
const origin = originOf(value);
|
|
1744
|
+
if (origin.kind !== "source") return { value: { derived: origin.kind } };
|
|
1745
|
+
return { value: {
|
|
1746
|
+
sourceKind: origin.sourceKind,
|
|
1747
|
+
pointer: Reflect.get(value, POINTER),
|
|
1748
|
+
label: origin.label,
|
|
1749
|
+
secretsKey: origin.sourceKind === "secret" ? origin.secretsKey : void 0,
|
|
1750
|
+
payload: inner(Reflect.get(value, "payload"))
|
|
1751
|
+
} };
|
|
1752
|
+
}
|
|
1753
|
+
if (Array.isArray(value)) return { array: value.map(inner) };
|
|
1754
|
+
if (value instanceof Date) return { date: value.getTime() };
|
|
1755
|
+
if (value instanceof RegExp) return { regexp: String(value) };
|
|
1756
|
+
if (value instanceof Map) return { map: [...value].map(([key, entry]) => [inner(key), inner(entry)]) };
|
|
1757
|
+
if (value instanceof Set) return { set: [...value].map(inner) };
|
|
1758
|
+
const fields = Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, inner(entry)]));
|
|
1759
|
+
if (isPlainObject(value)) return { object: fields };
|
|
2552
1760
|
return {
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
graph,
|
|
2556
|
-
name,
|
|
2557
|
-
assembled,
|
|
2558
|
-
configuration,
|
|
2559
|
-
secrets
|
|
1761
|
+
instance: value.constructor?.name,
|
|
1762
|
+
fields
|
|
2560
1763
|
};
|
|
2561
1764
|
}
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
}
|
|
2570
|
-
/** Letters, digits, `-` and `_`, starting with a letter or digit: always a valid git ref, so no `git` is needed to check it. */
|
|
2571
|
-
const PLAIN_ENVIRONMENT_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
2572
|
-
/** 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. */
|
|
2573
|
-
function validateEnvironmentName(environment, spawn = spawnSync) {
|
|
2574
|
-
if (PLAIN_ENVIRONMENT_NAME.test(environment)) return;
|
|
2575
|
-
const result = spawn("git", ["check-ref-format", `refs/heads/${environment}`], { stdio: "ignore" });
|
|
2576
|
-
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 });
|
|
2577
|
-
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}").`);
|
|
1765
|
+
/** The `name` of the error `lower()` fails with when it builds a graph whose node addresses differ from `firstProcessNodeAddresses`. */
|
|
1766
|
+
const GRAPH_CHANGED_ERROR = "GraphChangedError";
|
|
1767
|
+
const PROVIDER_FAILURE_TAG = "ProviderFailure";
|
|
1768
|
+
Data.TaggedError(PROVIDER_FAILURE_TAG);
|
|
1769
|
+
/** The original error of a provider failure `toProviderError` wrapped, or `undefined` for any other error. */
|
|
1770
|
+
function wrappedProviderError(error) {
|
|
1771
|
+
return Predicate.isTagged(error, PROVIDER_FAILURE_TAG) && "cause" in error ? error.cause : void 0;
|
|
2578
1772
|
}
|
|
2579
1773
|
//#endregion
|
|
2580
|
-
export {
|
|
1774
|
+
export { loadEntry as a, GraphCheckError as c, assertAppName as d, nodeAddresses as f, appFilesNamedBy as i, Load as l, describeKind as m, comparableProps as n, namesDirectoryWithIndex as o, secretsKeys as p, wrappedProviderError as r, registerEntryResolution as s, GRAPH_CHANGED_ERROR as t, ROOT_INPUT_UNREAD_ERROR as u };
|
|
2581
1775
|
|
|
2582
|
-
//# sourceMappingURL=
|
|
1776
|
+
//# sourceMappingURL=deploy-Br1yvLe3.mjs.map
|