nw-builder 4.0.1 → 4.0.2
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/README.md +0 -38
- package/docs/index.md +112 -0
- package/nwbuild.cjs +113 -0
- package/package.json +10 -3
- package/src/bld/compress.js +0 -1
- package/src/bld/linuxCfg.js +1 -1
- package/src/bld/osxCfg.js +47 -78
- package/src/bld/package.js +2 -2
- package/src/bld/winCfg.js +13 -2
- package/test/demo/bld.cjs +30 -0
- package/test/demo/nwapp/package.json +1 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Build NW.js desktop applications for Mac, Windows and Linux.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"main": "./src/nwbuild.js",
|
|
18
|
+
"exports": {
|
|
19
|
+
"import": "./src/nwbuild.js",
|
|
20
|
+
"require": "./nwbuild.cjs"
|
|
21
|
+
},
|
|
18
22
|
"type": "module",
|
|
19
23
|
"homepage": "https://github.com/nwutils/nw-builder",
|
|
20
24
|
"repository": {
|
|
@@ -22,12 +26,15 @@
|
|
|
22
26
|
"url": "https://github.com/nwutils/nw-builder.git"
|
|
23
27
|
},
|
|
24
28
|
"scripts": {
|
|
25
|
-
"format": "prettier --write \"**/*.{js,md}\"",
|
|
29
|
+
"format": "prettier --write \"**/*.{js,cjs,md}\"",
|
|
26
30
|
"lint": "eslint ./src",
|
|
27
31
|
"docs": "jsdoc ./src/nwbuild.js -d docs",
|
|
28
|
-
"demo": "cd ./test/demo && nwbuild ./nwapp --version=0.69.1 --flavour=sdk --platform=linux --arch=x64 --outDir=./build"
|
|
32
|
+
"demo": "cd ./test/demo && nwbuild ./nwapp --version=0.69.1 --flavour=sdk --platform=linux --arch=x64 --outDir=./build",
|
|
33
|
+
"demo:cjs": "cd ./test/demo && node bld.cjs",
|
|
34
|
+
"cjs": "esbuild ./src/nwbuild.js --bundle --minify --legal-comments=inline --platform=node --outfile=./nwbuild.cjs"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
37
|
+
"esbuild": "^0.15.15",
|
|
31
38
|
"eslint": "^8.25.0",
|
|
32
39
|
"eslint-config-tjw-jsdoc": "^1.0.3",
|
|
33
40
|
"jest": "^29.2.0",
|
package/src/bld/compress.js
CHANGED
package/src/bld/linuxCfg.js
CHANGED
|
@@ -17,7 +17,7 @@ export const setLinuxConfig = async (pkg, outDir) => {
|
|
|
17
17
|
Exec: pkg.name,
|
|
18
18
|
};
|
|
19
19
|
await rename(`${outDir}/nw`, `${outDir}/${pkg.name}`);
|
|
20
|
-
if (typeof pkg.nwbuild
|
|
20
|
+
if (typeof pkg.nwbuild?.linuxCfg === "object") {
|
|
21
21
|
Object.keys(pkg.nwbuild.linuxCfg).forEach((key) => {
|
|
22
22
|
if (key !== "Type") {
|
|
23
23
|
desktopEntryFile[key] = pkg.nwbuild.linuxCfg[key];
|
package/src/bld/osxCfg.js
CHANGED
|
@@ -1,88 +1,57 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
|
|
3
4
|
import plist from "plist";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
/**
|
|
7
|
+
* OSX specific configuration steps
|
|
8
|
+
*
|
|
9
|
+
* @param {object} pkg The srcDir/package.json as a JSON
|
|
10
|
+
* @param {string} outDir The directory to hold build artifacts
|
|
11
|
+
* @param {object} releaseInfo NW binary release metadata
|
|
12
|
+
*/
|
|
13
|
+
const setOsxConfig = async (pkg, outDir) => {
|
|
14
|
+
// const setOsxConfig = async (pkg, outDir, releaseInfo) => {
|
|
15
|
+
const outApp = path.resolve(outDir, `${pkg.name}.app`);
|
|
16
|
+
await fs.rename(path.resolve(outDir, "nwjs.app"), outApp);
|
|
17
|
+
|
|
6
18
|
// Rename CFBundleDisplayName in Contents/Info.plist
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
let contents_info_plist = plist.build(contents_info_plist_json);
|
|
13
|
-
await fs.writeFile(contents_info_plist_path, contents_info_plist);
|
|
19
|
+
const contentsInfoPlistPath = path.resolve(outApp, "Contents/Info.plist");
|
|
20
|
+
const contentsInfoPlistJson = plist.parse(await fs.readFile(contentsInfoPlistPath, "utf-8"));
|
|
21
|
+
contentsInfoPlistJson.CFBundleDisplayName = pkg.name;
|
|
22
|
+
const contentsInfoPlist = plist.build(contentsInfoPlistJson);
|
|
23
|
+
await fs.writeFile(contentsInfoPlistPath, contentsInfoPlist);
|
|
14
24
|
|
|
15
25
|
// Rename CFBundleDisplayName in Contents/Resources/en.lproj/InfoPlist.strings
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)}/Contents/Info.plist`;
|
|
46
|
-
let helper_app_render_plist_path = `${helper_app_path_renderer(
|
|
47
|
-
pkg.name,
|
|
48
|
-
)}/Contents/Info.plist`;
|
|
49
|
-
let helper_app_plist_path = `${helper_app_path(
|
|
50
|
-
pkg.name,
|
|
51
|
-
)}/Contents/Info.plist`;
|
|
52
|
-
|
|
53
|
-
let helper_app_alerts_plist_json = plist.parse(
|
|
54
|
-
await fs.readFile(helper_app_alerts_plist_path, "utf-8"),
|
|
55
|
-
);
|
|
56
|
-
let helper_app_gpu_plist_json = plist.parse(
|
|
57
|
-
await fs.readFile(helper_app_gpu_plist_path, "utf-8"),
|
|
58
|
-
);
|
|
59
|
-
let helper_app_plugin_plist_json = plist.parse(
|
|
60
|
-
await fs.readFile(helper_app_plugin_plist_path, "utf-8"),
|
|
61
|
-
);
|
|
62
|
-
let helper_app_render_plist_json = plist.parse(
|
|
63
|
-
await fs.readFile(helper_app_render_plist_path, "utf-8"),
|
|
64
|
-
);
|
|
65
|
-
let helper_app_plist_json = plist.parse(
|
|
66
|
-
await fs.readFile(helper_app_plist_path, "utf-8"),
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
helper_app_alerts_plist_json.CFBundleDisplayName = pkg.name;
|
|
70
|
-
helper_app_gpu_plist_json.CFBundleDisplayName = pkg.name;
|
|
71
|
-
helper_app_render_plist_json.CFBundleDisplayName = pkg.name;
|
|
72
|
-
helper_app_plugin_plist_json.CFBundleDisplayName = pkg.name;
|
|
73
|
-
helper_app_plist_json.CFBundleDisplayName = pkg.name;
|
|
74
|
-
|
|
75
|
-
let helper_app_alerts_plist = plist.build(helper_app_alerts_plist_json);
|
|
76
|
-
let helper_app_gpu_plist = plist.build(helper_app_gpu_plist_json);
|
|
77
|
-
let helper_app_render_plist = plist.build(helper_app_render_plist_json);
|
|
78
|
-
let helper_app_plugin_plist = plist.build(helper_app_plugin_plist_json);
|
|
79
|
-
let helper_app_plist = plist.build(helper_app_plist_json);
|
|
80
|
-
|
|
81
|
-
await fs.writeFile(helper_app_alerts_plist_path, helper_app_alerts_plist);
|
|
82
|
-
await fs.writeFile(helper_app_gpu_plist_path, helper_app_gpu_plist);
|
|
83
|
-
await fs.writeFile(helper_app_plugin_plist_path, helper_app_plugin_plist);
|
|
84
|
-
await fs.writeFile(helper_app_render_plist_path, helper_app_render_plist);
|
|
85
|
-
await fs.writeFile(helper_app_plist_path, helper_app_plist);
|
|
26
|
+
const contentsInfoPlistStringsPath = path.resolve(outApp, "Contents/Resources/en.lproj/InfoPlist.strings");
|
|
27
|
+
const contentsInfoPlistStrings = await fs.readFile(contentsInfoPlistStringsPath, "utf-8");
|
|
28
|
+
const newPlistStrings = contentsInfoPlistStrings.replace(/CFBundleGetInfoString = "nwjs /, `CFBundleGetInfoString = "${pkg.name} `);
|
|
29
|
+
await fs.writeFile(contentsInfoPlistStringsPath, newPlistStrings);
|
|
30
|
+
|
|
31
|
+
// Add product_string property to package.json
|
|
32
|
+
// const packageJsonPath = path.resolve(outApp, "Contents/Resources/app.nw/package.json");
|
|
33
|
+
// pkg.product_string = pkg.name;
|
|
34
|
+
// await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 4));
|
|
35
|
+
|
|
36
|
+
// Update Helper apps
|
|
37
|
+
// TODO: determine why this prevents app from launching
|
|
38
|
+
// for (const helperName of [" (Alerts)", " (GPU)", " (Plugin)", " (Renderer)", ""]) {
|
|
39
|
+
// const helperPath = (name = "nwjs") => path.resolve(
|
|
40
|
+
// outApp,
|
|
41
|
+
// `Contents/Frameworks/nwjs Framework.framework/Versions/${releaseInfo.components.chromium}/Helpers/`,
|
|
42
|
+
// `${name} Helper${helperName}.app`
|
|
43
|
+
// );
|
|
44
|
+
|
|
45
|
+
// // Rename Helper apps in Contents/Framework.framework/Versions/n.n.n.n/Helpers
|
|
46
|
+
// await fs.rename(helperPath(), helperPath(pkg.name));
|
|
47
|
+
|
|
48
|
+
// // Update Helper app Info.plist files in Contents/Framework.framework/Versions/n.n.n.n/Helpers
|
|
49
|
+
// const helperPlistPath = path.resolve(helperPath(pkg.name), "Contents/Info.plist");
|
|
50
|
+
// const helperPlistJson = plist.parse(await fs.readFile(helperPlistPath, "utf-8"));
|
|
51
|
+
// helperPlistJson.CFBundleDisplayName = pkg.name;
|
|
52
|
+
// const helperPlist = plist.build(helperPlistJson);
|
|
53
|
+
// await fs.writeFile(helperPlistPath, helperPlist);
|
|
54
|
+
// }
|
|
86
55
|
};
|
|
87
56
|
|
|
88
57
|
export { setOsxConfig };
|
package/src/bld/package.js
CHANGED
|
@@ -27,7 +27,7 @@ const packager = async (srcDir, nwDir, outDir, platform, zip, releaseInfo) => {
|
|
|
27
27
|
await cp(
|
|
28
28
|
srcDir,
|
|
29
29
|
`${outDir}/${
|
|
30
|
-
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/nw
|
|
30
|
+
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/app.nw"
|
|
31
31
|
}`,
|
|
32
32
|
{
|
|
33
33
|
recursive: true,
|
|
@@ -37,7 +37,7 @@ const packager = async (srcDir, nwDir, outDir, platform, zip, releaseInfo) => {
|
|
|
37
37
|
log.debug("Get NW's package.json as a buffer");
|
|
38
38
|
let buffer = await readFile(
|
|
39
39
|
`${outDir}/${
|
|
40
|
-
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/nw
|
|
40
|
+
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/app.nw"
|
|
41
41
|
}/package.json`,
|
|
42
42
|
);
|
|
43
43
|
log.debug("Convert package.json buffer into JSON");
|
package/src/bld/winCfg.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { rename } from "node:fs/promises";
|
|
2
|
+
|
|
1
3
|
import rcedit from "rcedit";
|
|
2
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Windows specific configuration steps
|
|
7
|
+
*
|
|
8
|
+
* @param {object} pkg The srcDir/package.json as a JSON
|
|
9
|
+
* @param {string} outDir The directory to hold build artifacts
|
|
10
|
+
*/
|
|
3
11
|
const setWinConfig = async (pkg, outDir) => {
|
|
4
|
-
|
|
12
|
+
await rename(`${outDir}/nw.exe`, `${outDir}/${pkg.name}.exe`);
|
|
13
|
+
|
|
14
|
+
// https://learn.microsoft.com/en-gb/windows/win32/menurc/versioninfo-resource?redirectedfrom=MSDN#string-name
|
|
15
|
+
await rcedit(`${outDir}/${pkg.name}.exe`, {
|
|
5
16
|
"file-version": pkg.version,
|
|
6
17
|
"product-version": pkg.version,
|
|
7
18
|
"icon": pkg.icon,
|
|
@@ -9,7 +20,7 @@ const setWinConfig = async (pkg, outDir) => {
|
|
|
9
20
|
FileDescription: pkg.description,
|
|
10
21
|
LegalCopyright: pkg.copyright,
|
|
11
22
|
ProductName: pkg.name,
|
|
12
|
-
OriginalFilename:
|
|
23
|
+
OriginalFilename: pkg.name,
|
|
13
24
|
},
|
|
14
25
|
});
|
|
15
26
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { nwbuild } = require("nw-builder");
|
|
2
|
+
|
|
3
|
+
const bld = async () => {
|
|
4
|
+
await nwbuild({
|
|
5
|
+
srcDir: "./nwapp",
|
|
6
|
+
version: "0.70.1",
|
|
7
|
+
flavour: "normal",
|
|
8
|
+
platform: "linux",
|
|
9
|
+
arch: "x64",
|
|
10
|
+
outDir: "./build/nix",
|
|
11
|
+
});
|
|
12
|
+
await nwbuild({
|
|
13
|
+
srcDir: "./nwapp",
|
|
14
|
+
version: "0.70.1",
|
|
15
|
+
flavour: "normal",
|
|
16
|
+
platform: "osx",
|
|
17
|
+
arch: "x64",
|
|
18
|
+
outDir: "./build/osx",
|
|
19
|
+
});
|
|
20
|
+
await nwbuild({
|
|
21
|
+
srcDir: "./nwapp",
|
|
22
|
+
version: "0.70.1",
|
|
23
|
+
flavour: "normal",
|
|
24
|
+
platform: "win",
|
|
25
|
+
arch: "x64",
|
|
26
|
+
outDir: "./build/win",
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
bld();
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nwdemo",
|
|
3
|
-
"main": "index.html"
|
|
4
|
-
"product_string": "nwdemo",
|
|
5
|
-
"nwbuild": {
|
|
6
|
-
"srcDir": "./nwapp",
|
|
7
|
-
"version": "0.70.1",
|
|
8
|
-
"flavour": "sdk",
|
|
9
|
-
"platform": "linux",
|
|
10
|
-
"arch": "x64",
|
|
11
|
-
"outDir": "./build",
|
|
12
|
-
"run": false,
|
|
13
|
-
"linuxCfg": {
|
|
14
|
-
"Type": "Application",
|
|
15
|
-
"Name": "nwdemo"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
3
|
+
"main": "index.html"
|
|
18
4
|
}
|