nw-builder 4.17.13 → 4.18.1

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/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
- /** String of space separated glob patterns which correspond to NW app code */
9
- srcDir?: "./" | string,
10
- /** Run or build application */
11
- mode?: "build" | "get" | "run",
12
- /** NW runtime version */
13
- version?: "latest" | "stable" | string,
14
- /** NW runtime flavor */
15
- flavor?: "normal" | "sdk",
16
- /** NW supported platforms */
17
- platform?: P,
18
- /** NW supported architectures */
19
- arch?: "ia32" | "x64" | "arm64",
20
- /** Directory to store build artifacts */
21
- outDir?: "./out" | string,
22
- /** Directry to store NW binaries */
23
- cacheDir?: "./cache" | string,
24
- /** URI to download NW binaries from */
25
- downloadUrl?: "https://dl.nwjs.io" | string,
26
- /** URI to download manifest */
27
- manifestUrl?: "https://nwjs.io/versions.json" | string,
28
- /** Refer to Linux/Windows/Osx specific options */
29
- app: AppOptions<P>,
30
- /** If true the existing cache is used. Otherwise it removes and redownloads it. */
31
- cache?: boolean,
32
- /** If true, "zip", "tar" or "tgz" the outDir directory is compressed. */
33
- zip?: boolean | "zip" | "tar" | "tgz",
34
- /** If true the CLI is used to glob srcDir and parse other options */
35
- cli?: boolean,
36
- /** If true the chromium ffmpeg is replaced by community version */
37
- ffmpeg?: boolean,
38
- /** If true globbing is enabled */
39
- glob?: boolean,
40
- /** Specified log level. */
41
- logLevel?: "error" | "warn" | "info" | "debug",
42
- /** Managed manifest */
43
- managedManifest?: boolean | string | object,
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
- P extends 'win' ? WindowsAppOptions :
49
- P extends 'osx' ? OsxAppOptions :
50
- P extends 'linux' ? LinuxAppOptions
51
- : (WindowsAppOptions | OsxAppOptions | LinuxAppOptions);
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
- /** The name of the application */
63
- name?: string,
64
- /** The version of the application */
65
- version?: string,
66
- /** Additional information that should be displayed for diagnostic purposes. */
67
- comments?: string,
68
- /** Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required. */
69
- company: string,
70
- /** 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. */
71
- fileDescription: string,
72
- /** Version number of the file. For example, 3.10 or 5.00.RC2. This string is required. */
73
- fileVersion: string,
74
- /** The path to the icon file. It should be a .ico file. */
75
- icon?: string,
76
- /** 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. */
77
- internalName: string,
78
- /** 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. */
79
- legalCopyright?: string,
80
- /** 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. */
81
- legalTrademark?: string,
82
- /** 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. */
83
- originalFilename: string,
84
- /** 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. */
85
- privateBuild?: string,
86
- /** Name of the product with which the file is distributed. This string is required. */
87
- productName: string,
88
- /** Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. This string is required. */
89
- productVersion: string,
90
- /** 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. */
91
- specialBuild?: string,
92
- /** Language of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a */
93
- languageCode?: number,
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
- /** Name of the application */
103
- name?: string,
104
- /** Generic name of the application */
105
- genericName?: string,
106
- /** If true the application is not displayed */
107
- noDisplay?: boolean,
108
- /** Tooltip for the entry, for example "View sites on the Internet". */
109
- comment?: string,
110
- /** Icon to display in file manager, menus, etc. */
111
- icon?: string,
112
- /** A list of strings identifying the desktop environments that should (/not) display a given desktop entry */
113
- onlyShowIn?: string[],
114
- /** A list of strings identifying the desktop environments that should (/not) display a given desktop entry */
115
- notShowIn?: string[],
116
- /** A boolean value specifying if D-Bus activation is supported for this application */
117
- dBusActivatable?: boolean,
118
- /** Path to an executable file on disk used to determine if the program is actually installed */
119
- tryExec?: string,
120
- /** Program to execute, possibly with arguments. */
121
- exec?: string,
122
- /** If entry is of type Application, the working directory to run the program in. */
123
- path?: string,
124
- /** Whether the program runs in a terminal window. */
125
- terminal?: boolean,
126
- /** Identifiers for application actions. */
127
- actions?: string[],
128
- /** The MIME type(s) supported by this application. */
129
- mimeType?: string[],
130
- /** Categories in which the entry should be shown in a menu */
131
- categories?: string[],
132
- /** A list of interfaces that this application implements. */
133
- implements?: string[],
134
- /** A list of strings which may be used in addition to other metadata to describe this entry. */
135
- keywords?: string[],
136
- /** 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. */
137
- startupNotify?: boolean,
138
- /** 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 */
139
- startupWMClass?: string,
140
- /** If true, the application prefers to be run on a more powerful discrete GPU if available. */
141
- prefersNonDefaultGPU?: boolean,
142
- /** If true, the application has a single main window, and does not support having an additional one opened. */
143
- singleMainWindow?: string,
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
- /** The name of the application */
153
- name?: string,
154
- /** The path to the icon file. It should be a .icns file. */
155
- icon?: string,
156
- /** The category that best describes your app for the App Store. */
157
- LSApplicationCategoryType?: string,
158
- /** A unique identifier for a bundle usually in reverse DNS format. */
159
- CFBundleIdentifier?: string,
160
- /** A user-visible short name for the bundle. */
161
- CFBundleName?: string,
162
- /** The user-visible name for the bundle. */
163
- CFBundleDisplayName?: string,
164
- /** A replacement for the app name in text-to-speech operations. */
165
- CFBundleSpokenName?: string,
166
- /** The version of the build that identifies an iteration of the bundle. */
167
- CFBundleVersion?: string,
168
- /** The release or version number of the bundle. */
169
- CFBundleShortVersionString?: string,
170
- /** A human-readable copyright notice for the bundle. */
171
- NSHumanReadableCopyright?: string,
172
- /** A human-readable description of why the application needs access to the local network. */
173
- NSLocalNetworkUsageDescription?: string,
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>(options: Options<P>): Promise<child_process.ChildProcess | null | undefined>;
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 'node:child_process';
2
- import console from 'node:console';
3
- import fs from 'node:fs';
4
- import path from 'node:path';
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 '@nwutils/getter';
7
- import run from '@nwutils/runner';
6
+ import get from "@nwutils/getter";
7
+ import run from "@nwutils/runner";
8
8
 
