@joiner-platform/cli 0.1.17 → 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 +1 -1
- 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/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
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joiner-platform/cli",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "0.1.18",
|
|
4
|
+
"gitHead": "d9ce5e8decd6d5eac5c4415fac656ac686dbc402",
|
|
5
5
|
"description": "The Joiner CLI: create, test, and publish Joiner tiles, with agent skills for coding agents.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"joiner",
|
|
@@ -61,7 +61,7 @@ an older pin, so prefer the live result when upgrading:
|
|
|
61
61
|
|
|
62
62
|
<!-- begin: sdk-tarball-snippet (auto-generated by packages/poe-tiles-sdk/scripts/publish-tar.ts — do not edit by hand) -->
|
|
63
63
|
```json
|
|
64
|
-
"joiner-sdk": "https://misc-dev-uploads.quora-913.workers.dev/
|
|
64
|
+
"joiner-sdk": "https://misc-dev-uploads.quora-913.workers.dev/7a524cd85ec30b6f07c29659d5c6109df3ca1d9d07d445d1603e9b1b99437336"
|
|
65
65
|
```
|
|
66
66
|
<!-- end: sdk-tarball-snippet -->
|
|
67
67
|
|
|
@@ -35,15 +35,7 @@ import {
|
|
|
35
35
|
applyInternalMonoRepoTypeCheckScripts,
|
|
36
36
|
} from "./package-json-scripts.js";
|
|
37
37
|
import { readSdkTarballUrl } from "./sdk-tarball-url.js";
|
|
38
|
-
|
|
39
|
-
export const TEMPLATES = [
|
|
40
|
-
"react",
|
|
41
|
-
"vanilla-js",
|
|
42
|
-
"solidjs",
|
|
43
|
-
"preact",
|
|
44
|
-
"phaserjs",
|
|
45
|
-
] as const;
|
|
46
|
-
export type TemplateName = (typeof TEMPLATES)[number];
|
|
38
|
+
import { TEMPLATES, type TemplateName } from "./template-names.js";
|
|
47
39
|
|
|
48
40
|
/**
|
|
49
41
|
* Allowed app-name shape and length cap. Re-exported from
|
|
@@ -56,6 +48,7 @@ export {
|
|
|
56
48
|
TILE_HANDLE_MAX_LENGTH as VALID_NAME_MAX_LENGTH,
|
|
57
49
|
TILE_HANDLE_REGEX as VALID_NAME_RE,
|
|
58
50
|
} from "../../poe-tile-config.js";
|
|
51
|
+
export { TEMPLATES, type TemplateName };
|
|
59
52
|
export const INVALID_NAME_HINT =
|
|
60
53
|
"Use lowercase letters, numbers, and hyphens only. Must start and end with a letter or number; 1-100 characters.";
|
|
61
54
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Auto-generated by poe-tiles-sdk/scripts/publish-tar.ts — do not edit
|
|
2
|
-
// publishedAt: 2026-11-
|
|
2
|
+
// publishedAt: 2026-11-30T17:00:08.574Z
|
|
3
3
|
export const SDK_TARBALL_URL =
|
|
4
|
-
"https://misc-dev-uploads.quora-913.workers.dev/
|
|
4
|
+
"https://misc-dev-uploads.quora-913.workers.dev/7a524cd85ec30b6f07c29659d5c6109df3ca1d9d07d445d1603e9b1b99437336";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
// Kept import-free: scripts/pack-tarball.ts reads it to choose which template
|
|
3
|
+
// directories ship, and runs before the CLI's dependencies are installed.
|
|
4
|
+
export const TEMPLATES = [
|
|
5
|
+
"react",
|
|
6
|
+
"vanilla-js",
|
|
7
|
+
"solidjs",
|
|
8
|
+
"preact",
|
|
9
|
+
"phaserjs",
|
|
10
|
+
] as const;
|
|
11
|
+
export type TemplateName = (typeof TEMPLATES)[number];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The top-level directories of packages/poe-tile-templates the published CLI
|
|
15
|
+
* ships and scaffolds from. The package's own tests, scripts and manifest stay
|
|
16
|
+
* out, and edits to them do not trigger a CLI release.
|
|
17
|
+
*/
|
|
18
|
+
export const BUNDLED_TEMPLATE_DIRS = ["base", ...TEMPLATES] as const;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/**
|
|
3
|
-
* Poe app templates for scaffolding new apps.
|
|
4
|
-
*
|
|
5
|
-
* Exports template names and a function to resolve template directories.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { resolve } from "node:path";
|
|
9
|
-
|
|
10
|
-
export const TEMPLATES = [
|
|
11
|
-
"react",
|
|
12
|
-
"vanilla-js",
|
|
13
|
-
"solidjs",
|
|
14
|
-
"preact",
|
|
15
|
-
"phaserjs",
|
|
16
|
-
] as const;
|
|
17
|
-
export type TemplateName = (typeof TEMPLATES)[number];
|
|
18
|
-
|
|
19
|
-
/** Resolve the base template directory. */
|
|
20
|
-
export function baseTemplateDir(): string {
|
|
21
|
-
return resolve(import.meta.dir, "base");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Resolve a framework-specific template directory. */
|
|
25
|
-
export function frameworkTemplateDir(template: TemplateName): string {
|
|
26
|
-
return resolve(import.meta.dir, template);
|
|
27
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@poe-tile/templates",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "index.ts",
|
|
6
|
-
"types": "index.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./index.ts",
|
|
10
|
-
"default": "./index.ts"
|
|
11
|
-
},
|
|
12
|
-
"./test-utils/customized-manager": "./tests/fixtures/customized-manager.ts"
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"generate-test-apps": "bun scripts/generate.ts && bun install --ignore-scripts --no-save",
|
|
16
|
-
"generate:cleanup": "bun scripts/cleanup.ts",
|
|
17
|
-
"test": "bun test tests/check-source.test.ts tests/playwright-version.test.ts tests/happy-dom-version.test.ts tests/native-gesture-defaults.test.ts tests/visual-check.test.ts tests/install-diagnostics.test.ts tests/render-check-scaffold.test.ts tests/sdk-dependency-key.test.ts tests/doctor-launcher.test.ts",
|
|
18
|
-
"test:generated": "bun test tests/generated-templates.test.ts",
|
|
19
|
-
"test:generated:packaged-sdk": "bun scripts/verify-local-sdk-tarball.ts",
|
|
20
|
-
"test:slow": "bun run generate-test-apps && bun test ./tests/*.test.slow.ts --reporter=junit --reporter-outfile=junit-slow.xml",
|
|
21
|
-
"verify:all-sdks": "bun scripts/verify-all-sdks.ts",
|
|
22
|
-
"lint": "biome lint --error-on-warnings .",
|
|
23
|
-
"format:check": "biome format ."
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/bun": "^1"
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"typescript": "^6 || ^7"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/**
|
|
3
|
-
* Removes generated template dirs.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { rmSync } from "node:fs";
|
|
7
|
-
import { GENERATED_APPS_DIR } from "./paths.ts";
|
|
8
|
-
|
|
9
|
-
rmSync(GENERATED_APPS_DIR, { recursive: true, force: true });
|
|
10
|
-
console.log(" Removed: generated-apps/");
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/**
|
|
3
|
-
* Scaffolds all templates into generated-apps/template-<name>/.
|
|
4
|
-
* Run this before testing to create workspace-resolvable template instances.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { mkdirSync, rmSync } from "node:fs";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
import { scaffoldApp } from "../../../projects/poe-tiles-cli/src/commands/init/scaffold.ts";
|
|
10
|
-
import { TEMPLATES } from "..";
|
|
11
|
-
import { GENERATED_APPS_DIR } from "./paths.ts";
|
|
12
|
-
|
|
13
|
-
mkdirSync(GENERATED_APPS_DIR, { recursive: true });
|
|
14
|
-
|
|
15
|
-
for (const template of TEMPLATES) {
|
|
16
|
-
const dir = join(GENERATED_APPS_DIR, `template-${template}`);
|
|
17
|
-
rmSync(dir, { recursive: true, force: true });
|
|
18
|
-
scaffoldApp({
|
|
19
|
-
appName: `template-${template}`,
|
|
20
|
-
template,
|
|
21
|
-
outputDir: dir,
|
|
22
|
-
// Generated apps live inside the monorepo workspace, so resolve
|
|
23
|
-
// `joiner-sdk` to `workspace:*` rather than the published tarball.
|
|
24
|
-
// Without this, the base template's mutator tests fail with
|
|
25
|
-
// "Export named 'waitForKeyExists' not found" because the tarball
|
|
26
|
-
// SDK lags the workspace SDK. The tarball path is exercised
|
|
27
|
-
// separately by `bun run test:generated-apps:all-sdks` /
|
|
28
|
-
// `verify-all-sdks.ts`.
|
|
29
|
-
internalMonoRepo: true,
|
|
30
|
-
// Mirror `poe-tiles tiles init` CLI defaults so the generated-apps
|
|
31
|
-
// suite verifies the actual getting-started experience — a user
|
|
32
|
-
// running the CLI with no flags gets `--blank` + `--skills`, and any
|
|
33
|
-
// regression that breaks build/test/e2e for that exact shape (or
|
|
34
|
-
// drops the bundled SDK skills) must fail this suite.
|
|
35
|
-
includeSkill: true,
|
|
36
|
-
blank: true,
|
|
37
|
-
});
|
|
38
|
-
console.log(` Generated: ${template}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// The store-less variant behind `poe-tiles tiles init --no-store`. Generated
|
|
42
|
-
// beside the default so the suite proves each template still installs,
|
|
43
|
-
// type-checks, tests, and builds with synced-store removed.
|
|
44
|
-
for (const template of TEMPLATES) {
|
|
45
|
-
const dir = join(GENERATED_APPS_DIR, `template-${template}-no-store`);
|
|
46
|
-
rmSync(dir, { recursive: true, force: true });
|
|
47
|
-
scaffoldApp({
|
|
48
|
-
appName: `template-${template}-no-store`,
|
|
49
|
-
template,
|
|
50
|
-
outputDir: dir,
|
|
51
|
-
internalMonoRepo: true,
|
|
52
|
-
includeSkill: true,
|
|
53
|
-
blank: true,
|
|
54
|
-
noStore: true,
|
|
55
|
-
});
|
|
56
|
-
console.log(` Generated (no-store): ${template}`);
|
|
57
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
|
|
5
|
-
/** Preserve only install evidence, never the scaffold's environment or credentials. */
|
|
6
|
-
export function saveInstallDiagnostics(
|
|
7
|
-
appDir: string,
|
|
8
|
-
outputDir: string,
|
|
9
|
-
): void {
|
|
10
|
-
mkdirSync(outputDir, { recursive: true });
|
|
11
|
-
for (const name of ["package.json", "bun.lock"]) {
|
|
12
|
-
const path = join(appDir, name);
|
|
13
|
-
if (existsSync(path)) copyFileSync(path, join(outputDir, name));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const appRequire = createRequire(join(appDir, "package.json"));
|
|
17
|
-
const resolutions: Record<string, string> = {};
|
|
18
|
-
try {
|
|
19
|
-
const vitePath = appRequire.resolve("vite/package.json");
|
|
20
|
-
resolutions["vite"] = vitePath;
|
|
21
|
-
copyFileSync(vitePath, join(outputDir, "vite-package.json"));
|
|
22
|
-
// Follow Vite's dependency graph, including a nested Rollup installation.
|
|
23
|
-
const rollupPath = createRequire(vitePath).resolve("rollup/package.json");
|
|
24
|
-
resolutions["rollup"] = rollupPath;
|
|
25
|
-
copyFileSync(rollupPath, join(outputDir, "rollup-package.json"));
|
|
26
|
-
const rollupRequire = createRequire(rollupPath);
|
|
27
|
-
const rollup: { optionalDependencies?: Record<string, string> } =
|
|
28
|
-
rollupRequire(rollupPath);
|
|
29
|
-
for (const name of Object.keys(rollup.optionalDependencies ?? {})) {
|
|
30
|
-
try {
|
|
31
|
-
resolutions[name] = rollupRequire.resolve(name);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
resolutions[name] = String(error);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
} catch (error) {
|
|
37
|
-
resolutions["error"] = String(error);
|
|
38
|
-
}
|
|
39
|
-
writeFileSync(
|
|
40
|
-
join(outputDir, "resolution.json"),
|
|
41
|
-
JSON.stringify(
|
|
42
|
-
{
|
|
43
|
-
platform: process.platform,
|
|
44
|
-
arch: process.arch,
|
|
45
|
-
bun: Bun.version,
|
|
46
|
-
resolutions,
|
|
47
|
-
},
|
|
48
|
-
null,
|
|
49
|
-
2,
|
|
50
|
-
),
|
|
51
|
-
);
|
|
52
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/** Shared path constants for template generation scripts and tests. */
|
|
3
|
-
|
|
4
|
-
import { join, resolve } from "node:path";
|
|
5
|
-
|
|
6
|
-
export const MONOREPO_ROOT = resolve(import.meta.dir, "../../..");
|
|
7
|
-
export const GENERATED_APPS_DIR = join(MONOREPO_ROOT, "generated-apps");
|
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
// owner: jyoung-q
|
|
2
|
-
/**
|
|
3
|
-
* Lets the packed-SDK verification run a scaffold under either SDK dependency
|
|
4
|
-
* key (`joiner-sdk` or the legacy `poe-tiles-sdk`), and repack the tarball
|
|
5
|
-
* under either package name. Every tarball the release bot publishes must
|
|
6
|
-
* install and build under both keys, because old projects keep the legacy
|
|
7
|
-
* key with no end date:
|
|
8
|
-
*
|
|
9
|
-
* bun scripts/verify-local-sdk-tarball.ts \
|
|
10
|
-
* [--dependency-key joiner-sdk|poe-tiles-sdk] \
|
|
11
|
-
* [--tarball-name joiner-sdk|poe-tiles-sdk]
|
|
12
|
-
*
|
|
13
|
-
* `--dependency-key` (default `joiner-sdk`, what the CLI scaffold writes) is
|
|
14
|
-
* the key the scaffolded projects install the SDK under and the name their
|
|
15
|
-
* source imports. `--tarball-name` repacks the tarball under that package
|
|
16
|
-
* name first (default: the name in the source package.json, `joiner-sdk`).
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import assert from "node:assert/strict";
|
|
20
|
-
import { execFileSync } from "node:child_process";
|
|
21
|
-
import {
|
|
22
|
-
copyFileSync,
|
|
23
|
-
existsSync,
|
|
24
|
-
mkdtempSync,
|
|
25
|
-
readdirSync,
|
|
26
|
-
readFileSync,
|
|
27
|
-
rmSync,
|
|
28
|
-
writeFileSync,
|
|
29
|
-
} from "node:fs";
|
|
30
|
-
import { tmpdir } from "node:os";
|
|
31
|
-
import { extname, join } from "node:path";
|
|
32
|
-
import { runVerificationCommand } from "./verify-local-sdk-command";
|
|
33
|
-
|
|
34
|
-
export const SDK_DEPENDENCY_KEYS = ["poe-tiles-sdk", "joiner-sdk"] as const;
|
|
35
|
-
export type SdkDependencyKey = (typeof SDK_DEPENDENCY_KEYS)[number];
|
|
36
|
-
|
|
37
|
-
/** The key the CLI scaffold writes, and the packed tarball's `name`. */
|
|
38
|
-
const SCAFFOLD_KEY: SdkDependencyKey = "joiner-sdk";
|
|
39
|
-
|
|
40
|
-
export interface VerifyOptions {
|
|
41
|
-
/** The key the scaffolded project installs the SDK under. */
|
|
42
|
-
dependencyKey: SdkDependencyKey;
|
|
43
|
-
/** Repack the tarball under this `name`; undefined keeps the packed name. */
|
|
44
|
-
tarballName: SdkDependencyKey | undefined;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function parseKey(flag: string, value: string | undefined): SdkDependencyKey {
|
|
48
|
-
const key = SDK_DEPENDENCY_KEYS.find((candidate) => candidate === value);
|
|
49
|
-
if (!key) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
`${flag} must be one of ${SDK_DEPENDENCY_KEYS.join(", ")}; got ${value ?? "nothing"}`,
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
return key;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** `--dependency-key <key>` and `--tarball-name <key>`; both optional. */
|
|
58
|
-
export function parseVerifyOptions(argv: readonly string[]): VerifyOptions {
|
|
59
|
-
const options: VerifyOptions = {
|
|
60
|
-
dependencyKey: SCAFFOLD_KEY,
|
|
61
|
-
tarballName: undefined,
|
|
62
|
-
};
|
|
63
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
64
|
-
const flag = argv[index];
|
|
65
|
-
const value = argv[index + 1];
|
|
66
|
-
if (flag === "--dependency-key") {
|
|
67
|
-
options.dependencyKey = parseKey(flag, value);
|
|
68
|
-
} else if (flag === "--tarball-name") {
|
|
69
|
-
options.tarballName = parseKey(flag, value);
|
|
70
|
-
} else {
|
|
71
|
-
throw new Error(`Unknown option: ${flag}`);
|
|
72
|
-
}
|
|
73
|
-
index += 1;
|
|
74
|
-
}
|
|
75
|
-
return options;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const QUOTED_SDK_SPECIFIER = /(["'`])joiner-sdk(?=["'`/])/g;
|
|
79
|
-
const INSTALLED_SDK_PATH = /node_modules\/joiner-sdk(?=\/)/g;
|
|
80
|
-
|
|
81
|
-
/** Rewrites quoted `joiner-sdk` specifiers and installed paths to `key`. */
|
|
82
|
-
export function rewriteSdkSpecifiers(
|
|
83
|
-
text: string,
|
|
84
|
-
key: SdkDependencyKey,
|
|
85
|
-
): string {
|
|
86
|
-
if (key === SCAFFOLD_KEY) return text;
|
|
87
|
-
return text
|
|
88
|
-
.replace(QUOTED_SDK_SPECIFIER, `$1${key}`)
|
|
89
|
-
.replace(INSTALLED_SDK_PATH, `node_modules/${key}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const PROJECT_SOURCE_EXTENSIONS = new Set([
|
|
93
|
-
".ts",
|
|
94
|
-
".tsx",
|
|
95
|
-
".mts",
|
|
96
|
-
".cts",
|
|
97
|
-
".js",
|
|
98
|
-
".jsx",
|
|
99
|
-
".mjs",
|
|
100
|
-
".cjs",
|
|
101
|
-
".json",
|
|
102
|
-
".html",
|
|
103
|
-
]);
|
|
104
|
-
const SKIPPED_DIRECTORIES = new Set(["node_modules", ".git", "dist"]);
|
|
105
|
-
|
|
106
|
-
function* projectSourceFiles(dir: string): Generator<string> {
|
|
107
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
108
|
-
const path = join(dir, entry.name);
|
|
109
|
-
if (entry.isDirectory()) {
|
|
110
|
-
if (!SKIPPED_DIRECTORIES.has(entry.name)) yield* projectSourceFiles(path);
|
|
111
|
-
} else if (
|
|
112
|
-
entry.isFile() &&
|
|
113
|
-
PROJECT_SOURCE_EXTENSIONS.has(extname(entry.name))
|
|
114
|
-
) {
|
|
115
|
-
yield path;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
type PackageJson = Record<string, unknown> & {
|
|
121
|
-
dependencies?: Record<string, string>;
|
|
122
|
-
devDependencies?: Record<string, string>;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Moves a scaffolded project from the `joiner-sdk` key to `key`: the
|
|
127
|
-
* dependency entry (renamed in place, so the manifest changes only by name)
|
|
128
|
-
* and every import and installed path in its source.
|
|
129
|
-
*/
|
|
130
|
-
export function useSdkDependencyKey(
|
|
131
|
-
appDir: string,
|
|
132
|
-
key: SdkDependencyKey,
|
|
133
|
-
): void {
|
|
134
|
-
if (key === SCAFFOLD_KEY) return;
|
|
135
|
-
for (const path of projectSourceFiles(appDir)) {
|
|
136
|
-
const text = readFileSync(path, "utf8");
|
|
137
|
-
const rewritten = rewriteSdkSpecifiers(text, key);
|
|
138
|
-
if (rewritten !== text) writeFileSync(path, rewritten);
|
|
139
|
-
}
|
|
140
|
-
const manifestPath = join(appDir, "package.json");
|
|
141
|
-
const manifest = JSON.parse(
|
|
142
|
-
readFileSync(manifestPath, "utf8"),
|
|
143
|
-
) as PackageJson;
|
|
144
|
-
const declared = [manifest.dependencies, manifest.devDependencies].some(
|
|
145
|
-
(deps) => deps !== undefined && key in deps && !(SCAFFOLD_KEY in deps),
|
|
146
|
-
);
|
|
147
|
-
if (!declared) {
|
|
148
|
-
throw new Error(`${manifestPath} must depend on ${key} only`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* The SDK's imports of its own entries, which the packer keeps external: the
|
|
154
|
-
* `joiner-sdk/...` entries of `EXTERNAL` in
|
|
155
|
-
* `packages/poe-tiles-sdk/scripts/publish-constants.ts`. A self-import missing
|
|
156
|
-
* here keeps its old name in the repacked tarball and fails to resolve there,
|
|
157
|
-
* so the verification fails loudly rather than passing on a stale list.
|
|
158
|
-
*/
|
|
159
|
-
const SDK_SELF_IMPORTS = [
|
|
160
|
-
"joiner-sdk/v1/test-utils/harness.js",
|
|
161
|
-
"joiner-sdk/v1/test-utils/headless-element.js",
|
|
162
|
-
"joiner-sdk/v1/test-utils.js",
|
|
163
|
-
"joiner-sdk/v1/test-utils/playwright.js",
|
|
164
|
-
];
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Rewrites the SDK's self-imports in one packed file to `name`. Only the
|
|
168
|
-
* self-imports change: the wire specifiers the SDK emits into built tiles
|
|
169
|
-
* (`poe-tiles-sdk/v1/client.js`) stay as they are.
|
|
170
|
-
*/
|
|
171
|
-
export function renameSdkSelfImports(text: string, name: string): string {
|
|
172
|
-
let result = text;
|
|
173
|
-
for (const specifier of SDK_SELF_IMPORTS) {
|
|
174
|
-
const renamed = `${name}${specifier.slice(SCAFFOLD_KEY.length)}`;
|
|
175
|
-
for (const quote of ['"', "'"]) {
|
|
176
|
-
result = result.replaceAll(
|
|
177
|
-
`${quote}${specifier}${quote}`,
|
|
178
|
-
`${quote}${renamed}${quote}`,
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return result;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function* packedCodeFiles(dir: string): Generator<string> {
|
|
186
|
-
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
187
|
-
const path = join(dir, entry.name);
|
|
188
|
-
if (entry.isDirectory()) yield* packedCodeFiles(path);
|
|
189
|
-
else if (entry.name.endsWith(".js") || entry.name.endsWith(".d.ts"))
|
|
190
|
-
yield path;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Repacks `sourceTarball` as `targetTarball` with package `name`, and its
|
|
196
|
-
* self-imports under that name. This builds the tarball the workspace rename
|
|
197
|
-
* will publish, from today's source, so both keys can be tested against it.
|
|
198
|
-
*/
|
|
199
|
-
export function repackSdkTarballAs(
|
|
200
|
-
sourceTarball: string,
|
|
201
|
-
targetTarball: string,
|
|
202
|
-
name: SdkDependencyKey,
|
|
203
|
-
): void {
|
|
204
|
-
const workDir = mkdtempSync(join(tmpdir(), "sdk-tarball-repack-"));
|
|
205
|
-
try {
|
|
206
|
-
execFileSync("tar", ["xzf", sourceTarball, "-C", workDir]);
|
|
207
|
-
const packageDir = join(workDir, "package");
|
|
208
|
-
const manifestPath = join(packageDir, "package.json");
|
|
209
|
-
const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as {
|
|
210
|
-
name: string;
|
|
211
|
-
};
|
|
212
|
-
manifest.name = name;
|
|
213
|
-
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, "\t")}\n`);
|
|
214
|
-
let rewrittenFiles = 0;
|
|
215
|
-
for (const path of packedCodeFiles(packageDir)) {
|
|
216
|
-
const text = readFileSync(path, "utf8");
|
|
217
|
-
const rewritten = renameSdkSelfImports(text, name);
|
|
218
|
-
if (rewritten === text) continue;
|
|
219
|
-
writeFileSync(path, rewritten);
|
|
220
|
-
rewrittenFiles += 1;
|
|
221
|
-
}
|
|
222
|
-
if (name !== SCAFFOLD_KEY && rewrittenFiles === 0) {
|
|
223
|
-
throw new Error(
|
|
224
|
-
"Repacked SDK tarball has no self-imports to rename; update SDK_SELF_IMPORTS",
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
execFileSync("tar", [
|
|
228
|
-
"czf",
|
|
229
|
-
targetTarball,
|
|
230
|
-
"--no-xattrs",
|
|
231
|
-
"-C",
|
|
232
|
-
workDir,
|
|
233
|
-
"package",
|
|
234
|
-
]);
|
|
235
|
-
} finally {
|
|
236
|
-
rmSync(workDir, { recursive: true, force: true });
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/** The SDK is installed under the key only, from the tarball, by its packed name. */
|
|
241
|
-
export function assertInstalledSdk(
|
|
242
|
-
appDir: string,
|
|
243
|
-
{ dependencyKey, tarballName }: VerifyOptions,
|
|
244
|
-
): void {
|
|
245
|
-
const manifestPath = join(
|
|
246
|
-
appDir,
|
|
247
|
-
"node_modules",
|
|
248
|
-
dependencyKey,
|
|
249
|
-
"package.json",
|
|
250
|
-
);
|
|
251
|
-
const manifest = JSON.parse(readFileSync(manifestPath, "utf8")) as {
|
|
252
|
-
name: string;
|
|
253
|
-
};
|
|
254
|
-
const expected = tarballName ?? SCAFFOLD_KEY;
|
|
255
|
-
assert.equal(
|
|
256
|
-
manifest.name,
|
|
257
|
-
expected,
|
|
258
|
-
`${manifestPath} must name ${expected}`,
|
|
259
|
-
);
|
|
260
|
-
for (const other of SDK_DEPENDENCY_KEYS) {
|
|
261
|
-
if (other === dependencyKey) continue;
|
|
262
|
-
assert(
|
|
263
|
-
!existsSync(join(appDir, "node_modules", other)),
|
|
264
|
-
`the SDK must be installed under ${dependencyKey} only, not ${other}`,
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/** Copies the packed tarball to `target`, repacked as `tarballName` if set. */
|
|
270
|
-
export function stageSdkTarball(
|
|
271
|
-
source: string,
|
|
272
|
-
target: string,
|
|
273
|
-
tarballName: SdkDependencyKey | undefined,
|
|
274
|
-
): void {
|
|
275
|
-
if (tarballName === undefined) copyFileSync(source, target);
|
|
276
|
-
else repackSdkTarballAs(source, target, tarballName);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/** Moves a scaffold to the key, installs it, and checks what got installed. */
|
|
280
|
-
export function installWithSdkKey(
|
|
281
|
-
appDir: string,
|
|
282
|
-
options: VerifyOptions,
|
|
283
|
-
label: string,
|
|
284
|
-
): void {
|
|
285
|
-
useSdkDependencyKey(appDir, options.dependencyKey);
|
|
286
|
-
runVerificationCommand(["bun", "install", "--ignore-scripts"], appDir, label);
|
|
287
|
-
assertInstalledSdk(appDir, options);
|
|
288
|
-
}
|