Skip to content

Commit b1e0201

Browse files
committed
Fixed deploy zips shipping pnpm files and repaired the ncc build
The zip step's hard-coded exclude list covered yarn* and npm* but not pnpm*, so themes deployed from pnpm-based repos shipped pnpm-lock.yaml and pnpm-workspace.yaml to the live Ghost site (found via the pnpm migration in TryGhost/Themes#529, where all 16 demo-site deploys were affected). Added pnpm* to the default excludes. Preparing this fix surfaced that the build has been broken since Renovate bumped @actions/core, @actions/exec, and slug to ESM-only majors: the CommonJS source can no longer require() them, so ncc build fails and dist has not been rebuildable since February. Load the three packages via dynamic import() instead, keeping the source and dist CommonJS so the node20 runtime keeps executing the action as before. dist/ is intentionally not rebuilt in this commit; it must be regenerated with yarn build (which works again with this change) when the action is next shipped. Note ncc now also emits the dynamic imports as async chunk files next to dist/index.js — they are part of the build output and need to ship with it.
1 parent c0861b6 commit b1e0201

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
const path = require('path');
2-
const slug = require('slug');
3-
const core = require('@actions/core');
4-
const exec = require('@actions/exec');
52
const GhostAdminApi = require('@tryghost/admin-api');
63

74
(async function main() {
85
try {
6+
// slug and the @actions toolkit packages are ESM-only in their current
7+
// majors, so they must be loaded via dynamic import from CommonJS.
8+
const [core, exec, {default: slug}] = await Promise.all([
9+
import('@actions/core'),
10+
import('@actions/exec'),
11+
import('slug')
12+
]);
13+
914
const url = core.getInput('api-url');
1015
const api = new GhostAdminApi({
1116
url,
@@ -26,7 +31,7 @@ const GhostAdminApi = require('@tryghost/admin-api');
2631
zipPath = themeZip;
2732

2833
// Create a zip
29-
await exec.exec(`zip -r ${themeZip} . -x *.git* *.zip yarn* npm* node_modules* *routes.yaml *redirects.yaml *redirects.json ${exclude}`, [], {cwd: basePath});
34+
await exec.exec(`zip -r ${themeZip} . -x *.git* *.zip yarn* npm* pnpm* node_modules* *routes.yaml *redirects.yaml *redirects.json ${exclude}`, [], {cwd: basePath});
3035
}
3136

3237
zipPath = path.join(basePath, zipPath);

0 commit comments

Comments
 (0)