@mindw1n/webnative 1.0.0 → 1.0.1
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 +4 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,7 +24,7 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
|
|
|
24
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=W(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=W(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
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.
|
|
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 q(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 R(){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 z,copyFile as I,cp as Y,writeFile as
|
|
27
|
+
`)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(n=>e.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function q(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 R(){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 z,copyFile as I,cp as Y,writeFile as vt,chmod as G}from"node:fs/promises";import{join as f}from"node:path";import{exec as ut}from"child_process";import{promisify as ht}from"util";var pt=ht(ut),x=pt;import{rm as ct}from"node:fs/promises";import{join as B}from"node:path";import{cwd as mt}from"node:process";var dt=B(mt(),"dist");async function F(){await ct(B(dt,"tmp"),{recursive:!0})}import ft from"node:path";import{fileURLToPath as gt}from"node:url";var _t=ft.dirname(gt(import.meta.url)),V=_t;import{chmod as Ot,mkdir as bt}from"node:fs/promises";import{existsSync as Ct}from"node:fs";import{dirname as wt}from"node:path";async function U(o){Ct(o)||(console.log("Downloading appimagetool..."),await bt(wt(o),{recursive:!0}),await x(`wget -O ${o} https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage`),await Ot(o,493))}import{join as xt}from"node:path";import{homedir as At}from"node:os";var J=xt(At(),".webnative");import{readFile as yt}from"node:fs/promises";import{join as Et}from"node:path";var k;async function K(){return k||(k=await $t(),k)}async function $t(){let o=await yt(Et(process.cwd(),"webnative.json"),"utf-8");return JSON.parse(o)}var E=process.cwd(),d={prebuilds:f(V,"prebuilds/dist"),appImageTool:f(J,"appimagetool"),bin:f(E,"dist/tmp/bin"),public:f(E,"app/public"),backend:f(E,"app/backend/dist"),dist:f(E,"dist")};async function j(){await U(d.appImageTool),await St(),await z(d.dist,{recursive:!0}),await x(`${d.appImageTool} ${d.bin} -n ${d.dist}/linux-appimage`),await G(f(d.dist,"linux-appimage"),493),await F()}async function St(){let o=await K();await z(f(d.bin,"usr/bin"),{recursive:!0}),await I(f(d.prebuilds,"AppRun"),f(d.bin,"AppRun")),await G(f(d.bin,"AppRun"),493),await vt(f(d.bin,"app.desktop"),`[Desktop Entry]
|
|
28
28
|
Name=${o.name}
|
|
29
29
|
Exec=app
|
|
30
30
|
Icon=app
|
|
@@ -37,9 +37,9 @@ ${N()}`).option("-t, --target <target>","build specific target","all").addHelpTe
|
|
|
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)=>Z(t,e.target))}async function Z(o,t){if(o=="all"){if(t)throw new Error("Can't use target option with platform set to 'all'");return
|
|
40
|
+
$ webnative build linux -t appimage`).action(async(t,e)=>Z(t,e.target))}async function Z(o,t){if(o=="all"){if(t)throw new Error("Can't use target option with platform set to 'all'");return Tt()}return tt(o,t)}async function tt(o,t){return t=="all"?Ht(o):et(o,t)}async function Ht(o){for(let t of P[o])await et(o,t)}async function et(o,t){let e=Q[t];if(!e)throw new Error(`Unknown target ${t}
|
|
41
41
|
|
|
42
|
-
${N()}`);console.log(`Building ${o} ${t}...`),await e(),console.log(`${t} is built`)}async function
|
|
42
|
+
${N()}`);console.log(`Building ${o} ${t}...`),await e(),console.log(`${t} is built`)}async function Tt(){for(let o of Object.keys(P))await tt(o,"all")}import{join as M}from"path";import{cp as Vt}from"fs/promises";function it(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(nt)}async function nt(o){await
|
|
45
|
+
$ webnative init my-app`).action(nt)}async function nt(o){await kt(o),await Pt(o),console.log(`Project initialized${o?` in ${o}`:""}`)}async function kt(o){let t=o?M(process.cwd(),o):process.cwd();await Vt(M(V,"template"),t,{recursive:!0})}async function Pt(o){let t=o?M(process.cwd(),o):process.cwd();await x("npm init -y",{cwd:t})}it(T);X(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.0.
|
|
4
|
+
"version": "1.0.1",
|
|
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
|
},
|