From 7633e3343ebcdb04b8e8ec3c0365057a34956f2c Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra Date: Thu, 24 Aug 2023 11:12:09 -0400 Subject: [PATCH 01/17] build(compressing): bump to v1.10.0 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 62e466520..273a016ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "cli-progress": "^3.12.0", - "compressing": "^1.9.0", + "compressing": "^1.10.0", "glob": "^10.3.3", "plist": "^3.1.0", "rcedit": "^3.0.1", @@ -1784,9 +1784,9 @@ "dev": true }, "node_modules/compressing": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/compressing/-/compressing-1.9.1.tgz", - "integrity": "sha512-5fyyxjvFRbY7/FEzmqUTSXQdyUA+ETsBEjLHqsYnWbZrZbE7aqyiHCGWHWYD1Xpq83O2b4geN0ctDccRyRjZwg==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/compressing/-/compressing-1.10.0.tgz", + "integrity": "sha512-k2vpbZLaJoHe9euyUZjYYE8vOrbR19aU3HcWIYw5EBXiUs34ygfDVnXU+ubI41JXMriHutnoiu0ZFdwCkH6jPA==", "dependencies": { "@eggjs/yauzl": "^2.11.0", "flushwritable": "^1.0.0", diff --git a/package.json b/package.json index 3482a30e2..7e2f948e7 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "cli-progress": "^3.12.0", - "compressing": "^1.9.0", + "compressing": "^1.10.0", "glob": "^10.3.3", "plist": "^3.1.0", "rcedit": "^3.0.1", From 363380ddb8f72ddc0fb92c950aa5484ca9e87a47 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra Date: Thu, 24 Aug 2023 11:12:43 -0400 Subject: [PATCH 02/17] fix(get): remove symbolic links workaround --- src/get.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/get.js b/src/get.js index 893f49ea3..6ee3c1dd5 100644 --- a/src/get.js +++ b/src/get.js @@ -10,7 +10,6 @@ import compressing from "compressing"; import { log } from "./log.js"; import { PLATFORM_KV, ARCH_KV } from "./util.js"; import { replaceFfmpeg } from "./util/ffmpeg.js"; -import child_process from "child_process"; /** * _Note: This an internal function which is not called directly. Please see example usage below._ @@ -163,22 +162,6 @@ export async function get({ compressing.tgz .uncompress(out, ffmpeg ? nwDir : cacheDir) .then(() => resolve()); - } else if (platform === "osx") { - //TODO: compressing package does not restore symlinks on some macOS (eg: circleCI) - const exec = function (cmd) { - log.debug(cmd); - const result = child_process.spawnSync(cmd, { - shell: true, - stdio: "inherit", - }); - if (result.status !== 0) { - log.debug(`Command failed with status ${result.status}`); - if (result.error) console.log(result.error); - process.exit(1); - } - return resolve(); - }; - exec(`unzip -o "${out}" -d "${ffmpeg ? nwDir : cacheDir}"`); } else { compressing.zip .uncompress(out, ffmpeg ? nwDir : cacheDir) From f125be459462e3a359b7d81f0aeea46bcce257f5 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra Date: Thu, 24 Aug 2023 11:13:38 -0400 Subject: [PATCH 03/17] ci: remove `Install Package` GHA --- .github/workflows/e2e.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 86adcfdeb..7d715358a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -19,10 +19,6 @@ jobs: run: shell: ${{ matrix.shell }} steps: - - name: Install packages - uses: ConorMacBride/install-package@v1.1.0 - with: - brew: unzip - name: Checkout repository uses: actions/checkout@v3.3.0 - name: Setup Node From 4f6f9340a608e82bd10e26239f7c160b1f38d840 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Tue, 3 Oct 2023 19:50:53 -0400 Subject: [PATCH 04/17] do not rely on unzip --- src/get.js | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/get.js b/src/get.js index a6c3f9302..489e7d56e 100644 --- a/src/get.js +++ b/src/get.js @@ -182,7 +182,7 @@ async function get_nwjs({ log.debug(`Response from ${url}`); let chunks = 0; bar.start(Number(response.headers["content-length"]), 0); - response.on("data", async (chunk) => { + response.on("data", (chunk) => { chunks += chunk.length; bar.increment(); bar.update(chunks); @@ -197,22 +197,6 @@ async function get_nwjs({ bar.stop(); if (platform === "linux") { compressing.tgz.uncompress(out, cacheDir).then(() => resolve()); - } else if (platform === "osx") { - //TODO: compressing package does not restore symlinks on some macOS (eg: circleCI) - const exec = function (cmd) { - log.debug(cmd); - const result = spawnSync(cmd, { - shell: true, - stdio: "inherit", - }); - if (result.status !== 0) { - log.debug(`Command failed with status ${result.status}`); - if (result.error) console.log(result.error); - EXIT(1); - } - return resolve(); - }; - exec(`unzip -o "${out}" -d "${cacheDir}"`); } else { compressing.zip.uncompress(out, cacheDir).then(() => resolve()); } @@ -329,7 +313,7 @@ async function get_ffmpeg({ log.debug(`Response from ${url}`); let chunks = 0; bar.start(Number(response.headers["content-length"]), 0); - response.on("data", async (chunk) => { + response.on("data", (chunk) => { chunks += chunk.length; bar.increment(); bar.update(chunks); From 1f7a4f827ce94ac5f724973a3f349d150c54429a Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Tue, 3 Oct 2023 19:53:00 -0400 Subject: [PATCH 05/17] fix: lint --- src/get.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/get.js b/src/get.js index 489e7d56e..270b443f7 100644 --- a/src/get.js +++ b/src/get.js @@ -1,9 +1,8 @@ -import { spawnSync } from "node:child_process"; import { createWriteStream, existsSync } from "node:fs"; import { mkdir, readdir, rm, rmdir } from "node:fs/promises"; import { get as getRequest } from "node:https"; import { resolve } from "node:path"; -import { arch as ARCH, platform as PLATFORM, exit as EXIT } from "node:process"; +import { arch as ARCH, platform as PLATFORM } from "node:process"; import progress from "cli-progress"; import compressing from "compressing"; From fac439db2552a937a8dd1db31fb915af3603494e Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:13:58 -0400 Subject: [PATCH 06/17] build(compressing): use `yauzl-promise` to unzip MacOS build on MacOS platform --- package-lock.json | 384 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 3 +- src/get.js | 34 +++- 3 files changed, 409 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index bc40208f7..d994bf9d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,8 @@ "plist": "^3.1.0", "rcedit": "^4.0.0", "winston": "^3.10.0", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "yauzl-promise": "^4.0.0" }, "bin": { "nwbuild": "src/cli.js" @@ -234,7 +235,6 @@ "version": "7.22.15", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.15.tgz", "integrity": "sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==", - "dev": true, "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -873,6 +873,228 @@ "node": ">= 10" } }, + "node_modules/@node-rs/crc32": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32/-/crc32-1.7.2.tgz", + "integrity": "sha512-SmWxRftq+zYSv4qfhdFHM8ruBqY8eVTnIs43dFUWAyD0x6a7LpzNd8KHWqKxlaly8QGpGxBv2Dol/3gs5DeknA==", + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "optionalDependencies": { + "@node-rs/crc32-android-arm-eabi": "1.7.2", + "@node-rs/crc32-android-arm64": "1.7.2", + "@node-rs/crc32-darwin-arm64": "1.7.2", + "@node-rs/crc32-darwin-x64": "1.7.2", + "@node-rs/crc32-freebsd-x64": "1.7.2", + "@node-rs/crc32-linux-arm-gnueabihf": "1.7.2", + "@node-rs/crc32-linux-arm64-gnu": "1.7.2", + "@node-rs/crc32-linux-arm64-musl": "1.7.2", + "@node-rs/crc32-linux-x64-gnu": "1.7.2", + "@node-rs/crc32-linux-x64-musl": "1.7.2", + "@node-rs/crc32-win32-arm64-msvc": "1.7.2", + "@node-rs/crc32-win32-ia32-msvc": "1.7.2", + "@node-rs/crc32-win32-x64-msvc": "1.7.2" + } + }, + "node_modules/@node-rs/crc32-android-arm-eabi": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-android-arm-eabi/-/crc32-android-arm-eabi-1.7.2.tgz", + "integrity": "sha512-6IoXQTHt9U/1Ejz/MPbAk3mtcAGcS1WUvg2YfEtezLCmzbDpQO3OTA9fZpu3z2AhBuLHiKMKDVcfrWybRiWBJw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-android-arm64": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-android-arm64/-/crc32-android-arm64-1.7.2.tgz", + "integrity": "sha512-SMEd6cN+034LTv9kFmCGMZjBNTf39xXIcgqq05JM9A55ywUvXdoXnFOttrQ9x/iZgqANNU6Ms5uZCAJbNA2dZA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-darwin-arm64": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-darwin-arm64/-/crc32-darwin-arm64-1.7.2.tgz", + "integrity": "sha512-sPJisK5pyZ+iBs9KuGsvu0Z+Qshw4GvOgaHjPktQ+suz0p00Yts3zl5D6PpGaaW4EAKTo8zCUIlVEArV0vglvw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-darwin-x64": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-darwin-x64/-/crc32-darwin-x64-1.7.2.tgz", + "integrity": "sha512-+/lgHYJaZdXU+7fhGYTnXvGkeSqZE3UwPyKAUO5YSL0nIpFHMybZMnvqjcoxrfx0QfMFOwVEbd7vfVh+1GpwhA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-freebsd-x64": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-freebsd-x64/-/crc32-freebsd-x64-1.7.2.tgz", + "integrity": "sha512-OgkxnkiGdztcBilm7m31Sb6zx89ghK4WpZz9WVVU86PIHQH0sfrZEebdomw6R7mMnQuqbnRwjTS5r1nchVMPzQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-linux-arm-gnueabihf": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-linux-arm-gnueabihf/-/crc32-linux-arm-gnueabihf-1.7.2.tgz", + "integrity": "sha512-hTY83MQML8WrMnD3dmzjrcCn0Sqgw0w2wRc1Ji2dCaE0fDqra47W5KBQXx4hKZYFwNr5KreTqdvD3Ejf/mKzEA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-linux-arm64-gnu": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-linux-arm64-gnu/-/crc32-linux-arm64-gnu-1.7.2.tgz", + "integrity": "sha512-4p6DZ9YT+CBSi+72OclzI5hBin15brqrbLLHFePPl4AhAazg6+ReTv3C4DnyJqyL0ZHZamiA9zDtOlvHo0nk0Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-linux-arm64-musl": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-linux-arm64-musl/-/crc32-linux-arm64-musl-1.7.2.tgz", + "integrity": "sha512-/shZkkNyDyDjaxU5rYFY4aoajLjBqdfKQYZCcA6XS27FiGzHQ3petgP0I5Zjm+Jf75G7gLT8NQXiQWIzkgo2xw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-linux-x64-gnu": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-linux-x64-gnu/-/crc32-linux-x64-gnu-1.7.2.tgz", + "integrity": "sha512-rzoqXqPLjx5sx8jzEg/xRAdBDkjnaM+D3Nrm9xJckHWzeeUB0FC0E4QGrdtqFo15lQ1GDVV/q6n93mLSK5vCkQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-linux-x64-musl": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-linux-x64-musl/-/crc32-linux-x64-musl-1.7.2.tgz", + "integrity": "sha512-Hwim1Wc8LoNqG53qX8Dm3VY32ClbKWpdi9pkbJU4/aG5RFUfd3k/x9WSeATlBx+K36Tc1XsrWvbsf1eWwryEYA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-win32-arm64-msvc": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-win32-arm64-msvc/-/crc32-win32-arm64-msvc-1.7.2.tgz", + "integrity": "sha512-vj+HWzwy86wNBY+1vW+QPje/MrJppufGCYIisFwvghBzk6WtClNGEjbQqotieIxDNohcmHREQEeg8wY8PMCvew==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-win32-ia32-msvc": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-win32-ia32-msvc/-/crc32-win32-ia32-msvc-1.7.2.tgz", + "integrity": "sha512-YQQtPkHvqbMEJmaMzEH3diYHk0q9zWb+Tkzij9d4OZZzpt4HM6j8FuiIB37BJ0CQmgMiDZEBYsX3KOfYxxO0VA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@node-rs/crc32-win32-x64-msvc": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/@node-rs/crc32-win32-x64-msvc/-/crc32-win32-x64-msvc-1.7.2.tgz", + "integrity": "sha512-DnluAFM6X8qsYVI1VaFQtI6ukigIQ2P4eVcEuNQ3d1lF5fs0RYAKY7Ajqrdk298TSGZ2joMiqfJksTHBsQoxtA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1969,6 +2191,35 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/define-data-property": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.0.tgz", + "integrity": "sha512-UzGwzcjyv3OtAvolTj1GoyNYzfFR+iqbGjcnBEENZVCpM4/Ng1yhGNvS3lR/xDS74Tb2wGG9WzNSNIOS9UVb2g==", + "dependencies": { + "get-intrinsic": "^1.2.1", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/dmd": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/dmd/-/dmd-6.2.0.tgz", @@ -2554,6 +2805,11 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -2562,6 +2818,20 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-intrinsic": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", + "integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==", + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/get-ready": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/get-ready/-/get-ready-1.0.0.tgz", @@ -2659,6 +2929,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/globby": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", @@ -2695,6 +2979,17 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -2728,6 +3023,14 @@ "uglify-js": "^3.1.4" } }, + "node_modules/has": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.4.tgz", + "integrity": "sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==", + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -2737,6 +3040,39 @@ "node": ">=8" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dependencies": { + "get-intrinsic": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/iconv-lite": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.2.tgz", @@ -2866,6 +3202,18 @@ "node": ">=0.10.0" } }, + "node_modules/is-it-type": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/is-it-type/-/is-it-type-5.1.2.tgz", + "integrity": "sha512-q/gOZQTNYABAxaXWnBKZjTFH4yACvWEFtgVOj+LbgxYIgAJG1xVmUZOsECSrZPIemYUQvaQWVilSFVbh4Eyt8A==", + "dependencies": { + "@babel/runtime": "^7.16.7", + "globalthis": "^1.0.2" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -3423,6 +3771,14 @@ "integrity": "sha512-7n4IpLMzGGcLEMiQKsNR7vCe+N5E9LORFrtNUVy4sO3dj9a3HedZCxEL2T7QuLhcHN1NBuBsMOKaOsAYI9IIvg==", "dev": true }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/object-to-spawn-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object-to-spawn-args/-/object-to-spawn-args-2.0.1.tgz", @@ -3906,8 +4262,7 @@ "node_modules/regenerator-runtime": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz", - "integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==", - "dev": true + "integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==" }, "node_modules/require-directory": { "version": "2.1.1", @@ -4151,6 +4506,14 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/simple-invariant": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/simple-invariant/-/simple-invariant-2.0.1.tgz", + "integrity": "sha512-1sbhsxqI+I2tqlmjbz99GXNmZtr6tKIyEgGGnJw/MKGblalqk/XoOYYFJlBzTKZCxx8kLaD3FD5s9BEEjx5Pyg==", + "engines": { + "node": ">=10" + } + }, "node_modules/simple-swizzle": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", @@ -5036,6 +5399,19 @@ "node": ">=12" } }, + "node_modules/yauzl-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yauzl-promise/-/yauzl-promise-4.0.0.tgz", + "integrity": "sha512-/HCXpyHXJQQHvFq9noqrjfa/WpQC2XYs3vI7tBiAi4QiIU1knvYhZGaO1QPjwIVMdqflxbmwgMXtYeaRiAE0CA==", + "dependencies": { + "@node-rs/crc32": "^1.7.0", + "is-it-type": "^5.1.2", + "simple-invariant": "^2.0.1" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/yazl": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/yazl/-/yazl-2.5.1.tgz", diff --git a/package.json b/package.json index 74d7c3040..7c2c701f3 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,8 @@ "plist": "^3.1.0", "rcedit": "^4.0.0", "winston": "^3.10.0", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "yauzl-promise": "^4.0.0" }, "packageManager": "npm@9.8.1", "engines": { diff --git a/src/get.js b/src/get.js index 270b443f7..d3225dbf3 100644 --- a/src/get.js +++ b/src/get.js @@ -3,9 +3,11 @@ import { mkdir, readdir, rm, rmdir } from "node:fs/promises"; import { get as getRequest } from "node:https"; import { resolve } from "node:path"; import { arch as ARCH, platform as PLATFORM } from "node:process"; +import { pipeline } from "node:stream/promises"; import progress from "cli-progress"; import compressing from "compressing"; +import yauzl from "yauzl-promise"; import { log } from "./log.js"; import { PLATFORM_KV, ARCH_KV } from "./util.js"; @@ -137,11 +139,9 @@ async function get_nwjs({ downloadUrl === "https://npm.taobao.org/mirrors/nwjs" || downloadUrl === "https://npmmirror.com/mirrors/nwjs" ) { - url = `${downloadUrl}/v${version}/nwjs${ - flavor === "sdk" ? "-sdk" : "" - }-v${version}-${platform}-${arch}.${ - platform === "linux" ? "tar.gz" : "zip" - }`; + url = `${downloadUrl}/v${version}/nwjs${flavor === "sdk" ? "-sdk" : "" + }-v${version}-${platform}-${arch}.${platform === "linux" ? "tar.gz" : "zip" + }`; out = resolve(cacheDir, `nw.${platform === "linux" ? "tgz" : "zip"}`); } @@ -191,13 +191,33 @@ async function get_nwjs({ reject(error); }); - response.on("end", () => { + response.on("end", async () => { log.debug(`Binary fully downloaded`); bar.stop(); if (platform === "linux") { compressing.tgz.uncompress(out, cacheDir).then(() => resolve()); } else { - compressing.zip.uncompress(out, cacheDir).then(() => resolve()); + // Symlinks are copied as files during decompress of MacOS zip on MacOS platform. + if (platform === "osx" && PLATFORM === "darwin") { + const zip = await yauzl.open(out); + try { + for await (const entry of zip) { + if (entry.filename.endsWith('/')) { + await fs.promises.mkdir(`${cacheDir}/${entry.filename}`); + } else { + const readStream = await entry.openReadStream(); + const writeStream = createWriteStream( + `${cacheDir}/${entry.filename}` + ); + await pipeline(readStream, writeStream); + } + } + } finally { + await zip.close(); + } + } else { + compressing.zip.uncompress(out, cacheDir).then(() => resolve()); + } } }); From f5477c2fb49094eb40bb082b62289780d637695e Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:17:48 -0400 Subject: [PATCH 07/17] fix: format and lint --- src/get.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/get.js b/src/get.js index d3225dbf3..49cbab323 100644 --- a/src/get.js +++ b/src/get.js @@ -139,9 +139,11 @@ async function get_nwjs({ downloadUrl === "https://npm.taobao.org/mirrors/nwjs" || downloadUrl === "https://npmmirror.com/mirrors/nwjs" ) { - url = `${downloadUrl}/v${version}/nwjs${flavor === "sdk" ? "-sdk" : "" - }-v${version}-${platform}-${arch}.${platform === "linux" ? "tar.gz" : "zip" - }`; + url = `${downloadUrl}/v${version}/nwjs${ + flavor === "sdk" ? "-sdk" : "" + }-v${version}-${platform}-${arch}.${ + platform === "linux" ? "tar.gz" : "zip" + }`; out = resolve(cacheDir, `nw.${platform === "linux" ? "tgz" : "zip"}`); } @@ -202,12 +204,12 @@ async function get_nwjs({ const zip = await yauzl.open(out); try { for await (const entry of zip) { - if (entry.filename.endsWith('/')) { - await fs.promises.mkdir(`${cacheDir}/${entry.filename}`); + if (entry.filename.endsWith("/")) { + await mkdir(`${cacheDir}/${entry.filename}`); } else { const readStream = await entry.openReadStream(); const writeStream = createWriteStream( - `${cacheDir}/${entry.filename}` + `${cacheDir}/${entry.filename}`, ); await pipeline(readStream, writeStream); } From 456fe58f38429925755af48b2f7241ed02d373af Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:26:36 -0400 Subject: [PATCH 08/17] fix(npm): `engines.node` versions --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d994bf9d2..914d375b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "vitepress": "^1.0.0-rc.20" }, "engines": { - "node": ">= v16.20.1 || >= v18.18.0 || >= v20.7.0" + "node": "^16.20.1 || ^18.18.0 || >= v20.7.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 7c2c701f3..ea440918e 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,6 @@ }, "packageManager": "npm@9.8.1", "engines": { - "node": ">= v16.20.1 || >= v18.18.0 || >= v20.7.0" + "node": "^16.20.1 || ^18.18.0 || >= v20.7.0" } } From fb7645eaa246ebd3ac90c941be17f4f1ed9603cc Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Thu, 5 Oct 2023 01:54:08 -0400 Subject: [PATCH 09/17] docs: clarify `yauzl-promise` usage --- src/get.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/get.js b/src/get.js index 49cbab323..59bf34ee2 100644 --- a/src/get.js +++ b/src/get.js @@ -199,7 +199,8 @@ async function get_nwjs({ if (platform === "linux") { compressing.tgz.uncompress(out, cacheDir).then(() => resolve()); } else { - // Symlinks are copied as files during decompress of MacOS zip on MacOS platform. + // For MacOS build on MacOS platform, Symlinks are copied as files during `compressing.zip.uncompress`. + // We instead use yauzl-promise for this specific build and platform. if (platform === "osx" && PLATFORM === "darwin") { const zip = await yauzl.open(out); try { From b0ca0cdb377899f345b647cfc3bd49b2c8126297 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Thu, 5 Oct 2023 01:55:51 -0400 Subject: [PATCH 10/17] build(node): update current version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 914d375b7..15baf93c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "vitepress": "^1.0.0-rc.20" }, "engines": { - "node": "^16.20.1 || ^18.18.0 || >= v20.7.0" + "node": "^16.20.1 || ^18.18.0 || >= v20.8.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index ea440918e..07ec73164 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,6 @@ }, "packageManager": "npm@9.8.1", "engines": { - "node": "^16.20.1 || ^18.18.0 || >= v20.7.0" + "node": "^16.20.1 || ^18.18.0 || >= v20.8.0" } } From 4bebce96d224b80589aa5262f63d61a156ef4480 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Thu, 5 Oct 2023 01:56:58 -0400 Subject: [PATCH 11/17] build(node): update maintaince release version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15baf93c5..885616ff5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "vitepress": "^1.0.0-rc.20" }, "engines": { - "node": "^16.20.1 || ^18.18.0 || >= v20.8.0" + "node": "^16.20.2 || ^18.18.0 || >= v20.8.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 07ec73164..13871e4b2 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,6 @@ }, "packageManager": "npm@9.8.1", "engines": { - "node": "^16.20.1 || ^18.18.0 || >= v20.8.0" + "node": "^16.20.2 || ^18.18.0 || >= v20.8.0" } } From bc0515a3df098d23260d8e1cdc0f55365d54b4cc Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Thu, 5 Oct 2023 22:11:58 -0400 Subject: [PATCH 12/17] test: simplify demo --- package.json | 3 +-- test/fixture/demo.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 13871e4b2..81a6a374c 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,7 @@ "doc:bld": "node .github/jsdoc.config.cjs && vitepress build doc", "test:unit": "node --test test/unit/index.js", "test:e2e": "node --test test/e2e/index.js", - "test:mod": "npm link nw-builder && cd test/fixture && node demo.js", - "test:cli": "npm link nw-builder && cd test/fixture && nwbuild --platform win --arch x64 --outDir out --no-glob app" + "demo": "cd test/fixture && node demo.js" }, "devDependencies": { "concurrently": "^8.2.1", diff --git a/test/fixture/demo.js b/test/fixture/demo.js index b2fa72b99..593880871 100644 --- a/test/fixture/demo.js +++ b/test/fixture/demo.js @@ -1,4 +1,4 @@ -import nwbuild from "nw-builder"; +import nwbuild from "../../src/index.js"; await nwbuild({ mode: "build", From a6f67a2808dbc3c5cf424a160f7f5585b2693567 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Thu, 5 Oct 2023 22:14:13 -0400 Subject: [PATCH 13/17] test: demo get mode --- test/fixture/demo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixture/demo.js b/test/fixture/demo.js index 593880871..b81d5d494 100644 --- a/test/fixture/demo.js +++ b/test/fixture/demo.js @@ -1,7 +1,7 @@ import nwbuild from "../../src/index.js"; await nwbuild({ - mode: "build", + mode: "get", version: "0.80.0", srcDir: "app", outDir: "out", From 5af156573cdb52e662ebe4546a1dc66d60f4fe43 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 6 Oct 2023 01:03:16 -0400 Subject: [PATCH 14/17] fix: typo --- src/get.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/get.js b/src/get.js index 59bf34ee2..11796aa20 100644 --- a/src/get.js +++ b/src/get.js @@ -199,7 +199,7 @@ async function get_nwjs({ if (platform === "linux") { compressing.tgz.uncompress(out, cacheDir).then(() => resolve()); } else { - // For MacOS build on MacOS platform, Symlinks are copied as files during `compressing.zip.uncompress`. + // For MacOS build on MacOS platform, symlinks are copied as files during `compressing.zip.uncompress`. // We instead use yauzl-promise for this specific build and platform. if (platform === "osx" && PLATFORM === "darwin") { const zip = await yauzl.open(out); From 67d220dd8b9c9fecd9571bd657ca5cd88113fcfb Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 6 Oct 2023 18:04:19 -0400 Subject: [PATCH 15/17] build(fs): recursively mkdir --- src/get.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/get.js b/src/get.js index 11796aa20..24b22f017 100644 --- a/src/get.js +++ b/src/get.js @@ -206,7 +206,7 @@ async function get_nwjs({ try { for await (const entry of zip) { if (entry.filename.endsWith("/")) { - await mkdir(`${cacheDir}/${entry.filename}`); + await mkdir(`${cacheDir}/${entry.filename}`, { recursive: true }); } else { const readStream = await entry.openReadStream(); const writeStream = createWriteStream( From 159f472e988ec98e3d771888a9432bcd32956494 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 6 Oct 2023 18:05:32 -0400 Subject: [PATCH 16/17] fix: format --- src/get.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/get.js b/src/get.js index 24b22f017..76ebfb318 100644 --- a/src/get.js +++ b/src/get.js @@ -206,7 +206,9 @@ async function get_nwjs({ try { for await (const entry of zip) { if (entry.filename.endsWith("/")) { - await mkdir(`${cacheDir}/${entry.filename}`, { recursive: true }); + await mkdir(`${cacheDir}/${entry.filename}`, { + recursive: true, + }); } else { const readStream = await entry.openReadStream(); const writeStream = createWriteStream( From 066824a5de6d9c9ad655d13bc261029d427c56ac Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 6 Oct 2023 18:22:58 -0400 Subject: [PATCH 17/17] fix: decompression --- src/get.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/get.js b/src/get.js index 76ebfb318..11796aa20 100644 --- a/src/get.js +++ b/src/get.js @@ -206,9 +206,7 @@ async function get_nwjs({ try { for await (const entry of zip) { if (entry.filename.endsWith("/")) { - await mkdir(`${cacheDir}/${entry.filename}`, { - recursive: true, - }); + await mkdir(`${cacheDir}/${entry.filename}`); } else { const readStream = await entry.openReadStream(); const writeStream = createWriteStream(