nw-builder 4.0.2 → 4.0.3
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/.github/dependabot.yml +2 -4
- package/.github/workflows/cd.yml +1 -0
- package/.github/workflows/ci.yml +3 -4
- package/README.md +324 -0
- package/package.json +16 -9
- package/src/bld/linuxCfg.js +34 -16
- package/src/bld/osxCfg.js +40 -44
- package/src/bld/package.js +29 -25
- package/src/bld/winCfg.js +42 -14
- package/src/cli.js +6 -3
- package/src/get/download.js +5 -7
- package/src/get/getReleaseInfo.js +4 -0
- package/src/nwbuild.js +172 -71
- package/src/run/develop.js +23 -7
- package/src/run/execute.js +22 -6
- package/src/util/arch.js +9 -0
- package/src/util/arch.test.js +9 -0
- package/src/util/cache.js +17 -0
- package/src/util/cache.test.js +9 -0
- package/src/util/parse.js +70 -0
- package/src/util/parse.test.js +5 -0
- package/src/util/platform.js +18 -0
- package/src/util/platform.test.js +13 -0
- package/src/util/validate.js +30 -0
- package/test/{demo/bld.cjs → e2e/bld.js} +13 -5
- package/test/e2e/nix.js +11 -0
- package/test/{demo → e2e}/nwapp/index.html +0 -0
- package/test/e2e/nwapp/package.json +6 -0
- package/test/e2e/osx.js +11 -0
- package/test/e2e/win.js +11 -0
- package/test/fixture/cacheDir/nw +0 -0
- package/docs/index.md +0 -112
- package/nwbuild.cjs +0 -113
- package/test/demo/nwapp/package.json +0 -4
package/.github/dependabot.yml
CHANGED
|
@@ -8,10 +8,8 @@ updates:
|
|
|
8
8
|
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
9
|
directory: "/" # Location of package manifests
|
|
10
10
|
schedule:
|
|
11
|
-
interval: "
|
|
12
|
-
day: "friday"
|
|
11
|
+
interval: "daily"
|
|
13
12
|
- package-ecosystem: "github-actions" # See documentation for possible values
|
|
14
13
|
directory: ".github/" # Location of package manifests
|
|
15
14
|
schedule:
|
|
16
|
-
interval: "
|
|
17
|
-
day: "friday"
|
|
15
|
+
interval: "daily"
|
package/.github/workflows/cd.yml
CHANGED
package/.github/workflows/ci.yml
CHANGED
|
@@ -20,10 +20,9 @@ jobs:
|
|
|
20
20
|
runs-on: ${{ matrix.os }}
|
|
21
21
|
steps:
|
|
22
22
|
- uses: actions/checkout@v3
|
|
23
|
-
- uses: volta-cli/action@v1
|
|
24
|
-
with:
|
|
25
|
-
node-version: ${{ matrix.node-version }}
|
|
26
|
-
npm-version: '8.5.0'
|
|
27
23
|
- run: npm ci
|
|
28
24
|
- run: npm run format
|
|
29
25
|
- run: npm run lint
|
|
26
|
+
- run: npm run test:unit
|
|
27
|
+
- run: npm run cjs
|
|
28
|
+
- run: npm run test:e2e
|
package/README.md
CHANGED
|
@@ -5,6 +5,330 @@
|
|
|
5
5
|
|
|
6
6
|
Build [NW.js](https://github.com/nwjs/nw.js) applications for Mac, Windows and Linux.
|
|
7
7
|
|
|
8
|
+
> Before using `nw-builder`, please go through how to [write an NW.js application](https://nwjs.readthedocs.io/en/latest/For%20Users/Getting%20Started/).
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Install `nw-builder` via `npm` or your preferred Node package manager of choice.
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm i -D nw-builder
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Run your first application
|
|
21
|
+
|
|
22
|
+
Module usage
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
import nwbuild from "nw-builder";
|
|
26
|
+
|
|
27
|
+
nwbuild({
|
|
28
|
+
// Globing does not matter since a process is spawned against the nwapp directory
|
|
29
|
+
srcDir: "./nwapp/**/*",
|
|
30
|
+
mode: "run",
|
|
31
|
+
version: "0.70.1",
|
|
32
|
+
flavor: "sdk",
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
CLI usage
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
nwbuild ./nwapp --mode=run --version=0.70.1 --flavor=sdk
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
package.json usage
|
|
43
|
+
|
|
44
|
+
`./nwapp/package.json`
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"name": "nwdemo",
|
|
49
|
+
"main": "./index.html",
|
|
50
|
+
"nwbuild": {
|
|
51
|
+
"srcDir": "./nwapp/**/*",
|
|
52
|
+
"mode": "run",
|
|
53
|
+
"version": "0.70.1",
|
|
54
|
+
"flavor": "sdk"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Build your first application
|
|
60
|
+
|
|
61
|
+
Module usage
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
import nwbuild from "nw-builder";
|
|
65
|
+
|
|
66
|
+
nwbuild({
|
|
67
|
+
srcDir: "./nwapp/**/*",
|
|
68
|
+
mode: "build",
|
|
69
|
+
version: "0.70.1",
|
|
70
|
+
flavor: "normal",
|
|
71
|
+
platform: "linux",
|
|
72
|
+
arch: "x64",
|
|
73
|
+
outDir: "./out",
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
CLI usage
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
nwbuild ./nwapp --mode=build --version=0.70.1 --flavor=normal --platform=linux --arch=x64 --outDir=./out
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
package.json usage
|
|
84
|
+
|
|
85
|
+
`./nwapp/package.json`
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"name": "nwdemo",
|
|
90
|
+
"main": "./index.html",
|
|
91
|
+
"nwbuild": {
|
|
92
|
+
"srcDir": "./nwapp/**/*",
|
|
93
|
+
"mode": "build",
|
|
94
|
+
"version": "0.70.1",
|
|
95
|
+
"flavor": "normal",
|
|
96
|
+
"platform": "linux",
|
|
97
|
+
"arch": "x64",
|
|
98
|
+
"outDir": "./out"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## API Reference
|
|
104
|
+
|
|
105
|
+
### Methods
|
|
106
|
+
|
|
107
|
+
`nwbuild(options) :Promise<undefined>`
|
|
108
|
+
|
|
109
|
+
| Name | Type | Default | Description |
|
|
110
|
+
| ----------- | ----------------------------------- | -------------------------- | ------------------------------------------------------------------------------ |
|
|
111
|
+
| srcDir | `string` | `./` | Directories which hold NW app code |
|
|
112
|
+
| mode | `run \| build` | `build` | Run or build application |
|
|
113
|
+
| version | `latest \| stable \| string \| lts` | `latest` | NW runtime version |
|
|
114
|
+
| flavor | `sdk \| normal` | `normal` | NW runtime build flavor. |
|
|
115
|
+
| platform | `linux \| osx \| win` | `<current platform>` | NW supported platforms |
|
|
116
|
+
| arch | `ia32 \| x64` | `<current architecture>` | NW supported architectures |
|
|
117
|
+
| outDir | `string` | `./out` | Directory to store build artifacts |
|
|
118
|
+
| cacheDir | `string` | `./cacheDir` | Directory to store NW binaries |
|
|
119
|
+
| downloadUrl | `string` | `https://dl.nwjs.io` | URI to download NW binaries from |
|
|
120
|
+
| manifestUrl | `string` | `https://nwjs.io/versions` | URI to download manifest from |
|
|
121
|
+
| cache | `boolean` | `true` | If `true` the existing cache is used. Otherwise it removes and redownloads it. |
|
|
122
|
+
| zip | `boolean` | `false` | If `true` the `outDir` directory is zipped |
|
|
123
|
+
|
|
124
|
+
## Migration to v4
|
|
125
|
+
|
|
126
|
+
### Update `nw-builder`
|
|
127
|
+
|
|
128
|
+
With npm:
|
|
129
|
+
|
|
130
|
+
```shell
|
|
131
|
+
npm update nw-builder@^4.0.3
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
With yarn:
|
|
135
|
+
|
|
136
|
+
```shell
|
|
137
|
+
yarn upgrade nw-builder@^4.0.3
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
With pnpm:
|
|
141
|
+
|
|
142
|
+
```shell
|
|
143
|
+
pnpm update nw-builder@^4.0.3
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
> Note: `nw-builder` has been tested on Node 16 and 18 only.
|
|
147
|
+
|
|
148
|
+
### Update options
|
|
149
|
+
|
|
150
|
+
Let's take an example of v3 code and migrate it to v4.
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
const NwBuilder = require("nw-builder");
|
|
154
|
+
|
|
155
|
+
const nw = new NwBuilder({
|
|
156
|
+
files: ["./nwapp/**/*", "./other/**/*.js"],
|
|
157
|
+
version: "latest",
|
|
158
|
+
flavor: "normal",
|
|
159
|
+
platforms: ["win32", "win64", "osx32", "osx64", "linux32", "linux64"],
|
|
160
|
+
cacheDir: "./cache",
|
|
161
|
+
buildDir: "./build",
|
|
162
|
+
buildType: "versioned",
|
|
163
|
+
forceDownload: true,
|
|
164
|
+
appName: "nwdemo",
|
|
165
|
+
appVersion: "0.1.0",
|
|
166
|
+
argv: "--nw-stderr-logging",
|
|
167
|
+
macCredits: "./nwapp/credits.html",
|
|
168
|
+
macIcns: "./nwapp/mac.icns",
|
|
169
|
+
macPlist: { ... },
|
|
170
|
+
winVersionString: { ... },
|
|
171
|
+
winIco: "./nwapp/win.ico",
|
|
172
|
+
zip: true,
|
|
173
|
+
macZip: false,
|
|
174
|
+
mergeZip: false,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
nw.build();
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Update the import path
|
|
181
|
+
|
|
182
|
+
```patch
|
|
183
|
+
-const NwBuilder = require("nw-builder");
|
|
184
|
+
+const nwbuild = require("nw-builder");
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Replace the `NwBuilder` initialization with a function
|
|
188
|
+
|
|
189
|
+
```patch
|
|
190
|
+
-const nw = new NwBuilder({
|
|
191
|
+
+await nwbuild({
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The `files` property has been renamed to `srcDir`.S
|
|
195
|
+
|
|
196
|
+
```patch
|
|
197
|
+
- files: ["./nwapp/**/*", "./other/**/*.js"],
|
|
198
|
+
+ srcDir: "./nwapp/**/* ./other/**/*.js",
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Add the `mode` option and remove the now redundant `nw.build` function call.
|
|
202
|
+
|
|
203
|
+
```patch
|
|
204
|
+
+ mode: "build",
|
|
205
|
+
|
|
206
|
+
-nw.build();
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The `platforms` option has been removed and replaced with `platform` and `arch`. Notice that one `nwbuild` function call now creates one build only. Refer to the [documentation](./index.md) for valid `platform` and `arch` values.
|
|
210
|
+
|
|
211
|
+
```patch
|
|
212
|
+
- platforms: ["win32", "win64", "osx32", "osx64", "linux32", "linux64"],
|
|
213
|
+
+ platform: "linux",
|
|
214
|
+
+ arch: "x64",
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
> If platform is Linux then even if Windows or MacOS specific `app.*` properties are defined, only the Linux `app.*` properties will be parsed. Multiple platform `app.*` properties have been shown in this guide to cater to all platforms.
|
|
218
|
+
|
|
219
|
+
The `buildDir` option has been rename to `outDir`.
|
|
220
|
+
|
|
221
|
+
```patch
|
|
222
|
+
- buildDir: "./build",
|
|
223
|
+
+ outDir: "./build",
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
The `buildType` option has been removed.
|
|
227
|
+
|
|
228
|
+
```patch
|
|
229
|
+
- buildType: "versioned",
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The `forceDownload` option has been changed to `cache`.
|
|
233
|
+
|
|
234
|
+
```patch
|
|
235
|
+
- forceDownload: true,
|
|
236
|
+
+ cache: false,
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
The `appName` option has been changed to `app.name`.
|
|
240
|
+
|
|
241
|
+
```patch
|
|
242
|
+
- appName: "nwdemo",
|
|
243
|
+
+ app: { name: "nwdemo" },
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The `appVersion` option has been removed. The `version` is automatically taken from `srcDir/package.json`.
|
|
247
|
+
|
|
248
|
+
```patch
|
|
249
|
+
- appVersion: "0.1.0",
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The `macCredit` option has been removed.
|
|
253
|
+
|
|
254
|
+
```patch
|
|
255
|
+
- macCredits: "./nwapp/credits.html",
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
The `macIcns` option has been replaced with `icon`.
|
|
259
|
+
|
|
260
|
+
```patch
|
|
261
|
+
- macIcns: "./nwapp/mac.icns",
|
|
262
|
+
+ icon: "./nwapp/mac.icns",
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The `macPlist` option has been removed.
|
|
266
|
+
|
|
267
|
+
```patch
|
|
268
|
+
- macPlist: { ... },
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The `winVersionString` option has been replaced with `app`.
|
|
272
|
+
|
|
273
|
+
```patch
|
|
274
|
+
- winVersionString: {
|
|
275
|
+
- 'CompanyName': 'Some Company',
|
|
276
|
+
- 'FileDescription': 'Process Name',
|
|
277
|
+
- 'ProductName': 'Some Product',
|
|
278
|
+
- 'LegalCopyright': 'Copyright 2017',
|
|
279
|
+
- }
|
|
280
|
+
+ app: {
|
|
281
|
+
+ company: "Some Company",
|
|
282
|
+
+ fileDescription: "Process Name",
|
|
283
|
+
+ productName: "Some Product",
|
|
284
|
+
+ legalCopyright: "Copyright 2017",
|
|
285
|
+
+ }
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
The `winIco` option has been replaced by `app.icon`.
|
|
289
|
+
|
|
290
|
+
```patch
|
|
291
|
+
- winIco: "./nwapp/win.ico",
|
|
292
|
+
+ app: { icon: "./nwapp/win.ico" },
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
The `macZip` option has been removed.
|
|
296
|
+
|
|
297
|
+
```patch
|
|
298
|
+
- macZip: false,
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
The `mergeZip` option has been removed.
|
|
302
|
+
|
|
303
|
+
```patch
|
|
304
|
+
- mergeZip: false,
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The final code should look like this.
|
|
308
|
+
|
|
309
|
+
```javascript
|
|
310
|
+
const { nwbuild } = require("nw-builder");
|
|
311
|
+
|
|
312
|
+
await nwbuild({
|
|
313
|
+
srcDir: "./nwapp",
|
|
314
|
+
mode: "build",
|
|
315
|
+
version: "latest",
|
|
316
|
+
flavor: "normal",
|
|
317
|
+
platform: "linux",
|
|
318
|
+
arch: "x64",
|
|
319
|
+
outDir: "./build",
|
|
320
|
+
cache: false,
|
|
321
|
+
app: {
|
|
322
|
+
name: "Some Product",
|
|
323
|
+
icon: "./nwapp/icon.png",
|
|
324
|
+
company: "Some Company",
|
|
325
|
+
fileDescription: "Process Name",
|
|
326
|
+
productName: "Some Product",
|
|
327
|
+
legalCopyright: "Copyright 2017",
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
```
|
|
331
|
+
|
|
8
332
|
## Contributing
|
|
9
333
|
|
|
10
334
|
1. Pick and install a Node version manager
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"description": "Build NW.js desktop applications for
|
|
3
|
+
"version": "4.0.3",
|
|
4
|
+
"description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
7
7
|
"node-webkit",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"main": "./src/nwbuild.js",
|
|
18
18
|
"exports": {
|
|
19
19
|
"import": "./src/nwbuild.js",
|
|
20
|
-
"require": "./nwbuild.cjs"
|
|
20
|
+
"require": "./dist/nwbuild.cjs"
|
|
21
21
|
},
|
|
22
22
|
"type": "module",
|
|
23
23
|
"homepage": "https://github.com/nwutils/nw-builder",
|
|
@@ -26,15 +26,20 @@
|
|
|
26
26
|
"url": "https://github.com/nwutils/nw-builder.git"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"format": "prettier --write \"
|
|
29
|
+
"format": "prettier --write \"./**/*.{js,cjs,md}\"",
|
|
30
30
|
"lint": "eslint ./src",
|
|
31
31
|
"docs": "jsdoc ./src/nwbuild.js -d docs",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
32
|
+
"test:cli": "cd ./test/e2e && nwbuild ./nwapp --mode=build --version=0.70.1 --flavour=normal --platform=win --arch=x64 --outDir=./build",
|
|
33
|
+
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
34
|
+
"test:e2e": "cd ./test/e2e && node bld.js",
|
|
35
|
+
"demo:nix": "cd ./test/e2e && node nix.js",
|
|
36
|
+
"demo:osx": "cd ./test/e2e && node osx.js",
|
|
37
|
+
"demo:win": "cd ./test/e2e && node win.js",
|
|
38
|
+
"cjs": "esbuild ./src/nwbuild.js --bundle --minify --legal-comments=inline --platform=node --outfile=./dist/nwbuild.cjs",
|
|
39
|
+
"checklist": "npm run cjs && npm run format && npm run lint && npm run test:unit && npm run test:e2e"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
|
-
"esbuild": "^0.
|
|
42
|
+
"esbuild": "^0.16.12",
|
|
38
43
|
"eslint": "^8.25.0",
|
|
39
44
|
"eslint-config-tjw-jsdoc": "^1.0.3",
|
|
40
45
|
"jest": "^29.2.0",
|
|
@@ -47,6 +52,7 @@
|
|
|
47
52
|
"archiver": "^5.3.1",
|
|
48
53
|
"cli-progress": "^3.11.2",
|
|
49
54
|
"extract-zip": "^2.0.1",
|
|
55
|
+
"glob-promise": "^6.0.0",
|
|
50
56
|
"plist": "^3.0.6",
|
|
51
57
|
"progress": "^2.0.3",
|
|
52
58
|
"rcedit": "^3.0.1",
|
|
@@ -80,7 +86,8 @@
|
|
|
80
86
|
},
|
|
81
87
|
"env": {
|
|
82
88
|
"es6": true,
|
|
83
|
-
"node": true
|
|
89
|
+
"node": true,
|
|
90
|
+
"jest": true
|
|
84
91
|
},
|
|
85
92
|
"extends": [
|
|
86
93
|
"eslint:recommended",
|
package/src/bld/linuxCfg.js
CHANGED
|
@@ -6,30 +6,48 @@ import { log } from "../log.js";
|
|
|
6
6
|
* Generates a Desktop Entry file for Linux
|
|
7
7
|
* https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
|
|
8
8
|
*
|
|
9
|
-
* @param {object}
|
|
10
|
-
* @param {string} outDir
|
|
9
|
+
* @param {object} app Multi platform configuration options
|
|
10
|
+
* @param {string} outDir Directory which stores build artifacts
|
|
11
11
|
* @return {undefined}
|
|
12
12
|
*/
|
|
13
|
-
export const setLinuxConfig = async (
|
|
13
|
+
export const setLinuxConfig = async (app, outDir) => {
|
|
14
14
|
let desktopEntryFile = {
|
|
15
15
|
Type: "Application",
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Version: "1.5",
|
|
17
|
+
Name: app.name,
|
|
18
|
+
GenericName: app.genericName,
|
|
19
|
+
NoDisplay: app.noDisplay,
|
|
20
|
+
Comment: app.comment,
|
|
21
|
+
Icon: app.icon,
|
|
22
|
+
Hidden: app.hidden,
|
|
23
|
+
OnlyShowIn: app.onlyShowIn,
|
|
24
|
+
NotShowIn: app.notShowIn,
|
|
25
|
+
DBusActivatable: app.dBusActivatable,
|
|
26
|
+
TryExec: app.tryExec,
|
|
27
|
+
Exec: app.name,
|
|
28
|
+
Path: app.path,
|
|
29
|
+
Terminal: app.terminal,
|
|
30
|
+
Actions: app.actions,
|
|
31
|
+
MimeType: app.mimeType,
|
|
32
|
+
Categories: app.categories,
|
|
33
|
+
Implements: app.implements,
|
|
34
|
+
Keywords: app.keywords,
|
|
35
|
+
StartupNotify: app.startupNotify,
|
|
36
|
+
StartupWMClass: app.startupWMClass,
|
|
37
|
+
PrefersNonDefaultGPU: app.prefersNonDefaultGPU,
|
|
38
|
+
SingleMainWindow: app.singleMainWindow,
|
|
18
39
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (key !== "Type") {
|
|
23
|
-
desktopEntryFile[key] = pkg.nwbuild.linuxCfg[key];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
40
|
+
|
|
41
|
+
await rename(`${outDir}/nw`, `${outDir}/${app.name}`);
|
|
42
|
+
|
|
27
43
|
let fileContent = `[Desktop Entry]\n`;
|
|
28
44
|
Object.keys(desktopEntryFile).forEach((key) => {
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
if (desktopEntryFile[key] !== undefined) {
|
|
46
|
+
fileContent += `${key}=${desktopEntryFile[key]}\n`;
|
|
47
|
+
log.debug(`Add ${key}=${desktopEntryFile[key]} to Desktop Entry File`);
|
|
48
|
+
}
|
|
31
49
|
});
|
|
32
|
-
let filePath = `${outDir}/${
|
|
50
|
+
let filePath = `${outDir}/${app.name}.desktop`;
|
|
33
51
|
await writeFile(filePath, fileContent);
|
|
34
52
|
log.debug("Desktop Entry file generated");
|
|
35
53
|
};
|
package/src/bld/osxCfg.js
CHANGED
|
@@ -3,55 +3,51 @@ import path from "node:path";
|
|
|
3
3
|
|
|
4
4
|
import plist from "plist";
|
|
5
5
|
|
|
6
|
+
import { log } from "../log.js";
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* OSX specific configuration steps
|
|
8
10
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @
|
|
11
|
+
* @param {object} pkg The srcDir/package.json as a JSON
|
|
12
|
+
* @param {string} outDir The directory to hold build artifacts
|
|
13
|
+
* @return {Promise<undefined>}
|
|
12
14
|
*/
|
|
13
15
|
const setOsxConfig = async (pkg, outDir) => {
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
// }
|
|
16
|
+
try {
|
|
17
|
+
const outApp = path.resolve(outDir, `${pkg.name}.app`);
|
|
18
|
+
await fs.rename(path.resolve(outDir, "nwjs.app"), outApp);
|
|
19
|
+
|
|
20
|
+
// Rename CFBundleDisplayName in Contents/Info.plist
|
|
21
|
+
const contentsInfoPlistPath = path.resolve(outApp, "Contents/Info.plist");
|
|
22
|
+
const contentsInfoPlistJson = plist.parse(
|
|
23
|
+
await fs.readFile(contentsInfoPlistPath, "utf-8"),
|
|
24
|
+
);
|
|
25
|
+
contentsInfoPlistJson.CFBundleDisplayName = pkg.name;
|
|
26
|
+
const contentsInfoPlist = plist.build(contentsInfoPlistJson);
|
|
27
|
+
await fs.writeFile(contentsInfoPlistPath, contentsInfoPlist);
|
|
28
|
+
|
|
29
|
+
// Rename CFBundleDisplayName in Contents/Resources/en.lproj/InfoPlist.strings
|
|
30
|
+
const contentsInfoPlistStringsPath = path.resolve(
|
|
31
|
+
outApp,
|
|
32
|
+
"Contents/Resources/en.lproj/InfoPlist.strings",
|
|
33
|
+
);
|
|
34
|
+
const contentsInfoPlistStrings = await fs.readFile(
|
|
35
|
+
contentsInfoPlistStringsPath,
|
|
36
|
+
"utf-8",
|
|
37
|
+
);
|
|
38
|
+
const newPlistStrings = contentsInfoPlistStrings.replace(
|
|
39
|
+
/CFBundleGetInfoString = "nwjs /,
|
|
40
|
+
`CFBundleGetInfoString = "${pkg.name} `,
|
|
41
|
+
);
|
|
42
|
+
await fs.writeFile(contentsInfoPlistStringsPath, newPlistStrings);
|
|
43
|
+
|
|
44
|
+
// Add product_string property to package.json
|
|
45
|
+
// const packageJsonPath = path.resolve(outApp, "Contents/Resources/app.nw/package.json");
|
|
46
|
+
// pkg.product_string = pkg.name;
|
|
47
|
+
// await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 4));
|
|
48
|
+
} catch (error) {
|
|
49
|
+
log.error(error);
|
|
50
|
+
}
|
|
55
51
|
};
|
|
56
52
|
|
|
57
53
|
export { setOsxConfig };
|
package/src/bld/package.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { cp,
|
|
1
|
+
import { cp, rm } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
2
3
|
|
|
3
4
|
import { log } from "../log.js";
|
|
4
5
|
|
|
@@ -10,49 +11,52 @@ import { setWinConfig } from "./winCfg.js";
|
|
|
10
11
|
/**
|
|
11
12
|
* Generate NW build artifacts
|
|
12
13
|
*
|
|
13
|
-
* @param {string}
|
|
14
|
+
* @param {string[]} files Array of NW app files
|
|
14
15
|
* @param {string} nwDir Directory to hold NW binaries
|
|
15
16
|
* @param {string} outDir Directory to store build artifacts
|
|
16
17
|
* @param {"linux" | "osx" | "win"} platform Platform is the operating system type
|
|
17
18
|
* @param {"zip" | boolean} zip Specify if the build artifacts are to be zipped
|
|
18
19
|
* @param {object} releaseInfo NW version specific release information
|
|
19
|
-
* @
|
|
20
|
+
* @param {object} app Multi platform configuration options
|
|
21
|
+
* @return {Promise<undefined>}
|
|
20
22
|
*/
|
|
21
|
-
const packager = async (
|
|
23
|
+
const packager = async (
|
|
24
|
+
files,
|
|
25
|
+
nwDir,
|
|
26
|
+
outDir,
|
|
27
|
+
platform,
|
|
28
|
+
zip,
|
|
29
|
+
releaseInfo,
|
|
30
|
+
app,
|
|
31
|
+
) => {
|
|
22
32
|
log.debug(`Remove any files at ${outDir} directory`);
|
|
23
33
|
await rm(outDir, { force: true, recursive: true });
|
|
24
34
|
log.debug(`Copy ${nwDir} files to ${outDir} directory`);
|
|
25
35
|
await cp(nwDir, outDir, { recursive: true });
|
|
26
|
-
log.debug(`Copy ${srcDir} files to ${outDir} directory`);
|
|
27
|
-
await cp(
|
|
28
|
-
srcDir,
|
|
29
|
-
`${outDir}/${
|
|
30
|
-
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/app.nw"
|
|
31
|
-
}`,
|
|
32
|
-
{
|
|
33
|
-
recursive: true,
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
for (const file of files) {
|
|
38
|
+
log.debug(`Copy ${file} file to ${outDir} directory`);
|
|
39
|
+
await cp(
|
|
40
|
+
file,
|
|
41
|
+
`${outDir}/${
|
|
42
|
+
platform !== "osx" ? "package.nw" : "nwjs.app/Contents/Resources/app.nw"
|
|
43
|
+
}/${basename(file)}`,
|
|
44
|
+
{
|
|
45
|
+
recursive: true,
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
}
|
|
45
49
|
|
|
46
50
|
log.debug(`Starting platform specific config steps for ${platform}`);
|
|
47
51
|
switch (platform) {
|
|
48
52
|
case "linux":
|
|
49
|
-
setLinuxConfig(
|
|
53
|
+
setLinuxConfig(app, outDir);
|
|
50
54
|
break;
|
|
51
55
|
case "win":
|
|
52
|
-
setWinConfig(
|
|
56
|
+
setWinConfig(app, outDir);
|
|
53
57
|
break;
|
|
54
58
|
case "osx":
|
|
55
|
-
setOsxConfig(
|
|
59
|
+
setOsxConfig(app, outDir, releaseInfo);
|
|
56
60
|
break;
|
|
57
61
|
default:
|
|
58
62
|
break;
|