@joiner-platform/cli 0.1.17 → 0.1.19

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.
Files changed (38) hide show
  1. package/package.json +2 -2
  2. package/skills/tile-creator/references/cli.md +1 -1
  3. package/skills/tile-creator/references/client-api.md +16 -6
  4. package/src/commands/init/scaffold.ts +2 -9
  5. package/src/commands/init/sdk-tarball-url.generated.ts +2 -2
  6. package/src/commands/init/template-names.ts +18 -0
  7. package/bundled-resources/poe-tile-templates/coverage.config.json +0 -6
  8. package/bundled-resources/poe-tile-templates/index.ts +0 -27
  9. package/bundled-resources/poe-tile-templates/package.json +0 -31
  10. package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +0 -10
  11. package/bundled-resources/poe-tile-templates/scripts/generate.ts +0 -57
  12. package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +0 -52
  13. package/bundled-resources/poe-tile-templates/scripts/paths.ts +0 -7
  14. package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +0 -288
  15. package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +0 -132
  16. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +0 -30
  17. package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +0 -397
  18. package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +0 -131
  19. package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +0 -166
  20. package/bundled-resources/poe-tile-templates/tests/doctor-launcher.test.ts +0 -48
  21. package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +0 -67
  22. package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +0 -106
  23. package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +0 -103
  24. package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +0 -67
  25. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +0 -85
  26. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +0 -69
  27. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +0 -73
  28. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +0 -54
  29. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +0 -70
  30. package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +0 -85
  31. package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +0 -278
  32. package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +0 -27
  33. package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +0 -99
  34. package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +0 -23
  35. package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +0 -84
  36. package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +0 -56
  37. package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +0 -129
  38. package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +0 -90
