@gtkx/cli 1.3.0 → 1.5.0
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/README.md +5 -4
- package/dist/builder.d.ts +1 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +6 -6
- package/dist/builder.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +3 -2
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +41 -12
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/commands/build.d.ts +0 -4
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +0 -5
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/codegen.d.ts.map +1 -1
- package/dist/commands/codegen.js +2 -4
- package/dist/commands/codegen.js.map +1 -1
- package/dist/deploy/depends.d.ts +2 -2
- package/dist/deploy/depends.d.ts.map +1 -1
- package/dist/deploy/depends.js +30 -15
- package/dist/deploy/depends.js.map +1 -1
- package/dist/deploy/freedesktop/localize.d.ts +6 -0
- package/dist/deploy/freedesktop/localize.d.ts.map +1 -0
- package/dist/deploy/freedesktop/localize.js +107 -0
- package/dist/deploy/freedesktop/localize.js.map +1 -0
- package/dist/deploy/install-hints.d.ts.map +1 -1
- package/dist/deploy/install-hints.js +5 -0
- package/dist/deploy/install-hints.js.map +1 -1
- package/dist/deploy/nfpm/config.js +1 -1
- package/dist/deploy/nfpm/config.js.map +1 -1
- package/dist/deploy/node-runtime/elf.d.ts +1 -1
- package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
- package/dist/deploy/node-runtime/elf.js +2 -2
- package/dist/deploy/node-runtime/elf.js.map +1 -1
- package/dist/deploy/node-runtime/index.js +2 -2
- package/dist/deploy/node-runtime/index.js.map +1 -1
- package/dist/deploy/notices/collect.d.ts +3 -1
- package/dist/deploy/notices/collect.d.ts.map +1 -1
- package/dist/deploy/notices/collect.js +2 -2
- package/dist/deploy/notices/collect.js.map +1 -1
- package/dist/deploy/notices/packages.d.ts +2 -1
- package/dist/deploy/notices/packages.d.ts.map +1 -1
- package/dist/deploy/notices/packages.js +4 -27
- package/dist/deploy/notices/packages.js.map +1 -1
- package/dist/deploy/payload/icons.d.ts +7 -3
- package/dist/deploy/payload/icons.d.ts.map +1 -1
- package/dist/deploy/payload/icons.js +46 -28
- package/dist/deploy/payload/icons.js.map +1 -1
- package/dist/deploy/payload/launcher.d.ts.map +1 -1
- package/dist/deploy/payload/launcher.js +2 -0
- package/dist/deploy/payload/launcher.js.map +1 -1
- package/dist/deploy/payload/stage.d.ts +1 -1
- package/dist/deploy/payload/stage.d.ts.map +1 -1
- package/dist/deploy/payload/stage.js +23 -13
- package/dist/deploy/payload/stage.js.map +1 -1
- package/dist/deploy/run-deploy.d.ts.map +1 -1
- package/dist/deploy/run-deploy.js +149 -25
- package/dist/deploy/run-deploy.js.map +1 -1
- package/dist/deploy/settings/build-manifest.d.ts +9 -0
- package/dist/deploy/settings/build-manifest.d.ts.map +1 -0
- package/dist/deploy/settings/build-manifest.js +80 -0
- package/dist/deploy/settings/build-manifest.js.map +1 -0
- package/dist/deploy/settings/index.d.ts.map +1 -1
- package/dist/deploy/settings/index.js +9 -3
- package/dist/deploy/settings/index.js.map +1 -1
- package/dist/deploy/settings/libraries.d.ts +8 -0
- package/dist/deploy/settings/libraries.d.ts.map +1 -0
- package/dist/deploy/settings/libraries.js +39 -0
- package/dist/deploy/settings/libraries.js.map +1 -0
- package/dist/deploy/settings/paths.d.ts +3 -0
- package/dist/deploy/settings/paths.d.ts.map +1 -1
- package/dist/deploy/settings/paths.js +6 -32
- package/dist/deploy/settings/paths.js.map +1 -1
- package/dist/deploy/targets/appimage.d.ts.map +1 -1
- package/dist/deploy/targets/appimage.js +19 -13
- package/dist/deploy/targets/appimage.js.map +1 -1
- package/dist/deploy/targets/flatpak-manifest.d.ts +2 -1
- package/dist/deploy/targets/flatpak-manifest.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak-manifest.js +5 -1
- package/dist/deploy/targets/flatpak-manifest.js.map +1 -1
- package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak-source.js +30 -16
- package/dist/deploy/targets/flatpak-source.js.map +1 -1
- package/dist/deploy/tools.d.ts +6 -1
- package/dist/deploy/tools.d.ts.map +1 -1
- package/dist/deploy/tools.js +26 -1
- package/dist/deploy/tools.js.map +1 -1
- package/dist/deploy/types.d.ts +4 -4
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/deploy/types.js.map +1 -1
- package/dist/dev/icon-dir.d.ts +1 -1
- package/dist/dev/icon-dir.d.ts.map +1 -1
- package/dist/dev/icon-dir.js +20 -7
- package/dist/dev/icon-dir.js.map +1 -1
- package/dist/dev/locale-dir.d.ts +3 -0
- package/dist/dev/locale-dir.d.ts.map +1 -0
- package/dist/dev/locale-dir.js +17 -0
- package/dist/dev/locale-dir.js.map +1 -0
- package/dist/dev/runner-deps.d.ts.map +1 -1
- package/dist/dev/runner-deps.js +5 -1
- package/dist/dev/runner-deps.js.map +1 -1
- package/dist/dev/runner-main.d.ts.map +1 -1
- package/dist/dev/runner-main.js +6 -4
- package/dist/dev/runner-main.js.map +1 -1
- package/dist/dev/runner.d.ts +1 -1
- package/dist/dev/runner.d.ts.map +1 -1
- package/dist/dev/runner.js +7 -1
- package/dist/dev/runner.js.map +1 -1
- package/dist/dev/schema-dir.d.ts +1 -1
- package/dist/dev/schema-dir.d.ts.map +1 -1
- package/dist/dev/schema-dir.js +3 -1
- package/dist/dev/schema-dir.js.map +1 -1
- package/dist/dev/vite-dev-server.d.ts +1 -0
- package/dist/dev/vite-dev-server.d.ts.map +1 -1
- package/dist/dev/vite-dev-server.js.map +1 -1
- package/dist/i18n/binding-extractor.d.ts +30 -0
- package/dist/i18n/binding-extractor.d.ts.map +1 -0
- package/dist/i18n/binding-extractor.js +1324 -0
- package/dist/i18n/binding-extractor.js.map +1 -0
- package/dist/i18n/catalog-template.d.ts +3 -0
- package/dist/i18n/catalog-template.d.ts.map +1 -0
- package/dist/i18n/catalog-template.js +18 -0
- package/dist/i18n/catalog-template.js.map +1 -0
- package/dist/i18n/catalogs.d.ts +21 -0
- package/dist/i18n/catalogs.d.ts.map +1 -0
- package/dist/i18n/catalogs.js +139 -0
- package/dist/i18n/catalogs.js.map +1 -0
- package/dist/i18n/extractor-plugin.d.ts +8 -0
- package/dist/i18n/extractor-plugin.d.ts.map +1 -0
- package/dist/i18n/extractor-plugin.js +247 -0
- package/dist/i18n/extractor-plugin.js.map +1 -0
- package/dist/i18n/metadata-templates.d.ts +11 -0
- package/dist/i18n/metadata-templates.d.ts.map +1 -0
- package/dist/i18n/metadata-templates.js +11 -0
- package/dist/i18n/metadata-templates.js.map +1 -0
- package/dist/i18n/source-messages.d.ts +23 -0
- package/dist/i18n/source-messages.d.ts.map +1 -0
- package/dist/i18n/source-messages.js +403 -0
- package/dist/i18n/source-messages.js.map +1 -0
- package/dist/i18n/types.d.ts +10 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +108 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/internal/build-manifest.d.ts +20 -0
- package/dist/internal/build-manifest.d.ts.map +1 -0
- package/dist/internal/build-manifest.js +6 -0
- package/dist/internal/build-manifest.js.map +1 -0
- package/dist/internal/icon-path.d.ts +13 -0
- package/dist/internal/icon-path.d.ts.map +1 -0
- package/dist/internal/icon-path.js +86 -0
- package/dist/internal/icon-path.js.map +1 -0
- package/dist/internal/source-imports.d.ts +12 -0
- package/dist/internal/source-imports.d.ts.map +1 -0
- package/dist/internal/source-imports.js +123 -0
- package/dist/internal/source-imports.js.map +1 -0
- package/dist/mcp/client.d.ts +0 -1
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +11 -39
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/handlers.d.ts +2 -1
- package/dist/mcp/handlers.d.ts.map +1 -1
- package/dist/mcp/handlers.js.map +1 -1
- package/dist/mcp/widget-properties.d.ts.map +1 -1
- package/dist/mcp/widget-properties.js +3 -12
- package/dist/mcp/widget-properties.js.map +1 -1
- package/dist/settings/render.d.ts +10 -1
- package/dist/settings/render.d.ts.map +1 -1
- package/dist/settings/render.js +78 -20
- package/dist/settings/render.js.map +1 -1
- package/dist/settings/schema.d.ts +4 -3
- package/dist/settings/schema.d.ts.map +1 -1
- package/dist/settings/schema.js +124 -15
- package/dist/settings/schema.js.map +1 -1
- package/dist/vite-plugins/asset-emitter.d.ts +1 -1
- package/dist/vite-plugins/asset-emitter.d.ts.map +1 -1
- package/dist/vite-plugins/asset-emitter.js.map +1 -1
- package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
- package/dist/vite-plugins/asset-extensions.js +1 -0
- package/dist/vite-plugins/asset-extensions.js.map +1 -1
- package/dist/vite-plugins/asset-imports.d.ts +2 -1
- package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
- package/dist/vite-plugins/asset-imports.js +39 -28
- package/dist/vite-plugins/asset-imports.js.map +1 -1
- package/dist/vite-plugins/asset-specifier.d.ts +13 -1
- package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
- package/dist/vite-plugins/asset-specifier.js +39 -1
- package/dist/vite-plugins/asset-specifier.js.map +1 -1
- package/dist/vite-plugins/build-manifest.d.ts +5 -0
- package/dist/vite-plugins/build-manifest.d.ts.map +1 -0
- package/dist/vite-plugins/{bundled-packages.js → build-manifest.js} +20 -14
- package/dist/vite-plugins/build-manifest.js.map +1 -0
- package/dist/vite-plugins/built-url.d.ts +1 -1
- package/dist/vite-plugins/built-url.d.ts.map +1 -1
- package/dist/vite-plugins/built-url.js +37 -24
- package/dist/vite-plugins/built-url.js.map +1 -1
- package/dist/vite-plugins/i18n.d.ts +5 -0
- package/dist/vite-plugins/i18n.d.ts.map +1 -0
- package/dist/vite-plugins/i18n.js +88 -0
- package/dist/vite-plugins/i18n.js.map +1 -0
- package/dist/vite-plugins/icons.d.ts +2 -1
- package/dist/vite-plugins/icons.d.ts.map +1 -1
- package/dist/vite-plugins/icons.js +25 -12
- package/dist/vite-plugins/icons.js.map +1 -1
- package/dist/vite-plugins/index.d.ts +2 -1
- package/dist/vite-plugins/index.d.ts.map +1 -1
- package/dist/vite-plugins/index.js +9 -5
- package/dist/vite-plugins/index.js.map +1 -1
- package/dist/vite-plugins/native.d.ts.map +1 -1
- package/dist/vite-plugins/native.js +23 -4
- package/dist/vite-plugins/native.js.map +1 -1
- package/dist/vite-plugins/resource-init-module.d.ts +7 -3
- package/dist/vite-plugins/resource-init-module.d.ts.map +1 -1
- package/dist/vite-plugins/resource-init-module.js +39 -14
- package/dist/vite-plugins/resource-init-module.js.map +1 -1
- package/dist/vite-plugins/resource-shared.d.ts +3 -1
- package/dist/vite-plugins/resource-shared.d.ts.map +1 -1
- package/dist/vite-plugins/resource-shared.js +3 -1
- package/dist/vite-plugins/resource-shared.js.map +1 -1
- package/dist/vite-plugins/resources.d.ts +1 -1
- package/dist/vite-plugins/resources.d.ts.map +1 -1
- package/dist/vite-plugins/resources.js +877 -86
- package/dist/vite-plugins/resources.js.map +1 -1
- package/dist/vite-plugins/self-contained.d.ts.map +1 -1
- package/dist/vite-plugins/self-contained.js +128 -135
- package/dist/vite-plugins/self-contained.js.map +1 -1
- package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
- package/dist/vite-plugins/settings-worker-env.js +6 -3
- package/dist/vite-plugins/settings-worker-env.js.map +1 -1
- package/dist/vite-plugins/settings.d.ts +3 -1
- package/dist/vite-plugins/settings.d.ts.map +1 -1
- package/dist/vite-plugins/settings.js +63 -23
- package/dist/vite-plugins/settings.js.map +1 -1
- package/env.d.ts +11 -192
- package/package.json +11 -10
- package/src/builder.ts +7 -7
- package/src/codegen/run-codegen.ts +64 -15
- package/src/commands/build.ts +0 -5
- package/src/commands/codegen.ts +2 -4
- package/src/deploy/depends.ts +47 -18
- package/src/deploy/freedesktop/localize.ts +144 -0
- package/src/deploy/install-hints.ts +5 -0
- package/src/deploy/nfpm/config.ts +1 -1
- package/src/deploy/node-runtime/elf.ts +3 -3
- package/src/deploy/node-runtime/index.ts +2 -2
- package/src/deploy/notices/collect.ts +4 -2
- package/src/deploy/notices/packages.ts +5 -43
- package/src/deploy/payload/icons.ts +64 -34
- package/src/deploy/payload/launcher.ts +2 -0
- package/src/deploy/payload/stage.ts +40 -12
- package/src/deploy/run-deploy.ts +214 -24
- package/src/deploy/settings/build-manifest.ts +122 -0
- package/src/deploy/settings/index.ts +9 -4
- package/src/deploy/settings/libraries.ts +57 -0
- package/src/deploy/settings/paths.ts +10 -47
- package/src/deploy/targets/appimage.ts +32 -15
- package/src/deploy/targets/flatpak-manifest.ts +7 -1
- package/src/deploy/targets/flatpak-source.ts +42 -20
- package/src/deploy/tools.ts +35 -0
- package/src/deploy/types.ts +4 -4
- package/src/dev/icon-dir.ts +31 -7
- package/src/dev/locale-dir.ts +22 -0
- package/src/dev/runner-deps.ts +5 -1
- package/src/dev/runner-main.ts +6 -4
- package/src/dev/runner.ts +10 -2
- package/src/dev/schema-dir.ts +3 -1
- package/src/dev/vite-dev-server.ts +1 -0
- package/src/i18n/binding-extractor.ts +1969 -0
- package/src/i18n/catalog-template.ts +24 -0
- package/src/i18n/catalogs.ts +216 -0
- package/src/i18n/extractor-plugin.ts +413 -0
- package/src/i18n/metadata-templates.ts +29 -0
- package/src/i18n/source-messages.ts +608 -0
- package/src/i18n/types.ts +154 -0
- package/src/internal/build-manifest.ts +32 -0
- package/src/internal/icon-path.ts +127 -0
- package/src/internal/source-imports.ts +171 -0
- package/src/mcp/client.ts +17 -44
- package/src/mcp/handlers.ts +7 -6
- package/src/mcp/widget-properties.ts +3 -14
- package/src/settings/render.ts +113 -21
- package/src/settings/schema.ts +192 -17
- package/src/vite-plugins/asset-emitter.ts +1 -1
- package/src/vite-plugins/asset-extensions.ts +1 -0
- package/src/vite-plugins/asset-imports.ts +62 -33
- package/src/vite-plugins/asset-specifier.ts +73 -1
- package/src/vite-plugins/{bundled-packages.ts → build-manifest.ts} +30 -19
- package/src/vite-plugins/built-url.ts +49 -28
- package/src/vite-plugins/i18n.ts +146 -0
- package/src/vite-plugins/icons.ts +33 -14
- package/src/vite-plugins/index.ts +15 -5
- package/src/vite-plugins/native.ts +31 -4
- package/src/vite-plugins/resource-init-module.ts +44 -15
- package/src/vite-plugins/resource-shared.ts +4 -0
- package/src/vite-plugins/resources.ts +1397 -100
- package/src/vite-plugins/self-contained.ts +150 -169
- package/src/vite-plugins/settings-worker-env.ts +7 -3
- package/src/vite-plugins/settings.ts +89 -21
- package/dist/vite-plugins/bundled-packages.d.ts +0 -5
- package/dist/vite-plugins/bundled-packages.d.ts.map +0 -1
- package/dist/vite-plugins/bundled-packages.js.map +0 -1
package/src/deploy/run-deploy.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { loadConfig } from "@gtkx/config";
|
|
2
2
|
import { info, warn } from "@gtkx/utils";
|
|
3
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join, relative } from "node:path";
|
|
5
5
|
import type {
|
|
6
6
|
DeployArtifact,
|
|
@@ -12,7 +12,19 @@ import type {
|
|
|
12
12
|
} from "./types.js";
|
|
13
13
|
import { build as buildApp } from "../builder.js";
|
|
14
14
|
import { ensureGenerated } from "../codegen/run-codegen.js";
|
|
15
|
+
import { replaceCatalogTemplate } from "../i18n/catalog-template.js";
|
|
16
|
+
import {
|
|
17
|
+
type CatalogProject,
|
|
18
|
+
compileCatalogs,
|
|
19
|
+
LOCALE_DIRNAME,
|
|
20
|
+
requiresCatalogInitialization,
|
|
21
|
+
resolveCatalogProject,
|
|
22
|
+
synchronizeCatalogs,
|
|
23
|
+
} from "../i18n/catalogs.js";
|
|
24
|
+
import { extractSourceCatalogTo } from "../i18n/source-messages.js";
|
|
25
|
+
import { discoverSourceFiles } from "../internal/source-imports.js";
|
|
15
26
|
import { renderDesktopEntry } from "./freedesktop/desktop-entry.js";
|
|
27
|
+
import { extractMetadataMessages, localizeMetadata } from "./freedesktop/localize.js";
|
|
16
28
|
import { renderMetainfo } from "./freedesktop/metainfo.js";
|
|
17
29
|
import { renderMimePackage } from "./freedesktop/mime-package.js";
|
|
18
30
|
import { validateDesktopEntry, validateMetainfo } from "./freedesktop/validate.js";
|
|
@@ -20,10 +32,11 @@ import { resolveNodeRuntime } from "./node-runtime/index.js";
|
|
|
20
32
|
import { collectNotices } from "./notices/collect.js";
|
|
21
33
|
import { type StagedMetadata, stageOverlays, stagePayload } from "./payload/stage.js";
|
|
22
34
|
import { DEFAULT_TARGETS, parseTargetList, targetsFor } from "./registry.js";
|
|
35
|
+
import { readBuildManifest } from "./settings/build-manifest.js";
|
|
23
36
|
import { resolveDeploySettings } from "./settings/index.js";
|
|
24
37
|
import { readPackageManifest } from "./settings/package-manifest.js";
|
|
25
38
|
import { missingDeployError } from "./settings/starter.js";
|
|
26
|
-
import { finishArgsFor, hasDisplaySocket } from "./targets/flatpak-manifest.js";
|
|
39
|
+
import { finishArgsFor, hasDisplaySocket, runtimeLabelFor } from "./targets/flatpak-manifest.js";
|
|
27
40
|
import { detectPackageManager } from "./targets/flatpak-sources.js";
|
|
28
41
|
import {
|
|
29
42
|
APPSTREAMCLI,
|
|
@@ -31,10 +44,15 @@ import {
|
|
|
31
44
|
DESKTOP_FILE_VALIDATE,
|
|
32
45
|
FLATPAK_NODE_GENERATOR,
|
|
33
46
|
FLATPAK_NODE_GENERATOR_PNPM,
|
|
47
|
+
MSGFMT,
|
|
48
|
+
MSGGREP,
|
|
49
|
+
MSGINIT,
|
|
50
|
+
MSGMERGE,
|
|
34
51
|
probeTools,
|
|
35
52
|
STRIP,
|
|
36
53
|
TAR,
|
|
37
54
|
warnMissingOptional,
|
|
55
|
+
XGETTEXT,
|
|
38
56
|
} from "./tools.js";
|
|
39
57
|
|
|
40
58
|
type DeployOptions = {
|
|
@@ -46,10 +64,20 @@ type DeployOptions = {
|
|
|
46
64
|
shouldSkipBuild: boolean;
|
|
47
65
|
};
|
|
48
66
|
|
|
67
|
+
type PreflightRequest = {
|
|
68
|
+
targets: DeployTarget[];
|
|
69
|
+
settings: DeploySettings;
|
|
70
|
+
project: CatalogProject | null;
|
|
71
|
+
shouldPrintManifests: boolean;
|
|
72
|
+
shouldSkipBuild: boolean;
|
|
73
|
+
};
|
|
74
|
+
|
|
49
75
|
const BUILD_MODE = "production";
|
|
50
76
|
const BYTES_PER_MIB = 1024 * 1024;
|
|
51
77
|
const WEBKIT_LIBRARY = "WebKit-6.0";
|
|
52
78
|
const NETWORK_ARG = "--share=network";
|
|
79
|
+
const APPIMAGE_TARGET = "appimage";
|
|
80
|
+
const FLATPAK_TARGET = "flatpak";
|
|
53
81
|
|
|
54
82
|
const displayPath = (settings: DeploySettings, path: string): string => relative(settings.paths.root, path);
|
|
55
83
|
const megabytes = (size: number): string => (size / BYTES_PER_MIB).toFixed(1);
|
|
@@ -66,7 +94,7 @@ const renderMetadata = (settings: DeploySettings): StagedMetadata => ({
|
|
|
66
94
|
});
|
|
67
95
|
|
|
68
96
|
const isFlathubSubmission = (settings: DeploySettings, targets: DeployTarget[]): boolean =>
|
|
69
|
-
settings.deploy.flatpak?.mode === "source" && targets.some((target) => target.name ===
|
|
97
|
+
settings.deploy.flatpak?.mode === "source" && targets.some((target) => target.name === FLATPAK_TARGET);
|
|
70
98
|
|
|
71
99
|
const validateMetadata = (settings: DeploySettings, metadata: StagedMetadata, areWarningsFatal: boolean): void => {
|
|
72
100
|
const dir = settings.paths.metadata;
|
|
@@ -104,7 +132,7 @@ const warnMissingNetwork = (settings: DeploySettings, finishArgs: string[]): voi
|
|
|
104
132
|
};
|
|
105
133
|
|
|
106
134
|
const warnFlatpakPermissions = (targets: DeployTarget[], settings: DeploySettings): void => {
|
|
107
|
-
if (targets.every((target) => target.name !==
|
|
135
|
+
if (targets.every((target) => target.name !== FLATPAK_TARGET)) {
|
|
108
136
|
return;
|
|
109
137
|
}
|
|
110
138
|
|
|
@@ -113,10 +141,68 @@ const warnFlatpakPermissions = (targets: DeployTarget[], settings: DeploySetting
|
|
|
113
141
|
warnMissingNetwork(settings, finishArgs);
|
|
114
142
|
};
|
|
115
143
|
|
|
144
|
+
const minimumSummary = (settings: DeploySettings): string =>
|
|
145
|
+
settings.libraries
|
|
146
|
+
.filter((library) => settings.minimumLibraryVersions[library] !== undefined)
|
|
147
|
+
.map((library) => `${library} >= ${String(settings.minimumLibraryVersions[library])}`)
|
|
148
|
+
.join(", ");
|
|
149
|
+
|
|
150
|
+
const warnAppImageMinimums = (settings: DeploySettings, summary: string): void => {
|
|
151
|
+
warn(
|
|
152
|
+
`An AppImage cannot declare a dependency, so nothing stops ${settings.name} from starting on a host ` +
|
|
153
|
+
`whose libraries are older than the ones its bindings were generated against (${summary}). ` +
|
|
154
|
+
"Publish that requirement alongside the AppImage, or build on the oldest host you support.",
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const warnFlatpakMinimums = (settings: DeploySettings, summary: string): void => {
|
|
159
|
+
warn(
|
|
160
|
+
`The flatpak bundles binaries built against ${summary}, but runs them on ` +
|
|
161
|
+
`${runtimeLabelFor(settings)}, whose libraries are whatever that runtime ships. ` +
|
|
162
|
+
'Set `deploy.flatpak.mode: "source"` to build inside the runtime instead.',
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const warnUnusedMinimums = (settings: DeploySettings): void => {
|
|
167
|
+
const minimums = settings.deploy.minimumLibraryVersions;
|
|
168
|
+
|
|
169
|
+
if (minimums === undefined) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const unused = Object.keys(minimums).filter((library) => !settings.libraries.includes(library));
|
|
174
|
+
|
|
175
|
+
if (unused.length === 0) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
warn(
|
|
180
|
+
`\`deploy.minimumLibraryVersions\` names ${unused.join(", ")}, which this project generates no bindings for, ` +
|
|
181
|
+
"so those minimums change nothing.",
|
|
182
|
+
);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const isPrebuiltFlatpak = (targets: DeployTarget[], settings: DeploySettings): boolean =>
|
|
186
|
+
targets.some((target) => target.name === FLATPAK_TARGET) && settings.deploy.flatpak?.mode !== "source";
|
|
187
|
+
|
|
188
|
+
const warnLibraryMinimums = (targets: DeployTarget[], settings: DeploySettings): void => {
|
|
189
|
+
const summary = minimumSummary(settings);
|
|
190
|
+
|
|
191
|
+
if (summary.length > 0 && targets.some((target) => target.name === APPIMAGE_TARGET)) {
|
|
192
|
+
warnAppImageMinimums(settings, summary);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (summary.length > 0 && isPrebuiltFlatpak(targets, settings)) {
|
|
196
|
+
warnFlatpakMinimums(settings, summary);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
warnUnusedMinimums(settings);
|
|
200
|
+
};
|
|
201
|
+
|
|
116
202
|
const sourceModeTools = (targets: DeployTarget[], settings: DeploySettings): DeployTool[] => {
|
|
117
203
|
const isFlatpakSource = settings.deploy.flatpak?.mode === "source";
|
|
118
204
|
|
|
119
|
-
if (!isFlatpakSource || targets.every((target) => target.name !==
|
|
205
|
+
if (!isFlatpakSource || targets.every((target) => target.name !== FLATPAK_TARGET)) {
|
|
120
206
|
return [];
|
|
121
207
|
}
|
|
122
208
|
|
|
@@ -124,7 +210,7 @@ const sourceModeTools = (targets: DeployTarget[], settings: DeploySettings): Dep
|
|
|
124
210
|
};
|
|
125
211
|
|
|
126
212
|
const isNodeRequired = (targets: DeployTarget[], settings: DeploySettings): boolean =>
|
|
127
|
-
!(settings.deploy.flatpak?.mode === "source" && targets.every((target) => target.name ===
|
|
213
|
+
!(settings.deploy.flatpak?.mode === "source" && targets.every((target) => target.name === FLATPAK_TARGET));
|
|
128
214
|
|
|
129
215
|
const runtimeToolsFor = (targets: DeployTarget[], settings: DeploySettings): DeployTool[] => {
|
|
130
216
|
if (!isNodeRequired(targets, settings)) {
|
|
@@ -137,16 +223,55 @@ const runtimeToolsFor = (targets: DeployTarget[], settings: DeploySettings): Dep
|
|
|
137
223
|
return node.shouldStrip === false ? archiveTools : [...archiveTools, STRIP];
|
|
138
224
|
};
|
|
139
225
|
|
|
140
|
-
const
|
|
226
|
+
const mutableCatalogTools = (project: CatalogProject): DeployTool[] => {
|
|
227
|
+
if (project.catalogs.length === 0) {
|
|
228
|
+
return [MSGGREP, XGETTEXT];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return [
|
|
232
|
+
MSGFMT,
|
|
233
|
+
MSGGREP,
|
|
234
|
+
...(requiresCatalogInitialization(project) ? [MSGINIT] : []),
|
|
235
|
+
MSGMERGE,
|
|
236
|
+
XGETTEXT,
|
|
237
|
+
];
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const catalogTools = (project: CatalogProject | null, shouldSkipBuild: boolean): DeployTool[] => {
|
|
241
|
+
if (project === null) {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (!shouldSkipBuild) {
|
|
246
|
+
return mutableCatalogTools(project);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return project.catalogs.length === 0 ? [] : [MSGFMT];
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const preflight = ({
|
|
253
|
+
targets,
|
|
254
|
+
settings,
|
|
255
|
+
project,
|
|
256
|
+
shouldPrintManifests,
|
|
257
|
+
shouldSkipBuild,
|
|
258
|
+
}: PreflightRequest): void => {
|
|
141
259
|
const packagerTools = shouldPrintManifests
|
|
142
260
|
? []
|
|
143
261
|
: [...runtimeToolsFor(targets, settings), ...targets.flatMap((target) => target.tools)];
|
|
144
262
|
|
|
145
|
-
const required = [
|
|
263
|
+
const required = [
|
|
264
|
+
DESKTOP_FILE_VALIDATE,
|
|
265
|
+
APPSTREAMCLI,
|
|
266
|
+
...catalogTools(project, shouldSkipBuild),
|
|
267
|
+
...sourceModeTools(targets, settings),
|
|
268
|
+
];
|
|
269
|
+
|
|
146
270
|
const report = probeTools([...required, ...packagerTools]);
|
|
147
271
|
assertTools(report);
|
|
148
272
|
warnMissingOptional(report);
|
|
149
273
|
warnFlatpakPermissions(targets, settings);
|
|
274
|
+
warnLibraryMinimums(targets, settings);
|
|
150
275
|
};
|
|
151
276
|
|
|
152
277
|
const resolveTargetNames = (options: DeployOptions, settings: DeploySettings): string[] => {
|
|
@@ -167,28 +292,77 @@ const loadSettings = async (options: DeployOptions): Promise<DeploySettings> =>
|
|
|
167
292
|
return resolveDeploySettings({ root, config, outDirOverride: options.outDir });
|
|
168
293
|
};
|
|
169
294
|
|
|
295
|
+
const synchronizeMetadataCatalogs = async (
|
|
296
|
+
settings: DeploySettings,
|
|
297
|
+
templates: StagedMetadata,
|
|
298
|
+
project: CatalogProject | null,
|
|
299
|
+
): Promise<void> => {
|
|
300
|
+
if (project === null) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const srcDir = join(project.root, "src");
|
|
305
|
+
const sourceFiles = discoverSourceFiles(existsSync(srcDir) ? srcDir : project.root);
|
|
306
|
+
const stagingDir = mkdtempSync(join(project.poDir, ".gtkx-deploy-i18n-"));
|
|
307
|
+
const stagedTemplate = join(stagingDir, `${project.domain}.pot`);
|
|
308
|
+
const template = join(project.poDir, `${project.domain}.pot`);
|
|
309
|
+
|
|
310
|
+
try {
|
|
311
|
+
await extractSourceCatalogTo(project, sourceFiles, stagedTemplate);
|
|
312
|
+
extractMetadataMessages(templates, project, stagedTemplate);
|
|
313
|
+
replaceCatalogTemplate(stagedTemplate, template);
|
|
314
|
+
synchronizeCatalogs(project);
|
|
315
|
+
compileCatalogs(project, join(settings.paths.dist, LOCALE_DIRNAME));
|
|
316
|
+
} finally {
|
|
317
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
170
321
|
const buildPayload = async (
|
|
171
322
|
options: DeployOptions,
|
|
172
323
|
settings: DeploySettings,
|
|
173
324
|
targets: DeployTarget[],
|
|
325
|
+
project: CatalogProject | null,
|
|
174
326
|
): Promise<DeployPayload> => {
|
|
175
|
-
const
|
|
176
|
-
validateMetadata(settings, metadata, isFlathubSubmission(settings, targets));
|
|
327
|
+
const templates = renderMetadata(settings);
|
|
177
328
|
|
|
178
329
|
if (!options.shouldSkipBuild) {
|
|
179
330
|
info(`Building ${options.entry}`);
|
|
180
|
-
|
|
331
|
+
|
|
332
|
+
await buildApp({
|
|
333
|
+
entry: options.entry,
|
|
334
|
+
vite: { root: options.cwd },
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
await synchronizeMetadataCatalogs(settings, templates, project);
|
|
338
|
+
} else if (project !== null) {
|
|
339
|
+
compileCatalogs(project, join(settings.paths.dist, LOCALE_DIRNAME));
|
|
181
340
|
}
|
|
182
341
|
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
342
|
+
const metadata = localizeMetadata(templates, project);
|
|
343
|
+
validateMetadata(settings, metadata, isFlathubSubmission(settings, targets));
|
|
344
|
+
const buildManifest = readBuildManifest(settings);
|
|
186
345
|
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
346
|
+
const builtSettings: DeploySettings = {
|
|
347
|
+
...settings,
|
|
348
|
+
paths: { ...settings.paths, schemaFiles: buildManifest.schemaFiles },
|
|
349
|
+
};
|
|
190
350
|
|
|
191
|
-
|
|
351
|
+
const node = options.shouldPrintManifests || !isNodeRequired(targets, builtSettings)
|
|
352
|
+
? null
|
|
353
|
+
: await resolveNodeRuntime(builtSettings);
|
|
354
|
+
|
|
355
|
+
const stage = stagePayload({ settings: builtSettings, node, metadata });
|
|
356
|
+
info(`Staged ${String(stage.length)} files into ${displayPath(builtSettings, builtSettings.paths.stage)}`);
|
|
357
|
+
const notices = collectNotices({ settings: builtSettings, node, packages: buildManifest.packages });
|
|
358
|
+
|
|
359
|
+
return {
|
|
360
|
+
settings: builtSettings,
|
|
361
|
+
node,
|
|
362
|
+
stage,
|
|
363
|
+
notices,
|
|
364
|
+
overlays: stageOverlays(builtSettings, notices, metadata),
|
|
365
|
+
};
|
|
192
366
|
};
|
|
193
367
|
|
|
194
368
|
const renderTargetManifests = (
|
|
@@ -237,15 +411,31 @@ const announce = (settings: DeploySettings, targets: DeployTarget[]): void => {
|
|
|
237
411
|
};
|
|
238
412
|
|
|
239
413
|
const runDeploy = async (options: DeployOptions): Promise<void> => {
|
|
414
|
+
let settings = await loadSettings(options);
|
|
415
|
+
let project = resolveCatalogProject(settings.paths.root, settings.applicationId);
|
|
416
|
+
let targets = targetsFor(resolveTargetNames(options, settings));
|
|
417
|
+
announce(settings, targets);
|
|
418
|
+
|
|
419
|
+
preflight({
|
|
420
|
+
targets,
|
|
421
|
+
settings,
|
|
422
|
+
project,
|
|
423
|
+
shouldPrintManifests: options.shouldPrintManifests,
|
|
424
|
+
shouldSkipBuild: options.shouldSkipBuild,
|
|
425
|
+
});
|
|
426
|
+
|
|
240
427
|
if (!options.shouldSkipBuild) {
|
|
241
|
-
await ensureGenerated(options.cwd, {
|
|
428
|
+
await ensureGenerated(options.cwd, {
|
|
429
|
+
shouldAnnounce: true,
|
|
430
|
+
mode: BUILD_MODE,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
settings = await loadSettings(options);
|
|
434
|
+
project = resolveCatalogProject(settings.paths.root, settings.applicationId);
|
|
435
|
+
targets = targetsFor(resolveTargetNames(options, settings));
|
|
242
436
|
}
|
|
243
437
|
|
|
244
|
-
const
|
|
245
|
-
const targets = targetsFor(resolveTargetNames(options, settings));
|
|
246
|
-
announce(settings, targets);
|
|
247
|
-
preflight(targets, settings, options.shouldPrintManifests);
|
|
248
|
-
const payload = await buildPayload(options, settings, targets);
|
|
438
|
+
const payload = await buildPayload(options, settings, targets, project);
|
|
249
439
|
const rendered = renderTargetManifests(targets, payload);
|
|
250
440
|
|
|
251
441
|
if (options.shouldPrintManifests) {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { isRecord, sortStrings } from "@gtkx/utils";
|
|
2
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import type { DeploySettings } from "../types.js";
|
|
5
|
+
import {
|
|
6
|
+
BUILD_MANIFEST_FILENAME,
|
|
7
|
+
BUILD_MANIFEST_FORMAT_VERSION,
|
|
8
|
+
BUILD_MANIFEST_GENERATOR,
|
|
9
|
+
type BuildManifest,
|
|
10
|
+
type RecordedPackage,
|
|
11
|
+
} from "../../internal/build-manifest.js";
|
|
12
|
+
import {
|
|
13
|
+
assertUniqueSchemaBasenames,
|
|
14
|
+
projectRelativeSchemaPath,
|
|
15
|
+
SCHEMA_SUFFIX,
|
|
16
|
+
} from "../../settings/schema.js";
|
|
17
|
+
|
|
18
|
+
type ResolvedBuildManifest = {
|
|
19
|
+
packages: RecordedPackage[];
|
|
20
|
+
schemaFiles: string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const invalidManifest = (path: string): Error =>
|
|
24
|
+
new Error(`Cannot deploy: ${path} is not a valid GTKX build manifest. Run \`gtkx build\` again.`);
|
|
25
|
+
|
|
26
|
+
const recordedSchemas = (value: unknown[], path: string): string[] =>
|
|
27
|
+
value.map((entry) => {
|
|
28
|
+
if (typeof entry !== "string") {
|
|
29
|
+
throw invalidManifest(path);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return entry;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const recordedPackage = (value: unknown, path: string): RecordedPackage => {
|
|
36
|
+
if (
|
|
37
|
+
!isRecord(value) ||
|
|
38
|
+
typeof value.name !== "string" ||
|
|
39
|
+
typeof value.dir !== "string" ||
|
|
40
|
+
isAbsolute(value.dir) ||
|
|
41
|
+
(value.version !== null && typeof value.version !== "string")
|
|
42
|
+
) {
|
|
43
|
+
throw invalidManifest(path);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { name: value.name, version: value.version, dir: value.dir };
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const parseBuildManifest = (value: unknown, path: string): BuildManifest => {
|
|
50
|
+
if (
|
|
51
|
+
!isRecord(value) ||
|
|
52
|
+
value.generator !== BUILD_MANIFEST_GENERATOR ||
|
|
53
|
+
value.formatVersion !== BUILD_MANIFEST_FORMAT_VERSION ||
|
|
54
|
+
!Array.isArray(value.schemas) ||
|
|
55
|
+
!Array.isArray(value.packages)
|
|
56
|
+
) {
|
|
57
|
+
throw invalidManifest(path);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const packages: unknown[] = value.packages;
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
generator: BUILD_MANIFEST_GENERATOR,
|
|
64
|
+
formatVersion: BUILD_MANIFEST_FORMAT_VERSION,
|
|
65
|
+
schemas: recordedSchemas(value.schemas, path),
|
|
66
|
+
packages: packages.map((entry) => recordedPackage(entry, path)),
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const isFile = (path: string): boolean => {
|
|
71
|
+
try {
|
|
72
|
+
return statSync(path, { throwIfNoEntry: false })?.isFile() === true;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const isInsideProject = (root: string, filePath: string): boolean => {
|
|
79
|
+
const rel = relative(root, filePath);
|
|
80
|
+
|
|
81
|
+
return rel.length > 0 && rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const resolveRecordedSchema = (root: string, manifestPath: string, entry: string): string => {
|
|
85
|
+
if (isAbsolute(entry) || !entry.endsWith(SCHEMA_SUFFIX)) {
|
|
86
|
+
throw new Error(`Cannot deploy: ${manifestPath} records an invalid GSettings schema path.`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const filePath = resolve(root, entry);
|
|
90
|
+
|
|
91
|
+
if (!isInsideProject(root, filePath)) {
|
|
92
|
+
throw new Error(`Cannot deploy: ${manifestPath} records a GSettings schema outside the project.`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!isFile(filePath)) {
|
|
96
|
+
throw new Error(`Cannot deploy: the recorded GSettings schema ${filePath} is missing.`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (projectRelativeSchemaPath(root, filePath) === null) {
|
|
100
|
+
throw new Error(`Cannot deploy: ${manifestPath} records a GSettings schema outside the project.`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return filePath;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const readBuildManifest = (settings: DeploySettings): ResolvedBuildManifest => {
|
|
107
|
+
const manifestPath = join(settings.paths.dist, BUILD_MANIFEST_FILENAME);
|
|
108
|
+
|
|
109
|
+
if (!existsSync(manifestPath)) {
|
|
110
|
+
throw new Error(`Cannot deploy: ${manifestPath} is missing. Run \`gtkx build\` first.`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const parsed: unknown = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
114
|
+
const manifest = parseBuildManifest(parsed, manifestPath);
|
|
115
|
+
const files = manifest.schemas.map((entry) => resolveRecordedSchema(settings.paths.root, manifestPath, entry));
|
|
116
|
+
const unique = sortStrings(new Set(files));
|
|
117
|
+
assertUniqueSchemaBasenames(unique);
|
|
118
|
+
|
|
119
|
+
return { packages: manifest.packages, schemaFiles: unique };
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { readBuildManifest };
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
resolveSummary,
|
|
23
23
|
resolveVersionString,
|
|
24
24
|
} from "./identity.js";
|
|
25
|
+
import { resolveLibraries } from "./libraries.js";
|
|
25
26
|
import { readPackageManifest } from "./package-manifest.js";
|
|
26
27
|
import { resolvePaths } from "./paths.js";
|
|
27
28
|
import { resolveScreenshots } from "./screenshots.js";
|
|
@@ -113,8 +114,6 @@ const resolveDesktopActions = (deploy: DeployConfig): DeployDesktopAction[] =>
|
|
|
113
114
|
icon: action.icon ?? null,
|
|
114
115
|
}));
|
|
115
116
|
|
|
116
|
-
const resolveLibraries = (config: Config): string[] => (Array.isArray(config.libraries) ? config.libraries : []);
|
|
117
|
-
|
|
118
117
|
const identitySlice = ({ identity, developer, date }: ResolvedCore): IdentitySlice => ({
|
|
119
118
|
applicationId: identity.applicationId,
|
|
120
119
|
binaryName: resolveBinaryName(identity),
|
|
@@ -181,8 +180,14 @@ const resolveDeploySettings = (request: SettingsRequest): DeploySettings => {
|
|
|
181
180
|
extraFiles: resolveExtraFiles(deploy),
|
|
182
181
|
versions: core.versions,
|
|
183
182
|
arch: resolveArch(),
|
|
184
|
-
paths: resolvePaths({
|
|
185
|
-
|
|
183
|
+
paths: resolvePaths({
|
|
184
|
+
root: request.root,
|
|
185
|
+
deploy,
|
|
186
|
+
applicationIcon: request.config.applicationIcon,
|
|
187
|
+
applicationId: request.config.applicationId,
|
|
188
|
+
outDirOverride: request.outDirOverride,
|
|
189
|
+
}),
|
|
190
|
+
...resolveLibraries(request.root, request.config),
|
|
186
191
|
deploy,
|
|
187
192
|
};
|
|
188
193
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Config } from "@gtkx/config";
|
|
2
|
+
import {
|
|
3
|
+
resolveLibraries as expandLibraries,
|
|
4
|
+
type GeneratedLibraries,
|
|
5
|
+
readGeneratedLibraries,
|
|
6
|
+
resolveGirPath,
|
|
7
|
+
resolveStore,
|
|
8
|
+
} from "@gtkx/codegen";
|
|
9
|
+
|
|
10
|
+
type ResolvedLibraries = {
|
|
11
|
+
libraries: string[];
|
|
12
|
+
minimumLibraryVersions: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const DEFAULT_LIBRARY = "Gtk-4.0";
|
|
16
|
+
const DEFAULT_LIBRARY_PREFIX = "Gtk-";
|
|
17
|
+
|
|
18
|
+
const generatedLibraries = (root: string): GeneratedLibraries | null => {
|
|
19
|
+
try {
|
|
20
|
+
return readGeneratedLibraries(resolveStore(root).gi.storeDir);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const discoveredLibraries = (config: Config): string[] | null => {
|
|
27
|
+
try {
|
|
28
|
+
return expandLibraries(config.libraries, resolveGirPath(config.girPath));
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const configLibraries = (config: Config): string[] => {
|
|
35
|
+
const libraries = config.libraries;
|
|
36
|
+
|
|
37
|
+
if (!Array.isArray(libraries)) {
|
|
38
|
+
return discoveredLibraries(config) ?? [DEFAULT_LIBRARY];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return libraries.some((library) => library.startsWith(DEFAULT_LIBRARY_PREFIX))
|
|
42
|
+
? [...libraries]
|
|
43
|
+
: [DEFAULT_LIBRARY, ...libraries];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const resolveLibraries = (root: string, config: Config): ResolvedLibraries => {
|
|
47
|
+
const generated = generatedLibraries(root);
|
|
48
|
+
const libraries = generated?.libraries ?? configLibraries(config);
|
|
49
|
+
const deploy = config.deploy ?? {};
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
libraries,
|
|
53
|
+
minimumLibraryVersions: deploy.minimumLibraryVersions ?? {},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { resolveLibraries };
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Config } from "@gtkx/config";
|
|
2
|
+
import { statSync } from "node:fs";
|
|
2
3
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
3
4
|
import type { DeployConfig, DeployPaths } from "../types.js";
|
|
4
|
-
import {
|
|
5
|
-
import { findSchemaFiles } from "../../settings/schema.js";
|
|
5
|
+
import { resolveApplicationIcon } from "../../internal/icon-path.js";
|
|
6
6
|
|
|
7
7
|
type PathsRequest = {
|
|
8
8
|
root: string;
|
|
9
9
|
deploy: DeployConfig;
|
|
10
|
+
applicationIcon: Config["applicationIcon"];
|
|
11
|
+
applicationId: Config["applicationId"];
|
|
10
12
|
outDirOverride: string | undefined;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
|
-
type ResolvedIcons = {
|
|
14
|
-
iconsDir: string | null;
|
|
15
|
-
iconFile: string | null;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
15
|
const DEFAULT_OUT_DIR = "build";
|
|
19
16
|
const DIST_DIR = "dist";
|
|
20
|
-
const ICONS_DIR = "icons";
|
|
21
17
|
const LICENSE_CANDIDATES = ["LICENSE", "LICENSE.md", "LICENSE.txt", "COPYING", "COPYING.md"];
|
|
22
18
|
|
|
23
19
|
const isInside = (parent: string, candidate: string): boolean => {
|
|
@@ -37,17 +33,14 @@ const resolveOutDir = ({ root, deploy, outDirOverride }: PathsRequest): string =
|
|
|
37
33
|
return outDir;
|
|
38
34
|
};
|
|
39
35
|
|
|
40
|
-
const
|
|
36
|
+
const existingFile = (path: string): string | null => {
|
|
41
37
|
try {
|
|
42
|
-
return statSync(path, { throwIfNoEntry: false });
|
|
38
|
+
return statSync(path, { throwIfNoEntry: false })?.isFile() === true ? path : null;
|
|
43
39
|
} catch {
|
|
44
|
-
return
|
|
40
|
+
return null;
|
|
45
41
|
}
|
|
46
42
|
};
|
|
47
43
|
|
|
48
|
-
const existingFile = (path: string): string | null => (getStats(path)?.isFile() === true ? path : null);
|
|
49
|
-
const existingDir = (path: string): string | null => (getStats(path)?.isDirectory() === true ? path : null);
|
|
50
|
-
|
|
51
44
|
const resolveLicenseFile = (root: string, configured: string | undefined): string | null => {
|
|
52
45
|
if (configured !== undefined) {
|
|
53
46
|
const path = resolve(root, configured);
|
|
@@ -62,37 +55,9 @@ const resolveLicenseFile = (root: string, configured: string | undefined): strin
|
|
|
62
55
|
return LICENSE_CANDIDATES.map((name) => existingFile(join(root, name))).find((path) => path !== null) ?? null;
|
|
63
56
|
};
|
|
64
57
|
|
|
65
|
-
const configuredIcons = (root: string, configured: string): ResolvedIcons => {
|
|
66
|
-
const path = resolve(root, configured);
|
|
67
|
-
|
|
68
|
-
if (!isInside(root, path)) {
|
|
69
|
-
throw new Error(`Cannot use "${configured}" as the icon path: it is outside ${root}`);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (existingDir(path) !== null) {
|
|
73
|
-
return { iconsDir: path, iconFile: null };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (existingFile(path) === null) {
|
|
77
|
-
throw new Error(`Cannot read the icon path "${configured}": no such file or directory under ${root}`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return { iconsDir: null, iconFile: path };
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const defaultIcons = (root: string, dataDir: string | null): ResolvedIcons => ({
|
|
84
|
-
iconsDir: dataDir === null ? null : existingDir(join(root, dataDir, ICONS_DIR)),
|
|
85
|
-
iconFile: null,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const resolveIcons = (root: string, dataDir: string | null, configured: string | undefined): ResolvedIcons =>
|
|
89
|
-
configured === undefined ? defaultIcons(root, dataDir) : configuredIcons(root, configured);
|
|
90
|
-
|
|
91
58
|
const resolvePaths = (request: PathsRequest): DeployPaths => {
|
|
92
59
|
const { root, deploy } = request;
|
|
93
60
|
const outDir = resolveOutDir(request);
|
|
94
|
-
const dataDir = resolveDataDir(root);
|
|
95
|
-
const { iconsDir, iconFile } = resolveIcons(root, dataDir, deploy.icons);
|
|
96
61
|
|
|
97
62
|
return {
|
|
98
63
|
root,
|
|
@@ -104,11 +69,9 @@ const resolvePaths = (request: PathsRequest): DeployPaths => {
|
|
|
104
69
|
overlay: join(outDir, "overlay"),
|
|
105
70
|
targets: join(outDir, "targets"),
|
|
106
71
|
output: join(outDir, "out"),
|
|
107
|
-
|
|
108
|
-
iconsDir,
|
|
109
|
-
iconFile,
|
|
72
|
+
applicationIcon: resolveApplicationIcon(root, request.applicationId, request.applicationIcon),
|
|
110
73
|
licenseFile: resolveLicenseFile(root, deploy.licenseFile),
|
|
111
|
-
schemaFiles:
|
|
74
|
+
schemaFiles: [],
|
|
112
75
|
};
|
|
113
76
|
};
|
|
114
77
|
|