nw-builder 4.3.0 → 4.3.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/package.json +3 -2
- package/src/bld/osxCfg.js +13 -8
- package/src/cli.js +36 -0
- package/src/index.js +0 -3
- package/src/util/parse.js +1 -1
- package/src/util/xattr.js +0 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"doc:bld": "vitepress build doc",
|
|
47
47
|
"test:unit": "node --test-reporter=spec --test test/unit/index.js",
|
|
48
48
|
"test:e2e": "node --test-reporter=spec --test test/e2e/index.js",
|
|
49
|
-
"test:
|
|
49
|
+
"test:mod": "cd test/fixture && node demo.js",
|
|
50
|
+
"test:cli": "cd test/fixture && nwbuild --platform win --arch x64 --outDir out --no-glob app"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"eslint": "^8.44.0",
|
package/src/bld/osxCfg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { platform } from "node:process";
|
|
2
|
-
import
|
|
2
|
+
import { copyFile, rename, readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
|
|
5
5
|
import plist from "plist";
|
|
@@ -9,6 +9,7 @@ import { log } from "../log.js";
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {object} OsxRc OSX resource configuration options
|
|
11
11
|
* @property {string} name The name of the application
|
|
12
|
+
* @property {string} icon The path to the icon file. It should be a .icns file.
|
|
12
13
|
* @property {string} LSApplicationCategoryType The category that best describes your app for the App Store.
|
|
13
14
|
* @property {string} CFBundleIdentifier A unique identifier for a bundle usually in reverse DNS format.
|
|
14
15
|
* @property {string} CFBundleName A user-visible short name for the bundle.
|
|
@@ -33,14 +34,19 @@ const setOsxConfig = async (app, outDir) => {
|
|
|
33
34
|
"MacOS apps built on Windows platform do not preserve all file permissions. See #716"
|
|
34
35
|
);
|
|
35
36
|
}
|
|
37
|
+
|
|
36
38
|
try {
|
|
37
39
|
const outApp = resolve(outDir, `${app.name}.app`);
|
|
38
|
-
await
|
|
40
|
+
await rename(resolve(outDir, "nwjs.app"), outApp);
|
|
41
|
+
if (app.icon !== undefined) {
|
|
42
|
+
await copyFile(
|
|
43
|
+
resolve(app.icon),
|
|
44
|
+
resolve(outApp, "Contents", "Resources", "app.icns")
|
|
45
|
+
);
|
|
46
|
+
}
|
|
39
47
|
|
|
40
|
-
const infoPlistPath = resolve(outApp, "Contents
|
|
41
|
-
const infoPlistJson = plist.parse(
|
|
42
|
-
await fs.readFile(infoPlistPath, "utf-8")
|
|
43
|
-
);
|
|
48
|
+
const infoPlistPath = resolve(outApp, "Contents", "Info.plist");
|
|
49
|
+
const infoPlistJson = plist.parse(await readFile(infoPlistPath, "utf-8"));
|
|
44
50
|
|
|
45
51
|
infoPlistJson.LSApplicationCategoryType = app.LSApplicationCategoryType;
|
|
46
52
|
infoPlistJson.CFBundleIdentifier = app.CFBundleIdentifier;
|
|
@@ -50,7 +56,6 @@ const setOsxConfig = async (app, outDir) => {
|
|
|
50
56
|
infoPlistJson.CFBundleVersion = app.CFBundleVersion;
|
|
51
57
|
infoPlistJson.CFBundleShortVersionString = app.CFBundleShortVersionString;
|
|
52
58
|
infoPlistJson.NSHumanReadableCopyright = app.NSHumanReadableCopyright;
|
|
53
|
-
infoPlistJson.CFBundleIconFile = app.CFBundleIconFile;
|
|
54
59
|
|
|
55
60
|
Object.keys(infoPlistJson).forEach((option) => {
|
|
56
61
|
if (infoPlistJson[option] === undefined) {
|
|
@@ -58,7 +63,7 @@ const setOsxConfig = async (app, outDir) => {
|
|
|
58
63
|
}
|
|
59
64
|
});
|
|
60
65
|
|
|
61
|
-
await
|
|
66
|
+
await writeFile(infoPlistPath, plist.build(infoPlistJson));
|
|
62
67
|
} catch (error) {
|
|
63
68
|
log.error(error);
|
|
64
69
|
}
|
package/src/cli.js
CHANGED
|
@@ -32,6 +32,42 @@ const cli = yargs(hideBin(process.argv))
|
|
|
32
32
|
type: "string",
|
|
33
33
|
description: "NW.js build artifacts",
|
|
34
34
|
})
|
|
35
|
+
.option("cacheDir", {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Cache NW.js binaries",
|
|
38
|
+
})
|
|
39
|
+
.option("downloadUrl", {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "NW.js download server",
|
|
42
|
+
})
|
|
43
|
+
.option("manifestUrl", {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "NW.js version info",
|
|
46
|
+
})
|
|
47
|
+
.option("glob", {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
description: "Flag to enable/disable globbing",
|
|
50
|
+
})
|
|
51
|
+
.option("app", {
|
|
52
|
+
type: "object",
|
|
53
|
+
description: "Platform specific app metadata. Refer to docs for more info",
|
|
54
|
+
})
|
|
55
|
+
.option("cache", {
|
|
56
|
+
type: "boolean",
|
|
57
|
+
description: "Flag to enable/disable caching",
|
|
58
|
+
})
|
|
59
|
+
.option("zip", {
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "Flag to enable/disable compression",
|
|
62
|
+
})
|
|
63
|
+
.option("ffmpeg", {
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "Flag to enable/disable downloading community ffmpeg",
|
|
66
|
+
})
|
|
67
|
+
.option("logLevel", {
|
|
68
|
+
type: "string",
|
|
69
|
+
description: "Specify log level",
|
|
70
|
+
})
|
|
35
71
|
.parse();
|
|
36
72
|
|
|
37
73
|
nwbuild({
|
package/src/index.js
CHANGED
|
@@ -14,7 +14,6 @@ import { getFiles } from "./util/files.js";
|
|
|
14
14
|
import { getVersionManifest } from "./util/versionManifest.js";
|
|
15
15
|
import { parse } from "./util/parse.js";
|
|
16
16
|
import { validate } from "./util/validate.js";
|
|
17
|
-
import { xattr } from "./util/xattr.js";
|
|
18
17
|
|
|
19
18
|
import { log, setLogLevel } from "./log.js";
|
|
20
19
|
|
|
@@ -182,8 +181,6 @@ const nwbuild = async (options) => {
|
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
|
|
185
|
-
await xattr(options.platform, options.arch, nwDir);
|
|
186
|
-
|
|
187
184
|
// Downloading binaries is required for run and build modes
|
|
188
185
|
// If mode is get, exit function since we have gotten the binaries
|
|
189
186
|
if (options.mode === "get") {
|
package/src/util/parse.js
CHANGED
|
@@ -43,6 +43,7 @@ export const parse = async (options, pkg) => {
|
|
|
43
43
|
|
|
44
44
|
options.app = options.app ?? {};
|
|
45
45
|
options.app.name = options.app.name ?? pkg.name;
|
|
46
|
+
options.app.icon = options.app.icon ?? undefined;
|
|
46
47
|
|
|
47
48
|
// TODO(#737): move this out
|
|
48
49
|
if (options.platform === "linux") {
|
|
@@ -50,7 +51,6 @@ export const parse = async (options, pkg) => {
|
|
|
50
51
|
options.app.genericName = options.app.genericName ?? undefined;
|
|
51
52
|
options.app.noDisplay = options.app.noDisplay ?? undefined;
|
|
52
53
|
options.app.comment = options.app.comment ?? undefined;
|
|
53
|
-
options.app.icon = options.app.icon ?? undefined;
|
|
54
54
|
options.app.hidden = options.app.hidden ?? undefined;
|
|
55
55
|
options.app.onlyShowIn = options.app.onlyShowIn ?? undefined;
|
|
56
56
|
options.app.notShowIn = options.app.notShowIn ?? undefined;
|
package/src/util/xattr.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { exec } from "node:child_process";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
|
|
4
|
-
import { log } from "../log.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Remove the quarantine attribute from the app bundle
|
|
8
|
-
*
|
|
9
|
-
* @param {string} platform - The platform to build for
|
|
10
|
-
* @param {string} arch - The arch to build for
|
|
11
|
-
* @param {string} nwDir - The path to the nw directory
|
|
12
|
-
* @return {Promise<void>} - A promise that resolves when the attribute is removed
|
|
13
|
-
*/
|
|
14
|
-
export const xattr = (platform, arch, nwDir) => {
|
|
15
|
-
return new Promise((res, rej) => {
|
|
16
|
-
if (platform === "osx" && arch === "arm64") {
|
|
17
|
-
let app = resolve(nwDir, "nwjs.app");
|
|
18
|
-
exec(`sudo xattr -d com.apple.quarantine ${app}`, (err, stdout) => {
|
|
19
|
-
log.debug(stdout);
|
|
20
|
-
if (err) {
|
|
21
|
-
rej(err);
|
|
22
|
-
} else {
|
|
23
|
-
res();
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
res();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
};
|