@xpack/xpm-lib 3.1.2 → 4.0.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.
Files changed (202) hide show
  1. package/README.md +16 -212
  2. package/dist/classes/actions.d.ts +58 -0
  3. package/dist/classes/actions.d.ts.map +1 -0
  4. package/dist/classes/actions.js +250 -0
  5. package/dist/classes/actions.js.map +1 -0
  6. package/dist/classes/build-configurations.d.ts +78 -0
  7. package/dist/classes/build-configurations.d.ts.map +1 -0
  8. package/dist/classes/build-configurations.js +489 -0
  9. package/dist/classes/build-configurations.js.map +1 -0
  10. package/dist/classes/combinations-generator.d.ts +19 -0
  11. package/dist/classes/combinations-generator.d.ts.map +1 -0
  12. package/dist/classes/combinations-generator.js +48 -0
  13. package/dist/classes/combinations-generator.js.map +1 -0
  14. package/dist/classes/data-model.d.ts +21 -0
  15. package/dist/classes/data-model.d.ts.map +1 -0
  16. package/dist/classes/data-model.js +47 -0
  17. package/dist/classes/data-model.js.map +1 -0
  18. package/dist/classes/errors.d.ts +13 -0
  19. package/dist/classes/errors.d.ts.map +1 -0
  20. package/dist/classes/errors.js +13 -0
  21. package/dist/classes/errors.js.map +1 -0
  22. package/dist/classes/init-template-base.d.ts +47 -0
  23. package/dist/classes/init-template-base.d.ts.map +1 -0
  24. package/dist/classes/init-template-base.js +358 -0
  25. package/dist/classes/init-template-base.js.map +1 -0
  26. package/dist/classes/liquid-drop.d.ts +28 -0
  27. package/dist/classes/liquid-drop.d.ts.map +1 -0
  28. package/dist/classes/liquid-drop.js +70 -0
  29. package/dist/classes/liquid-drop.js.map +1 -0
  30. package/dist/classes/liquid-engine.d.ts +7 -0
  31. package/dist/classes/liquid-engine.d.ts.map +1 -0
  32. package/dist/classes/liquid-engine.js +72 -0
  33. package/dist/classes/liquid-engine.js.map +1 -0
  34. package/dist/classes/package.d.ts +31 -0
  35. package/dist/classes/package.d.ts.map +1 -0
  36. package/dist/classes/package.js +268 -0
  37. package/dist/classes/package.js.map +1 -0
  38. package/dist/classes/platform-detector.d.ts +14 -0
  39. package/dist/classes/platform-detector.d.ts.map +1 -0
  40. package/dist/classes/platform-detector.js +26 -0
  41. package/dist/classes/platform-detector.js.map +1 -0
  42. package/dist/classes/policies.d.ts +14 -0
  43. package/dist/classes/policies.d.ts.map +1 -0
  44. package/dist/classes/policies.js +20 -0
  45. package/dist/classes/policies.js.map +1 -0
  46. package/dist/classes/template-expander.d.ts +29 -0
  47. package/dist/classes/template-expander.d.ts.map +1 -0
  48. package/dist/classes/template-expander.js +62 -0
  49. package/dist/classes/template-expander.js.map +1 -0
  50. package/dist/data/substitutions-variables.d.ts +43 -0
  51. package/dist/data/substitutions-variables.d.ts.map +1 -0
  52. package/dist/{lib → data}/substitutions-variables.js +1 -16
  53. package/dist/data/substitutions-variables.js.map +1 -0
  54. package/dist/functions/chmod-recursively.d.ts +9 -0
  55. package/dist/functions/chmod-recursively.d.ts.map +1 -0
  56. package/dist/functions/chmod-recursively.js +66 -0
  57. package/dist/functions/chmod-recursively.js.map +1 -0
  58. package/dist/functions/filter-paths.d.ts +5 -0
  59. package/dist/functions/filter-paths.d.ts.map +1 -0
  60. package/dist/functions/filter-paths.js +16 -0
  61. package/dist/functions/filter-paths.js.map +1 -0
  62. package/dist/functions/is-something.d.ts +9 -0
  63. package/dist/functions/is-something.d.ts.map +1 -0
  64. package/dist/functions/is-something.js +25 -0
  65. package/dist/functions/is-something.js.map +1 -0
  66. package/dist/functions/matrix-expander.d.ts +17 -0
  67. package/dist/functions/matrix-expander.d.ts.map +1 -0
  68. package/dist/functions/matrix-expander.js +52 -0
  69. package/dist/functions/matrix-expander.js.map +1 -0
  70. package/dist/functions/perform-substitutions.d.ts +12 -0
  71. package/dist/functions/perform-substitutions.d.ts.map +1 -0
  72. package/dist/functions/perform-substitutions.js +76 -0
  73. package/dist/functions/perform-substitutions.js.map +1 -0
  74. package/dist/functions/utils.d.ts +8 -0
  75. package/dist/functions/utils.d.ts.map +1 -0
  76. package/dist/functions/utils.js +16 -0
  77. package/dist/functions/utils.js.map +1 -0
  78. package/dist/index.d.ts +22 -15
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +22 -29
  81. package/dist/index.js.map +1 -1
  82. package/dist/{lib/types.d.ts → types/json.d.ts} +31 -22
  83. package/dist/types/json.d.ts.map +1 -0
  84. package/dist/types/json.js +2 -0
  85. package/dist/types/json.js.map +1 -0
  86. package/dist/types/xpm-init-template.d.ts +21 -0
  87. package/dist/types/xpm-init-template.d.ts.map +1 -0
  88. package/dist/types/xpm-init-template.js +2 -0
  89. package/dist/types/xpm-init-template.js.map +1 -0
  90. package/dist/types/xpm.d.ts +16 -0
  91. package/dist/types/xpm.d.ts.map +1 -0
  92. package/dist/types/xpm.js +2 -0
  93. package/dist/types/xpm.js.map +1 -0
  94. package/package.json +53 -44
  95. package/src/CODE-REVIEW.md +2167 -0
  96. package/src/README.md +393 -6
  97. package/src/classes/actions.ts +1157 -0
  98. package/src/classes/build-configurations.ts +2127 -0
  99. package/src/classes/combinations-generator.ts +331 -0
  100. package/src/classes/data-model.ts +337 -0
  101. package/src/classes/errors.ts +105 -0
  102. package/src/classes/init-template-base.ts +1028 -0
  103. package/src/classes/liquid-drop.ts +376 -0
  104. package/src/classes/liquid-engine.ts +249 -0
  105. package/src/classes/package.ts +765 -0
  106. package/src/classes/platform-detector.ts +237 -0
  107. package/src/classes/policies.ts +200 -0
  108. package/src/classes/template-expander.ts +330 -0
  109. package/src/data/substitutions-variables.ts +390 -0
  110. package/src/functions/chmod-recursively.ts +195 -0
  111. package/src/functions/filter-paths.ts +126 -0
  112. package/src/functions/is-something.ts +223 -0
  113. package/src/functions/matrix-expander.ts +172 -0
  114. package/src/functions/perform-substitutions.ts +253 -0
  115. package/src/functions/utils.ts +151 -0
  116. package/src/index.ts +72 -19
  117. package/src/types/json.ts +519 -0
  118. package/src/types/xpm-init-template.ts +282 -0
  119. package/src/types/xpm.ts +162 -0
  120. package/dist/lib/chmod-recursive.d.ts +0 -7
  121. package/dist/lib/chmod-recursive.d.ts.map +0 -1
  122. package/dist/lib/chmod-recursive.js +0 -81
  123. package/dist/lib/chmod-recursive.js.map +0 -1
  124. package/dist/lib/errors.d.ts +0 -11
  125. package/dist/lib/errors.d.ts.map +0 -1
  126. package/dist/lib/errors.js +0 -26
  127. package/dist/lib/errors.js.map +0 -1
  128. package/dist/lib/functions/chmod-recursive.d.ts +0 -7
  129. package/dist/lib/functions/chmod-recursive.d.ts.map +0 -1
  130. package/dist/lib/functions/chmod-recursive.js +0 -81
  131. package/dist/lib/functions/chmod-recursive.js.map +0 -1
  132. package/dist/lib/functions/perform-substitutions.d.ts +0 -20
  133. package/dist/lib/functions/perform-substitutions.d.ts.map +0 -1
  134. package/dist/lib/functions/perform-substitutions.js +0 -85
  135. package/dist/lib/functions/perform-substitutions.js.map +0 -1
  136. package/dist/lib/functions/utils.d.ts +0 -30
  137. package/dist/lib/functions/utils.d.ts.map +0 -1
  138. package/dist/lib/functions/utils.js +0 -70
  139. package/dist/lib/functions/utils.js.map +0 -1
  140. package/dist/lib/init-template-base.d.ts +0 -46
  141. package/dist/lib/init-template-base.d.ts.map +0 -1
  142. package/dist/lib/init-template-base.js +0 -281
  143. package/dist/lib/init-template-base.js.map +0 -1
  144. package/dist/lib/liquid-actions.d.ts +0 -37
  145. package/dist/lib/liquid-actions.d.ts.map +0 -1
  146. package/dist/lib/liquid-actions.js +0 -148
  147. package/dist/lib/liquid-actions.js.map +0 -1
  148. package/dist/lib/liquid-build-configurations.d.ts +0 -47
  149. package/dist/lib/liquid-build-configurations.d.ts.map +0 -1
  150. package/dist/lib/liquid-build-configurations.js +0 -282
  151. package/dist/lib/liquid-build-configurations.js.map +0 -1
  152. package/dist/lib/liquid-drop.d.ts +0 -13
  153. package/dist/lib/liquid-drop.d.ts.map +0 -1
  154. package/dist/lib/liquid-drop.js +0 -56
  155. package/dist/lib/liquid-drop.js.map +0 -1
  156. package/dist/lib/liquid-engine.d.ts +0 -5
  157. package/dist/lib/liquid-engine.d.ts.map +0 -1
  158. package/dist/lib/liquid-engine.js +0 -85
  159. package/dist/lib/liquid-engine.js.map +0 -1
  160. package/dist/lib/liquid-package.d.ts +0 -17
  161. package/dist/lib/liquid-package.d.ts.map +0 -1
  162. package/dist/lib/liquid-package.js +0 -70
  163. package/dist/lib/liquid-package.js.map +0 -1
  164. package/dist/lib/package.d.ts +0 -66
  165. package/dist/lib/package.d.ts.map +0 -1
  166. package/dist/lib/package.js +0 -700
  167. package/dist/lib/package.js.map +0 -1
  168. package/dist/lib/perform-substitutions.d.ts +0 -20
  169. package/dist/lib/perform-substitutions.d.ts.map +0 -1
  170. package/dist/lib/perform-substitutions.js +0 -85
  171. package/dist/lib/perform-substitutions.js.map +0 -1
  172. package/dist/lib/policies.d.ts +0 -14
  173. package/dist/lib/policies.d.ts.map +0 -1
  174. package/dist/lib/policies.js +0 -33
  175. package/dist/lib/policies.js.map +0 -1
  176. package/dist/lib/substitutions-variables.d.ts +0 -117
  177. package/dist/lib/substitutions-variables.d.ts.map +0 -1
  178. package/dist/lib/substitutions-variables.js.map +0 -1
  179. package/dist/lib/types.d.ts.map +0 -1
  180. package/dist/lib/types.js +0 -13
  181. package/dist/lib/types.js.map +0 -1
  182. package/dist/lib/utils.d.ts +0 -30
  183. package/dist/lib/utils.d.ts.map +0 -1
  184. package/dist/lib/utils.js +0 -70
  185. package/dist/lib/utils.js.map +0 -1
  186. package/dist/tsconfig.tsbuildinfo +0 -1
  187. package/src/lib/errors.ts +0 -29
  188. package/src/lib/functions/chmod-recursive.ts +0 -103
  189. package/src/lib/functions/perform-substitutions.ts +0 -116
  190. package/src/lib/functions/utils.ts +0 -88
  191. package/src/lib/init-template-base.ts +0 -408
  192. package/src/lib/liquid-actions.ts +0 -223
  193. package/src/lib/liquid-build-configurations.ts +0 -433
  194. package/src/lib/liquid-drop.ts +0 -99
  195. package/src/lib/liquid-engine.ts +0 -135
  196. package/src/lib/liquid-package.ts +0 -108
  197. package/src/lib/package.ts +0 -947
  198. package/src/lib/policies.ts +0 -51
  199. package/src/lib/substitutions-variables.ts +0 -177
  200. package/src/lib/types.ts +0 -109
  201. package/src/package.json +0 -3
  202. package/src/tsconfig.json +0 -10
