@gjsify/cli 0.64.39 → 0.64.41-next.335
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 +311 -260
- package/lib/cli-app.js +2 -1
- package/lib/commands/flatpark.d.ts +11 -0
- package/lib/commands/flatpark.js +147 -0
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.js +1 -0
- package/lib/commands/ship.js +17 -0
- package/lib/commands/webext/subcommands.d.ts +1 -0
- package/lib/commands/webext/subcommands.js +5 -1
- package/lib/utils/ship/app-runtime.d.ts +29 -0
- package/lib/utils/ship/app-runtime.js +99 -2
- package/lib/utils/ship/flatpark.d.ts +84 -0
- package/lib/utils/ship/flatpark.js +298 -0
- package/lib/utils/ship/formats.js +80 -0
- package/lib/utils/ship/tarball.d.ts +25 -0
- package/lib/utils/ship/tarball.js +69 -0
- package/lib/utils/ship/types.d.ts +1 -1
- package/lib/utils/webext/stores/index.d.ts +227 -0
- package/lib/utils/webext/stores/index.js +252 -0
- package/package.json +22 -21
package/lib/cli-app.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import yargs from 'yargs';
|
|
19
19
|
import { classifyCliFailure } from './cli-fail.js';
|
|
20
20
|
import { cliVersion } from './utils/publish-headers.js';
|
|
21
|
-
import { buildCommand as build, clearCommand as clear, copyCommand as copy, envCommand as env, execCommand as exec, testCommand as test, runCommand as run, infoCommand as info, systemCheckCommand as systemCheck, checkCommand as check, showcaseCommand as showcase, createCommand as create, gresourceCommand as gresource, gettextCommand as gettext, gsettingsCommand as gsettings, flatpakCommand as flatpak, shipCommand as ship, dlxCommand as dlx, installCommand as install, linkCommand as link, unlinkCommand as unlink, foreachCommand as foreach, workspaceCommand as workspace, packCommand as pack, publishCommand as publish, whoamiCommand as whoami, releaseNotesCommand as releaseNotes, androidIconsCommand as androidIcons, creditsCommand as credits, loginCommand as login, logoutCommand as logout, trustCommand as trust, onboardCommand as onboard, selfUpdateCommand as selfUpdate, generateInstallerCommand as generateInstaller, pruneCommand as prune, uninstallCommand as uninstall, formatCommand as format, lintCommand as lint, fixCommand as fix, upgradeCommand as upgrade, barrelsCommand as barrels, tscCommand as tsc, affectedCommand as affected, storybookCommand as storybook, siteCommand as site, devCommand as dev, debugCommand as debug, devtoolsCommand as devtools, browseCommand as browse, webextCommand as webext, blueprintCommand as blueprint, } from './commands/index.js';
|
|
21
|
+
import { buildCommand as build, clearCommand as clear, copyCommand as copy, envCommand as env, execCommand as exec, testCommand as test, runCommand as run, infoCommand as info, systemCheckCommand as systemCheck, checkCommand as check, showcaseCommand as showcase, createCommand as create, gresourceCommand as gresource, gettextCommand as gettext, gsettingsCommand as gsettings, flatpakCommand as flatpak, shipCommand as ship, flatparkCommand as flatpark, dlxCommand as dlx, installCommand as install, linkCommand as link, unlinkCommand as unlink, foreachCommand as foreach, workspaceCommand as workspace, packCommand as pack, publishCommand as publish, whoamiCommand as whoami, releaseNotesCommand as releaseNotes, androidIconsCommand as androidIcons, creditsCommand as credits, loginCommand as login, logoutCommand as logout, trustCommand as trust, onboardCommand as onboard, selfUpdateCommand as selfUpdate, generateInstallerCommand as generateInstaller, pruneCommand as prune, uninstallCommand as uninstall, formatCommand as format, lintCommand as lint, fixCommand as fix, upgradeCommand as upgrade, barrelsCommand as barrels, tscCommand as tsc, affectedCommand as affected, storybookCommand as storybook, siteCommand as site, devCommand as dev, debugCommand as debug, devtoolsCommand as devtools, browseCommand as browse, webextCommand as webext, blueprintCommand as blueprint, } from './commands/index.js';
|
|
22
22
|
import { APP_NAME } from './constants.js';
|
|
23
23
|
import { isBun, isDeno, isNode, gjsSystemVersion } from '@gjsify/rolldown-plugin-gjsify/runtime';
|
|
24
24
|
import { ensureGjsifyShimOnPath } from './utils/gjsify-shim.js';
|
|
@@ -112,6 +112,7 @@ export async function runCli(argv) {
|
|
|
112
112
|
.command(gsettings.command, gsettings.description, gsettings.builder, gsettings.handler)
|
|
113
113
|
.command(flatpak.command, flatpak.description, flatpak.builder, flatpak.handler)
|
|
114
114
|
.command(ship.command, ship.description, ship.builder, ship.handler)
|
|
115
|
+
.command(flatpark.command, flatpark.description, flatpark.builder, flatpark.handler)
|
|
115
116
|
.command(foreach.command, foreach.description, foreach.builder, foreach.handler)
|
|
116
117
|
.command(workspace.command, workspace.description, workspace.builder, workspace.handler)
|
|
117
118
|
.command(pack.command, pack.description, pack.builder, pack.handler)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from '../types/index.js';
|
|
2
|
+
interface FlatparkOptions {
|
|
3
|
+
project?: string;
|
|
4
|
+
out: string;
|
|
5
|
+
stage?: string;
|
|
6
|
+
'release-dir'?: string;
|
|
7
|
+
repo?: string;
|
|
8
|
+
'tag-prefix': string;
|
|
9
|
+
}
|
|
10
|
+
export declare const flatparkCommand: Command<unknown, FlatparkOptions>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// `gjsify flatpark [project] --out <dir>` — write the FlatPark package directory
|
|
2
|
+
// (`registry/<app-id>/`) for a project that already ran `gjsify ship`.
|
|
3
|
+
//
|
|
4
|
+
// It only WRITES FILES. No pull request, no push, no network, no hashing: the
|
|
5
|
+
// download URL, sha256 and size come from the release record `ship` wrote beside
|
|
6
|
+
// the `linux-tar-flatpak` archive, and a missing record stops the command. What
|
|
7
|
+
// goes where is the module header of `utils/ship/flatpark.ts` and ADR 0143.
|
|
8
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { dirname, join, relative, resolve } from 'node:path';
|
|
10
|
+
import { Config } from '../config.js';
|
|
11
|
+
import { readPackageJson } from '../utils/pkg-json.js';
|
|
12
|
+
import { parseGithubRepo, readFlatparkSources, releaseDateOf, renderFlatparkPackage } from '../utils/ship/flatpark.js';
|
|
13
|
+
import { readStageManifest } from '../utils/ship/stage-manifest.js';
|
|
14
|
+
const LOG = '[gjsify flatpark]';
|
|
15
|
+
/** `--repo`, else the project's `repository`, else `gjsify.site.repository` of it or of an ancestor. */
|
|
16
|
+
function resolveRepo(flag, projectDir) {
|
|
17
|
+
const candidates = [];
|
|
18
|
+
if (flag !== undefined)
|
|
19
|
+
candidates.push(['--repo', flag]);
|
|
20
|
+
let dir = projectDir;
|
|
21
|
+
for (let depth = 0; depth < 5; depth++) {
|
|
22
|
+
const pkg = readPackageJson(join(dir, 'package.json'));
|
|
23
|
+
if (pkg !== undefined && pkg !== null) {
|
|
24
|
+
const repository = typeof pkg.repository === 'string' ? pkg.repository : pkg.repository?.url;
|
|
25
|
+
if (depth === 0)
|
|
26
|
+
candidates.push([`${join(dir, 'package.json')} repository`, repository]);
|
|
27
|
+
candidates.push([`${join(dir, 'package.json')} gjsify.site.repository`, pkg.gjsify?.site?.repository]);
|
|
28
|
+
}
|
|
29
|
+
if (dirname(dir) === dir)
|
|
30
|
+
break;
|
|
31
|
+
dir = dirname(dir);
|
|
32
|
+
}
|
|
33
|
+
for (const [source, value] of candidates) {
|
|
34
|
+
if (value === undefined)
|
|
35
|
+
continue;
|
|
36
|
+
const repo = parseGithubRepo(value);
|
|
37
|
+
if (repo === undefined)
|
|
38
|
+
throw new Error(`${LOG} ${source} is "${value}", which is not a GitHub repository.`);
|
|
39
|
+
return repo;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`${LOG} no GitHub repository to download from. Pass --repo owner/name, or set \`repository\` in ` +
|
|
42
|
+
'package.json or `gjsify.site.repository`.');
|
|
43
|
+
}
|
|
44
|
+
export const flatparkCommand = {
|
|
45
|
+
command: 'flatpark [project]',
|
|
46
|
+
description: 'Write the FlatPark package directory (registry/<app-id>/) for a project that ran `gjsify ship`.',
|
|
47
|
+
builder: (yargs) => yargs
|
|
48
|
+
.positional('project', {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'The project directory. Default: the current directory.',
|
|
51
|
+
})
|
|
52
|
+
.option('out', {
|
|
53
|
+
type: 'string',
|
|
54
|
+
demandOption: true,
|
|
55
|
+
requiresArg: true,
|
|
56
|
+
description: 'The package directory to write, e.g. `<flatpark>/registry/eu.example.App`.',
|
|
57
|
+
})
|
|
58
|
+
.option('stage', {
|
|
59
|
+
type: 'string',
|
|
60
|
+
requiresArg: true,
|
|
61
|
+
description: 'A `gjsify ship --stage` directory. Default: `<out dir of ship>/stage` of the project.',
|
|
62
|
+
})
|
|
63
|
+
.option('release-dir', {
|
|
64
|
+
type: 'string',
|
|
65
|
+
requiresArg: true,
|
|
66
|
+
description: 'The directory holding `<artifact>.gjsify-release.json`. Default: `out/` of the ship out dir.',
|
|
67
|
+
})
|
|
68
|
+
.option('repo', {
|
|
69
|
+
type: 'string',
|
|
70
|
+
requiresArg: true,
|
|
71
|
+
description: 'GitHub `owner/name` the releases are published on. Default: read from the project.',
|
|
72
|
+
})
|
|
73
|
+
.option('tag-prefix', {
|
|
74
|
+
type: 'string',
|
|
75
|
+
default: 'v',
|
|
76
|
+
description: 'What precedes the version in the release tag.',
|
|
77
|
+
}),
|
|
78
|
+
handler: async (args) => {
|
|
79
|
+
const projectDir = resolve(args.project ?? process.cwd());
|
|
80
|
+
const config = await new Config().forCommand(projectDir);
|
|
81
|
+
const shipOut = resolve(projectDir, config.ship?.outDir ?? 'ship');
|
|
82
|
+
const stageDir = resolve(projectDir, args.stage ?? join(shipOut, 'stage'));
|
|
83
|
+
const releaseDir = resolve(projectDir, args['release-dir'] ?? join(shipOut, 'out'));
|
|
84
|
+
const outDir = resolve(args.out);
|
|
85
|
+
const manifest = readStageManifest(stageDir);
|
|
86
|
+
const settings = manifest.settings;
|
|
87
|
+
const staged = (path) => {
|
|
88
|
+
const file = join(stageDir, path);
|
|
89
|
+
if (!existsSync(file)) {
|
|
90
|
+
throw new Error(`${LOG} the stage has no ${path}. A FlatPark package needs a desktop application: ` +
|
|
91
|
+
'stage it with `gjsify ship --stage` on a project of `kind: app`.');
|
|
92
|
+
}
|
|
93
|
+
return file;
|
|
94
|
+
};
|
|
95
|
+
const repo = resolveRepo(args.repo, projectDir);
|
|
96
|
+
const icon = pickIcon(stageDir, settings.appId);
|
|
97
|
+
const sources = readFlatparkSources({
|
|
98
|
+
dir: releaseDir,
|
|
99
|
+
repo,
|
|
100
|
+
version: settings.version,
|
|
101
|
+
tagPrefix: args['tag-prefix'],
|
|
102
|
+
stageArch: manifest.target.arch,
|
|
103
|
+
});
|
|
104
|
+
const files = renderFlatparkPackage({
|
|
105
|
+
appId: settings.appId,
|
|
106
|
+
name: settings.name,
|
|
107
|
+
binaryName: settings.binaryName,
|
|
108
|
+
summary: settings.summary,
|
|
109
|
+
version: settings.version,
|
|
110
|
+
...(settings.homepage === undefined ? {} : { homepage: settings.homepage }),
|
|
111
|
+
repo,
|
|
112
|
+
flatpak: settings.flatpak,
|
|
113
|
+
sources,
|
|
114
|
+
desktopEntry: readFileSync(staged(`share/applications/${settings.appId}.desktop`), 'utf-8'),
|
|
115
|
+
metainfo: readFileSync(staged(`share/metainfo/${settings.appId}.metainfo.xml`), 'utf-8'),
|
|
116
|
+
icon,
|
|
117
|
+
releaseDate: releaseDateOf(manifest.mtime),
|
|
118
|
+
});
|
|
119
|
+
mkdirSync(outDir, { recursive: true });
|
|
120
|
+
for (const file of files) {
|
|
121
|
+
writeFileSync(join(outDir, file.path), file.data, { mode: file.mode });
|
|
122
|
+
}
|
|
123
|
+
console.log(`${LOG} wrote ${files.length} file(s) for ${settings.appId} ${settings.version} to ${outDir}`);
|
|
124
|
+
for (const source of sources)
|
|
125
|
+
console.log(`${LOG} ${source.arch}: ${source.url}`);
|
|
126
|
+
console.log(`${LOG} next: ${relative(process.cwd(), join(outDir, 'flatpark.yml')) || 'flatpark.yml'} has ` +
|
|
127
|
+
"`upstream_approved: false`; a row in FlatPark's docs/reference/upstream-approvals.md is the maintainer's.");
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
/** The 128 px raster when the stage has one, else the largest up to 512 px. FlatPark takes no bigger. */
|
|
131
|
+
function pickIcon(stageDir, appId) {
|
|
132
|
+
const base = join(stageDir, 'share', 'icons', 'hicolor');
|
|
133
|
+
const sizes = existsSync(base)
|
|
134
|
+
? readdirSync(base)
|
|
135
|
+
.map((entry) => /^(\d+)x\1$/.exec(entry)?.[1])
|
|
136
|
+
.filter((size) => size !== undefined)
|
|
137
|
+
.map(Number)
|
|
138
|
+
.filter((size) => size <= 512 && existsSync(join(base, `${size}x${size}`, 'apps', `${appId}.png`)))
|
|
139
|
+
.sort((a, b) => a - b)
|
|
140
|
+
: [];
|
|
141
|
+
const size = sizes.includes(128) ? 128 : sizes[sizes.length - 1];
|
|
142
|
+
if (size === undefined) {
|
|
143
|
+
throw new Error(`${LOG} the stage has no PNG icon for ${appId} up to 512 px under share/icons/hicolor/. FlatPark ` +
|
|
144
|
+
'takes a PNG or an SVG, and an SVG can fail AppStream compose, so this command wants a raster.');
|
|
145
|
+
}
|
|
146
|
+
return { bytes: readFileSync(join(base, `${size}x${size}`, 'apps', `${appId}.png`)), size };
|
|
147
|
+
}
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './gettext.js';
|
|
|
15
15
|
export * from './gsettings.js';
|
|
16
16
|
export { flatpakCommand } from './flatpak/index.js';
|
|
17
17
|
export * from './ship.js';
|
|
18
|
+
export * from './flatpark.js';
|
|
18
19
|
export * from './dlx.js';
|
|
19
20
|
export * from './install.js';
|
|
20
21
|
export * from './link.js';
|
package/lib/commands/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from './gettext.js';
|
|
|
15
15
|
export * from './gsettings.js';
|
|
16
16
|
export { flatpakCommand } from './flatpak/index.js';
|
|
17
17
|
export * from './ship.js';
|
|
18
|
+
export * from './flatpark.js';
|
|
18
19
|
export * from './dlx.js';
|
|
19
20
|
export * from './install.js';
|
|
20
21
|
export * from './link.js';
|
package/lib/commands/ship.js
CHANGED
|
@@ -52,6 +52,7 @@ import { isNodeRuntimeTarget, resolveNodeRuntime } from '../utils/ship/node-runt
|
|
|
52
52
|
import { isUnder, SHARE } from '../utils/ship/share-dirs.js';
|
|
53
53
|
import { compileSchemasForPayload, compileSchemasForStage } from '../utils/ship/schemas.js';
|
|
54
54
|
import { buildMsi, MSI_PAYLOAD_DIR } from '../utils/ship/msi.js';
|
|
55
|
+
import { buildLinuxTarball } from '../utils/ship/tarball.js';
|
|
55
56
|
import { buildZip, zipEntriesFromPayload } from '../utils/ship/zip.js';
|
|
56
57
|
import { assertEntryRunsUnder } from '../utils/ship/entry-interpreter.js';
|
|
57
58
|
import { scanGiRequirements } from '@gjsify/rolldown-plugin-gjsify';
|
|
@@ -1247,6 +1248,22 @@ async function packOne(input) {
|
|
|
1247
1248
|
});
|
|
1248
1249
|
break;
|
|
1249
1250
|
}
|
|
1251
|
+
case 'linux-tar':
|
|
1252
|
+
case 'linux-tar-flatpak': {
|
|
1253
|
+
// FROM THE PAYLOAD, like every container here. The Flatpak variant adds
|
|
1254
|
+
// the one file the shared Linux stage cannot carry — see the `appimage`
|
|
1255
|
+
// arm for why the compile is on the pack path — and nothing else.
|
|
1256
|
+
const schemaCache = format.id === 'linux-tar-flatpak'
|
|
1257
|
+
? await compileSchemasForPayload({ payload, workDir: join(outRoot, 'tar-schemas') })
|
|
1258
|
+
: undefined;
|
|
1259
|
+
writeFileSync(target, await buildLinuxTarball({
|
|
1260
|
+
settings,
|
|
1261
|
+
payload: schemaCache === undefined ? payload : [...payload, schemaCache],
|
|
1262
|
+
archLabel,
|
|
1263
|
+
mtime,
|
|
1264
|
+
}));
|
|
1265
|
+
break;
|
|
1266
|
+
}
|
|
1250
1267
|
case 'macos-app':
|
|
1251
1268
|
case 'windows-dir':
|
|
1252
1269
|
// ONE STATEMENT FOR TWO ROWS, folded because the code really is
|
|
@@ -15,6 +15,7 @@ export declare const webextZipCommand: Command<unknown, WebextArgs>;
|
|
|
15
15
|
export declare const webextDevCommand: Command<unknown, WebextArgs>;
|
|
16
16
|
interface ListingArgs {
|
|
17
17
|
store: string;
|
|
18
|
+
stores?: string;
|
|
18
19
|
out?: string;
|
|
19
20
|
check: boolean;
|
|
20
21
|
metainfo?: string;
|
|
@@ -213,6 +213,10 @@ export const webextListingCommand = {
|
|
|
213
213
|
type: 'string',
|
|
214
214
|
choices: ['cws', 'edge', 'amo', 'all'],
|
|
215
215
|
default: 'all',
|
|
216
|
+
})
|
|
217
|
+
.option('stores', {
|
|
218
|
+
description: 'Several stores at once, comma separated (cws,edge,amo) or all; wins over --store.',
|
|
219
|
+
type: 'string',
|
|
216
220
|
})
|
|
217
221
|
.option('out', { description: 'Output directory, emptied first (default: dist/listing).', type: 'string' })
|
|
218
222
|
.option('check', {
|
|
@@ -243,7 +247,7 @@ export const webextListingCommand = {
|
|
|
243
247
|
.option('globals', { description: 'Value for `gjsify build --globals` (default: auto).', type: 'string' }),
|
|
244
248
|
handler: async (args) => {
|
|
245
249
|
const cwd = process.cwd();
|
|
246
|
-
const forwarded = ['listing', '--store', args.store];
|
|
250
|
+
const forwarded = ['listing', '--store', args.stores ?? args.store];
|
|
247
251
|
if (args.root)
|
|
248
252
|
forwarded.push('--root', resolve(cwd, args.root));
|
|
249
253
|
if (args.out)
|
|
@@ -99,6 +99,35 @@ export declare function resolveGtkRuntime(target: GtkRuntimeTarget, options?: Re
|
|
|
99
99
|
* built against, which is #910's failure shape wearing a convenience.
|
|
100
100
|
*/
|
|
101
101
|
export declare function resolveNodeGiAddon(target: GtkRuntimeTarget, options?: ResolveRuntimeOptions): ResolvedNodeGiAddon | null;
|
|
102
|
+
/** The facade `@gjsify/adwaita-app` lists as an optionalDependency (ADR 0141). */
|
|
103
|
+
export declare const QUARTZ_BRIDGE_FACADE = "@gjsify/gtk-quartz-native";
|
|
104
|
+
/** The bridge's GI typelib and library, as both per-target companions name them. */
|
|
105
|
+
export declare const QUARTZ_BRIDGE_TYPELIB = "GjsifyQuartz-1.0.typelib";
|
|
106
|
+
export declare const QUARTZ_BRIDGE_LIBRARY = "libgjsifyquartz.dylib";
|
|
107
|
+
/** The per-target companion carrying the bridge's prebuild. Only darwin targets have one. */
|
|
108
|
+
export declare function quartzBridgePackageName(target: GtkRuntimeTarget): string;
|
|
109
|
+
/** The Dock-reopen bridge's prebuild, once found. */
|
|
110
|
+
export interface ResolvedQuartzBridge {
|
|
111
|
+
source: string;
|
|
112
|
+
typelibPath: string;
|
|
113
|
+
libraryPath: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Locate the Dock-reopen bridge (`GjsifyQuartz`, ADR 0141) for `target`.
|
|
117
|
+
*
|
|
118
|
+
* `null` = the app does not have the dependency, and the bundle stays as it was.
|
|
119
|
+
* `{ unpopulated }` = the app has it but this target's companion is not installed
|
|
120
|
+
* (npm installs the optionalDependency of the HOST's arch only) or holds no
|
|
121
|
+
* prebuild — reported, never fatal: the bridge is an optional fix.
|
|
122
|
+
*
|
|
123
|
+
* Found from the project, else through `@gjsify/adwaita-app` (the package that
|
|
124
|
+
* declares it) — the companion is an optionalDependency of the facade, which is
|
|
125
|
+
* an optionalDependency of adwaita-app, so a strict layout (pnpm) hides it from
|
|
126
|
+
* the project root but not from its parent.
|
|
127
|
+
*/
|
|
128
|
+
export declare function resolveQuartzBridge(target: GtkRuntimeTarget, options?: ResolveRuntimeOptions): ResolvedQuartzBridge | {
|
|
129
|
+
unpopulated: string;
|
|
130
|
+
} | null;
|
|
102
131
|
/** node-gi's JavaScript, as package-relative paths. */
|
|
103
132
|
export interface ResolvedNodeGiPackage {
|
|
104
133
|
source: string;
|
|
@@ -209,15 +209,87 @@ function resolveNodeGiRoot(options) {
|
|
|
209
209
|
* answers from the runtime's global install cache for a project that merely has a
|
|
210
210
|
* `package.json` and no `node_modules`, which would put files the author never
|
|
211
211
|
* declared inside a `.app`. See that function for the measurement.
|
|
212
|
+
*
|
|
213
|
+
* `fromCli: false` drops the fallback to the CLI's own install: the Dock bridge is
|
|
214
|
+
* optional, so only the project (or adwaita-app inside it) may declare it. Else a
|
|
215
|
+
* CLI running from this monorepo, or a global install, stages it into every app.
|
|
212
216
|
*/
|
|
213
|
-
function resolveStagedPackage(specifier, options) {
|
|
214
|
-
const opts = { bundleUrl: import.meta.url };
|
|
217
|
+
function resolveStagedPackage(specifier, options, { fromCli = true } = {}) {
|
|
218
|
+
const opts = fromCli ? { bundleUrl: import.meta.url } : {};
|
|
215
219
|
if (options.cwd !== undefined)
|
|
216
220
|
opts.cwd = options.cwd;
|
|
217
221
|
if (options.resolve !== undefined)
|
|
218
222
|
opts.resolve = options.resolve;
|
|
219
223
|
return resolveInstalledPackage(specifier, opts);
|
|
220
224
|
}
|
|
225
|
+
/** The facade `@gjsify/adwaita-app` lists as an optionalDependency (ADR 0141). */
|
|
226
|
+
export const QUARTZ_BRIDGE_FACADE = '@gjsify/gtk-quartz-native';
|
|
227
|
+
/** The bridge's GI typelib and library, as both per-target companions name them. */
|
|
228
|
+
export const QUARTZ_BRIDGE_TYPELIB = 'GjsifyQuartz-1.0.typelib';
|
|
229
|
+
export const QUARTZ_BRIDGE_LIBRARY = 'libgjsifyquartz.dylib';
|
|
230
|
+
/** The per-target companion carrying the bridge's prebuild. Only darwin targets have one. */
|
|
231
|
+
export function quartzBridgePackageName(target) {
|
|
232
|
+
return `${QUARTZ_BRIDGE_FACADE}-${target}`;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Locate the Dock-reopen bridge (`GjsifyQuartz`, ADR 0141) for `target`.
|
|
236
|
+
*
|
|
237
|
+
* `null` = the app does not have the dependency, and the bundle stays as it was.
|
|
238
|
+
* `{ unpopulated }` = the app has it but this target's companion is not installed
|
|
239
|
+
* (npm installs the optionalDependency of the HOST's arch only) or holds no
|
|
240
|
+
* prebuild — reported, never fatal: the bridge is an optional fix.
|
|
241
|
+
*
|
|
242
|
+
* Found from the project, else through `@gjsify/adwaita-app` (the package that
|
|
243
|
+
* declares it) — the companion is an optionalDependency of the facade, which is
|
|
244
|
+
* an optionalDependency of adwaita-app, so a strict layout (pnpm) hides it from
|
|
245
|
+
* the project root but not from its parent.
|
|
246
|
+
*/
|
|
247
|
+
export function resolveQuartzBridge(target, options = {}) {
|
|
248
|
+
if (!target.startsWith('darwin-'))
|
|
249
|
+
return null;
|
|
250
|
+
const companion = quartzBridgePackageName(target);
|
|
251
|
+
const dirOf = (specifier, from) => {
|
|
252
|
+
const entry = resolveStagedPackage(`${specifier}/package.json`, from, { fromCli: false });
|
|
253
|
+
return entry === null ? null : dirname(entry);
|
|
254
|
+
};
|
|
255
|
+
let companionDir = dirOf(companion, options);
|
|
256
|
+
let facadeDir = null;
|
|
257
|
+
if (companionDir === null) {
|
|
258
|
+
facadeDir = dirOf(QUARTZ_BRIDGE_FACADE, options);
|
|
259
|
+
if (facadeDir === null) {
|
|
260
|
+
const adwaitaEntry = resolveStagedPackage('@gjsify/adwaita-app', options, { fromCli: false });
|
|
261
|
+
const adwaitaDir = adwaitaEntry === null ? null : packageRootOf(adwaitaEntry);
|
|
262
|
+
if (adwaitaDir !== null)
|
|
263
|
+
facadeDir = dirOf(QUARTZ_BRIDGE_FACADE, { ...options, cwd: adwaitaDir });
|
|
264
|
+
}
|
|
265
|
+
if (facadeDir !== null)
|
|
266
|
+
companionDir = dirOf(companion, { ...options, cwd: facadeDir });
|
|
267
|
+
}
|
|
268
|
+
if (companionDir === null) {
|
|
269
|
+
return facadeDir === null ? null : { unpopulated: `${companion} is not installed` };
|
|
270
|
+
}
|
|
271
|
+
const prebuilds = join(companionDir, 'prebuilds', target);
|
|
272
|
+
const typelibPath = join(prebuilds, QUARTZ_BRIDGE_TYPELIB);
|
|
273
|
+
const libraryPath = join(prebuilds, QUARTZ_BRIDGE_LIBRARY);
|
|
274
|
+
if (!existsSync(typelibPath) || !existsSync(libraryPath)) {
|
|
275
|
+
return {
|
|
276
|
+
unpopulated: `${companion} holds no prebuilds/${target}/{${QUARTZ_BRIDGE_TYPELIB},${QUARTZ_BRIDGE_LIBRARY}}`,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
return { source: companion, typelibPath, libraryPath };
|
|
280
|
+
}
|
|
281
|
+
/** The nearest directory above `file` holding a `package.json`. */
|
|
282
|
+
function packageRootOf(file) {
|
|
283
|
+
let dir = dirname(file);
|
|
284
|
+
for (;;) {
|
|
285
|
+
if (existsSync(join(dir, 'package.json')))
|
|
286
|
+
return dir;
|
|
287
|
+
const parent = dirname(dir);
|
|
288
|
+
if (parent === dir)
|
|
289
|
+
return null;
|
|
290
|
+
dir = parent;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
221
293
|
/**
|
|
222
294
|
* The files a SHIPPED `.app` needs from `@gjsify/node-gi`, or `null`.
|
|
223
295
|
*
|
|
@@ -357,6 +429,28 @@ export function stageAppRuntime(input) {
|
|
|
357
429
|
}
|
|
358
430
|
launcher.gtkRuntimeDir = paths.gtkDir;
|
|
359
431
|
found.push(`GTK closure from ${gtk.source}`);
|
|
432
|
+
// The Dock-reopen bridge goes INTO the closure's own typelib and library
|
|
433
|
+
// directories (ADR 0141 § Node hosts). node-gi already puts exactly those
|
|
434
|
+
// two on GI's typelib and library search paths when the bundled GTK is the
|
|
435
|
+
// chosen one (`activateBundledGtkRuntime`, `activateGiLibraryPath`), so the
|
|
436
|
+
// launcher needs no new variable and `installDockReopen` finds the pair.
|
|
437
|
+
const bridge = resolveQuartzBridge(input.target, discoveryOptions(input));
|
|
438
|
+
if (bridge !== null && 'unpopulated' in bridge) {
|
|
439
|
+
missing.push(`Dock-click reopen bridge not carried — ${bridge.unpopulated}`);
|
|
440
|
+
}
|
|
441
|
+
else if (bridge !== null) {
|
|
442
|
+
files.push({
|
|
443
|
+
path: posix.join(paths.gtkDir, 'girepository-1.0', QUARTZ_BRIDGE_TYPELIB),
|
|
444
|
+
mode: 0o644,
|
|
445
|
+
source: { kind: 'file', path: bridge.typelibPath },
|
|
446
|
+
});
|
|
447
|
+
files.push({
|
|
448
|
+
path: posix.join(paths.gtkDir, nativeSubdirOf(input.target), QUARTZ_BRIDGE_LIBRARY),
|
|
449
|
+
mode: 0o755,
|
|
450
|
+
source: { kind: 'file', path: bridge.libraryPath },
|
|
451
|
+
});
|
|
452
|
+
found.push(`Dock-click reopen bridge from ${bridge.source}`);
|
|
453
|
+
}
|
|
360
454
|
}
|
|
361
455
|
else {
|
|
362
456
|
// The native subdirectory is `bin` on win32 and `lib` everywhere else,
|
|
@@ -403,6 +497,9 @@ export function stageAppRuntime(input) {
|
|
|
403
497
|
}
|
|
404
498
|
return { files, launcher, found, missing };
|
|
405
499
|
}
|
|
500
|
+
function nativeSubdirOf(target) {
|
|
501
|
+
return target.startsWith('win32-') ? 'bin' : 'lib';
|
|
502
|
+
}
|
|
406
503
|
/**
|
|
407
504
|
* The discovery options every piece is looked up with.
|
|
408
505
|
*
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ShipFlatpakSettings } from './types.js';
|
|
2
|
+
/** The extra-data file name inside the Flatpak. Fixed: the hook and the resolver both name it. */
|
|
3
|
+
export declare const FLATPARK_EXTRA_FILE = "app.tar.gz";
|
|
4
|
+
/** The only format whose archive is meant as an `extra-data` source (ADR 0142). */
|
|
5
|
+
export declare const FLATPARK_RECORD_FORMAT = "linux-tar-flatpak";
|
|
6
|
+
export interface FlatparkSource {
|
|
7
|
+
/** Flatpak spelling: `x86_64` or `aarch64`. */
|
|
8
|
+
arch: string;
|
|
9
|
+
/** Release asset name — the record's `artifact`. */
|
|
10
|
+
artifact: string;
|
|
11
|
+
url: string;
|
|
12
|
+
sha256: string;
|
|
13
|
+
size: number;
|
|
14
|
+
}
|
|
15
|
+
export interface FlatparkInputs {
|
|
16
|
+
appId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
binaryName: string;
|
|
19
|
+
summary: string;
|
|
20
|
+
version: string;
|
|
21
|
+
homepage?: string;
|
|
22
|
+
/** `owner/name` of the GitHub repository the releases are published on. */
|
|
23
|
+
repo: string;
|
|
24
|
+
flatpak: Pick<ShipFlatpakSettings, 'runtime' | 'runtimeVersion' | 'sdk' | 'finishArgs'>;
|
|
25
|
+
/** Sorted by arch by the caller of {@link readFlatparkSources}; rendered in the order given. */
|
|
26
|
+
sources: readonly FlatparkSource[];
|
|
27
|
+
/** The stage's own, as `gjsify ship` rendered it. */
|
|
28
|
+
desktopEntry: string;
|
|
29
|
+
metainfo: string;
|
|
30
|
+
icon: {
|
|
31
|
+
bytes: Uint8Array;
|
|
32
|
+
size: number;
|
|
33
|
+
};
|
|
34
|
+
/** `YYYY-MM-DD`, UTC. */
|
|
35
|
+
releaseDate: string;
|
|
36
|
+
}
|
|
37
|
+
export interface FlatparkFile {
|
|
38
|
+
/** Relative to the package directory. */
|
|
39
|
+
path: string;
|
|
40
|
+
mode: number;
|
|
41
|
+
data: string | Uint8Array;
|
|
42
|
+
}
|
|
43
|
+
/** `owner/name` out of `owner/name`, a github.com URL, or a `git+https://….git` URL. */
|
|
44
|
+
export declare function parseGithubRepo(value: string): string | undefined;
|
|
45
|
+
/** The UTC calendar date of a build stamp (seconds since the epoch). */
|
|
46
|
+
export declare function releaseDateOf(mtime: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* The release records beside the artifacts in `dir`, as FlatPark sources.
|
|
49
|
+
*
|
|
50
|
+
* The URL is the only thing derived here and it is derived from the repository
|
|
51
|
+
* and the version, never fetched; `sha256` and `size` are the record's, which
|
|
52
|
+
* `gjsify ship` took from the bytes it wrote. A missing record is an error and
|
|
53
|
+
* not a reason to hash the file ourselves: a hash this command computed would
|
|
54
|
+
* describe whatever is on this disk, not what was published.
|
|
55
|
+
*/
|
|
56
|
+
export declare function readFlatparkSources(input: {
|
|
57
|
+
dir: string;
|
|
58
|
+
repo: string;
|
|
59
|
+
version: string;
|
|
60
|
+
tagPrefix: string;
|
|
61
|
+
/**
|
|
62
|
+
* The arch the stage was assembled for. A pure-script payload records `noarch`, but its archive
|
|
63
|
+
* name still carries one label and a FlatPark source needs an arch to pin — the stage's.
|
|
64
|
+
*/
|
|
65
|
+
stageArch?: string;
|
|
66
|
+
}): FlatparkSource[];
|
|
67
|
+
/** The unpack hook. No version anywhere; the one asserted path derives from `binaryName`. */
|
|
68
|
+
export declare function renderApplyExtra(binaryName: string): string;
|
|
69
|
+
export declare function renderWrapper(binaryName: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* The Flatpak manifest. The `extra-data` sources sit between marker comments
|
|
72
|
+
* because FlatPark's updater rewrites exactly that block on every release.
|
|
73
|
+
*/
|
|
74
|
+
export declare function renderManifest(input: FlatparkInputs): string;
|
|
75
|
+
export declare function renderDescriptor(input: FlatparkInputs): string;
|
|
76
|
+
export declare function renderResolveUpdate(input: FlatparkInputs): string;
|
|
77
|
+
/**
|
|
78
|
+
* The metainfo with a `<releases>` block carrying this version, unless it has
|
|
79
|
+
* one. FlatPark compares the resolver's version against the newest `<release>`
|
|
80
|
+
* here, and Flatpak ignores an undated one — so a package starts with exactly one.
|
|
81
|
+
*/
|
|
82
|
+
export declare function withRelease(metainfo: string, version: string, date: string): string;
|
|
83
|
+
/** Every file of the package directory, in a fixed order. */
|
|
84
|
+
export declare function renderFlatparkPackage(input: FlatparkInputs): FlatparkFile[];
|