@napi-rs/cli 3.0.0-alpha.29 → 3.0.0-alpha.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/cli",
3
- "version": "3.0.0-alpha.29",
3
+ "version": "3.0.0-alpha.30",
4
4
  "description": "Cli tools for napi-rs",
5
5
  "author": "LongYinan <lynweklm@gmail.com>",
6
6
  "homepage": "https://github.com/napi-rs/napi-rs",
@@ -77,6 +77,7 @@
77
77
  "inquirer": "^9.2.12",
78
78
  "js-yaml": "^4.1.0",
79
79
  "lodash-es": "^4.17.21",
80
+ "semver": "^7.5.4",
80
81
  "toml": "^3.0.0",
81
82
  "typanion": "^3.14.0"
82
83
  },
@@ -130,5 +131,5 @@
130
131
  "**/__tests__/**/*.spec.ts"
131
132
  ]
132
133
  },
133
- "gitHead": "8e3e688c28cbcdb6c8db447b6c10419e0eab845d"
134
+ "gitHead": "1392954c32a08d38ca6110899c8b9ce39da1f57e"
134
135
  }
@@ -1,5 +1,7 @@
1
1
  import { join, resolve } from 'node:path'
2
2
 
3
+ import { parse } from 'semver'
4
+
3
5
  import {
4
6
  applyDefaultCreateNpmDirsOptions,
5
7
  CreateNpmDirsOptions,
@@ -88,6 +90,24 @@ export async function createNpmDirs(userOptions: CreateNpmDirsOptions) {
88
90
  const entry = `${binaryName}.wasi.cjs`
89
91
  scopedPackageJson.files.push(entry, `wasi-worker.mjs`)
90
92
  scopedPackageJson.main = entry
93
+ let needRestrictNodeVersion = true
94
+ if (scopedPackageJson.engines?.node) {
95
+ try {
96
+ const { major } = parse(scopedPackageJson.engines.node) ?? {
97
+ major: 0,
98
+ }
99
+ if (major >= 14) {
100
+ needRestrictNodeVersion = false
101
+ }
102
+ } catch {
103
+ // ignore
104
+ }
105
+ }
106
+ if (needRestrictNodeVersion) {
107
+ scopedPackageJson.engines = {
108
+ node: '>=14.0.0',
109
+ }
110
+ }
91
111
  const emnapiCore = await fetch(
92
112
  `https://registry.npmjs.org/@emnapi/core`,
93
113
  ).then((res) => res.json() as Promise<PackageMeta>)
@@ -192,7 +192,8 @@ export async function prePublish(userOptions: PrePublishOptions) {
192
192
  'content-length': dstFileStats.size,
193
193
  'content-type': 'application/octet-stream',
194
194
  },
195
- data: await readFileAsync(dstPath, { encoding: 'utf-8' }),
195
+ // @ts-expect-error octokit types are wrong
196
+ data: await readFileAsync(dstPath),
196
197
  })
197
198
  debug.info(`GitHub release created`)
198
199
  debug.info(`Download URL: %s`, assetInfo.data.browser_download_url)
@@ -317,6 +317,13 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
317
317
  } catch {
318
318
  // ignore
319
319
  }
320
+ if (!nativeBinding) {
321
+ try {
322
+ nativeBinding = require('${pkgName}-wasm32-wasi')
323
+ } catch (err) {
324
+ console.error(err)
325
+ }
326
+ }
320
327
  }
321
328
 
322
329
  if (!nativeBinding) {