@@ -0,0 +1,519 @@
1
+ /*
2
+ * This file is part of the xPack project (http://xpack.github.io).
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software
6
+ * for any purpose is hereby granted, under the terms of the MIT license.
7
+ *
8
+ * If a copy of the license was not distributed with this file, it can
9
+ * be obtained from https://opensource.org/license/mit.
10
+ */
11
+
12
+ // ============================================================================
13
+
14
+ /**
15
+ * Represents a JSON property value.
16
+ */
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ export type JsonPropertyValue = any
19
+
20
+ /**
21
+ * Represents a JSON map of properties.
22
+ */
23
+ export type JsonProperties = Record<string, JsonPropertyValue>
24
+
25
+ /**
26
+ * Represents a JSON array of build configuration names to inherit from.
27
+ */
28
+ export type JsonBuildConfigurationInherits = string[]
29
+
30
+ /**
31
+ * Represents a JSON map of npm scripts.
32
+ */
33
+ export type JsonScripts = Record<string, string>
34
+
35
+ /**
36
+ * Represents a JSON map of dependencies.
37
+ */
38
+ export type JsonDependencies = Record<string, JsonDependenciesContent>
39
+
40
+ /**
41
+ * Represents a JSON dependency content as a string or extended definition.
42
+ */
43
+ export type JsonDependenciesContent = string | JsonDependencyExtended
44
+
45
+ /**
46
+ * Represents a JSON extended dependency definition.
47
+ *
48
+ * @remarks
49
+ * Extended dependency format introduced in xpm 0.16.0 to support richer
50
+ * dependency metadata beyond simple version strings. Allows specifying
51
+ * platform constraints and local installation modes.
52
+ *
53
+ * Example usage in `package.json`:
54
+ * ```json
55
+ * "dependencies": {
56
+ * "@scope/package": {
57
+ * "specifier": "^1.0.0",
58
+ * "platforms": ["linux-x64", "darwin-x64"],
59
+ * "local": "link"
60
+ * }
61
+ * }
62
+ * ```
63
+ *
64
+ * Platform filtering enables platform-specific dependencies, useful for
65
+ * binary packages that only work on certain operating systems or
66
+ * architectures. Local installation modes control how dependencies are
67
+ * installed in the workspace (symbolic link vs. file copy).
68
+ */
69
+ export interface JsonDependencyExtended {
70
+ /**
71
+ * The dependency version specifier.
72
+ */
73
+ specifier: string
74
+ /**
75
+ * The local installation mode, if applicable.
76
+ */
77
+ local?: 'link' | 'copy'
78
+ /**
79
+ * The supported platforms for the dependency.
80
+ */
81
+ platforms?: string | string[]
82
+ }
83
+
84
+ // --------------------------------------------------------------------------
85
+
86
+ /**
87
+ * Represents a JSON action content as a string or string array.
88
+ */
89
+ export type JsonActionContent = string | string[]
90
+
91
+ /**
92
+ * Represents a JSON template action with a matrix for expansion.
93
+ *
94
+ * @remarks
95
+ * Template actions use matrix parameters to generate multiple action
96
+ * variants from a single definition via Cartesian product expansion. This
97
+ * enables creating platform-specific or configuration-specific actions
98
+ * without duplication.
99
+ *
100
+ * Example usage in `package.json`:
101
+ * ```json
102
+ * "actions": {
103
+ * "build-{{ matrix.platform }}": {
104
+ * "matrix": {
105
+ * "platform": ["linux", "darwin", "win32"]
106
+ * },
107
+ * "template": "make build PLATFORM={{ matrix.platform }}"
108
+ * }
109
+ * }
110
+ * ```
111
+ *
112
+ * This generates three actions: `build-linux`, `build-darwin`, and
113
+ * `build-win32`.
114
+ * Matrix values are accessible in both the action name and template content
115
+ * via `{{ matrix.key }}` Liquid syntax.
116
+ */
117
+ export interface JsonActionTemplate {
118
+ /**
119
+ * The matrix of parameters used to generate action variants.
120
+ */
121
+ matrix: JsonTemplateMatrix
122
+ /**
123
+ * The action template content.
124
+ */
125
+ template: JsonActionContent
126
+ }
127
+
128
+ /**
129
+ * Represents a JSON action definition or a template of one.
130
+ */
131
+ export type JsonAction = JsonActionContent | JsonActionTemplate
132
+
133
+ /**
134
+ * Represents a JSON map of action definitions.
135
+ */
136
+ export type JsonActions = Record<string, JsonAction>
137
+
138
+ // --------------------------------------------------------------------------
139
+
140
+ /**
141
+ * Represents a JSON build configuration definition.
142
+ */
143
+ export interface JsonBuildConfigurationContent {
144
+ /**
145
+ * The configurations to inherit from.
146
+ */
147
+ inherits?: JsonBuildConfigurationInherits | string
148
+ /**
149
+ * Deprecated alias of {@link JsonBuildConfigurationContent.inherits}.
150
+ */
151
+ inherit?: JsonBuildConfigurationInherits | string
152
+ /**
153
+ * Whether the configuration should be hidden.
154
+ */
155
+ hidden?: boolean
156
+ /**
157
+ * The properties map for substitutions.
158
+ */
159
+ properties?: JsonProperties
160
+ /**
161
+ * The action definitions for this configuration.
162
+ */
163
+ actions?: JsonActions
164
+ /**
165
+ * The dependencies for this configuration.
166
+ */
167
+ dependencies?: JsonDependencies
168
+ /**
169
+ * The development dependencies for this configuration.
170
+ */
171
+ devDependencies?: JsonDependencies
172
+
173
+ /**
174
+ * Allows additional configuration properties.
175
+ */
176
+ [key: string]: JsonPropertyValue
177
+ }
178
+
179
+ /**
180
+ * Represents a JSON template build configuration with matrix expansion.
181
+ *
182
+ * @remarks
183
+ * Template build configurations use matrix parameters to generate multiple
184
+ * configuration variants from a single definition via Cartesian product
185
+ * expansion. Common for cross-compilation scenarios where multiple
186
+ * architecture or platform combinations are needed.
187
+ *
188
+ * Example usage in `package.json`:
189
+ * ```json
190
+ * "buildConfigurations": {
191
+ * "{{ matrix.os }}-{{ matrix.arch }}": {
192
+ * "matrix": {
193
+ * "os": ["linux", "darwin"],
194
+ * "arch": ["x64", "arm64"]
195
+ * },
196
+ * "template": {
197
+ * "properties": {
198
+ * "target": "{{ matrix.os }}-{{ matrix.arch }}"
199
+ * }
200
+ * }
201
+ * }
202
+ * }
203
+ * ```
204
+ *
205
+ * This generates four configurations: `linux-x64`, `linux-arm64`,
206
+ * `darwin-x64`, and `darwin-arm64`, each with matrix values available
207
+ * for property substitution.
208
+ */
209
+ export interface JsonBuildConfigurationTemplate {
210
+ /**
211
+ * The matrix of parameters used to generate configuration variants.
212
+ */
213
+ matrix: JsonTemplateMatrix
214
+ /**
215
+ * The configuration template content.
216
+ */
217
+ template: JsonBuildConfigurationContent
218
+ }
219
+
220
+ /**
221
+ * Represents a matrix of parameters for template
222
+ * expansion.
223
+ *
224
+ * @remarks
225
+ * The matrix defines parameter arrays used to generate multiple template
226
+ * variants through Cartesian product expansion. Each key
227
+ * represents a parameter name, and its value is an array of possible
228
+ * values for that parameter.
229
+ *
230
+ * Matrix expansion rules:
231
+ *
232
+ * <ul>
233
+ * <li>Each parameter array is combined with all others to create every
234
+ * possible combination.</li>
235
+ * <li>Matrix values are accessible in template names and template
236
+ * content via <code>\{\{ matrix.parameterName \}\}</code> Liquid
237
+ * syntax.</li>
238
+ * <li>The number of generated template variants equals the product of all
239
+ * array lengths.</li>
240
+ * </ul>
241
+ *
242
+ * Example:
243
+ * ```js
244
+ * {
245
+ * "os": ["linux", "darwin"],
246
+ * "arch": ["x64", "arm64"]
247
+ * }
248
+ * ```
249
+ *
250
+ * This generates 4 template variants (2 × 2): `linux-x64`, `linux-arm64`,
251
+ * `darwin-x64`, `darwin-arm64`.
252
+ */
253
+ export type JsonTemplateMatrix = Record<string, JsonTemplateMatrixContent>
254
+
255
+ /**
256
+ * Represents an array of string values for a single matrix parameter.
257
+ *
258
+ * @remarks
259
+ * Each matrix parameter defined in {@link JsonTemplateMatrix} contains an
260
+ * array of string values that will be used during Cartesian product
261
+ * expansion. All values must be strings to ensure consistent template
262
+ * substitution via Liquid syntax.
263
+ *
264
+ * Example for an operating system parameter:
265
+ * ```js
266
+ * ["linux", "darwin", "win32"]
267
+ * ```
268
+ *
269
+ * During template expansion, each value is combined with values from other
270
+ * matrix parameters to generate all possible combinations.
271
+ */
272
+ export type JsonTemplateMatrixContent = string[]
273
+
274
+ /**
275
+ * Represents a JSON build configuration definition or a template of one.
276
+ */
277
+ export type JsonBuildConfiguration =
278
+ | JsonBuildConfigurationContent
279
+ | JsonBuildConfigurationTemplate
280
+
281
+ /**
282
+ * Represents a JSON map of build configuration definitions.
283
+ */
284
+ export type JsonBuildConfigurations = Record<string, JsonBuildConfiguration>
285
+
286
+ // --------------------------------------------------------------------------
287
+
288
+ /**
289
+ * Represents a JSON xpm-specific section in `package.json`.
290
+ *
291
+ * @remarks
292
+ * The `xpack` section extends standard npm `package.json` with xpm-specific
293
+ * metadata for binary package management, build automation, and
294
+ * cross-platform development workflows.
295
+ *
296
+ * Key capabilities:
297
+ *
298
+ * <ul>
299
+ * <li><b>Binary packages:</b> Define platform-specific binary distributions
300
+ * with download URLs, checksums, and installation configuration.</li>
301
+ * <li><b>Build configurations:</b> Organize multiple build targets (debug,
302
+ * release,
303
+ * platform variants) with inherited properties and dependencies.</li>
304
+ * <li><b>Actions:</b> Define build automation commands that can reference
305
+ * properties and build configuration context via Liquid templates.</li>
306
+ * <li><b>Properties:</b> User-defined configuration values accessible
307
+ * throughout the package via template substitution.</li>
308
+ * <li><b>Version requirements:</b> Specify minimum <b>xpm</b> version for
309
+ * feature compatibility and policy enforcement.</li>
310
+ * </ul>
311
+ *
312
+ * The `xpack` section is optional in npm packages but required for packages
313
+ * using xpm-specific features like build configurations or binary
314
+ * distributions.
315
+ */
316
+ export interface JsonXpack {
317
+ /**
318
+ * The minimum required <b>xpm</b> version.
319
+ */
320
+ minimumXpmRequired?: string
321
+ /**
322
+ * The binaries definition, if the package provides binaries.
323
+ */
324
+ binaries?: JsonXpmBinaries
325
+ /**
326
+ * The executables map.
327
+ */
328
+ executables?: Record<string, string>
329
+ /**
330
+ * Deprecated alias of {@link JsonXpack.executables}.
331
+ */
332
+ bin?: Record<string, string> // Deprecated, use executables
333
+ /**
334
+ * The dependencies map.
335
+ */
336
+ dependencies?: JsonDependencies
337
+ /**
338
+ * The development dependencies map.
339
+ */
340
+ devDependencies?: JsonDependencies
341
+ /**
342
+ * The properties map.
343
+ */
344
+ properties?: JsonProperties
345
+ /**
346
+ * The action definitions.
347
+ */
348
+ actions?: JsonActions
349
+ /**
350
+ * The build configurations map.
351
+ */
352
+ buildConfigurations?: JsonBuildConfigurations
353
+ }
354
+
355
+ /**
356
+ * Represents a JSON map of binaries platforms.
357
+ */
358
+ export type JsonXpmBinariesPlatforms = Record<string, JsonXpmPlatformFile>
359
+
360
+ /**
361
+ * Represents a JSON binaries definition in `package.`
362
+ *
363
+ * @remarks
364
+ * Configures binary package distribution for tools, SDKs, or compiled
365
+ * applications. <b>xpm</b> downloads platform-specific archives, verifies
366
+ * their integrity, and extracts them to the specified destination.
367
+ *
368
+ * Example usage in `package.json`:
369
+ * ```json
370
+ * "binaries": {
371
+ * "destination": ".content",
372
+ * "baseUrl": "https://github.com/org/repo/releases/download/v1.0.0",
373
+ * "skip": 1,
374
+ * "platforms": {
375
+ * "linux-x64": {
376
+ * "fileName": "tool-linux-x64.tar.gz",
377
+ * "sha256": "abc123..."
378
+ * }
379
+ * }
380
+ * }
381
+ * ```
382
+ *
383
+ * The skip parameter removes leading path segments from archive entries
384
+ * during extraction, useful for archives with wrapper folders. Checksums
385
+ * ensure downloaded files haven't been corrupted or tampered with.
386
+ */
387
+ export interface JsonXpmBinaries {
388
+ /**
389
+ * The destination folder for extracted binaries.
390
+ */
391
+ destination: string
392
+ /**
393
+ * The base URL used to download binaries.
394
+ */
395
+ baseUrl: string
396
+ /**
397
+ * The number of path segments to skip when extracting.
398
+ */
399
+ skip?: number
400
+ /**
401
+ * The platforms map for available binaries.
402
+ */
403
+ platforms: JsonXpmBinariesPlatforms
404
+ }
405
+
406
+ /**
407
+ * Represents a JSON platform-specific binary file definition.
408
+ */
409
+ export interface JsonXpmPlatformFile {
410
+ /**
411
+ * The binary archive file name.
412
+ */
413
+ fileName: string
414
+ /**
415
+ * The SHA-256 checksum for integrity verification.
416
+ */
417
+ sha256?: string
418
+ /**
419
+ * The SHA-512 checksum for integrity verification.
420
+ */
421
+ sha512?: string
422
+ /**
423
+ * Optional base URL override for this platform.
424
+ */
425
+ baseUrl?: string
426
+ /**
427
+ * The number of path segments to skip when extracting.
428
+ */
429
+ skip?: number
430
+ }
431
+
432
+ /**
433
+ * Represents a JSON npm `package.json` structure.
434
+ */
435
+ export interface JsonNpmPackage {
436
+ /**
437
+ * The package name.
438
+ */
439
+ name?: string
440
+ /**
441
+ * The package version.
442
+ */
443
+ version?: string
444
+ /**
445
+ * The npm scripts map.
446
+ */
447
+ scripts?: JsonScripts
448
+ /**
449
+ * The binary entry points.
450
+ */
451
+ bin?: Record<string, string> | string
452
+ /**
453
+ * The dependencies map.
454
+ */
455
+ dependencies?: JsonDependencies
456
+ /**
457
+ * The development dependencies map.
458
+ */
459
+ devDependencies?: JsonDependencies
460
+
461
+ /**
462
+ * Allows additional `package.json` properties.
463
+ */
464
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
465
+ [key: string]: any // Allow any additional property
466
+ }
467
+
468
+ /**
469
+ * Represents a JSON <b>xpm</b> `package.json` structure.
470
+ *
471
+ * @remarks
472
+ * Combines standard npm `package.json` properties with xpm-specific
473
+ * extensions via the required `xpack` section. All <b>xpm</b> packages are
474
+ * valid npm packages, but not all npm packages are <b>xpm</b> packages.
475
+ *
476
+ * An <b>xpm</b> package can be:
477
+ *
478
+ * <ul>
479
+ * <li><b>A source package:</b> Provides reusable code or resources for other
480
+ * packages. It contains code, build configurations,
481
+ * and actions.</li>
482
+ * <li><b>A binary package:</b> Distributes pre-built binaries for multiple
483
+ * platforms with automated installation.</li>
484
+ * </ul>
485
+ *
486
+ * The presence of the `xpack` section enables <b>xpm</b>-specific features
487
+ * like template-based build configurations, matrix expansion, property
488
+ * substitution, and platform-specific binary distribution. Standard npm
489
+ * fields (name, version, etc.) are used for package
490
+ * identification.
491
+ */
492
+ export interface JsonXpmPackage extends JsonNpmPackage {
493
+ /**
494
+ * The xpm-specific configuration section.
495
+ */
496
+ xpack: JsonXpack
497
+ }
498
+
499
+ // --------------------------------------------------------------------------
500
+
501
+ /**
502
+ * Represents a JSON npm package specifier.
503
+ */
504
+ export interface JsonPackageSpecifier {
505
+ /**
506
+ * The package scope, if present.
507
+ */
508
+ scope?: string
509
+ /**
510
+ * The package name.
511
+ */
512
+ name?: string
513
+ /**
514
+ * The version specifier, if present.
515
+ */
516
+ version?: string
517
+ }
518
+
519
+ // ----------------------------------------------------------------------------