@gjsify/cli 0.4.12 → 0.4.13
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 +2 -2
- package/lib/commands/flatpak/init.js +2 -2
- package/lib/types/config-data.d.ts +8 -0
- package/package.json +15 -15
package/dist/cli.gjs.mjs
CHANGED
|
@@ -754,8 +754,8 @@ No install command available for your package manager. Install manually.`),proce
|
|
|
754
754
|
`),S(Error(`Cancelled by user`));return}F.name===`up`||F.name===`k`?(C=(C-1+n.length)%n.length,render(n,C,!1)):F.name===`down`||F.name===`j`?(C=(C+1)%n.length,render(n,C,!1)):(F.name===`return`||F.name===`enter`)&&(cleanup(),a(n[C]))}};Jt.on(`keypress`,onKeypress)})}Be();const UT={command:`create [project-name]`,description:`Scaffold a new Gjsify project in a new directory.`,builder:n=>{let a=discoverTemplates().map(n=>n.name);return n.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:a.length>0?a:void 0}).option(`force`,{alias:`f`,describe:`Scaffold into a non-empty directory`,type:`boolean`,default:!1}).option(`install`,{describe:`Run npm install after scaffolding`,type:`boolean`,default:!1})},handler:async n=>{let a=n.template;if(!a){let n=discoverTemplates();if(!process.stdin.isTTY){let a=n.map(n=>n.name).join(`, `);ze.error(`Error: --template is required in non-interactive mode. Available templates: ${a||`(none)`}`),process.exit(1)}a=(await promptTemplate(n)).name}await createProject({projectName:n[`project-name`],template:a,force:n.force,install:n.install})}};Be(),gx(),gs(),qo(),gc();const WT=promisify(execFile);function defaultTargetFor(n){let a=Bo(n,Vo(n));return No(zo(n),a)}const GT={command:`gresource <xml>`,description:"Compile a GResource XML descriptor into a binary .gresource bundle (wraps `glib-compile-resources`).",builder:n=>n.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 n=>{let a=No(n.xml),S=n.target?No(n.target):defaultTargetFor(a),C=[`--sourcedir=${n.sourcedir?No(n.sourcedir):zo(a)}`,`--target=${S}`,a];n.verbose&&ze.log(`[gjsify gresource] glib-compile-resources ${C.join(` `)}`),await mkdir$1(zo(S),{recursive:!0});try{let{stdout:a,stderr:N}=await WT(`glib-compile-resources`,C);a&&process.stdout.write(a),N&&process.stderr.write(N),n.verbose&&ze.log(`[gjsify gresource] wrote ${S}`)}catch(n){n?.code===`ENOENT`?ze.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),ze.error(`[gjsify gresource] glib-compile-resources failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}};Be(),gx(),gs(),qo(),gc();const KT=promisify(execFile);async function listLanguages(n){return(await readdir$1(n)).filter(n=>n.endsWith(`.po`)&&!n.startsWith(`.`)).map(n=>n.slice(0,-3)).sort()}function stripXmlComments(n){return n.replace(/<!--[\s\S]*?-->/g,``)}async function ensureDir(n){await mkdir$1(n,{recursive:!0})}async function fileExists(n){try{return await stat$1(n),!0}catch{return!1}}async function compileBulkXml(n){let a=Io(n.outDir,n.filename);await ensureDir(n.outDir);let S=[`--output-file=${a}`,`--xml`,`--template=${n.template}`,`-d`,n.poDir];n.verbose&&ze.log(`[gjsify gettext] msgfmt ${S.join(` `)}`),await KT(`msgfmt`,S),n.removeXmlComments&&await writeFile$1(a,stripXmlComments(await readFile$1(a,`utf-8`))),n.verbose&&ze.log(`[gjsify gettext] wrote ${a}`)}async function compilePerLanguage(n){let a=await listLanguages(n.poDir);if(a.length===0){ze.warn(`[gjsify gettext] no .po files found in ${n.poDir}`);return}for(let S of a){let a=Io(n.poDir,`${S}.po`),C=n.format===`mo`?Io(n.outDir,S,`LC_MESSAGES`):Io(n.outDir,S);await ensureDir(C);let N=[`--output-file=${Io(C,n.filename)}`];n.format!==`mo`&&N.push(`--${n.format}`),N.push(a),n.verbose&&ze.log(`[gjsify gettext] msgfmt ${N.join(` `)}`),await KT(`msgfmt`,N)}n.verbose&&ze.log(`[gjsify gettext] compiled ${a.length} language(s) into ${n.outDir}`)}function defaultFilename(n,a,S){switch(a){case`mo`:return`${n}.mo`;case`json`:return`${n}.json`;case`desktop`:return`${n}.desktop`;case`xml`:if(S){let n=S.replace(/\.in$/,``),a=n.lastIndexOf(`/`);return a>=0?n.slice(a+1):n}return`${n}.xml`}}const qT={command:`gettext <poDir> <outDir>`,description:`Compile gettext .po files to .mo (per-language locale tree) or substitute a metainfo template via msgfmt --xml.`,builder:n=>n.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/json)`,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`,`json`],default:`mo`}).option(`metainfo`,{description:"For --format=xml: path to the template (`.metainfo.xml.in`) used as msgfmt --template",type:`string`,normalize:!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 n=>{let a=No(n.poDir),S=No(n.outDir),C=n.domain,N=n.format??`mo`,F=n.metainfo?No(n.metainfo):void 0,I=n.filename??defaultFilename(C,N,F),H=!!n.verbose,W=!!n[`remove-xml-comments`];if(!await fileExists(a)){ze.error(`[gjsify gettext] PO directory does not exist: ${a}`),process.exitCode=1;return}try{N===`xml`&&F?await compileBulkXml({poDir:a,outDir:S,domain:C,template:F,filename:I,removeXmlComments:W,verbose:H}):(N===`xml`&&ze.warn(`[gjsify gettext] --format=xml without --metainfo: falling back to per-language XML files`),await compilePerLanguage({poDir:a,outDir:S,domain:C,format:N,filename:I,verbose:H}))}catch(n){n?.code===`ENOENT`?ze.error(`[gjsify gettext] msgfmt not found. Install it via your distro (package: gettext).`):(n?.stderr&&process.stderr.write(n.stderr),ze.error(`[gjsify gettext] msgfmt failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}};Be(),gx(),gs(),qo(),gc();const JT=promisify(execFile),YT={command:`gsettings <schemadir>`,description:"Compile GSettings schema XML files into a binary gschemas.compiled (wraps `glib-compile-schemas`).",builder:n=>n.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 n=>{let a=No(n.schemadir),S=n.targetdir?No(n.targetdir):a,C=[];n.strict&&C.push(`--strict`),C.push(`--targetdir=${S}`),C.push(a),n.verbose&&ze.log(`[gjsify gsettings] glib-compile-schemas ${C.join(` `)}`),await mkdir$1(S,{recursive:!0});try{let{stdout:a,stderr:N}=await JT(`glib-compile-schemas`,C);a&&process.stdout.write(a),N&&process.stderr.write(N),n.verbose&&ze.log(`[gjsify gsettings] wrote ${S}/gschemas.compiled`)}catch(n){n?.code===`ENOENT`?ze.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),ze.error(`[gjsify gsettings] glib-compile-schemas failed${n?.code===void 0?``:` (exit ${n.code})`}`)),process.exitCode=typeof n?.code==`number`?n.code:1}}};Rs(),qo();const XT=[`--device=dri`,`--share=ipc`,`--socket=fallback-x11`,`--socket=wayland`],ZT=[];function readPackageJson(n){let a=No(n,`package.json`),S;try{S=readFileSync(a,`utf-8`)}catch{throw Error(`gjsify flatpak: no package.json found at ${a}`)}try{return JSON.parse(S)}catch(n){throw Error(`gjsify flatpak: package.json at ${a} is not valid JSON: ${n.message}`)}}function looksLikeAppId(n){return typeof n==`string`&&/^[A-Za-z][A-Za-z0-9_-]*(\.[A-Za-z][A-Za-z0-9_-]*){2,}$/.test(n)}function resolveRuntime(n,a){let S=a.runtime??n?.runtime??`gnome`;if(S!==`gnome`&&S!==`freedesktop`)throw Error(`gjsify flatpak: unknown runtime "${S}" (expected "gnome" or "freedesktop")`);let C=a.runtimeVersion??n?.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 defaultCiContainer(n,a){return`ghcr.io/flathub-infra/flatpak-github-actions:${`${n}-${a}`}`}Rs();function loadDesktopTemplate(){return readFileSync(new URL(`../../templates/flatpak/desktop.tmpl`,import.meta.url),`utf-8`)}function loadFlathubAppTemplate(){return readFileSync(new URL(`../../templates/flatpak/flathub-app.json.tmpl`,import.meta.url),`utf-8`)}function loadFlathubCliTemplate(){return readFileSync(new URL(`../../templates/flatpak/flathub-cli.json.tmpl`,import.meta.url),`utf-8`)}function validateScaffoldInputs(n){let a=n.flatpak,S=[];return(!a.developer?.id||!a.developer?.name)&&S.push({field:`gjsify.flatpak.developer`,hint:'Set `gjsify.flatpak.developer = { "id": "io.github.you", "name": "Your Name" }` in package.json. The id is reverse-DNS.'}),a.summary||S.push({field:`gjsify.flatpak.summary`,hint:`One-line app summary, ≤80 chars, no trailing period. Example: "Learn 6502 assembly language".`}),a.description||S.push({field:`gjsify.flatpak.description`,hint:`Plain text (split on blank lines) or DescriptionBlock[] for rich content with bullet lists + translator hints.`}),a.license?.project||S.push({field:`gjsify.flatpak.license.project`,hint:`SPDX identifier of the project license, e.g. "MIT", "GPL-3.0-or-later".`}),a.homepageUrl||S.push({field:`gjsify.flatpak.homepageUrl`,hint:`Required by Flathub. Example: "https://github.com/you/your-repo".`}),S}function renderMetainfoApp(n){return renderMetainfo(n,`desktop-application`)}function renderMetainfoCli(n){return renderMetainfo(n,`console-application`)}function renderDesktop(n){let a=n.flatpak,S=(a.categories??[`Utility`]).join(`;`)+`;`,C=a.keywords?.length?`Keywords=${a.keywords.join(`;`)};\n`:``;return substitute(loadDesktopTemplate(),{NAME:n.name,SUMMARY:a.summary??n.name,COMMAND:n.command,APP_ID:n.appId,CATEGORIES_LINE:S,KEYWORDS_LINE:C})}function renderFlathubJson(n){return n===`cli`?loadFlathubCliTemplate():loadFlathubAppTemplate()}function renderMetainfo(n,a){let S=n.flatpak,C=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="${a}">`),F.push(` <id>${escapeXml(n.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(n.name)}</name>`),pushTranslatorHint(F,S.summaryTranslatorHint,` `),F.push(` <summary>${escapeXml(S.summary??n.name)}</summary>`),S.iconRemote&&F.push(` <icon type="remote">${escapeXml(S.iconRemote)}</icon>`),F.push(` <description>`);for(let n of renderDescriptionBlocks(S.description??``,` `))F.push(n);if(F.push(` </description>`),S.developer?.id&&S.developer?.name){F.push(` <developer id="${escapeXml(S.developer.id)}">`);let n=S.developer.nameTranslatable===!0?``:` translate="no"`;F.push(` <name${n}>${escapeXml(S.developer.name)}</name>`),S.developer.email&&F.push(` <email>${escapeXml(S.developer.email)}</email>`),F.push(` </developer>`)}a===`desktop-application`&&F.push(` <launchable type="desktop-id">${escapeXml(n.appId)}.desktop</launchable>`),S.screenshots?.length&&(F.push(` <screenshots>`),S.screenshots.forEach((n,a)=>{let S=n.type??(a===0?`default`:void 0),C=S?` type="${escapeXml(S)}"`:``,N=n.environment?` environment="${escapeXml(n.environment)}"`:``;F.push(` <screenshot${C}${N}>`),F.push(` <image>${escapeXml(n.url)}</image>`),n.caption&&(pushTranslatorHint(F,n.captionTranslatorHint,` `),F.push(` <caption>${escapeXml(n.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&&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[n,a]of Object.entries(I.attributes))F.push(` <content_attribute id="${escapeXml(n)}">${escapeXml(a)}</content_attribute>`);F.push(` </content_rating>`)}else F.push(` <content_rating type="${escapeXml(I.type)}" />`);if(S.releases?.length){F.push(` <releases>`);for(let n of S.releases)if(n.description===void 0)F.push(` <release version="${escapeXml(n.version)}" date="${escapeXml(n.date)}" />`);else{F.push(` <release version="${escapeXml(n.version)}" date="${escapeXml(n.date)}">`),F.push(` <description>`);for(let a of renderDescriptionBlocks(n.description,` `))F.push(a);F.push(` </description>`),F.push(` </release>`)}F.push(` </releases>`)}if(S.categories?.length){F.push(` <categories>`);for(let n of S.categories)F.push(` <category>${escapeXml(n)}</category>`);F.push(` </categories>`)}if(S.keywords?.length){F.push(` <keywords>`);for(let n of S.keywords)F.push(` <keyword>${escapeXml(n)}</keyword>`);F.push(` </keywords>`)}if(a===`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 n of S.kudos)F.push(` <kudo>${escapeXml(n)}</kudo>`);F.push(` </kudos>`)}let H=S.provides?.binaries??[n.command],W=S.provides?.mimetypes??[],K=S.provides?.dbus??[];if(H.length||W.length||K.length){F.push(` <provides>`);for(let n of H)F.push(` <binary>${escapeXml(n)}</binary>`);for(let n of W)F.push(` <mediatype>${escapeXml(n)}</mediatype>`);for(let n of K)F.push(` <dbus type="${escapeXml(n.type)}">${escapeXml(n.id)}</dbus>`);F.push(` </provides>`)}if(S.supports?.controls?.length||S.supports?.internet){F.push(` <supports>`);for(let n of S.supports.controls??[])F.push(` <control>${escapeXml(n)}</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 n of S.requires.controls??[])F.push(` <control>${escapeXml(n)}</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 n of S.recommends.controls??[])F.push(` <control>${escapeXml(n)}</control>`);F.push(` </recommends>`)}return F.push(`</component>`),F.join(`
|
|
755
755
|
`)+`
|
|
756
756
|
`}function renderDescriptionBlocks(n,a){let S=typeof n==`string`?stringToBlocks(n):n,C=[];for(let n of S)if(`p`in n)pushTranslatorHint(C,n.translatorHint,a),C.push(`${a}<p>${escapeXml(n.p.trim().replace(/\s+/g,` `))}</p>`);else{pushTranslatorHint(C,n.translatorHint,a),C.push(`${a}<ul>`);for(let S of n.ul)typeof S==`string`?C.push(`${a} <li>${escapeXml(S)}</li>`):(pushTranslatorHint(C,S.translatorHint,`${a} `),C.push(`${a} <li>${escapeXml(S.item)}</li>`));C.push(`${a}</ul>`)}return C}function stringToBlocks(n){return n.trim().split(/\n\n+/).map(n=>({p:n.trim().replace(/\s+/g,` `)}))}function pushTranslatorHint(n,a,S){a&&n.push(`${S}<!-- TRANSLATORS: ${a} -->`)}function normaliseContentRating(n){return n===void 0?{type:`oars-1.1`}:typeof n==`string`?{type:n}:{type:n.type??`oars-1.1`,attributes:n.attributes}}function substitute(n,a){let S=n;for(let[n,C]of Object.entries(a))S=S.split(`{{${n}}}`).join(C);return S}function escapeXml(n){return n.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}Be(),Rs(),qo();const QT={command:`init`,description:"Generate Flatpak manifest + MetaInfo XML + .desktop + flathub.json from `gjsify.flatpak` config.",builder:n=>n.option(`app-id`,{description:"Reverse-DNS app id (default: `gjsify.flatpak.appId` or package.json#name)",type:`string`}).option(`runtime`,{description:`Runtime family`,choices:[`gnome`,`freedesktop`]}).option(`runtime-version`,{description:`Runtime version (default: gnome -> 50, freedesktop -> 24.08)`,type:`string`}).option(`kind`,{description:`App kind: "app" (default, desktop) or "cli" (console-application MetaInfo, no .desktop)`,choices:[`app`,`cli`]}).option(`cli-only`,{description:"(Deprecated) Alias for `--kind cli`. Use --kind instead.",type:`boolean`,default:!1}).option(`manifest`,{description:"Output path for the manifest. Default: `<app-id>.json` in cwd.",type:`string`,normalize:!0}).option(`metainfo`,{description:"Output path for the MetaInfo XML. Default: `data/<app-id>.metainfo.xml.in` in cwd.",type:`string`,normalize:!0}).option(`desktop`,{description:"Output path for the .desktop entry (app kind only). Default: `data/<app-id>.desktop.in`.",type:`string`,normalize:!0}).option(`flathub-json`,{description:"Output path for the flathub.json policy stub. Default: `flathub.json` in cwd.",type:`string`,normalize:!0}).option(`command`,{description:`Binary name in /app/bin (default: app id)`,type:`string`}).option(`sdk-extension`,{description:`Extra SDK extension (repeatable)`,type:`string`,array:!0}).option(`finish-arg`,{description:`Extra finish-arg (repeatable). Override defaults entirely with multiple --finish-arg.`,type:`string`,array:!0}).option(`force`,{description:`Overwrite existing output files (manifest, metainfo, desktop, flathub.json)`,type:`boolean`,default:!1}).option(`verbose`,{description:`Print the resolved manifest fields before writing`,type:`boolean`,default:!1}),handler:async n=>{let a=(await new Config().forBuild({}).catch(()=>({}))).flatpak??{},S=process.cwd(),C=readPackageJson(S),N=n.appId??a.appId??(looksLikeAppId(C.name)?C.name:void 0);if(!N)throw Error(`gjsify flatpak init: no app id available. Pass --app-id, set gjsify.flatpak.appId in package.json, or rename the package to a reverse-DNS id like org.example.MyApp.`);let F=n.kind??a.kind??(n.cliOnly?`cli`:`app`),{runtime:I,runtimeId:H,sdk:W,runtimeVersion:K}=resolveRuntime(a,{runtime:n.runtime,runtimeVersion:n.runtimeVersion}),q=mergeArrays(a.sdkExtensions,n.sdkExtension),Y=a.appendPath??(q?.length?deriveAppendPath(q):void 0),X=n.command??a.command??N,te=n.finishArg,ne=te===void 0?a.finishArgs??(F===`cli`?ZT:XT):te,re={id:N,runtime:H,"runtime-version":K,sdk:W};q?.length&&(re[`sdk-extensions`]=q),Y?.length&&(re[`build-options`]={"append-path":Y.join(`:`)}),re.command=X,re[`finish-args`]=ne;let ie=a.cleanup;ie?.length&&(re.cleanup=ie);let ae=[];a.extraModules?.length&&ae.push(...a.extraModules),ae.push({name:deriveModuleName(N),buildsystem:`meson`,sources:[{type:`dir`,path:`.`}]}),re.modules=ae,writeIfFresh(No(S,n.manifest??`${N}.json`),JSON.stringify(re,null,4)+`
|
|
757
|
-
`,n.force??!1,`manifest`);let oe={appId:N,name:
|
|
758
|
-
Fill these fields in package.json#gjsify.flatpak (or .gjsifyrc.*) and re-run with --force.`)}else{let C=F===`cli`?renderMetainfoCli(oe):renderMetainfoApp(oe);writeIfFresh(No(S,n.metainfo??`data/${N}.metainfo.xml.in`),C,n.force??!1,`metainfo`),F===`app`&&(writeIfFresh(No(S,n.desktop??`data/${N}.desktop.in`),renderDesktop(oe),n.force??!1,`desktop`),a.icon||ze.warn(`[gjsify flatpak init] No gjsify.flatpak.icon set. Flathub requires a scalable SVG at\n data/icons/hicolor/scalable/apps/${N}.svg`)),writeIfFresh(No(S,n.flathubJson??`flathub.json`),renderFlathubJson(F),n.force??!1,`flathub.json`)}n.verbose&&(ze.log(`[gjsify flatpak init] kind=${F} runtime=${H} ${K} sdk=${W}`),ze.log(`[gjsify flatpak init] command=${X} finish-args=${JSON.stringify(ne)}`))}};function writeIfFresh(n,a,S,C){if(existsSync(n)&&!S){ze.log(`[gjsify flatpak init] skipped ${C}: ${n} (exists; --force to overwrite)`);return}mkdirSync(zo(n),{recursive:!0}),writeFileSync(n,a,`utf-8`),ze.log(`[gjsify flatpak init] wrote ${C}: ${n}`)}function friendlyName(n,a){if(n.startsWith(`@`))return n.slice(n.indexOf(`/`)+1);if(n===a){let n=a.split(`.`);return n[n.length-1]??a}return n}function mergeArrays(n,a){if(!(!n?.length&&!a?.length))return[...n??[],...a??[]]}function deriveAppendPath(n){let a=[];for(let S of n){let n=/^org\.freedesktop\.Sdk\.Extension\.([A-Za-z0-9-]+)$/.exec(S);n&&a.push(`/usr/lib/sdk/${n[1]}/bin`)}return a.push(`/app/bin`),a}function deriveModuleName(n){let a=n.split(`.`);return a[a.length-1]||n}Be(),gx(),Rs(),qo();const $T={command:`build [manifest]`,description:"Build the Flatpak via `flatpak-builder`. Wraps a typical install + export + bundle + tarball pipeline.",builder:n=>n.positional(`manifest`,{description:`Path to the Flatpak manifest (default: first *.json that looks like a manifest in cwd)`,type:`string`,normalize:!0}).option(`build-dir`,{description:`flatpak-builder working directory`,type:`string`,default:`flatpak-build`,normalize:!0}).option(`install`,{description:"After build, run `flatpak-builder --user --install` to install locally",type:`boolean`,default:!1}).option(`repo`,{description:"Export the build into the given OSTree repo (passes `--repo=<dir>` to flatpak-builder)",type:`string`,normalize:!0}).option(`bundle`,{description:"After --repo export, build a single-file bundle (`flatpak build-bundle`) at this path",type:`string`,normalize:!0}).option(`tarball`,{description:`Create a tarball of the build dir (parity with the legacy build-flatpak.sh tarball step)`,type:`string`,normalize:!0}).option(`force-clean`,{description:`Pass --force-clean to flatpak-builder (default true)`,type:`boolean`,default:!0}).option(`sandbox`,{description:`Pass --sandbox to flatpak-builder (default true)`,type:`boolean`,default:!0}).option(`delete-build-dirs`,{description:`Pass --delete-build-dirs to flatpak-builder (default true)`,type:`boolean`,default:!0}).option(`install-deps-from`,{description:"Pass --install-deps-from to flatpak-builder (e.g. `flathub`)",type:`string`}).option(`verbose`,{description:`Print the underlying flatpak-builder invocations`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=No(a,n.manifest??findDefaultManifest(a));if(!existsSync(S))throw Error(`gjsify flatpak build: manifest ${S} not found`);let C=No(a,n.buildDir??`flatpak-build`),N=[];if(n.forceClean!==!1&&N.push(`--force-clean`),n.sandbox!==!1&&N.push(`--sandbox`),n.deleteBuildDirs!==!1&&N.push(`--delete-build-dirs`),n.installDepsFrom&&N.push(`--install-deps-from=${n.installDepsFrom}`),existsSync(C)&&rmSync(C,{recursive:!0,force:!0}),await runFlatpakBuilder([...N,C,S],{verbose:n.verbose}),n.install&&await runFlatpakBuilder([`--user`,`--install`,`--force-clean`,C,S],{verbose:n.verbose}),n.repo){let N=No(a,n.repo);mkdirSync(zo(N),{recursive:!0}),await runFlatpakBuilder([`--repo=${N}`,`--force-clean`,C,S],{verbose:n.verbose})}if(n.bundle){if(!n.repo)throw Error(`gjsify flatpak build: --bundle requires --repo (the bundle is built from the OSTree repo).`);let C=No(a,n.bundle);mkdirSync(zo(C),{recursive:!0}),await runFlatpak([`build-bundle`,No(a,n.repo),C,readManifestAppId(S)],{verbose:n.verbose})}if(n.tarball){let S=No(a,n.tarball);mkdirSync(zo(S),{recursive:!0}),await runTar([`-czf`,S,`-C`,C,`.`],{verbose:n.verbose})}ze.log(`[gjsify flatpak build] done (${C})`)}};function findDefaultManifest(n){return scanForManifest(n)??`flatpak.json`}function scanForManifest(n){let a=[];try{a=readdirSync(n)}catch{return}for(let S of a)if(S.endsWith(`.json`)&&!(S===`package.json`||S===`tsconfig.json`||S.startsWith(`.`)))try{let a=JSON.parse(readFileSync(No(n,S),`utf-8`));if(typeof a.id==`string`&&typeof a.runtime==`string`&&Array.isArray(a.modules))return S}catch{}}function readManifestAppId(n){let a=readFileSync(n,`utf-8`),S=JSON.parse(a);if(typeof S.id!=`string`)throw Error(`gjsify flatpak build: ${n} has no string "id" field`);return S.id}async function runFlatpakBuilder(n,a){return runProc(`flatpak-builder`,n,a,{notFoundHint:"flatpak-builder not found. Install via your distro (Fedora: `sudo dnf install flatpak-builder`)."})}async function runFlatpak(n,a){return runProc(`flatpak`,n,a,{notFoundHint:`flatpak not found. Install via your distro and add Flathub: see https://flathub.org/setup.`})}async function runTar(n,a){return runProc(`tar`,n,a,{notFoundHint:`tar not found.`})}function runProc(n,a,S,C){return S.verbose&&ze.log(`[gjsify flatpak] ${n} ${a.join(` `)}`),new Promise((S,N)=>{let F=spawn(n,a,{stdio:`inherit`});F.on(`error`,n=>{n.code===`ENOENT`?N(Error(`gjsify flatpak: ${C.notFoundHint}`)):N(n)}),F.on(`exit`,a=>{a===0?S():N(Error(`gjsify flatpak: ${n} exited with status ${a}`))})})}Be(),gx(),Rs(),qo();const eE={command:`deps`,description:"Generate Flatpak offline-cache sources from a yarn.lock / package-lock.json (wraps `flatpak-node-generator`).",builder:n=>n.option(`lockfile`,{description:`Path to lockfile (default: yarn.lock or package-lock.json in cwd)`,type:`string`,normalize:!0}).option(`type`,{description:`Lockfile type. Default: detected from filename.`,choices:[`yarn`,`npm`]}).option(`out`,{description:`Output JSON sources file`,type:`string`,default:`flatpak-node-sources.json`,normalize:!0}).option(`xdg-layout`,{description:`Pass --xdg-layout (recommended for Yarn Berry / PnP setups)`,type:`boolean`,default:!0}).option(`electron-node-headers`,{description:`Pass --electron-node-headers`,type:`boolean`,default:!1}).option(`verbose`,{description:`Print the underlying flatpak-node-generator invocation`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=No(a,n.lockfile??detectLockfile(a));if(!existsSync(S))throw Error(`gjsify flatpak deps: lockfile ${S} not found (use --lockfile to override)`);let C=n.type??(S.endsWith(`package-lock.json`)?`npm`:`yarn`),N=No(a,n.out??`flatpak-node-sources.json`);mkdirSync(zo(N),{recursive:!0});let F=[C,S,`-o`,N];n.xdgLayout!==!1&&F.push(`--xdg-layout`),n.electronNodeHeaders&&F.push(`--electron-node-headers`),n.verbose&&ze.log(`[gjsify flatpak deps] flatpak-node-generator ${F.join(` `)}`),await new Promise((n,a)=>{let S=spawn(`flatpak-node-generator`,F,{stdio:`inherit`});S.on(`error`,n=>{n.code===`ENOENT`?a(Error("gjsify flatpak deps: flatpak-node-generator not found. Install via `pipx install flatpak-node-generator` (see https://github.com/flatpak/flatpak-builder-tools/tree/master/node).")):a(n)}),S.on(`exit`,S=>{S===0?n():a(Error(`gjsify flatpak deps: flatpak-node-generator exited with status ${S}`))})}),ze.log(`[gjsify flatpak deps] wrote ${N}`)}};function detectLockfile(n){return existsSync(No(n,`yarn.lock`))?`yarn.lock`:existsSync(No(n,`package-lock.json`))?`package-lock.json`:`yarn.lock`}Be(),Rs(),qo();const tE={command:`ci`,description:`Scaffold .github/workflows/flatpak.yml using the flathub-infra container + flatpak-builder@v6 action.`,builder:n=>n.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 n=>{let a=process.cwd(),S=(await new Config().forBuild({}).catch(()=>({}))).flatpak??{},C=readPackageJson(a),N=S.appId??(looksLikeAppId(C.name)?C.name:void 0);if(!N)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 F=n.manifest??`${N}.json`,I=n.bundle??`${N}.flatpak`,{runtime:H,runtimeVersion:W}=resolveRuntime(S,{}),K=n.runtimeImage??S.ciContainer??defaultCiContainer(H,W),q=n.branches??S.ciBranches??[`main`],Y=n.cacheKey??"flatpak-builder-${{ github.sha }}",X=No(a,n.out??`.github/workflows/flatpak.yml`);if(existsSync(X)&&!n.force){if(readFileSync(X,`utf-8`)===renderWorkflow({manifest:F,bundle:I,runtimeImage:K,branches:q,cacheKey:Y})){ze.log(`[gjsify flatpak ci] ${X} already up to date`);return}throw Error(`gjsify flatpak ci: ${X} exists with different content. Pass --force to overwrite.`)}let te=renderWorkflow({manifest:F,bundle:I,runtimeImage:K,branches:q,cacheKey:Y});mkdirSync(zo(X),{recursive:!0}),writeFileSync(X,te,`utf-8`),n.verbose&&ze.log(`[gjsify flatpak ci] runtime-image=${K} manifest=${F} bundle=${I}`),ze.log(`[gjsify flatpak ci] wrote ${X}`)}};function renderWorkflow(n){let a=`[${n.branches.map(n=>JSON.stringify(n)).join(`, `)}]`;return`name: Flatpak
|
|
757
|
+
`,n.force??!1,`manifest`);let oe=C.name??N,Z={appId:N,name:a.name??friendlyName(oe,N),command:X,kind:F,flatpak:a},se=validateScaffoldInputs(Z);if(se.length>0){ze.warn(`[gjsify flatpak init] Manifest written, but MetaInfo / .desktop are skipped — config gaps:`);for(let n of se)ze.warn(` - ${n.field}: ${n.hint}`);ze.warn(`
|
|
758
|
+
Fill these fields in package.json#gjsify.flatpak (or .gjsifyrc.*) and re-run with --force.`)}else{let C=F===`cli`?renderMetainfoCli(Z):renderMetainfoApp(Z);writeIfFresh(No(S,n.metainfo??`data/${N}.metainfo.xml.in`),C,n.force??!1,`metainfo`),F===`app`&&(writeIfFresh(No(S,n.desktop??`data/${N}.desktop.in`),renderDesktop(Z),n.force??!1,`desktop`),a.icon||ze.warn(`[gjsify flatpak init] No gjsify.flatpak.icon set. Flathub requires a scalable SVG at\n data/icons/hicolor/scalable/apps/${N}.svg`)),writeIfFresh(No(S,n.flathubJson??`flathub.json`),renderFlathubJson(F),n.force??!1,`flathub.json`)}n.verbose&&(ze.log(`[gjsify flatpak init] kind=${F} runtime=${H} ${K} sdk=${W}`),ze.log(`[gjsify flatpak init] command=${X} finish-args=${JSON.stringify(ne)}`))}};function writeIfFresh(n,a,S,C){if(existsSync(n)&&!S){ze.log(`[gjsify flatpak init] skipped ${C}: ${n} (exists; --force to overwrite)`);return}mkdirSync(zo(n),{recursive:!0}),writeFileSync(n,a,`utf-8`),ze.log(`[gjsify flatpak init] wrote ${C}: ${n}`)}function friendlyName(n,a){if(n.startsWith(`@`))return n.slice(n.indexOf(`/`)+1);if(n===a){let n=a.split(`.`);return n[n.length-1]??a}return n}function mergeArrays(n,a){if(!(!n?.length&&!a?.length))return[...n??[],...a??[]]}function deriveAppendPath(n){let a=[];for(let S of n){let n=/^org\.freedesktop\.Sdk\.Extension\.([A-Za-z0-9-]+)$/.exec(S);n&&a.push(`/usr/lib/sdk/${n[1]}/bin`)}return a.push(`/app/bin`),a}function deriveModuleName(n){let a=n.split(`.`);return a[a.length-1]||n}Be(),gx(),Rs(),qo();const $T={command:`build [manifest]`,description:"Build the Flatpak via `flatpak-builder`. Wraps a typical install + export + bundle + tarball pipeline.",builder:n=>n.positional(`manifest`,{description:`Path to the Flatpak manifest (default: first *.json that looks like a manifest in cwd)`,type:`string`,normalize:!0}).option(`build-dir`,{description:`flatpak-builder working directory`,type:`string`,default:`flatpak-build`,normalize:!0}).option(`install`,{description:"After build, run `flatpak-builder --user --install` to install locally",type:`boolean`,default:!1}).option(`repo`,{description:"Export the build into the given OSTree repo (passes `--repo=<dir>` to flatpak-builder)",type:`string`,normalize:!0}).option(`bundle`,{description:"After --repo export, build a single-file bundle (`flatpak build-bundle`) at this path",type:`string`,normalize:!0}).option(`tarball`,{description:`Create a tarball of the build dir (parity with the legacy build-flatpak.sh tarball step)`,type:`string`,normalize:!0}).option(`force-clean`,{description:`Pass --force-clean to flatpak-builder (default true)`,type:`boolean`,default:!0}).option(`sandbox`,{description:`Pass --sandbox to flatpak-builder (default true)`,type:`boolean`,default:!0}).option(`delete-build-dirs`,{description:`Pass --delete-build-dirs to flatpak-builder (default true)`,type:`boolean`,default:!0}).option(`install-deps-from`,{description:"Pass --install-deps-from to flatpak-builder (e.g. `flathub`)",type:`string`}).option(`verbose`,{description:`Print the underlying flatpak-builder invocations`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=No(a,n.manifest??findDefaultManifest(a));if(!existsSync(S))throw Error(`gjsify flatpak build: manifest ${S} not found`);let C=No(a,n.buildDir??`flatpak-build`),N=[];if(n.forceClean!==!1&&N.push(`--force-clean`),n.sandbox!==!1&&N.push(`--sandbox`),n.deleteBuildDirs!==!1&&N.push(`--delete-build-dirs`),n.installDepsFrom&&N.push(`--install-deps-from=${n.installDepsFrom}`),existsSync(C)&&rmSync(C,{recursive:!0,force:!0}),await runFlatpakBuilder([...N,C,S],{verbose:n.verbose}),n.install&&await runFlatpakBuilder([`--user`,`--install`,`--force-clean`,C,S],{verbose:n.verbose}),n.repo){let N=No(a,n.repo);mkdirSync(zo(N),{recursive:!0}),await runFlatpakBuilder([`--repo=${N}`,`--force-clean`,C,S],{verbose:n.verbose})}if(n.bundle){if(!n.repo)throw Error(`gjsify flatpak build: --bundle requires --repo (the bundle is built from the OSTree repo).`);let C=No(a,n.bundle);mkdirSync(zo(C),{recursive:!0}),await runFlatpak([`build-bundle`,No(a,n.repo),C,readManifestAppId(S)],{verbose:n.verbose})}if(n.tarball){let S=No(a,n.tarball);mkdirSync(zo(S),{recursive:!0}),await runTar([`-czf`,S,`-C`,C,`.`],{verbose:n.verbose})}ze.log(`[gjsify flatpak build] done (${C})`)}};function findDefaultManifest(n){return scanForManifest(n)??`flatpak.json`}function scanForManifest(n){let a=[];try{a=readdirSync(n)}catch{return}for(let S of a)if(S.endsWith(`.json`)&&!(S===`package.json`||S===`tsconfig.json`||S.startsWith(`.`)))try{let a=JSON.parse(readFileSync(No(n,S),`utf-8`));if(typeof a.id==`string`&&typeof a.runtime==`string`&&Array.isArray(a.modules))return S}catch{}}function readManifestAppId(n){let a=readFileSync(n,`utf-8`),S=JSON.parse(a);if(typeof S.id!=`string`)throw Error(`gjsify flatpak build: ${n} has no string "id" field`);return S.id}async function runFlatpakBuilder(n,a){return runProc(`flatpak-builder`,n,a,{notFoundHint:"flatpak-builder not found. Install via your distro (Fedora: `sudo dnf install flatpak-builder`)."})}async function runFlatpak(n,a){return runProc(`flatpak`,n,a,{notFoundHint:`flatpak not found. Install via your distro and add Flathub: see https://flathub.org/setup.`})}async function runTar(n,a){return runProc(`tar`,n,a,{notFoundHint:`tar not found.`})}function runProc(n,a,S,C){return S.verbose&&ze.log(`[gjsify flatpak] ${n} ${a.join(` `)}`),new Promise((S,N)=>{let F=spawn(n,a,{stdio:`inherit`});F.on(`error`,n=>{n.code===`ENOENT`?N(Error(`gjsify flatpak: ${C.notFoundHint}`)):N(n)}),F.on(`exit`,a=>{a===0?S():N(Error(`gjsify flatpak: ${n} exited with status ${a}`))})})}Be(),gx(),Rs(),qo();const eE={command:`deps`,description:"Generate Flatpak offline-cache sources from a yarn.lock / package-lock.json (wraps `flatpak-node-generator`).",builder:n=>n.option(`lockfile`,{description:`Path to lockfile (default: yarn.lock or package-lock.json in cwd)`,type:`string`,normalize:!0}).option(`type`,{description:`Lockfile type. Default: detected from filename.`,choices:[`yarn`,`npm`]}).option(`out`,{description:`Output JSON sources file`,type:`string`,default:`flatpak-node-sources.json`,normalize:!0}).option(`xdg-layout`,{description:`Pass --xdg-layout (recommended for Yarn Berry / PnP setups)`,type:`boolean`,default:!0}).option(`electron-node-headers`,{description:`Pass --electron-node-headers`,type:`boolean`,default:!1}).option(`verbose`,{description:`Print the underlying flatpak-node-generator invocation`,type:`boolean`,default:!1}),handler:async n=>{let a=process.cwd(),S=No(a,n.lockfile??detectLockfile(a));if(!existsSync(S))throw Error(`gjsify flatpak deps: lockfile ${S} not found (use --lockfile to override)`);let C=n.type??(S.endsWith(`package-lock.json`)?`npm`:`yarn`),N=No(a,n.out??`flatpak-node-sources.json`);mkdirSync(zo(N),{recursive:!0});let F=[C,S,`-o`,N];n.xdgLayout!==!1&&F.push(`--xdg-layout`),n.electronNodeHeaders&&F.push(`--electron-node-headers`),n.verbose&&ze.log(`[gjsify flatpak deps] flatpak-node-generator ${F.join(` `)}`),await new Promise((n,a)=>{let S=spawn(`flatpak-node-generator`,F,{stdio:`inherit`});S.on(`error`,n=>{n.code===`ENOENT`?a(Error("gjsify flatpak deps: flatpak-node-generator not found. Install via `pipx install flatpak-node-generator` (see https://github.com/flatpak/flatpak-builder-tools/tree/master/node).")):a(n)}),S.on(`exit`,S=>{S===0?n():a(Error(`gjsify flatpak deps: flatpak-node-generator exited with status ${S}`))})}),ze.log(`[gjsify flatpak deps] wrote ${N}`)}};function detectLockfile(n){return existsSync(No(n,`yarn.lock`))?`yarn.lock`:existsSync(No(n,`package-lock.json`))?`package-lock.json`:`yarn.lock`}Be(),Rs(),qo();const tE={command:`ci`,description:`Scaffold .github/workflows/flatpak.yml using the flathub-infra container + flatpak-builder@v6 action.`,builder:n=>n.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 n=>{let a=process.cwd(),S=(await new Config().forBuild({}).catch(()=>({}))).flatpak??{},C=readPackageJson(a),N=S.appId??(looksLikeAppId(C.name)?C.name:void 0);if(!N)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 F=n.manifest??`${N}.json`,I=n.bundle??`${N}.flatpak`,{runtime:H,runtimeVersion:W}=resolveRuntime(S,{}),K=n.runtimeImage??S.ciContainer??defaultCiContainer(H,W),q=n.branches??S.ciBranches??[`main`],Y=n.cacheKey??"flatpak-builder-${{ github.sha }}",X=No(a,n.out??`.github/workflows/flatpak.yml`);if(existsSync(X)&&!n.force){if(readFileSync(X,`utf-8`)===renderWorkflow({manifest:F,bundle:I,runtimeImage:K,branches:q,cacheKey:Y})){ze.log(`[gjsify flatpak ci] ${X} already up to date`);return}throw Error(`gjsify flatpak ci: ${X} exists with different content. Pass --force to overwrite.`)}let te=renderWorkflow({manifest:F,bundle:I,runtimeImage:K,branches:q,cacheKey:Y});mkdirSync(zo(X),{recursive:!0}),writeFileSync(X,te,`utf-8`),n.verbose&&ze.log(`[gjsify flatpak ci] runtime-image=${K} manifest=${F} bundle=${I}`),ze.log(`[gjsify flatpak ci] wrote ${X}`)}};function renderWorkflow(n){let a=`[${n.branches.map(n=>JSON.stringify(n)).join(`, `)}]`;return`name: Flatpak
|
|
759
759
|
|
|
760
760
|
on:
|
|
761
761
|
push:
|
|
@@ -143,10 +143,10 @@ export const flatpakInitCommand = {
|
|
|
143
143
|
const manifestOut = args.manifest ?? `${appId}.json`;
|
|
144
144
|
const manifestPath = resolve(cwd, manifestOut);
|
|
145
145
|
writeIfFresh(manifestPath, JSON.stringify(manifest, null, 4) + '\n', args.force ?? false, 'manifest');
|
|
146
|
-
const
|
|
146
|
+
const pkgName = pkg.name ?? appId;
|
|
147
147
|
const scaffold = {
|
|
148
148
|
appId,
|
|
149
|
-
name: friendlyName(
|
|
149
|
+
name: flatpak.name ?? friendlyName(pkgName, appId),
|
|
150
150
|
command,
|
|
151
151
|
kind,
|
|
152
152
|
flatpak,
|
|
@@ -241,6 +241,14 @@ export interface ConfigDataFlatpak {
|
|
|
241
241
|
* `gjsify flatpak init`.
|
|
242
242
|
*/
|
|
243
243
|
kind?: 'app' | 'cli';
|
|
244
|
+
/**
|
|
245
|
+
* App display name (`.desktop` `Name=` + MetaInfo `<name>`). Defaults
|
|
246
|
+
* to a friendly derivation of `package.json#name` — that works when
|
|
247
|
+
* `name` is the reverse-DNS app id, but breaks when it's an npm
|
|
248
|
+
* package name like `learn6502`. Set this explicitly to the
|
|
249
|
+
* human-readable name shown in app stores (e.g. `"Learn 6502 Assembly"`).
|
|
250
|
+
*/
|
|
251
|
+
name?: string;
|
|
244
252
|
/**
|
|
245
253
|
* Developer attribution required by Flathub. `id` must be reverse-DNS.
|
|
246
254
|
* `email` (optional) becomes `<email>` inside `<developer>`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.13",
|
|
4
4
|
"description": "CLI for Gjsify",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"cli"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@gjsify/buffer": "^0.4.
|
|
41
|
-
"@gjsify/create-app": "^0.4.
|
|
42
|
-
"@gjsify/node-globals": "^0.4.
|
|
43
|
-
"@gjsify/node-polyfills": "^0.4.
|
|
44
|
-
"@gjsify/npm-registry": "^0.4.
|
|
45
|
-
"@gjsify/resolve-npm": "^0.4.
|
|
46
|
-
"@gjsify/rolldown-plugin-gjsify": "^0.4.
|
|
47
|
-
"@gjsify/rolldown-plugin-pnp": "^0.4.
|
|
48
|
-
"@gjsify/semver": "^0.4.
|
|
49
|
-
"@gjsify/tar": "^0.4.
|
|
50
|
-
"@gjsify/web-polyfills": "^0.4.
|
|
51
|
-
"@gjsify/workspace": "^0.4.
|
|
40
|
+
"@gjsify/buffer": "^0.4.13",
|
|
41
|
+
"@gjsify/create-app": "^0.4.13",
|
|
42
|
+
"@gjsify/node-globals": "^0.4.13",
|
|
43
|
+
"@gjsify/node-polyfills": "^0.4.13",
|
|
44
|
+
"@gjsify/npm-registry": "^0.4.13",
|
|
45
|
+
"@gjsify/resolve-npm": "^0.4.13",
|
|
46
|
+
"@gjsify/rolldown-plugin-gjsify": "^0.4.13",
|
|
47
|
+
"@gjsify/rolldown-plugin-pnp": "^0.4.13",
|
|
48
|
+
"@gjsify/semver": "^0.4.13",
|
|
49
|
+
"@gjsify/tar": "^0.4.13",
|
|
50
|
+
"@gjsify/web-polyfills": "^0.4.13",
|
|
51
|
+
"@gjsify/workspace": "^0.4.13",
|
|
52
52
|
"cosmiconfig": "^9.0.1",
|
|
53
53
|
"get-tsconfig": "^4.14.0",
|
|
54
54
|
"pkg-types": "^2.3.1",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"yargs": "^18.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@gjsify/unit": "^0.4.
|
|
59
|
+
"@gjsify/unit": "^0.4.13",
|
|
60
60
|
"@types/yargs": "^17.0.35",
|
|
61
61
|
"typescript": "^6.0.3"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@gjsify/rolldown-native": "^0.4.
|
|
64
|
+
"@gjsify/rolldown-native": "^0.4.13"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@gjsify/rolldown-native": {
|