@mindw1n/webnative 1.1.1 → 1.1.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.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- var _=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},C=class extends _{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var A=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:(e.push(t),e)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function $(o){let t=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+t+">":"["+t+"]"}import{EventEmitter as ut}from"node:events";import I from"node:child_process";import g from"node:path";import S from"node:fs";import m from"node:process";import{stripVTControlCharacters as ht}from"node:util";import{stripVTControlCharacters as ot}from"node:util";var y=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((n,s)=>n.name().localeCompare(s.name())),e}compareOptions(t,e){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),s=i.long&&t._findOption(i.long);!n&&!s?e.push(i):i.long&&!s?e.push(t.createOption(i.long,i.description)):i.short&&!n&&e.push(t.createOption(i.short,i.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);e.push(...n)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(i=>$(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(n)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(n)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(n)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,e,i){return e.length===0?[]:[i.styleTitle(t),...e,""]}groupItems(t,e,i){let n=new Map;return t.forEach(s=>{let r=i(s);n.has(r)||n.set(r,[])}),e.forEach(s=>{let r=i(s);n.has(r)||n.set(r,[]),n.get(r).push(s)}),n}formatHelp(t,e){let i=e.padWidth(t,e),n=e.helpWidth??80;function s(u,c){return e.formatItem(u,i,c,e)}let r=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(r=r.concat([e.boxWrap(e.styleCommandDescription(a),n),""]));let h=e.visibleArguments(t).map(u=>s(e.styleArgumentTerm(e.argumentTerm(u)),e.styleArgumentDescription(e.argumentDescription(u))));if(r=r.concat(this.formatItemList("Arguments:",h,e)),this.groupItems(t.options,e.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,c)=>{let w=u.map(b=>s(e.styleOptionTerm(e.optionTerm(b)),e.styleOptionDescription(e.optionDescription(b))));r=r.concat(this.formatItemList(c,w,e))}),e.showGlobalOptions){let u=e.visibleGlobalOptions(t).map(c=>s(e.styleOptionTerm(e.optionTerm(c)),e.styleOptionDescription(e.optionDescription(c))));r=r.concat(this.formatItemList("Global Options:",u,e))}return this.groupItems(t.commands,e.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,c)=>{let w=u.map(b=>s(e.styleSubcommandTerm(e.subcommandTerm(b)),e.styleSubcommandDescription(e.subcommandDescription(b))));r=r.concat(this.formatItemList(c,w,e))}),r.join(`
2
+ var b=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},C=class extends b{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var y=class{constructor(t,e){switch(this.description=e||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:(e.push(t),e)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new C(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function $(o){let t=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+t+">":"["+t+"]"}import{EventEmitter as ut}from"node:events";import I from"node:child_process";import _ from"node:path";import S from"node:fs";import m from"node:process";import{stripVTControlCharacters as ht}from"node:util";import{stripVTControlCharacters as ot}from"node:util";var A=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(n=>!n._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((n,s)=>n.name().localeCompare(s.name())),e}compareOptions(t,e){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(n=>!n.hidden),i=t._getHelpOption();if(i&&!i.hidden){let n=i.short&&t._findOption(i.short),s=i.long&&t._findOption(i.long);!n&&!s?e.push(i):i.long&&!s?e.push(t.createOption(i.long,i.description)):i.short&&!n&&e.push(t.createOption(i.short,i.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let n=i.options.filter(s=>!s.hidden);e.push(...n)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(i=>$(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(n)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(n)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(n)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,n)=>Math.max(i,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(n)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let n=t.parent;n;n=n.parent)i=n.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,e,i){return e.length===0?[]:[i.styleTitle(t),...e,""]}groupItems(t,e,i){let n=new Map;return t.forEach(s=>{let r=i(s);n.has(r)||n.set(r,[])}),e.forEach(s=>{let r=i(s);n.has(r)||n.set(r,[]),n.get(r).push(s)}),n}formatHelp(t,e){let i=e.padWidth(t,e),n=e.helpWidth??80;function s(u,c){return e.formatItem(u,i,c,e)}let r=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(r=r.concat([e.boxWrap(e.styleCommandDescription(a),n),""]));let h=e.visibleArguments(t).map(u=>s(e.styleArgumentTerm(e.argumentTerm(u)),e.styleArgumentDescription(e.argumentDescription(u))));if(r=r.concat(this.formatItemList("Arguments:",h,e)),this.groupItems(t.options,e.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,c)=>{let w=u.map(O=>s(e.styleOptionTerm(e.optionTerm(O)),e.styleOptionDescription(e.optionDescription(O))));r=r.concat(this.formatItemList(c,w,e))}),e.showGlobalOptions){let u=e.visibleGlobalOptions(t).map(c=>s(e.styleOptionTerm(e.optionTerm(c)),e.styleOptionDescription(e.optionDescription(c))));r=r.concat(this.formatItemList("Global Options:",u,e))}return this.groupItems(t.commands,e.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,c)=>{let w=u.map(O=>s(e.styleSubcommandTerm(e.subcommandTerm(O)),e.styleSubcommandDescription(e.subcommandDescription(O))));r=r.concat(this.formatItemList(c,w,e))}),r.join(`
3
3
  `)}displayWidth(t){return ot(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e==="[command]"?this.styleSubcommandText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleCommandText(e)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleSubcommandText(e)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,i,n){let r=" ".repeat(2);if(!i)return r+t;let a=t.padEnd(e+t.length-n.displayWidth(t)),h=2,l=(this.helpWidth??80)-e-h-2,u;return l<this.minWidthToWrap||n.preformatted(i)?u=i:u=n.boxWrap(i,l).replace(/\n/g,`
4
4
  `+" ".repeat(e+h)),r+a+" ".repeat(h)+u.replace(/\n/g,`
5
5
  ${r}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,s=[];return i.forEach(r=>{let a=r.match(n);if(a===null){s.push("");return}let h=[a.shift()],p=this.displayWidth(h[0]);a.forEach(l=>{let u=this.displayWidth(l);if(p+u<=e){h.push(l),p+=u;return}s.push(h.join(""));let c=l.trimStart();h=[c],p=this.displayWidth(c)}),s.push(h.join(""))}),s.join(`
@@ -9,37 +9,37 @@ ${r}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),n
9
9
  - or use a double dash for a long option (and can have two, like '--ws, --workspace')`):i.test(r)?new Error(`${a}
10
10
  - too many short flags`):n.test(r)?new Error(`${a}
11
11
  - too many long flags`):new Error(`${a}
12
- - unrecognised flag format`)}if(t===void 0&&e===void 0)throw new Error(`option creation failed due to no flags found in '${o}'.`);return{shortFlag:t,longFlag:e}}function lt(o,t){if(Math.abs(o.length-t.length)>3)return Math.max(o.length,t.length);let e=[];for(let i=0;i<=o.length;i++)e[i]=[i];for(let i=0;i<=t.length;i++)e[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=o.length;n++){let s;o[n-1]===t[i-1]?s=0:s=1,e[n][i]=Math.min(e[n-1][i]+1,e[n][i-1]+1,e[n-1][i-1]+s),n>1&&i>1&&o[n-1]===t[i-2]&&o[n-2]===t[i-1]&&(e[n][i]=Math.min(e[n][i],e[n-2][i-2]+1))}return e[o.length][t.length]}function F(o,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let e=o.startsWith("--");e&&(o=o.slice(2),t=t.map(r=>r.slice(2)));let i=[],n=3,s=.4;return t.forEach(r=>{if(r.length<=1)return;let a=lt(o,r),h=Math.max(o.length,r.length);(h-a)/h>s&&(a<n?(n=a,i=[r]):a===n&&i.push(r))}),i.sort((r,a)=>r.localeCompare(a)),e&&(i=i.map(r=>`--${r}`)),i.length>1?`
12
+ - unrecognised flag format`)}if(t===void 0&&e===void 0)throw new Error(`option creation failed due to no flags found in '${o}'.`);return{shortFlag:t,longFlag:e}}function lt(o,t){if(Math.abs(o.length-t.length)>3)return Math.max(o.length,t.length);let e=[];for(let i=0;i<=o.length;i++)e[i]=[i];for(let i=0;i<=t.length;i++)e[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=o.length;n++){let s;o[n-1]===t[i-1]?s=0:s=1,e[n][i]=Math.min(e[n-1][i]+1,e[n][i-1]+1,e[n-1][i-1]+s),n>1&&i>1&&o[n-1]===t[i-2]&&o[n-2]===t[i-1]&&(e[n][i]=Math.min(e[n][i],e[n-2][i-2]+1))}return e[o.length][t.length]}function D(o,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let e=o.startsWith("--");e&&(o=o.slice(2),t=t.map(r=>r.slice(2)));let i=[],n=3,s=.4;return t.forEach(r=>{if(r.length<=1)return;let a=lt(o,r),h=Math.max(o.length,r.length);(h-a)/h>s&&(a<n?(n=a,i=[r]):a===n&&i.push(r))}),i.sort((r,a)=>r.localeCompare(a)),e&&(i=i.map(r=>`--${r}`)),i.length>1?`
13
13
  (Did you mean one of ${i.join(", ")}?)`:i.length===1?`
14
- (Did you mean ${i[0]}?)`:""}var H=class o extends ut{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>m.stdout.write(e),writeErr:e=>m.stderr.write(e),outputError:(e,i)=>i(e),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>J()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>J()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:e=>ht(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let n=e,s=i;typeof n=="object"&&n!==null&&(s=n,n=null),s=s||{};let[,r,a]=t.match(/([^ ]+) *(.*)/),h=this.createCommand(r);return n&&(h.description(n),h._executableHandler=!0),s.isDefault&&(this._defaultCommandName=h._name),h._hidden=!!(s.noHelp||s.hidden),h._executableFile=s.executableFile||null,a&&h.arguments(a),this._registerCommand(h),h.parent=this,h.copyInheritedSettings(this),n?this:h}createCommand(t){return new o(t)}createHelp(){return Object.assign(new y,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
15
- - specify the name in Command constructor or using .name()`);return e=e||{},e.isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new A(t,e)}argument(t,e,i,n){let s=this.createArgument(t,e);return typeof i=="function"?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=t??"help [command]",[,n,s]=i.match(/([^ ]+) *(.*)/),r=e??"display help for command",a=this.createCommand(n);return a.helpOption(!1),s&&a.arguments(s),r&&a.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||e)&&this._initCommandGroup(a),this}addHelpCommand(t,e){return typeof t!="object"?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
16
- Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync")throw e},this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new _(t,e,i)),m.exit(t)}action(t){let e=i=>{let n=this.registeredArguments.length,s=i.slice(0,n);return this._storeOptionsAsProperties?s[n]=this:s[n]=this.opts(),s.push(this),t.apply(this,s)};return this._actionHandler=e,this}createOption(t,e){return new x(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(s){if(s.code==="commander.invalidArgument"){let r=`${n} ${s.message}`;this.error(r,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
14
+ (Did you mean ${i[0]}?)`:""}var k=class o extends ut{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:e=>m.stdout.write(e),writeErr:e=>m.stderr.write(e),outputError:(e,i)=>i(e),getOutHelpWidth:()=>m.stdout.isTTY?m.stdout.columns:void 0,getErrHelpWidth:()=>m.stderr.isTTY?m.stderr.columns:void 0,getOutHasColors:()=>J()??(m.stdout.isTTY&&m.stdout.hasColors?.()),getErrHasColors:()=>J()??(m.stderr.isTTY&&m.stderr.hasColors?.()),stripColor:e=>ht(e)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let n=e,s=i;typeof n=="object"&&n!==null&&(s=n,n=null),s=s||{};let[,r,a]=t.match(/([^ ]+) *(.*)/),h=this.createCommand(r);return n&&(h.description(n),h._executableHandler=!0),s.isDefault&&(this._defaultCommandName=h._name),h._hidden=!!(s.noHelp||s.hidden),h._executableFile=s.executableFile||null,a&&h.arguments(a),this._registerCommand(h),h.parent=this,h.copyInheritedSettings(this),n?this:h}createCommand(t){return new o(t)}createHelp(){return Object.assign(new A,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
15
+ - specify the name in Command constructor or using .name()`);return e=e||{},e.isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new y(t,e)}argument(t,e,i,n){let s=this.createArgument(t,e);return typeof i=="function"?s.default(n).argParser(i):s.default(i),this.addArgument(s),this}arguments(t){return t.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw new Error(`only the last argument can be variadic '${e.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,e){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let i=t??"help [command]",[,n,s]=i.match(/([^ ]+) *(.*)/),r=e??"display help for command",a=this.createCommand(n);return a.helpOption(!1),s&&a.arguments(s),r&&a.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||e)&&this._initCommandGroup(a),this}addHelpCommand(t,e){return typeof t!="object"?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,e){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
16
+ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync")throw e},this}_exit(t,e,i){this._exitCallback&&this._exitCallback(new b(t,e,i)),m.exit(t)}action(t){let e=i=>{let n=this.registeredArguments.length,s=i.slice(0,n);return this._storeOptionsAsProperties?s[n]=this:s[n]=this.opts(),s.push(this),t.apply(this,s)};return this._actionHandler=e,this}createOption(t,e){return new x(t,e)}_callParseArg(t,e,i,n){try{return t.parseArg(e,i)}catch(s){if(s.code==="commander.invalidArgument"){let r=`${n} ${s.message}`;this.error(r,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let i=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}'
17
17
  - already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let e=n=>[n.name()].concat(n.aliases()),i=e(t).find(n=>this._findCommand(n));if(i){let n=e(this._findCommand(i)).join("|"),s=e(t).join("|");throw new Error(`cannot add command '${s}' as already have command '${n}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let e=t.name(),i=t.attributeName();t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let n=(s,r,a)=>{s==null&&t.presetArg!==void 0&&(s=t.presetArg);let h=this.getOptionValue(i);s!==null&&t.parseArg?s=this._callParseArg(t,s,h,r):s!==null&&t.variadic&&(s=t._collectValue(s,h)),s==null&&(t.negate?s=!1:t.isBoolean()||t.optional?s=!0:s=""),this.setOptionValueWithSource(i,s,a)};return this.on("option:"+e,s=>{let r=`error: option '${t.flags}' argument '${s}' is invalid.`;n(s,r,"cli")}),t.envVar&&this.on("optionEnv:"+e,s=>{let r=`error: option '${t.flags}' value '${s}' from env '${t.envVar}' is invalid.`;n(s,r,"env")}),this}_optionEx(t,e,i,n,s){if(typeof e=="object"&&e instanceof x)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let r=this.createOption(e,i);if(r.makeOptionMandatory(!!t.mandatory),typeof n=="function")r.default(s).argParser(n);else if(n instanceof RegExp){let a=n;n=(h,p)=>{let l=a.exec(h);return l?l[0]:p},r.default(s).argParser(n)}else r.default(n);return this.addOption(r)}option(t,e,i,n){return this._optionEx({},t,e,i,n)}requiredOption(t,e,i,n){return this._optionEx({mandatory:!0},t,e,i,n)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(e=i.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},t===void 0&&e.from===void 0){m.versions?.electron&&(e.from="electron");let n=m.execArgv??[];(n.includes("-e")||n.includes("--eval")||n.includes("-p")||n.includes("--print"))&&(e.from="eval")}t===void 0&&(t=m.argv),this.rawArgs=t.slice();let i;switch(e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":m.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),this}_prepareForParse(){this._savedState===null?(this.options.filter(t=>t.negate&&t.defaultValue===void 0&&this.getOptionValue(t.attributeName())===void 0).forEach(t=>{let e=t.long.replace(/^--no-/,"--");this._findOption(e)||this.setOptionValueWithSource(t.attributeName(),!0,"default")}),this.saveStateBeforeParse()):this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
18
18
  - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,e,i){if(S.existsSync(t))return;let n=e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${t}' does not exist
19
19
  - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
20
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
- - ${n}`;throw new Error(s)}_executeSubCommand(t,e){e=e.slice();let i=[".js",".ts",".tsx",".mjs",".cjs"];function n(l,u){let c=g.resolve(l,u);if(S.existsSync(c))return c;if(i.includes(g.extname(u)))return;let w=i.find(b=>S.existsSync(`${c}${b}`));if(w)return`${c}${w}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=t._executableFile||`${this._name}-${t._name}`,r=this._executableDir||"";if(this._scriptPath){let l;try{l=S.realpathSync(this._scriptPath)}catch{l=this._scriptPath}r=g.resolve(g.dirname(l),r)}if(r){let l=n(r,s);if(!l&&!t._executableFile&&this._scriptPath){let u=g.basename(this._scriptPath,g.extname(this._scriptPath));u!==this._name&&(l=n(r,`${u}-${t._name}`))}s=l||s}let a=i.includes(g.extname(s)),h;m.platform!=="win32"?a?(e.unshift(s),e=U(m.execArgv).concat(e),h=I.spawn(m.argv[0],e,{stdio:"inherit"})):h=I.spawn(s,e,{stdio:"inherit"}):(this._checkForMissingExecutable(s,r,t._name),e.unshift(s),e=U(m.execArgv).concat(e),h=I.spawn(m.execPath,e,{stdio:"inherit"})),h.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{m.on(u,()=>{h.killed===!1&&h.exitCode===null&&h.kill(u)})});let p=this._exitCallback;h.on("close",l=>{l=l??1,p?p(new _(l,"commander.executeSubCommandAsync","(close)")):m.exit(l)}),h.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(s,r,t._name);else if(l.code==="EACCES")throw new Error(`'${s}' not executable`);if(!p)m.exit(1);else{let u=new _(1,"commander.executeSubCommandAsync","(error)");u.nestedError=l,p(u)}}),this.runningCommand=h}_dispatchSubcommand(t,e,i){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,e.concat(i));else return n._parseCommand(e,i)}),s}_dispatchHelpCommand(t){t||this.help();let e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&this.args[e]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(i,n,s)=>{let r=n;if(n!==null&&i.parseArg){let a=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;r=this._callParseArg(i,n,s,a)}return r};this._checkNumberOfArguments();let e=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((r,a)=>t(i,a,r),i.defaultValue))):s===void 0&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),e[n]=s}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&typeof t.then=="function"?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t,n=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[e]!==void 0).forEach(s=>{s._lifeCycleHooks[e].forEach(r=>{n.push({hookedCommand:s,callback:r})})}),e==="postAction"&&n.reverse(),n.forEach(s=>{i=this._chainOrCall(i,()=>s.callback(s.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let n=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(s=>{n=this._chainOrCall(n,()=>s(this,e))}),n}_parseCommand(t,e){let i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(s,t,e)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&t.getOptionValue(e.attributeName())===void 0&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=t.find(s=>i.conflictsWith.includes(s.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let e=[],i=[],n=e;function s(l){return l.length>1&&l[0]==="-"}let r=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(u=>u.options.map(c=>c.short).some(c=>/^-\d$/.test(c))):!1,a=null,h=null,p=0;for(;p<t.length||h;){let l=h??t[p++];if(h=null,l==="--"){n===i&&n.push(l),n.push(...t.slice(p));break}if(a&&(!s(l)||r(l))){this.emit(`option:${a.name()}`,l);continue}if(a=null,s(l)){let u=this._findOption(l);if(u){if(u.required){let c=t[p++];c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;p<t.length&&(!s(t[p])||r(t[p]))&&(c=t[p++]),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),h=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),c=this._findOption(l.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,l.slice(u+1));continue}}if(n===e&&s(l)&&!(this.commands.length===0&&r(l))&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&i.length===0){if(this._findCommand(l)){e.push(l),i.push(...t.slice(p));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){e.push(l,...t.slice(p));break}else if(this._defaultCommandName){i.push(l,...t.slice(p));break}}if(this._passThroughOptions){n.push(l,...t.slice(p));break}n.push(l)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},e=this.options.length;for(let i=0;i<e;i++){let n=this.options[i].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}
21
+ - ${n}`;throw new Error(s)}_executeSubCommand(t,e){e=e.slice();let i=[".js",".ts",".tsx",".mjs",".cjs"];function n(l,u){let c=_.resolve(l,u);if(S.existsSync(c))return c;if(i.includes(_.extname(u)))return;let w=i.find(O=>S.existsSync(`${c}${O}`));if(w)return`${c}${w}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=t._executableFile||`${this._name}-${t._name}`,r=this._executableDir||"";if(this._scriptPath){let l;try{l=S.realpathSync(this._scriptPath)}catch{l=this._scriptPath}r=_.resolve(_.dirname(l),r)}if(r){let l=n(r,s);if(!l&&!t._executableFile&&this._scriptPath){let u=_.basename(this._scriptPath,_.extname(this._scriptPath));u!==this._name&&(l=n(r,`${u}-${t._name}`))}s=l||s}let a=i.includes(_.extname(s)),h;m.platform!=="win32"?a?(e.unshift(s),e=U(m.execArgv).concat(e),h=I.spawn(m.argv[0],e,{stdio:"inherit"})):h=I.spawn(s,e,{stdio:"inherit"}):(this._checkForMissingExecutable(s,r,t._name),e.unshift(s),e=U(m.execArgv).concat(e),h=I.spawn(m.execPath,e,{stdio:"inherit"})),h.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{m.on(u,()=>{h.killed===!1&&h.exitCode===null&&h.kill(u)})});let p=this._exitCallback;h.on("close",l=>{l=l??1,p?p(new b(l,"commander.executeSubCommandAsync","(close)")):m.exit(l)}),h.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(s,r,t._name);else if(l.code==="EACCES")throw new Error(`'${s}' not executable`);if(!p)m.exit(1);else{let u=new b(1,"commander.executeSubCommandAsync","(error)");u.nestedError=l,p(u)}}),this.runningCommand=h}_dispatchSubcommand(t,e,i){let n=this._findCommand(t);n||this.help({error:!0}),n._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(n._executableHandler)this._executeSubCommand(n,e.concat(i));else return n._parseCommand(e,i)}),s}_dispatchHelpCommand(t){t||this.help();let e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&this.args[e]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=(i,n,s)=>{let r=n;if(n!==null&&i.parseArg){let a=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;r=this._callParseArg(i,n,s,a)}return r};this._checkNumberOfArguments();let e=[];this.registeredArguments.forEach((i,n)=>{let s=i.defaultValue;i.variadic?n<this.args.length?(s=this.args.slice(n),i.parseArg&&(s=s.reduce((r,a)=>t(i,a,r),i.defaultValue))):s===void 0&&(s=[]):n<this.args.length&&(s=this.args[n],i.parseArg&&(s=t(i,s,i.defaultValue))),e[n]=s}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&typeof t.then=="function"?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t,n=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[e]!==void 0).forEach(s=>{s._lifeCycleHooks[e].forEach(r=>{n.push({hookedCommand:s,callback:r})})}),e==="postAction"&&n.reverse(),n.forEach(s=>{i=this._chainOrCall(i,()=>s.callback(s.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let n=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(s=>{n=this._chainOrCall(n,()=>s(this,e))}),n}_parseCommand(t,e){let i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let r;return r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(s,t,e)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent?.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&t.getOptionValue(e.attributeName())===void 0&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=t.find(s=>i.conflictsWith.includes(s.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let e=[],i=[],n=e;function s(l){return l.length>1&&l[0]==="-"}let r=l=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(l)?!this._getCommandAndAncestors().some(u=>u.options.map(c=>c.short).some(c=>/^-\d$/.test(c))):!1,a=null,h=null,p=0;for(;p<t.length||h;){let l=h??t[p++];if(h=null,l==="--"){n===i&&n.push(l),n.push(...t.slice(p));break}if(a&&(!s(l)||r(l))){this.emit(`option:${a.name()}`,l);continue}if(a=null,s(l)){let u=this._findOption(l);if(u){if(u.required){let c=t[p++];c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;p<t.length&&(!s(t[p])||r(t[p]))&&(c=t[p++]),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);a=u.variadic?u:null;continue}}if(l.length>2&&l[0]==="-"&&l[1]!=="-"){let u=this._findOption(`-${l[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,l.slice(2)):(this.emit(`option:${u.name()}`),h=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let u=l.indexOf("="),c=this._findOption(l.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,l.slice(u+1));continue}}if(n===e&&s(l)&&!(this.commands.length===0&&r(l))&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&i.length===0){if(this._findCommand(l)){e.push(l),i.push(...t.slice(p));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){e.push(l,...t.slice(p));break}else if(this._defaultCommandName){i.push(l,...t.slice(p));break}}if(this._passThroughOptions){n.push(l,...t.slice(p));break}n.push(l)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},e=this.options.length;for(let i=0;i<e;i++){let n=this.options[i].attributeName();t[n]=n===this._versionOptionName?this._version:this[n]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){this._outputConfiguration.outputError(`${t}
22
22
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
23
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
24
- `),this.outputHelp({error:!0}));let i=e||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in m.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,m.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new v(this.options),e=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!e(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let i=r=>{let a=r.attributeName(),h=this.getOptionValue(a),p=this.options.find(u=>u.negate&&a===u.attributeName()),l=this.options.find(u=>!u.negate&&a===u.attributeName());return p&&(p.presetArg===void 0&&h===!1||p.presetArg!==void 0&&h===p.presetArg)?p:l||r},n=r=>{let a=i(r),h=a.attributeName();return this.getOptionValueSource(h)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let r=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);n=n.concat(r),s=s.parent}while(s&&!s._enablePositionalOptions);e=F(t,n)}let i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,i=e===1?"":"s",n=t.length,s=this.parent?` for '${this.name()}'`:"",r=t.join(", "),a=`error: too many arguments${s}. Expected ${e} argument${i} but got ${n}: ${r}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),e=F(t,n)}let i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";let n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
- `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(i=>$(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=g.basename(t,g.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=e.formatHelp(this,e);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let e=!!t.error,i,n,s;return e?(i=a=>this._outputConfiguration.writeErr(a),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(n||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:n,helpWidth:s}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:i.error});if(e&&(s=e(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",n))}helpOption(t,e){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",e??"display help for command"),(t||e)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let e=Number(m.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
24
+ `),this.outputHelp({error:!0}));let i=e||{},n=i.exitCode||1,s=i.code||"commander.error";this._exit(n,s,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in m.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,m.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new v(this.options),e=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!e(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let i=r=>{let a=r.attributeName(),h=this.getOptionValue(a),p=this.options.find(u=>u.negate&&a===u.attributeName()),l=this.options.find(u=>!u.negate&&a===u.attributeName());return p&&(p.presetArg===void 0&&h===!1||p.presetArg!==void 0&&h===p.presetArg)?p:l||r},n=r=>{let a=i(r),h=a.attributeName();return this.getOptionValueSource(h)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${n(t)} cannot be used with ${n(e)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let n=[],s=this;do{let r=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);n=n.concat(r),s=s.parent}while(s&&!s._enablePositionalOptions);e=D(t,n)}let i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,i=e===1?"":"s",n=t.length,s=this.parent?` for '${this.name()}'`:"",r=t.join(", "),a=`error: too many arguments${s}. Expected ${e} argument${i} but got ${n}: ${r}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(s=>{n.push(s.name()),s.alias()&&n.push(s.alias())}),e=D(t,n)}let i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";let n=this.createOption(e,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${t}
25
+ `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${n}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(i=>$(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=_.basename(t,_.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let n=e.formatHelp(this,e);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(t){t=t||{};let e=!!t.error,i,n,s;return e?(i=a=>this._outputConfiguration.writeErr(a),n=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),n=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(n||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:n,helpWidth:s}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let i=this._getOutputContext(t),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",n)),this.emit("beforeHelp",n);let s=this.helpInformation({error:i.error});if(e&&(s=e(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",n))}helpOption(t,e){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",e??"display help for command"),(t||e)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let e=Number(m.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
26
26
  Expecting one of '${i.join("', '")}'`);let n=`${t}Help`;return this.on(n,s=>{let r;typeof e=="function"?r=e({error:s.error,command:s.command}):r=e,r&&s.write(`${r}
27
- `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(n=>e.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function U(o){return o.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",n="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?e=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=s[1],i=s[3],n=s[4]),e&&n!=="0"?`${e}=${i}:${parseInt(n)+1}`:t})}function J(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var T=new H;import{mkdir as X,copyFile as P,cp as Q,writeFile as Ft,chmod as W}from"node:fs/promises";import{join as f}from"node:path";import{exec as pt}from"child_process";import{promisify as ct}from"util";var mt=ct(pt),O=mt;import{rm as dt}from"node:fs/promises";import{join as z}from"node:path";import{cwd as ft}from"node:process";var gt=z(ft(),"dist");async function G(){await dt(z(gt,"tmp"),{recursive:!0})}import _t from"node:path";import{fileURLToPath as Ot}from"node:url";var bt=_t.dirname(Ot(import.meta.url)),V=bt;import{chmod as Ct,mkdir as wt}from"node:fs/promises";import{existsSync as xt}from"node:fs";import{dirname as At}from"node:path";async function K(o){xt(o)||(console.log("Downloading appimagetool..."),await wt(At(o),{recursive:!0}),await O(`wget -O ${o} https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage`),await Ct(o,493))}import{join as yt}from"node:path";import{homedir as Et}from"node:os";var N=yt(Et(),".webnative");import{readFile as $t}from"node:fs/promises";import{join as vt}from"node:path";var k;async function Y(){return k||(k=await St(),k)}async function St(){let o=await $t(vt(process.cwd(),"webnative.json"),"utf-8");return JSON.parse(o)}import{existsSync as kt}from"node:fs";import{createWriteStream as Ht}from"node:fs";import{Readable as Tt}from"node:stream";import{pipeline as Vt}from"node:stream/promises";async function j(o,t){let e=await fetch(o);if(!e.body)throw new Error(`Failed to download ${o}`);await Vt(Tt.fromWeb(e.body),Ht(t))}import{dirname as Pt}from"node:path";import{chmod as Wt,rm as Dt}from"node:fs/promises";async function M(o){if(kt(o))return;console.log("Downloading Node.js...");let t="v22.0.0",e=`https://nodejs.org/dist/${t}/node-${t}-linux-x64.tar.gz`,i=o+".tar.gz";await j(e,i),await O(`tar -xz -f ${i} -C ${Pt(o)} --strip-components=2 node-${t}-linux-x64/bin/node`),await Dt(i),await Wt(o,493)}var E=process.cwd(),d={prebuilds:f(V,"prebuilds/dist"),appImageTool:f(N,"appimagetool"),node:f(N,"node"),bin:f(E,"dist/tmp/bin"),public:f(E,"app/public"),backend:f(E,"app/backend/dist"),dist:f(E,"dist")};async function L(){await K(d.appImageTool),await M(d.node),await It(),await X(d.dist,{recursive:!0}),await O(`${d.appImageTool} ${d.bin} -n ${d.dist}/linux-appimage`),await W(f(d.dist,"linux-appimage"),493),await G()}async function It(){let o=await Y();await X(f(d.bin,"usr/bin"),{recursive:!0}),await P(f(d.prebuilds,"AppRun"),f(d.bin,"AppRun")),await W(f(d.bin,"AppRun"),493),await Ft(f(d.bin,"app.desktop"),`[Desktop Entry]
27
+ `)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(n=>e.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function U(o){return o.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",n="9229",s;return(s=t.match(/^(--inspect(-brk)?)$/))!==null?e=s[1]:(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=s[1],/^\d+$/.test(s[3])?n=s[3]:i=s[3]):(s=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=s[1],i=s[3],n=s[4]),e&&n!=="0"?`${e}=${i}:${parseInt(n)+1}`:t})}function J(){if(m.env.NO_COLOR||m.env.FORCE_COLOR==="0"||m.env.FORCE_COLOR==="false")return!1;if(m.env.FORCE_COLOR||m.env.CLICOLOR_FORCE!==void 0)return!0}var T=new k;import{readFile as jt}from"node:fs/promises";import{mkdir as X,copyFile as P,cp as Q,writeFile as Dt,chmod as W}from"node:fs/promises";import{join as f}from"node:path";import{exec as pt}from"child_process";import{promisify as ct}from"util";var mt=ct(pt),g=mt;import{rm as dt}from"node:fs/promises";import{join as z}from"node:path";import{cwd as ft}from"node:process";var gt=z(ft(),"dist");async function j(){await dt(z(gt,"tmp"),{recursive:!0})}import _t from"node:path";import{fileURLToPath as bt}from"node:url";var Ot=_t.dirname(bt(import.meta.url)),H=Ot;import{chmod as Ct,mkdir as wt}from"node:fs/promises";import{existsSync as xt}from"node:fs";import{dirname as yt}from"node:path";async function K(o){xt(o)||(console.log("Downloading appimagetool..."),await wt(yt(o),{recursive:!0}),await g(`wget -O ${o} https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage`),await Ct(o,493))}import{join as At}from"node:path";import{homedir as Et}from"node:os";var G=At(Et(),".webnative");import{readFile as $t}from"node:fs/promises";import{join as vt}from"node:path";var V;async function Y(){return V||(V=await St(),V)}async function St(){let o=await $t(vt(process.cwd(),"webnative.json"),"utf-8");return JSON.parse(o)}import{existsSync as Vt}from"node:fs";import{createWriteStream as kt}from"node:fs";import{Readable as Tt}from"node:stream";import{pipeline as Ht}from"node:stream/promises";async function N(o,t){let e=await fetch(o);if(!e.body)throw new Error(`Failed to download ${o}`);await Ht(Tt.fromWeb(e.body),kt(t))}import{dirname as Pt}from"node:path";import{chmod as Wt,rm as Ft}from"node:fs/promises";async function M(o){if(Vt(o))return;console.log("Downloading Node.js...");let t="v22.0.0",e=`https://nodejs.org/dist/${t}/node-${t}-linux-x64.tar.gz`,i=o+".tar.gz";await N(e,i),await g(`tar -xz -f ${i} -C ${Pt(o)} --strip-components=2 node-${t}-linux-x64/bin/node`),await Ft(i),await Wt(o,493)}var E=process.cwd(),d={prebuilds:f(H,"prebuilds/dist"),appImageTool:f(G,"appimagetool"),node:f(G,"node"),bin:f(E,"dist/tmp/bin"),public:f(E,"app/public"),backend:f(E,"app/backend/dist"),dist:f(E,"dist")};async function L(){await K(d.appImageTool),await M(d.node),await It(),await X(d.dist,{recursive:!0}),await g(`${d.appImageTool} ${d.bin} -n ${d.dist}/linux-appimage`),await W(f(d.dist,"linux-appimage"),493),await j()}async function It(){let o=await Y();await X(f(d.bin,"usr/bin"),{recursive:!0}),await P(f(d.prebuilds,"AppRun"),f(d.bin,"AppRun")),await W(f(d.bin,"AppRun"),493),await Dt(f(d.bin,"app.desktop"),`[Desktop Entry]
28
28
  Name=${o.name}
29
29
  Exec=app
30
30
  Icon=app
31
31
  Type=Application
32
- Categories=${(o.categories??["Utility"]).join(";")};`),o.icon&&await P(f(E,o.icon),f(d.bin,"app.png")),await P(f(d.prebuilds,"linux_self_contained"),f(d.bin,"usr/bin/linux")),await W(f(d.bin,"usr/bin/linux"),493),await Q(d.public,f(d.bin,"usr/bin/public"),{recursive:!0}),await Q(d.backend,f(d.bin,"usr/bin/backend"),{recursive:!0}),await P(d.node,f(d.bin,"usr/bin/node")),await W(f(d.bin,"usr/bin/node"),493)}var Z={appimage:L},D={linux:["appimage"]};function R(){return`Available platforms:
33
- `+Object.entries(D).map(([o,t])=>` ${o}, targets: ${t.join(", ")}`).join(`
34
- `)}function tt(o){o.command("build <platform>").usage("<platform> [options]").description(`Build the application
32
+ Categories=${(o.categories??["Utility"]).join(";")};`),o.icon&&await P(f(E,o.icon),f(d.bin,"app.png")),await P(f(d.prebuilds,"linux_self_contained"),f(d.bin,"usr/bin/linux")),await W(f(d.bin,"usr/bin/linux"),493),await Q(d.public,f(d.bin,"usr/bin/public"),{recursive:!0}),await Q(d.backend,f(d.bin,"usr/bin/backend"),{recursive:!0}),await P(d.node,f(d.bin,"usr/bin/node")),await W(f(d.bin,"usr/bin/node"),493)}var Z={appimage:L},F={linux:["appimage"]};function R(){return`Available platforms:
33
+ `+Object.entries(F).map(([o,t])=>` ${o}, targets: ${t.join(", ")}`).join(`
34
+ `)}import{join as Gt}from"node:path";function tt(o){o.command("build <platform>").usage("<platform> [options]").description(`Build the application
35
35
 
36
36
  ${R()}`).option("-t, --target <target>","build specific target","all").addHelpText("after",`
37
37
  Examples:
38
38
  $ webnative build linux
39
39
  $ webnative build linux --target appimage
40
- $ webnative build linux -t appimage`).action(async(t,e)=>et(t,e.target))}async function et(o,t){if(o=="all"){if(t)throw new Error("Can't use target option with platform set to 'all'");return Nt()}return it(o,t)}async function it(o,t){return t=="all"?Gt(o):nt(o,t)}async function Gt(o){for(let t of D[o])await nt(o,t)}async function nt(o,t){let e=Z[t];if(!e)throw new Error(`Unknown target ${t}
40
+ $ webnative build linux -t appimage`).action(async(t,e)=>et(t,e.target))}async function et(o,t){if(o=="all"){if(t!="all")throw new Error("Can't use target option with platform set to 'all'");return Lt()}return it(o,t)}async function it(o,t){return t=="all"?Nt(o):nt(o,t)}async function Nt(o){for(let t of F[o])await nt(o,t)}async function nt(o,t){let e=Z[t];if(!e)throw new Error(`Unknown target ${t}
41
41
 
42
- ${R()}`);console.log(`Building ${o} ${t}...`),await e(),console.log(`${t} is built`)}async function Nt(){for(let o of Object.keys(D))await it(o,"all")}import{join as q}from"path";import{cp as jt}from"fs/promises";function st(o){o.command("init [project-name]").description("Initialize a new webnative project").addHelpText("after",`
42
+ ${R()}`);await Mt(o),console.log(`Building ${o} ${t}...`),await e(),console.log(`${t} is built`)}async function Mt(o){console.log("Building fullstack first..."),JSON.parse(await jt(Gt(process.cwd(),"package.json"),"utf-8")).scripts?.build&&await g("npm run build",{env:{...process.env,PLATFORM:o}})}async function Lt(){for(let o of Object.keys(F))await it(o,"all")}import{join as q}from"path";import{cp as Rt,readFile as qt,writeFile as Bt}from"fs/promises";import{createInterface as Ut}from"node:readline/promises";function st(o){o.command("init [project-name]").description("Initialize a new webnative project").addHelpText("after",`
43
43
  Examples:
44
44
  $ webnative init
45
- $ webnative init my-app`).action(rt)}async function rt(o){await Mt(o),await Lt(o),console.log(`Project initialized${o?` in ${o}`:""}`)}async function Mt(o){let t=o?q(process.cwd(),o):process.cwd();await jt(q(V,"template"),t,{recursive:!0})}async function Lt(o){let t=o?q(process.cwd(),o):process.cwd();await O("npm init -y",{cwd:t})}st(T);tt(T);T.parse();
45
+ $ webnative init my-app`).action(rt)}async function rt(o){let t=o?q(process.cwd(),o):process.cwd(),e=await Jt();await zt(e,t),await Kt(e,t),console.log(`Project initialized${o?` in ${o}`:""}`)}async function Jt(){let o=Ut({input:process.stdin,output:process.stdout}),t=await o.question("Would you like to use TypeScript? (y/n): ");return o.close(),t.toLowerCase()==="y"}async function zt(o,t){await Rt(q(H,"template",o?"ts":"js"),t,{recursive:!0})}async function Kt(o,t){await g("npm init -y",{cwd:t});let e=q(t,"package.json");await Yt(o,e),await Qt(o,t)}async function Yt(o,t){let e=JSON.parse(await qt(t,"utf-8"));e.scripts={...e.scripts,"build:frontend":"webpack","build:backend":`esbuild app/backend/index.${o?"ts":"js"} --bundle --platform=node --format=esm --outfile=app/backend/dist/index.js`,build:"npm run build:frontend && npm run build:backend"},e.type="module",await Bt(t,JSON.stringify(e,null,2),"utf-8")}async function Qt(o,t){await g(`npm install ${`webpack webpack-cli esbuild${o?" ts-loader typescript":""}`} --save-dev`,{cwd:t})}st(T);tt(T);T.parse();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mindw1n/webnative",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "scripts": {
6
6
  "build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=es2020 --outfile=index.js --banner:js=\"#!/usr/bin/env node\" --minify"
7
7
  },
@@ -12,7 +12,7 @@
12
12
  "index.js",
13
13
  "prebuilds/dist",
14
14
  "template",
15
- "readme.md"
15
+ "readme.md"
16
16
  ],
17
17
  "keywords": [],
18
18
  "author": "",
@@ -22,6 +22,7 @@
22
22
  "@eslint/js": "^9.39.2",
23
23
  "@types/getos": "^3.0.4",
24
24
  "@types/node": "^25.9.1",
25
+ "@types/package-json": "^5.0.0",
25
26
  "@typescript-eslint/eslint-plugin": "^8.54.0",
26
27
  "@typescript-eslint/parser": "^8.54.0",
27
28
  "esbuild": "^0.27.2",
@@ -31,7 +32,6 @@
31
32
  "typescript-eslint": "^8.54.0"
32
33
  },
33
34
  "dependencies": {
34
- "commander": "^15.0.0",
35
- "getos": "^3.2.1"
35
+ "commander": "^15.0.0"
36
36
  }
37
37
  }
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Android";
3
+ }
@@ -0,0 +1 @@
1
+ export declare function getPlatform(): string;
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "iPhone";
3
+ }
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Linux";
3
+ }
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Mac";
3
+ }
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Windows";
3
+ }
@@ -0,0 +1 @@
1
+ console.log("hello from backend");
@@ -0,0 +1,4 @@
1
+ import { getPlatform } from "./api";
2
+
3
+ const platform = document.getElementById("platform");
4
+ if (platform) platform.textContent = getPlatform();
@@ -0,0 +1,63 @@
1
+ * { margin: 0; padding: 0; box-sizing: border-box; }
2
+
3
+ body {
4
+ min-height: 100vh;
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ background: #0f0f13;
9
+ font-family: system-ui, -apple-system, sans-serif;
10
+ }
11
+
12
+ .center {
13
+ display: flex;
14
+ flex-direction: column;
15
+ align-items: center;
16
+ text-align: center;
17
+ }
18
+
19
+ .badge {
20
+ display: inline-block;
21
+ font-size: 11px;
22
+ font-weight: 500;
23
+ letter-spacing: 0.12em;
24
+ text-transform: uppercase;
25
+ color: #a78bfa;
26
+ border: 1px solid #3d2f6e;
27
+ border-radius: 99px;
28
+ padding: 4px 14px;
29
+ margin-bottom: 24px;
30
+ }
31
+
32
+ h1 {
33
+ font-size: clamp(2rem, 5vw, 3.5rem);
34
+ font-weight: 600;
35
+ color: #ffffff;
36
+ letter-spacing: -0.02em;
37
+ line-height: 1.1;
38
+ margin-bottom: 16px;
39
+ }
40
+
41
+ h1 span {
42
+ color: #7c6fff;
43
+ }
44
+
45
+ p {
46
+ font-size: clamp(0.95rem, 2vw, 1.1rem);
47
+ color: #8b8b9e;
48
+ max-width: 400px;
49
+ line-height: 1.6;
50
+ }
51
+
52
+ h2 {
53
+ position: fixed;
54
+ bottom: 20px;
55
+ right: 24px;
56
+ font-size: 20px;
57
+ font-weight: 400;
58
+ color: #3d3d52;
59
+ }
60
+
61
+ h2 span {
62
+ color: #7c6fff;
63
+ }
@@ -11,6 +11,8 @@
11
11
  <div class="badge">v1.0.0</div>
12
12
  <h1>Your webnative app,<br><span>Build web. Ship anywhere.</span></h1>
13
13
  <p>Deliver your application fast with just one codebase for every platform</p>
14
+ <h2>Currently runs on <span id="platform"></span></h2>
14
15
  </div>
16
+ <script src="./index.js"></script>
15
17
  </body>
16
18
  </html>
@@ -0,0 +1,25 @@
1
+ import { fileURLToPath } from "url";
2
+ import { dirname, join } from "path";
3
+ import { exit } from "process";
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ const platform = process.env.PLATFORM;
7
+
8
+ if (!platform) {
9
+ console.error("No platform specified. Aborting...")
10
+ exit(1);
11
+ }
12
+
13
+ export default {
14
+ entry: "./app/index.js",
15
+ output: {
16
+ path: join(__dirname, "app/public"),
17
+ filename: "index.js",
18
+ },
19
+ resolve: {
20
+ extensions: [".js"],
21
+ alias: {
22
+ "./api": join(__dirname, `app/api/${platform}.js`),
23
+ },
24
+ },
25
+ };
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Android";
3
+ }
@@ -0,0 +1 @@
1
+ export declare function getPlatform(): string;
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "iPhone";
3
+ }
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Linux";
3
+ }
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Mac";
3
+ }
@@ -0,0 +1,3 @@
1
+ export function getPlatform() {
2
+ return "Windows";
3
+ }
@@ -0,0 +1 @@
1
+ console.log("hello from backend");
Binary file
@@ -0,0 +1,4 @@
1
+ import { getPlatform } from "./api";
2
+
3
+ const platform = document.getElementById("platform");
4
+ if (platform) platform.textContent = getPlatform();
@@ -0,0 +1,63 @@
1
+ * { margin: 0; padding: 0; box-sizing: border-box; }
2
+
3
+ body {
4
+ min-height: 100vh;
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ background: #0f0f13;
9
+ font-family: system-ui, -apple-system, sans-serif;
10
+ }
11
+
12
+ .center {
13
+ display: flex;
14
+ flex-direction: column;
15
+ align-items: center;
16
+ text-align: center;
17
+ }
18
+
19
+ .badge {
20
+ display: inline-block;
21
+ font-size: 11px;
22
+ font-weight: 500;
23
+ letter-spacing: 0.12em;
24
+ text-transform: uppercase;
25
+ color: #a78bfa;
26
+ border: 1px solid #3d2f6e;
27
+ border-radius: 99px;
28
+ padding: 4px 14px;
29
+ margin-bottom: 24px;
30
+ }
31
+
32
+ h1 {
33
+ font-size: clamp(2rem, 5vw, 3.5rem);
34
+ font-weight: 600;
35
+ color: #ffffff;
36
+ letter-spacing: -0.02em;
37
+ line-height: 1.1;
38
+ margin-bottom: 16px;
39
+ }
40
+
41
+ h1 span {
42
+ color: #7c6fff;
43
+ }
44
+
45
+ p {
46
+ font-size: clamp(0.95rem, 2vw, 1.1rem);
47
+ color: #8b8b9e;
48
+ max-width: 400px;
49
+ line-height: 1.6;
50
+ }
51
+
52
+ h2 {
53
+ position: fixed;
54
+ bottom: 20px;
55
+ right: 24px;
56
+ font-size: 20px;
57
+ font-weight: 400;
58
+ color: #3d3d52;
59
+ }
60
+
61
+ h2 span {
62
+ color: #7c6fff;
63
+ }
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Webnative</title>
7
+ <link rel="stylesheet" href="./index.css">
8
+ </head>
9
+ <body>
10
+ <div class="center">
11
+ <div class="badge">v1.0.0</div>
12
+ <h1>Your webnative app,<br><span>Build web. Ship anywhere.</span></h1>
13
+ <p>Deliver your application fast with just one codebase for every platform</p>
14
+ <h2>Currently runs on <span id="platform"></span></h2>
15
+ </div>
16
+ <script src="./index.js"></script>
17
+ </body>
18
+ </html>
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "lib": ["ES2020", "DOM"],
8
+ "types": ["node"],
9
+ },
10
+ "include": ["app/**/*"],
11
+ "exclude": ["app/public", "node_modules"],
12
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "My App",
3
+ "icon": "app/icon.png",
4
+ "categories": ["Utility"]
5
+ }
@@ -0,0 +1,32 @@
1
+ import { fileURLToPath } from "url";
2
+ import { dirname, join } from "path";
3
+ import { exit } from "process";
4
+
5
+ const __dirname = dirname(fileURLToPath(import.meta.url));
6
+ const platform = process.env.PLATFORM;
7
+
8
+ if (!platform) {
9
+ console.error("No platform specified. Aborting...");
10
+ exit(1);
11
+ }
12
+
13
+ export default {
14
+ entry: "./app/index.ts",
15
+ output: {
16
+ path: join(__dirname, "app/public"),
17
+ filename: "index.js",
18
+ },
19
+ resolve: {
20
+ extensions: [".ts", ".js"],
21
+ alias: {
22
+ "./api": join(__dirname, `app/api/${platform}.ts`),
23
+ },
24
+ },
25
+ module: {
26
+ rules: [{
27
+ test: /\.ts$/,
28
+ use: "ts-loader",
29
+ exclude: /node_modules/,
30
+ }],
31
+ },
32
+ };
@@ -1 +0,0 @@
1
- console.log("hello from backend");
@@ -1,50 +0,0 @@
1
- * { margin: 0; padding: 0; box-sizing: border-box; }
2
-
3
- body {
4
- min-height: 100vh;
5
- display: flex;
6
- align-items: center;
7
- justify-content: center;
8
- background: #0f0f13;
9
- font-family: system-ui, -apple-system, sans-serif;
10
- }
11
-
12
- .center {
13
- display: flex;
14
- flex-direction: column;
15
- align-items: center;
16
- text-align: center;
17
- }
18
-
19
- .badge {
20
- display: inline-block;
21
- font-size: 11px;
22
- font-weight: 500;
23
- letter-spacing: 0.12em;
24
- text-transform: uppercase;
25
- color: #a78bfa;
26
- border: 1px solid #3d2f6e;
27
- border-radius: 99px;
28
- padding: 4px 14px;
29
- margin-bottom: 24px;
30
- }
31
-
32
- h1 {
33
- font-size: clamp(2rem, 5vw, 3.5rem);
34
- font-weight: 600;
35
- color: #ffffff;
36
- letter-spacing: -0.02em;
37
- line-height: 1.1;
38
- margin-bottom: 16px;
39
- }
40
-
41
- h1 span {
42
- color: #7c6fff;
43
- }
44
-
45
- p {
46
- font-size: clamp(0.95rem, 2vw, 1.1rem);
47
- color: #8b8b9e;
48
- max-width: 400px;
49
- line-height: 1.6;
50
- }
@@ -1 +0,0 @@
1
- console.log("Hello world");
File without changes
File without changes