From 9154085e2c903eed948cabab397f44cc63d1d727 Mon Sep 17 00:00:00 2001 From: Abimael Martell Date: Thu, 2 Apr 2026 11:52:12 -0700 Subject: [PATCH] fix publish: generate platform packages manually, add optionalDependencies Skip napi prepublish/artifacts commands that require GitHub API auth. Instead, create platform package.json files and copy binaries directly. Add optionalDependencies to main package so npm/bun auto-selects the right binary. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/publish.yml | 48 ++++++++++++++++++++++++++--------- napi/package.json | 12 ++++++--- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ef24fdd..dfb39fe 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -78,30 +78,54 @@ jobs: - name: Prepare and publish working-directory: napi - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc echo "@firecrawl:registry=https://npm.pkg.github.com" >> .npmrc - # Create platform package dirs expected by napi artifacts + VERSION=$(node -p "require('./package.json').version") + + # Create platform package dirs and package.json files mkdir -p npm/linux-x64-gnu npm/darwin-arm64 - # Move binaries into platform dirs - bunx napi artifacts --build-output-dir artifacts + cat > npm/linux-x64-gnu/package.json << PKGEOF + { + "name": "@firecrawl/pdf-inspector-js-linux-x64-gnu", + "version": "${VERSION}", + "os": ["linux"], + "cpu": ["x64"], + "main": "pdf-inspector.linux-x64-gnu.node", + "files": ["pdf-inspector.linux-x64-gnu.node"], + "license": "MIT", + "repository": { "type": "git", "url": "https://github.com/firecrawl/pdf-inspector" }, + "publishConfig": { "registry": "https://npm.pkg.github.com", "access": "public" } + } + PKGEOF - # Generate platform package.json files - bunx napi prepublish -t npm --skip-gh-release + cat > npm/darwin-arm64/package.json << PKGEOF + { + "name": "@firecrawl/pdf-inspector-js-darwin-arm64", + "version": "${VERSION}", + "os": ["darwin"], + "cpu": ["arm64"], + "main": "pdf-inspector.darwin-arm64.node", + "files": ["pdf-inspector.darwin-arm64.node"], + "license": "MIT", + "repository": { "type": "git", "url": "https://github.com/firecrawl/pdf-inspector" }, + "publishConfig": { "registry": "https://npm.pkg.github.com", "access": "public" } + } + PKGEOF + + # Move binaries into platform dirs + cp artifacts/bindings-x86_64-unknown-linux-gnu/*.node npm/linux-x64-gnu/ + cp artifacts/bindings-aarch64-apple-darwin/*.node npm/darwin-arm64/ echo "=== Package contents ===" ls -R npm/ # Publish platform packages first, then main package for dir in npm/*/; do - if [ -f "$dir/package.json" ]; then - echo "Publishing $dir" - (cd "$dir" && npm publish --access public) || true - fi + echo "Publishing $dir" + (cd "$dir" && npm publish --access public) done echo "Publishing main package" - npm publish --access public || true + npm publish --access public diff --git a/napi/package.json b/napi/package.json index 86b28eb..30dd3f3 100644 --- a/napi/package.json +++ b/napi/package.json @@ -4,6 +4,10 @@ "main": "index.js", "types": "index.d.ts", "license": "MIT", + "files": [ + "index.js", + "index.d.ts" + ], "repository": { "type": "git", "url": "https://github.com/firecrawl/pdf-inspector" @@ -22,11 +26,13 @@ "name": "@firecrawl/pdf-inspector-js" } }, + "optionalDependencies": { + "@firecrawl/pdf-inspector-js-linux-x64-gnu": "0.2.0", + "@firecrawl/pdf-inspector-js-darwin-arm64": "0.2.0" + }, "scripts": { "build": "napi build --platform --release", - "build:debug": "napi build --platform", - "prepublishOnly": "napi prepublish -t npm", - "artifacts": "napi artifacts" + "build:debug": "napi build --platform" }, "devDependencies": { "@napi-rs/cli": "^3.4.1"