Skip to content

Commit 12bfbd7

Browse files
committed
Add script to update package.json variants
1 parent a79129e commit 12bfbd7

File tree

9 files changed

+146
-60
lines changed

9 files changed

+146
-60
lines changed

npm/darwin-arm64/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
{
22
"name": "@alphahydrae/exec-darwin-arm64",
3+
"version": "0.2.4",
34
"description": "The execvp function for Node.js",
4-
"license": "MIT",
5+
"author": "Simon Oulevay <[email protected]>",
56
"keywords": [
67
"exec",
78
"execvp"
89
],
9-
"version": "0.2.4",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
14+
},
15+
"main": "exec.darwin-arm64.node",
16+
"files": [
17+
"exec.darwin-arm64.node"
18+
],
1019
"os": [
1120
"darwin"
1221
],
1322
"cpu": [
1423
"arm64"
1524
],
16-
"main": "exec.darwin-arm64.node",
17-
"files": [
18-
"exec.darwin-arm64.node"
19-
],
20-
"repository": {
21-
"type": "git",
22-
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
23-
},
2425
"engines": {
2526
"node": "^18 || ^20 || ^22"
2627
}

npm/darwin-x64/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
{
22
"name": "@alphahydrae/exec-darwin-x64",
3+
"version": "0.2.4",
34
"description": "The execvp function for Node.js",
4-
"license": "MIT",
5+
"author": "Simon Oulevay <[email protected]>",
56
"keywords": [
67
"exec",
78
"execvp"
89
],
9-
"version": "0.2.4",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
14+
},
15+
"main": "exec.darwin-x64.node",
16+
"files": [
17+
"exec.darwin-x64.node"
18+
],
1019
"os": [
1120
"darwin"
1221
],
1322
"cpu": [
1423
"x64"
1524
],
16-
"main": "exec.darwin-x64.node",
17-
"files": [
18-
"exec.darwin-x64.node"
19-
],
20-
"repository": {
21-
"type": "git",
22-
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
23-
},
2425
"engines": {
2526
"node": "^18 || ^20 || ^22"
2627
}

npm/linux-arm64-gnu/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
{
22
"name": "@alphahydrae/exec-linux-arm64-gnu",
3+
"version": "0.2.4",
34
"description": "The execvp function for Node.js",
4-
"license": "MIT",
5+
"author": "Simon Oulevay <[email protected]>",
56
"keywords": [
67
"exec",
78
"execvp"
89
],
9-
"version": "0.2.4",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
14+
},
15+
"main": "exec.linux-arm64-gnu.node",
16+
"files": [
17+
"exec.linux-arm64-gnu.node"
18+
],
1019
"os": [
1120
"linux"
1221
],
@@ -16,14 +25,6 @@
1625
"libc": [
1726
"glibc"
1827
],
19-
"main": "exec.linux-arm64-gnu.node",
20-
"files": [
21-
"exec.linux-arm64-gnu.node"
22-
],
23-
"repository": {
24-
"type": "git",
25-
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
26-
},
2728
"engines": {
2829
"node": "^18 || ^20 || ^22"
2930
}

npm/linux-arm64-musl/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
{
22
"name": "@alphahydrae/exec-linux-arm64-musl",
3+
"version": "0.2.4",
34
"description": "The execvp function for Node.js",
4-
"license": "MIT",
5+
"author": "Simon Oulevay <[email protected]>",
56
"keywords": [
67
"exec",
78
"execvp"
89
],
9-
"version": "0.2.4",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
14+
},
15+
"main": "exec.linux-arm64-musl.node",
16+
"files": [
17+
"exec.linux-arm64-musl.node"
18+
],
1019
"os": [
1120
"linux"
1221
],
@@ -16,14 +25,6 @@
1625
"libc": [
1726
"musl"
1827
],
19-
"main": "exec.linux-arm64-musl.node",
20-
"files": [
21-
"exec.linux-arm64-musl.node"
22-
],
23-
"repository": {
24-
"type": "git",
25-
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
26-
},
2728
"engines": {
2829
"node": "^18 || ^20 || ^22"
2930
}

