nw-builder 3.7.4 → 3.8.2

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.
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.8.1] - 2022-07-18
11
+
12
+ ### Changed
13
+
14
+ - Fix regex to match `package.json` _files_ only
15
+
16
+ ## [3.8.0] - 2022-07-11
17
+
18
+ ## Added
19
+
20
+ - `mode` option which defaults to run
21
+ - `nwbuild` function
22
+ - `quiet` option to documentation
23
+
24
+ ## Changed
25
+
26
+ - CLI options by matching them to the API
27
+
10
28
  ## [3.7.4] - 2022-06-06
11
29
 
12
30
  ## Removed
@@ -0,0 +1,17 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "npm" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
12
+ day: "friday"
13
+ - package-ecosystem: "github-actions" # See documentation for possible values
14
+ directory: ".github/" # Location of package manifests
15
+ schedule:
16
+ interval: "weekly"
17
+ day: "friday"
@@ -9,16 +9,11 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
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
12
+ - uses: actions/setup-node@v3
18
13
  with:
19
14
  node-version: "16"
20
15
 
21
- - run: pnpm install
16
+ - run: npm ci
22
17
  - uses: JS-DevTools/npm-publish@v1
23
18
  with:
24
19
  token: ${{ secrets.NPM_TOKEN }}
@@ -12,20 +12,15 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  os: [ubuntu-latest, macos-latest, windows-latest]
15
- node: [14, 16, 18]
15
+ node-version: [14, 16, 18]
16
16
  runs-on: ${{ matrix.os }}
17
17
  steps:
18
18
  - uses: actions/checkout@v3
19
- - uses: pnpm/action-setup@v2.2.1
19
+ - uses: volta-cli/action@v1
20
20
  with:
21
- version: 7.1.0
22
- run_install: true
23
-
24
- - uses: actions/setup-node@v3
25
- with:
26
- node-version: ${{ matrix.node }}
27
-
28
- - run: pnpm install
29
- - run: pnpm format
30
- - run: pnpm lint
31
- - run: pnpm test
21
+ node-version: ${{ matrix.node-version }}
22
+ npm-version: '8.5.0'
23
+ - run: npm ci
24
+ - run: npm run format
25
+ - run: npm run lint
26
+ - run: npm run test
package/README.md CHANGED
@@ -42,68 +42,48 @@ pnpm add nw-builder
42
42
  ### CLI
43
43
 
44
44
  ```shell
45
- Usage:
46
- nwbuild [options] [path] [-- <args>]
47
-
48
- Options:
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]
56
- --cacheDir The cache folder
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:
63
-
64
- ```
65
- nwbuild -r path/to/app -- <args>
45
+ nwbuild ./path/to/app
66
46
  ```
67
47
 
68
48
  ### Module
69
49
 
70
50
  ```js
71
- var NwBuilder = require('nw-builder');
72
- var nw = new NwBuilder({
73
- files: './path/to/nwfiles/**/**', // use the glob format
74
- platforms: ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
75
- version: 'latest',
76
- argv: ['<nwjs_arg>', ... ] // see nwjs docs for possible <nwjs_arg> values
77
- });
51
+ const { nwbuild } = require("nw-builder");
78
52
 
