chore: update binary package generation scripts and dependencies

- Renamed binary package generation script from `generate-binary-packages.ts` to `generate-packages.ts`.
- Updated package.json and workflows to reflect the new script name.
- Added `jiti` as a new dependency for improved script execution.
- Removed the obsolete `sync-binary-package-versions.ts` script.
- Introduced tests for binary package generation functionality.
This commit is contained in:
2026-06-21 14:06:58 -04:00
parent 46fb81fab4
commit 0cfe86eeeb
10 changed files with 125 additions and 60 deletions
+36 -5
View File
@@ -17,12 +17,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: "24"
@@ -85,6 +85,10 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
if: steps.check.outputs.needs_update == 'true' && steps.pr_check.outputs.pr_exists == 'false'
run: npm ci --ignore-scripts --omit=optional
- name: Create branch and bump version
if: steps.check.outputs.needs_update == 'true' && steps.pr_check.outputs.pr_exists == 'false'
run: |
@@ -97,11 +101,38 @@ jobs:
# Use npm version to properly bump (updates package.json and package-lock.json)
# --no-git-tag-version prevents creating a tag, we'll let the publish workflow handle that
npm version "$LATEST" --no-git-tag-version
npm run sync-binary-package-versions
node --input-type=module <<'NODE'
import fs from "node:fs";
const packageJsonPath = "package.json";
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
if (!packageJson.optionalDependencies || Object.keys(packageJson.optionalDependencies).length === 0) {
throw new Error("package.json has no optionalDependencies to sync");
}
packageJson.optionalDependencies = Object.fromEntries(
Object.keys(packageJson.optionalDependencies).map((packageName) => [
packageName,
packageJson.version,
]),
);
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
NODE
npm install --package-lock-only --ignore-scripts
# Stage package files
git add package.json package-lock.json
- name: Generate current platform binary package
if: steps.check.outputs.needs_update == 'true' && steps.pr_check.outputs.pr_exists == 'false'
run: npm run generate-packages -- --set-github-env
- name: Regenerate Hugo spec and types
if: steps.check.outputs.needs_update == 'true' && steps.pr_check.outputs.pr_exists == 'false'
run: npm run generate-types
- name: Stage updated files
if: steps.check.outputs.needs_update == 'true' && steps.pr_check.outputs.pr_exists == 'false'
run: git add package.json package-lock.json
- name: Commit and push
if: steps.check.outputs.needs_update == 'true' && steps.pr_check.outputs.pr_exists == 'false'
+8 -8
View File
@@ -29,23 +29,23 @@ jobs:
os: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install -g npm@latest && npm ci
run: npm ci
- name: Generate binary package
env:
PACKAGE_NAME: ${{ matrix.package_name }}
run: npm run generate-binary-packages -- --package "$PACKAGE_NAME" --pack-dry-run
run: npm run generate-packages -- --package "$PACKAGE_NAME" --pack-dry-run
- name: Publish binary package
env:
@@ -61,21 +61,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install -g npm@latest && npm ci
run: npm ci
- name: Generate current platform binary package
run: npm run generate-binary-packages -- --set-github-env
run: npm run generate-packages -- --set-github-env
- name: Generate types
run: npm run generate-types
+53 -18
View File
@@ -19,10 +19,10 @@ jobs:
node: ["20", "22", "24"]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: "npm"
@@ -31,7 +31,7 @@ jobs:
run: npm ci
- name: Generate current platform binary package
run: npm run generate-binary-packages -- --set-github-env
run: npm run generate-packages -- --set-github-env
- name: Generate types
run: npm run generate-types
@@ -59,10 +59,10 @@ jobs:
node: ["20", "22", "24"]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: "npm"
@@ -71,7 +71,7 @@ jobs:
run: npm ci
- name: Generate current platform binary package
run: npm run generate-binary-packages -- --set-github-env
run: npm run generate-packages -- --set-github-env
- name: Generate types
run: npm run generate-types
@@ -92,10 +92,10 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: "24"
cache: "npm"
@@ -104,7 +104,7 @@ jobs:
run: npm ci
- name: Generate current platform binary package
run: npm run generate-binary-packages -- --set-github-env
run: npm run generate-packages -- --set-github-env
- name: Generate types
run: npm run generate-types
@@ -125,10 +125,10 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: "24"
cache: "npm"
@@ -137,12 +137,39 @@ jobs:
run: npm ci
- name: Generate current platform binary package
run: npm run generate-binary-packages
run: npm run generate-packages
- name: Install generated binary package
shell: bash
run: |
package_dir=$(find dist-platforms -mindepth 1 -maxdepth 1 -type d ! -name .downloads | head -n 1)
case "${RUNNER_OS}-${RUNNER_ARCH}" in
Linux-X64)
package_dir="dist-platforms/hugo-extended-linux-amd64"
;;
Linux-ARM64)
package_dir="dist-platforms/hugo-extended-linux-arm64"
;;
macOS-X64|macOS-ARM64)
package_dir="dist-platforms/hugo-extended-darwin-universal"
;;
Windows-X64)
package_dir="dist-platforms/hugo-extended-windows-amd64"
;;
Windows-ARM64)
package_dir="dist-platforms/hugo-windows-arm64"
;;
*)
echo "::error::No binary package mapping for ${RUNNER_OS}/${RUNNER_ARCH}"
exit 1
;;
esac
if [[ ! -d "$package_dir" ]]; then
echo "::error::Expected generated binary package at $package_dir"
find dist-platforms -mindepth 1 -maxdepth 1 -type d -print
exit 1
fi
npm install --no-save --package-lock=false "$package_dir"
- name: Generate types
@@ -154,11 +181,19 @@ jobs:
- name: Verify package-resolved Hugo
run: |
node -e "
import('./dist/hugo.mjs').then(async (m) => {
Promise.all([import('./dist/hugo.mjs'), import('node:fs')]).then(async ([m, fs]) => {
const expected = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
const bin = await m.default();
console.log(bin);
const { stdout } = await m.execWithOutput('version');
console.log(stdout.trim());
const versionOutput = stdout.trim();
console.log(versionOutput);
const match = versionOutput.match(/\bv([0-9]+\.[0-9]+\.[0-9]+)/);
const actual = match ? match[1] : null;
if (actual !== expected) {
throw new Error('Expected Hugo v' + expected + ', got ' + (actual || 'unparseable version') + ' from: ' + versionOutput);
}
}).catch((error) => {
console.error(error);
process.exit(1);
@@ -171,10 +206,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # ratchet:actions/checkout@v7
- name: Setup Node.js
uses: actions/setup-node@v6
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # ratchet:actions/setup-node@v6
with:
node-version: "24"
cache: "npm"
@@ -183,7 +218,7 @@ jobs:
run: npm ci
- name: Generate current platform binary package
run: npm run generate-binary-packages
run: npm run generate-packages
- name: Root package dry run
run: npm pack --dry-run
+2 -2
View File
@@ -29,7 +29,7 @@ Notes for LLM coding agents working on `hugo-extended`.
- Extended packages use `hugo-extended-*` names only where upstream Hugo ships Extended.
- Windows ARM64 uses the vanilla `@jakejarvis/hugo-windows-arm64` package.
- **Binary package generation**: `scripts/generate-binary-packages.ts`
- **Binary package generation**: `scripts/generate-packages.ts`
- Downloads Hugo release assets and verifies SHA-256 checksums during release packaging.
- **macOS v0.153.0+**: uses `pkgutil --expand-full` to extract the binary from the `.pkg` file, so the macOS package must be generated on macOS.
- `.tar.gz` and `.zip` assets can be generated on Linux/macOS.
@@ -111,7 +111,7 @@ npm run test:coverage # coverage via v8
- Re-run `npm run generate-types` if the change depends on spec shape.
- Prefer making tests match **the committed generated spec**, not an assumed kebab-case transform.
- If you touch binary package generation (`scripts/generate-binary-packages.ts`):
- If you touch binary package generation (`scripts/generate-packages.ts`):
- macOS `.pkg` extraction requires macOS `pkgutil`.
- Keep generated package manifests script-free.
- Use exact package versions that match the root package/Hugo version.
+9 -5
View File
@@ -40,14 +40,14 @@ These integrate seamlessly with Hugo's [built-in PostCSS pipes](https://gohugo.i
The simplest way — just run `hugo` commands directly:
```json
```jsonc
// package.json
{
"scripts": {
"dev": "hugo server --buildDrafts",
"build": "hugo --minify",
"build:preview": "hugo --baseURL \"${DEPLOY_PRIME_URL:-/}\" --buildDrafts --buildFuture"
}
"build:preview": "hugo --baseURL \"${DEPLOY_PRIME_URL:-/}\" --buildDrafts --buildFuture",
},
}
```
@@ -232,11 +232,15 @@ HUGO_BIN_PATH=/usr/local/bin/hugo npm run build
`hugo-extended` depends on platform-specific optional packages such as `@jakejarvis/hugo-extended-linux-amd64`. If you install with optional dependencies omitted, the wrapper cannot find its bundled Hugo binary.
Reinstall with optional dependencies explicitly enabled. A plain install will not fix this if your environment or package-manager config is still omitting optional dependencies.
```sh
npm install
npm install --include=optional
pnpm install --config.optional=true
yarn config set ignore-optional false && yarn install
```
If your environment intentionally omits optional dependencies, set `HUGO_BIN_PATH` to a compatible Hugo binary.
If your environment intentionally omits optional dependencies, set `HUGO_BIN_PATH` to a compatible Hugo binary instead.
### macOS installation
+11
View File
@@ -18,6 +18,7 @@
"@types/tar": "^6.1.13",
"@vitest/coverage-v8": "^4.1.9",
"adm-zip": "^0.5.17",
"jiti": "^2.7.0",
"oxfmt": "^0.55.0",
"oxlint": "^1.70.0",
"tar": "^7.5.16",
@@ -1861,6 +1862,16 @@
"node": ">=8"
}
},
"node_modules/jiti": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
"integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==",
"dev": true,
"license": "MIT",
"bin": {
"jiti": "lib/jiti-cli.mjs"
}
},
"node_modules/js-tokens": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz",
+5 -3
View File
@@ -50,8 +50,7 @@
"build": "tsdown",
"dev": "tsdown --watch",
"generate-types": "npx jiti scripts/generate-types.ts",
"generate-binary-packages": "npx jiti scripts/generate-binary-packages.ts",
"sync-binary-package-versions": "npx jiti scripts/sync-binary-package-versions.ts",
"generate-packages": "npx jiti scripts/generate-packages.ts",
"lint": "oxlint",
"lint:fix": "oxlint --fix",
"fmt": "oxfmt",
@@ -63,7 +62,6 @@
"test:integration": "vitest run tests/integration",
"test:e2e": "vitest run tests/e2e",
"test:coverage": "vitest run --coverage",
"pack:dry-run": "npm pack --dry-run && npm run generate-binary-packages -- --pack-dry-run",
"prepublishOnly": "npm run generate-types && npm run build"
},
"devDependencies": {
@@ -72,6 +70,7 @@
"@types/tar": "^6.1.13",
"@vitest/coverage-v8": "^4.1.9",
"adm-zip": "^0.5.17",
"jiti": "^2.7.0",
"oxfmt": "^0.55.0",
"oxlint": "^1.70.0",
"tar": "^7.5.16",
@@ -89,5 +88,8 @@
},
"engines": {
"node": "^20.19.0 || >=22.12.0"
},
"allowScripts": {
"fsevents@2.3.3": true
}
}
-18
View File
@@ -1,18 +0,0 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { HUGO_PLATFORM_PACKAGES } from "../src/lib/platform";
const currentDir = path.dirname(fileURLToPath(import.meta.url));
const packageJsonPath = path.join(currentDir, "..", "package.json");
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")) as {
version: string;
optionalDependencies?: Record<string, string>;
};
packageJson.optionalDependencies = Object.fromEntries(
HUGO_PLATFORM_PACKAGES.map((pkg) => [pkg.packageName, packageJson.version]),
);
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
@@ -6,7 +6,7 @@ import {
getBinaryPackageBinPath,
getBinaryPackageDir,
parseChecksumFile,
} from "../../scripts/generate-binary-packages";
} from "../../scripts/generate-packages";
import { getPlatformPackageByName, HUGO_PLATFORM_PACKAGES } from "../../src/lib/platform";
describe("binary package generation", () => {