Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/registry-verification-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@emdash-cms/registry-verification": patch
---

Fixes site builds on Windows failing when the plugin registry verifier is imported.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ jobs:
# leave them unbuilt and their tests would fail to resolve workspace
# links to dist/.
- run: pnpm run --filter emdash... --filter "@emdash-cms/aggregator" --filter "@emdash-cms/labeler" --filter "@emdash-cms/plugin-cli" --filter "@emdash-cms/registry-*" --filter "@emdash-cms/plugin-types" build
- name: Check registry-verification package
if: matrix.shardIndex == 1
run: pnpm --filter @emdash-cms/registry-verification test:package
- run: pnpm --filter emdash exec vitest run --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
EMDASH_TEST_PG: postgres://postgres:test@localhost:5432/emdash_test
Expand Down
2 changes: 1 addition & 1 deletion apps/release-action/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8161,7 +8161,7 @@ function createGzipDecoder() {
//#endregion
//#region ../../packages/registry-verification/dist/index.js
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __require = /* @__PURE__ */ createRequire("file:///emdash-registry-verification.js");
var __require = /* @__PURE__ */ createRequire("file:///C:/emdash-registry-verification.js");
const DEFAULT_FETCH_LIMITS = {
headerTimeoutMs: 1e4,
totalTimeoutMs: 3e4,
Expand Down
14 changes: 14 additions & 0 deletions packages/registry-verification/scripts/check-packed-output.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { createReadStream } from "node:fs";
import { mkdtemp, readFile, rm } from "node:fs/promises";
import { createRequire } from "node:module";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { pipeline } from "node:stream/promises";
import { fileURLToPath } from "node:url";
import { createGunzip } from "node:zlib";

import { unpackTar } from "modern-tar/fs";
Expand Down Expand Up @@ -42,6 +45,17 @@ try {
if (publishedOutput.includes("createRequire(import.meta.url)")) {
throw new Error("Packed verifier output cannot be safely rebundled");
}
const requireUrl = publishedOutput.match(/createRequire\("([^"\n]+)"\)/)?.[1];
if (!requireUrl) {
throw new Error("Packed verifier output is missing the CJS interop shim");
}
// Check both path conventions regardless of the platform running this test.
fileURLToPath(requireUrl, { windows: true });
fileURLToPath(requireUrl, { windows: false });
const require = createRequire(requireUrl);
assert.equal(typeof require("crypto").createHash, "function");
assert.equal(typeof require("util").promisify, "function");

if (
publishedBundleOutput.includes("createRequire") ||
publishedBundleOutput.includes("@sigstore") ||
Expand Down
3 changes: 2 additions & 1 deletion packages/registry-verification/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { defineConfig } from "tsdown";

// Consumers rebundle this artifact, where import.meta.url may no longer name a file.
// The generated require only resolves Node builtins, so a stable absolute base is sufficient.
// A drive letter keeps the synthetic URL valid on Windows.
const rebundleSafeRequire = {
name: "rebundle-safe-require",
renderChunk(code: string) {
return code.replace(
"createRequire(import.meta.url)",
'createRequire("file:///emdash-registry-verification.js")',
'createRequire("file:///C:/emdash-registry-verification.js")',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[needs fixing] The source URL now includes a drive letter, but the committed GitHub Action artifact still carries the old URL. apps/release-action/dist/index.js bundles @emdash-cms/registry-verification and still contains:

var __require = /* @__PURE__ */ createRequire("file:///emdash-registry-verification.js");

The typecheck CI job rebuilds @emdash-cms/release-action and then runs git diff --exit-code -- apps/release-action/dist/index.js. Because that build inlines the changed registry-verification output, the committed dist will differ after this change and the CI guard will fail.

Fix by rebuilding and committing the regenerated action bundle:

pnpm build
pnpm --filter @emdash-cms/release-action build

then commit apps/release-action/dist/index.js.

);
},
};
Expand Down
Loading