npm/linux-x64-gnu/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
{
22
"name": "@alphahydrae/exec-linux-x64-gnu",
3+
"version": "0.2.4",
34
"description": "The execvp function for Node.js",
4-
"license": "MIT",
5+
"author": "Simon Oulevay <[email protected]>",
56
"keywords": [
67
"exec",
78
"execvp"
89
],
9-
"version": "0.2.4",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
14+
},
15+
"main": "exec.linux-x64-gnu.node",
16+
"files": [
17+
"exec.linux-x64-gnu.node"
18+
],
1019
"os": [
1120
"linux"
1221
],
@@ -16,14 +25,6 @@
1625
"libc": [
1726
"glibc"
1827
],
19-
"main": "exec.linux-x64-gnu.node",
20-
"files": [
21-
"exec.linux-x64-gnu.node"
22-
],
23-
"repository": {
24-
"type": "git",
25-
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
26-
},
2728
"engines": {
2829
"node": "^18 || ^20 || ^22"
2930
}

npm/linux-x64-musl/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
{
22
"name": "@alphahydrae/exec-linux-x64-musl",
3+
"version": "0.2.4",
34
"description": "The execvp function for Node.js",
4-
"license": "MIT",
5+
"author": "Simon Oulevay <[email protected]>",
56
"keywords": [
67
"exec",
78
"execvp"
89
],
9-
"version": "0.2.4",
10+
"license": "MIT",
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
14+
},
15+
"main": "exec.linux-x64-musl.node",
16+
"files": [
17+
"exec.linux-x64-musl.node"
18+
],
1019
"os": [
1120
"linux"
1221
],
@@ -16,14 +25,6 @@
1625
"libc": [
1726
"musl"
1827
],
19-
"main": "exec.linux-x64-musl.node",
20-
"files": [
21-
"exec.linux-x64-musl.node"
22-
],
23-
"repository": {
24-
"type": "git",
25-
"url": "git+https://github.com/AlphaHydrae/node-exec.git"
26-
},
2728
"engines": {
2829
"node": "^18 || ^20 || ^22"
2930
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"artifacts": "napi artifacts",
3838
"build": "napi build --platform --release",
3939
"build:debug": "napi build --platform",
40+
"build:package": "node scripts/build-packages.mjs",
4041
"check": "npm run lint && npm run format",
4142
"check:write": "npm run lint && npm run format:write",
4243
"doctoc": "doctoc --github --notitle README.md && prettier --write README.md",

scripts/build-packages.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { readFile, writeFile } from 'node:fs/promises';
2+
import path from 'node:path';
3+
4+
const root = path.resolve(path.join(path.dirname(new URL(import.meta.url).pathname), '..'));
5+
const packageJson = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf-8'));
6+
const variants = JSON.parse(await readFile(path.join(root, 'variants.json'), 'utf-8'));
7+
8+
const { devDependencies, ...commonPackageJsonProperties } = packageJson;
9+
10+
await Promise.all(
11+
variants.map(async variant => {
12+
const libcName = variant.libc === 'glibc' ? 'gnu' : variant.libc;
13+
const variantName = [variant.os, variant.cpu, libcName]
14+
.filter(part => part !== undefined)
15+
.join('-');
16+
const nativeBindingFile = `exec.${variantName}.node`;
17+
await writeFile(
18+
path.join(root, 'npm', variantName, 'package.json'),
19+
JSON.stringify(
20+
{
21+
name: `${packageJson.name}-${variantName}`,
22+
version: packageJson.version,
23+
description: packageJson.description,
24+
author: packageJson.author,
25+
keywords: packageJson.keywords,
26+
license: packageJson.license,
27+
repository: packageJson.repository,
28+
main: nativeBindingFile,
29+
files: [nativeBindingFile],
30+
os: toArray(variant.os),
31+
cpu: toArray(variant.cpu),
32+
libc: toArray(variant.libc),
33+
engines: packageJson.engines
34+
},
35+
undefined,
36+
2
37+
),
38+
'utf8'
39+
);
40+
})
41+
);
42+
43+
function toArray(value) {
44+
if (value === undefined) {
45+
return undefined;
46+
}
47+
48+
return Array.isArray(value) ? value : [value];
49+
}

variants.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
"os": "darwin",
4+
"cpu": "arm64"
5+
},
6+
{
7+
"os": "darwin",
8+
"cpu": "x64"
9+
},
10+
{
11+
"os": "linux",
12+
"cpu": "arm64",
13+
"libc": "glibc"
14+
},
15+
{
16+
"os": "linux",
17+
"cpu": "arm64",
18+
"libc": "musl"
19+
},
20+
{
21+
"os": "linux",
22+
"cpu": "x64",
23+
"libc": "glibc"
24+
},
25+
{
26+
"os": "linux",
27+
"cpu": "x64",
28+
"libc": "musl"
29+
}
30+
]

0 commit comments

Comments
 (0)