nw-builder 3.5.4 → 3.6.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 (63) hide show
  1. package/{CHANGELOG.md → .github/CHANGELOG.md} +26 -4
  2. package/.github/ISSUE_REQUEST_TEMPLATE.md +16 -0
  3. package/{LICENSE → .github/LICENSE} +0 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +5 -0
  5. package/.github/workflows/cd.yml +24 -0
  6. package/.github/workflows/ci.yml +27 -0
  7. package/README.md +94 -96
  8. package/bin/nwbuild +19 -22
  9. package/demo.js +22 -0
  10. package/example/icons/README.md +7 -0
  11. package/example/icons/icon.icns +0 -0
  12. package/example/icons/icon.ico +0 -0
  13. package/example/nwapp/Credits.html +9 -0
  14. package/example/nwapp/README.md +7 -0
  15. package/example/nwapp/images/README.md +7 -0
  16. package/example/nwapp/images/kitten.jpg +0 -0
  17. package/example/nwapp/index.html +22 -0
  18. package/example/nwapp/package.json +23 -0
  19. package/example/package.json +7 -0
  20. package/lib/index.js +17 -7
  21. package/lib/platformOverrides.js +122 -0
  22. package/package.json +65 -61
  23. package/test/downloader.js +87 -0
  24. package/test/expected/README.md +7 -0
  25. package/test/expected/merged +1 -0
  26. package/test/expected/oneOveriddenRestNot/README.md +7 -0
  27. package/test/expected/oneOveriddenRestNot/osx32.json +9 -0
  28. package/test/expected/oneOveriddenRestNot/osx64.json +9 -0
  29. package/test/expected/osx-plist/1.plist +47 -0
  30. package/test/expected/osx-plist/2.plist +40 -0
  31. package/test/expected/osx-plist/README.md +7 -0
  32. package/test/expected/platformOverrides/README.md +7 -0
  33. package/test/expected/platformOverrides/linux32.json +13 -0
  34. package/test/expected/platformOverrides/linux64.json +9 -0
  35. package/test/expected/platformOverrides/osx32.json +12 -0
  36. package/test/expected/platformOverrides/osx64.json +12 -0
  37. package/test/expected/platformOverrides/win32.json +12 -0
  38. package/test/expected/platformOverrides/win64.json +12 -0
  39. package/test/fixtures/README.md +7 -0
  40. package/test/fixtures/invalid.json +3 -0
  41. package/test/fixtures/manifest/README.md +7 -0
  42. package/test/fixtures/manifest/versions.json +23 -0
  43. package/test/fixtures/nwapp/README.md +7 -0
  44. package/test/fixtures/nwapp/images/imagefile.img +1 -0
  45. package/test/fixtures/nwapp/index.html +10 -0
  46. package/test/fixtures/nwapp/javascript/bower_packages/simple/package.json +1 -0
  47. package/test/fixtures/nwapp/javascript/jsfile.js +1 -0
  48. package/test/fixtures/nwapp/package.json +5 -0
  49. package/test/fixtures/oneOveriddenRestNot/README.md +7 -0
  50. package/test/fixtures/oneOveriddenRestNot/package.json +16 -0
  51. package/test/fixtures/osx-plist/Info.plist +93 -0
  52. package/test/fixtures/osx-plist/README.md +7 -0
  53. package/test/fixtures/platformOverrides/README.md +7 -0
  54. package/test/fixtures/platformOverrides/package.json +52 -0
  55. package/test/fixtures/test-strip.zip +0 -0
  56. package/test/fixtures/test.tar.gz +0 -0
  57. package/test/fixtures/test.zip +0 -0
  58. package/test/fixtures/testVersions.html +17 -0
  59. package/test/nwBuilder.js +237 -0
  60. package/test/utils.js +232 -0
  61. package/test/versions.js +330 -0
  62. package/bin/README.md +0 -7
  63. package/lib/README.md +0 -7
