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.
Files changed (84) hide show
  1. package/.github/CHANGELOG.md +128 -0
  2. package/.github/CODE_OF_CONDUCT.md +55 -0
  3. package/.github/ISSUE_TEMPLATE.md +17 -0
  4. package/{LICENSE → .github/LICENSE} +0 -0
  5. package/.github/PULL_REQUEST_TEMPLATE.md +5 -0
  6. package/.github/workflows/cd.yml +24 -0
  7. package/.github/workflows/ci.yml +30 -0
  8. package/README.md +169 -113
  9. package/bin/nwbuild.cjs +97 -0
  10. package/dist/index.cjs +1 -0
  11. package/lib/Version.cjs +81 -0
  12. package/lib/downloader.cjs +177 -0
  13. package/lib/index.cjs +1078 -0
  14. package/lib/platformOverrides.cjs +147 -0
  15. package/lib/platforms.cjs +141 -0
  16. package/lib/utils.cjs +293 -0
  17. package/lib/versions.cjs +206 -0
  18. package/package.json +94 -62
  19. package/src/index.js +2 -0
  20. package/src/schema/Platform.js +16 -0
  21. package/src/schema/index.js +3 -0
  22. package/src/utilities/checkCache.js +30 -0
  23. package/src/utilities/detectCurrentPlatform.js +24 -0
  24. package/src/utilities/index.js +4 -0
  25. package/test/demo/icon.icns +0 -0
  26. package/test/demo/icon.ico +0 -0
  27. package/test/demo/index.cjs +14 -0
  28. package/test/demo/index.html +10 -0
  29. package/test/demo/package.json +24 -0
  30. package/test/downloader.cjs +131 -0
  31. package/test/expected/README.md +7 -0
  32. package/test/expected/merged +1 -0
  33. package/test/expected/oneOveriddenRestNot/README.md +7 -0
  34. package/test/expected/oneOveriddenRestNot/osx32.json +9 -0
  35. package/test/expected/oneOveriddenRestNot/osx64.json +9 -0
  36. package/test/expected/osx-plist/1.plist +47 -0
  37. package/test/expected/osx-plist/2.plist +40 -0
  38. package/test/expected/osx-plist/README.md +7 -0
  39. package/test/expected/platformOverrides/README.md +7 -0
  40. package/test/expected/platformOverrides/linux32.json +13 -0
  41. package/test/expected/platformOverrides/linux64.json +9 -0
  42. package/test/expected/platformOverrides/osx32.json +12 -0
  43. package/test/expected/platformOverrides/osx64.json +12 -0
  44. package/test/expected/platformOverrides/win32.json +12 -0
  45. package/test/expected/platformOverrides/win64.json +12 -0
  46. package/test/fixtures/README.md +7 -0
  47. package/test/fixtures/invalid.json +3 -0
  48. package/test/fixtures/manifest/README.md +7 -0
  49. package/test/fixtures/manifest/versions.json +29 -0
  50. package/test/fixtures/nwapp/README.md +7 -0
  51. package/test/fixtures/nwapp/images/imagefile.img +1 -0
  52. package/test/fixtures/nwapp/index.html +13 -0
  53. package/test/fixtures/nwapp/javascript/bower_packages/simple/package.json +1 -0
  54. package/test/fixtures/nwapp/javascript/jsfile.js +1 -0
  55. package/test/fixtures/nwapp/package.json +5 -0
  56. package/test/fixtures/oneOveriddenRestNot/README.md +7 -0
  57. package/test/fixtures/oneOveriddenRestNot/package.json +16 -0
  58. package/test/fixtures/osx-plist/Info.plist +93 -0
  59. package/test/fixtures/osx-plist/README.md +7 -0
  60. package/test/fixtures/platformOverrides/README.md +7 -0
  61. package/test/fixtures/platformOverrides/package.json +72 -0
  62. package/test/fixtures/test-strip.zip +0 -0
  63. package/test/fixtures/test.tar.gz +0 -0
  64. package/test/fixtures/test.zip +0 -0
  65. package/test/fixtures/testVersions.html +74 -0
  66. package/test/nwBuilder.cjs +339 -0
  67. package/test/unit/checkCache.test.js +19 -0
  68. package/test/unit/checkCacheDir/v0.64.1/linux64/nw1.app +0 -0
  69. package/test/unit/checkCacheDir/v0.64.1/linux64/nw2.app +0 -0
  70. package/test/unit/detectCurrentPlatform.test.js +58 -0
  71. package/test/utils.cjs +310 -0
  72. package/test/versions.cjs +486 -0
  73. package/CHANGELOG.md +0 -83
  74. package/bin/README.md +0 -7
  75. package/bin/nwbuild +0 -101
  76. package/index.js +0 -1
  77. package/lib/README.md +0 -7
  78. package/lib/Version.js +0 -60
  79. package/lib/detectCurrentPlatform.js +0 -17
  80. package/lib/downloader.js +0 -192
  81. package/lib/index.js +0 -863
  82. package/lib/platforms.js +0 -76
  83. package/lib/utils.js +0 -249
  84. package/lib/versions.js +0 -198
