@gtkx/cli 1.1.0 → 1.2.1

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.
Files changed (153) hide show
  1. package/dist/builder.d.ts.map +1 -1
  2. package/dist/builder.js +2 -0
  3. package/dist/builder.js.map +1 -1
  4. package/dist/codegen/report.d.ts.map +1 -1
  5. package/dist/codegen/report.js +3 -0
  6. package/dist/codegen/report.js.map +1 -1
  7. package/dist/codegen/run-codegen.d.ts +1 -0
  8. package/dist/codegen/run-codegen.d.ts.map +1 -1
  9. package/dist/codegen/run-codegen.js +7 -1
  10. package/dist/codegen/run-codegen.js.map +1 -1
  11. package/dist/commands/docs.d.ts.map +1 -1
  12. package/dist/commands/docs.js +1 -0
  13. package/dist/commands/docs.js.map +1 -1
  14. package/dist/deploy/freedesktop/copyright.d.ts +2 -2
  15. package/dist/deploy/freedesktop/copyright.d.ts.map +1 -1
  16. package/dist/deploy/freedesktop/copyright.js +105 -14
  17. package/dist/deploy/freedesktop/copyright.js.map +1 -1
  18. package/dist/deploy/install-hints.d.ts.map +1 -1
  19. package/dist/deploy/install-hints.js +7 -4
  20. package/dist/deploy/install-hints.js.map +1 -1
  21. package/dist/deploy/node-runtime/download.d.ts +5 -1
  22. package/dist/deploy/node-runtime/download.d.ts.map +1 -1
  23. package/dist/deploy/node-runtime/download.js +6 -3
  24. package/dist/deploy/node-runtime/download.js.map +1 -1
  25. package/dist/deploy/node-runtime/index.d.ts +2 -1
  26. package/dist/deploy/node-runtime/index.d.ts.map +1 -1
  27. package/dist/deploy/node-runtime/index.js +10 -9
  28. package/dist/deploy/node-runtime/index.js.map +1 -1
  29. package/dist/deploy/node-runtime/license.d.ts +4 -0
  30. package/dist/deploy/node-runtime/license.d.ts.map +1 -0
  31. package/dist/deploy/node-runtime/license.js +19 -0
  32. package/dist/deploy/node-runtime/license.js.map +1 -0
  33. package/dist/deploy/notices/collect.d.ts +8 -0
  34. package/dist/deploy/notices/collect.d.ts.map +1 -0
  35. package/dist/deploy/notices/collect.js +17 -0
  36. package/dist/deploy/notices/collect.js.map +1 -0
  37. package/dist/deploy/notices/dependencies.d.ts +5 -0
  38. package/dist/deploy/notices/dependencies.d.ts.map +1 -0
  39. package/dist/deploy/notices/dependencies.js +39 -0
  40. package/dist/deploy/notices/dependencies.js.map +1 -0
  41. package/dist/deploy/notices/gtkx.d.ts +6 -0
  42. package/dist/deploy/notices/gtkx.d.ts.map +1 -0
  43. package/dist/deploy/notices/gtkx.js +68 -0
  44. package/dist/deploy/notices/gtkx.js.map +1 -0
  45. package/dist/deploy/notices/libraries.d.ts +4 -0
  46. package/dist/deploy/notices/libraries.d.ts.map +1 -0
  47. package/dist/deploy/notices/libraries.js +60 -0
  48. package/dist/deploy/notices/libraries.js.map +1 -0
  49. package/dist/deploy/notices/node-runtime.d.ts +4 -0
  50. package/dist/deploy/notices/node-runtime.d.ts.map +1 -0
  51. package/dist/deploy/notices/node-runtime.js +78 -0
  52. package/dist/deploy/notices/node-runtime.js.map +1 -0
  53. package/dist/deploy/notices/packages.d.ts +13 -0
  54. package/dist/deploy/notices/packages.d.ts.map +1 -0
  55. package/dist/deploy/notices/packages.js +115 -0
  56. package/dist/deploy/notices/packages.js.map +1 -0
  57. package/dist/deploy/notices/render.d.ts +4 -0
  58. package/dist/deploy/notices/render.d.ts.map +1 -0
  59. package/dist/deploy/notices/render.js +41 -0
  60. package/dist/deploy/notices/render.js.map +1 -0
  61. package/dist/deploy/notices/text.d.ts +5 -0
  62. package/dist/deploy/notices/text.d.ts.map +1 -0
  63. package/dist/deploy/notices/text.js +34 -0
  64. package/dist/deploy/notices/text.js.map +1 -0
  65. package/dist/deploy/payload/copy-tree.d.ts +2 -1
  66. package/dist/deploy/payload/copy-tree.d.ts.map +1 -1
  67. package/dist/deploy/payload/copy-tree.js +3 -1
  68. package/dist/deploy/payload/copy-tree.js.map +1 -1
  69. package/dist/deploy/payload/stage.d.ts +7 -3
  70. package/dist/deploy/payload/stage.d.ts.map +1 -1
  71. package/dist/deploy/payload/stage.js +25 -14
  72. package/dist/deploy/payload/stage.js.map +1 -1
  73. package/dist/deploy/run-deploy.d.ts.map +1 -1
  74. package/dist/deploy/run-deploy.js +28 -7
  75. package/dist/deploy/run-deploy.js.map +1 -1
  76. package/dist/deploy/settings/extra-files.d.ts +4 -0
  77. package/dist/deploy/settings/extra-files.d.ts.map +1 -0
  78. package/dist/deploy/settings/extra-files.js +11 -0
  79. package/dist/deploy/settings/extra-files.js.map +1 -0
  80. package/dist/deploy/settings/index.d.ts.map +1 -1
  81. package/dist/deploy/settings/index.js +2 -1
  82. package/dist/deploy/settings/index.js.map +1 -1
  83. package/dist/deploy/settings/package-manifest.d.ts +2 -0
  84. package/dist/deploy/settings/package-manifest.d.ts.map +1 -1
  85. package/dist/deploy/settings/package-manifest.js +8 -0
  86. package/dist/deploy/settings/package-manifest.js.map +1 -1
  87. package/dist/deploy/settings/paths.d.ts +2 -1
  88. package/dist/deploy/settings/paths.d.ts.map +1 -1
  89. package/dist/deploy/settings/paths.js +1 -1
  90. package/dist/deploy/settings/paths.js.map +1 -1
  91. package/dist/deploy/targets/flatpak-manifest.d.ts +3 -1
  92. package/dist/deploy/targets/flatpak-manifest.d.ts.map +1 -1
  93. package/dist/deploy/targets/flatpak-manifest.js +50 -4
  94. package/dist/deploy/targets/flatpak-manifest.js.map +1 -1
  95. package/dist/deploy/targets/flatpak-pnpm.d.ts +15 -0
  96. package/dist/deploy/targets/flatpak-pnpm.d.ts.map +1 -0
  97. package/dist/deploy/targets/flatpak-pnpm.js +69 -0
  98. package/dist/deploy/targets/flatpak-pnpm.js.map +1 -0
  99. package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
  100. package/dist/deploy/targets/flatpak-source.js +70 -7
  101. package/dist/deploy/targets/flatpak-source.js.map +1 -1
  102. package/dist/deploy/targets/flatpak-sources.d.ts +5 -3
  103. package/dist/deploy/targets/flatpak-sources.d.ts.map +1 -1
  104. package/dist/deploy/targets/flatpak-sources.js +23 -9
  105. package/dist/deploy/targets/flatpak-sources.js.map +1 -1
  106. package/dist/deploy/targets/flatpak.d.ts.map +1 -1
  107. package/dist/deploy/targets/flatpak.js +3 -2
  108. package/dist/deploy/targets/flatpak.js.map +1 -1
  109. package/dist/deploy/tools.d.ts +3 -1
  110. package/dist/deploy/tools.d.ts.map +1 -1
  111. package/dist/deploy/tools.js +17 -3
  112. package/dist/deploy/tools.js.map +1 -1
  113. package/dist/deploy/types.d.ts +22 -2
  114. package/dist/deploy/types.d.ts.map +1 -1
  115. package/dist/deploy/types.js.map +1 -1
  116. package/dist/vite-plugins/bundled-packages.d.ts +5 -0
  117. package/dist/vite-plugins/bundled-packages.d.ts.map +1 -0
  118. package/dist/vite-plugins/bundled-packages.js +63 -0
  119. package/dist/vite-plugins/bundled-packages.js.map +1 -0
  120. package/package.json +9 -9
  121. package/src/builder.ts +2 -0
  122. package/src/codegen/report.ts +4 -0
  123. package/src/codegen/run-codegen.ts +11 -1
  124. package/src/commands/docs.ts +1 -0
  125. package/src/deploy/freedesktop/copyright.ts +153 -18
  126. package/src/deploy/install-hints.ts +9 -6
  127. package/src/deploy/node-runtime/download.ts +13 -4
  128. package/src/deploy/node-runtime/index.ts +17 -11
  129. package/src/deploy/node-runtime/license.ts +24 -0
  130. package/src/deploy/notices/collect.ts +26 -0
  131. package/src/deploy/notices/dependencies.ts +53 -0
  132. package/src/deploy/notices/gtkx.ts +92 -0
  133. package/src/deploy/notices/libraries.ts +81 -0
  134. package/src/deploy/notices/node-runtime.ts +101 -0
  135. package/src/deploy/notices/packages.ts +168 -0
  136. package/src/deploy/notices/render.ts +52 -0
  137. package/src/deploy/notices/text.ts +42 -0
  138. package/src/deploy/payload/copy-tree.ts +5 -1
  139. package/src/deploy/payload/stage.ts +40 -16
  140. package/src/deploy/run-deploy.ts +34 -6
  141. package/src/deploy/settings/extra-files.ts +21 -0
  142. package/src/deploy/settings/index.ts +2 -1
  143. package/src/deploy/settings/package-manifest.ts +12 -0
  144. package/src/deploy/settings/paths.ts +1 -1
  145. package/src/deploy/targets/flatpak-manifest.ts +69 -4
  146. package/src/deploy/targets/flatpak-pnpm.ts +115 -0
  147. package/src/deploy/targets/flatpak-source.ts +105 -6
  148. package/src/deploy/targets/flatpak-sources.ts +36 -9
  149. package/src/deploy/targets/flatpak.ts +3 -2
  150. package/src/deploy/tools.ts +23 -2
  151. package/src/deploy/types.ts +27 -1
  152. package/src/vite-plugins/bundled-packages.ts +95 -0
  153. package/LICENSE +0 -373