@@ -5,13 +5,36 @@ All notable changes to this project will be documented in this file and in the [
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [3.6.0] - 2022-05-18
11
+ ### Added
12
+ - GitHub Actions for CICD [#552](https://github.com/nwjs-community/nw-builder/pull/552)
13
+ - Support multiple locales on OSX [#389](https://github.com/nwjs-community/nw-builder/pull/389)
14
+ - Pull request and issue template [#553](https://github.com/nwjs-community/nw-builder/pull/553)
15
+ ### Changed
16
+ - Dependencies [#550](https://github.com/nwjs-community/nw-builder/pull/550)
17
+ - Documentation [#540](https://github.com/nwjs-community/nw-builder/pull/540) [#553](https://github.com/nwjs-community/nw-builder/pull/553) [#555](https://github.com/nwjs-community/nw-builder/pull/555)
18
+ - Improve run mode by detecting current platform to prevent downloading additional binaries
19
+ ### Removed
20
+ - Travis
21
+ - AppVeyor
22
+ - JSHint
23
+ - EditorConfig
24
+
25
+ ## [3.5.7]
26
+
27
+ ### Security
28
+
29
+ - Source platform overrides module into the project instead of it being an extenal dependency. This helped us get rid of a vulnerable lodash version. See https://github.com/nwjs-community/nw-builder/issues/500
30
+
8
31
  ## [3.5.1] - 2017-10-19
9
32
 
10
- ## Added
33
+ ### Added
11
34
 
12
35
  - Add option.winVersionString for accurate process name. See https://github.com/nwjs-community/nw-builder/pull/459.
13
36
 
14
- ## Fixed
37
+ ### Fixed
15
38
 
16
39
  - Small platform overrides fix. See https://github.com/nwjs-community/nw-builder/pull/477/files.
17
40
 
@@ -47,7 +70,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
47
70
  ## Old format
48
71
 
49
72
  - 2017-05-22 `3.2.3` Fix for caching when a version is specified (thanks @piwonesien for the help).
50
- - 2017-05-20 `3.2.2` Fix: when using the `nwbuild` in run mode, the `-p` option was ignored and the current platform was always used.
73
+ - 2017-05-20 `3.2.2` Fix: when using the `nwbuild` in run mode, the `-p` option was ignored and the current platform was always used.
51
74
  - 2017-05-16 `3.2.1` Fix: NW.js 0.22.0+ apps didn't open.
52
75
  - 2017-02-12 `3.2.0` Defaults to HTTPS now, added `manifestUrl` option, and bumped some dependencies.
53
76
  - 2016-10-09 `3.1.2` Fix for passing array as files option when running app (plus some security fixes).
@@ -80,4 +103,3 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
80
103
  - 2014-07-31 `0.0.4` fixed compatibility with nodewebkit 0.10.0
81
104
  - 2014-04-20 Added run option, bug fixes
82
105
  - 2014-04-13 Preview Release
83
-
@@ -0,0 +1,16 @@
1
+ ### Issue Type
2
+
3
+ - [ ] Bug Fix
4
+ - [ ] Feature
5
+ - [ ] Other
6
+
7
+ ### Current/Missing Behaviour
8
+
9
+ ### Expected/Proposed Behaviour
10
+
11
+ ### Additional Info
12
+
13
+ - Operating System:
14
+ - Node version:
15
+ - NW.js version:
16
+ - ...
File without changes
@@ -0,0 +1,5 @@
1
+ Fixes: #
2
+
3
+ ### Changes
4
+
5
+ - ...
@@ -0,0 +1,24 @@
1
+ name: cd
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - uses: pnpm/action-setup@v2.2.1
13
+ with:
14
+ version: 7.1.0
15
+ run_install: true
16
+
17
+ - uses: actions/setup-node@v2
18
+ with:
19
+ node-version: '16'
20
+
21
+ - run: pnpm install
22
+ - uses: JS-DevTools/npm-publish@v1
23
+ with:
24
+ token: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,27 @@
1
+ name: ci
2
+ on:
3
+ pull_request:
4
+ branches:
5
+ - master
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ node: [14, 16]
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: pnpm/action-setup@v2.2.1
16
+ with:
17
+ version: 7.1.0
18
+ run_install: true
19
+
20
+ - uses: actions/setup-node@v3
21
+ with:
22
+ node-version: ${{ matrix.node }}
23
+
24
+ - run: pnpm install
25
+ - run: pnpm format
26
+ # - run: pnpm lint
27
+ - run: pnpm test
package/README.md CHANGED
@@ -1,52 +1,66 @@
1
- # nw-builder [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-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
+ ## Installation
7
11
 
8
- ### Installation
12
+ Using npm:
13
+ ```javascript
14
+ npm install nw-builder
15
+ ```
9
16
 
10
- ##### Local
11
- ```shell
12
- npm install nw-builder --save-dev
17
+ Using yarn:
18
+ ```javascript
19
+ yarn add nw-builder
13
20
  ```
14
21
 
15
- ##### Global
16
- ```shell
17
- npm install nw-builder -g
22
+ Using pnpm:
23
+ ```javascript
24
+ pnpm add nw-builder
18
25
  ```
19
26
 
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 :)
22
27
 
28
+ ## Usage
23
29
 
24
- ## CLI Usage
30
+ ### CLI
25
31
 
26
32
  ```shell
27
- Usage: nwbuild [options] [path]
33
+ Usage:
34
+ nwbuild [options] [path] [-- <args>]
28
35
 
29
36
  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]
37
+ -p, --platforms Platforms to build, comma-sperated, can be:
38
+ win32, win64, osx32, osx64, linux32, linux64 or
39
+ win, osx, linux [default: <Current OS>]
40
+ -v, --version The nw version, eg. 0.64.1 [default: "latest"]
41
+ -r, --run Runs NW.js for the current platform [default: false]
42
+ -o, --buildDir The build folder [default: "./build"]
43
+ -f, --forceDownload Force download of NW.js [default: false]
35
44
  --cacheDir The cache folder
36
- --quiet Disables logging [default: false]
45
+ --quiet Disables logging [default: false]
46
+ -- <args> Pass custom arguments to the NW.js instance
47
+ (-r, --run mode only)
48
+ ```
37
49
 
50
+ To run NW.js in dev mode:
51
+ ```
52
+ nwbuild -r path/to/app -- <args>
38
53
  ```
39
- #### Run NW.js
40
- During development you can run NW.js with `nwbuild -r path/to/your/younwapp/`
41
54
 
42
- ## Module Usage
55
+ ### Module
43
56
 
44
57
  ```js
45
58
  var NwBuilder = require('nw-builder');
46
59
  var nw = new NwBuilder({
47
60
  files: './path/to/nwfiles/**/**', // use the glob format
48
- platforms: ['osx64', 'win32', 'win64'],
49
- version: '0.14.6'
61
+ platforms: ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
62
+ version: 'latest',
63
+ argv: ['<nwjs_arg>', ... ] // see nwjs docs for possible <nwjs_arg> values
50
64
  });
51
65
 
52
66
  // Log stuff you want
@@ -59,8 +73,7 @@ nw.build().then(function () {
59
73
  });
60
74
  ```
61
75
 
62
- During development you can run NW.js with `run`:
63
-
76
+ To run NW.js in dev mode:
64
77
  ```js
65
78
  nw.run().then(function () {
66
79
  console.log('all done!');
@@ -69,41 +82,37 @@ nw.run().then(function () {
69
82
  });
70
83
  ```
71
84
 
72
- `build` and `run` also supports callbacks:
85
+ ## API Reference
73
86
 
74
- ```js
75
- nw.build(function(err) {
76
- if(err) return console.error(err);
77
- console.log('all done!');
78
- });
79
- ```
87
+ > Stay up to date via the [Changelog](https://github.com/nwjs-community/nw-builder/blob/master/.github/CHANGELOG.md).
80
88
 
81
89
  ### Options
82
90
 
83
91
  #### options.files *Required*
84
- Type: `String`
85
- Default value: `null`
92
+ Type: `String`
93
+ Default value: `null`
86
94
 
87
95
  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']`.
88
96
 
89
97
 
90
98
  #### options.version
91
- Type: `String`
92
- Default value: `'latest'`
99
+ Type: `String`
100
+ Default value: `'latest'`
93
101
 
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
102
+ 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
103
 
96
104
  #### options.flavor
97
- Type: `String`
98
- Default value: `'sdk'`
105
+ Type: `String`
106
+ Default value: `'sdk'`
99
107
 
100
108
  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
109
 
102
110
  The value `sdk` is most used for development whereas `normal` for production.
103
111
 
104
112
  #### options.platforms
105
- Type: `Array`
106
- Default value: `['osx64', 'win32', 'win64']`
113
+ Type `(CLI)`: `String` (comma separated values)
114
+ Type `(API)`: `Array` of `String`
115
+ Default value: [`<current OS>`]
107
116
 
108
117
  The platforms you want to build. Can be `['win32', 'win64', 'osx32', 'osx64', 'linux32', 'linux64']`
109
118
 
@@ -112,32 +121,32 @@ The values `['win', 'osx', 'linux']` can also be used and will build both the 32
112
121
  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
122
 
114
123
  #### options.appName
115
- Type: `String`
116
- Default value: `false`
124
+ Type: `String`
125
+ Default value: `false`
117
126
 
118
127
  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
128
 
120
129
  #### options.appVersion
121
- Type: `String`
122
- Default value: `false`
130
+ Type: `String`
131
+ Default value: `false`
123
132
 
124
133
  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
134
 
126
135
  #### options.buildDir
127
- Type: `String`
128
- Default value: `./build`
136
+ Type: `String`
137
+ Default value: `./build`
129
138
 
130
139
  This is where the releases are saved.
131
140
 
132
141
  #### options.cacheDir
133
- Type: `String`
134
- Default value: `./cache`
142
+ Type: `String`
143
+ Default value: `./cache`
135
144
 
136
- This is where the cached NW.js downloads are
145
+ This is where the cached NW.js downloads are.
137
146
 
138
147
  #### options.buildType
139
148
  Type: `String` or `function`
140
- Default value: `default`
149
+ Default value: `default`
141
150
 
142
151
  How you want to save your build.
143
152
 
@@ -147,40 +156,47 @@ How you want to save your build.
147
156
  * A function with options as scope (e.g `function () {return this.appVersion;}` )
148
157
 
149
158
  #### options.forceDownload
150
- Type: `Boolean`
151
- Default value: `false`
159
+ Type: `Boolean`
160
+ Default value: `false`
161
+
162
+ This will delete everything in your `build_dir` directory, including the cached downloaded prebuilt binaries.
152
163
 
153
- This will delete everything in your `build_dir` directory, including the cached downloaded prebuilt binaries
164
+ #### options.argv
165
+ Type `(CLI)`: `String` (comma separated values)
166
+ Type `(API)`: `Array` of `String`
167
+ Default Value: []
168
+
169
+ Pass Command Line Options when you run an NW.js instance. Ignored in case of build.
154
170
 
155
171
  #### options.macCredits
156
- Type: `String`
157
- Default value: `false`
172
+ Type: `String`
173
+ Default value: `false`
158
174
 
159
175
  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
176
 
161
177
  #### options.macIcns
162
- Type: `String`
163
- Default value: `false`
178
+ Type: `String`
179
+ Default value: `false`
164
180
 
165
181
  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
182
 
167
183
  #### options.zip
168
- Type: `Boolean`
169
- Default value: `null`
184
+ Type: `Boolean`
185
+ Default value: `null`
170
186
 
171
187
  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
188
 
173
189
  #### options.zipOptions
174
- Type: `Object`
175
- Default value: `null`
190
+ Type: `Object`
191
+ Default value: `null`
176
192
 
177
193
  Allows to configure the underling zip library parameters, like store or compression ratio.
178
194
 
179
195
  See [archiver](http://archiverjs.com/docs/global.html#ZipOptions) documentation for detailed description of properties.
180
196
 
181
197
  #### options.macPlist
182
- Type: `String` or `Object`
183
- Default value: `false`
198
+ Type: `String` or `Object`
199
+ Default value: `false`
184
200
 
185
201
  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.
186
202
 
@@ -203,14 +219,14 @@ winVersionString: {
203
219
  ```
204
220
 
205
221
  #### options.winIco
206
- Type: `String`
207
- Default value: `null`
222
+ Type: `String`
223
+ Default value: `null`
208
224
 
209
225
  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
226
 
211
227
  #### options.macZip (DEPRECATED)
212
- Type: `Boolean`
213
- Default value: `null`
228
+ Type: `Boolean`
229
+ Default value: `null`
214
230
 
215
231
  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
232
 
@@ -298,35 +314,17 @@ To get around it, run `ulimit -n 1024` (or add it to your `~/.bash_profile`). Fo
298
314
 
299
315
  ## Team
300
316
 
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))
317
+ 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
318
 
313
319
  ## Contributing
314
320
 
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).
321
+ - Whenever possible, open an issue before submitting a pull request.
322
+ - PRs should have short descriptive titles. For example:
323
+ - fix(docs): fix typo in `options.platform` description
324
+ - feat(platform): add support for mac m1
325
+ - Ideally, a PR should reference a related issue
326
+ - ~Ensure there are tests that cover your changes~
320
327
 
321
328
  ## License
322
329
 
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
330
+ MIT
package/bin/nwbuild CHANGED
@@ -5,15 +5,18 @@ var NwBuilder = require('./../lib');
5
5
  var path = require('path');
6
6
  var detectCurrentPlatform = require('../lib/detectCurrentPlatform.js');
7
7
 
8
+ var currentPlatform = detectCurrentPlatform();
9
+
8
10
  var argv = optimist
9
- .usage('Usage: nwbuild [options] [path]')
11
+ .usage('Usage:\n nwbuild [options] [path] [-- <args>]')
10
12
 
11
13
  .alias('p', 'platforms')
12
- .describe('p', 'Platforms to build, comma-sperated, can be: win32,win64,osx32,osx64,linux32,linux64')
14
+ .default('p', currentPlatform)
15
+ .describe('p', 'Platforms to build, comma-sperated, can be: \n win32, win64, osx32, osx64, linux32, linux64 or \nwin, osx, linux')
13
16
 
14
17
  .alias('v', 'version')
15
18
  .default('v', 'latest')
16
- .describe('v', 'The nw version, eg. 0.8.4')
19
+ .describe('v', 'The NW.js version, eg. 0.8.4')
17
20
 
18
21
  .alias('r', 'run')
19
22
  .default('r', false)
@@ -38,6 +41,10 @@ var argv = optimist
38
41
  .describe('quiet', 'Disables logging')
39
42
  .boolean('quiet')
40
43
 
44
+ .describe(' <args>', 'Pass custom arguments to the NW.js instance \n(-r, --run mode only)')
45
+
46
+ .wrap(100)
47
+
41
48
  .argv;
42
49
 
43
50
  // Howto Help
@@ -57,31 +64,21 @@ var options = {
57
64
  appName: argv.name,
58
65
  files: path.resolve(process.cwd(), files) + '/**/*',
59
66
  flavor: argv.flavor || 'sdk',
60
- platforms: argv.platforms ? argv.platforms.split(',') : null,
67
+ platforms: argv.platforms ? argv.platforms.split(',') : [currentPlatform],
68
+ currentPlatform: currentPlatform,
61
69
  version: argv.version,
62
70
  macIcns: argv.macIcns || false,
63
71
  winIco: argv.winIco || false,
64
72
  cacheDir: argv.cacheDir ? path.resolve(process.cwd(), argv.cacheDir) : path.resolve(__dirname, '..', 'cache'),
65
73
  buildDir: path.resolve(process.cwd(), argv.buildDir),
66
- forceDownload: argv.forceDownload
74
+ forceDownload: argv.forceDownload,
75
+ // get all argv arguments after --
76
+ argv: process.argv.slice(process.argv.findIndex(function firstDash(el) {
77
+ return el === '--'
78
+ }) + 1)
67
79
  };
68
80
 
69
- // If we are in run mode
70
- if(argv.r) {
71
- var currentPlatform = detectCurrentPlatform();
72
- if(!options.platforms){
73
- options.platforms = [ currentPlatform ];
74
- }
75
- options.currentPlatform = currentPlatform;
76
- }
77
-
78
- // Set default target platforms here
79
- // Remove osx32 from default, nwjs didn't support osx32 yet
80
- if (!options.platforms) {
81
- options.platforms = ['osx64', 'win32', 'win64']
82
- }
83
-
84
- // Build App
81
+ // Initialize Builder
85
82
  var nw = new NwBuilder(options);
86
83
 
87
84
  // Logging
@@ -89,7 +86,7 @@ if(!(argv.quiet || argv.quite)) {
89
86
  nw.on('log', console.log);
90
87
  }
91
88
 
92
- // Build or run the app
89
+ // Build or Run the app
93
90
  var np = (argv.r ? nw.run() : nw.build());
94
91
  np.then(function() {
95
92
  process.exit(0);
package/demo.js ADDED
@@ -0,0 +1,22 @@
1
+ const NwBuilder = require('./lib');
2
+ const detectCurrentPlatform = require('./lib/detectCurrentPlatform');
3
+
4
+ const nw = new NwBuilder({
5
+ version: '0.64.1',
6
+ files: './example/nwapp/**',
7
+ macIcns: './icons/icon.icns',
8
+ macPlist: {mac_bundle_id: 'myPkg'},
9
+ platforms: [
10
+ detectCurrentPlatform(),
11
+ // 'linux64',
12
+ // 'osx64',
13
+ // 'win64',
14
+ ]
15
+ });
16
+
17
+
18
+ nw.on('log', (msg) => console.log('nw-builder', msg));
19
+
20
+ nw.run()
21
+ .then(() => process.exit(0))
22
+ .catch((error) => console.log(error))
@@ -0,0 +1,7 @@
1
+ This directory contains app icons passed to nw-builder.
2
+
3
+ ---
4
+
5
+ ## See something which could be improved?
6
+
7
+ Great, see [CONTRIBUTING.md](../../CONTRIBUTING.md).
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ <style type="text/css">
2
+ html,body,.body {
3
+ overflow: hidden;
4
+ }
5
+ </style>
6
+ <div class="body">
7
+ <h1>me, myself and i.</h1>
8
+ <p>much has been done.</p>
9
+ </div>
@@ -0,0 +1,7 @@
1
+ This directory contains the actual example app code.
2
+
3
+ ---
4
+
5
+ ## See something which could be improved?
6
+
7
+ Great, see [CONTRIBUTING.md](../../CONTRIBUTING.md).
@@ -0,0 +1,7 @@
1
+ Any images used within the example app are stored in this directory.
2
+
3
+ ---
4
+
5
+ ## See something which could be improved?
6
+
7
+ Great, see [CONTRIBUTING.md](../../CONTRIBUTING.md).
Binary file
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Hello World from nw-builder!</title>
5
+ </head>
6
+ <body>
7
+ <h1>Hello World!</h1>
8
+ We are using node.js <script>document.write(process.version)</script>
9
+
10
+ <h2>Here is a required node_module</h2>
11
+ <ul>
12
+ <script>
13
+ for (var counter=0; counter<xs.length; counter++) {
14
+ document.write("<li>" + counter + "</li>");
15
+ }
16
+ </script>
17
+ </ul>
18
+
19
+ <h2>And here is a cute kitten:</h2>
20
+ <img src="images/kitten.jpg">
21
+ </body>
22
+ </html>
@@ -0,0 +1,23 @@
1
+ {
2
+ "main": "index.html",
3
+ "name": "nw-demo",
4
+ "description": "demo app of NW.js",
5
+ "version": "0.1.0",
6
+ "keywords": [ "demo", "NW.js" ],
7
+ "window": {
8
+ "title": "NW.js demo",
9
+ "icon": "link.png",
10
+ "toolbar": false,
11
+ "frame": true,
12
+ "width": 800,
13
+ "height": 500,
14
+ "position": "center",
15
+ "min_width": 400,
16
+ "min_height": 200,
17
+ "max_width": 800,
18
+ "max_height": 600
19
+ },
20
+ "webkit": {
21
+ "plugin": true
22
+ }
23
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "example",
3
+ "private": true,
4
+ "scripts": {
5
+ "start": "node index.js"
6
+ }
7
+ }