@dreamboard-games/cli 0.1.30-alpha.19 → 0.1.30-alpha.20
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/README.md +22 -102
- package/dist/agent-verifier/agent-workspace-verifier.mjs +1508 -55
- package/dist/agent-verifier/agent-workspace-verifier.mjs.map +1 -1
- package/dist/agent-verifier/{chunk-V7ABTZXW.mjs → chunk-4I2WWAPK.mjs} +26 -7
- package/dist/agent-verifier/chunk-4I2WWAPK.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-7LFDFXLS.mjs → chunk-BWBN2TDJ.mjs} +338 -133
- package/dist/agent-verifier/chunk-BWBN2TDJ.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-AWZ4M4NS.mjs → chunk-DQUYBIGQ.mjs} +5 -6
- package/dist/agent-verifier/chunk-DQUYBIGQ.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-H5L4KK4Y.mjs → chunk-GCFGAFYC.mjs} +7 -7
- package/dist/agent-verifier/chunk-GCFGAFYC.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-TAEQKBJB.mjs → chunk-GWRZRWCF.mjs} +1 -1
- package/dist/agent-verifier/chunk-GWRZRWCF.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-6AKXIY37.mjs → chunk-IWB4L2HV.mjs} +3 -3
- package/dist/agent-verifier/chunk-IWB4L2HV.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-334H4LE4.mjs → chunk-KDAQ4CZY.mjs} +3 -3
- package/dist/agent-verifier/{chunk-WSIYUUSD.mjs → chunk-TIDX3YLW.mjs} +2 -2
- package/dist/agent-verifier/{chunk-WSIYUUSD.mjs.map → chunk-TIDX3YLW.mjs.map} +1 -1
- package/dist/agent-verifier/{chunk-UMW24KZI.mjs → chunk-UXGTT25Q.mjs} +3 -3
- package/dist/agent-verifier/{global-config-SXR6X3OZ.mjs → global-config-IXZLY4BS.mjs} +4 -4
- package/dist/agent-verifier/{local-files-DAFIR7SN.mjs → local-files-OF4QFISU.mjs} +4 -4
- package/dist/agent-verifier/{chunk-POBFNXD4.mjs → local-typecheck-DHVLM37Z.mjs} +3 -3
- package/dist/agent-verifier/local-typecheck-DHVLM37Z.mjs.map +1 -0
- package/dist/agent-verifier/{materialize-workspace-PWNT6HQK.mjs → materialize-workspace-VS5RHSBO.mjs} +7 -7
- package/dist/agent-verifier/{chunk-HLHT57AW.mjs → reducer-bundle-preflight-GLUJKTWU.mjs} +13 -10
- package/dist/agent-verifier/reducer-bundle-preflight-GLUJKTWU.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-INIK6LHK.mjs → reducer-contract-preflight-WVQQPW5F.mjs} +6 -5
- package/dist/agent-verifier/reducer-contract-preflight-WVQQPW5F.mjs.map +1 -0
- package/dist/agent-verifier/{chunk-3Y4FRMTK.mjs → reducer-native-test-harness-H6G6RBRY.mjs} +150 -34
- package/dist/agent-verifier/reducer-native-test-harness-H6G6RBRY.mjs.map +1 -0
- package/dist/agent-verifier/{static-scaffold-HXUQLJVN.mjs → static-scaffold-C36KROJA.mjs} +3 -3
- package/dist/agent-verifier/{workspace-dependencies-ZMHPHVQV.mjs → workspace-dependencies-5HEEKZFP.mjs} +4 -2
- package/dist/authoring-compatibility-internal.js +2 -2
- package/dist/{chunk-R6RB4EKH.js → chunk-5PJWUB6W.js} +179 -210
- package/dist/chunk-5PJWUB6W.js.map +1 -0
- package/dist/{chunk-YRSE5DLH.js → chunk-EJGB3IR7.js} +422 -264
- package/dist/chunk-EJGB3IR7.js.map +1 -0
- package/dist/{chunk-FFO2IJL3.js → chunk-EQNBQVIW.js} +1 -1
- package/dist/chunk-EQNBQVIW.js.map +1 -0
- package/dist/{chunk-VWMKJL4A.js → chunk-UI7NWSYA.js} +3 -3
- package/dist/chunk-UI7NWSYA.js.map +1 -0
- package/dist/{global-config-UHGWFJIK.js → global-config-GK2UC2X6.js} +3 -3
- package/dist/index.js +2691 -3953
- package/dist/index.js.map +1 -1
- package/dist/internal.js +4 -4
- package/package.json +1 -1
- package/release/authoring-release-set.json +2 -2
- package/skills/dreamboard/SKILL.md +30 -28
- package/skills/dreamboard/references/building-your-first-game.md +15 -15
- package/skills/dreamboard/references/cli.md +48 -47
- package/skills/dreamboard/references/quickstart.md +16 -13
- package/skills/dreamboard/references/testing.md +10 -10
- package/dist/agent-verifier/chunk-3Y4FRMTK.mjs.map +0 -1
- package/dist/agent-verifier/chunk-5D3OJBDT.mjs +0 -1547
- package/dist/agent-verifier/chunk-5D3OJBDT.mjs.map +0 -1
- package/dist/agent-verifier/chunk-6AKXIY37.mjs.map +0 -1
- package/dist/agent-verifier/chunk-7LFDFXLS.mjs.map +0 -1
- package/dist/agent-verifier/chunk-AWZ4M4NS.mjs.map +0 -1
- package/dist/agent-verifier/chunk-H5L4KK4Y.mjs.map +0 -1
- package/dist/agent-verifier/chunk-HLHT57AW.mjs.map +0 -1
- package/dist/agent-verifier/chunk-INIK6LHK.mjs.map +0 -1
- package/dist/agent-verifier/chunk-LEWM26XR.mjs +0 -618
- package/dist/agent-verifier/chunk-LEWM26XR.mjs.map +0 -1
- package/dist/agent-verifier/chunk-PLXXH5LY.mjs +0 -222
- package/dist/agent-verifier/chunk-PLXXH5LY.mjs.map +0 -1
- package/dist/agent-verifier/chunk-POBFNXD4.mjs.map +0 -1
- package/dist/agent-verifier/chunk-TAEQKBJB.mjs.map +0 -1
- package/dist/agent-verifier/chunk-V7ABTZXW.mjs.map +0 -1
- package/dist/agent-verifier/chunk-ZOR5FTIG.mjs +0 -39
- package/dist/agent-verifier/chunk-ZOR5FTIG.mjs.map +0 -1
- package/dist/agent-verifier/compile-MO2URO5Z.mjs +0 -317
- package/dist/agent-verifier/compile-MO2URO5Z.mjs.map +0 -1
- package/dist/agent-verifier/local-typecheck-3JXL2NMG.mjs +0 -10
- package/dist/agent-verifier/reducer-bundle-preflight-3DSXIELT.mjs +0 -20
- package/dist/agent-verifier/reducer-contract-preflight-FQB7M4PU.mjs +0 -11
- package/dist/agent-verifier/reducer-native-test-harness-X2KQYSCD.mjs +0 -53
- package/dist/agent-verifier/reducer-native-test-harness-X2KQYSCD.mjs.map +0 -1
- package/dist/agent-verifier/static-scaffold-HXUQLJVN.mjs.map +0 -1
- package/dist/agent-verifier/sync-5YM4CSXL.mjs +0 -598
- package/dist/agent-verifier/sync-5YM4CSXL.mjs.map +0 -1
- package/dist/agent-verifier/test-CNNVTFIG.mjs +0 -356
- package/dist/agent-verifier/test-CNNVTFIG.mjs.map +0 -1
- package/dist/agent-verifier/workspace-dependencies-ZMHPHVQV.mjs.map +0 -1
- package/dist/chunk-FFO2IJL3.js.map +0 -1
- package/dist/chunk-R6RB4EKH.js.map +0 -1
- package/dist/chunk-VWMKJL4A.js.map +0 -1
- package/dist/chunk-YRSE5DLH.js.map +0 -1
- package/dist/global-config-UHGWFJIK.js.map +0 -1
- package/skills/dreamboard/scripts/events-extract.mjs +0 -218
- /package/dist/agent-verifier/{chunk-334H4LE4.mjs.map → chunk-KDAQ4CZY.mjs.map} +0 -0
- /package/dist/agent-verifier/{chunk-UMW24KZI.mjs.map → chunk-UXGTT25Q.mjs.map} +0 -0
- /package/dist/agent-verifier/{global-config-SXR6X3OZ.mjs.map → global-config-IXZLY4BS.mjs.map} +0 -0
- /package/dist/agent-verifier/{local-files-DAFIR7SN.mjs.map → local-files-OF4QFISU.mjs.map} +0 -0
- /package/dist/agent-verifier/{materialize-workspace-PWNT6HQK.mjs.map → materialize-workspace-VS5RHSBO.mjs.map} +0 -0
- /package/dist/agent-verifier/{local-typecheck-3JXL2NMG.mjs.map → static-scaffold-C36KROJA.mjs.map} +0 -0
- /package/dist/agent-verifier/{reducer-bundle-preflight-3DSXIELT.mjs.map → workspace-dependencies-5HEEKZFP.mjs.map} +0 -0
- /package/dist/{agent-verifier/reducer-contract-preflight-FQB7M4PU.mjs.map → global-config-GK2UC2X6.js.map} +0 -0
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
CONFIG_FLAG_ARGS,
|
|
4
|
-
defineCommand,
|
|
5
|
-
findProjectCompiledResultsForRevision,
|
|
6
|
-
getProjectCompiledResultSdk,
|
|
7
|
-
parseConfigFlags,
|
|
8
|
-
uploadInitialProjectionSdk
|
|
9
|
-
} from "./chunk-LEWM26XR.mjs";
|
|
10
|
-
import {
|
|
11
|
-
getProjectAuthoringState,
|
|
12
|
-
getProjectCompileState,
|
|
13
|
-
getProjectPendingAuthoringSync
|
|
14
|
-
} from "./chunk-YE7UAO3T.mjs";
|
|
15
|
-
import {
|
|
16
|
-
generateReducerNativeArtifacts,
|
|
17
|
-
isReducerNativeTestingWorkspace,
|
|
18
|
-
runReducerNativeScenarios
|
|
19
|
-
} from "./chunk-3Y4FRMTK.mjs";
|
|
20
|
-
import "./chunk-QD4SQNUP.mjs";
|
|
21
|
-
import {
|
|
22
|
-
STALE_CONTRACT_ARTIFACT_CODE,
|
|
23
|
-
STALE_CONTRACT_ARTIFACT_EXIT_CODE,
|
|
24
|
-
isDreamboardApiError,
|
|
25
|
-
isStaleContractArtifactMessage
|
|
26
|
-
} from "./chunk-PLXXH5LY.mjs";
|
|
27
|
-
import {
|
|
28
|
-
assertReleaseEnvironmentPortableDependencies,
|
|
29
|
-
configureClient,
|
|
30
|
-
consola,
|
|
31
|
-
resolveProjectContext
|
|
32
|
-
} from "./chunk-5D3OJBDT.mjs";
|
|
33
|
-
import "./chunk-WSIYUUSD.mjs";
|
|
34
|
-
import {
|
|
35
|
-
IS_PUBLISHED_BUILD
|
|
36
|
-
} from "./chunk-AWZ4M4NS.mjs";
|
|
37
|
-
import "./chunk-UMW24KZI.mjs";
|
|
38
|
-
import "./chunk-6AKXIY37.mjs";
|
|
39
|
-
import "./chunk-334H4LE4.mjs";
|
|
40
|
-
import "./chunk-TAEQKBJB.mjs";
|
|
41
|
-
import "./chunk-F2DIOJJZ.mjs";
|
|
42
|
-
import "./chunk-RDYXWXXC.mjs";
|
|
43
|
-
import "./chunk-7LFDFXLS.mjs";
|
|
44
|
-
import "./chunk-JZTH3EMV.mjs";
|
|
45
|
-
import "./chunk-TTB7AIHZ.mjs";
|
|
46
|
-
import "./chunk-MYMVXTZT.mjs";
|
|
47
|
-
import "./chunk-OJFZVGEL.mjs";
|
|
48
|
-
import "./chunk-M7UVBANQ.mjs";
|
|
49
|
-
import "./chunk-H6XDQJ3N.mjs";
|
|
50
|
-
|
|
51
|
-
// src/commands/test.ts
|
|
52
|
-
import { readFile } from "fs/promises";
|
|
53
|
-
import path from "path";
|
|
54
|
-
|
|
55
|
-
// src/services/testing/runtime-mode.ts
|
|
56
|
-
function isRemoteTestEnvironment(environment) {
|
|
57
|
-
return environment === "staging" || environment === "prod";
|
|
58
|
-
}
|
|
59
|
-
function shouldUseRemoteTestRuntime(environment) {
|
|
60
|
-
return IS_PUBLISHED_BUILD || isRemoteTestEnvironment(environment);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/services/workflows/resolve-latest-compiled-result.ts
|
|
64
|
-
async function resolveLatestCompiledResult(projectRoot, projectConfig) {
|
|
65
|
-
void projectRoot;
|
|
66
|
-
const authoring = getProjectAuthoringState(projectConfig);
|
|
67
|
-
if (getProjectPendingAuthoringSync(projectConfig)) {
|
|
68
|
-
throw new Error(
|
|
69
|
-
"Previous sync did not finish updating local scaffold files. Run 'dreamboard sync' again first."
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
if (authoring.revisionDigest) {
|
|
73
|
-
const compile = getProjectCompileState(projectConfig);
|
|
74
|
-
const latestSuccess = (await findProjectCompiledResultsForRevision({
|
|
75
|
-
projectId: projectConfig.projectId,
|
|
76
|
-
revisionDigest: authoring.revisionDigest
|
|
77
|
-
})).find((result) => result.success);
|
|
78
|
-
const matchingLocalSuccess = compile.latestSuccessful?.revisionDigest === authoring.revisionDigest ? compile.latestSuccessful : void 0;
|
|
79
|
-
const resolvedSuccess = latestSuccess ?? (matchingLocalSuccess?.resultId ? await getProjectCompiledResultSdk(
|
|
80
|
-
projectConfig.projectId,
|
|
81
|
-
matchingLocalSuccess.resultId
|
|
82
|
-
) : void 0);
|
|
83
|
-
if (!resolvedSuccess?.success) {
|
|
84
|
-
throw new Error(
|
|
85
|
-
"No successful compile exists for the current authored revision. Run 'dreamboard compile' first."
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
const resultRevisionDigest = resolvedSuccess.revisionDigest;
|
|
89
|
-
if (resultRevisionDigest && resultRevisionDigest !== authoring.revisionDigest) {
|
|
90
|
-
consola.warn(
|
|
91
|
-
`Latest successful compile ${resolvedSuccess.id} belongs to ${resultRevisionDigest}, not ${authoring.revisionDigest}.`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
consola.info(
|
|
95
|
-
`Project summary:
|
|
96
|
-
compiledResultId: ${resolvedSuccess.id}
|
|
97
|
-
revisionDigest: ${authoring.revisionDigest}`
|
|
98
|
-
);
|
|
99
|
-
return resolvedSuccess;
|
|
100
|
-
}
|
|
101
|
-
throw new Error(
|
|
102
|
-
"This workspace does not know its project revision yet. Run 'dreamboard sync' first."
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// src/commands/test.ts
|
|
107
|
-
var REDUCER_NATIVE_TEST_WORKSPACE_ERROR = "dreamboard test now requires a reducer-native workspace with app/game.ts, shared/generated/ui-contract.ts, test/bases/*.base.ts, and test/scenarios/*.scenario.ts. Legacy test/base-scenarios.json workspaces are no longer supported.";
|
|
108
|
-
var NO_REDUCER_NATIVE_BASES_FOUND_ERROR = "No bases found under test/bases/*.base.ts";
|
|
109
|
-
var NO_REDUCER_NATIVE_SCENARIOS_FOUND_ERROR = "No scenarios found under test/scenarios/*.scenario.ts";
|
|
110
|
-
function isPreviewProjectionEndpointUnavailable(error) {
|
|
111
|
-
if (!isDreamboardApiError(error) || error.status !== 404) {
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
const endpoint = error.problem.instance ?? error.problem.context?.endpoint;
|
|
115
|
-
const message = error.problem.detail ?? error.problem.title;
|
|
116
|
-
return endpoint?.includes("/preview/initial-projection") === true && message?.toLowerCase() === "not found";
|
|
117
|
-
}
|
|
118
|
-
async function uploadGeneratedPreviewProjection(options) {
|
|
119
|
-
const previewBase = options.bases.find((base) => base.definition.id === "initial-turn") ?? options.bases[0];
|
|
120
|
-
if (!previewBase) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const projectionPath = path.join(
|
|
124
|
-
options.projectRoot,
|
|
125
|
-
"test",
|
|
126
|
-
"generated",
|
|
127
|
-
"bases",
|
|
128
|
-
previewBase.definition.id,
|
|
129
|
-
"player-1.projection.json"
|
|
130
|
-
);
|
|
131
|
-
const projectionJson = await readFile(projectionPath, "utf8");
|
|
132
|
-
try {
|
|
133
|
-
await uploadInitialProjectionSdk(options.gameId, projectionJson);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
if (isPreviewProjectionEndpointUnavailable(error)) {
|
|
136
|
-
consola.warn(
|
|
137
|
-
"Skipping preview projection upload because the selected backend does not expose the preview projection endpoint."
|
|
138
|
-
);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function resolveRequestedRunner(value) {
|
|
145
|
-
if (value == null || value === "") {
|
|
146
|
-
return void 0;
|
|
147
|
-
}
|
|
148
|
-
if (value === "reducer" || value === "remote" || value === "browser") {
|
|
149
|
-
return value;
|
|
150
|
-
}
|
|
151
|
-
throw new Error(
|
|
152
|
-
`Unsupported test runner '${String(value)}'. Expected one of reducer, remote, browser.`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
function isStaleContractArtifactResult(result) {
|
|
156
|
-
return result.errorCode === STALE_CONTRACT_ARTIFACT_CODE || (result.error ? isStaleContractArtifactMessage(result.error) : false);
|
|
157
|
-
}
|
|
158
|
-
function resolveTestRunExitCode(summary) {
|
|
159
|
-
if (summary.failed === 0) {
|
|
160
|
-
return 0;
|
|
161
|
-
}
|
|
162
|
-
return summary.results.some(
|
|
163
|
-
(result) => !result.success && isStaleContractArtifactResult(result)
|
|
164
|
-
) ? STALE_CONTRACT_ARTIFACT_EXIT_CODE : 1;
|
|
165
|
-
}
|
|
166
|
-
async function assertReducerNativeTestingWorkspace(projectRoot) {
|
|
167
|
-
if (await isReducerNativeTestingWorkspace(projectRoot)) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
throw new Error(REDUCER_NATIVE_TEST_WORKSPACE_ERROR);
|
|
171
|
-
}
|
|
172
|
-
async function resolveReducerNativeRuntimeIdentity(options) {
|
|
173
|
-
if (options.useRemoteRuntime || options.runner === "remote" || options.runner === "browser") {
|
|
174
|
-
const latestCompiledResult = await resolveLatestCompiledResult(
|
|
175
|
-
options.projectRoot,
|
|
176
|
-
options.projectConfig
|
|
177
|
-
);
|
|
178
|
-
return {
|
|
179
|
-
gameId: options.projectConfig.gameId,
|
|
180
|
-
compiledResultId: latestCompiledResult.id
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
gameId: options.projectConfig.gameId,
|
|
185
|
-
compiledResultId: options.projectConfig.compile?.latestSuccessful?.resultId
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
var generateCommand = defineCommand({
|
|
189
|
-
meta: {
|
|
190
|
-
name: "generate",
|
|
191
|
-
description: "Generate reducer-native base artifacts for typed scenarios"
|
|
192
|
-
},
|
|
193
|
-
args: {
|
|
194
|
-
scenario: {
|
|
195
|
-
type: "string",
|
|
196
|
-
description: "Optional scenario file path under test/scenarios"
|
|
197
|
-
},
|
|
198
|
-
debug: {
|
|
199
|
-
type: "boolean",
|
|
200
|
-
description: "Print full reducer-native validation details",
|
|
201
|
-
default: false
|
|
202
|
-
},
|
|
203
|
-
"update-snapshots": {
|
|
204
|
-
type: "boolean",
|
|
205
|
-
description: "Refresh generated projection and scenario snapshots",
|
|
206
|
-
default: false
|
|
207
|
-
},
|
|
208
|
-
...CONFIG_FLAG_ARGS
|
|
209
|
-
},
|
|
210
|
-
async run({ args }) {
|
|
211
|
-
const parsedFlags = parseConfigFlags(args);
|
|
212
|
-
const useRemoteRuntime = shouldUseRemoteTestRuntime(parsedFlags.env);
|
|
213
|
-
const { projectRoot, projectConfig, config } = await resolveProjectContext(
|
|
214
|
-
parsedFlags,
|
|
215
|
-
{ requireAuth: useRemoteRuntime }
|
|
216
|
-
);
|
|
217
|
-
await assertReleaseEnvironmentPortableDependencies({
|
|
218
|
-
projectRoot,
|
|
219
|
-
projectConfig,
|
|
220
|
-
environment: config.environment
|
|
221
|
-
});
|
|
222
|
-
await assertReducerNativeTestingWorkspace(projectRoot);
|
|
223
|
-
const runtimeIdentity = await resolveReducerNativeRuntimeIdentity({
|
|
224
|
-
projectRoot,
|
|
225
|
-
projectConfig,
|
|
226
|
-
useRemoteRuntime
|
|
227
|
-
});
|
|
228
|
-
const { bases, scenarios } = await generateReducerNativeArtifacts({
|
|
229
|
-
projectRoot,
|
|
230
|
-
scenarioPath: args.scenario,
|
|
231
|
-
compiledResultId: runtimeIdentity.compiledResultId,
|
|
232
|
-
gameId: runtimeIdentity.gameId,
|
|
233
|
-
debug: Boolean(args.debug)
|
|
234
|
-
});
|
|
235
|
-
if (bases.length === 0) {
|
|
236
|
-
throw new Error(NO_REDUCER_NATIVE_BASES_FOUND_ERROR);
|
|
237
|
-
}
|
|
238
|
-
if (scenarios.length === 0) {
|
|
239
|
-
throw new Error(NO_REDUCER_NATIVE_SCENARIOS_FOUND_ERROR);
|
|
240
|
-
}
|
|
241
|
-
if (useRemoteRuntime && (config.authToken || config.refreshToken)) {
|
|
242
|
-
await configureClient(config);
|
|
243
|
-
await uploadGeneratedPreviewProjection({
|
|
244
|
-
projectRoot,
|
|
245
|
-
gameId: runtimeIdentity.gameId,
|
|
246
|
-
bases
|
|
247
|
-
});
|
|
248
|
-
} else {
|
|
249
|
-
consola.info(
|
|
250
|
-
"Skipping preview projection upload because this test generation is local-only."
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
consola.success(
|
|
254
|
-
`Generated ${bases.length} base state(s) for ${scenarios.length} scenario(s).`
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
var runCommand = defineCommand({
|
|
259
|
-
meta: {
|
|
260
|
-
name: "run",
|
|
261
|
-
description: "Run reducer-native scenarios from test/scenarios"
|
|
262
|
-
},
|
|
263
|
-
args: {
|
|
264
|
-
scenario: {
|
|
265
|
-
type: "string",
|
|
266
|
-
description: "Optional scenario file path under test/scenarios"
|
|
267
|
-
},
|
|
268
|
-
debug: {
|
|
269
|
-
type: "boolean",
|
|
270
|
-
description: "Print full reducer-native validation details",
|
|
271
|
-
default: false
|
|
272
|
-
},
|
|
273
|
-
"update-snapshots": {
|
|
274
|
-
type: "boolean",
|
|
275
|
-
description: "Refresh generated projection and scenario snapshots",
|
|
276
|
-
default: false
|
|
277
|
-
},
|
|
278
|
-
runner: {
|
|
279
|
-
type: "string",
|
|
280
|
-
valueHint: "reducer|remote|browser",
|
|
281
|
-
description: "Scenario runner: reducer (in-process, default), remote (live sessions against the configured backend), or browser (local web stack)."
|
|
282
|
-
},
|
|
283
|
-
...CONFIG_FLAG_ARGS
|
|
284
|
-
},
|
|
285
|
-
async run({ args }) {
|
|
286
|
-
const parsedFlags = parseConfigFlags(args);
|
|
287
|
-
const useRemoteRuntime = shouldUseRemoteTestRuntime(parsedFlags.env);
|
|
288
|
-
const runner = resolveRequestedRunner(args.runner) ?? "reducer";
|
|
289
|
-
const { projectRoot, projectConfig, config } = await resolveProjectContext(
|
|
290
|
-
parsedFlags,
|
|
291
|
-
{
|
|
292
|
-
requireAuth: useRemoteRuntime || runner === "remote" || runner === "browser"
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
await assertReleaseEnvironmentPortableDependencies({
|
|
296
|
-
projectRoot,
|
|
297
|
-
projectConfig,
|
|
298
|
-
environment: config.environment
|
|
299
|
-
});
|
|
300
|
-
await assertReducerNativeTestingWorkspace(projectRoot);
|
|
301
|
-
const runtimeIdentity = await resolveReducerNativeRuntimeIdentity({
|
|
302
|
-
projectRoot,
|
|
303
|
-
projectConfig,
|
|
304
|
-
useRemoteRuntime,
|
|
305
|
-
runner
|
|
306
|
-
});
|
|
307
|
-
const summary = await runReducerNativeScenarios({
|
|
308
|
-
projectRoot,
|
|
309
|
-
projectConfig,
|
|
310
|
-
resolvedConfig: config,
|
|
311
|
-
runner,
|
|
312
|
-
scenarioPath: args.scenario,
|
|
313
|
-
compiledResultId: runtimeIdentity.compiledResultId,
|
|
314
|
-
gameId: runtimeIdentity.gameId,
|
|
315
|
-
debug: Boolean(args.debug),
|
|
316
|
-
updateSnapshots: Boolean(args["update-snapshots"])
|
|
317
|
-
});
|
|
318
|
-
for (const result of summary.results) {
|
|
319
|
-
if (result.success) {
|
|
320
|
-
consola.success(`PASS ${result.id}`);
|
|
321
|
-
} else if (result.errorCode === STALE_CONTRACT_ARTIFACT_CODE && result.error) {
|
|
322
|
-
consola.error(result.error);
|
|
323
|
-
} else {
|
|
324
|
-
consola.error(
|
|
325
|
-
`FAIL ${result.id}: ${result.error ?? "Scenario failed"}`
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
consola.info(
|
|
330
|
-
`Test summary: ${summary.passed} passed, ${summary.failed} failed.`
|
|
331
|
-
);
|
|
332
|
-
if (summary.failed > 0) {
|
|
333
|
-
process.exitCode = resolveTestRunExitCode(summary);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
var test_default = defineCommand({
|
|
338
|
-
meta: {
|
|
339
|
-
name: "test",
|
|
340
|
-
description: "Reducer-native test runner with typed bases and scenarios"
|
|
341
|
-
},
|
|
342
|
-
subCommands: {
|
|
343
|
-
generate: generateCommand,
|
|
344
|
-
run: runCommand
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
export {
|
|
348
|
-
NO_REDUCER_NATIVE_BASES_FOUND_ERROR,
|
|
349
|
-
NO_REDUCER_NATIVE_SCENARIOS_FOUND_ERROR,
|
|
350
|
-
REDUCER_NATIVE_TEST_WORKSPACE_ERROR,
|
|
351
|
-
test_default as default,
|
|
352
|
-
isPreviewProjectionEndpointUnavailable,
|
|
353
|
-
resolveRequestedRunner,
|
|
354
|
-
resolveTestRunExitCode
|
|
355
|
-
};
|
|
356
|
-
//# sourceMappingURL=test-CNNVTFIG.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/test.ts","../../src/services/testing/runtime-mode.ts","../../src/services/workflows/resolve-latest-compiled-result.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport consola from \"consola\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { CONFIG_FLAG_ARGS } from \"../command-args.js\";\nimport { configureClient, resolveProjectContext } from \"../config/resolve.js\";\nimport { parseConfigFlags } from \"../flags.js\";\nimport { uploadInitialProjectionSdk } from \"../services/api/index.js\";\nimport { assertReleaseEnvironmentPortableDependencies } from \"../services/project/dependency-portability.js\";\nimport {\n generateReducerNativeArtifacts,\n isReducerNativeTestingWorkspace,\n runReducerNativeScenarios,\n type ReducerNativeScenarioSummary,\n} from \"../services/testing/reducer-native-test-harness.js\";\nimport { shouldUseRemoteTestRuntime } from \"../services/testing/runtime-mode.js\";\nimport { resolveLatestCompiledResult } from \"../services/workflows/resolve-latest-compiled-result.js\";\nimport type { ProjectConfig } from \"../types.js\";\nimport {\n isDreamboardApiError,\n isStaleContractArtifactMessage,\n STALE_CONTRACT_ARTIFACT_CODE,\n STALE_CONTRACT_ARTIFACT_EXIT_CODE,\n} from \"../utils/errors.js\";\n\ntype RequestedTestRunner = \"reducer\" | \"remote\" | \"browser\";\n\nexport const REDUCER_NATIVE_TEST_WORKSPACE_ERROR =\n \"dreamboard test now requires a reducer-native workspace with app/game.ts, shared/generated/ui-contract.ts, test/bases/*.base.ts, and test/scenarios/*.scenario.ts. Legacy test/base-scenarios.json workspaces are no longer supported.\";\n\nexport const NO_REDUCER_NATIVE_BASES_FOUND_ERROR =\n \"No bases found under test/bases/*.base.ts\";\n\nexport const NO_REDUCER_NATIVE_SCENARIOS_FOUND_ERROR =\n \"No scenarios found under test/scenarios/*.scenario.ts\";\n\nexport function isPreviewProjectionEndpointUnavailable(\n error: unknown,\n): boolean {\n if (!isDreamboardApiError(error) || error.status !== 404) {\n return false;\n }\n\n const endpoint = error.problem.instance ?? error.problem.context?.endpoint;\n const message = error.problem.detail ?? error.problem.title;\n return (\n endpoint?.includes(\"/preview/initial-projection\") === true &&\n message?.toLowerCase() === \"not found\"\n );\n}\n\nasync function uploadGeneratedPreviewProjection(options: {\n projectRoot: string;\n gameId: string;\n bases: Array<{ definition: { id: string } }>;\n}): Promise<void> {\n const previewBase =\n options.bases.find((base) => base.definition.id === \"initial-turn\") ??\n options.bases[0];\n if (!previewBase) {\n return;\n }\n const projectionPath = path.join(\n options.projectRoot,\n \"test\",\n \"generated\",\n \"bases\",\n previewBase.definition.id,\n \"player-1.projection.json\",\n );\n const projectionJson = await readFile(projectionPath, \"utf8\");\n try {\n await uploadInitialProjectionSdk(options.gameId, projectionJson);\n } catch (error) {\n if (isPreviewProjectionEndpointUnavailable(error)) {\n consola.warn(\n \"Skipping preview projection upload because the selected backend does not expose the preview projection endpoint.\",\n );\n return;\n }\n throw error;\n }\n}\n\nexport function resolveRequestedRunner(\n value: unknown,\n): RequestedTestRunner | undefined {\n if (value == null || value === \"\") {\n return undefined;\n }\n if (value === \"reducer\" || value === \"remote\" || value === \"browser\") {\n return value;\n }\n throw new Error(\n `Unsupported test runner '${String(value)}'. Expected one of reducer, remote, browser.`,\n );\n}\n\nfunction isStaleContractArtifactResult(\n result: ReducerNativeScenarioSummary[\"results\"][number],\n): boolean {\n return (\n result.errorCode === STALE_CONTRACT_ARTIFACT_CODE ||\n (result.error ? isStaleContractArtifactMessage(result.error) : false)\n );\n}\n\nexport function resolveTestRunExitCode(\n summary: ReducerNativeScenarioSummary,\n): number {\n if (summary.failed === 0) {\n return 0;\n }\n return summary.results.some(\n (result) => !result.success && isStaleContractArtifactResult(result),\n )\n ? STALE_CONTRACT_ARTIFACT_EXIT_CODE\n : 1;\n}\n\nasync function assertReducerNativeTestingWorkspace(\n projectRoot: string,\n): Promise<void> {\n if (await isReducerNativeTestingWorkspace(projectRoot)) {\n return;\n }\n\n throw new Error(REDUCER_NATIVE_TEST_WORKSPACE_ERROR);\n}\n\nasync function resolveReducerNativeRuntimeIdentity(options: {\n projectRoot: string;\n projectConfig: ProjectConfig;\n useRemoteRuntime: boolean;\n runner?: RequestedTestRunner;\n}): Promise<{\n gameId: string;\n compiledResultId?: string;\n}> {\n if (\n options.useRemoteRuntime ||\n options.runner === \"remote\" ||\n options.runner === \"browser\"\n ) {\n const latestCompiledResult = await resolveLatestCompiledResult(\n options.projectRoot,\n options.projectConfig,\n );\n return {\n gameId: options.projectConfig.gameId,\n compiledResultId: latestCompiledResult.id,\n };\n }\n\n return {\n gameId: options.projectConfig.gameId,\n compiledResultId: options.projectConfig.compile?.latestSuccessful?.resultId,\n };\n}\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: \"Generate reducer-native base artifacts for typed scenarios\",\n },\n args: {\n scenario: {\n type: \"string\",\n description: \"Optional scenario file path under test/scenarios\",\n },\n debug: {\n type: \"boolean\",\n description: \"Print full reducer-native validation details\",\n default: false,\n },\n \"update-snapshots\": {\n type: \"boolean\",\n description: \"Refresh generated projection and scenario snapshots\",\n default: false,\n },\n ...CONFIG_FLAG_ARGS,\n },\n async run({ args }) {\n const parsedFlags = parseConfigFlags(args);\n const useRemoteRuntime = shouldUseRemoteTestRuntime(parsedFlags.env);\n const { projectRoot, projectConfig, config } = await resolveProjectContext(\n parsedFlags,\n { requireAuth: useRemoteRuntime },\n );\n await assertReleaseEnvironmentPortableDependencies({\n projectRoot,\n projectConfig,\n environment: config.environment,\n });\n\n await assertReducerNativeTestingWorkspace(projectRoot);\n\n const runtimeIdentity = await resolveReducerNativeRuntimeIdentity({\n projectRoot,\n projectConfig,\n useRemoteRuntime,\n });\n const { bases, scenarios } = await generateReducerNativeArtifacts({\n projectRoot,\n scenarioPath: args.scenario,\n compiledResultId: runtimeIdentity.compiledResultId,\n gameId: runtimeIdentity.gameId,\n debug: Boolean(args.debug),\n });\n\n if (bases.length === 0) {\n throw new Error(NO_REDUCER_NATIVE_BASES_FOUND_ERROR);\n }\n if (scenarios.length === 0) {\n throw new Error(NO_REDUCER_NATIVE_SCENARIOS_FOUND_ERROR);\n }\n\n if (useRemoteRuntime && (config.authToken || config.refreshToken)) {\n await configureClient(config);\n await uploadGeneratedPreviewProjection({\n projectRoot,\n gameId: runtimeIdentity.gameId,\n bases,\n });\n } else {\n consola.info(\n \"Skipping preview projection upload because this test generation is local-only.\",\n );\n }\n\n consola.success(\n `Generated ${bases.length} base state(s) for ${scenarios.length} scenario(s).`,\n );\n },\n});\n\nconst runCommand = defineCommand({\n meta: {\n name: \"run\",\n description: \"Run reducer-native scenarios from test/scenarios\",\n },\n args: {\n scenario: {\n type: \"string\",\n description: \"Optional scenario file path under test/scenarios\",\n },\n debug: {\n type: \"boolean\",\n description: \"Print full reducer-native validation details\",\n default: false,\n },\n \"update-snapshots\": {\n type: \"boolean\",\n description: \"Refresh generated projection and scenario snapshots\",\n default: false,\n },\n runner: {\n type: \"string\",\n valueHint: \"reducer|remote|browser\",\n description:\n \"Scenario runner: reducer (in-process, default), remote (live sessions against the configured backend), or browser (local web stack).\",\n },\n ...CONFIG_FLAG_ARGS,\n },\n async run({ args }) {\n const parsedFlags = parseConfigFlags(args);\n const useRemoteRuntime = shouldUseRemoteTestRuntime(parsedFlags.env);\n const runner = resolveRequestedRunner(args.runner) ?? \"reducer\";\n const { projectRoot, projectConfig, config } = await resolveProjectContext(\n parsedFlags,\n {\n requireAuth:\n useRemoteRuntime || runner === \"remote\" || runner === \"browser\",\n },\n );\n await assertReleaseEnvironmentPortableDependencies({\n projectRoot,\n projectConfig,\n environment: config.environment,\n });\n\n await assertReducerNativeTestingWorkspace(projectRoot);\n\n const runtimeIdentity = await resolveReducerNativeRuntimeIdentity({\n projectRoot,\n projectConfig,\n useRemoteRuntime,\n runner,\n });\n const summary = await runReducerNativeScenarios({\n projectRoot,\n projectConfig,\n resolvedConfig: config,\n runner,\n scenarioPath: args.scenario,\n compiledResultId: runtimeIdentity.compiledResultId,\n gameId: runtimeIdentity.gameId,\n debug: Boolean(args.debug),\n updateSnapshots: Boolean(args[\"update-snapshots\"]),\n });\n\n for (const result of summary.results) {\n if (result.success) {\n consola.success(`PASS ${result.id}`);\n } else if (\n result.errorCode === STALE_CONTRACT_ARTIFACT_CODE &&\n result.error\n ) {\n consola.error(result.error);\n } else {\n consola.error(\n `FAIL ${result.id}: ${result.error ?? \"Scenario failed\"}`,\n );\n }\n }\n\n consola.info(\n `Test summary: ${summary.passed} passed, ${summary.failed} failed.`,\n );\n if (summary.failed > 0) {\n process.exitCode = resolveTestRunExitCode(summary);\n }\n },\n});\n\nexport default defineCommand({\n meta: {\n name: \"test\",\n description: \"Reducer-native test runner with typed bases and scenarios\",\n },\n subCommands: {\n generate: generateCommand,\n run: runCommand,\n },\n});\n","import { IS_PUBLISHED_BUILD } from \"../../build-target.js\";\n\nexport function isRemoteTestEnvironment(\n environment: string | undefined,\n): environment is \"staging\" | \"prod\" {\n return environment === \"staging\" || environment === \"prod\";\n}\n\nexport function shouldUseRemoteTestRuntime(\n environment: string | undefined,\n): boolean {\n return IS_PUBLISHED_BUILD || isRemoteTestEnvironment(environment);\n}\n","import consola from \"consola\";\nimport type { CompiledResult } from \"@dreamboard-games/api-client\";\nimport type { ProjectConfig } from \"../../types.js\";\nimport {\n findProjectCompiledResultsForRevision,\n getProjectCompiledResultSdk,\n} from \"../api/compiled-results-api.js\";\nimport {\n getProjectCompileState,\n getProjectAuthoringState,\n getProjectPendingAuthoringSync,\n} from \"../project/project-state.js\";\n\nexport async function resolveLatestCompiledResult(\n projectRoot: string,\n projectConfig: ProjectConfig,\n): Promise<CompiledResult> {\n void projectRoot;\n const authoring = getProjectAuthoringState(projectConfig);\n if (getProjectPendingAuthoringSync(projectConfig)) {\n throw new Error(\n \"Previous sync did not finish updating local scaffold files. Run 'dreamboard sync' again first.\",\n );\n }\n if (authoring.revisionDigest) {\n const compile = getProjectCompileState(projectConfig);\n const latestSuccess = (\n await findProjectCompiledResultsForRevision({\n projectId: projectConfig.projectId,\n revisionDigest: authoring.revisionDigest,\n })\n ).find((result) => result.success);\n const matchingLocalSuccess =\n compile.latestSuccessful?.revisionDigest === authoring.revisionDigest\n ? compile.latestSuccessful\n : undefined;\n const resolvedSuccess =\n latestSuccess ??\n (matchingLocalSuccess?.resultId\n ? await getProjectCompiledResultSdk(\n projectConfig.projectId,\n matchingLocalSuccess.resultId,\n )\n : undefined);\n\n if (!resolvedSuccess?.success) {\n throw new Error(\n \"No successful compile exists for the current authored revision. Run 'dreamboard compile' first.\",\n );\n }\n\n const resultRevisionDigest = (resolvedSuccess as { revisionDigest?: string })\n .revisionDigest;\n if (\n resultRevisionDigest &&\n resultRevisionDigest !== authoring.revisionDigest\n ) {\n consola.warn(\n `Latest successful compile ${resolvedSuccess.id} belongs to ${resultRevisionDigest}, not ${authoring.revisionDigest}.`,\n );\n }\n\n consola.info(\n `Project summary:\\n compiledResultId: ${resolvedSuccess.id}\\n revisionDigest: ${authoring.revisionDigest}`,\n );\n\n return resolvedSuccess;\n }\n\n throw new Error(\n \"This workspace does not know its project revision yet. Run 'dreamboard sync' first.\",\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,gBAAgB;AACzB,OAAO,UAAU;;;ACDV,SAAS,wBACd,aACmC;AACnC,SAAO,gBAAgB,aAAa,gBAAgB;AACtD;AAEO,SAAS,2BACd,aACS;AACT,SAAO,sBAAsB,wBAAwB,WAAW;AAClE;;;ACCA,eAAsB,4B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
1
|
-
{"version":3,"sources":["../src/utils/fs.ts","../src/constants.ts","../src/utils/atomic-file.ts"],"sourcesContent":["import { mkdir, readFile, stat, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport async function ensureDir(dirPath: string): Promise<void> {\n await mkdir(dirPath, { recursive: true });\n}\n\nexport async function exists(filePath: string): Promise<boolean> {\n try {\n await stat(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function readTextFile(filePath: string): Promise<string> {\n return readFile(filePath, \"utf8\");\n}\n\nexport async function readTextFileIfExists(\n filePath: string,\n): Promise<string | null> {\n try {\n return await readFile(filePath, \"utf8\");\n } catch {\n return null;\n }\n}\n\nexport async function writeTextFile(\n filePath: string,\n content: string,\n): Promise<void> {\n await ensureDir(path.dirname(filePath));\n await writeFile(filePath, content, \"utf8\");\n}\n\nexport async function readJsonFile<T>(filePath: string): Promise<T> {\n const data = await readTextFile(filePath);\n return JSON.parse(data) as T;\n}\n\nexport async function writeJsonFile(\n filePath: string,\n data: unknown,\n): Promise<void> {\n await writeTextFile(filePath, `${JSON.stringify(data, null, 2)}\\n`);\n}\n","import type { EnvironmentConfig } from \"./types.js\";\n\nexport const DEFAULT_API_BASE_URL = \"https://api.dreamboard.games\";\nexport const DEFAULT_WEB_BASE_URL = \"https://dreamboard.games\";\n\nexport const PROJECT_DIR_NAME = \".dreamboard\";\nexport const DEFAULT_CLERK_OAUTH_SCOPE =\n \"openid profile email offline_access\";\n\n// Predefined environment configurations. These are intentionally static:\n// process/env overrides are applied in config resolution so the CLI does not\n// depend on a shell-sourced env file just to know first-party environments.\nexport const ENVIRONMENT_CONFIGS: Record<string, EnvironmentConfig> = {\n local: {\n apiBaseUrl: \"http://localhost:8080\",\n webBaseUrl: \"http://localhost:5173\",\n clerkOAuthScope: DEFAULT_CLERK_OAUTH_SCOPE,\n },\n staging: {\n apiBaseUrl: \"https://api-staging.dreamboard.games\",\n webBaseUrl: \"https://staging.dreamboard.games\",\n clerkOAuthIssuer: \"https://happy-caribou-19.clerk.accounts.dev\",\n clerkOAuthClientId: \"wkjMF92OFsKbSaGI\",\n clerkOAuthTokenUrl:\n \"https://happy-caribou-19.clerk.accounts.dev/oauth/token\",\n clerkOAuthScope: DEFAULT_CLERK_OAUTH_SCOPE,\n },\n prod: {\n apiBaseUrl: \"https://api.dreamboard.games\",\n webBaseUrl: \"https://dreamboard.games\",\n clerkOAuthScope: DEFAULT_CLERK_OAUTH_SCOPE,\n },\n};\nexport const PROJECT_CONFIG_FILE = \"project.json\";\nexport const PROJECT_STATE_FILE = \"state.json\";\nexport const SNAPSHOT_FILE = \"snapshot.json\";\nexport const MANIFEST_FILE = \"manifest.ts\";\nexport const GENERATED_DIR_NAME = \"generated\";\nexport const MATERIALIZED_MANIFEST_FILE = `${PROJECT_DIR_NAME}/${GENERATED_DIR_NAME}/manifest.json`;\nexport const MANIFEST_TYPECHECK_CONFIG_FILE = \"manifest.tsconfig.json\";\nexport const RULE_FILE = \"rule.md\";\nexport const DEFAULT_LOGIN_TIMEOUT_MS = 5 * 60 * 1000;\nexport const DEFAULT_TURN_DELAY_MS = 250;\n\nexport const LOCAL_IGNORE_DIRS = new Set([\n \".dreamboard\",\n \".git\",\n \"node_modules\",\n \"dist\",\n]);\n","/**\n * Primitives for safely mutating local state files owned by the CLI.\n *\n * Two guarantees:\n * - Writes are atomic-ish: we stage the payload in a sibling temp file with\n * the target permissions, fsync the contents, then `rename` over the target.\n * On POSIX `rename` within the same directory is atomic; on Windows it is\n * atomic within the same volume which is always the case for files we write\n * inside `~/.dreamboard`.\n * - We refuse to clobber a file with an empty payload. The original bug that\n * wiped refresh tokens on a failing `sync`/`compile` hinged on `undefined`\n * JSON values being persisted and reloaded as `{}`. Forbidding empty\n * writes here removes that entire failure mode at the primitive level.\n *\n * Additionally, `withFileLock` provides a cross-process advisory lock built on\n * `O_CREAT | O_EXCL` so that parallel CLI invocations (e.g. `dreamboard sync`\n * running while `dreamboard compile` is in flight) serialize around mutations\n * of the same credential state.\n */\n\nimport { constants as fsConstants, promises as fs, type Stats } from \"node:fs\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\n\nexport type AtomicWriteOptions = {\n /** File mode applied to the written file (default: 0o600). */\n mode?: number;\n /** Call `fsync` on the temp file before renaming. Default: true. */\n fsync?: boolean;\n};\n\nexport async function atomicWriteFile(\n targetPath: string,\n contents: string,\n options: AtomicWriteOptions = {},\n): Promise<void> {\n if (contents.length === 0) {\n throw new Error(\n `Refusing to atomicWriteFile an empty payload to ${targetPath}`,\n );\n }\n const mode = options.mode ?? 0o600;\n const shouldFsync = options.fsync ?? true;\n const dir = path.dirname(targetPath);\n await fs.mkdir(dir, { recursive: true });\n\n const suffix = crypto.randomBytes(6).toString(\"hex\");\n const tmpPath = `${targetPath}.tmp-${process.pid}-${suffix}`;\n\n const fh = await fs.open(\n tmpPath,\n fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL,\n mode,\n );\n try {\n await fh.writeFile(contents, \"utf8\");\n try {\n await fh.chmod(mode);\n } catch {\n // Some filesystems (e.g. network volumes, Windows) refuse chmod.\n // Ignoring here is safe: the `open` call above already created the\n // file with the requested mode on systems that honor it.\n }\n if (shouldFsync) {\n try {\n await fh.sync();\n } catch {\n // Best-effort. Not all backends (tmpfs on some platforms) support fsync.\n }\n }\n } finally {\n await fh.close();\n }\n\n try {\n await fs.rename(tmpPath, targetPath);\n } catch (err) {\n await fs.unlink(tmpPath).catch(() => undefined);\n throw err;\n }\n}\n\nexport type FileLockOptions = {\n /** Max number of acquisition attempts before giving up. Default: 100. */\n retries?: number;\n /** Minimum backoff between retries in ms. Default: 20. */\n minDelayMs?: number;\n /** Maximum backoff between retries in ms. Default: 200. */\n maxDelayMs?: number;\n /**\n * A lockfile older than this is considered stale and forcibly removed.\n * Guards against crashed processes leaving a permanent lock. Default: 30s.\n */\n staleMs?: number;\n};\n\nexport async function withFileLock<T>(\n lockPath: string,\n fn: () => Promise<T>,\n options: FileLockOptions = {},\n): Promise<T> {\n const retries = options.retries ?? 100;\n const minDelayMs = options.minDelayMs ?? 20;\n const maxDelayMs = options.maxDelayMs ?? 200;\n const staleMs = options.staleMs ?? 30_000;\n\n await fs.mkdir(path.dirname(lockPath), { recursive: true });\n\n let attempt = 0;\n let acquired = false;\n while (!acquired) {\n try {\n const fh = await fs.open(\n lockPath,\n fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL,\n 0o600,\n );\n await fh.writeFile(`${process.pid}\\n`, \"utf8\");\n await fh.close();\n acquired = true;\n break;\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code !== \"EEXIST\") {\n throw err;\n }\n }\n\n let stat: Stats | null = null;\n try {\n stat = await fs.stat(lockPath);\n } catch {\n continue;\n }\n if (stat !== null) {\n const ageMs = Date.now() - stat.mtimeMs;\n if (ageMs > staleMs) {\n await fs.unlink(lockPath).catch(() => undefined);\n continue;\n }\n }\n\n attempt += 1;\n if (attempt >= retries) {\n throw new Error(\n `Timed out acquiring file lock at ${lockPath} after ${retries} attempts.`,\n );\n }\n const jitter = Math.floor(\n Math.random() * Math.max(1, maxDelayMs - minDelayMs),\n );\n await new Promise((resolve) => setTimeout(resolve, minDelayMs + jitter));\n }\n\n try {\n return await fn();\n } finally {\n await fs.unlink(lockPath).catch(() => undefined);\n }\n}\n"],"mappings":";;;AAAA,SAAS,OAAO,UAAU,MAAM,iBAAiB;AACjD,OAAO,UAAU;AAEjB,eAAsB,UAAU,SAAgC;AAC9D,QAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;AAC1C;AAEA,eAAsB,OAAO,UAAoC;AAC/D,MAAI;AACF,UAAM,KAAK,QAAQ;AACnB,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,aAAa,UAAmC;AACpE,SAAO,SAAS,UAAU,MAAM;AAClC;AAEA,eAAsB,qBACpB,UACwB;AACxB,MAAI;AACF,WAAO,MAAM,SAAS,UAAU,MAAM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