Skip to content

Commit 1a9a70b

Browse files
fix: add optionalDependencies and platform npm packages for automatic native binding installation
Platform-specific native packages now include os/cpu/libc fields and are committed to the repo, enabling npm/pnpm to auto-select the correct binding per platform. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent be05917 commit 1a9a70b

13 files changed

Lines changed: 143 additions & 23 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -167,24 +167,30 @@ jobs:
167167
done
168168
ls -la *.node
169169
170-
- name: Update native package version
170+
- name: Update native package versions
171171
run: |
172172
VERSION="${{ github.ref_name }}"
173173
VERSION="${VERSION#v}"
174174
cd native
175175
node -e "
176176
const fs = require('fs');
177+
const path = require('path');
178+
// Update native/package.json
177179
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
178180
pkg.version = '$VERSION';
179181
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
182+
// Update all platform package versions
183+
const npmDir = path.join('.', 'npm');
184+
for (const dir of fs.readdirSync(npmDir)) {
185+
const pkgPath = path.join(npmDir, dir, 'package.json');
186+
if (fs.existsSync(pkgPath)) {
187+
const platformPkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
188+
platformPkg.version = '$VERSION';
189+
fs.writeFileSync(pkgPath, JSON.stringify(platformPkg, null, 2) + '\n');
190+
}
191+
}
180192
"
181193
182-
- name: Create npm packages
183-
run: |
184-
cd native
185-
pnpm napi create-npm-dirs
186-
ls -la npm/
187-
188194
- name: Copy binaries to npm packages
189195
run: |
190196
cd native
@@ -199,21 +205,6 @@ jobs:
199205
fi
200206
done
201207
202-
- name: Add repository to platform packages
203-
run: |
204-
cd native
205-
for pkg in npm/*/package.json; do
206-
node -e "
207-
const fs = require('fs');
208-
const pkg = JSON.parse(fs.readFileSync('$pkg', 'utf8'));
209-
pkg.repository = {
210-
type: 'git',
211-
url: 'https://github.com/productdevbook/nitro-graphql'
212-
};
213-
fs.writeFileSync('$pkg', JSON.stringify(pkg, null, 2) + '\n');
214-
"
215-
done
216-
217208
- name: Determine npm tag
218209
id: npm-tag
219210
run: |

native/npm/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.node

native/npm/darwin-arm64/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `nitro-graphql-darwin-arm64`
2+
3+
This is the **aarch64-apple-darwin** binary for `nitro-graphql`
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "nitro-graphql-darwin-arm64",
3+
"version": "2.0.0-beta.70",
4+
"description": "GraphQL integration for Nitro - native darwin-arm64 binding",
5+
"license": "MIT",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/productdevbook/nitro-graphql"
9+
},
10+
"cpu": [
11+
"arm64"
12+
],
13+
"os": [
14+
"darwin"
15+
],
16+
"main": "graphql-lint.darwin-arm64.node",
17+
"files": [
18+
"graphql-lint.darwin-arm64.node"
19+
]
20+
}

native/npm/darwin-x64/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `nitro-graphql-darwin-x64`
2+
3+
This is the **x86_64-apple-darwin** binary for `nitro-graphql`

native/npm/darwin-x64/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "nitro-graphql-darwin-x64",
3+
"version": "2.0.0-beta.70",
4+
"description": "GraphQL integration for Nitro - native darwin-x64 binding",
5+
"license": "MIT",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/productdevbook/nitro-graphql"
9+
},
10+
"cpu": [
11+
"x64"
12+
],
13+
"os": [
14+
"darwin"
15+
],
16+
"main": "graphql-lint.darwin-x64.node",
17+
"files": [
18+
"graphql-lint.darwin-x64.node"
19+
]
20+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `nitro-graphql-linux-arm64-gnu`
2+
3+
This is the **aarch64-unknown-linux-gnu** binary for `nitro-graphql`
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nitro-graphql-linux-arm64-gnu",
3+
"version": "2.0.0-beta.70",
4+
"description": "GraphQL integration for Nitro - native linux-arm64-gnu binding",
5+
"license": "MIT",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/productdevbook/nitro-graphql"
9+
},
10+
"cpu": [
11+
"arm64"
12+
],
13+
"os": [
14+
"linux"
15+
],
16+
"libc": [
17+
"glibc"
18+
],
19+
"main": "graphql-lint.linux-arm64-gnu.node",
20+
"files": [
21+
"graphql-lint.linux-arm64-gnu.node"
22+
]
23+
}

native/npm/linux-x64-gnu/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `nitro-graphql-linux-x64-gnu`
2+
3+
This is the **x86_64-unknown-linux-gnu** binary for `nitro-graphql`
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "nitro-graphql-linux-x64-gnu",
3+
"version": "2.0.0-beta.70",
4+
"description": "GraphQL integration for Nitro - native linux-x64-gnu binding",
5+
"license": "MIT",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/productdevbook/nitro-graphql"
9+
},
10+
"cpu": [
11+
"x64"
12+
],
13+
"os": [
14+
"linux"
15+
],
16+
"libc": [
17+
"glibc"
18+
],
19+
"main": "graphql-lint.linux-x64-gnu.node",
20+
"files": [
21+
"graphql-lint.linux-x64-gnu.node"
22+
]
23+
}

0 commit comments

Comments
 (0)