package/README.md CHANGED
@@ -1,52 +1,79 @@
1
- # nw-builder [![NPM version][npm-image]][npm-url] [![Dependency Status][depstat-image]][depstat-url] [![Join the chat at https://gitter.im/nwjs/nw-builder](https://badges.gitter.im/nwjs/nw-builder.svg)](https://gitter.im/nwjs/nw-builder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1
+ # nw-builder
2
2
 
3
- [![NPM](https://nodei.co/npm/nw-builder.png?downloads=true)](https://nodei.co/npm/nw-builder/)
3
+ [![npm](https://img.shields.io/npm/v/nw-builder.svg?style=flat)](https://www.npmjs.com/package/nw-builder)
4
+ [![ci](https://github.com/nwjs-community/nw-builder/actions/workflows/ci.yml/badge.svg)](https://github.com/nwjs-community/nw-builder/actions/workflows/ci.yml)
5
+ [![cd](https://github.com/nwjs-community/nw-builder/actions/workflows/cd.yml/badge.svg)](https://github.com/nwjs-community/nw-builder/actions/workflows/cd.yml)
6
+ [![Join the chat at https://gitter.im/nwjs/nw-builder](https://badges.gitter.im/nwjs/nw-builder.svg)](https://gitter.im/nwjs/nw-builder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
7
 
5
- > Build your [NW.js](https://github.com/nwjs/nw.js) apps for Mac, Win and Linux programmatically or via CLI.
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
- ### Installation
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
- ##### Local
11
- ```shell
12
- npm install nw-builder --save-dev
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
- ##### Global
16
- ```shell
17
- npm install nw-builder -g
28
+ Using yarn:
29
+
30
+ ```javascript
31
+ yarn add nw-builder
18
32
  ```
19
33
 
20
- ##### Grunt and Gulp Plugins
21
- Yes, there is also a [Grunt Plugin](https://github.com/nwjs/grunt-nw-builder). For Gulp, just use the module :)
34
+ Using pnpm:
35
+
36
+ ```javascript
37
+ pnpm add nw-builder
38
+ ```
22
39
 
40
+ ## Usage
23
41
 
24
- ## CLI Usage
42
+ ### CLI
25
43
 
26
44
  ```shell
27
- Usage: nwbuild [options] [path]
45
+ Usage:
46
+ nwbuild [options] [path] [-- <args>]
28
47
 
29
48
  Options:
30
- -p, --platforms Platforms to build, comma-sperated, can be: win32,win64,osx32,osx64,linux32,linux64 ['osx64', 'win32', 'win64']
31
- -v, --version The nw version, eg. 0.8.4 [default: "latest"]
32
- -r, --run Runs NW.js for the current platform [default: false]
33
- -o, --buildDir The build folder [default: "./build"]
34
- -f, --forceDownload Force download of NW.js [default: false]
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 [default: false]
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
- #### Run NW.js
40
- During development you can run NW.js with `nwbuild -r path/to/your/younwapp/`
65
+ nwbuild -r path/to/app -- <args>
66
+ ```
41
67
 
42
- ## Module Usage
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: '0.14.6'
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
- During development you can run NW.js with `run`:
89
+ To run NW.js in dev mode:
63
90
 
64
91
  ```js
65
- nw.run().then(function () {
66
- console.log('all done!');
67
- }).catch(function (error) {
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
- `build` and `run` also supports callbacks:
101
+ ## API Reference
73
102
 
74
- ```js
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 *Required*
84
- Type: `String`
85
- Default value: `null`
107
+ #### options.files _Required_
86
108
 
87
- 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']`.
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
- 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/wiki/Downloads-of-old-versions) of all available releases
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
- Type: `String`
98
- Default value: `'sdk'`
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
- Type: `Array`
106
- Default value: `['osx64', 'win32', 'win64']`
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
- Type: `String`
116
- Default value: `false`
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
- Type: `String`
122
- Default value: `false`
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
- Type: `String`
128
- Default value: `./build`
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
- This is where the cached NW.js downloads are
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
- * `default` [appName]
145
- * `versioned` [appName] -v[appVersion]
146
- * `timestamped` [appName] - [timestamp];
147
- * A function with options as scope (e.g `function () {return this.appVersion;}` )
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
- This will delete everything in your `build_dir` directory, including the cached downloaded prebuilt binaries
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
- Type: `String`
157
- Default value: `false`
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
- Type: `String`
163
- Default value: `false`
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
- Type: `Boolean`
169
- Default value: `null`
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
- Type: `Object`
175
- Default value: `null`
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
- 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.
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
- Type: `String`
207
- Default value: `null`
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
- Type: `Boolean`
213
- Default value: `null`
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
- "name": "nw-demo",
278
- "version": "0.1.0",
279
- "main": "index.html",
280
- "window": {
281
- "frame": true,
282
- "toolbar": false
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
- **Current**
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
- See [CONTRIBUTING.md](CONTRIBUTING.md).
316
-
317
- ## Release History
318
-
319
- See [CHANGELOG.md](CHANGELOG.md) or [Releases](https://github.com/nwjs-community/nw-builder/blob/develop/releases).
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 License](https://en.wikipedia.org/wiki/MIT_License)
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)
@@ -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});
@@ -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
+ };