@@ -1,14 +1,21 @@
1
- import { posix, relative } from "node:path";
1
+ import { existsSync, realpathSync } from "node:fs";
2
+ import { posix, relative, resolve } from "node:path";
2
3
  import { listFilesRecursive } from "../../internal/list-files.js";
3
4
  import { BUNDLE_FILENAME } from "../../vite-plugins/esm-extension.js";
4
5
  import { renderDbusService } from "../freedesktop/dbus-service.js";
5
6
  import { renderDesktopEntry } from "../freedesktop/desktop-entry.js";
6
7
  import { renderMetainfo } from "../freedesktop/metainfo.js";
8
+ import { renderMimePackage } from "../freedesktop/mime-package.js";
7
9
  import { optional } from "../nfpm/optional.js";
10
+ import { renderNotices } from "../notices/render.js";
11
+ import { executableModeFor } from "../payload/copy-tree.js";
8
12
  import { iconPathFor } from "../payload/icons.js";
9
13
  import { renderLauncher } from "../payload/launcher.js";
14
+ import { licenseDestination, nodeLicenseDestination, NOTICES_FILENAME, noticesDestination } from "../payload/stage.js";
15
+ import { isInside } from "../settings/paths.js";
16
+ import { pnpmPathFor, pnpmSources } from "./flatpak-pnpm.js";
10
17
  import { DESTINATION, postInstallCommands, validationCommands } from "./flatpak-prebuilt.js";
