@gjsify/cli 0.64.2-next.253 → 0.64.2-next.255
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/dist/cli.gjs.mjs
CHANGED
|
@@ -145,7 +145,7 @@ fi
|
|
|
145
145
|
`)}`:``;n.fail(N(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(C).length,Object.keys(C).join(`, `)+S))}},F.unknownArguments=function unknownArguments(S,C,I,H,W=!0){let q=t.getInternalMethods().getCommandInstance().getCommands(),Y=[],X=t.getInternalMethods().getContext();if(Object.keys(S).forEach(n=>{!bp.includes(n)&&!Object.prototype.hasOwnProperty.call(I,n)&&!Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),n)&&!F.isValidAndSomeAliasIsNotNew(n,C)&&Y.push(n)}),W&&(X.commands.length>0||q.length>0||H)&&S._.slice(X.commands.length).forEach(t=>{q.includes(``+t)||Y.push(``+t)}),W){let n=t.getDemandedCommands()._?.max||0,C=X.commands.length+n;C<S._.length&&S._.slice(C).forEach(t=>{t=String(t),!X.commands.includes(t)&&!Y.includes(t)&&Y.push(t)})}Y.length&&n.fail(N(`Unknown argument: %s`,`Unknown arguments: %s`,Y.length,Y.map(t=>t.trim()?t:`"${t}"`).join(`, `)))},F.unknownCommands=function unknownCommands(S){let C=t.getInternalMethods().getCommandInstance().getCommands(),F=[],I=t.getInternalMethods().getContext();return(I.commands.length>0||C.length>0)&&S._.slice(I.commands.length).forEach(t=>{C.includes(``+t)||F.push(``+t)}),F.length>0?(n.fail(N(`Unknown command: %s`,`Unknown commands: %s`,F.length,F.join(`, `))),!0):!1},F.isValidAndSomeAliasIsNotNew=function isValidAndSomeAliasIsNotNew(n,S){if(!Object.prototype.hasOwnProperty.call(S,n))return!1;let C=t.parsed.newAliases;return[n,...S[n]].some(t=>!Object.prototype.hasOwnProperty.call(C,t)||!C[n])},F.limitedChoices=function limitedChoices(S){let N=t.getOptions(),F={};if(!Object.keys(N.choices).length)return;Object.keys(S).forEach(t=>{bp.indexOf(t)===-1&&Object.prototype.hasOwnProperty.call(N.choices,t)&&[].concat(S[t]).forEach(n=>{N.choices[t].indexOf(n)===-1&&n!==void 0&&(F[t]=(F[t]||[]).concat(n))})});let I=Object.keys(F);if(!I.length)return;let H=C(`Invalid values:`);I.forEach(t=>{H+=`\n ${C(`Argument: %s, Given: %s, Choices: %s`,t,n.stringifiedValues(F[t]),n.stringifiedValues(N.choices[t]))}`}),n.fail(H)};let I={};F.implies=function implies(n,C){argsert(`<string|object> [array|number|string]`,[n,C],arguments.length),typeof n==`object`?Object.keys(n).forEach(t=>{F.implies(t,n[t])}):(t.global(n),I[n]||(I[n]=[]),Array.isArray(C)?C.forEach(t=>F.implies(n,t)):(assertNotStrictEqual(C,void 0,S),I[n].push(C)))},F.getImplied=function getImplied(){return I};function keyExists(t,n){let S=Number(n);return n=isNaN(S)?n:S,typeof n==`number`?n=t._.length>=n:n.match(/^--no-.+/)?(n=n.match(/^--no-(.+)/)[1],n=!Object.prototype.hasOwnProperty.call(t,n)):n=Object.prototype.hasOwnProperty.call(t,n),n}F.implications=function implications(t){let S=[];if(Object.keys(I).forEach(n=>{let C=n;(I[n]||[]).forEach(n=>{let N=C,F=n;N=keyExists(t,N),n=keyExists(t,n),N&&!n&&S.push(` ${C} -> ${F}`)})}),S.length){let t=`${C(`Implications failed:`)}\n`;S.forEach(n=>{t+=n}),n.fail(t)}};let H={};F.conflicts=function conflicts(n,S){argsert(`<string|object> [array|string]`,[n,S],arguments.length),typeof n==`object`?Object.keys(n).forEach(t=>{F.conflicts(t,n[t])}):(t.global(n),H[n]||(H[n]=[]),Array.isArray(S)?S.forEach(t=>F.conflicts(n,t)):H[n].push(S))},F.getConflicting=()=>H,F.conflicting=function conflictingFn(N){Object.keys(N).forEach(t=>{H[t]&&H[t].forEach(S=>{S&&N[t]!==void 0&&N[S]!==void 0&&n.fail(C(`Arguments %s and %s are mutually exclusive`,t,S))})}),t.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(H).forEach(t=>{H[t].forEach(F=>{F&&N[S.Parser.camelCase(t)]!==void 0&&N[S.Parser.camelCase(F)]!==void 0&&n.fail(C(`Arguments %s and %s are mutually exclusive`,t,F))})})},F.recommendCommands=function recommendCommands(t,S){S=S.sort((t,n)=>n.length-t.length);let N=null,F=1/0;for(let n=0,C;(C=S[n])!==void 0;n++){let n=levenshtein(t,C);n<=3&&n<F&&(F=n,N=C)}N&&n.fail(C(`Did you mean %s?`,N))},F.reset=function reset(t){return I=objFilter(I,n=>!t[n]),H=objFilter(H,n=>!t[n]),F};let W=[];return F.freeze=function freeze(){W.push({implied:I,conflicting:H})},F.unfreeze=function unfreeze(){let t=W.pop();assertNotStrictEqual(t,void 0,S),{implied:I,conflicting:H}=t},F}var bp,xp=__esmMin(()=>{ap(),tp(),yp(),dp(),bp=[`$0`,`--`,`_`]});function YargsFactory(t){return(n=[],S=t.process.cwd(),C)=>{let N=new YargsInstance(n,S,C,t);return Object.defineProperty(N,"argv",{get:()=>N.parse(),enumerable:!0}),N.help(),N.version(),N}}function isYargsInstance(t){return!!t&&typeof t.getInternalMethods==`function`}var __classPrivateFieldSet,__classPrivateFieldGet,Sp,Cp,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np,Pp,Fp,Ip,Lp,Rp,zp,Bp,Vp,Hp,Up,Wp,Gp,Kp,qp,Jp,Yp,Xp,Zp,Qp,$p,em,tm,nm,im,am,om,sm,cm,lm,um,dm,fm,pm,mm,hm,gm,_m,vm,ym,bm,xm,Sm,Cm,wm,Tm,Em,Dm,Om,km,Am,jm,Mm,Nm,Pm,Fm,Im,Lm,Rm,zm,Bm,YargsInstance,Vm=__esmMin(()=>{_e(),up(),tp(),Cl(),pp(),ap(),vp(),xp(),dp(),El(),op(),np(),sp(),fp(),__classPrivateFieldSet=function(t,n,S,C,N){if(C===`m`)throw TypeError(`Private method is not writable`);if(C===`a`&&!N)throw TypeError(`Private accessor was defined without a setter`);if(typeof n==`function`?t!==n||!N:!n.has(t))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return C===`a`?N.call(t,S):N?N.value=S:n.set(t,S),S},__classPrivateFieldGet=function(t,n,S,C){if(S===`a`&&!C)throw TypeError(`Private accessor was defined without a getter`);if(typeof n==`function`?t!==n||!C:!n.has(t))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return S===`m`?C:S===`a`?C.call(t):C?C.value:n.get(t)},im=Symbol(`copyDoubleDash`),am=Symbol(`copyDoubleDash`),om=Symbol(`deleteFromParserHintObject`),sm=Symbol(`emitWarning`),cm=Symbol(`freeze`),lm=Symbol(`getDollarZero`),um=Symbol(`getParserConfiguration`),dm=Symbol(`getUsageConfiguration`),fm=Symbol(`guessLocale`),pm=Symbol(`guessVersion`),mm=Symbol(`parsePositionalNumbers`),hm=Symbol(`pkgUp`),gm=Symbol(`populateParserHintArray`),_m=Symbol(`populateParserHintSingleValueDictionary`),vm=Symbol(`populateParserHintArrayDictionary`),ym=Symbol(`populateParserHintDictionary`),bm=Symbol(`sanitizeKey`),xm=Symbol(`setKey`),Sm=Symbol(`unfreeze`),Cm=Symbol(`validateAsync`),wm=Symbol(`getCommandInstance`),Tm=Symbol(`getContext`),Em=Symbol(`getHasOutput`),Dm=Symbol(`getLoggerInstance`),Om=Symbol(`getParseContext`),km=Symbol(`getUsageInstance`),Am=Symbol(`getValidationInstance`),jm=Symbol(`hasParseCallback`),Mm=Symbol(`isGlobalContext`),Nm=Symbol(`postProcess`),Pm=Symbol(`rebase`),Fm=Symbol(`reset`),Im=Symbol(`runYargsParserAndExecuteCommands`),Lm=Symbol(`runValidation`),Rm=Symbol(`setHasOutput`),zm=Symbol(`kTrackManuallySetKeys`),Bm=`en_US`,YargsInstance=class{constructor(t=[],n,S,C){this.customScriptName=!1,this.parsed=!1,Sp.set(this,void 0),Cp.set(this,void 0),wp.set(this,{commands:[],fullCommands:[]}),Tp.set(this,null),Ep.set(this,null),Dp.set(this,`show-hidden`),Op.set(this,null),kp.set(this,!0),Ap.set(this,{}),jp.set(this,!0),Mp.set(this,[]),Np.set(this,void 0),Pp.set(this,{}),Fp.set(this,!1),Ip.set(this,null),Lp.set(this,!0),Rp.set(this,void 0),zp.set(this,``),Bp.set(this,void 0),Vp.set(this,void 0),Hp.set(this,{}),Up.set(this,null),Wp.set(this,null),Gp.set(this,{}),Kp.set(this,{}),qp.set(this,void 0),Jp.set(this,!1),Yp.set(this,void 0),Xp.set(this,!1),Zp.set(this,!1),Qp.set(this,!1),$p.set(this,void 0),em.set(this,{}),tm.set(this,null),nm.set(this,void 0),__classPrivateFieldSet(this,Yp,C,`f`),__classPrivateFieldSet(this,qp,t,`f`),__classPrivateFieldSet(this,Cp,n,`f`),__classPrivateFieldSet(this,Vp,S,`f`),__classPrivateFieldSet(this,Np,new GlobalMiddleware(this),`f`),this.$0=this[lm](),this[Fm](),__classPrivateFieldSet(this,Sp,__classPrivateFieldGet(this,Sp,`f`),`f`),__classPrivateFieldSet(this,$p,__classPrivateFieldGet(this,$p,`f`),`f`),__classPrivateFieldSet(this,nm,__classPrivateFieldGet(this,nm,`f`),`f`),__classPrivateFieldSet(this,Bp,__classPrivateFieldGet(this,Bp,`f`),`f`),__classPrivateFieldGet(this,Bp,`f`).showHiddenOpt=__classPrivateFieldGet(this,Dp,`f`),__classPrivateFieldSet(this,Rp,this[am](),`f`),__classPrivateFieldGet(this,Yp,`f`).y18n.setLocale(Bm)}addHelpOpt(t,n){return argsert(`[string|boolean] [string]`,[t,n],arguments.length),__classPrivateFieldGet(this,Ip,`f`)&&(this[om](__classPrivateFieldGet(this,Ip,`f`)),__classPrivateFieldSet(this,Ip,null,`f`)),t===!1&&n===void 0?this:(__classPrivateFieldSet(this,Ip,typeof t==`string`?t:`help`,`f`),this.boolean(__classPrivateFieldGet(this,Ip,`f`)),this.describe(__classPrivateFieldGet(this,Ip,`f`),n||__classPrivateFieldGet(this,$p,`f`).deferY18nLookup(`Show help`)),this)}help(t,n){return this.addHelpOpt(t,n)}addShowHiddenOpt(t,n){if(argsert(`[string|boolean] [string]`,[t,n],arguments.length),t===!1&&n===void 0)return this;let S=typeof t==`string`?t:__classPrivateFieldGet(this,Dp,`f`);return this.boolean(S),this.describe(S,n||__classPrivateFieldGet(this,$p,`f`).deferY18nLookup(`Show hidden options`)),__classPrivateFieldGet(this,Bp,`f`).showHiddenOpt=S,this}showHidden(t,n){return this.addShowHiddenOpt(t,n)}alias(t,n){return argsert(`<object|string|array> [string|array]`,[t,n],arguments.length),this[vm](this.alias.bind(this),`alias`,t,n),this}array(t){return argsert(`<array|string>`,[t],arguments.length),this[gm](`array`,t),this[zm](t),this}boolean(t){return argsert(`<array|string>`,[t],arguments.length),this[gm](`boolean`,t),this[zm](t),this}check(t,n){return argsert(`<function> [boolean]`,[t,n],arguments.length),this.middleware((n,S)=>maybeAsyncResult(()=>t(n,S.getOptions()),S=>(S?(typeof S==`string`||S instanceof Error)&&__classPrivateFieldGet(this,$p,`f`).fail(S.toString(),S):__classPrivateFieldGet(this,$p,`f`).fail(__classPrivateFieldGet(this,Yp,`f`).y18n.__(`Argument check failed: %s`,t.toString())),n),t=>(__classPrivateFieldGet(this,$p,`f`).fail(t.message?t.message:t.toString(),t),n)),!1,n),this}choices(t,n){return argsert(`<object|string|array> [string|array]`,[t,n],arguments.length),this[vm](this.choices.bind(this),`choices`,t,n),this}coerce(t,n){if(argsert(`<object|string|array> [function]`,[t,n],arguments.length),Array.isArray(t)){if(!n)throw new Sl(`coerce callback must be provided`);for(let S of t)this.coerce(S,n);return this}else if(typeof t==`object`){for(let n of Object.keys(t))this.coerce(n,t[n]);return this}if(!n)throw new Sl(`coerce callback must be provided`);let S=t;return __classPrivateFieldGet(this,Bp,`f`).key[S]=!0,__classPrivateFieldGet(this,Np,`f`).addCoerceMiddleware((t,C)=>{let N=C.getAliases()[S]??[],F=[S,...N].filter(n=>Object.prototype.hasOwnProperty.call(t,n));return F.length===0?t:maybeAsyncResult(()=>n(t[F[0]]),n=>(F.forEach(S=>{t[S]=n}),t),t=>{throw new Sl(t.message)})},S),this}conflicts(t,n){return argsert(`<string|object> [string|array]`,[t,n],arguments.length),__classPrivateFieldGet(this,nm,`f`).conflicts(t,n),this}config(t=`config`,n,S){return argsert(`[object|string] [string|function] [function]`,[t,n,S],arguments.length),typeof t==`object`&&!Array.isArray(t)?(t=applyExtends(t,__classPrivateFieldGet(this,Cp,`f`),this[um]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,Yp,`f`)),__classPrivateFieldGet(this,Bp,`f`).configObjects=(__classPrivateFieldGet(this,Bp,`f`).configObjects||[]).concat(t),this):(typeof n==`function`&&(S=n,n=void 0),this.describe(t,n||__classPrivateFieldGet(this,$p,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(t)?t:[t]).forEach(t=>{__classPrivateFieldGet(this,Bp,`f`).config[t]=S||!0}),this)}completion(t,n,S){return argsert(`[string] [string|boolean|function] [function]`,[t,n,S],arguments.length),typeof n==`function`&&(S=n,n=void 0),__classPrivateFieldSet(this,Ep,t||__classPrivateFieldGet(this,Ep,`f`)||`completion`,`f`),!n&&n!==!1&&(n=`generate completion script`),this.command(__classPrivateFieldGet(this,Ep,`f`),n),S&&__classPrivateFieldGet(this,Tp,`f`).registerFunction(S),this}command(t,n,S,C,N,F){return argsert(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[t,n,S,C,N,F],arguments.length),__classPrivateFieldGet(this,Sp,`f`).addHandler(t,n,S,C,N,F),this}commands(t,n,S,C,N,F){return this.command(t,n,S,C,N,F)}commandDir(t,n){argsert(`<string> [object]`,[t,n],arguments.length);let S=__classPrivateFieldGet(this,Vp,`f`)||__classPrivateFieldGet(this,Yp,`f`).require;return __classPrivateFieldGet(this,Sp,`f`).addDirectory(t,S,__classPrivateFieldGet(this,Yp,`f`).getCallerFile(),n),this}count(t){return argsert(`<array|string>`,[t],arguments.length),this[gm](`count`,t),this[zm](t),this}default(t,n,S){return argsert(`<object|string|array> [*] [string]`,[t,n,S],arguments.length),S&&(assertSingleKey(t,__classPrivateFieldGet(this,Yp,`f`)),__classPrivateFieldGet(this,Bp,`f`).defaultDescription[t]=S),typeof n==`function`&&(assertSingleKey(t,__classPrivateFieldGet(this,Yp,`f`)),__classPrivateFieldGet(this,Bp,`f`).defaultDescription[t]||(__classPrivateFieldGet(this,Bp,`f`).defaultDescription[t]=__classPrivateFieldGet(this,$p,`f`).functionDescription(n)),n=n.call()),this[_m](this.default.bind(this),`default`,t,n),this}defaults(t,n,S){return this.default(t,n,S)}demandCommand(t=1,n,S,C){return argsert(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[t,n,S,C],arguments.length),typeof n!=`number`&&(S=n,n=1/0),this.global(`_`,!1),__classPrivateFieldGet(this,Bp,`f`).demandedCommands._={min:t,max:n,minMsg:S,maxMsg:C},this}demand(t,n,S){return Array.isArray(n)?(n.forEach(t=>{assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,Yp,`f`)),this.demandOption(t,S)}),n=1/0):typeof n!=`number`&&(S=n,n=1/0),typeof t==`number`?(assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,Yp,`f`)),this.demandCommand(t,n,S,S)):Array.isArray(t)?t.forEach(t=>{assertNotStrictEqual(S,!0,__classPrivateFieldGet(this,Yp,`f`)),this.demandOption(t,S)}):typeof S==`string`?this.demandOption(t,S):(S===!0||S===void 0)&&this.demandOption(t),this}demandOption(t,n){return argsert(`<object|string|array> [string]`,[t,n],arguments.length),this[_m](this.demandOption.bind(this),`demandedOptions`,t,n),this}deprecateOption(t,n){return argsert(`<string> [string|boolean]`,[t,n],arguments.length),__classPrivateFieldGet(this,Bp,`f`).deprecatedOptions[t]=n,this}describe(t,n){return argsert(`<object|string|array> [string]`,[t,n],arguments.length),this[xm](t,!0),__classPrivateFieldGet(this,$p,`f`).describe(t,n),this}detectLocale(t){return argsert(`<boolean>`,[t],arguments.length),__classPrivateFieldSet(this,kp,t,`f`),this}env(t){return argsert(`[string|boolean]`,[t],arguments.length),t===!1?delete __classPrivateFieldGet(this,Bp,`f`).envPrefix:__classPrivateFieldGet(this,Bp,`f`).envPrefix=t||``,this}epilogue(t){return argsert(`<string>`,[t],arguments.length),__classPrivateFieldGet(this,$p,`f`).epilog(t),this}epilog(t){return this.epilogue(t)}example(t,n){return argsert(`<string|array> [string]`,[t,n],arguments.length),Array.isArray(t)?t.forEach(t=>this.example(...t)):__classPrivateFieldGet(this,$p,`f`).example(t,n),this}exit(t,n){__classPrivateFieldSet(this,Fp,!0,`f`),__classPrivateFieldSet(this,Op,n,`f`),__classPrivateFieldGet(this,jp,`f`)&&__classPrivateFieldGet(this,Yp,`f`).process.exit(t)}exitProcess(t=!0){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,jp,t,`f`),this}fail(t){if(argsert(`<function|boolean>`,[t],arguments.length),typeof t==`boolean`&&t!==!1)throw new Sl(`Invalid first argument. Expected function or boolean 'false'`);return __classPrivateFieldGet(this,$p,`f`).failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,n){return argsert(`<array> [function]`,[t,n],arguments.length),n?__classPrivateFieldGet(this,Tp,`f`).getCompletion(t,n):new Promise((n,S)=>{__classPrivateFieldGet(this,Tp,`f`).getCompletion(t,(t,C)=>{t?S(t):n(C)})})}getDemandedOptions(){return argsert([],0),__classPrivateFieldGet(this,Bp,`f`).demandedOptions}getDemandedCommands(){return argsert([],0),__classPrivateFieldGet(this,Bp,`f`).demandedCommands}getDeprecatedOptions(){return argsert([],0),__classPrivateFieldGet(this,Bp,`f`).deprecatedOptions}getDetectLocale(){return __classPrivateFieldGet(this,kp,`f`)}getExitProcess(){return __classPrivateFieldGet(this,jp,`f`)}getGroups(){return Object.assign({},__classPrivateFieldGet(this,Pp,`f`),__classPrivateFieldGet(this,Kp,`f`))}getHelp(){if(__classPrivateFieldSet(this,Fp,!0,`f`),!__classPrivateFieldGet(this,$p,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[Im](__classPrivateFieldGet(this,qp,`f`),void 0,void 0,0,!0);if(isPromise(t))return t.then(()=>__classPrivateFieldGet(this,$p,`f`).help())}let t=__classPrivateFieldGet(this,Sp,`f`).runDefaultBuilderOn(this);if(isPromise(t))return t.then(()=>__classPrivateFieldGet(this,$p,`f`).help())}return Promise.resolve(__classPrivateFieldGet(this,$p,`f`).help())}getOptions(){return __classPrivateFieldGet(this,Bp,`f`)}getStrict(){return __classPrivateFieldGet(this,Xp,`f`)}getStrictCommands(){return __classPrivateFieldGet(this,Zp,`f`)}getStrictOptions(){return __classPrivateFieldGet(this,Qp,`f`)}global(t,n){return argsert(`<string|array> [boolean]`,[t,n],arguments.length),t=[].concat(t),n===!1?t.forEach(t=>{__classPrivateFieldGet(this,Bp,`f`).local.includes(t)||__classPrivateFieldGet(this,Bp,`f`).local.push(t)}):__classPrivateFieldGet(this,Bp,`f`).local=__classPrivateFieldGet(this,Bp,`f`).local.filter(n=>t.indexOf(n)===-1),this}group(t,n){argsert(`<string|array> <string>`,[t,n],arguments.length);let S=__classPrivateFieldGet(this,Kp,`f`)[n]||__classPrivateFieldGet(this,Pp,`f`)[n];__classPrivateFieldGet(this,Kp,`f`)[n]&&delete __classPrivateFieldGet(this,Kp,`f`)[n];let C={};return __classPrivateFieldGet(this,Pp,`f`)[n]=(S||[]).concat(t).filter(t=>C[t]?!1:C[t]=!0),this}hide(t){return argsert(`<string>`,[t],arguments.length),__classPrivateFieldGet(this,Bp,`f`).hiddenOptions.push(t),this}implies(t,n){return argsert(`<string|object> [number|string|array]`,[t,n],arguments.length),__classPrivateFieldGet(this,nm,`f`).implies(t,n),this}locale(t){return argsert(`[string]`,[t],arguments.length),t===void 0?(this[fm](),__classPrivateFieldGet(this,Yp,`f`).y18n.getLocale()):(__classPrivateFieldSet(this,kp,!1,`f`),__classPrivateFieldGet(this,Yp,`f`).y18n.setLocale(t),this)}middleware(t,n,S){return __classPrivateFieldGet(this,Np,`f`).addMiddleware(t,!!n,S)}nargs(t,n){return argsert(`<string|object|array> [number]`,[t,n],arguments.length),this[_m](this.nargs.bind(this),`narg`,t,n),this}normalize(t){return argsert(`<array|string>`,[t],arguments.length),this[gm](`normalize`,t),this}number(t){return argsert(`<array|string>`,[t],arguments.length),this[gm](`number`,t),this[zm](t),this}option(t,n){if(argsert(`<string|object> [object]`,[t,n],arguments.length),typeof t==`object`)Object.keys(t).forEach(n=>{this.options(n,t[n])});else{typeof n!=`object`&&(n={}),this[zm](t),__classPrivateFieldGet(this,tm,`f`)&&(t===`version`||n?.alias===`version`)&&this[sm]([`"version" is a reserved word.`,`Please do one of the following:`,'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)",`- Use a different option key`,`https://yargs.js.org/docs/#api-reference-version`].join(`
|
|
146
146
|
`),void 0,`versionWarning`),__classPrivateFieldGet(this,Bp,`f`).key[t]=!0,n.alias&&this.alias(t,n.alias);let S=n.deprecate||n.deprecated;S&&this.deprecateOption(t,S);let C=n.demand||n.required||n.require;C&&this.demand(t,C),n.demandOption&&this.demandOption(t,typeof n.demandOption==`string`?n.demandOption:void 0),n.conflicts&&this.conflicts(t,n.conflicts),`default`in n&&this.default(t,n.default),n.implies!==void 0&&this.implies(t,n.implies),n.nargs!==void 0&&this.nargs(t,n.nargs),n.config&&this.config(t,n.configParser),n.normalize&&this.normalize(t),n.choices&&this.choices(t,n.choices),n.coerce&&this.coerce(t,n.coerce),n.group&&this.group(t,n.group),(n.boolean||n.type===`boolean`)&&(this.boolean(t),n.alias&&this.boolean(n.alias)),(n.array||n.type===`array`)&&(this.array(t),n.alias&&this.array(n.alias)),(n.number||n.type===`number`)&&(this.number(t),n.alias&&this.number(n.alias)),(n.string||n.type===`string`)&&(this.string(t),n.alias&&this.string(n.alias)),(n.count||n.type===`count`)&&this.count(t),typeof n.global==`boolean`&&this.global(t,n.global),n.defaultDescription&&(__classPrivateFieldGet(this,Bp,`f`).defaultDescription[t]=n.defaultDescription),n.skipValidation&&this.skipValidation(t);let N=n.describe||n.description||n.desc,F=__classPrivateFieldGet(this,$p,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(F,t)||typeof N==`string`)&&this.describe(t,N),n.hidden&&this.hide(t),n.requiresArg&&this.requiresArg(t)}return this}options(t,n){return this.option(t,n)}parse(t,n,S){argsert(`[string|array] [function|boolean|object] [function]`,[t,n,S],arguments.length),this[cm](),t===void 0&&(t=__classPrivateFieldGet(this,qp,`f`)),typeof n==`object`&&(__classPrivateFieldSet(this,Wp,n,`f`),n=S),typeof n==`function`&&(__classPrivateFieldSet(this,Up,n,`f`),n=!1),n||__classPrivateFieldSet(this,qp,t,`f`),__classPrivateFieldGet(this,Up,`f`)&&__classPrivateFieldSet(this,jp,!1,`f`);let C=this[Im](t,!!n),N=this.parsed;return __classPrivateFieldGet(this,Tp,`f`).setParsed(this.parsed),isPromise(C)?C.then(t=>(__classPrivateFieldGet(this,Up,`f`)&&__classPrivateFieldGet(this,Up,`f`).call(this,__classPrivateFieldGet(this,Op,`f`),t,__classPrivateFieldGet(this,zp,`f`)),t)).catch(t=>{throw __classPrivateFieldGet(this,Up,`f`)&&__classPrivateFieldGet(this,Up,`f`)(t,this.parsed.argv,__classPrivateFieldGet(this,zp,`f`)),t}).finally(()=>{this[Sm](),this.parsed=N}):(__classPrivateFieldGet(this,Up,`f`)&&__classPrivateFieldGet(this,Up,`f`).call(this,__classPrivateFieldGet(this,Op,`f`),C,__classPrivateFieldGet(this,zp,`f`)),this[Sm](),this.parsed=N,C)}parseAsync(t,n,S){let C=this.parse(t,n,S);return isPromise(C)?C:Promise.resolve(C)}parseSync(t,n,S){let C=this.parse(t,n,S);if(isPromise(C))throw new Sl(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return C}parserConfiguration(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,Hp,t,`f`),this}pkgConf(t,n){argsert(`<string> [string]`,[t,n],arguments.length);let S=null,C=this[hm](n||__classPrivateFieldGet(this,Cp,`f`));return C[t]&&typeof C[t]==`object`&&(S=applyExtends(C[t],n||__classPrivateFieldGet(this,Cp,`f`),this[um]()[`deep-merge-config`]||!1,__classPrivateFieldGet(this,Yp,`f`)),__classPrivateFieldGet(this,Bp,`f`).configObjects=(__classPrivateFieldGet(this,Bp,`f`).configObjects||[]).concat(S)),this}positional(t,n){argsert(`<string> <object>`,[t,n],arguments.length);let S=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];n=objFilter(n,(t,n)=>t===`type`&&![`string`,`number`,`boolean`].includes(n)?!1:S.includes(t));let C=__classPrivateFieldGet(this,wp,`f`).fullCommands[__classPrivateFieldGet(this,wp,`f`).fullCommands.length-1],N=C?__classPrivateFieldGet(this,Sp,`f`).cmdToParseOptions(C):{array:[],alias:{},default:{},demand:{}};return objectKeys(N).forEach(S=>{let C=N[S];Array.isArray(C)?C.indexOf(t)!==-1&&(n[S]=!0):C[t]&&!(S in n)&&(n[S]=C[t])}),this.group(t,__classPrivateFieldGet(this,$p,`f`).getPositionalGroupName()),this.option(t,n)}recommendCommands(t=!0){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Jp,t,`f`),this}required(t,n,S){return this.demand(t,n,S)}require(t,n,S){return this.demand(t,n,S)}requiresArg(t){return argsert(`<array|string|object> [number]`,[t],arguments.length),typeof t==`string`&&__classPrivateFieldGet(this,Bp,`f`).narg[t]||this[_m](this.requiresArg.bind(this),`narg`,t,NaN),this}showCompletionScript(t,n){return argsert(`[string] [string]`,[t,n],arguments.length),t||=this.$0,__classPrivateFieldGet(this,Rp,`f`).log(__classPrivateFieldGet(this,Tp,`f`).generateCompletionScript(t,n||__classPrivateFieldGet(this,Ep,`f`)||`completion`)),this}showHelp(t){if(argsert(`[string|function]`,[t],arguments.length),__classPrivateFieldSet(this,Fp,!0,`f`),!__classPrivateFieldGet(this,$p,`f`).hasCachedHelpMessage()){if(!this.parsed){let n=this[Im](__classPrivateFieldGet(this,qp,`f`),void 0,void 0,0,!0);if(isPromise(n))return n.then(()=>{__classPrivateFieldGet(this,$p,`f`).showHelp(t)}),this}let n=__classPrivateFieldGet(this,Sp,`f`).runDefaultBuilderOn(this);if(isPromise(n))return n.then(()=>{__classPrivateFieldGet(this,$p,`f`).showHelp(t)}),this}return __classPrivateFieldGet(this,$p,`f`).showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,n){return argsert(`[boolean|string] [string]`,[t,n],arguments.length),__classPrivateFieldGet(this,$p,`f`).showHelpOnFail(t,n),this}showVersion(t){return argsert(`[string|function]`,[t],arguments.length),__classPrivateFieldGet(this,$p,`f`).showVersion(t),this}skipValidation(t){return argsert(`<array|string>`,[t],arguments.length),this[gm](`skipValidation`,t),this}strict(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Xp,t!==!1,`f`),this}strictCommands(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Zp,t!==!1,`f`),this}strictOptions(t){return argsert(`[boolean]`,[t],arguments.length),__classPrivateFieldSet(this,Qp,t!==!1,`f`),this}string(t){return argsert(`<array|string>`,[t],arguments.length),this[gm](`string`,t),this[zm](t),this}terminalWidth(){return argsert([],0),__classPrivateFieldGet(this,Yp,`f`).process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,kp,!1,`f`),__classPrivateFieldGet(this,Yp,`f`).y18n.updateLocale(t),this}usage(t,n,S,C){if(argsert(`<string|null|undefined> [string|boolean] [function|object] [function]`,[t,n,S,C],arguments.length),n!==void 0){if(assertNotStrictEqual(t,null,__classPrivateFieldGet(this,Yp,`f`)),(t||``).match(/^\$0( |$)/))return this.command(t,n,S,C);throw new Sl(`.usage() description must start with $0 if being used as alias for .command()`)}else return __classPrivateFieldGet(this,$p,`f`).usage(t),this}usageConfiguration(t){return argsert(`<object>`,[t],arguments.length),__classPrivateFieldSet(this,em,t,`f`),this}version(t,n,S){let C=`version`;if(argsert(`[boolean|string] [string] [string]`,[t,n,S],arguments.length),__classPrivateFieldGet(this,tm,`f`)&&(this[om](__classPrivateFieldGet(this,tm,`f`)),__classPrivateFieldGet(this,$p,`f`).version(void 0),__classPrivateFieldSet(this,tm,null,`f`)),arguments.length===0)S=this[pm](),t=C;else if(arguments.length===1){if(t===!1)return this;S=t,t=C}else arguments.length===2&&(S=n,n=void 0);return __classPrivateFieldSet(this,tm,typeof t==`string`?t:C,`f`),n||=__classPrivateFieldGet(this,$p,`f`).deferY18nLookup(`Show version number`),__classPrivateFieldGet(this,$p,`f`).version(S||void 0),this.boolean(__classPrivateFieldGet(this,tm,`f`)),this.describe(__classPrivateFieldGet(this,tm,`f`),n),this}wrap(t){return argsert(`<number|null|undefined>`,[t],arguments.length),__classPrivateFieldGet(this,$p,`f`).wrap(t),this}[(Sp=new WeakMap,Cp=new WeakMap,wp=new WeakMap,Tp=new WeakMap,Ep=new WeakMap,Dp=new WeakMap,Op=new WeakMap,kp=new WeakMap,Ap=new WeakMap,jp=new WeakMap,Mp=new WeakMap,Np=new WeakMap,Pp=new WeakMap,Fp=new WeakMap,Ip=new WeakMap,Lp=new WeakMap,Rp=new WeakMap,zp=new WeakMap,Bp=new WeakMap,Vp=new WeakMap,Hp=new WeakMap,Up=new WeakMap,Wp=new WeakMap,Gp=new WeakMap,Kp=new WeakMap,qp=new WeakMap,Jp=new WeakMap,Yp=new WeakMap,Xp=new WeakMap,Zp=new WeakMap,Qp=new WeakMap,$p=new WeakMap,em=new WeakMap,tm=new WeakMap,nm=new WeakMap,im)](t){if(!t._||!t[`--`])return t;t._.push.apply(t._,t[`--`]);try{delete t[`--`]}catch{}return t}[am](){return{log:(...t)=>{this[jm]()||ge.log(...t),__classPrivateFieldSet(this,Fp,!0,`f`),__classPrivateFieldGet(this,zp,`f`).length&&__classPrivateFieldSet(this,zp,__classPrivateFieldGet(this,zp,`f`)+`
|
|
147
147
|
`,`f`),__classPrivateFieldSet(this,zp,__classPrivateFieldGet(this,zp,`f`)+t.join(` `),`f`)},error:(...t)=>{this[jm]()||ge.error(...t),__classPrivateFieldSet(this,Fp,!0,`f`),__classPrivateFieldGet(this,zp,`f`).length&&__classPrivateFieldSet(this,zp,__classPrivateFieldGet(this,zp,`f`)+`
|
|
148
|
-
`,`f`),__classPrivateFieldSet(this,zp,__classPrivateFieldGet(this,zp,`f`)+t.join(` `),`f`)}}}[om](t){objectKeys(__classPrivateFieldGet(this,Bp,`f`)).forEach(n=>{if((t=>t===`configObjects`)(n))return;let S=__classPrivateFieldGet(this,Bp,`f`)[n];Array.isArray(S)?S.includes(t)&&S.splice(S.indexOf(t),1):typeof S==`object`&&delete S[t]}),delete __classPrivateFieldGet(this,$p,`f`).getDescriptions()[t]}[sm](t,n,S){__classPrivateFieldGet(this,Ap,`f`)[S]||(__classPrivateFieldGet(this,Yp,`f`).process.emitWarning(t,n),__classPrivateFieldGet(this,Ap,`f`)[S]=!0)}[cm](){__classPrivateFieldGet(this,Mp,`f`).push({options:__classPrivateFieldGet(this,Bp,`f`),configObjects:__classPrivateFieldGet(this,Bp,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,jp,`f`),groups:__classPrivateFieldGet(this,Pp,`f`),strict:__classPrivateFieldGet(this,Xp,`f`),strictCommands:__classPrivateFieldGet(this,Zp,`f`),strictOptions:__classPrivateFieldGet(this,Qp,`f`),completionCommand:__classPrivateFieldGet(this,Ep,`f`),output:__classPrivateFieldGet(this,zp,`f`),exitError:__classPrivateFieldGet(this,Op,`f`),hasOutput:__classPrivateFieldGet(this,Fp,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,Up,`f`),parseContext:__classPrivateFieldGet(this,Wp,`f`)}),__classPrivateFieldGet(this,$p,`f`).freeze(),__classPrivateFieldGet(this,nm,`f`).freeze(),__classPrivateFieldGet(this,Sp,`f`).freeze(),__classPrivateFieldGet(this,Np,`f`).freeze()}[lm](){let t=``,n;return n=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,Yp,`f`).process.argv()[0])?__classPrivateFieldGet(this,Yp,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,Yp,`f`).process.argv().slice(0,1),t=n.map(t=>{let n=this[Pm](__classPrivateFieldGet(this,Cp,`f`),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&n.length<t.length?n:t}).join(` `).trim(),__classPrivateFieldGet(this,Yp,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,Yp,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,Yp,`f`).getEnv(`_`)&&(t=__classPrivateFieldGet(this,Yp,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,Yp,`f`).path.dirname(__classPrivateFieldGet(this,Yp,`f`).process.execPath())}/`,``)),t}[um](){return __classPrivateFieldGet(this,Hp,`f`)}[dm](){return __classPrivateFieldGet(this,em,`f`)}[fm](){if(!__classPrivateFieldGet(this,kp,`f`))return;let t=__classPrivateFieldGet(this,Yp,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,Yp,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,Yp,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,Yp,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(t.replace(/[.:].*/,``))}[pm](){return this[hm]().version||`unknown`}[mm](t){let n=t[`--`]?t[`--`]:t._;for(let t=0,S;(S=n[t])!==void 0;t++)__classPrivateFieldGet(this,Yp,`f`).Parser.looksLikeNumber(S)&&Number.isSafeInteger(Math.floor(parseFloat(`${S}`)))&&(n[t]=Number(S));return t}[hm](t){let n=t||`*`;if(__classPrivateFieldGet(this,Gp,`f`)[n])return __classPrivateFieldGet(this,Gp,`f`)[n];let S={};try{let n=t||__classPrivateFieldGet(this,Yp,`f`).mainFilename;__classPrivateFieldGet(this,Yp,`f`).path.extname(n)&&(n=__classPrivateFieldGet(this,Yp,`f`).path.dirname(n));let C=__classPrivateFieldGet(this,Yp,`f`).findUp(n,(t,n)=>{if(n.includes(`package.json`))return`package.json`});assertNotStrictEqual(C,void 0,__classPrivateFieldGet(this,Yp,`f`)),S=JSON.parse(__classPrivateFieldGet(this,Yp,`f`).readFileSync(C,`utf8`))}catch{}return __classPrivateFieldGet(this,Gp,`f`)[n]=S||{},__classPrivateFieldGet(this,Gp,`f`)[n]}[gm](t,n){n=[].concat(n),n.forEach(n=>{n=this[bm](n),__classPrivateFieldGet(this,Bp,`f`)[t].push(n)})}[_m](t,n,S,C){this[ym](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Bp,`f`)[t][n]=S})}[vm](t,n,S,C){this[ym](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Bp,`f`)[t][n]=(__classPrivateFieldGet(this,Bp,`f`)[t][n]||[]).concat(S)})}[ym](t,n,S,C,N){if(Array.isArray(S))S.forEach(n=>{t(n,C)});else if((t=>typeof t==`object`)(S))for(let n of objectKeys(S))t(n,S[n]);else N(n,this[bm](S),C)}[bm](t){return t===`__proto__`?`___proto___`:t}[xm](t,n){return this[_m](this[xm].bind(this),`key`,t,n),this}[Sm](){var t,n,S,C,N,F,I,H,W,q,Y,X;let Z=__classPrivateFieldGet(this,Mp,`f`).pop();assertNotStrictEqual(Z,void 0,__classPrivateFieldGet(this,Yp,`f`));let te;t=this,n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,{options:{set value(n){__classPrivateFieldSet(t,Bp,n,`f`)}}.value,configObjects:te,exitProcess:{set value(t){__classPrivateFieldSet(n,jp,t,`f`)}}.value,groups:{set value(t){__classPrivateFieldSet(S,Pp,t,`f`)}}.value,output:{set value(t){__classPrivateFieldSet(C,zp,t,`f`)}}.value,exitError:{set value(t){__classPrivateFieldSet(N,Op,t,`f`)}}.value,hasOutput:{set value(t){__classPrivateFieldSet(F,Fp,t,`f`)}}.value,parsed:this.parsed,strict:{set value(t){__classPrivateFieldSet(I,Xp,t,`f`)}}.value,strictCommands:{set value(t){__classPrivateFieldSet(H,Zp,t,`f`)}}.value,strictOptions:{set value(t){__classPrivateFieldSet(W,Qp,t,`f`)}}.value,completionCommand:{set value(t){__classPrivateFieldSet(q,Ep,t,`f`)}}.value,parseFn:{set value(t){__classPrivateFieldSet(Y,Up,t,`f`)}}.value,parseContext:{set value(t){__classPrivateFieldSet(X,Wp,t,`f`)}}.value}=Z,__classPrivateFieldGet(this,Bp,`f`).configObjects=te,__classPrivateFieldGet(this,$p,`f`).unfreeze(),__classPrivateFieldGet(this,nm,`f`).unfreeze(),__classPrivateFieldGet(this,Sp,`f`).unfreeze(),__classPrivateFieldGet(this,Np,`f`).unfreeze()}[Cm](t,n){return maybeAsyncResult(n,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[wm].bind(this),getContext:this[Tm].bind(this),getHasOutput:this[Em].bind(this),getLoggerInstance:this[Dm].bind(this),getParseContext:this[Om].bind(this),getParserConfiguration:this[um].bind(this),getUsageConfiguration:this[dm].bind(this),getUsageInstance:this[km].bind(this),getValidationInstance:this[Am].bind(this),hasParseCallback:this[jm].bind(this),isGlobalContext:this[Mm].bind(this),postProcess:this[Nm].bind(this),reset:this[Fm].bind(this),runValidation:this[Lm].bind(this),runYargsParserAndExecuteCommands:this[Im].bind(this),setHasOutput:this[Rm].bind(this)}}[wm](){return __classPrivateFieldGet(this,Sp,`f`)}[Tm](){return __classPrivateFieldGet(this,wp,`f`)}[Em](){return __classPrivateFieldGet(this,Fp,`f`)}[Dm](){return __classPrivateFieldGet(this,Rp,`f`)}[Om](){return __classPrivateFieldGet(this,Wp,`f`)||{}}[km](){return __classPrivateFieldGet(this,$p,`f`)}[Am](){return __classPrivateFieldGet(this,nm,`f`)}[jm](){return!!__classPrivateFieldGet(this,Up,`f`)}[Mm](){return __classPrivateFieldGet(this,Lp,`f`)}[Nm](t,n,S,C){return S||isPromise(t)?t:(n||(t=this[im](t)),(this[um]()[`parse-positional-numbers`]||this[um]()[`parse-positional-numbers`]===void 0)&&(t=this[mm](t)),C&&(t=applyMiddleware(t,this,__classPrivateFieldGet(this,Np,`f`).getMiddleware(),!1)),t)}[Fm](t={}){__classPrivateFieldSet(this,Bp,__classPrivateFieldGet(this,Bp,`f`)||{},`f`);let n={};n.local=__classPrivateFieldGet(this,Bp,`f`).local||[],n.configObjects=__classPrivateFieldGet(this,Bp,`f`).configObjects||[];let S={};return n.local.forEach(n=>{S[n]=!0,(t[n]||[]).forEach(t=>{S[t]=!0})}),Object.assign(__classPrivateFieldGet(this,Kp,`f`),Object.keys(__classPrivateFieldGet(this,Pp,`f`)).reduce((t,n)=>{let C=__classPrivateFieldGet(this,Pp,`f`)[n].filter(t=>!(t in S));return C.length>0&&(t[n]=C),t},{})),__classPrivateFieldSet(this,Pp,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(t=>{n[t]=(__classPrivateFieldGet(this,Bp,`f`)[t]||[]).filter(t=>!S[t])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(t=>{n[t]=objFilter(__classPrivateFieldGet(this,Bp,`f`)[t],t=>!S[t])}),n.envPrefix=__classPrivateFieldGet(this,Bp,`f`).envPrefix,__classPrivateFieldSet(this,Bp,n,`f`),__classPrivateFieldSet(this,$p,__classPrivateFieldGet(this,$p,`f`)?__classPrivateFieldGet(this,$p,`f`).reset(S):usage(this,__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldSet(this,nm,__classPrivateFieldGet(this,nm,`f`)?__classPrivateFieldGet(this,nm,`f`).reset(S):validation(this,__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldSet(this,Sp,__classPrivateFieldGet(this,Sp,`f`)?__classPrivateFieldGet(this,Sp,`f`).reset():command(__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,nm,`f`),__classPrivateFieldGet(this,Np,`f`),__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldGet(this,Tp,`f`)||__classPrivateFieldSet(this,Tp,completion(this,__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,Sp,`f`),__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldGet(this,Np,`f`).reset(),__classPrivateFieldSet(this,Ep,null,`f`),__classPrivateFieldSet(this,zp,``,`f`),__classPrivateFieldSet(this,Op,null,`f`),__classPrivateFieldSet(this,Fp,!1,`f`),this.parsed=!1,this}[Pm](t,n){return __classPrivateFieldGet(this,Yp,`f`).path.relative(t,n)}[Im](t,n,S,C=0,N=!1){let F=!!S||N;t||=__classPrivateFieldGet(this,qp,`f`),__classPrivateFieldGet(this,Bp,`f`).__=__classPrivateFieldGet(this,Yp,`f`).y18n.__,__classPrivateFieldGet(this,Bp,`f`).configuration=this[um]();let I=!!__classPrivateFieldGet(this,Bp,`f`).configuration[`populate--`],H=Object.assign({},__classPrivateFieldGet(this,Bp,`f`).configuration,{"populate--":!0}),W=__classPrivateFieldGet(this,Yp,`f`).Parser.detailed(t,Object.assign({},__classPrivateFieldGet(this,Bp,`f`),{configuration:{"parse-positional-numbers":!1,...H}})),q=Object.assign(W.argv,__classPrivateFieldGet(this,Wp,`f`)),Y,X=W.aliases,Z=!1,te=!1;Object.keys(q).forEach(t=>{t===__classPrivateFieldGet(this,Ip,`f`)&&q[t]?Z=!0:t===__classPrivateFieldGet(this,tm,`f`)&&q[t]&&(te=!0)}),q.$0=this.$0,this.parsed=W,C===0&&__classPrivateFieldGet(this,$p,`f`).clearCachedHelpMessage();try{if(this[fm](),n)return this[Nm](q,I,!!S,!1);__classPrivateFieldGet(this,Ip,`f`)&&[__classPrivateFieldGet(this,Ip,`f`)].concat(X[__classPrivateFieldGet(this,Ip,`f`)]||[]).filter(t=>t.length>1).includes(``+q._[q._.length-1])&&(q._.pop(),Z=!0),__classPrivateFieldSet(this,Lp,!1,`f`);let H=__classPrivateFieldGet(this,Sp,`f`).getCommands(),ne=__classPrivateFieldGet(this,Tp,`f`)?.completionKey?[__classPrivateFieldGet(this,Tp,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Tp,`f`)?.completionKey]??[]].some(t=>Object.prototype.hasOwnProperty.call(q,t)):!1,re=Z||ne||N;if(q._.length){if(H.length){let t;for(let n=C||0,F;q._[n]!==void 0;n++)if(F=String(q._[n]),H.includes(F)&&F!==__classPrivateFieldGet(this,Ep,`f`)){let t=__classPrivateFieldGet(this,Sp,`f`).runCommand(F,this,W,n+1,N,Z||te||N);return this[Nm](t,I,!!S,!1)}else if(!t&&F!==__classPrivateFieldGet(this,Ep,`f`)){t=F;break}!__classPrivateFieldGet(this,Sp,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,Jp,`f`)&&t&&!re&&__classPrivateFieldGet(this,nm,`f`).recommendCommands(t,H)}__classPrivateFieldGet(this,Ep,`f`)&&q._.includes(__classPrivateFieldGet(this,Ep,`f`))&&!ne&&(__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,Sp,`f`).hasDefaultCommand()&&!re){let t=__classPrivateFieldGet(this,Sp,`f`).runCommand(null,this,W,0,N,Z||te||N);return this[Nm](t,I,!!S,!1)}if(ne){__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),t=[].concat(t);let n=t.slice(t.indexOf(`--${__classPrivateFieldGet(this,Tp,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Tp,`f`).getCompletion(n,(t,n)=>{if(t)throw new Sl(t.message);(n||[]).forEach(t=>{__classPrivateFieldGet(this,Rp,`f`).log(t)}),this.exit(0)}),this[Nm](q,!I,!!S,!1)}if(__classPrivateFieldGet(this,Fp,`f`)||(Z?(__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),F=!0,this.showHelp(t=>{__classPrivateFieldGet(this,Rp,`f`).log(t),this.exit(0)})):te&&(__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),F=!0,__classPrivateFieldGet(this,$p,`f`).showVersion(`log`),this.exit(0))),!F&&__classPrivateFieldGet(this,Bp,`f`).skipValidation.length>0&&(F=Object.keys(q).some(t=>__classPrivateFieldGet(this,Bp,`f`).skipValidation.indexOf(t)>=0&&q[t]===!0)),!F){if(W.error)throw new Sl(W.error.message);if(!ne){let t=this[Lm](X,{},W.error);S||(Y=applyMiddleware(q,this,__classPrivateFieldGet(this,Np,`f`).getMiddleware(),!0)),Y=this[Cm](t,Y??q),isPromise(Y)&&!S&&(Y=Y.then(()=>applyMiddleware(q,this,__classPrivateFieldGet(this,Np,`f`).getMiddleware(),!1)))}}}catch(t){if(t instanceof Sl)__classPrivateFieldGet(this,$p,`f`).fail(t.message,t);else throw t}return this[Nm](Y??q,I,!!S,!0)}[Lm](t,n,S,C){let N={...this.getDemandedOptions()};return F=>{if(S)throw new Sl(S.message);__classPrivateFieldGet(this,nm,`f`).nonOptionCount(F),__classPrivateFieldGet(this,nm,`f`).requiredArguments(F,N);let I=!1;__classPrivateFieldGet(this,Zp,`f`)&&(I=__classPrivateFieldGet(this,nm,`f`).unknownCommands(F)),__classPrivateFieldGet(this,Xp,`f`)&&!I?__classPrivateFieldGet(this,nm,`f`).unknownArguments(F,t,n,!!C):__classPrivateFieldGet(this,Qp,`f`)&&__classPrivateFieldGet(this,nm,`f`).unknownArguments(F,t,{},!1,!1),__classPrivateFieldGet(this,nm,`f`).limitedChoices(F),__classPrivateFieldGet(this,nm,`f`).implications(F),__classPrivateFieldGet(this,nm,`f`).conflicting(F)}}[Rm](){__classPrivateFieldSet(this,Fp,!0,`f`)}[zm](t){if(typeof t==`string`)__classPrivateFieldGet(this,Bp,`f`).key[t]=!0;else for(let n of t)__classPrivateFieldGet(this,Bp,`f`).key[n]=!0}}}),Hm,Um=__esmMin(()=>{ep(),Vm(),Hm=YargsFactory($f)});function classifyCliFailure(t,n){return typeof t==`string`&&t.length>0?{kind:`usage`,message:t}:{kind:`runtime`}}var Wm=__esmMin(()=>{});function buildHeaders(t,n){let S={"user-agent":`gjsify-install/0.64.2-next.253`,"accept-encoding":n.acceptEncoding??`identity`};if(n.npmrc){let C=resolveAuthForUrl(t,n.npmrc);C&&(S.authorization=C)}if(n.headers)for(let[t,C]of Object.entries(n.headers))S[t.toLowerCase()]=C;return S}function resolveAuthForUrl(t,n){let S=pathPrefixes(new URL(t));for(let t of S){let S=n.authTokens[t];if(S)return`Bearer ${S}`;let C=n.basicAuth[t];if(C)return`Basic ${btoa(`${C.username}:${C.password}`)}`}return null}function pathPrefixes(t){let n=t.pathname.split(`/`).filter(Boolean),S=[];for(let C=n.length;C>=0;C--){let N=n.slice(0,C).join(`/`);S.push(N?`//${t.host}/${N}`:`//${t.host}`)}return S}var Gm=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,Km=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(t,n){super(`Package not found in registry: ${t} (${n})`),this.name=t,this.url=n,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(t,n){super(`Tarball integrity mismatch for ${t} (expected ${n})`),this.url=t,this.integrity=n,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(t,n,S){let C=Math.round(n/100)/10,N=Math.round(n*S/100)/10;super(`@gjsify/npm-registry: GET ${t} timed out after ${C}s × ${S} attempt(s) (total ~${N}s). This usually means the registry CDN is slow or unreachable.`),this.url=t,this.timeoutMs=n,this.attempts=S,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(t,n,S,C){let N=Math.round(S/100)/10,F=C instanceof Error?C.message:String(C);super(`@gjsify/npm-registry: GET ${t} failed after ${n} attempt(s) over ~${N}s: ${F}. This usually means the registry or the network dropped out.`),this.url=t,this.attempts=n,this.elapsedMs=S,this.name=`RegistryUnreachableError`,this.cause=C}}});function registryFor(t,n){if(n&&t.startsWith(`@`)){let S=t.slice(0,t.indexOf(`/`)),C=n.scopes[S];if(C)return ensureTrailingSlash$1(C)}return n?.registry?ensureTrailingSlash$1(n.registry):qm}function parseNpmrc(t){let n={registry:qm,scopes:{},authTokens:{},basicAuth:{}},S=t.split(/\r?\n/),C={};for(let t of S){let S=t.replace(/^\s+|\s+$/g,``);if(!S||S.startsWith(`#`)||S.startsWith(`;`))continue;let N=S.indexOf(`=`);if(N<0)continue;let F=S.slice(0,N).trim(),I=expandEnv(stripQuotes(S.slice(N+1).trim()));if(F===`registry`){n.registry=ensureTrailingSlash$1(I);continue}let H=F.match(/^(@[^:]+):registry$/);if(H){n.scopes[H[1]]=ensureTrailingSlash$1(I);continue}let W=F.match(/^\/\/(.+):_authToken$/);if(W){n.authTokens[normalizeAuthHost(W[1])]=I;continue}let q=F.match(/^\/\/(.+):username$/);if(q){(C[normalizeAuthHost(q[1])]??={}).user=I;continue}let Y=F.match(/^\/\/(.+):_password$/);if(Y){let t=base64Decode$1(I);(C[normalizeAuthHost(Y[1])]??={}).pass=t;continue}}for(let[t,S]of Object.entries(C))S.user&&S.pass!==void 0&&(n.basicAuth[t]={username:S.user,password:S.pass});return n}function normalizeAuthHost(t){return`//${t.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(t){return t.endsWith(`/`)?t:t+`/`}function stripQuotes(t){return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function expandEnv(t){return t.replace(/\$\{([A-Z0-9_]+)\}/gi,(t,n)=>globalThis.process?.env?.[n]??``)}function base64Decode$1(t){return atob(t)}var qm,Jm=__esmMin(()=>{qm=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(t,n,S){let C=S.fetch??globalThis.fetch;if(!C)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let N=Math.max(0,S.retries??5),F=Math.max(0,S.retryDelayMs??1e3),I=Math.max(0,S.timeoutMs??3e4),H=S.retryNotFound??!1,W=Date.now(),q=0,Y,X=0;for(;;){if(n.signal?.aborted)throw signalAbortError(n.signal);let Z=I>0?new AbortController:null,te=Z===null?null:setTimeout(()=>Z.abort(Error(`@gjsify/npm-registry: per-request timeout ${I}ms`)),I),ne=composeSignals(n.signal,Z?.signal);try{let F=await C(t,{...n,signal:ne}),I=isRetryableStatus(F.status)||H&&F.status===404;if(F.ok||!I||q>=N)return S.read?await S.read(F):F;try{await F.arrayBuffer()}catch{}Y=Error(`HTTP ${F.status} ${F.statusText}`)}catch(S){let C=Z!==null&&Z.signal.aborted,F=n.signal?.aborted===!0;if(C&&!F){if(X++,q>=N)throw new RegistryTimeoutError(t,I,X);Y=S}else if(F)throw signalAbortError(n.signal);else{if(!isRetryableError(S))throw S;if(q>=N)throw new RegistryUnreachableError(t,q+1,Date.now()-W,S);Y=S}}finally{te!==null&&clearTimeout(te)}let re=Math.min(F*2**q,8e3);S.onRetry?.({attempt:q+1,error:Y,delayMs:re}),await delay$1(re,n.signal),q++}}function composeSignals(t,n){return t?n?AbortSignal.any([t,n]):t:n}function isRetryableStatus(t){return t===408||t===425||t===429||t===500||t===502||t===503||t===504||t===521||t===522||t===524||t===525}function isRetryableError(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return!1;if(t instanceof TypeError)return!0;if(t&&typeof t==`object`&&`name`in t){let n=t.name;if(n===`FetchError`)return!0;if(n===`AbortError`)return!1}let n=t?.cause;if(n&&typeof n==`object`&&`code`in n){let t=n.code;if(typeof t==`string`)return t===`ECONNRESET`||t===`ECONNREFUSED`||t===`ENETUNREACH`||t===`ENOTFOUND`||t===`ETIMEDOUT`||t===`EAI_AGAIN`||t===`UND_ERR_SOCKET`||t===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(t,n){return t<=0?Promise.resolve():new Promise((S,C)=>{let N=setTimeout(()=>{n?.removeEventListener?.(`abort`,onAbort),S()},t),onAbort=()=>{clearTimeout(N),C(signalAbortError(n))};if(n?.aborted){clearTimeout(N),C(signalAbortError(n));return}n?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(t){let n=t&&`reason`in t?t.reason:void 0;if(n instanceof Error)return n;let S=Error(`Aborted`);return S.name=`AbortError`,S}var Ym=__esmMin(()=>{Km(),__name$1(delay$1,`delay`)});async function verifyIntegrity(t,n){let S=n.trim().split(/\s+/);for(let n of S){let S=n.indexOf(`-`);if(S<0)continue;let C=n.slice(0,S).toLowerCase(),N=n.slice(S+1),F=globalThis.crypto?.subtle;if(!F)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let I=subriToWebCryptoAlgo(C);if(!I)continue;let H=await F.digest(I,dataAsArrayBuffer(t));if(bytesToBase64(new Uint8Array(H))===N)return!0}return!1}function subriToWebCryptoAlgo(t){switch(t){case`sha1`:return`SHA-1`;case`sha256`:return`SHA-256`;case`sha384`:return`SHA-384`;case`sha512`:return`SHA-512`;default:return null}}function dataAsArrayBuffer(t){if(t.byteOffset===0&&t.byteLength===t.buffer.byteLength)return t.buffer;let n=new Uint8Array(t.byteLength);return n.set(t),n.buffer}function bytesToBase64(t){let n=``;for(let S=0;S<t.length;S++)n+=String.fromCharCode(t[S]);return btoa(n)}var Xm=__esmMin(()=>{});function assertPackument(t,n){if(!n||typeof n!=`object`)throw TypeError(`registry: ${t} packument is not an object`);let S=n;if(typeof S.name!=`string`)throw TypeError(`registry: ${t} packument missing string name`);if(!S.versions||typeof S.versions!=`object`)throw TypeError(`registry: ${t} packument missing versions map`)}function packumentUrl(t,n){let S=ensureTrailingSlash$1(n);if(t.startsWith(`@`)){let n=t.indexOf(`/`);if(n<0)throw TypeError(`Invalid scoped package name: ${t}`);let C=t.slice(0,n),N=t.slice(n+1);return`${S}${encodeURIComponent(C)}/${encodeURIComponent(N)}`}return`${S}${encodeURIComponent(t)}`}async function fetchPackumentConditional(t,n={}){let S=packumentUrl(t,n.registry??registryFor(t,n.npmrc)),C=buildHeaders(S,{...n,acceptEncoding:`gzip`});C.accept??=n.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,n.ifNoneMatch&&(C[`if-none-match`]=n.ifNoneMatch);let N=await fetchWithRetry(S,{headers:C,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,read:async n=>{if(n.status===304){try{await n.arrayBuffer()}catch{}return{status:`not-modified`}}if(!n.ok)throw n.status===404||n.status===406?new PackageNotFoundError(t,S):Error(`registry GET ${S} -> ${n.status} ${n.statusText}`);return{status:`fresh`,body:await decodeJsonBody(n),etag:n.headers.get(`etag`)??void 0}}});if(N.status===`not-modified`)return{status:`not-modified`,etag:n.ifNoneMatch};let F=N.body;return assertPackument(t,F),{status:`fresh`,packument:F,etag:N.etag}}async function decodeJsonBody(t){return t.json()}async function fetchPackument(t,n={}){let S=await fetchPackumentConditional(t,n);if(!S.packument)throw Error(`registry: ${t} returned 304 Not Modified to an unconditional request`);return S.packument}var Zm=__esmMin(()=>{Gm(),Km(),Jm(),Ym()});async function fetchTarball(t,n={}){let S=buildHeaders(t,{...n,acceptEncoding:`identity`});S.accept??=`application/octet-stream`;let C=await fetchWithRetry(t,{headers:S,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,retryNotFound:n.retryNotFound??!0,read:async n=>{if(!n.ok)throw Error(`tarball GET ${t} -> ${n.status} ${n.statusText}`);return new Uint8Array(await n.arrayBuffer())}});if(n.integrity&&!await verifyIntegrity(C,n.integrity))throw new IntegrityError(t,n.integrity);return C}var Qm=__esmMin(()=>{Gm(),Km(),Ym(),Xm()});async function whoami(t,n){let S=`${ensureTrailingSlash$1(t)}-/whoami`,C=buildHeaders(S,{npmrc:n});C.accept=`application/json`;let N=globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=await N(S,{method:`GET`,headers:C});if(!F.ok)throw Error(`whoami GET ${S} -> ${F.status} ${F.statusText}`);let I=await F.json();if(I&&typeof I==`object`&&`username`in I){let t=I.username;if(typeof t==`string`&&t.length>0)return{username:t}}return{}}var $m=__esmMin(()=>{Gm(),Jm()}),eh=__esmMin(()=>{Gm(),Km(),Jm(),Xm(),Zm(),Qm(),$m()});function escapePackageName(t){return t.replace(`/`,`%2f`)}function buildPublishHeaders(t,n){let S=buildHeaders(t,{npmrc:n.npmrc});return S[`content-type`]=`application/json`,S[`npm-command`]=`publish`,S[`npm-auth-type`]=n.otp?`legacy`:`web`,S[`user-agent`]=n.userAgent??defaultUserAgent(),n.otp&&(S[`npm-otp`]=n.otp),n.authorization&&(S.authorization=n.authorization),S}function cliVersion(){return th===void 0&&(th=`0.64.2-next.253`),th}function cliPackageDir(){let t=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,n;try{n=En(t||fileURLToPath(import.meta.url))}catch{return null}for(let t=0;t<12;t++){try{if(JSON.parse(readFileSync(`${n}/package.json`,`utf8`)).name===`@gjsify/cli`)return n}catch{}let t=En(n);if(t===n)break;n=t}return null}function defaultUserAgent(){let t=globalThis.process,n=t?.arch??`x64`,S=t?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${S} ${n})`}var th,nh=__esmMin(()=>{Rd(),Pn(),Gn(),eh()}),rh,ih=__esmMin(()=>{rh=`gjsify`});function parseDeclaredChannel(t,n){if(!(t===void 0||t===``)){if(ah.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a distribution channel. Known: ${ah.join(`, `)}.`)}}function channelAllowsDonations(t){return t!==void 0&&oh[t]===!0}var ah,oh,sh,ch=__esmMin(()=>{ah=[`flathub`,`web`,`microsoft-store`,`apple-app-store`],oh={flathub:!0,web:!0,"microsoft-store":!1,"apple-app-store":!1},sh=`GJSIFY_CHANNEL`}),lh=__commonJSMin(((t,n)=>{let S=(Pn(),__toCommonJS(yn)),C=(Il(),__toCommonJS(Ml)),N=(Rd(),__toCommonJS(Id)),resolveFrom=(t,n,F)=>{if(typeof t!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof t}\``);if(typeof n!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof n}\``);try{t=N.realpathSync(t)}catch(n){if(n.code===`ENOENT`)t=S.resolve(t);else if(F)return null;else throw n}let I=S.join(t,`noop.js`),resolveFileName=()=>C._resolveFilename(n,{id:I,filename:I,paths:C._nodeModulePaths(t)});if(F)try{return resolveFileName()}catch{return null}return resolveFileName()};n.exports=(t,n)=>resolveFrom(t,n),n.exports.silent=(t,n)=>resolveFrom(t,n,!0)})),uh=__commonJSMin(((t,n)=>{let callsites=()=>{let t=Error.prepareStackTrace;Error.prepareStackTrace=(t,n)=>n;let n=Error().stack.slice(1);return Error.prepareStackTrace=t,n};n.exports=callsites,n.exports.default=callsites})),dh=__commonJSMin(((t,n)=>{let S=uh();n.exports=t=>{let n=S();if(!t)return n[2].getFileName();let C=!1;n.shift();for(let S of n){let n=S.getFileName();if(typeof n==`string`){if(n===t){C=!0;continue}if(n!==`module.js`&&C&&n!==t)return n}}}})),fh=__commonJSMin(((t,n)=>{var{__gjsifyModuleDir:S,__gjsifyModuleFile:C}=(Bl(),__toCommonJS(Ll)),N=S(`import-fresh/index.js`),F=C(`import-fresh/index.js`);let I=(Pn(),__toCommonJS(yn)),H=lh(),W=dh();n.exports=t=>{if(typeof t!=`string`)throw TypeError(`Expected a string`);let n=W(F),S=n?I.dirname(n):N,C=H(S,t),q=Y.cache[C];if(q&&q.parent){let t=q.parent.children.length;for(;t--;)q.parent.children[t].id===C&&q.parent.children.splice(t,1)}delete Y.cache[C];let X=Y.cache[n];return X===void 0||X.require===void 0?Y(C):X.require(C)}})),ph=__commonJSMin(((t,n)=>{n.exports=function isArrayish(t){return t?t instanceof Array||Array.isArray(t)||t.length>=0&&t.splice instanceof Function:!1}})),mh=__commonJSMin(((t,n)=>{var S=(Tu(),__toCommonJS(xu)),C=ph(),N=function errorEx(t,n){(!t||t.constructor!==String)&&(n=t||{},t=Error.name);var N=function ErrorEXError(S){if(!this)return new ErrorEXError(S);S=S instanceof Error?S.message:S||this.message,Error.call(this,S),Error.captureStackTrace(this,N),this.name=t,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var t=S.split(/\r?\n/g);for(var N in n)if(n.hasOwnProperty(N)){var F=n[N];`message`in F&&(t=F.message(this[N],t)||t,C(t)||(t=[t]))}return t.join(`
|
|
148
|
+
`,`f`),__classPrivateFieldSet(this,zp,__classPrivateFieldGet(this,zp,`f`)+t.join(` `),`f`)}}}[om](t){objectKeys(__classPrivateFieldGet(this,Bp,`f`)).forEach(n=>{if((t=>t===`configObjects`)(n))return;let S=__classPrivateFieldGet(this,Bp,`f`)[n];Array.isArray(S)?S.includes(t)&&S.splice(S.indexOf(t),1):typeof S==`object`&&delete S[t]}),delete __classPrivateFieldGet(this,$p,`f`).getDescriptions()[t]}[sm](t,n,S){__classPrivateFieldGet(this,Ap,`f`)[S]||(__classPrivateFieldGet(this,Yp,`f`).process.emitWarning(t,n),__classPrivateFieldGet(this,Ap,`f`)[S]=!0)}[cm](){__classPrivateFieldGet(this,Mp,`f`).push({options:__classPrivateFieldGet(this,Bp,`f`),configObjects:__classPrivateFieldGet(this,Bp,`f`).configObjects.slice(0),exitProcess:__classPrivateFieldGet(this,jp,`f`),groups:__classPrivateFieldGet(this,Pp,`f`),strict:__classPrivateFieldGet(this,Xp,`f`),strictCommands:__classPrivateFieldGet(this,Zp,`f`),strictOptions:__classPrivateFieldGet(this,Qp,`f`),completionCommand:__classPrivateFieldGet(this,Ep,`f`),output:__classPrivateFieldGet(this,zp,`f`),exitError:__classPrivateFieldGet(this,Op,`f`),hasOutput:__classPrivateFieldGet(this,Fp,`f`),parsed:this.parsed,parseFn:__classPrivateFieldGet(this,Up,`f`),parseContext:__classPrivateFieldGet(this,Wp,`f`)}),__classPrivateFieldGet(this,$p,`f`).freeze(),__classPrivateFieldGet(this,nm,`f`).freeze(),__classPrivateFieldGet(this,Sp,`f`).freeze(),__classPrivateFieldGet(this,Np,`f`).freeze()}[lm](){let t=``,n;return n=/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this,Yp,`f`).process.argv()[0])?__classPrivateFieldGet(this,Yp,`f`).process.argv().slice(1,2):__classPrivateFieldGet(this,Yp,`f`).process.argv().slice(0,1),t=n.map(t=>{let n=this[Pm](__classPrivateFieldGet(this,Cp,`f`),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&n.length<t.length?n:t}).join(` `).trim(),__classPrivateFieldGet(this,Yp,`f`).getEnv(`_`)&&__classPrivateFieldGet(this,Yp,`f`).getProcessArgvBin()===__classPrivateFieldGet(this,Yp,`f`).getEnv(`_`)&&(t=__classPrivateFieldGet(this,Yp,`f`).getEnv(`_`).replace(`${__classPrivateFieldGet(this,Yp,`f`).path.dirname(__classPrivateFieldGet(this,Yp,`f`).process.execPath())}/`,``)),t}[um](){return __classPrivateFieldGet(this,Hp,`f`)}[dm](){return __classPrivateFieldGet(this,em,`f`)}[fm](){if(!__classPrivateFieldGet(this,kp,`f`))return;let t=__classPrivateFieldGet(this,Yp,`f`).getEnv(`LC_ALL`)||__classPrivateFieldGet(this,Yp,`f`).getEnv(`LC_MESSAGES`)||__classPrivateFieldGet(this,Yp,`f`).getEnv(`LANG`)||__classPrivateFieldGet(this,Yp,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(t.replace(/[.:].*/,``))}[pm](){return this[hm]().version||`unknown`}[mm](t){let n=t[`--`]?t[`--`]:t._;for(let t=0,S;(S=n[t])!==void 0;t++)__classPrivateFieldGet(this,Yp,`f`).Parser.looksLikeNumber(S)&&Number.isSafeInteger(Math.floor(parseFloat(`${S}`)))&&(n[t]=Number(S));return t}[hm](t){let n=t||`*`;if(__classPrivateFieldGet(this,Gp,`f`)[n])return __classPrivateFieldGet(this,Gp,`f`)[n];let S={};try{let n=t||__classPrivateFieldGet(this,Yp,`f`).mainFilename;__classPrivateFieldGet(this,Yp,`f`).path.extname(n)&&(n=__classPrivateFieldGet(this,Yp,`f`).path.dirname(n));let C=__classPrivateFieldGet(this,Yp,`f`).findUp(n,(t,n)=>{if(n.includes(`package.json`))return`package.json`});assertNotStrictEqual(C,void 0,__classPrivateFieldGet(this,Yp,`f`)),S=JSON.parse(__classPrivateFieldGet(this,Yp,`f`).readFileSync(C,`utf8`))}catch{}return __classPrivateFieldGet(this,Gp,`f`)[n]=S||{},__classPrivateFieldGet(this,Gp,`f`)[n]}[gm](t,n){n=[].concat(n),n.forEach(n=>{n=this[bm](n),__classPrivateFieldGet(this,Bp,`f`)[t].push(n)})}[_m](t,n,S,C){this[ym](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Bp,`f`)[t][n]=S})}[vm](t,n,S,C){this[ym](t,n,S,C,(t,n,S)=>{__classPrivateFieldGet(this,Bp,`f`)[t][n]=(__classPrivateFieldGet(this,Bp,`f`)[t][n]||[]).concat(S)})}[ym](t,n,S,C,N){if(Array.isArray(S))S.forEach(n=>{t(n,C)});else if((t=>typeof t==`object`)(S))for(let n of objectKeys(S))t(n,S[n]);else N(n,this[bm](S),C)}[bm](t){return t===`__proto__`?`___proto___`:t}[xm](t,n){return this[_m](this[xm].bind(this),`key`,t,n),this}[Sm](){var t,n,S,C,N,F,I,H,W,q,Y,X;let Z=__classPrivateFieldGet(this,Mp,`f`).pop();assertNotStrictEqual(Z,void 0,__classPrivateFieldGet(this,Yp,`f`));let te;t=this,n=this,S=this,C=this,N=this,F=this,I=this,H=this,W=this,q=this,Y=this,X=this,{options:{set value(n){__classPrivateFieldSet(t,Bp,n,`f`)}}.value,configObjects:te,exitProcess:{set value(t){__classPrivateFieldSet(n,jp,t,`f`)}}.value,groups:{set value(t){__classPrivateFieldSet(S,Pp,t,`f`)}}.value,output:{set value(t){__classPrivateFieldSet(C,zp,t,`f`)}}.value,exitError:{set value(t){__classPrivateFieldSet(N,Op,t,`f`)}}.value,hasOutput:{set value(t){__classPrivateFieldSet(F,Fp,t,`f`)}}.value,parsed:this.parsed,strict:{set value(t){__classPrivateFieldSet(I,Xp,t,`f`)}}.value,strictCommands:{set value(t){__classPrivateFieldSet(H,Zp,t,`f`)}}.value,strictOptions:{set value(t){__classPrivateFieldSet(W,Qp,t,`f`)}}.value,completionCommand:{set value(t){__classPrivateFieldSet(q,Ep,t,`f`)}}.value,parseFn:{set value(t){__classPrivateFieldSet(Y,Up,t,`f`)}}.value,parseContext:{set value(t){__classPrivateFieldSet(X,Wp,t,`f`)}}.value}=Z,__classPrivateFieldGet(this,Bp,`f`).configObjects=te,__classPrivateFieldGet(this,$p,`f`).unfreeze(),__classPrivateFieldGet(this,nm,`f`).unfreeze(),__classPrivateFieldGet(this,Sp,`f`).unfreeze(),__classPrivateFieldGet(this,Np,`f`).unfreeze()}[Cm](t,n){return maybeAsyncResult(n,n=>(t(n),n))}getInternalMethods(){return{getCommandInstance:this[wm].bind(this),getContext:this[Tm].bind(this),getHasOutput:this[Em].bind(this),getLoggerInstance:this[Dm].bind(this),getParseContext:this[Om].bind(this),getParserConfiguration:this[um].bind(this),getUsageConfiguration:this[dm].bind(this),getUsageInstance:this[km].bind(this),getValidationInstance:this[Am].bind(this),hasParseCallback:this[jm].bind(this),isGlobalContext:this[Mm].bind(this),postProcess:this[Nm].bind(this),reset:this[Fm].bind(this),runValidation:this[Lm].bind(this),runYargsParserAndExecuteCommands:this[Im].bind(this),setHasOutput:this[Rm].bind(this)}}[wm](){return __classPrivateFieldGet(this,Sp,`f`)}[Tm](){return __classPrivateFieldGet(this,wp,`f`)}[Em](){return __classPrivateFieldGet(this,Fp,`f`)}[Dm](){return __classPrivateFieldGet(this,Rp,`f`)}[Om](){return __classPrivateFieldGet(this,Wp,`f`)||{}}[km](){return __classPrivateFieldGet(this,$p,`f`)}[Am](){return __classPrivateFieldGet(this,nm,`f`)}[jm](){return!!__classPrivateFieldGet(this,Up,`f`)}[Mm](){return __classPrivateFieldGet(this,Lp,`f`)}[Nm](t,n,S,C){return S||isPromise(t)?t:(n||(t=this[im](t)),(this[um]()[`parse-positional-numbers`]||this[um]()[`parse-positional-numbers`]===void 0)&&(t=this[mm](t)),C&&(t=applyMiddleware(t,this,__classPrivateFieldGet(this,Np,`f`).getMiddleware(),!1)),t)}[Fm](t={}){__classPrivateFieldSet(this,Bp,__classPrivateFieldGet(this,Bp,`f`)||{},`f`);let n={};n.local=__classPrivateFieldGet(this,Bp,`f`).local||[],n.configObjects=__classPrivateFieldGet(this,Bp,`f`).configObjects||[];let S={};return n.local.forEach(n=>{S[n]=!0,(t[n]||[]).forEach(t=>{S[t]=!0})}),Object.assign(__classPrivateFieldGet(this,Kp,`f`),Object.keys(__classPrivateFieldGet(this,Pp,`f`)).reduce((t,n)=>{let C=__classPrivateFieldGet(this,Pp,`f`)[n].filter(t=>!(t in S));return C.length>0&&(t[n]=C),t},{})),__classPrivateFieldSet(this,Pp,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(t=>{n[t]=(__classPrivateFieldGet(this,Bp,`f`)[t]||[]).filter(t=>!S[t])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(t=>{n[t]=objFilter(__classPrivateFieldGet(this,Bp,`f`)[t],t=>!S[t])}),n.envPrefix=__classPrivateFieldGet(this,Bp,`f`).envPrefix,__classPrivateFieldSet(this,Bp,n,`f`),__classPrivateFieldSet(this,$p,__classPrivateFieldGet(this,$p,`f`)?__classPrivateFieldGet(this,$p,`f`).reset(S):usage(this,__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldSet(this,nm,__classPrivateFieldGet(this,nm,`f`)?__classPrivateFieldGet(this,nm,`f`).reset(S):validation(this,__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldSet(this,Sp,__classPrivateFieldGet(this,Sp,`f`)?__classPrivateFieldGet(this,Sp,`f`).reset():command(__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,nm,`f`),__classPrivateFieldGet(this,Np,`f`),__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldGet(this,Tp,`f`)||__classPrivateFieldSet(this,Tp,completion(this,__classPrivateFieldGet(this,$p,`f`),__classPrivateFieldGet(this,Sp,`f`),__classPrivateFieldGet(this,Yp,`f`)),`f`),__classPrivateFieldGet(this,Np,`f`).reset(),__classPrivateFieldSet(this,Ep,null,`f`),__classPrivateFieldSet(this,zp,``,`f`),__classPrivateFieldSet(this,Op,null,`f`),__classPrivateFieldSet(this,Fp,!1,`f`),this.parsed=!1,this}[Pm](t,n){return __classPrivateFieldGet(this,Yp,`f`).path.relative(t,n)}[Im](t,n,S,C=0,N=!1){let F=!!S||N;t||=__classPrivateFieldGet(this,qp,`f`),__classPrivateFieldGet(this,Bp,`f`).__=__classPrivateFieldGet(this,Yp,`f`).y18n.__,__classPrivateFieldGet(this,Bp,`f`).configuration=this[um]();let I=!!__classPrivateFieldGet(this,Bp,`f`).configuration[`populate--`],H=Object.assign({},__classPrivateFieldGet(this,Bp,`f`).configuration,{"populate--":!0}),W=__classPrivateFieldGet(this,Yp,`f`).Parser.detailed(t,Object.assign({},__classPrivateFieldGet(this,Bp,`f`),{configuration:{"parse-positional-numbers":!1,...H}})),q=Object.assign(W.argv,__classPrivateFieldGet(this,Wp,`f`)),Y,X=W.aliases,Z=!1,te=!1;Object.keys(q).forEach(t=>{t===__classPrivateFieldGet(this,Ip,`f`)&&q[t]?Z=!0:t===__classPrivateFieldGet(this,tm,`f`)&&q[t]&&(te=!0)}),q.$0=this.$0,this.parsed=W,C===0&&__classPrivateFieldGet(this,$p,`f`).clearCachedHelpMessage();try{if(this[fm](),n)return this[Nm](q,I,!!S,!1);__classPrivateFieldGet(this,Ip,`f`)&&[__classPrivateFieldGet(this,Ip,`f`)].concat(X[__classPrivateFieldGet(this,Ip,`f`)]||[]).filter(t=>t.length>1).includes(``+q._[q._.length-1])&&(q._.pop(),Z=!0),__classPrivateFieldSet(this,Lp,!1,`f`);let H=__classPrivateFieldGet(this,Sp,`f`).getCommands(),ne=__classPrivateFieldGet(this,Tp,`f`)?.completionKey?[__classPrivateFieldGet(this,Tp,`f`)?.completionKey,...this.getAliases()[__classPrivateFieldGet(this,Tp,`f`)?.completionKey]??[]].some(t=>Object.prototype.hasOwnProperty.call(q,t)):!1,re=Z||ne||N;if(q._.length){if(H.length){let t;for(let n=C||0,F;q._[n]!==void 0;n++)if(F=String(q._[n]),H.includes(F)&&F!==__classPrivateFieldGet(this,Ep,`f`)){let t=__classPrivateFieldGet(this,Sp,`f`).runCommand(F,this,W,n+1,N,Z||te||N);return this[Nm](t,I,!!S,!1)}else if(!t&&F!==__classPrivateFieldGet(this,Ep,`f`)){t=F;break}!__classPrivateFieldGet(this,Sp,`f`).hasDefaultCommand()&&__classPrivateFieldGet(this,Jp,`f`)&&t&&!re&&__classPrivateFieldGet(this,nm,`f`).recommendCommands(t,H)}__classPrivateFieldGet(this,Ep,`f`)&&q._.includes(__classPrivateFieldGet(this,Ep,`f`))&&!ne&&(__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),this.showCompletionScript(),this.exit(0))}if(__classPrivateFieldGet(this,Sp,`f`).hasDefaultCommand()&&!re){let t=__classPrivateFieldGet(this,Sp,`f`).runCommand(null,this,W,0,N,Z||te||N);return this[Nm](t,I,!!S,!1)}if(ne){__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),t=[].concat(t);let n=t.slice(t.indexOf(`--${__classPrivateFieldGet(this,Tp,`f`).completionKey}`)+1);return __classPrivateFieldGet(this,Tp,`f`).getCompletion(n,(t,n)=>{if(t)throw new Sl(t.message);(n||[]).forEach(t=>{__classPrivateFieldGet(this,Rp,`f`).log(t)}),this.exit(0)}),this[Nm](q,!I,!!S,!1)}if(__classPrivateFieldGet(this,Fp,`f`)||(Z?(__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),F=!0,this.showHelp(t=>{__classPrivateFieldGet(this,Rp,`f`).log(t),this.exit(0)})):te&&(__classPrivateFieldGet(this,jp,`f`)&&setBlocking(!0),F=!0,__classPrivateFieldGet(this,$p,`f`).showVersion(`log`),this.exit(0))),!F&&__classPrivateFieldGet(this,Bp,`f`).skipValidation.length>0&&(F=Object.keys(q).some(t=>__classPrivateFieldGet(this,Bp,`f`).skipValidation.indexOf(t)>=0&&q[t]===!0)),!F){if(W.error)throw new Sl(W.error.message);if(!ne){let t=this[Lm](X,{},W.error);S||(Y=applyMiddleware(q,this,__classPrivateFieldGet(this,Np,`f`).getMiddleware(),!0)),Y=this[Cm](t,Y??q),isPromise(Y)&&!S&&(Y=Y.then(()=>applyMiddleware(q,this,__classPrivateFieldGet(this,Np,`f`).getMiddleware(),!1)))}}}catch(t){if(t instanceof Sl)__classPrivateFieldGet(this,$p,`f`).fail(t.message,t);else throw t}return this[Nm](Y??q,I,!!S,!0)}[Lm](t,n,S,C){let N={...this.getDemandedOptions()};return F=>{if(S)throw new Sl(S.message);__classPrivateFieldGet(this,nm,`f`).nonOptionCount(F),__classPrivateFieldGet(this,nm,`f`).requiredArguments(F,N);let I=!1;__classPrivateFieldGet(this,Zp,`f`)&&(I=__classPrivateFieldGet(this,nm,`f`).unknownCommands(F)),__classPrivateFieldGet(this,Xp,`f`)&&!I?__classPrivateFieldGet(this,nm,`f`).unknownArguments(F,t,n,!!C):__classPrivateFieldGet(this,Qp,`f`)&&__classPrivateFieldGet(this,nm,`f`).unknownArguments(F,t,{},!1,!1),__classPrivateFieldGet(this,nm,`f`).limitedChoices(F),__classPrivateFieldGet(this,nm,`f`).implications(F),__classPrivateFieldGet(this,nm,`f`).conflicting(F)}}[Rm](){__classPrivateFieldSet(this,Fp,!0,`f`)}[zm](t){if(typeof t==`string`)__classPrivateFieldGet(this,Bp,`f`).key[t]=!0;else for(let n of t)__classPrivateFieldGet(this,Bp,`f`).key[n]=!0}}}),Hm,Um=__esmMin(()=>{ep(),Vm(),Hm=YargsFactory($f)});function classifyCliFailure(t,n){return typeof t==`string`&&t.length>0?{kind:`usage`,message:t}:{kind:`runtime`}}var Wm=__esmMin(()=>{});function buildHeaders(t,n){let S={"user-agent":`gjsify-install/0.64.2-next.255`,"accept-encoding":n.acceptEncoding??`identity`};if(n.npmrc){let C=resolveAuthForUrl(t,n.npmrc);C&&(S.authorization=C)}if(n.headers)for(let[t,C]of Object.entries(n.headers))S[t.toLowerCase()]=C;return S}function resolveAuthForUrl(t,n){let S=pathPrefixes(new URL(t));for(let t of S){let S=n.authTokens[t];if(S)return`Bearer ${S}`;let C=n.basicAuth[t];if(C)return`Basic ${btoa(`${C.username}:${C.password}`)}`}return null}function pathPrefixes(t){let n=t.pathname.split(`/`).filter(Boolean),S=[];for(let C=n.length;C>=0;C--){let N=n.slice(0,C).join(`/`);S.push(N?`//${t.host}/${N}`:`//${t.host}`)}return S}var Gm=__esmMin(()=>{}),PackageNotFoundError,IntegrityError,RegistryTimeoutError,RegistryUnreachableError,Km=__esmMin(()=>{PackageNotFoundError=class extends Error{name;url;constructor(t,n){super(`Package not found in registry: ${t} (${n})`),this.name=t,this.url=n,this.name=`PackageNotFoundError`}},IntegrityError=class extends Error{url;integrity;constructor(t,n){super(`Tarball integrity mismatch for ${t} (expected ${n})`),this.url=t,this.integrity=n,this.name=`IntegrityError`}},RegistryTimeoutError=class extends Error{url;timeoutMs;attempts;constructor(t,n,S){let C=Math.round(n/100)/10,N=Math.round(n*S/100)/10;super(`@gjsify/npm-registry: GET ${t} timed out after ${C}s × ${S} attempt(s) (total ~${N}s). This usually means the registry CDN is slow or unreachable.`),this.url=t,this.timeoutMs=n,this.attempts=S,this.name=`RegistryTimeoutError`}},RegistryUnreachableError=class extends Error{url;attempts;elapsedMs;constructor(t,n,S,C){let N=Math.round(S/100)/10,F=C instanceof Error?C.message:String(C);super(`@gjsify/npm-registry: GET ${t} failed after ${n} attempt(s) over ~${N}s: ${F}. This usually means the registry or the network dropped out.`),this.url=t,this.attempts=n,this.elapsedMs=S,this.name=`RegistryUnreachableError`,this.cause=C}}});function registryFor(t,n){if(n&&t.startsWith(`@`)){let S=t.slice(0,t.indexOf(`/`)),C=n.scopes[S];if(C)return ensureTrailingSlash$1(C)}return n?.registry?ensureTrailingSlash$1(n.registry):qm}function parseNpmrc(t){let n={registry:qm,scopes:{},authTokens:{},basicAuth:{}},S=t.split(/\r?\n/),C={};for(let t of S){let S=t.replace(/^\s+|\s+$/g,``);if(!S||S.startsWith(`#`)||S.startsWith(`;`))continue;let N=S.indexOf(`=`);if(N<0)continue;let F=S.slice(0,N).trim(),I=expandEnv(stripQuotes(S.slice(N+1).trim()));if(F===`registry`){n.registry=ensureTrailingSlash$1(I);continue}let H=F.match(/^(@[^:]+):registry$/);if(H){n.scopes[H[1]]=ensureTrailingSlash$1(I);continue}let W=F.match(/^\/\/(.+):_authToken$/);if(W){n.authTokens[normalizeAuthHost(W[1])]=I;continue}let q=F.match(/^\/\/(.+):username$/);if(q){(C[normalizeAuthHost(q[1])]??={}).user=I;continue}let Y=F.match(/^\/\/(.+):_password$/);if(Y){let t=base64Decode$1(I);(C[normalizeAuthHost(Y[1])]??={}).pass=t;continue}}for(let[t,S]of Object.entries(C))S.user&&S.pass!==void 0&&(n.basicAuth[t]={username:S.user,password:S.pass});return n}function normalizeAuthHost(t){return`//${t.replace(/\/+$/,``)}`}function ensureTrailingSlash$1(t){return t.endsWith(`/`)?t:t+`/`}function stripQuotes(t){return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1):t}function expandEnv(t){return t.replace(/\$\{([A-Z0-9_]+)\}/gi,(t,n)=>globalThis.process?.env?.[n]??``)}function base64Decode$1(t){return atob(t)}var qm,Jm=__esmMin(()=>{qm=`https://registry.npmjs.org/`,__name$1(ensureTrailingSlash$1,`ensureTrailingSlash`),__name$1(base64Decode$1,`base64Decode`)});async function fetchWithRetry(t,n,S){let C=S.fetch??globalThis.fetch;if(!C)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let N=Math.max(0,S.retries??5),F=Math.max(0,S.retryDelayMs??1e3),I=Math.max(0,S.timeoutMs??3e4),H=S.retryNotFound??!1,W=Date.now(),q=0,Y,X=0;for(;;){if(n.signal?.aborted)throw signalAbortError(n.signal);let Z=I>0?new AbortController:null,te=Z===null?null:setTimeout(()=>Z.abort(Error(`@gjsify/npm-registry: per-request timeout ${I}ms`)),I),ne=composeSignals(n.signal,Z?.signal);try{let F=await C(t,{...n,signal:ne}),I=isRetryableStatus(F.status)||H&&F.status===404;if(F.ok||!I||q>=N)return S.read?await S.read(F):F;try{await F.arrayBuffer()}catch{}Y=Error(`HTTP ${F.status} ${F.statusText}`)}catch(S){let C=Z!==null&&Z.signal.aborted,F=n.signal?.aborted===!0;if(C&&!F){if(X++,q>=N)throw new RegistryTimeoutError(t,I,X);Y=S}else if(F)throw signalAbortError(n.signal);else{if(!isRetryableError(S))throw S;if(q>=N)throw new RegistryUnreachableError(t,q+1,Date.now()-W,S);Y=S}}finally{te!==null&&clearTimeout(te)}let re=Math.min(F*2**q,8e3);S.onRetry?.({attempt:q+1,error:Y,delayMs:re}),await delay$1(re,n.signal),q++}}function composeSignals(t,n){return t?n?AbortSignal.any([t,n]):t:n}function isRetryableStatus(t){return t===408||t===425||t===429||t===500||t===502||t===503||t===504||t===521||t===522||t===524||t===525}function isRetryableError(t){if(t&&typeof t==`object`&&`name`in t&&t.name===`AbortError`)return!1;if(t instanceof TypeError)return!0;if(t&&typeof t==`object`&&`name`in t){let n=t.name;if(n===`FetchError`)return!0;if(n===`AbortError`)return!1}let n=t?.cause;if(n&&typeof n==`object`&&`code`in n){let t=n.code;if(typeof t==`string`)return t===`ECONNRESET`||t===`ECONNREFUSED`||t===`ENETUNREACH`||t===`ENOTFOUND`||t===`ETIMEDOUT`||t===`EAI_AGAIN`||t===`UND_ERR_SOCKET`||t===`UND_ERR_CONNECT_TIMEOUT`}return!1}function delay$1(t,n){return t<=0?Promise.resolve():new Promise((S,C)=>{let N=setTimeout(()=>{n?.removeEventListener?.(`abort`,onAbort),S()},t),onAbort=()=>{clearTimeout(N),C(signalAbortError(n))};if(n?.aborted){clearTimeout(N),C(signalAbortError(n));return}n?.addEventListener?.(`abort`,onAbort,{once:!0})})}function signalAbortError(t){let n=t&&`reason`in t?t.reason:void 0;if(n instanceof Error)return n;let S=Error(`Aborted`);return S.name=`AbortError`,S}var Ym=__esmMin(()=>{Km(),__name$1(delay$1,`delay`)});async function verifyIntegrity(t,n){let S=n.trim().split(/\s+/);for(let n of S){let S=n.indexOf(`-`);if(S<0)continue;let C=n.slice(0,S).toLowerCase(),N=n.slice(S+1),F=globalThis.crypto?.subtle;if(!F)throw Error(`@gjsify/npm-registry: globalThis.crypto.subtle is missing`);let I=subriToWebCryptoAlgo(C);if(!I)continue;let H=await F.digest(I,dataAsArrayBuffer(t));if(bytesToBase64(new Uint8Array(H))===N)return!0}return!1}function subriToWebCryptoAlgo(t){switch(t){case`sha1`:return`SHA-1`;case`sha256`:return`SHA-256`;case`sha384`:return`SHA-384`;case`sha512`:return`SHA-512`;default:return null}}function dataAsArrayBuffer(t){if(t.byteOffset===0&&t.byteLength===t.buffer.byteLength)return t.buffer;let n=new Uint8Array(t.byteLength);return n.set(t),n.buffer}function bytesToBase64(t){let n=``;for(let S=0;S<t.length;S++)n+=String.fromCharCode(t[S]);return btoa(n)}var Xm=__esmMin(()=>{});function assertPackument(t,n){if(!n||typeof n!=`object`)throw TypeError(`registry: ${t} packument is not an object`);let S=n;if(typeof S.name!=`string`)throw TypeError(`registry: ${t} packument missing string name`);if(!S.versions||typeof S.versions!=`object`)throw TypeError(`registry: ${t} packument missing versions map`)}function packumentUrl(t,n){let S=ensureTrailingSlash$1(n);if(t.startsWith(`@`)){let n=t.indexOf(`/`);if(n<0)throw TypeError(`Invalid scoped package name: ${t}`);let C=t.slice(0,n),N=t.slice(n+1);return`${S}${encodeURIComponent(C)}/${encodeURIComponent(N)}`}return`${S}${encodeURIComponent(t)}`}async function fetchPackumentConditional(t,n={}){let S=packumentUrl(t,n.registry??registryFor(t,n.npmrc)),C=buildHeaders(S,{...n,acceptEncoding:`gzip`});C.accept??=n.fullMetadata?`application/json`:`application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*`,n.ifNoneMatch&&(C[`if-none-match`]=n.ifNoneMatch);let N=await fetchWithRetry(S,{headers:C,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,read:async n=>{if(n.status===304){try{await n.arrayBuffer()}catch{}return{status:`not-modified`}}if(!n.ok)throw n.status===404||n.status===406?new PackageNotFoundError(t,S):Error(`registry GET ${S} -> ${n.status} ${n.statusText}`);return{status:`fresh`,body:await decodeJsonBody(n),etag:n.headers.get(`etag`)??void 0}}});if(N.status===`not-modified`)return{status:`not-modified`,etag:n.ifNoneMatch};let F=N.body;return assertPackument(t,F),{status:`fresh`,packument:F,etag:N.etag}}async function decodeJsonBody(t){return t.json()}async function fetchPackument(t,n={}){let S=await fetchPackumentConditional(t,n);if(!S.packument)throw Error(`registry: ${t} returned 304 Not Modified to an unconditional request`);return S.packument}var Zm=__esmMin(()=>{Gm(),Km(),Jm(),Ym()});async function fetchTarball(t,n={}){let S=buildHeaders(t,{...n,acceptEncoding:`identity`});S.accept??=`application/octet-stream`;let C=await fetchWithRetry(t,{headers:S,signal:n.signal},{fetch:n.fetch,retries:n.retries,retryDelayMs:n.retryDelayMs,timeoutMs:n.timeoutMs,onRetry:n.onRetry,retryNotFound:n.retryNotFound??!0,read:async n=>{if(!n.ok)throw Error(`tarball GET ${t} -> ${n.status} ${n.statusText}`);return new Uint8Array(await n.arrayBuffer())}});if(n.integrity&&!await verifyIntegrity(C,n.integrity))throw new IntegrityError(t,n.integrity);return C}var Qm=__esmMin(()=>{Gm(),Km(),Ym(),Xm()});async function whoami(t,n){let S=`${ensureTrailingSlash$1(t)}-/whoami`,C=buildHeaders(S,{npmrc:n});C.accept=`application/json`;let N=globalThis.fetch;if(!N)throw Error(`@gjsify/npm-registry: globalThis.fetch is missing`);let F=await N(S,{method:`GET`,headers:C});if(!F.ok)throw Error(`whoami GET ${S} -> ${F.status} ${F.statusText}`);let I=await F.json();if(I&&typeof I==`object`&&`username`in I){let t=I.username;if(typeof t==`string`&&t.length>0)return{username:t}}return{}}var $m=__esmMin(()=>{Gm(),Jm()}),eh=__esmMin(()=>{Gm(),Km(),Jm(),Xm(),Zm(),Qm(),$m()});function escapePackageName(t){return t.replace(`/`,`%2f`)}function buildPublishHeaders(t,n){let S=buildHeaders(t,{npmrc:n.npmrc});return S[`content-type`]=`application/json`,S[`npm-command`]=`publish`,S[`npm-auth-type`]=n.otp?`legacy`:`web`,S[`user-agent`]=n.userAgent??defaultUserAgent(),n.otp&&(S[`npm-otp`]=n.otp),n.authorization&&(S.authorization=n.authorization),S}function cliVersion(){return th===void 0&&(th=`0.64.2-next.255`),th}function cliPackageDir(){let t=globalThis.process?.env?.GJSIFY_CLI_PACKAGE_JSON,n;try{n=En(t||fileURLToPath(import.meta.url))}catch{return null}for(let t=0;t<12;t++){try{if(JSON.parse(readFileSync(`${n}/package.json`,`utf8`)).name===`@gjsify/cli`)return n}catch{}let t=En(n);if(t===n)break;n=t}return null}function defaultUserAgent(){let t=globalThis.process,n=t?.arch??`x64`,S=t?.platform??`linux`;return`gjsify-publish/${cliVersion()} (${S} ${n})`}var th,nh=__esmMin(()=>{Rd(),Pn(),Gn(),eh()}),rh,ih=__esmMin(()=>{rh=`gjsify`});function parseDeclaredChannel(t,n){if(!(t===void 0||t===``)){if(ah.includes(t))return t;throw Error(`${n}: "${String(t)}" is not a distribution channel. Known: ${ah.join(`, `)}.`)}}function channelAllowsDonations(t){return t!==void 0&&oh[t]===!0}var ah,oh,sh,ch=__esmMin(()=>{ah=[`flathub`,`web`,`microsoft-store`,`apple-app-store`],oh={flathub:!0,web:!0,"microsoft-store":!1,"apple-app-store":!1},sh=`GJSIFY_CHANNEL`}),lh=__commonJSMin(((t,n)=>{let S=(Pn(),__toCommonJS(yn)),C=(Il(),__toCommonJS(Ml)),N=(Rd(),__toCommonJS(Id)),resolveFrom=(t,n,F)=>{if(typeof t!=`string`)throw TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof t}\``);if(typeof n!=`string`)throw TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof n}\``);try{t=N.realpathSync(t)}catch(n){if(n.code===`ENOENT`)t=S.resolve(t);else if(F)return null;else throw n}let I=S.join(t,`noop.js`),resolveFileName=()=>C._resolveFilename(n,{id:I,filename:I,paths:C._nodeModulePaths(t)});if(F)try{return resolveFileName()}catch{return null}return resolveFileName()};n.exports=(t,n)=>resolveFrom(t,n),n.exports.silent=(t,n)=>resolveFrom(t,n,!0)})),uh=__commonJSMin(((t,n)=>{let callsites=()=>{let t=Error.prepareStackTrace;Error.prepareStackTrace=(t,n)=>n;let n=Error().stack.slice(1);return Error.prepareStackTrace=t,n};n.exports=callsites,n.exports.default=callsites})),dh=__commonJSMin(((t,n)=>{let S=uh();n.exports=t=>{let n=S();if(!t)return n[2].getFileName();let C=!1;n.shift();for(let S of n){let n=S.getFileName();if(typeof n==`string`){if(n===t){C=!0;continue}if(n!==`module.js`&&C&&n!==t)return n}}}})),fh=__commonJSMin(((t,n)=>{var{__gjsifyModuleDir:S,__gjsifyModuleFile:C}=(Bl(),__toCommonJS(Ll)),N=S(`import-fresh/index.js`),F=C(`import-fresh/index.js`);let I=(Pn(),__toCommonJS(yn)),H=lh(),W=dh();n.exports=t=>{if(typeof t!=`string`)throw TypeError(`Expected a string`);let n=W(F),S=n?I.dirname(n):N,C=H(S,t),q=Y.cache[C];if(q&&q.parent){let t=q.parent.children.length;for(;t--;)q.parent.children[t].id===C&&q.parent.children.splice(t,1)}delete Y.cache[C];let X=Y.cache[n];return X===void 0||X.require===void 0?Y(C):X.require(C)}})),ph=__commonJSMin(((t,n)=>{n.exports=function isArrayish(t){return t?t instanceof Array||Array.isArray(t)||t.length>=0&&t.splice instanceof Function:!1}})),mh=__commonJSMin(((t,n)=>{var S=(Tu(),__toCommonJS(xu)),C=ph(),N=function errorEx(t,n){(!t||t.constructor!==String)&&(n=t||{},t=Error.name);var N=function ErrorEXError(S){if(!this)return new ErrorEXError(S);S=S instanceof Error?S.message:S||this.message,Error.call(this,S),Error.captureStackTrace(this,N),this.name=t,Object.defineProperty(this,"message",{configurable:!0,enumerable:!1,get:function(){var t=S.split(/\r?\n/g);for(var N in n)if(n.hasOwnProperty(N)){var F=n[N];`message`in F&&(t=F.message(this[N],t)||t,C(t)||(t=[t]))}return t.join(`
|
|
149
149
|
`)},set:function(t){S=t}});var F=null,I=Object.getOwnPropertyDescriptor(this,`stack`),H=I.get,W=I.value;delete I.value,delete I.writable,I.set=function(t){F=t},I.get=function(){var t=(F||(H?H.call(this):W)).split(/\r?\n+/g);F||(t[0]=this.name+`: `+this.message);var S=1;for(var C in n)if(n.hasOwnProperty(C)){var N=n[C];if(`line`in N){var I=N.line(this[C]);I&&t.splice(S++,0,` `+I)}`stack`in N&&N.stack(this[C],t)}return t.join(`
|
|
150
150
|
`)},Object.defineProperty(this,"stack",I)};return Object.setPrototypeOf?(Object.setPrototypeOf(N.prototype,Error.prototype),Object.setPrototypeOf(N,Error)):S.inherits(N,Error),N};N.append=function(t,n){return{message:function(S,C){return S||=n,S&&(C[0]+=` `+t.replace(`%s`,S.toString())),C}}},N.line=function(t,n){return{line:function(S){return S||=n,S?t.replace(`%s`,S.toString()):null}}},n.exports=N})),hh=__commonJSMin(((t,n)=>{let hexify=t=>{let n=t.charCodeAt(0).toString(16).toUpperCase();return`0x`+(n.length%2?`0`:``)+n},parseError=(t,n,S)=>{if(!n)return{message:t.message+` while parsing empty string`,position:0};let C=t.message.match(/^Unexpected token (.) .*position\s+(\d+)/i),N=C?+C[2]:t.message.match(/^Unexpected end of JSON.*/i)?n.length-1:null,F=C?t.message.replace(/^Unexpected token ./,`Unexpected token ${JSON.stringify(C[1])} (${hexify(C[1])})`):t.message;if(N!=null){let t=N<=S?0:N-S,C=N+S>=n.length?n.length:N+S,I=(t===0?``:`...`)+n.slice(t,C)+(C===n.length?``:`...`);return{message:F+` while parsing ${n===I?``:`near `}${JSON.stringify(I)}`,position:N}}else return{message:F+` while parsing '${n.slice(0,S*2)}'`,position:0}};var JSONParseError=class extends SyntaxError{constructor(t,n,S,C){S||=20;let N=parseError(t,n,S);super(N.message),Object.assign(this,N),this.code=`EJSONPARSE`,this.systemError=t,Error.captureStackTrace(this,C||this.constructor)}get name(){return this.constructor.name}set name(t){}get[Symbol.toStringTag](){return this.constructor.name}};let S=Symbol.for(`indent`),C=Symbol.for(`newline`),N=/^\s*[{\[]((?:\r?\n)+)([\s\t]*)/,F=/^(?:\{\}|\[\])((?:\r?\n)+)?$/,parseJson=(t,n,I)=>{let H=stripBOM(t);I||=20;try{let[,t=`
|
|
151
151
|
`,I=` `]=H.match(F)||H.match(N)||[,``,``],W=JSON.parse(H,n);return W&&typeof W==`object`&&(W[C]=t,W[S]=I),W}catch(n){if(typeof t!=`string`&&!Buffer.isBuffer(t)){let S=Array.isArray(t)&&t.length===0;throw Object.assign(TypeError(`Cannot parse ${S?`an empty array`:String(t)}`),{code:`EJSONPARSE`,systemError:n})}throw new JSONParseError(n,H,I,parseJson)}},stripBOM=t=>String(t).replace(/^\uFEFF/,``);n.exports=parseJson,parseJson.JSONParseError=JSONParseError,parseJson.noExceptions=(t,n)=>{try{return JSON.parse(stripBOM(t),n)}catch{}}})),gh=__commonJSMin((t=>{t.__esModule=!0,t.LinesAndColumns=void 0;var n=`
|
|
@@ -948,7 +948,7 @@ No install command available for your package manager. Install manually.`),proce
|
|
|
948
948
|
deno run -A --reload --min-dep-age 0 npm:@gjsify/cli@latest showcase <name>`,LR={command:`showcase [name]`,description:`List or run curated gjsify showcase applications.`,builder:t=>t.positional(`name`,{description:`Showcase name to run (omit to list all)`,type:`string`}).option(`json`,{description:`Output as JSON`,type:`boolean`,default:!1}).option(`list`,{description:`List available showcases`,type:`boolean`,default:!1}).option(`runtime`,{type:`string`,choices:H_,defaultDescription:`gjs when gjs is installed, else the host runtime`,description:"Runtime to run the showcase on: gjs | node | bun | deno (default: gjs when installed, else the host runtime). node/bun/deno run its `--app node` bundle."}),handler:async t=>{if(!t.name||t.list){let n=discoverShowcases();if(t.json){ge.log(JSON.stringify(n,null,2));return}if(n.length===0){ge.log("No showcases found. The CLI ships a curated list in `showcases.json`; if it is missing the CLI install is incomplete.");return}let S=new Map;for(let t of n){let n=S.get(t.category)??[];n.push(t),S.set(t.category,n)}ge.log(`Available gjsify showcases:
|
|
949
949
|
`);for(let[t,n]of S){ge.log(` ${t.toUpperCase()}:`);let S=Math.max(...n.map(t=>t.name.length));for(let t of n){let n=` `.repeat(S-t.name.length+2),C=t.description?`${n}${t.description}`:``;ge.log(` ${t.name}${C}`)}ge.log(``)}ge.log(`Run a showcase: gjsify showcase <name>`);return}let n=findShowcase(t.name);if(!n)return ge.error(`Unknown showcase: "${t.name}"`),ge.error(`Run "gjsify showcase" to list available showcases.`),process.exit(1);let S=t.runtime??defaultExampleRuntime();if(!isExampleRuntime(S))return ge.error(`Unknown --runtime "${S}" (expected: ${H_.join(`, `)}).`),process.exit(1);if(requiresGjsSystemDeps(S)){let t=runMinimalChecks().filter(t=>!t.found&&t.severity===`required`);if(t.length>0){ge.error(`Missing system dependencies:
|
|
950
950
|
`);for(let n of t)ge.error(` ✗ ${n.name}`);let n=buildInstallCommand(detectPackageManager$1(),t);return n&&ge.error(`\nInstall with:\n ${n}`),process.exit(1)}}let C=readCliVersion();if(S!==`gjs`){await runShowcaseOnRuntime(n,S,C);return}let N=C?`${n.packageName}@${C}`:n.packageName;ge.log(`Running showcase: ${n.name} ${runningAs(C)}(via gjsify dlx ${N})\n`);try{let{runCli:t}=await Promise.resolve().then(()=>(FK(),PK));await t([`dlx`,N])}catch(t){ge.error(t.message),process.exit(1)}}}});function resolveTemplatesRoot(){let t=En(fileURLToPath(import.meta.url)),n=[wn(t,`..`,`dist-templates`),wn(t,`dist-templates`)];try{let t=createRequire(import.meta.url).resolve(`@gjsify/create-app/package.json`);n.splice(1,0,wn(En(t),`dist-templates`))}catch{}return n.find(t=>existsSync(t))}function discoverTemplates(){let t=resolveTemplatesRoot();if(!t)return[];let n=[];for(let S of readdirSync(t)){let C=wn(t,S),N=wn(C,`package.json`);if(!statSync(C).isDirectory()||!existsSync(N))continue;let F=zR[S]??``;try{let t=JSON.parse(readFileSync(N,`utf-8`));typeof t.description==`string`&&t.description.trim()&&(F=t.description)}catch{}n.push({name:S,description:F,path:C})}return n.sort((t,n)=>t.name.localeCompare(n.name)),n}function findTemplate(t){return discoverTemplates().find(n=>n.name===t)}var zR,BR=__esmMin(()=>{Rd(),Il(),Pn(),Gn(),zR={"gtk-minimal":`Minimal GTK4 app — Gtk.ApplicationWindow + Gtk.Label, no Adwaita (Blueprint UI).`,cli:`Command-line tool using yargs (Node.js + GJS).`,"adw-canvas2d":`Adwaita app with HTML Canvas 2D rendering (Blueprint UI).`,"adw-webgl":`Adwaita app with WebGL + three.js (Blueprint UI).`,"adw-game":`Adwaita game shell using Excalibur.js, WebGL → Canvas2D fallback.`,"web-server-hono":`HTTP server using Hono (Web-standard fetch-style API).`,"web-server-express":`HTTP server using Express (familiar Node.js stack).`}});function installCommandLine(t){return[t,...HR[t]].join(` `)}function runScriptCommand(t){return UR[t]}function packageManagersForRuntime(t){return WR[t]}function hostRuntime(){let t=globalThis;return t.Bun===void 0?t.Deno===void 0?t.imports?.gi===void 0?`node`:`gjs`:`deno`:`bun`}function defaultRuntimeFor(t,n){if(n)return t.find(t=>packageManagersForRuntime(t)?.includes(n));let S=hostRuntime();return t.includes(S)?S:t[0]}function startScriptFor(t){return t===`gjs`?`start`:`start:${t}`}var VR,HR,UR,WR,GR,KR=__esmMin(()=>{VR=[`npm`,`yarn`,`pnpm`,`gjsify`,`bun`,`deno`],HR={npm:[`install`,`--no-audit`,`--no-fund`],yarn:[`install`],pnpm:[`install`],gjsify:[`install`],bun:[`install`],deno:[`install`]},UR={npm:`npm run`,yarn:`yarn`,pnpm:`pnpm`,gjsify:`gjsify run`,bun:`bun run`,deno:`deno task`},WR={gjs:[`gjsify`],node:[`npm`,`yarn`,`pnpm`,`gjsify`],bun:[`bun`],deno:[`deno`]},GR={gjs:`GNOME JavaScript — no Node.js needed at runtime.`,node:`Node.js — gi:// via the @gjsify/node-gi bridge.`,bun:`Bun — runs the same --app node bundle.`,deno:`Deno — runs the same --app node bundle.`}});function selectRuntime(t){let{flag:n,offered:S,manager:C,interactive:N}=t;if(n!==void 0)return S.length>0&&!S.includes(n)?{kind:`error`,message:`this template does not run on "${n}". Declared runtimes: ${S.join(`, `)}.`}:{kind:`value`,value:n};if(S.length===1)return{kind:`value`,value:S[0]};if(S.length===0)return{kind:`error`,message:`this template declares no runtime this scaffolder can install for.`};let F=defaultRuntimeFor(S,C);return F===void 0?{kind:`error`,message:`no runtime this template declares installs with "${C}". Declared runtimes: ${S.join(`, `)}.`}:C===void 0?N?{kind:`prompt`,choices:S,initial:F}:{kind:`auto`,value:F,notice:`--runtime not given, using "${F}". Runs on: ${S.join(`, `)}.`}:{kind:`auto`,value:F,notice:`Setting up for ${F} — the runtime ${C} installs for.`}}function selectPackageManager(t){let{flag:n,runtime:S,install:C,interactive:N}=t,F=packageManagersForRuntime(S);return F===void 0||F.length===0?{kind:`error`,message:`no package manager known for runtime "${S}".`}:n===void 0?F.length===1?{kind:`auto`,value:F[0],notice:`Using ${F[0]} — the only package manager that installs for ${S}.`}:N?{kind:`prompt`,choices:F,initial:F[0]}:C?{kind:`error`,message:`--package-manager is required with --install in non-interactive mode. Package managers for ${S}: ${F.join(`, `)}.`}:{kind:`auto`,value:F[0],notice:`--package-manager not given, using "${F[0]}" for ${S}.`}:F.includes(n)?{kind:`value`,value:n}:{kind:`error`,message:`"${n}" cannot install a project you intend to run on ${S}. Package managers for ${S}: ${F.join(`, `)}.`}}var qR=__esmMin(()=>{KR()});function applicationIdFor(t){let n=t.replace(/[^A-Za-z0-9_-]/g,`-`);return`org.gjsify.${/^[0-9]/.test(n)?`app-${n}`:n}`}function sanitizeProjectName(t){let n=t.trim();if(!n)throw Error(`Project name cannot be empty.`);let S=n.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[._-]+/,``).replace(/[._-]+$/,``);if(!S)throw Error(`"${t}" is not a valid npm package name.`);return S}function isDirEmpty(t){return existsSync(t)?readdirSync(t).length===0:!0}async function createProject(t){let n=sanitizeProjectName(t.projectName),{template:S,force:C=!1,install:N=!1}=t,F=findTemplate(S);if(!F){let t=discoverTemplates().map(t=>t.name).join(`, `);throw Error(`Unknown template "${S}". Available templates: ${t||`(none — run "yarn build" first)`}`)}let I=supportedRuntimes(F),H=t.runtime??defaultRuntimeFor(I,t.packageManager)??hostRuntime(),W=packageManagersForRuntime(H);if(!W)throw Error(`Template "${F.name}" was asked for runtime "${H}", which this version of @gjsify/create-app has no installer mapping for. Upgrade it, or pick one of: ${I.join(`, `)||`(none)`}.`);let q=t.packageManager??W[0];if(!W.includes(q))throw Error(`"${q}" cannot install a project you intend to run on ${H}. Package managers for ${H}: ${W.join(`, `)}.`);let Y=xn(process.cwd(),n);if(existsSync(Y)&&!isDirEmpty(Y)&&!C)return ge.error(`Error: Directory "${n}" exists and is not empty. Use --force to scaffold into it anyway.`),process.exit(1);if(ge.log(`Creating new Gjsify project in ${Y} (template: ${F.name})...`),mkdirSync(Y,{recursive:!0}),cpSync(F.path,Y,{recursive:!0}),substituteTemplateSentinels(Y,n),N){let t=installCommandLine(q);ge.log(`Running ${t}...`);let n=spawnSync(t,{cwd:Y,stdio:`inherit`,shell:!0});n.error?ge.warn(`${q} install could not start (${n.error.message}); re-run it manually.`):n.status!==0&&ge.warn(`${q} install failed; re-run it manually in the project directory.`)}printNextSteps(n,F,N,q,H)}function substituteTemplateSentinels(t,n){let S=[[JR,n],[YR,applicationIdFor(n)]],C=new Set([`node_modules`,`dist`,`lib`]),N=[t];for(;N.length>0;){let t=N.pop();for(let n of readdirSync(t,{withFileTypes:!0})){let F=wn(t,n.name);if(n.isDirectory()){C.has(n.name)||N.push(F);continue}if(!n.isFile())continue;let I=n.name.lastIndexOf(`.`),H=I>=0?n.name.slice(I):``;if(!XR.has(H))continue;let W=readFileSync(F,`utf-8`),q=W;for(let[t,n]of S)q=q.replaceAll(t,n);q!==W&&writeFileSync(F,q)}}}function printNextSteps(t,n,S,C,N){let F=runScriptCommand(C),I=templateScripts(n),H=startScriptFor(N);ge.log(``),ge.log(`Project created from template "${n.name}", set up for ${N}.`),ge.log(``),ge.log(`Next steps:`),ge.log(` cd ${t}`),S||ge.log(` ${C} install`),N===`gjs`&&I.dev?ge.log(` ${F} dev`):(ge.log(` ${F} build`),ge.log(` ${F} ${H}`)),ge.log(``);let W=supportedRuntimes(n).filter(t=>t!==N&&I[startScriptFor(t)]);if(W.length>0){ge.log(`Also runs on ${W.join(`, `)}:`);for(let t of W)ge.log(` ${F} ${startScriptFor(t)}`);ge.log(``)}}function templateManifest(t){try{return JSON.parse(readFileSync(wn(t.path,`package.json`),`utf-8`))}catch{return{}}}function templateScripts(t){let n=templateManifest(t).scripts;return n?Object.fromEntries(Object.entries(n).filter(t=>typeof t[1]==`string`)):{}}function supportedRuntimes(t){let n=templateManifest(t).gjsify?.example?.runtimes;return Array.isArray(n)?n.filter(t=>typeof t==`string`&&packageManagersForRuntime(t)!==void 0):[]}var JR,YR,XR,ZR=__esmMin(()=>{_e(),P_(),Rd(),Pn(),BR(),KR(),qR(),JR=`new-gjsify-app`,YR=`org.gjsify.example`,XR=new Set([`.json`,`.md`,`.ts`,`.tsx`,`.js`,`.mjs`,`.cjs`,`.blp`,`.html`,`.css`,`.scss`,`.xml`,`.ui`,`.txt`])});function isCancelled(t){return t instanceof Error&&t.message===$R}function render(t,n,S){S||an.write(`\x1b[${t.length}A`);for(let S=0;S<t.length;S++){let C=t[S],N=S===n?`${QR.cyan}❯${QR.reset}`:` `,F=S===n?`${QR.bold}${QR.green}${C.label}${QR.reset}`:C.label,I=C.description?` ${QR.dim}${C.description}${QR.reset}`:``;an.write(`\x1b[2K\r ${N} ${F}${I}\n`)}}function promptChoice(t,n,S=0){return n.length===0?Promise.reject(Error(`Nothing to choose for "${t}".`)):new Promise((C,N)=>{let F=S>=0&&S<n.length?S:0;an.write(`${QR.bold}${t}${QR.reset} ${QR.dim}(↑/↓ to navigate, Enter to confirm, Ctrl+C to cancel)${QR.reset}\n`),render(n,F,!0),emitKeypressEvents(on),on.isTTY&&on.setRawMode(!0),on.resume();let cleanup=()=>{on.removeListener(`keypress`,onKeypress),on.isTTY&&on.setRawMode(!1),on.pause()},onKeypress=(t,S)=>{if(S){if(S.ctrl&&S.name===`c`){cleanup(),an.write(`
|
|
951
|
-
`),N(Error($R));return}S.name===`up`||S.name===`k`?(F=(F-1+n.length)%n.length,render(n,F,!1)):S.name===`down`||S.name===`j`?(F=(F+1)%n.length,render(n,F,!1)):(S.name===`return`||S.name===`enter`)&&(cleanup(),C(n[F].value))}};on.on(`keypress`,onKeypress)})}function promptTemplate(t){return t.length===0?Promise.reject(Error(`No templates available.`)):promptChoice(`Select a template`,t.map(t=>({value:t,label:t.name,description:t.description})))}function promptRuntime(t,n){return promptChoice(`Select a runtime`,t.map(t=>({value:t,label:t,description:GR[t]??``})),t.indexOf(n))}function promptPackageManager(t,n){return promptChoice(`Select a package manager`,t.map(t=>({value:t,label:t,description:``})),t.indexOf(n))}async function settle(t,n){switch(t.kind){case`value`:return t.value;case`auto`:return ge.error(t.notice),t.value;case`prompt`:try{return await n(t.choices,t.initial)}catch(t){if(!isCancelled(t))throw t;ge.error(`Cancelled.`);return}case`error`:ge.error(`Error: ${t.message}`);return}}async function promptSetup(t){let{offered:n,install:S,interactive:C}=t,N=await settle(selectRuntime({flag:t.runtime,offered:n,manager:t.packageManager,interactive:C}),(t,n)=>promptRuntime(t,n));if(N===void 0)return;let F=await settle(selectPackageManager({flag:t.packageManager,runtime:N,install:S,interactive:C}),(t,n)=>promptPackageManager(t,n));if(F!==void 0)return{runtime:N,packageManager:F}}var QR,$R,ez=__esmMin(()=>{_e(),sn(),Ad(),KR(),qR(),QR={reset:`\x1B[0m`,bold:`\x1B[1m`,dim:`\x1B[2m`,cyan:`\x1B[36m`,green:`\x1B[32m`},$R=`Cancelled by user`}),tz,nz=__esmMin(()=>{_e(),ZR(),ez(),tz={command:`create [project-name]`,description:`Scaffold a new Gjsify project in a new directory.`,builder:t=>{let n=discoverTemplates(),S=n.map(t=>t.name),C=[...new Set(n.flatMap(t=>supportedRuntimes(t)))];return t.positional(`project-name`,{describe:`Name of the project directory to create`,type:`string`,default:`my-gjs-app`}).option(`template`,{alias:`t`,describe:`Template to scaffold from`,type:`string`,choices:S.length>0?S:void 0}).option(`runtime`,{alias:`r`,describe:`Runtime to set the project up for. Decides which package managers are offered and which start script the next steps name.`,type:`string`,choices:C.length>0?C:void 0}).option(`force`,{alias:`f`,describe:`Scaffold into a non-empty directory`,type:`boolean`,default:!1}).option(`install`,{describe:`Install dependencies after scaffolding`,type:`boolean`,default:!1}).option(`package-manager`,{alias:`p`,describe:"Package manager to install with, and to name in the printed next steps. Must be one the chosen runtime can install for. `gjsify` is the only one that works on a host with no Node.js.",type:`string`,choices:VR})},handler:async t=>{let n=!!process.stdin.isTTY,S=discoverTemplates(),C=t.template;if(!C){if(!n){let t=S.map(t=>t.name).join(`, `);return ge.error(`Error: --template is required in non-interactive mode. Available templates: ${t||`(none)`}`),process.exit(1)}let t=await promptTemplate(S).catch(t=>{if(!isCancelled(t))throw t;ge.error(`Cancelled.`)});if(t===void 0)return process.exit(1);C=t.name}let N=S.find(t=>t.name===C),F=await promptSetup({offered:N?supportedRuntimes(N):[],runtime:t.runtime,packageManager:t[`package-manager`],install:t.install,interactive:n});if(F===void 0)return process.exit(1);await createProject({projectName:t[`project-name`],template:C,runtime:F.runtime,force:t.force,install:t.install,packageManager:F.packageManager})}}});function defaultTargetFor(t){let n=Dn(t,On(t));return xn(En(t),n)}var rz,iz,az=__esmMin(()=>{_e(),P_(),xd(),Pn(),Tu(),rz=promisify(execFile),iz={command:`gresource <xml>`,description:"Compile a GResource XML descriptor into a binary .gresource bundle (wraps `glib-compile-resources`).",builder:t=>t.positional(`xml`,{description:`Path to the .gresource.xml descriptor`,type:`string`,normalize:!0,demandOption:!0}).option(`sourcedir`,{description:`Directory containing the resource files referenced by <xml>`,type:`string`,normalize:!0}).option(`target`,{alias:`t`,description:`Output .gresource file (default: <xml-without-.xml> next to <xml>)`,type:`string`,normalize:!0}).option(`verbose`,{description:`Print the underlying glib-compile-resources invocation`,type:`boolean`,default:!1}),handler:async t=>{let n=xn(t.xml),S=t.target?xn(t.target):defaultTargetFor(n),C=[`--sourcedir=${t.sourcedir?xn(t.sourcedir):En(n)}`,`--target=${S}`,n];t.verbose&&ge.log(`[gjsify gresource] glib-compile-resources ${C.join(` `)}`),await mkdir$1(En(S),{recursive:!0});try{let{stdout:n,stderr:N}=await rz(`glib-compile-resources`,C);n&&process.stdout.write(n),N&&process.stderr.write(N),t.verbose&&ge.log(`[gjsify gresource] wrote ${S}`)}catch(t){let n=t;n?.code===`ENOENT`?ge.error(`[gjsify gresource] glib-compile-resources not found. Install it via your distro (package: glib2-devel / libglib2.0-dev).`):(n?.stderr&&process.stderr.write(n.stderr),ge.error(`[gjsify gresource] glib-compile-resources failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}}});function mergeCatalogues(t){let n=t.template,S=new Set;for(let{locale:n}of t.catalogues){if(S.has(n))throw Error(`mergeCatalogues: two catalogues both claim locale "${n}". msgfmt APPENDS each --locale, so the chain would emit a duplicate key (desktop-file-validate: "multiple keys named Name[${n}]"; appstreamcli: "tag-duplicated") from two exit-0 calls. Merge them into one .po first (msgcat --use-first) and pass that.`);S.add(n)}for(let[S,C]of t.catalogues.entries()){let N=wn(t.workDir,`${S}${t.extension}`),F=[t.mode,`--template=${n}`,`--locale=${C.locale}`,`--output-file=${N}`,C.po];t.onCall?.(F),execFileSync(`msgfmt`,F,{stdio:`pipe`}),n=N}return n}var oz=__esmMin(()=>{P_(),Pn()});async function listLanguages(t){return(await readdir$1(t)).filter(t=>t.endsWith(`.po`)&&!t.startsWith(`.`)).map(t=>t.slice(0,-3)).sort()}function stripXmlComments(t){return t.replace(/<!--[\s\S]*?-->/g,``)}async function ensureDir(t){await mkdir$1(t,{recursive:!0})}async function fileExists(t){try{return await stat$1(t),!0}catch{return!1}}async function compileMerged(t){let n=await listLanguages(t.poDir);if(n.length===0){ge.warn(`[gjsify gettext] no .po files found in ${t.poDir}`);return}let S=wn(t.outDir,t.filename);await ensureDir(t.outDir);let C=await mkdtemp$1(wn(tmpdir(),`gjsify-gettext-`));try{let N=await readFile$1(mergeCatalogues({mode:`--${t.format}`,template:t.template,extension:`-${Dn(t.template).replace(/\.in$/,``)}`,catalogues:n.map(n=>({locale:n,po:wn(t.poDir,`${n}.po`)})),workDir:C,onCall:t.verbose?t=>ge.log(`[gjsify gettext] msgfmt ${t.join(` `)}`):void 0}),`utf-8`);await writeFile$1(S,t.removeXmlComments&&t.format===`xml`?stripXmlComments(N):N)}finally{await rm$1(C,{recursive:!0,force:!0})}t.verbose&&ge.log(`[gjsify gettext] merged ${n.length} language(s) into ${S}`)}async function compileCatalogues(t){let n=await listLanguages(t.poDir);if(n.length===0){ge.warn(`[gjsify gettext] no .po files found in ${t.poDir}`);return}for(let S of n){let n=wn(t.outDir,S,`LC_MESSAGES`);await ensureDir(n);let C=[`--output-file=${wn(n,t.filename)}`,wn(t.poDir,`${S}.po`)];t.verbose&&ge.log(`[gjsify gettext] msgfmt ${C.join(` `)}`),await sz(`msgfmt`,C)}t.verbose&&ge.log(`[gjsify gettext] compiled ${n.length} language(s) into ${t.outDir}`)}function defaultFilename(t,n,S){switch(n){case`mo`:return`${t}.mo`;case`desktop`:return`${t}.desktop`;case`xml`:return S?Dn(S.replace(/\.in$/,``)):`${t}.xml`}}var sz,cz,lz=__esmMin(()=>{_e(),P_(),xd(),Lg(),Pn(),Tu(),oz(),sz=promisify(execFile),cz={command:`gettext <poDir> <outDir>`,description:`Compile gettext .po files to .mo (per-language locale tree), or merge every catalogue into a .desktop / AppStream template via msgfmt --desktop / --xml.`,builder:t=>t.positional(`poDir`,{description:`Directory containing <lang>.po files`,type:`string`,normalize:!0,demandOption:!0}).positional(`outDir`,{description:`Output directory (locale tree for --format=mo, plain dir for xml/desktop)`,type:`string`,normalize:!0,demandOption:!0}).option(`domain`,{description:"Text domain / application ID (e.g. `org.pixelrpg.maker`)",type:`string`,normalize:!0,demandOption:!0}).option(`format`,{description:`Output format`,type:`string`,choices:[`mo`,`xml`,`desktop`],default:`mo`}).option(`template`,{description:"Required for --format=xml|desktop: the file msgfmt substitutes into. Its SUFFIX matters — msgfmt --xml finds its ITS rules by filename pattern, so an AppStream template must be named `*.metainfo.xml[.in]`.",type:`string`,normalize:!0}).option(`metainfo`,{description:`Deprecated alias for --template.`,type:`string`,normalize:!0,hidden:!0}).option(`filename`,{description:`Override the output filename (defaults to <domain>.<ext>)`,type:`string`,normalize:!0}).option(`remove-xml-comments`,{description:`For --format=xml: strip XML comments from the compiled output`,type:`boolean`,default:!0}).option(`verbose`,{description:`Print each msgfmt invocation`,type:`boolean`,default:!1}),handler:async t=>{let n=xn(t.poDir),S=xn(t.outDir),C=t.domain,N=t.format??`mo`,F=t.template??t.metainfo,I=F?xn(F):void 0,H=t.filename??defaultFilename(C,N,I),W=!!t.verbose,q=!!t[`remove-xml-comments`];if(!await fileExists(n)){ge.error(`[gjsify gettext] PO directory does not exist: ${n}`),process.exitCode=1;return}if(N!==`mo`&&I===void 0){ge.error(`[gjsify gettext] --format=${N} needs a template to substitute into: pass \`--template <file>\`. msgfmt has no way to produce this format from .po files alone.`+(N===`xml`?" Name it `*.metainfo.xml[.in]` — msgfmt --xml finds its ITS rules by filename pattern.":``)),process.exitCode=1;return}try{N===`mo`?await compileCatalogues({poDir:n,outDir:S,filename:H,verbose:W}):await compileMerged({poDir:n,outDir:S,format:N,template:I,filename:H,removeXmlComments:q,verbose:W})}catch(t){let n=t;n?.code===`ENOENT`?ge.error(`[gjsify gettext] msgfmt not found. Install it via your distro (package: gettext).`):(n?.stderr&&process.stderr.write(n.stderr),ge.error(`[gjsify gettext] msgfmt failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}}}),uz,dz,fz=__esmMin(()=>{_e(),P_(),xd(),Pn(),Tu(),uz=promisify(execFile),dz={command:`gsettings <schemadir>`,description:"Compile GSettings schema XML files into a binary gschemas.compiled (wraps `glib-compile-schemas`).",builder:t=>t.positional(`schemadir`,{description:`Directory containing *.gschema.xml descriptors`,type:`string`,normalize:!0,demandOption:!0}).option(`targetdir`,{alias:`t`,description:`Directory to write gschemas.compiled (default: <schemadir>)`,type:`string`,normalize:!0}).option(`strict`,{description:`Abort on any schema warning (passes --strict to glib-compile-schemas)`,type:`boolean`,default:!0}).option(`verbose`,{description:`Print the underlying glib-compile-schemas invocation`,type:`boolean`,default:!1}),handler:async t=>{let n=xn(t.schemadir),S=t.targetdir?xn(t.targetdir):n,C=[];t.strict&&C.push(`--strict`),C.push(`--targetdir=${S}`),C.push(n),t.verbose&&ge.log(`[gjsify gsettings] glib-compile-schemas ${C.join(` `)}`),await mkdir$1(S,{recursive:!0});try{let{stdout:n,stderr:N}=await uz(`glib-compile-schemas`,C);n&&process.stdout.write(n),N&&process.stderr.write(N),t.verbose&&ge.log(`[gjsify gsettings] wrote ${S}/gschemas.compiled`)}catch(t){let n=t;n?.code===`ENOENT`?ge.error(`[gjsify gsettings] glib-compile-schemas not found. Install it via your distro (package: glib2-devel / libglib2.0-dev).`):(n?.stderr&&process.stderr.write(n.stderr),ge.error(`[gjsify gsettings] glib-compile-schemas failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}}});function readPackageJson(t){let n=xn(t,`package.json`),S;try{S=readFileSync(n,`utf-8`)}catch{throw Error(`gjsify flatpak: no package.json found at ${n}`)}try{return JSON.parse(S)}catch(t){throw Error(`gjsify flatpak: package.json at ${n} is not valid JSON: ${t.message}`)}}function looksLikeAppId(t){return typeof t==`string`&&/^[A-Za-z][A-Za-z0-9_-]*(\.[A-Za-z][A-Za-z0-9_-]*){2,}$/.test(t)}function defaultCiContainer(t,n){return`ghcr.io/flathub-infra/flatpak-github-actions:${`${t}-${n}`}`}var pz,mz=__esmMin(()=>{Rd(),Pn(),pz=`gjsify-sources.json`});function resolveRuntime(t,n){let S=n.runtime??t?.runtime??`gnome`;if(S!==`gnome`&&S!==`freedesktop`)throw Error(`gjsify flatpak: unknown runtime "${S}" (expected "gnome" or "freedesktop")`);let C=n.runtimeVersion??t?.runtimeVersion??(S===`gnome`?`50`:`24.08`);return S===`gnome`?{runtime:S,runtimeId:`org.gnome.Platform`,sdk:`org.gnome.Sdk`,runtimeVersion:C}:{runtime:S,runtimeId:`org.freedesktop.Platform`,sdk:`org.freedesktop.Sdk`,runtimeVersion:C}}function deriveAppendPath(t){let n=[];for(let S of t){let t=/^org\.freedesktop\.Sdk\.Extension\.([A-Za-z0-9-]+)$/.exec(S);t&&n.push(`/usr/lib/sdk/${t[1]}/bin`)}return n.push(`/app/bin`),n}var hz,gz,_z=__esmMin(()=>{hz=[`--device=dri`,`--share=ipc`,`--socket=fallback-x11`,`--socket=wayland`],gz=[]});function pickFlatpakBuildKeys(t,n){let S=t??{},C={},N=[];for(let t of yz){let F=S[t];if(F!==void 0){C[t]=F;continue}let I=n[t];I!==void 0&&N.push(t),C[t]=I}return{values:C,fromLegacy:N}}function resolveShipFlatpakSettings(t){let n=t.ship.flatpak??{},{values:S,fromLegacy:C}=pickFlatpakBuildKeys(n,t.flatpak),N=resolveRuntime(S,{}),F=S.sdkExtensions??[],{appendPath:I,finishArgs:H,cleanup:W}=S;return{settings:{runtime:N.runtimeId,runtimeVersion:N.runtimeVersion,sdk:N.sdk,branch:n.branch??`stable`,sdkExtensions:[...F],appendPath:I??(F.length>0?deriveAppendPath(F):[]),finishArgs:H??(t.kind===`cli`?gz:hz),cleanup:[...new Set([...W??[],...t.kind===`app`?[bz]:[]])]},warnings:C.length===0?[]:[deprecationWarning(C)]}}function assertNoDroppedFlatpakModules(t){let n=[`modules`,`extraModules`].filter(n=>(t[n]?.length??0)>0);if(n.length===0)return;let S=n.map(t=>`gjsify.flatpak.${t}`).join(` and `);throw Error(`gjsify ship: ${S} ${n.length>1?`are`:`is`} set, but the \`flatpak\` target renders ONE module, the staged payload, and would drop ${n.length>1?`them`:`it`} (ADR 0024 § 2). Build this Flatpak with \`gjsify flatpak init\` + \`gjsify flatpak build\`, which honour the key, or leave \`flatpak\` out of \`--target\` / \`gjsify.ship.targets\`.`)}function deprecationWarning(t){let n=t.map(t=>`gjsify.flatpak.${t}`).join(`, `),S=t.map(t=>`gjsify.ship.flatpak.${t}`).join(`, `);return`DEPRECATION: ${n} ${t.length>1?`are`:`is`} read by \`gjsify ship\` for compatibility and will be removed in ${vz}. Move ${t.length>1?`them`:`it`} to ${S} — both spellings resolve until then, and \`gjsify.ship.flatpak\` wins where both are set. The app METADATA in \`gjsify.flatpak\` (name, summary, developer, categories, licence) is NOT deprecated: both blocks describe the same application and either may carry it (ADR 0024 § 8).`}var vz,yz,bz,xz=__esmMin(()=>{_z(),vz=`1.0.0`,yz=[`runtime`,`runtimeVersion`,`sdkExtensions`,`appendPath`,`finishArgs`,`cleanup`],bz=`/share/icons/hicolor/scalable`});function loadDesktopTemplate(){return Sz}function validateAppMetadata(t){let n=t.metadata,S=t.configKey,C=[];return(!n.developer?.id||!n.developer?.name)&&C.push({field:`${S}.developer`,hint:`Set \`${S}.developer = { "id": "io.github.you", "name": "Your Name" }\` in package.json. The id is reverse-DNS.`}),n.summary||C.push({field:`${S}.summary`,hint:`One-line app summary, ≤80 chars, no trailing period. Example: "Learn 6502 assembly language".`}),n.description||C.push({field:`${S}.description`,hint:`Plain text (split on blank lines) or DescriptionBlock[] for rich content with bullet lists + translator hints.`}),n.license?.project||C.push({field:`${S}.license.project`,hint:`SPDX identifier of the project license, e.g. "MIT", "GPL-3.0-or-later".`}),n.homepageUrl||C.push({field:`${S}.homepageUrl`,hint:`Required by Flathub. Example: "https://github.com/you/your-repo".`}),C}function renderMetainfoApp$1(t){return renderMetainfo(t,`desktop-application`)}function renderMetainfoCli$1(t){return renderMetainfo(t,`console-application`)}function renderDesktopEntry(t){let n=t.metadata,S=(n.categories??[`Utility`]).join(`;`)+`;`,C=n.keywords?.length?`Keywords=${n.keywords.join(`;`)};\n`:``,N=n.provides?.mimetypes??[],F=N.length?`MimeType=${N.join(`;`)};\n`:``;return substitute(loadDesktopTemplate(),{NAME:t.name,SUMMARY:n.summary??t.name,COMMAND:`${t.command}${execFieldCode(N)}`,APP_ID:t.appId,CATEGORIES_LINE:S,KEYWORDS_LINE:C,MIMETYPES_LINE:F})}function execFieldCode(t){return t.some(t=>t.startsWith(`x-scheme-handler/`))?` %u`:t.length>0?` %f`:``}function renderMetainfo(t,n){let S=t.metadata,C=t.copyrightYear??new Date().getFullYear(),N=S.developer?.name??``,F=[];F.push(`<?xml version="1.0" encoding="UTF-8"?>`),F.push(`<!-- Copyright ${C} ${escapeXml(N)} -->`),F.push(`<component type="${n}">`),F.push(` <id>${escapeXml(t.appId)}</id>`),F.push(` <metadata_license>${escapeXml(S.license?.metadata??`CC0-1.0`)}</metadata_license>`),F.push(` <project_license>${escapeXml(S.license?.project??``)}</project_license>`),F.push(` <name>${escapeXml(t.name)}</name>`),pushTranslatorHint(F,S.summaryTranslatorHint,` `),F.push(` <summary>${escapeXml(S.summary??t.name)}</summary>`),S.iconRemote&&F.push(` <icon type="remote">${escapeXml(S.iconRemote)}</icon>`),F.push(` <description>`);for(let t of renderDescriptionBlocks(S.description??``,` `))F.push(t);if(F.push(` </description>`),S.developer?.id&&S.developer?.name){F.push(` <developer id="${escapeXml(S.developer.id)}">`);let t=S.developer.nameTranslatable===!0?``:` translate="no"`;F.push(` <name${t}>${escapeXml(S.developer.name)}</name>`),S.developer.email&&F.push(` <email>${escapeXml(S.developer.email)}</email>`),F.push(` </developer>`)}n===`desktop-application`&&F.push(` <launchable type="desktop-id">${escapeXml(t.appId)}.desktop</launchable>`),S.screenshots?.length&&(F.push(` <screenshots>`),S.screenshots.forEach((t,n)=>{let S=t.type??(n===0?`default`:void 0),C=S?` type="${escapeXml(S)}"`:``,N=t.environment?` environment="${escapeXml(t.environment)}"`:``;F.push(` <screenshot${C}${N}>`),F.push(` <image>${escapeXml(t.url)}</image>`),t.caption&&(pushTranslatorHint(F,t.captionTranslatorHint,` `),F.push(` <caption>${escapeXml(t.caption)}</caption>`)),F.push(` </screenshot>`)}),F.push(` </screenshots>`)),S.homepageUrl&&F.push(` <url type="homepage">${escapeXml(S.homepageUrl)}</url>`),S.bugtrackerUrl&&F.push(` <url type="bugtracker">${escapeXml(S.bugtrackerUrl)}</url>`),S.vcsBrowserUrl&&F.push(` <url type="vcs-browser">${escapeXml(S.vcsBrowserUrl)}</url>`),S.donationUrl&&channelAllowsDonations(t.channel)&&F.push(` <url type="donation">${escapeXml(S.donationUrl)}</url>`),S.translateUrl&&F.push(` <url type="translate">${escapeXml(S.translateUrl)}</url>`);let I=normaliseContentRating(S.contentRating);if(I.attributes&&Object.keys(I.attributes).length>0){F.push(` <content_rating type="${escapeXml(I.type)}">`);for(let[t,n]of Object.entries(I.attributes))F.push(` <content_attribute id="${escapeXml(t)}">${escapeXml(n)}</content_attribute>`);F.push(` </content_rating>`)}else F.push(` <content_rating type="${escapeXml(I.type)}" />`);if(S.releases?.length){F.push(` <releases>`);for(let t of S.releases)if(t.description===void 0)F.push(` <release version="${escapeXml(t.version)}" date="${escapeXml(t.date)}" />`);else{F.push(` <release version="${escapeXml(t.version)}" date="${escapeXml(t.date)}">`),F.push(` <description>`);for(let n of renderDescriptionBlocks(t.description,` `))F.push(n);F.push(` </description>`),F.push(` </release>`)}F.push(` </releases>`)}if(S.categories?.length){F.push(` <categories>`);for(let t of S.categories)F.push(` <category>${escapeXml(t)}</category>`);F.push(` </categories>`)}if(S.keywords?.length){F.push(` <keywords>`);for(let t of S.keywords)F.push(` <keyword>${escapeXml(t)}</keyword>`);F.push(` </keywords>`)}if(n===`desktop-application`&&S.branding&&(F.push(` <branding>`),F.push(` <color type="primary" scheme_preference="light">${escapeXml(S.branding.accentLight)}</color>`),F.push(` <color type="primary" scheme_preference="dark">${escapeXml(S.branding.accentDark)}</color>`),F.push(` </branding>`)),S.kudos?.length){F.push(` <kudos>`);for(let t of S.kudos)F.push(` <kudo>${escapeXml(t)}</kudo>`);F.push(` </kudos>`)}let H=S.provides?.binaries??[t.command],W=S.provides?.mimetypes??[],q=S.provides?.dbus??[];if(H.length||W.length||q.length){F.push(` <provides>`);for(let t of H)F.push(` <binary>${escapeXml(t)}</binary>`);for(let t of W)F.push(` <mediatype>${escapeXml(t)}</mediatype>`);for(let t of q)F.push(` <dbus type="${escapeXml(t.type)}">${escapeXml(t.id)}</dbus>`);F.push(` </provides>`)}if(S.supports?.controls?.length||S.supports?.internet){F.push(` <supports>`);for(let t of S.supports.controls??[])F.push(` <control>${escapeXml(t)}</control>`);S.supports.internet&&F.push(` <internet>${escapeXml(S.supports.internet)}</internet>`),F.push(` </supports>`)}if(S.requires?.displayLengthMin||S.requires?.controls?.length||S.requires?.internet){F.push(` <requires>`),S.requires.displayLengthMin&&F.push(` <display_length compare="ge">${S.requires.displayLengthMin}</display_length>`);for(let t of S.requires.controls??[])F.push(` <control>${escapeXml(t)}</control>`);S.requires.internet&&F.push(` <internet>${escapeXml(S.requires.internet)}</internet>`),F.push(` </requires>`)}if(S.recommends?.displayLengthMin||S.recommends?.controls?.length){F.push(` <recommends>`),S.recommends.displayLengthMin&&F.push(` <display_length compare="ge">${S.recommends.displayLengthMin}</display_length>`);for(let t of S.recommends.controls??[])F.push(` <control>${escapeXml(t)}</control>`);F.push(` </recommends>`)}return F.push(`</component>`),F.join(`
|
|
951
|
+
`),N(Error($R));return}S.name===`up`||S.name===`k`?(F=(F-1+n.length)%n.length,render(n,F,!1)):S.name===`down`||S.name===`j`?(F=(F+1)%n.length,render(n,F,!1)):(S.name===`return`||S.name===`enter`)&&(cleanup(),C(n[F].value))}};on.on(`keypress`,onKeypress)})}function promptTemplate(t){return t.length===0?Promise.reject(Error(`No templates available.`)):promptChoice(`Select a template`,t.map(t=>({value:t,label:t.name,description:t.description})))}function promptRuntime(t,n){return promptChoice(`Select a runtime`,t.map(t=>({value:t,label:t,description:GR[t]??``})),t.indexOf(n))}function promptPackageManager(t,n){return promptChoice(`Select a package manager`,t.map(t=>({value:t,label:t,description:``})),t.indexOf(n))}async function settle(t,n){switch(t.kind){case`value`:return t.value;case`auto`:return ge.error(t.notice),t.value;case`prompt`:try{return await n(t.choices,t.initial)}catch(t){if(!isCancelled(t))throw t;ge.error(`Cancelled.`);return}case`error`:ge.error(`Error: ${t.message}`);return}}async function promptSetup(t){let{offered:n,install:S,interactive:C}=t,N=await settle(selectRuntime({flag:t.runtime,offered:n,manager:t.packageManager,interactive:C}),(t,n)=>promptRuntime(t,n));if(N===void 0)return;let F=await settle(selectPackageManager({flag:t.packageManager,runtime:N,install:S,interactive:C}),(t,n)=>promptPackageManager(t,n));if(F!==void 0)return{runtime:N,packageManager:F}}var QR,$R,ez=__esmMin(()=>{_e(),sn(),Ad(),KR(),qR(),QR={reset:`\x1B[0m`,bold:`\x1B[1m`,dim:`\x1B[2m`,cyan:`\x1B[36m`,green:`\x1B[32m`},$R=`Cancelled by user`}),tz,nz=__esmMin(()=>{_e(),ZR(),ez(),tz={command:`create [project-name]`,description:`Scaffold a new Gjsify project in a new directory.`,builder:t=>{let n=discoverTemplates(),S=n.map(t=>t.name),C=[...new Set(n.flatMap(t=>supportedRuntimes(t)))];return t.positional(`project-name`,{describe:`Name of the project directory to create`,type:`string`,default:`my-gjs-app`}).option(`template`,{alias:`t`,describe:`Template to scaffold from`,type:`string`,choices:S.length>0?S:void 0}).option(`runtime`,{alias:`r`,describe:`Runtime to set the project up for. Decides which package managers are offered and which start script the next steps name.`,type:`string`,choices:C.length>0?C:void 0}).option(`force`,{alias:`f`,describe:`Scaffold into a non-empty directory`,type:`boolean`,default:!1}).option(`install`,{describe:`Install dependencies after scaffolding`,type:`boolean`,default:!1}).option(`package-manager`,{alias:`p`,describe:"Package manager to install with, and to name in the printed next steps. Must be one the chosen runtime can install for. `gjsify` is the only one that works on a host with no Node.js.",type:`string`,choices:VR})},handler:async t=>{let n=!!process.stdin.isTTY,S=discoverTemplates(),C=t.template;if(!C){if(!n){let t=S.map(t=>t.name).join(`, `);return ge.error(`Error: --template is required in non-interactive mode. Available templates: ${t||`(none)`}`),process.exit(1)}let t=await promptTemplate(S).catch(t=>{if(!isCancelled(t))throw t;ge.error(`Cancelled.`)});if(t===void 0)return process.exit(1);C=t.name}let N=S.find(t=>t.name===C),F=await promptSetup({offered:N?supportedRuntimes(N):[],runtime:t.runtime,packageManager:t[`package-manager`],install:t.install,interactive:n});if(F===void 0)return process.exit(1);await createProject({projectName:t[`project-name`],template:C,runtime:F.runtime,force:t.force,install:t.install,packageManager:F.packageManager})}}});function defaultTargetFor(t){let n=Dn(t,On(t));return xn(En(t),n)}var rz,iz,az=__esmMin(()=>{_e(),P_(),xd(),Pn(),Tu(),rz=promisify(execFile),iz={command:`gresource <xml>`,description:"Compile a GResource XML descriptor into a binary .gresource bundle (wraps `glib-compile-resources`).",builder:t=>t.positional(`xml`,{description:`Path to the .gresource.xml descriptor`,type:`string`,normalize:!0,demandOption:!0}).option(`sourcedir`,{description:`Directory containing the resource files referenced by <xml>`,type:`string`,normalize:!0}).option(`target`,{alias:`t`,description:`Output .gresource file (default: <xml-without-.xml> next to <xml>)`,type:`string`,normalize:!0}).option(`verbose`,{description:`Print the underlying glib-compile-resources invocation`,type:`boolean`,default:!1}),handler:async t=>{let n=xn(t.xml),S=t.target?xn(t.target):defaultTargetFor(n),C=[`--sourcedir=${t.sourcedir?xn(t.sourcedir):En(n)}`,`--target=${S}`,n];t.verbose&&ge.log(`[gjsify gresource] glib-compile-resources ${C.join(` `)}`),await mkdir$1(En(S),{recursive:!0});try{let{stdout:n,stderr:N}=await rz(`glib-compile-resources`,C);n&&process.stdout.write(n),N&&process.stderr.write(N),t.verbose&&ge.log(`[gjsify gresource] wrote ${S}`)}catch(t){let n=t;n?.code===`ENOENT`?ge.error(`[gjsify gresource] glib-compile-resources not found. Install it via your distro (package: glib2-devel / libglib2.0-dev).`):(n?.stderr&&process.stderr.write(n.stderr),ge.error(`[gjsify gresource] glib-compile-resources failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}}});function mergeCatalogues(t){let n=t.template,S=new Set;for(let{locale:n}of t.catalogues){if(S.has(n))throw Error(`mergeCatalogues: two catalogues both claim locale "${n}". msgfmt APPENDS each --locale, so the chain would emit a duplicate key (desktop-file-validate: "multiple keys named Name[${n}]"; appstreamcli: "tag-duplicated") from two exit-0 calls. Merge them into one .po first (msgcat --use-first) and pass that.`);S.add(n)}for(let[S,C]of t.catalogues.entries()){let N=wn(t.workDir,`${S}${t.extension}`),F=[t.mode,`--template=${n}`,`--locale=${C.locale}`,`--output-file=${N}`,C.po];t.onCall?.(F),execFileSync(`msgfmt`,F,{stdio:`pipe`}),n=N}return n}var oz=__esmMin(()=>{P_(),Pn()});async function listLanguages(t){return(await readdir$1(t)).filter(t=>t.endsWith(`.po`)&&!t.startsWith(`.`)).map(t=>t.slice(0,-3)).sort()}function stripXmlComments(t){return t.replace(/<!--[\s\S]*?-->/g,``)}async function ensureDir(t){await mkdir$1(t,{recursive:!0})}async function fileExists(t){try{return await stat$1(t),!0}catch{return!1}}async function compileMerged(t){let n=await listLanguages(t.poDir);if(n.length===0){ge.warn(`[gjsify gettext] no .po files found in ${t.poDir}`);return}let S=wn(t.outDir,t.filename);await ensureDir(t.outDir);let C=await mkdtemp$1(wn(tmpdir(),`gjsify-gettext-`));try{let N=await readFile$1(mergeCatalogues({mode:`--${t.format}`,template:t.template,extension:`-${Dn(t.template).replace(/\.in$/,``)}`,catalogues:n.map(n=>({locale:n,po:wn(t.poDir,`${n}.po`)})),workDir:C,onCall:t.verbose?t=>ge.log(`[gjsify gettext] msgfmt ${t.join(` `)}`):void 0}),`utf-8`);await writeFile$1(S,t.removeXmlComments&&t.format===`xml`?stripXmlComments(N):N)}finally{await rm$1(C,{recursive:!0,force:!0})}t.verbose&&ge.log(`[gjsify gettext] merged ${n.length} language(s) into ${S}`)}async function compileCatalogues(t){let n=await listLanguages(t.poDir);if(n.length===0){ge.warn(`[gjsify gettext] no .po files found in ${t.poDir}`);return}for(let S of n){let n=wn(t.outDir,S,`LC_MESSAGES`);await ensureDir(n);let C=[`--output-file=${wn(n,t.filename)}`,wn(t.poDir,`${S}.po`)];t.verbose&&ge.log(`[gjsify gettext] msgfmt ${C.join(` `)}`),await sz(`msgfmt`,C)}t.verbose&&ge.log(`[gjsify gettext] compiled ${n.length} language(s) into ${t.outDir}`)}function defaultFilename(t,n,S){switch(n){case`mo`:return`${t}.mo`;case`desktop`:return`${t}.desktop`;case`xml`:return S?Dn(S.replace(/\.in$/,``)):`${t}.xml`}}var sz,cz,lz=__esmMin(()=>{_e(),P_(),xd(),Lg(),Pn(),Tu(),oz(),sz=promisify(execFile),cz={command:`gettext <poDir> <outDir>`,description:`Compile gettext .po files to .mo (per-language locale tree), or merge every catalogue into a .desktop / AppStream template via msgfmt --desktop / --xml.`,builder:t=>t.positional(`poDir`,{description:`Directory containing <lang>.po files`,type:`string`,normalize:!0,demandOption:!0}).positional(`outDir`,{description:`Output directory (locale tree for --format=mo, plain dir for xml/desktop)`,type:`string`,normalize:!0,demandOption:!0}).option(`domain`,{description:"Text domain / application ID (e.g. `org.pixelrpg.maker`)",type:`string`,normalize:!0,demandOption:!0}).option(`format`,{description:`Output format`,type:`string`,choices:[`mo`,`xml`,`desktop`],default:`mo`}).option(`template`,{description:"Required for --format=xml|desktop: the file msgfmt substitutes into. Its SUFFIX matters — msgfmt --xml finds its ITS rules by filename pattern, so an AppStream template must be named `*.metainfo.xml[.in]`.",type:`string`,normalize:!0}).option(`metainfo`,{description:`Deprecated alias for --template.`,type:`string`,normalize:!0,hidden:!0}).option(`filename`,{description:`Override the output filename (defaults to <domain>.<ext>)`,type:`string`,normalize:!0}).option(`remove-xml-comments`,{description:`For --format=xml: strip XML comments from the compiled output`,type:`boolean`,default:!0}).option(`verbose`,{description:`Print each msgfmt invocation`,type:`boolean`,default:!1}),handler:async t=>{let n=xn(t.poDir),S=xn(t.outDir),C=t.domain,N=t.format??`mo`,F=t.template??t.metainfo,I=F?xn(F):void 0,H=t.filename??defaultFilename(C,N,I),W=!!t.verbose,q=!!t[`remove-xml-comments`];if(!await fileExists(n)){ge.error(`[gjsify gettext] PO directory does not exist: ${n}`),process.exitCode=1;return}if(N!==`mo`&&I===void 0){ge.error(`[gjsify gettext] --format=${N} needs a template to substitute into: pass \`--template <file>\`. msgfmt has no way to produce this format from .po files alone.`+(N===`xml`?" Name it `*.metainfo.xml[.in]` — msgfmt --xml finds its ITS rules by filename pattern.":``)),process.exitCode=1;return}try{N===`mo`?await compileCatalogues({poDir:n,outDir:S,filename:H,verbose:W}):await compileMerged({poDir:n,outDir:S,format:N,template:I,filename:H,removeXmlComments:q,verbose:W})}catch(t){let n=t;n?.code===`ENOENT`?ge.error(`[gjsify gettext] msgfmt not found. Install it via your distro (package: gettext).`):(n?.stderr&&process.stderr.write(n.stderr),ge.error(`[gjsify gettext] msgfmt failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}}}),uz,dz,fz=__esmMin(()=>{_e(),P_(),xd(),Pn(),Tu(),uz=promisify(execFile),dz={command:`gsettings <schemadir>`,description:"Compile GSettings schema XML files into a binary gschemas.compiled (wraps `glib-compile-schemas`).",builder:t=>t.positional(`schemadir`,{description:`Directory containing *.gschema.xml descriptors`,type:`string`,normalize:!0,demandOption:!0}).option(`targetdir`,{alias:`t`,description:`Directory to write gschemas.compiled (default: <schemadir>)`,type:`string`,normalize:!0}).option(`strict`,{description:`Abort on any schema warning (passes --strict to glib-compile-schemas)`,type:`boolean`,default:!0}).option(`verbose`,{description:`Print the underlying glib-compile-schemas invocation`,type:`boolean`,default:!1}),handler:async t=>{let n=xn(t.schemadir),S=t.targetdir?xn(t.targetdir):n,C=[];t.strict&&C.push(`--strict`),C.push(`--targetdir=${S}`),C.push(n),t.verbose&&ge.log(`[gjsify gsettings] glib-compile-schemas ${C.join(` `)}`),await mkdir$1(S,{recursive:!0});try{let{stdout:n,stderr:N}=await uz(`glib-compile-schemas`,C);n&&process.stdout.write(n),N&&process.stderr.write(N),t.verbose&&ge.log(`[gjsify gsettings] wrote ${S}/gschemas.compiled`)}catch(t){let n=t;n?.code===`ENOENT`?ge.error(`[gjsify gsettings] glib-compile-schemas not found. Install it via your distro (package: glib2-devel / libglib2.0-dev).`):(n?.stderr&&process.stderr.write(n.stderr),ge.error(`[gjsify gsettings] glib-compile-schemas failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}}});function readPackageJson(t){let n=xn(t,`package.json`),S;try{S=readFileSync(n,`utf-8`)}catch{throw Error(`gjsify flatpak: no package.json found at ${n}`)}try{return JSON.parse(S)}catch(t){throw Error(`gjsify flatpak: package.json at ${n} is not valid JSON: ${t.message}`)}}function looksLikeAppId(t){return typeof t==`string`&&/^[A-Za-z][A-Za-z0-9_-]*(\.[A-Za-z][A-Za-z0-9_-]*){2,}$/.test(t)}function defaultCiContainer(t,n){return`ghcr.io/flathub-infra/flatpak-github-actions:${`${t}-${n}`}`}var pz,mz=__esmMin(()=>{Rd(),Pn(),pz=`gjsify-sources.json`});function resolveRuntime(t,n){let S=n.runtime??t?.runtime??`gnome`;if(S!==`gnome`&&S!==`freedesktop`)throw Error(`gjsify flatpak: unknown runtime "${S}" (expected "gnome" or "freedesktop")`);let C=n.runtimeVersion??t?.runtimeVersion??(S===`gnome`?`50`:`24.08`);return S===`gnome`?{runtime:S,runtimeId:`org.gnome.Platform`,sdk:`org.gnome.Sdk`,runtimeVersion:C}:{runtime:S,runtimeId:`org.freedesktop.Platform`,sdk:`org.freedesktop.Sdk`,runtimeVersion:C}}function deriveAppendPath(t){let n=[];for(let S of t){let t=/^org\.freedesktop\.Sdk\.Extension\.([A-Za-z0-9-]+)$/.exec(S);t&&n.push(`/usr/lib/sdk/${t[1]}/bin`)}return n.push(`/app/bin`),n}var hz,gz,_z=__esmMin(()=>{hz=[`--device=dri`,`--share=ipc`,`--socket=fallback-x11`,`--socket=wayland`],gz=[]});function pickFlatpakBuildKeys(t,n){let S=t??{},C={},N=[];for(let t of yz){let F=S[t];if(F!==void 0){C[t]=F;continue}let I=n[t];I!==void 0&&N.push(t),C[t]=I}return{values:C,fromLegacy:N}}function resolveShipFlatpakSettings(t){let n=t.ship.flatpak??{},{values:S,fromLegacy:C}=pickFlatpakBuildKeys(n,t.flatpak),N=resolveRuntime(S,{}),F=S.sdkExtensions??[],{appendPath:I,finishArgs:H,cleanup:W}=S;return{settings:{runtime:N.runtimeId,runtimeVersion:N.runtimeVersion,sdk:N.sdk,branch:n.branch??`stable`,sdkExtensions:[...F],appendPath:I??(F.length>0?deriveAppendPath(F):[]),finishArgs:H??(t.kind===`cli`?gz:hz),cleanup:[...new Set([...W??[],...t.kind===`app`?[bz]:[]])]},warnings:C.length===0?[]:[deprecationWarning(C)]}}function assertNoDroppedFlatpakModules(t){let n=[`modules`,`extraModules`].filter(n=>(t[n]?.length??0)>0);if(n.length===0)return;let S=n.map(t=>`gjsify.flatpak.${t}`).join(` and `);throw Error(`gjsify ship: ${S} ${n.length>1?`are`:`is`} set, but the \`flatpak\` target renders ONE module, the staged payload, and would drop ${n.length>1?`them`:`it`} (ADR 0024 § 2). Build this Flatpak with \`gjsify flatpak init\` + \`gjsify flatpak build\`, which honour the key, or leave \`flatpak\` out of \`--target\` / \`gjsify.ship.targets\`.`)}function deprecationWarning(t){let n=t.map(t=>`gjsify.flatpak.${t}`).join(`, `),S=t.map(t=>`gjsify.ship.flatpak.${t}`).join(`, `);return`DEPRECATION: ${n} ${t.length>1?`are`:`is`} read by \`gjsify ship\` for compatibility and will be removed in ${vz}. Move ${t.length>1?`them`:`it`} to ${S} — both spellings resolve until then, and \`gjsify.ship.flatpak\` wins where both are set. The app METADATA in \`gjsify.flatpak\` (name, summary, developer, categories, licence) is NOT deprecated: both blocks describe the same application and either may carry it (ADR 0024 § 8).`}var vz,yz,bz,xz=__esmMin(()=>{_z(),vz=`1.0.0`,yz=[`runtime`,`runtimeVersion`,`sdkExtensions`,`appendPath`,`finishArgs`,`cleanup`],bz=`/share/icons/hicolor/scalable`});function loadDesktopTemplate(){return Sz}function validateAppMetadata(t){let n=t.metadata,S=t.configKey,C=[];return(!n.developer?.id||!n.developer?.name)&&C.push({field:`${S}.developer`,hint:`Set \`${S}.developer = { "id": "io.github.you", "name": "Your Name" }\` in package.json. The id is reverse-DNS.`}),n.summary||C.push({field:`${S}.summary`,hint:`One-line app summary, ≤80 chars, no trailing period. Example: "Learn 6502 assembly language".`}),n.description||C.push({field:`${S}.description`,hint:`Plain text (split on blank lines) or DescriptionBlock[] for rich content with bullet lists + translator hints.`}),n.license?.project||C.push({field:`${S}.license.project`,hint:`SPDX identifier of the project license, e.g. "MIT", "GPL-3.0-or-later".`}),n.homepageUrl||C.push({field:`${S}.homepageUrl`,hint:`Required by Flathub. Example: "https://github.com/you/your-repo".`}),C}function renderMetainfoApp$1(t){return renderMetainfo(t,`desktop-application`)}function renderMetainfoCli$1(t){return renderMetainfo(t,`console-application`)}function renderDesktopEntry(t){let n=t.metadata,S=(n.categories??[`Utility`]).join(`;`)+`;`,C=n.keywords?.length?`Keywords=${n.keywords.join(`;`)};\n`:``,N=n.provides?.mimetypes??[],F=N.length?`MimeType=${N.join(`;`)};\n`:``;return substitute(loadDesktopTemplate(),{NAME:t.name,SUMMARY:n.summary??t.name,COMMAND:`${t.command}${execFieldCode(N)}`,APP_ID:t.appId,CATEGORIES_LINE:S,KEYWORDS_LINE:C,MIMETYPES_LINE:F})}function execFieldCode(t){return t.some(t=>t.startsWith(`x-scheme-handler/`))?` %u`:t.length>0?` %f`:``}function renderMetainfo(t,n){let S=t.metadata,C=t.copyrightYear??new Date().getFullYear(),N=S.developer?.name??``,F=[];F.push(`<?xml version="1.0" encoding="UTF-8"?>`),F.push(`<!-- Copyright ${C} ${escapeXml(N)} -->`),F.push(`<component type="${n}">`),F.push(` <id>${escapeXml(t.appId)}</id>`),F.push(` <metadata_license>${escapeXml(S.license?.metadata??`CC0-1.0`)}</metadata_license>`),F.push(` <project_license>${escapeXml(S.license?.project??``)}</project_license>`),F.push(` <name>${escapeXml(t.name)}</name>`),pushTranslatorHint(F,S.summaryTranslatorHint,` `),F.push(` <summary>${escapeXml(S.summary??t.name)}</summary>`),S.iconRemote&&F.push(` <icon type="remote">${escapeXml(S.iconRemote)}</icon>`),F.push(` <description>`);for(let t of renderDescriptionBlocks(S.description??``,` `))F.push(t);if(F.push(` </description>`),S.developer?.id&&S.developer?.name){F.push(` <developer id="${escapeXml(S.developer.id)}">`);let t=S.developer.nameTranslatable===!0?``:` translate="no"`;F.push(` <name${t}>${escapeXml(S.developer.name)}</name>`),S.developer.email&&F.push(` <email>${escapeXml(S.developer.email)}</email>`),F.push(` </developer>`)}n===`desktop-application`&&F.push(` <launchable type="desktop-id">${escapeXml(t.appId)}.desktop</launchable>`),S.screenshots?.length&&(F.push(` <screenshots>`),S.screenshots.forEach((t,n)=>{let S=t.type??(n===0?`default`:void 0),C=S?` type="${escapeXml(S)}"`:``,N=t.environment?` environment="${escapeXml(t.environment)}"`:``;F.push(` <screenshot${C}${N}>`),F.push(` <image>${escapeXml(t.url)}</image>`);for(let[n,S]of Object.entries(t.localizedUrls??{}))F.push(` <image xml:lang="${escapeXml(n)}">${escapeXml(S)}</image>`);t.caption&&(pushTranslatorHint(F,t.captionTranslatorHint,` `),F.push(` <caption>${escapeXml(t.caption)}</caption>`)),F.push(` </screenshot>`)}),F.push(` </screenshots>`)),S.homepageUrl&&F.push(` <url type="homepage">${escapeXml(S.homepageUrl)}</url>`),S.bugtrackerUrl&&F.push(` <url type="bugtracker">${escapeXml(S.bugtrackerUrl)}</url>`),S.vcsBrowserUrl&&F.push(` <url type="vcs-browser">${escapeXml(S.vcsBrowserUrl)}</url>`),S.donationUrl&&channelAllowsDonations(t.channel)&&F.push(` <url type="donation">${escapeXml(S.donationUrl)}</url>`),S.translateUrl&&F.push(` <url type="translate">${escapeXml(S.translateUrl)}</url>`);let I=normaliseContentRating(S.contentRating);if(I.attributes&&Object.keys(I.attributes).length>0){F.push(` <content_rating type="${escapeXml(I.type)}">`);for(let[t,n]of Object.entries(I.attributes))F.push(` <content_attribute id="${escapeXml(t)}">${escapeXml(n)}</content_attribute>`);F.push(` </content_rating>`)}else F.push(` <content_rating type="${escapeXml(I.type)}" />`);if(S.releases?.length){F.push(` <releases>`);for(let t of S.releases)if(t.description===void 0)F.push(` <release version="${escapeXml(t.version)}" date="${escapeXml(t.date)}" />`);else{F.push(` <release version="${escapeXml(t.version)}" date="${escapeXml(t.date)}">`),F.push(` <description>`);for(let n of renderDescriptionBlocks(t.description,` `))F.push(n);F.push(` </description>`),F.push(` </release>`)}F.push(` </releases>`)}if(S.categories?.length){F.push(` <categories>`);for(let t of S.categories)F.push(` <category>${escapeXml(t)}</category>`);F.push(` </categories>`)}if(S.keywords?.length){F.push(` <keywords>`);for(let t of S.keywords)F.push(` <keyword>${escapeXml(t)}</keyword>`);F.push(` </keywords>`)}if(n===`desktop-application`&&S.branding&&(F.push(` <branding>`),F.push(` <color type="primary" scheme_preference="light">${escapeXml(S.branding.accentLight)}</color>`),F.push(` <color type="primary" scheme_preference="dark">${escapeXml(S.branding.accentDark)}</color>`),F.push(` </branding>`)),S.kudos?.length){F.push(` <kudos>`);for(let t of S.kudos)F.push(` <kudo>${escapeXml(t)}</kudo>`);F.push(` </kudos>`)}let H=S.provides?.binaries??[t.command],W=S.provides?.mimetypes??[],q=S.provides?.dbus??[];if(H.length||W.length||q.length){F.push(` <provides>`);for(let t of H)F.push(` <binary>${escapeXml(t)}</binary>`);for(let t of W)F.push(` <mediatype>${escapeXml(t)}</mediatype>`);for(let t of q)F.push(` <dbus type="${escapeXml(t.type)}">${escapeXml(t.id)}</dbus>`);F.push(` </provides>`)}if(S.supports?.controls?.length||S.supports?.internet){F.push(` <supports>`);for(let t of S.supports.controls??[])F.push(` <control>${escapeXml(t)}</control>`);S.supports.internet&&F.push(` <internet>${escapeXml(S.supports.internet)}</internet>`),F.push(` </supports>`)}if(S.requires?.displayLengthMin||S.requires?.controls?.length||S.requires?.internet){F.push(` <requires>`),S.requires.displayLengthMin&&F.push(` <display_length compare="ge">${S.requires.displayLengthMin}</display_length>`);for(let t of S.requires.controls??[])F.push(` <control>${escapeXml(t)}</control>`);S.requires.internet&&F.push(` <internet>${escapeXml(S.requires.internet)}</internet>`),F.push(` </requires>`)}if(S.recommends?.displayLengthMin||S.recommends?.controls?.length){F.push(` <recommends>`),S.recommends.displayLengthMin&&F.push(` <display_length compare="ge">${S.recommends.displayLengthMin}</display_length>`);for(let t of S.recommends.controls??[])F.push(` <control>${escapeXml(t)}</control>`);F.push(` </recommends>`)}return F.push(`</component>`),F.join(`
|
|
952
952
|
`)+`
|
|
953
953
|
`}function renderDescriptionBlocks(t,n){let S=typeof t==`string`?stringToBlocks(t):t,C=[];for(let t of S)if(`p`in t)pushTranslatorHint(C,t.translatorHint,n),C.push(`${n}<p>${escapeXml(t.p.trim().replace(/\s+/g,` `))}</p>`);else{pushTranslatorHint(C,t.translatorHint,n),C.push(`${n}<ul>`);for(let S of t.ul)typeof S==`string`?C.push(`${n} <li>${escapeXml(S)}</li>`):(pushTranslatorHint(C,S.translatorHint,`${n} `),C.push(`${n} <li>${escapeXml(S.item)}</li>`));C.push(`${n}</ul>`)}return C}function stringToBlocks(t){return t.trim().split(/\n\n+/).map(t=>({p:t.trim().replace(/\s+/g,` `)}))}function pushTranslatorHint(t,n,S){n&&t.push(`${S}<!-- TRANSLATORS: ${n} -->`)}function normaliseContentRating(t){return t===void 0?{type:`oars-1.1`}:typeof t==`string`?{type:t}:{type:t.type??`oars-1.1`,attributes:t.attributes}}function substitute(t,n){let S=t;for(let[t,C]of Object.entries(n))S=S.split(`{{${t}}}`).join(C);return S}function escapeXml(t){return t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var Sz,Cz=__esmMin(()=>{ch(),Sz=`[Desktop Entry]
|
|
954
954
|
Name={{NAME}}
|
|
@@ -1086,7 +1086,7 @@ jobs:
|
|
|
1086
1086
|
manifest-path: ${t.manifest}
|
|
1087
1087
|
bundle: ${t.bundle}
|
|
1088
1088
|
cache-key: ${t.cacheKey}
|
|
1089
|
-
`}var Vz,Hz=__esmMin(()=>{_e(),Rd(),Pn(),wI(),mz(),_z(),xz(),Vz={command:`ci`,description:`Scaffold .github/workflows/flatpak.yml using the flathub-infra container + flatpak-builder@v6 action.`,builder:t=>t.option(`manifest`,{description:`Manifest path the workflow points at (default: <app-id>.json)`,type:`string`,normalize:!0}).option(`bundle`,{description:`Bundle filename produced by the action (default: <app-id>.flatpak)`,type:`string`,normalize:!0}).option(`runtime-image`,{description:"Container image override. Default derived from gjsify.flatpak.runtime + runtimeVersion (e.g. `ghcr.io/flathub-infra/flatpak-github-actions:gnome-50`).",type:`string`}).option(`branches`,{description:`Branches the workflow runs on push for (default: main)`,type:`string`,array:!0}).option(`out`,{description:`Output path`,type:`string`,default:`.github/workflows/flatpak.yml`,normalize:!0}).option(`cache-key`,{description:"Override the action `cache-key` (default: `flatpak-builder-${{ github.sha }}`)",type:`string`}).option(`force`,{description:`Overwrite an existing workflow file`,type:`boolean`,default:!1}).option(`verbose`,{description:`Print resolved fields`,type:`boolean`,default:!1}),handler:async t=>{let n=process.cwd(),S=await new Config().forCommand().catch(()=>({})),C=S.flatpak??{},N=readPackageJson(n),F=C.appId??(looksLikeAppId(N.name)?N.name:void 0);if(!F)throw Error(`gjsify flatpak ci: no app id available. Set gjsify.flatpak.appId in package.json or rename the package to a reverse-DNS id.`);let I=t.manifest??`${F}.json`,H=t.bundle??`${F}.flatpak`,W=pickFlatpakBuildKeys(S.ship?.flatpak,C).values,{runtime:q,runtimeVersion:Y}=resolveRuntime(W,{}),X=t.runtimeImage??C.ciContainer??defaultCiContainer(q,Y),Z=t.branches??C.ciBranches??[`main`],te=t.cacheKey??"flatpak-builder-${{ github.sha }}",ne=xn(n,t.out??`.github/workflows/flatpak.yml`);if(existsSync(ne)&&!t.force){if(readFileSync(ne,`utf-8`)===renderWorkflow({manifest:I,bundle:H,runtimeImage:X,branches:Z,cacheKey:te})){ge.log(`[gjsify flatpak ci] ${ne} already up to date`);return}throw Error(`gjsify flatpak ci: ${ne} exists with different content. Pass --force to overwrite.`)}let re=renderWorkflow({manifest:I,bundle:H,runtimeImage:X,branches:Z,cacheKey:te});mkdirSync(En(ne),{recursive:!0}),writeFileSync(ne,re,`utf-8`),t.verbose&&ge.log(`[gjsify flatpak ci] runtime-image=${X} manifest=${I} bundle=${H}`),ge.log(`[gjsify flatpak ci] wrote ${ne}`)}}});function buildTree(t){let n={name:`#root`,attrs:{},children:[],text:``},S=[n];for(let n of scanXml(t)){let t=S[S.length-1];if(n.kind===`text`)for(let t of S)t.text+=n.text;else if(n.kind===`open`){let C={name:normName(n.name),attrs:n.attributes,children:[],text:``};t.children.push(C),n.selfClosing||S.push(C)}else S.length>1&&S.pop()}return n}function localized(t,n){let S=new Map;for(let C of kids(t,n)){let t=clean(C.text);t!==``&&!S.has(lang(C))&&S.set(lang(C),t)}return S}function parseHex(t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(n===null)return null;let S=n[1];S.length===3&&(S=S.replace(/./g,t=>t+t));let C=Number.parseInt(S.slice(0,2),16)/255,N=Number.parseInt(S.slice(2,4),16)/255,F=Number.parseInt(S.slice(4,6),16)/255,I=Math.max(C,N,F),H=Math.min(C,N,F),W=(I+H)/2,q=I-H;return{s:q===0?0:q/(1-Math.abs(2*W-1)),l:W}}function readImageInfo(t){if(t.length>=24&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71){let u32=n=>(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0;return{kind:`raster`,width:u32(16),height:u32(20)}}if(t.length>=4&&t[0]===255&&t[1]===216){let n=2;for(;n+9<t.length;){if(t[n]!==255){n++;continue}let S=t[n+1];if(S===255){n++;continue}if(S>=192&&S<=207&&S!==196&&S!==200&&S!==204)return{kind:`raster`,height:t[n+5]<<8|t[n+6],width:t[n+7]<<8|t[n+8]};n+=2+(t[n+2]<<8|t[n+3])}return null}let n=``;for(let S=0;S<Math.min(t.length,1024);S++)n+=String.fromCharCode(t[S]);return/<svg[\s>]/.test(n)?{kind:`svg`}:null}function termPattern(t,n=`iu`){let S=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\s+/g,`\\s+`);return RegExp(`(^|[^\\p{L}\\p{N}])${S}($|[^\\p{L}\\p{N}])`,n)}async function lintMetainfo(t,n={}){let S=[],add=(t,n,C,N,F)=>{S.push({rule:t,severity:n,message:F,location:N,url:`${Uz}#${C}`})},C=child(buildTree(t),`component`);if(C===void 0)return add(`no-component`,`error`,`app-name`,`document`,`no <component> element found`),S;let loc=(t,n)=>n===``?t:`${t}[${n}]`,N=localized(C,`name`),F=localized(C,`summary`);for(let[t,n]of N){let S=loc(`name`,t),C=[...n].length;if(C>=20?add(`name-too-long`,`error`,`not-too-long`,S,`"${n}" is ${C} characters; a name must be shorter than 20`):C>15&&add(`name-long`,`warning`,`not-too-long`,S,`"${n}" is ${C} characters; ideally at most 15`),/\s[-–—:]\s|:\s|\(.+\)/.test(n)||/\b(web browser|editor|client|viewer|player)$/i.test(n)&&n.includes(` `))add(`name-extra-info`,`warning`,`just-the-name`,S,`"${n}" carries a description; keep just the name and put the rest in the summary`);else if(/[.-]/.test(n))add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" contains a dot or dash; avoid punctuation in names`);else if(/\p{L}/u.test(n)){let t=n.replace(/[^\p{L}]/gu,``);n===n.toLowerCase()?add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" is all lowercase`):t.length>1&&n===n.toUpperCase()?add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" is all uppercase (exempt only for an established brand such as VLC)`):!/\s/.test(n)&&/\p{Ll}\p{Lu}/u.test(n)&&add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" is camel/pascal case`)}}let I=(n.technicalTerms??[...Wz]).map(t=>({term:t,re:termPattern(t)}));for(let[t,n]of F){let S=loc(`summary`,t),C=[...n].length;C>35?add(`summary-too-long`,`error`,`not-too-long-1`,S,`"${n}" is ${C} characters; at most 35 allowed`):(C>25||C<10)&&add(`summary-length`,`warning`,`not-too-long-1`,S,`"${n}" is ${C} characters; ideal is 10 to 25`),/[.。]$/.test(n)&&add(`summary-full-stop`,`warning`,`no-weird-formatting-1`,S,`a summary does not end with a full stop`);let F=n.split(/\s+/).filter(t=>/^\p{L}/u.test(t)),H=F.filter(t=>/^\p{Lu}/u.test(t)).length;F.length>=3&&H/F.length>=.75&&add(`summary-title-case`,`warning`,`no-weird-formatting-1`,S,`use sentence case, not Title Case`);let W=Kz[langBase(t===``?`en`:t)],q=n.split(/\s+/)[0]?.toLowerCase();W?.includes(q)&&add(`summary-article`,`warning`,`dont-start-with-an-article`,S,`starts with the article "${q}"; omit it or phrase it with a verb`);let Y=N.get(t)??N.get(``);Y!==void 0&&[...Y].length>=3&&termPattern(Y,`u`).test(n)&&add(`summary-repeats-name`,`warning`,`dont-repeat-the-name`,S,`repeats the app name "${Y}"`);let X=I.find(({re:t})=>t.test(n));X!==void 0&&add(`summary-technical`,`warning`,`not-technical`,S,`mentions "${X.term}"; say what the app does for people, not how it is built`)}let H=kids(C,`description`).find(t=>lang(t)===``)??child(C,`description`);if(H!==void 0){let t=F.get(``)??``,n=kids(H,`p`).filter(t=>lang(t)===``).map(t=>clean(t.text)),S=n.join(` `);t!==``&&n.length>0&&n[0].replace(/[.!]$/,``).toLowerCase()===t.toLowerCase()&&add(`description-repeats-summary`,`warning`,`dont-repeat-the-summary`,`description`,`the first paragraph repeats the summary`),t!==``&&[...S].length<Math.max(80,3*[...t].length)&&add(`description-short`,`warning`,`not-too-short`,`description`,`${[...S].length} characters; it should be substantially longer than the summary`);for(let t of[...kids(H,`ul`),...kids(H,`ol`)]){let n=kids(t,`li`).filter(t=>lang(t)===``).length;n>10&&add(`description-long-list`,`warning`,`no-super-long-lists`,`description`,`a list with ${n} items; group them or use paragraphs (max 10)`)}}let W=kids(child(C,`branding`),`color`).filter(t=>t.attrs.type===`primary`),q=W.find(t=>t.attrs.scheme_preference===`light`),Y=W.find(t=>t.attrs.scheme_preference===`dark`);if(q===void 0||Y===void 0)add(`branding-missing`,`warning`,`has-primary-brand-colors`,`branding`,`set two primary brand colors, scheme_preference="light" and "dark"`);else{let t=clean(q.text).toLowerCase(),n=clean(Y.text).toLowerCase();t===n&&add(`branding-identical`,`warning`,`good-brand-colors`,`branding`,`light and dark primary colors are the same`);let S=parseHex(t),C=parseHex(n);for(let[N,F,I]of[[`light`,S,t],[`dark`,C,n]])F!==null&&(F.s<.15||F.l>.93||F.l<.07)&&add(`branding-dull`,`warning`,`good-brand-colors`,`branding/${N}`,`${I} is near white, black or gray; brand colors should be colorful`);S!==null&&C!==null&&t!==n&&C.l>=S.l&&add(`branding-dark-not-darker`,`warning`,`good-brand-colors`,`branding/dark`,`the dark variant should be darker than the light one`)}if(n.probeImage!==void 0)for(let t of n.iconRefs??[]){let S=await n.probeImage(t);if(S!==null){S.kind===`raster`&&(S.width===S.height?S.width<256&&add(`icon-too-small`,`error`,`icon-size`,`icon`,`${t} is ${S.width}×${S.height}; use SVG or at least 256×256`):add(`icon-not-square`,`error`,`icon-size`,`icon`,`${t} is ${S.width}×${S.height}; the icon has to be square`));break}}let X=kids(child(C,`screenshots`),`screenshot`);if(X.length===0)add(`screenshot-missing`,`warning`,`at-least-one-screenshot`,`screenshots`,`at least one screenshot is expected`);else{let isEnglish=t=>[lang(t),...kids(t,`image`).map(lang)].every(t=>t===``||langBase(t)===`en`);X.some(isEnglish)||add(`screenshot-no-english`,`warning`,`at-least-one-screenshot`,`screenshots`,`no screenshot without xml:lang (or in English)`),X[0].attrs.type!=="default"&&add(`screenshot-default-not-first`,`warning`,`at-least-one-screenshot`,`screenshot[1]`,`the first screenshot should be type="default" — it is the one users see first`);for(let t=0;t<X.length;t++){let S=X[t],C=`screenshot[${t+1}]`,N=kids(S,`caption`);N.length===0&&add(`screenshot-caption-missing`,`warning`,`image-captions`,C,`no <caption>`);for(let t of N){let n=clean(t.text),S=`${C}/${loc(`caption`,lang(t))}`;/[.。]$/.test(n)&&add(`caption-full-stop`,`warning`,`image-captions`,S,`a caption does not end with a full stop`),/^\d/.test(n)&&add(`caption-starts-with-number`,`warning`,`image-captions`,S,`a caption does not start with a number`),/[.!?]\s+\p{Lu}/u.test(n)&&add(`caption-multiple-sentences`,`warning`,`image-captions`,S,`a caption is one sentence`)}if(n.probeImage!==void 0){let t=kids(S,`image`).find(t=>(t.attrs.type??`source`)===`source`),N=t===void 0?``:clean(t.text),F=N===``?null:await n.probeImage(N);F?.kind===`raster`&&(F.width>2e3||F.height>1400)&&add(`screenshot-too-large`,`warning`,`reasonable-window-size`,C,`${F.width}×${F.height}; keep the window at most 1000×700 (2000×1400 on HiDPI)`)}}}for(let t of kids(child(C,`releases`),`release`)){let n=`release ${t.attrs.version??`?`}`,S=child(t,`description`),C=S===void 0?``:clean(S.text);if(C===``){add(`release-notes-missing`,`warning`,`release-notes-for-every-release`,n,`no release notes`);continue}Gz.some(t=>t.test(C.replace(/[.!]+$/,``)))?add(`release-notes-generic`,`warning`,`no-bug-fixes-and-performance-improvements`,n,`"${C}" says nothing about what changed`):([...C].length>600||kids(child(S,`ul`),`li`).length>10)&&add(`release-notes-long`,`warning`,`short-but-informative`,n,`release notes are long; summarise what changed for users`)}return S}function summarizeFindings(t,n){let S=0,C=0;for(let N of t)N.severity===`error`||n?S++:C++;return{errors:S,warnings:C}}function formatFinding(t,n){return`${(n?`error`:t.severity).padEnd(7)} ${t.rule} ${t.location}: ${t.message}\n ${t.url}`}var Uz,Wz,Gz,Kz,normName,child,kids,clean,lang,langBase,qz=__esmMin(()=>{He(),Uz=`https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/quality-guidelines`,Wz=`GTK.GTK3.GTK4.Qt.Qt5.Qt6.libadwaita.Electron.Rust.Python.JavaScript.TypeScript.GJS.Flatpak.written in.open source.open-source.free software.FOSS.app.application.tool.client.wrapper.App.Anwendung.Werkzeug`.split(`.`),Gz=[/^(minor |various |general |misc(ellaneous)? )?bug ?fix(es)?( (and|&) (minor )?(performance )?(improvements?|fixes|tweaks))?$/i,/^(minor |various |general )?(performance )?improvements?( (and|&) (bug ?fix(es)?|fixes))?$/i,/^bug ?fix(es)?,? (and )?(performance|stability) improvements?$/i,/^(performance|stability) (improvements?|fixes)( (and|&) bug ?fix(es)?)?$/i,/^(fehlerbehebungen?|fehlerkorrekturen?|verbesserungen)( (und|&) (fehlerbehebungen?|verbesserungen|leistungsverbesserungen))?$/i,/^(kleinere )?(fehlerbehebungen|verbesserungen)$/i],Kz={en:[`a`,`an`,`the`],de:[`ein`,`eine`,`einen`,`einem`,`einer`,`der`,`die`,`das`,`den`,`dem`]},normName=t=>t.startsWith(`_`)?t.slice(1):t,child=(t,n)=>t?.children.find(t=>t.name===n),kids=(t,n)=>t?.children.filter(t=>t.name===n)??[],clean=t=>t.replace(/\s+/g,` `).trim(),lang=t=>t.attrs[`xml:lang`]??``,langBase=t=>t.split(/[_\-.@]/)[0].toLowerCase()});async function runQuality(t,n,S){let C=En(t),probeImage=async t=>{if(/^https?:\/\//.test(t)){if(!S.qualityNetwork)return null;try{let n=await fetch(t);return n.ok?readImageInfo(new Uint8Array(await n.arrayBuffer())):null}catch{return null}}let n=xn(C,t);return existsSync(n)?readImageInfo(new Uint8Array(readFileSync(n))):null},N=n??``,F=N?[`icons/hicolor/scalable/apps/${N}.svg`,`icons/${N}.svg`,`${N}.svg`,`${N}.png`,`../data/icons/hicolor/scalable/apps/${N}.svg`]:[],I=await lintMetainfo(readFileSync(t,`utf-8`),{probeImage,iconRefs:F}),H=S.strict===!0,{errors:W,warnings:q}=summarizeFindings(I,H);if(S.json)ge.log(JSON.stringify({file:t,errors:W,warnings:q,findings:I.map(t=>({...t,severity:H?`error`:t.severity}))},null,2));else{for(let t of I)ge.log(formatFinding(t,H));ge.log(`[gjsify flatpak check] ${W===0?`OK`:`FAIL`}: quality ${t} — ${W} error(s), ${q} warning(s)`)}return W===0}function resolveAppId(t,n,S){if(n.appId)return n.appId;try{let t=readPackageJson(S);if(looksLikeAppId(t.name))return t.name}catch{}if(t)return t.replace(/\.json$/,``)}function resolveManifestPath(t,n,S){if(t)return xn(S,t);if(n)return xn(S,`${n}.json`);let C=readdirSync(S).filter(t=>t.endsWith(`.json`)&&!t.startsWith(`package`));if(C.length===1)return xn(S,C[0]);throw Error(`gjsify flatpak check: no manifest path given and could not auto-detect. Pass the manifest as a positional argument.`)}async function runLinter(t,n,S){let C;try{C=await spawnToCompletion(t,n,{completion:`return`,stdio:S?`inherit`:`capture`})}catch(n){let S=n;return S.code===`ENOENT`?ge.error(`[gjsify flatpak check] ${t} not found in PATH.\nInstall via:\n flatpak install -y flathub org.flatpak.Builder\n alias ${t}="flatpak run --command=${t} org.flatpak.Builder"`):ge.error(`[gjsify flatpak check] ${t} failed to spawn: ${S.message}`),!1}let N=C.code===0;return ge.log(`[gjsify flatpak check] ${N?`OK`:`FAIL`}: ${t} ${n.join(` `)}`),!N&&!S&&(C.stdout?.trim()&&ge.log(C.stdout.trimEnd()),C.stderr?.trim()&&ge.error(C.stderr.trimEnd())),N}var Jz,Yz=__esmMin(()=>{_e(),Rd(),Pn(),V_(),mz(),wI(),qz(),Jz={command:`check [manifest]`,description:`Run Flathub pre-submission linters: appstreamcli validate + flatpak-builder-lint.`,builder:t=>t.positional(`manifest`,{description:"Path to the Flatpak manifest. Auto-detects `<app-id>.json` if omitted.",type:`string`,normalize:!0}).option(`repo`,{description:"Built ostree-repo path. If given, also runs `flatpak-builder-lint repo`.",type:`string`,normalize:!0}).option(`metainfo`,{description:"MetaInfo XML path. Default: `data/<app-id>.metainfo.xml.in`.",type:`string`,normalize:!0}).option(`appstream`,{description:"Run `appstreamcli validate --strict` (default: true).",type:`boolean`,default:!0}).option(`quality`,{description:`Run Flathub's quality guidelines (name, summary, branding, screenshots, release notes) on the MetaInfo (default: true).`,type:`boolean`,default:!0}).option(`strict`,{description:`Treat quality warnings as errors.`,type:`boolean`,default:!1}).option(`json`,{description:`Print the quality findings as JSON (and nothing else on stdout).`,type:`boolean`,default:!1}).option(`quality-network`,{description:`Let the quality check fetch http(s) screenshot/icon URLs to measure their size.`,type:`boolean`,default:!1}).option(`builder-lint`,{description:"Run `flatpak-builder-lint manifest` (default: true).",type:`boolean`,default:!0}).option(`verbose`,{description:`Stream linter stdout/stderr verbatim.`,type:`boolean`,default:!1}),handler:async t=>{let n=(await new Config().forCommand().catch(()=>({}))).flatpak??{},S=process.cwd(),C=resolveAppId(t.manifest,n,S),N=resolveManifestPath(t.manifest,C,S),F=xn(S,t.metainfo??`data/${C??`unknown`}.metainfo.xml.in`),I=0;if(t.appstream!==!1&&(existsSync(F)?await runLinter(`appstreamcli`,[`validate`,`--strict`,F],t.verbose??!1)||I++:ge.warn(`[gjsify flatpak check] skipping appstreamcli — ${F} not found`)),t.quality!==!1&&(existsSync(F)?await runQuality(F,C,t)||I++:ge.warn(`[gjsify flatpak check] skipping quality check — ${F} not found`)),t.builderLint!==!1&&!t.json){if(!existsSync(N))return ge.error(`[gjsify flatpak check] manifest not found: ${N}`),process.exit(1);await runLinter(`flatpak-builder-lint`,[`manifest`,N],t.verbose??!1)||I++,t.repo&&(await runLinter(`flatpak-builder-lint`,[`repo`,xn(S,t.repo)],t.verbose??!1)||I++)}if(I>0)return ge.error(`\n[gjsify flatpak check] ${I} check(s) failed.`),process.exit(1);ge.log(`[gjsify flatpak check] all checks passed.`)}}});async function readSourceListAtTag(t,n,S,C){let N;try{let{stdout:C}=await Xz(`git`,[`show`,`${n}:${S}`],{cwd:t,maxBuffer:64*1024*1024});N=C}catch(N){return await assertGitMeantAbsent(t,n,S,N),C&&ge.log(`[gjsify flatpak sync-flathub] ${S} not present at ${n} — skipping`),null}if(N.trim()===``)return C&&ge.log(`[gjsify flatpak sync-flathub] ${S} is empty at ${n} — skipping`),null;let F;try{F=JSON.parse(N)}catch(t){throw Error(`[gjsify flatpak sync-flathub] ${S} at ${n} is not JSON: `+(t instanceof Error?t.message:String(t)))}if(!Array.isArray(F)||F.length===0)throw Error(`[gjsify flatpak sync-flathub] ${S} at ${n} is not a non-empty array of flatpak sources`);return N}async function assertGitMeantAbsent(t,n,S,C){if(typeof C?.code!=`number`)throw Error(`[gjsify flatpak sync-flathub] could not run \`git show ${n}:${S}\` — `+(C instanceof Error?C.message:String(C)));if(!await Xz(`git`,[`rev-parse`,`--verify`,`--quiet`,`${n}^{commit}`],{cwd:t}).then(({stdout:t})=>t.trim()).catch(()=>``))throw Error(`[gjsify flatpak sync-flathub] ${n} does not resolve in ${t}, so whether it carries ${S} is unanswered. Run \`git fetch --tags\`, pass --version <an existing tag>, or run from the app checkout.`)}async function resolveLatestTag$1(t,n){try{let{stdout:S}=await Xz(`git`,[`describe`,`--tags`,`--abbrev=0`],{cwd:t});return n&&ge.log(`[gjsify flatpak sync-flathub] resolved latest tag → ${S.trim()}`),S.trim()||null}catch{return null}}async function resolveCommitForTag(t,n,S){try{let{stdout:C}=await Xz(`git`,[`rev-list`,`-n`,`1`,n],{cwd:t}),N=C.trim();if(!N)throw Error(`empty rev-list output`);return S&&ge.log(`[gjsify flatpak sync-flathub] resolved ${n} → ${N}`),N}catch(t){throw Error(`[gjsify flatpak sync-flathub] tag ${n} not found locally. Run \`git fetch --tags\` or pass --commit <sha>.\n underlying error: ${t instanceof Error?t.message:String(t)}`)}}function normaliseBranchSegment(t){return t.replace(/^v/,``).replace(/[^A-Za-z0-9._-]/g,`-`)}function flathubCacheRoot(){return wn(process.env.XDG_CACHE_HOME||wn(homedir(),`.cache`),`gjsify`,`flathub-sync`)}async function ensureClone(t,n,S){if(existsSync(wn(t,`.git`))){S&&ge.log(`[gjsify flatpak sync-flathub] reusing clone at ${t}`),await gitInRepo(t,[`fetch`,`origin`],S);let n=await detectDefaultBranch(t,S);await gitInRepo(t,[`checkout`,n],S),await gitInRepo(t,[`reset`,`--hard`,`origin/${n}`],S);return}mkdirSync(xn(t,`..`),{recursive:!0});let C=`https://github.com/${n}.git`;S&&ge.log(`[gjsify flatpak sync-flathub] git clone ${C} ${t}`);try{await Xz(`git`,[`clone`,C,t])}catch(t){throw t?.code===`ENOENT`?Error("[gjsify flatpak sync-flathub] `git` not found. Install git from your distro (Fedora: `dnf install git`, Debian: `apt install git`)."):t}}async function detectDefaultBranch(t,n){try{let{stdout:S}=await Xz(`git`,[`remote`,`show`,`origin`],{cwd:t}),C=S.match(/HEAD branch: (\S+)/);if(C&&C[1]&&C[1]!==`(unknown)`)return n&&ge.log(`[gjsify flatpak sync-flathub] default branch → ${C[1]}`),C[1]}catch{}return`master`}async function gitInRepo(t,n,S){S&&ge.log(`[gjsify flatpak sync-flathub] git ${n.join(` `)} (in ${t})`);let C=await spawnToCompletion(`git`,n,{completion:`return`,cwd:t,notFound:()=>Error("[gjsify flatpak sync-flathub] `git` not found. Install it from your distro.")});if(C.code!==0)throw Error(`git ${n[0]} exited ${describeExit(C)}`)}async function ghCreate(t,n,S,C,N,F){let I=[`pr`,`create`,`--repo`,n,`--head`,S,`--title`,`Update to ${C}`,`--body`,N];F&&ge.log(`[gjsify flatpak sync-flathub] gh ${I.join(` `)} (in ${t})`);let H=await spawnToCompletion(`gh`,I,{completion:`return`,cwd:t,notFound:()=>Error("[gjsify flatpak sync-flathub] `gh` (GitHub CLI) not found. Install via `dnf install gh` (Fedora), `apt install gh` (Debian/Ubuntu), or `flatpak install -y flathub com.github.cli`.")});if(H.code!==0)throw Error(`gh pr create exited ${describeExit(H)}`)}function editManifest(t,n){let S=JSON.parse(t),C=S.modules??[];if(C.length===0)throw Error(`[gjsify flatpak sync-flathub] manifest has no modules`);let N=C[0].sources??[];if(N.length===0)throw Error(`[gjsify flatpak sync-flathub] modules[0] has no sources`);let isObject=t=>typeof t==`object`,F=n.sourceIndex??N.findIndex(t=>isObject(t)&&t.type===`git`);if(F<0||F>=N.length)throw Error(`[gjsify flatpak sync-flathub] no git source found in modules[0].sources (use --source-index <n>)`);let I=N[F];if(!isObject(I)||I.type!==`git`){let t=isObject(I)?`type is "${I.type}"`:`is the file reference "${I}"`;throw Error(`[gjsify flatpak sync-flathub] modules[0].sources[${F}] ${t}, expected a git source`)}let H=I;H.tag=n.tag,H.commit=n.commit,H[`x-checker-data`]||={type:`git`,"tag-pattern":`^v(\\d+\\.\\d+\\.\\d+)$`,"version-scheme":`semantic`},n.sourcesFile&&!namesFile(N,n.sourcesFile)&&N.push(n.sourcesFile);let W=detectIndent$1(t);return JSON.stringify(S,null,W)+(t.endsWith(`
|
|
1089
|
+
`}var Vz,Hz=__esmMin(()=>{_e(),Rd(),Pn(),wI(),mz(),_z(),xz(),Vz={command:`ci`,description:`Scaffold .github/workflows/flatpak.yml using the flathub-infra container + flatpak-builder@v6 action.`,builder:t=>t.option(`manifest`,{description:`Manifest path the workflow points at (default: <app-id>.json)`,type:`string`,normalize:!0}).option(`bundle`,{description:`Bundle filename produced by the action (default: <app-id>.flatpak)`,type:`string`,normalize:!0}).option(`runtime-image`,{description:"Container image override. Default derived from gjsify.flatpak.runtime + runtimeVersion (e.g. `ghcr.io/flathub-infra/flatpak-github-actions:gnome-50`).",type:`string`}).option(`branches`,{description:`Branches the workflow runs on push for (default: main)`,type:`string`,array:!0}).option(`out`,{description:`Output path`,type:`string`,default:`.github/workflows/flatpak.yml`,normalize:!0}).option(`cache-key`,{description:"Override the action `cache-key` (default: `flatpak-builder-${{ github.sha }}`)",type:`string`}).option(`force`,{description:`Overwrite an existing workflow file`,type:`boolean`,default:!1}).option(`verbose`,{description:`Print resolved fields`,type:`boolean`,default:!1}),handler:async t=>{let n=process.cwd(),S=await new Config().forCommand().catch(()=>({})),C=S.flatpak??{},N=readPackageJson(n),F=C.appId??(looksLikeAppId(N.name)?N.name:void 0);if(!F)throw Error(`gjsify flatpak ci: no app id available. Set gjsify.flatpak.appId in package.json or rename the package to a reverse-DNS id.`);let I=t.manifest??`${F}.json`,H=t.bundle??`${F}.flatpak`,W=pickFlatpakBuildKeys(S.ship?.flatpak,C).values,{runtime:q,runtimeVersion:Y}=resolveRuntime(W,{}),X=t.runtimeImage??C.ciContainer??defaultCiContainer(q,Y),Z=t.branches??C.ciBranches??[`main`],te=t.cacheKey??"flatpak-builder-${{ github.sha }}",ne=xn(n,t.out??`.github/workflows/flatpak.yml`);if(existsSync(ne)&&!t.force){if(readFileSync(ne,`utf-8`)===renderWorkflow({manifest:I,bundle:H,runtimeImage:X,branches:Z,cacheKey:te})){ge.log(`[gjsify flatpak ci] ${ne} already up to date`);return}throw Error(`gjsify flatpak ci: ${ne} exists with different content. Pass --force to overwrite.`)}let re=renderWorkflow({manifest:I,bundle:H,runtimeImage:X,branches:Z,cacheKey:te});mkdirSync(En(ne),{recursive:!0}),writeFileSync(ne,re,`utf-8`),t.verbose&&ge.log(`[gjsify flatpak ci] runtime-image=${X} manifest=${I} bundle=${H}`),ge.log(`[gjsify flatpak ci] wrote ${ne}`)}}});function buildTree(t){let n={name:`#root`,attrs:{},children:[],text:``},S=[n];for(let n of scanXml(t)){let t=S[S.length-1];if(n.kind===`text`)for(let t of S)t.text+=n.text;else if(n.kind===`open`){let C={name:normName(n.name),attrs:n.attributes,children:[],text:``};t.children.push(C),n.selfClosing||S.push(C)}else S.length>1&&S.pop()}return n}function localized(t,n){let S=new Map;for(let C of kids(t,n)){let t=clean(C.text);t!==``&&!S.has(lang(C))&&S.set(lang(C),t)}return S}function parseHex(t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(n===null)return null;let S=n[1];S.length===3&&(S=S.replace(/./g,t=>t+t));let C=Number.parseInt(S.slice(0,2),16)/255,N=Number.parseInt(S.slice(2,4),16)/255,F=Number.parseInt(S.slice(4,6),16)/255,I=Math.max(C,N,F),H=Math.min(C,N,F),W=(I+H)/2,q=I-H;return{s:q===0?0:q/(1-Math.abs(2*W-1)),l:W}}function readImageInfo(t){if(t.length>=24&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71){let u32=n=>(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0;return{kind:`raster`,width:u32(16),height:u32(20)}}if(t.length>=4&&t[0]===255&&t[1]===216){let n=2;for(;n+9<t.length;){if(t[n]!==255){n++;continue}let S=t[n+1];if(S===255){n++;continue}if(S>=192&&S<=207&&S!==196&&S!==200&&S!==204)return{kind:`raster`,height:t[n+5]<<8|t[n+6],width:t[n+7]<<8|t[n+8]};n+=2+(t[n+2]<<8|t[n+3])}return null}let n=``;for(let S=0;S<Math.min(t.length,1024);S++)n+=String.fromCharCode(t[S]);return/<svg[\s>]/.test(n)?{kind:`svg`}:null}function termPattern(t,n=`iu`){let S=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\s+/g,`\\s+`);return RegExp(`(^|[^\\p{L}\\p{N}])${S}($|[^\\p{L}\\p{N}])`,n)}async function lintMetainfo(t,n={}){let S=[],add=(t,n,C,N,F)=>{S.push({rule:t,severity:n,message:F,location:N,url:`${Uz}#${C}`})},C=child(buildTree(t),`component`);if(C===void 0)return add(`no-component`,`error`,`app-name`,`document`,`no <component> element found`),S;let loc=(t,n)=>n===``?t:`${t}[${n}]`,N=localized(C,`name`),F=localized(C,`summary`);for(let[t,n]of N){let S=loc(`name`,t),C=[...n].length;if(C>=20?add(`name-too-long`,`error`,`not-too-long`,S,`"${n}" is ${C} characters; a name must be shorter than 20`):C>15&&add(`name-long`,`warning`,`not-too-long`,S,`"${n}" is ${C} characters; ideally at most 15`),/\s[-–—:]\s|:\s|\(.+\)/.test(n)||/\b(web browser|editor|client|viewer|player)$/i.test(n)&&n.includes(` `))add(`name-extra-info`,`warning`,`just-the-name`,S,`"${n}" carries a description; keep just the name and put the rest in the summary`);else if(/[.-]/.test(n))add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" contains a dot or dash; avoid punctuation in names`);else if(/\p{L}/u.test(n)){let t=n.replace(/[^\p{L}]/gu,``);n===n.toLowerCase()?add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" is all lowercase`):t.length>1&&n===n.toUpperCase()?add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" is all uppercase (exempt only for an established brand such as VLC)`):!/\s/.test(n)&&/\p{Ll}\p{Lu}/u.test(n)&&add(`name-formatting`,`warning`,`no-weird-formatting`,S,`"${n}" is camel/pascal case`)}}let I=(n.technicalTerms??[...Wz]).map(t=>({term:t,re:termPattern(t)}));for(let[t,n]of F){let S=loc(`summary`,t),C=[...n].length;C>35?add(`summary-too-long`,`error`,`not-too-long-1`,S,`"${n}" is ${C} characters; at most 35 allowed`):(C>25||C<10)&&add(`summary-length`,`warning`,`not-too-long-1`,S,`"${n}" is ${C} characters; ideal is 10 to 25`),/[.。]$/.test(n)&&add(`summary-full-stop`,`warning`,`no-weird-formatting-1`,S,`a summary does not end with a full stop`);let F=n.split(/\s+/).filter(t=>/^\p{L}/u.test(t)),H=F.filter(t=>/^\p{Lu}/u.test(t)).length;F.length>=3&&H/F.length>=.75&&add(`summary-title-case`,`warning`,`no-weird-formatting-1`,S,`use sentence case, not Title Case`);let W=Kz[langBase(t===``?`en`:t)],q=n.split(/\s+/)[0]?.toLowerCase();W?.includes(q)&&add(`summary-article`,`warning`,`dont-start-with-an-article`,S,`starts with the article "${q}"; omit it or phrase it with a verb`);let Y=N.get(t)??N.get(``);Y!==void 0&&[...Y].length>=3&&termPattern(Y,`u`).test(n)&&add(`summary-repeats-name`,`warning`,`dont-repeat-the-name`,S,`repeats the app name "${Y}"`);let X=I.find(({re:t})=>t.test(n));X!==void 0&&add(`summary-technical`,`warning`,`not-technical`,S,`mentions "${X.term}"; say what the app does for people, not how it is built`)}let H=kids(C,`description`).find(t=>lang(t)===``)??child(C,`description`);if(H!==void 0){let t=F.get(``)??``,n=kids(H,`p`).filter(t=>lang(t)===``).map(t=>clean(t.text)),S=n.join(` `);t!==``&&n.length>0&&n[0].replace(/[.!]$/,``).toLowerCase()===t.toLowerCase()&&add(`description-repeats-summary`,`warning`,`dont-repeat-the-summary`,`description`,`the first paragraph repeats the summary`),t!==``&&[...S].length<Math.max(80,3*[...t].length)&&add(`description-short`,`warning`,`not-too-short`,`description`,`${[...S].length} characters; it should be substantially longer than the summary`);for(let t of[...kids(H,`ul`),...kids(H,`ol`)]){let n=kids(t,`li`).filter(t=>lang(t)===``).length;n>10&&add(`description-long-list`,`warning`,`no-super-long-lists`,`description`,`a list with ${n} items; group them or use paragraphs (max 10)`)}}let W=kids(child(C,`branding`),`color`).filter(t=>t.attrs.type===`primary`),q=W.find(t=>t.attrs.scheme_preference===`light`),Y=W.find(t=>t.attrs.scheme_preference===`dark`);if(q===void 0||Y===void 0)add(`branding-missing`,`warning`,`has-primary-brand-colors`,`branding`,`set two primary brand colors, scheme_preference="light" and "dark"`);else{let t=clean(q.text).toLowerCase(),n=clean(Y.text).toLowerCase();t===n&&add(`branding-identical`,`warning`,`good-brand-colors`,`branding`,`light and dark primary colors are the same`);let S=parseHex(t),C=parseHex(n);for(let[N,F,I]of[[`light`,S,t],[`dark`,C,n]])F!==null&&(F.s<.15||F.l>.93||F.l<.07)&&add(`branding-dull`,`warning`,`good-brand-colors`,`branding/${N}`,`${I} is near white, black or gray; brand colors should be colorful`);S!==null&&C!==null&&t!==n&&C.l>=S.l&&add(`branding-dark-not-darker`,`warning`,`good-brand-colors`,`branding/dark`,`the dark variant should be darker than the light one`)}if(n.probeImage!==void 0)for(let t of n.iconRefs??[]){let S=await n.probeImage(t);if(S!==null){S.kind===`raster`&&(S.width===S.height?S.width<256&&add(`icon-too-small`,`error`,`icon-size`,`icon`,`${t} is ${S.width}×${S.height}; use SVG or at least 256×256`):add(`icon-not-square`,`error`,`icon-size`,`icon`,`${t} is ${S.width}×${S.height}; the icon has to be square`));break}}let X=kids(child(C,`screenshots`),`screenshot`);if(X.length===0)add(`screenshot-missing`,`warning`,`at-least-one-screenshot`,`screenshots`,`at least one screenshot is expected`);else{let englishTag=t=>t===``||langBase(t)===`en`,isEnglish=t=>{let n=kids(t,`image`).map(lang);return englishTag(lang(t))&&(n.length===0||n.some(englishTag))};X.some(isEnglish)||add(`screenshot-no-english`,`warning`,`at-least-one-screenshot`,`screenshots`,`no screenshot without xml:lang (or in English)`),X[0].attrs.type!=="default"&&add(`screenshot-default-not-first`,`warning`,`at-least-one-screenshot`,`screenshot[1]`,`the first screenshot should be type="default" — it is the one users see first`);for(let t=0;t<X.length;t++){let S=X[t],C=`screenshot[${t+1}]`,N=kids(S,`caption`);N.length===0&&add(`screenshot-caption-missing`,`warning`,`image-captions`,C,`no <caption>`);for(let t of N){let n=clean(t.text),S=`${C}/${loc(`caption`,lang(t))}`;/[.。]$/.test(n)&&add(`caption-full-stop`,`warning`,`image-captions`,S,`a caption does not end with a full stop`),/^\d/.test(n)&&add(`caption-starts-with-number`,`warning`,`image-captions`,S,`a caption does not start with a number`),/[.!?]\s+\p{Lu}/u.test(n)&&add(`caption-multiple-sentences`,`warning`,`image-captions`,S,`a caption is one sentence`)}if(n.probeImage!==void 0){let t=kids(S,`image`).find(t=>(t.attrs.type??`source`)===`source`),N=t===void 0?``:clean(t.text),F=N===``?null:await n.probeImage(N);F?.kind===`raster`&&(F.width>2e3||F.height>1400)&&add(`screenshot-too-large`,`warning`,`reasonable-window-size`,C,`${F.width}×${F.height}; keep the window at most 1000×700 (2000×1400 on HiDPI)`)}}}for(let t of kids(child(C,`releases`),`release`)){let n=`release ${t.attrs.version??`?`}`,S=child(t,`description`),C=S===void 0?``:clean(S.text);if(C===``){add(`release-notes-missing`,`warning`,`release-notes-for-every-release`,n,`no release notes`);continue}Gz.some(t=>t.test(C.replace(/[.!]+$/,``)))?add(`release-notes-generic`,`warning`,`no-bug-fixes-and-performance-improvements`,n,`"${C}" says nothing about what changed`):([...C].length>600||kids(child(S,`ul`),`li`).length>10)&&add(`release-notes-long`,`warning`,`short-but-informative`,n,`release notes are long; summarise what changed for users`)}return S}function summarizeFindings(t,n){let S=0,C=0;for(let N of t)N.severity===`error`||n?S++:C++;return{errors:S,warnings:C}}function formatFinding(t,n){return`${(n?`error`:t.severity).padEnd(7)} ${t.rule} ${t.location}: ${t.message}\n ${t.url}`}var Uz,Wz,Gz,Kz,normName,child,kids,clean,lang,langBase,qz=__esmMin(()=>{He(),Uz=`https://docs.flathub.org/docs/for-app-authors/metainfo-guidelines/quality-guidelines`,Wz=`GTK.GTK3.GTK4.Qt.Qt5.Qt6.libadwaita.Electron.Rust.Python.JavaScript.TypeScript.GJS.Flatpak.written in.open source.open-source.free software.FOSS.app.application.tool.client.wrapper.App.Anwendung.Werkzeug`.split(`.`),Gz=[/^(minor |various |general |misc(ellaneous)? )?bug ?fix(es)?( (and|&) (minor )?(performance )?(improvements?|fixes|tweaks))?$/i,/^(minor |various |general )?(performance )?improvements?( (and|&) (bug ?fix(es)?|fixes))?$/i,/^bug ?fix(es)?,? (and )?(performance|stability) improvements?$/i,/^(performance|stability) (improvements?|fixes)( (and|&) bug ?fix(es)?)?$/i,/^(fehlerbehebungen?|fehlerkorrekturen?|verbesserungen)( (und|&) (fehlerbehebungen?|verbesserungen|leistungsverbesserungen))?$/i,/^(kleinere )?(fehlerbehebungen|verbesserungen)$/i],Kz={en:[`a`,`an`,`the`],de:[`ein`,`eine`,`einen`,`einem`,`einer`,`der`,`die`,`das`,`den`,`dem`]},normName=t=>t.startsWith(`_`)?t.slice(1):t,child=(t,n)=>t?.children.find(t=>t.name===n),kids=(t,n)=>t?.children.filter(t=>t.name===n)??[],clean=t=>t.replace(/\s+/g,` `).trim(),lang=t=>t.attrs[`xml:lang`]??``,langBase=t=>t.split(/[_\-.@]/)[0].toLowerCase()});async function runQuality(t,n,S){let C=En(t),probeImage=async t=>{if(/^https?:\/\//.test(t)){if(!S.qualityNetwork)return null;try{let n=await fetch(t);return n.ok?readImageInfo(new Uint8Array(await n.arrayBuffer())):null}catch{return null}}let n=xn(C,t);return existsSync(n)?readImageInfo(new Uint8Array(readFileSync(n))):null},N=n??``,F=N?[`icons/hicolor/scalable/apps/${N}.svg`,`icons/${N}.svg`,`${N}.svg`,`${N}.png`,`../data/icons/hicolor/scalable/apps/${N}.svg`]:[],I=await lintMetainfo(readFileSync(t,`utf-8`),{probeImage,iconRefs:F}),H=S.strict===!0,{errors:W,warnings:q}=summarizeFindings(I,H);if(S.json)ge.log(JSON.stringify({file:t,errors:W,warnings:q,findings:I.map(t=>({...t,severity:H?`error`:t.severity}))},null,2));else{for(let t of I)ge.log(formatFinding(t,H));ge.log(`[gjsify flatpak check] ${W===0?`OK`:`FAIL`}: quality ${t} — ${W} error(s), ${q} warning(s)`)}return W===0}function resolveAppId(t,n,S){if(n.appId)return n.appId;try{let t=readPackageJson(S);if(looksLikeAppId(t.name))return t.name}catch{}if(t)return t.replace(/\.json$/,``)}function resolveManifestPath(t,n,S){if(t)return xn(S,t);if(n)return xn(S,`${n}.json`);let C=readdirSync(S).filter(t=>t.endsWith(`.json`)&&!t.startsWith(`package`));if(C.length===1)return xn(S,C[0]);throw Error(`gjsify flatpak check: no manifest path given and could not auto-detect. Pass the manifest as a positional argument.`)}async function runLinter(t,n,S){let C;try{C=await spawnToCompletion(t,n,{completion:`return`,stdio:S?`inherit`:`capture`})}catch(n){let S=n;return S.code===`ENOENT`?ge.error(`[gjsify flatpak check] ${t} not found in PATH.\nInstall via:\n flatpak install -y flathub org.flatpak.Builder\n alias ${t}="flatpak run --command=${t} org.flatpak.Builder"`):ge.error(`[gjsify flatpak check] ${t} failed to spawn: ${S.message}`),!1}let N=C.code===0;return ge.log(`[gjsify flatpak check] ${N?`OK`:`FAIL`}: ${t} ${n.join(` `)}`),!N&&!S&&(C.stdout?.trim()&&ge.log(C.stdout.trimEnd()),C.stderr?.trim()&&ge.error(C.stderr.trimEnd())),N}var Jz,Yz=__esmMin(()=>{_e(),Rd(),Pn(),V_(),mz(),wI(),qz(),Jz={command:`check [manifest]`,description:`Run Flathub pre-submission linters: appstreamcli validate + flatpak-builder-lint.`,builder:t=>t.positional(`manifest`,{description:"Path to the Flatpak manifest. Auto-detects `<app-id>.json` if omitted.",type:`string`,normalize:!0}).option(`repo`,{description:"Built ostree-repo path. If given, also runs `flatpak-builder-lint repo`.",type:`string`,normalize:!0}).option(`metainfo`,{description:"MetaInfo XML path. Default: `data/<app-id>.metainfo.xml.in`.",type:`string`,normalize:!0}).option(`appstream`,{description:"Run `appstreamcli validate --strict` (default: true).",type:`boolean`,default:!0}).option(`quality`,{description:`Run Flathub's quality guidelines (name, summary, branding, screenshots, release notes) on the MetaInfo (default: true).`,type:`boolean`,default:!0}).option(`strict`,{description:`Treat quality warnings as errors.`,type:`boolean`,default:!1}).option(`json`,{description:`Print the quality findings as JSON (and nothing else on stdout).`,type:`boolean`,default:!1}).option(`quality-network`,{description:`Let the quality check fetch http(s) screenshot/icon URLs to measure their size.`,type:`boolean`,default:!1}).option(`builder-lint`,{description:"Run `flatpak-builder-lint manifest` (default: true).",type:`boolean`,default:!0}).option(`verbose`,{description:`Stream linter stdout/stderr verbatim.`,type:`boolean`,default:!1}),handler:async t=>{let n=(await new Config().forCommand().catch(()=>({}))).flatpak??{},S=process.cwd(),C=resolveAppId(t.manifest,n,S),N=resolveManifestPath(t.manifest,C,S),F=xn(S,t.metainfo??`data/${C??`unknown`}.metainfo.xml.in`),I=0;if(t.appstream!==!1&&(existsSync(F)?await runLinter(`appstreamcli`,[`validate`,`--strict`,F],t.verbose??!1)||I++:ge.warn(`[gjsify flatpak check] skipping appstreamcli — ${F} not found`)),t.quality!==!1&&(existsSync(F)?await runQuality(F,C,t)||I++:ge.warn(`[gjsify flatpak check] skipping quality check — ${F} not found`)),t.builderLint!==!1&&!t.json){if(!existsSync(N))return ge.error(`[gjsify flatpak check] manifest not found: ${N}`),process.exit(1);await runLinter(`flatpak-builder-lint`,[`manifest`,N],t.verbose??!1)||I++,t.repo&&(await runLinter(`flatpak-builder-lint`,[`repo`,xn(S,t.repo)],t.verbose??!1)||I++)}if(I>0)return ge.error(`\n[gjsify flatpak check] ${I} check(s) failed.`),process.exit(1);ge.log(`[gjsify flatpak check] all checks passed.`)}}});async function readSourceListAtTag(t,n,S,C){let N;try{let{stdout:C}=await Xz(`git`,[`show`,`${n}:${S}`],{cwd:t,maxBuffer:64*1024*1024});N=C}catch(N){return await assertGitMeantAbsent(t,n,S,N),C&&ge.log(`[gjsify flatpak sync-flathub] ${S} not present at ${n} — skipping`),null}if(N.trim()===``)return C&&ge.log(`[gjsify flatpak sync-flathub] ${S} is empty at ${n} — skipping`),null;let F;try{F=JSON.parse(N)}catch(t){throw Error(`[gjsify flatpak sync-flathub] ${S} at ${n} is not JSON: `+(t instanceof Error?t.message:String(t)))}if(!Array.isArray(F)||F.length===0)throw Error(`[gjsify flatpak sync-flathub] ${S} at ${n} is not a non-empty array of flatpak sources`);return N}async function assertGitMeantAbsent(t,n,S,C){if(typeof C?.code!=`number`)throw Error(`[gjsify flatpak sync-flathub] could not run \`git show ${n}:${S}\` — `+(C instanceof Error?C.message:String(C)));if(!await Xz(`git`,[`rev-parse`,`--verify`,`--quiet`,`${n}^{commit}`],{cwd:t}).then(({stdout:t})=>t.trim()).catch(()=>``))throw Error(`[gjsify flatpak sync-flathub] ${n} does not resolve in ${t}, so whether it carries ${S} is unanswered. Run \`git fetch --tags\`, pass --version <an existing tag>, or run from the app checkout.`)}async function resolveLatestTag$1(t,n){try{let{stdout:S}=await Xz(`git`,[`describe`,`--tags`,`--abbrev=0`],{cwd:t});return n&&ge.log(`[gjsify flatpak sync-flathub] resolved latest tag → ${S.trim()}`),S.trim()||null}catch{return null}}async function resolveCommitForTag(t,n,S){try{let{stdout:C}=await Xz(`git`,[`rev-list`,`-n`,`1`,n],{cwd:t}),N=C.trim();if(!N)throw Error(`empty rev-list output`);return S&&ge.log(`[gjsify flatpak sync-flathub] resolved ${n} → ${N}`),N}catch(t){throw Error(`[gjsify flatpak sync-flathub] tag ${n} not found locally. Run \`git fetch --tags\` or pass --commit <sha>.\n underlying error: ${t instanceof Error?t.message:String(t)}`)}}function normaliseBranchSegment(t){return t.replace(/^v/,``).replace(/[^A-Za-z0-9._-]/g,`-`)}function flathubCacheRoot(){return wn(process.env.XDG_CACHE_HOME||wn(homedir(),`.cache`),`gjsify`,`flathub-sync`)}async function ensureClone(t,n,S){if(existsSync(wn(t,`.git`))){S&&ge.log(`[gjsify flatpak sync-flathub] reusing clone at ${t}`),await gitInRepo(t,[`fetch`,`origin`],S);let n=await detectDefaultBranch(t,S);await gitInRepo(t,[`checkout`,n],S),await gitInRepo(t,[`reset`,`--hard`,`origin/${n}`],S);return}mkdirSync(xn(t,`..`),{recursive:!0});let C=`https://github.com/${n}.git`;S&&ge.log(`[gjsify flatpak sync-flathub] git clone ${C} ${t}`);try{await Xz(`git`,[`clone`,C,t])}catch(t){throw t?.code===`ENOENT`?Error("[gjsify flatpak sync-flathub] `git` not found. Install git from your distro (Fedora: `dnf install git`, Debian: `apt install git`)."):t}}async function detectDefaultBranch(t,n){try{let{stdout:S}=await Xz(`git`,[`remote`,`show`,`origin`],{cwd:t}),C=S.match(/HEAD branch: (\S+)/);if(C&&C[1]&&C[1]!==`(unknown)`)return n&&ge.log(`[gjsify flatpak sync-flathub] default branch → ${C[1]}`),C[1]}catch{}return`master`}async function gitInRepo(t,n,S){S&&ge.log(`[gjsify flatpak sync-flathub] git ${n.join(` `)} (in ${t})`);let C=await spawnToCompletion(`git`,n,{completion:`return`,cwd:t,notFound:()=>Error("[gjsify flatpak sync-flathub] `git` not found. Install it from your distro.")});if(C.code!==0)throw Error(`git ${n[0]} exited ${describeExit(C)}`)}async function ghCreate(t,n,S,C,N,F){let I=[`pr`,`create`,`--repo`,n,`--head`,S,`--title`,`Update to ${C}`,`--body`,N];F&&ge.log(`[gjsify flatpak sync-flathub] gh ${I.join(` `)} (in ${t})`);let H=await spawnToCompletion(`gh`,I,{completion:`return`,cwd:t,notFound:()=>Error("[gjsify flatpak sync-flathub] `gh` (GitHub CLI) not found. Install via `dnf install gh` (Fedora), `apt install gh` (Debian/Ubuntu), or `flatpak install -y flathub com.github.cli`.")});if(H.code!==0)throw Error(`gh pr create exited ${describeExit(H)}`)}function editManifest(t,n){let S=JSON.parse(t),C=S.modules??[];if(C.length===0)throw Error(`[gjsify flatpak sync-flathub] manifest has no modules`);let N=C[0].sources??[];if(N.length===0)throw Error(`[gjsify flatpak sync-flathub] modules[0] has no sources`);let isObject=t=>typeof t==`object`,F=n.sourceIndex??N.findIndex(t=>isObject(t)&&t.type===`git`);if(F<0||F>=N.length)throw Error(`[gjsify flatpak sync-flathub] no git source found in modules[0].sources (use --source-index <n>)`);let I=N[F];if(!isObject(I)||I.type!==`git`){let t=isObject(I)?`type is "${I.type}"`:`is the file reference "${I}"`;throw Error(`[gjsify flatpak sync-flathub] modules[0].sources[${F}] ${t}, expected a git source`)}let H=I;H.tag=n.tag,H.commit=n.commit,H[`x-checker-data`]||={type:`git`,"tag-pattern":`^v(\\d+\\.\\d+\\.\\d+)$`,"version-scheme":`semantic`},n.sourcesFile&&!namesFile(N,n.sourcesFile)&&N.push(n.sourcesFile);let W=detectIndent$1(t);return JSON.stringify(S,null,W)+(t.endsWith(`
|
|
1090
1090
|
`)?`
|
|
1091
1091
|
`:``)}function namesFile(t,n){let S=stripDotSlash(n);return t.some(t=>typeof t==`string`&&stripDotSlash(t)===S)}function stripDotSlash(t){return t.replace(/^\.\//,``)}function detectIndent$1(t){let n=t.match(/^\{\n( +)/);return n?n[1].length:2}var Xz,Zz,Qz=__esmMin(()=>{_e(),Rd(),Pn(),Lg(),P_(),V_(),Tu(),wI(),mz(),Xz=promisify(execFile),Zz={command:`sync-flathub`,description:`Update the per-app Flathub tracking-repo manifest to a new git tag + commit. Clones, edits, commits, optionally opens a PR.`,builder:t=>t.version(!1).option(`version`,{description:"Git tag to sync to. Default: `git describe --tags --abbrev=0` in cwd.",type:`string`}).option(`app-id`,{description:"Reverse-DNS app id. Default: `gjsify.flatpak.appId`.",type:`string`}).option(`flathub-repo`,{description:"Flathub tracking-repo (owner/name). Default: `flathub/<appId>`.",type:`string`}).option(`commit`,{description:"Commit SHA to pin. Default: resolved via `git rev-list -n 1 <version>` in cwd.",type:`string`}).option(`branch`,{description:"Branch name in the flathub-repo. Default: `update-to-<version>`.",type:`string`}).option(`sources-file`,{description:`Generated offline tarball list to carry into the Flathub repo and name in the manifest. Default: \`${pz}\`. Skipped when the tag does not carry it.`,type:`string`,default:pz}).option(`source-index`,{description:"Index into modules[0].sources[] to update (when manifest has multiple sources). Default: first `type: git` source.",type:`number`}).option(`pr`,{description:"After commit + push, open a PR via `gh pr create`. Pass `--no-pr` to skip and stop after push.",type:`boolean`,default:!0}).option(`dry-run`,{description:`Show what would be edited; touch no files, run no git commands.`,type:`boolean`,default:!1}).option(`verbose`,{description:`Echo every git / gh invocation before running.`,type:`boolean`,default:!1}),handler:async t=>{let n=process.cwd(),S=(await new Config().forCommand().catch(()=>({}))).flatpak??{},C=t.appId??S.appId??readPackageJson(n).name;if(!C)throw Error(`[gjsify flatpak sync-flathub] no app id available — pass --app-id or set gjsify.flatpak.appId.`);let N=t.flathubRepo??S.flathubRepo??`flathub/${C}`,F=t.version??await resolveLatestTag$1(n,t.verbose);if(!F)throw Error(`[gjsify flatpak sync-flathub] no version resolved — pass --version vX.Y.Z or create a git tag locally.`);let I=t.commit??await resolveCommitForTag(n,F,t.verbose),H=t.branch??`update-to-${normaliseBranchSegment(F)}`;if(ge.log(`[gjsify flatpak sync-flathub] appId=${C}`),ge.log(`[gjsify flatpak sync-flathub] flathubRepo=${N}`),ge.log(`[gjsify flatpak sync-flathub] version=${F}`),ge.log(`[gjsify flatpak sync-flathub] commit=${I}`),ge.log(`[gjsify flatpak sync-flathub] branch=${H}`),t.dryRun){ge.log(`[gjsify flatpak sync-flathub] --dry-run set; not cloning / writing / pushing.`);return}let W=flathubCacheRoot(),q=wn(W,N.replace(`/`,`__`));mkdirSync(W,{recursive:!0}),await ensureClone(q,N,t.verbose);let Y=wn(q,`${C}.json`);if(!existsSync(Y))throw Error(`[gjsify flatpak sync-flathub] Flathub manifest not found at ${Y} — wrong appId / wrong flathub-repo?`);let X=t.sourcesFile??`gjsify-sources.json`,Z=await readSourceListAtTag(n,F,X,t.verbose),te=!1;if(Z!==null){let t=wn(q,X);te=!existsSync(t)||readFileSync(t,`utf-8`)!==Z,te&&(writeFileSync(t,Z,`utf-8`),ge.log(`[gjsify flatpak sync-flathub] ${X} copied from ${F}`))}let ne=readFileSync(Y,`utf-8`),re=editManifest(ne,{tag:F,commit:I,sourceIndex:t.sourceIndex,sourcesFile:Z===null?void 0:X});if(re===ne&&!te){ge.log(`[gjsify flatpak sync-flathub] manifest already at ${F} — nothing to do.`);return}if(writeFileSync(Y,re,`utf-8`),ge.log(`[gjsify flatpak sync-flathub] manifest patched at ${Y}`),await gitInRepo(q,[`checkout`,`-B`,H],t.verbose),await gitInRepo(q,[`add`,`.`],t.verbose),await gitInRepo(q,[`commit`,`-m`,`Update to ${F}`],t.verbose),t.pr===!1){ge.log(`[gjsify flatpak sync-flathub] --no-pr set; branch ${H} committed locally in ${q}.`);return}await gitInRepo(q,[`push`,`-u`,`origin`,H,`--force-with-lease`],t.verbose),await ghCreate(q,N,H,F,`Auto-generated by \`gjsify flatpak sync-flathub\`.\n\n- Version: \`${F}\`\n- Commit: \`${I}\`\n`,t.verbose)}},__name$1(resolveLatestTag$1,`resolveLatestTag`),__name$1(detectIndent$1,`detectIndent`)});async function loadFlathubSource(t,n){let S;if(t.against){if(!existsSync(t.against))throw Error(`[gjsify flatpak diff] --against path ${t.against} does not exist`);S=readFileSync(t.against,`utf-8`)}else S=await fetchFlathubManifest(t.flathubRepo,t.appId,t.verbose);let C;try{C=JSON.parse(S)}catch(t){throw Error(`[gjsify flatpak diff] failed to parse Flathub manifest as JSON: ${t.message}`)}let N=(C.modules??[])[0]?.sources??[];if(N.length===0)return null;let F=n??N.findIndex(t=>isSourceObject(t)&&t.type===`git`);if(F<0||F>=N.length)return null;let I=N[F];return isSourceObject(I)?I:null}function isSourceObject(t){return typeof t==`object`&&!!t}async function fetchFlathubManifest(t,n,S){for(let C of[`master`,`main`]){let N=`https://raw.githubusercontent.com/${t}/${C}/${n}.json`;S&&ge.log(`[gjsify flatpak diff] fetch ${N}`);try{let t=await fetch(N);if(t.ok)return await t.text();S&&ge.log(`[gjsify flatpak diff] ${C} → HTTP ${t.status}`)}catch(t){S&&ge.log(`[gjsify flatpak diff] ${C} fetch error: ${t.message}`)}}throw Error(`[gjsify flatpak diff] could not fetch flathub manifest from ${t} on master or main`)}async function resolveLatestTag(t,n){try{let{stdout:S}=await $z(`git`,[`describe`,`--tags`,`--abbrev=0`],{cwd:t}),C=S.trim();return n&&ge.log(`[gjsify flatpak diff] local latest tag → ${C}`),C||null}catch{return null}}var $z,eB,tB=__esmMin(()=>{_e(),Rd(),P_(),Tu(),wI(),mz(),$z=promisify(execFile),eB={command:`diff`,description:`Compare the per-app Flathub tracking-repo manifest against the local git state and report version / commit drift.`,builder:t=>t.version(!1).option(`version`,{description:"Local version to compare against. Default: `git describe --tags --abbrev=0` in cwd.",type:`string`}).option(`app-id`,{description:"Reverse-DNS app id. Default: `gjsify.flatpak.appId`.",type:`string`}).option(`flathub-repo`,{description:"Flathub tracking-repo (owner/name). Default: `gjsify.flatpak.flathubRepo` or `flathub/<appId>`.",type:`string`}).option(`against`,{description:`Read the Flathub manifest from a local file instead of fetching it. Useful in CI or offline.`,type:`string`}).option(`detail`,{description:`Also print the full Flathub manifest source entry alongside the resolved local version.`,type:`boolean`,default:!1}).option(`source-index`,{description:`Index into modules[0].sources[] to inspect (when the manifest has multiple sources).`,type:`number`}).option(`verbose`,{description:`Echo fetch URL + resolved values.`,type:`boolean`,default:!1}),handler:async t=>{let n=process.cwd(),S=(await new Config().forCommand().catch(()=>({}))).flatpak??{},C=t.appId??S.appId??readPackageJson(n).name;if(!C)throw Error(`[gjsify flatpak diff] no app id available — pass --app-id or set gjsify.flatpak.appId.`);let N=t.flathubRepo??S.flathubRepo??`flathub/${C}`,F=t.version??await resolveLatestTag(n,t.verbose),I=await loadFlathubSource({appId:C,flathubRepo:N,against:t.against,verbose:t.verbose},t.sourceIndex),H=I?.tag,W=I?.commit;if(ge.log(`[gjsify flatpak diff] appId=${C}`),ge.log(`[gjsify flatpak diff] flathubRepo=${N}`),ge.log(`[gjsify flatpak diff] flathub: tag=${H??`(missing)`} commit=${W??`(missing)`}`),ge.log(`[gjsify flatpak diff] local: tag=${F??`(none)`}`),t.detail&&I&&(ge.log(`[gjsify flatpak diff] flathub manifest source:`),ge.log(JSON.stringify(I,null,2))),!F){ge.warn("[gjsify flatpak diff] no local git tag found — cut a release (`git tag vX.Y.Z`) or pass --version vX.Y.Z to compare against an explicit value.");return}if(!H)return ge.warn("[gjsify flatpak diff] flathub manifest has no `tag` field on the inspected source."),process.exit(1);if(H===F){ge.log(`✅ in sync (${F})`);return}ge.log(`❌ drift detected — flathub=${H} vs local=${F}`),ge.log(` run \`gjsify flatpak sync-flathub --version ${F}\` to update the Flathub manifest.`),process.exit(1)}}});function resolveCliEntry(){return xn(xn(En(fileURLToPath(import.meta.url)),`..`,`..`),`index.js`)}async function runNode(t,n){let S=await spawnToCompletion(`node`,t,{completion:`return`,cwd:n});if(S.code!==0)throw Error(`sub-command exited with ${describeExit(S)}: node ${t.join(` `)}`)}var nB,rB,iB=__esmMin(()=>{_e(),P_(),V_(),Tu(),Gn(),Pn(),nB=promisify(execFile),rB={command:`release <version>`,description:"Cut a release end-to-end: regenerate Flathub assets, run linters, create + push the git tag, then open the Flathub PR. Each step delegates to the equivalent `gjsify flatpak <sub>` command.",builder:t=>t.version(!1).positional(`version`,{description:"Release tag, e.g. `v0.6.6`.",type:`string`,demandOption:!0}).option(`skip-init`,{description:"Skip the `flatpak init --force` regen step.",type:`boolean`,default:!1}).option(`skip-check`,{description:"Skip the `flatpak check` linter step.",type:`boolean`,default:!1}).option(`skip-tag`,{description:"Skip the `git tag` + `git push --tags` step (use when the tag was already created out-of-band).",type:`boolean`,default:!1}).option(`push-tag`,{description:`Push the created tag after creating it. Default: true.`,type:`boolean`,default:!0}).option(`flathub-repo`,{description:`Flathub tracking-repo override forwarded to sync-flathub.`,type:`string`}).option(`dry-run`,{description:`Print each step that would run without executing any of them.`,type:`boolean`,default:!1}).option(`verbose`,{description:`Echo every sub-command invocation.`,type:`boolean`,default:!1}),handler:async t=>{let n=typeof t.version==`string`?t.version.trim():``;if(!n)throw Error(`[gjsify flatpak release] missing <version> positional`);let S=resolveCliEntry(),C=process.cwd(),N=[];t.skipInit||N.push({name:`init`,args:[S,`flatpak`,`init`,`--force`]}),t.skipCheck||N.push({name:`check`,args:[S,`flatpak`,`check`]});let F=[S,`flatpak`,`sync-flathub`,`--version`,n];if(t.flathubRepo&&F.push(`--flathub-repo`,t.flathubRepo),t.verbose&&F.push(`--verbose`),ge.log(`[gjsify flatpak release] starting release of ${n}`),t.dryRun){ge.log(`[gjsify flatpak release] --dry-run set; printing plan only:`);for(let t of N)ge.log(` · ${t.name}: node ${t.args.join(` `)}`);t.skipTag||ge.log(` · tag: git tag ${n}${t.pushTag===!1?``:` && git push origin `+n}`),ge.log(` · sync: node ${F.join(` `)}`);return}for(let n of N)t.verbose&&ge.log(`[gjsify flatpak release] step ${n.name}: node ${n.args.join(` `)}`),await runNode(n.args,C),ge.log(`[gjsify flatpak release] ${n.name} ✔`);if(!t.skipTag){t.verbose&&ge.log(`[gjsify flatpak release] git tag ${n}`);try{await nB(`git`,[`tag`,n],{cwd:C}),ge.log(`[gjsify flatpak release] tag ${n} created`)}catch(t){throw Error(`[gjsify flatpak release] git tag failed (${t.message}). If the tag already exists, re-run with --skip-tag.`)}t.pushTag!==!1&&(t.verbose&&ge.log(`[gjsify flatpak release] git push origin ${n}`),await nB(`git`,[`push`,`origin`,n],{cwd:C}),ge.log(`[gjsify flatpak release] tag pushed`))}t.verbose&&ge.log(`[gjsify flatpak release] sync: node ${F.join(` `)}`),await runNode(F,C),ge.log(`[gjsify flatpak release] ✅ release ${n} complete`)}}}),aB,oB=__esmMin(()=>{kz(),jz(),Nz(),Bz(),Hz(),Yz(),Qz(),tB(),iB(),aB={command:`flatpak <subcommand>`,description:`Flatpak toolchain: init/build/deps/sources/ci/check/sync-flathub/diff/release subcommands for shipping GJS apps and CLIs as Flatpaks.`,builder:t=>t.command(Oz.command,Oz.description,Oz.builder,Oz.handler).command(Az.command,Az.description,Az.builder,Az.handler).command(Mz.command,Mz.description,Mz.builder,Mz.handler).command(zz.command,zz.description,zz.builder,zz.handler).command(Vz.command,Vz.description,Vz.builder,Vz.handler).command(Jz.command,Jz.description,Jz.builder,Jz.handler).command(Zz.command,Zz.description,Zz.builder,Zz.handler).command(eB.command,eB.description,eB.builder,eB.handler).command(rB.command,rB.description,rB.builder,rB.handler).demandCommand(1).strict()}});function concatBytes(t){let n=0;for(let S of t)n+=S.byteLength;let S=new Uint8Array(n),C=0;for(let n of t)S.set(n,C),C+=n.byteLength;return S}function encodeUtf8(t){return new TextEncoder().encode(t)}var sB=__esmMin(()=>{});function createArArchive(t){let n=[encodeUtf8(cB)];for(let S of t)n.push(buildMemberHeader(S)),n.push(S.data),S.data.byteLength%2==1&&n.push(encodeUtf8(`
|
|
1092
1092
|
`));return concatBytes(n)}function buildMemberHeader(t){let n=pad(t.name,16)+pad(String(t.mtime??0),12)+pad(`0`,6)+pad(`0`,6)+pad((t.mode??33188).toString(8),8)+pad(String(t.data.byteLength),10)+`\`
|
|
@@ -354,10 +354,14 @@ export interface AppMetadata {
|
|
|
354
354
|
/**
|
|
355
355
|
* App-store screenshots. `url` must be an absolute HTTPS URL to a PNG;
|
|
356
356
|
* `environment` lets Flathub group by desktop; the first entry defaults to
|
|
357
|
-
* `type="default"`.
|
|
357
|
+
* `type="default"`. `localizedUrls` maps a language code (`de`, `pt_BR`)
|
|
358
|
+
* to a screenshot of the app in that language; each becomes an extra
|
|
359
|
+
* `<image xml:lang="…">`, so software centres show the user's language
|
|
360
|
+
* and fall back to `url`.
|
|
358
361
|
*/
|
|
359
362
|
screenshots?: Array<{
|
|
360
363
|
url: string;
|
|
364
|
+
localizedUrls?: Record<string, string>;
|
|
361
365
|
caption?: string;
|
|
362
366
|
captionTranslatorHint?: string;
|
|
363
367
|
environment?: 'plasma' | 'gnome' | 'cli';
|
|
@@ -176,6 +176,9 @@ function renderMetainfo(inputs, kind) {
|
|
|
176
176
|
const envAttr = s.environment ? ` environment="${escapeXml(s.environment)}"` : '';
|
|
177
177
|
lines.push(` <screenshot${typeAttr}${envAttr}>`);
|
|
178
178
|
lines.push(` <image>${escapeXml(s.url)}</image>`);
|
|
179
|
+
for (const [lang, url] of Object.entries(s.localizedUrls ?? {})) {
|
|
180
|
+
lines.push(` <image xml:lang="${escapeXml(lang)}">${escapeXml(url)}</image>`);
|
|
181
|
+
}
|
|
179
182
|
if (s.caption) {
|
|
180
183
|
pushTranslatorHint(lines, s.captionTranslatorHint, ' ');
|
|
181
184
|
lines.push(` <caption>${escapeXml(s.caption)}</caption>`);
|
|
@@ -306,9 +306,12 @@ export async function lintMetainfo(xml, options = {}) {
|
|
|
306
306
|
add('screenshot-missing', 'warning', 'at-least-one-screenshot', 'screenshots', 'at least one screenshot is expected');
|
|
307
307
|
}
|
|
308
308
|
else {
|
|
309
|
+
// A screenshot with an untagged image plus `<image xml:lang="de">` twins is English: the
|
|
310
|
+
// twins are alternatives, and the untagged one is what a non-German user sees.
|
|
311
|
+
const englishTag = (t) => t === '' || langBase(t) === 'en';
|
|
309
312
|
const isEnglish = (s) => {
|
|
310
|
-
const
|
|
311
|
-
return
|
|
313
|
+
const images = kids(s, 'image').map(lang);
|
|
314
|
+
return englishTag(lang(s)) && (images.length === 0 || images.some(englishTag));
|
|
312
315
|
};
|
|
313
316
|
if (!shots.some(isEnglish)) {
|
|
314
317
|
add('screenshot-no-english', 'warning', 'at-least-one-screenshot', 'screenshots', 'no screenshot without xml:lang (or in English)');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/cli",
|
|
3
|
-
"version": "0.64.2-next.
|
|
3
|
+
"version": "0.64.2-next.255",
|
|
4
4
|
"description": "CLI for Gjsify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -142,22 +142,22 @@
|
|
|
142
142
|
"cli"
|
|
143
143
|
],
|
|
144
144
|
"dependencies": {
|
|
145
|
-
"@gjsify/blueprint": "0.64.2-next.
|
|
146
|
-
"@gjsify/buffer": "0.64.2-next.
|
|
147
|
-
"@gjsify/create-app": "0.64.2-next.
|
|
148
|
-
"@gjsify/node-globals": "0.64.2-next.
|
|
149
|
-
"@gjsify/node-polyfills": "0.64.2-next.
|
|
150
|
-
"@gjsify/npm-registry": "0.64.2-next.
|
|
151
|
-
"@gjsify/resolve-npm": "0.64.2-next.
|
|
152
|
-
"@gjsify/rolldown-plugin-gjsify": "0.64.2-next.
|
|
153
|
-
"@gjsify/vite-plugin-blueprint": "0.64.2-next.
|
|
154
|
-
"@gjsify/rolldown-plugin-pnp": "0.64.2-next.
|
|
155
|
-
"@gjsify/semver": "0.64.2-next.
|
|
156
|
-
"@gjsify/tar": "0.64.2-next.
|
|
157
|
-
"@gjsify/tsc": "0.64.2-next.
|
|
158
|
-
"@gjsify/utils": "0.64.2-next.
|
|
159
|
-
"@gjsify/web-polyfills": "0.64.2-next.
|
|
160
|
-
"@gjsify/workspace": "0.64.2-next.
|
|
145
|
+
"@gjsify/blueprint": "0.64.2-next.255",
|
|
146
|
+
"@gjsify/buffer": "0.64.2-next.255",
|
|
147
|
+
"@gjsify/create-app": "0.64.2-next.255",
|
|
148
|
+
"@gjsify/node-globals": "0.64.2-next.255",
|
|
149
|
+
"@gjsify/node-polyfills": "0.64.2-next.255",
|
|
150
|
+
"@gjsify/npm-registry": "0.64.2-next.255",
|
|
151
|
+
"@gjsify/resolve-npm": "0.64.2-next.255",
|
|
152
|
+
"@gjsify/rolldown-plugin-gjsify": "0.64.2-next.255",
|
|
153
|
+
"@gjsify/vite-plugin-blueprint": "0.64.2-next.255",
|
|
154
|
+
"@gjsify/rolldown-plugin-pnp": "0.64.2-next.255",
|
|
155
|
+
"@gjsify/semver": "0.64.2-next.255",
|
|
156
|
+
"@gjsify/tar": "0.64.2-next.255",
|
|
157
|
+
"@gjsify/tsc": "0.64.2-next.255",
|
|
158
|
+
"@gjsify/utils": "0.64.2-next.255",
|
|
159
|
+
"@gjsify/web-polyfills": "0.64.2-next.255",
|
|
160
|
+
"@gjsify/workspace": "0.64.2-next.255",
|
|
161
161
|
"acorn": "^8.17.0",
|
|
162
162
|
"cosmiconfig": "^9.0.2",
|
|
163
163
|
"get-tsconfig": "^4.14.0",
|
|
@@ -166,13 +166,13 @@
|
|
|
166
166
|
"yargs": "^18.0.0"
|
|
167
167
|
},
|
|
168
168
|
"devDependencies": {
|
|
169
|
-
"@gjsify/unit": "0.64.2-next.
|
|
169
|
+
"@gjsify/unit": "0.64.2-next.255",
|
|
170
170
|
"@types/yargs": "^17.0.35",
|
|
171
171
|
"typescript": "^6.0.3"
|
|
172
172
|
},
|
|
173
173
|
"peerDependencies": {
|
|
174
|
-
"@gjsify/oxfmt-native": "0.64.2-next.
|
|
175
|
-
"@gjsify/rolldown-native": "0.64.2-next.
|
|
174
|
+
"@gjsify/oxfmt-native": "0.64.2-next.255",
|
|
175
|
+
"@gjsify/rolldown-native": "0.64.2-next.255"
|
|
176
176
|
},
|
|
177
177
|
"peerDependenciesMeta": {
|
|
178
178
|
"@gjsify/oxfmt-native": {
|
|
@@ -192,5 +192,5 @@
|
|
|
192
192
|
"url": "https://github.com/gjsify/gjsify/issues"
|
|
193
193
|
},
|
|
194
194
|
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/infra/cli#readme",
|
|
195
|
-
"gitHead": "
|
|
195
|
+
"gitHead": "6c88ac780b9742fce781e9b35aa2f45c125d8064"
|
|
196
196
|
}
|