@joiner-platform/cli 0.1.16 → 0.1.18
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/package.json +2 -2
- package/skills/tile-creator/references/cli.md +4 -3
- package/src/commands/init/scaffold.ts +2 -9
- package/src/commands/init/sdk-tarball-url.generated.ts +2 -2
- package/src/commands/init/template-names.ts +18 -0
- package/src/commands/schema-input-example.ts +142 -14
- package/bundled-resources/poe-tile-templates/coverage.config.json +0 -6
- package/bundled-resources/poe-tile-templates/index.ts +0 -27
- package/bundled-resources/poe-tile-templates/package.json +0 -31
- package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +0 -10
- package/bundled-resources/poe-tile-templates/scripts/generate.ts +0 -57
- package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +0 -52
- package/bundled-resources/poe-tile-templates/scripts/paths.ts +0 -7
- package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +0 -288
- package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +0 -132
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +0 -30
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +0 -397
- package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +0 -131
- package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +0 -166
- package/bundled-resources/poe-tile-templates/tests/doctor-launcher.test.ts +0 -48
- package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +0 -67
- package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +0 -106
- package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +0 -103
- package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +0 -67
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +0 -85
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +0 -69
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +0 -73
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +0 -54
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +0 -70
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +0 -85
- package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +0 -278
- package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +0 -27
- package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +0 -99
- package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +0 -23
- package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +0 -84
- package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +0 -56
- package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +0 -129
- package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +0 -90
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/**
|
|
3
|
-
* Verify standalone builds and the creator journey with the locally packed SDK.
|
|
4
|
-
* `--dependency-key` and `--tarball-name` are described in sdk-dependency-key.ts;
|
|
5
|
-
* the creator journey (its own CLI scaffold) runs only with the defaults.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import assert from "node:assert/strict";
|
|
9
|
-
import {
|
|
10
|
-
copyFileSync,
|
|
11
|
-
existsSync,
|
|
12
|
-
lstatSync,
|
|
13
|
-
mkdirSync,
|
|
14
|
-
mkdtempSync,
|
|
15
|
-
readFileSync,
|
|
16
|
-
rmSync,
|
|
17
|
-
writeFileSync,
|
|
18
|
-
} from "node:fs";
|
|
19
|
-
import { tmpdir } from "node:os";
|
|
20
|
-
import { join } from "node:path";
|
|
21
|
-
import { pathToFileURL } from "node:url";
|
|
22
|
-
import { scaffoldApp } from "../../../projects/poe-tiles-cli/src/commands/init/scaffold.ts";
|
|
23
|
-
import { writeCustomizedManagerFixture } from "../tests/fixtures/customized-manager";
|
|
24
|
-
import { saveInstallDiagnostics } from "./install-diagnostics";
|
|
25
|
-
import { MONOREPO_ROOT } from "./paths.ts";
|
|
26
|
-
import {
|
|
27
|
-
installWithSdkKey,
|
|
28
|
-
parseVerifyOptions,
|
|
29
|
-
stageSdkTarball,
|
|
30
|
-
} from "./sdk-dependency-key";
|
|
31
|
-
import {
|
|
32
|
-
getPublishEnvironment as publishEnv,
|
|
33
|
-
runVerificationCommand as run,
|
|
34
|
-
} from "./verify-local-sdk-command";
|
|
35
|
-
|
|
36
|
-
const TEMPLATE = "react";
|
|
37
|
-
const APP_NAME = "template-react-packaged-sdk";
|
|
38
|
-
const PACKAGED_APP_ROOT = mkdtempSync(join(tmpdir(), "poe-packaged-app-"));
|
|
39
|
-
const APP_DIR = join(PACKAGED_APP_ROOT, APP_NAME);
|
|
40
|
-
const SOLID_APP_NAME = "template-solidjs-packaged-sdk";
|
|
41
|
-
const INSTALL_DIAGNOSTICS_DIR = join(
|
|
42
|
-
MONOREPO_ROOT,
|
|
43
|
-
"packages/poe-tile-templates/test-results/packaged-sdk-install",
|
|
44
|
-
);
|
|
45
|
-
const SDK_TARBALL_PATH = join(
|
|
46
|
-
MONOREPO_ROOT,
|
|
47
|
-
"packages/poe-tiles-sdk/dist/publish/poe-tiles-sdk.tgz",
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const options = parseVerifyOptions(process.argv.slice(2));
|
|
51
|
-
const { dependencyKey: SDK_KEY, tarballName } = options;
|
|
52
|
-
const runsDefaults = SDK_KEY === "joiner-sdk" && tarballName === undefined;
|
|
53
|
-
|
|
54
|
-
let tempTarballDir: string | undefined;
|
|
55
|
-
try {
|
|
56
|
-
rmSync(INSTALL_DIAGNOSTICS_DIR, { recursive: true, force: true });
|
|
57
|
-
rmSync(APP_DIR, { recursive: true, force: true });
|
|
58
|
-
|
|
59
|
-
run(
|
|
60
|
-
["bunx", "turbo", "build", "--filter", "joiner-sdk"],
|
|
61
|
-
MONOREPO_ROOT,
|
|
62
|
-
"turbo build joiner-sdk",
|
|
63
|
-
);
|
|
64
|
-
run(
|
|
65
|
-
["bun", "run", "--filter", "joiner-sdk", "publish-tar"],
|
|
66
|
-
MONOREPO_ROOT,
|
|
67
|
-
"pack local SDK tarball",
|
|
68
|
-
publishEnv(),
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
if (!existsSync(SDK_TARBALL_PATH)) {
|
|
72
|
-
throw new Error(`Local SDK tarball not found: ${SDK_TARBALL_PATH}`);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
tempTarballDir = mkdtempSync(join(tmpdir(), "poe-tiles-sdk-tarball-"));
|
|
76
|
-
const tempTarballPath = join(
|
|
77
|
-
tempTarballDir,
|
|
78
|
-
`poe-tiles-sdk-${Date.now()}.tgz`,
|
|
79
|
-
);
|
|
80
|
-
stageSdkTarball(SDK_TARBALL_PATH, tempTarballPath, tarballName);
|
|
81
|
-
|
|
82
|
-
mkdirSync(PACKAGED_APP_ROOT, { recursive: true });
|
|
83
|
-
scaffoldApp({
|
|
84
|
-
appName: APP_NAME,
|
|
85
|
-
template: TEMPLATE,
|
|
86
|
-
outputDir: APP_DIR,
|
|
87
|
-
sdkVersion: pathToFileURL(tempTarballPath).href,
|
|
88
|
-
includeSkill: true,
|
|
89
|
-
blank: true,
|
|
90
|
-
});
|
|
91
|
-
copyFileSync(
|
|
92
|
-
join(import.meta.dir, "../tests/fixtures/extended-mutators.ts.txt"),
|
|
93
|
-
join(APP_DIR, "tests/extended-mutators.test.ts"),
|
|
94
|
-
);
|
|
95
|
-
writeCustomizedManagerFixture({
|
|
96
|
-
dir: join(APP_DIR, "tests/customized-manager"),
|
|
97
|
-
managerExample: readFileSync(
|
|
98
|
-
join(APP_DIR, "synced-store/manager.test.ts"),
|
|
99
|
-
"utf8",
|
|
100
|
-
),
|
|
101
|
-
});
|
|
102
|
-
copyFileSync(
|
|
103
|
-
join(
|
|
104
|
-
import.meta.dir,
|
|
105
|
-
"../tests/fixtures/multiplayer-verification.test.playwright.ts.txt",
|
|
106
|
-
),
|
|
107
|
-
join(APP_DIR, "tests/multiplayer-verification.test.playwright.ts"),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
// This runs against the isolated tarball dependency graph. Monorepo type
|
|
111
|
-
// checks cannot catch undeclared packages that happen to be hoisted at root.
|
|
112
|
-
writeFileSync(
|
|
113
|
-
join(APP_DIR, "tests/sdk-schema-types.ts"),
|
|
114
|
-
[
|
|
115
|
-
'import { z } from "zod";',
|
|
116
|
-
`import { defineSchema, table } from "${SDK_KEY}/v1/backend.js";`,
|
|
117
|
-
`import type { InferSchemaTableTypes } from "${SDK_KEY}/v1/client.js";`,
|
|
118
|
-
"",
|
|
119
|
-
"const probeSchema = defineSchema({",
|
|
120
|
-
"\tschemaVersion: 1,",
|
|
121
|
-
"\ttables: {",
|
|
122
|
-
'\t\tround: { schema: table(z.object({ cells: z.array(z.enum(["X", "O"]).nullable()) })) },',
|
|
123
|
-
"\t},",
|
|
124
|
-
"\tmutators: {},",
|
|
125
|
-
"});",
|
|
126
|
-
"",
|
|
127
|
-
"type ProbeTables = InferSchemaTableTypes<typeof probeSchema>;",
|
|
128
|
-
'declare const cells: ProbeTables["round"]["cells"];',
|
|
129
|
-
"cells.map((cell, index) => {",
|
|
130
|
-
'\tconst typedCell: "X" | "O" | null = cell;',
|
|
131
|
-
"\tconst typedIndex: number = index;",
|
|
132
|
-
"\treturn [typedCell, typedIndex];",
|
|
133
|
-
"});",
|
|
134
|
-
"",
|
|
135
|
-
].join("\n"),
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
installWithSdkKey(APP_DIR, options, "bun install (local SDK tarball)");
|
|
139
|
-
// Check the installed SDK, not the scaffold's separately copied skills.
|
|
140
|
-
// A symlink back to the build checkout cannot work for external creators.
|
|
141
|
-
for (const skill of ["tile-creator", "synced-store"]) {
|
|
142
|
-
const skillDir = join(APP_DIR, "node_modules", SDK_KEY, "skills", skill);
|
|
143
|
-
assert(
|
|
144
|
-
lstatSync(skillDir).isDirectory(),
|
|
145
|
-
`${skill} must be a real directory`,
|
|
146
|
-
);
|
|
147
|
-
const skillFile = join(skillDir, "SKILL.md");
|
|
148
|
-
assert(
|
|
149
|
-
lstatSync(skillFile).isFile(),
|
|
150
|
-
`${skill}/SKILL.md must be a real file`,
|
|
151
|
-
);
|
|
152
|
-
assert(readFileSync(skillFile, "utf-8").includes(`name: ${skill}`));
|
|
153
|
-
}
|
|
154
|
-
run(["bun", "run", "type-check"], APP_DIR, "generated app type-check");
|
|
155
|
-
run(["bun", "run", "test"], APP_DIR, "generated app Happy DOM tests");
|
|
156
|
-
run(
|
|
157
|
-
[
|
|
158
|
-
"bun",
|
|
159
|
-
"test",
|
|
160
|
-
"--conditions",
|
|
161
|
-
"browser",
|
|
162
|
-
"tests/extended-mutators.test.ts",
|
|
163
|
-
],
|
|
164
|
-
APP_DIR,
|
|
165
|
-
"extended scaffold mutator regression",
|
|
166
|
-
);
|
|
167
|
-
run(
|
|
168
|
-
["bun", "test", "tests/customized-manager/manager.test.ts"],
|
|
169
|
-
APP_DIR,
|
|
170
|
-
"customized manager example regression",
|
|
171
|
-
);
|
|
172
|
-
const schemaProbePath = join(APP_DIR, "tests/packaged-schema-probe.ts");
|
|
173
|
-
writeFileSync(
|
|
174
|
-
schemaProbePath,
|
|
175
|
-
[
|
|
176
|
-
'import { z } from "zod";',
|
|
177
|
-
`import { defineSchema, table } from "${SDK_KEY}/v1/backend.js";`,
|
|
178
|
-
"",
|
|
179
|
-
'const markSchema = z.enum(["X", "O"]);',
|
|
180
|
-
'const matchStatusSchema = z.enum(["waiting", "x-turn", "o-turn", "x-won", "o-won", "draw"]);',
|
|
181
|
-
"export const schema = defineSchema({",
|
|
182
|
-
"\tschemaVersion: 1,",
|
|
183
|
-
"\ttables: {",
|
|
184
|
-
"\t\tplayers: {",
|
|
185
|
-
"\t\t\tschema: table(z.object({ userId: z.string(), mark: markSchema.nullable() })),",
|
|
186
|
-
"\t\t},",
|
|
187
|
-
"\t\tgame: {",
|
|
188
|
-
"\t\t\tschema: table(z.object({",
|
|
189
|
-
"\t\t\t\tboard: z.array(markSchema.nullable()).length(9),",
|
|
190
|
-
"\t\t\t\tstatus: matchStatusSchema,",
|
|
191
|
-
"\t\t\t\twinningLine: z.array(z.number()).nullable(),",
|
|
192
|
-
"\t\t\t})),",
|
|
193
|
-
"\t\t},",
|
|
194
|
-
"\t},",
|
|
195
|
-
"\tmutators: {",
|
|
196
|
-
'\t\tmakeMove: { description: "Place the current player mark", input: z.object({ cellIndex: z.number().int().min(0).max(8) }) },',
|
|
197
|
-
'\t\tstartNewRound: { description: "Reset the board", input: z.object({}) },',
|
|
198
|
-
"\t},",
|
|
199
|
-
"});",
|
|
200
|
-
"export type AppSchema = typeof schema;",
|
|
201
|
-
"",
|
|
202
|
-
].join("\n"),
|
|
203
|
-
);
|
|
204
|
-
const dataProbePath = join(APP_DIR, "tests/packaged-data-probe.ts");
|
|
205
|
-
writeFileSync(
|
|
206
|
-
dataProbePath,
|
|
207
|
-
[
|
|
208
|
-
`import type { InferReadContext, InferSchemaTableTypes } from "${SDK_KEY}/v1/client.js";`,
|
|
209
|
-
'import type { AppSchema } from "./packaged-schema-probe";',
|
|
210
|
-
"export type AppTableTypes = InferSchemaTableTypes<AppSchema>;",
|
|
211
|
-
"export type AppReadContext = InferReadContext<AppSchema>;",
|
|
212
|
-
'export type Player = AppTableTypes["players"];',
|
|
213
|
-
'export type Game = AppTableTypes["game"];',
|
|
214
|
-
"",
|
|
215
|
-
].join("\n"),
|
|
216
|
-
);
|
|
217
|
-
const clientProbePath = join(APP_DIR, "tests/packaged-client-probe.ts");
|
|
218
|
-
writeFileSync(
|
|
219
|
-
clientProbePath,
|
|
220
|
-
[
|
|
221
|
-
`import type { InferSyncedStoreClient } from "${SDK_KEY}/v1/client.js";`,
|
|
222
|
-
'import type { AppSchema } from "./packaged-schema-probe";',
|
|
223
|
-
"export type AppStoreClient = InferSyncedStoreClient<AppSchema>;",
|
|
224
|
-
'export type { AppReadContext, Game, Player } from "./packaged-data-probe";',
|
|
225
|
-
"",
|
|
226
|
-
].join("\n"),
|
|
227
|
-
);
|
|
228
|
-
const typeProbePath = join(APP_DIR, "tests/packaged-types-probe.ts");
|
|
229
|
-
writeFileSync(
|
|
230
|
-
typeProbePath,
|
|
231
|
-
[
|
|
232
|
-
`import { useLiveQuery } from "${SDK_KEY}/v1/react";`,
|
|
233
|
-
`import type { InferMutatorHandlers } from "${SDK_KEY}/v1/client.js";`,
|
|
234
|
-
'import type { AppSchema } from "./packaged-schema-probe";',
|
|
235
|
-
'import type { AppReadContext, AppStoreClient, Game, Player } from "./packaged-client-probe";',
|
|
236
|
-
"",
|
|
237
|
-
'type MakeMoveInput = Parameters<InferMutatorHandlers<AppSchema>["makeMove"]>[1];',
|
|
238
|
-
"type IsAny<T> = 0 extends 1 & T ? true : false;",
|
|
239
|
-
"type Equal<A, B> =",
|
|
240
|
-
"\t(<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2",
|
|
241
|
-
"\t\t? true",
|
|
242
|
-
"\t\t: false;",
|
|
243
|
-
'const packagedGameIsExact: Equal<Game, { board: ("X" | "O" | null)[]; status: "waiting" | "x-turn" | "o-turn" | "x-won" | "o-won" | "draw"; winningLine: number[] | null }> = true;',
|
|
244
|
-
'const packagedPlayerIsExact: Equal<Player, { userId: string; mark: "X" | "O" | null }> = true;',
|
|
245
|
-
"const packagedMoveInputIsExact: Equal<MakeMoveInput, { cellIndex: number }> = true;",
|
|
246
|
-
"const packagedGameTypeIsNotAny: IsAny<Game> = false;",
|
|
247
|
-
"const packagedPlayerTypeIsNotAny: IsAny<Player> = false;",
|
|
248
|
-
"const packagedMutatorInputIsNotAny: IsAny<MakeMoveInput> = false;",
|
|
249
|
-
'const packagedBoardCellIsNotAny: IsAny<Game["board"][number]> = false;',
|
|
250
|
-
'const packagedStatusIsNotAny: IsAny<Game["status"]> = false;',
|
|
251
|
-
'const packagedPlayerMarkIsNotAny: IsAny<Player["mark"]> = false;',
|
|
252
|
-
'const packagedMoveIndexIsNotAny: IsAny<MakeMoveInput["cellIndex"]> = false;',
|
|
253
|
-
"declare const game: Game;",
|
|
254
|
-
"declare const player: Player;",
|
|
255
|
-
"declare const moveInput: MakeMoveInput;",
|
|
256
|
-
'const packagedBoardCell: "X" | "O" | null = game.board[0];',
|
|
257
|
-
'const packagedStatus: "waiting" | "x-turn" | "o-turn" | "x-won" | "o-won" | "draw" = game.status;',
|
|
258
|
-
'const packagedPlayerMark: "X" | "O" | null = player.mark;',
|
|
259
|
-
"const packagedMoveIndex: number = moveInput.cellIndex;",
|
|
260
|
-
"async function readMatch(ctx: AppReadContext) {",
|
|
261
|
-
'\tconst players = await ctx.table("players").scan().values().toArray();',
|
|
262
|
-
'\tconst game = await ctx.table("game").get("state");',
|
|
263
|
-
'\tconst profiles = await ctx.table("$userInfo").scan().values().toArray();',
|
|
264
|
-
"\treturn { players, game, profiles };",
|
|
265
|
-
"}",
|
|
266
|
-
"declare const store: AppStoreClient;",
|
|
267
|
-
"const { data } = useLiveQuery(store, readMatch);",
|
|
268
|
-
'const currentPlayer = data?.players.find((player) => player.mark === "X");',
|
|
269
|
-
"async function queryStore() {",
|
|
270
|
-
"\tconst result = await store.query(readMatch);",
|
|
271
|
-
'\treturn result.players.find((player) => player.mark === "X");',
|
|
272
|
-
"}",
|
|
273
|
-
"void currentPlayer;",
|
|
274
|
-
"void queryStore;",
|
|
275
|
-
"void packagedGameTypeIsNotAny;",
|
|
276
|
-
"void packagedGameIsExact;",
|
|
277
|
-
"void packagedPlayerIsExact;",
|
|
278
|
-
"void packagedMoveInputIsExact;",
|
|
279
|
-
"void packagedPlayerTypeIsNotAny;",
|
|
280
|
-
"void packagedMutatorInputIsNotAny;",
|
|
281
|
-
"void packagedBoardCellIsNotAny;",
|
|
282
|
-
"void packagedStatusIsNotAny;",
|
|
283
|
-
"void packagedPlayerMarkIsNotAny;",
|
|
284
|
-
"void packagedMoveIndexIsNotAny;",
|
|
285
|
-
"void packagedBoardCell;",
|
|
286
|
-
"void packagedStatus;",
|
|
287
|
-
"void packagedPlayerMark;",
|
|
288
|
-
"void packagedMoveIndex;",
|
|
289
|
-
"",
|
|
290
|
-
].join("\n"),
|
|
291
|
-
);
|
|
292
|
-
run(["bun", "run", "type-check"], APP_DIR, "packaged SDK type probe");
|
|
293
|
-
run(["bun", "run", "build"], APP_DIR, "generated app build");
|
|
294
|
-
run(
|
|
295
|
-
["bun", "run", "test:playwright"],
|
|
296
|
-
APP_DIR,
|
|
297
|
-
"packaged multiplayer browser helpers",
|
|
298
|
-
);
|
|
299
|
-
// Exercise the render-check entry from the tarball.
|
|
300
|
-
run(["bun", "run", "render-check"], APP_DIR, "packaged render check");
|
|
301
|
-
|
|
302
|
-
// Probe published exports that the templates do not otherwise exercise.
|
|
303
|
-
const probePath = join(APP_DIR, "sdk-surface-probe.ts");
|
|
304
|
-
writeFileSync(
|
|
305
|
-
probePath,
|
|
306
|
-
[
|
|
307
|
-
`const backend = await import("${SDK_KEY}/v1/backend.js");`,
|
|
308
|
-
'for (const name of ["createModelStream", "collectModelText", "createImageGenerator"] as const) {',
|
|
309
|
-
' if (typeof backend[name] !== "function") {',
|
|
310
|
-
' throw new Error("missing v1/backend.js export: " + name);',
|
|
311
|
-
" }",
|
|
312
|
-
"}",
|
|
313
|
-
`const testUtils = await import("${SDK_KEY}/v1/test-utils.js");`,
|
|
314
|
-
'if (typeof testUtils.createClientInfo !== "function") {',
|
|
315
|
-
' throw new Error("missing v1/test-utils.js export: createClientInfo");',
|
|
316
|
-
"}",
|
|
317
|
-
`const devServer = await import("${SDK_KEY}/v1/test-utils/dev-server.js");`,
|
|
318
|
-
'if (typeof devServer.runPoeTileDevServer !== "function") {',
|
|
319
|
-
'\tthrow new Error("missing v1/test-utils/dev-server.js export: runPoeTileDevServer");',
|
|
320
|
-
"}",
|
|
321
|
-
// The CLI's stale-pin check reads this export.
|
|
322
|
-
`const names = await import("${SDK_KEY}/sdk-package-names");`,
|
|
323
|
-
'if (names.SDK_PACKAGE_NAME !== "joiner-sdk" || names.SDK_WIRE_CLIENT_SPECIFIER !== "poe-tiles-sdk/v1/client.js") {',
|
|
324
|
-
'\tthrow new Error("unexpected sdk-package-names export");',
|
|
325
|
-
"}",
|
|
326
|
-
'console.log("OK: SDK surface probe passed");',
|
|
327
|
-
"",
|
|
328
|
-
].join("\n"),
|
|
329
|
-
);
|
|
330
|
-
run(["bun", probePath], APP_DIR, "SDK surface probe");
|
|
331
|
-
|
|
332
|
-
const quickjsBytecodePath = join(
|
|
333
|
-
APP_DIR,
|
|
334
|
-
"dist/synced-store-backend-config.quickjs",
|
|
335
|
-
);
|
|
336
|
-
if (!existsSync(quickjsBytecodePath)) {
|
|
337
|
-
throw new Error(`QuickJS bytecode not emitted: ${quickjsBytecodePath}`);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
const solidDir = join(PACKAGED_APP_ROOT, SOLID_APP_NAME);
|
|
341
|
-
scaffoldApp({
|
|
342
|
-
appName: SOLID_APP_NAME,
|
|
343
|
-
template: "solidjs",
|
|
344
|
-
outputDir: solidDir,
|
|
345
|
-
sdkVersion: pathToFileURL(tempTarballPath).href,
|
|
346
|
-
includeSkill: true,
|
|
347
|
-
blank: true,
|
|
348
|
-
});
|
|
349
|
-
installWithSdkKey(solidDir, options, "install standalone SolidJS scaffold");
|
|
350
|
-
run(["bun", "run", "type-check"], solidDir, "standalone SolidJS type-check");
|
|
351
|
-
run(["bun", "run", "test"], solidDir, "standalone SolidJS tests");
|
|
352
|
-
run(["bun", "run", "build"], solidDir, "standalone SolidJS build");
|
|
353
|
-
|
|
354
|
-
if (runsDefaults) {
|
|
355
|
-
const cliDir = join(MONOREPO_ROOT, "projects/poe-tiles-cli");
|
|
356
|
-
// The workspace runner can use a different Playwright revision from the
|
|
357
|
-
// standalone app. Install its browser too instead of relying on local caches.
|
|
358
|
-
run(
|
|
359
|
-
["bunx", "playwright", "install", "chromium"],
|
|
360
|
-
cliDir,
|
|
361
|
-
"creator journey browser",
|
|
362
|
-
);
|
|
363
|
-
run(
|
|
364
|
-
[
|
|
365
|
-
"bun",
|
|
366
|
-
"test",
|
|
367
|
-
"--config=./bunfig.slow.toml",
|
|
368
|
-
"./src/creator-journey.test.slow.ts",
|
|
369
|
-
],
|
|
370
|
-
cliDir,
|
|
371
|
-
"packaged creator journey",
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
console.log(
|
|
376
|
-
`\nOK: Generated apps build with the ${SDK_KEY} key against the locally packed SDK tarball (name ${tarballName ?? "as packed"}).`,
|
|
377
|
-
);
|
|
378
|
-
} catch (error) {
|
|
379
|
-
// A successful install can omit an optional native package. Keep the exact
|
|
380
|
-
// resolved graph before finally removes it; never retry or mask the failure.
|
|
381
|
-
for (const appName of [APP_NAME, SOLID_APP_NAME]) {
|
|
382
|
-
const appDir = join(PACKAGED_APP_ROOT, appName);
|
|
383
|
-
if (!existsSync(join(appDir, "package.json"))) continue;
|
|
384
|
-
try {
|
|
385
|
-
saveInstallDiagnostics(appDir, join(INSTALL_DIAGNOSTICS_DIR, appName));
|
|
386
|
-
} catch (diagnosticError) {
|
|
387
|
-
console.error("Could not save install diagnostics:", diagnosticError);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
console.error(`Packaged SDK install diagnostics: ${INSTALL_DIAGNOSTICS_DIR}`);
|
|
391
|
-
throw error;
|
|
392
|
-
} finally {
|
|
393
|
-
rmSync(PACKAGED_APP_ROOT, { recursive: true, force: true });
|
|
394
|
-
if (tempTarballDir !== undefined) {
|
|
395
|
-
rmSync(tempTarballDir, { recursive: true, force: true });
|
|
396
|
-
}
|
|
397
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { afterEach, expect, test } from "bun:test";
|
|
2
|
-
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { tmpdir } from "node:os";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import {
|
|
6
|
-
findSourceProblems,
|
|
7
|
-
MAX_SOURCE_LINES,
|
|
8
|
-
} from "../base/scripts/check-source";
|
|
9
|
-
|
|
10
|
-
const SCRIPT = join(import.meta.dir, "../base/scripts/check-source.ts");
|
|
11
|
-
const roots: string[] = [];
|
|
12
|
-
|
|
13
|
-
/** A tile directory holding `files` (relative path to text). */
|
|
14
|
-
function tile(files: Record<string, string>): string {
|
|
15
|
-
const root = mkdtempSync(join(tmpdir(), "check-source-"));
|
|
16
|
-
roots.push(root);
|
|
17
|
-
for (const [path, text] of Object.entries(files)) {
|
|
18
|
-
mkdirSync(dirname(join(root, path)), { recursive: true });
|
|
19
|
-
writeFileSync(join(root, path), text);
|
|
20
|
-
}
|
|
21
|
-
return root;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function linesOf(count: number): string {
|
|
25
|
-
return "export const x = 1;\n".repeat(count);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
for (const root of roots.splice(0)) rmSync(root, { recursive: true });
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("a file of exactly MAX_SOURCE_LINES lines passes and one more line fails", () => {
|
|
33
|
-
const root = tile({
|
|
34
|
-
"ui/at-limit.ts": linesOf(MAX_SOURCE_LINES),
|
|
35
|
-
"ui/over-limit.ts": linesOf(MAX_SOURCE_LINES + 1),
|
|
36
|
-
});
|
|
37
|
-
expect(findSourceProblems(root)).toEqual([
|
|
38
|
-
`ui/over-limit.ts: ${MAX_SOURCE_LINES + 1} lines. Split it into focused modules of at most ${MAX_SOURCE_LINES} lines each.`,
|
|
39
|
-
]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test.each([
|
|
43
|
-
["// @ts-nocheck", "nocheck"],
|
|
44
|
-
[" //@ts-ignore", "ignore"],
|
|
45
|
-
["/* @ts-expect-error */ const y: number = 'a';", "expect-error"],
|
|
46
|
-
["/** @ts-ignore */", "ignore"],
|
|
47
|
-
["{/* @ts-expect-error */}", "expect-error"],
|
|
48
|
-
])("the suppression %p is reported with its line number", (line, directive) => {
|
|
49
|
-
const root = tile({ "synced-store/rules.ts": `const a = 1;\n${line}\n` });
|
|
50
|
-
expect(findSourceProblems(root)).toEqual([
|
|
51
|
-
`synced-store/rules.ts:2: @ts-${directive} hides type errors. Remove it and fix the errors tsc reports.`,
|
|
52
|
-
]);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test.each([
|
|
56
|
-
["/*\n@ts-ignore */", "ignore"],
|
|
57
|
-
["/**\n * @ts-expect-error\n */", "expect-error"],
|
|
58
|
-
])("the suppression on a later line of the block comment %p is reported", (comment, directive) => {
|
|
59
|
-
const root = tile({
|
|
60
|
-
"ui/game.ts": `const a = 1;\n${comment}\nconst b: number = "x";\n`,
|
|
61
|
-
});
|
|
62
|
-
expect(findSourceProblems(root)).toEqual([
|
|
63
|
-
`ui/game.ts:3: @ts-${directive} hides type errors. Remove it and fix the errors tsc reports.`,
|
|
64
|
-
]);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test("a directive-shaped line after a closed block comment passes", () => {
|
|
68
|
-
const root = tile({
|
|
69
|
-
"ui/game.ts": '/* note */\nconst tags = ["x"];\n@ts-ignore;\n',
|
|
70
|
-
});
|
|
71
|
-
expect(findSourceProblems(root)).toEqual([]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test("prose that names a suppression outside a directive passes", () => {
|
|
75
|
-
const root = tile({
|
|
76
|
-
"ui/help.ts":
|
|
77
|
-
'// Never add a @ts-ignore here.\nexport const tip = "use @ts-nocheck sparingly";\n',
|
|
78
|
-
});
|
|
79
|
-
expect(findSourceProblems(root)).toEqual([]);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("JavaScript fails in type-checked folders and passes at the tile root", () => {
|
|
83
|
-
const root = tile({
|
|
84
|
-
"ui/game.js": "export const x = 1;\n",
|
|
85
|
-
"tile/src/entry.jsx": "export const x = 1;\n",
|
|
86
|
-
"client.js": "export const x = 1;\n",
|
|
87
|
-
"postcss.config.js": "export default {};\n",
|
|
88
|
-
"scripts/tool.mjs": "export const x = 1;\n",
|
|
89
|
-
});
|
|
90
|
-
expect(findSourceProblems(root)).toEqual([
|
|
91
|
-
"client.js: JavaScript is not type-checked. Rename it to TypeScript and fix the errors tsc reports.",
|
|
92
|
-
"tile/src/entry.jsx: JavaScript is not type-checked. Rename it to TypeScript and fix the errors tsc reports.",
|
|
93
|
-
"ui/game.js: JavaScript is not type-checked. Rename it to TypeScript and fix the errors tsc reports.",
|
|
94
|
-
]);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test("dependencies, build output and dot folders are not scanned", () => {
|
|
98
|
-
const root = tile({
|
|
99
|
-
"node_modules/pkg/index.ts": "// @ts-nocheck\n",
|
|
100
|
-
"dist/index.js": linesOf(MAX_SOURCE_LINES + 1),
|
|
101
|
-
".claude/skills/tile-creator/example.ts": "// @ts-ignore\n",
|
|
102
|
-
".visual-checks/probe.ts": "// @ts-ignore\n",
|
|
103
|
-
"ui/App.ts": "export const ok = true;\n",
|
|
104
|
-
});
|
|
105
|
-
expect(findSourceProblems(root)).toEqual([]);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
test("the script exits 1 and lists every problem when run in a tile", () => {
|
|
109
|
-
const root = tile({
|
|
110
|
-
"ui/a.ts": "// @ts-nocheck\n",
|
|
111
|
-
"ui/b.js": "export const x = 1;\n",
|
|
112
|
-
});
|
|
113
|
-
const result = Bun.spawnSync([process.execPath, SCRIPT], { cwd: root });
|
|
114
|
-
expect(result.exitCode).toBe(1);
|
|
115
|
-
expect(result.stderr.toString()).toBe(
|
|
116
|
-
[
|
|
117
|
-
"Source check failed (scripts/check-source.ts):",
|
|
118
|
-
" ui/a.ts:1: @ts-nocheck hides type errors. Remove it and fix the errors tsc reports.",
|
|
119
|
-
" ui/b.js: JavaScript is not type-checked. Rename it to TypeScript and fix the errors tsc reports.",
|
|
120
|
-
"",
|
|
121
|
-
].join("\n"),
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("the script exits 0 silently on a clean tile", () => {
|
|
126
|
-
const root = tile({ "ui/App.ts": "export const ok = true;\n" });
|
|
127
|
-
const result = Bun.spawnSync([process.execPath, SCRIPT], { cwd: root });
|
|
128
|
-
expect(result.exitCode).toBe(0);
|
|
129
|
-
expect(result.stdout.toString()).toBe("");
|
|
130
|
-
expect(result.stderr.toString()).toBe("");
|
|
131
|
-
});
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/**
|
|
3
|
-
* Verifies the template's `bun run dev` script:
|
|
4
|
-
* - boots a TestServer + reload-injecting proxy
|
|
5
|
-
* - injects a /__dev_reload_ws client into the top-level HTML
|
|
6
|
-
* - broadcasts "reload" when dist/ changes (after vite rebuilds)
|
|
7
|
-
*
|
|
8
|
-
* Prerequisites: `bun run generate` to scaffold templates into
|
|
9
|
-
* generated-apps/template-<name>/, and `bun install --ignore-scripts` at
|
|
10
|
-
* the monorepo root so workspace deps resolve.
|
|
11
|
-
*
|
|
12
|
-
* Slow because each iteration spawns vite + waits for a real rebuild.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { afterAll, expect, test } from "bun:test";
|
|
16
|
-
import { type Subprocess, spawn } from "bun";
|
|
17
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
18
|
-
import { join } from "node:path";
|
|
19
|
-
import { GENERATED_APPS_DIR } from "../scripts/paths.ts";
|
|
20
|
-
|
|
21
|
-
const TEMPLATE = "react";
|
|
22
|
-
const APP_DIR = join(GENERATED_APPS_DIR, `template-${TEMPLATE}`);
|
|
23
|
-
const TYPE_ID = `template-${TEMPLATE}`;
|
|
24
|
-
|
|
25
|
-
if (!existsSync(APP_DIR)) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`Generated app not found: ${APP_DIR}\nRun "bun run generate" in poe-tile-templates first.`,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const dev: Subprocess<"ignore", "pipe", "pipe"> = spawn({
|
|
32
|
-
cmd: ["bun", "scripts/dev.ts"],
|
|
33
|
-
cwd: APP_DIR,
|
|
34
|
-
stdout: "pipe",
|
|
35
|
-
stderr: "pipe",
|
|
36
|
-
env: { ...process.env, FORCE_COLOR: "0" },
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Drain stderr into a buffer so timeout errors below can include it. Without
|
|
40
|
-
// this, a TestServer/proxy boot error printed to stderr is invisible in the
|
|
41
|
-
// failure message — we'd only see whatever stdout had buffered.
|
|
42
|
-
let stderrBuffer = "";
|
|
43
|
-
void (async () => {
|
|
44
|
-
const reader = (dev.stderr as ReadableStream<Uint8Array>).getReader();
|
|
45
|
-
const stderrDecoder = new TextDecoder();
|
|
46
|
-
try {
|
|
47
|
-
while (true) {
|
|
48
|
-
// biome-ignore lint/performance/noAwaitInLoops: Existing sequential async loops need case-by-case review; keep rule enabled for new code.
|
|
49
|
-
const { done, value } = await reader.read();
|
|
50
|
-
if (done) break;
|
|
51
|
-
stderrBuffer += stderrDecoder.decode(value, { stream: true });
|
|
52
|
-
}
|
|
53
|
-
} catch {
|
|
54
|
-
// stream closed during shutdown — fine.
|
|
55
|
-
}
|
|
56
|
-
})();
|
|
57
|
-
|
|
58
|
-
afterAll(() => {
|
|
59
|
-
dev.kill("SIGINT");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Tiered readUntil: each call advances `stdoutBuffer` and waits up to
|
|
63
|
-
// `timeoutMs` for `pattern`. Splitting the boot wait into multiple tiers
|
|
64
|
-
// (vite first build → testserver listening → URL printed) means the next CI
|
|
65
|
-
// flake fails at one specific tier and pinpoints which boot phase blew its
|
|
66
|
-
// budget, instead of the previous "the whole 10s envelope expired somewhere
|
|
67
|
-
// in there" failure. The shared `stdoutBuffer` is intentional: a fast tier
|
|
68
|
-
// might finish before its log line is read, so the next tier's match may
|
|
69
|
-
// already be in the buffer from a previous read.
|
|
70
|
-
const decoder = new TextDecoder();
|
|
71
|
-
let stdoutBuffer = "";
|
|
72
|
-
const stdoutReader = (dev.stdout as ReadableStream<Uint8Array>).getReader();
|
|
73
|
-
|
|
74
|
-
async function readUntil(
|
|
75
|
-
pattern: RegExp,
|
|
76
|
-
timeoutMs: number,
|
|
77
|
-
tierName: string,
|
|
78
|
-
): Promise<RegExpMatchArray> {
|
|
79
|
-
let match = stdoutBuffer.match(pattern);
|
|
80
|
-
if (match) return match;
|
|
81
|
-
const deadline = Date.now() + timeoutMs;
|
|
82
|
-
while (Date.now() < deadline) {
|
|
83
|
-
const remaining = deadline - Date.now();
|
|
84
|
-
// biome-ignore lint/performance/noAwaitInLoops: Existing sequential async loops need case-by-case review; keep rule enabled for new code.
|
|
85
|
-
const result = await Promise.race([
|
|
86
|
-
stdoutReader.read(),
|
|
87
|
-
new Promise<null>((r) =>
|
|
88
|
-
// biome-ignore lint: real I/O timeout — slow test waits on child-process stdout
|
|
89
|
-
setTimeout(() => r(null), remaining),
|
|
90
|
-
),
|
|
91
|
-
]);
|
|
92
|
-
if (result === null) break;
|
|
93
|
-
if (result.done) break;
|
|
94
|
-
stdoutBuffer += decoder.decode(result.value, { stream: true });
|
|
95
|
-
match = stdoutBuffer.match(pattern);
|
|
96
|
-
if (match) return match;
|
|
97
|
-
}
|
|
98
|
-
throw new Error(
|
|
99
|
-
`Timed out at tier "${tierName}" waiting for /${pattern.source}/ in dev output (${timeoutMs}ms).\n` +
|
|
100
|
-
`Stdout buffered:\n${stdoutBuffer}\n` +
|
|
101
|
-
`Stderr buffered:\n${stderrBuffer}`,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Skipped 2026-05-07: chronic CI flake on the "vite first build" tier
|
|
106
|
-
// (8000ms budget). Tracked in PR #2962. Re-observed in PRs #2963 (which
|
|
107
|
-
// added the tier wait + stderr capture) and #2973 (passed on no-cache,
|
|
108
|
-
// failed on cached for the same commit, strong flake signal). Un-skip
|
|
109
|
-
// once the underlying boot-time variance is fixed; the test still runs
|
|
110
|
-
// locally for development.
|
|
111
|
-
test.skip("dev script boots, injects reload script, broadcasts on rebuild", async () => {
|
|
112
|
-
// Tiered boot wait: vite first build (cold prod bundle, the historically
|
|
113
|
-
// slow phase per PR #2816) gets the largest budget; subsequent phases
|
|
114
|
-
// should be near-instant. Total envelope still ~11s so the test stays
|
|
115
|
-
// "fast" per PRINCIPLES.md.
|
|
116
|
-
await readUntil(/\[dev\] vite first build done/, 8_000, "vite first build");
|
|
117
|
-
await readUntil(
|
|
118
|
-
/\[dev\] testserver listening/,
|
|
119
|
-
1_500,
|
|
120
|
-
"testserver listening",
|
|
121
|
-
);
|
|
122
|
-
const urlMatch = await readUntil(
|
|
123
|
-
/URL:\s+(http:\/\/\S+)/,
|
|
124
|
-
1_500,
|
|
125
|
-
"proxy URL printed",
|
|
126
|
-
);
|
|
127
|
-
const url = urlMatch[1]!;
|
|
128
|
-
expect(url).toContain(`/room/${TYPE_ID}/dev/tile/${TYPE_ID}/dev`);
|
|
129
|
-
|
|
130
|
-
const html = await fetch(url).then((r) => r.text());
|
|
131
|
-
expect(html).toContain("/__dev_reload_ws");
|
|
132
|
-
expect(html).toContain("location.reload()");
|
|
133
|
-
|
|
134
|
-
const wsUrl = new URL(url);
|
|
135
|
-
wsUrl.protocol = "ws:";
|
|
136
|
-
wsUrl.pathname = "/__dev_reload_ws";
|
|
137
|
-
wsUrl.search = "";
|
|
138
|
-
|
|
139
|
-
const ws = new WebSocket(wsUrl.toString());
|
|
140
|
-
const reloadMessage = new Promise<string>((resolve, reject) => {
|
|
141
|
-
ws.addEventListener("message", (e) => resolve(String(e.data)));
|
|
142
|
-
ws.addEventListener("error", () => reject(new Error("ws error")));
|
|
143
|
-
});
|
|
144
|
-
await new Promise<void>((resolve, reject) => {
|
|
145
|
-
ws.addEventListener("open", () => resolve());
|
|
146
|
-
ws.addEventListener("error", () => reject(new Error("ws connect failed")));
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const appPath = join(APP_DIR, "ui/App.tsx");
|
|
150
|
-
const original = readFileSync(appPath, "utf-8");
|
|
151
|
-
writeFileSync(appPath, `${original}\n// dev-reload-test ${Date.now()}\n`);
|
|
152
|
-
|
|
153
|
-
try {
|
|
154
|
-
const message = await Promise.race([
|
|
155
|
-
reloadMessage,
|
|
156
|
-
new Promise<never>((_, r) =>
|
|
157
|
-
// biome-ignore lint: real I/O timeout — slow test waits on vite rebuild + ws broadcast
|
|
158
|
-
setTimeout(() => r(new Error("reload not received in 10s")), 10_000),
|
|
159
|
-
),
|
|
160
|
-
]);
|
|
161
|
-
expect(message).toBe("reload");
|
|
162
|
-
} finally {
|
|
163
|
-
writeFileSync(appPath, original);
|
|
164
|
-
ws.close();
|
|
165
|
-
}
|
|
166
|
-
}, 20_000);
|