nw-builder 4.17.12 → 4.18.0
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 +89 -89
- package/package.json +13 -9
- package/src/bld/osx.js +78 -52
- package/src/bld.js +106 -94
- package/src/cli.js +44 -24
- package/src/index.d.ts +142 -139
- package/src/index.js +58 -28
- package/src/postinstall.js +12 -4
- package/src/util.js +516 -271
package/src/index.d.ts
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
|
|
2
1
|
/** NW supported platform */
|
|
3
2
|
export type SupportedPlatform = "linux" | "osx" | "win";
|
|
4
3
|
|
|
5
4
|
/** Configuration options
|
|
6
5
|
*/
|
|
7
6
|
export interface Options<P extends SupportedPlatform = SupportedPlatform> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
7
|
+
/** String of space separated glob patterns which correspond to NW app code */
|
|
8
|
+
srcDir?: "./" | string;
|
|
9
|
+
/** Run or build application */
|
|
10
|
+
mode?: "build" | "get" | "run";
|
|
11
|
+
/** NW runtime version */
|
|
12
|
+
version?: "latest" | "stable" | string;
|
|
13
|
+
/** NW runtime flavor */
|
|
14
|
+
flavor?: "normal" | "sdk";
|
|
15
|
+
/** NW supported platforms */
|
|
16
|
+
platform?: P;
|
|
17
|
+
/** NW supported architectures */
|
|
18
|
+
arch?: "ia32" | "x64" | "arm64";
|
|
19
|
+
/** Directory to store build artifacts */
|
|
20
|
+
outDir?: "./out" | string;
|
|
21
|
+
/** Directry to store NW binaries */
|
|
22
|
+
cacheDir?: "./cache" | string;
|
|
23
|
+
/** URI to download NW binaries from */
|
|
24
|
+
downloadUrl?: "https://dl.nwjs.io" | string;
|
|
25
|
+
/** URI to download manifest */
|
|
26
|
+
manifestUrl?: "https://nwjs.io/versions.json" | string;
|
|
27
|
+
/** Refer to Linux/Windows/Osx specific options */
|
|
28
|
+
app: AppOptions<P>;
|
|
29
|
+
/** If true the existing cache is used. Otherwise it removes and redownloads it. */
|
|
30
|
+
cache?: boolean;
|
|
31
|
+
/** If true, "zip", "tar" or "tgz" the outDir directory is compressed. */
|
|
32
|
+
zip?: boolean | "zip" | "tar" | "tgz";
|
|
33
|
+
/** If true the CLI is used to glob srcDir and parse other options */
|
|
34
|
+
cli?: boolean;
|
|
35
|
+
/** If true the chromium ffmpeg is replaced by community version */
|
|
36
|
+
ffmpeg?: boolean;
|
|
37
|
+
/** If true globbing is enabled */
|
|
38
|
+
glob?: boolean;
|
|
39
|
+
/** Specified log level. */
|
|
40
|
+
logLevel?: "error" | "warn" | "info" | "debug";
|
|
41
|
+
/** Managed manifest */
|
|
42
|
+
managedManifest?: boolean | string | object;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/** Platform-specific application options */
|
|
47
|
-
export type AppOptions<P extends SupportedPlatform> =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
:
|
|
46
|
+
export type AppOptions<P extends SupportedPlatform> = P extends "win"
|
|
47
|
+
? WindowsAppOptions
|
|
48
|
+
: P extends "osx"
|
|
49
|
+
? OsxAppOptions
|
|
50
|
+
: P extends "linux"
|
|
51
|
+
? LinuxAppOptions
|
|
52
|
+
: WindowsAppOptions | OsxAppOptions | LinuxAppOptions;
|
|
52
53
|
|
|
53
54
|
/** Windows configuration options
|
|
54
55
|
*
|
|
@@ -59,38 +60,38 @@ export type AppOptions<P extends SupportedPlatform> =
|
|
|
59
60
|
* - https://learn.microsoft.com/en-gb/windows/win32/menurc/versioninfo-resource
|
|
60
61
|
*/
|
|
61
62
|
export interface WindowsAppOptions {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
63
|
+
/** The name of the application */
|
|
64
|
+
name?: string;
|
|
65
|
+
/** The version of the application */
|
|
66
|
+
version?: string;
|
|
67
|
+
/** Additional information that should be displayed for diagnostic purposes. */
|
|
68
|
+
comments?: string;
|
|
69
|
+
/** Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required. */
|
|
70
|
+
company: string;
|
|
71
|
+
/** 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. */
|
|
72
|
+
fileDescription: string;
|
|
73
|
+
/** Version number of the file. For example, 3.10 or 5.00.RC2. This string is required. */
|
|
74
|
+
fileVersion: string;
|
|
75
|
+
/** The path to the icon file. It should be a .ico file. */
|
|
76
|
+
icon?: string;
|
|
77
|
+
/** 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. */
|
|
78
|
+
internalName: string;
|
|
79
|
+
/** 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. */
|
|
80
|
+
legalCopyright?: string;
|
|
81
|
+
/** 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. */
|
|
82
|
+
legalTrademark?: string;
|
|
83
|
+
/** 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. */
|
|
84
|
+
originalFilename: string;
|
|
85
|
+
/** Information about a private version of the file—for example, Built by TESTER1 on \\TESTBED. This string should be present only if VS_FF_PRIVATEBUILD is specified in the fileflags parameter of the root block. */
|
|
86
|
+
privateBuild?: string;
|
|
87
|
+
/** Name of the product with which the file is distributed. This string is required. */
|
|
88
|
+
productName: string;
|
|
89
|
+
/** Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. This string is required. */
|
|
90
|
+
productVersion: string;
|
|
91
|
+
/** 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. This string should be present only if VS_FF_SPECIALBUILD is specified in the fileflags parameter of the root block. */
|
|
92
|
+
specialBuild?: string;
|
|
93
|
+
/** Language of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a */
|
|
94
|
+
languageCode?: number;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
/** Linux configuration options
|
|
@@ -99,48 +100,48 @@ export interface WindowsAppOptions {
|
|
|
99
100
|
* https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
|
|
100
101
|
*/
|
|
101
102
|
export interface LinuxAppOptions {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
103
|
+
/** Name of the application */
|
|
104
|
+
name?: string;
|
|
105
|
+
/** Generic name of the application */
|
|
106
|
+
genericName?: string;
|
|
107
|
+
/** If true the application is not displayed */
|
|
108
|
+
noDisplay?: boolean;
|
|
109
|
+
/** Tooltip for the entry, for example "View sites on the Internet". */
|
|
110
|
+
comment?: string;
|
|
111
|
+
/** Icon to display in file manager, menus, etc. */
|
|
112
|
+
icon?: string;
|
|
113
|
+
/** A list of strings identifying the desktop environments that should (/not) display a given desktop entry */
|
|
114
|
+
onlyShowIn?: string[];
|
|
115
|
+
/** A list of strings identifying the desktop environments that should (/not) display a given desktop entry */
|
|
116
|
+
notShowIn?: string[];
|
|
117
|
+
/** A boolean value specifying if D-Bus activation is supported for this application */
|
|
118
|
+
dBusActivatable?: boolean;
|
|
119
|
+
/** Path to an executable file on disk used to determine if the program is actually installed */
|
|
120
|
+
tryExec?: string;
|
|
121
|
+
/** Program to execute, possibly with arguments. */
|
|
122
|
+
exec?: string;
|
|
123
|
+
/** If entry is of type Application, the working directory to run the program in. */
|
|
124
|
+
path?: string;
|
|
125
|
+
/** Whether the program runs in a terminal window. */
|
|
126
|
+
terminal?: boolean;
|
|
127
|
+
/** Identifiers for application actions. */
|
|
128
|
+
actions?: string[];
|
|
129
|
+
/** The MIME type(s) supported by this application. */
|
|
130
|
+
mimeType?: string[];
|
|
131
|
+
/** Categories in which the entry should be shown in a menu */
|
|
132
|
+
categories?: string[];
|
|
133
|
+
/** A list of interfaces that this application implements. */
|
|
134
|
+
implements?: string[];
|
|
135
|
+
/** A list of strings which may be used in addition to other metadata to describe this entry. */
|
|
136
|
+
keywords?: string[];
|
|
137
|
+
/** If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_STARTUP_ID environment variable set. If false, it is KNOWN that the application does not work with startup notification at all. */
|
|
138
|
+
startupNotify?: boolean;
|
|
139
|
+
/** If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hin */
|
|
140
|
+
startupWMClass?: string;
|
|
141
|
+
/** If true, the application prefers to be run on a more powerful discrete GPU if available. */
|
|
142
|
+
prefersNonDefaultGPU?: boolean;
|
|
143
|
+
/** If true, the application has a single main window, and does not support having an additional one opened. */
|
|
144
|
+
singleMainWindow?: string;
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
/** OSX resource configuration options
|
|
@@ -149,33 +150,35 @@ export interface LinuxAppOptions {
|
|
|
149
150
|
* https://developer.apple.com/documentation/bundleresources/information_property_list
|
|
150
151
|
*/
|
|
151
152
|
export interface OsxAppOptions {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
153
|
+
/** The name of the application */
|
|
154
|
+
name?: string;
|
|
155
|
+
/** The path to the icon file. It should be a .icns file. */
|
|
156
|
+
icon?: string;
|
|
157
|
+
/** The category that best describes your app for the App Store. */
|
|
158
|
+
LSApplicationCategoryType?: string;
|
|
159
|
+
/** A unique identifier for a bundle usually in reverse DNS format. */
|
|
160
|
+
CFBundleIdentifier?: string;
|
|
161
|
+
/** A user-visible short name for the bundle. */
|
|
162
|
+
CFBundleName?: string;
|
|
163
|
+
/** The user-visible name for the bundle. */
|
|
164
|
+
CFBundleDisplayName?: string;
|
|
165
|
+
/** A replacement for the app name in text-to-speech operations. */
|
|
166
|
+
CFBundleSpokenName?: string;
|
|
167
|
+
/** The version of the build that identifies an iteration of the bundle. */
|
|
168
|
+
CFBundleVersion?: string;
|
|
169
|
+
/** The release or version number of the bundle. */
|
|
170
|
+
CFBundleShortVersionString?: string;
|
|
171
|
+
/** A human-readable copyright notice for the bundle. */
|
|
172
|
+
NSHumanReadableCopyright?: string;
|
|
173
|
+
/** A human-readable description of why the application needs access to the local network. */
|
|
174
|
+
NSLocalNetworkUsageDescription?: string;
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
/**
|
|
177
178
|
* Automates building an NW.js application.
|
|
178
179
|
*/
|
|
179
|
-
declare function nwbuild<P extends SupportedPlatform>(
|
|
180
|
+
declare function nwbuild<P extends SupportedPlatform>(
|
|
181
|
+
options: Options<P>,
|
|
182
|
+
): Promise<child_process.ChildProcess | null | undefined>;
|
|
180
183
|
|
|
181
184
|
export default nwbuild;
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import child_process from
|
|
2
|
-
import console from
|
|
3
|
-
import fs from
|
|
4
|
-
import path from
|
|
1
|
+
import child_process from "node:child_process";
|
|
2
|
+
import console from "node:console";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
5
|
|
|
6
|
-
import get from
|
|
7
|
-
import run from
|
|
6
|
+
import get from "@nwutils/getter";
|
|
7
|
+
import run from "@nwutils/runner";
|
|
8
8
|
|
|
9
|
-
import bld from
|
|
10
|
-
import util from
|
|
9
|
+
import bld from "./bld.js";
|
|
10
|
+
import util from "./util.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @typedef {object} Options Configuration options
|
|
@@ -44,31 +44,43 @@ async function nwbuild(options) {
|
|
|
44
44
|
let built;
|
|
45
45
|
let releaseInfo;
|
|
46
46
|
let manifest = {
|
|
47
|
-
path:
|
|
47
|
+
path: "",
|
|
48
48
|
json: undefined,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
try {
|
|
52
52
|
/* Parse options */
|
|
53
53
|
options = await util.parse(options, manifest);
|
|
54
|
-
util.log(
|
|
54
|
+
util.log("debug", "info", "Parse initial options");
|
|
55
55
|
|
|
56
|
-
util.log(
|
|
57
|
-
manifest = await util.getNodeManifest({
|
|
58
|
-
|
|
56
|
+
util.log("debug", "info", "Get node manifest...");
|
|
57
|
+
manifest = await util.getNodeManifest({
|
|
58
|
+
srcDir: options.srcDir,
|
|
59
|
+
glob: options.glob,
|
|
60
|
+
});
|
|
61
|
+
if (typeof manifest.json?.nwbuild === "object") {
|
|
59
62
|
options = { ...options, ...manifest.json.nwbuild };
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
util.log(
|
|
65
|
+
util.log(
|
|
66
|
+
"info",
|
|
67
|
+
options.logLevel,
|
|
68
|
+
"Parse final options using node manifest",
|
|
69
|
+
);
|
|
63
70
|
options = await util.parse(options, manifest.json);
|
|
64
|
-
util.log(
|
|
71
|
+
util.log(
|
|
72
|
+
"debug",
|
|
73
|
+
options.logLevel,
|
|
74
|
+
"Manifest: ",
|
|
75
|
+
`${manifest.path}\n${manifest.json}\n`,
|
|
76
|
+
);
|
|
65
77
|
|
|
66
78
|
built = fs.existsSync(options.cacheDir);
|
|
67
79
|
if (built === false) {
|
|
68
80
|
await fs.promises.mkdir(options.cacheDir, { recursive: true });
|
|
69
81
|
}
|
|
70
82
|
|
|
71
|
-
if (options.mode ===
|
|
83
|
+
if (options.mode === "build") {
|
|
72
84
|
built = fs.existsSync(options.outDir);
|
|
73
85
|
if (built === false) {
|
|
74
86
|
await fs.promises.mkdir(options.outDir, { recursive: true });
|
|
@@ -76,7 +88,7 @@ async function nwbuild(options) {
|
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
/* Validate options.version to get the version specific release info */
|
|
79
|
-
util.log(
|
|
91
|
+
util.log("info", options.logLevel, "Get version specific release info...");
|
|
80
92
|
releaseInfo = await util.getReleaseInfo(
|
|
81
93
|
options.version,
|
|
82
94
|
options.platform,
|
|
@@ -84,16 +96,24 @@ async function nwbuild(options) {
|
|
|
84
96
|
options.cacheDir,
|
|
85
97
|
options.manifestUrl,
|
|
86
98
|
);
|
|
87
|
-
util.log(
|
|
99
|
+
util.log(
|
|
100
|
+
"debug",
|
|
101
|
+
options.logLevel,
|
|
102
|
+
`Release info:\n${JSON.stringify(releaseInfo, null, 2)}\n`,
|
|
103
|
+
);
|
|
88
104
|
|
|
89
|
-
util.log(
|
|
105
|
+
util.log("info", options.logLevel, "Validate options.* ...");
|
|
90
106
|
await util.validate(options, releaseInfo);
|
|
91
|
-
util.log(
|
|
107
|
+
util.log(
|
|
108
|
+
"debug",
|
|
109
|
+
options.logLevel,
|
|
110
|
+
`Options:\n${JSON.stringify(options, null, 2)}`,
|
|
111
|
+
);
|
|
92
112
|
|
|
93
113
|
/* Remove leading "v" from version string */
|
|
94
114
|
options.version = releaseInfo.version.slice(1);
|
|
95
115
|
|
|
96
|
-
util.log(
|
|
116
|
+
util.log("info", options.logLevel, "Getting NW.js and related binaries...");
|
|
97
117
|
await get({
|
|
98
118
|
version: options.version,
|
|
99
119
|
flavor: options.flavor,
|
|
@@ -109,15 +129,17 @@ async function nwbuild(options) {
|
|
|
109
129
|
logLevel: options.logLevel,
|
|
110
130
|
});
|
|
111
131
|
|
|
112
|
-
if (options.mode ===
|
|
132
|
+
if (options.mode === "get") {
|
|
113
133
|
// Do nothing else since we have already downloaded the binaries.
|
|
114
134
|
return undefined;
|
|
115
135
|
}
|
|
116
136
|
|
|
117
|
-
if (options.mode ===
|
|
118
|
-
util.log(
|
|
137
|
+
if (options.mode === "run") {
|
|
138
|
+
util.log("info", options.logLevel, "Running NW.js in run mode...");
|
|
119
139
|
if (options.glob) {
|
|
120
|
-
throw new Error(
|
|
140
|
+
throw new Error(
|
|
141
|
+
"Glob option is not supported when mode is set to run.",
|
|
142
|
+
);
|
|
121
143
|
}
|
|
122
144
|
const nwProcess = await run({
|
|
123
145
|
version: options.version,
|
|
@@ -129,8 +151,12 @@ async function nwbuild(options) {
|
|
|
129
151
|
argv: options.argv,
|
|
130
152
|
});
|
|
131
153
|
return nwProcess;
|
|
132
|
-
} else if (options.mode ===
|
|
133
|
-
util.log(
|
|
154
|
+
} else if (options.mode === "build") {
|
|
155
|
+
util.log(
|
|
156
|
+
"info",
|
|
157
|
+
options.logLevel,
|
|
158
|
+
`Build a NW.js application for ${options.platform} ${options.arch}...`,
|
|
159
|
+
);
|
|
134
160
|
await bld({
|
|
135
161
|
version: options.version,
|
|
136
162
|
flavor: options.flavor,
|
|
@@ -146,7 +172,11 @@ async function nwbuild(options) {
|
|
|
146
172
|
zip: options.zip,
|
|
147
173
|
releaseInfo: releaseInfo,
|
|
148
174
|
});
|
|
149
|
-
util.log(
|
|
175
|
+
util.log(
|
|
176
|
+
"info",
|
|
177
|
+
options.logLevel,
|
|
178
|
+
`Appliction is available at ${path.resolve(options.outDir)}`,
|
|
179
|
+
);
|
|
150
180
|
}
|
|
151
181
|
} catch (error) {
|
|
152
182
|
console.error(error);
|
package/src/postinstall.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
import path
|
|
2
|
-
import url from
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import url from "node:url";
|
|
3
3
|
|
|
4
4
|
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
5
5
|
|
|
6
|
-
const baseVoltaPath = path.resolve(
|
|
6
|
+
const baseVoltaPath = path.resolve(
|
|
7
|
+
path.join(
|
|
8
|
+
__dirname,
|
|
9
|
+
"..",
|
|
10
|
+
"node_modules",
|
|
11
|
+
"base-volta-off-of-nwjs",
|
|
12
|
+
"index.js",
|
|
13
|
+
),
|
|
14
|
+
);
|
|
7
15
|
|
|
8
16
|
/* Execute the script in development mode only since it is used during testing */
|
|
9
17
|
import(baseVoltaPath)
|
|
10
|
-
.then(() => console.log(
|
|
18
|
+
.then(() => console.log("Node version is updated"))
|
|
11
19
|
.catch((error) => console.log(error));
|