@joiner-platform/cli 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/bundled-resources/poe-tile-templates/base/CLAUDE.md +72 -0
- package/bundled-resources/poe-tile-templates/base/README.md +7 -0
- package/bundled-resources/poe-tile-templates/base/_bunfig.toml +8 -0
- package/bundled-resources/poe-tile-templates/base/_gitignore +18 -0
- package/bundled-resources/poe-tile-templates/base/client.ts +12 -0
- package/bundled-resources/poe-tile-templates/base/package.json +36 -0
- package/bundled-resources/poe-tile-templates/base/playwright.config.ts +38 -0
- package/bundled-resources/poe-tile-templates/base/scripts/check-source.ts +148 -0
- package/bundled-resources/poe-tile-templates/base/scripts/dev.ts +19 -0
- package/bundled-resources/poe-tile-templates/base/scripts/doctor.sh +29 -0
- package/bundled-resources/poe-tile-templates/base/scripts/visual-check.ts +64 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/backend-config.ts +9 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/client-config.ts +8 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/data/items.ts +16 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/index.ts +10 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/remove-todo.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/set-todo.ts +20 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators/types.ts +5 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/mutators.test.ts +138 -0
- package/bundled-resources/poe-tile-templates/base/synced-store/schema.ts +40 -0
- package/bundled-resources/poe-tile-templates/base/tests/e2e.test.playwright.ts +92 -0
- package/bundled-resources/poe-tile-templates/base/tests/mobile-viewport.test.playwright.ts +111 -0
- package/bundled-resources/poe-tile-templates/base/tests/render-check.test.playwright.ts +128 -0
- package/bundled-resources/poe-tile-templates/base/tests/screenshot.test.playwright.ts +86 -0
- package/bundled-resources/poe-tile-templates/base/tests/setup-dom.ts +70 -0
- package/bundled-resources/poe-tile-templates/base/tile/src/backend.ts +3 -0
- package/bundled-resources/poe-tile-templates/base/tile/styles.css +47 -0
- package/bundled-resources/poe-tile-templates/base/tsconfig.json +13 -0
- package/bundled-resources/poe-tile-templates/coverage.config.json +6 -0
- package/bundled-resources/poe-tile-templates/index.ts +27 -0
- package/bundled-resources/poe-tile-templates/package.json +31 -0
- package/bundled-resources/poe-tile-templates/phaserjs/package.partial.json +6 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/phaserjs/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.test.happydom.tsx +98 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/App.ts +180 -0
- package/bundled-resources/poe-tile-templates/phaserjs/ui/phaser-scene.ts +174 -0
- package/bundled-resources/poe-tile-templates/phaserjs/vite.config.ts +28 -0
- package/bundled-resources/poe-tile-templates/preact/package.partial.json +9 -0
- package/bundled-resources/poe-tile-templates/preact/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/preact/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/preact/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/preact/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/preact/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.test.happydom.tsx +69 -0
- package/bundled-resources/poe-tile-templates/preact/ui/App.tsx +116 -0
- package/bundled-resources/poe-tile-templates/preact/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/react/package.partial.json +12 -0
- package/bundled-resources/poe-tile-templates/react/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/react/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/react/tile/src/entry.tsx +38 -0
- package/bundled-resources/poe-tile-templates/react/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/react/tsconfig.json +14 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.test.happydom.tsx +71 -0
- package/bundled-resources/poe-tile-templates/react/ui/App.tsx +110 -0
- package/bundled-resources/poe-tile-templates/react/vite.config.ts +21 -0
- package/bundled-resources/poe-tile-templates/scripts/cleanup.ts +10 -0
- package/bundled-resources/poe-tile-templates/scripts/generate.ts +57 -0
- package/bundled-resources/poe-tile-templates/scripts/install-diagnostics.ts +52 -0
- package/bundled-resources/poe-tile-templates/scripts/paths.ts +7 -0
- package/bundled-resources/poe-tile-templates/scripts/sdk-dependency-key.ts +288 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-all-sdks.ts +132 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-command.ts +30 -0
- package/bundled-resources/poe-tile-templates/scripts/verify-local-sdk-tarball.ts +397 -0
- package/bundled-resources/poe-tile-templates/solidjs/_bunfig.toml +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/package.partial.json +13 -0
- package/bundled-resources/poe-tile-templates/solidjs/postcss.config.js +5 -0
- package/bundled-resources/poe-tile-templates/solidjs/tests/solid-plugin.ts +49 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/src/entry.tsx +36 -0
- package/bundled-resources/poe-tile-templates/solidjs/tile/styles.css +51 -0
- package/bundled-resources/poe-tile-templates/solidjs/tsconfig.json +15 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.test.happydom.tsx +70 -0
- package/bundled-resources/poe-tile-templates/solidjs/ui/App.tsx +129 -0
- package/bundled-resources/poe-tile-templates/solidjs/vite.config.ts +18 -0
- package/bundled-resources/poe-tile-templates/tests/check-source.test.ts +131 -0
- package/bundled-resources/poe-tile-templates/tests/dev-script.test.slow.ts +166 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/customized-manager.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/extended-mutators.ts.txt +106 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/multiplayer-verification.test.playwright.ts.txt +103 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/replace-starter-schema.ts +67 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/phaserjs.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/preact.tsx.txt +69 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/react.tsx.txt +73 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/seating.ts.txt +54 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/solidjs.tsx.txt +70 -0
- package/bundled-resources/poe-tile-templates/tests/fixtures/starter-demo/vanilla-js.tsx.txt +85 -0
- package/bundled-resources/poe-tile-templates/tests/generated-templates.test.ts +278 -0
- package/bundled-resources/poe-tile-templates/tests/happy-dom-version.test.ts +27 -0
- package/bundled-resources/poe-tile-templates/tests/install-diagnostics.test.ts +99 -0
- package/bundled-resources/poe-tile-templates/tests/native-gesture-defaults.test.ts +23 -0
- package/bundled-resources/poe-tile-templates/tests/playwright-version.test.ts +84 -0
- package/bundled-resources/poe-tile-templates/tests/render-check-scaffold.test.ts +56 -0
- package/bundled-resources/poe-tile-templates/tests/sdk-dependency-key.test.ts +129 -0
- package/bundled-resources/poe-tile-templates/tests/visual-check.test.ts +90 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/package.partial.json +3 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/index.html +14 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/tile/src/entry.ts +35 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.test.happydom.tsx +96 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/ui/App.ts +113 -0
- package/bundled-resources/poe-tile-templates/vanilla-js/vite.config.ts +17 -0
- package/cli.ts +134 -0
- package/index.ts +96 -0
- package/package.json +48 -5
- package/skills/audio-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/audio-generation/SKILL.md +125 -0
- package/skills/finish-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/finish-prototype/SKILL.md +22 -0
- package/skills/help-me-build/.generated-by-poe-templated-docs +0 -0
- package/skills/help-me-build/SKILL.md +56 -0
- package/skills/image-generation/.generated-by-poe-templated-docs +0 -0
- package/skills/image-generation/SKILL.md +128 -0
- package/skills/one-shot/.generated-by-poe-templated-docs +0 -0
- package/skills/one-shot/SKILL.md +22 -0
- package/skills/platform-prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-prototype/SKILL.md +60 -0
- package/skills/platform-subagent/.generated-by-poe-templated-docs +0 -0
- package/skills/platform-subagent/SKILL.md +16 -0
- package/skills/poe-tiles-cli/.generated-by-poe-templated-docs +0 -0
- package/skills/poe-tiles-cli/SKILL.md +609 -0
- package/skills/poe-tiles-cli/references/device-motion.md +40 -0
- package/skills/poe-tiles-cli/references/player-updates.md +41 -0
- package/skills/prototype/.generated-by-poe-templated-docs +0 -0
- package/skills/prototype/SKILL.md +149 -0
- package/skills/publish/.generated-by-poe-templated-docs +0 -0
- package/skills/publish/SKILL.md +73 -0
- package/skills/synced-store/.generated-by-poe-templated-docs +0 -0
- package/skills/synced-store/SKILL.md +583 -0
- package/skills/synced-store/references/actions.md +85 -0
- package/skills/synced-store/references/api-patterns.md +245 -0
- package/skills/synced-store/references/architecture-scaling-and-performance.md +280 -0
- package/skills/synced-store/references/client-api-reference.md +263 -0
- package/skills/synced-store/references/data-visibility.md +95 -0
- package/skills/synced-store/references/external-stores.md +162 -0
- package/skills/synced-store/references/file-uploads.md +216 -0
- package/skills/synced-store/references/getting-user-info-of-members.md +228 -0
- package/skills/synced-store/references/limitations.md +72 -0
- package/skills/synced-store/references/live-data-limit-hook.md +131 -0
- package/skills/synced-store/references/mutator-rules.md +169 -0
- package/skills/synced-store/references/platform.md +49 -0
- package/skills/synced-store/references/schema-and-bindings.md +85 -0
- package/skills/synced-store/references/schema-libraries.md +57 -0
- package/skills/synced-store/references/schema-migrations.md +119 -0
- package/skills/synced-store/references/searchable-tables.md +27 -0
- package/skills/synced-store/references/server-forking.md +115 -0
- package/skills/synced-store/references/singleton-tables.md +61 -0
- package/skills/synced-store/references/sort-keys.md +253 -0
- package/skills/synced-store/references/ui-patterns.md +95 -0
- package/skills/tile-creator/.generated-by-poe-templated-docs +0 -0
- package/skills/tile-creator/SKILL.md +197 -0
- package/skills/tile-creator/references/assets.md +124 -0
- package/skills/tile-creator/references/backend-api.md +354 -0
- package/skills/tile-creator/references/cli-limitations.md +64 -0
- package/skills/tile-creator/references/cli.md +604 -0
- package/skills/tile-creator/references/client-api.md +2407 -0
- package/skills/tile-creator/references/composing-apps.md +166 -0
- package/skills/tile-creator/references/e2e-tests.md +55 -0
- package/skills/tile-creator/references/game-ux-best-practices.md +57 -0
- package/skills/tile-creator/references/migrating-pre-rename-tiles.md +79 -0
- package/skills/tile-creator/references/multiplayer-api-recipe.md +205 -0
- package/skills/tile-creator/references/native-results.md +100 -0
- package/skills/tile-creator/references/platform-integration.md +201 -0
- package/skills/tile-creator/references/power-report.md +199 -0
- package/skills/tile-creator/references/publish-rollout.md +166 -0
- package/skills/tile-creator/references/publishing.md +33 -0
- package/skills/tile-creator/references/push-notification-guidelines.md +58 -0
- package/skills/tile-creator/references/render-check.md +266 -0
- package/skills/tile-creator/references/running-the-client-api-on-a-server-owned-by-the-user.md +95 -0
- package/skills/tile-creator/references/safe-area-insets.md +79 -0
- package/skills/tile-creator/references/sandbox-limitations.md +32 -0
- package/skills/tile-creator/references/scaffolded-tile-folder-structure.md +48 -0
- package/skills/tile-creator/references/scaffolding-a-new-app.md +202 -0
- package/skills/tile-creator/references/simulations.md +125 -0
- package/skills/tile-creator/references/synced-store-client-reference.md +92 -0
- package/skills/tile-creator/references/troubleshooting.md +22 -0
- package/skills/tile-creator/references/turn-based-mutator.md +43 -0
- package/skills/tile-creator/references/user-erasure.md +14 -0
- package/skills/tile-creator/references/vite-plugin.md +166 -0
- package/skills/tile-creator/references/workspace-retention.md +72 -0
- package/src/admin-conversions-client.ts +28 -0
- package/src/admin-reviews-client.ts +36 -0
- package/src/api.generated.ts +1527 -0
- package/src/auth-token.ts +198 -0
- package/src/bounded-read.ts +35 -0
- package/src/bun-version.ts +33 -0
- package/src/checkout-base.ts +207 -0
- package/src/cli-bun-version.ts +16 -0
- package/src/cli-env.ts +28 -0
- package/src/cli-name.ts +23 -0
- package/src/client.ts +2474 -0
- package/src/collect-files.ts +226 -0
- package/src/commands/accounts.ts +55 -0
- package/src/commands/admin-abandon-conversion.ts +60 -0
- package/src/commands/admin-reviews.ts +66 -0
- package/src/commands/admin.ts +219 -0
- package/src/commands/auth.ts +89 -0
- package/src/commands/checkout-prototype.ts +67 -0
- package/src/commands/creator-source-capability.ts +11 -0
- package/src/commands/doctor-bun.ts +145 -0
- package/src/commands/doctor-command.ts +64 -0
- package/src/commands/doctor-package-json.ts +47 -0
- package/src/commands/doctor-sdk-pin.ts +156 -0
- package/src/commands/doctor-store-keys-lexer.ts +213 -0
- package/src/commands/doctor-store-keys-scan.ts +262 -0
- package/src/commands/doctor-store-keys.ts +196 -0
- package/src/commands/doctor.ts +371 -0
- package/src/commands/init/blank-scaffold-templates.ts +397 -0
- package/src/commands/init/index.ts +170 -0
- package/src/commands/init/internal-toolchain.ts +49 -0
- package/src/commands/init/manager-test-template.ts +107 -0
- package/src/commands/init/multiplayer-test-template.ts +217 -0
- package/src/commands/init/name-input.tsx +167 -0
- package/src/commands/init/no-store-scaffold-templates.ts +281 -0
- package/src/commands/init/no-store-scaffold.ts +134 -0
- package/src/commands/init/package-json-scripts.ts +72 -0
- package/src/commands/init/scaffold.ts +960 -0
- package/src/commands/init/sdk-tarball-url.generated.ts +4 -0
- package/src/commands/init/sdk-tarball-url.ts +31 -0
- package/src/commands/init/template-picker.tsx +147 -0
- package/src/commands/inspect-child-entry.ts +107 -0
- package/src/commands/inspect-contract.ts +87 -0
- package/src/commands/inspect-freshness.ts +217 -0
- package/src/commands/inspect-lock.ts +201 -0
- package/src/commands/inspect-options.ts +360 -0
- package/src/commands/inspect-orchestrate.ts +375 -0
- package/src/commands/inspect-process.ts +172 -0
- package/src/commands/inspect-ready.ts +65 -0
- package/src/commands/inspect-report.ts +235 -0
- package/src/commands/inspect-run-state.ts +296 -0
- package/src/commands/inspect-run.ts +157 -0
- package/src/commands/inspect-watchdog.ts +74 -0
- package/src/commands/install-joiner.ts +208 -0
- package/src/commands/login.ts +308 -0
- package/src/commands/models.ts +40 -0
- package/src/commands/parse-options.ts +36 -0
- package/src/commands/remix-package-json.ts +64 -0
- package/src/commands/remix.ts +379 -0
- package/src/commands/sdk-url.ts +141 -0
- package/src/commands/simulations.ts +133 -0
- package/src/commands/skills.ts +108 -0
- package/src/commands/store-files.ts +92 -0
- package/src/commands/stores.ts +703 -0
- package/src/commands/tiles-channel-commands.ts +115 -0
- package/src/commands/tiles-checkout.ts +351 -0
- package/src/commands/tiles-gallery-command.ts +95 -0
- package/src/commands/tiles-get-helpers.ts +27 -0
- package/src/commands/tiles-inspect.ts +276 -0
- package/src/commands/tiles-power-command.ts +308 -0
- package/src/commands/tiles-power-format.ts +396 -0
- package/src/commands/tiles-power-versions.ts +299 -0
- package/src/commands/tiles-publish-helpers.ts +145 -0
- package/src/commands/tiles-upload-command.ts +277 -0
- package/src/commands/tiles-version-commands.ts +201 -0
- package/src/commands/tiles-visibility-command.ts +103 -0
- package/src/commands/tiles.ts +257 -0
- package/src/commands/upgrade.ts +307 -0
- package/src/commit-in-progress.ts +42 -0
- package/src/creator-source-context.ts +97 -0
- package/src/creator-source-publish.ts +52 -0
- package/src/deferred-assets.ts +125 -0
- package/src/distribution.ts +28 -0
- package/src/errors.ts +61 -0
- package/src/install-command.ts +43 -0
- package/src/output.ts +62 -0
- package/src/poe-tile-config-files.ts +100 -0
- package/src/poe-tile-config-players.ts +168 -0
- package/src/poe-tile-config-remix.ts +166 -0
- package/src/poe-tile-config.ts +831 -0
- package/src/power-report-client.ts +55 -0
- package/src/prototype-startup.ts +21 -0
- package/src/publish-change-summary.ts +55 -0
- package/src/publish-overrides-validation.ts +49 -0
- package/src/publish-pack.ts +167 -0
- package/src/publish-phases.ts +57 -0
- package/src/publish-retry.ts +51 -0
- package/src/publish-tile-from-config.ts +434 -0
- package/src/recorder-stream.ts +169 -0
- package/src/remix-provenance.ts +156 -0
- package/src/resolve-client-credential.ts +71 -0
- package/src/resolve-media-uploads.ts +147 -0
- package/src/sdk-dependency.ts +54 -0
- package/src/sdk-skills.ts +85 -0
- package/src/should-skip-client-setup.ts +20 -0
- package/src/simulation-snapshot.ts +123 -0
- package/src/simulation-types.ts +74 -0
- package/src/simulations-client.ts +112 -0
- package/src/source-bundle.ts +466 -0
- package/src/staged-publish-cleanup.ts +44 -0
- package/src/staged-publish-deferred.ts +160 -0
- package/src/staged-publish.ts +401 -0
- package/src/store-file-upload.ts +268 -0
- package/src/store-request.ts +168 -0
- package/src/tar-canonical.ts +41 -0
- package/src/tar-extensions.ts +159 -0
- package/src/tar-extract.ts +193 -0
- package/src/tar-parse.ts +224 -0
- package/src/tar.ts +231 -0
- package/src/template-check-scripts.ts +18 -0
- package/src/tile-gallery-client.ts +82 -0
- package/src/types.ts +258 -0
- package/src/upload-concurrency.ts +54 -0
- package/src/whole-tile.ts +52 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { findSdkDependency } from "../sdk-dependency.js";
|
|
2
|
+
|
|
3
|
+
export interface RemixPackageJson {
|
|
4
|
+
name?: string;
|
|
5
|
+
dependencies?: Record<string, string>;
|
|
6
|
+
devDependencies?: Record<string, string>;
|
|
7
|
+
optionalDependencies?: Record<string, string>;
|
|
8
|
+
overrides?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Preserve the monorepo's tested Playwright family when first-party source loses
|
|
12
|
+
// the root overrides outside the workspace. A fresh caret resolution can select
|
|
13
|
+
// a newer release while its separately published playwright-core is still absent.
|
|
14
|
+
// A completed upstream publish fixes that install, but does not prevent recurrence;
|
|
15
|
+
// these exact pins intentionally make upgrades deliberate, including patches and
|
|
16
|
+
// security fixes. They are not a temporary workaround to remove after publication.
|
|
17
|
+
//
|
|
18
|
+
// To upgrade, first confirm the target release exists for all three packages.
|
|
19
|
+
// Update the root @playwright/test dependency, all three root overrides, and this
|
|
20
|
+
// map to that same exact version, then run bun install to update the lockfile.
|
|
21
|
+
// remix-playwright.test.ts and remix-standalone.test.slow.ts enforce agreement;
|
|
22
|
+
// run both before releasing the CLI. Updated CLI pins apply to future remixes,
|
|
23
|
+
// not existing copies: their owners update dependencies, overrides, and lockfiles.
|
|
24
|
+
// Keep the map tarball-safe; importing the root manifest breaks the published CLI.
|
|
25
|
+
const WORKSPACE_PLAYWRIGHT_PINS = {
|
|
26
|
+
"@playwright/test": "1.59.1",
|
|
27
|
+
playwright: "1.59.1",
|
|
28
|
+
"playwright-core": "1.59.1",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Preserve first-party Playwright resolution before rewriting the workspace SDK. */
|
|
32
|
+
export function pinFirstPartyPlaywright(pkg: RemixPackageJson): boolean {
|
|
33
|
+
if (typeof pkg.name !== "string" || !pkg.name.startsWith("@poe-tile/"))
|
|
34
|
+
return false;
|
|
35
|
+
const sdk = findSdkDependency(pkg);
|
|
36
|
+
if (sdk === null || "error" in sdk || !sdk.spec.startsWith("workspace:"))
|
|
37
|
+
return false;
|
|
38
|
+
|
|
39
|
+
const changed = [
|
|
40
|
+
pkg.dependencies,
|
|
41
|
+
pkg.devDependencies,
|
|
42
|
+
pkg.optionalDependencies,
|
|
43
|
+
]
|
|
44
|
+
.map(pinPlaywrightDependencies)
|
|
45
|
+
.some(Boolean);
|
|
46
|
+
if (changed) {
|
|
47
|
+
// Also pin transitive copies, such as playwright-core via browser tooling.
|
|
48
|
+
pkg.overrides = { ...pkg.overrides, ...WORKSPACE_PLAYWRIGHT_PINS };
|
|
49
|
+
}
|
|
50
|
+
return changed;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function pinPlaywrightDependencies(
|
|
54
|
+
deps: Record<string, string> | undefined,
|
|
55
|
+
): boolean {
|
|
56
|
+
if (!deps) return false;
|
|
57
|
+
let changed = false;
|
|
58
|
+
for (const [name, version] of Object.entries(WORKSPACE_PLAYWRIGHT_PINS)) {
|
|
59
|
+
if (typeof deps[name] !== "string") continue;
|
|
60
|
+
deps[name] = version;
|
|
61
|
+
changed = true;
|
|
62
|
+
}
|
|
63
|
+
return changed;
|
|
64
|
+
}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
// owner: jyoung-q
|
|
2
|
+
/**
|
|
3
|
+
* Creator-facing source remix command.
|
|
4
|
+
*
|
|
5
|
+
* Downloads a published app's source bundle, then makes the extracted copy
|
|
6
|
+
* usable outside the monorepo:
|
|
7
|
+
* - rewrites the `joiner-sdk` or `poe-tiles-sdk` workspace dependency to the
|
|
8
|
+
* published tarball URL (so `bun install` resolves the SDK),
|
|
9
|
+
* - pins declared Playwright dependencies and adds matching overrides for
|
|
10
|
+
* first-party (`@poe-tile/*`) bundles with a workspace SDK, preserving the
|
|
11
|
+
* monorepo's tested Playwright version; external apps keep their versions,
|
|
12
|
+
* - installs the SDK skills into `.claude/skills/` (so Claude Code has the
|
|
13
|
+
* tile-creator / synced-store skills locally), and
|
|
14
|
+
* - records where the copy came from in the extracted `.poe-tile.json`
|
|
15
|
+
* (`remixOf`), so publishing it shows the original app in a "Remix of" row
|
|
16
|
+
* on this app's own detail page. Nothing is added to the original's page.
|
|
17
|
+
* Best-effort: a download whose provenance can't be stamped still yields a
|
|
18
|
+
* working checkout, with the reason reported.
|
|
19
|
+
*
|
|
20
|
+
* First-party apps published from the monorepo may carry additional internal
|
|
21
|
+
* `workspace:*` dependencies that have no external tarball. We leave those
|
|
22
|
+
* intact and warn — surfacing the problem rather than silently stripping a dep
|
|
23
|
+
* the app might genuinely use. Cleanly-remixable apps depend only on the SDK
|
|
24
|
+
* (`joiner-sdk` or `poe-tiles-sdk`).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { existsSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
28
|
+
import { join, resolve } from "node:path";
|
|
29
|
+
import { Command, Option } from "commander";
|
|
30
|
+
import type { SlopPoeClient } from "../client.js";
|
|
31
|
+
import {
|
|
32
|
+
readCreatorSourceMode,
|
|
33
|
+
readCreatorSourceRemixProvenance,
|
|
34
|
+
} from "../creator-source-context.js";
|
|
35
|
+
import { assertSuccess, CliError } from "../errors.js";
|
|
36
|
+
import { isJsonMode, printJson, printKeyValue } from "../output.js";
|
|
37
|
+
import {
|
|
38
|
+
prepareCopiedTileConfig,
|
|
39
|
+
type RemixProvenanceResult,
|
|
40
|
+
} from "../remix-provenance.js";
|
|
41
|
+
import { findSdkDependency } from "../sdk-dependency.js";
|
|
42
|
+
import { installWorkspaceSkills } from "../sdk-skills.js";
|
|
43
|
+
import { SOURCE_BUNDLE_MAX_BYTES } from "../source-bundle.js";
|
|
44
|
+
import { extractTarGzToDirectory } from "../tar.js";
|
|
45
|
+
import { isTemplateCheckScript } from "../template-check-scripts.js";
|
|
46
|
+
import { readSdkTarballUrl } from "./init/sdk-tarball-url.js";
|
|
47
|
+
import {
|
|
48
|
+
pinFirstPartyPlaywright,
|
|
49
|
+
type RemixPackageJson,
|
|
50
|
+
} from "./remix-package-json.js";
|
|
51
|
+
|
|
52
|
+
interface RemixOptions {
|
|
53
|
+
dir?: string;
|
|
54
|
+
skills?: boolean;
|
|
55
|
+
localArchive?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function createRemixCommand(client: SlopPoeClient): Command {
|
|
59
|
+
return new Command("remix")
|
|
60
|
+
.description(
|
|
61
|
+
"Download and unpack a published app's uploaded source bundle into a local directory",
|
|
62
|
+
)
|
|
63
|
+
.argument(
|
|
64
|
+
"[typeIdOrCreatorName]",
|
|
65
|
+
"App type ID, creatorName/appHandle, or creator name",
|
|
66
|
+
)
|
|
67
|
+
.argument(
|
|
68
|
+
"[handle]",
|
|
69
|
+
"App handle when the first argument is a creator name",
|
|
70
|
+
)
|
|
71
|
+
.option(
|
|
72
|
+
"--dir <path>",
|
|
73
|
+
"Output directory for the remixed source. Defaults to the app handle.",
|
|
74
|
+
)
|
|
75
|
+
.option(
|
|
76
|
+
"--no-skills",
|
|
77
|
+
"Skip installing SDK skills for Claude and Codex. Default: skills are installed.",
|
|
78
|
+
)
|
|
79
|
+
.addOption(
|
|
80
|
+
new Option(
|
|
81
|
+
"--local-archive <path>",
|
|
82
|
+
"Platform-owned local source archive",
|
|
83
|
+
).hideHelp(),
|
|
84
|
+
)
|
|
85
|
+
.action(async function (
|
|
86
|
+
this: Command,
|
|
87
|
+
typeIdOrCreatorName: string | undefined,
|
|
88
|
+
handle: string | undefined,
|
|
89
|
+
opts: RemixOptions,
|
|
90
|
+
) {
|
|
91
|
+
const localArchive = opts.localArchive;
|
|
92
|
+
if (localArchive !== undefined) {
|
|
93
|
+
runLocalArchiveRemix({ ...opts, localArchive });
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (typeIdOrCreatorName === undefined) {
|
|
97
|
+
throw new CliError("A tile ID or creator/handle is required.");
|
|
98
|
+
}
|
|
99
|
+
const tileHandleOrId = resolveAppHandleOrId(typeIdOrCreatorName, handle);
|
|
100
|
+
const lookup = await client.getTile(tileHandleOrId);
|
|
101
|
+
assertSuccess(lookup);
|
|
102
|
+
|
|
103
|
+
const targetDir = resolve(opts.dir ?? lookup.tile.handle);
|
|
104
|
+
if (existsSync(targetDir)) {
|
|
105
|
+
throw new CliError(`Output directory already exists: ${targetDir}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const download = await client.downloadSourceBundle(lookup.tile.id);
|
|
109
|
+
const extracted = extractBundle(download.bytes, targetDir);
|
|
110
|
+
const depRewrite = rewriteRemixDependencies(targetDir);
|
|
111
|
+
// Record the branch point in the extracted config so the creator's
|
|
112
|
+
// first publish from this directory credits the original app. The
|
|
113
|
+
// ids come from the SAME download response as the bytes, so the
|
|
114
|
+
// pair can't be torn by a concurrent republish of the source.
|
|
115
|
+
const provenance = prepareCopiedTileConfig(targetDir, {
|
|
116
|
+
tileId: lookup.tile.id,
|
|
117
|
+
sourceBundleId: download.sourceBundleId,
|
|
118
|
+
versionNumber: download.versionNumber,
|
|
119
|
+
});
|
|
120
|
+
const installedSkills = opts.skills
|
|
121
|
+
? installWorkspaceSkills(targetDir)
|
|
122
|
+
: [];
|
|
123
|
+
|
|
124
|
+
reportRemix(isJsonMode(this), {
|
|
125
|
+
lookup,
|
|
126
|
+
targetDir,
|
|
127
|
+
extracted,
|
|
128
|
+
depRewrite,
|
|
129
|
+
provenance,
|
|
130
|
+
installedSkills,
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function runLocalArchiveRemix(
|
|
136
|
+
opts: RemixOptions & { localArchive: string },
|
|
137
|
+
): void {
|
|
138
|
+
if (readCreatorSourceMode() === null) {
|
|
139
|
+
throw new CliError(
|
|
140
|
+
"Local source archives are available only inside a platform Edit or Remix session.",
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
if (opts.dir === undefined) {
|
|
144
|
+
throw new CliError("--dir is required with the platform source archive.");
|
|
145
|
+
}
|
|
146
|
+
const targetDir = resolve(opts.dir);
|
|
147
|
+
const extracted = extractLocalSourceArchive({
|
|
148
|
+
archivePath: resolve(opts.localArchive),
|
|
149
|
+
targetDir,
|
|
150
|
+
});
|
|
151
|
+
const depRewrite = rewriteRemixDependencies(targetDir);
|
|
152
|
+
// Only a Remix session stamps provenance. An Edit session republishes the
|
|
153
|
+
// SAME app, so recording it as a remix of itself would be wrong — the
|
|
154
|
+
// sandbox simply omits the flags there.
|
|
155
|
+
const provenance = prepareCopiedTileConfig(
|
|
156
|
+
targetDir,
|
|
157
|
+
readCreatorSourceRemixProvenance(),
|
|
158
|
+
);
|
|
159
|
+
if (opts.skills) installWorkspaceSkills(targetDir);
|
|
160
|
+
console.log(
|
|
161
|
+
`Source prepared (${extracted.fileCount} files, ${extracted.totalBytes} bytes; SDK ${depRewrite.sdkVersion ?? "unchanged"}; remix of ${describeProvenance(provenance)}).`,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function extractLocalSourceArchive(options: {
|
|
166
|
+
archivePath: string;
|
|
167
|
+
targetDir: string;
|
|
168
|
+
maxArchiveBytes?: number;
|
|
169
|
+
maxExtractedBytes?: number;
|
|
170
|
+
}): { fileCount: number; totalBytes: number } {
|
|
171
|
+
const maxArchiveBytes = options.maxArchiveBytes ?? SOURCE_BUNDLE_MAX_BYTES;
|
|
172
|
+
const archive = statSync(options.archivePath, { throwIfNoEntry: false });
|
|
173
|
+
if (!archive?.isFile()) {
|
|
174
|
+
throw new CliError(`Source archive not found: ${options.archivePath}`);
|
|
175
|
+
}
|
|
176
|
+
if (archive.size > maxArchiveBytes) {
|
|
177
|
+
throw new CliError(
|
|
178
|
+
`Source archive is ${archive.size} bytes; the maximum is ${maxArchiveBytes}.`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
return extractTarGzToDirectory(
|
|
183
|
+
new Uint8Array(readFileSync(options.archivePath)),
|
|
184
|
+
options.targetDir,
|
|
185
|
+
{
|
|
186
|
+
maxTotalBytes: options.maxExtractedBytes,
|
|
187
|
+
executablePath: isTemplateCheckScript,
|
|
188
|
+
},
|
|
189
|
+
);
|
|
190
|
+
} catch (error) {
|
|
191
|
+
throw new CliError(
|
|
192
|
+
`Failed to extract source bundle: ${errorMessage(error)}`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
interface RemixReport {
|
|
198
|
+
lookup: { tile: { id: string; handle: string } };
|
|
199
|
+
targetDir: string;
|
|
200
|
+
extracted: { fileCount: number; totalBytes: number };
|
|
201
|
+
depRewrite: SdkDependencyRewrite;
|
|
202
|
+
provenance: RemixProvenanceResult;
|
|
203
|
+
installedSkills: string[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** One-line summary of the `remixOf` stamp for the human-readable report. */
|
|
207
|
+
function describeProvenance(provenance: RemixProvenanceResult): string {
|
|
208
|
+
return provenance.stamped
|
|
209
|
+
? `${provenance.remixOf.tileId} @ v${provenance.remixOf.versionNumber}`
|
|
210
|
+
: `not recorded (${provenance.reason})`;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function reportRemix(jsonMode: boolean, r: RemixReport): void {
|
|
214
|
+
if (jsonMode) {
|
|
215
|
+
printJson({
|
|
216
|
+
id: r.lookup.tile.id,
|
|
217
|
+
handle: r.lookup.tile.handle,
|
|
218
|
+
dir: r.targetDir,
|
|
219
|
+
files: r.extracted.fileCount,
|
|
220
|
+
bytes: r.extracted.totalBytes,
|
|
221
|
+
sdkVersion: r.depRewrite.sdkVersion,
|
|
222
|
+
skills: r.installedSkills,
|
|
223
|
+
strandedWorkspaceDeps: r.depRewrite.strandedWorkspaceDeps,
|
|
224
|
+
remixOf: r.provenance.stamped ? r.provenance.remixOf : null,
|
|
225
|
+
...(r.provenance.stamped
|
|
226
|
+
? {}
|
|
227
|
+
: { remixOfSkippedReason: r.provenance.reason }),
|
|
228
|
+
});
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
console.log("Source remixed.");
|
|
232
|
+
printKeyValue([
|
|
233
|
+
["App ID", r.lookup.tile.id],
|
|
234
|
+
["Handle", r.lookup.tile.handle],
|
|
235
|
+
["Directory", r.targetDir],
|
|
236
|
+
["Files", r.extracted.fileCount],
|
|
237
|
+
["Bytes", r.extracted.totalBytes],
|
|
238
|
+
["SDK", r.depRewrite.sdkVersion ?? "unchanged (workspace:*)"],
|
|
239
|
+
["Remix of", describeProvenance(r.provenance)],
|
|
240
|
+
[
|
|
241
|
+
"Skills",
|
|
242
|
+
r.installedSkills.length ? r.installedSkills.join(", ") : "none",
|
|
243
|
+
],
|
|
244
|
+
]);
|
|
245
|
+
warnStrandedWorkspaceDeps(r.depRewrite.strandedWorkspaceDeps);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function extractBundle(
|
|
249
|
+
sourceBundle: Uint8Array,
|
|
250
|
+
targetDir: string,
|
|
251
|
+
): { fileCount: number; totalBytes: number } {
|
|
252
|
+
try {
|
|
253
|
+
return extractTarGzToDirectory(sourceBundle, targetDir, {
|
|
254
|
+
executablePath: isTemplateCheckScript,
|
|
255
|
+
});
|
|
256
|
+
} catch (error) {
|
|
257
|
+
throw new CliError(
|
|
258
|
+
`Failed to extract source bundle: ${errorMessage(error)}`,
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export interface SdkDependencyRewrite {
|
|
264
|
+
/** The value the SDK key was rewritten to, or `null` if not rewritten. */
|
|
265
|
+
sdkVersion: string | null;
|
|
266
|
+
/** Non-SDK `workspace:*` deps left intact (won't resolve outside the monorepo). */
|
|
267
|
+
strandedWorkspaceDeps: string[];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Preserve first-party Playwright pins and rewrite the SDK key from
|
|
272
|
+
* `workspace:*` to the published tarball URL so `bun install` works outside
|
|
273
|
+
* the monorepo. Returns the new SDK value (or `null` when there was nothing to
|
|
274
|
+
* rewrite / no tarball URL is available) and any other `workspace:*` deps left
|
|
275
|
+
* intact for the caller to warn about.
|
|
276
|
+
*/
|
|
277
|
+
export function rewriteRemixDependencies(
|
|
278
|
+
targetDir: string,
|
|
279
|
+
): SdkDependencyRewrite {
|
|
280
|
+
const pkgPath = join(targetDir, "package.json");
|
|
281
|
+
if (!existsSync(pkgPath)) {
|
|
282
|
+
return { sdkVersion: null, strandedWorkspaceDeps: [] };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
let pkg: RemixPackageJson;
|
|
286
|
+
try {
|
|
287
|
+
pkg = JSON.parse(readFileSync(pkgPath, "utf-8")) as RemixPackageJson;
|
|
288
|
+
} catch (error) {
|
|
289
|
+
throw new CliError(
|
|
290
|
+
`Remixed package.json is not valid JSON: ${errorMessage(error)}`,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const tarballUrl = readSdkTarballUrl();
|
|
295
|
+
// Remix keeps the source project's key: first-party source moves to
|
|
296
|
+
// `joiner-sdk`, older source keeps `poe-tiles-sdk`. A project with both keys
|
|
297
|
+
// gets neither rewritten; both stay listed as unresolved.
|
|
298
|
+
const sdk = findSdkDependency(pkg);
|
|
299
|
+
const acc: DepRewriteAccumulator = {
|
|
300
|
+
sdkKey: sdk !== null && !("error" in sdk) ? sdk.key : null,
|
|
301
|
+
sdkVersion: null,
|
|
302
|
+
stranded: [],
|
|
303
|
+
changed: pinFirstPartyPlaywright(pkg),
|
|
304
|
+
};
|
|
305
|
+
for (const section of ["dependencies", "devDependencies"] as const) {
|
|
306
|
+
rewriteWorkspaceDeps(pkg[section], tarballUrl, acc);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (acc.changed) {
|
|
310
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, "\t")}\n`);
|
|
311
|
+
}
|
|
312
|
+
return { sdkVersion: acc.sdkVersion, strandedWorkspaceDeps: acc.stranded };
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
interface DepRewriteAccumulator {
|
|
316
|
+
/** The SDK key to rewrite, or null when there is none or both. */
|
|
317
|
+
sdkKey: string | null;
|
|
318
|
+
sdkVersion: string | null;
|
|
319
|
+
stranded: string[];
|
|
320
|
+
changed: boolean;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Rewrite the SDK key to the tarball URL within one dependency section,
|
|
325
|
+
* collecting any other `workspace:*` deps as stranded. Mutates `acc` and the
|
|
326
|
+
* section object in place.
|
|
327
|
+
*/
|
|
328
|
+
function rewriteWorkspaceDeps(
|
|
329
|
+
bag: unknown,
|
|
330
|
+
tarballUrl: string | null,
|
|
331
|
+
acc: DepRewriteAccumulator,
|
|
332
|
+
): void {
|
|
333
|
+
if (!bag || typeof bag !== "object") return;
|
|
334
|
+
const deps = bag as Record<string, string>;
|
|
335
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
336
|
+
if (typeof version !== "string" || !version.startsWith("workspace:")) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (name === acc.sdkKey && tarballUrl) {
|
|
340
|
+
deps[name] = tarballUrl;
|
|
341
|
+
acc.sdkVersion = tarballUrl;
|
|
342
|
+
acc.changed = true;
|
|
343
|
+
} else {
|
|
344
|
+
// A non-SDK internal package, an SDK key with no tarball URL
|
|
345
|
+
// available, or both SDK keys — none resolves outside the monorepo.
|
|
346
|
+
acc.stranded.push(name);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export function warnStrandedWorkspaceDeps(deps: string[]): void {
|
|
352
|
+
if (deps.length === 0) return;
|
|
353
|
+
console.warn(
|
|
354
|
+
`\nWarning: ${deps.length} workspace dependenc${deps.length === 1 ? "y" : "ies"} ` +
|
|
355
|
+
"left unresolved (internal monorepo packages with no published tarball):",
|
|
356
|
+
);
|
|
357
|
+
for (const name of deps) console.warn(` ${name}`);
|
|
358
|
+
console.warn(
|
|
359
|
+
"`bun install` will fail until these are removed or replaced. Cleanly-remixable " +
|
|
360
|
+
"apps depend only on the SDK (joiner-sdk, or poe-tiles-sdk in older source).",
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function resolveAppHandleOrId(
|
|
365
|
+
typeIdOrCreatorName: string,
|
|
366
|
+
handle: string | undefined,
|
|
367
|
+
): string {
|
|
368
|
+
if (handle === undefined) return typeIdOrCreatorName;
|
|
369
|
+
if (typeIdOrCreatorName.includes("/")) {
|
|
370
|
+
throw new CliError(
|
|
371
|
+
"Pass either creatorName/appHandle or creatorName appHandle, not both.",
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
return `${typeIdOrCreatorName}/${handle}`;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function errorMessage(error: unknown): string {
|
|
378
|
+
return error instanceof Error ? error.message : String(error);
|
|
379
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// owner: kevlu94
|
|
2
|
+
/**
|
|
3
|
+
* `poe-tiles sdk-url` command.
|
|
4
|
+
*
|
|
5
|
+
* Prints the current published SDK tarball URL — the value a tile's
|
|
6
|
+
* `package.json` pins under `joiner-sdk` (or `poe-tiles-sdk` in older
|
|
7
|
+
* projects) — so creators can bump an existing app
|
|
8
|
+
* without scaffolding a throwaway one to fish the URL out of its
|
|
9
|
+
* package.json.
|
|
10
|
+
*
|
|
11
|
+
* Resolution order:
|
|
12
|
+
* 1. The docs-site manifest (`latest.json`, same one `upgrade` uses) — always
|
|
13
|
+
* current, host-pinned before printing.
|
|
14
|
+
* 2. The URL baked into this CLI install at build time — an offline fallback
|
|
15
|
+
* that is only as fresh as the CLI itself (hence the stderr note).
|
|
16
|
+
*
|
|
17
|
+
* The default output stays a bare URL on stdout, so existing scripts keep
|
|
18
|
+
* working. `--snippet` prints `"<key>": "<url>"` instead, where the key is the
|
|
19
|
+
* SDK key of the project in the current folder, or `joiner-sdk` when there is
|
|
20
|
+
* no project or it has no SDK key yet.
|
|
21
|
+
*
|
|
22
|
+
* Local-only: does not call the Poe Tiles API, so the preAction auth hook in
|
|
23
|
+
* `cli.ts` skips client setup for this command.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { readFileSync } from "node:fs";
|
|
27
|
+
import { join } from "node:path";
|
|
28
|
+
import { Command } from "commander";
|
|
29
|
+
import { cliName } from "../cli-name.js";
|
|
30
|
+
import { CliError } from "../errors.js";
|
|
31
|
+
import {
|
|
32
|
+
findSdkDependency,
|
|
33
|
+
LEGACY_SDK_PACKAGE_NAME,
|
|
34
|
+
SDK_PACKAGE_NAME,
|
|
35
|
+
type SdkDependencySections,
|
|
36
|
+
type SdkPackageName,
|
|
37
|
+
} from "../sdk-dependency.js";
|
|
38
|
+
import { readSdkTarballUrl } from "./init/sdk-tarball-url.js";
|
|
39
|
+
import {
|
|
40
|
+
assertAllowedTarballUrl,
|
|
41
|
+
isLatestManifest,
|
|
42
|
+
MANIFEST_URL,
|
|
43
|
+
} from "./upgrade.js";
|
|
44
|
+
|
|
45
|
+
export interface SdkUrlDeps {
|
|
46
|
+
fetchManifest?: (url: string) => Promise<Response>;
|
|
47
|
+
readBakedUrl?: () => string | null;
|
|
48
|
+
stdout?: { write: (chunk: string) => void };
|
|
49
|
+
stderr?: { write: (chunk: string) => void };
|
|
50
|
+
/** Folder whose package.json supplies the `--snippet` key. */
|
|
51
|
+
cwd?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SdkUrlOptions {
|
|
55
|
+
snippet?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function runSdkUrl(
|
|
59
|
+
deps: SdkUrlDeps = {},
|
|
60
|
+
options: SdkUrlOptions = {},
|
|
61
|
+
): Promise<void> {
|
|
62
|
+
const stdout = deps.stdout ?? process.stdout;
|
|
63
|
+
// Read the key first, so a project with both keys fails before any fetch.
|
|
64
|
+
const key = options.snippet
|
|
65
|
+
? readSnippetKey(deps.cwd ?? process.cwd())
|
|
66
|
+
: null;
|
|
67
|
+
const url = await resolveSdkUrl(deps);
|
|
68
|
+
stdout.write(
|
|
69
|
+
key === null
|
|
70
|
+
? `${url}\n`
|
|
71
|
+
: `${JSON.stringify(key)}: ${JSON.stringify(url)}\n`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The project's SDK key, or `joiner-sdk` when there is none. */
|
|
76
|
+
export function readSnippetKey(cwd: string): SdkPackageName {
|
|
77
|
+
let pkg: SdkDependencySections;
|
|
78
|
+
try {
|
|
79
|
+
pkg = JSON.parse(
|
|
80
|
+
readFileSync(join(cwd, "package.json"), "utf8"),
|
|
81
|
+
) as SdkDependencySections;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT")
|
|
84
|
+
return SDK_PACKAGE_NAME;
|
|
85
|
+
throw new CliError(
|
|
86
|
+
`Could not read package.json in ${cwd} to choose the SDK key for --snippet.`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const sdk = findSdkDependency(pkg ?? {});
|
|
90
|
+
if (sdk === null) return SDK_PACKAGE_NAME;
|
|
91
|
+
if ("error" in sdk) {
|
|
92
|
+
throw new CliError(
|
|
93
|
+
`package.json declares both ${SDK_PACKAGE_NAME} and ${LEGACY_SDK_PACKAGE_NAME}. Keep one key, then retry.`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return sdk.key;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function resolveSdkUrl(deps: SdkUrlDeps): Promise<string> {
|
|
100
|
+
const fetchManifest = deps.fetchManifest ?? ((url) => fetch(url));
|
|
101
|
+
const readBakedUrl = deps.readBakedUrl ?? (() => readSdkTarballUrl());
|
|
102
|
+
const stderr = deps.stderr ?? process.stderr;
|
|
103
|
+
const cli = cliName();
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const response = await fetchManifest(MANIFEST_URL);
|
|
107
|
+
if (response.ok) {
|
|
108
|
+
const body: unknown = await response.json();
|
|
109
|
+
if (isLatestManifest(body) && body.sdkTarballUrl !== undefined) {
|
|
110
|
+
return assertAllowedTarballUrl(body.sdkTarballUrl).toString();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
// Fall through to the baked URL below (offline, DNS, etc.).
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const bakedUrl = readBakedUrl();
|
|
118
|
+
if (bakedUrl === null) {
|
|
119
|
+
throw new CliError(
|
|
120
|
+
`Could not resolve the current SDK tarball URL from ${MANIFEST_URL} or this CLI install. Run \`${cli} upgrade\` and retry.`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
stderr.write(
|
|
124
|
+
`Note: using the SDK URL baked into this CLI install (the live manifest was unavailable or did not carry an SDK URL). Run \`${cli} upgrade\` for the freshest value.\n`,
|
|
125
|
+
);
|
|
126
|
+
return bakedUrl;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function createSdkUrlCommand(): Command {
|
|
130
|
+
return new Command("sdk-url")
|
|
131
|
+
.description(
|
|
132
|
+
"Print the current SDK tarball URL — the value to pin as the `joiner-sdk` dependency in a tile's package.json. Older projects keep their `poe-tiles-sdk` key; --snippet uses the project's own key.",
|
|
133
|
+
)
|
|
134
|
+
.option(
|
|
135
|
+
"--snippet",
|
|
136
|
+
'Print a package.json entry, `"<key>": "<url>"`, using this project\'s SDK key.',
|
|
137
|
+
)
|
|
138
|
+
.action(
|
|
139
|
+
async (opts: SdkUrlOptions): Promise<void> => await runSdkUrl({}, opts),
|
|
140
|
+
);
|
|
141
|
+
}
|