@napi-rs/cli 3.0.0-alpha.2 → 3.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/artifacts.js +5 -2
- package/dist/api/artifacts.js.map +1 -0
- package/dist/api/build.d.ts +1 -1
- package/dist/api/build.js +182 -32
- package/dist/api/build.js.map +1 -0
- package/dist/api/create-npm-dirs.js +3 -2
- package/dist/api/create-npm-dirs.js.map +1 -0
- package/dist/api/load-wasi-template.d.ts +1 -0
- package/dist/api/load-wasi-template.js +60 -0
- package/dist/api/load-wasi-template.js.map +1 -0
- package/dist/api/new.js +31 -12
- package/dist/api/new.js.map +1 -0
- package/dist/api/pre-publish.js +4 -3
- package/dist/api/pre-publish.js.map +1 -0
- package/dist/api/rename.js +9 -0
- package/dist/api/rename.js.map +1 -0
- package/dist/api/templates/.gitignore.d.ts +1 -1
- package/dist/api/templates/.gitignore.js +2 -0
- package/dist/api/templates/.gitignore.js.map +1 -0
- package/dist/api/templates/.npmignore.js +1 -0
- package/dist/api/templates/.npmignore.js.map +1 -0
- package/dist/api/templates/build.rs.js +1 -0
- package/dist/api/templates/build.rs.js.map +1 -0
- package/dist/api/templates/cargo.toml.js +1 -0
- package/dist/api/templates/cargo.toml.js.map +1 -0
- package/dist/api/templates/ci-template.js +64 -57
- package/dist/api/templates/ci-template.js.map +1 -0
- package/dist/api/templates/ci.yml.d.ts +1 -1
- package/dist/api/templates/ci.yml.js +10 -3
- package/dist/api/templates/ci.yml.js.map +1 -0
- package/dist/api/templates/index.js +1 -0
- package/dist/api/templates/index.js.map +1 -0
- package/dist/api/templates/js-binding.d.ts +1 -1
- package/dist/api/templates/js-binding.js +306 -108
- package/dist/api/templates/js-binding.js.map +1 -0
- package/dist/api/templates/lib.rs.js +2 -4
- package/dist/api/templates/lib.rs.js.map +1 -0
- package/dist/api/templates/package.json.js +30 -28
- package/dist/api/templates/package.json.js.map +1 -0
- package/dist/api/universalize.js +2 -1
- package/dist/api/universalize.js.map +1 -0
- package/dist/api/version.js +2 -1
- package/dist/api/version.js.map +1 -0
- package/dist/api/wasi-worker-template.d.ts +1 -0
- package/dist/api/wasi-worker-template.js +53 -0
- package/dist/api/wasi-worker-template.js.map +1 -0
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/artifacts.js +1 -0
- package/dist/commands/artifacts.js.map +1 -0
- package/dist/commands/build.js +1 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/create-npm-dirs.js +1 -0
- package/dist/commands/create-npm-dirs.js.map +1 -0
- package/dist/commands/help.js +1 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/new.js +2 -4
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/pre-publish.js +1 -0
- package/dist/commands/pre-publish.js.map +1 -0
- package/dist/commands/rename.js +1 -0
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/universalize.js +1 -0
- package/dist/commands/universalize.js.map +1 -0
- package/dist/commands/version.js +1 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/def/artifacts.d.ts +11 -1
- package/dist/def/artifacts.js +7 -2
- package/dist/def/artifacts.js.map +1 -0
- package/dist/def/build.d.ts +32 -2
- package/dist/def/build.js +23 -2
- package/dist/def/build.js.map +1 -0
- package/dist/def/create-npm-dirs.d.ts +10 -0
- package/dist/def/create-npm-dirs.js +5 -0
- package/dist/def/create-npm-dirs.js.map +1 -0
- package/dist/def/new.d.ts +2 -2
- package/dist/def/new.js +1 -0
- package/dist/def/new.js.map +1 -0
- package/dist/def/pre-publish.d.ts +10 -0
- package/dist/def/pre-publish.js +7 -2
- package/dist/def/pre-publish.js.map +1 -0
- package/dist/def/rename.d.ts +11 -1
- package/dist/def/rename.js +6 -1
- package/dist/def/rename.js.map +1 -0
- package/dist/def/universalize.d.ts +10 -0
- package/dist/def/universalize.js +5 -0
- package/dist/def/universalize.js.map +1 -0
- package/dist/def/version.d.ts +10 -0
- package/dist/def/version.js +5 -0
- package/dist/def/version.js.map +1 -0
- package/dist/index.cjs +3424 -8044
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/__tests__/config.spec.d.ts +1 -0
- package/dist/utils/__tests__/config.spec.js +63 -0
- package/dist/utils/__tests__/config.spec.js.map +1 -0
- package/dist/utils/__tests__/target.spec.js +1 -0
- package/dist/utils/__tests__/target.spec.js.map +1 -0
- package/dist/utils/__tests__/typegen.spec.js +9 -4
- package/dist/utils/__tests__/typegen.spec.js.map +1 -0
- package/dist/utils/__tests__/version.spec.js +1 -0
- package/dist/utils/__tests__/version.spec.js.map +1 -0
- package/dist/utils/cargo.js +1 -0
- package/dist/utils/cargo.js.map +1 -0
- package/dist/utils/ci.js +10 -0
- package/dist/utils/ci.js.map +1 -0
- package/dist/utils/config.d.ts +16 -5
- package/dist/utils/config.js +37 -6
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/log.js +1 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/metadata.js +1 -0
- package/dist/utils/metadata.js.map +1 -0
- package/dist/utils/misc.js +1 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/target.d.ts +6 -5
- package/dist/utils/target.js +15 -1
- package/dist/utils/target.js.map +1 -0
- package/dist/utils/typegen.d.ts +4 -1
- package/dist/utils/typegen.js +27 -6
- package/dist/utils/typegen.js.map +1 -0
- package/dist/utils/version.d.ts +2 -1
- package/dist/utils/version.js +13 -10
- package/dist/utils/version.js.map +1 -0
- package/package.json +48 -15
- package/src/api/artifacts.ts +7 -4
- package/src/api/build.ts +283 -39
- package/src/api/create-npm-dirs.ts +5 -2
- package/src/api/load-wasi-template.ts +62 -0
- package/src/api/new.ts +37 -14
- package/src/api/pre-publish.ts +14 -8
- package/src/api/rename.ts +9 -0
- package/src/api/templates/.gitignore.ts +1 -0
- package/src/api/templates/ci-template.ts +63 -57
- package/src/api/templates/ci.yml.ts +9 -6
- package/src/api/templates/js-binding.ts +299 -104
- package/src/api/templates/lib.rs.ts +1 -4
- package/src/api/templates/package.json.ts +31 -27
- package/src/api/universalize.ts +4 -1
- package/src/api/version.ts +4 -1
- package/src/api/wasi-worker-template.ts +52 -0
- package/src/commands/new.ts +1 -5
- package/src/def/artifacts.ts +12 -3
- package/src/def/build.ts +51 -4
- package/src/def/create-npm-dirs.ts +9 -0
- package/src/def/new.ts +1 -1
- package/src/def/pre-publish.ts +11 -2
- package/src/def/rename.ts +11 -2
- package/src/def/universalize.ts +9 -0
- package/src/def/version.ts +9 -0
- package/src/index.ts +2 -0
- package/src/utils/__tests__/__snapshots__/config.spec.ts.md +97 -0
- package/src/utils/__tests__/__snapshots__/config.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.md +7 -0
- package/src/utils/__tests__/__snapshots__/target.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.md +555 -0
- package/src/utils/__tests__/__snapshots__/typegen.spec.ts.snap +0 -0
- package/src/utils/__tests__/__snapshots__/version.spec.ts.md +9 -8
- package/src/utils/__tests__/__snapshots__/version.spec.ts.snap +0 -0
- package/src/utils/__tests__/config.spec.ts +81 -0
- package/src/utils/__tests__/typegen.spec.ts +19 -4
- package/src/utils/ci.ts +9 -0
- package/src/utils/config.ts +64 -9
- package/src/utils/target.ts +22 -8
- package/src/utils/typegen.ts +30 -5
- package/src/utils/version.ts +11 -9
- package/dist/def/commands/artifacts.d.ts +0 -15
- package/dist/def/commands/artifacts.js +0 -29
- package/dist/def/commands/build.d.ts +0 -53
- package/dist/def/commands/build.js +0 -105
- package/dist/def/commands/create-npm-dirs.d.ts +0 -15
- package/dist/def/commands/create-npm-dirs.js +0 -29
- package/dist/def/commands/new.d.ts +0 -27
- package/dist/def/commands/new.js +0 -53
- package/dist/def/commands/pre-publish.d.ts +0 -23
- package/dist/def/commands/pre-publish.js +0 -45
- package/dist/def/commands/rename.d.ts +0 -25
- package/dist/def/commands/rename.js +0 -49
- package/dist/def/commands/universalize.d.ts +0 -13
- package/dist/def/commands/universalize.js +0 -25
- package/dist/def/commands/version.d.ts +0 -13
- package/dist/def/commands/version.js +0 -25
- package/dist/def/options/artifacts.d.ts +0 -35
- package/dist/def/options/artifacts.js +0 -11
- package/dist/def/options/build.d.ts +0 -97
- package/dist/def/options/build.js +0 -3
- package/dist/def/options/create-npm-dirs.d.ts +0 -35
- package/dist/def/options/create-npm-dirs.js +0 -11
- package/dist/def/options/new.d.ts +0 -79
- package/dist/def/options/new.js +0 -15
- package/dist/def/options/pre-publish.d.ts +0 -65
- package/dist/def/options/pre-publish.js +0 -13
- package/dist/def/options/rename.d.ts +0 -75
- package/dist/def/options/rename.js +0 -11
- package/dist/def/options/universalize.d.ts +0 -28
- package/dist/def/options/universalize.js +0 -10
- package/dist/def/options/version.d.ts +0 -28
- package/dist/def/options/version.js +0 -10
package/src/api/new.ts
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
debugFactory,
|
|
11
11
|
DEFAULT_TARGETS,
|
|
12
12
|
mkdirAsync,
|
|
13
|
+
readdirAsync,
|
|
14
|
+
statAsync,
|
|
13
15
|
writeFileAsync,
|
|
14
16
|
} from '../utils/index.js'
|
|
15
17
|
import { napiEngineRequirement } from '../utils/version.js'
|
|
@@ -69,21 +71,45 @@ export async function newProject(userOptions: RawNewOptions) {
|
|
|
69
71
|
|
|
70
72
|
const outputs = generateFiles(options)
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
debug(`Try to create target directory: ${options.path}`)
|
|
74
|
-
if (!options.dryRun) {
|
|
75
|
-
await mkdirAsync(options.path, { recursive: true })
|
|
76
|
-
}
|
|
77
|
-
} catch (e) {
|
|
78
|
-
throw new Error(`Failed to create target directory: ${options.path}`, {
|
|
79
|
-
cause: e,
|
|
80
|
-
})
|
|
81
|
-
}
|
|
74
|
+
await ensurePath(options.path, options.dryRun)
|
|
82
75
|
|
|
83
76
|
await dumpOutputs(outputs, options.dryRun)
|
|
84
77
|
debug(`Project created at: ${options.path}`)
|
|
85
78
|
}
|
|
86
79
|
|
|
80
|
+
async function ensurePath(path: string, dryRun = false) {
|
|
81
|
+
const stat = await statAsync(path, {}).catch(() => undefined)
|
|
82
|
+
|
|
83
|
+
// file descriptor exists
|
|
84
|
+
if (stat) {
|
|
85
|
+
if (stat.isFile()) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Path ${path} for creating new napi-rs project already exists and it's not a directory.`,
|
|
88
|
+
)
|
|
89
|
+
} else if (stat.isDirectory()) {
|
|
90
|
+
const files = await readdirAsync(path)
|
|
91
|
+
if (files.length) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Path ${path} for creating new napi-rs project already exists and it's not empty.`,
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!dryRun) {
|
|
100
|
+
try {
|
|
101
|
+
debug(`Try to create target directory: ${path}`)
|
|
102
|
+
if (!dryRun) {
|
|
103
|
+
await mkdirAsync(path, { recursive: true })
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
throw new Error(`Failed to create target directory: ${path}`, {
|
|
107
|
+
cause: e,
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
87
113
|
function generateFiles(options: NewOptions): Output[] {
|
|
88
114
|
return [
|
|
89
115
|
generateCargoToml,
|
|
@@ -157,10 +183,7 @@ function generateGithubWorkflow(options: NewOptions): Output | null {
|
|
|
157
183
|
|
|
158
184
|
return {
|
|
159
185
|
target: './.github/workflows/ci.yml',
|
|
160
|
-
content: createGithubActionsCIYml(
|
|
161
|
-
getBinaryName(options.name),
|
|
162
|
-
options.targets,
|
|
163
|
-
),
|
|
186
|
+
content: createGithubActionsCIYml(options.targets),
|
|
164
187
|
}
|
|
165
188
|
}
|
|
166
189
|
|
package/src/api/pre-publish.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execSync } from 'child_process'
|
|
2
2
|
import { existsSync, statSync } from 'fs'
|
|
3
|
-
import { join,
|
|
3
|
+
import { join, resolve } from 'path'
|
|
4
4
|
|
|
5
5
|
import { Octokit } from '@octokit/rest'
|
|
6
6
|
|
|
@@ -31,10 +31,13 @@ export async function prePublish(userOptions: PrePublishOptions) {
|
|
|
31
31
|
|
|
32
32
|
const options = applyDefaultPrePublishOptions(userOptions)
|
|
33
33
|
|
|
34
|
-
const packageJsonPath =
|
|
34
|
+
const packageJsonPath = resolve(options.cwd, options.packageJsonPath)
|
|
35
35
|
|
|
36
36
|
const { packageJson, targets, packageName, binaryName, npmClient } =
|
|
37
|
-
await readNapiConfig(
|
|
37
|
+
await readNapiConfig(
|
|
38
|
+
packageJsonPath,
|
|
39
|
+
options.configPath ? resolve(options.cwd, options.configPath) : undefined,
|
|
40
|
+
)
|
|
38
41
|
|
|
39
42
|
async function createGhRelease(packageName: string, version: string) {
|
|
40
43
|
if (!options.ghRelease) {
|
|
@@ -129,11 +132,14 @@ export async function prePublish(userOptions: PrePublishOptions) {
|
|
|
129
132
|
if (!options.dryRun) {
|
|
130
133
|
await version(userOptions)
|
|
131
134
|
await updatePackageJson(packageJsonPath, {
|
|
132
|
-
optionalDependencies: targets.reduce(
|
|
133
|
-
deps
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
optionalDependencies: targets.reduce(
|
|
136
|
+
(deps, target) => {
|
|
137
|
+
deps[`${packageName}-${target.platformArchABI}`] = packageJson.version
|
|
138
|
+
|
|
139
|
+
return deps
|
|
140
|
+
},
|
|
141
|
+
{} as Record<string, string>,
|
|
142
|
+
),
|
|
137
143
|
})
|
|
138
144
|
}
|
|
139
145
|
|
package/src/api/rename.ts
CHANGED
|
@@ -30,6 +30,15 @@ export async function renameProject(userOptions: RenameOptions) {
|
|
|
30
30
|
},
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
+
if (options.configPath) {
|
|
34
|
+
const configPath = resolve(options.cwd, options.configPath)
|
|
35
|
+
const configContent = await readFileAsync(configPath, 'utf8')
|
|
36
|
+
const configData = JSON.parse(configContent)
|
|
37
|
+
configData.binaryName = options.binaryName
|
|
38
|
+
configData.packageName = options.packageName
|
|
39
|
+
await writeFileAsync(configPath, JSON.stringify(configData, null, 2))
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
await writeFileAsync(
|
|
34
43
|
packageJsonPath,
|
|
35
44
|
JSON.stringify(packageJsonData, null, 2),
|
|
@@ -5,6 +5,10 @@ env:
|
|
|
5
5
|
DEBUG: 'napi:*'
|
|
6
6
|
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
|
7
7
|
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
8
12
|
on:
|
|
9
13
|
push:
|
|
10
14
|
branches:
|
|
@@ -71,7 +75,7 @@ jobs:
|
|
|
71
75
|
sudo apt-get update
|
|
72
76
|
sudo apt-get install gcc-arm-linux-gnueabihf -y
|
|
73
77
|
build: |
|
|
74
|
-
yarn build --platform --target armv7-unknown-linux-gnueabihf
|
|
78
|
+
yarn build --platform --target armv7-unknown-linux-gnueabihf --cross-compile
|
|
75
79
|
arm-linux-gnueabihf-strip *.node
|
|
76
80
|
- host: ubuntu-latest
|
|
77
81
|
target: 'aarch64-linux-android'
|
|
@@ -94,19 +98,26 @@ jobs:
|
|
|
94
98
|
- host: windows-latest
|
|
95
99
|
target: 'aarch64-pc-windows-msvc'
|
|
96
100
|
build: yarn build --platform --target aarch64-pc-windows-msvc
|
|
101
|
+
- host: ubuntu-latest
|
|
102
|
+
target: 'riscv64gc-unknown-linux-gnu'
|
|
103
|
+
setup: |
|
|
104
|
+
sudo apt-get update
|
|
105
|
+
sudo apt-get install gcc-riscv64-linux-gnu -y
|
|
106
|
+
build: |
|
|
107
|
+
yarn build --platform --target riscv64gc-unknown-linux-gnu
|
|
108
|
+
riscv64-linux-gnu-strip *.node
|
|
97
109
|
|
|
98
110
|
name: stable - \${{ matrix.settings.target }} - node@18
|
|
99
111
|
runs-on: \${{ matrix.settings.host }}
|
|
100
112
|
|
|
101
113
|
steps:
|
|
102
|
-
- uses: actions/checkout@
|
|
114
|
+
- uses: actions/checkout@v4
|
|
103
115
|
|
|
104
116
|
- name: Setup node
|
|
105
|
-
uses: actions/setup-node@
|
|
117
|
+
uses: actions/setup-node@v4
|
|
106
118
|
if: \${{ !matrix.settings.docker }}
|
|
107
119
|
with:
|
|
108
120
|
node-version: 18
|
|
109
|
-
check-latest: true
|
|
110
121
|
cache: yarn
|
|
111
122
|
|
|
112
123
|
- name: Install
|
|
@@ -130,7 +141,7 @@ jobs:
|
|
|
130
141
|
- uses: goto-bus-stop/setup-zig@v2
|
|
131
142
|
if: \${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
|
|
132
143
|
with:
|
|
133
|
-
version: 0.
|
|
144
|
+
version: 0.11.0
|
|
134
145
|
|
|
135
146
|
- name: Setup toolchain
|
|
136
147
|
run: \${{ matrix.settings.setup }}
|
|
@@ -146,11 +157,10 @@ jobs:
|
|
|
146
157
|
run: yarn install
|
|
147
158
|
|
|
148
159
|
- name: Setup node x86
|
|
149
|
-
uses: actions/setup-node@
|
|
160
|
+
uses: actions/setup-node@v4
|
|
150
161
|
if: matrix.settings.target == 'i686-pc-windows-msvc'
|
|
151
162
|
with:
|
|
152
163
|
node-version: 18
|
|
153
|
-
check-latest: true
|
|
154
164
|
cache: yarn
|
|
155
165
|
architecture: x86
|
|
156
166
|
|
|
@@ -178,34 +188,32 @@ jobs:
|
|
|
178
188
|
runs-on: macos-12
|
|
179
189
|
name: Build FreeBSD
|
|
180
190
|
steps:
|
|
181
|
-
- uses: actions/checkout@
|
|
191
|
+
- uses: actions/checkout@v4
|
|
182
192
|
- name: Build
|
|
183
193
|
id: build
|
|
184
|
-
uses:
|
|
194
|
+
uses: cross-platform-actions/action@v0.21.0
|
|
185
195
|
env:
|
|
186
196
|
DEBUG: 'napi:*'
|
|
187
|
-
RUSTUP_HOME: /usr/local/rustup
|
|
188
|
-
CARGO_HOME: /usr/local/cargo
|
|
189
197
|
RUSTUP_IO_THREADS: 1
|
|
190
198
|
with:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
199
|
+
operating_system: freebsd
|
|
200
|
+
version: '13.2'
|
|
201
|
+
memory: 13G
|
|
202
|
+
cpu_count: 3
|
|
203
|
+
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
|
|
204
|
+
shell: bash
|
|
194
205
|
prepare: |
|
|
195
|
-
pkg install -y -f curl node libnghttp2
|
|
196
|
-
|
|
197
|
-
npm install --location=global --ignore-scripts yarn
|
|
206
|
+
sudo pkg install -y -f curl node libnghttp2 npm
|
|
207
|
+
sudo npm install -g yarn --ignore-scripts
|
|
198
208
|
curl https://sh.rustup.rs -sSf --output rustup.sh
|
|
199
|
-
sh rustup.sh -y --profile minimal --default-toolchain
|
|
200
|
-
|
|
209
|
+
sh rustup.sh -y --profile minimal --default-toolchain stable
|
|
210
|
+
source "$HOME/.cargo/env"
|
|
201
211
|
echo "~~~~ rustc --version ~~~~"
|
|
202
212
|
rustc --version
|
|
203
213
|
echo "~~~~ node -v ~~~~"
|
|
204
214
|
node -v
|
|
205
215
|
echo "~~~~ yarn --version ~~~~"
|
|
206
216
|
yarn --version
|
|
207
|
-
run: |
|
|
208
|
-
export PATH="/usr/local/cargo/bin:$PATH"
|
|
209
217
|
pwd
|
|
210
218
|
ls -lah
|
|
211
219
|
whoami
|
|
@@ -237,17 +245,16 @@ jobs:
|
|
|
237
245
|
target: 'x86_64-apple-darwin'
|
|
238
246
|
- host: windows-latest
|
|
239
247
|
target: 'x86_64-pc-windows-msvc'
|
|
240
|
-
node: ['
|
|
248
|
+
node: ['18', '20']
|
|
241
249
|
runs-on: \${{ matrix.settings.host }}
|
|
242
250
|
|
|
243
251
|
steps:
|
|
244
|
-
- uses: actions/checkout@
|
|
252
|
+
- uses: actions/checkout@v4
|
|
245
253
|
|
|
246
254
|
- name: Setup node
|
|
247
|
-
uses: actions/setup-node@
|
|
255
|
+
uses: actions/setup-node@v4
|
|
248
256
|
with:
|
|
249
257
|
node-version: \${{ matrix.node }}
|
|
250
|
-
check-latest: true
|
|
251
258
|
cache: 'yarn'
|
|
252
259
|
|
|
253
260
|
- name: 'Install dependencies'
|
|
@@ -273,17 +280,16 @@ jobs:
|
|
|
273
280
|
strategy:
|
|
274
281
|
fail-fast: false
|
|
275
282
|
matrix:
|
|
276
|
-
node: ['
|
|
283
|
+
node: ['18', '20']
|
|
277
284
|
runs-on: ubuntu-latest
|
|
278
285
|
|
|
279
286
|
steps:
|
|
280
|
-
- uses: actions/checkout@
|
|
287
|
+
- uses: actions/checkout@v4
|
|
281
288
|
|
|
282
289
|
- name: Setup node
|
|
283
|
-
uses: actions/setup-node@
|
|
290
|
+
uses: actions/setup-node@v4
|
|
284
291
|
with:
|
|
285
292
|
node-version: \${{ matrix.node }}
|
|
286
|
-
check-latest: true
|
|
287
293
|
cache: 'yarn'
|
|
288
294
|
|
|
289
295
|
- name: 'Install dependencies'
|
|
@@ -309,17 +315,16 @@ jobs:
|
|
|
309
315
|
strategy:
|
|
310
316
|
fail-fast: false
|
|
311
317
|
matrix:
|
|
312
|
-
node: ['
|
|
318
|
+
node: ['18', '20']
|
|
313
319
|
runs-on: ubuntu-latest
|
|
314
320
|
|
|
315
321
|
steps:
|
|
316
|
-
- uses: actions/checkout@
|
|
322
|
+
- uses: actions/checkout@v4
|
|
317
323
|
|
|
318
324
|
- name: Setup node
|
|
319
|
-
uses: actions/setup-node@
|
|
325
|
+
uses: actions/setup-node@v4
|
|
320
326
|
with:
|
|
321
327
|
node-version: \${{ matrix.node }}
|
|
322
|
-
check-latest: true
|
|
323
328
|
cache: 'yarn'
|
|
324
329
|
|
|
325
330
|
- name: 'Install dependencies'
|
|
@@ -347,11 +352,11 @@ jobs:
|
|
|
347
352
|
strategy:
|
|
348
353
|
fail-fast: false
|
|
349
354
|
matrix:
|
|
350
|
-
node: ['
|
|
355
|
+
node: ['18', '20']
|
|
351
356
|
runs-on: ubuntu-latest
|
|
352
357
|
|
|
353
358
|
steps:
|
|
354
|
-
- uses: actions/checkout@
|
|
359
|
+
- uses: actions/checkout@v4
|
|
355
360
|
|
|
356
361
|
- name: Download artifacts
|
|
357
362
|
uses: actions/download-artifact@v3
|
|
@@ -368,9 +373,9 @@ jobs:
|
|
|
368
373
|
yarn config set supportedArchitectures.cpu "arm64"
|
|
369
374
|
yarn config set supportedArchitectures.libc "glibc"
|
|
370
375
|
yarn install
|
|
371
|
-
|
|
376
|
+
|
|
372
377
|
- name: Set up QEMU
|
|
373
|
-
uses: docker/setup-qemu-action@
|
|
378
|
+
uses: docker/setup-qemu-action@v3
|
|
374
379
|
with:
|
|
375
380
|
platforms: arm64
|
|
376
381
|
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
@@ -389,11 +394,15 @@ jobs:
|
|
|
389
394
|
name: Test bindings on aarch64-unknown-linux-musl - node@\${{ matrix.node }}
|
|
390
395
|
needs:
|
|
391
396
|
- build
|
|
397
|
+
strategy:
|
|
398
|
+
fail-fast: false
|
|
399
|
+
matrix:
|
|
400
|
+
node: ['18', '20']
|
|
392
401
|
|
|
393
402
|
runs-on: ubuntu-latest
|
|
394
403
|
|
|
395
404
|
steps:
|
|
396
|
-
- uses: actions/checkout@
|
|
405
|
+
- uses: actions/checkout@v4
|
|
397
406
|
|
|
398
407
|
- name: Download artifacts
|
|
399
408
|
uses: actions/download-artifact@v3
|
|
@@ -412,7 +421,7 @@ jobs:
|
|
|
412
421
|
yarn install
|
|
413
422
|
|
|
414
423
|
- name: Set up QEMU
|
|
415
|
-
uses: docker/setup-qemu-action@
|
|
424
|
+
uses: docker/setup-qemu-action@v3
|
|
416
425
|
with:
|
|
417
426
|
platforms: arm64
|
|
418
427
|
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
@@ -420,7 +429,7 @@ jobs:
|
|
|
420
429
|
- name: Setup and run tests
|
|
421
430
|
uses: addnab/docker-run-action@v3
|
|
422
431
|
with:
|
|
423
|
-
image: node
|
|
432
|
+
image: node:\${{ matrix.node }}-alpine
|
|
424
433
|
options: --platform linux/arm64 -v \${{ github.workspace }}:/build -w /build
|
|
425
434
|
run: |
|
|
426
435
|
set -e
|
|
@@ -433,11 +442,11 @@ jobs:
|
|
|
433
442
|
strategy:
|
|
434
443
|
fail-fast: false
|
|
435
444
|
matrix:
|
|
436
|
-
node: ['
|
|
445
|
+
node: ['18', '20']
|
|
437
446
|
runs-on: ubuntu-latest
|
|
438
447
|
|
|
439
448
|
steps:
|
|
440
|
-
- uses: actions/checkout@
|
|
449
|
+
- uses: actions/checkout@v4
|
|
441
450
|
|
|
442
451
|
- name: Download artifacts
|
|
443
452
|
uses: actions/download-artifact@v3
|
|
@@ -455,7 +464,7 @@ jobs:
|
|
|
455
464
|
yarn install
|
|
456
465
|
|
|
457
466
|
- name: Set up QEMU
|
|
458
|
-
uses: docker/setup-qemu-action@
|
|
467
|
+
uses: docker/setup-qemu-action@v3
|
|
459
468
|
with:
|
|
460
469
|
platforms: arm
|
|
461
470
|
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
@@ -477,13 +486,12 @@ jobs:
|
|
|
477
486
|
runs-on: macos-latest
|
|
478
487
|
|
|
479
488
|
steps:
|
|
480
|
-
- uses: actions/checkout@
|
|
489
|
+
- uses: actions/checkout@v4
|
|
481
490
|
|
|
482
491
|
- name: Setup node
|
|
483
|
-
uses: actions/setup-node@
|
|
492
|
+
uses: actions/setup-node@v4
|
|
484
493
|
with:
|
|
485
494
|
node-version: 18
|
|
486
|
-
check-latest: true
|
|
487
495
|
cache: yarn
|
|
488
496
|
|
|
489
497
|
- name: 'Install dependencies'
|
|
@@ -493,15 +501,15 @@ jobs:
|
|
|
493
501
|
uses: actions/download-artifact@v3
|
|
494
502
|
with:
|
|
495
503
|
name: bindings-x86_64-apple-darwin
|
|
496
|
-
path:
|
|
504
|
+
path: .
|
|
497
505
|
- name: Download macOS arm64 artifact
|
|
498
506
|
uses: actions/download-artifact@v3
|
|
499
507
|
with:
|
|
500
508
|
name: bindings-aarch64-apple-darwin
|
|
501
|
-
path:
|
|
509
|
+
path: .
|
|
502
510
|
|
|
503
511
|
- name: Combine binaries
|
|
504
|
-
run: yarn
|
|
512
|
+
run: yarn napi universalize
|
|
505
513
|
|
|
506
514
|
- name: Upload artifact
|
|
507
515
|
uses: actions/upload-artifact@v3
|
|
@@ -523,14 +531,14 @@ jobs:
|
|
|
523
531
|
- build-freebsd
|
|
524
532
|
|
|
525
533
|
steps:
|
|
526
|
-
- uses: actions/checkout@
|
|
534
|
+
- uses: actions/checkout@v4
|
|
527
535
|
|
|
528
536
|
- name: Setup node
|
|
529
|
-
uses: actions/setup-node@
|
|
537
|
+
uses: actions/setup-node@v4
|
|
530
538
|
with:
|
|
531
539
|
node-version: 18
|
|
532
|
-
check-latest: true
|
|
533
540
|
cache: 'yarn'
|
|
541
|
+
registry-url: 'https://registry.npmjs.org'
|
|
534
542
|
|
|
535
543
|
- name: 'Install dependencies'
|
|
536
544
|
run: yarn install
|
|
@@ -551,16 +559,14 @@ jobs:
|
|
|
551
559
|
run: |
|
|
552
560
|
if git log -1 --pretty=%B | grep "^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$";
|
|
553
561
|
then
|
|
554
|
-
|
|
555
|
-
npm publish --access public
|
|
562
|
+
npm publish --access public --provenance
|
|
556
563
|
elif git log -1 --pretty=%B | grep "^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+";
|
|
557
564
|
then
|
|
558
|
-
|
|
559
|
-
npm publish --tag next --access public
|
|
565
|
+
npm publish --tag next --access public --provenance
|
|
560
566
|
else
|
|
561
567
|
echo "Not a release, skipping publish"
|
|
562
568
|
fi
|
|
563
569
|
env:
|
|
564
570
|
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
|
|
565
|
-
|
|
571
|
+
NODE_AUTH_TOKEN: \${{ secrets.NPM_TOKEN }}
|
|
566
572
|
`
|
|
@@ -17,10 +17,7 @@ const TEST_LINUX_AARCH64_MUSL = 'test-linux-aarch64-musl-binding'
|
|
|
17
17
|
const TEST_LINUX_ARM_GNUEABIHF = 'test-linux-arm-gnueabihf-binding'
|
|
18
18
|
const UNIVERSAL_MACOS = 'universal-macOS'
|
|
19
19
|
|
|
20
|
-
export const createGithubActionsCIYml = (
|
|
21
|
-
binaryName: string,
|
|
22
|
-
targets: string[],
|
|
23
|
-
) => {
|
|
20
|
+
export const createGithubActionsCIYml = (targets: string[]) => {
|
|
24
21
|
const allTargets = new Set(
|
|
25
22
|
targets.flatMap((t) => {
|
|
26
23
|
const platform = parseTriple(t)
|
|
@@ -63,10 +60,16 @@ export const createGithubActionsCIYml = (
|
|
|
63
60
|
if (!enableWindowsX86 && !enableMacOSX86) {
|
|
64
61
|
delete fullTemplate.jobs[TEST_MACOS_WINDOWS]
|
|
65
62
|
} else {
|
|
66
|
-
const
|
|
63
|
+
const filterTargets = new Set<string>()
|
|
64
|
+
if (enableWindowsX86) {
|
|
65
|
+
filterTargets.add('windows-latest')
|
|
66
|
+
}
|
|
67
|
+
if (enableMacOSUni || enableMacOSX86) {
|
|
68
|
+
filterTargets.add('macos-latest')
|
|
69
|
+
}
|
|
67
70
|
fullTemplate.jobs[TEST_MACOS_WINDOWS].strategy.matrix.settings =
|
|
68
71
|
fullTemplate.jobs[TEST_MACOS_WINDOWS].strategy.matrix.settings.filter(
|
|
69
|
-
({ host }: { host: string; target: string }) => host
|
|
72
|
+
({ host }: { host: string; target: string }) => filterTargets.has(host),
|
|
70
73
|
)
|
|
71
74
|
|
|
72
75
|
requiredSteps.push(TEST_MACOS_WINDOWS)
|