Skip to content

Write HTML. Render video. Built for agents.

fix: rewrite workspace deps before npm publish (#67)

Miguel Ángele1c1c6fb30c1
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 4e22ea1b4c..d5ec28d892 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -21,36 +21,39 @@ jobs:
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
+ - run: corepack enable
+ - run: corepack prepare [email protected] --activate
- run: bun install --frozen-lockfile
- run: bun run build
+ - run: bun run verify:packed-manifests
- name: Publish @hyperframes/core
continue-on-error: true
- run: npm --workspace packages/core publish --access public --no-git-checks
+ run: pnpm --filter @hyperframes/core publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @hyperframes/engine
continue-on-error: true
- run: npm --workspace packages/engine publish --access public --no-git-checks
+ run: pnpm --filter @hyperframes/engine publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @hyperframes/producer
continue-on-error: true
- run: npm --workspace packages/producer publish --access public --no-git-checks
+ run: pnpm --filter @hyperframes/producer publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @hyperframes/studio
continue-on-error: true
- run: npm --workspace packages/studio publish --access public --no-git-checks
+ run: pnpm --filter @hyperframes/studio publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish hyperframes (CLI)
continue-on-error: true
- run: npm --workspace packages/cli publish --access public --no-git-checks
+ run: pnpm --filter @hyperframes/cli publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/package.json b/package.json
index 9657921fe0..507f5d0391 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,7 @@
"studio": "bun run --filter @hyperframes/studio dev",
"build:hyperframes-runtime": "bun run --filter @hyperframes/core build:hyperframes-runtime",
"build:hyperframes-runtime:modular": "bun run --filter @hyperframes/core build:hyperframes-runtime:modular",
+ "verify:packed-manifests": "node scripts/verify-packed-manifests.mjs",
"set-version": "tsx scripts/set-version.ts",
"lint": "oxlint .",
"lint:fix": "oxlint --fix .",
diff --git a/scripts/verify-packed-manifests.mjs b/scripts/verify-packed-manifests.mjs
new file mode 100644
index 0000000000..0af65e02d2
--- /dev/null
+++ b/scripts/verify-packed-manifests.mjs
@@ -0,0 +1,75 @@
+#!/usr/bin/env node
+
+import { execFileSync } from "node:child_process";
+import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node:fs";
+import { join } from "node:path";
+import { tmpdir } from "node:os";
+
+const ROOT = join(import.meta.dirname, "..");
+const PACKAGES_DIR = join(ROOT, "packages");
+const DEP_FIELDS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
+
+function listWorkspacePackageDirs() {
+ return readdirSync(PACKAGES_DIR)
+ .map((dir) => join("packages", dir))
+ .filter((dir) => existsSync(join(ROOT, dir, "package.json")));
+}
+
+function listWorkspaceRefs(pkg) {
+ const refs = [];
+
+ for (const field of DEP_FIELDS) {
+ for (const [depName, spec] of Object.entries(pkg[field] || {})) {
+ if (String(spec).startsWith("workspace:")) {
+ refs.push(`${field}:${depName}=${spec}`);
+ }
+ }
+ }
+
+ return refs;
+}
+
+function parsePackJson(output, workspace) {
+ try {
+ const parsed = JSON.parse(output);
+ return Array.isArray(parsed) ? parsed : [parsed];
+ } catch {
+ throw new Error(`Could not parse pnpm pack JSON output for ${workspace}`);
+ }
+}
+
+function main() {
+ for (const workspace of listWorkspacePackageDirs()) {
+ const sourcePackageJson = JSON.parse(
+ readFileSync(join(ROOT, workspace, "package.json"), "utf8"),
+ );
+ if (listWorkspaceRefs(sourcePackageJson).length === 0) continue;
+
+ const packDir = mkdtempSync(join(tmpdir(), "hyperframes-pack-"));
+ const packOutput = execFileSync("pnpm", ["pack", "--json", "--pack-destination", packDir], {
+ cwd: join(ROOT, workspace),
+ encoding: "utf8",
+ });
+ const [{ filename }] = parsePackJson(packOutput, workspace);
+
+ try {
+ const packedPackageJson = execFileSync("tar", ["-xOf", filename, "package/package.json"], {
+ cwd: ROOT,
+ encoding: "utf8",
+ });
+ const packedRefs = listWorkspaceRefs(JSON.parse(packedPackageJson));
+
+ if (packedRefs.length > 0) {
+ throw new Error(
+ `Packed manifest for ${workspace} still contains workspace refs: ${packedRefs.join(", ")}`,
+ );
+ }
+
+ console.log(`Verified ${workspace}: packed manifest is publish-safe.`);
+ } finally {
+ rmSync(packDir, { force: true, recursive: true });
+ }
+ }
+}
+
+main();