@gtkx/cli 1.1.0 → 1.2.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/dist/codegen/report.d.ts.map +1 -1
- package/dist/codegen/report.js +3 -0
- package/dist/codegen/report.js.map +1 -1
- package/dist/codegen/run-codegen.d.ts +1 -0
- package/dist/codegen/run-codegen.d.ts.map +1 -1
- package/dist/codegen/run-codegen.js +7 -1
- package/dist/codegen/run-codegen.js.map +1 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +1 -0
- package/dist/commands/docs.js.map +1 -1
- package/dist/deploy/install-hints.d.ts.map +1 -1
- package/dist/deploy/install-hints.js +7 -4
- package/dist/deploy/install-hints.js.map +1 -1
- package/dist/deploy/run-deploy.d.ts.map +1 -1
- package/dist/deploy/run-deploy.js +6 -2
- package/dist/deploy/run-deploy.js.map +1 -1
- package/dist/deploy/settings/package-manifest.d.ts +1 -0
- package/dist/deploy/settings/package-manifest.d.ts.map +1 -1
- package/dist/deploy/settings/package-manifest.js +1 -0
- package/dist/deploy/settings/package-manifest.js.map +1 -1
- package/dist/deploy/targets/flatpak-pnpm.d.ts +15 -0
- package/dist/deploy/targets/flatpak-pnpm.d.ts.map +1 -0
- package/dist/deploy/targets/flatpak-pnpm.js +69 -0
- package/dist/deploy/targets/flatpak-pnpm.js.map +1 -0
- package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak-source.js +15 -6
- package/dist/deploy/targets/flatpak-source.js.map +1 -1
- package/dist/deploy/targets/flatpak-sources.d.ts +5 -3
- package/dist/deploy/targets/flatpak-sources.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak-sources.js +23 -9
- package/dist/deploy/targets/flatpak-sources.js.map +1 -1
- package/dist/deploy/targets/flatpak.d.ts.map +1 -1
- package/dist/deploy/targets/flatpak.js +3 -2
- package/dist/deploy/targets/flatpak.js.map +1 -1
- package/dist/deploy/tools.d.ts +3 -1
- package/dist/deploy/tools.d.ts.map +1 -1
- package/dist/deploy/tools.js +17 -3
- package/dist/deploy/tools.js.map +1 -1
- package/package.json +9 -9
- package/src/codegen/report.ts +4 -0
- package/src/codegen/run-codegen.ts +11 -1
- package/src/commands/docs.ts +1 -0
- package/src/deploy/install-hints.ts +9 -6
- package/src/deploy/run-deploy.ts +7 -1
- package/src/deploy/settings/package-manifest.ts +2 -0
- package/src/deploy/targets/flatpak-pnpm.ts +115 -0
- package/src/deploy/targets/flatpak-source.ts +18 -5
- package/src/deploy/targets/flatpak-sources.ts +36 -9
- package/src/deploy/targets/flatpak.ts +3 -2
- package/src/deploy/tools.ts +23 -2
|
@@ -7,8 +7,9 @@ import { renderMetainfo } from "../freedesktop/metainfo.js";
|
|
|
7
7
|
import { optional } from "../nfpm/optional.js";
|
|
8
8
|
import { iconPathFor } from "../payload/icons.js";
|
|
9
9
|
import { renderLauncher } from "../payload/launcher.js";
|
|
10
|
+
import { pnpmPathFor, pnpmSources } from "./flatpak-pnpm.js";
|
|
10
11
|
import { DESTINATION, postInstallCommands, validationCommands } from "./flatpak-prebuilt.js";
|
|
11
|
-
import { detectPackageManager, GENERATED_SOURCES, installCommandFor, nodeExtensionPathFor, resolveGitSource, } from "./flatpak-sources.js";
|
|
12
|
+
import { detectPackageManager, GENERATED_SOURCES, installCommandFor, nodeExtensionPathFor, pnpmPinFor, resolveGitSource, } from "./flatpak-sources.js";
|
|
12
13
|
const LAUNCHER_FILENAME = "launcher.sh";
|
|
13
14
|
const MODULE_BUILD_ROOT = "/run/build";
|
|
14
15
|
const RUNTIME_PREFIX = "/app";
|
|
@@ -64,29 +65,37 @@ const iconInstallCommands = (settings) => {
|
|
|
64
65
|
}
|
|
65
66
|
return listFilesRecursive(iconsDir).map((icon) => iconInstallCommand(settings, icon.absPath, icon.rel));
|
|
66
67
|
};
|
|
68
|
+
const moduleDirFor = (settings) => `${MODULE_BUILD_ROOT}/${settings.binaryName}`;
|
|
67
69
|
const offlineEnvFor = (manager, settings) => {
|
|
68
|
-
|
|
70
|
+
if (manager === "pnpm") {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
69
73
|
if (manager === "yarn") {
|
|
70
|
-
return { YARN_OFFLINE_MIRROR: `${
|
|
74
|
+
return { YARN_OFFLINE_MIRROR: `${moduleDirFor(settings)}/${YARN_MIRROR_DIR}` };
|
|
71
75
|
}
|
|
72
|
-
return { npm_config_cache: `${
|
|
76
|
+
return { npm_config_cache: `${moduleDirFor(settings)}/${NPM_CACHE_DIR}`, npm_config_offline: "true" };
|
|
73
77
|
};
|
|
78
|
+
const appendPathFor = (settings, pin, nodeExtensionPath) => pin === null
|
|
79
|
+
? `${nodeExtensionPath}/bin`
|
|
80
|
+
: `${pnpmPathFor(moduleDirFor(settings))}:${nodeExtensionPath}/bin`;
|
|
74
81
|
const flatpakSourceModule = (payload) => {
|
|
75
82
|
const settings = payload.settings;
|
|
76
83
|
const manager = detectPackageManager(settings);
|
|
84
|
+
const pin = pnpmPinFor(settings, manager);
|
|
77
85
|
const postInstall = postInstallCommands(payload);
|
|
78
86
|
const nodeExtensionPath = nodeExtensionPathFor(settings);
|
|
79
87
|
return {
|
|
80
88
|
name: settings.binaryName,
|
|
81
89
|
buildsystem: "simple",
|
|
82
90
|
"build-options": {
|
|
83
|
-
"append-path":
|
|
91
|
+
"append-path": appendPathFor(settings, pin, nodeExtensionPath),
|
|
84
92
|
env: { npm_config_nodedir: nodeExtensionPath, ...offlineEnvFor(manager, settings) },
|
|
85
93
|
strip: false,
|
|
86
94
|
"no-debuginfo": true,
|
|
87
95
|
},
|
|
88
96
|
sources: [
|
|
89
97
|
resolveGitSource(settings),
|
|
98
|
+
...(pin === null ? [] : pnpmSources(pin, moduleDirFor(settings))),
|
|
90
99
|
GENERATED_SOURCES,
|
|
91
100
|
inlineSource(`${settings.applicationId}.desktop`, renderDesktopEntry(settings)),
|
|
92
101
|
inlineSource(`${settings.applicationId}.metainfo.xml`, renderMetainfo(settings)),
|
|
@@ -94,7 +103,7 @@ const flatpakSourceModule = (payload) => {
|
|
|
94
103
|
...activationSource(settings),
|
|
95
104
|
],
|
|
96
105
|
"build-commands": [
|
|
97
|
-
installCommandFor(manager),
|
|
106
|
+
installCommandFor(settings, manager),
|
|
98
107
|
"npx gtkx build",
|
|
99
108
|
...runtimeInstallCommands(settings, nodeExtensionPath),
|
|
100
109
|
...metadataInstallCommands(settings),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatpak-source.js","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAsB,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACjH,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EAEpB,gBAAgB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,iBAAiB,GAAG,aAAa,CAAC;AACxC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,cAAc,GAAG,MAAM,CAAC;AAC9B,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAC/C,MAAM,eAAe,GAAG,0BAA0B,CAAC;A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EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;YACzD,GAAG,gBAAgB,CAAC,QAAQ,CAAC;SAChC;QACD,gBAAgB,EAAE;YACd,iBAAiB,CAAC,OAAO,CAAC;YAC1B,gBAAgB;YAChB,GAAG,sBAAsB,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACtD,GAAG,uBAAuB,CAAC,QAAQ,CAAC;YACpC,GAAG,qBAAqB,CAAC,QAAQ,CAAC;YAClC,GAAG,mBAAmB,CAAC,QAAQ,CAAC;YAChC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,IAAI,EAAE,CAAC;YACjD,GAAG,kBAAkB,CAAC,QAAQ,CAAC;SAClC;QACD,GAAG,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;KAClF,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["import { posix, relative } from \"node:path\";\nimport type { DeployPayload, DeploySettings } from \"../types.js\";\nimport { listFilesRecursive } from \"../../internal/list-files.js\";\nimport { BUNDLE_FILENAME } from \"../../vite-plugins/esm-extension.js\";\nimport { renderDbusService } from \"../freedesktop/dbus-service.js\";\nimport { renderDesktopEntry } from \"../freedesktop/desktop-entry.js\";\nimport { renderMetainfo } from \"../freedesktop/metainfo.js\";\nimport { optional } from \"../nfpm/optional.js\";\nimport { iconPathFor } from \"../payload/icons.js\";\nimport { renderLauncher } from \"../payload/launcher.js\";\nimport { DESTINATION, type FlatpakModule, postInstallCommands, validationCommands } from \"./flatpak-prebuilt.js\";\nimport {\n detectPackageManager,\n GENERATED_SOURCES,\n installCommandFor,\n nodeExtensionPathFor,\n type PackageManager,\n resolveGitSource,\n} from \"./flatpak-sources.js\";\n\nconst LAUNCHER_FILENAME = \"launcher.sh\";\nconst MODULE_BUILD_ROOT = \"/run/build\";\nconst RUNTIME_PREFIX = \"/app\";\nconst NPM_CACHE_DIR = \"flatpak-node/npm-cache\";\nconst YARN_MIRROR_DIR = \"flatpak-node/yarn-mirror\";\nconst PLAIN_ARGUMENT = /^[\\w./-]+$/;\nconst QUOTE_ESCAPE = String.raw`'\\''`;\n\nconst inlineSource = (fileName: string, contents: string): FlatpakModule => ({\n type: \"inline\",\n \"dest-filename\": fileName,\n contents,\n});\n\nconst projectRelative = (settings: DeploySettings, path: string): string =>\n relative(settings.paths.root, path).replaceAll(\"\\\\\", \"/\");\n\nconst shellArgument = (value: string): string =>\n PLAIN_ARGUMENT.test(value) ? value : `'${value.split(\"'\").join(QUOTE_ESCAPE)}'`;\n\nconst pathArgument = (value: string): string => shellArgument(value.startsWith(\"-\") ? `./${value}` : value);\n\nconst installCommand = (source: string, destination: string, mode: string): string =>\n `install -D${mode} ${pathArgument(source)} ${destination}`;\n\nconst runtimeInstallCommands = (settings: DeploySettings, nodeExtensionPath: string): string[] => {\n const lib = `${DESTINATION}/lib/${settings.binaryName}`;\n\n return [\n installCommand(`${nodeExtensionPath}/bin/node`, `${lib}/node`, \"m755\"),\n installCommand(`dist/${BUNDLE_FILENAME}`, `${lib}/${BUNDLE_FILENAME}`, \"m644\"),\n installCommand(\"dist/gtkx.node\", `${lib}/gtkx.node`, \"m755\"),\n \"test ! -f dist/gtkx.gresource || \" + installCommand(\"dist/gtkx.gresource\", `${lib}/gtkx.gresource`, \"m644\"),\n \"test ! -f dist/gschemas.compiled || \" +\n installCommand(\"dist/gschemas.compiled\", `${lib}/gschemas.compiled`, \"m644\"),\n `test ! -d dist/assets || cp -a dist/assets ${lib}/assets`,\n installCommand(LAUNCHER_FILENAME, `${DESTINATION}/bin/${settings.binaryName}`, \"m755\"),\n ];\n};\n\nconst activationSource = (settings: DeploySettings): FlatpakModule[] =>\n settings.isDbusActivatable\n ? [inlineSource(`${settings.applicationId}.service`, renderDbusService(settings, RUNTIME_PREFIX))]\n : [];\n\nconst activationInstallCommands = (settings: DeploySettings): string[] =>\n settings.isDbusActivatable\n ? [installCommand(\n `${settings.applicationId}.service`,\n `${DESTINATION}/share/dbus-1/services/${settings.applicationId}.service`,\n \"m644\",\n )]\n : [];\n\nconst metadataInstallCommands = (settings: DeploySettings): string[] => [\n installCommand(\n `${settings.applicationId}.desktop`,\n `${DESTINATION}/share/applications/${settings.applicationId}.desktop`,\n \"m644\",\n ),\n installCommand(\n `${settings.applicationId}.metainfo.xml`,\n `${DESTINATION}/share/metainfo/${settings.applicationId}.metainfo.xml`,\n \"m644\",\n ),\n ...activationInstallCommands(settings),\n];\n\nconst schemaInstallCommands = (settings: DeploySettings): string[] =>\n settings.paths.schemaFiles.map((file) => {\n const name = posix.basename(file);\n\n return installCommand(\n projectRelative(settings, file),\n `${DESTINATION}/share/glib-2.0/schemas/${shellArgument(name)}`,\n \"m644\",\n );\n });\n\nconst iconInstallCommand = (settings: DeploySettings, source: string, rel: string): string =>\n installCommand(\n projectRelative(settings, source),\n `${DESTINATION}/share/icons/${shellArgument(rel.replaceAll(\"\\\\\", \"/\"))}`,\n \"m644\",\n );\n\nconst iconInstallCommands = (settings: DeploySettings): string[] => {\n const { iconsDir, iconFile } = settings.paths;\n\n if (iconFile !== null) {\n return [iconInstallCommand(settings, iconFile, iconPathFor(settings, iconFile))];\n }\n\n if (iconsDir === null) {\n return [];\n }\n\n return listFilesRecursive(iconsDir).map((icon) => iconInstallCommand(settings, icon.absPath, icon.rel));\n};\n\nconst offlineEnvFor = (manager: PackageManager, settings: DeploySettings): Record<string, string> => {\n const moduleDir = `${MODULE_BUILD_ROOT}/${settings.binaryName}`;\n\n if (manager === \"yarn\") {\n return { YARN_OFFLINE_MIRROR: `${moduleDir}/${YARN_MIRROR_DIR}` };\n }\n\n return { npm_config_cache: `${moduleDir}/${NPM_CACHE_DIR}`, npm_config_offline: \"true\" };\n};\n\nconst flatpakSourceModule = (payload: DeployPayload): FlatpakModule => {\n const settings = payload.settings;\n const manager = detectPackageManager(settings);\n const postInstall = postInstallCommands(payload);\n const nodeExtensionPath = nodeExtensionPathFor(settings);\n\n return {\n name: settings.binaryName,\n buildsystem: \"simple\",\n \"build-options\": {\n \"append-path\": `${nodeExtensionPath}/bin`,\n env: { npm_config_nodedir: nodeExtensionPath, ...offlineEnvFor(manager, settings) },\n strip: false,\n \"no-debuginfo\": true,\n },\n sources: [\n resolveGitSource(settings),\n GENERATED_SOURCES,\n inlineSource(`${settings.applicationId}.desktop`, renderDesktopEntry(settings)),\n inlineSource(`${settings.applicationId}.metainfo.xml`, renderMetainfo(settings)),\n inlineSource(LAUNCHER_FILENAME, renderLauncher(settings)),\n ...activationSource(settings),\n ],\n \"build-commands\": [\n installCommandFor(manager),\n \"npx gtkx build\",\n ...runtimeInstallCommands(settings, nodeExtensionPath),\n ...metadataInstallCommands(settings),\n ...schemaInstallCommands(settings),\n ...iconInstallCommands(settings),\n ...(settings.deploy.flatpak?.buildCommands ?? []),\n ...validationCommands(settings),\n ],\n ...optional(\"post-install\", postInstall.length === 0 ? undefined : postInstall),\n };\n};\n\nexport { flatpakSourceModule };\n"]}
|
|
1
|
+
{"version":3,"file":"flatpak-source.js","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAw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CAAC;YACpC,gBAAgB;YAChB,GAAG,sBAAsB,CAAC,QAAQ,EAAE,iBAAiB,CAAC;YACtD,GAAG,uBAAuB,CAAC,QAAQ,CAAC;YACpC,GAAG,qBAAqB,CAAC,QAAQ,CAAC;YAClC,GAAG,mBAAmB,CAAC,QAAQ,CAAC;YAChC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,IAAI,EAAE,CAAC;YACjD,GAAG,kBAAkB,CAAC,QAAQ,CAAC;SAClC;QACD,GAAG,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;KAClF,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC","sourcesContent":["import { posix, relative } from \"node:path\";\nimport type { DeployPayload, DeploySettings } from \"../types.js\";\nimport { listFilesRecursive } from \"../../internal/list-files.js\";\nimport { BUNDLE_FILENAME } from \"../../vite-plugins/esm-extension.js\";\nimport { renderDbusService } from \"../freedesktop/dbus-service.js\";\nimport { renderDesktopEntry } from \"../freedesktop/desktop-entry.js\";\nimport { renderMetainfo } from \"../freedesktop/metainfo.js\";\nimport { optional } from \"../nfpm/optional.js\";\nimport { iconPathFor } from \"../payload/icons.js\";\nimport { renderLauncher } from \"../payload/launcher.js\";\nimport { pnpmPathFor, type PnpmPin, pnpmSources } from \"./flatpak-pnpm.js\";\nimport { DESTINATION, type FlatpakModule, postInstallCommands, validationCommands } from \"./flatpak-prebuilt.js\";\nimport {\n detectPackageManager,\n GENERATED_SOURCES,\n installCommandFor,\n nodeExtensionPathFor,\n type PackageManager,\n pnpmPinFor,\n resolveGitSource,\n} from \"./flatpak-sources.js\";\n\nconst LAUNCHER_FILENAME = \"launcher.sh\";\nconst MODULE_BUILD_ROOT = \"/run/build\";\nconst RUNTIME_PREFIX = \"/app\";\nconst NPM_CACHE_DIR = \"flatpak-node/npm-cache\";\nconst YARN_MIRROR_DIR = \"flatpak-node/yarn-mirror\";\nconst PLAIN_ARGUMENT = /^[\\w./-]+$/;\nconst QUOTE_ESCAPE = String.raw`'\\''`;\n\nconst inlineSource = (fileName: string, contents: string): FlatpakModule => ({\n type: \"inline\",\n \"dest-filename\": fileName,\n contents,\n});\n\nconst projectRelative = (settings: DeploySettings, path: string): string =>\n relative(settings.paths.root, path).replaceAll(\"\\\\\", \"/\");\n\nconst shellArgument = (value: string): string =>\n PLAIN_ARGUMENT.test(value) ? value : `'${value.split(\"'\").join(QUOTE_ESCAPE)}'`;\n\nconst pathArgument = (value: string): string => shellArgument(value.startsWith(\"-\") ? `./${value}` : value);\n\nconst installCommand = (source: string, destination: string, mode: string): string =>\n `install -D${mode} ${pathArgument(source)} ${destination}`;\n\nconst runtimeInstallCommands = (settings: DeploySettings, nodeExtensionPath: string): string[] => {\n const lib = `${DESTINATION}/lib/${settings.binaryName}`;\n\n return [\n installCommand(`${nodeExtensionPath}/bin/node`, `${lib}/node`, \"m755\"),\n installCommand(`dist/${BUNDLE_FILENAME}`, `${lib}/${BUNDLE_FILENAME}`, \"m644\"),\n installCommand(\"dist/gtkx.node\", `${lib}/gtkx.node`, \"m755\"),\n \"test ! -f dist/gtkx.gresource || \" + installCommand(\"dist/gtkx.gresource\", `${lib}/gtkx.gresource`, \"m644\"),\n \"test ! -f dist/gschemas.compiled || \" +\n installCommand(\"dist/gschemas.compiled\", `${lib}/gschemas.compiled`, \"m644\"),\n `test ! -d dist/assets || cp -a dist/assets ${lib}/assets`,\n installCommand(LAUNCHER_FILENAME, `${DESTINATION}/bin/${settings.binaryName}`, \"m755\"),\n ];\n};\n\nconst activationSource = (settings: DeploySettings): FlatpakModule[] =>\n settings.isDbusActivatable\n ? [inlineSource(`${settings.applicationId}.service`, renderDbusService(settings, RUNTIME_PREFIX))]\n : [];\n\nconst activationInstallCommands = (settings: DeploySettings): string[] =>\n settings.isDbusActivatable\n ? [installCommand(\n `${settings.applicationId}.service`,\n `${DESTINATION}/share/dbus-1/services/${settings.applicationId}.service`,\n \"m644\",\n )]\n : [];\n\nconst metadataInstallCommands = (settings: DeploySettings): string[] => [\n installCommand(\n `${settings.applicationId}.desktop`,\n `${DESTINATION}/share/applications/${settings.applicationId}.desktop`,\n \"m644\",\n ),\n installCommand(\n `${settings.applicationId}.metainfo.xml`,\n `${DESTINATION}/share/metainfo/${settings.applicationId}.metainfo.xml`,\n \"m644\",\n ),\n ...activationInstallCommands(settings),\n];\n\nconst schemaInstallCommands = (settings: DeploySettings): string[] =>\n settings.paths.schemaFiles.map((file) => {\n const name = posix.basename(file);\n\n return installCommand(\n projectRelative(settings, file),\n `${DESTINATION}/share/glib-2.0/schemas/${shellArgument(name)}`,\n \"m644\",\n );\n });\n\nconst iconInstallCommand = (settings: DeploySettings, source: string, rel: string): string =>\n installCommand(\n projectRelative(settings, source),\n `${DESTINATION}/share/icons/${shellArgument(rel.replaceAll(\"\\\\\", \"/\"))}`,\n \"m644\",\n );\n\nconst iconInstallCommands = (settings: DeploySettings): string[] => {\n const { iconsDir, iconFile } = settings.paths;\n\n if (iconFile !== null) {\n return [iconInstallCommand(settings, iconFile, iconPathFor(settings, iconFile))];\n }\n\n if (iconsDir === null) {\n return [];\n }\n\n return listFilesRecursive(iconsDir).map((icon) => iconInstallCommand(settings, icon.absPath, icon.rel));\n};\n\nconst moduleDirFor = (settings: DeploySettings): string => `${MODULE_BUILD_ROOT}/${settings.binaryName}`;\n\nconst offlineEnvFor = (manager: PackageManager, settings: DeploySettings): Record<string, string> => {\n if (manager === \"pnpm\") {\n return {};\n }\n\n if (manager === \"yarn\") {\n return { YARN_OFFLINE_MIRROR: `${moduleDirFor(settings)}/${YARN_MIRROR_DIR}` };\n }\n\n return { npm_config_cache: `${moduleDirFor(settings)}/${NPM_CACHE_DIR}`, npm_config_offline: \"true\" };\n};\n\nconst appendPathFor = (settings: DeploySettings, pin: PnpmPin | null, nodeExtensionPath: string): string =>\n pin === null\n ? `${nodeExtensionPath}/bin`\n : `${pnpmPathFor(moduleDirFor(settings))}:${nodeExtensionPath}/bin`;\n\nconst flatpakSourceModule = (payload: DeployPayload): FlatpakModule => {\n const settings = payload.settings;\n const manager = detectPackageManager(settings);\n const pin = pnpmPinFor(settings, manager);\n const postInstall = postInstallCommands(payload);\n const nodeExtensionPath = nodeExtensionPathFor(settings);\n\n return {\n name: settings.binaryName,\n buildsystem: \"simple\",\n \"build-options\": {\n \"append-path\": appendPathFor(settings, pin, nodeExtensionPath),\n env: { npm_config_nodedir: nodeExtensionPath, ...offlineEnvFor(manager, settings) },\n strip: false,\n \"no-debuginfo\": true,\n },\n sources: [\n resolveGitSource(settings),\n ...(pin === null ? [] : pnpmSources(pin, moduleDirFor(settings))),\n GENERATED_SOURCES,\n inlineSource(`${settings.applicationId}.desktop`, renderDesktopEntry(settings)),\n inlineSource(`${settings.applicationId}.metainfo.xml`, renderMetainfo(settings)),\n inlineSource(LAUNCHER_FILENAME, renderLauncher(settings)),\n ...activationSource(settings),\n ],\n \"build-commands\": [\n installCommandFor(settings, manager),\n \"npx gtkx build\",\n ...runtimeInstallCommands(settings, nodeExtensionPath),\n ...metadataInstallCommands(settings),\n ...schemaInstallCommands(settings),\n ...iconInstallCommands(settings),\n ...(settings.deploy.flatpak?.buildCommands ?? []),\n ...validationCommands(settings),\n ],\n ...optional(\"post-install\", postInstall.length === 0 ? undefined : postInstall),\n };\n};\n\nexport { flatpakSourceModule };\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DeploySettings } from "../types.js";
|
|
2
|
+
import { type PnpmPin } from "./flatpak-pnpm.js";
|
|
2
3
|
type PackageManager = "npm" | "pnpm" | "yarn";
|
|
3
4
|
type GitSource = {
|
|
4
5
|
type: "git";
|
|
@@ -8,10 +9,11 @@ type GitSource = {
|
|
|
8
9
|
};
|
|
9
10
|
declare const GENERATED_SOURCES = "generated-sources.json";
|
|
10
11
|
declare const detectPackageManager: (settings: DeploySettings) => PackageManager;
|
|
11
|
-
declare const
|
|
12
|
+
declare const pnpmPinFor: (settings: DeploySettings, manager: PackageManager) => PnpmPin | null;
|
|
13
|
+
declare const installCommandFor: (settings: DeploySettings, manager: PackageManager) => string;
|
|
12
14
|
declare const nodeExtensionFor: (settings: DeploySettings) => string;
|
|
13
15
|
declare const nodeExtensionPathFor: (settings: DeploySettings) => string;
|
|
14
16
|
declare const resolveGitSource: (settings: DeploySettings) => GitSource;
|
|
15
|
-
declare const generateNodeSources: (settings: DeploySettings, manager: PackageManager) => void;
|
|
16
|
-
export { detectPackageManager, GENERATED_SOURCES, generateNodeSources, installCommandFor, nodeExtensionFor, nodeExtensionPathFor, type PackageManager, resolveGitSource, };
|
|
17
|
+
declare const generateNodeSources: (settings: DeploySettings, manager: PackageManager, pin: PnpmPin | null) => void;
|
|
18
|
+
export { detectPackageManager, GENERATED_SOURCES, generateNodeSources, installCommandFor, nodeExtensionFor, nodeExtensionPathFor, type PackageManager, pnpmPinFor, resolveGitSource, };
|
|
17
19
|
//# sourceMappingURL=flatpak-sources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatpak-sources.d.ts","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak-sources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,KAAK,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"flatpak-sources.d.ts","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak-sources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,EAAsB,KAAK,OAAO,EAAuC,MAAM,mBAAmB,CAAC;AAE1G,KAAK,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAG9C,KAAK,SAAS,GAAG;IACb,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAOF,QAAA,MAAM,iBAAiB,2BAA2B,CAAC;AAkBnD,QAAA,MAAM,oBAAoB,GAAI,UAAU,cAAc,KAAG,cAkBxD,CAAC;AAEF,QAAA,MAAM,UAAU,GAAI,UAAU,cAAc,EAAE,SAAS,cAAc,KAAG,OAAO,GAAG,IAC1B,CAAC;AAEzD,QAAA,MAAM,iBAAiB,GAAI,UAAU,cAAc,EAAE,SAAS,cAAc,KAAG,MACiB,CAAC;AAEjG,QAAA,MAAM,gBAAgB,GAAI,UAAU,cAAc,KAAG,MACe,CAAC;AAErE,QAAA,MAAM,oBAAoB,GAAI,UAAU,cAAc,KAAG,MAWxD,CAAC;AA2DF,QAAA,MAAM,gBAAgB,GAAI,UAAU,cAAc,KAAG,SAInD,CAAC;AAuBH,QAAA,MAAM,mBAAmB,GAAI,UAAU,cAAc,EAAE,SAAS,cAAc,EAAE,KAAK,OAAO,GAAG,IAAI,KAAG,IAgBrG,CAAC;AAEF,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,cAAc,EACnB,UAAU,EACV,gBAAgB,GACnB,CAAC"}
|
|
@@ -4,8 +4,10 @@ import { basename, dirname, join } from "node:path";
|
|
|
4
4
|
import { runCliTool } from "../../internal/run-cli-tool.js";
|
|
5
5
|
import { gitRemoteUrl, runGit } from "../git.js";
|
|
6
6
|
import { optional } from "../nfpm/optional.js";
|
|
7
|
+
import { FLATPAK_NODE_GENERATOR, GENERATOR_PNPM_OPTION } from "../tools.js";
|
|
8
|
+
import { pnpmInstallCommand, pnpmStoreVersionFor, resolvePnpmPin } from "./flatpak-pnpm.js";
|
|
7
9
|
const GENERATED_SOURCES = "generated-sources.json";
|
|
8
|
-
const
|
|
10
|
+
const COMMIT_PEEL = "^{commit}";
|
|
9
11
|
const FETCHABLE_URL = /^https?:\/\//;
|
|
10
12
|
const DEFAULT_NODE_EXTENSION = "org.freedesktop.Sdk.Extension.node24";
|
|
11
13
|
const NODE_EXTENSION_PREFIX = "org.freedesktop.Sdk.Extension.";
|
|
@@ -17,7 +19,6 @@ const LOCKFILE_BY_MANAGER = {
|
|
|
17
19
|
};
|
|
18
20
|
const INSTALL_COMMAND = {
|
|
19
21
|
npm: "npm ci --offline",
|
|
20
|
-
pnpm: "pnpm install --offline --frozen-lockfile",
|
|
21
22
|
yarn: "yarn install --offline",
|
|
22
23
|
};
|
|
23
24
|
const detectPackageManager = (settings) => {
|
|
@@ -33,7 +34,8 @@ const detectPackageManager = (settings) => {
|
|
|
33
34
|
}
|
|
34
35
|
return found;
|
|
35
36
|
};
|
|
36
|
-
const
|
|
37
|
+
const pnpmPinFor = (settings, manager) => manager === "pnpm" ? resolvePnpmPin(settings) : null;
|
|
38
|
+
const installCommandFor = (settings, manager) => manager === "pnpm" ? pnpmInstallCommand(resolvePnpmPin(settings)) : INSTALL_COMMAND[manager];
|
|
37
39
|
const nodeExtensionFor = (settings) => settings.deploy.flatpak?.nodeExtension ?? DEFAULT_NODE_EXTENSION;
|
|
38
40
|
const nodeExtensionPathFor = (settings) => {
|
|
39
41
|
const extension = nodeExtensionFor(settings);
|
|
@@ -56,12 +58,23 @@ const resolveSourceUrl = (settings) => {
|
|
|
56
58
|
}
|
|
57
59
|
return url;
|
|
58
60
|
};
|
|
61
|
+
const commitForTag = (root, tag) => {
|
|
62
|
+
const commit = runGit(root, ["rev-parse", `${tag}${COMMIT_PEEL}`]);
|
|
63
|
+
if (commit === null) {
|
|
64
|
+
throw new Error(`Cannot pin the Flathub source to "${tag}": Flathub builds a fixed tree, not a movable tag, and that ` +
|
|
65
|
+
`tag does not resolve in ${root}. Create or fetch it, or set \`deploy.flatpak.source.commit\`.`);
|
|
66
|
+
}
|
|
67
|
+
return commit;
|
|
68
|
+
};
|
|
59
69
|
const configuredRevision = (settings) => {
|
|
60
70
|
const source = settings.deploy.flatpak?.source ?? {};
|
|
61
71
|
if (source.commit !== undefined) {
|
|
62
72
|
return { ...optional("tag", source.tag), commit: source.commit };
|
|
63
73
|
}
|
|
64
|
-
|
|
74
|
+
if (source.tag === undefined) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return { tag: source.tag, commit: commitForTag(settings.paths.root, source.tag) };
|
|
65
78
|
};
|
|
66
79
|
const workingTreeRevision = (settings) => {
|
|
67
80
|
const root = settings.paths.root;
|
|
@@ -87,16 +100,17 @@ const isolateLockfile = (root, lockfile) => {
|
|
|
87
100
|
copyFileSync(source, join(dir, basename(lockfile)));
|
|
88
101
|
return dir;
|
|
89
102
|
};
|
|
90
|
-
const
|
|
103
|
+
const storeVersionArgs = (pin) => pin === null ? [] : [GENERATOR_PNPM_OPTION, pnpmStoreVersionFor(pin)];
|
|
104
|
+
const generateNodeSources = (settings, manager, pin) => {
|
|
91
105
|
const lockfile = settings.deploy.flatpak?.lockfile ?? LOCKFILE_BY_MANAGER[manager];
|
|
92
106
|
const output = generatedSourcesPath(settings);
|
|
93
107
|
mkdirSync(dirname(output), { recursive: true });
|
|
94
108
|
const isolated = isolateLockfile(settings.paths.root, lockfile);
|
|
95
109
|
try {
|
|
96
110
|
runCliTool({
|
|
97
|
-
tool:
|
|
98
|
-
args: [manager, join(isolated, basename(lockfile)), "-o", output],
|
|
99
|
-
target: "the offline
|
|
111
|
+
tool: FLATPAK_NODE_GENERATOR.command,
|
|
112
|
+
args: [manager, join(isolated, basename(lockfile)), ...storeVersionArgs(pin), "-o", output],
|
|
113
|
+
target: "the offline dependency sources",
|
|
100
114
|
shouldStream: true,
|
|
101
115
|
});
|
|
102
116
|
}
|
|
@@ -104,5 +118,5 @@ const generateNodeSources = (settings, manager) => {
|
|
|
104
118
|
rmSync(isolated, { recursive: true, force: true, maxRetries: 5 });
|
|
105
119
|
}
|
|
106
120
|
};
|
|
107
|
-
export { detectPackageManager, GENERATED_SOURCES, generateNodeSources, installCommandFor, nodeExtensionFor, nodeExtensionPathFor, resolveGitSource, };
|
|
121
|
+
export { detectPackageManager, GENERATED_SOURCES, generateNodeSources, installCommandFor, nodeExtensionFor, nodeExtensionPathFor, pnpmPinFor, resolveGitSource, };
|
|
108
122
|
//# sourceMappingURL=flatpak-sources.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatpak-sources.js","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAgB/C,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AACnD,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAC3C,MAAM,aAAa,GAAG,cAAc,CAAC;AACrC,MAAM,sBAAsB,GAAG,sCAAsC,CAAC;AACtE,MAAM,qBAAqB,GAAG,gCAAgC,CAAC;AAC/D,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAE1C,MAAM,mBAAmB,GAAmC;IACxD,GAAG,EAAE,mBAAmB;IACxB,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,WAAW;CACpB,CAAC;AAEF,MAAM,eAAe,GAAmC;IACpD,GAAG,EAAE,kBAAkB;IACvB,IAAI,EAAE,0CAA0C;IAChD,IAAI,EAAE,wBAAwB;CACjC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,QAAwB,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,GAAG,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,QAAwB,EAAE,OAAuB,EAAQ,EAAE;IACpF,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC9C,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEhE,IAAI,CAAC;QACD,UAAU,CAAC;YACP,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC;YACjE,MAAM,EAAE,yBAAyB;YACjC,YAAY,EAAE,IAAI;SACrB,CAAC,CAAC;IACP,CAAC;YAAS,CAAC;QACP,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EAEpB,gBAAgB,GACnB,CAAC","sourcesContent":["import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join } from \"node:path\";\nimport type { DeploySettings } from \"../types.js\";\nimport { runCliTool } from \"../../internal/run-cli-tool.js\";\nimport { gitRemoteUrl, runGit } from \"../git.js\";\nimport { optional } from \"../nfpm/optional.js\";\n\ntype PackageManager = \"npm\" | \"pnpm\" | \"yarn\";\n\ntype GitSource = {\n type: \"git\";\n url: string;\n tag?: string;\n commit?: string;\n};\n\ntype GitRevision = {\n tag?: string;\n commit?: string;\n};\n\nconst GENERATED_SOURCES = \"generated-sources.json\";\nconst GENERATOR = \"flatpak-node-generator\";\nconst FETCHABLE_URL = /^https?:\\/\\//;\nconst DEFAULT_NODE_EXTENSION = \"org.freedesktop.Sdk.Extension.node24\";\nconst NODE_EXTENSION_PREFIX = \"org.freedesktop.Sdk.Extension.\";\nconst SDK_EXTENSION_ROOT = \"/usr/lib/sdk\";\n\nconst LOCKFILE_BY_MANAGER: Record<PackageManager, string> = {\n npm: \"package-lock.json\",\n pnpm: \"pnpm-lock.yaml\",\n yarn: \"yarn.lock\",\n};\n\nconst INSTALL_COMMAND: Record<PackageManager, string> = {\n npm: \"npm ci --offline\",\n pnpm: \"pnpm install --offline --frozen-lockfile\",\n yarn: \"yarn install --offline\",\n};\n\nconst detectPackageManager = (settings: DeploySettings): PackageManager => {\n const configured = settings.deploy.flatpak?.packageManager;\n\n if (configured !== undefined) {\n return configured;\n }\n\n const found = ([\"pnpm\", \"yarn\", \"npm\"] as const)\n .find((manager) => existsSync(join(settings.paths.root, LOCKFILE_BY_MANAGER[manager])));\n\n if (found === undefined) {\n throw new Error(\n \"Cannot build a Flathub-ready manifest without a lockfile: the sandbox installs dependencies offline. \" +\n \"Commit a package-lock.json, pnpm-lock.yaml, or yarn.lock, or set `deploy.flatpak.packageManager`.\",\n );\n }\n\n return found;\n};\n\nconst installCommandFor = (manager: PackageManager): string => INSTALL_COMMAND[manager];\n\nconst nodeExtensionFor = (settings: DeploySettings): string =>\n settings.deploy.flatpak?.nodeExtension ?? DEFAULT_NODE_EXTENSION;\n\nconst nodeExtensionPathFor = (settings: DeploySettings): string => {\n const extension = nodeExtensionFor(settings);\n\n if (!extension.startsWith(NODE_EXTENSION_PREFIX)) {\n throw new Error(\n `Cannot resolve where \"${extension}\" mounts: the sandbox installs Node SDK extensions under ` +\n `${SDK_EXTENSION_ROOT}, so \\`deploy.flatpak.nodeExtension\\` has to be an ${NODE_EXTENSION_PREFIX}* id.`,\n );\n }\n\n return `${SDK_EXTENSION_ROOT}/${extension.slice(NODE_EXTENSION_PREFIX.length)}`;\n};\n\nconst resolveSourceUrl = (settings: DeploySettings): string => {\n const url = settings.deploy.flatpak?.source?.url ?? gitRemoteUrl(settings.paths.root);\n\n if (url === null) {\n throw new Error(\n \"Cannot build a Flathub-ready manifest without a public source: Flathub builds from a fetchable \" +\n \"repository, not from your working tree. Set `deploy.flatpak.source.url`.\",\n );\n }\n\n if (!FETCHABLE_URL.test(url)) {\n throw new Error(\n `Cannot build a Flathub-ready manifest from \"${url}\": Flathub's builders clone over HTTPS and have no ` +\n \"credentials, so an SSH remote never resolves there. Set `deploy.flatpak.source.url` to the \" +\n \"repository's https:// URL.\",\n );\n }\n\n return url;\n};\n\nconst configuredRevision = (settings: DeploySettings): GitRevision | null => {\n const source = settings.deploy.flatpak?.source ?? {};\n\n if (source.commit !== undefined) {\n return { ...optional(\"tag\", source.tag), commit: source.commit };\n }\n\n return source.tag === undefined ? null : { tag: source.tag };\n};\n\nconst workingTreeRevision = (settings: DeploySettings): GitRevision => {\n const root = settings.paths.root;\n\n return {\n ...optional(\"tag\", runGit(root, [\"describe\", \"--tags\", \"--exact-match\"]) ?? undefined),\n ...optional(\"commit\", runGit(root, [\"rev-parse\", \"HEAD\"]) ?? undefined),\n };\n};\n\nconst resolveGitSource = (settings: DeploySettings): GitSource => ({\n type: \"git\",\n url: resolveSourceUrl(settings),\n ...(configuredRevision(settings) ?? workingTreeRevision(settings)),\n});\n\nconst generatedSourcesPath = (settings: DeploySettings): string =>\n join(settings.paths.targets, \"flatpak\", GENERATED_SOURCES);\n\nconst isolateLockfile = (root: string, lockfile: string): string => {\n const source = join(root, lockfile);\n\n if (!existsSync(source)) {\n throw new Error(`Cannot vendor the offline sources: no ${lockfile} under ${root}`);\n }\n\n const manifest = join(dirname(source), \"package.json\");\n const dir = mkdtempSync(join(tmpdir(), \"gtkx-lockfile-\"));\n copyFileSync(existsSync(manifest) ? manifest : join(root, \"package.json\"), join(dir, \"package.json\"));\n copyFileSync(source, join(dir, basename(lockfile)));\n\n return dir;\n};\n\nconst generateNodeSources = (settings: DeploySettings, manager: PackageManager): void => {\n const lockfile = settings.deploy.flatpak?.lockfile ?? LOCKFILE_BY_MANAGER[manager];\n const output = generatedSourcesPath(settings);\n mkdirSync(dirname(output), { recursive: true });\n const isolated = isolateLockfile(settings.paths.root, lockfile);\n\n try {\n runCliTool({\n tool: GENERATOR,\n args: [manager, join(isolated, basename(lockfile)), \"-o\", output],\n target: \"the offline npm sources\",\n shouldStream: true,\n });\n } finally {\n rmSync(isolated, { recursive: true, force: true, maxRetries: 5 });\n }\n};\n\nexport {\n detectPackageManager,\n GENERATED_SOURCES,\n generateNodeSources,\n installCommandFor,\n nodeExtensionFor,\n nodeExtensionPathFor,\n type PackageManager,\n resolveGitSource,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"flatpak-sources.js","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAgB,mBAAmB,EAAE,cAAc,E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oBAAoB,EAEpB,UAAU,EACV,gBAAgB,GACnB,CAAC","sourcesContent":["import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, join } from \"node:path\";\nimport type { DeploySettings } from \"../types.js\";\nimport { runCliTool } from \"../../internal/run-cli-tool.js\";\nimport { gitRemoteUrl, runGit } from \"../git.js\";\nimport { optional } from \"../nfpm/optional.js\";\nimport { FLATPAK_NODE_GENERATOR, GENERATOR_PNPM_OPTION } from \"../tools.js\";\nimport { pnpmInstallCommand, type PnpmPin, pnpmStoreVersionFor, resolvePnpmPin } from \"./flatpak-pnpm.js\";\n\ntype PackageManager = \"npm\" | \"pnpm\" | \"yarn\";\ntype VendoredManager = Exclude<PackageManager, \"pnpm\">;\n\ntype GitSource = {\n type: \"git\";\n url: string;\n tag?: string;\n commit?: string;\n};\n\ntype GitRevision = {\n tag?: string;\n commit?: string;\n};\n\nconst GENERATED_SOURCES = \"generated-sources.json\";\nconst COMMIT_PEEL = \"^{commit}\";\nconst FETCHABLE_URL = /^https?:\\/\\//;\nconst DEFAULT_NODE_EXTENSION = \"org.freedesktop.Sdk.Extension.node24\";\nconst NODE_EXTENSION_PREFIX = \"org.freedesktop.Sdk.Extension.\";\nconst SDK_EXTENSION_ROOT = \"/usr/lib/sdk\";\n\nconst LOCKFILE_BY_MANAGER: Record<PackageManager, string> = {\n npm: \"package-lock.json\",\n pnpm: \"pnpm-lock.yaml\",\n yarn: \"yarn.lock\",\n};\n\nconst INSTALL_COMMAND: Record<VendoredManager, string> = {\n npm: \"npm ci --offline\",\n yarn: \"yarn install --offline\",\n};\n\nconst detectPackageManager = (settings: DeploySettings): PackageManager => {\n const configured = settings.deploy.flatpak?.packageManager;\n\n if (configured !== undefined) {\n return configured;\n }\n\n const found = ([\"pnpm\", \"yarn\", \"npm\"] as const)\n .find((manager) => existsSync(join(settings.paths.root, LOCKFILE_BY_MANAGER[manager])));\n\n if (found === undefined) {\n throw new Error(\n \"Cannot build a Flathub-ready manifest without a lockfile: the sandbox installs dependencies offline. \" +\n \"Commit a package-lock.json, pnpm-lock.yaml, or yarn.lock, or set `deploy.flatpak.packageManager`.\",\n );\n }\n\n return found;\n};\n\nconst pnpmPinFor = (settings: DeploySettings, manager: PackageManager): PnpmPin | null =>\n manager === \"pnpm\" ? resolvePnpmPin(settings) : null;\n\nconst installCommandFor = (settings: DeploySettings, manager: PackageManager): string =>\n manager === \"pnpm\" ? pnpmInstallCommand(resolvePnpmPin(settings)) : INSTALL_COMMAND[manager];\n\nconst nodeExtensionFor = (settings: DeploySettings): string =>\n settings.deploy.flatpak?.nodeExtension ?? DEFAULT_NODE_EXTENSION;\n\nconst nodeExtensionPathFor = (settings: DeploySettings): string => {\n const extension = nodeExtensionFor(settings);\n\n if (!extension.startsWith(NODE_EXTENSION_PREFIX)) {\n throw new Error(\n `Cannot resolve where \"${extension}\" mounts: the sandbox installs Node SDK extensions under ` +\n `${SDK_EXTENSION_ROOT}, so \\`deploy.flatpak.nodeExtension\\` has to be an ${NODE_EXTENSION_PREFIX}* id.`,\n );\n }\n\n return `${SDK_EXTENSION_ROOT}/${extension.slice(NODE_EXTENSION_PREFIX.length)}`;\n};\n\nconst resolveSourceUrl = (settings: DeploySettings): string => {\n const url = settings.deploy.flatpak?.source?.url ?? gitRemoteUrl(settings.paths.root);\n\n if (url === null) {\n throw new Error(\n \"Cannot build a Flathub-ready manifest without a public source: Flathub builds from a fetchable \" +\n \"repository, not from your working tree. Set `deploy.flatpak.source.url`.\",\n );\n }\n\n if (!FETCHABLE_URL.test(url)) {\n throw new Error(\n `Cannot build a Flathub-ready manifest from \"${url}\": Flathub's builders clone over HTTPS and have no ` +\n \"credentials, so an SSH remote never resolves there. Set `deploy.flatpak.source.url` to the \" +\n \"repository's https:// URL.\",\n );\n }\n\n return url;\n};\n\nconst commitForTag = (root: string, tag: string): string => {\n const commit = runGit(root, [\"rev-parse\", `${tag}${COMMIT_PEEL}`]);\n\n if (commit === null) {\n throw new Error(\n `Cannot pin the Flathub source to \"${tag}\": Flathub builds a fixed tree, not a movable tag, and that ` +\n `tag does not resolve in ${root}. Create or fetch it, or set \\`deploy.flatpak.source.commit\\`.`,\n );\n }\n\n return commit;\n};\n\nconst configuredRevision = (settings: DeploySettings): GitRevision | null => {\n const source = settings.deploy.flatpak?.source ?? {};\n\n if (source.commit !== undefined) {\n return { ...optional(\"tag\", source.tag), commit: source.commit };\n }\n\n if (source.tag === undefined) {\n return null;\n }\n\n return { tag: source.tag, commit: commitForTag(settings.paths.root, source.tag) };\n};\n\nconst workingTreeRevision = (settings: DeploySettings): GitRevision => {\n const root = settings.paths.root;\n\n return {\n ...optional(\"tag\", runGit(root, [\"describe\", \"--tags\", \"--exact-match\"]) ?? undefined),\n ...optional(\"commit\", runGit(root, [\"rev-parse\", \"HEAD\"]) ?? undefined),\n };\n};\n\nconst resolveGitSource = (settings: DeploySettings): GitSource => ({\n type: \"git\",\n url: resolveSourceUrl(settings),\n ...(configuredRevision(settings) ?? workingTreeRevision(settings)),\n});\n\nconst generatedSourcesPath = (settings: DeploySettings): string =>\n join(settings.paths.targets, \"flatpak\", GENERATED_SOURCES);\n\nconst isolateLockfile = (root: string, lockfile: string): string => {\n const source = join(root, lockfile);\n\n if (!existsSync(source)) {\n throw new Error(`Cannot vendor the offline sources: no ${lockfile} under ${root}`);\n }\n\n const manifest = join(dirname(source), \"package.json\");\n const dir = mkdtempSync(join(tmpdir(), \"gtkx-lockfile-\"));\n copyFileSync(existsSync(manifest) ? manifest : join(root, \"package.json\"), join(dir, \"package.json\"));\n copyFileSync(source, join(dir, basename(lockfile)));\n\n return dir;\n};\n\nconst storeVersionArgs = (pin: PnpmPin | null): string[] =>\n pin === null ? [] : [GENERATOR_PNPM_OPTION, pnpmStoreVersionFor(pin)];\n\nconst generateNodeSources = (settings: DeploySettings, manager: PackageManager, pin: PnpmPin | null): void => {\n const lockfile = settings.deploy.flatpak?.lockfile ?? LOCKFILE_BY_MANAGER[manager];\n const output = generatedSourcesPath(settings);\n mkdirSync(dirname(output), { recursive: true });\n const isolated = isolateLockfile(settings.paths.root, lockfile);\n\n try {\n runCliTool({\n tool: FLATPAK_NODE_GENERATOR.command,\n args: [manager, join(isolated, basename(lockfile)), ...storeVersionArgs(pin), \"-o\", output],\n target: \"the offline dependency sources\",\n shouldStream: true,\n });\n } finally {\n rmSync(isolated, { recursive: true, force: true, maxRetries: 5 });\n }\n};\n\nexport {\n detectPackageManager,\n GENERATED_SOURCES,\n generateNodeSources,\n installCommandFor,\n nodeExtensionFor,\n nodeExtensionPathFor,\n type PackageManager,\n pnpmPinFor,\n resolveGitSource,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatpak.d.ts","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAiE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgB/G,QAAA,MAAM,aAAa,EAAE,YAMpB,CAAC;
|
|
1
|
+
{"version":3,"file":"flatpak.d.ts","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAiE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgB/G,QAAA,MAAM,aAAa,EAAE,YAMpB,CAAC;AAqHF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { stringify } from "yaml";
|
|
|
5
5
|
import { runCliTool } from "../../internal/run-cli-tool.js";
|
|
6
6
|
import { APPSTREAMCLI, DESKTOP_FILE_VALIDATE, FLATPAK, FLATPAK_BUILDER } from "../tools.js";
|
|
7
7
|
import { branchFor, renderFlatpakManifest } from "./flatpak-manifest.js";
|
|
8
|
-
import { detectPackageManager, generateNodeSources } from "./flatpak-sources.js";
|
|
8
|
+
import { detectPackageManager, generateNodeSources, pnpmPinFor } from "./flatpak-sources.js";
|
|
9
9
|
const PREFIX = "/app";
|
|
10
10
|
const TARGET_DIR = "flatpak";
|
|
11
11
|
const FLATHUB_REPO = "https://dl.flathub.org/repo/flathub.flatpakrepo";
|
|
@@ -29,7 +29,8 @@ const isSourceMode = (settings) => settings.deploy.flatpak?.mode === "source";
|
|
|
29
29
|
const renderManifests = (payload) => {
|
|
30
30
|
const settings = payload.settings;
|
|
31
31
|
if (isSourceMode(settings)) {
|
|
32
|
-
|
|
32
|
+
const manager = detectPackageManager(settings);
|
|
33
|
+
generateNodeSources(settings, manager, pnpmPinFor(settings, manager));
|
|
33
34
|
}
|
|
34
35
|
return [{
|
|
35
36
|
path: manifestPathFor(settings),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flatpak.js","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAOjF,MAAM,MAAM,GAAG,MAAM,CAAC;AACtB,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,YAAY,GAAG,iDAAiD,CAAC;AACvE,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C,MAAM,aAAa,GAAiB;IAChC,IAAI,EAAE,SAAS;IACf,MAAM,EAA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Aa,EAAE,CAAC","sourcesContent":["import { errorMessage, info, tryResolveExecutable } from \"@gtkx/utils\";\nimport { existsSync, mkdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { stringify } from \"yaml\";\nimport type { DeployArtifact, DeployManifest, DeployPayload, DeploySettings, DeployTarget } from \"../types.js\";\nimport { runCliTool } from \"../../internal/run-cli-tool.js\";\nimport { APPSTREAMCLI, DESKTOP_FILE_VALIDATE, FLATPAK, FLATPAK_BUILDER } from \"../tools.js\";\nimport { branchFor, renderFlatpakManifest } from \"./flatpak-manifest.js\";\nimport { detectPackageManager, generateNodeSources } from \"./flatpak-sources.js\";\n\ntype BuilderInvocation = {\n tool: string;\n prefix: string[];\n};\n\nconst PREFIX = \"/app\";\nconst TARGET_DIR = \"flatpak\";\nconst FLATHUB_REPO = \"https://dl.flathub.org/repo/flathub.flatpakrepo\";\nconst BUILDER_REF = \"org.flatpak.Builder\";\n\nconst flatpakTarget: DeployTarget = {\n name: \"flatpak\",\n prefix: PREFIX,\n tools: [FLATPAK, FLATPAK_BUILDER, DESKTOP_FILE_VALIDATE, APPSTREAMCLI],\n render: (payload) => renderManifests(payload),\n pack: (payload) => Promise.try(() => packFlatpak(payload)),\n};\n\nconst flatpakDir = (settings: DeploySettings): string => join(settings.paths.targets, TARGET_DIR);\n\nconst manifestPathFor = (settings: DeploySettings): string =>\n join(flatpakDir(settings), `${settings.applicationId}.yml`);\n\nconst resolveBuilder = (): BuilderInvocation => {\n if (tryResolveExecutable(FLATPAK_BUILDER.command) !== undefined) {\n return { tool: FLATPAK_BUILDER.command, prefix: [] };\n }\n\n return { tool: FLATPAK.command, prefix: [\"run\", BUILDER_REF] };\n};\n\nconst isSourceMode = (settings: DeploySettings): boolean => settings.deploy.flatpak?.mode === \"source\";\n\nconst renderManifests = (payload: DeployPayload): DeployManifest[] => {\n const settings = payload.settings;\n\n if (isSourceMode(settings)) {\n generateNodeSources(settings, detectPackageManager(settings));\n }\n\n return [{\n path: manifestPathFor(settings),\n contents: stringify(renderFlatpakManifest(payload), { lineWidth: 0 }),\n }];\n};\n\nconst builderArgsFor = (settings: DeploySettings, dir: string): string[] => [\n \"--force-clean\",\n \"--user\",\n \"--install-deps-from=flathub\",\n `--default-branch=${branchFor(settings)}`,\n ...(settings.deploy.flatpak?.shouldUseRofilesFuse === false ? [\"--disable-rofiles-fuse\"] : []),\n `--state-dir=${join(dir, \"state\")}`,\n `--repo=${join(dir, \"repo\")}`,\n join(dir, \"build\"),\n manifestPathFor(settings),\n];\n\nconst buildFlatpak = (settings: DeploySettings): void => {\n const dir = flatpakDir(settings);\n const builder = resolveBuilder();\n info(\"flatpak: running flatpak-builder, this can take several minutes\");\n\n try {\n runCliTool({\n tool: builder.tool,\n args: [...builder.prefix, ...builderArgsFor(settings, dir)],\n target: \"the flatpak\",\n shouldStream: true,\n });\n } catch (error) {\n throw new Error(\n `${errorMessage(error)}\\n\\nIf it stopped at \"Failure spawning rofiles-fuse\", the build is running ` +\n \"somewhere FUSE is unavailable, such as a container. Set `deploy.flatpak.shouldUseRofilesFuse: false` \" +\n \"to build without it.\",\n { cause: error },\n );\n }\n};\n\nconst bundleArgsFor = (settings: DeploySettings, target: string): string[] => {\n const signing = settings.deploy.signing?.flatpak;\n const runtimeRepo = settings.deploy.flatpak?.runtimeRepo ?? FLATHUB_REPO;\n\n return [\n \"build-bundle\",\n join(flatpakDir(settings), \"repo\"),\n target,\n settings.applicationId,\n branchFor(settings),\n `--arch=${settings.arch.flatpak}`,\n `--runtime-repo=${runtimeRepo}`,\n ...(signing === undefined ? [] : [`--gpg-sign=${signing.gpgKeyId}`]),\n ...(signing?.gpgHomeDir === undefined ? [] : [`--gpg-homedir=${signing.gpgHomeDir}`]),\n ];\n};\n\nconst bundleFlatpak = (settings: DeploySettings): DeployArtifact => {\n const output = settings.paths.output;\n mkdirSync(output, { recursive: true });\n const version = settings.versions.packageVersion;\n const target = join(output, `${settings.applicationId}-${version}-${settings.arch.flatpak}.flatpak`);\n runCliTool({ tool: FLATPAK.command, args: bundleArgsFor(settings, target), target: \"the flatpak bundle\" });\n\n if (!existsSync(target)) {\n throw new Error(`flatpak build-bundle reported success but wrote no bundle at ${target}`);\n }\n\n return { path: target, size: statSync(target).size };\n};\n\nconst installFlatpak = (settings: DeploySettings): void => {\n runCliTool({\n tool: FLATPAK.command,\n args: [\"install\", \"--user\", \"--noninteractive\", \"--reinstall\", join(flatpakDir(settings), \"repo\"),\n settings.applicationId],\n target: \"the flatpak\",\n shouldStream: true,\n });\n};\n\nconst packFlatpak = (payload: DeployPayload): DeployArtifact[] => {\n const settings = payload.settings;\n buildFlatpak(settings);\n\n if (settings.deploy.flatpak?.shouldInstall === true) {\n installFlatpak(settings);\n }\n\n return settings.deploy.flatpak?.shouldEmitBundle === false ? [] : [bundleFlatpak(settings)];\n};\n\nexport { flatpakTarget };\n"]}
|
|
1
|
+
{"version":3,"file":"flatpak.js","sourceRoot":"","sources":["../../../src/deploy/targets/flatpak.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAO7F,MAAM,MAAM,GAAG,MAAM,CAAC;AACtB,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,M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AAC,CAAC;IAC7B,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,gBAAgB,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChG,CAAC,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { errorMessage, info, tryResolveExecutable } from \"@gtkx/utils\";\nimport { existsSync, mkdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { stringify } from \"yaml\";\nimport type { DeployArtifact, DeployManifest, DeployPayload, DeploySettings, DeployTarget } from \"../types.js\";\nimport { runCliTool } from \"../../internal/run-cli-tool.js\";\nimport { APPSTREAMCLI, DESKTOP_FILE_VALIDATE, FLATPAK, FLATPAK_BUILDER } from \"../tools.js\";\nimport { branchFor, renderFlatpakManifest } from \"./flatpak-manifest.js\";\nimport { detectPackageManager, generateNodeSources, pnpmPinFor } from \"./flatpak-sources.js\";\n\ntype BuilderInvocation = {\n tool: string;\n prefix: string[];\n};\n\nconst PREFIX = \"/app\";\nconst TARGET_DIR = \"flatpak\";\nconst FLATHUB_REPO = \"https://dl.flathub.org/repo/flathub.flatpakrepo\";\nconst BUILDER_REF = \"org.flatpak.Builder\";\n\nconst flatpakTarget: DeployTarget = {\n name: \"flatpak\",\n prefix: PREFIX,\n tools: [FLATPAK, FLATPAK_BUILDER, DESKTOP_FILE_VALIDATE, APPSTREAMCLI],\n render: (payload) => renderManifests(payload),\n pack: (payload) => Promise.try(() => packFlatpak(payload)),\n};\n\nconst flatpakDir = (settings: DeploySettings): string => join(settings.paths.targets, TARGET_DIR);\n\nconst manifestPathFor = (settings: DeploySettings): string =>\n join(flatpakDir(settings), `${settings.applicationId}.yml`);\n\nconst resolveBuilder = (): BuilderInvocation => {\n if (tryResolveExecutable(FLATPAK_BUILDER.command) !== undefined) {\n return { tool: FLATPAK_BUILDER.command, prefix: [] };\n }\n\n return { tool: FLATPAK.command, prefix: [\"run\", BUILDER_REF] };\n};\n\nconst isSourceMode = (settings: DeploySettings): boolean => settings.deploy.flatpak?.mode === \"source\";\n\nconst renderManifests = (payload: DeployPayload): DeployManifest[] => {\n const settings = payload.settings;\n\n if (isSourceMode(settings)) {\n const manager = detectPackageManager(settings);\n generateNodeSources(settings, manager, pnpmPinFor(settings, manager));\n }\n\n return [{\n path: manifestPathFor(settings),\n contents: stringify(renderFlatpakManifest(payload), { lineWidth: 0 }),\n }];\n};\n\nconst builderArgsFor = (settings: DeploySettings, dir: string): string[] => [\n \"--force-clean\",\n \"--user\",\n \"--install-deps-from=flathub\",\n `--default-branch=${branchFor(settings)}`,\n ...(settings.deploy.flatpak?.shouldUseRofilesFuse === false ? [\"--disable-rofiles-fuse\"] : []),\n `--state-dir=${join(dir, \"state\")}`,\n `--repo=${join(dir, \"repo\")}`,\n join(dir, \"build\"),\n manifestPathFor(settings),\n];\n\nconst buildFlatpak = (settings: DeploySettings): void => {\n const dir = flatpakDir(settings);\n const builder = resolveBuilder();\n info(\"flatpak: running flatpak-builder, this can take several minutes\");\n\n try {\n runCliTool({\n tool: builder.tool,\n args: [...builder.prefix, ...builderArgsFor(settings, dir)],\n target: \"the flatpak\",\n shouldStream: true,\n });\n } catch (error) {\n throw new Error(\n `${errorMessage(error)}\\n\\nIf it stopped at \"Failure spawning rofiles-fuse\", the build is running ` +\n \"somewhere FUSE is unavailable, such as a container. Set `deploy.flatpak.shouldUseRofilesFuse: false` \" +\n \"to build without it.\",\n { cause: error },\n );\n }\n};\n\nconst bundleArgsFor = (settings: DeploySettings, target: string): string[] => {\n const signing = settings.deploy.signing?.flatpak;\n const runtimeRepo = settings.deploy.flatpak?.runtimeRepo ?? FLATHUB_REPO;\n\n return [\n \"build-bundle\",\n join(flatpakDir(settings), \"repo\"),\n target,\n settings.applicationId,\n branchFor(settings),\n `--arch=${settings.arch.flatpak}`,\n `--runtime-repo=${runtimeRepo}`,\n ...(signing === undefined ? [] : [`--gpg-sign=${signing.gpgKeyId}`]),\n ...(signing?.gpgHomeDir === undefined ? [] : [`--gpg-homedir=${signing.gpgHomeDir}`]),\n ];\n};\n\nconst bundleFlatpak = (settings: DeploySettings): DeployArtifact => {\n const output = settings.paths.output;\n mkdirSync(output, { recursive: true });\n const version = settings.versions.packageVersion;\n const target = join(output, `${settings.applicationId}-${version}-${settings.arch.flatpak}.flatpak`);\n runCliTool({ tool: FLATPAK.command, args: bundleArgsFor(settings, target), target: \"the flatpak bundle\" });\n\n if (!existsSync(target)) {\n throw new Error(`flatpak build-bundle reported success but wrote no bundle at ${target}`);\n }\n\n return { path: target, size: statSync(target).size };\n};\n\nconst installFlatpak = (settings: DeploySettings): void => {\n runCliTool({\n tool: FLATPAK.command,\n args: [\"install\", \"--user\", \"--noninteractive\", \"--reinstall\", join(flatpakDir(settings), \"repo\"),\n settings.applicationId],\n target: \"the flatpak\",\n shouldStream: true,\n });\n};\n\nconst packFlatpak = (payload: DeployPayload): DeployArtifact[] => {\n const settings = payload.settings;\n buildFlatpak(settings);\n\n if (settings.deploy.flatpak?.shouldInstall === true) {\n installFlatpak(settings);\n }\n\n return settings.deploy.flatpak?.shouldEmitBundle === false ? [] : [bundleFlatpak(settings)];\n};\n\nexport { flatpakTarget };\n"]}
|
package/dist/deploy/tools.d.ts
CHANGED
|
@@ -3,16 +3,18 @@ type ToolReport = {
|
|
|
3
3
|
missingRequired: DeployTool[];
|
|
4
4
|
missingOptional: DeployTool[];
|
|
5
5
|
};
|
|
6
|
+
declare const GENERATOR_PNPM_OPTION = "--pnpm-store-version";
|
|
6
7
|
declare const APPSTREAMCLI: DeployTool;
|
|
7
8
|
declare const DESKTOP_FILE_VALIDATE: DeployTool;
|
|
8
9
|
declare const FILE_TOOL: DeployTool;
|
|
9
10
|
declare const FLATPAK: DeployTool;
|
|
10
11
|
declare const FLATPAK_BUILDER: DeployTool;
|
|
11
12
|
declare const FLATPAK_NODE_GENERATOR: DeployTool;
|
|
13
|
+
declare const FLATPAK_NODE_GENERATOR_PNPM: DeployTool;
|
|
12
14
|
declare const STRIP: DeployTool;
|
|
13
15
|
declare const TAR: DeployTool;
|
|
14
16
|
declare const probeTools: (tools: DeployTool[]) => ToolReport;
|
|
15
17
|
declare const assertTools: (report: ToolReport) => void;
|
|
16
18
|
declare const warnMissingOptional: (report: ToolReport) => void;
|
|
17
|
-
export { APPSTREAMCLI, FLATPAK_NODE_GENERATOR, assertTools, DESKTOP_FILE_VALIDATE, FILE_TOOL, FLATPAK, FLATPAK_BUILDER, probeTools, STRIP, TAR, warnMissingOptional, };
|
|
19
|
+
export { APPSTREAMCLI, FLATPAK_NODE_GENERATOR, FLATPAK_NODE_GENERATOR_PNPM, GENERATOR_PNPM_OPTION, assertTools, DESKTOP_FILE_VALIDATE, FILE_TOOL, FLATPAK, FLATPAK_BUILDER, probeTools, STRIP, TAR, warnMissingOptional, };
|
|
18
20
|
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/deploy/tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,KAAK,UAAU,GAAG;IACd,eAAe,EAAE,UAAU,EAAE,CAAC;IAC9B,eAAe,EAAE,UAAU,EAAE,CAAC;CACjC,CAAC;AAKF,QAAA,MAAM,YAAY,EAAE,UAInB,CAAC;AAEF,QAAA,MAAM,qBAAqB,EAAE,UAI5B,CAAC;AAEF,QAAA,MAAM,SAAS,EAAE,UAIhB,CAAC;AAEF,QAAA,MAAM,OAAO,EAAE,UAId,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,UAMtB,CAAC;AAEF,QAAA,MAAM,sBAAsB,EAAE,UAI7B,CAAC;AAEF,QAAA,MAAM,KAAK,EAAE,UAIZ,CAAC;AAEF,QAAA,MAAM,GAAG,EAAE,UAIV,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/deploy/tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,KAAK,UAAU,GAAG;IACd,eAAe,EAAE,UAAU,EAAE,CAAC;IAC9B,eAAe,EAAE,UAAU,EAAE,CAAC;CACjC,CAAC;AAKF,QAAA,MAAM,qBAAqB,yBAAyB,CAAC;AAErD,QAAA,MAAM,YAAY,EAAE,UAInB,CAAC;AAEF,QAAA,MAAM,qBAAqB,EAAE,UAI5B,CAAC;AAEF,QAAA,MAAM,SAAS,EAAE,UAIhB,CAAC;AAEF,QAAA,MAAM,OAAO,EAAE,UAId,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,UAMtB,CAAC;AAEF,QAAA,MAAM,sBAAsB,EAAE,UAI7B,CAAC;AAEF,QAAA,MAAM,2BAA2B,EAAE,UAGlC,CAAC;AAEF,QAAA,MAAM,KAAK,EAAE,UAIZ,CAAC;AAEF,QAAA,MAAM,GAAG,EAAE,UAIV,CAAC;AA8BF,QAAA,MAAM,UAAU,GAAI,OAAO,UAAU,EAAE,KAAG,UAOzC,CAAC;AAwBF,QAAA,MAAM,WAAW,GAAI,QAAQ,UAAU,KAAG,IAIzC,CAAC;AAEF,QAAA,MAAM,mBAAmB,GAAI,QAAQ,UAAU,KAAG,IAIjD,CAAC;AAEF,OAAO,EACH,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,OAAO,EACP,eAAe,EACf,UAAU,EACV,KAAK,EACL,GAAG,EACH,mBAAmB,GACtB,CAAC"}
|
package/dist/deploy/tools.js
CHANGED
|
@@ -3,6 +3,8 @@ import { spawnSync } from "node:child_process";
|
|
|
3
3
|
import { detectPackageFamily, installHints } from "./install-hints.js";
|
|
4
4
|
const DETAIL_COLUMN = 26;
|
|
5
5
|
const FLATPAK_BUILDER_REF = "org.flatpak.Builder";
|
|
6
|
+
const FLATPAK_NODE_GENERATOR_COMMAND = "flatpak-node-generator";
|
|
7
|
+
const GENERATOR_PNPM_OPTION = "--pnpm-store-version";
|
|
6
8
|
const APPSTREAMCLI = {
|
|
7
9
|
command: "appstreamcli",
|
|
8
10
|
purpose: "validates the AppStream metainfo",
|
|
@@ -30,10 +32,14 @@ const FLATPAK_BUILDER = {
|
|
|
30
32
|
isPresent: () => tryResolveExecutable("flatpak-builder") !== undefined || isFlatpakRefInstalled(FLATPAK_BUILDER_REF),
|
|
31
33
|
};
|
|
32
34
|
const FLATPAK_NODE_GENERATOR = {
|
|
33
|
-
command:
|
|
34
|
-
purpose: "vendors the
|
|
35
|
+
command: FLATPAK_NODE_GENERATOR_COMMAND,
|
|
36
|
+
purpose: "vendors the dependencies a Flathub build installs offline",
|
|
35
37
|
isOptional: false,
|
|
36
38
|
};
|
|
39
|
+
const FLATPAK_NODE_GENERATOR_PNPM = {
|
|
40
|
+
...FLATPAK_NODE_GENERATOR,
|
|
41
|
+
isPresent: () => hasGeneratorPnpmSupport(),
|
|
42
|
+
};
|
|
37
43
|
const STRIP = {
|
|
38
44
|
command: "strip",
|
|
39
45
|
purpose: "would shrink the bundled Node.js by removing its symbols",
|
|
@@ -51,6 +57,14 @@ const isFlatpakRefInstalled = (ref) => {
|
|
|
51
57
|
}
|
|
52
58
|
return spawnSync(flatpak, ["info", ref], { stdio: "ignore" }).status === 0;
|
|
53
59
|
};
|
|
60
|
+
const hasGeneratorPnpmSupport = () => {
|
|
61
|
+
const generator = tryResolveExecutable(FLATPAK_NODE_GENERATOR_COMMAND);
|
|
62
|
+
if (generator === undefined) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const help = spawnSync(generator, ["--help"], { encoding: "utf8" });
|
|
66
|
+
return help.error === undefined && help.output.join("").includes(GENERATOR_PNPM_OPTION);
|
|
67
|
+
};
|
|
54
68
|
const isToolPresent = (tool) => tool.isPresent === undefined ? tryResolveExecutable(tool.command) !== undefined : tool.isPresent();
|
|
55
69
|
const uniqueTools = (tools) => new Map(tools.map((tool) => [tool.command, tool])).values().toArray();
|
|
56
70
|
const probeTools = (tools) => {
|
|
@@ -88,5 +102,5 @@ const warnMissingOptional = (report) => {
|
|
|
88
102
|
warn(`${tool.command} is not installed: it ${tool.purpose}`);
|
|
89
103
|
}
|
|
90
104
|
};
|
|
91
|
-
export { APPSTREAMCLI, FLATPAK_NODE_GENERATOR, assertTools, DESKTOP_FILE_VALIDATE, FILE_TOOL, FLATPAK, FLATPAK_BUILDER, probeTools, STRIP, TAR, warnMissingOptional, };
|
|
105
|
+
export { APPSTREAMCLI, FLATPAK_NODE_GENERATOR, FLATPAK_NODE_GENERATOR_PNPM, GENERATOR_PNPM_OPTION, assertTools, DESKTOP_FILE_VALIDATE, FILE_TOOL, FLATPAK, FLATPAK_BUILDER, probeTools, STRIP, TAR, warnMissingOptional, };
|
|
92
106
|
//# sourceMappingURL=tools.js.map
|
package/dist/deploy/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/deploy/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOvE,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/deploy/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAOvE,MA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K,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAErD,OAAO;QACH,kBAAkB,MAAM,CAAC,KAAK,CAAC,aAAa,MAAM,WAAW;QAC7D,EAAE;QACF,GAAG,QAAQ;QACX,EAAE;QACF,uEAAuE;KAC1E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAQ,EAAE;IAC7C,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjD,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,MAAkB,EAAQ,EAAE;IACrD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QACxC,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,yBAAyB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EACH,YAAY,EACZ,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,OAAO,EACP,eAAe,EACf,UAAU,EACV,KAAK,EACL,GAAG,EACH,mBAAmB,GACtB,CAAC","sourcesContent":["import { tryResolveExecutable, warn } from \"@gtkx/utils\";\nimport { spawnSync } from \"node:child_process\";\nimport type { DeployTool } from \"./types.js\";\nimport { detectPackageFamily, installHints } from \"./install-hints.js\";\n\ntype ToolReport = {\n missingRequired: DeployTool[];\n missingOptional: DeployTool[];\n};\n\nconst DETAIL_COLUMN = 26;\nconst FLATPAK_BUILDER_REF = \"org.flatpak.Builder\";\nconst FLATPAK_NODE_GENERATOR_COMMAND = \"flatpak-node-generator\";\nconst GENERATOR_PNPM_OPTION = \"--pnpm-store-version\";\n\nconst APPSTREAMCLI: DeployTool = {\n command: \"appstreamcli\",\n purpose: \"validates the AppStream metainfo\",\n isOptional: false,\n};\n\nconst DESKTOP_FILE_VALIDATE: DeployTool = {\n command: \"desktop-file-validate\",\n purpose: \"validates the desktop entry\",\n isOptional: false,\n};\n\nconst FILE_TOOL: DeployTool = {\n command: \"file\",\n purpose: \"required by appimagetool to inspect the payload\",\n isOptional: false,\n};\n\nconst FLATPAK: DeployTool = {\n command: \"flatpak\",\n purpose: \"installs the runtime and writes the bundle\",\n isOptional: false,\n};\n\nconst FLATPAK_BUILDER: DeployTool = {\n command: \"flatpak-builder\",\n purpose: \"builds the Flatpak\",\n isOptional: false,\n isPresent: () =>\n tryResolveExecutable(\"flatpak-builder\") !== undefined || isFlatpakRefInstalled(FLATPAK_BUILDER_REF),\n};\n\nconst FLATPAK_NODE_GENERATOR: DeployTool = {\n command: FLATPAK_NODE_GENERATOR_COMMAND,\n purpose: \"vendors the dependencies a Flathub build installs offline\",\n isOptional: false,\n};\n\nconst FLATPAK_NODE_GENERATOR_PNPM: DeployTool = {\n ...FLATPAK_NODE_GENERATOR,\n isPresent: () => hasGeneratorPnpmSupport(),\n};\n\nconst STRIP: DeployTool = {\n command: \"strip\",\n purpose: \"would shrink the bundled Node.js by removing its symbols\",\n isOptional: true,\n};\n\nconst TAR: DeployTool = {\n command: \"tar\",\n purpose: \"unpacks the downloaded Node.js and packaging tools\",\n isOptional: false,\n};\n\nconst isFlatpakRefInstalled = (ref: string): boolean => {\n const flatpak = tryResolveExecutable(FLATPAK.command);\n\n if (flatpak === undefined) {\n return false;\n }\n\n return spawnSync(flatpak, [\"info\", ref], { stdio: \"ignore\" }).status === 0;\n};\n\nconst hasGeneratorPnpmSupport = (): boolean => {\n const generator = tryResolveExecutable(FLATPAK_NODE_GENERATOR_COMMAND);\n\n if (generator === undefined) {\n return false;\n }\n\n const help = spawnSync(generator, [\"--help\"], { encoding: \"utf8\" });\n\n return help.error === undefined && help.output.join(\"\").includes(GENERATOR_PNPM_OPTION);\n};\n\nconst isToolPresent = (tool: DeployTool): boolean =>\n tool.isPresent === undefined ? tryResolveExecutable(tool.command) !== undefined : tool.isPresent();\n\nconst uniqueTools = (tools: DeployTool[]): DeployTool[] =>\n new Map(tools.map((tool) => [tool.command, tool])).values().toArray();\n\nconst probeTools = (tools: DeployTool[]): ToolReport => {\n const missing = uniqueTools(tools).filter((tool) => !isToolPresent(tool));\n\n return {\n missingRequired: missing.filter((tool) => !tool.isOptional),\n missingOptional: missing.filter((tool) => tool.isOptional),\n };\n};\n\nconst pad = (text: string): string => text.padEnd(DETAIL_COLUMN);\n\nconst toolLines = (tool: DeployTool, hints: string[]): string[] => [\n ` ${pad(tool.command)}${tool.purpose}`,\n ...hints.map((hint) => ` ${pad(\"\")}${hint}`),\n];\n\nconst missingToolsMessage = (report: ToolReport): string => {\n const family = detectPackageFamily();\n const required = report.missingRequired.flatMap((tool) => toolLines(tool, installHints(tool.command, family)));\n const count = report.missingRequired.length;\n const plural = count === 1 ? \"tool is\" : \"tools are\";\n\n return [\n `Cannot deploy: ${String(count)} required ${plural} missing.`,\n \"\",\n ...required,\n \"\",\n \"Narrow the run with --target if you do not need every package format.\",\n ].join(\"\\n\");\n};\n\nconst assertTools = (report: ToolReport): void => {\n if (report.missingRequired.length > 0) {\n throw new Error(missingToolsMessage(report));\n }\n};\n\nconst warnMissingOptional = (report: ToolReport): void => {\n for (const tool of report.missingOptional) {\n warn(`${tool.command} is not installed: it ${tool.purpose}`);\n }\n};\n\nexport {\n APPSTREAMCLI,\n FLATPAK_NODE_GENERATOR,\n FLATPAK_NODE_GENERATOR_PNPM,\n GENERATOR_PNPM_OPTION,\n assertTools,\n DESKTOP_FILE_VALIDATE,\n FILE_TOOL,\n FLATPAK,\n FLATPAK_BUILDER,\n probeTools,\n STRIP,\n TAR,\n warnMissingOptional,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Command-line tool and Vite plugin stack that scaffolds, develops, builds, and documents GTKX applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -73,19 +73,19 @@
|
|
|
73
73
|
"react-refresh": "^0.18.0",
|
|
74
74
|
"vite": "^8.2.1",
|
|
75
75
|
"yaml": "^2.9.0",
|
|
76
|
-
"@gtkx/codegen": "1.
|
|
77
|
-
"@gtkx/
|
|
78
|
-
"@gtkx/
|
|
79
|
-
"@gtkx/
|
|
80
|
-
"@gtkx/
|
|
81
|
-
"
|
|
82
|
-
"
|
|
76
|
+
"@gtkx/codegen": "1.2.0",
|
|
77
|
+
"@gtkx/config": "1.2.0",
|
|
78
|
+
"@gtkx/utils": "1.2.0",
|
|
79
|
+
"@gtkx/runtime": "1.2.0",
|
|
80
|
+
"@gtkx/mcp": "1.2.0",
|
|
81
|
+
"@gtkx/vitest": "1.2.0",
|
|
82
|
+
"create-gtkx": "1.2.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/babel__core": "^7.20.5",
|
|
86
86
|
"@types/react-refresh": "^0.14.7",
|
|
87
87
|
"vitest": "^4.1.10",
|
|
88
|
-
"@gtkx/testing": "1.
|
|
88
|
+
"@gtkx/testing": "1.2.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"react": "^19"
|
package/src/codegen/report.ts
CHANGED
|
@@ -17,6 +17,10 @@ const formatCodegenResult = (result: RunCodegenResult, totalMs: number): string[
|
|
|
17
17
|
details.push(`girPath=${result.girPath.join(":")}`);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
if (result.future && result.future.length > 0) {
|
|
21
|
+
details.push(`future=${result.future.join(", ")}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
details.push(
|
|
21
25
|
`${String(result.namespaces)} namespaces, ${String(result.intrinsicElements)} intrinsic elements ` +
|
|
22
26
|
`in ${String(result.duration)}ms (total ${String(totalMs)}ms)`,
|
|
@@ -36,6 +36,7 @@ type RunCodegenResult = {
|
|
|
36
36
|
girPath?: string[] | undefined;
|
|
37
37
|
configFile?: string | undefined;
|
|
38
38
|
libraries?: string[] | undefined;
|
|
39
|
+
future?: string[] | undefined;
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
type CodegenOptionsInput = {
|
|
@@ -43,6 +44,7 @@ type CodegenOptionsInput = {
|
|
|
43
44
|
libraries: string[];
|
|
44
45
|
girPath: string[];
|
|
45
46
|
elements: Config["elements"];
|
|
47
|
+
isByteArrayTyped: boolean;
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
type PreparedCodegen = CodegenInputs & { isForced: boolean };
|
|
@@ -71,9 +73,10 @@ const removeShadowingStores = (cwd: string): void => {
|
|
|
71
73
|
removeStores(getShadowingStorePaths(cwd));
|
|
72
74
|
};
|
|
73
75
|
|
|
74
|
-
const codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsInput) => ({
|
|
76
|
+
const codegenOptions = ({ store, libraries, girPath, elements, isByteArrayTyped }: CodegenOptionsInput) => ({
|
|
75
77
|
libraries,
|
|
76
78
|
girPath,
|
|
79
|
+
isByteArrayTyped,
|
|
77
80
|
gi: {
|
|
78
81
|
storeDir: store.giStoreDir,
|
|
79
82
|
linkDir: store.giLinkDir,
|
|
@@ -94,6 +97,11 @@ const codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsI
|
|
|
94
97
|
userOmittedProps: resolveOmittedProps(elements),
|
|
95
98
|
});
|
|
96
99
|
|
|
100
|
+
const enabledFutureFlags = (config: Config): string[] =>
|
|
101
|
+
Object.entries(config.future ?? {})
|
|
102
|
+
.filter(([, value]) => value === true)
|
|
103
|
+
.map(([name]) => name);
|
|
104
|
+
|
|
97
105
|
const disabledCodegenResult = (configFile: string): RunCodegenResult => ({
|
|
98
106
|
isRegenerated: false,
|
|
99
107
|
namespaces: 0,
|
|
@@ -153,6 +161,7 @@ const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenRe
|
|
|
153
161
|
libraries,
|
|
154
162
|
girPath,
|
|
155
163
|
elements: config.elements,
|
|
164
|
+
isByteArrayTyped: config.future?.v2ByteArrays === true,
|
|
156
165
|
}),
|
|
157
166
|
isForced,
|
|
158
167
|
});
|
|
@@ -165,6 +174,7 @@ const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenRe
|
|
|
165
174
|
girPath,
|
|
166
175
|
configFile,
|
|
167
176
|
libraries,
|
|
177
|
+
future: enabledFutureFlags(config),
|
|
168
178
|
};
|
|
169
179
|
};
|
|
170
180
|
|
package/src/commands/docs.ts
CHANGED
|
@@ -78,6 +78,7 @@ const docs = defineCommand({
|
|
|
78
78
|
props: builtin.props,
|
|
79
79
|
omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),
|
|
80
80
|
isForced: args.force,
|
|
81
|
+
isByteArrayTyped: config.future?.v2ByteArrays === true,
|
|
81
82
|
});
|
|
82
83
|
|
|
83
84
|
if (!isRegenerated) {
|