9
- import bld from './bld.js';
10
- import util from './util.js';
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('debug', 'info', 'Parse initial options');
54
+ util.log("debug", "info", "Parse initial options");
55
55
 
56
- util.log('debug', 'info', 'Get node manifest...');
57
- manifest = await util.getNodeManifest({ srcDir: options.srcDir, glob: options.glob });
58
- if (typeof manifest.json?.nwbuild === 'object') {
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('info', options.logLevel, 'Parse final options using node manifest');
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('debug', options.logLevel, 'Manifest: ', `${manifest.path}\n${manifest.json}\n`);
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 === 'build') {
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('info', options.logLevel, 'Get version specific release info...');
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('debug', options.logLevel, `Release info:\n${JSON.stringify(releaseInfo, null, 2)}\n`);
99
+ util.log(
100
+ "debug",
101
+ options.logLevel,
102
+ `Release info:\n${JSON.stringify(releaseInfo, null, 2)}\n`,
103
+ );
88
104
 
89
- util.log('info', options.logLevel, 'Validate options.* ...');
105
+ util.log("info", options.logLevel, "Validate options.* ...");
90
106
  await util.validate(options, releaseInfo);
91
- util.log('debug', options.logLevel, `Options:\n${JSON.stringify(options, null, 2)}`);
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('info', options.logLevel, 'Getting NW.js and related binaries...');
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 === 'get') {
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 === 'run') {
118
- util.log('info', options.logLevel, 'Running NW.js in run mode...');
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('Glob option is not supported when mode is set to run.');
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 === 'build') {
133
- util.log('info', options.logLevel, `Build a NW.js application for ${options.platform} ${options.arch}...`);
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('info', options.logLevel, `Appliction is available at ${path.resolve(options.outDir)}`);
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);
@@ -1,11 +1,19 @@
1
- import path from 'node:path';
2
- import url from 'node:url';
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(path.join(__dirname, '..', 'node_modules', 'base-volta-off-of-nwjs', 'index.js'));
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('Node version is updated'))
18
+ .then(() => console.log("Node version is updated"))
11
19
  .catch((error) => console.log(error));