nw-builder 3.8.3 → 3.8.4
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 +12 -0
- package/.github/workflows/cd.yml +1 -1
- package/.github/workflows/ci.yml +6 -2
- package/README.md +1 -43
- package/bin/nwbuild.cjs +8 -2
- package/dist/index.cjs +1 -1
- package/lib/index.cjs +27 -96
- package/package.json +6 -10
- package/src/utilities/checkPkgOptions.js +3 -5
- package/test/demo/index.cjs +13 -2
- package/test/demo/package.json +1 -0
- package/lib/downloader.cjs +0 -176
- package/test/downloader.cjs +0 -131
package/.github/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.8.4] - 2022-09-20
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Refactor download function
|
|
15
|
+
|
|
16
|
+
## [3.8.3-beta.1]
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Check for first instance of `package.json`
|
|
21
|
+
|
|
10
22
|
## [3.8.3] - 2022-08-26
|
|
11
23
|
|
|
12
24
|
### Changed
|
package/.github/workflows/cd.yml
CHANGED
package/.github/workflows/ci.yml
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
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)
|
|
7
|
-
|
|
8
3
|
Build [NW.js](https://github.com/nwjs/nw.js) applications for Mac, Windows and Linux.
|
|
9
4
|
|
|
10
5
|
## Table of Contents
|
|
@@ -39,51 +34,14 @@ pnpm add nw-builder
|
|
|
39
34
|
|
|
40
35
|
## Usage
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```shell
|
|
45
|
-
nwbuild ./path/to/app
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Module
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
const { nwbuild } = require("nw-builder");
|
|
52
|
-
|
|
53
|
-
nwbuild({
|
|
54
|
-
files: "./path/to/app",
|
|
55
|
-
platforms: ["linux64", "win32"],
|
|
56
|
-
});
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
> If no `mode` option is defined, it defaults to `run`. If no `platforms` option is defined, it defaults to the current platform.
|
|
37
|
+
Check out the the demo under `/test/demo` directory for examples of module usage. For CLI, type in `nwbuild --help` in your terminal.
|
|
60
38
|
|
|
61
39
|
## API Reference
|
|
62
40
|
|
|
63
41
|
> Stay up to date via the [Changelog](https://github.com/nwjs-community/nw-builder/blob/master/.github/CHANGELOG.md).
|
|
64
42
|
|
|
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
|
-
|
|
71
43
|
### Options
|
|
72
44
|
|
|
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
|
-
|
|
87
45
|
#### options.files _Required_
|
|
88
46
|
|
|
89
47
|
Type: `String`
|
package/bin/nwbuild.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const yargs = require("yargs/yargs");
|
|
4
4
|
const { hideBin } = require("yargs/helpers");
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const NwBuilder = require("../lib/index.cjs");
|
|
7
7
|
const { Options, detectCurrentPlatform } = require("../dist/index.cjs");
|
|
8
8
|
|
|
9
9
|
const cli = yargs(hideBin(process.argv))
|
|
@@ -139,8 +139,14 @@ const cli = yargs(hideBin(process.argv))
|
|
|
139
139
|
})
|
|
140
140
|
.parse();
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
const nw = new NwBuilder({
|
|
143
143
|
...cli,
|
|
144
144
|
currentPlatform: detectCurrentPlatform(process),
|
|
145
145
|
files: cli._,
|
|
146
146
|
});
|
|
147
|
+
|
|
148
|
+
if (cli.mode === "build") {
|
|
149
|
+
nw.build();
|
|
150
|
+
} else {
|
|
151
|
+
nw.run();
|
|
152
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -3,4 +3,4 @@ var va=Object.create;var He=Object.defineProperty;var da=Object.getOwnPropertyDe
|
|
|
3
3
|
globstar while`,e,h,t,f,p),this.matchOne(e.slice(h),t.slice(f),r))return this.debug("globstar found match!",h,a,p),!0;if(p==="."||p===".."||!n.dot&&p.charAt(0)==="."){this.debug("dot detected!",e,h,t,f);break}this.debug("globstar swallow a segment, and continue"),h++}return!!(r&&(this.debug(`
|
|
4
4
|
>>> no match, partial?`,e,h,t,f),h===a))}var c;if(typeof o=="string"?(c=l===o,this.debug("string match",o,l,c)):(c=l.match(o),this.debug("pattern match",o,l,c)),!c)return!1}if(i===a&&s===u)return!0;if(i===a)return r;if(s===u)return i===a-1&&e[i]==="";throw new Error("wtf?")};function Lh(e){return e.replace(/\\(.)/g,"$1")}function Th(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}});var Ps=v((Rp,ur)=>{typeof Object.create=="function"?ur.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:ur.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}}});var Ds=v(($p,cr)=>{try{if(lr=require("util"),typeof lr.inherits!="function")throw"";cr.exports=lr.inherits}catch{cr.exports=Ps()}var lr});var Et=v((Np,mt)=>{"use strict";function Gs(e){return e.charAt(0)==="/"}function ks(e){var t=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,r=t.exec(e),n=r[1]||"",i=Boolean(n&&n.charAt(1)!==":");return Boolean(r[2]||i)}mt.exports=process.platform==="win32"?ks:Gs;mt.exports.posix=Gs;mt.exports.win32=ks});var fr=v(Q=>{Q.setopts=Gh;Q.ownProp=Fs;Q.makeAbs=ke;Q.finish=kh;Q.mark=Fh;Q.isIgnored=Xs;Q.childrenIgnored=Mh;function Fs(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var qh=require("fs"),Oe=require("path"),jh=gt(),Ms=Et(),hr=jh.Minimatch;function Ch(e,t){return e.localeCompare(t,"en")}function Ph(e,t){e.ignore=t.ignore||[],Array.isArray(e.ignore)||(e.ignore=[e.ignore]),e.ignore.length&&(e.ignore=e.ignore.map(Dh))}function Dh(e){var t=null;if(e.slice(-3)==="/**"){var r=e.replace(/(\/\*\*)+$/,"");t=new hr(r,{dot:!0})}return{matcher:new hr(e,{dot:!0}),gmatcher:t}}function Gh(e,t,r){if(r||(r={}),r.matchBase&&t.indexOf("/")===-1){if(r.noglobstar)throw new Error("base matching requires globstar");t="**/"+t}e.silent=!!r.silent,e.pattern=t,e.strict=r.strict!==!1,e.realpath=!!r.realpath,e.realpathCache=r.realpathCache||Object.create(null),e.follow=!!r.follow,e.dot=!!r.dot,e.mark=!!r.mark,e.nodir=!!r.nodir,e.nodir&&(e.mark=!0),e.sync=!!r.sync,e.nounique=!!r.nounique,e.nonull=!!r.nonull,e.nosort=!!r.nosort,e.nocase=!!r.nocase,e.stat=!!r.stat,e.noprocess=!!r.noprocess,e.absolute=!!r.absolute,e.fs=r.fs||qh,e.maxLength=r.maxLength||1/0,e.cache=r.cache||Object.create(null),e.statCache=r.statCache||Object.create(null),e.symlinks=r.symlinks||Object.create(null),Ph(e,r),e.changedCwd=!1;var n=process.cwd();Fs(r,"cwd")?(e.cwd=Oe.resolve(r.cwd),e.changedCwd=e.cwd!==n):e.cwd=n,e.root=r.root||Oe.resolve(e.cwd,"/"),e.root=Oe.resolve(e.root),process.platform==="win32"&&(e.root=e.root.replace(/\\/g,"/")),e.cwdAbs=Ms(e.cwd)?e.cwd:ke(e,e.cwd),process.platform==="win32"&&(e.cwdAbs=e.cwdAbs.replace(/\\/g,"/")),e.nomount=!!r.nomount,r.nonegate=!0,r.nocomment=!0,r.allowWindowsEscape=!1,e.minimatch=new hr(t,r),e.options=e.minimatch.options}function kh(e){for(var t=e.nounique,r=t?[]:Object.create(null),n=0,i=e.matches.length;n<i;n++){var s=e.matches[n];if(!s||Object.keys(s).length===0){if(e.nonull){var a=e.minimatch.globSet[n];t?r.push(a):r[a]=!0}}else{var u=Object.keys(s);t?r.push.apply(r,u):u.forEach(function(o){r[o]=!0})}}if(t||(r=Object.keys(r)),e.nosort||(r=r.sort(Ch)),e.mark){for(var n=0;n<r.length;n++)r[n]=e._mark(r[n]);e.nodir&&(r=r.filter(function(o){var l=!/\/$/.test(o),h=e.cache[o]||e.cache[ke(e,o)];return l&&h&&(l=h!=="DIR"&&!Array.isArray(h)),l}))}e.ignore.length&&(r=r.filter(function(o){return!Xs(e,o)})),e.found=r}function Fh(e,t){var r=ke(e,t),n=e.cache[r],i=t;if(n){var s=n==="DIR"||Array.isArray(n),a=t.slice(-1)==="/";if(s&&!a?i+="/":!s&&a&&(i=i.slice(0,-1)),i!==t){var u=ke(e,i);e.statCache[u]=e.statCache[r],e.cache[u]=e.cache[r]}}return i}function ke(e,t){var r=t;return t.charAt(0)==="/"?r=Oe.join(e.root,t):Ms(t)||t===""?r=t:e.changedCwd?r=Oe.resolve(e.cwd,t):r=Oe.resolve(t),process.platform==="win32"&&(r=r.replace(/\\/g,"/")),r}function Xs(e,t){return e.ignore.length?e.ignore.some(function(r){return r.matcher.match(t)||!!(r.gmatcher&&r.gmatcher.match(t))}):!1}function Mh(e,t){return e.ignore.length?e.ignore.some(function(r){return!!(r.gmatcher&&r.gmatcher.match(t))}):!1}});var zs=v((jp,Vs)=>{Vs.exports=Bs;Bs.GlobSync=A;var Xh=rr(),Us=gt(),Lp=Us.Minimatch,Tp=dr().Glob,qp=require("util"),pr=require("path"),Hs=require("assert"),yt=Et(),ue=fr(),Uh=ue.setopts,vr=ue.ownProp,Hh=ue.childrenIgnored,Bh=ue.isIgnored;function Bs(e,t){if(typeof t=="function"||arguments.length===3)throw new TypeError(`callback provided to sync glob
|
|
5
5
|
See: https://github.com/isaacs/node-glob/issues/167`);return new A(e,t).found}function A(e,t){if(!e)throw new Error("must provide pattern");if(typeof t=="function"||arguments.length===3)throw new TypeError(`callback provided to sync glob
|
|
6
|
-
See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof A))return new A(e,t);if(Uh(this,e,t),this.noprocess)return this;var r=this.minimatch.set.length;this.matches=new Array(r);for(var n=0;n<r;n++)this._process(this.minimatch.set[n],n,!1);this._finish()}A.prototype._finish=function(){if(Hs.ok(this instanceof A),this.realpath){var e=this;this.matches.forEach(function(t,r){var n=e.matches[r]=Object.create(null);for(var i in t)try{i=e._makeAbs(i);var s=Xh.realpathSync(i,e.realpathCache);n[s]=!0}catch(a){if(a.syscall==="stat")n[e._makeAbs(i)]=!0;else throw a}})}ue.finish(this)};A.prototype._process=function(e,t,r){Hs.ok(this instanceof A);for(var n=0;typeof e[n]=="string";)n++;var i;switch(n){case e.length:this._processSimple(e.join("/"),t);return;case 0:i=null;break;default:i=e.slice(0,n).join("/");break}var s=e.slice(n),a;i===null?a=".":((yt(i)||yt(e.map(function(l){return typeof l=="string"?l:"[*]"}).join("/")))&&(!i||!yt(i))&&(i="/"+i),a=i);var u=this._makeAbs(a);if(!Hh(this,a)){var o=s[0]===Us.GLOBSTAR;o?this._processGlobStar(i,a,u,s,t,r):this._processReaddir(i,a,u,s,t,r)}};A.prototype._processReaddir=function(e,t,r,n,i,s){var a=this._readdir(r,s);if(!!a){for(var u=n[0],o=!!this.minimatch.negate,l=u._glob,h=this.dot||l.charAt(0)===".",f=[],p=0;p<a.length;p++){var c=a[p];if(c.charAt(0)!=="."||h){var m;o&&!e?m=!c.match(u):m=c.match(u),m&&f.push(c)}}var y=f.length;if(y!==0){if(n.length===1&&!this.mark&&!this.stat){this.matches[i]||(this.matches[i]=Object.create(null));for(var p=0;p<y;p++){var c=f[p];e&&(e.slice(-1)!=="/"?c=e+"/"+c:c=e+c),c.charAt(0)==="/"&&!this.nomount&&(c=pr.join(this.root,c)),this._emitMatch(i,c)}return}n.shift();for(var p=0;p<y;p++){var c=f[p],b;e?b=[e,c]:b=[c],this._process(b.concat(n),i,s)}}}};A.prototype._emitMatch=function(e,t){if(!Bh(this,t)){var r=this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var n=this.cache[r];if(n==="DIR"||Array.isArray(n))return}this.matches[e][t]=!0,this.stat&&this._stat(t)}}};A.prototype._readdirInGlobStar=function(e){if(this.follow)return this._readdir(e,!1);var t,r,n;try{r=this.fs.lstatSync(e)}catch(s){if(s.code==="ENOENT")return null}var i=r&&r.isSymbolicLink();return this.symlinks[e]=i,!i&&r&&!r.isDirectory()?this.cache[e]="FILE":t=this._readdir(e,!1),t};A.prototype._readdir=function(e,t){var r;if(t&&!vr(this.symlinks,e))return this._readdirInGlobStar(e);if(vr(this.cache,e)){var n=this.cache[e];if(!n||n==="FILE")return null;if(Array.isArray(n))return n}try{return this._readdirEntries(e,this.fs.readdirSync(e))}catch(i){return this._readdirError(e,i),null}};A.prototype._readdirEntries=function(e,t){if(!this.mark&&!this.stat)for(var r=0;r<t.length;r++){var n=t[r];e==="/"?n=e+n:n=e+"/"+n,this.cache[n]=!0}return this.cache[e]=t,t};A.prototype._readdirError=function(e,t){switch(t.code){case"ENOTSUP":case"ENOTDIR":var r=this._makeAbs(e);if(this.cache[r]="FILE",r===this.cwdAbs){var n=new Error(t.code+" invalid cwd "+this.cwd);throw n.path=this.cwd,n.code=t.code,n}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:if(this.cache[this._makeAbs(e)]=!1,this.strict)throw t;this.silent||console.error("glob error",t);break}};A.prototype._processGlobStar=function(e,t,r,n,i,s){var a=this._readdir(r,s);if(!!a){var u=n.slice(1),o=e?[e]:[],l=o.concat(u);this._process(l,i,!1);var h=a.length,f=this.symlinks[r];if(!(f&&s))for(var p=0;p<h;p++){var c=a[p];if(!(c.charAt(0)==="."&&!this.dot)){var m=o.concat(a[p],u);this._process(m,i,!0);var y=o.concat(a[p],n);this._process(y,i,!0)}}}};A.prototype._processSimple=function(e,t){var r=this._stat(e);if(this.matches[t]||(this.matches[t]=Object.create(null)),!!r){if(e&&yt(e)&&!this.nomount){var n=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=pr.join(this.root,e):(e=pr.resolve(this.root,e),n&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e)}};A.prototype._stat=function(e){var t=this._makeAbs(e),r=e.slice(-1)==="/";if(e.length>this.maxLength)return!1;if(!this.stat&&vr(this.cache,t)){var a=this.cache[t];if(Array.isArray(a)&&(a="DIR"),!r||a==="DIR")return a;if(r&&a==="FILE")return!1}var n,i=this.statCache[t];if(!i){var s;try{s=this.fs.lstatSync(t)}catch(u){if(u&&(u.code==="ENOENT"||u.code==="ENOTDIR"))return this.statCache[t]=!1,!1}if(s&&s.isSymbolicLink())try{i=this.fs.statSync(t)}catch{i=s}else i=s}this.statCache[t]=i;var a=!0;return i&&(a=i.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||a,r&&a==="FILE"?!1:a};A.prototype._mark=function(e){return ue.mark(this,e)};A.prototype._makeAbs=function(e){return ue.makeAbs(this,e)}});var gr=v((Cp,Ws)=>{Ws.exports=Zs;function Zs(e,t){if(e&&t)return Zs(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(n){r[n]=e[n]}),r;function r(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];var s=e.apply(this,n),a=n[n.length-1];return typeof s=="function"&&s!==a&&Object.keys(a).forEach(function(u){s[u]=a[u]}),s}}});var Er=v((Pp,mr)=>{var Ys=gr();mr.exports=Ys(bt);mr.exports.strict=Ys(Qs);bt.proto=bt(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return bt(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Qs(this)},configurable:!0})});function bt(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Qs(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}});var Js=v((Dp,Ks)=>{var Vh=gr(),Fe=Object.create(null),zh=Er();Ks.exports=Vh(Zh);function Zh(e,t){return Fe[e]?(Fe[e].push(t),null):(Fe[e]=[t],Wh(e))}function Wh(e){return zh(function t(){var r=Fe[e],n=r.length,i=Yh(arguments);try{for(var s=0;s<n;s++)r[s].apply(null,i)}finally{r.length>n?(r.splice(0,n),process.nextTick(function(){t.apply(null,i)})):delete Fe[e]}})}function Yh(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n]=e[n];return r}});var dr=v((Fp,ta)=>{ta.exports=le;var Qh=rr(),ea=gt(),Gp=ea.Minimatch,Kh=Ds(),Jh=require("events").EventEmitter,yr=require("path"),br=require("assert"),Me=Et(),_r=zs(),ce=fr(),ef=ce.setopts,wr=ce.ownProp,Or=Js(),kp=require("util"),tf=ce.childrenIgnored,rf=ce.isIgnored,nf=Er();function le(e,t,r){if(typeof t=="function"&&(r=t,t={}),t||(t={}),t.sync){if(r)throw new TypeError("callback provided to sync glob");return _r(e,t)}return new _(e,t,r)}le.sync=_r;var sf=le.GlobSync=_r.GlobSync;le.glob=le;function af(e,t){if(t===null||typeof t!="object")return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}le.hasMagic=function(e,t){var r=af({},t);r.noprocess=!0;var n=new _(e,r),i=n.minimatch.set;if(!e)return!1;if(i.length>1)return!0;for(var s=0;s<i[0].length;s++)if(typeof i[0][s]!="string")return!0;return!1};le.Glob=_;Kh(_,Jh);function _(e,t,r){if(typeof t=="function"&&(r=t,t=null),t&&t.sync){if(r)throw new TypeError("callback provided to sync glob");return new sf(e,t)}if(!(this instanceof _))return new _(e,t,r);ef(this,e,t),this._didRealPath=!1;var n=this.minimatch.set.length;this.matches=new Array(n),typeof r=="function"&&(r=nf(r),this.on("error",r),this.on("end",function(o){r(null,o)}));var i=this;if(this._processing=0,this._emitQueue=[],this._processQueue=[],this.paused=!1,this.noprocess)return this;if(n===0)return u();for(var s=!0,a=0;a<n;a++)this._process(this.minimatch.set[a],a,!1,u);s=!1;function u(){--i._processing,i._processing<=0&&(s?process.nextTick(function(){i._finish()}):i._finish())}}_.prototype._finish=function(){if(br(this instanceof _),!this.aborted){if(this.realpath&&!this._didRealpath)return this._realpath();ce.finish(this),this.emit("end",this.found)}};_.prototype._realpath=function(){if(this._didRealpath)return;this._didRealpath=!0;var e=this.matches.length;if(e===0)return this._finish();for(var t=this,r=0;r<this.matches.length;r++)this._realpathSet(r,n);function n(){--e===0&&t._finish()}};_.prototype._realpathSet=function(e,t){var r=this.matches[e];if(!r)return t();var n=Object.keys(r),i=this,s=n.length;if(s===0)return t();var a=this.matches[e]=Object.create(null);n.forEach(function(u,o){u=i._makeAbs(u),Qh.realpath(u,i.realpathCache,function(l,h){l?l.syscall==="stat"?a[u]=!0:i.emit("error",l):a[h]=!0,--s===0&&(i.matches[e]=a,t())})})};_.prototype._mark=function(e){return ce.mark(this,e)};_.prototype._makeAbs=function(e){return ce.makeAbs(this,e)};_.prototype.abort=function(){this.aborted=!0,this.emit("abort")};_.prototype.pause=function(){this.paused||(this.paused=!0,this.emit("pause"))};_.prototype.resume=function(){if(this.paused){if(this.emit("resume"),this.paused=!1,this._emitQueue.length){var e=this._emitQueue.slice(0);this._emitQueue.length=0;for(var t=0;t<e.length;t++){var r=e[t];this._emitMatch(r[0],r[1])}}if(this._processQueue.length){var n=this._processQueue.slice(0);this._processQueue.length=0;for(var t=0;t<n.length;t++){var i=n[t];this._processing--,this._process(i[0],i[1],i[2],i[3])}}}};_.prototype._process=function(e,t,r,n){if(br(this instanceof _),br(typeof n=="function"),!this.aborted){if(this._processing++,this.paused){this._processQueue.push([e,t,r,n]);return}for(var i=0;typeof e[i]=="string";)i++;var s;switch(i){case e.length:this._processSimple(e.join("/"),t,n);return;case 0:s=null;break;default:s=e.slice(0,i).join("/");break}var a=e.slice(i),u;s===null?u=".":((Me(s)||Me(e.map(function(h){return typeof h=="string"?h:"[*]"}).join("/")))&&(!s||!Me(s))&&(s="/"+s),u=s);var o=this._makeAbs(u);if(tf(this,u))return n();var l=a[0]===ea.GLOBSTAR;l?this._processGlobStar(s,u,o,a,t,r,n):this._processReaddir(s,u,o,a,t,r,n)}};_.prototype._processReaddir=function(e,t,r,n,i,s,a){var u=this;this._readdir(r,s,function(o,l){return u._processReaddir2(e,t,r,n,i,s,l,a)})};_.prototype._processReaddir2=function(e,t,r,n,i,s,a,u){if(!a)return u();for(var o=n[0],l=!!this.minimatch.negate,h=o._glob,f=this.dot||h.charAt(0)===".",p=[],c=0;c<a.length;c++){var m=a[c];if(m.charAt(0)!=="."||f){var y;l&&!e?y=!m.match(o):y=m.match(o),y&&p.push(m)}}var b=p.length;if(b===0)return u();if(n.length===1&&!this.mark&&!this.stat){this.matches[i]||(this.matches[i]=Object.create(null));for(var c=0;c<b;c++){var m=p[c];e&&(e!=="/"?m=e+"/"+m:m=e+m),m.charAt(0)==="/"&&!this.nomount&&(m=yr.join(this.root,m)),this._emitMatch(i,m)}return u()}n.shift();for(var c=0;c<b;c++){var m=p[c],O;e&&(e!=="/"?m=e+"/"+m:m=e+m),this._process([m].concat(n),i,s,u)}u()};_.prototype._emitMatch=function(e,t){if(!this.aborted&&!rf(this,t)){if(this.paused){this._emitQueue.push([e,t]);return}var r=Me(t)?t:this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var n=this.cache[r];if(n==="DIR"||Array.isArray(n))return}this.matches[e][t]=!0;var i=this.statCache[r];i&&this.emit("stat",t,i),this.emit("match",t)}}};_.prototype._readdirInGlobStar=function(e,t){if(this.aborted)return;if(this.follow)return this._readdir(e,!1,t);var r="lstat\0"+e,n=this,i=Or(r,s);i&&n.fs.lstat(e,i);function s(a,u){if(a&&a.code==="ENOENT")return t();var o=u&&u.isSymbolicLink();n.symlinks[e]=o,!o&&u&&!u.isDirectory()?(n.cache[e]="FILE",t()):n._readdir(e,!1,t)}};_.prototype._readdir=function(e,t,r){if(!this.aborted&&(r=Or("readdir\0"+e+"\0"+t,r),!!r)){if(t&&!wr(this.symlinks,e))return this._readdirInGlobStar(e,r);if(wr(this.cache,e)){var n=this.cache[e];if(!n||n==="FILE")return r();if(Array.isArray(n))return r(null,n)}var i=this;i.fs.readdir(e,of(this,e,r))}};function of(e,t,r){return function(n,i){n?e._readdirError(t,n,r):e._readdirEntries(t,i,r)}}_.prototype._readdirEntries=function(e,t,r){if(!this.aborted){if(!this.mark&&!this.stat)for(var n=0;n<t.length;n++){var i=t[n];e==="/"?i=e+i:i=e+"/"+i,this.cache[i]=!0}return this.cache[e]=t,r(null,t)}};_.prototype._readdirError=function(e,t,r){if(!this.aborted){switch(t.code){case"ENOTSUP":case"ENOTDIR":var n=this._makeAbs(e);if(this.cache[n]="FILE",n===this.cwdAbs){var i=new Error(t.code+" invalid cwd "+this.cwd);i.path=this.cwd,i.code=t.code,this.emit("error",i),this.abort()}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:this.cache[this._makeAbs(e)]=!1,this.strict&&(this.emit("error",t),this.abort()),this.silent||console.error("glob error",t);break}return r()}};_.prototype._processGlobStar=function(e,t,r,n,i,s,a){var u=this;this._readdir(r,s,function(o,l){u._processGlobStar2(e,t,r,n,i,s,l,a)})};_.prototype._processGlobStar2=function(e,t,r,n,i,s,a,u){if(!a)return u();var o=n.slice(1),l=e?[e]:[],h=l.concat(o);this._process(h,i,!1,u);var f=this.symlinks[r],p=a.length;if(f&&s)return u();for(var c=0;c<p;c++){var m=a[c];if(!(m.charAt(0)==="."&&!this.dot)){var y=l.concat(a[c],o);this._process(y,i,!0,u);var b=l.concat(a[c],n);this._process(b,i,!0,u)}}u()};_.prototype._processSimple=function(e,t,r){var n=this;this._stat(e,function(i,s){n._processSimple2(e,t,i,s,r)})};_.prototype._processSimple2=function(e,t,r,n,i){if(this.matches[t]||(this.matches[t]=Object.create(null)),!n)return i();if(e&&Me(e)&&!this.nomount){var s=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=yr.join(this.root,e):(e=yr.resolve(this.root,e),s&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e),i()};_.prototype._stat=function(e,t){var r=this._makeAbs(e),n=e.slice(-1)==="/";if(e.length>this.maxLength)return t();if(!this.stat&&wr(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||i==="DIR")return t(null,i);if(n&&i==="FILE")return t()}var s,a=this.statCache[r];if(a!==void 0){if(a===!1)return t(null,a);var u=a.isDirectory()?"DIR":"FILE";return n&&u==="FILE"?t():t(null,u,a)}var o=this,l=Or("stat\0"+r,h);l&&o.fs.lstat(r,l);function h(f,p){if(p&&p.isSymbolicLink())return o.fs.stat(r,function(c,m){c?o._stat2(e,r,null,p,t):o._stat2(e,r,c,m,t)});o._stat2(e,r,f,p,t)}};_.prototype._stat2=function(e,t,r,n,i){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))return this.statCache[t]=!1,i();var s=e.slice(-1)==="/";if(this.statCache[t]=n,t.slice(-1)==="/"&&n&&!n.isDirectory())return i(null,!1,n);var a=!0;return n&&(a=n.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||a,s&&a==="FILE"?i():i(null,a,n)}});var ia=v((Mp,na)=>{"use strict";var ra=qi(),uf=require("fs"),lf=require("path"),cf=Bi(),hf=Qi(),ff=cs(),pf=dr(),vf=function(e,t){var r=[];return hf(e).forEach(function(n){var i=n.indexOf("!")===0;i&&(n=n.slice(1));var s=t(n);i?r=cf(r,s):r=ff(r,s)}),r};na.exports=function(){var e=ra.toArray(arguments),t=ra.kindOf(e[0])==="object"?e.shift():{},r=Array.isArray(e[0])?e[0]:e;if(r.length===0)return[];var n=vf(r,function(i){return pf.sync(i,t)});return t.filter&&(n=n.filter(function(i){i=lf.join(t.cwd||"",i);try{return typeof t.filter=="function"?t.filter(i):uf.statSync(i)[t.filter]()}catch{return!1}})),n}});var Ef={};ya(Ef,{Options:()=>Nr,Platform:()=>X,Platforms:()=>$i,checkCache:()=>xi,checkPkgOptions:()=>ua,detectCurrentPlatform:()=>la,parseOptions:()=>ca});module.exports=ba(Ef);var wa={mode:"run",quiet:"info",files:null,version:"latest",flavor:"sdk",cacheDir:"./cache",platforms:[],currentPlatform:null,downloadUrl:"https://dl.nwjs.io/",manifestUrl:"https://nwjs.io/versions.json",appName:!1,appVersion:!1,buildDir:"./build",buildType:"default",forceDownload:!1,macCredits:!1,macIcns:!1,macZip:null,macPlist:!1,winVersionString:{},winIco:null,useRcedit:!1,argv:[],zip:null,zipOptions:null,mergeZip:!0},Nr=wa;var xr={NIX_32:"linux32",NIX_64:"linux64",OSX_32:"osx32",OSX_64:"osx64",WIN_32:"win32",WIN_64:"win64"};Object.freeze(xr);var X=xr;var kt=fe(Ri(),1),Nu={win32:{needsZip:!0,getRunnable:function(){return"nw.exe"},files:{"<=0.9.2":["nw.exe","ffmpegsumo.dll","icudt.dll","libEGL.dll","libGLESv2.dll","nw.pak"],">0.9.2 <0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales"],">=0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales","d3dcompiler_47.dll","pdf.dll"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-win-ia32.zip"},win64:{needsZip:!0,getRunnable:function(){return"nw.exe"},files:{"<=0.9.2":["nw.exe","ffmpegsumo.dll","icudt.dll","libEGL.dll","libGLESv2.dll","nw.pak","locales"],">0.9.2 <0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales"],">=0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales","d3dcompiler_47.dll","pdf.dll"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-win-x64.zip"},osx32:{needsZip:!1,getRunnable:function(e){return kt.default.satisfies(e,">=0.12.0 || ~0.12.0-alpha")?"nwjs.app/Contents/MacOS/nwjs":"node-webkit.app/Contents/MacOS/node-webkit"},files:{"<0.12.0-alpha":["node-webkit.app"],">=0.12.0 || ~0.12.0-alpha":["nwjs.app"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-osx-ia32.zip"},osx64:{needsZip:!1,getRunnable:function(e){return kt.default.satisfies(e,">=0.12.0 || ~0.12.0-alpha")?"nwjs.app/Contents/MacOS/nwjs":"node-webkit.app/Contents/MacOS/node-webkit"},files:{"<0.12.0-alpha":["node-webkit.app"],">=0.12.0 || ~0.12.0-alpha":["nwjs.app"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-osx-x64.zip"},linux32:{needsZip:!0,chmod:"0755",getRunnable:function(){return"nw"},files:{"<=0.9.2":["nw","nw.pak","libffmpegsumo.so"],">0.9.2 <=0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat"],">0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat","locales"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-linux-ia32.tar.gz"},linux64:{needsZip:!0,chmod:"0755",getRunnable:function(){return"nw"},files:{"<=0.9.2":["nw","nw.pak","libffmpegsumo.so"],">0.9.2 <=0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat"],">0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat","locales"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-linux-x64.tar.gz"}},$i=Nu;var it=fe(require("fs"),1),Ni=fe(require("path"),1),xu=(e,t)=>{let r=!1;if(t.length===1&&t[0]==="*")return it.default.existsSync(e)&&it.default.readdirSync(e).length>=2;for(let n of t){if(r)return!1;it.default.existsSync(Ni.default.join(e,n))||(r=!0)}return!r},xi=xu;var sa=fe(require("fs"),1),aa=fe(require("path"),1),oa=fe(ia(),1),df=e=>{let t={},r=(0,oa.default)(e);return r.length===0&&(console.error("[ ERROR ] package.json not found"),process.exit(1)),r.forEach(n=>{aa.default.basename(n)==="package.json"&&(t=sa.default.readFileSync(`${n}`,"utf8"),t=JSON.parse(t))}),t.nwbuild?t.nwbuild:{}},ua=df;var gf=e=>{switch(e.platform){case"darwin":return e.arch==="x64"?X.OSX_64:X.OSX_32;case"win32":return e.arch==="x64"||e.env.PROCESSOR_ARCHITEW6432?X.WIN_64:X.WIN_32;case"linux":return e.arch==="x64"?X.NIX_64:X.NIX_32;default:return}},la=gf;var mf=(e,t)=>{for(let r of Object.keys(e))t.hasOwnProperty(r)&&(t[r]=e[r]);return t},ca=mf;0&&(module.exports={Options,Platform,Platforms,checkCache,checkPkgOptions,detectCurrentPlatform,parseOptions});
|
|
6
|
+
See: https://github.com/isaacs/node-glob/issues/167`);if(!(this instanceof A))return new A(e,t);if(Uh(this,e,t),this.noprocess)return this;var r=this.minimatch.set.length;this.matches=new Array(r);for(var n=0;n<r;n++)this._process(this.minimatch.set[n],n,!1);this._finish()}A.prototype._finish=function(){if(Hs.ok(this instanceof A),this.realpath){var e=this;this.matches.forEach(function(t,r){var n=e.matches[r]=Object.create(null);for(var i in t)try{i=e._makeAbs(i);var s=Xh.realpathSync(i,e.realpathCache);n[s]=!0}catch(a){if(a.syscall==="stat")n[e._makeAbs(i)]=!0;else throw a}})}ue.finish(this)};A.prototype._process=function(e,t,r){Hs.ok(this instanceof A);for(var n=0;typeof e[n]=="string";)n++;var i;switch(n){case e.length:this._processSimple(e.join("/"),t);return;case 0:i=null;break;default:i=e.slice(0,n).join("/");break}var s=e.slice(n),a;i===null?a=".":((yt(i)||yt(e.map(function(l){return typeof l=="string"?l:"[*]"}).join("/")))&&(!i||!yt(i))&&(i="/"+i),a=i);var u=this._makeAbs(a);if(!Hh(this,a)){var o=s[0]===Us.GLOBSTAR;o?this._processGlobStar(i,a,u,s,t,r):this._processReaddir(i,a,u,s,t,r)}};A.prototype._processReaddir=function(e,t,r,n,i,s){var a=this._readdir(r,s);if(!!a){for(var u=n[0],o=!!this.minimatch.negate,l=u._glob,h=this.dot||l.charAt(0)===".",f=[],p=0;p<a.length;p++){var c=a[p];if(c.charAt(0)!=="."||h){var m;o&&!e?m=!c.match(u):m=c.match(u),m&&f.push(c)}}var y=f.length;if(y!==0){if(n.length===1&&!this.mark&&!this.stat){this.matches[i]||(this.matches[i]=Object.create(null));for(var p=0;p<y;p++){var c=f[p];e&&(e.slice(-1)!=="/"?c=e+"/"+c:c=e+c),c.charAt(0)==="/"&&!this.nomount&&(c=pr.join(this.root,c)),this._emitMatch(i,c)}return}n.shift();for(var p=0;p<y;p++){var c=f[p],b;e?b=[e,c]:b=[c],this._process(b.concat(n),i,s)}}}};A.prototype._emitMatch=function(e,t){if(!Bh(this,t)){var r=this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var n=this.cache[r];if(n==="DIR"||Array.isArray(n))return}this.matches[e][t]=!0,this.stat&&this._stat(t)}}};A.prototype._readdirInGlobStar=function(e){if(this.follow)return this._readdir(e,!1);var t,r,n;try{r=this.fs.lstatSync(e)}catch(s){if(s.code==="ENOENT")return null}var i=r&&r.isSymbolicLink();return this.symlinks[e]=i,!i&&r&&!r.isDirectory()?this.cache[e]="FILE":t=this._readdir(e,!1),t};A.prototype._readdir=function(e,t){var r;if(t&&!vr(this.symlinks,e))return this._readdirInGlobStar(e);if(vr(this.cache,e)){var n=this.cache[e];if(!n||n==="FILE")return null;if(Array.isArray(n))return n}try{return this._readdirEntries(e,this.fs.readdirSync(e))}catch(i){return this._readdirError(e,i),null}};A.prototype._readdirEntries=function(e,t){if(!this.mark&&!this.stat)for(var r=0;r<t.length;r++){var n=t[r];e==="/"?n=e+n:n=e+"/"+n,this.cache[n]=!0}return this.cache[e]=t,t};A.prototype._readdirError=function(e,t){switch(t.code){case"ENOTSUP":case"ENOTDIR":var r=this._makeAbs(e);if(this.cache[r]="FILE",r===this.cwdAbs){var n=new Error(t.code+" invalid cwd "+this.cwd);throw n.path=this.cwd,n.code=t.code,n}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:if(this.cache[this._makeAbs(e)]=!1,this.strict)throw t;this.silent||console.error("glob error",t);break}};A.prototype._processGlobStar=function(e,t,r,n,i,s){var a=this._readdir(r,s);if(!!a){var u=n.slice(1),o=e?[e]:[],l=o.concat(u);this._process(l,i,!1);var h=a.length,f=this.symlinks[r];if(!(f&&s))for(var p=0;p<h;p++){var c=a[p];if(!(c.charAt(0)==="."&&!this.dot)){var m=o.concat(a[p],u);this._process(m,i,!0);var y=o.concat(a[p],n);this._process(y,i,!0)}}}};A.prototype._processSimple=function(e,t){var r=this._stat(e);if(this.matches[t]||(this.matches[t]=Object.create(null)),!!r){if(e&&yt(e)&&!this.nomount){var n=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=pr.join(this.root,e):(e=pr.resolve(this.root,e),n&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e)}};A.prototype._stat=function(e){var t=this._makeAbs(e),r=e.slice(-1)==="/";if(e.length>this.maxLength)return!1;if(!this.stat&&vr(this.cache,t)){var a=this.cache[t];if(Array.isArray(a)&&(a="DIR"),!r||a==="DIR")return a;if(r&&a==="FILE")return!1}var n,i=this.statCache[t];if(!i){var s;try{s=this.fs.lstatSync(t)}catch(u){if(u&&(u.code==="ENOENT"||u.code==="ENOTDIR"))return this.statCache[t]=!1,!1}if(s&&s.isSymbolicLink())try{i=this.fs.statSync(t)}catch{i=s}else i=s}this.statCache[t]=i;var a=!0;return i&&(a=i.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||a,r&&a==="FILE"?!1:a};A.prototype._mark=function(e){return ue.mark(this,e)};A.prototype._makeAbs=function(e){return ue.makeAbs(this,e)}});var gr=v((Cp,Ws)=>{Ws.exports=Zs;function Zs(e,t){if(e&&t)return Zs(e)(t);if(typeof e!="function")throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(n){r[n]=e[n]}),r;function r(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];var s=e.apply(this,n),a=n[n.length-1];return typeof s=="function"&&s!==a&&Object.keys(a).forEach(function(u){s[u]=a[u]}),s}}});var Er=v((Pp,mr)=>{var Ys=gr();mr.exports=Ys(bt);mr.exports.strict=Ys(Qs);bt.proto=bt(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return bt(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Qs(this)},configurable:!0})});function bt(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Qs(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}});var Js=v((Dp,Ks)=>{var Vh=gr(),Fe=Object.create(null),zh=Er();Ks.exports=Vh(Zh);function Zh(e,t){return Fe[e]?(Fe[e].push(t),null):(Fe[e]=[t],Wh(e))}function Wh(e){return zh(function t(){var r=Fe[e],n=r.length,i=Yh(arguments);try{for(var s=0;s<n;s++)r[s].apply(null,i)}finally{r.length>n?(r.splice(0,n),process.nextTick(function(){t.apply(null,i)})):delete Fe[e]}})}function Yh(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n]=e[n];return r}});var dr=v((Fp,ta)=>{ta.exports=le;var Qh=rr(),ea=gt(),Gp=ea.Minimatch,Kh=Ds(),Jh=require("events").EventEmitter,yr=require("path"),br=require("assert"),Me=Et(),_r=zs(),ce=fr(),ef=ce.setopts,wr=ce.ownProp,Or=Js(),kp=require("util"),tf=ce.childrenIgnored,rf=ce.isIgnored,nf=Er();function le(e,t,r){if(typeof t=="function"&&(r=t,t={}),t||(t={}),t.sync){if(r)throw new TypeError("callback provided to sync glob");return _r(e,t)}return new _(e,t,r)}le.sync=_r;var sf=le.GlobSync=_r.GlobSync;le.glob=le;function af(e,t){if(t===null||typeof t!="object")return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}le.hasMagic=function(e,t){var r=af({},t);r.noprocess=!0;var n=new _(e,r),i=n.minimatch.set;if(!e)return!1;if(i.length>1)return!0;for(var s=0;s<i[0].length;s++)if(typeof i[0][s]!="string")return!0;return!1};le.Glob=_;Kh(_,Jh);function _(e,t,r){if(typeof t=="function"&&(r=t,t=null),t&&t.sync){if(r)throw new TypeError("callback provided to sync glob");return new sf(e,t)}if(!(this instanceof _))return new _(e,t,r);ef(this,e,t),this._didRealPath=!1;var n=this.minimatch.set.length;this.matches=new Array(n),typeof r=="function"&&(r=nf(r),this.on("error",r),this.on("end",function(o){r(null,o)}));var i=this;if(this._processing=0,this._emitQueue=[],this._processQueue=[],this.paused=!1,this.noprocess)return this;if(n===0)return u();for(var s=!0,a=0;a<n;a++)this._process(this.minimatch.set[a],a,!1,u);s=!1;function u(){--i._processing,i._processing<=0&&(s?process.nextTick(function(){i._finish()}):i._finish())}}_.prototype._finish=function(){if(br(this instanceof _),!this.aborted){if(this.realpath&&!this._didRealpath)return this._realpath();ce.finish(this),this.emit("end",this.found)}};_.prototype._realpath=function(){if(this._didRealpath)return;this._didRealpath=!0;var e=this.matches.length;if(e===0)return this._finish();for(var t=this,r=0;r<this.matches.length;r++)this._realpathSet(r,n);function n(){--e===0&&t._finish()}};_.prototype._realpathSet=function(e,t){var r=this.matches[e];if(!r)return t();var n=Object.keys(r),i=this,s=n.length;if(s===0)return t();var a=this.matches[e]=Object.create(null);n.forEach(function(u,o){u=i._makeAbs(u),Qh.realpath(u,i.realpathCache,function(l,h){l?l.syscall==="stat"?a[u]=!0:i.emit("error",l):a[h]=!0,--s===0&&(i.matches[e]=a,t())})})};_.prototype._mark=function(e){return ce.mark(this,e)};_.prototype._makeAbs=function(e){return ce.makeAbs(this,e)};_.prototype.abort=function(){this.aborted=!0,this.emit("abort")};_.prototype.pause=function(){this.paused||(this.paused=!0,this.emit("pause"))};_.prototype.resume=function(){if(this.paused){if(this.emit("resume"),this.paused=!1,this._emitQueue.length){var e=this._emitQueue.slice(0);this._emitQueue.length=0;for(var t=0;t<e.length;t++){var r=e[t];this._emitMatch(r[0],r[1])}}if(this._processQueue.length){var n=this._processQueue.slice(0);this._processQueue.length=0;for(var t=0;t<n.length;t++){var i=n[t];this._processing--,this._process(i[0],i[1],i[2],i[3])}}}};_.prototype._process=function(e,t,r,n){if(br(this instanceof _),br(typeof n=="function"),!this.aborted){if(this._processing++,this.paused){this._processQueue.push([e,t,r,n]);return}for(var i=0;typeof e[i]=="string";)i++;var s;switch(i){case e.length:this._processSimple(e.join("/"),t,n);return;case 0:s=null;break;default:s=e.slice(0,i).join("/");break}var a=e.slice(i),u;s===null?u=".":((Me(s)||Me(e.map(function(h){return typeof h=="string"?h:"[*]"}).join("/")))&&(!s||!Me(s))&&(s="/"+s),u=s);var o=this._makeAbs(u);if(tf(this,u))return n();var l=a[0]===ea.GLOBSTAR;l?this._processGlobStar(s,u,o,a,t,r,n):this._processReaddir(s,u,o,a,t,r,n)}};_.prototype._processReaddir=function(e,t,r,n,i,s,a){var u=this;this._readdir(r,s,function(o,l){return u._processReaddir2(e,t,r,n,i,s,l,a)})};_.prototype._processReaddir2=function(e,t,r,n,i,s,a,u){if(!a)return u();for(var o=n[0],l=!!this.minimatch.negate,h=o._glob,f=this.dot||h.charAt(0)===".",p=[],c=0;c<a.length;c++){var m=a[c];if(m.charAt(0)!=="."||f){var y;l&&!e?y=!m.match(o):y=m.match(o),y&&p.push(m)}}var b=p.length;if(b===0)return u();if(n.length===1&&!this.mark&&!this.stat){this.matches[i]||(this.matches[i]=Object.create(null));for(var c=0;c<b;c++){var m=p[c];e&&(e!=="/"?m=e+"/"+m:m=e+m),m.charAt(0)==="/"&&!this.nomount&&(m=yr.join(this.root,m)),this._emitMatch(i,m)}return u()}n.shift();for(var c=0;c<b;c++){var m=p[c],O;e&&(e!=="/"?m=e+"/"+m:m=e+m),this._process([m].concat(n),i,s,u)}u()};_.prototype._emitMatch=function(e,t){if(!this.aborted&&!rf(this,t)){if(this.paused){this._emitQueue.push([e,t]);return}var r=Me(t)?t:this._makeAbs(t);if(this.mark&&(t=this._mark(t)),this.absolute&&(t=r),!this.matches[e][t]){if(this.nodir){var n=this.cache[r];if(n==="DIR"||Array.isArray(n))return}this.matches[e][t]=!0;var i=this.statCache[r];i&&this.emit("stat",t,i),this.emit("match",t)}}};_.prototype._readdirInGlobStar=function(e,t){if(this.aborted)return;if(this.follow)return this._readdir(e,!1,t);var r="lstat\0"+e,n=this,i=Or(r,s);i&&n.fs.lstat(e,i);function s(a,u){if(a&&a.code==="ENOENT")return t();var o=u&&u.isSymbolicLink();n.symlinks[e]=o,!o&&u&&!u.isDirectory()?(n.cache[e]="FILE",t()):n._readdir(e,!1,t)}};_.prototype._readdir=function(e,t,r){if(!this.aborted&&(r=Or("readdir\0"+e+"\0"+t,r),!!r)){if(t&&!wr(this.symlinks,e))return this._readdirInGlobStar(e,r);if(wr(this.cache,e)){var n=this.cache[e];if(!n||n==="FILE")return r();if(Array.isArray(n))return r(null,n)}var i=this;i.fs.readdir(e,of(this,e,r))}};function of(e,t,r){return function(n,i){n?e._readdirError(t,n,r):e._readdirEntries(t,i,r)}}_.prototype._readdirEntries=function(e,t,r){if(!this.aborted){if(!this.mark&&!this.stat)for(var n=0;n<t.length;n++){var i=t[n];e==="/"?i=e+i:i=e+"/"+i,this.cache[i]=!0}return this.cache[e]=t,r(null,t)}};_.prototype._readdirError=function(e,t,r){if(!this.aborted){switch(t.code){case"ENOTSUP":case"ENOTDIR":var n=this._makeAbs(e);if(this.cache[n]="FILE",n===this.cwdAbs){var i=new Error(t.code+" invalid cwd "+this.cwd);i.path=this.cwd,i.code=t.code,this.emit("error",i),this.abort()}break;case"ENOENT":case"ELOOP":case"ENAMETOOLONG":case"UNKNOWN":this.cache[this._makeAbs(e)]=!1;break;default:this.cache[this._makeAbs(e)]=!1,this.strict&&(this.emit("error",t),this.abort()),this.silent||console.error("glob error",t);break}return r()}};_.prototype._processGlobStar=function(e,t,r,n,i,s,a){var u=this;this._readdir(r,s,function(o,l){u._processGlobStar2(e,t,r,n,i,s,l,a)})};_.prototype._processGlobStar2=function(e,t,r,n,i,s,a,u){if(!a)return u();var o=n.slice(1),l=e?[e]:[],h=l.concat(o);this._process(h,i,!1,u);var f=this.symlinks[r],p=a.length;if(f&&s)return u();for(var c=0;c<p;c++){var m=a[c];if(!(m.charAt(0)==="."&&!this.dot)){var y=l.concat(a[c],o);this._process(y,i,!0,u);var b=l.concat(a[c],n);this._process(b,i,!0,u)}}u()};_.prototype._processSimple=function(e,t,r){var n=this;this._stat(e,function(i,s){n._processSimple2(e,t,i,s,r)})};_.prototype._processSimple2=function(e,t,r,n,i){if(this.matches[t]||(this.matches[t]=Object.create(null)),!n)return i();if(e&&Me(e)&&!this.nomount){var s=/[\/\\]$/.test(e);e.charAt(0)==="/"?e=yr.join(this.root,e):(e=yr.resolve(this.root,e),s&&(e+="/"))}process.platform==="win32"&&(e=e.replace(/\\/g,"/")),this._emitMatch(t,e),i()};_.prototype._stat=function(e,t){var r=this._makeAbs(e),n=e.slice(-1)==="/";if(e.length>this.maxLength)return t();if(!this.stat&&wr(this.cache,r)){var i=this.cache[r];if(Array.isArray(i)&&(i="DIR"),!n||i==="DIR")return t(null,i);if(n&&i==="FILE")return t()}var s,a=this.statCache[r];if(a!==void 0){if(a===!1)return t(null,a);var u=a.isDirectory()?"DIR":"FILE";return n&&u==="FILE"?t():t(null,u,a)}var o=this,l=Or("stat\0"+r,h);l&&o.fs.lstat(r,l);function h(f,p){if(p&&p.isSymbolicLink())return o.fs.stat(r,function(c,m){c?o._stat2(e,r,null,p,t):o._stat2(e,r,c,m,t)});o._stat2(e,r,f,p,t)}};_.prototype._stat2=function(e,t,r,n,i){if(r&&(r.code==="ENOENT"||r.code==="ENOTDIR"))return this.statCache[t]=!1,i();var s=e.slice(-1)==="/";if(this.statCache[t]=n,t.slice(-1)==="/"&&n&&!n.isDirectory())return i(null,!1,n);var a=!0;return n&&(a=n.isDirectory()?"DIR":"FILE"),this.cache[t]=this.cache[t]||a,s&&a==="FILE"?i():i(null,a,n)}});var ia=v((Mp,na)=>{"use strict";var ra=qi(),uf=require("fs"),lf=require("path"),cf=Bi(),hf=Qi(),ff=cs(),pf=dr(),vf=function(e,t){var r=[];return hf(e).forEach(function(n){var i=n.indexOf("!")===0;i&&(n=n.slice(1));var s=t(n);i?r=cf(r,s):r=ff(r,s)}),r};na.exports=function(){var e=ra.toArray(arguments),t=ra.kindOf(e[0])==="object"?e.shift():{},r=Array.isArray(e[0])?e[0]:e;if(r.length===0)return[];var n=vf(r,function(i){return pf.sync(i,t)});return t.filter&&(n=n.filter(function(i){i=lf.join(t.cwd||"",i);try{return typeof t.filter=="function"?t.filter(i):uf.statSync(i)[t.filter]()}catch{return!1}})),n}});var Ef={};ya(Ef,{Options:()=>Nr,Platform:()=>X,Platforms:()=>$i,checkCache:()=>xi,checkPkgOptions:()=>ua,detectCurrentPlatform:()=>la,parseOptions:()=>ca});module.exports=ba(Ef);var wa={mode:"run",quiet:"info",files:null,version:"latest",flavor:"sdk",cacheDir:"./cache",platforms:[],currentPlatform:null,downloadUrl:"https://dl.nwjs.io/",manifestUrl:"https://nwjs.io/versions.json",appName:!1,appVersion:!1,buildDir:"./build",buildType:"default",forceDownload:!1,macCredits:!1,macIcns:!1,macZip:null,macPlist:!1,winVersionString:{},winIco:null,useRcedit:!1,argv:[],zip:null,zipOptions:null,mergeZip:!0},Nr=wa;var xr={NIX_32:"linux32",NIX_64:"linux64",OSX_32:"osx32",OSX_64:"osx64",WIN_32:"win32",WIN_64:"win64"};Object.freeze(xr);var X=xr;var kt=fe(Ri(),1),Nu={win32:{needsZip:!0,getRunnable:function(){return"nw.exe"},files:{"<=0.9.2":["nw.exe","ffmpegsumo.dll","icudt.dll","libEGL.dll","libGLESv2.dll","nw.pak"],">0.9.2 <0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales"],">=0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales","d3dcompiler_47.dll","pdf.dll"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-win-ia32.zip"},win64:{needsZip:!0,getRunnable:function(){return"nw.exe"},files:{"<=0.9.2":["nw.exe","ffmpegsumo.dll","icudt.dll","libEGL.dll","libGLESv2.dll","nw.pak","locales"],">0.9.2 <0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales"],">=0.12.0":["nw.exe","ffmpegsumo.dll","icudtl.dat","libEGL.dll","libGLESv2.dll","nw.pak","locales","d3dcompiler_47.dll","pdf.dll"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-win-x64.zip"},osx32:{needsZip:!1,getRunnable:function(e){return kt.default.satisfies(e,">=0.12.0 || ~0.12.0-alpha")?"nwjs.app/Contents/MacOS/nwjs":"node-webkit.app/Contents/MacOS/node-webkit"},files:{"<0.12.0-alpha":["node-webkit.app"],">=0.12.0 || ~0.12.0-alpha":["nwjs.app"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-osx-ia32.zip"},osx64:{needsZip:!1,getRunnable:function(e){return kt.default.satisfies(e,">=0.12.0 || ~0.12.0-alpha")?"nwjs.app/Contents/MacOS/nwjs":"node-webkit.app/Contents/MacOS/node-webkit"},files:{"<0.12.0-alpha":["node-webkit.app"],">=0.12.0 || ~0.12.0-alpha":["nwjs.app"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-osx-x64.zip"},linux32:{needsZip:!0,chmod:"0755",getRunnable:function(){return"nw"},files:{"<=0.9.2":["nw","nw.pak","libffmpegsumo.so"],">0.9.2 <=0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat"],">0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat","locales"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-linux-ia32.tar.gz"},linux64:{needsZip:!0,chmod:"0755",getRunnable:function(){return"nw"},files:{"<=0.9.2":["nw","nw.pak","libffmpegsumo.so"],">0.9.2 <=0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat"],">0.10.1":["nw","nw.pak","libffmpegsumo.so","icudtl.dat","locales"]},versionNameTemplate:"v${ version }/${ name }-v${ version }-linux-x64.tar.gz"}},$i=Nu;var it=fe(require("fs"),1),Ni=fe(require("path"),1),xu=(e,t)=>{let r=!1;if(t.length===1&&t[0]==="*")return it.default.existsSync(e)&&it.default.readdirSync(e).length>=2;for(let n of t){if(r)return!1;it.default.existsSync(Ni.default.join(e,n))||(r=!0)}return!r},xi=xu;var sa=fe(require("fs"),1),aa=fe(require("path"),1),oa=fe(ia(),1),df=e=>{let t={},r=(0,oa.default)(e),n=!1;return r.forEach(i=>{!n&&aa.default.basename(i)==="package.json"&&(t=sa.default.readFileSync(`${i}`,"utf8"),t=JSON.parse(t),n=!0)}),t.nwbuild?t.nwbuild:{}},ua=df;var gf=e=>{switch(e.platform){case"darwin":return e.arch==="x64"?X.OSX_64:X.OSX_32;case"win32":return e.arch==="x64"||e.env.PROCESSOR_ARCHITEW6432?X.WIN_64:X.WIN_32;case"linux":return e.arch==="x64"?X.NIX_64:X.NIX_32;default:return}},la=gf;var mf=(e,t)=>{for(let r of Object.keys(e))t.hasOwnProperty(r)&&(t[r]=e[r]);return t},ca=mf;0&&(module.exports={Options,Platform,Platforms,checkCache,checkPkgOptions,detectCurrentPlatform,parseOptions});
|
package/lib/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { existsSync } = require("node:fs");
|
|
1
2
|
var _ = require("lodash");
|
|
2
3
|
var inherits = require("inherits");
|
|
3
4
|
var EventEmitter = require("events").EventEmitter;
|
|
@@ -11,6 +12,7 @@ var spawn = require("child_process").spawn;
|
|
|
11
12
|
var semver = require("semver");
|
|
12
13
|
var platformOverrides = require("./platformOverrides.cjs");
|
|
13
14
|
var deprecate = require("deprecate");
|
|
15
|
+
const { install } = require("nw-install");
|
|
14
16
|
|
|
15
17
|
const {
|
|
16
18
|
checkCache,
|
|
@@ -23,20 +25,6 @@ const {
|
|
|
23
25
|
var NwVersions = require("./versions.cjs");
|
|
24
26
|
var Version = require("./Version.cjs");
|
|
25
27
|
var Utils = require("./utils.cjs");
|
|
26
|
-
var Downloader = require("./downloader.cjs");
|
|
27
|
-
// var platforms = require("./platforms.cjs");
|
|
28
|
-
|
|
29
|
-
var pkg = require("../package.json");
|
|
30
|
-
|
|
31
|
-
(async () => {
|
|
32
|
-
let updateNotifier = undefined;
|
|
33
|
-
try {
|
|
34
|
-
updateNotifier = await import("update-notifier");
|
|
35
|
-
updateNotifier.default({ pkg }).notify();
|
|
36
|
-
} catch (e) {
|
|
37
|
-
console.error(e);
|
|
38
|
-
}
|
|
39
|
-
})();
|
|
40
28
|
|
|
41
29
|
// We inherit from EventEmitter for logging
|
|
42
30
|
inherits(NwBuilder, EventEmitter);
|
|
@@ -325,74 +313,35 @@ NwBuilder.prototype.platformFilesForVersion = function () {
|
|
|
325
313
|
return Promise.resolve();
|
|
326
314
|
};
|
|
327
315
|
|
|
328
|
-
NwBuilder.prototype.downloadNwjs = function () {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
platform.url = self._version.platforms[name + "-" + self._version.flavor];
|
|
340
|
-
|
|
341
|
-
// Ensure that there is a cache folder
|
|
342
|
-
if (self.options.forceDownload) {
|
|
343
|
-
fs.removeSync(platform.cache);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
fs.mkdirpSync(platform.cache);
|
|
347
|
-
self.emit(
|
|
348
|
-
"log",
|
|
349
|
-
"Create cache folder in " +
|
|
350
|
-
path.resolve(
|
|
351
|
-
self.options.cacheDir,
|
|
352
|
-
self._version.version + "-" + self._version.flavor,
|
|
353
|
-
),
|
|
354
|
-
);
|
|
355
|
-
|
|
316
|
+
NwBuilder.prototype.downloadNwjs = async function () {
|
|
317
|
+
let options = this.options;
|
|
318
|
+
for await (let osName of options.platforms) {
|
|
319
|
+
let plat = osName.slice(0, osName.length - 2);
|
|
320
|
+
let arch =
|
|
321
|
+
osName.slice(osName.length - 2, osName.length) === "32" ? "ia32" : "x64";
|
|
322
|
+
this._platforms[osName].url =
|
|
323
|
+
this._version.platforms[osName + "-" + this._version.flavor];
|
|
324
|
+
this._platforms[
|
|
325
|
+
osName
|
|
326
|
+
].cache = `${this.options.cacheDir}/${this.options.version}-${this.options.flavor}/${osName}/nwjs-${this.options.flavor}-v${this.options.version}-${plat}-${arch}`;
|
|
356
327
|
if (
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
self._version.flavor,
|
|
362
|
-
)
|
|
328
|
+
options.forceDownload === true ||
|
|
329
|
+
existsSync(
|
|
330
|
+
`${this.options.cacheDir}/${this.options.version}-${this.options.flavor}/${osName}/nwjs-${this.options.flavor}-v${this.options.version}-${plat}-${arch}`,
|
|
331
|
+
) === false
|
|
363
332
|
) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
self._version.flavor +
|
|
374
|
-
") does not have a corresponding build posted at " +
|
|
375
|
-
self.options.downloadUrl +
|
|
376
|
-
". Please choose a version from that list.",
|
|
377
|
-
);
|
|
378
|
-
} else {
|
|
379
|
-
self.emit("log", err.msg);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return Promise.reject("Unable to download NWjs.");
|
|
383
|
-
},
|
|
384
|
-
),
|
|
333
|
+
await install(
|
|
334
|
+
this.options.version,
|
|
335
|
+
this.options.flavor,
|
|
336
|
+
plat,
|
|
337
|
+
arch,
|
|
338
|
+
"https://nwjs.io",
|
|
339
|
+
"https://dl.nwjs.io",
|
|
340
|
+
`${this.options.cacheDir}/${this.options.version}-${this.options.flavor}/${osName}`,
|
|
341
|
+
`nwjs-${this.options.flavor}-v${this.options.version}-${plat}-${arch}`,
|
|
385
342
|
);
|
|
386
|
-
self.emit("log", "Downloading: " + platform.url);
|
|
387
|
-
} else {
|
|
388
|
-
self.emit("log", "Using cache for: " + name);
|
|
389
343
|
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return Promise.all(downloads).then(function (data) {
|
|
393
|
-
Downloader.clearProgressbar();
|
|
394
|
-
return data;
|
|
395
|
-
});
|
|
344
|
+
}
|
|
396
345
|
};
|
|
397
346
|
|
|
398
347
|
NwBuilder.prototype.buildGypModules = function () {
|
|
@@ -1086,22 +1035,4 @@ NwBuilder.prototype.preparePlatformFiles = function (
|
|
|
1086
1035
|
return true;
|
|
1087
1036
|
};
|
|
1088
1037
|
|
|
1089
|
-
const nwbuild = (options, callback = [() => {}, () => {}, () => {}]) => {
|
|
1090
|
-
const nw = new NwBuilder(options);
|
|
1091
|
-
|
|
1092
|
-
nw.on("log", (msg) => {
|
|
1093
|
-
console.log(`[ INFO ] ${msg}`);
|
|
1094
|
-
});
|
|
1095
|
-
|
|
1096
|
-
if (nw.options.mode === "run") {
|
|
1097
|
-
nw.run().then(callback[0]).catch(callback[1]).finally(callback[2]);
|
|
1098
|
-
} else if (nw.options.mode === "build") {
|
|
1099
|
-
nw.build().then(callback[0]).catch(callback[1]).finally(callback[2]);
|
|
1100
|
-
} else {
|
|
1101
|
-
console.log("[ WARN ] Invalid mode option.");
|
|
1102
|
-
}
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
1038
|
module.exports = NwBuilder;
|
|
1106
|
-
exports = module.exports;
|
|
1107
|
-
exports.nwbuild = nwbuild;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.4",
|
|
4
4
|
"description": "Build NW.js desktop applications for Mac, Windows and Linux.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"author": "Steffen Müller <steffen@mllrsohn.com>",
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"main": "lib/index.cjs",
|
|
12
|
+
"main": "./lib/index.cjs",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"homepage": "https://github.com/nwutils/nw-builder",
|
|
15
15
|
"repository": {
|
|
@@ -21,19 +21,18 @@
|
|
|
21
21
|
"lint": "eslint ./bin/**.cjs ./lib/**.cjs ./src/**.js",
|
|
22
22
|
"test": "npm run test:unit && tape './test/*.cjs'",
|
|
23
23
|
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
24
|
-
"demo": "cd ./test/demo && npm start",
|
|
24
|
+
"demo": "cd ./test/demo && npm run start",
|
|
25
25
|
"demo:cli": "nwbuild ./** --mode=build --platforms=linux32, linux64 --version=0.67.1",
|
|
26
26
|
"build": "esbuild src/index.js --bundle --minify --platform=node --outfile=./dist/index.cjs"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"decompress-zip": "^0.3.3",
|
|
30
|
-
"eol": "^0.9.1",
|
|
31
30
|
"esbuild": "^0.15.2",
|
|
32
31
|
"eslint": "^8.18.0",
|
|
33
32
|
"eslint-config-tjw-jsdoc": "^1.0.3",
|
|
34
33
|
"eslint-plugin-jsdoc": "^39.3.3",
|
|
35
|
-
"jest": "^
|
|
36
|
-
"jest-environment-jsdom": "^
|
|
34
|
+
"jest": "^29.0.2",
|
|
35
|
+
"jest-environment-jsdom": "^29.0.2",
|
|
37
36
|
"jsdom": "^20.0.0",
|
|
38
37
|
"nock": "^13.2.7",
|
|
39
38
|
"prettier": "^2.7.1",
|
|
@@ -43,11 +42,10 @@
|
|
|
43
42
|
"dependencies": {
|
|
44
43
|
"archiver": "^5.3.1",
|
|
45
44
|
"deprecate": "^1.1.1",
|
|
46
|
-
"extract-zip": "^2.0.1",
|
|
47
45
|
"graceful-fs-extra": "^2.0.0",
|
|
48
|
-
"graceful-ncp": "^3.0.0",
|
|
49
46
|
"inherits": "^2.0.4",
|
|
50
47
|
"lodash": "^4.17.21",
|
|
48
|
+
"nw-install": "^0.3.3",
|
|
51
49
|
"plist": "^3.0.5",
|
|
52
50
|
"progress": "^2.0.3",
|
|
53
51
|
"rcedit": "^3.0.1",
|
|
@@ -56,10 +54,8 @@
|
|
|
56
54
|
"rimraf": "^3.0.2",
|
|
57
55
|
"semver": "^7.3.7",
|
|
58
56
|
"simple-glob": "^0.2.0",
|
|
59
|
-
"tar-fs": "^2.1.1",
|
|
60
57
|
"temp": "^0.9.4",
|
|
61
58
|
"thenify": "^3.3.1",
|
|
62
|
-
"update-notifier": "^6.0.2",
|
|
63
59
|
"winresourcer": "^0.9.0",
|
|
64
60
|
"yargs": "^17.5.1"
|
|
65
61
|
},
|
|
@@ -8,15 +8,13 @@ const checkPkgOptions = (files) => {
|
|
|
8
8
|
|
|
9
9
|
let matches = Glob(files);
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
console.error("[ ERROR ] package.json not found");
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
11
|
+
let packageJsonExists = false;
|
|
15
12
|
|
|
16
13
|
matches.forEach((file) => {
|
|
17
|
-
if (path.basename(file) === "package.json") {
|
|
14
|
+
if (!packageJsonExists && path.basename(file) === "package.json") {
|
|
18
15
|
pkg = fs.readFileSync(`${file}`, "utf8");
|
|
19
16
|
pkg = JSON.parse(pkg);
|
|
17
|
+
packageJsonExists = true;
|
|
20
18
|
}
|
|
21
19
|
});
|
|
22
20
|
|
package/test/demo/index.cjs
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
const NwBuilder = require("../../lib/index.cjs");
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const nw = new NwBuilder({
|
|
4
4
|
files: "./**",
|
|
5
|
+
version: "0.67.1",
|
|
6
|
+
platforms: ["linux64"],
|
|
5
7
|
});
|
|
8
|
+
|
|
9
|
+
// Replace `build` with `run` to run the application instead
|
|
10
|
+
nw.build()
|
|
11
|
+
.then((msg) => {
|
|
12
|
+
console.log(msg);
|
|
13
|
+
})
|
|
14
|
+
.catch((error) => {
|
|
15
|
+
console.log(error);
|
|
16
|
+
});
|
package/test/demo/package.json
CHANGED
package/lib/downloader.cjs
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
var request = require("request");
|
|
2
|
-
var progress = require("progress");
|
|
3
|
-
var fs = require("fs");
|
|
4
|
-
var path = require("path");
|
|
5
|
-
var zlib = require("zlib");
|
|
6
|
-
var tar = require("tar-fs");
|
|
7
|
-
var temp = require("temp");
|
|
8
|
-
var ncp = require("graceful-ncp").ncp;
|
|
9
|
-
var rimraf = require("rimraf");
|
|
10
|
-
var extract = require("extract-zip");
|
|
11
|
-
|
|
12
|
-
// Automatically track and cleanup files at exit
|
|
13
|
-
temp.track();
|
|
14
|
-
var isWin = /^win/.test(process.platform);
|
|
15
|
-
|
|
16
|
-
// one progressbar for all downloads
|
|
17
|
-
var bar;
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
clearProgressbar: function () {
|
|
21
|
-
bar && bar.terminate();
|
|
22
|
-
bar = null;
|
|
23
|
-
},
|
|
24
|
-
downloadAndUnpack: function (cachepath, url) {
|
|
25
|
-
var extension = path.extname(url),
|
|
26
|
-
self = this,
|
|
27
|
-
rq = request(url),
|
|
28
|
-
len,
|
|
29
|
-
stream;
|
|
30
|
-
|
|
31
|
-
function format(statusCode) {
|
|
32
|
-
return statusCode + ": " + require("http").STATUS_CODES[statusCode];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return new Promise(function (resolve, reject) {
|
|
36
|
-
rq.proxy = true;
|
|
37
|
-
rq.on("error", function (err) {
|
|
38
|
-
bar && bar.terminate();
|
|
39
|
-
reject(err);
|
|
40
|
-
});
|
|
41
|
-
rq.on("response", function (res) {
|
|
42
|
-
len = parseInt(res.headers["content-length"], 10);
|
|
43
|
-
if (res.statusCode !== 200) {
|
|
44
|
-
reject({
|
|
45
|
-
statusCode: res.statusCode,
|
|
46
|
-
msg: "Recieved status code " + format(res.statusCode),
|
|
47
|
-
});
|
|
48
|
-
} else if (len) {
|
|
49
|
-
if (!bar) {
|
|
50
|
-
bar = new progress(" downloading [:bar] :percent :etas", {
|
|
51
|
-
complete: "=",
|
|
52
|
-
incomplete: "-",
|
|
53
|
-
width: 20,
|
|
54
|
-
total: len,
|
|
55
|
-
});
|
|
56
|
-
} else {
|
|
57
|
-
bar.total += len;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
rq.on("data", function (chunk) {
|
|
62
|
-
len && bar && bar.tick(chunk.length);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
if (extension === ".zip") {
|
|
66
|
-
rq.on("response", function (res) {
|
|
67
|
-
if (res.statusCode !== 200) return;
|
|
68
|
-
stream = temp.createWriteStream();
|
|
69
|
-
|
|
70
|
-
stream.on("finish", function () {
|
|
71
|
-
self
|
|
72
|
-
.extractZip(stream.path, cachepath)
|
|
73
|
-
.then(self.stripRootFolder)
|
|
74
|
-
.then(function (files) {
|
|
75
|
-
resolve(files);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
rq.pipe(stream);
|
|
80
|
-
});
|
|
81
|
-
} else if (extension === ".gz") {
|
|
82
|
-
rq.on("response", function (res) {
|
|
83
|
-
if (res.statusCode !== 200) return;
|
|
84
|
-
self
|
|
85
|
-
.extractTar(res, cachepath)
|
|
86
|
-
.then(self.stripRootFolder)
|
|
87
|
-
.then(function (files) {
|
|
88
|
-
resolve(files);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
extractTar: function (tarstream, destination) {
|
|
95
|
-
var gunzip = zlib.createGunzip(),
|
|
96
|
-
files = [];
|
|
97
|
-
|
|
98
|
-
return new Promise(function (resolve, reject) {
|
|
99
|
-
tarstream
|
|
100
|
-
.pipe(gunzip)
|
|
101
|
-
.on("error", function (err) {
|
|
102
|
-
reject(err);
|
|
103
|
-
})
|
|
104
|
-
.pipe(
|
|
105
|
-
tar.extract(destination, {
|
|
106
|
-
umask: isWin ? false : 0,
|
|
107
|
-
map: function (header) {
|
|
108
|
-
files.push({ path: path.basename(header.name) });
|
|
109
|
-
return header;
|
|
110
|
-
},
|
|
111
|
-
}),
|
|
112
|
-
)
|
|
113
|
-
.on("finish", function () {
|
|
114
|
-
resolve({ files: files, destination: destination });
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
extractZip: function (zipfile, destination) {
|
|
119
|
-
var files = [];
|
|
120
|
-
|
|
121
|
-
var onEntry = function (entry) {
|
|
122
|
-
files.push({
|
|
123
|
-
mode: entry.externalFileAttributes >>> 16,
|
|
124
|
-
path: entry.fileName,
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
return new Promise(function (resolve, reject) {
|
|
129
|
-
extract(zipfile, { dir: destination, onEntry: onEntry })
|
|
130
|
-
.catch(reject)
|
|
131
|
-
.then(function () {
|
|
132
|
-
// Setup chmodSync to fix permissions
|
|
133
|
-
files.forEach(function (file) {
|
|
134
|
-
fs.chmodSync(path.join(destination, file.path), file.mode);
|
|
135
|
-
});
|
|
136
|
-
resolve({ files, destination });
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
stripRootFolder: function (extracted) {
|
|
141
|
-
var files = extracted.files,
|
|
142
|
-
destination = extracted.destination,
|
|
143
|
-
rootFiles = fs.readdirSync(destination),
|
|
144
|
-
fromDir = path.join(
|
|
145
|
-
destination,
|
|
146
|
-
rootFiles.length === 1 ? rootFiles[0] : "",
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
// strip out root folder if it exists
|
|
150
|
-
if (rootFiles.length === 1 && fs.statSync(fromDir).isDirectory()) {
|
|
151
|
-
// strip folder from files
|
|
152
|
-
for (var i = 0; i < files.length; i++) {
|
|
153
|
-
var file = files[i];
|
|
154
|
-
file.path = path.relative(rootFiles[0], file.path);
|
|
155
|
-
if (file.path === "") {
|
|
156
|
-
files.splice(i, 1);
|
|
157
|
-
i--;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return new Promise(function (resolve, reject) {
|
|
162
|
-
// move stripped folder to destination
|
|
163
|
-
ncp(fromDir, destination, function (err) {
|
|
164
|
-
if (err) {
|
|
165
|
-
return reject();
|
|
166
|
-
} else
|
|
167
|
-
rimraf(fromDir, function () {
|
|
168
|
-
resolve(files);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
} else {
|
|
173
|
-
return Promise.resolve(files);
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
};
|
package/test/downloader.cjs
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
var test = require("tape"),
|
|
2
|
-
nock = require("nock"),
|
|
3
|
-
temp = require("temp"),
|
|
4
|
-
path = require("path"),
|
|
5
|
-
fs = require("fs");
|
|
6
|
-
|
|
7
|
-
temp.track();
|
|
8
|
-
|
|
9
|
-
var downloader = require("../lib/downloader.cjs");
|
|
10
|
-
var fixturesZip = "./test/fixtures/test.zip";
|
|
11
|
-
var fixturesZipStrip = "./test/fixtures/test-strip.zip";
|
|
12
|
-
var fixturesTar = "./test/fixtures/test.tar.gz";
|
|
13
|
-
var isWindows = process.platform === "win32";
|
|
14
|
-
|
|
15
|
-
test("downloadAndUnpack: zip", function (t) {
|
|
16
|
-
t.plan(isWindows ? 3 : 6);
|
|
17
|
-
nock("https://amazon.s3.nw.com")
|
|
18
|
-
.get("/test.zip")
|
|
19
|
-
.replyWithFile(200, fixturesZip);
|
|
20
|
-
temp.mkdir("tmpcache", function (err, dirPath) {
|
|
21
|
-
downloader
|
|
22
|
-
.downloadAndUnpack(dirPath, "https://amazon.s3.nw.com/test.zip")
|
|
23
|
-
.then(function (files) {
|
|
24
|
-
files.forEach(function (file) {
|
|
25
|
-
t.ok(
|
|
26
|
-
fs.existsSync(path.join(dirPath, file.path)),
|
|
27
|
-
file.path + " unpacked",
|
|
28
|
-
);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
if (!isWindows) {
|
|
32
|
-
t.ok(
|
|
33
|
-
fs.statSync(path.join(dirPath, "file1")).mode.toString(8) == 100444,
|
|
34
|
-
"444 file permission",
|
|
35
|
-
);
|
|
36
|
-
t.ok(
|
|
37
|
-
fs.statSync(path.join(dirPath, "file2")).mode.toString(8) == 100666,
|
|
38
|
-
"666 file permission",
|
|
39
|
-
);
|
|
40
|
-
t.ok(
|
|
41
|
-
fs.statSync(path.join(dirPath, "file3")).mode.toString(8) == 100644,
|
|
42
|
-
"644 file permission",
|
|
43
|
-
); // DOES NOT WORK ON WINDOWS
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("downloadAndUnpack: zip+strip", function (t) {
|
|
50
|
-
t.plan(isWindows ? 3 : 6);
|
|
51
|
-
nock("https://amazon.s3.nw.com")
|
|
52
|
-
.get("/test-strip.zip")
|
|
53
|
-
.replyWithFile(200, fixturesZipStrip);
|
|
54
|
-
temp.mkdir("tmpcache", function (err, dirPath) {
|
|
55
|
-
downloader
|
|
56
|
-
.downloadAndUnpack(dirPath, "https://amazon.s3.nw.com/test-strip.zip")
|
|
57
|
-
.then(function (files) {
|
|
58
|
-
files.forEach(function (file) {
|
|
59
|
-
t.ok(
|
|
60
|
-
fs.existsSync(path.join(dirPath, file.path)),
|
|
61
|
-
file.path + " unpacked",
|
|
62
|
-
);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
if (!isWindows) {
|
|
66
|
-
t.ok(
|
|
67
|
-
fs.statSync(path.join(dirPath, "file1")).mode.toString(8) == 100444,
|
|
68
|
-
"444 file permission",
|
|
69
|
-
);
|
|
70
|
-
t.ok(
|
|
71
|
-
fs.statSync(path.join(dirPath, "file2")).mode.toString(8) == 100666,
|
|
72
|
-
"666 file permission",
|
|
73
|
-
);
|
|
74
|
-
t.ok(
|
|
75
|
-
fs.statSync(path.join(dirPath, "file3")).mode.toString(8) == 100644,
|
|
76
|
-
"644 file permission",
|
|
77
|
-
); // DOES NOT WORK ON WINDOWS
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("downloadAndUnpack: tar", function (t) {
|
|
84
|
-
t.plan(isWindows ? 3 : 6);
|
|
85
|
-
nock("https://amazon.s3.nw.com")
|
|
86
|
-
.get("/test.tar.gz")
|
|
87
|
-
.replyWithFile(200, fixturesTar);
|
|
88
|
-
temp.mkdir("tmpcache", function (err, dirPath) {
|
|
89
|
-
downloader
|
|
90
|
-
.downloadAndUnpack(dirPath, "https://amazon.s3.nw.com/test.tar.gz")
|
|
91
|
-
.then(function (files) {
|
|
92
|
-
files.forEach(function (file) {
|
|
93
|
-
t.ok(
|
|
94
|
-
fs.existsSync(path.join(dirPath, file.path)),
|
|
95
|
-
file.path + " unpacked",
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
if (!isWindows) {
|
|
100
|
-
t.ok(
|
|
101
|
-
fs.statSync(path.join(dirPath, "file1")).mode.toString(8) == 100444,
|
|
102
|
-
"444 file permission",
|
|
103
|
-
); // DOES NOT WORK ON WINDOWS
|
|
104
|
-
t.ok(
|
|
105
|
-
fs.statSync(path.join(dirPath, "file2")).mode.toString(8) == 100666,
|
|
106
|
-
"666 file permission",
|
|
107
|
-
);
|
|
108
|
-
t.ok(
|
|
109
|
-
fs.statSync(path.join(dirPath, "file3")).mode.toString(8) == 100644,
|
|
110
|
-
"644 file permission",
|
|
111
|
-
); // DOES NOT WORK ON WINDOWS
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test("Should throw an error if you try to download a file that is not available", function (t) {
|
|
118
|
-
t.plan(2);
|
|
119
|
-
nock("https://doesnot.com").get("/exist.zip").reply(404);
|
|
120
|
-
downloader
|
|
121
|
-
.downloadAndUnpack("/", "https://doesnot.com/exist.zip")
|
|
122
|
-
.catch(function (err) {
|
|
123
|
-
t.equal(err.statusCode, 404, err.msg);
|
|
124
|
-
});
|
|
125
|
-
nock("https://doesnot.com").get("/exist.tar").reply(404);
|
|
126
|
-
downloader
|
|
127
|
-
.downloadAndUnpack("/", "https://doesnot.com/exist.tar")
|
|
128
|
-
.catch(function (err) {
|
|
129
|
-
t.equal(err.statusCode, 404, err.msg);
|
|
130
|
-
});
|
|
131
|
-
});
|