nw-builder 3.5.6 → 3.7.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/.github/CHANGELOG.md +128 -0
- package/.github/CODE_OF_CONDUCT.md +55 -0
- package/.github/ISSUE_TEMPLATE.md +17 -0
- package/{LICENSE → .github/LICENSE} +0 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +5 -0
- package/.github/workflows/cd.yml +24 -0
- package/.github/workflows/ci.yml +30 -0
- package/README.md +169 -113
- package/bin/nwbuild.cjs +97 -0
- package/dist/index.cjs +1 -0
- package/lib/Version.cjs +81 -0
- package/lib/downloader.cjs +177 -0
- package/lib/index.cjs +1078 -0
- package/lib/platformOverrides.cjs +147 -0
- package/lib/platforms.cjs +141 -0
- package/lib/utils.cjs +293 -0
- package/lib/versions.cjs +206 -0
- package/package.json +94 -62
- package/src/index.js +2 -0
- package/src/schema/Platform.js +16 -0
- package/src/schema/index.js +3 -0
- package/src/utilities/checkCache.js +30 -0
- package/src/utilities/detectCurrentPlatform.js +24 -0
- package/src/utilities/index.js +4 -0
- package/test/demo/icon.icns +0 -0
- package/test/demo/icon.ico +0 -0
- package/test/demo/index.cjs +14 -0
- package/test/demo/index.html +10 -0
- package/test/demo/package.json +24 -0
- package/test/downloader.cjs +131 -0
- package/test/expected/README.md +7 -0
- package/test/expected/merged +1 -0
- package/test/expected/oneOveriddenRestNot/README.md +7 -0
- package/test/expected/oneOveriddenRestNot/osx32.json +9 -0
- package/test/expected/oneOveriddenRestNot/osx64.json +9 -0
- package/test/expected/osx-plist/1.plist +47 -0
- package/test/expected/osx-plist/2.plist +40 -0
- package/test/expected/osx-plist/README.md +7 -0
- package/test/expected/platformOverrides/README.md +7 -0
- package/test/expected/platformOverrides/linux32.json +13 -0
- package/test/expected/platformOverrides/linux64.json +9 -0
- package/test/expected/platformOverrides/osx32.json +12 -0
- package/test/expected/platformOverrides/osx64.json +12 -0
- package/test/expected/platformOverrides/win32.json +12 -0
- package/test/expected/platformOverrides/win64.json +12 -0
- package/test/fixtures/README.md +7 -0
- package/test/fixtures/invalid.json +3 -0
- package/test/fixtures/manifest/README.md +7 -0
- package/test/fixtures/manifest/versions.json +29 -0
- package/test/fixtures/nwapp/README.md +7 -0
- package/test/fixtures/nwapp/images/imagefile.img +1 -0
- package/test/fixtures/nwapp/index.html +13 -0
- package/test/fixtures/nwapp/javascript/bower_packages/simple/package.json +1 -0
- package/test/fixtures/nwapp/javascript/jsfile.js +1 -0
- package/test/fixtures/nwapp/package.json +5 -0
- package/test/fixtures/oneOveriddenRestNot/README.md +7 -0
- package/test/fixtures/oneOveriddenRestNot/package.json +16 -0
- package/test/fixtures/osx-plist/Info.plist +93 -0
- package/test/fixtures/osx-plist/README.md +7 -0
- package/test/fixtures/platformOverrides/README.md +7 -0
- package/test/fixtures/platformOverrides/package.json +72 -0
- package/test/fixtures/test-strip.zip +0 -0
- package/test/fixtures/test.tar.gz +0 -0
- package/test/fixtures/test.zip +0 -0
- package/test/fixtures/testVersions.html +74 -0
- package/test/nwBuilder.cjs +339 -0
- package/test/unit/checkCache.test.js +19 -0
- package/test/unit/checkCacheDir/v0.64.1/linux64/nw1.app +0 -0
- package/test/unit/checkCacheDir/v0.64.1/linux64/nw2.app +0 -0
- package/test/unit/detectCurrentPlatform.test.js +58 -0
- package/test/utils.cjs +310 -0
- package/test/versions.cjs +486 -0
- package/CHANGELOG.md +0 -83
- package/bin/README.md +0 -7
- package/bin/nwbuild +0 -101
- package/index.js +0 -1
- package/lib/README.md +0 -7
- package/lib/Version.js +0 -60
- package/lib/detectCurrentPlatform.js +0 -17
- package/lib/downloader.js +0 -192
- package/lib/index.js +0 -863
- package/lib/platforms.js +0 -76
- package/lib/utils.js +0 -249
- package/lib/versions.js +0 -198
package/README.md
CHANGED
|
@@ -1,52 +1,79 @@
|
|
|
1
|
-
# nw-builder
|
|
1
|
+
# nw-builder
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/nw-builder)
|
|
4
|
+
[](https://github.com/nwjs-community/nw-builder/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/nwjs-community/nw-builder/actions/workflows/cd.yml)
|
|
6
|
+
[](https://gitter.im/nwjs/nw-builder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
Build [NW.js](https://github.com/nwjs/nw.js) applications for Mac, Windows and Linux.
|
|
6
9
|
|
|
10
|
+
## Table of Contents
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
- [Installation](https://github.com/nwutils/nw-builder#installation)
|
|
13
|
+
- [Usage](https://github.com/nwutils/nw-builder#usage)
|
|
14
|
+
- [API Reference](https://github.com/nwutils/nw-builder#api-reference)
|
|
15
|
+
- [Contributing](https://github.com/nwutils/nw-builder#contributing)
|
|
16
|
+
- [License](https://github.com/nwutils/nw-builder#license)
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
> Tested and runs on Node 14, 16 and 18!
|
|
21
|
+
|
|
22
|
+
Using npm:
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
npm install nw-builder
|
|
13
26
|
```
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
Using yarn:
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
yarn add nw-builder
|
|
18
32
|
```
|
|
19
33
|
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
Using pnpm:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
pnpm add nw-builder
|
|
38
|
+
```
|
|
22
39
|
|
|
40
|
+
## Usage
|
|
23
41
|
|
|
24
|
-
|
|
42
|
+
### CLI
|
|
25
43
|
|
|
26
44
|
```shell
|
|
27
|
-
Usage:
|
|
45
|
+
Usage:
|
|
46
|
+
nwbuild [options] [path] [-- <args>]
|
|
28
47
|
|
|
29
48
|
Options:
|
|
30
|
-
-p, --platforms Platforms to build, comma-sperated, can be:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
49
|
+
-p, --platforms Platforms to build, comma-sperated, can be:
|
|
50
|
+
win32, win64, osx32, osx64, linux32, linux64 or
|
|
51
|
+
win, osx, linux [default: <Current OS>]
|
|
52
|
+
-v, --version The nw version, eg. 0.64.1 [default: "latest"]
|
|
53
|
+
-r, --run Runs NW.js for the current platform [default: false]
|
|
54
|
+
-o, --buildDir The build folder [default: "./build"]
|
|
55
|
+
-f, --forceDownload Force download of NW.js [default: false]
|
|
35
56
|
--cacheDir The cache folder
|
|
36
|
-
--quiet Disables logging
|
|
57
|
+
--quiet Disables logging [default: false]
|
|
58
|
+
-- <args> Pass custom arguments to the NW.js instance
|
|
59
|
+
(-r, --run mode only)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
To run NW.js in dev mode:
|
|
37
63
|
|
|
38
64
|
```
|
|
39
|
-
|
|
40
|
-
|
|
65
|
+
nwbuild -r path/to/app -- <args>
|
|
66
|
+
```
|
|
41
67
|
|
|
42
|
-
|
|
68
|
+
### Module
|
|
43
69
|
|
|
44
70
|
```js
|
|
45
71
|
var NwBuilder = require('nw-builder');
|
|
46
72
|
var nw = new NwBuilder({
|
|
47
73
|
files: './path/to/nwfiles/**/**', // use the glob format
|
|
48
|
-
platforms: ['osx64', 'win32', 'win64'],
|
|
49
|
-
version: '
|
|
74
|
+
platforms: ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
|
|
75
|
+
version: 'latest',
|
|
76
|
+
argv: ['<nwjs_arg>', ... ] // see nwjs docs for possible <nwjs_arg> values
|
|
50
77
|
});
|
|
51
78
|
|
|
52
79
|
// Log stuff you want
|
|
@@ -59,51 +86,52 @@ nw.build().then(function () {
|
|
|
59
86
|
});
|
|
60
87
|
```
|
|
61
88
|
|
|
62
|
-
|
|
89
|
+
To run NW.js in dev mode:
|
|
63
90
|
|
|
64
91
|
```js
|
|
65
|
-
nw.run()
|
|
66
|
-
|
|
67
|
-
|
|
92
|
+
nw.run()
|
|
93
|
+
.then(function () {
|
|
94
|
+
console.log("all done!");
|
|
95
|
+
})
|
|
96
|
+
.catch(function (error) {
|
|
68
97
|
console.error(error);
|
|
69
|
-
});
|
|
98
|
+
});
|
|
70
99
|
```
|
|
71
100
|
|
|
72
|
-
|
|
101
|
+
## API Reference
|
|
73
102
|
|
|
74
|
-
|
|
75
|
-
nw.build(function(err) {
|
|
76
|
-
if(err) return console.error(err);
|
|
77
|
-
console.log('all done!');
|
|
78
|
-
});
|
|
79
|
-
```
|
|
103
|
+
> Stay up to date via the [Changelog](https://github.com/nwjs-community/nw-builder/blob/master/.github/CHANGELOG.md).
|
|
80
104
|
|
|
81
105
|
### Options
|
|
82
106
|
|
|
83
|
-
#### options.files
|
|
84
|
-
Type: `String`
|
|
85
|
-
Default value: `null`
|
|
107
|
+
#### options.files _Required_
|
|
86
108
|
|
|
87
|
-
|
|
109
|
+
Type: `String`
|
|
110
|
+
Default value: `null`
|
|
88
111
|
|
|
112
|
+
The path to your node webkit app. It supports [simple-glob](https://github.com/jedmao/simple-glob) so you can do stuff like `['foo/*.js', '!foo/bar.js', 'foo/bar.js']`.
|
|
89
113
|
|
|
90
114
|
#### options.version
|
|
91
|
-
Type: `String`
|
|
92
|
-
Default value: `'latest'`
|
|
93
115
|
|
|
94
|
-
|
|
116
|
+
Type: `String`
|
|
117
|
+
Default value: `'latest'`
|
|
118
|
+
|
|
119
|
+
The version of NW.js you want to use. Per default it looks up the latest version. [Here is a list](https://github.com/nwjs/nw.js/tags) of all available releases.
|
|
95
120
|
|
|
96
121
|
#### options.flavor
|
|
97
|
-
|
|
98
|
-
|
|
122
|
+
|
|
123
|
+
Type: `String`
|
|
124
|
+
Default value: `'sdk'`
|
|
99
125
|
|
|
100
126
|
The flavor of NW.js you want to use. Per default it will be `sdk`. [Here is a list](https://github.com/nwjs/nw.js/wiki/Build-Flavors) of all flavor available.
|
|
101
127
|
|
|
102
128
|
The value `sdk` is most used for development whereas `normal` for production.
|
|
103
129
|
|
|
104
130
|
#### options.platforms
|
|
105
|
-
|
|
106
|
-
|
|
131
|
+
|
|
132
|
+
Type `(CLI)`: `String` (comma separated values)
|
|
133
|
+
Type `(API)`: `Array` of `String`
|
|
134
|
+
Default value: [`<current OS>`]
|
|
107
135
|
|
|
108
136
|
The platforms you want to build. Can be `['win32', 'win64', 'osx32', 'osx64', 'linux32', 'linux64']`
|
|
109
137
|
|
|
@@ -112,80 +140,99 @@ The values `['win', 'osx', 'linux']` can also be used and will build both the 32
|
|
|
112
140
|
Be aware that the osx32 version can only be built with legacy version of nwjs. Since > 0.12.0, only 64 bits for osx works.
|
|
113
141
|
|
|
114
142
|
#### options.appName
|
|
115
|
-
|
|
116
|
-
|
|
143
|
+
|
|
144
|
+
Type: `String`
|
|
145
|
+
Default value: `false`
|
|
117
146
|
|
|
118
147
|
The Name of your NW.js app. If this value is set to null, it will autodetect the `name` from your projects package.json. This will be used to generate a plist file for mac.
|
|
119
148
|
|
|
120
149
|
#### options.appVersion
|
|
121
|
-
|
|
122
|
-
|
|
150
|
+
|
|
151
|
+
Type: `String`
|
|
152
|
+
Default value: `false`
|
|
123
153
|
|
|
124
154
|
The version of your NW.js app. If this value is set to null, it will autodetect the `version` form your projects package.json. This will be used to generate a plist file for mac.
|
|
125
155
|
|
|
126
156
|
#### options.buildDir
|
|
127
|
-
|
|
128
|
-
|
|
157
|
+
|
|
158
|
+
Type: `String`
|
|
159
|
+
Default value: `./build`
|
|
129
160
|
|
|
130
161
|
This is where the releases are saved.
|
|
131
162
|
|
|
132
163
|
#### options.cacheDir
|
|
133
|
-
Type: `String`
|
|
134
|
-
Default value: `./cache`
|
|
135
164
|
|
|
136
|
-
|
|
165
|
+
Type: `String`
|
|
166
|
+
Default value: `./cache`
|
|
167
|
+
|
|
168
|
+
This is where the cached NW.js downloads are.
|
|
137
169
|
|
|
138
170
|
#### options.buildType
|
|
171
|
+
|
|
139
172
|
Type: `String` or `function`
|
|
140
|
-
Default value: `default`
|
|
173
|
+
Default value: `default`
|
|
141
174
|
|
|
142
175
|
How you want to save your build.
|
|
143
176
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
177
|
+
- `default` [appName]
|
|
178
|
+
- `versioned` [appName] -v[appVersion]
|
|
179
|
+
- `timestamped` [appName] - [timestamp];
|
|
180
|
+
- A function with options as scope (e.g `function () {return this.appVersion;}` )
|
|
148
181
|
|
|
149
182
|
#### options.forceDownload
|
|
150
|
-
Type: `Boolean`
|
|
151
|
-
Default value: `false`
|
|
152
183
|
|
|
153
|
-
|
|
184
|
+
Type: `Boolean`
|
|
185
|
+
Default value: `false`
|
|
186
|
+
|
|
187
|
+
This will delete everything in your `build_dir` directory, including the cached downloaded prebuilt binaries.
|
|
188
|
+
|
|
189
|
+
#### options.argv
|
|
190
|
+
|
|
191
|
+
Type `(CLI)`: `String` (comma separated values)
|
|
192
|
+
Type `(API)`: `Array` of `String`
|
|
193
|
+
Default Value: []
|
|
194
|
+
|
|
195
|
+
Pass Command Line Options when you run an NW.js instance. Ignored in case of build.
|
|
154
196
|
|
|
155
197
|
#### options.macCredits
|
|
156
|
-
|
|
157
|
-
|
|
198
|
+
|
|
199
|
+
Type: `String`
|
|
200
|
+
Default value: `false`
|
|
158
201
|
|
|
159
202
|
MAC ONLY: The path to your credits.html file. If your don't provide your own it will use the one provided by NW.js
|
|
160
203
|
|
|
161
204
|
#### options.macIcns
|
|
162
|
-
|
|
163
|
-
|
|
205
|
+
|
|
206
|
+
Type: `String`
|
|
207
|
+
Default value: `false`
|
|
164
208
|
|
|
165
209
|
MAC ONLY: The path to your ICNS icon file. If your don't provide your own it will use the one provided by NW.js
|
|
166
210
|
|
|
167
211
|
#### options.zip
|
|
168
|
-
|
|
169
|
-
|
|
212
|
+
|
|
213
|
+
Type: `Boolean`
|
|
214
|
+
Default value: `null`
|
|
170
215
|
|
|
171
216
|
WINDOW ONLY: Instead of zipping the application and merging it into the executable the application content is placed next to the application (which speed up the startup time for large apps). The default behaviour is platform specific. For `windows` and `linux`, the application is zipped and merged into the executable. For `mac`, the application is not zipped.
|
|
172
217
|
|
|
173
218
|
#### options.zipOptions
|
|
174
|
-
|
|
175
|
-
|
|
219
|
+
|
|
220
|
+
Type: `Object`
|
|
221
|
+
Default value: `null`
|
|
176
222
|
|
|
177
223
|
Allows to configure the underling zip library parameters, like store or compression ratio.
|
|
178
224
|
|
|
179
225
|
See [archiver](http://archiverjs.com/docs/global.html#ZipOptions) documentation for detailed description of properties.
|
|
180
226
|
|
|
181
227
|
#### options.macPlist
|
|
182
|
-
Type: `String` or `Object`
|
|
183
|
-
Default value: `false`
|
|
184
228
|
|
|
185
|
-
|
|
229
|
+
Type: `String` or `Object`
|
|
230
|
+
Default value: `false`
|
|
186
231
|
|
|
232
|
+
MAC ONLY: Pass a string containing the path to your own plist file. If a string isn't passed, a plist file will be generated from your package.json. Pass an object to overwrite or add properties to the generated plist file.
|
|
187
233
|
|
|
188
234
|
#### options.winVersionString
|
|
235
|
+
|
|
189
236
|
Type: `Object`
|
|
190
237
|
Default value: `{}`
|
|
191
238
|
|
|
@@ -203,17 +250,26 @@ winVersionString: {
|
|
|
203
250
|
```
|
|
204
251
|
|
|
205
252
|
#### options.winIco
|
|
206
|
-
|
|
207
|
-
|
|
253
|
+
|
|
254
|
+
Type: `String`
|
|
255
|
+
Default value: `null`
|
|
208
256
|
|
|
209
257
|
WINDOWS ONLY: The path to your ICO icon file. If your don't provide your own it will use the one provided by NW.js. If you are building on MAC or LINUX you must have [Wine](https://www.winehq.org/) installed to use this option.
|
|
210
258
|
|
|
211
259
|
#### options.macZip (DEPRECATED)
|
|
212
|
-
|
|
213
|
-
|
|
260
|
+
|
|
261
|
+
Type: `Boolean`
|
|
262
|
+
Default value: `null`
|
|
214
263
|
|
|
215
264
|
MAC ONLY: Use a `app.nw` folder instead of `ZIP` file, this significantly improves the startup speed of applications on `mac`, since no decompressing is needed. Builds on other platforms will still use `ZIP` files. The default behaviour of node-webkit-builder is to not use `ZIP` files on the `mac` platform. In case of the `mac` platform the option `macZip` can override the option `zip`.
|
|
216
265
|
|
|
266
|
+
#### options.mergeZip
|
|
267
|
+
|
|
268
|
+
Type: `Boolean`
|
|
269
|
+
Default value: `true`
|
|
270
|
+
|
|
271
|
+
WINDOWS AND LINUX ONLY: Merge the source file package with the Node Webkit executable.
|
|
272
|
+
|
|
217
273
|
### Manifest Options
|
|
218
274
|
|
|
219
275
|
#### platformOverrides
|
|
@@ -274,13 +330,13 @@ For example, when building for Windows, the manifest generated and put into the
|
|
|
274
330
|
|
|
275
331
|
```json
|
|
276
332
|
{
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
333
|
+
"name": "nw-demo",
|
|
334
|
+
"version": "0.1.0",
|
|
335
|
+
"main": "index.html",
|
|
336
|
+
"window": {
|
|
337
|
+
"frame": true,
|
|
338
|
+
"toolbar": false
|
|
339
|
+
}
|
|
284
340
|
}
|
|
285
341
|
```
|
|
286
342
|
|
|
@@ -298,35 +354,35 @@ To get around it, run `ulimit -n 1024` (or add it to your `~/.bash_profile`). Fo
|
|
|
298
354
|
|
|
299
355
|
## Team
|
|
300
356
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
- Adam Lynch ([@adam-lynch](https://github.com/adam-lynch))
|
|
304
|
-
- Rémy Boulanouar ([@DblK](https://github.com/DblK))
|
|
305
|
-
- You? :smile:. We're open to contributions (to the code, documentation, or anything else) and or additional maintainers.
|
|
306
|
-
|
|
307
|
-
**Past**
|
|
308
|
-
|
|
309
|
-
- Steffen Müller ([@steffenmllr](https://github.com/steffenmllr)) (Creator)
|
|
310
|
-
- Gabe Paez ([@gabepaez](https://github.com/gabepaez))
|
|
311
|
-
- Andy Trevorah ([@trevorah](https://github.com/trevorah))
|
|
357
|
+
This project was created by [Steffen Müller](https://github.com/steffenmllr) and has been maintained by [Gabe Paez](https://github.com/gabepaez), [Andy Trevorah](https://github.com/trevorah), [Adam Lynch](https://github.com/adam-lynch) and [Rémy Boulanouar](https://github.com/DblK) in the past. This project is currently maintained by [Ayushman Chhabra](https://github.com/ayushmxn).
|
|
312
358
|
|
|
313
359
|
## Contributing
|
|
314
360
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
361
|
+
### Getting Started
|
|
362
|
+
|
|
363
|
+
1. Pick and install a Node version manager
|
|
364
|
+
* Linux/OSX - [nvm](https://github.com/nvm-sh/nvm)
|
|
365
|
+
* Windows 8+ - [nvm-windows](https://github.com/coreybutler/nvm-windows)
|
|
366
|
+
* Windows 7 - [nodist](https://github.com/nullivex/nodist)
|
|
367
|
+
* Win/Lin/OSX - [volta](https://volta.sh)
|
|
368
|
+
1. Use your version manager to install Node 14.19, 16.9, 18.2 or above
|
|
369
|
+
1. Run `corepack enable`
|
|
370
|
+
1. `corepack prepare pnpm@7.1.7 --activate`
|
|
371
|
+
1. `pnpm install`
|
|
372
|
+
* If you haven't used `pnpm` before, [here is a cheatsheet](https://dev.to/equiman/npm-vs-yarn-vs-pnpm-commands-cheatsheet-3el8)
|
|
373
|
+
1. `pnpm demo` to test your changes at first glance
|
|
374
|
+
1. `pnpm test` to run unit tests
|
|
375
|
+
1. Don't forget to run `pnpm format && pnpm lint` before commiting your changes
|
|
376
|
+
|
|
377
|
+
### General Guidelines
|
|
378
|
+
|
|
379
|
+
- Whenever possible, open an issue before submitting a pull request.
|
|
380
|
+
- PRs should have short descriptive titles. For example:
|
|
381
|
+
- fix(docs): fix typo in `options.platform` description
|
|
382
|
+
- feat(platform): add support for mac m1
|
|
383
|
+
- Ideally, a PR should reference a related issue
|
|
384
|
+
- Ensure there are tests that cover your changes
|
|
320
385
|
|
|
321
386
|
## License
|
|
322
387
|
|
|
323
|
-
[MIT
|
|
324
|
-
|
|
325
|
-
[npm-url]: https://www.npmjs.com/package/nw-builder
|
|
326
|
-
[npm-image]: https://img.shields.io/npm/v/nw-builder.svg?style=flat
|
|
327
|
-
|
|
328
|
-
[travis-url]: https://travis-ci.org/nwjs/nw-builder
|
|
329
|
-
[travis-image]: https://img.shields.io/travis/nwjs/nw-builder/master.svg?style=flat
|
|
330
|
-
|
|
331
|
-
[depstat-url]: https://david-dm.org/nwjs/nw-builder
|
|
332
|
-
[depstat-image]: https://david-dm.org/nwjs/nw-builder.svg?style=flat
|
|
388
|
+
[MIT](https://github.com/nwutils/nw-builder/blob/master/.github/LICENSE)
|
package/bin/nwbuild.cjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const NwBuilder = require("../lib/index.cjs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { detectCurrentPlatform } = require("../dist/index.cjs");
|
|
5
|
+
|
|
6
|
+
const currentPlatform = detectCurrentPlatform(process);
|
|
7
|
+
|
|
8
|
+
const argv = require("yargs")
|
|
9
|
+
.command("$0 <path>")
|
|
10
|
+
.usage("Usage:\n $0 [options] [path] [-- <args>]")
|
|
11
|
+
|
|
12
|
+
.alias("p", "platforms")
|
|
13
|
+
.default("p", currentPlatform)
|
|
14
|
+
.describe(
|
|
15
|
+
"p",
|
|
16
|
+
"Platforms to build, comma-sperated, can be: \n win32, win64, osx32, osx64, linux32, linux64 or \nwin, osx, linux",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
.version(false)
|
|
20
|
+
.alias("v", "version")
|
|
21
|
+
.default("v", "latest")
|
|
22
|
+
.describe("v", "The NW.js version, eg. 0.8.4")
|
|
23
|
+
|
|
24
|
+
.alias("r", "run")
|
|
25
|
+
.default("r", false)
|
|
26
|
+
.describe("r", "Runs NW.js for the current platform")
|
|
27
|
+
.boolean("r")
|
|
28
|
+
|
|
29
|
+
.alias("o", "buildDir")
|
|
30
|
+
.default("o", "./build")
|
|
31
|
+
.describe("o", "The build folder")
|
|
32
|
+
|
|
33
|
+
.alias("f", "forceDownload")
|
|
34
|
+
.default("f", false)
|
|
35
|
+
.describe("f", "Force download of NW.js")
|
|
36
|
+
.boolean("f")
|
|
37
|
+
|
|
38
|
+
.alias("n", "name")
|
|
39
|
+
.describe("n", "The Name of your NW.js app.")
|
|
40
|
+
|
|
41
|
+
.describe("cacheDir", "The cache folder")
|
|
42
|
+
|
|
43
|
+
.default("quiet", false)
|
|
44
|
+
.describe("quiet", "Disables logging")
|
|
45
|
+
.boolean("quiet")
|
|
46
|
+
|
|
47
|
+
.describe(
|
|
48
|
+
" <args>",
|
|
49
|
+
"Pass custom arguments to the NW.js instance \n(-r, --run mode only)",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
// Howto Help
|
|
53
|
+
.help("h")
|
|
54
|
+
.alias("h", "help")
|
|
55
|
+
|
|
56
|
+
.wrap(100).argv;
|
|
57
|
+
|
|
58
|
+
const options = {
|
|
59
|
+
appName: argv.name,
|
|
60
|
+
files: path.resolve(process.cwd(), argv.path) + "/**/*",
|
|
61
|
+
flavor: argv.flavor || "sdk",
|
|
62
|
+
platforms: argv.platforms ? argv.platforms.split(",") : [currentPlatform],
|
|
63
|
+
currentPlatform: currentPlatform,
|
|
64
|
+
version: argv.version,
|
|
65
|
+
macIcns: argv.macIcns || false,
|
|
66
|
+
winIco: argv.winIco || false,
|
|
67
|
+
cacheDir: argv.cacheDir
|
|
68
|
+
? path.resolve(process.cwd(), argv.cacheDir)
|
|
69
|
+
: path.resolve(__dirname, "..", "cache"),
|
|
70
|
+
buildDir: path.resolve(process.cwd(), argv.buildDir),
|
|
71
|
+
forceDownload: argv.forceDownload,
|
|
72
|
+
// get all argv arguments after --
|
|
73
|
+
argv: process.argv.slice(
|
|
74
|
+
process.argv.findIndex(function firstDash(el) {
|
|
75
|
+
return el === "--";
|
|
76
|
+
}) + 1,
|
|
77
|
+
),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Initialize Builder
|
|
81
|
+
const nw = new NwBuilder(options);
|
|
82
|
+
|
|
83
|
+
// Logging
|
|
84
|
+
if (!(argv.quiet || argv.quite)) {
|
|
85
|
+
nw.on("log", console.log);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Build or Run the app
|
|
89
|
+
const np = argv.r ? nw.run() : nw.build();
|
|
90
|
+
np.then(function () {
|
|
91
|
+
process.exit(0);
|
|
92
|
+
}).catch(function (error) {
|
|
93
|
+
if (error) {
|
|
94
|
+
console.error(error);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var s=(r,t)=>{for(var e in t)a(r,e,{get:t[e],enumerable:!0})},u=(r,t,e,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!S.call(r,n)&&n!==e&&a(r,n,{get:()=>t[n],enumerable:!(f=h(t,n))||f.enumerable});return r};var l=(r,t,e)=>(e=r!=null?d(I(r)):{},u(t||!r||!r.__esModule?a(e,"default",{value:r,enumerable:!0}):e,r)),C=r=>u(a({},"__esModule",{value:!0}),r);var O={};s(O,{Platform:()=>o,checkCache:()=>c,detectCurrentPlatform:()=>i});module.exports=C(O);var x={NIX_32:"linux32",NIX_64:"linux64",OSX_32:"osx32",OSX_64:"osx64",WIN_32:"win32",WIN_64:"win64"};Object.freeze(x);var o=x;var m=l(require("fs"),1),_=l(require("path"),1),N=(r,t)=>{let e=!1;if(t.length===1&&t[0]==="*")return m.default.existsSync(r)&&m.default.readdirSync(r).length>=2;for(let f of t){if(e)return!1;m.default.existsSync(_.default.join(r,f))||(e=!0)}return!e},c=N;var X=r=>{switch(r.platform){case"darwin":return r.arch==="x64"?o.OSX_64:o.OSX_32;case"win32":return r.arch==="x64"||r.env.PROCESSOR_ARCHITEW6432?o.WIN_64:o.WIN_32;case"linux":return r.arch==="x64"?o.NIX_64:o.NIX_32;default:return}},i=X;0&&(module.exports={Platform,checkCache,detectCurrentPlatform});
|
package/lib/Version.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var platforms = require("./platforms.cjs");
|
|
2
|
+
var _ = require("lodash");
|
|
3
|
+
var semver = require("semver");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a version.
|
|
7
|
+
* @constructor
|
|
8
|
+
* @param {string} args.version.
|
|
9
|
+
* @param {string} args.flavors.
|
|
10
|
+
* @param {array} args.supportedPlatforms - array of strings like `osx64`.
|
|
11
|
+
* @param {string} args.downloadUrl.
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function Version(args) {
|
|
14
|
+
var generatePlatformUrls,
|
|
15
|
+
result = {
|
|
16
|
+
isLegacy: semver.lt(args.version, "0.12.3"),
|
|
17
|
+
name:
|
|
18
|
+
semver.gte(args.version, "0.12.0") ||
|
|
19
|
+
semver.satisfies(args.version, "~0.12.0-alpha")
|
|
20
|
+
? "nwjs"
|
|
21
|
+
: "node-webkit",
|
|
22
|
+
version: args.version,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// 0.12.3 is an exception that is in the manifest but is pretty much a legacy version
|
|
26
|
+
if (result.isLegacy || args.version === "0.12.3") {
|
|
27
|
+
generatePlatformUrls = function (version, flavors, supportedPlatforms) {
|
|
28
|
+
var platformUrls = {};
|
|
29
|
+
supportedPlatforms.forEach(function (supportedPlatform) {
|
|
30
|
+
flavors.forEach(function (flavor) {
|
|
31
|
+
platformUrls[supportedPlatform + "-" + flavor] =
|
|
32
|
+
args.downloadUrl +
|
|
33
|
+
_.template(platforms[supportedPlatform].versionNameTemplate)(
|
|
34
|
+
result,
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
return platformUrls;
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
var fixPlatformName = function (platform) {
|
|
42
|
+
return platform.replace("32", "-ia32").replace("64", "-x64");
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var mapPlatformToExtension = function (platform) {
|
|
46
|
+
if (platform.indexOf("linux") === 0) {
|
|
47
|
+
return "tar.gz";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return "zip";
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
generatePlatformUrls = function (version, flavors, supportedPlatforms) {
|
|
54
|
+
var platformUrls = {};
|
|
55
|
+
supportedPlatforms.forEach(function (platform) {
|
|
56
|
+
flavors.forEach(function (flavor) {
|
|
57
|
+
platformUrls[platform + "-" + flavor] =
|
|
58
|
+
args.downloadUrl +
|
|
59
|
+
"v" +
|
|
60
|
+
version +
|
|
61
|
+
"/nwjs" +
|
|
62
|
+
(flavor === "normal" ? "" : "-" + flavor) +
|
|
63
|
+
"-v" +
|
|
64
|
+
version +
|
|
65
|
+
"-" +
|
|
66
|
+
fixPlatformName(platform) +
|
|
67
|
+
"." +
|
|
68
|
+
mapPlatformToExtension(platform);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
return platformUrls;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
result.platforms = generatePlatformUrls(
|
|
76
|
+
args.version,
|
|
77
|
+
args.flavors,
|
|
78
|
+
args.supportedPlatforms,
|
|
79
|
+
);
|
|
80
|
+
return result;
|
|
81
|
+
};
|