79
- // Log stuff you want
80
- nw.on('log', console.log);
81
-
82
- nw.build().then(function () {
83
- console.log('all done!');
84
- }).catch(function (error) {
85
- console.error(error);
53
+ nwbuild({
54
+ files: "./path/to/app",
55
+ platforms: ["linux64", "win32"],
86
56
  });
87
57
  ```
88
58
 
89
- To run NW.js in dev mode:
90
-
91
- ```js
92
- nw.run()
93
- .then(function () {
94
- console.log("all done!");
95
- })
96
- .catch(function (error) {
97
- console.error(error);
98
- });
99
- ```
59
+ > If no `mode` option is defined, it defaults to `run`. If no `platforms` option is defined, it defaults to the current platform.
100
60
 
101
61
  ## API Reference
102
62
 
103
63
  > Stay up to date via the [Changelog](https://github.com/nwjs-community/nw-builder/blob/master/.github/CHANGELOG.md).
104
64
 
65
+ ### Methods
66
+
67
+ #### nwbuild(options, callbacks)
68
+
69
+ The function that setups up, runs and builds your NW.js applications. The `callbacks` are for the `run` and `build` function that run inside the `nwbuild` function. The callbacks `callback[0]`, `callback[1]`, `callback[2]` correspond to the `.then`, `.catch` and `.finally` functions of the `run` or `build` promise.
70
+
105
71
  ### Options
106
72
 
73
+ #### options.mode
74
+
75
+ Type: `run` | `build`
76
+ Default value: `run`
77
+
78
+ Specify if you want to run or build your app.
79
+
80
+ #### options.quiet
81
+
82
+ Type: `String`
83
+ Default value: `info`
84
+
85
+ Choose your level of logging between error, warn, info, debug and off.
86
+
107
87
  #### options.files _Required_
108
88
 
109
89
  Type: `String`
@@ -144,7 +124,7 @@ Be aware that the osx32 version can only be built with legacy version of nwjs. S
144
124
  Type: `String`
145
125
  Default value: `false`
146
126
 
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.
127
+ The Name of your NW.js app. If this value is set to null, it will autodetect the `name` from your project's package.json. This will be used to generate a plist file for mac.
148
128
 
149
129
  #### options.appVersion
150
130
 
@@ -361,18 +341,13 @@ This project was created by [Steffen Müller](https://github.com/steffenmllr) an
361
341
  ### Getting Started
362
342
 
363
343
  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
344
+ - Linux/OSX - [nvm](https://github.com/nvm-sh/nvm)
345
+ - Win 7+/Linux/OSX - [volta](https://volta.sh)
346
+ 1. Use your version manager to install Node 14.19 or above
347
+ 1. Run `npm install`
348
+ 1. `npm run demo` to test your changes at first glance
349
+ 1. `npm t` to run unit tests
350
+ 1. Don't forget to run `npm run format && npm run lint` before commiting your changes
376
351
 
377
352
  ### General Guidelines
378
353
 
package/bin/nwbuild.cjs CHANGED
@@ -1,102 +1,146 @@
1
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
2
 
6
- const currentPlatform = detectCurrentPlatform(process);
3
+ const yargs = require("yargs/yargs");
4
+ const { hideBin } = require("yargs/helpers");
7
5
 
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
- )
6
+ const { nwbuild } = require("../lib/index.cjs");
7
+ const { Options, detectCurrentPlatform } = require("../dist/index.cjs");
18
8
 
9
+ const cli = yargs(hideBin(process.argv))
19
10
  .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
- macCredits: argv.macCredits || false,
66
- macPlist: argv.macPlist || false,
67
- macIcns: argv.macIcns || false,
68
- winIco: argv.winIco || false,
69
- cacheDir: argv.cacheDir
70
- ? path.resolve(process.cwd(), argv.cacheDir)
71
- : path.resolve(__dirname, "..", "cache"),
72
- buildDir: path.resolve(process.cwd(), argv.buildDir),
73
- buildType: argv.buildType || 'default',
74
- forceDownload: argv.forceDownload,
75
- // get all argv arguments after --
76
- argv: process.argv.slice(
77
- process.argv.findIndex(function firstDash(el) {
78
- return el === "--";
79
- }) + 1,
80
- ),
81
- zip: argv.zip || null,
82
- zipOptions: argv.zipOptions || null
83
- };
84
-
85
- // Initialize Builder
86
- const nw = new NwBuilder(options);
87
-
88
- // Logging
89
- if (!(argv.quiet || argv.quite)) {
90
- nw.on("log", console.log);
91
- }
92
-
93
- // Build or Run the app
94
- const np = argv.r ? nw.run() : nw.build();
95
- np.then(function () {
96
- process.exit(0);
97
- }).catch(function (error) {
98
- if (error) {
99
- console.error(error);
100
- process.exit(1);
101
- }
11
+ .command("[file(glob)] [options]")
12
+ .option("mode", {
13
+ type: "string",
14
+ description: "Choose between run and build mode",
15
+ default: Options["mode"],
16
+ })
17
+ .option("quiet", {
18
+ type: "string",
19
+ description:
20
+ "Choose your level of logging between error, warn, info, debug and off",
21
+ default: Options["quiet"],
22
+ })
23
+ .option("version", {
24
+ type: "string",
25
+ description: "Version of NW.js you want to use.",
26
+ group: "Run API",
27
+ default: Options["version"],
28
+ })
29
+ .option("flavor", {
30
+ type: "string",
31
+ description:
32
+ "sdk is recommended for development and normal is recommended for production.",
33
+ group: "Run API",
34
+ default: Options["flavor"],
35
+ })
36
+ .option("cacheDir", {
37
+ type: "string",
38
+ description: "Path to NW.js cache",
39
+ group: "Run API",
40
+ default: Options["cacheDir"],
41
+ })
42
+ .option("platforms", {
43
+ type: "array",
44
+ description:
45
+ "Supported platforms are linux32, linux64, osx32, osx64, win32, win64",
46
+ group: "Run API",
47
+ default: detectCurrentPlatform(process),
48
+ })
49
+ .option("appName", {
50
+ type: "string",
51
+ description: "Name of your application",
52
+ group: "Build API",
53
+ default: Options["appName"],
54
+ })
55
+ .option("appVersion", {
56
+ type: "string",
57
+ description: "Version of your application",
58
+ group: "Build API",
59
+ default: Options["appVersion"],
60
+ })
61
+ .option("buildDir", {
62
+ type: "string",
63
+ description: "Path to NW.js build",
64
+ group: "Build API",
65
+ default: Options["buildDir"],
66
+ })
67
+ .option("buildType", {
68
+ type: "string",
69
+ description:
70
+ "default is appName, \nversioned is [appName] -v[appVersion], \ntimestamped is [appName] - [timestamp]",
71
+ group: "Build API",
72
+ default: Options["buildType"],
73
+ })
74
+ .option("forceDownload", {
75
+ type: "boolean",
76
+ description: "Delete all cache and builds and redownload them",
77
+ group: "Build API",
78
+ default: Options["forceDownload"],
79
+ })
80
+ .option("macCredits", {
81
+ type: "string",
82
+ description:
83
+ "The path to your credits.html file. By default it uses the one provided by NW.js",
84
+ group: "Build API",
85
+ default: Options["macCredits"],
86
+ })
87
+ .option("macIcns", {
88
+ type: "string",
89
+ description:
90
+ "The path to your ICNS file. By default it uses the one provided by NW.js",
91
+ group: "Build API",
92
+ default: Options["macIcns"],
93
+ })
94
+ .option("macPlist", {
95
+ type: "string",
96
+ description:
97
+ "The path to your Plist file. By default a Plist file is generated from the package.json",
98
+ group: "Build API",
99
+ default: Options["macPlist"],
100
+ })
101
+ .option("winVersionString", {
102
+ type: "object",
103
+ description: "Descriptors for Windows executable",
104
+ group: "Build API",
105
+ default: Options["winVersionString"],
106
+ })
107
+ .option("winIco", {
108
+ type: "string",
109
+ description:
110
+ "Path to your ICO file. By default it uses the one provided by NW.js",
111
+ group: "Build API",
112
+ default: Options["winIco"],
113
+ })
114
+ .option("useRcedit", {
115
+ type: "string",
116
+ description:
117
+ "If set to true, it allows you to set the Windows icon using rcedit instead of winresourcer",
118
+ group: "Build API",
119
+ default: Options["useRcedit"],
120
+ })
121
+ .option("zip", {
122
+ type: "boolean",
123
+ description: "Zip your NW.js application",
124
+ group: "Package API",
125
+ default: Options["zip"],
126
+ })
127
+ .option("zipOptions", {
128
+ type: "boolean",
129
+ description:
130
+ "Configure the underling zip library parameters, like store or compression ratio",
131
+ group: "Package API",
132
+ default: Options["zipOptions"],
133
+ })
134
+ .option("mergeZip", {
135
+ type: "boolean",
136
+ description: "Merge the source file package with the NW.js executable",
137
+ group: "Package API",
138
+ default: Options["mergeZip"],
139
+ })
140
+ .parse();
141
+
142
+ nwbuild({
143
+ ...cli,
144
+ currentPlatform: detectCurrentPlatform(process),
145
+ files: cli._,
102
146
  });