@@ -1,132 +0,0 @@
1
- // owner: jyoung-q
2
- /**
3
- * Cleans and scaffolds every template with both SDK resolution modes. Workspace
4
- * mode exercises the default blank creator experience against the code under
5
- * test. Released-tarball mode retains the canonical example because a scaffold
6
- * may intentionally depend on SDK changes that have not shipped yet. The local
7
- * packed-SDK regression covers that exact candidate combination.
8
- *
9
- * Workspace mode requires the SDK to be built (the `./vite` export resolves
10
- * to `dist/`), so we run `turbo build --filter joiner-sdk` once up front.
11
- * Tarball mode pulls a prebuilt SDK from the URL committed at
12
- * `projects/poe-tiles-cli/src/commands/init/sdk-tarball-url.generated.ts`.
13
- *
14
- * Note: installs pass --no-save so the root bun.lock is not rewritten;
15
- * the gitignored generated-apps/template-* workspaces would otherwise
16
- * leak into the lockfile and pollute unrelated PR diffs.
17
- */
18
-
19
- import { spawnSync } from "node:child_process";
20
- import { copyFileSync, mkdirSync, rmSync } from "node:fs";
21
- import { join } from "node:path";
22
- import { scaffoldApp } from "../../../projects/poe-tiles-cli/src/commands/init/scaffold.ts";
23
- import { SDK_TARBALL_URL } from "../../../projects/poe-tiles-cli/src/commands/init/sdk-tarball-url.generated.ts";
24
- import { TEMPLATES } from "..";
25
- import {
26
- installStarterDemoTests,
27
- replaceStarterSchema,
28
- } from "../tests/fixtures/replace-starter-schema";
29
- import { GENERATED_APPS_DIR, MONOREPO_ROOT } from "./paths.ts";
30
-
31
- type SdkMode = "workspace" | "tarball";
32
-
33
- function run(cmd: string[], cwd: string, label: string): void {
34
- console.log(`\n→ ${label}: ${cmd.join(" ")}`);
35
- const result = spawnSync(cmd[0]!, cmd.slice(1), {
36
- cwd,
37
- stdio: "inherit",
38
- env: process.env,
39
- });
40
- if (result.status !== 0) {
41
- throw new Error(`${label} failed (exit ${result.status})`);
42
- }
43
- }
44
-
45
- function scaffoldAll(mode: SdkMode): void {
46
- rmSync(GENERATED_APPS_DIR, { recursive: true, force: true });
47
- mkdirSync(GENERATED_APPS_DIR, { recursive: true });
48
- const sdkVersion = mode === "workspace" ? "workspace:*" : SDK_TARBALL_URL;
49
- for (const template of TEMPLATES) {
50
- const dir = join(GENERATED_APPS_DIR, `template-${template}`);
51
- scaffoldApp({
52
- appName: `template-${template}`,
53
- template,
54
- outputDir: dir,
55
- sdkVersion,
56
- includeSkill: true,
57
- blank: mode === "workspace",
58
- });
59
- if (mode === "workspace") {
60
- installStarterDemoTests(dir, template);
61
- copyFileSync(
62
- join(
63
- import.meta.dir,
64
- "../tests/fixtures/multiplayer-verification.test.playwright.ts.txt",
65
- ),
66
- join(dir, "tests/multiplayer-verification.test.playwright.ts"),
67
- );
68
- }
69
- console.log(` Scaffolded (${mode}): ${template}`);
70
- }
71
- }
72
-
73
- function verifyMode(mode: SdkMode): void {
74
- console.log("\n=========================");
75
- console.log(`SDK mode: ${mode}`);
76
- console.log("=========================");
77
- scaffoldAll(mode);
78
- run(
79
- ["bun", "install", "--ignore-scripts", "--no-save"],
80
- MONOREPO_ROOT,
81
- `bun install (${mode})`,
82
- );
83
- for (const template of TEMPLATES) {
84
- const dir = join(GENERATED_APPS_DIR, `template-${template}`);
85
- run(["bun", "run", "type-check"], dir, `${mode}/${template} type-check`);
86
- run(["bun", "run", "test"], dir, `${mode}/${template} test`);
87
- if (mode === "workspace") {
88
- run(
89
- [
90
- "bun",
91
- "test",
92
- "--conditions",
93
- "browser",
94
- "./ui/starter-demo.test.happydom.tsx",
95
- ],
96
- dir,
97
- `${template} starter demo UI`,
98
- );
99
- replaceStarterSchema(dir, template);
100
- run(
101
- ["bun", "run", "type-check"],
102
- dir,
103
- `${template} replacement schema types`,
104
- );
105
- run(
106
- ["bun", "run", "test"],
107
- dir,
108
- `${template} unchanged tests after schema replacement`,
109
- );
110
- }
111
- run(
112
- ["bun", "run", "test:playwright"],
113
- dir,
114
- `${mode}/${template} test:playwright`,
115
- );
116
- }
117
- }
118
-
119
- // Workspace mode resolves `joiner-sdk/vite` to dist/ — build first.
120
- run(
121
- ["bunx", "turbo", "build", "--filter", "joiner-sdk"],
122
- MONOREPO_ROOT,
123
- "turbo build poe-tiles-sdk",
124
- );
125
-
126
- verifyMode("workspace");
127
- verifyMode("tarball");
128
-
129
- rmSync(GENERATED_APPS_DIR, { recursive: true, force: true });
130
- console.log(
131
- "\n✓ All templates passed type-check + test + test:playwright in both SDK modes.",
132
- );
@@ -1,30 +0,0 @@
1
- // owner: jyoung-q
2
- import { spawnSync } from "node:child_process";
3
-
4
- export function runVerificationCommand(
5
- cmd: string[],
6
- cwd: string,
7
- label: string,
8
- env: NodeJS.ProcessEnv = process.env,
9
- ): void {
10
- console.log(`\n-> ${label}: ${cmd.join(" ")}`);
11
- const result = spawnSync(cmd[0]!, cmd.slice(1), {
12
- cwd,
13
- stdio: "inherit",
14
- env,
15
- });
16
- if (result.status !== 0) {
17
- throw new Error(`${label} failed (exit ${result.status})`);
18
- }
19
- }
20
-
21
- export function getPublishEnvironment(): NodeJS.ProcessEnv {
22
- const env: NodeJS.ProcessEnv = {
23
- ...process.env,
24
- SKIP_SDK_TARBALL_UPLOAD: "1",
25
- };
26
- delete env["UPLOAD_SECRET"];
27
- delete env["POE_API_KEY"];
28
- delete env["POE_API_KEY_USER_2"];
29
- return env;
30
- }
@@ -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
- });