11
- import { detectPackageManager, GENERATED_SOURCES, installCommandFor, nodeExtensionPathFor, resolveGitSource, } from "./flatpak-sources.js";
18
+ import { detectPackageManager, GENERATED_SOURCES, installCommandFor, nodeExtensionPathFor, pnpmPinFor, resolveGitSource, } from "./flatpak-sources.js";
12
19
  const LAUNCHER_FILENAME = "launcher.sh";
13
20
  const MODULE_BUILD_ROOT = "/run/build";
14
21
  const RUNTIME_PREFIX = "/app";
@@ -16,6 +23,7 @@ const NPM_CACHE_DIR = "flatpak-node/npm-cache";
16
23
  const YARN_MIRROR_DIR = "flatpak-node/yarn-mirror";
17
24
  const PLAIN_ARGUMENT = /^[\w./-]+$/;
18
25
  const QUOTE_ESCAPE = String.raw `'\''`;
26
+ const OCTAL_RADIX = 8;
19
27
  const inlineSource = (fileName, contents) => ({
20
28
  type: "inline",
21
29
  "dest-filename": fileName,
@@ -44,10 +52,18 @@ const activationSource = (settings) => settings.isDbusActivatable
44
52
  const activationInstallCommands = (settings) => settings.isDbusActivatable
45
53
  ? [installCommand(`${settings.applicationId}.service`, `${DESTINATION}/share/dbus-1/services/${settings.applicationId}.service`, "m644")]
46
54
  : [];
55
+ const mimeSources = (settings) => {
56
+ const contents = renderMimePackage(settings);
57
+ return contents === null ? [] : [inlineSource(`${settings.applicationId}.xml`, contents)];
58
+ };
59
+ const mimeInstallCommands = (settings) => settings.fileAssociations.length === 0
60
+ ? []
61
+ : [installCommand(`${settings.applicationId}.xml`, `${DESTINATION}/share/mime/packages/${settings.applicationId}.xml`, "m644")];
47
62
  const metadataInstallCommands = (settings) => [
48
63
  installCommand(`${settings.applicationId}.desktop`, `${DESTINATION}/share/applications/${settings.applicationId}.desktop`, "m644"),
49
64
  installCommand(`${settings.applicationId}.metainfo.xml`, `${DESTINATION}/share/metainfo/${settings.applicationId}.metainfo.xml`, "m644"),
50
65
  ...activationInstallCommands(settings),
66
+ ...mimeInstallCommands(settings),
51
67
  ];
52
68
  const schemaInstallCommands = (settings) => settings.paths.schemaFiles.map((file) => {
53
69
  const name = posix.basename(file);
@@ -64,42 +80,89 @@ const iconInstallCommands = (settings) => {
64
80
  }
65
81
  return listFilesRecursive(iconsDir).map((icon) => iconInstallCommand(settings, icon.absPath, icon.rel));
66
82
  };
83
+ const assertInsideProject = (settings, installed) => {
84
+ const { resolved } = installed;
85
+ const target = existsSync(resolved) ? realpathSync(resolved) : resolved;
86
+ if (isInside(settings.paths.root, target)) {
87
+ return;
88
+ }
89
+ throw new Error(`Cannot install "${installed.destination}" from "${installed.source}": a source-mode manifest builds from ` +
90
+ `your git checkout, so every file it installs has to live inside ${settings.paths.root} and be committed. ` +
91
+ "Move it into the project, or drop it from the source build.");
92
+ };
93
+ const licenseInstallCommands = (settings) => {
94
+ const licenseFile = settings.paths.licenseFile;
95
+ if (licenseFile === null) {
96
+ return [];
97
+ }
98
+ const destination = licenseDestination(settings);
99
+ assertInsideProject(settings, { destination, source: licenseFile, resolved: licenseFile });
100
+ const target = `${DESTINATION}/${shellArgument(destination)}`;
101
+ return [installCommand(projectRelative(settings, licenseFile), target, "m644")];
102
+ };
103
+ const noticesInstallCommands = (settings) => {
104
+ const extensionLicense = `${nodeExtensionPathFor(settings)}/LICENSE`;
105
+ const nodeTarget = `${DESTINATION}/${shellArgument(nodeLicenseDestination(settings))}`;
106
+ return [
107
+ installCommand(NOTICES_FILENAME, `${DESTINATION}/${shellArgument(noticesDestination(settings))}`, "m644"),
108
+ `test ! -f ${extensionLicense} || ${installCommand(extensionLicense, nodeTarget, "m644")}`,
109
+ ];
110
+ };
111
+ const extraFileInstallCommands = (settings) => settings.extraFiles.map((file) => {
112
+ const resolved = resolve(settings.paths.root, file.source);
113
+ assertInsideProject(settings, { destination: file.destination, source: file.source, resolved });
114
+ const mode = file.mode ?? executableModeFor(resolved);
115
+ return installCommand(projectRelative(settings, resolved), `${DESTINATION}/${shellArgument(file.destination)}`, `m${mode.toString(OCTAL_RADIX)}`);
116
+ });
117
+ const moduleDirFor = (settings) => `${MODULE_BUILD_ROOT}/${settings.binaryName}`;
67
118
  const offlineEnvFor = (manager, settings) => {
68
- const moduleDir = `${MODULE_BUILD_ROOT}/${settings.binaryName}`;
119
+ if (manager === "pnpm") {
120
+ return {};
121
+ }
69
122
  if (manager === "yarn") {
70
- return { YARN_OFFLINE_MIRROR: `${moduleDir}/${YARN_MIRROR_DIR}` };
123
+ return { YARN_OFFLINE_MIRROR: `${moduleDirFor(settings)}/${YARN_MIRROR_DIR}` };
71
124
  }
72
- return { npm_config_cache: `${moduleDir}/${NPM_CACHE_DIR}`, npm_config_offline: "true" };
125
+ return { npm_config_cache: `${moduleDirFor(settings)}/${NPM_CACHE_DIR}`, npm_config_offline: "true" };
73
126
  };
127
+ const appendPathFor = (settings, pin, nodeExtensionPath) => pin === null
128
+ ? `${nodeExtensionPath}/bin`
129
+ : `${pnpmPathFor(moduleDirFor(settings))}:${nodeExtensionPath}/bin`;
74
130
  const flatpakSourceModule = (payload) => {
75
131
  const settings = payload.settings;
76
132
  const manager = detectPackageManager(settings);
133
+ const pin = pnpmPinFor(settings, manager);
77
134
  const postInstall = postInstallCommands(payload);
78
135
  const nodeExtensionPath = nodeExtensionPathFor(settings);
79
136
  return {
80
137
  name: settings.binaryName,
81
138
  buildsystem: "simple",
82
139
  "build-options": {
83
- "append-path": `${nodeExtensionPath}/bin`,
140
+ "append-path": appendPathFor(settings, pin, nodeExtensionPath),
84
141
  env: { npm_config_nodedir: nodeExtensionPath, ...offlineEnvFor(manager, settings) },
85
142
  strip: false,
86
143
  "no-debuginfo": true,
87
144
  },
88
145
  sources: [
89
146
  resolveGitSource(settings),
147
+ ...(pin === null ? [] : pnpmSources(pin, moduleDirFor(settings))),
90
148
  GENERATED_SOURCES,
91
149
  inlineSource(`${settings.applicationId}.desktop`, renderDesktopEntry(settings)),
92
150
  inlineSource(`${settings.applicationId}.metainfo.xml`, renderMetainfo(settings)),
151
+ ...mimeSources(settings),
93
152
  inlineSource(LAUNCHER_FILENAME, renderLauncher(settings)),
153
+ inlineSource(NOTICES_FILENAME, renderNotices(settings, payload.notices)),
94
154
  ...activationSource(settings),
95
155
  ],
96
156
  "build-commands": [
97
- installCommandFor(manager),
157
+ installCommandFor(settings, manager),
98
158
  "npx gtkx build",
99
159
  ...runtimeInstallCommands(settings, nodeExtensionPath),
100
160
  ...metadataInstallCommands(settings),
101
161
  ...schemaInstallCommands(settings),
102
162
  ...iconInstallCommands(settings),
163
+ ...licenseInstallCommands(settings),
164
+ ...noticesInstallCommands(settings),
165
+ ...extraFileInstallCommands(settings),
103
166
  ...(settings.deploy.flatpak?.buildCommands ?? []),
104
167
  ...validationCommands(settings),
105
168
  ],
@@ -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;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA,MAAM,CAAC;AAEtC,MAAM,YA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AiB,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,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAErD,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,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAA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AClC;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 { existsSync, realpathSync } from \"node:fs\";\nimport { posix, relative, resolve } 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 { renderMimePackage } from \"../freedesktop/mime-package.js\";\nimport { optional } from \"../nfpm/optional.js\";\nimport { renderNotices } from \"../notices/render.js\";\nimport { executableModeFor } from \"../payload/copy-tree.js\";\nimport { iconPathFor } from \"../payload/icons.js\";\nimport { renderLauncher } from \"../payload/launcher.js\";\nimport { licenseDestination, nodeLicenseDestination, NOTICES_FILENAME, noticesDestination } from \"../payload/stage.js\";\nimport { isInside } from \"../settings/paths.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\ntype InstalledFile = {\n destination: string;\n source: string;\n resolved: string;\n};\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`'\\''`;\nconst OCTAL_RADIX = 8;\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 mimeSources = (settings: DeploySettings): FlatpakModule[] => {\n const contents = renderMimePackage(settings);\n\n return contents === null ? [] : [inlineSource(`${settings.applicationId}.xml`, contents)];\n};\n\nconst mimeInstallCommands = (settings: DeploySettings): string[] =>\n settings.fileAssociations.length === 0\n ? []\n : [installCommand(\n `${settings.applicationId}.xml`,\n `${DESTINATION}/share/mime/packages/${settings.applicationId}.xml`,\n \"m644\",\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 ...mimeInstallCommands(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 assertInsideProject = (settings: DeploySettings, installed: InstalledFile): void => {\n const { resolved } = installed;\n const target = existsSync(resolved) ? realpathSync(resolved) : resolved;\n\n if (isInside(settings.paths.root, target)) {\n return;\n }\n\n throw new Error(\n `Cannot install \"${installed.destination}\" from \"${installed.source}\": a source-mode manifest builds from ` +\n `your git checkout, so every file it installs has to live inside ${settings.paths.root} and be committed. ` +\n \"Move it into the project, or drop it from the source build.\",\n );\n};\n\nconst licenseInstallCommands = (settings: DeploySettings): string[] => {\n const licenseFile = settings.paths.licenseFile;\n\n if (licenseFile === null) {\n return [];\n }\n\n const destination = licenseDestination(settings);\n assertInsideProject(settings, { destination, source: licenseFile, resolved: licenseFile });\n const target = `${DESTINATION}/${shellArgument(destination)}`;\n\n return [installCommand(projectRelative(settings, licenseFile), target, \"m644\")];\n};\n\nconst noticesInstallCommands = (settings: DeploySettings): string[] => {\n const extensionLicense = `${nodeExtensionPathFor(settings)}/LICENSE`;\n const nodeTarget = `${DESTINATION}/${shellArgument(nodeLicenseDestination(settings))}`;\n\n return [\n installCommand(NOTICES_FILENAME, `${DESTINATION}/${shellArgument(noticesDestination(settings))}`, \"m644\"),\n `test ! -f ${extensionLicense} || ${installCommand(extensionLicense, nodeTarget, \"m644\")}`,\n ];\n};\n\nconst extraFileInstallCommands = (settings: DeploySettings): string[] =>\n settings.extraFiles.map((file) => {\n const resolved = resolve(settings.paths.root, file.source);\n assertInsideProject(settings, { destination: file.destination, source: file.source, resolved });\n const mode = file.mode ?? executableModeFor(resolved);\n\n return installCommand(\n projectRelative(settings, resolved),\n `${DESTINATION}/${shellArgument(file.destination)}`,\n `m${mode.toString(OCTAL_RADIX)}`,\n );\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 ...mimeSources(settings),\n inlineSource(LAUNCHER_FILENAME, renderLauncher(settings)),\n inlineSource(NOTICES_FILENAME, renderNotices(settings, payload.notices)),\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 ...licenseInstallCommands(settings),\n ...noticesInstallCommands(settings),\n ...extraFileInstallCommands(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 installCommandFor: (manager: PackageManager) => string;
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;AAE9C,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;AAmBnD,QAAA,MAAM,oBAAoB,GAAI,UAAU,cAAc,KAAG,cAkBxD,CAAC;AAEF,Q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c,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 GENERATOR = "flatpak-node-generator";
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 installCommandFor = (manager) => INSTALL_COMMAND[manager];
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
- return source.tag === undefined ? null : { tag: source.tag };
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 generateNodeSources = (settings, manager) => {
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: GENERATOR,
98
- args: [manager, join(isolated, basename(lockfile)), "-o", output],
99
- target: "the offline npm sources",
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,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ACH,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,Q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AAM,CAAC;YAC3F,MAAM,EAAE,gCAAgC;YACxC,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,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;AAoHF,OAAO,EAAE,aAAa,EAAE,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
- generateNodeSources(settings, detectPackageManager(settings));
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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;QAClD,cAAc,CAAC,QAAQ,CAAC,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 } 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,aA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M,WAAW,GAAG,CAAC,OAAsB,EAAoB,EAAE;IAC7D,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAEvB,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,EAAE,CAAC;QAClD,cAAc,CAAC,QAAQ,CAAC,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"]}
@@ -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,QAA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U,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"}
@@ -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: "flatpak-node-generator",
34
- purpose: "vendors the npm dependencies a Flathub build installs offline",
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
@@ -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;AAElD,MAAM,YAAY,GAAe;IAC7B,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,kCAAkC;IAC3C,UAAU,EAAE,KAAK;CACpB,CAAC;AAEF,MAAM,qBAAqB,GAAe;IACtC,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,6BAA6B;IACtC,UAAU,EAA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MAAM,GAAG,mBAAmB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/G,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC;IAC5C,MAAM,MAAM,GAAG,KAAK,KAAK,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,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\";\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\",\n purpose: \"vendors the npm dependencies a Flathub build installs offline\",\n isOptional: false,\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 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 assertTools,\n DESKTOP_FILE_VALIDATE,\n FILE_TOOL,\n FLATPAK,\n FLATPAK_BUILDER,\n probeTools,\n STRIP,\n TAR,\n warnMissingOptional,\n};\n"]}
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,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AAC,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"]}