@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 @@
|
|
|
1
|
+
{"version":3,"file":"redaction-DY6eDC12-BrK1aSN5.mjs","names":["#names"],"sources":["../../../0-framework/3-tooling/cli/dist/redaction-DY6eDC12.mjs"],"sourcesContent":["import { CliStructuredError } from \"@internal/foundation/errors\";\nimport { inspect } from \"node:util\";\n//#region src/redaction.ts\nconst REDACTED = \"[redacted]\";\n/** Env var names whose values are credentials: the service token, preflight payloads, and the usual secret spellings. */\nconst SECRET_ENV_NAME = /TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|AUTH|API_?KEY|ACCESS_?KEY|_KEY$|DATABASE_URL|_DSN$|^PRISMA_COMPOSER_PREFLIGHT_/i;\n/**\n* The credential-looking values in `variables`: text of eight characters or more under a name\n* that looks like a credential's. The length limit keeps a one-letter placeholder from blanking\n* every matching letter.\n*/\nfunction credentialLookingValues(variables) {\n\treturn Object.entries(variables).flatMap(([name, value]) => SECRET_ENV_NAME.test(name) && typeof value === \"string\" && value.length >= 8 ? [value] : []);\n}\n/** `value` as it appears inside a string that `JSON.stringify` or `util.inspect` printed, where a newline, quote or backslash is escaped. */\nfunction escapedForms(value) {\n\treturn [\n\t\tvalue,\n\t\tJSON.stringify(value).slice(1, -1),\n\t\tinspect(value).slice(1, -1)\n\t];\n}\n/**\n* Finds every secret in a text, as written or as `JSON.stringify` and `util.format` escape it:\n* one regular expression for all of them, built once. A match is the span of the longest\n* secret that starts at a position, and spans that overlap are merged, so two overlapping\n* secrets are hidden whole.\n*/\nvar SecretMatcher = class {\n\tstarts;\n\tprefixes = /* @__PURE__ */ new Set();\n\tlongestPrefix;\n\tconstructor(values) {\n\t\tconst sorted = [...new Set([...values].flatMap(escapedForms))].filter((value) => value.length > 0).sort((a, b) => b.length - a.length);\n\t\tthis.starts = sorted.length === 0 ? void 0 : new RegExp(`(?=(${sorted.map((value) => value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")).join(\"|\")}))`, \"g\");\n\t\tfor (const value of sorted) for (let length = 1; length < value.length; length++) this.prefixes.add(value.slice(0, length));\n\t\tthis.longestPrefix = Math.max(0, (sorted[0]?.length ?? 0) - 1);\n\t}\n\t/** The merged spans of every secret in `text`, in order, as `[start, end)`. */\n\tspans(text) {\n\t\tconst spans = [];\n\t\tif (this.starts === void 0) return spans;\n\t\tfor (const match of text.matchAll(this.starts)) {\n\t\t\tconst start = match.index;\n\t\t\tconst end = start + (match[1]?.length ?? 0);\n\t\t\tconst last = spans.at(-1);\n\t\t\tif (last !== void 0 && start < last[1]) last[1] = Math.max(last[1], end);\n\t\t\telse spans.push([start, end]);\n\t\t}\n\t\treturn spans;\n\t}\n\t/** The length of the longest end of `text` that is the start, not the whole, of a secret. */\n\tstartOfSecretAtEnd(text) {\n\t\tfor (let length = Math.min(this.longestPrefix, text.length); length > 0; length--) if (this.prefixes.has(text.slice(text.length - length))) return length;\n\t\treturn 0;\n\t}\n\t/** `text` with each span replaced by `[redacted]`. */\n\tredact(text) {\n\t\tlet out = \"\";\n\t\tlet from = 0;\n\t\tfor (const [start, end] of this.spans(text)) {\n\t\t\tout += text.slice(from, start) + REDACTED;\n\t\t\tfrom = end;\n\t\t}\n\t\treturn from === 0 ? text : out + text.slice(from);\n\t}\n};\n/** `text` with each value in `values` replaced by `[redacted]`, at any length; an empty one is skipped. Overlapping values are hidden whole. */\nfunction redactValues(text, values) {\n\treturn new SecretMatcher(values).redact(text);\n}\n/** `text` with bearer and basic tokens, JWTs, the password in a URL, and `token=…`-style pairs replaced by `[redacted]`. The `<value>` placeholder in a printed command is kept. */\nfunction redactShapes(text) {\n\treturn text.replace(/\\b(Bearer|Basic)\\s+[\\w.~+/=-]+/gi, `$1 ${REDACTED}`).replace(/\\beyJ[\\w-]+\\.[\\w-]+\\.[\\w-]*/g, REDACTED).replace(/(\\b[a-z][\\w+.-]*:\\/\\/[^\\s:/@]*:)[^\\s/@]+@/gi, `$1${REDACTED}@`).replace(/\\b((?:[\\w-]*[_-])?(?:token|secret|password|passwd|api[_-]?key|access[_-]?key|private[_-]?key)[\"']?\\s*[:=]\\s*[\"']?)(?!<value>(?:[\\s\"',;&]|$))[^\\s\"',;&]+/gi, `$1${REDACTED}`);\n}\n/**\n* `text` with the credential-looking values of `env` and the credential shapes replaced by\n* `[redacted]`. For a process that has no `SecretRedaction`; `SecretRedaction.redact` hides\n* the known secrets too.\n*/\nfunction redactCredentialLooking(text, env) {\n\treturn redactShapes(redactValues(text, credentialLookingValues(env)));\n}\n/**\n* The known secrets of one command: the values under the secrets keys the graph names, in the app\n* secrets and the app configuration (ADR-0062). The app configuration file must not hold any of them.\n*/\nvar KnownSecrets = class {\n\t#names = /* @__PURE__ */ new Map();\n\tconstructor(secrets = []) {\n\t\tthis.add(secrets);\n\t}\n\t/** Adds each secret whose value is not empty. A value already known keeps its first name. */\n\tadd(secrets) {\n\t\tfor (const { name, value } of secrets) if (value.length > 0 && !this.#names.has(value)) this.#names.set(value, name);\n\t}\n\tvalues() {\n\t\treturn new Set(this.#names.keys());\n\t}\n\t/**\n\t* The name of a known secret `text` holds, or undefined. A secret of\n\t* `MIN_SECRET_LENGTH_INSIDE_A_VALUE` characters or more is found anywhere in `text`; a shorter\n\t* one only when it is all of `text`.\n\t*/\n\tnameIn(text) {\n\t\tfor (const [value, name] of this.#names) if (value.length >= 8 ? text.includes(value) : text === value) return name;\n\t}\n};\n/**\n* What one command hides from everything it prints, returns or reports (ADR-0062): its known\n* secrets, and the credential-looking values, which only look like secrets by the name of the\n* variable they are under. It starts with the credential-looking values of the process\n* environment.\n*/\nvar SecretRedaction = class {\n\tknownSecrets = new KnownSecrets();\n\tcredentialLooking = /* @__PURE__ */ new Set();\n\tmatcher;\n\tconstructor(env) {\n\t\tthis.addCredentialLookingValues(credentialLookingValues(env));\n\t}\n\taddKnownSecrets(secrets) {\n\t\tthis.knownSecrets.add(secrets);\n\t}\n\taddCredentialLookingValues(values) {\n\t\tfor (const value of values) if (value.length > 0) this.credentialLooking.add(value);\n\t}\n\t/** The known secrets and the credential-looking values, longest first. */\n\tallValues() {\n\t\treturn [.../* @__PURE__ */ new Set([...this.knownSecrets.values(), ...this.credentialLooking])].sort((a, b) => b.length - a.length);\n\t}\n\t/** `text` with every known secret and credential-looking value replaced by `[redacted]` at any length, then bearer tokens, JWTs, URL passwords and `token=…` pairs. */\n\tredact(text) {\n\t\tconst size = this.knownSecrets.values().size + this.credentialLooking.size;\n\t\tif (this.matcher?.size !== size) this.matcher = {\n\t\t\tsize,\n\t\t\tmatcher: new SecretMatcher(this.allValues())\n\t\t};\n\t\treturn redactShapes(this.matcher.matcher.redact(text));\n\t}\n};\n/** The text under each name in `secretsKeys`, in the app configuration and in the app secrets, at any length. */\nfunction valuesUnderSecretsKeys(configuration, secrets, secretsKeys) {\n\treturn secretsKeys.flatMap((name) => [configuration[name], secrets[name]].flatMap((value) => typeof value === \"string\" ? [{\n\t\tname,\n\t\tvalue\n\t}] : []));\n}\nfunction redactReader(reader, redaction) {\n\tswitch (reader.kind) {\n\t\tcase \"field\": return {\n\t\t\tkind: \"field\",\n\t\t\tservice: redaction.redact(reader.service),\n\t\t\tpath: redaction.redact(reader.path)\n\t\t};\n\t\tcase \"unread\": return {\n\t\t\tkind: \"unread\",\n\t\t\tnode: redaction.redact(reader.node)\n\t\t};\n\t}\n}\n/** `variable` with every text in it redacted: its name, each reader's names and each command. */\nfunction redactUnsetPlatformVariable(variable, redaction) {\n\treturn {\n\t\tname: redaction.redact(variable.name),\n\t\treaders: variable.readers.map((reader) => redactReader(reader, redaction)),\n\t\tcommands: variable.commands.map((command) => redaction.redact(command))\n\t};\n}\nfunction redactData(value, redaction) {\n\tif (typeof value === \"string\") return redaction.redact(value);\n\tif (Array.isArray(value)) return value.map((member) => redactData(member, redaction));\n\tif (typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype) return Object.fromEntries(Object.entries(value).map(([key, member]) => [key, redactData(member, redaction)]));\n\treturn value;\n}\n/**\n* `error` with every value `redaction` hides removed from its summary, `why`, `fix` and every string in\n* its `meta`. The code, severity, `where` and docs link are kept. The cause is dropped, because\n* it holds the same text unredacted and a renderer may print it.\n*/\nfunction redactError(error, redaction) {\n\treturn new CliStructuredError(error.code, redaction.redact(error.message), {\n\t\tseverity: error.severity,\n\t\t...error.why === void 0 ? {} : { why: redaction.redact(error.why) },\n\t\t...error.fix === void 0 ? {} : { fix: redaction.redact(error.fix) },\n\t\t...error.where === void 0 ? {} : { where: error.where },\n\t\t...error.meta === void 0 ? {} : { meta: Object.fromEntries(Object.entries(error.meta).map(([key, value]) => [key, redactData(value, redaction)])) },\n\t\t...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl }\n\t});\n}\nfunction setOwn(error, name, value) {\n\tObject.defineProperty(error, name, {\n\t\tvalue,\n\t\twritable: true,\n\t\tconfigurable: true\n\t});\n}\nconst UNPRINTABLE = \"A value was thrown that cannot be turned into text.\";\nfunction safeString(value) {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\ttry {\n\t\t\treturn Object.prototype.toString.call(value);\n\t\t} catch {\n\t\t\treturn UNPRINTABLE;\n\t\t}\n\t}\n}\n/**\n* The error to rethrow in place of a thrown defect, with every secret removed from its message\n* and stack, and from those of each error in its `cause` chain and in an `AggregateError`'s\n* `errors`. A cause that is text or plain data becomes a redacted copy. Each error is redacted\n* in place where it can be. One whose properties cannot change, such as a frozen error, is\n* replaced by a new error with the redacted message, stack and cause. A thrown value that is not\n* an `Error` becomes an `Error` whose message is its redacted text. Never throws: when reading\n* the error fails, the result is a new `Error` holding the redacted text of what was thrown.\n*/\nfunction redactThrown(thrown, redaction) {\n\ttry {\n\t\treturn thrown instanceof Error ? redactErrorChain(thrown, redaction, /* @__PURE__ */ new Map()) : new Error(redaction.redact(safeString(thrown)));\n\t} catch {\n\t\treturn new Error(redaction.redact(safeString(thrown)));\n\t}\n}\nfunction redactErrorChain(error, redaction, seen) {\n\tconst done = seen.get(error);\n\tif (done !== void 0) return done;\n\tseen.set(error, error);\n\tconst message = redaction.redact(typeof error.message === \"string\" ? error.message : safeString(error.message));\n\tconst stack = typeof error.stack === \"string\" ? redaction.redact(error.stack) : void 0;\n\tconst cause = error.cause instanceof Error ? redactErrorChain(error.cause, redaction, seen) : redactData(error.cause, redaction);\n\tconst members = error instanceof AggregateError ? error.errors.map((member) => member instanceof Error ? redactErrorChain(member, redaction, seen) : redactData(member, redaction)) : void 0;\n\ttry {\n\t\tsetOwn(error, \"message\", message);\n\t\tif (stack !== void 0) setOwn(error, \"stack\", stack);\n\t\tif (error.cause !== void 0) setOwn(error, \"cause\", cause);\n\t\tif (members !== void 0) setOwn(error, \"errors\", members);\n\t\treturn error;\n\t} catch {\n\t\tconst options = cause === void 0 ? void 0 : { cause };\n\t\tconst copy = members === void 0 ? new Error(message, options) : new AggregateError(members, message, options);\n\t\tcopy.name = error.name;\n\t\tsetOwn(copy, \"stack\", stack ?? `${error.name}: ${message}`);\n\t\tseen.set(error, copy);\n\t\treturn copy;\n\t}\n}\n/** `event` with every value `redaction` hides removed from the text it carries: a message, an Alchemy log line, a converge failure's reasons, or a dev server's output line. */\nfunction redactDevEvent(event, redaction) {\n\tswitch (event.kind) {\n\t\tcase \"target-warning\":\n\t\tcase \"rebuild-failed\":\n\t\tcase \"watch-error\":\n\t\tcase \"stop-error\": return {\n\t\t\t...event,\n\t\t\tmessage: redaction.redact(event.message)\n\t\t};\n\t\tcase \"message\": return {\n\t\t\t...event,\n\t\t\ttext: redaction.redact(event.text)\n\t\t};\n\t\tcase \"converge-failed\": return {\n\t\t\t...event,\n\t\t\tmessage: redaction.redact(event.message),\n\t\t\treasons: event.reasons.map(({ tag, message }) => ({\n\t\t\t\ttag,\n\t\t\t\tmessage: redaction.redact(message)\n\t\t\t}))\n\t\t};\n\t\tcase \"dev-server-output\": return {\n\t\t\t...event,\n\t\t\tline: redaction.redact(event.line)\n\t\t};\n\t\tdefault: return event;\n\t}\n}\n/** `summary` with every value `redaction` hides removed from each entity's id, url and details. */\nfunction redactSummary(summary, redaction) {\n\tif (summary === void 0) return void 0;\n\treturn {\n\t\tapp: summary.app,\n\t\tfindings: { unset: summary.findings.unset.map((variable) => redactUnsetPlatformVariable(variable, redaction)) },\n\t\tnodes: summary.nodes.map((node) => ({\n\t\t\taddress: node.address,\n\t\t\tentities: node.entities.map((entity) => ({\n\t\t\t\t...entity,\n\t\t\t\tid: redaction.redact(entity.id),\n\t\t\t\t...entity.url === void 0 ? {} : { url: redaction.redact(entity.url) },\n\t\t\t\t...entity.details === void 0 ? {} : { details: Object.fromEntries(Object.entries(entity.details).map(([key, value]) => [key, redaction.redact(value)])) }\n\t\t\t}))\n\t\t}))\n\t};\n}\nfunction isHighSurrogate(code) {\n\treturn code >= 55296 && code <= 56319;\n}\n/**\n* Redacts a stream of text chunk by chunk: every value in `values` becomes `[redacted]`, and\n* overlapping values are hidden whole. It holds back only the end of the text that could still\n* be part of a value: the longest end that could start one, or a match that a later value could\n* extend. So a value split across two chunks is still replaced, and text that cannot start one,\n* such as a prompt, is returned at once. It never splits a surrogate pair. `push` returns the\n* text that is ready; `end` returns the rest.\n*/\nvar StreamRedactor = class {\n\theld = \"\";\n\tmatcher;\n\tconstructor(values) {\n\t\tthis.matcher = new SecretMatcher(values);\n\t}\n\tpush(chunk) {\n\t\tconst text = this.held + chunk;\n\t\tconst cut = text.length - this.matcher.startOfSecretAtEnd(text);\n\t\tlet out = \"\";\n\t\tlet from = 0;\n\t\tlet ready = cut;\n\t\tfor (const [start, end] of this.matcher.spans(text)) {\n\t\t\tif (end > cut) {\n\t\t\t\tready = Math.min(cut, start);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout += text.slice(from, start) + REDACTED;\n\t\t\tfrom = end;\n\t\t}\n\t\tif (ready > from && ready < text.length && isHighSurrogate(text.charCodeAt(ready - 1))) ready -= 1;\n\t\tthis.held = text.slice(ready);\n\t\treturn out + text.slice(from, ready);\n\t}\n\tend() {\n\t\tconst text = this.held;\n\t\tthis.held = \"\";\n\t\treturn this.matcher.redact(text);\n\t}\n};\n//#endregion\nexport { redactDevEvent as a, redactThrown as c, redactCredentialLooking as i, redactUnsetPlatformVariable as l, StreamRedactor as n, redactError as o, credentialLookingValues as r, redactSummary as s, SecretRedaction as t, valuesUnderSecretsKeys as u };\n\n//# sourceMappingURL=redaction-DY6eDC12.mjs.map"],"mappings":";;;AAGA,MAAM,WAAW;;AA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AAO,KAAK,QAAQ,OAAO,IAAI;CAChC;AACD"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { n as blindCast, t as InternalError } from "./internal-error-Dfur7Zqt-B8J8e7ac.mjs";
|
|
2
|
+
//#region ../../0-framework/0-foundation/foundation/dist/result.mjs
|
|
3
|
+
/**
|
|
4
|
+
* Generic Result type for representing success or failure outcomes.
|
|
5
|
+
*
|
|
6
|
+
* This is the standard way to return "expected failures" as values rather than
|
|
7
|
+
* throwing exceptions. See docs/Error Handling.md for the full taxonomy.
|
|
8
|
+
*
|
|
9
|
+
* Naming rationale:
|
|
10
|
+
* - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator
|
|
11
|
+
* - `NotOk` avoids collision with domain types like "Failure" or "Error"
|
|
12
|
+
* - `failure` property distinguishes from JS Error semantics
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Result class that implements both Ok and NotOk variants.
|
|
16
|
+
*/
|
|
17
|
+
var ResultImpl = class ResultImpl {
|
|
18
|
+
ok;
|
|
19
|
+
_value;
|
|
20
|
+
_failure;
|
|
21
|
+
constructor(ok, valueOrFailure) {
|
|
22
|
+
this.ok = ok;
|
|
23
|
+
if (ok) this._value = blindCast(valueOrFailure);
|
|
24
|
+
else this._failure = blindCast(valueOrFailure);
|
|
25
|
+
Object.freeze(this);
|
|
26
|
+
}
|
|
27
|
+
get value() {
|
|
28
|
+
if (!this.ok) throw new InternalError("Cannot access value on NotOk result");
|
|
29
|
+
return this._value;
|
|
30
|
+
}
|
|
31
|
+
get failure() {
|
|
32
|
+
if (this.ok) throw new InternalError("Cannot access failure on Ok result");
|
|
33
|
+
return this._failure;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a successful result.
|
|
37
|
+
*/
|
|
38
|
+
static ok(value) {
|
|
39
|
+
return blindCast(new ResultImpl(true, value));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates an unsuccessful result.
|
|
43
|
+
*/
|
|
44
|
+
static notOk(failure) {
|
|
45
|
+
return blindCast(new ResultImpl(false, failure));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Asserts that this result is Ok and returns the value.
|
|
49
|
+
* Throws if the result is NotOk.
|
|
50
|
+
*/
|
|
51
|
+
assertOk() {
|
|
52
|
+
if (!this.ok) throw new InternalError("Expected Ok result but got NotOk");
|
|
53
|
+
return this.value;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Asserts that this result is NotOk and returns the failure.
|
|
57
|
+
* Throws if the result is Ok.
|
|
58
|
+
*/
|
|
59
|
+
assertNotOk() {
|
|
60
|
+
if (this.ok) throw new InternalError("Expected NotOk result but got Ok");
|
|
61
|
+
return this.failure;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Creates a successful result.
|
|
66
|
+
*/
|
|
67
|
+
function ok(value) {
|
|
68
|
+
return ResultImpl.ok(value);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates an unsuccessful result.
|
|
72
|
+
*/
|
|
73
|
+
function notOk(failure) {
|
|
74
|
+
return ResultImpl.notOk(failure);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Singleton for void success results.
|
|
78
|
+
* Use this for validation checks that don't produce a value.
|
|
79
|
+
*/
|
|
80
|
+
const OK_VOID = ResultImpl.ok(void 0);
|
|
81
|
+
/**
|
|
82
|
+
* Returns a successful void result.
|
|
83
|
+
* Use this for validation checks that don't produce a value.
|
|
84
|
+
*/
|
|
85
|
+
function okVoid() {
|
|
86
|
+
return OK_VOID;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { ok as n, okVoid as r, notOk as t };
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=result-CttmabB6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-CttmabB6.mjs","names":[],"sources":["../../../0-framework/0-foundation/foundation/dist/result.mjs"],"sourcesContent":["import { t as blindCast } from \"./casts-DpaahrlC.mjs\";\nimport { t as InternalError } from \"./internal-error-Dfur7Zqt.mjs\";\n//#region src/result.ts\n/**\n* Generic Result type for representing success or failure outcomes.\n*\n* This is the standard way to return \"expected failures\" as values rather than\n* throwing exceptions. See docs/Error Handling.md for the full taxonomy.\n*\n* Naming rationale:\n* - `Ok<T>` / `NotOk<F>` mirror the `ok: true/false` discriminator\n* - `NotOk` avoids collision with domain types like \"Failure\" or \"Error\"\n* - `failure` property distinguishes from JS Error semantics\n*/\n/**\n* Result class that implements both Ok and NotOk variants.\n*/\nvar ResultImpl = class ResultImpl {\n\tok;\n\t_value;\n\t_failure;\n\tconstructor(ok, valueOrFailure) {\n\t\tthis.ok = ok;\n\t\tif (ok) this._value = blindCast(valueOrFailure);\n\t\telse this._failure = blindCast(valueOrFailure);\n\t\tObject.freeze(this);\n\t}\n\tget value() {\n\t\tif (!this.ok) throw new InternalError(\"Cannot access value on NotOk result\");\n\t\treturn this._value;\n\t}\n\tget failure() {\n\t\tif (this.ok) throw new InternalError(\"Cannot access failure on Ok result\");\n\t\treturn this._failure;\n\t}\n\t/**\n\t* Creates a successful result.\n\t*/\n\tstatic ok(value) {\n\t\treturn blindCast(new ResultImpl(true, value));\n\t}\n\t/**\n\t* Creates an unsuccessful result.\n\t*/\n\tstatic notOk(failure) {\n\t\treturn blindCast(new ResultImpl(false, failure));\n\t}\n\t/**\n\t* Asserts that this result is Ok and returns the value.\n\t* Throws if the result is NotOk.\n\t*/\n\tassertOk() {\n\t\tif (!this.ok) throw new InternalError(\"Expected Ok result but got NotOk\");\n\t\treturn this.value;\n\t}\n\t/**\n\t* Asserts that this result is NotOk and returns the failure.\n\t* Throws if the result is Ok.\n\t*/\n\tassertNotOk() {\n\t\tif (this.ok) throw new InternalError(\"Expected NotOk result but got Ok\");\n\t\treturn this.failure;\n\t}\n};\n/**\n* Creates a successful result.\n*/\nfunction ok(value) {\n\treturn ResultImpl.ok(value);\n}\n/**\n* Creates an unsuccessful result.\n*/\nfunction notOk(failure) {\n\treturn ResultImpl.notOk(failure);\n}\n/**\n* Singleton for void success results.\n* Use this for validation checks that don't produce a value.\n*/\nconst OK_VOID = ResultImpl.ok(void 0);\n/**\n* Returns a successful void result.\n* Use this for validation checks that don't produce a value.\n*/\nfunction okVoid() {\n\treturn OK_VOID;\n}\n//#endregion\nexport { notOk, ok, okVoid };\n\n//# sourceMappingURL=result.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAI,aAAa,MAAM,WAAW;CACjC;CACA;CACA;CACA,YAAY,IAAI,gBAAgB;EAC/B,KAAK,KAAK;EACV,IAAI,IAAI,KAAK,SAAS,UAAU,cAAc;OACzC,KAAK,WAAW,UAAU,cAAc;EAC7C,OAAO,OAAO,IAAI;CACnB;CACA,IAAI,QAAQ;EACX,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,cAAc,qCAAqC;EAC3E,OAAO,KAAK;CACb;CACA,IAAI,UAAU;EACb,IAAI,KAAK,IAAI,MAAM,IAAI,cAAc,oCAAoC;EACzE,OAAO,KAAK;CACb;;;;CAIA,OAAO,GAAG,OAAO;EAChB,OAAO,UAAU,IAAI,WAAW,MAAM,KAAK,CAAC;CAC7C;;;;CAIA,OAAO,MAAM,SAAS;EACrB,OAAO,UAAU,IAAI,WAAW,OAAO,OAAO,CAAC;CAChD;;;;;CAKA,WAAW;EACV,IAAI,CAAC,KAAK,IAAI,MAAM,IAAI,cAAc,kCAAkC;EACxE,OAAO,KAAK;CACb;;;;;CAKA,cAAc;EACb,IAAI,KAAK,IAAI,MAAM,IAAI,cAAc,kCAAkC;EACvE,OAAO,KAAK;CACb;AACD;;;;AAIA,SAAS,GAAG,OAAO;CAClB,OAAO,WAAW,GAAG,KAAK;AAC3B;;;;AAIA,SAAS,MAAM,SAAS;CACvB,OAAO,WAAW,MAAM,OAAO;AAChC;;;;;AAKA,MAAM,UAAU,WAAW,GAAG,KAAK,CAAC;;;;;AAKpC,SAAS,SAAS;CACjB,OAAO;AACR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
25
|
+
//#endregion
|
|
26
|
+
export { __require as n, __toESM as r, __commonJSMin as t };
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { t as CliStructuredError } from "./errors-CVYwN2km.mjs";
|
|
2
|
+
import { n as StreamRedactor } from "./redaction-DY6eDC12-BrK1aSN5.mjs";
|
|
3
|
+
import { t as DEV_DIR } from "./app-config-CErnR6NK-DnKH4Kqc.mjs";
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import "node:util";
|
|
7
|
+
//#region ../../0-framework/3-tooling/cli/dist/deployment-summary-CVJZn2v0.mjs
|
|
8
|
+
/**
|
|
9
|
+
* The deploy result as data, and what a stack file run as a child hands back
|
|
10
|
+
* to the CLI: the summary file the report hook writes, and the failure cause
|
|
11
|
+
* the child records when it exits non-zero. `DeploymentResult` holds live
|
|
12
|
+
* graph nodes (ADR-0033), so the summary keeps only what can be serialized.
|
|
13
|
+
* Both files are best-effort: a write failure never fails the child.
|
|
14
|
+
*/
|
|
15
|
+
/** Env var the deploy operation sets on the alchemy child: when present,
|
|
16
|
+
* the report hook also writes the JSON DeploymentSummary there. */
|
|
17
|
+
const DEPLOYMENT_RESULT_FILE_ENV = "PRISMA_COMPOSER_DEPLOYMENT_RESULT_FILE";
|
|
18
|
+
/** Pure projection: keeps app, each node's address/entities and the findings, drops the in-process `node`. */
|
|
19
|
+
function toDeploymentSummary(result) {
|
|
20
|
+
return {
|
|
21
|
+
app: result.app,
|
|
22
|
+
nodes: result.nodes.map((node) => ({
|
|
23
|
+
address: node.address,
|
|
24
|
+
entities: node.entities
|
|
25
|
+
})),
|
|
26
|
+
findings: result.findings
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The child's failure cause rides beside the result file, so the one env var names both and the parent's cleanup removes both. */
|
|
30
|
+
function engineFailureFilePath(resultFilePath) {
|
|
31
|
+
return `${resultFilePath}.failure.txt`;
|
|
32
|
+
}
|
|
33
|
+
/** Fits the platform's 5000-character build `errorMessage` with room for the exit-status prefix. */
|
|
34
|
+
const ENGINE_FAILURE_CAUSE_LIMIT = 1e3;
|
|
35
|
+
/** Alchemy's advice to rerun its own CLI with `--adopt` or to import a resource with adoption, which a Composer user has no way to do. */
|
|
36
|
+
const ALCHEMY_ADOPT_ADVICE = [
|
|
37
|
+
[/Re-run with `--adopt` \(or wrap the effect in `adopt\(true\)`\) to take it over\./g, "Something other than this app holds it. Remove that resource, then deploy again."],
|
|
38
|
+
[/Re-run with `--adopt` \(or wrap the effect in `adopt\(true\)`\) to replace it anyway\./g, "Remove that resource, then deploy again."],
|
|
39
|
+
[/\(re-deploy with --adopt to take ownership, then destroy\)/g, "(remove it by hand)"],
|
|
40
|
+
[/Import it with explicit adoption (?:instead of silently taking it over|or choose a different [\w ]+ name)\./g, "Something other than this app holds it. Remove that resource, then deploy again."],
|
|
41
|
+
[/; rerun with adoption enabled if it is the intended [\w ]+\./g, ". Remove that resource, then deploy again."]
|
|
42
|
+
];
|
|
43
|
+
/** Replaces Alchemy CLI advice in engine output with steps that work from Composer. */
|
|
44
|
+
function withComposerAdvice(text) {
|
|
45
|
+
return ALCHEMY_ADOPT_ADVICE.reduce((current, [advice, replacement]) => current.replace(advice, replacement), text);
|
|
46
|
+
}
|
|
47
|
+
/** Parent half: the cause the child recorded, passed through `redact`, or undefined when it recorded none. The child redacts only what its own environment names as a credential; the parent also knows the known secrets. */
|
|
48
|
+
function readEngineFailureCause(resultFilePath, redact) {
|
|
49
|
+
let cause;
|
|
50
|
+
try {
|
|
51
|
+
cause = fs.readFileSync(engineFailureFilePath(resultFilePath), "utf8");
|
|
52
|
+
} catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
return cause.length > 0 ? redact(cause) : void 0;
|
|
56
|
+
}
|
|
57
|
+
/** A failure cause capped to fit the platform build's error message. */
|
|
58
|
+
function capFailureCause(cause) {
|
|
59
|
+
return cause.length <= ENGINE_FAILURE_CAUSE_LIMIT ? cause : `${cause.slice(0, ENGINE_FAILURE_CAUSE_LIMIT - 1)}…`;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ../../0-framework/3-tooling/cli/dist/app-configuration-file-D0rB5g65.mjs
|
|
63
|
+
function textIn(value, at) {
|
|
64
|
+
if (typeof value === "string") return [{
|
|
65
|
+
at,
|
|
66
|
+
text: value
|
|
67
|
+
}];
|
|
68
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return [{
|
|
69
|
+
at,
|
|
70
|
+
text: String(value)
|
|
71
|
+
}];
|
|
72
|
+
if (Array.isArray(value)) return value.flatMap((member, index) => textIn(member, [...at, String(index)]));
|
|
73
|
+
if (typeof value === "object" && value !== null) return Object.entries(value).flatMap(([key, member]) => textIn(member, [...at, key]));
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a root input field Load read holds a known secret. */
|
|
77
|
+
function refuseSecretsInRootInput(read, knownSecrets, consequence) {
|
|
78
|
+
const readPlaces = read.rootInput.flatMap((field) => textIn(field.value, field.path).map(({ at, text }) => ({
|
|
79
|
+
where: `Root input field input.${at.join(".")}`,
|
|
80
|
+
text
|
|
81
|
+
})));
|
|
82
|
+
for (const { where, text } of readPlaces) {
|
|
83
|
+
const name = knownSecrets.nameIn(text);
|
|
84
|
+
if (name === void 0) continue;
|
|
85
|
+
throw new CliStructuredError("CONFIG.SECRET_AS_PLAIN_VALUE", `${where} holds the value of the platform secret "${name}". ${consequence}`, { fix: `Pass the value of the platform secret "${name}" to where this value is used, or give this plain value text that does not contain the value of "${name}".` });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a plain platform variable's text holds a known secret. */
|
|
89
|
+
function refuseSecretsInPlainVariables(plainVariableText, knownSecrets, consequence) {
|
|
90
|
+
for (const [variable, text] of Object.entries(plainVariableText)) {
|
|
91
|
+
const name = knownSecrets.nameIn(text);
|
|
92
|
+
if (name === void 0) continue;
|
|
93
|
+
throw new CliStructuredError("CONFIG.SECRET_AS_PLAIN_VALUE", `The platform variable "${variable}", which prisma dev read from the \`config\` adapters, holds the value of the platform secret "${name}". ${consequence}`, { fix: `Keep the value of "${name}" out of the platform variable "${variable}", or give "${variable}" a different value.` });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Names the app configuration file the first process wrote for this run (ADR-0062). */
|
|
97
|
+
const APP_CONFIGURATION_FILE_ENV = "PRISMA_COMPOSER_APP_CONFIGURATION_FILE";
|
|
98
|
+
const FILE_NAME = /^app-configuration-(\d+)(-[^/]*)?\.json$/;
|
|
99
|
+
/** The app configuration file a destroy run writes: unique per run, so concurrent runs from one checkout never share one. */
|
|
100
|
+
function deployAppConfigurationFile(cwd, runId) {
|
|
101
|
+
return path.join(cwd, ".prisma-composer", `app-configuration-${String(process.pid)}-${runId}.json`);
|
|
102
|
+
}
|
|
103
|
+
function isRunning(pid) {
|
|
104
|
+
try {
|
|
105
|
+
process.kill(pid, 0);
|
|
106
|
+
return true;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return error instanceof Error && "code" in error && error.code === "EPERM";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Deletes the app configuration files that earlier runs left in `.prisma-composer/` and in
|
|
113
|
+
* each dev environment's folder: a run killed before its exit handler ran leaves its file. A
|
|
114
|
+
* file is deleted only when its process is not running and it is older than
|
|
115
|
+
* `LEFTOVER_APP_CONFIGURATION_FILE_AGE_MS`. Never throws.
|
|
116
|
+
*/
|
|
117
|
+
function removeLeftoverAppConfigurationFiles(cwd) {
|
|
118
|
+
const devRoot = path.join(cwd, DEV_DIR);
|
|
119
|
+
const dirs = [path.join(cwd, ".prisma-composer")];
|
|
120
|
+
try {
|
|
121
|
+
for (const entry of fs.readdirSync(devRoot, { withFileTypes: true })) if (entry.isDirectory()) dirs.push(path.join(devRoot, entry.name));
|
|
122
|
+
} catch {}
|
|
123
|
+
for (const dir of dirs) {
|
|
124
|
+
let names;
|
|
125
|
+
try {
|
|
126
|
+
names = fs.readdirSync(dir);
|
|
127
|
+
} catch {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
for (const name of names) {
|
|
131
|
+
const pid = Number(FILE_NAME.exec(name)?.[1]);
|
|
132
|
+
if (Number.isNaN(pid) || pid === process.pid || isRunning(pid)) continue;
|
|
133
|
+
const file = path.join(dir, name);
|
|
134
|
+
try {
|
|
135
|
+
if (Date.now() - fs.statSync(file).mtimeMs < 6e5) continue;
|
|
136
|
+
fs.rmSync(file, { force: true });
|
|
137
|
+
} catch {}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* First process: the app configuration file and the environment the second process starts with (ADR-0062).
|
|
143
|
+
* Refuses a file that would hold any of `knownSecrets`.
|
|
144
|
+
*/
|
|
145
|
+
function prepareSecondProcess(input) {
|
|
146
|
+
const { file } = input;
|
|
147
|
+
refuseSecretsInRootInput(input.appConfigurationRead, input.knownSecrets, "Composer hands the second process every plain value Load read, in a file, and never writes a secret to a file.");
|
|
148
|
+
refuseSecretsInPlainVariables(input.plainVariableText, input.knownSecrets, "Composer hands the second process every plain value in a file, and never writes a secret to a file.");
|
|
149
|
+
const contents = {
|
|
150
|
+
appConfigurationRead: input.appConfigurationRead,
|
|
151
|
+
plainVariableText: input.plainVariableText,
|
|
152
|
+
nodeAddresses: input.nodeAddresses
|
|
153
|
+
};
|
|
154
|
+
const env = { [APP_CONFIGURATION_FILE_ENV]: file };
|
|
155
|
+
const remove = () => {
|
|
156
|
+
try {
|
|
157
|
+
fs.rmSync(file, { force: true });
|
|
158
|
+
} catch {}
|
|
159
|
+
};
|
|
160
|
+
return {
|
|
161
|
+
env,
|
|
162
|
+
writeFile() {
|
|
163
|
+
fs.rmSync(file, { force: true });
|
|
164
|
+
fs.writeFileSync(file, JSON.stringify(contents), {
|
|
165
|
+
mode: 384,
|
|
166
|
+
flag: "wx"
|
|
167
|
+
});
|
|
168
|
+
process.off("exit", remove);
|
|
169
|
+
process.on("exit", remove);
|
|
170
|
+
},
|
|
171
|
+
removeFile() {
|
|
172
|
+
process.off("exit", remove);
|
|
173
|
+
remove();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region ../../0-framework/3-tooling/cli/dist/steps-BZXNqW6U.mjs
|
|
179
|
+
/**
|
|
180
|
+
* Times each step for the host's `onEvent`. Steps are matched by `keyOf`, so
|
|
181
|
+
* a step can finish under a newer status than it started with. `emit` sends
|
|
182
|
+
* the operation's other events. A host `onEvent` that throws is the host's
|
|
183
|
+
* bug and cannot fail the operation.
|
|
184
|
+
*/
|
|
185
|
+
function stepTracker(keyOf, onEvent) {
|
|
186
|
+
const open = /* @__PURE__ */ new Map();
|
|
187
|
+
const emit = (event) => {
|
|
188
|
+
try {
|
|
189
|
+
onEvent?.(event);
|
|
190
|
+
} catch {}
|
|
191
|
+
};
|
|
192
|
+
const finish = (step, outcome, data) => {
|
|
193
|
+
const entry = open.get(keyOf(step));
|
|
194
|
+
if (entry === void 0) return;
|
|
195
|
+
open.delete(keyOf(step));
|
|
196
|
+
const durationMs = Math.round(performance.now() - entry.startedAt);
|
|
197
|
+
emit({
|
|
198
|
+
kind: "step-finished",
|
|
199
|
+
step,
|
|
200
|
+
outcome,
|
|
201
|
+
durationMs,
|
|
202
|
+
data
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
start(step) {
|
|
207
|
+
open.set(keyOf(step), {
|
|
208
|
+
step,
|
|
209
|
+
startedAt: performance.now()
|
|
210
|
+
});
|
|
211
|
+
emit({
|
|
212
|
+
kind: "step-started",
|
|
213
|
+
step
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
finish(step, data) {
|
|
217
|
+
finish(step, "ok", data);
|
|
218
|
+
},
|
|
219
|
+
fail(step) {
|
|
220
|
+
finish(step, "failed");
|
|
221
|
+
},
|
|
222
|
+
/** Closes every open step with `outcome`, innermost first. */
|
|
223
|
+
closeOpen(outcome) {
|
|
224
|
+
for (const { step } of [...open.values()].reverse()) finish(step, outcome);
|
|
225
|
+
},
|
|
226
|
+
isOpen(step) {
|
|
227
|
+
return open.has(keyOf(step));
|
|
228
|
+
},
|
|
229
|
+
message(severity, text) {
|
|
230
|
+
emit({
|
|
231
|
+
kind: "message",
|
|
232
|
+
severity,
|
|
233
|
+
text
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
emit
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/** One converge event as step events: each resource is a step, made by `resourceStep`; a log line is a message. */
|
|
240
|
+
function reportConvergeEvent(steps, event, redact, resourceStep) {
|
|
241
|
+
if (event.kind === "log") {
|
|
242
|
+
steps.message(event.severity, redact(withComposerAdvice(event.text)));
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const step = resourceStep({
|
|
246
|
+
resourceId: event.fqn,
|
|
247
|
+
resourceType: event.resourceType,
|
|
248
|
+
status: event.status
|
|
249
|
+
});
|
|
250
|
+
switch (event.phase) {
|
|
251
|
+
case "running":
|
|
252
|
+
if (!steps.isOpen(step)) steps.start(step);
|
|
253
|
+
return;
|
|
254
|
+
case "done":
|
|
255
|
+
if (!steps.isOpen(step)) steps.start(step);
|
|
256
|
+
steps.finish(step);
|
|
257
|
+
return;
|
|
258
|
+
case "failed":
|
|
259
|
+
if (!steps.isOpen(step)) steps.start(step);
|
|
260
|
+
steps.fail(step);
|
|
261
|
+
if (event.message !== void 0) steps.message("warn", redact(`${event.fqn}: ${withComposerAdvice(event.message)}`));
|
|
262
|
+
return;
|
|
263
|
+
case "pending": return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Alchemy's terminal text as `info` messages, one per complete line, redacted. A secret split
|
|
268
|
+
* across writes or lines is still found, because the text passes through a `StreamRedactor`
|
|
269
|
+
* before it is cut into lines. `end` sends the last line that has no line break.
|
|
270
|
+
*/
|
|
271
|
+
function interactionMessages(steps, redaction) {
|
|
272
|
+
const stream = new StreamRedactor(redaction.allValues());
|
|
273
|
+
let partial = "";
|
|
274
|
+
const send = (text, last) => {
|
|
275
|
+
const lines = (partial + text).split("\n");
|
|
276
|
+
partial = last ? "" : lines.pop() ?? "";
|
|
277
|
+
for (const line of lines) if (line.trim() !== "") steps.message("info", redaction.redact(line));
|
|
278
|
+
};
|
|
279
|
+
return {
|
|
280
|
+
push: (text) => send(stream.push(text), false),
|
|
281
|
+
end: () => send(stream.end(), true)
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
export { prepareSecondProcess as a, removeLeftoverAppConfigurationFiles as c, engineFailureFilePath as d, readEngineFailureCause as f, deployAppConfigurationFile as i, DEPLOYMENT_RESULT_FILE_ENV as l, withComposerAdvice as m, reportConvergeEvent as n, refuseSecretsInPlainVariables as o, toDeploymentSummary as p, stepTracker as r, refuseSecretsInRootInput as s, interactionMessages as t, capFailureCause as u };
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=steps-BZXNqW6U-BM2Aa8Bp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps-BZXNqW6U-BM2Aa8Bp.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/deployment-summary-CVJZn2v0.mjs","../../../0-framework/3-tooling/cli/dist/app-configuration-file-D0rB5g65.mjs","../../../0-framework/3-tooling/cli/dist/steps-BZXNqW6U.mjs"],"sourcesContent":["import { i as redactCredentialLooking } from \"./redaction-DY6eDC12.mjs\";\nimport * as fs from \"node:fs\";\nimport { format, stripVTControlCharacters } from \"node:util\";\n//#region src/deployment-summary.ts\n/**\n* The deploy result as data, and what a stack file run as a child hands back\n* to the CLI: the summary file the report hook writes, and the failure cause\n* the child records when it exits non-zero. `DeploymentResult` holds live\n* graph nodes (ADR-0033), so the summary keeps only what can be serialized.\n* Both files are best-effort: a write failure never fails the child.\n*/\n/** Env var the deploy operation sets on the alchemy child: when present,\n* the report hook also writes the JSON DeploymentSummary there. */\nconst DEPLOYMENT_RESULT_FILE_ENV = \"PRISMA_COMPOSER_DEPLOYMENT_RESULT_FILE\";\n/** Pure projection: keeps app, each node's address/entities and the findings, drops the in-process `node`. */\nfunction toDeploymentSummary(result) {\n\treturn {\n\t\tapp: result.app,\n\t\tnodes: result.nodes.map((node) => ({\n\t\t\taddress: node.address,\n\t\t\tentities: node.entities\n\t\t})),\n\t\tfindings: result.findings\n\t};\n}\n/**\n* Writer half, called by the report hook inside the alchemy child: when the\n* env var names a file, write the summary there. Best-effort — a write\n* failure must not fail a deploy that already converged, so it is swallowed.\n*/\nfunction writeDeploymentSummaryFile(result) {\n\tconst file = process.env[DEPLOYMENT_RESULT_FILE_ENV];\n\tif (file === void 0 || file.length === 0) return;\n\ttry {\n\t\tfs.writeFileSync(file, JSON.stringify(toDeploymentSummary(result)));\n\t} catch {}\n}\n/** The child's failure cause rides beside the result file, so the one env var names both and the parent's cleanup removes both. */\nfunction engineFailureFilePath(resultFilePath) {\n\treturn `${resultFilePath}.failure.txt`;\n}\n/** Fits the platform's 5000-character build `errorMessage` with room for the exit-status prefix. */\nconst ENGINE_FAILURE_CAUSE_LIMIT = 1e3;\n/** Alchemy's advice to rerun its own CLI with `--adopt` or to import a resource with adoption, which a Composer user has no way to do. */\nconst ALCHEMY_ADOPT_ADVICE = [\n\t[/Re-run with `--adopt` \\(or wrap the effect in `adopt\\(true\\)`\\) to take it over\\./g, \"Something other than this app holds it. Remove that resource, then deploy again.\"],\n\t[/Re-run with `--adopt` \\(or wrap the effect in `adopt\\(true\\)`\\) to replace it anyway\\./g, \"Remove that resource, then deploy again.\"],\n\t[/\\(re-deploy with --adopt to take ownership, then destroy\\)/g, \"(remove it by hand)\"],\n\t[/Import it with explicit adoption (?:instead of silently taking it over|or choose a different [\\w ]+ name)\\./g, \"Something other than this app holds it. Remove that resource, then deploy again.\"],\n\t[/; rerun with adoption enabled if it is the intended [\\w ]+\\./g, \". Remove that resource, then deploy again.\"]\n];\n/** Replaces Alchemy CLI advice in engine output with steps that work from Composer. */\nfunction withComposerAdvice(text) {\n\treturn ALCHEMY_ADOPT_ADVICE.reduce((current, [advice, replacement]) => current.replace(advice, replacement), text);\n}\nconst STDOUT_CONSOLE_METHODS = /* @__PURE__ */ new Set([\n\t\"log\",\n\t\"info\",\n\t\"debug\"\n]);\n/**\n* Child half of the failure protocol, called by the generated stack file.\n* Keeps a bounded tail of everything this process logs through `console`,\n* passing every call through except Alchemy's CLI advice (see\n* {@link withComposerAdvice}), and on a non-zero exit writes the\n* redacted cause beside the result file. `console`, not the output streams:\n* alchemy's logger and its error reporting both go through it, and under Bun\n* `console` does not reach `process.stdout.write`.\n*\n* When stdout is not a terminal it carries the parent's data lines, so\n* everything this process prints goes to stderr instead.\n*/\nfunction captureEngineFailure() {\n\tconst resultFile = process.env[DEPLOYMENT_RESULT_FILE_ENV];\n\tif (resultFile === void 0 || resultFile.length === 0) return;\n\tconst stdoutToStderr = process.stdout.isTTY !== true;\n\tif (stdoutToStderr) process.stdout.write = process.stderr.write.bind(process.stderr);\n\tlet tail = \"\";\n\tfor (const method of [\n\t\t\"log\",\n\t\t\"info\",\n\t\t\"warn\",\n\t\t\"error\",\n\t\t\"debug\"\n\t]) {\n\t\tconst original = stdoutToStderr && STDOUT_CONSOLE_METHODS.has(method) ? console.error : console[method];\n\t\tconsole[method] = (...args) => {\n\t\t\tconst text = format(...args);\n\t\t\tconst shown = withComposerAdvice(text);\n\t\t\ttail = `${tail}${redactCredentialLooking(shown, process.env)}\\n`.slice(-65536);\n\t\t\tif (shown === text) original.apply(console, args);\n\t\t\telse original.call(console, shown);\n\t\t};\n\t}\n\tprocess.once(\"exit\", (code) => {\n\t\tif (code === 0) return;\n\t\tconst cause = engineFailureCause(tail, process.env);\n\t\tif (cause === void 0) return;\n\t\ttry {\n\t\t\tfs.writeFileSync(engineFailureFilePath(resultFile), cause);\n\t\t} catch {}\n\t});\n}\n/** Parent half: the cause the child recorded, passed through `redact`, or undefined when it recorded none. The child redacts only what its own environment names as a credential; the parent also knows the known secrets. */\nfunction readEngineFailureCause(resultFilePath, redact) {\n\tlet cause;\n\ttry {\n\t\tcause = fs.readFileSync(engineFailureFilePath(resultFilePath), \"utf8\");\n\t} catch {\n\t\treturn;\n\t}\n\treturn cause.length > 0 ? redact(cause) : void 0;\n}\n/** Effect's pretty log prefix, e.g. `[10:29:16.556] INFO (#53): `. */\nconst LOG_PREFIX = /^\\[[\\d:.]+\\] ([A-Z]+) \\(#\\d+\\): ?/;\n/** Alchemy's per-resource failure row, e.g. `[web] fail — UnknownError: …`. */\nconst RESOURCE_FAIL_ROW = /^\\[[^\\]]+\\] fail\\b/;\nconst STACK_FRAME = /^\\s*at /;\n/**\n* The failure the output describes: every line from the first failure line\n* (a failed resource row, an ERROR log, or an `error:` line) to the end, minus\n* blank lines, stack frames and info logs; the last five lines when there is no\n* failure line. Redacted, then capped.\n*/\nfunction engineFailureCause(output, env) {\n\tconst lines = [];\n\tfor (const raw of stripVTControlCharacters(output).split(/\\r\\n|\\r|\\n/)) {\n\t\tconst clean = raw.replace(/(?![\\t])\\p{Cc}/gu, \"\").trimEnd();\n\t\tconst prefix = LOG_PREFIX.exec(clean);\n\t\tconst text = (prefix === null ? clean : clean.slice(prefix[0].length)).trim();\n\t\tif (text.length === 0 || text === \"{\" || text === \"}\" || STACK_FRAME.test(text)) continue;\n\t\tconst level = prefix?.[1];\n\t\tconst failure = level === \"ERROR\" || level === \"FATAL\" || RESOURCE_FAIL_ROW.test(text) || /^\\W*error:/i.test(text);\n\t\tlines.push({\n\t\t\ttext,\n\t\t\tfailure,\n\t\t\tinfo: !failure && level !== void 0\n\t\t});\n\t}\n\tconst start = lines.findIndex((line) => line.failure);\n\tconst kept = start === -1 ? lines.slice(-5) : lines.slice(start).filter((line) => !line.info);\n\tif (kept.length === 0) return void 0;\n\tconst cause = redactCredentialLooking(kept.map((line) => line.text).join(\"\\n\"), env);\n\treturn cause.length <= ENGINE_FAILURE_CAUSE_LIMIT ? cause : `${cause.slice(0, ENGINE_FAILURE_CAUSE_LIMIT - 1)}…`;\n}\n/** A failure cause capped to fit the platform build's error message. */\nfunction capFailureCause(cause) {\n\treturn cause.length <= ENGINE_FAILURE_CAUSE_LIMIT ? cause : `${cause.slice(0, ENGINE_FAILURE_CAUSE_LIMIT - 1)}…`;\n}\n//#endregion\nexport { readEngineFailureCause as a, writeDeploymentSummaryFile as c, engineFailureFilePath as i, capFailureCause as n, toDeploymentSummary as o, captureEngineFailure as r, withComposerAdvice as s, DEPLOYMENT_RESULT_FILE_ENV as t };\n\n//# sourceMappingURL=deployment-summary-CVJZn2v0.mjs.map","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport { DEV_DIR } from \"@internal/core/config\";\n//#region src/secret-as-plain-value.ts\nfunction textIn(value, at) {\n\tif (typeof value === \"string\") return [{\n\t\tat,\n\t\ttext: value\n\t}];\n\tif (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return [{\n\t\tat,\n\t\ttext: String(value)\n\t}];\n\tif (Array.isArray(value)) return value.flatMap((member, index) => textIn(member, [...at, String(index)]));\n\tif (typeof value === \"object\" && value !== null) return Object.entries(value).flatMap(([key, member]) => textIn(member, [...at, key]));\n\treturn [];\n}\n/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a root input field Load read holds a known secret. */\nfunction refuseSecretsInRootInput(read, knownSecrets, consequence) {\n\tconst readPlaces = read.rootInput.flatMap((field) => textIn(field.value, field.path).map(({ at, text }) => ({\n\t\twhere: `Root input field input.${at.join(\".\")}`,\n\t\ttext\n\t})));\n\tfor (const { where, text } of readPlaces) {\n\t\tconst name = knownSecrets.nameIn(text);\n\t\tif (name === void 0) continue;\n\t\tthrow new CliStructuredError(\"CONFIG.SECRET_AS_PLAIN_VALUE\", `${where} holds the value of the platform secret \"${name}\". ${consequence}`, { fix: `Pass the value of the platform secret \"${name}\" to where this value is used, or give this plain value text that does not contain the value of \"${name}\".` });\n\t}\n}\n/** Throws `CONFIG.SECRET_AS_PLAIN_VALUE` when a plain platform variable's text holds a known secret. */\nfunction refuseSecretsInPlainVariables(plainVariableText, knownSecrets, consequence) {\n\tfor (const [variable, text] of Object.entries(plainVariableText)) {\n\t\tconst name = knownSecrets.nameIn(text);\n\t\tif (name === void 0) continue;\n\t\tthrow new CliStructuredError(\"CONFIG.SECRET_AS_PLAIN_VALUE\", `The platform variable \"${variable}\", which prisma dev read from the \\`config\\` adapters, holds the value of the platform secret \"${name}\". ${consequence}`, { fix: `Keep the value of \"${name}\" out of the platform variable \"${variable}\", or give \"${variable}\" a different value.` });\n\t}\n}\n//#endregion\n//#region src/app-configuration-file.ts\n/** Names the app configuration file the first process wrote for this run (ADR-0062). */\nconst APP_CONFIGURATION_FILE_ENV = \"PRISMA_COMPOSER_APP_CONFIGURATION_FILE\";\nconst FILE_NAME = /^app-configuration-(\\d+)(-[^/]*)?\\.json$/;\n/** The app configuration file a destroy run writes: unique per run, so concurrent runs from one checkout never share one. */\nfunction deployAppConfigurationFile(cwd, runId) {\n\treturn path.join(cwd, \".prisma-composer\", `app-configuration-${String(process.pid)}-${runId}.json`);\n}\nfunction isRunning(pid) {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn error instanceof Error && \"code\" in error && error.code === \"EPERM\";\n\t}\n}\n/**\n* Deletes the app configuration files that earlier runs left in `.prisma-composer/` and in\n* each dev environment's folder: a run killed before its exit handler ran leaves its file. A\n* file is deleted only when its process is not running and it is older than\n* `LEFTOVER_APP_CONFIGURATION_FILE_AGE_MS`. Never throws.\n*/\nfunction removeLeftoverAppConfigurationFiles(cwd) {\n\tconst devRoot = path.join(cwd, DEV_DIR);\n\tconst dirs = [path.join(cwd, \".prisma-composer\")];\n\ttry {\n\t\tfor (const entry of fs.readdirSync(devRoot, { withFileTypes: true })) if (entry.isDirectory()) dirs.push(path.join(devRoot, entry.name));\n\t} catch {}\n\tfor (const dir of dirs) {\n\t\tlet names;\n\t\ttry {\n\t\t\tnames = fs.readdirSync(dir);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const name of names) {\n\t\t\tconst pid = Number(FILE_NAME.exec(name)?.[1]);\n\t\t\tif (Number.isNaN(pid) || pid === process.pid || isRunning(pid)) continue;\n\t\t\tconst file = path.join(dir, name);\n\t\t\ttry {\n\t\t\t\tif (Date.now() - fs.statSync(file).mtimeMs < 6e5) continue;\n\t\t\t\tfs.rmSync(file, { force: true });\n\t\t\t} catch {}\n\t\t}\n\t}\n}\n/**\n* First process: the app configuration file and the environment the second process starts with (ADR-0062).\n* Refuses a file that would hold any of `knownSecrets`.\n*/\nfunction prepareSecondProcess(input) {\n\tconst { file } = input;\n\trefuseSecretsInRootInput(input.appConfigurationRead, input.knownSecrets, \"Composer hands the second process every plain value Load read, in a file, and never writes a secret to a file.\");\n\trefuseSecretsInPlainVariables(input.plainVariableText, input.knownSecrets, \"Composer hands the second process every plain value in a file, and never writes a secret to a file.\");\n\tconst contents = {\n\t\tappConfigurationRead: input.appConfigurationRead,\n\t\tplainVariableText: input.plainVariableText,\n\t\tnodeAddresses: input.nodeAddresses\n\t};\n\tconst env = { [APP_CONFIGURATION_FILE_ENV]: file };\n\tconst remove = () => {\n\t\ttry {\n\t\t\tfs.rmSync(file, { force: true });\n\t\t} catch {}\n\t};\n\treturn {\n\t\tenv,\n\t\twriteFile() {\n\t\t\tfs.rmSync(file, { force: true });\n\t\t\tfs.writeFileSync(file, JSON.stringify(contents), {\n\t\t\t\tmode: 384,\n\t\t\t\tflag: \"wx\"\n\t\t\t});\n\t\t\tprocess.off(\"exit\", remove);\n\t\t\tprocess.on(\"exit\", remove);\n\t\t},\n\t\tremoveFile() {\n\t\t\tprocess.off(\"exit\", remove);\n\t\t\tremove();\n\t\t}\n\t};\n}\nfunction missingVariable(name, what) {\n\treturn `${name} is not set. This stack file runs as the second process of a Composer destroy, which ${what}.`;\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction isTextList(value) {\n\treturn Array.isArray(value) && value.every((member) => typeof member === \"string\");\n}\nfunction rootFieldsOf(value) {\n\tif (!Array.isArray(value)) return void 0;\n\tconst fields = [];\n\tfor (const member of value) {\n\t\tif (!isRecord(member) || !isTextList(member[\"path\"])) return void 0;\n\t\tfields.push(\"value\" in member ? {\n\t\t\tpath: member[\"path\"],\n\t\t\tvalue: member[\"value\"]\n\t\t} : { path: member[\"path\"] });\n\t}\n\treturn fields;\n}\nfunction textByKeyOf(value) {\n\tif (!isRecord(value)) return void 0;\n\tconst byKey = {};\n\tfor (const [key, member] of Object.entries(value)) {\n\t\tif (typeof member !== \"string\") return void 0;\n\t\tbyKey[key] = member;\n\t}\n\treturn byKey;\n}\n/** Second process: the app configuration file the first process named in its environment. */\nfunction readAppConfigurationFile(env) {\n\tconst file = env[APP_CONFIGURATION_FILE_ENV];\n\tif (file === void 0 || file === \"\") throw new Error(missingVariable(APP_CONFIGURATION_FILE_ENV, \"names the app configuration file it wrote there\"));\n\tlet text;\n\ttry {\n\t\ttext = fs.readFileSync(file, \"utf8\");\n\t} catch (cause) {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tthrow new Error(`Could not read the app configuration file ${file}: ${message}. Composer deletes it when the run ends, so a stack file run by hand after that cannot read it; run the command again.`, { cause });\n\t}\n\tconst notComposers = (what) => /* @__PURE__ */ new Error(`The app configuration file ${file} is not in the shape this version of Composer reads: ${what}. The usual cause is a \\`prisma\\` CLI and an app on different Composer versions. Put the \\`prisma\\` CLI and the app's \\`@prisma/composer\\` on the same version.`);\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(text);\n\t} catch {\n\t\tthrow notComposers(\"it is not JSON\");\n\t}\n\tif (!isRecord(parsed)) throw notComposers(\"it is not JSON\");\n\tconst read = parsed[\"appConfigurationRead\"];\n\tif (!isRecord(read)) throw notComposers(\"appConfigurationRead is not an object\");\n\tconst rootInput = rootFieldsOf(read[\"rootInput\"]);\n\tif (rootInput === void 0) throw notComposers(\"rootInput is not a list of fields\");\n\tconst plainVariableText = textByKeyOf(parsed[\"plainVariableText\"]);\n\tif (plainVariableText === void 0) throw notComposers(\"plainVariableText is not an object of text\");\n\tconst addresses = parsed[\"nodeAddresses\"];\n\tif (!isTextList(addresses)) throw notComposers(\"nodeAddresses is not a list of node addresses\");\n\treturn {\n\t\tappConfigurationRead: { rootInput },\n\t\tplainVariableText,\n\t\tnodeAddresses: addresses\n\t};\n}\n//#endregion\nexport { refuseSecretsInPlainVariables as a, removeLeftoverAppConfigurationFiles as i, prepareSecondProcess as n, refuseSecretsInRootInput as o, readAppConfigurationFile as r, deployAppConfigurationFile as t };\n\n//# sourceMappingURL=app-configuration-file-D0rB5g65.mjs.map","import { n as StreamRedactor } from \"./redaction-DY6eDC12.mjs\";\nimport { s as withComposerAdvice } from \"./deployment-summary-CVJZn2v0.mjs\";\n//#region src/operations/steps.ts\n/**\n* Times each step for the host's `onEvent`. Steps are matched by `keyOf`, so\n* a step can finish under a newer status than it started with. `emit` sends\n* the operation's other events. A host `onEvent` that throws is the host's\n* bug and cannot fail the operation.\n*/\nfunction stepTracker(keyOf, onEvent) {\n\tconst open = /* @__PURE__ */ new Map();\n\tconst emit = (event) => {\n\t\ttry {\n\t\t\tonEvent?.(event);\n\t\t} catch {}\n\t};\n\tconst finish = (step, outcome, data) => {\n\t\tconst entry = open.get(keyOf(step));\n\t\tif (entry === void 0) return;\n\t\topen.delete(keyOf(step));\n\t\tconst durationMs = Math.round(performance.now() - entry.startedAt);\n\t\temit({\n\t\t\tkind: \"step-finished\",\n\t\t\tstep,\n\t\t\toutcome,\n\t\t\tdurationMs,\n\t\t\tdata\n\t\t});\n\t};\n\treturn {\n\t\tstart(step) {\n\t\t\topen.set(keyOf(step), {\n\t\t\t\tstep,\n\t\t\t\tstartedAt: performance.now()\n\t\t\t});\n\t\t\temit({\n\t\t\t\tkind: \"step-started\",\n\t\t\t\tstep\n\t\t\t});\n\t\t},\n\t\tfinish(step, data) {\n\t\t\tfinish(step, \"ok\", data);\n\t\t},\n\t\tfail(step) {\n\t\t\tfinish(step, \"failed\");\n\t\t},\n\t\t/** Closes every open step with `outcome`, innermost first. */\n\t\tcloseOpen(outcome) {\n\t\t\tfor (const { step } of [...open.values()].reverse()) finish(step, outcome);\n\t\t},\n\t\tisOpen(step) {\n\t\t\treturn open.has(keyOf(step));\n\t\t},\n\t\tmessage(severity, text) {\n\t\t\temit({\n\t\t\t\tkind: \"message\",\n\t\t\t\tseverity,\n\t\t\t\ttext\n\t\t\t});\n\t\t},\n\t\temit\n\t};\n}\n/** One converge event as step events: each resource is a step, made by `resourceStep`; a log line is a message. */\nfunction reportConvergeEvent(steps, event, redact, resourceStep) {\n\tif (event.kind === \"log\") {\n\t\tsteps.message(event.severity, redact(withComposerAdvice(event.text)));\n\t\treturn;\n\t}\n\tconst step = resourceStep({\n\t\tresourceId: event.fqn,\n\t\tresourceType: event.resourceType,\n\t\tstatus: event.status\n\t});\n\tswitch (event.phase) {\n\t\tcase \"running\":\n\t\t\tif (!steps.isOpen(step)) steps.start(step);\n\t\t\treturn;\n\t\tcase \"done\":\n\t\t\tif (!steps.isOpen(step)) steps.start(step);\n\t\t\tsteps.finish(step);\n\t\t\treturn;\n\t\tcase \"failed\":\n\t\t\tif (!steps.isOpen(step)) steps.start(step);\n\t\t\tsteps.fail(step);\n\t\t\tif (event.message !== void 0) steps.message(\"warn\", redact(`${event.fqn}: ${withComposerAdvice(event.message)}`));\n\t\t\treturn;\n\t\tcase \"pending\": return;\n\t}\n}\n/**\n* Alchemy's terminal text as `info` messages, one per complete line, redacted. A secret split\n* across writes or lines is still found, because the text passes through a `StreamRedactor`\n* before it is cut into lines. `end` sends the last line that has no line break.\n*/\nfunction interactionMessages(steps, redaction) {\n\tconst stream = new StreamRedactor(redaction.allValues());\n\tlet partial = \"\";\n\tconst send = (text, last) => {\n\t\tconst lines = (partial + text).split(\"\\n\");\n\t\tpartial = last ? \"\" : lines.pop() ?? \"\";\n\t\tfor (const line of lines) if (line.trim() !== \"\") steps.message(\"info\", redaction.redact(line));\n\t};\n\treturn {\n\t\tpush: (text) => send(stream.push(text), false),\n\t\tend: () => send(stream.end(), true)\n\t};\n}\n//#endregion\nexport { reportConvergeEvent as n, stepTracker as r, interactionMessages as t };\n\n//# sourceMappingURL=steps-BZXNqW6U.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAaA,MAAM,6BAA6B;;AAEnC,SAAS,oBAAoB,QAAQ;CACpC,OAAO;EACN,KAAK,OAAO;EACZ,OAAO,OAAO,MAAM,KAAK,UAAU;GAClC,SAAS,KAAK;GACd,UAAU,KAAK;EAChB,EAAE;EACF,UAAU,OAAO;CAClB;AACD;;AAcA,SAAS,sBAAsB,gBAAgB;CAC9C,OAAO,GAAG,eAAe;AAC1B;;AAEA,MAAM,6BAA6B;;AAEnC,MAAM,uBAAuB;CAC5B,CAAC,sFAAsF,kFAAkF;CACzK,CAAC,2FAA2F,0CAA0C;CACtI,CAAC,+DAA+D,qBAAqB;CACrF,CAAC,gHAAgH,kFAAkF;CACnM,CAAC,iEAAiE,4CAA4C;AAC/G;;AAEA,SAAS,mBAAmB,MAAM;CACjC,OAAO,qBAAqB,QAAQ,SAAS,CAAC,QAAQ,iBAAiB,QAAQ,QAAQ,QAAQ,WAAW,GAAG,IAAI;AAClH;;AAkDA,SAAS,uBAAuB,gBAAgB,QAAQ;CACvD,IAAI;CACJ,IAAI;EACH,QAAQ,GAAG,aAAa,sBAAsB,cAAc,GAAG,MAAM;CACtE,QAAQ;EACP;CACD;CACA,OAAO,MAAM,SAAS,IAAI,OAAO,KAAK,IAAI,KAAK;AAChD;;AAkCA,SAAS,gBAAgB,OAAO;CAC/B,OAAO,MAAM,UAAU,6BAA6B,QAAQ,GAAG,MAAM,MAAM,GAAG,6BAA6B,CAAC,EAAE;AAC/G;;;AC/IA,SAAS,OAAO,OAAO,IAAI;CAC1B,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC;EACtC;EACA,MAAM;CACP,CAAC;CACD,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,aAAa,OAA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AC;CAC/F;CACA,OAAO;EACN,OAAO,SAAS,KAAK,OAAO,KAAK,IAAI,GAAG,KAAK;EAC7C,WAAW,KAAK,OAAO,IAAI,GAAG,IAAI;CACnC;AACD"}
|
package/dist/testing.d.mts
CHANGED
|
@@ -1,45 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region ../../0-framework/3-tooling/cli/dist/app-configuration-file-BTNkc0y8.d.mts
|
|
3
|
-
/** What the first process hands the second: the app configuration file, and the environment that names it. */
|
|
4
|
-
interface SecondProcessHandover {
|
|
5
|
-
/** What the first process adds to the second process's environment. */
|
|
6
|
-
readonly env: Readonly<Record<string, string>>;
|
|
7
|
-
/** Writes the app configuration file, readable only by its owner, and deletes it when the process exits. A file already there is replaced. */
|
|
8
|
-
writeFile(): void;
|
|
9
|
-
/** Deletes the app configuration file. Never throws: the run's own result is the one to report. */
|
|
10
|
-
removeFile(): void;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* First process: the app configuration file and the environment the second process starts with (ADR-0062).
|
|
14
|
-
* Refuses a file that would hold any of `knownSecrets`.
|
|
15
|
-
*/
|
|
16
|
-
declare function prepareSecondProcess(input: {
|
|
17
|
-
readonly file: string;
|
|
18
|
-
readonly appConfigurationRead: AppConfigurationRead;
|
|
19
|
-
readonly plainVariableText: Readonly<Record<string, string>>;
|
|
20
|
-
readonly nodeAddresses: readonly string[];
|
|
21
|
-
readonly secretsKeys: readonly string[];
|
|
22
|
-
readonly knownSecrets: KnownSecrets;
|
|
23
|
-
readonly appSecrets?: AppSecrets;
|
|
24
|
-
}): SecondProcessHandover;
|
|
25
|
-
//#endregion
|
|
1
|
+
import { _ as ServiceEndpoint, a as DeployEvent, c as DevStopInput, d as DevUrlInput, g as OperationDeps, h as DevSession, l as DevStopped, m as DevInput, o as DeployInput, p as DevEvent, s as DeploySuccess, t as ComposerOperations, u as DevUrl, v as Result, y as CliStructuredError } from "./family-DfwviKFj-CS1L-EvS.mjs";
|
|
26
2
|
//#region ../../0-framework/3-tooling/cli/dist/testing.d.mts
|
|
27
|
-
//#region src/dev/generate-dev-stack.d.ts
|
|
28
|
-
interface DevStackFileInput {
|
|
29
|
-
/** Absolute path to the entry module (the app's default-exported node). */
|
|
30
|
-
readonly entryPath: string;
|
|
31
|
-
/** The process's cwd — where `.prisma-composer/dev/` is written. */
|
|
32
|
-
readonly cwd: string;
|
|
33
|
-
/** The environment the app runs as locally; its folder holds the stack file. */
|
|
34
|
-
readonly environment: string;
|
|
35
|
-
/** Absolute path to the `prisma.config.ts` that declared the `composer` section — imported by relative path. */
|
|
36
|
-
readonly configFile: string;
|
|
37
|
-
readonly name: string;
|
|
38
|
-
readonly assembled: AssembledServices;
|
|
39
|
-
}
|
|
40
|
-
/** Renders the dev stack module's source (tests assert on it without touching disk). */
|
|
41
|
-
declare function renderDevStackFile(input: DevStackFileInput): string;
|
|
42
|
-
//#endregion
|
|
43
3
|
//#region src/testing/operations-double.d.ts
|
|
44
4
|
interface OperationsDoubleFixtures {
|
|
45
5
|
/** Returned as-is; pass notOk(error) for a failing deploy. Default: ok with no summary and a zero duration. */
|
|
@@ -85,5 +45,5 @@ interface OperationsDouble {
|
|
|
85
45
|
}
|
|
86
46
|
declare function createOperationsDouble(fixtures?: OperationsDoubleFixtures): OperationsDouble;
|
|
87
47
|
//#endregion
|
|
88
|
-
export { type
|
|
48
|
+
export { type OperationsDouble, type OperationsDoubleCalls, type OperationsDoubleFixtures, createOperationsDouble };
|
|
89
49
|
//# sourceMappingURL=testing.d.mts.map
|
package/dist/testing.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/
|
|
1
|
+
{"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.d.mts"],"mappings":";;;UAMU;;WAEC,SAAS,OAAO,eAAe;;WAE/B,wBAAwB;;;;;WAKxB,MAAM,OAAO,YAAY;;WAEzB,wBAAwB;;WAExB,qBAAqB;;WAErB,SAAS,OAAO,QAAQ;;WAExB,UAAU,OAAO,YAAY;;;;;;;;UAQ9B;WACC,iBAAiB;WACjB,cAAc;;;UAGf;WACC,iBAAiB;WACjB,cAAc;WACd,iBAAiB;WACjB,kBAAkB;WAClB,MAAM;;UAEP;;WAEC,YAAY;WACZ,OAAO;;iBAED,uBAAuB,WAAW,2BAA2B"}
|
package/dist/testing.mjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as ok } from "./result-DlBttLS8.mjs";
|
|
3
|
-
import { r as prepareSecondProcess } from "./app-configuration-file-Bbfq5PR3-CYdGtitc.mjs";
|
|
4
|
-
import { n as renderDevStackFile } from "./generate-dev-stack-BEpqJ3AH-B7o7JyER.mjs";
|
|
1
|
+
import { n as ok } from "./result-CttmabB6.mjs";
|
|
5
2
|
//#region ../../0-framework/3-tooling/cli/dist/testing.mjs
|
|
6
3
|
function devSessionDouble(input, endpoints, events) {
|
|
7
4
|
let resolveClosed;
|
|
@@ -82,6 +79,6 @@ function createOperationsDouble(fixtures = {}) {
|
|
|
82
79
|
};
|
|
83
80
|
}
|
|
84
81
|
//#endregion
|
|
85
|
-
export {
|
|
82
|
+
export { createOperationsDouble };
|
|
86
83
|
|
|
87
84
|
//# sourceMappingURL=testing.mjs.map
|
package/dist/testing.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.mjs"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.mjs"],"sourcesContent":["import { ok } from \"@internal/foundation/result\";\n//#region src/testing/operations-double.ts\nfunction devSessionDouble(input, endpoints, events) {\n\tlet resolveClosed;\n\tconst closed = new Promise((resolve) => {\n\t\tresolveClosed = resolve;\n\t});\n\tlet stopped = false;\n\tinput.onEvent?.({\n\t\tkind: \"ready\",\n\t\tendpoints\n\t});\n\tfor (const event of events) input.onEvent?.(event);\n\treturn {\n\t\tendpoints,\n\t\tclosed,\n\t\tstop: async () => {\n\t\t\tif (stopped) return;\n\t\t\tstopped = true;\n\t\t\tinput.onEvent?.({ kind: \"stopping\" });\n\t\t\tinput.onEvent?.({ kind: \"stopped\" });\n\t\t\tresolveClosed();\n\t\t}\n\t};\n}\nfunction createOperationsDouble(fixtures = {}) {\n\tconst deployCalls = [];\n\tconst devCalls = [];\n\tconst deps = {\n\t\tdeploy: [],\n\t\tdev: []\n\t};\n\tconst devUrlCalls = [];\n\tconst devStopCalls = [];\n\tconst calls = {\n\t\tdeploy: deployCalls,\n\t\tdev: devCalls,\n\t\tdevUrl: devUrlCalls,\n\t\tdevStop: devStopCalls,\n\t\tdeps\n\t};\n\treturn {\n\t\toperations: {\n\t\t\tdeploy: async (input, operationDeps) => {\n\t\t\t\tcalls.deploy.push(input);\n\t\t\t\tdeps.deploy.push(operationDeps);\n\t\t\t\tfor (const event of fixtures.deployEvents ?? []) try {\n\t\t\t\t\tinput.onEvent?.(event);\n\t\t\t\t} catch {}\n\t\t\t\treturn fixtures.deploy ?? ok({\n\t\t\t\t\tsummary: void 0,\n\t\t\t\t\tdurationMs: 0\n\t\t\t\t});\n\t\t\t},\n\t\t\tdev: async (input, operationDeps) => {\n\t\t\t\tcalls.dev.push(input);\n\t\t\t\tdeps.dev.push(operationDeps);\n\t\t\t\treturn fixtures.dev ?? ok(devSessionDouble(input, fixtures.devEndpoints ?? [], fixtures.devEvents ?? []));\n\t\t\t},\n\t\t\tdevUrl: async (input) => {\n\t\t\t\tdevUrlCalls.push(input);\n\t\t\t\treturn fixtures.devUrl ?? ok({\n\t\t\t\t\taddress: input.address,\n\t\t\t\t\tkind: \"service\",\n\t\t\t\t\turl: \"http://localhost:3000\",\n\t\t\t\t\tstate: \"running\"\n\t\t\t\t});\n\t\t\t},\n\t\t\tdevStop: async (input) => {\n\t\t\t\tdevStopCalls.push(input);\n\t\t\t\treturn fixtures.devStop ?? ok({\n\t\t\t\t\tapp: \"app\",\n\t\t\t\t\tenvironment: input.environment ?? \"dev\",\n\t\t\t\t\tstopped: []\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcalls\n\t};\n}\n//#endregion\nexport { createOperationsDouble };\n\n//# sourceMappingURL=testing.mjs.map"],"mappings":";;AAEA,SAAS,iBAAiB,OAAO,WAAW,QAAQ;CACnD,IAAI;CACJ,MAAM,SAAS,IAAI,SAAS,YAAY;EACvC,gBAAgB;CACjB,CAAC;CACD,IAAI,UAAU;CACd,MAAM,UAAU;EACf,MAAM;EACN;CACD,CAAC;CACD,KAAK,MAAM,SAAS,QAAQ,MAAM,UAAU,KAAK;CACjD,OAAO;EACN;EACA;EACA,MAAM,YAAY;GACjB,IAAI,SAAS;GACb,UAAU;GACV,MAAM,UAAU,EAAE,MAAM,WAAW,CAAC;GACpC,MAAM,UAAU,EAAE,MAAM,UAAU,CAAC;GACnC,cAAc;EACf;CACD;AACD;AACA,SAAS,uBAAuB,WAAW,CAAC,GAAG;CAC9C,MAAM,cAAc,CAAC;CACrB,MAAM,WAAW,CAAC;CAClB,MAAM,OAAO;EACZ,QAAQ,CAAC;EACT,KAAK,CAAC;CACP;CACA,MAAM,cAAc,CAAC;CACrB,MAAM,eAAe,CAAC;CACtB,MAAM,QAAQ;EACb,QAAQ;EACR,KAAK;EACL,QAAQ;EACR,SAAS;EACT;CACD;CACA,OAAO;EACN,YAAY;GACX,QAAQ,OAAO,OAAO,kBAAkB;IACvC,MAAM,OAAO,KAAK,KAAK;IACvB,KAAK,OAAO,KAAK,aAAa;IAC9B,KAAK,MAAM,SAAS,SAAS,gBAAgB,CAAC,GAAG,IAAI;KACpD,MAAM,UAAU,KAAK;IACtB,QAAQ,CAAC;IACT,OAAO,SAAS,UAAU,GAAG;KAC5B,SAAS,KAAK;KACd,YAAY;IACb,CAAC;GACF;GACA,KAAK,OAAO,OAAO,kBAAkB;I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