From 0c9fb931770245ca5be6930db3492daafd5e679c Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:21:27 +0530 Subject: [PATCH 01/47] chore(docs): update roadmap --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1a1f9576..a60e1753 100644 --- a/README.md +++ b/README.md @@ -385,7 +385,6 @@ nwbuild({ ### Chores -- chore: add Linux, MacOS and Windows fixtures - chore(docs): don't store JSDoc definitions in `typedef`s - get's hard to understand during development. - chore: annotate file paths as `fs.PathLike` instead of `string`. - chore(bld): factor out core build step From 8125b86b36f525c30633cdb654446aa7ad6eef0b Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:26:53 +0530 Subject: [PATCH 02/47] chore(ci): upgrade MacOS and Ubuntu image runners --- .github/workflows/e2e.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index ea229219..05d2ee12 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -14,8 +14,8 @@ jobs: strategy: matrix: os: - - macos-14 - - ubuntu-22.04 + - macos-15 + - ubuntu-24.04 - windows-2022 fail-fast: false runs-on: ${{ matrix.os }} From e305f3a30d445273d5158f8deee0013836adeb18 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:37:31 +0530 Subject: [PATCH 03/47] chore(test): start Windows fixture configuration --- tests/fixtures/demo.win.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/fixtures/demo.win.js diff --git a/tests/fixtures/demo.win.js b/tests/fixtures/demo.win.js new file mode 100644 index 00000000..7454ec90 --- /dev/null +++ b/tests/fixtures/demo.win.js @@ -0,0 +1,16 @@ +import nwbuild from '../../src/index.js'; + +await nwbuild({ + mode: 'build', + flavor: 'sdk', + platform: 'win', + srcDir: './tests/fixtures/app', + cacheDir: './node_modules/nw', + outDir: './tests/fixtures/out', + glob: false, + app: { + name: 'Demo', + /* Relative to where the manifest will be located */ + icon: './icon.ico', + } +}); From ab3e4a6a1ff9cc4b0752bf615f75adb7e600ee16 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:38:18 +0530 Subject: [PATCH 04/47] chore(test): rename demo.js to demo.osx.js --- tests/fixtures/{demo.js => demo.osx.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/fixtures/{demo.js => demo.osx.js} (100%) diff --git a/tests/fixtures/demo.js b/tests/fixtures/demo.osx.js similarity index 100% rename from tests/fixtures/demo.js rename to tests/fixtures/demo.osx.js From 186a32d865b0165a12b3e68c4281930a103445ce Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:40:59 +0530 Subject: [PATCH 05/47] fix: undeprecate options.version --- README.md | 2 +- src/bld.js | 2 +- src/index.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a60e1753..8ed0e2ed 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,7 @@ This object defines additional properties used for building for a specific platf | ---- | ------- | --------- | ----------- | | `icon` | `string` | `undefined` | The path to the icon file. It should be a .ico file. | | `name` | `string` | Value of `name` in app's `package.json` | The name of the application | -| `version` | `string` | Value of `version` in app's `package.json` | (deprecated, Use `fileVersion` instead) The version of the application | +| `version` | `string` | Value of `version` in app's `package.json` | The version of the application | | `comments` | `string` | `undefined` | Additional information that should be displayed for diagnostic purposes. | | `company` | `string` | Value of `author` in app's `package.json` | Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required. | | `fileDescription` | `string` | Value of `description` in app's `package.json` | File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required. | diff --git a/src/bld.js b/src/bld.js index 9c11bfb2..976e06bf 100644 --- a/src/bld.js +++ b/src/bld.js @@ -66,7 +66,7 @@ import setOsxConfig from './bld/osx.js'; * https://learn.microsoft.com/en-gb/windows/win32/menurc/versioninfo-resource * @typedef {object} WinRc Windows configuration options. More info * @property {string} name The name of the application - * @property {string} version @deprecated Use {@link fileVersion} instead. The version of the application + * @property {string} version The version of the application * @property {string} comments Additional information that should be displayed for diagnostic purposes. * @property {string} company Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required. * @property {string} fileDescription File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required. diff --git a/src/index.d.ts b/src/index.d.ts index 0b686134..45749d2b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -61,7 +61,7 @@ export type AppOptions
= export interface WindowsAppOptions { /** The name of the application */ name?: string, - /** @deprecated Use {@link fileVersion} instead. The version of the application */ + /** The version of the application */ version?: string, /** Additional information that should be displayed for diagnostic purposes. */ comments?: string, From c1ccd814fd39851652e22921f289e13093da220a Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:50:59 +0530 Subject: [PATCH 06/47] chore(bld): update docs link --- src/bld.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bld.js b/src/bld.js index 976e06bf..73cf071e 100644 --- a/src/bld.js +++ b/src/bld.js @@ -62,7 +62,7 @@ import setOsxConfig from './bld/osx.js'; * References: * https://learn.microsoft.com/en-us/windows/win32/msi/version * https://learn.microsoft.com/en-gb/windows/win32/sbscs/application-manifests - * https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/deployment/trustinfo-element-clickonce-application?view=vs-2015#requestedexecutionlevel + * https://learn.microsoft.com/en-us/visualstudio/deployment/trustinfo-element-clickonce-application?view=vs-2022#requestedexecutionlevel * https://learn.microsoft.com/en-gb/windows/win32/menurc/versioninfo-resource * @typedef {object} WinRc Windows configuration options. More info * @property {string} name The name of the application From 523b445a93af4fcc9ee69cff79262a70b07e81d9 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:33:45 +0530 Subject: [PATCH 07/47] chore(docs): update roadmap --- src/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/index.js b/src/index.js index b77986d4..ae3a3af8 100644 --- a/src/index.js +++ b/src/index.js @@ -55,8 +55,6 @@ async function nwbuild(options) { options = await util.parse(options, manifest.json); - //TODO: impl logging - built = fs.existsSync(options.cacheDir); if (built === false) { await fs.promises.mkdir(options.cacheDir, { recursive: true }); From c444b69e102eb1f0091b36cf59d5eaa5da888e9a Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:09:49 +0530 Subject: [PATCH 08/47] chore(util): add in house log function --- src/util.js | 29 ++++++++++++++++++++++++++++- tests/specs/util.test.js | 14 ++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/specs/util.test.js diff --git a/src/util.js b/src/util.js index 6ff94c64..754e927e 100644 --- a/src/util.js +++ b/src/util.js @@ -453,4 +453,31 @@ async function fileExists(filePath) { return exists; } -export default { fileExists, getReleaseInfo, getPath, PLATFORM_KV, ARCH_KV, EXE_NAME, globFiles, getNodeManifest, parse, validate }; +/** + * Custom logging function + * @param {'debug' | 'info' | 'warn' | 'error'} severity - severity of message + * @param {'debug' | 'info' | 'warn' | 'error'} logLevel - log level requested by user + * @param {string} message - contents of message + * @returns {string} - stdout + */ +function log(severity, logLevel = 'error', message) { + const sev = { + 'debug': 4, + 'info': 3, + 'warn': 2, + 'error': 1, + }; + let stdout = ''; + const messageSeverity = sev[severity]; + const userDefSeverity = sev[logLevel]; + + if (messageSeverity <= userDefSeverity) { + stdout = `[ ${severity.toUpperCase()} ] ${message}`; + } + + console.log(stdout); + + return stdout; +} + +export default { fileExists, getReleaseInfo, getPath, PLATFORM_KV, ARCH_KV, EXE_NAME, globFiles, getNodeManifest, parse, validate, log }; diff --git a/tests/specs/util.test.js b/tests/specs/util.test.js new file mode 100644 index 00000000..c2f13a62 --- /dev/null +++ b/tests/specs/util.test.js @@ -0,0 +1,14 @@ +import { describe, expect, it } from 'vitest'; + +import util from '../../src/util.js'; + +describe('util/log', function () { + + it('shows only error message if log level is error', async function () { + expect(util.log('error', 'error', 'Sample message with severity of error')).toBe('[ ERROR ] Sample message with severity of error'); + }); + + it('shows only error message if log level is debug', async function () { + expect(util.log('debug', 'error', 'Sample message with severity of error')).toBe(''); + }); +}); From 56905caf3cf65b19a839b97ad477cefb38ca1d9f Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:40:22 +0530 Subject: [PATCH 09/47] chore(util): check for invalid input --- tests/specs/util.test.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/specs/util.test.js b/tests/specs/util.test.js index c2f13a62..7c1185c7 100644 --- a/tests/specs/util.test.js +++ b/tests/specs/util.test.js @@ -5,10 +5,19 @@ import util from '../../src/util.js'; describe('util/log', function () { it('shows only error message if log level is error', async function () { - expect(util.log('error', 'error', 'Sample message with severity of error')).toBe('[ ERROR ] Sample message with severity of error'); + expect(util.log('error', 'error', 'Lorem ipsum')).toBe('[ ERROR ] Lorem ipsum'); }); it('shows only error message if log level is debug', async function () { - expect(util.log('debug', 'error', 'Sample message with severity of error')).toBe(''); + expect(util.log('debug', 'error', 'Lorem ipsum')).toBe(''); }); + + it('throws error if message severity is invalid', async function () { + expect(() => util.log('debuggy', 'error', 'Lorem ipsum')).toThrow(); + }); + + it('throws error if user defined log level is invalid', async function () { + expect(() => util.log('debug', 'errory', 'Lorem ipsum')).toThrow(); + }); + }); From 67bc126b0cefb715b70aa494de3c8ecffcb8738a Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:41:04 +0530 Subject: [PATCH 10/47] chore(util): check for invalid input --- src/util.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/util.js b/src/util.js index 754e927e..f998a11c 100644 --- a/src/util.js +++ b/src/util.js @@ -458,9 +458,17 @@ async function fileExists(filePath) { * @param {'debug' | 'info' | 'warn' | 'error'} severity - severity of message * @param {'debug' | 'info' | 'warn' | 'error'} logLevel - log level requested by user * @param {string} message - contents of message + * @throws {Error} - throw error on invalid input * @returns {string} - stdout */ -function log(severity, logLevel = 'error', message) { +function log(severity, logLevel, message) { + if (!['debug', 'info', 'warn', 'error'].includes(severity)) { + throw new Error(`Expected debug, info, warn or error message severity. Got ${severity}`); + } + if (!['debug', 'info', 'warn', 'error'].includes(logLevel)) { + throw new Error(`Expected debug, info, warn or error user defined log level. Got ${logLevel}`); + } + const sev = { 'debug': 4, 'info': 3, From e705ea0df14cfb3d8d0638f5061c86925e50adab Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 19:52:42 +0530 Subject: [PATCH 11/47] chore(test): try out log function --- package.json | 2 +- src/index.js | 5 +++++ tests/fixtures/demo.osx.js | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2304a678..2aba8140 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "lint:fix": "eslint --fix ./src ./tests", "test": "vitest run --coverage", "test:cov": "vitest --coverage.enabled true", - "demo:bld": "node ./tests/fixtures/demo.js", + "demo:bld": "node ./tests/fixtures/demo.osx.js", "demo:exe": "./tests/fixtures/out/Demo.app/Contents/MacOS/Demo", "demo:cli": "nwbuild --mode=run --flavor=sdk --glob=false --cacheDir=./node_modules/nw ./tests/fixtures/app" }, diff --git a/src/index.js b/src/index.js index ae3a3af8..8b429407 100644 --- a/src/index.js +++ b/src/index.js @@ -47,13 +47,18 @@ async function nwbuild(options) { try { // Parse options options = await util.parse(options, manifest); + util.log('debug', 'info', 'Parse initial options'); + util.log('debug', 'info', 'Get node manifest...'); manifest = await util.getNodeManifest({ srcDir: options.srcDir, glob: options.glob }); if (typeof manifest.json?.nwbuild === 'object') { options = manifest.json.nwbuild; } + util.log('info', options.logLevel, 'Parse final options'); options = await util.parse(options, manifest.json); + util.log('debug', options.logLevel, 'Manifest path: ', manifest.path); + util.log('debug', options.logLevel, 'Manifest file:\n', manifest.json); built = fs.existsSync(options.cacheDir); if (built === false) { diff --git a/tests/fixtures/demo.osx.js b/tests/fixtures/demo.osx.js index ae29dfee..e65a270e 100644 --- a/tests/fixtures/demo.osx.js +++ b/tests/fixtures/demo.osx.js @@ -8,6 +8,7 @@ await nwbuild({ cacheDir: './node_modules/nw', outDir: './tests/fixtures/out', glob: false, + logLevel: 'debug', app: { name: 'Demo', // MacOS options From 0ef2df35c4a2ec0bd1fb90bc37aaecb58bcd1afb Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:03:59 +0530 Subject: [PATCH 12/47] fix(get): listen for Ctrl+C and delete partially downloaded file --- src/get/request.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/get/request.js b/src/get/request.js index 2c39c2e8..0e077363 100644 --- a/src/get/request.js +++ b/src/get/request.js @@ -1,4 +1,5 @@ import fs from 'node:fs'; +import process from 'node:process'; import stream from 'node:stream'; import axios from 'axios'; @@ -15,6 +16,15 @@ export default async function request(url, filePath) { const writeStream = fs.createWriteStream(filePath); + // Listen for SIGINT (Ctrl+C) + process.on('SIGINT', function () { + /* Delete file if it exists. This prevents unecessary `Centrol Directory not found` errors. */ + if (fs.existsSync(filePath)) { + fs.unlinkSync(filePath); + } + process.exit(); + }); + const response = await axios({ method: 'get', url: url, @@ -22,4 +32,5 @@ export default async function request(url, filePath) { }); await stream.promises.pipeline(response.data, writeStream); + } From 79696d3ca6a017537cbd5990bbc8ca304174f38a Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:36:00 +0530 Subject: [PATCH 13/47] fix(docs): correct default value of options.app.legalCopyright for Windows --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ed0e2ed..f2395ff5 100644 --- a/README.md +++ b/README.md @@ -236,7 +236,7 @@ This object defines additional properties used for building for a specific platf | `fileDescription` | `string` | Value of `description` in app's `package.json` | File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required. | | `fileVersion` | `string` | Value of `version` option or value of `version` in app's `package.json` | Version number of the file. For example, 3.10 or 5.00.RC2. This string is required. | | `internalName` | `string` | Value of `name` in app's `package.json` |Internal name of the file, if one exists—for example, a module name if the file is a dynamic-link library. If the file has no internal name, this string should be the original filename, without extension. This string is required. | -| `legalCopyright` | `string` | NW.js' copyright info | Copyright notices that apply to the file. This should include the full text of all notices, legal symbols, copyright dates, and so on. This string is optional. | +| `legalCopyright` | `string` | `undefined` | Copyright notices that apply to the file. This should include the full text of all notices, legal symbols, copyright dates, and so on. This string is optional. | | `legalTrademark` | `string` | `undefined` | Trademarks and registered trademarks that apply to the file. This should include the full text of all notices, legal symbols, trademark numbers, and so on. This string is optional. | | `originalFilename` | `string` | Value of `name` option | Original name of the file, not including a path. This information enables an application to determine whether a file has been renamed by a user. The format of the name depends on the file system for which the file was created. This string is required. | | `privateBuild` | `string` | `undefined` | Information about a private version of the file—for example, Built by TESTER1 on \\TESTBED. | From 07248875f6f036fa661cf2931ba252049f62b10c Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:38:26 +0530 Subject: [PATCH 14/47] chore(docs): clarify options.app.fileVersion default values --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2395ff5..d4ab4b84 100644 --- a/README.md +++ b/README.md @@ -234,7 +234,7 @@ This object defines additional properties used for building for a specific platf | `comments` | `string` | `undefined` | Additional information that should be displayed for diagnostic purposes. | | `company` | `string` | Value of `author` in app's `package.json` | Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required. | | `fileDescription` | `string` | Value of `description` in app's `package.json` | File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required. | -| `fileVersion` | `string` | Value of `version` option or value of `version` in app's `package.json` | Version number of the file. For example, 3.10 or 5.00.RC2. This string is required. | +| `fileVersion` | `string` | Value of `version` or value of `version` in NW.js manifest | Version number of the file. For example, 3.10 or 5.00.RC2. This string is required. | | `internalName` | `string` | Value of `name` in app's `package.json` |Internal name of the file, if one exists—for example, a module name if the file is a dynamic-link library. If the file has no internal name, this string should be the original filename, without extension. This string is required. | | `legalCopyright` | `string` | `undefined` | Copyright notices that apply to the file. This should include the full text of all notices, legal symbols, copyright dates, and so on. This string is optional. | | `legalTrademark` | `string` | `undefined` | Trademarks and registered trademarks that apply to the file. This should include the full text of all notices, legal symbols, trademark numbers, and so on. This string is optional. | From 92d8dab164ae8368046a0c7685ca20a7b0843070 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:42:43 +0530 Subject: [PATCH 15/47] chore(docs): clarify terminology regarding package.json --- README.md | 14 +++++++------- tests/fixtures/demo.win.js | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d4ab4b84..04490da1 100644 --- a/README.md +++ b/README.md @@ -229,19 +229,19 @@ This object defines additional properties used for building for a specific platf | Name | Type | Default | Description | | ---- | ------- | --------- | ----------- | | `icon` | `string` | `undefined` | The path to the icon file. It should be a .ico file. | -| `name` | `string` | Value of `name` in app's `package.json` | The name of the application | -| `version` | `string` | Value of `version` in app's `package.json` | The version of the application | +| `name` | `string` | Value of `name` in NW.js manifest | The name of the application | +| `version` | `string` | Value of `version` in NW.js manifest | The version of the application | | `comments` | `string` | `undefined` | Additional information that should be displayed for diagnostic purposes. | -| `company` | `string` | Value of `author` in app's `package.json` | Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required. | -| `fileDescription` | `string` | Value of `description` in app's `package.json` | File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required. | +| `company` | `string` | Value of `author` in NW.js manifest | Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required. | +| `fileDescription` | `string` | Value of `description` in NW.js manifest | File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required. | | `fileVersion` | `string` | Value of `version` or value of `version` in NW.js manifest | Version number of the file. For example, 3.10 or 5.00.RC2. This string is required. | -| `internalName` | `string` | Value of `name` in app's `package.json` |Internal name of the file, if one exists—for example, a module name if the file is a dynamic-link library. If the file has no internal name, this string should be the original filename, without extension. This string is required. | +| `internalName` | `string` | Value of `name` in NW.js manifest |Internal name of the file, if one exists—for example, a module name if the file is a dynamic-link library. If the file has no internal name, this string should be the original filename, without extension. This string is required. | | `legalCopyright` | `string` | `undefined` | Copyright notices that apply to the file. This should include the full text of all notices, legal symbols, copyright dates, and so on. This string is optional. | | `legalTrademark` | `string` | `undefined` | Trademarks and registered trademarks that apply to the file. This should include the full text of all notices, legal symbols, trademark numbers, and so on. This string is optional. | | `originalFilename` | `string` | Value of `name` option | Original name of the file, not including a path. This information enables an application to determine whether a file has been renamed by a user. The format of the name depends on the file system for which the file was created. This string is required. | | `privateBuild` | `string` | `undefined` | Information about a private version of the file—for example, Built by TESTER1 on \\TESTBED. | -| `productName` | `string` | Matches the package name defined in app's `package.json` | Name of the product with which the file is distributed. This string is required. | -| `productVersion` | `string` | Value of `version` in app's `package.json` | Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. | +| `productName` | `string` | `name` in NW.js manifest | Name of the product with which the file is distributed. This string is required. | +| `productVersion` | `string` | Value of `version` in NW.js manifest | Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. | | `specialBuild` | `string` | `undefined` | Text that specifies how this version of the file differs from the standard version—for example, Private build for TESTER1 solving mouse problems on M250 and M250E computers. | | `languageCode` | `number` | `1033` | Language of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a | diff --git a/tests/fixtures/demo.win.js b/tests/fixtures/demo.win.js index 7454ec90..b16eb446 100644 --- a/tests/fixtures/demo.win.js +++ b/tests/fixtures/demo.win.js @@ -12,5 +12,14 @@ await nwbuild({ name: 'Demo', /* Relative to where the manifest will be located */ icon: './icon.ico', + version: '0.0.0', + comments: 'Diagnostic information', + company: 'NW.js Utilities', + fileDescription: 'This is a demo app to test nw-builder functionality', + fileVersion: '0.0.0', + internalName: 'Demo', + legalCopyright: '2024 (c) NW.js Utilties. All Rights Reserved', + originalFilename: 'Demo', + } }); From 2c774d8f8019cfaca1e3b66dc096a52eaa69bbb9 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:44:00 +0530 Subject: [PATCH 16/47] chore(test): configure initial Windows build --- tests/fixtures/demo.win.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/demo.win.js b/tests/fixtures/demo.win.js index b16eb446..e2b69ad8 100644 --- a/tests/fixtures/demo.win.js +++ b/tests/fixtures/demo.win.js @@ -20,6 +20,7 @@ await nwbuild({ internalName: 'Demo', legalCopyright: '2024 (c) NW.js Utilties. All Rights Reserved', originalFilename: 'Demo', - + productName: 'Demo', + productVersion: '0.0.0', } }); From 8bfbcea07ad3fe56b3babc863cba8fcde67d2a63 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:50:58 +0530 Subject: [PATCH 17/47] chore: create CLI command to build and execute Windows NW.js demo app --- package.json | 6 ++++-- tests/fixtures/demo.osx.js | 2 +- tests/fixtures/demo.win.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 2aba8140..8ef4a8f2 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,10 @@ "lint:fix": "eslint --fix ./src ./tests", "test": "vitest run --coverage", "test:cov": "vitest --coverage.enabled true", - "demo:bld": "node ./tests/fixtures/demo.osx.js", - "demo:exe": "./tests/fixtures/out/Demo.app/Contents/MacOS/Demo", + "demo:bld:osx": "node ./tests/fixtures/demo.osx.js", + "demo:bld:win": "node ./tests/fixtures/demo.osx.js", + "demo:exe:osx": "./tests/fixtures/out/osx/Demo.app/Contents/MacOS/Demo", + "demo:exe:win": "./tests/fixtures/out/win/Demo.exe", "demo:cli": "nwbuild --mode=run --flavor=sdk --glob=false --cacheDir=./node_modules/nw ./tests/fixtures/app" }, "devDependencies": { diff --git a/tests/fixtures/demo.osx.js b/tests/fixtures/demo.osx.js index e65a270e..5a6e73fa 100644 --- a/tests/fixtures/demo.osx.js +++ b/tests/fixtures/demo.osx.js @@ -6,7 +6,7 @@ await nwbuild({ platform: 'osx', srcDir: './tests/fixtures/app', cacheDir: './node_modules/nw', - outDir: './tests/fixtures/out', + outDir: './tests/fixtures/out/osx', glob: false, logLevel: 'debug', app: { diff --git a/tests/fixtures/demo.win.js b/tests/fixtures/demo.win.js index e2b69ad8..4194c976 100644 --- a/tests/fixtures/demo.win.js +++ b/tests/fixtures/demo.win.js @@ -6,7 +6,7 @@ await nwbuild({ platform: 'win', srcDir: './tests/fixtures/app', cacheDir: './node_modules/nw', - outDir: './tests/fixtures/out', + outDir: './tests/fixtures/out/win', glob: false, app: { name: 'Demo', From 9aaa5d76d96a2696b1b2f7e7fc36173eb1c65d6c Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:57:18 +0530 Subject: [PATCH 18/47] chore: create CLI command to build and execute Windows NW.js demo app --- package.json | 2 +- tests/fixtures/demo.win.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ef4a8f2..605422b8 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "test": "vitest run --coverage", "test:cov": "vitest --coverage.enabled true", "demo:bld:osx": "node ./tests/fixtures/demo.osx.js", - "demo:bld:win": "node ./tests/fixtures/demo.osx.js", + "demo:bld:win": "node ./tests/fixtures/demo.win.js", "demo:exe:osx": "./tests/fixtures/out/osx/Demo.app/Contents/MacOS/Demo", "demo:exe:win": "./tests/fixtures/out/win/Demo.exe", "demo:cli": "nwbuild --mode=run --flavor=sdk --glob=false --cacheDir=./node_modules/nw ./tests/fixtures/app" diff --git a/tests/fixtures/demo.win.js b/tests/fixtures/demo.win.js index 4194c976..828ac880 100644 --- a/tests/fixtures/demo.win.js +++ b/tests/fixtures/demo.win.js @@ -8,6 +8,7 @@ await nwbuild({ cacheDir: './node_modules/nw', outDir: './tests/fixtures/out/win', glob: false, + logLevel: 'debug', app: { name: 'Demo', /* Relative to where the manifest will be located */ From 3652910edb22e8d9c126ad08e8373735f7b02395 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:21:10 +0530 Subject: [PATCH 19/47] fix(test): point to valid icon path --- tests/fixtures/demo.win.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/demo.win.js b/tests/fixtures/demo.win.js index 828ac880..e7c833c1 100644 --- a/tests/fixtures/demo.win.js +++ b/tests/fixtures/demo.win.js @@ -12,7 +12,7 @@ await nwbuild({ app: { name: 'Demo', /* Relative to where the manifest will be located */ - icon: './icon.ico', + icon: './tests/fixtures/app/icon.ico', version: '0.0.0', comments: 'Diagnostic information', company: 'NW.js Utilities', From 60470f4e369ce5e861bb3b04b93c1047b6650844 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:22:26 +0530 Subject: [PATCH 20/47] chore(get): correct spelling in code comments --- src/get/request.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/get/request.js b/src/get/request.js index 0e077363..d8fede5b 100644 --- a/src/get/request.js +++ b/src/get/request.js @@ -16,9 +16,9 @@ export default async function request(url, filePath) { const writeStream = fs.createWriteStream(filePath); - // Listen for SIGINT (Ctrl+C) + /* Listen for SIGINT (Ctrl+C) */ process.on('SIGINT', function () { - /* Delete file if it exists. This prevents unecessary `Centrol Directory not found` errors. */ + /* Delete file if it exists. This prevents unnecessary `Central Directory not found` errors. */ if (fs.existsSync(filePath)) { fs.unlinkSync(filePath); } From c0e1fed676cbdeb22a822e319f0d1feb9cdcd8d4 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:47:58 +0530 Subject: [PATCH 21/47] chore(bld): improve readability --- src/bld.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bld.js b/src/bld.js index 73cf071e..ce156700 100644 --- a/src/bld.js +++ b/src/bld.js @@ -319,10 +319,11 @@ const setWinConfig = async ({ app, outDir }) => { if (app.icon) { const iconBuffer = await fs.promises.readFile(path.resolve(app.icon)); const iconFile = resedit.Data.IconFile.from(iconBuffer); + const iconGroupIDs = resedit.Resource.IconGroupEntry.fromEntries(res.entries).map((entry) => entry.id); resedit.Resource.IconGroupEntry.replaceIconsForResource( res.entries, - // This is the name of the icon group nw.js uses that gets shown in file exlorers - 'IDR_MAINFRAME', + /* Should be `IDR_MAINFRAME` */ + iconGroupIDs[0], EN_US, iconFile.icons.map(i => i.data) ); From ba081f5cbe5931fd4c86624410f0e284dae41189 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:48:22 +0530 Subject: [PATCH 22/47] chore(test): update title from NW.js Demo to Demo since it shows in Taskbarc --- tests/fixtures/app/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/app/index.html b/tests/fixtures/app/index.html index d5b84f9f..cdc892c0 100644 --- a/tests/fixtures/app/index.html +++ b/tests/fixtures/app/index.html @@ -2,7 +2,7 @@
-