@wallabyjs/cli 1.0.9 → 1.0.10

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 (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -51,7 +51,7 @@ tell application "System Events" to get value of property list item "CFBundleNam
51
51
  `)}),s&&(o=s(o)||o),console.log(o.map(u=>u.title?`${u.title}:
52
52
  ${u.body}`:u.body).join(`
53
53
 
54
- `))}outputVersion(){let{name:e}=this.cli,{versionNumber:r}=this.cli.globalCommand;r&&console.log(`${e}/${r} ${ph}`)}checkRequiredArgs(){let e=this.args.filter(r=>r.required).length;if(this.cli.args.length<e)throw new wt(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:r}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!r.hasOption(n))throw new wt(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:r}=this.cli,n=[...r.options,...this.options];for(let i of n){let s=e[i.name.split(".")[0]];if(i.required){let o=n.some(a=>a.negated&&a.names.includes(i.name));if(s===!0||s===!1&&!o)throw new wt(`option \`${i.rawName}\` value is missing`)}}}},zt=class extends Xt{constructor(e){super("@@global@@","",{},e)}},jt=Object.assign,kr=class extends ks.EventEmitter{constructor(e=""){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new zt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,r,n){let i=new Xt(e,r||"",n,this);return i.globalCommand=this.globalCommand,this.commands.push(i),i}option(e,r,n){return this.globalCommand.option(e,r,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,r="-v, --version"){return this.globalCommand.version(e,r),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:r},n,i){return this.args=e,this.options=r,n&&(this.matchedCommand=n),i&&(this.matchedCommandName=i),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e=mh,{run:r=!0}={}){this.rawArgs=e,this.name||(this.name=e[1]?dh(e[1]):"cli");let n=!0;for(let s of this.commands){let o=this.mri(e.slice(2),s),a=o.args[0];if(s.isMatched(a)){n=!1;let c=jt(jt({},o),{args:o.args.slice(1)});this.setParsedInfo(c,s,a),this.emit(`command:${a}`,s)}}if(n){for(let s of this.commands)if(s.name===""){n=!1;let o=this.mri(e.slice(2),s);this.setParsedInfo(o,s),this.emit("command:!",s)}}if(n){let s=this.mri(e.slice(2));this.setParsedInfo(s)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),r=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),r=!1,this.unsetMatchedCommand());let i={args:this.args,options:this.options};return r&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.emit("command:*"),i}mri(e,r){let n=[...this.globalCommand.options,...r?r.options:[]],i=uh(n),s=[],o=e.indexOf("--");o>-1&&(s=e.slice(o+1),e=e.slice(0,o));let a=ah(e,i);a=Object.keys(a).reduce((m,d)=>jt(jt({},m),{[Bs(d)]:a[d]}),{_:[]});let c=a._,u={"--":s},l=r&&r.config.ignoreOptionDefaultValue?r.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,f=Object.create(null);for(let m of n){if(!l&&m.config.default!==void 0)for(let d of m.names)u[d]=m.config.default;Array.isArray(m.config.type)&&f[m.name]===void 0&&(f[m.name]=Object.create(null),f[m.name].shouldTransform=!0,f[m.name].transformFunction=m.config.type[0])}for(let m of Object.keys(a))if(m!=="_"){let d=m.split(".");fh(u,d,a[m]),hh(u,f)}return{args:c,options:u}}runMatchedCommand(){let{args:e,options:r,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs();let i=[];return n.args.forEach((s,o)=>{s.variadic?i.push(e.slice(o)):i.push(e[o])}),i.push(r),n.commandAction.apply(this,i)}},Ms=(t="")=>new kr(t);var wr=Q(Ta()),F=Q(Fa()),qu=Q(vc()),_u=Q(Dc()),cE=!1,mr="https",Pu=!0,ku=__dirname,uE=(0,H.join)(ku,"bin"),Sr=Ms("wallaby"),Uu=require((0,H.join)(ku,"package.json")).version,Un=(0,H.join)((0,Fu.homedir)(),".wallaby"),ke=(0,H.join)(Un,"cli"),qn=(0,H.join)(ke,"downloads"),Bu=(0,H.join)(Un,"key.lic"),Mu=(0,H.join)(ke,"wallaby.json"),_n=(0,H.join)(ke,"core.json"),At=(0,H.join)(ke,"pinned.version"),bu=()=>mr+"://update.wallabyjs.com/",lE=10*60*1e3,pr,Fn=0,bt,Tt;Sr.command("[start]","start wallaby").alias("start").option("--doNotOpen","do not open browser on startup").option("--smart","use smart (lazy) start to run tests of modified test files only: https://wallabyjs.com/docs/intro/smart-start.html").option("--config <path>","use config file: https://wallabyjs.com/docs/config/overview.html").option("--update <version>","if no version is provided, forces a Wallaby Core update to the latest version before starting. Otherwise, installs and pins the specified Wallaby Core version before starting",{type:[String]}).option("--useHttp","use http instead of https for downloading Wallaby dependencies").option("--useNonStrictSSL","do not use strict SSL for downloading Wallaby dependencies").option("--suppressExpirationNotifications","do not notify about license expiration").action(async(t,e)=>{yE(e),e.useHttp&&(mr="http"),e.useNonStrictSSL&&(Pu=!1),Y.default.ensureDirSync(Un),Y.default.ensureDirSync(ke),await Vu(e)});Sr.help();Sr.version(Uu);Sr.parse();function Hu(t){clearTimeout(pr),pr=setTimeout(async()=>{await Gu(t)},lE)}async function Gu(t){try{Tt=await zu(t),Tt?.updated&&(bt?.process.send({type:"coreUpdated",version:Er(Tt.path)}),Fn=0)}catch{Fn++}finally{Fn<=3&&Hu(Tt?.path||t)}}async function Vu(t){clearTimeout(pr),bt?.process.removeAllListeners(),bt?.process.kill();let e=!1,r=t.update.trim();if(r==="undefined"||r==="0")e=!1;else if(r==="true")await Pn(),e=!0;else{let s=r.startsWith("v")?r.replace("v",""):r;e=!1,(0,wr.valid)(s)?await NE(s):await Pn()}let{path:n,type:i}=Tt||await hE({forceUpdate:e});bt=fE(n,t),i==="dist"&&Hu(bt.path)}function fE(t,e){let r=["--cli=true","--lkp="+Bu];e.smart&&r.push("--smartStart=true"),e.config&&r.push("--configPath="+(0,H.resolve)(e.config));let n=Bn();n&&r.push("--pinned="+n);let i=Er((0,H.dirname)(t)),[,,s]=i.split(".");parseInt(s,10)<1608&&(process.stdout.write(F.red(`${F.bold("Wallaby Core")} v${i} is not supported.
54
+ `))}outputVersion(){let{name:e}=this.cli,{versionNumber:r}=this.cli.globalCommand;r&&console.log(`${e}/${r} ${ph}`)}checkRequiredArgs(){let e=this.args.filter(r=>r.required).length;if(this.cli.args.length<e)throw new wt(`missing required args for command \`${this.rawName}\``)}checkUnknownOptions(){let{options:e,globalCommand:r}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!r.hasOption(n))throw new wt(`Unknown option \`${n.length>1?`--${n}`:`-${n}`}\``)}}checkOptionValue(){let{options:e,globalCommand:r}=this.cli,n=[...r.options,...this.options];for(let i of n){let s=e[i.name.split(".")[0]];if(i.required){let o=n.some(a=>a.negated&&a.names.includes(i.name));if(s===!0||s===!1&&!o)throw new wt(`option \`${i.rawName}\` value is missing`)}}}},zt=class extends Xt{constructor(e){super("@@global@@","",{},e)}},jt=Object.assign,kr=class extends ks.EventEmitter{constructor(e=""){super(),this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new zt(this),this.globalCommand.usage("<command> [options]")}usage(e){return this.globalCommand.usage(e),this}command(e,r,n){let i=new Xt(e,r||"",n,this);return i.globalCommand=this.globalCommand,this.commands.push(i),i}option(e,r,n){return this.globalCommand.option(e,r,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,r="-v, --version"){return this.globalCommand.version(e,r),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){this.matchedCommand?this.matchedCommand.outputHelp():this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:r},n,i){return this.args=e,this.options=r,n&&(this.matchedCommand=n),i&&(this.matchedCommandName=i),this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}parse(e=mh,{run:r=!0}={}){this.rawArgs=e,this.name||(this.name=e[1]?dh(e[1]):"cli");let n=!0;for(let s of this.commands){let o=this.mri(e.slice(2),s),a=o.args[0];if(s.isMatched(a)){n=!1;let c=jt(jt({},o),{args:o.args.slice(1)});this.setParsedInfo(c,s,a),this.emit(`command:${a}`,s)}}if(n){for(let s of this.commands)if(s.name===""){n=!1;let o=this.mri(e.slice(2),s);this.setParsedInfo(o,s),this.emit("command:!",s)}}if(n){let s=this.mri(e.slice(2));this.setParsedInfo(s)}this.options.help&&this.showHelpOnExit&&(this.outputHelp(),r=!1,this.unsetMatchedCommand()),this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null&&(this.outputVersion(),r=!1,this.unsetMatchedCommand());let i={args:this.args,options:this.options};return r&&this.runMatchedCommand(),!this.matchedCommand&&this.args[0]&&this.emit("command:*"),i}mri(e,r){let n=[...this.globalCommand.options,...r?r.options:[]],i=uh(n),s=[],o=e.indexOf("--");o>-1&&(s=e.slice(o+1),e=e.slice(0,o));let a=ah(e,i);a=Object.keys(a).reduce((m,d)=>jt(jt({},m),{[Bs(d)]:a[d]}),{_:[]});let c=a._,u={"--":s},l=r&&r.config.ignoreOptionDefaultValue?r.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,f=Object.create(null);for(let m of n){if(!l&&m.config.default!==void 0)for(let d of m.names)u[d]=m.config.default;Array.isArray(m.config.type)&&f[m.name]===void 0&&(f[m.name]=Object.create(null),f[m.name].shouldTransform=!0,f[m.name].transformFunction=m.config.type[0])}for(let m of Object.keys(a))if(m!=="_"){let d=m.split(".");fh(u,d,a[m]),hh(u,f)}return{args:c,options:u}}runMatchedCommand(){let{args:e,options:r,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs();let i=[];return n.args.forEach((s,o)=>{s.variadic?i.push(e.slice(o)):i.push(e[o])}),i.push(r),n.commandAction.apply(this,i)}},Ms=(t="")=>new kr(t);var wr=Q(Ta()),F=Q(Fa()),qu=Q(vc()),_u=Q(Dc()),cE=!1,mr="https",Pu=!0,ku=__dirname,uE=(0,H.join)(ku,"bin"),Sr=Ms("wallaby"),Uu=require((0,H.join)(ku,"package.json")).version,Un=(0,H.join)((0,Fu.homedir)(),".wallaby"),ke=(0,H.join)(Un,"cli"),qn=(0,H.join)(ke,"downloads"),Bu=(0,H.join)(Un,"key.lic"),Mu=(0,H.join)(ke,"wallaby.json"),_n=(0,H.join)(ke,"core.json"),At=(0,H.join)(ke,"pinned.version"),bu=()=>mr+"://update.wallabyjs.com/",lE=10*60*1e3,pr,Fn=0,bt,Tt;Sr.command("[start]","start wallaby").alias("start").option("--doNotOpen","do not open browser on startup").option("--smart","use smart (lazy) start to run tests of modified test files only: https://wallabyjs.com/docs/intro/smart-start.html").option("--config <path>","use config file: https://wallabyjs.com/docs/config/overview.html").option("--update <version>","if no version is provided, forces a Wallaby Core update to the latest version before starting. Otherwise, installs and pins the specified Wallaby Core version before starting",{type:[String]}).option("--useHttp","use http instead of https for downloading Wallaby dependencies").option("--useNonStrictSSL","do not use strict SSL for downloading Wallaby dependencies").option("--suppressExpirationNotifications","do not notify about license expiration").action(async(t,e)=>{yE(e),e.useHttp&&(mr="http"),e.useNonStrictSSL&&(Pu=!1),Y.default.ensureDirSync(Un),Y.default.ensureDirSync(ke),await Vu(e)});Sr.help();Sr.version(Uu);Sr.parse();function Hu(t){clearTimeout(pr),pr=setTimeout(async()=>{await Gu(t)},lE)}async function Gu(t){try{Tt=await zu(t),Tt?.updated&&(bt?.process.send({type:"coreUpdated",version:Er(Tt.path)}),Fn=0)}catch{Fn++}finally{Fn<=3&&Hu(Tt?.path||t)}}async function Vu(t){clearTimeout(pr),bt?.process.removeAllListeners(),bt?.process.kill();let e=!1,r=t.update?.trim();if(r==="undefined"||r==="0")e=!1;else if(r==="true")await Pn(),e=!0;else if(r){let s=r.startsWith("v")?r.replace("v",""):r;e=!1,(0,wr.valid)(s)?await NE(s):await Pn()}let{path:n,type:i}=Tt||await hE({forceUpdate:e});bt=fE(n,t),i==="dist"&&Hu(bt.path)}function fE(t,e){let r=["--cli=true","--lkp="+Bu];e.smart&&r.push("--smartStart=true"),e.config&&r.push("--configPath="+(0,H.resolve)(e.config));let n=Bn();n&&r.push("--pinned="+n);let i=Er((0,H.dirname)(t)),[,,s]=i.split(".");parseInt(s,10)<1608&&(process.stdout.write(F.red(`${F.bold("Wallaby Core")} v${i} is not supported.
55
55
  `)),process.stdout.write(F.red(`Run with ${F.bold("--update")} flag to get the latest version of Wallaby Core.
56
56
  `)),process.exit(1));let o=(0,gr.fork)(t,r,{env:process.env,silent:!0});return e.printLinks=!0,o.on("message",a=>{switch(a?.type){case"uiStarted":e.port=a.port,EE(e,i);break;case"notification":pE(e,a.notification);break;case"restart":Vu(e);break;case"licenseChanged":clearTimeout(pr),Gu(t);break;case"stopped":break;default:break}}),o.on("exit",()=>{process.stdout.write(F.gray(`
57
57
  ${F.bold("WALLABY CORE")} stopped
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallabyjs/cli",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "main": "./index.js",
5
5
  "description": "Wallaby CLI",
6
6
  "homepage": "https://wallabyjs.com",