@prisma/composer 0.39.0-dev.7 → 0.39.0-dev.9
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-config-DmCj4luV-BC36-MeB.d.mts → app-config-DriAu5RU-C8hYpR38.d.mts} +17 -15
- package/dist/app-config-DriAu5RU-C8hYpR38.d.mts.map +1 -0
- package/dist/{app-configuration-file-Bbfq5PR3-D4DUNKUM.mjs → app-configuration-file-D0rB5g65-CdMrjkCc.mjs} +10 -40
- package/dist/app-configuration-file-D0rB5g65-CdMrjkCc.mjs.map +1 -0
- package/dist/app-converge-C6Zrg2xM-D0k4EIJY.mjs +88 -0
- package/dist/app-converge-C6Zrg2xM-D0k4EIJY.mjs.map +1 -0
- package/dist/config-Bpi8QVLB.d.mts +1 -0
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/control.d.mts +8 -23
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +4 -4
- package/dist/control.mjs.map +1 -1
- package/dist/{converge-in-process-BBBeood8-BCIPOG8X.d.mts → converge-in-process-CTomEXaD-BnDylZP8.d.mts} +5 -5
- package/dist/{converge-in-process-BBBeood8-BCIPOG8X.d.mts.map → converge-in-process-CTomEXaD-BnDylZP8.d.mts.map} +1 -1
- package/dist/converge-in-process-x89zb2MF-Dvj-J8xo.mjs +258 -0
- package/dist/converge-in-process-x89zb2MF-Dvj-J8xo.mjs.map +1 -0
- package/dist/{deploy-B2kxaH5E.mjs → deploy-CSU0kr4j.mjs} +65 -5
- package/dist/{deploy-B2kxaH5E.mjs.map → deploy-CSU0kr4j.mjs.map} +1 -1
- package/dist/deploy-DHgEJDpg.d.mts +32 -0
- package/dist/deploy-DHgEJDpg.d.mts.map +1 -0
- package/dist/deploy.d.mts +4 -4
- package/dist/deploy.mjs +3 -3
- package/dist/{deployment-summary-6LgQDUuu-Dp8kwMs_.d.mts → deployment-summary-6LgQDUuu-Cu_6UNhc.d.mts} +4 -4
- package/dist/{deployment-summary-6LgQDUuu-Dp8kwMs_.d.mts.map → deployment-summary-6LgQDUuu-Cu_6UNhc.d.mts.map} +1 -1
- package/dist/{deployment-summary-YP7eMPJI-CQsj7BHh.mjs → deployment-summary-CVJZn2v0-Dz-gX1rp.mjs} +3 -3
- package/dist/{deployment-summary-YP7eMPJI-CQsj7BHh.mjs.map → deployment-summary-CVJZn2v0-Dz-gX1rp.mjs.map} +1 -1
- package/dist/dev-converge-messages-DML4rTz7-C_EAB5M_.mjs +165 -0
- package/dist/dev-converge-messages-DML4rTz7-C_EAB5M_.mjs.map +1 -0
- package/dist/dev-converge-worker.d.mts +1 -0
- package/dist/dev-converge-worker.mjs +142 -0
- package/dist/dev-converge-worker.mjs.map +1 -0
- package/dist/{dev-current-gQnmjB4V-BaNhcGpK.mjs → dev-current-EqQbrtj5-Dda1xCjU.mjs} +11 -7
- package/dist/dev-current-EqQbrtj5-Dda1xCjU.mjs.map +1 -0
- package/dist/{dev-environment-name-6eEr5PW8-6sPgQZG3.mjs → dev-environment-name-6eEr5PW8-7ntm9Xhs.mjs} +3 -3
- package/dist/{dev-environment-name-6eEr5PW8-6sPgQZG3.mjs.map → dev-environment-name-6eEr5PW8-7ntm9Xhs.mjs.map} +1 -1
- package/dist/{dist-CyrEbDx6.mjs → dist-Cf_mZHaH.mjs} +2 -2
- package/dist/{dist-CyrEbDx6.mjs.map → dist-Cf_mZHaH.mjs.map} +1 -1
- package/dist/{emulator-retry-CV8rl69G-BgUzkxc-.mjs → emulator-retry-CV8rl69G-scQ105wk.mjs} +2 -2
- package/dist/{emulator-retry-CV8rl69G-BgUzkxc-.mjs.map → emulator-retry-CV8rl69G-scQ105wk.mjs.map} +1 -1
- package/dist/{errors-0e8IVwzi.mjs → errors-DI3TBXE-.mjs} +7 -2
- package/dist/{errors-0e8IVwzi.mjs.map → errors-DI3TBXE-.mjs.map} +1 -1
- package/dist/{execute-deploy-destroy-DKbsBkqK-BWXh0zXQ.mjs → execute-deploy-destroy-DKEmb8WI-Cad08hR1.mjs} +246 -193
- package/dist/execute-deploy-destroy-DKEmb8WI-Cad08hR1.mjs.map +1 -0
- package/dist/{execute-dev-DVCWURmI-Cp3i7Hrp.mjs → execute-dev-C42niIFY-Cl5XzBy3.mjs} +434 -261
- package/dist/execute-dev-C42niIFY-Cl5XzBy3.mjs.map +1 -0
- package/dist/{execute-dev-current-Dt_9srY2-COEgQ9h4.mjs → execute-dev-current-AVT4zQ8F-WFr1pM2p.mjs} +7 -7
- package/dist/{execute-dev-current-Dt_9srY2-COEgQ9h4.mjs.map → execute-dev-current-AVT4zQ8F-WFr1pM2p.mjs.map} +1 -1
- package/dist/{execute-log-B34AeU97-CkJiGdIc.mjs → execute-log-DCe9fk1t-vVIgGSSi.mjs} +8 -8
- package/dist/{execute-log-B34AeU97-CkJiGdIc.mjs.map → execute-log-DCe9fk1t-vVIgGSSi.mjs.map} +1 -1
- package/dist/{graph-1ILOBl8O-DBaUZL2D.d.mts → graph-CUYXjK8S-BzL-mhjq.d.mts} +3 -3
- package/dist/graph-CUYXjK8S-BzL-mhjq.d.mts.map +1 -0
- package/dist/{graph-C6Fqe2gn-qJQBxs_C.mjs → graph-D2WMLL43-CeiC5wdy.mjs} +18 -9
- package/dist/graph-D2WMLL43-CeiC5wdy.mjs.map +1 -0
- package/dist/{graph-types-CaH3flhT-DgrCdRA3.d.mts → graph-types-D4PrtP-l-B0uuchTl.d.mts} +13 -11
- package/dist/{graph-types-CaH3flhT-DgrCdRA3.d.mts.map → graph-types-D4PrtP-l-B0uuchTl.d.mts.map} +1 -1
- package/dist/http.d.mts +2 -2
- package/dist/http.mjs +2 -2
- package/dist/{index-Cnbf_d0q.d.mts → index-D8chHe55.d.mts} +3 -3
- package/dist/{index-Cnbf_d0q.d.mts.map → index-D8chHe55.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/internal-app-configuration-file.d.mts +5 -9
- package/dist/internal-app-configuration-file.d.mts.map +1 -1
- package/dist/internal-app-configuration-file.mjs +2 -2
- package/dist/internal-converge-contract.d.mts +6 -4
- package/dist/internal-converge-contract.d.mts.map +1 -1
- package/dist/internal-converge-contract.mjs +7 -5
- package/dist/internal-converge-contract.mjs.map +1 -1
- package/dist/internal-converge.d.mts +5 -4
- package/dist/internal-converge.mjs +4 -228
- package/dist/load-entry-CEoVBdMj-CHOz7jKf.mjs +527 -0
- package/dist/load-entry-CEoVBdMj-CHOz7jKf.mjs.map +1 -0
- package/dist/local-target-7KRsLMDO.d.mts +31 -0
- package/dist/local-target-7KRsLMDO.d.mts.map +1 -0
- package/dist/{local-target-COdS1iNs.mjs → local-target-DhU1vaxd.mjs} +6 -6
- package/dist/{local-target-COdS1iNs.mjs.map → local-target-DhU1vaxd.mjs.map} +1 -1
- package/dist/local-target.d.mts +3 -31
- package/dist/local-target.mjs +1 -1
- package/dist/{nextjs-DLyeRR7M-CSKy5tFv.d.mts → nextjs-DLyeRR7M-CzUbvPaJ.d.mts} +3 -3
- package/dist/{nextjs-DLyeRR7M-CSKy5tFv.d.mts.map → nextjs-DLyeRR7M-CzUbvPaJ.d.mts.map} +1 -1
- package/dist/nextjs-control.d.mts +4 -4
- package/dist/nextjs.d.mts +1 -1
- package/dist/node-control.d.mts +3 -3
- package/dist/node.d.mts +2 -2
- package/dist/{preflight-transport-C7_3abXW-Bza_hn9G.mjs → preflight-transport-2d6iIchu-B-v7Di6I.mjs} +5 -4
- package/dist/preflight-transport-2d6iIchu-B-v7Di6I.mjs.map +1 -0
- package/dist/{redaction-CjMYXtGp-CEQ5z1PK.mjs → redaction-DY6eDC12-W-FzW7_r.mjs} +16 -4
- package/dist/{redaction-CjMYXtGp-CEQ5z1PK.mjs.map → redaction-DY6eDC12-W-FzW7_r.mjs.map} +1 -1
- package/dist/{redaction-CIaE4m9U-DyJoGPRw.d.mts → redaction-Dn7BRdaP-BcLSPhLV.d.mts} +58 -17
- package/dist/redaction-Dn7BRdaP-BcLSPhLV.d.mts.map +1 -0
- package/dist/report.d.mts +3 -3
- package/dist/report.mjs +2 -2
- package/dist/report.mjs.map +1 -1
- package/dist/service-rpc.d.mts +2 -2
- package/dist/service-rpc.mjs +2 -2
- package/dist/steps-BZXNqW6U-C_ME2VLd.mjs +112 -0
- package/dist/steps-BZXNqW6U-C_ME2VLd.mjs.map +1 -0
- package/dist/testing.d.mts +1 -1
- package/dist/validate-environment-DCZiNSlR-C7lv0cH1.mjs +344 -0
- package/dist/validate-environment-DCZiNSlR-C7lv0cH1.mjs.map +1 -0
- package/package.json +11 -11
- package/skills/prisma-composer-core-concepts/SKILL.md +8 -8
- package/src/exports/dev-converge-worker.ts +2 -0
- package/dist/app-config-DmCj4luV-BC36-MeB.d.mts.map +0 -1
- package/dist/app-configuration-file-Bbfq5PR3-D4DUNKUM.mjs.map +0 -1
- package/dist/config-vv8LBErH.d.mts +0 -1
- package/dist/deploy-w-BcRS8b.d.mts +0 -12
- package/dist/deploy-w-BcRS8b.d.mts.map +0 -1
- package/dist/dev-current-gQnmjB4V-BaNhcGpK.mjs.map +0 -1
- package/dist/execute-deploy-destroy-DKbsBkqK-BWXh0zXQ.mjs.map +0 -1
- package/dist/execute-dev-DVCWURmI-Cp3i7Hrp.mjs.map +0 -1
- package/dist/graph-1ILOBl8O-DBaUZL2D.d.mts.map +0 -1
- package/dist/graph-C6Fqe2gn-qJQBxs_C.mjs.map +0 -1
- package/dist/internal-converge.mjs.map +0 -1
- package/dist/local-target.d.mts.map +0 -1
- package/dist/preflight-transport-C7_3abXW-Bza_hn9G.mjs.map +0 -1
- package/dist/redaction-CIaE4m9U-DyJoGPRw.d.mts.map +0 -1
- package/dist/run-alchemy-BlYyc4Oh-mIzYC4lq.mjs +0 -236
- package/dist/run-alchemy-BlYyc4Oh-mIzYC4lq.mjs.map +0 -1
- package/dist/validate-environment-XwVDifWN-D14WhSH0.mjs +0 -739
- package/dist/validate-environment-XwVDifWN-D14WhSH0.mjs.map +0 -1
|
@@ -1,120 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
1
|
+
import { E as secretsKeys, a as ROOT_INPUT_UNREAD_ERROR, y as nodeAddresses } from "./graph-D2WMLL43-CeiC5wdy.mjs";
|
|
2
|
+
import { t as InternalError } from "./internal-error-Dfur7Zqt-D96dWHZK.mjs";
|
|
3
|
+
import { n as quotedList, t as CliStructuredError } from "./errors-DI3TBXE-.mjs";
|
|
4
4
|
import { i as devEnvironmentDir } from "./app-config-CErnR6NK-D9NgSBH4.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import "./deploy-
|
|
7
|
-
import {
|
|
8
|
-
import { r as resolveLocalTargets } from "./local-target-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
5
|
+
import { a as refuseSecretsInRootInput, i as refuseSecretsInPlainVariables, o as removeLeftoverAppConfigurationFiles } from "./app-configuration-file-D0rB5g65-CdMrjkCc.mjs";
|
|
6
|
+
import "./deploy-CSU0kr4j.mjs";
|
|
7
|
+
import { r as holdingConvergeProcess } from "./converge-in-process-x89zb2MF-Dvj-J8xo.mjs";
|
|
8
|
+
import { r as resolveLocalTargets } from "./local-target-DhU1vaxd.mjs";
|
|
9
|
+
import { c as requireContainerForEnvironment, d as ok, l as toStructured, t as convergeReasonsText, u as notOk } from "./dev-current-EqQbrtj5-Dda1xCjU.mjs";
|
|
10
|
+
import { t as loadAppConvergeEntry } from "./app-converge-C6Zrg2xM-D0k4EIJY.mjs";
|
|
11
|
+
import { a as valueReadsSnapshot, i as thrownResult, r as isWorkerMessage } from "./dev-converge-messages-DML4rTz7-C_EAB5M_.mjs";
|
|
12
|
+
import { a as redactDevEvent, c as redactThrown, o as redactError, t as SecretRedaction } from "./redaction-DY6eDC12-W-FzW7_r.mjs";
|
|
13
|
+
import { s as withComposerAdvice } from "./deployment-summary-CVJZn2v0-Dz-gX1rp.mjs";
|
|
14
|
+
import { i as validateEnvironmentName, r as runPipeline } from "./validate-environment-DCZiNSlR-C7lv0cH1.mjs";
|
|
15
|
+
import { n as reportConvergeEvent, r as stepTracker, t as interactionMessages } from "./steps-BZXNqW6U-C_ME2VLd.mjs";
|
|
16
|
+
import { n as requireDevEnvironmentName, t as claimDevEnvironmentName } from "./dev-environment-name-6eEr5PW8-7ntm9Xhs.mjs";
|
|
17
|
+
import { t as withEmulatorRetry } from "./emulator-retry-CV8rl69G-scQ105wk.mjs";
|
|
14
18
|
import * as path$1 from "node:path";
|
|
15
19
|
import { join, relative, resolve, sep } from "node:path";
|
|
16
20
|
import * as fs$1 from "node:fs";
|
|
17
|
-
import {
|
|
21
|
+
import { Worker, isMainThread } from "node:worker_threads";
|
|
18
22
|
import { fileURLToPath } from "node:url";
|
|
23
|
+
import { isDeepStrictEqual } from "node:util";
|
|
24
|
+
import { Readable } from "node:stream";
|
|
19
25
|
import * as sysPath from "path";
|
|
20
26
|
import { stat, unwatchFile, watch, watchFile } from "fs";
|
|
21
|
-
import { Readable } from "node:stream";
|
|
22
27
|
import { lstat, readdir, realpath, stat as stat$1 } from "node:fs/promises";
|
|
23
28
|
import { type } from "os";
|
|
24
29
|
import { EventEmitter } from "events";
|
|
25
30
|
import { createHash } from "node:crypto";
|
|
26
31
|
import { lstat as lstat$1, open, readdir as readdir$1, realpath as realpath$1, stat as stat$2 } from "fs/promises";
|
|
27
|
-
//#region ../../0-framework/3-tooling/cli/dist/
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* containers, top-level-awaits `resolveLocalTargets(config)` (the lazy
|
|
37
|
-
* `localTarget` thunks, ADR-0041), and passes
|
|
38
|
-
* `providers: localTargetProviders(...)` + `state: devState()` explicitly
|
|
39
|
-
* — `lower()` learns nothing about dev.
|
|
40
|
-
*/
|
|
41
|
-
const DEV_GENERATED_FILE = "alchemy.run.ts";
|
|
42
|
-
/** The stack file's path relative to the cwd. */
|
|
43
|
-
function devStackRelativePath(environment) {
|
|
44
|
-
return path$1.join(devEnvironmentDir(environment), DEV_GENERATED_FILE);
|
|
45
|
-
}
|
|
46
|
-
/** A relative import specifier from the stack file to `target` (posix separators). */
|
|
47
|
-
function relativeImportSpecifier(generatedDir, target) {
|
|
48
|
-
const rel = path$1.relative(generatedDir, target).split(path$1.sep).join("/");
|
|
49
|
-
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
50
|
-
}
|
|
51
|
-
function quote(value) {
|
|
52
|
-
return JSON.stringify(value);
|
|
53
|
-
}
|
|
54
|
-
function renderBundle(bundle) {
|
|
55
|
-
return `{ dir: ${quote(bundle.dir)}, entry: ${quote(bundle.entry)} }`;
|
|
56
|
-
}
|
|
57
|
-
function renderOptions(input) {
|
|
58
|
-
const lines = [];
|
|
59
|
-
lines.push(` name: ${quote(input.name)},`);
|
|
60
|
-
lines.push(` environment: ${quote(input.environment)},`);
|
|
61
|
-
lines.push(" appConfigurationRead: file.appConfigurationRead,");
|
|
62
|
-
lines.push(" firstProcessNodeAddresses: file.nodeAddresses,");
|
|
63
|
-
lines.push(" bundles: {");
|
|
64
|
-
for (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);
|
|
65
|
-
lines.push(" },");
|
|
66
|
-
const unassembled = Object.keys(input.assembled.devServers);
|
|
67
|
-
if (unassembled.length > 0) lines.push(` unassembled: [${unassembled.map(quote).join(", ")}],`);
|
|
68
|
-
lines.push(" providers: localTargetProviders(resolved, containers, devDir, file.plainVariableText, namedSecrets),");
|
|
69
|
-
lines.push(" state: devState(),");
|
|
70
|
-
return lines.join("\n");
|
|
71
|
-
}
|
|
72
|
-
/** Renders the dev stack module's source (tests assert on it without touching disk). */
|
|
73
|
-
function renderDevStackFile(input) {
|
|
74
|
-
const generatedDir = path$1.join(input.cwd, devEnvironmentDir(input.environment));
|
|
75
|
-
const appImport = relativeImportSpecifier(generatedDir, input.entryPath);
|
|
76
|
-
const imports = [
|
|
77
|
-
"import * as path from 'node:path';",
|
|
78
|
-
"import { deserializeContainers } from '@prisma/composer/config';",
|
|
79
|
-
"import { namedSecretsFromEnvironment, readAppConfigurationFile } from '@prisma/composer/internal/app-configuration-file';",
|
|
80
|
-
"import { lower } from '@prisma/composer/deploy';",
|
|
81
|
-
"import { devEnvironmentDir, devState, localTargetProviders, resolveLocalTargets } from '@prisma/composer/local-target';",
|
|
82
|
-
`import prismaConfig from ${quote(relativeImportSpecifier(generatedDir, input.configFile))};`,
|
|
83
|
-
`import app from ${quote(appImport)};`
|
|
84
|
-
].join("\n");
|
|
85
|
-
return `// Generated by \`prisma dev\` — overwritten on every run; do not
|
|
86
|
-
// edit by hand. Independently runnable from ${quote(input.cwd)} by the
|
|
87
|
-
// command Composer starts, which a failed run prints:
|
|
88
|
-
//
|
|
89
|
-
// <node> <bin of the alchemy @prisma/composer depends on> deploy ${devStackRelativePath(input.environment)} --yes --stage ${input.environment}
|
|
90
|
-
//
|
|
91
|
-
// bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).
|
|
92
|
-
// It runs no config or secrets adapter: it reads what the first process's Load read, and the text of each plain platform variable, from the app configuration file named in PRISMA_COMPOSER_APP_CONFIGURATION_FILE, and the named secrets from PRISMA_COMPOSER_NAMED_SECRETS.
|
|
93
|
-
${imports}
|
|
94
|
-
|
|
95
|
-
const config = prismaConfig.composer;
|
|
96
|
-
if (config === undefined) {
|
|
97
|
-
throw new Error(${quote(noComposerExportMessage(input.configFile))});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const containers = deserializeContainers(config.extensions, process.env);
|
|
101
|
-
const resolved = await resolveLocalTargets(config);
|
|
102
|
-
const devDir = path.join(process.cwd(), devEnvironmentDir(${quote(input.environment)}));
|
|
103
|
-
const file = readAppConfigurationFile(process.env);
|
|
104
|
-
const namedSecrets = namedSecretsFromEnvironment(process.env);
|
|
105
|
-
|
|
106
|
-
export default lower(app, config, {
|
|
107
|
-
${renderOptions(input)}
|
|
108
|
-
});
|
|
109
|
-
`;
|
|
110
|
-
}
|
|
111
|
-
/** Writes the dev stack file, returning its absolute path. */
|
|
112
|
-
function writeDevStackFile(input) {
|
|
113
|
-
const generatedDir = path$1.join(input.cwd, devEnvironmentDir(input.environment));
|
|
114
|
-
fs$1.mkdirSync(generatedDir, { recursive: true });
|
|
115
|
-
const filePath = path$1.join(generatedDir, DEV_GENERATED_FILE);
|
|
116
|
-
fs$1.writeFileSync(filePath, renderDevStackFile(input));
|
|
117
|
-
return filePath;
|
|
32
|
+
//#region ../../0-framework/3-tooling/cli/dist/value-reads-change-text-DcRCv7Zy.mjs
|
|
33
|
+
/** Which reads changed, as a clause: `reads of "shop.port" were added and "shop.key" was changed`. */
|
|
34
|
+
function valueReadsChangeText(change) {
|
|
35
|
+
const [first, second, third] = [
|
|
36
|
+
...change.added.length > 0 ? [`reads of ${quotedList(change.added)} were added`] : [],
|
|
37
|
+
...change.removed.length > 0 ? [`reads of ${quotedList(change.removed)} were removed`] : [],
|
|
38
|
+
...change.changed.length > 0 ? [`${quotedList(change.changed)} ${change.changed.length === 1 ? "was" : "were"} changed`] : []
|
|
39
|
+
];
|
|
40
|
+
return third !== void 0 ? `${first}, ${second}, and ${third}` : second !== void 0 ? `${first} and ${second}` : first ?? "";
|
|
118
41
|
}
|
|
119
42
|
//#endregion
|
|
120
43
|
//#region ../../0-framework/3-tooling/cli/node_modules/readdirp/esm/index.js
|
|
@@ -1665,48 +1588,7 @@ var esm_default = {
|
|
|
1665
1588
|
FSWatcher
|
|
1666
1589
|
};
|
|
1667
1590
|
//#endregion
|
|
1668
|
-
//#region ../../0-framework/3-tooling/cli/dist/execute-dev-
|
|
1669
|
-
const readKey = (read) => JSON.stringify([
|
|
1670
|
-
read.reader,
|
|
1671
|
-
read.resource,
|
|
1672
|
-
read.path
|
|
1673
|
-
]);
|
|
1674
|
-
function readsByResource(graph) {
|
|
1675
|
-
const byResource = /* @__PURE__ */ new Map();
|
|
1676
|
-
for (const read of graph.valueReads) {
|
|
1677
|
-
const keys = byResource.get(read.resource) ?? /* @__PURE__ */ new Set();
|
|
1678
|
-
keys.add(readKey(read));
|
|
1679
|
-
byResource.set(read.resource, keys);
|
|
1680
|
-
}
|
|
1681
|
-
return byResource;
|
|
1682
|
-
}
|
|
1683
|
-
function propsAt(graph, address) {
|
|
1684
|
-
const found = graph.nodes.find((entry) => entry.id === address)?.node;
|
|
1685
|
-
return found?.kind === "resource" ? found.props : void 0;
|
|
1686
|
-
}
|
|
1687
|
-
const hasMemberNotIn = (keys, other) => [...keys].some((key) => !other.has(key));
|
|
1688
|
-
function valueReadsChange(started, rebuilt) {
|
|
1689
|
-
const before = readsByResource(started);
|
|
1690
|
-
const after = readsByResource(rebuilt);
|
|
1691
|
-
const added = [];
|
|
1692
|
-
const removed = [];
|
|
1693
|
-
const changed = [];
|
|
1694
|
-
for (const address of /* @__PURE__ */ new Set([...before.keys(), ...after.keys()])) {
|
|
1695
|
-
const was = before.get(address) ?? /* @__PURE__ */ new Set();
|
|
1696
|
-
const is = after.get(address) ?? /* @__PURE__ */ new Set();
|
|
1697
|
-
const gained = hasMemberNotIn(is, was);
|
|
1698
|
-
const lost = hasMemberNotIn(was, is);
|
|
1699
|
-
if (was.size > 0 && is.size > 0 && !isDeepStrictEqual(propsAt(started, address), propsAt(rebuilt, address)) || gained && lost) changed.push(address);
|
|
1700
|
-
else if (gained) added.push(address);
|
|
1701
|
-
else if (lost) removed.push(address);
|
|
1702
|
-
}
|
|
1703
|
-
if (added.length + removed.length + changed.length === 0) return void 0;
|
|
1704
|
-
return {
|
|
1705
|
-
added,
|
|
1706
|
-
removed,
|
|
1707
|
-
changed
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1591
|
+
//#region ../../0-framework/3-tooling/cli/dist/execute-dev-C42niIFY.mjs
|
|
1710
1592
|
/**
|
|
1711
1593
|
* Local-dev spec § 6 `watch.ts`: watches each assembled bundle's declared
|
|
1712
1594
|
* `watch` paths and every authoring module (ADR-0056) — a directory watched
|
|
@@ -1782,7 +1664,9 @@ function authoringModuleTargets(entryPath, graph) {
|
|
|
1782
1664
|
* watched file; proven by the delete-recreate test failing on Linux CI
|
|
1783
1665
|
* only). Directory targets are watched recursively as themselves; a
|
|
1784
1666
|
* nonexistent path is treated as a file target, so it starts reporting the
|
|
1785
|
-
* moment something creates it.
|
|
1667
|
+
* moment something creates it. A file whose directory does not exist yet is
|
|
1668
|
+
* watched through its nearest existing ancestor, following only the
|
|
1669
|
+
* directories on the way to it.
|
|
1786
1670
|
*/
|
|
1787
1671
|
function startWatch(targets, onChange, onError) {
|
|
1788
1672
|
let timer;
|
|
@@ -1796,6 +1680,7 @@ function startWatch(targets, onChange, onError) {
|
|
|
1796
1680
|
const fileTargets = /* @__PURE__ */ new Set();
|
|
1797
1681
|
const directoryRoots = /* @__PURE__ */ new Set();
|
|
1798
1682
|
const parentRoots = /* @__PURE__ */ new Set();
|
|
1683
|
+
const filesInMissingDirectories = /* @__PURE__ */ new Set();
|
|
1799
1684
|
for (const target of targets) for (const p of target.paths) {
|
|
1800
1685
|
const abs = path$1.resolve(p);
|
|
1801
1686
|
let isDirectory = false;
|
|
@@ -1805,7 +1690,8 @@ function startWatch(targets, onChange, onError) {
|
|
|
1805
1690
|
if (isDirectory) directoryRoots.add(abs);
|
|
1806
1691
|
else {
|
|
1807
1692
|
fileTargets.add(abs);
|
|
1808
|
-
parentRoots.add(path$1.dirname(abs));
|
|
1693
|
+
if (fs$1.existsSync(path$1.dirname(abs))) parentRoots.add(path$1.dirname(abs));
|
|
1694
|
+
else filesInMissingDirectories.add(abs);
|
|
1809
1695
|
}
|
|
1810
1696
|
}
|
|
1811
1697
|
const reportError = (error) => {
|
|
@@ -1829,6 +1715,21 @@ function startWatch(targets, onChange, onError) {
|
|
|
1829
1715
|
parentWatcher.on("error", reportError);
|
|
1830
1716
|
watchers.push(parentWatcher);
|
|
1831
1717
|
}
|
|
1718
|
+
if (filesInMissingDirectories.size > 0) {
|
|
1719
|
+
const { roots, onTheWay } = nearestExistingAncestors(filesInMissingDirectories);
|
|
1720
|
+
const ancestorWatcher = esm_default.watch([...roots], {
|
|
1721
|
+
ignoreInitial: true,
|
|
1722
|
+
ignored: (candidate) => {
|
|
1723
|
+
const resolved = path$1.resolve(candidate);
|
|
1724
|
+
return !roots.has(resolved) && !onTheWay.has(resolved);
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
ancestorWatcher.on("all", (_event, eventPath) => {
|
|
1728
|
+
if (fileTargets.has(path$1.resolve(eventPath))) trigger();
|
|
1729
|
+
});
|
|
1730
|
+
ancestorWatcher.on("error", reportError);
|
|
1731
|
+
watchers.push(ancestorWatcher);
|
|
1732
|
+
}
|
|
1832
1733
|
let markReady = () => {};
|
|
1833
1734
|
const allReady = Promise.all(watchers.map((watcher) => new Promise((resolve) => watcher.on("ready", () => resolve())))).then(() => {});
|
|
1834
1735
|
return {
|
|
@@ -1841,13 +1742,151 @@ function startWatch(targets, onChange, onError) {
|
|
|
1841
1742
|
};
|
|
1842
1743
|
}
|
|
1843
1744
|
/**
|
|
1844
|
-
*
|
|
1845
|
-
*
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1745
|
+
* For files whose directory does not exist yet: the nearest existing ancestor of each, and every
|
|
1746
|
+
* path from there down to the file, which are all a watch on the ancestor needs to follow.
|
|
1747
|
+
*/
|
|
1748
|
+
function nearestExistingAncestors(files) {
|
|
1749
|
+
const roots = /* @__PURE__ */ new Set();
|
|
1750
|
+
const onTheWay = /* @__PURE__ */ new Set();
|
|
1751
|
+
for (const file of files) {
|
|
1752
|
+
onTheWay.add(file);
|
|
1753
|
+
let directory = path$1.dirname(file);
|
|
1754
|
+
while (!fs$1.existsSync(directory)) {
|
|
1755
|
+
onTheWay.add(directory);
|
|
1756
|
+
directory = path$1.dirname(directory);
|
|
1757
|
+
}
|
|
1758
|
+
roots.add(directory);
|
|
1759
|
+
}
|
|
1760
|
+
return {
|
|
1761
|
+
roots,
|
|
1762
|
+
onTheWay
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
/**
|
|
1766
|
+
* `prisma dev`'s default converge: one new worker thread per converge, so the
|
|
1767
|
+
* worker imports the app's definition files as they are on disk now. For the
|
|
1768
|
+
* worker's lifetime this thread holds the one-converge flag and the process's
|
|
1769
|
+
* working directory, which a worker cannot change.
|
|
1770
|
+
*/
|
|
1771
|
+
/** How long an interrupted converge has to stop on its own before its worker is ended. */
|
|
1772
|
+
const STOP_TIMEOUT_MS = 3e4;
|
|
1773
|
+
/** How long to wait for a worker's output streams to end after it exits. */
|
|
1774
|
+
const STREAM_END_TIMEOUT_MS = 1e3;
|
|
1775
|
+
/** The worker file beside this module: `.ts` from source, `.mjs` from the built package. */
|
|
1776
|
+
const WORKER_URL = new URL(`./dev-converge-worker${path$1.extname(fileURLToPath(import.meta.url))}`, import.meta.url);
|
|
1777
|
+
function failed(tag, message) {
|
|
1778
|
+
return {
|
|
1779
|
+
kind: "outcome",
|
|
1780
|
+
outcome: {
|
|
1781
|
+
kind: "failed",
|
|
1782
|
+
reasons: [{
|
|
1783
|
+
tag,
|
|
1784
|
+
message
|
|
1785
|
+
}]
|
|
1786
|
+
},
|
|
1787
|
+
appFiles: []
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
/** The worker's own converge refuses when its working directory is not the job's, which the main thread set: that is a fault in Composer, not in how dev was called. */
|
|
1791
|
+
function workerDirectoryFault(result, cwd) {
|
|
1792
|
+
if (result.kind !== "outcome" || result.outcome.kind !== "refused" || result.outcome.reason !== "worker-thread") return result;
|
|
1793
|
+
return {
|
|
1794
|
+
...failed("InternalError", `The converge worker thread's working directory was not "${cwd}", which prisma dev set before it started the worker. This is a bug in Composer; please report it.`),
|
|
1795
|
+
appFiles: result.appFiles
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
function streamEnded(stream) {
|
|
1799
|
+
if (stream === null) return Promise.resolve();
|
|
1800
|
+
return new Promise((resolve) => {
|
|
1801
|
+
stream.once("end", resolve);
|
|
1802
|
+
stream.once("error", () => resolve());
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
function runWorker(job, report, signal, stopTimeoutMs) {
|
|
1806
|
+
return new Promise((resolve) => {
|
|
1807
|
+
const worker = new Worker(WORKER_URL, {
|
|
1808
|
+
workerData: job,
|
|
1809
|
+
stdout: true,
|
|
1810
|
+
stderr: true
|
|
1811
|
+
});
|
|
1812
|
+
const streams = [worker.stdout, worker.stderr];
|
|
1813
|
+
for (const stream of streams) stream?.setEncoding("utf8").on("data", (chunk) => report.output(chunk));
|
|
1814
|
+
const ended = Promise.all(streams.map(streamEnded));
|
|
1815
|
+
let outcome;
|
|
1816
|
+
let stopTimer;
|
|
1817
|
+
const abort = () => {
|
|
1818
|
+
worker.postMessage({ kind: "abort" });
|
|
1819
|
+
stopTimer = setTimeout(() => {
|
|
1820
|
+
outcome ??= failed("ConvergeNotStopped", `The converge did not stop within ${String(stopTimeoutMs / 1e3)}s of being interrupted, so its worker thread was ended. Alchemy's local state may not record everything it changed; run \`prisma dev\` again, or \`prisma dev --fresh\` if that fails.`);
|
|
1821
|
+
worker.terminate();
|
|
1822
|
+
}, stopTimeoutMs);
|
|
1823
|
+
};
|
|
1824
|
+
if (signal?.aborted === true) abort();
|
|
1825
|
+
else signal?.addEventListener("abort", abort, { once: true });
|
|
1826
|
+
worker.on("message", (message) => {
|
|
1827
|
+
if (!isWorkerMessage(message) || outcome !== void 0) return;
|
|
1828
|
+
if (message.kind === "event") report.onEvent(message.event);
|
|
1829
|
+
else if (message.kind === "output") report.output(message.text);
|
|
1830
|
+
else outcome = workerDirectoryFault(message.result, job.cwd);
|
|
1831
|
+
});
|
|
1832
|
+
worker.on("error", (error) => {
|
|
1833
|
+
outcome ??= failed(error instanceof Error ? error.name : "Unknown", `The converge worker thread failed before it reported an outcome: ${error instanceof Error ? error.message : String(error)}`);
|
|
1834
|
+
});
|
|
1835
|
+
worker.on("exit", (code) => {
|
|
1836
|
+
clearTimeout(stopTimer);
|
|
1837
|
+
signal?.removeEventListener("abort", abort);
|
|
1838
|
+
const settled = outcome ?? failed("ConvergeWorkerExited", `The converge worker thread exited with code ${String(code)} before it reported an outcome.`);
|
|
1839
|
+
Promise.race([ended, new Promise((done) => setTimeout(done, STREAM_END_TIMEOUT_MS))]).then(() => resolve(settled));
|
|
1840
|
+
});
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
const refused = (reason) => ({
|
|
1844
|
+
kind: "outcome",
|
|
1845
|
+
outcome: {
|
|
1846
|
+
kind: "refused",
|
|
1847
|
+
reason
|
|
1848
|
+
},
|
|
1849
|
+
appFiles: []
|
|
1850
|
+
});
|
|
1851
|
+
/**
|
|
1852
|
+
* A {@link RunDevConverge} that runs each converge in a new worker thread. The job's `cwd` must be
|
|
1853
|
+
* a real path, as `process.cwd()` reports it once changed to. `stopTimeoutMs` bounds how long an
|
|
1854
|
+
* interrupted converge may take to stop.
|
|
1855
|
+
*/
|
|
1856
|
+
function runDevConvergeInWorkerWith(options = {}) {
|
|
1857
|
+
const stopTimeoutMs = options.stopTimeoutMs ?? STOP_TIMEOUT_MS;
|
|
1858
|
+
return async (job, report, signal) => {
|
|
1859
|
+
try {
|
|
1860
|
+
if (!isMainThread && process.cwd() !== job.cwd) return refused("worker-thread");
|
|
1861
|
+
const held = await holdingConvergeProcess({}, job.cwd, () => runWorker(job, report, signal, stopTimeoutMs));
|
|
1862
|
+
return held.held ? held.value : refused("already-running");
|
|
1863
|
+
} catch (error) {
|
|
1864
|
+
return thrownResult(error);
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
const runDevConvergeInWorker = runDevConvergeInWorkerWith();
|
|
1869
|
+
/**
|
|
1870
|
+
* The dev executor (local-dev spec § 6): events out through `onEvent`,
|
|
1871
|
+
* lifetime owned by the returned DevSession. Every converge lowers the app
|
|
1872
|
+
* against the local target and runs Alchemy's plan and apply in a new worker
|
|
1873
|
+
* thread, through the app's own install (`loadAppConvergeEntry`, ADR-0066), so
|
|
1874
|
+
* each converge imports the app as it is on disk. The operation
|
|
1875
|
+
* NEVER touches process signal handlers; the host does. Reached only by lazy
|
|
1876
|
+
* import from dev.ts: this module's static graph transitively loads alchemy's
|
|
1849
1877
|
* provider tree, so the control entry must never import it statically.
|
|
1850
1878
|
*/
|
|
1879
|
+
/** `dir` as the process reports it once it changes to it, so the converge worker's directory matches; `dir` resolved when it does not exist. */
|
|
1880
|
+
function realPath(dir) {
|
|
1881
|
+
try {
|
|
1882
|
+
return fs$1.realpathSync(path$1.resolve(dir));
|
|
1883
|
+
} catch {
|
|
1884
|
+
return path$1.resolve(dir);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
function isDottedCode(code) {
|
|
1888
|
+
return /^[^.]+\.[^.]/.test(code);
|
|
1889
|
+
}
|
|
1851
1890
|
function failureMessage(error) {
|
|
1852
1891
|
return error instanceof Error ? error.message : String(error);
|
|
1853
1892
|
}
|
|
@@ -1913,11 +1952,90 @@ function isDevPreflightResult(value) {
|
|
|
1913
1952
|
return (payload === void 0 || typeof payload === "string") && typeof plainVariableText === "object" && plainVariableText !== null && Object.values(plainVariableText).every((text) => typeof text === "string");
|
|
1914
1953
|
}
|
|
1915
1954
|
const olderLocalTargetError = (id) => /* @__PURE__ */ new Error(`The extension "${id}" returned a dev preflight result prisma dev cannot read: its local target was built for an older @prisma/composer. Upgrade "${id}" to a version built for the @prisma/composer this app uses.`);
|
|
1955
|
+
/** The app secrets under the graph's secrets keys, each with text, for the local providers. In memory only. */
|
|
1956
|
+
function namedSecrets(current) {
|
|
1957
|
+
const named = {};
|
|
1958
|
+
for (const key of secretsKeys(current.graph)) {
|
|
1959
|
+
const text = current.secrets[key];
|
|
1960
|
+
if (text !== void 0 && text !== "") named[key] = text;
|
|
1961
|
+
}
|
|
1962
|
+
return named;
|
|
1963
|
+
}
|
|
1964
|
+
/** A structured error's text with its why and fix after it, as dev reports a rebuild that failed on one. */
|
|
1965
|
+
function withHelp(error) {
|
|
1966
|
+
return [
|
|
1967
|
+
error.summary,
|
|
1968
|
+
error.why,
|
|
1969
|
+
error.fix
|
|
1970
|
+
].filter((line) => line !== void 0).join("\n");
|
|
1971
|
+
}
|
|
1972
|
+
/** The structured error a converge worker raised, rebuilt from its envelope; undefined when its code is not a dotted code. */
|
|
1973
|
+
function fromEnvelope(error) {
|
|
1974
|
+
if (!isDottedCode(error.code)) return void 0;
|
|
1975
|
+
return new CliStructuredError(error.code, error.summary, {
|
|
1976
|
+
severity: error.severity,
|
|
1977
|
+
...error.why === void 0 ? {} : { why: error.why },
|
|
1978
|
+
...error.fix === void 0 ? {} : { fix: error.fix },
|
|
1979
|
+
...error.where === void 0 ? {} : { where: error.where },
|
|
1980
|
+
...error.meta === void 0 ? {} : { meta: error.meta },
|
|
1981
|
+
...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl }
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1984
|
+
/** How a rebuild reports a structured error its worker raised before the converge began. */
|
|
1985
|
+
function errorFailure(error, redact, lookupKept) {
|
|
1986
|
+
return {
|
|
1987
|
+
code: "DEV.CONVERGE_FAILED",
|
|
1988
|
+
message: lookupKept ? `${redact(withHelp(error))}\n${LOOKUP_KEPT}` : redact(withHelp(error)),
|
|
1989
|
+
reasons: [{
|
|
1990
|
+
tag: error.code,
|
|
1991
|
+
message: redact(error.summary)
|
|
1992
|
+
}]
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1995
|
+
/** The code and text a converge that failed or was refused settles as. */
|
|
1996
|
+
function convergeFailure(outcome, redact) {
|
|
1997
|
+
if (outcome.kind === "refused") return outcome.reason === "already-running" ? {
|
|
1998
|
+
code: "DEV.CONVERGE_RUNNING",
|
|
1999
|
+
message: "Another converge is already running in this process.",
|
|
2000
|
+
reasons: []
|
|
2001
|
+
} : {
|
|
2002
|
+
code: "DEV.WORKER_THREAD",
|
|
2003
|
+
message: "dev's converge cannot run: dev was called from a thread that cannot change the process's working directory to its cwd.",
|
|
2004
|
+
reasons: []
|
|
2005
|
+
};
|
|
2006
|
+
const rootInputUnread = rootInputUnreadReason(outcome);
|
|
2007
|
+
return {
|
|
2008
|
+
code: "DEV.CONVERGE_FAILED",
|
|
2009
|
+
message: outcome.reasons.some(({ tag }) => tag === "GraphChangedError") ? NODES_CHANGED : rootInputUnread !== void 0 ? `${ROOT_INPUT_CHANGED}\n${redact(rootInputUnread.message)}` : redact(withComposerAdvice(convergeReasonsText(outcome.reasons))),
|
|
2010
|
+
reasons: outcome.reasons.map(({ tag, message }) => ({
|
|
2011
|
+
tag,
|
|
2012
|
+
message: redact(message)
|
|
2013
|
+
}))
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
function rootInputUnreadReason(outcome) {
|
|
2017
|
+
return outcome.kind === "refused" ? void 0 : outcome.reasons.find(({ tag }) => tag === ROOT_INPUT_UNREAD_ERROR);
|
|
2018
|
+
}
|
|
2019
|
+
const LOOKUP_KEPT = "The directory this import names has an `index.ts` now, but Bun keeps a failed lookup of a directory import for as long as the process runs. Restart `prisma dev` to load it.";
|
|
2020
|
+
const NODES_CHANGED = "The app now has a node added or removed. A running `prisma dev` keeps the nodes it started with, so restart `prisma dev` to apply the change.";
|
|
2021
|
+
const ROOT_INPUT_CHANGED = "The app's root now passes on a field of its input that dev did not read when it started, so the field has no value here. Restart `prisma dev` to apply the change.";
|
|
2022
|
+
const CHANGED_WHILE_STARTING = "An app file was edited after dev loaded it, or a module body builds a different graph each time.";
|
|
2023
|
+
const DEV_PLAIN = "prisma dev hands every plain value to the local services as plain configuration, and never hands a secret that way.";
|
|
2024
|
+
const REFUSAL_HELP = {
|
|
2025
|
+
"DEV.CONVERGE_RUNNING": {
|
|
2026
|
+
why: "A converge sets the process's environment and working directory while Alchemy runs, so two cannot overlap.",
|
|
2027
|
+
fix: "Wait for the other converge to finish, or run dev in its own process."
|
|
2028
|
+
},
|
|
2029
|
+
"DEV.WORKER_THREAD": {
|
|
2030
|
+
why: "Each dev converge runs in a worker thread with the process's working directory set to dev's cwd, because Alchemy reads `.env` and keeps `.alchemy` there. Only the main thread can change the process's working directory.",
|
|
2031
|
+
fix: "Call dev from the main thread, or with the process's working directory as its cwd."
|
|
2032
|
+
}
|
|
2033
|
+
};
|
|
1916
2034
|
/** Runs the full dev pipeline; resolves to a running session or a structured failure. */
|
|
1917
2035
|
async function executeDev(input, deps, cwd) {
|
|
1918
|
-
const redaction = new SecretRedaction(process.env);
|
|
2036
|
+
const redaction = deps.redaction ?? new SecretRedaction(process.env);
|
|
1919
2037
|
try {
|
|
1920
|
-
const result = await executeDevInner(input, deps, cwd, redaction);
|
|
2038
|
+
const result = await executeDevInner(input, deps, realPath(cwd), redaction);
|
|
1921
2039
|
return result.ok ? result : notOk(redactError(result.failure, redaction));
|
|
1922
2040
|
} catch (error) {
|
|
1923
2041
|
throw redactThrown(error, redaction);
|
|
@@ -1931,8 +2049,9 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
1931
2049
|
removeLeftoverAppConfigurationFiles(cwd);
|
|
1932
2050
|
let pipeline;
|
|
1933
2051
|
let resolved;
|
|
2052
|
+
let definitionFiles;
|
|
1934
2053
|
const containers = /* @__PURE__ */ new Map();
|
|
1935
|
-
|
|
2054
|
+
const preflightPayloads = /* @__PURE__ */ new Map();
|
|
1936
2055
|
const plainVariableText = {};
|
|
1937
2056
|
const attachmentsById = /* @__PURE__ */ new Map();
|
|
1938
2057
|
const emit = (event) => {
|
|
@@ -1951,6 +2070,8 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
1951
2070
|
pipeline = await runPipeline(input.entry, input.name, environment, cwd, input.config, pipelineDeps);
|
|
1952
2071
|
const { graph, name } = pipeline;
|
|
1953
2072
|
const config = pipeline.configSource.value;
|
|
2073
|
+
definitionFiles = [.../* @__PURE__ */ new Set([...pipeline.entryModule.files, ...authoringModuleTargets(pipeline.entryModule.path, graph).flatMap((target) => target.paths)])];
|
|
2074
|
+
if (deps.runDevConverge === void 0) await loadAppConvergeEntry(path$1.dirname(pipeline.configSource.file));
|
|
1954
2075
|
resolved = await resolveLocalTargets(config);
|
|
1955
2076
|
for (const [id, dev] of resolved) {
|
|
1956
2077
|
let container;
|
|
@@ -1977,7 +2098,6 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
1977
2098
|
throw toStructured("DEV.TEARDOWN_FAILED", error);
|
|
1978
2099
|
}
|
|
1979
2100
|
}
|
|
1980
|
-
const preflightPayloads = /* @__PURE__ */ new Map();
|
|
1981
2101
|
for (const [id, dev] of resolved) {
|
|
1982
2102
|
if (dev.preflight === void 0) continue;
|
|
1983
2103
|
try {
|
|
@@ -1999,12 +2119,6 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
1999
2119
|
throw toStructured("DEV.PREFLIGHT_FAILED", error);
|
|
2000
2120
|
}
|
|
2001
2121
|
}
|
|
2002
|
-
try {
|
|
2003
|
-
preflightTransportEnv = preflightEnv(preflightPayloads);
|
|
2004
|
-
} catch (error) {
|
|
2005
|
-
throw toStructured("DEV.PREFLIGHT_FAILED", error);
|
|
2006
|
-
}
|
|
2007
|
-
for (const extension of config.extensions) preflightTransportEnv[preflightEnvVarName(extension.id)] ??= "";
|
|
2008
2122
|
for (const [id, dev] of resolved) {
|
|
2009
2123
|
if (dev.emulators === void 0) continue;
|
|
2010
2124
|
try {
|
|
@@ -2037,69 +2151,66 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2037
2151
|
if (CliStructuredError.is(error)) return notOk(error);
|
|
2038
2152
|
throw error;
|
|
2039
2153
|
}
|
|
2040
|
-
const
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
command: "deploy",
|
|
2053
|
-
stackFileRelativePath: devStackRelativePath(environment),
|
|
2054
|
-
cwd,
|
|
2055
|
-
stage: environment,
|
|
2056
|
-
containerEnv: containerEnv(containers),
|
|
2057
|
-
preflightEnv: preflightTransportEnv,
|
|
2058
|
-
env: handover.env,
|
|
2059
|
-
redactedValues: redaction.allValues()
|
|
2060
|
-
}),
|
|
2061
|
-
handover
|
|
2062
|
-
};
|
|
2063
|
-
};
|
|
2064
|
-
const converge = async (p) => {
|
|
2065
|
-
const { invocation, handover } = invocationFor(p);
|
|
2066
|
-
let stackPath;
|
|
2154
|
+
const redact = (text) => redaction.redact(text);
|
|
2155
|
+
const runDevConverge = deps.runDevConverge ?? runDevConvergeInWorker;
|
|
2156
|
+
const startReads = valueReadsSnapshot(pipeline.graph);
|
|
2157
|
+
const steps = stepTracker((step) => step.name === "converge" ? step.id : `${step.converge}:${step.resourceId}`, emit);
|
|
2158
|
+
/**
|
|
2159
|
+
* Lowers `current` against the local target and plans and applies it in a
|
|
2160
|
+
* worker thread, as the step `id`. The worker, and every step it opened, end
|
|
2161
|
+
* before this returns.
|
|
2162
|
+
*/
|
|
2163
|
+
const converge = async (current, signal, id) => {
|
|
2164
|
+
refuseSecretsInRootInput(current.graph.appConfigurationRead, redaction.knownSecrets, DEV_PLAIN);
|
|
2165
|
+
refuseSecretsInPlainVariables(plainVariableText, redaction.knownSecrets, DEV_PLAIN);
|
|
2067
2166
|
try {
|
|
2068
2167
|
claimDevEnvironmentName(devDir, environment);
|
|
2069
|
-
stackPath = writeDevStackFile({
|
|
2070
|
-
entryPath: p.entryModule.path,
|
|
2071
|
-
cwd,
|
|
2072
|
-
environment,
|
|
2073
|
-
configFile: p.configSource.file,
|
|
2074
|
-
name: p.name,
|
|
2075
|
-
assembled: p.assembled
|
|
2076
|
-
});
|
|
2077
|
-
handover.writeFile();
|
|
2078
2168
|
} catch (error) {
|
|
2079
|
-
throw toStructured("DEV.
|
|
2169
|
+
throw toStructured("DEV.ENVIRONMENT_WRITE_FAILED", error);
|
|
2080
2170
|
}
|
|
2081
|
-
|
|
2171
|
+
if (current.graph.root.node.kind !== "module") throw new InternalError("runPipeline admitted a root that is not a module");
|
|
2172
|
+
steps.start({
|
|
2173
|
+
name: "converge",
|
|
2174
|
+
id
|
|
2175
|
+
});
|
|
2176
|
+
const result = await lowerAndConverge(current, signal, id);
|
|
2177
|
+
steps.closeOpen(result.kind === "outcome" && result.outcome.kind === "applied" ? "ok" : "failed");
|
|
2178
|
+
return result;
|
|
2179
|
+
};
|
|
2180
|
+
const lowerAndConverge = async (current, signal, id) => {
|
|
2181
|
+
const output = interactionMessages(steps, redaction);
|
|
2082
2182
|
try {
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2183
|
+
return await runDevConverge({
|
|
2184
|
+
configFile: current.configSource.file,
|
|
2185
|
+
entry: current.entryModule.path,
|
|
2186
|
+
appDir: path$1.dirname(current.configSource.file),
|
|
2187
|
+
cwd,
|
|
2188
|
+
name: current.name,
|
|
2189
|
+
environment,
|
|
2190
|
+
appConfigurationRead: current.graph.appConfigurationRead,
|
|
2191
|
+
bundles: Object.fromEntries(Object.entries(current.assembled.bundles).map(([address, { dir, entry }]) => [address, {
|
|
2192
|
+
dir,
|
|
2193
|
+
entry
|
|
2194
|
+
}])),
|
|
2195
|
+
unassembled: Object.keys(current.assembled.devServers),
|
|
2196
|
+
containers: Object.fromEntries([...containers].map(([extension, container]) => [extension, container.serialize()])),
|
|
2197
|
+
preflightPayloads: Object.fromEntries(preflightPayloads),
|
|
2198
|
+
devDir,
|
|
2199
|
+
plainVariableText,
|
|
2200
|
+
namedSecrets: namedSecrets(current),
|
|
2201
|
+
nodeAddresses: nodeAddresses(pipeline.graph),
|
|
2202
|
+
valueReads: startReads
|
|
2203
|
+
}, {
|
|
2204
|
+
onEvent: (event) => reportConvergeEvent(steps, event, redact, (resource) => ({
|
|
2205
|
+
name: "apply-resource",
|
|
2206
|
+
converge: id,
|
|
2207
|
+
...resource
|
|
2208
|
+
})),
|
|
2209
|
+
output: (text) => output.push(text)
|
|
2210
|
+
}, signal);
|
|
2095
2211
|
} finally {
|
|
2096
|
-
|
|
2212
|
+
output.end();
|
|
2097
2213
|
}
|
|
2098
|
-
return {
|
|
2099
|
-
outcome,
|
|
2100
|
-
stackPath,
|
|
2101
|
-
invocation
|
|
2102
|
-
};
|
|
2103
2214
|
};
|
|
2104
2215
|
const stopStartedServices = async () => {
|
|
2105
2216
|
for (const attachment of attachmentsById.values()) try {
|
|
@@ -2131,27 +2242,49 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2131
2242
|
if (restarted) onRestarted?.(address, server);
|
|
2132
2243
|
}
|
|
2133
2244
|
};
|
|
2134
|
-
let
|
|
2245
|
+
let firstResult;
|
|
2135
2246
|
try {
|
|
2136
|
-
|
|
2247
|
+
firstResult = await converge(pipeline, input.signal, "dev.converge");
|
|
2137
2248
|
} catch (error) {
|
|
2138
2249
|
await stopStartedServices();
|
|
2139
2250
|
if (CliStructuredError.is(error)) return notOk(error);
|
|
2140
2251
|
throw error;
|
|
2141
2252
|
}
|
|
2142
|
-
|
|
2143
|
-
if (firstStatus !== 0) {
|
|
2253
|
+
if (firstResult.kind === "value-reads-changed") {
|
|
2144
2254
|
await stopStartedServices();
|
|
2145
|
-
return notOk(new CliStructuredError("DEV.CONVERGE_FAILED",
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2255
|
+
return notOk(new CliStructuredError("DEV.CONVERGE_FAILED", `The platform variables the app reads changed while dev started: ${valueReadsChangeText(firstResult.change)}.`, {
|
|
2256
|
+
why: CHANGED_WHILE_STARTING,
|
|
2257
|
+
fix: "Run dev again."
|
|
2258
|
+
}));
|
|
2259
|
+
}
|
|
2260
|
+
if (firstResult.kind === "error") {
|
|
2261
|
+
await stopStartedServices();
|
|
2262
|
+
return notOk(fromEnvelope(firstResult.error) ?? new CliStructuredError("DEV.CONVERGE_FAILED", `The app could not be converged.\n${redact(withHelp(firstResult.error))}`, { meta: { reasons: [{
|
|
2263
|
+
tag: firstResult.error.code,
|
|
2264
|
+
message: firstResult.error.summary
|
|
2265
|
+
}] } }));
|
|
2266
|
+
}
|
|
2267
|
+
const first = firstResult.outcome;
|
|
2268
|
+
if (first.kind === "interrupted") {
|
|
2269
|
+
await stopStartedServices();
|
|
2270
|
+
return notOk(new CliStructuredError("DEV.INTERRUPTED", "dev was interrupted while it converged.", {
|
|
2271
|
+
why: "It stopped while Alchemy planned or applied the app. Resources it had already changed stay as they are.",
|
|
2272
|
+
fix: "Run dev again to finish."
|
|
2273
|
+
}));
|
|
2274
|
+
}
|
|
2275
|
+
if (first.kind !== "applied") {
|
|
2276
|
+
await stopStartedServices();
|
|
2277
|
+
const rootInputUnread = rootInputUnreadReason(first);
|
|
2278
|
+
if (rootInputUnread !== void 0) return notOk(new CliStructuredError("DEV.CONVERGE_FAILED", `The app could not be converged.\n${redact(rootInputUnread.message)}`, {
|
|
2279
|
+
why: CHANGED_WHILE_STARTING,
|
|
2280
|
+
fix: "Run dev again.",
|
|
2281
|
+
meta: { reasons: [{
|
|
2282
|
+
tag: rootInputUnread.tag,
|
|
2283
|
+
message: redact(rootInputUnread.message)
|
|
2284
|
+
}] }
|
|
2285
|
+
}));
|
|
2286
|
+
const failure = convergeFailure(first, redact);
|
|
2287
|
+
return notOk(failure.code === "DEV.CONVERGE_FAILED" ? new CliStructuredError(failure.code, `The app could not be converged.\n${failure.message}`, { meta: { reasons: failure.reasons } }) : new CliStructuredError(failure.code, failure.message, REFUSAL_HELP[failure.code]));
|
|
2155
2288
|
}
|
|
2156
2289
|
const attachments = [...attachmentsById.values()];
|
|
2157
2290
|
const started = [];
|
|
@@ -2161,6 +2294,8 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2161
2294
|
const stopBeforeExit = () => {
|
|
2162
2295
|
for (const attachment of attachments) attachment.stopAppBeforeExit?.();
|
|
2163
2296
|
};
|
|
2297
|
+
const stopController = new AbortController();
|
|
2298
|
+
const convergeSignal = stopController.signal;
|
|
2164
2299
|
try {
|
|
2165
2300
|
for (const attachment of attachments) {
|
|
2166
2301
|
started.push(attachment);
|
|
@@ -2207,11 +2342,26 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2207
2342
|
})();
|
|
2208
2343
|
}
|
|
2209
2344
|
const bundleWatch = watchTargetsFrom(pipeline.assembled.bundles);
|
|
2210
|
-
const
|
|
2345
|
+
const watchedDefinitions = /* @__PURE__ */ new Set([...definitionFiles, ...firstResult.appFiles]);
|
|
2346
|
+
const definitionTargets = (files) => [...files].map((file) => ({
|
|
2347
|
+
address: pipeline.graph.root.id,
|
|
2348
|
+
paths: [file]
|
|
2349
|
+
}));
|
|
2350
|
+
const targets = [...bundleWatch.targets, ...definitionTargets(watchedDefinitions)];
|
|
2211
2351
|
for (const address of bundleWatch.unwatchable) emit({
|
|
2212
2352
|
kind: "unwatchable",
|
|
2213
2353
|
address
|
|
2214
2354
|
});
|
|
2355
|
+
let stopping = false;
|
|
2356
|
+
let rebuilds = 0;
|
|
2357
|
+
let converging;
|
|
2358
|
+
const laterWatches = [];
|
|
2359
|
+
const watchNewAppFiles = (files) => {
|
|
2360
|
+
const added = files.filter((file) => !watchedDefinitions.has(file));
|
|
2361
|
+
if (added.length === 0 || stopping) return;
|
|
2362
|
+
for (const file of added) watchedDefinitions.add(file);
|
|
2363
|
+
laterWatches.push(watchFiles(definitionTargets(added), onChange, onWatchError));
|
|
2364
|
+
};
|
|
2215
2365
|
const watchDeps = {
|
|
2216
2366
|
runAssembler: deps.runAssembler,
|
|
2217
2367
|
devServers: true,
|
|
@@ -2230,13 +2380,15 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2230
2380
|
let readsChanged = false;
|
|
2231
2381
|
const paused = () => {
|
|
2232
2382
|
if (valuesChanged || readsChanged) return true;
|
|
2233
|
-
if (
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2383
|
+
if (configChanged || contentHash(configFile) !== startedConfig) {
|
|
2384
|
+
configChanged = true;
|
|
2385
|
+
emit({
|
|
2386
|
+
kind: "config-changed",
|
|
2387
|
+
file: configFile
|
|
2388
|
+
});
|
|
2389
|
+
return true;
|
|
2390
|
+
}
|
|
2391
|
+
return false;
|
|
2240
2392
|
};
|
|
2241
2393
|
configWatch = watchFiles([{
|
|
2242
2394
|
address: configFile,
|
|
@@ -2245,30 +2397,43 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2245
2397
|
const rebuild = async () => {
|
|
2246
2398
|
try {
|
|
2247
2399
|
const rePipeline = await runPipeline(input.entry, input.name, environment, cwd, input.config, watchDeps);
|
|
2400
|
+
if (stopping) return;
|
|
2248
2401
|
if (!sameValues(pipeline, rePipeline)) {
|
|
2249
2402
|
if (!valuesChanged) emit({ kind: "values-changed" });
|
|
2250
2403
|
valuesChanged = true;
|
|
2251
2404
|
return;
|
|
2252
2405
|
}
|
|
2253
|
-
|
|
2254
|
-
|
|
2406
|
+
rebuilds += 1;
|
|
2407
|
+
converging = converge(rePipeline, convergeSignal, `dev.rebuild.${String(rebuilds)}`);
|
|
2408
|
+
const result = await converging.finally(() => {
|
|
2409
|
+
converging = void 0;
|
|
2410
|
+
});
|
|
2411
|
+
watchNewAppFiles(result.appFiles);
|
|
2412
|
+
if (result.kind === "value-reads-changed") {
|
|
2255
2413
|
if (!readsChanged) emit({
|
|
2256
2414
|
kind: "value-reads-changed",
|
|
2257
|
-
...change
|
|
2415
|
+
...result.change
|
|
2258
2416
|
});
|
|
2259
2417
|
readsChanged = true;
|
|
2260
2418
|
return;
|
|
2261
2419
|
}
|
|
2262
|
-
|
|
2263
|
-
if (outcome.signal !== null || outcome.exitCode !== 0) {
|
|
2420
|
+
if (result.kind === "error") {
|
|
2264
2421
|
emit({
|
|
2265
2422
|
kind: "converge-failed",
|
|
2266
|
-
|
|
2267
|
-
reproduceCommand: reproduceCommand(invocation, outcome),
|
|
2268
|
-
cwd
|
|
2423
|
+
...errorFailure(result.error, redact, result.lookupKept === true)
|
|
2269
2424
|
});
|
|
2270
2425
|
return;
|
|
2271
2426
|
}
|
|
2427
|
+
const { outcome } = result;
|
|
2428
|
+
if (outcome.kind === "interrupted") return;
|
|
2429
|
+
if (outcome.kind !== "applied") {
|
|
2430
|
+
emit({
|
|
2431
|
+
kind: "converge-failed",
|
|
2432
|
+
...convergeFailure(outcome, redact)
|
|
2433
|
+
});
|
|
2434
|
+
return;
|
|
2435
|
+
}
|
|
2436
|
+
if (stopping) return;
|
|
2272
2437
|
await serveDevServers(rePipeline.graph, rePipeline.assembled.devServers, (address, server) => emit({
|
|
2273
2438
|
kind: "dev-server-restarted",
|
|
2274
2439
|
address,
|
|
@@ -2285,28 +2450,27 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2285
2450
|
});
|
|
2286
2451
|
}
|
|
2287
2452
|
};
|
|
2288
|
-
let rebuilding
|
|
2453
|
+
let rebuilding;
|
|
2289
2454
|
let changedDuringRebuild = false;
|
|
2290
2455
|
const rebuildUntilSettled = async () => {
|
|
2291
|
-
rebuilding = true;
|
|
2292
2456
|
do {
|
|
2293
2457
|
changedDuringRebuild = false;
|
|
2294
2458
|
await rebuild();
|
|
2295
|
-
} while (changedDuringRebuild && !paused());
|
|
2296
|
-
rebuilding =
|
|
2459
|
+
} while (changedDuringRebuild && !stopping && !paused());
|
|
2460
|
+
rebuilding = void 0;
|
|
2297
2461
|
};
|
|
2298
|
-
|
|
2299
|
-
if (paused()) return;
|
|
2300
|
-
if (rebuilding) {
|
|
2462
|
+
function onChange() {
|
|
2463
|
+
if (stopping || paused()) return;
|
|
2464
|
+
if (rebuilding !== void 0) {
|
|
2301
2465
|
changedDuringRebuild = true;
|
|
2302
2466
|
return;
|
|
2303
2467
|
}
|
|
2304
|
-
rebuildUntilSettled();
|
|
2305
|
-
}
|
|
2468
|
+
rebuilding = rebuildUntilSettled();
|
|
2469
|
+
}
|
|
2470
|
+
watch = watchFiles(targets, onChange, onWatchError);
|
|
2306
2471
|
const startedWatch = watch;
|
|
2307
2472
|
const startedConfigWatch = configWatch;
|
|
2308
2473
|
await Promise.all([watch.ready, configWatch.ready]);
|
|
2309
|
-
let stopping = false;
|
|
2310
2474
|
let resolveClosed = () => void 0;
|
|
2311
2475
|
const closed = new Promise((resolve) => {
|
|
2312
2476
|
resolveClosed = resolve;
|
|
@@ -2315,10 +2479,14 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2315
2479
|
if (!stopping) {
|
|
2316
2480
|
stopping = true;
|
|
2317
2481
|
emit({ kind: "stopping" });
|
|
2482
|
+
stopController.abort();
|
|
2318
2483
|
following.abort();
|
|
2319
2484
|
startedWatch.stop();
|
|
2320
2485
|
startedConfigWatch.stop();
|
|
2486
|
+
for (const later of laterWatches) later.stop();
|
|
2487
|
+
input.signal?.removeEventListener("abort", stopOnAbort);
|
|
2321
2488
|
(async () => {
|
|
2489
|
+
await converging?.catch(() => void 0);
|
|
2322
2490
|
for (const attachment of attachments) try {
|
|
2323
2491
|
await attachment.stopApp();
|
|
2324
2492
|
} catch (error) {
|
|
@@ -2334,6 +2502,11 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2334
2502
|
}
|
|
2335
2503
|
return closed;
|
|
2336
2504
|
};
|
|
2505
|
+
function stopOnAbort() {
|
|
2506
|
+
stop();
|
|
2507
|
+
}
|
|
2508
|
+
if (input.signal?.aborted === true) stop();
|
|
2509
|
+
else input.signal?.addEventListener("abort", stopOnAbort, { once: true });
|
|
2337
2510
|
return ok({
|
|
2338
2511
|
endpoints,
|
|
2339
2512
|
stop,
|
|
@@ -2352,4 +2525,4 @@ async function executeDevInner(input, deps, cwd, redaction) {
|
|
|
2352
2525
|
//#endregion
|
|
2353
2526
|
export { executeDev };
|
|
2354
2527
|
|
|
2355
|
-
//# sourceMappingURL=execute-dev-
|
|
2528
|
+
//# sourceMappingURL=execute-dev-C42niIFY-Cl5XzBy3.mjs.map
|