From 95c56eac8b425216526644940d12963e5163f248 Mon Sep 17 00:00:00 2001 From: Ayush C <14110965+ayushmanchhabra@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:04:46 -0500 Subject: [PATCH] docs: disable `options.nativeAddon` (#996) --- src/bld.js | 9 ++++++ src/index.js | 76 +++++++++++++++++++++----------------------- src/util.js | 16 +++++----- src/util/parse.js | 9 +++--- test/fixture/demo.js | 7 ++-- 5 files changed, 63 insertions(+), 54 deletions(-) diff --git a/src/bld.js b/src/bld.js index 5f0a39ad1..d8b6b7199 100644 --- a/src/bld.js +++ b/src/bld.js @@ -137,6 +137,15 @@ import util from "./util.js" * }); * * @example + * // Rebuild Node native modules + * // This behaviour is currently disabled. + * // Tracking issue: https://github.com/nwutils/nw-builder/pull/993 + * nwbuild({ + * mode: "build", + * nodeAddon: "gyp" + * }); + * + * @example * // For MacOS ARM unofficial builds (<= v0.75), remove quarantine flag post build. * sudo xattr -r -d com.apple.quarantine /path/to/nwjs.app * diff --git a/src/index.js b/src/index.js index 37a1040d9..5eabc564d 100644 --- a/src/index.js +++ b/src/index.js @@ -79,20 +79,18 @@ const nwbuild = async (options) => { let releaseInfo = {}; let manifest = {}; - const { version, flavor, platform, arch, downloadUrl, manifestUrl, srcDir, cacheDir, outDir, app, glob, managedManifest, nativeAddon, zip, argv, cache, ffmpeg } = options; - try { // Parse options options = await parse(options, manifest); - manifest = await util.getNodeManifest({ srcDir, glob }); + manifest = await util.getNodeManifest({ srcDir: srcDir, glob: glob }); if (typeof manifest?.nwbuild === "object") { options = manifest.nwbuild; } options = await parse(options, manifest); - //TODO: impl loggging + //TODO: impl logging built = fs.existsSync(options.cacheDir); if (built === false) { @@ -108,11 +106,11 @@ const nwbuild = async (options) => { // Validate options.version to get the version specific release info releaseInfo = await util.getReleaseInfo( - version, - platform, - arch, - cacheDir, - manifestUrl, + options.version, + options.platform, + options.arch, + options.cacheDir, + options.manifestUrl, ); await validate(options, releaseInfo); @@ -122,15 +120,15 @@ const nwbuild = async (options) => { // Download binaries await get({ - version, - flavor, - platform, - arch, - downloadUrl, - cacheDir, - cache, - ffmpeg, - nativeAddon, + version: options.version, + flavor: options.flavor, + platform: options.platform, + arch: options.arch, + downloadUrl: options.downloadUrl, + cacheDir: options.cacheDir, + cache: options.cache, + ffmpeg: options.ffmpeg, + nativeAddon: options.nativeAddon, }); if (options.mode === "get") { @@ -140,30 +138,30 @@ const nwbuild = async (options) => { if (options.mode === "run") { await run({ - version, - flavor, - platform, - arch, - srcDir, - cacheDir, - glob, - argv, + version: options.version, + flavor: options.flavor, + platform: options.platform, + arch: options.arch, + srcDir: options.srcDir, + cacheDir: options.cacheDir, + glob: options.glob, + argv: options.argv, }); } else if (options.mode === "build") { await bld({ - version, - flavor, - platform, - arch, - manifestUrl, - srcDir, - cacheDir, - outDir, - app, - glob, - managedManifest, - nativeAddon, - zip, + version: options.version, + flavor: options.flavor, + platform: options.platform, + arch: options.arch, + manifestUrl: options.manifestUrl, + srcDir: options.srcDir, + cacheDir: options.cacheDir, + outDir: options.outDir, + app: options.app, + glob: options.glob, + managedManifest: options.managedManifest, + nativeAddon: options.nativeAddon, + zip: options.zip, }); } } catch (error) { diff --git a/src/util.js b/src/util.js index bb9a8efa8..aa840fd68 100644 --- a/src/util.js +++ b/src/util.js @@ -14,24 +14,24 @@ import * as GlobModule from "glob"; function getManifest(manifestUrl) { let chunks = undefined; - return new Promise((res) => { - const req = https.get(manifestUrl, (res) => { - res.on("data", (chunk) => { + return new Promise((resolve) => { + const req = https.get(manifestUrl, (response) => { + response.on("data", (chunk) => { chunks += chunk; }); - res.on("error", (e) => { + response.on("error", (e) => { console.error(e); - res(undefined); + resolve(undefined); }); - res.on("end", () => { - res(chunks); + response.on("end", () => { + resolve(chunks); }); }); req.on("error", (e) => { console.error(e); - res(undefined); + resolve(undefined); }); }); } diff --git a/src/util/parse.js b/src/util/parse.js index 89cc22133..d43263b29 100644 --- a/src/util/parse.js +++ b/src/util/parse.js @@ -1,7 +1,7 @@ import { resolve } from "node:path"; import { arch, platform } from "node:process"; -import { ARCH_KV, PLATFORM_KV } from "../util.js"; +import util from "../util.js"; /** * Parse options @@ -16,8 +16,8 @@ export const parse = async (options, pkg) => { options.version = options.version ?? "latest"; options.flavor = options.flavor ?? "normal"; - options.platform = options.platform ?? PLATFORM_KV(platform); - options.arch = options.arch ?? ARCH_KV(arch); + options.platform = options.platform ?? util.PLATFORM_KV[platform]; + options.arch = options.arch ?? util.ARCH_KV[arch]; options.downloadUrl = options.downloadUrl ?? "https://dl.nwjs.io"; options.manifestUrl = options.manifestUrl ?? "https://nwjs.io/versions"; options.cacheDir = options.cacheDir ?? "./cache"; @@ -41,7 +41,8 @@ export const parse = async (options, pkg) => { options.zip = options.zip ?? false; options.managedManifest = options.managedManifest ?? false; - options.nativeAddon = options.nativeAddon ?? false; + // Node Native addons are disabled for now. See https://github.com/nwutils/nw-builder/pull/993 + options.nativeAddon = false; options.app = options.app ?? {}; options.app.name = options.app.name ?? pkg.name; diff --git a/test/fixture/demo.js b/test/fixture/demo.js index c74e7b068..860a86e3d 100644 --- a/test/fixture/demo.js +++ b/test/fixture/demo.js @@ -1,7 +1,8 @@ import nwbuild from "nw-builder"; await nwbuild({ - srcDir: "app", - mode: "build", - glob: false, + mode: "get", + flavor: "sdk", + platform: "osx", + srcDir: "app" });