@joiner-platform/cli 0.0.0-stage → 0.1.0
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 +148 -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 +196 -0
- package/skills/tile-creator/references/assets.md +124 -0
- package/skills/tile-creator/references/backend-api.md +308 -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,201 @@
|
|
|
1
|
+
// owner: aaronroe
|
|
2
|
+
/**
|
|
3
|
+
* Kernel `flock(2)` locks for `tiles inspect`: the machine-wide run slots,
|
|
4
|
+
* the per-tile build lock, and each run's liveness lock.
|
|
5
|
+
*
|
|
6
|
+
* A flock lock belongs to the open file. The kernel releases it when the
|
|
7
|
+
* last descriptor closes, so a run killed by any signal never leaves a
|
|
8
|
+
* stale lock, and a child process that inherits the descriptor keeps the
|
|
9
|
+
* lock while it lives. Lock files are never deleted.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { dlopen, FFIType, type Pointer, read } from "bun:ffi";
|
|
13
|
+
import {
|
|
14
|
+
closeSync,
|
|
15
|
+
ftruncateSync,
|
|
16
|
+
mkdirSync,
|
|
17
|
+
openSync,
|
|
18
|
+
writeSync,
|
|
19
|
+
} from "node:fs";
|
|
20
|
+
import { constants } from "node:os";
|
|
21
|
+
import { dirname, join } from "node:path";
|
|
22
|
+
|
|
23
|
+
const LOCK_EX = 2;
|
|
24
|
+
const LOCK_NB = 4;
|
|
25
|
+
const { EAGAIN, EWOULDBLOCK, EINTR } = constants.errno;
|
|
26
|
+
|
|
27
|
+
/** Calls flock(2); returns 0, or the errno of the failure. */
|
|
28
|
+
export type Flock = (fd: number, operation: number) => number;
|
|
29
|
+
|
|
30
|
+
let flockFn: Flock | null | undefined;
|
|
31
|
+
/** Why the last tryLock returned "unsupported" (no flock, or the lock file cannot be opened), for the warning. */
|
|
32
|
+
let unsupportedReason = "libc has no flock";
|
|
33
|
+
|
|
34
|
+
/** The C libraries that may hold flock, in the order tried. */
|
|
35
|
+
export const FLOCK_LIBRARIES =
|
|
36
|
+
process.platform === "darwin"
|
|
37
|
+
? ["libSystem.B.dylib", "/usr/lib/libSystem.B.dylib"]
|
|
38
|
+
: ["libc.so.6"];
|
|
39
|
+
|
|
40
|
+
/** flock(2) from the first of `libraries` that loads; null when none does. */
|
|
41
|
+
export function flockFrom(libraries: readonly string[]): Flock | null {
|
|
42
|
+
const errnoSymbol =
|
|
43
|
+
process.platform === "darwin" ? "__error" : "__errno_location";
|
|
44
|
+
for (const library of libraries) {
|
|
45
|
+
try {
|
|
46
|
+
const libc = dlopen(library, {
|
|
47
|
+
flock: { args: [FFIType.i32, FFIType.i32], returns: FFIType.i32 },
|
|
48
|
+
[errnoSymbol]: { args: [], returns: FFIType.ptr },
|
|
49
|
+
});
|
|
50
|
+
const errnoAt = libc.symbols[errnoSymbol] as () => Pointer | null;
|
|
51
|
+
return (fd, operation) => {
|
|
52
|
+
if (libc.symbols.flock(fd, operation) === 0) return 0;
|
|
53
|
+
const at = errnoAt();
|
|
54
|
+
return at === null ? EWOULDBLOCK : read.i32(at, 0);
|
|
55
|
+
};
|
|
56
|
+
} catch {
|
|
57
|
+
// Try the next name; without one, locking is unsupported.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function loadFlock(): Flock | null {
|
|
64
|
+
if (flockFn === undefined) flockFn = flockFrom(FLOCK_LIBRARIES);
|
|
65
|
+
return flockFn;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Only EWOULDBLOCK (or EINTR) means another holder; any other errno
|
|
70
|
+
* (ENOLCK, EOPNOTSUPP) means flock does not work on that file system.
|
|
71
|
+
*/
|
|
72
|
+
export function flockFailure(errno: number): "busy" | "unsupported" {
|
|
73
|
+
return errno === EWOULDBLOCK || errno === EAGAIN || errno === EINTR
|
|
74
|
+
? "busy"
|
|
75
|
+
: "unsupported";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The errno's symbolic name, such as "ENOLCK". */
|
|
79
|
+
export function errnoName(errno: number): string {
|
|
80
|
+
const entry = Object.entries(constants.errno).find(([, n]) => n === errno);
|
|
81
|
+
return entry ? entry[0] : `errno ${errno}`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface FileLock {
|
|
85
|
+
fd: number;
|
|
86
|
+
path: string;
|
|
87
|
+
release(): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type TryLock = FileLock | "busy" | "unsupported";
|
|
91
|
+
|
|
92
|
+
/** Tries an exclusive lock without waiting; records pid and time for diagnostics. */
|
|
93
|
+
export function tryLock(path: string): TryLock {
|
|
94
|
+
const flock = loadFlock();
|
|
95
|
+
if (!flock) return "unsupported";
|
|
96
|
+
let fd: number;
|
|
97
|
+
try {
|
|
98
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
99
|
+
fd = openSync(path, "a+");
|
|
100
|
+
} catch (error) {
|
|
101
|
+
// Another user's lock file in a shared /tmp, for example.
|
|
102
|
+
const code = (error as NodeJS.ErrnoException).code ?? String(error);
|
|
103
|
+
unsupportedReason = `cannot open ${path}: ${code}`;
|
|
104
|
+
return "unsupported";
|
|
105
|
+
}
|
|
106
|
+
const errno = flock(fd, LOCK_EX | LOCK_NB);
|
|
107
|
+
if (errno !== 0) {
|
|
108
|
+
closeSync(fd);
|
|
109
|
+
const failure = flockFailure(errno);
|
|
110
|
+
if (failure === "unsupported")
|
|
111
|
+
unsupportedReason = `flock on ${path} failed with ${errnoName(errno)}`;
|
|
112
|
+
return failure;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
ftruncateSync(fd, 0);
|
|
116
|
+
writeSync(
|
|
117
|
+
fd,
|
|
118
|
+
`${JSON.stringify({ pid: process.pid, at: new Date().toISOString() })}\n`,
|
|
119
|
+
0,
|
|
120
|
+
);
|
|
121
|
+
} catch {
|
|
122
|
+
// Diagnostics only.
|
|
123
|
+
}
|
|
124
|
+
let released = false;
|
|
125
|
+
return {
|
|
126
|
+
fd,
|
|
127
|
+
path,
|
|
128
|
+
release: () => {
|
|
129
|
+
if (released) return;
|
|
130
|
+
released = true;
|
|
131
|
+
closeSync(fd);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** True when another descriptor holds the lock (a live run); false when free or unsupported. */
|
|
137
|
+
export function isLocked(path: string): boolean {
|
|
138
|
+
const lock = tryLock(path);
|
|
139
|
+
if (lock === "busy") return true;
|
|
140
|
+
if (lock !== "unsupported") lock.release();
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface Acquired {
|
|
145
|
+
lock: FileLock | null;
|
|
146
|
+
waitMs: number;
|
|
147
|
+
warning: string | null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function pause(ms: number, signal: AbortSignal): Promise<void> {
|
|
151
|
+
return new Promise((resolve) => {
|
|
152
|
+
// biome-ignore lint: lock polling interval; not test code.
|
|
153
|
+
const timer = setTimeout(done, ms);
|
|
154
|
+
function done(): void {
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
signal.removeEventListener("abort", done);
|
|
157
|
+
resolve();
|
|
158
|
+
}
|
|
159
|
+
signal.addEventListener("abort", done, { once: true });
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Takes the first free lock of `paths`, polling every `pollMs` until the
|
|
165
|
+
* signal aborts (then it throws the signal's reason). Without flock it
|
|
166
|
+
* returns no lock and a warning.
|
|
167
|
+
*/
|
|
168
|
+
export async function acquireAny(
|
|
169
|
+
paths: readonly string[],
|
|
170
|
+
signal: AbortSignal,
|
|
171
|
+
what: string,
|
|
172
|
+
pollMs = 250,
|
|
173
|
+
now: () => number = Date.now,
|
|
174
|
+
): Promise<Acquired> {
|
|
175
|
+
const started = now();
|
|
176
|
+
const attempt = async (): Promise<Acquired> => {
|
|
177
|
+
signal.throwIfAborted();
|
|
178
|
+
for (const path of paths) {
|
|
179
|
+
const lock = tryLock(path);
|
|
180
|
+
if (lock === "unsupported") {
|
|
181
|
+
return {
|
|
182
|
+
lock: null,
|
|
183
|
+
waitMs: 0,
|
|
184
|
+
warning: `locking is unavailable here (${unsupportedReason}), so the ${what} was skipped`,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
if (lock !== "busy")
|
|
188
|
+
return { lock, waitMs: now() - started, warning: null };
|
|
189
|
+
}
|
|
190
|
+
await pause(pollMs, signal);
|
|
191
|
+
return await attempt();
|
|
192
|
+
};
|
|
193
|
+
return await attempt();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** The machine-wide run slots. */
|
|
197
|
+
export function slotPaths(dir: string, slots = 2): string[] {
|
|
198
|
+
return Array.from({ length: slots }, (_, i) =>
|
|
199
|
+
join(dir, `slot-${i + 1}.lock`),
|
|
200
|
+
);
|
|
201
|
+
}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
// owner: aaronroe
|
|
2
|
+
/**
|
|
3
|
+
* `tiles inspect` inputs: finding the tile, and checking every option
|
|
4
|
+
* before anything waits or builds.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
8
|
+
import {
|
|
9
|
+
dirname,
|
|
10
|
+
extname,
|
|
11
|
+
isAbsolute,
|
|
12
|
+
join,
|
|
13
|
+
relative,
|
|
14
|
+
resolve,
|
|
15
|
+
sep,
|
|
16
|
+
} from "node:path";
|
|
17
|
+
import { readBoundedText } from "../bounded-read.js";
|
|
18
|
+
import { cliName } from "../cli-name.js";
|
|
19
|
+
import {
|
|
20
|
+
isDefaultSourceBundleIgnored,
|
|
21
|
+
normalizeSourceBundlePath,
|
|
22
|
+
} from "../source-bundle.js";
|
|
23
|
+
import { SDK_INSPECT_SPECIFIERS } from "./inspect-child-entry.js";
|
|
24
|
+
import { checkReadyTarget, type InspectTarget } from "./inspect-ready.js";
|
|
25
|
+
|
|
26
|
+
export const VIEWPORTS = ["phone", "feed-mobile", "feed-desktop"] as const;
|
|
27
|
+
export type Viewport = (typeof VIEWPORTS)[number];
|
|
28
|
+
|
|
29
|
+
export const INSPECT_CLI_LIMITS = {
|
|
30
|
+
codeBytes: 64 * 1024,
|
|
31
|
+
scriptBytes: 256 * 1024,
|
|
32
|
+
players: 6,
|
|
33
|
+
variants: 6,
|
|
34
|
+
playerVariantPairs: 12,
|
|
35
|
+
defaultTimeoutS: 120,
|
|
36
|
+
maxTimeoutS: 300,
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
/** A usage, build, or environment error: exit 2, `{ error: { code, message } }` under --json. */
|
|
40
|
+
export class InspectExit2 extends Error {
|
|
41
|
+
constructor(
|
|
42
|
+
readonly code: string,
|
|
43
|
+
message: string,
|
|
44
|
+
) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "InspectExit2";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface RawInspectOptions {
|
|
51
|
+
code?: string;
|
|
52
|
+
script?: string;
|
|
53
|
+
players?: string;
|
|
54
|
+
viewport?: string;
|
|
55
|
+
colorScheme?: string;
|
|
56
|
+
time?: string;
|
|
57
|
+
ready?: string;
|
|
58
|
+
timeout?: string;
|
|
59
|
+
/** Commander's `--no-build` sets this false. */
|
|
60
|
+
build?: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type InspectBody =
|
|
64
|
+
| { kind: "code"; source: string }
|
|
65
|
+
| { kind: "script"; modulePath: string }
|
|
66
|
+
| { kind: "look" };
|
|
67
|
+
|
|
68
|
+
export interface InspectPlan {
|
|
69
|
+
tileDir: string;
|
|
70
|
+
body: InspectBody;
|
|
71
|
+
players: number;
|
|
72
|
+
variants: Array<{ viewport: Viewport; colorScheme: "light" | "dark" }>;
|
|
73
|
+
time: string | null;
|
|
74
|
+
ready: InspectTarget | null;
|
|
75
|
+
timeoutMs: number;
|
|
76
|
+
noBuild: boolean;
|
|
77
|
+
/** True when the script lives in the tile's source, so editing it rebuilds. */
|
|
78
|
+
scriptInSource: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* True when the script lives under a `.visual-checks/` directory: scratch
|
|
81
|
+
* output that Creator deletes when the container sleeps. Scripts belong in
|
|
82
|
+
* `.inspect-scripts/`; this one still runs, with a warning.
|
|
83
|
+
*/
|
|
84
|
+
scriptInVisualChecks: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const PROTOTYPE_MESSAGE =
|
|
88
|
+
"inspect needs a built tile (a package.json and a build); prototypes are previewed automatically";
|
|
89
|
+
|
|
90
|
+
/** The nearest directory at or above `start` with a `.poe-tile.json`. */
|
|
91
|
+
export function findTileRoot(start: string): string {
|
|
92
|
+
let dir = resolve(start);
|
|
93
|
+
for (;;) {
|
|
94
|
+
if (existsSync(join(dir, ".poe-tile.json"))) return dir;
|
|
95
|
+
const parent = dirname(dir);
|
|
96
|
+
if (parent === dir) {
|
|
97
|
+
throw new InspectExit2(
|
|
98
|
+
"not-a-tile",
|
|
99
|
+
`no .poe-tile.json at or above ${resolve(start)}`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
dir = parent;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function intInRange(
|
|
107
|
+
raw: string | undefined,
|
|
108
|
+
fallback: number,
|
|
109
|
+
min: number,
|
|
110
|
+
max: number,
|
|
111
|
+
name: string,
|
|
112
|
+
): number {
|
|
113
|
+
if (raw === undefined) return fallback;
|
|
114
|
+
const value = Number(raw);
|
|
115
|
+
if (!Number.isInteger(value) || value < min || value > max) {
|
|
116
|
+
throw new InspectExit2(
|
|
117
|
+
"invalid-options",
|
|
118
|
+
`--${name} must be an integer from ${min} to ${max}`,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function parseViewports(raw: string | undefined): Viewport[] {
|
|
125
|
+
if (raw === undefined) return ["phone"];
|
|
126
|
+
const names = raw.split(",").map((s) => s.trim());
|
|
127
|
+
for (const name of names) {
|
|
128
|
+
if (name !== "all" && !(VIEWPORTS as readonly string[]).includes(name)) {
|
|
129
|
+
throw new InspectExit2(
|
|
130
|
+
"invalid-options",
|
|
131
|
+
`--viewport: unknown size "${name}" (phone, feed-mobile, feed-desktop, or all)`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (names.includes("all")) return [...VIEWPORTS];
|
|
136
|
+
return [...new Set(names)] as Viewport[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function parseSchemes(raw: string | undefined): Array<"light" | "dark"> {
|
|
140
|
+
if (raw === undefined || raw === "light") return ["light"];
|
|
141
|
+
if (raw === "dark") return ["dark"];
|
|
142
|
+
if (raw === "both") return ["light", "dark"];
|
|
143
|
+
throw new InspectExit2(
|
|
144
|
+
"invalid-options",
|
|
145
|
+
"--color-scheme must be light, dark, or both",
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const codeOverLimit = () =>
|
|
150
|
+
new InspectExit2(
|
|
151
|
+
"invalid-options",
|
|
152
|
+
`--code is over ${INSPECT_CLI_LIMITS.codeBytes} bytes`,
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
function readCode(raw: string, cwd: string): string {
|
|
156
|
+
if (!raw.startsWith("@")) {
|
|
157
|
+
if (Buffer.byteLength(raw) > INSPECT_CLI_LIMITS.codeBytes)
|
|
158
|
+
throw codeOverLimit();
|
|
159
|
+
return raw;
|
|
160
|
+
}
|
|
161
|
+
const path = resolve(cwd, raw.slice(1));
|
|
162
|
+
try {
|
|
163
|
+
// Refused by its size before its contents are read.
|
|
164
|
+
return readBoundedText(path, INSPECT_CLI_LIMITS.codeBytes, codeOverLimit);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof InspectExit2) throw error;
|
|
167
|
+
throw new InspectExit2("invalid-options", `--code: cannot read ${path}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function checkScript(
|
|
172
|
+
raw: string,
|
|
173
|
+
cwd: string,
|
|
174
|
+
tileDir: string,
|
|
175
|
+
): { modulePath: string; inSource: boolean; inVisualChecks: boolean } {
|
|
176
|
+
const path = isAbsolute(raw) ? raw : resolve(cwd, raw);
|
|
177
|
+
let real: string;
|
|
178
|
+
try {
|
|
179
|
+
real = realpathSync(path);
|
|
180
|
+
} catch {
|
|
181
|
+
throw new InspectExit2(
|
|
182
|
+
"invalid-options",
|
|
183
|
+
`--script: ${path} does not exist`,
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const inside = relative(realpathSync(tileDir), real);
|
|
187
|
+
if (inside === ".." || inside.startsWith(`..${sep}`) || isAbsolute(inside)) {
|
|
188
|
+
throw new InspectExit2(
|
|
189
|
+
"invalid-options",
|
|
190
|
+
"--script must be a file inside the tile directory",
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (![".ts", ".tsx", ".js", ".mjs"].includes(extname(real))) {
|
|
194
|
+
throw new InspectExit2(
|
|
195
|
+
"invalid-options",
|
|
196
|
+
"--script must be a .ts, .tsx, .js, or .mjs file",
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
if (statSync(real).size > INSPECT_CLI_LIMITS.scriptBytes) {
|
|
200
|
+
throw new InspectExit2(
|
|
201
|
+
"invalid-options",
|
|
202
|
+
`--script is over ${INSPECT_CLI_LIMITS.scriptBytes} bytes`,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
// The source bundle's own rule decides: a default-ignored directory at any
|
|
206
|
+
// depth (`.inspect-scripts/`, `.visual-checks/`, `sub/.inspect-scripts/`)
|
|
207
|
+
// keeps the script out of the source, and so out of the build fingerprint.
|
|
208
|
+
const bundlePath = normalizeSourceBundlePath(inside);
|
|
209
|
+
return {
|
|
210
|
+
modulePath: real,
|
|
211
|
+
inSource: !isDefaultSourceBundleIgnored(bundlePath),
|
|
212
|
+
inVisualChecks: bundlePath
|
|
213
|
+
.split("/")
|
|
214
|
+
.slice(0, -1)
|
|
215
|
+
.includes(".visual-checks"),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function parseReady(raw: string | undefined): InspectTarget | null {
|
|
220
|
+
if (raw === undefined) return null;
|
|
221
|
+
let value: unknown;
|
|
222
|
+
try {
|
|
223
|
+
value = JSON.parse(raw);
|
|
224
|
+
} catch {
|
|
225
|
+
throw new InspectExit2(
|
|
226
|
+
"invalid-options",
|
|
227
|
+
'--ready must be JSON, for example \'{"testId":"board"}\'',
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
const problem = checkReadyTarget(value);
|
|
231
|
+
if (problem) throw new InspectExit2("invalid-options", `--${problem}`);
|
|
232
|
+
return value as InspectTarget;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function parseTime(raw: string | undefined): string | null {
|
|
236
|
+
if (raw === undefined) return null;
|
|
237
|
+
const ms = Date.parse(raw);
|
|
238
|
+
if (Number.isNaN(ms))
|
|
239
|
+
throw new InspectExit2(
|
|
240
|
+
"invalid-options",
|
|
241
|
+
"--time must be an ISO 8601 date and time",
|
|
242
|
+
);
|
|
243
|
+
return new Date(ms).toISOString();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function bodyOf(
|
|
247
|
+
raw: RawInspectOptions,
|
|
248
|
+
cwd: string,
|
|
249
|
+
tileDir: string,
|
|
250
|
+
): Pick<InspectPlan, "body" | "scriptInSource" | "scriptInVisualChecks"> {
|
|
251
|
+
if (raw.code !== undefined && raw.script !== undefined) {
|
|
252
|
+
throw new InspectExit2(
|
|
253
|
+
"invalid-options",
|
|
254
|
+
"pass --code or --script, not both",
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const noScript = { scriptInSource: false, scriptInVisualChecks: false };
|
|
258
|
+
if (raw.code !== undefined)
|
|
259
|
+
return {
|
|
260
|
+
body: { kind: "code", source: readCode(raw.code, cwd) },
|
|
261
|
+
...noScript,
|
|
262
|
+
};
|
|
263
|
+
if (raw.script === undefined) return { body: { kind: "look" }, ...noScript };
|
|
264
|
+
const script = checkScript(raw.script, cwd, tileDir);
|
|
265
|
+
return {
|
|
266
|
+
body: { kind: "script", modulePath: script.modulePath },
|
|
267
|
+
scriptInSource: script.inSource,
|
|
268
|
+
scriptInVisualChecks: script.inVisualChecks,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Checks every option and finds the tile; throws InspectExit2 on any problem. */
|
|
273
|
+
export function planInspection(
|
|
274
|
+
dir: string,
|
|
275
|
+
raw: RawInspectOptions,
|
|
276
|
+
cwd: string,
|
|
277
|
+
): InspectPlan {
|
|
278
|
+
const tileDir = findTileRoot(resolve(cwd, dir));
|
|
279
|
+
if (
|
|
280
|
+
existsSync(join(tileDir, ".poe-prototype")) ||
|
|
281
|
+
!existsSync(join(tileDir, "package.json"))
|
|
282
|
+
) {
|
|
283
|
+
throw new InspectExit2("prototype", PROTOTYPE_MESSAGE);
|
|
284
|
+
}
|
|
285
|
+
const { body, scriptInSource, scriptInVisualChecks } = bodyOf(
|
|
286
|
+
raw,
|
|
287
|
+
cwd,
|
|
288
|
+
tileDir,
|
|
289
|
+
);
|
|
290
|
+
const players = intInRange(
|
|
291
|
+
raw.players,
|
|
292
|
+
1,
|
|
293
|
+
1,
|
|
294
|
+
INSPECT_CLI_LIMITS.players,
|
|
295
|
+
"players",
|
|
296
|
+
);
|
|
297
|
+
const variants = parseViewports(raw.viewport).flatMap((viewport) =>
|
|
298
|
+
parseSchemes(raw.colorScheme).map((colorScheme) => ({
|
|
299
|
+
viewport,
|
|
300
|
+
colorScheme,
|
|
301
|
+
})),
|
|
302
|
+
);
|
|
303
|
+
if (variants.length > INSPECT_CLI_LIMITS.variants) {
|
|
304
|
+
throw new InspectExit2(
|
|
305
|
+
"invalid-options",
|
|
306
|
+
`at most ${INSPECT_CLI_LIMITS.variants} variants (sizes × color schemes)`,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
if (players * variants.length > INSPECT_CLI_LIMITS.playerVariantPairs) {
|
|
310
|
+
throw new InspectExit2(
|
|
311
|
+
"invalid-options",
|
|
312
|
+
`players × variants is at most ${INSPECT_CLI_LIMITS.playerVariantPairs} (${players} × ${variants.length} asked)`,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
const timeoutS = intInRange(
|
|
316
|
+
raw.timeout,
|
|
317
|
+
INSPECT_CLI_LIMITS.defaultTimeoutS,
|
|
318
|
+
1,
|
|
319
|
+
INSPECT_CLI_LIMITS.maxTimeoutS,
|
|
320
|
+
"timeout",
|
|
321
|
+
);
|
|
322
|
+
return {
|
|
323
|
+
tileDir,
|
|
324
|
+
body,
|
|
325
|
+
players,
|
|
326
|
+
variants,
|
|
327
|
+
time: parseTime(raw.time),
|
|
328
|
+
ready: parseReady(raw.ready),
|
|
329
|
+
timeoutMs: timeoutS * 1000,
|
|
330
|
+
noBuild: raw.build === false,
|
|
331
|
+
scriptInSource,
|
|
332
|
+
scriptInVisualChecks,
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export const SDK_PIN_FIX = `Run \`${cliName()} upgrade\`, then \`${cliName()} sdk-url\`, replace the SDK value in package.json with the printed URL, and run \`bun install\`.`;
|
|
337
|
+
|
|
338
|
+
/** Both inspect dependencies resolve from the tile's own node_modules. */
|
|
339
|
+
export function checkCapability(tileDir: string): void {
|
|
340
|
+
const resolveFrom = (specifier: string) => {
|
|
341
|
+
try {
|
|
342
|
+
Bun.resolveSync(specifier, tileDir);
|
|
343
|
+
return true;
|
|
344
|
+
} catch {
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
if (!resolveFrom("@playwright/test")) {
|
|
349
|
+
throw new InspectExit2(
|
|
350
|
+
"playwright-missing",
|
|
351
|
+
"@playwright/test is not installed in this tile. Run `bun install`.",
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
if (!SDK_INSPECT_SPECIFIERS.some(resolveFrom)) {
|
|
355
|
+
throw new InspectExit2(
|
|
356
|
+
"sdk-unsupported",
|
|
357
|
+
`This tile's SDK predates tiles inspect, or is not installed. ${SDK_PIN_FIX}`,
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|