@hominis/fireforge 0.9.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 (316) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE.md +294 -0
  3. package/README.md +435 -0
  4. package/dist/bin/fireforge.d.ts +10 -0
  5. package/dist/bin/fireforge.js +29 -0
  6. package/dist/src/cli.d.ts +33 -0
  7. package/dist/src/cli.js +180 -0
  8. package/dist/src/commands/bootstrap.d.ts +9 -0
  9. package/dist/src/commands/bootstrap.js +73 -0
  10. package/dist/src/commands/build.d.ts +11 -0
  11. package/dist/src/commands/build.js +102 -0
  12. package/dist/src/commands/config.d.ts +13 -0
  13. package/dist/src/commands/config.js +135 -0
  14. package/dist/src/commands/discard.d.ts +12 -0
  15. package/dist/src/commands/discard.js +84 -0
  16. package/dist/src/commands/doctor.d.ts +18 -0
  17. package/dist/src/commands/doctor.js +356 -0
  18. package/dist/src/commands/download.d.ts +11 -0
  19. package/dist/src/commands/download.js +127 -0
  20. package/dist/src/commands/export-all.d.ts +11 -0
  21. package/dist/src/commands/export-all.js +122 -0
  22. package/dist/src/commands/export-shared.d.ts +48 -0
  23. package/dist/src/commands/export-shared.js +208 -0
  24. package/dist/src/commands/export.d.ts +13 -0
  25. package/dist/src/commands/export.js +178 -0
  26. package/dist/src/commands/furnace/apply.d.ts +7 -0
  27. package/dist/src/commands/furnace/apply.js +80 -0
  28. package/dist/src/commands/furnace/create.d.ts +8 -0
  29. package/dist/src/commands/furnace/create.js +377 -0
  30. package/dist/src/commands/furnace/deploy.d.ts +8 -0
  31. package/dist/src/commands/furnace/deploy.js +338 -0
  32. package/dist/src/commands/furnace/diff.d.ts +7 -0
  33. package/dist/src/commands/furnace/diff.js +119 -0
  34. package/dist/src/commands/furnace/index.d.ts +16 -0
  35. package/dist/src/commands/furnace/index.js +121 -0
  36. package/dist/src/commands/furnace/list.d.ts +5 -0
  37. package/dist/src/commands/furnace/list.js +65 -0
  38. package/dist/src/commands/furnace/override.d.ts +8 -0
  39. package/dist/src/commands/furnace/override.js +188 -0
  40. package/dist/src/commands/furnace/preview.d.ts +7 -0
  41. package/dist/src/commands/furnace/preview.js +96 -0
  42. package/dist/src/commands/furnace/remove.d.ts +8 -0
  43. package/dist/src/commands/furnace/remove.js +159 -0
  44. package/dist/src/commands/furnace/scan.d.ts +5 -0
  45. package/dist/src/commands/furnace/scan.js +112 -0
  46. package/dist/src/commands/furnace/status.d.ts +7 -0
  47. package/dist/src/commands/furnace/status.js +137 -0
  48. package/dist/src/commands/furnace/validate.d.ts +6 -0
  49. package/dist/src/commands/furnace/validate.js +91 -0
  50. package/dist/src/commands/furnace/validation-output.d.ts +7 -0
  51. package/dist/src/commands/furnace/validation-output.js +22 -0
  52. package/dist/src/commands/import.d.ts +11 -0
  53. package/dist/src/commands/import.js +241 -0
  54. package/dist/src/commands/lint.d.ts +10 -0
  55. package/dist/src/commands/lint.js +118 -0
  56. package/dist/src/commands/package.d.ts +11 -0
  57. package/dist/src/commands/package.js +80 -0
  58. package/dist/src/commands/re-export.d.ts +12 -0
  59. package/dist/src/commands/re-export.js +242 -0
  60. package/dist/src/commands/rebase/abort.d.ts +7 -0
  61. package/dist/src/commands/rebase/abort.js +49 -0
  62. package/dist/src/commands/rebase/confirm.d.ts +18 -0
  63. package/dist/src/commands/rebase/confirm.js +33 -0
  64. package/dist/src/commands/rebase/continue.d.ts +7 -0
  65. package/dist/src/commands/rebase/continue.js +81 -0
  66. package/dist/src/commands/rebase/index.d.ts +22 -0
  67. package/dist/src/commands/rebase/index.js +127 -0
  68. package/dist/src/commands/rebase/patch-loop.d.ts +9 -0
  69. package/dist/src/commands/rebase/patch-loop.js +135 -0
  70. package/dist/src/commands/rebase/summary.d.ts +12 -0
  71. package/dist/src/commands/rebase/summary.js +43 -0
  72. package/dist/src/commands/rebase.d.ts +4 -0
  73. package/dist/src/commands/rebase.js +6 -0
  74. package/dist/src/commands/register.d.ts +13 -0
  75. package/dist/src/commands/register.js +67 -0
  76. package/dist/src/commands/reset.d.ts +11 -0
  77. package/dist/src/commands/reset.js +83 -0
  78. package/dist/src/commands/resolve.d.ts +9 -0
  79. package/dist/src/commands/resolve.js +124 -0
  80. package/dist/src/commands/run.d.ts +9 -0
  81. package/dist/src/commands/run.js +91 -0
  82. package/dist/src/commands/setup-support.d.ts +23 -0
  83. package/dist/src/commands/setup-support.js +310 -0
  84. package/dist/src/commands/setup.d.ts +11 -0
  85. package/dist/src/commands/setup.js +94 -0
  86. package/dist/src/commands/status.d.ts +11 -0
  87. package/dist/src/commands/status.js +268 -0
  88. package/dist/src/commands/test.d.ts +12 -0
  89. package/dist/src/commands/test.js +182 -0
  90. package/dist/src/commands/token-coverage.d.ts +5 -0
  91. package/dist/src/commands/token-coverage.js +57 -0
  92. package/dist/src/commands/token.d.ts +14 -0
  93. package/dist/src/commands/token.js +121 -0
  94. package/dist/src/commands/watch.d.ts +9 -0
  95. package/dist/src/commands/watch.js +112 -0
  96. package/dist/src/commands/wire.d.ts +13 -0
  97. package/dist/src/commands/wire.js +149 -0
  98. package/dist/src/core/ast-utils.d.ts +47 -0
  99. package/dist/src/core/ast-utils.js +57 -0
  100. package/dist/src/core/brand-validation.d.ts +7 -0
  101. package/dist/src/core/brand-validation.js +15 -0
  102. package/dist/src/core/branding.d.ts +49 -0
  103. package/dist/src/core/branding.js +229 -0
  104. package/dist/src/core/browser-wire.d.ts +40 -0
  105. package/dist/src/core/browser-wire.js +66 -0
  106. package/dist/src/core/build-prepare.d.ts +25 -0
  107. package/dist/src/core/build-prepare.js +93 -0
  108. package/dist/src/core/config-mutate.d.ts +15 -0
  109. package/dist/src/core/config-mutate.js +51 -0
  110. package/dist/src/core/config-paths.d.ts +28 -0
  111. package/dist/src/core/config-paths.js +65 -0
  112. package/dist/src/core/config-state.d.ts +28 -0
  113. package/dist/src/core/config-state.js +152 -0
  114. package/dist/src/core/config-validate.d.ts +11 -0
  115. package/dist/src/core/config-validate.js +141 -0
  116. package/dist/src/core/config.d.ts +39 -0
  117. package/dist/src/core/config.js +70 -0
  118. package/dist/src/core/file-lock.d.ts +11 -0
  119. package/dist/src/core/file-lock.js +80 -0
  120. package/dist/src/core/firefox-archive.d.ts +40 -0
  121. package/dist/src/core/firefox-archive.js +63 -0
  122. package/dist/src/core/firefox-cache.d.ts +23 -0
  123. package/dist/src/core/firefox-cache.js +134 -0
  124. package/dist/src/core/firefox-download.d.ts +21 -0
  125. package/dist/src/core/firefox-download.js +129 -0
  126. package/dist/src/core/firefox-extract.d.ts +21 -0
  127. package/dist/src/core/firefox-extract.js +53 -0
  128. package/dist/src/core/firefox.d.ts +34 -0
  129. package/dist/src/core/firefox.js +78 -0
  130. package/dist/src/core/furnace-apply-helpers.d.ts +21 -0
  131. package/dist/src/core/furnace-apply-helpers.js +244 -0
  132. package/dist/src/core/furnace-apply.d.ts +16 -0
  133. package/dist/src/core/furnace-apply.js +147 -0
  134. package/dist/src/core/furnace-config.d.ts +94 -0
  135. package/dist/src/core/furnace-config.js +372 -0
  136. package/dist/src/core/furnace-constants.d.ts +4 -0
  137. package/dist/src/core/furnace-constants.js +6 -0
  138. package/dist/src/core/furnace-registration-ast.d.ts +24 -0
  139. package/dist/src/core/furnace-registration-ast.js +218 -0
  140. package/dist/src/core/furnace-registration-remove.d.ts +14 -0
  141. package/dist/src/core/furnace-registration-remove.js +89 -0
  142. package/dist/src/core/furnace-registration-validate.d.ts +20 -0
  143. package/dist/src/core/furnace-registration-validate.js +40 -0
  144. package/dist/src/core/furnace-registration.d.ts +29 -0
  145. package/dist/src/core/furnace-registration.js +96 -0
  146. package/dist/src/core/furnace-rollback.d.ts +20 -0
  147. package/dist/src/core/furnace-rollback.js +66 -0
  148. package/dist/src/core/furnace-scanner.d.ts +40 -0
  149. package/dist/src/core/furnace-scanner.js +143 -0
  150. package/dist/src/core/furnace-stories.d.ts +37 -0
  151. package/dist/src/core/furnace-stories.js +185 -0
  152. package/dist/src/core/furnace-validate-accessibility.d.ts +6 -0
  153. package/dist/src/core/furnace-validate-accessibility.js +32 -0
  154. package/dist/src/core/furnace-validate-checks.d.ts +4 -0
  155. package/dist/src/core/furnace-validate-checks.js +7 -0
  156. package/dist/src/core/furnace-validate-compatibility.d.ts +6 -0
  157. package/dist/src/core/furnace-validate-compatibility.js +57 -0
  158. package/dist/src/core/furnace-validate-helpers.d.ts +28 -0
  159. package/dist/src/core/furnace-validate-helpers.js +129 -0
  160. package/dist/src/core/furnace-validate-registration.d.ts +37 -0
  161. package/dist/src/core/furnace-validate-registration.js +220 -0
  162. package/dist/src/core/furnace-validate-structure.d.ts +6 -0
  163. package/dist/src/core/furnace-validate-structure.js +66 -0
  164. package/dist/src/core/furnace-validate.d.ts +16 -0
  165. package/dist/src/core/furnace-validate.js +103 -0
  166. package/dist/src/core/git-base.d.ts +47 -0
  167. package/dist/src/core/git-base.js +50 -0
  168. package/dist/src/core/git-diff.d.ts +63 -0
  169. package/dist/src/core/git-diff.js +246 -0
  170. package/dist/src/core/git-file-ops.d.ts +65 -0
  171. package/dist/src/core/git-file-ops.js +141 -0
  172. package/dist/src/core/git-status.d.ts +65 -0
  173. package/dist/src/core/git-status.js +163 -0
  174. package/dist/src/core/git.d.ts +113 -0
  175. package/dist/src/core/git.js +363 -0
  176. package/dist/src/core/license-headers.d.ts +36 -0
  177. package/dist/src/core/license-headers.js +83 -0
  178. package/dist/src/core/mach-build-artifacts.d.ts +29 -0
  179. package/dist/src/core/mach-build-artifacts.js +117 -0
  180. package/dist/src/core/mach-mozconfig.d.ts +17 -0
  181. package/dist/src/core/mach-mozconfig.js +50 -0
  182. package/dist/src/core/mach-python.d.ts +16 -0
  183. package/dist/src/core/mach-python.js +126 -0
  184. package/dist/src/core/mach.d.ts +106 -0
  185. package/dist/src/core/mach.js +166 -0
  186. package/dist/src/core/manifest-helpers.d.ts +25 -0
  187. package/dist/src/core/manifest-helpers.js +96 -0
  188. package/dist/src/core/manifest-register.d.ts +30 -0
  189. package/dist/src/core/manifest-register.js +65 -0
  190. package/dist/src/core/manifest-rules.d.ts +39 -0
  191. package/dist/src/core/manifest-rules.js +151 -0
  192. package/dist/src/core/manifest-tokenizers.d.ts +34 -0
  193. package/dist/src/core/manifest-tokenizers.js +84 -0
  194. package/dist/src/core/parser-fallback.d.ts +36 -0
  195. package/dist/src/core/parser-fallback.js +43 -0
  196. package/dist/src/core/patch-apply-fuzz.d.ts +29 -0
  197. package/dist/src/core/patch-apply-fuzz.js +70 -0
  198. package/dist/src/core/patch-apply.d.ts +46 -0
  199. package/dist/src/core/patch-apply.js +235 -0
  200. package/dist/src/core/patch-export.d.ts +99 -0
  201. package/dist/src/core/patch-export.js +314 -0
  202. package/dist/src/core/patch-files.d.ts +11 -0
  203. package/dist/src/core/patch-files.js +51 -0
  204. package/dist/src/core/patch-lint.d.ts +72 -0
  205. package/dist/src/core/patch-lint.js +403 -0
  206. package/dist/src/core/patch-lock.d.ts +8 -0
  207. package/dist/src/core/patch-lock.js +29 -0
  208. package/dist/src/core/patch-manifest-consistency.d.ts +24 -0
  209. package/dist/src/core/patch-manifest-consistency.js +135 -0
  210. package/dist/src/core/patch-manifest-io.d.ts +36 -0
  211. package/dist/src/core/patch-manifest-io.js +77 -0
  212. package/dist/src/core/patch-manifest-query.d.ts +48 -0
  213. package/dist/src/core/patch-manifest-query.js +124 -0
  214. package/dist/src/core/patch-manifest-validate.d.ts +22 -0
  215. package/dist/src/core/patch-manifest-validate.js +72 -0
  216. package/dist/src/core/patch-manifest.d.ts +11 -0
  217. package/dist/src/core/patch-manifest.js +12 -0
  218. package/dist/src/core/patch-parse.d.ts +43 -0
  219. package/dist/src/core/patch-parse.js +143 -0
  220. package/dist/src/core/patch-transform.d.ts +21 -0
  221. package/dist/src/core/patch-transform.js +138 -0
  222. package/dist/src/core/rebase-session.d.ts +47 -0
  223. package/dist/src/core/rebase-session.js +65 -0
  224. package/dist/src/core/register-browser-content.d.ts +11 -0
  225. package/dist/src/core/register-browser-content.js +116 -0
  226. package/dist/src/core/register-module.d.ts +11 -0
  227. package/dist/src/core/register-module.js +76 -0
  228. package/dist/src/core/register-shared-css.d.ts +11 -0
  229. package/dist/src/core/register-shared-css.js +117 -0
  230. package/dist/src/core/register-test-manifest.d.ts +18 -0
  231. package/dist/src/core/register-test-manifest.js +99 -0
  232. package/dist/src/core/state-file.d.ts +4 -0
  233. package/dist/src/core/state-file.js +25 -0
  234. package/dist/src/core/token-coverage.d.ts +12 -0
  235. package/dist/src/core/token-coverage.js +74 -0
  236. package/dist/src/core/token-manager.d.ts +55 -0
  237. package/dist/src/core/token-manager.js +387 -0
  238. package/dist/src/core/wire-destroy.d.ts +21 -0
  239. package/dist/src/core/wire-destroy.js +103 -0
  240. package/dist/src/core/wire-dom-fragment.d.ts +23 -0
  241. package/dist/src/core/wire-dom-fragment.js +129 -0
  242. package/dist/src/core/wire-init.d.ts +23 -0
  243. package/dist/src/core/wire-init.js +201 -0
  244. package/dist/src/core/wire-subscript.d.ts +20 -0
  245. package/dist/src/core/wire-subscript.js +134 -0
  246. package/dist/src/core/wire-targets.d.ts +7 -0
  247. package/dist/src/core/wire-targets.js +9 -0
  248. package/dist/src/core/wire-utils.d.ts +88 -0
  249. package/dist/src/core/wire-utils.js +279 -0
  250. package/dist/src/errors/base.d.ts +60 -0
  251. package/dist/src/errors/base.js +87 -0
  252. package/dist/src/errors/build.d.ts +52 -0
  253. package/dist/src/errors/build.js +114 -0
  254. package/dist/src/errors/codes.d.ts +29 -0
  255. package/dist/src/errors/codes.js +30 -0
  256. package/dist/src/errors/config.d.ts +31 -0
  257. package/dist/src/errors/config.js +61 -0
  258. package/dist/src/errors/download.d.ts +42 -0
  259. package/dist/src/errors/download.js +95 -0
  260. package/dist/src/errors/furnace.d.ts +10 -0
  261. package/dist/src/errors/furnace.js +22 -0
  262. package/dist/src/errors/git.d.ts +41 -0
  263. package/dist/src/errors/git.js +99 -0
  264. package/dist/src/errors/patch.d.ts +10 -0
  265. package/dist/src/errors/patch.js +26 -0
  266. package/dist/src/errors/rebase.d.ts +20 -0
  267. package/dist/src/errors/rebase.js +30 -0
  268. package/dist/src/index.d.ts +21 -0
  269. package/dist/src/index.js +21 -0
  270. package/dist/src/types/cli.d.ts +14 -0
  271. package/dist/src/types/cli.js +2 -0
  272. package/dist/src/types/commands/index.d.ts +6 -0
  273. package/dist/src/types/commands/index.js +6 -0
  274. package/dist/src/types/commands/options.d.ts +239 -0
  275. package/dist/src/types/commands/options.js +6 -0
  276. package/dist/src/types/commands/patches.d.ts +89 -0
  277. package/dist/src/types/commands/patches.js +6 -0
  278. package/dist/src/types/commands/project.d.ts +71 -0
  279. package/dist/src/types/commands/project.js +6 -0
  280. package/dist/src/types/config.d.ts +101 -0
  281. package/dist/src/types/config.js +2 -0
  282. package/dist/src/types/furnace.d.ts +158 -0
  283. package/dist/src/types/furnace.js +2 -0
  284. package/dist/src/types/index.d.ts +6 -0
  285. package/dist/src/types/index.js +6 -0
  286. package/dist/src/utils/errors.d.ts +2 -0
  287. package/dist/src/utils/errors.js +15 -0
  288. package/dist/src/utils/fs.d.ts +72 -0
  289. package/dist/src/utils/fs.js +179 -0
  290. package/dist/src/utils/logger.d.ts +58 -0
  291. package/dist/src/utils/logger.js +120 -0
  292. package/dist/src/utils/options.d.ts +8 -0
  293. package/dist/src/utils/options.js +16 -0
  294. package/dist/src/utils/package-root.d.ts +10 -0
  295. package/dist/src/utils/package-root.js +53 -0
  296. package/dist/src/utils/parse.d.ts +110 -0
  297. package/dist/src/utils/parse.js +200 -0
  298. package/dist/src/utils/paths.d.ts +10 -0
  299. package/dist/src/utils/paths.js +43 -0
  300. package/dist/src/utils/platform.d.ts +38 -0
  301. package/dist/src/utils/platform.js +56 -0
  302. package/dist/src/utils/process.d.ts +80 -0
  303. package/dist/src/utils/process.js +188 -0
  304. package/dist/src/utils/regex.d.ts +24 -0
  305. package/dist/src/utils/regex.js +40 -0
  306. package/dist/src/utils/validation.d.ts +133 -0
  307. package/dist/src/utils/validation.js +250 -0
  308. package/package.json +106 -0
  309. package/templates/configs/common.mozconfig +24 -0
  310. package/templates/configs/darwin.mozconfig +10 -0
  311. package/templates/configs/linux.mozconfig +12 -0
  312. package/templates/configs/win32.mozconfig +14 -0
  313. package/templates/licenses/0BSD.md +14 -0
  314. package/templates/licenses/EUPL-1.2.md +294 -0
  315. package/templates/licenses/GPL-2.0-or-later.md +339 -0
  316. package/templates/licenses/MPL-2.0.md +383 -0
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Checks whether a value is a string.
3
+ * @param value - Value to check
4
+ * @returns True if value is a string
5
+ */
6
+ export declare function isString(value: unknown): value is string;
7
+ /**
8
+ * Checks whether a value is a finite number (excludes NaN).
9
+ * @param value - Value to check
10
+ * @returns True if value is a finite number
11
+ */
12
+ export declare function isNumber(value: unknown): value is number;
13
+ /**
14
+ * Checks whether a value is a positive integer (greater than zero).
15
+ * @param value - Value to check
16
+ * @returns True if value is a positive integer
17
+ */
18
+ export declare function isPositiveInteger(value: unknown): value is number;
19
+ /**
20
+ * Checks whether a value is a boolean.
21
+ * @param value - Value to check
22
+ * @returns True if value is a boolean
23
+ */
24
+ export declare function isBoolean(value: unknown): value is boolean;
25
+ /**
26
+ * Checks whether a value is a non-null, non-array object.
27
+ * @param value - Value to check
28
+ * @returns True if value is a plain object
29
+ */
30
+ export declare function isObject(value: unknown): value is Record<string, unknown>;
31
+ /**
32
+ * Checks whether a value is an array.
33
+ * @param value - Value to check
34
+ * @returns True if value is an array
35
+ */
36
+ export declare function isArray(value: unknown): value is unknown[];
37
+ /**
38
+ * Asserts that a value is a string or throws.
39
+ * @param value - Value to check
40
+ * @param name - Name of the field for error messages
41
+ */
42
+ export declare function assertString(value: unknown, name: string): asserts value is string;
43
+ /**
44
+ * Asserts that a value is a non-null object or throws.
45
+ * @param value - Value to check
46
+ * @param name - Name of the field for error messages
47
+ */
48
+ export declare function assertObject(value: unknown, name: string): asserts value is Record<string, unknown>;
49
+ /**
50
+ * Validates a Firefox version string.
51
+ * Accepts formats like "146.0", "146.0.1", "140.0esr", "147.0b1"
52
+ */
53
+ export declare function isValidFirefoxVersion(version: string): boolean;
54
+ /**
55
+ * Validates a Firefox product string.
56
+ * Accepts: firefox, firefox-esr, firefox-beta
57
+ */
58
+ export declare function isValidFirefoxProduct(product: string): boolean;
59
+ /**
60
+ * Valid project license SPDX identifiers.
61
+ */
62
+ export declare const PROJECT_LICENSES: readonly ["EUPL-1.2", "MPL-2.0", "0BSD", "GPL-2.0-or-later"];
63
+ /**
64
+ * Validates a project license string.
65
+ */
66
+ export declare function isValidProjectLicense(license: string): license is (typeof PROJECT_LICENSES)[number];
67
+ /**
68
+ * Valid patch categories.
69
+ */
70
+ export declare const PATCH_CATEGORIES: readonly ["branding", "ui", "privacy", "security", "infra"];
71
+ /**
72
+ * Validates a patch category string.
73
+ */
74
+ export declare function isValidPatchCategory(category: string): category is (typeof PATCH_CATEGORIES)[number];
75
+ /**
76
+ * Checks whether a Firefox version string has an ESR suffix.
77
+ */
78
+ export declare function isEsrVersion(version: string): boolean;
79
+ /**
80
+ * Checks whether a Firefox version string is a beta version (e.g. "147.0b1").
81
+ */
82
+ export declare function isBetaVersion(version: string): boolean;
83
+ /**
84
+ * Infers the Firefox product type from a version string.
85
+ * Returns undefined if no clear inference can be made.
86
+ */
87
+ export declare function inferProductFromVersion(version: string): 'firefox' | 'firefox-esr' | 'firefox-beta' | undefined;
88
+ /**
89
+ * Validates that a Firefox product and version are compatible.
90
+ *
91
+ * Rules:
92
+ * - `firefox-esr` requires an ESR version (e.g. "140.0esr", "128.0.1esr").
93
+ * - `firefox-beta` requires a beta version (e.g. "147.0b1").
94
+ * - `firefox` (stable) rejects both ESR and beta version strings.
95
+ *
96
+ * @returns An error message if incompatible, or undefined if valid.
97
+ */
98
+ export declare function validateFirefoxProductVersionCompatibility(version: string, product: string): string | undefined;
99
+ /**
100
+ * Validates an application ID string.
101
+ * Accepts reverse-domain format like "org.example.browser"
102
+ */
103
+ export declare function isValidAppId(appId: string): boolean;
104
+ /**
105
+ * Checks if a value is defined (not undefined or null).
106
+ */
107
+ export declare function isDefined<T>(value: T | undefined | null): value is T;
108
+ /**
109
+ * Validates that a string is a legal CSS custom property identifier (the part after `--`).
110
+ *
111
+ * A valid CSS custom property name requires the ident portion to:
112
+ * - Be non-empty
113
+ * - Contain no whitespace or control characters
114
+ * - Contain no sequences that would break CSS syntax
115
+ * - Consist of printable, CSS-safe characters (letters, digits, hyphens, underscores, etc.)
116
+ *
117
+ * @returns An error message if invalid, or undefined if valid.
118
+ */
119
+ export declare function validateTokenName(name: string): string | undefined;
120
+ /**
121
+ * Normalizes a CSS custom property token name.
122
+ * Strips leading `--` if present, then always prepends `--`.
123
+ * This allows users to pass either `--my-token` or `my-token`.
124
+ *
125
+ * @throws InvalidArgumentError if the resulting name is not a valid CSS custom property.
126
+ */
127
+ export declare function normalizeTokenName(name: string): string;
128
+ /**
129
+ * Validates a patch name.
130
+ * @param name - The patch name to validate
131
+ * @returns Error message if invalid, undefined if valid
132
+ */
133
+ export declare function validatePatchName(name: string): string | undefined;
@@ -0,0 +1,250 @@
1
+ // SPDX-License-Identifier: EUPL-1.2
2
+ /**
3
+ * Type guards and validation utilities.
4
+ * Used to safely narrow types from unknown values.
5
+ */
6
+ import { InvalidArgumentError } from '../errors/base.js';
7
+ /**
8
+ * Checks whether a value is a string.
9
+ * @param value - Value to check
10
+ * @returns True if value is a string
11
+ */
12
+ export function isString(value) {
13
+ return typeof value === 'string';
14
+ }
15
+ /**
16
+ * Checks whether a value is a finite number (excludes NaN).
17
+ * @param value - Value to check
18
+ * @returns True if value is a finite number
19
+ */
20
+ export function isNumber(value) {
21
+ return typeof value === 'number' && !Number.isNaN(value);
22
+ }
23
+ /**
24
+ * Checks whether a value is a positive integer (greater than zero).
25
+ * @param value - Value to check
26
+ * @returns True if value is a positive integer
27
+ */
28
+ export function isPositiveInteger(value) {
29
+ return isNumber(value) && Number.isInteger(value) && value > 0;
30
+ }
31
+ /**
32
+ * Checks whether a value is a boolean.
33
+ * @param value - Value to check
34
+ * @returns True if value is a boolean
35
+ */
36
+ export function isBoolean(value) {
37
+ return typeof value === 'boolean';
38
+ }
39
+ /**
40
+ * Checks whether a value is a non-null, non-array object.
41
+ * @param value - Value to check
42
+ * @returns True if value is a plain object
43
+ */
44
+ export function isObject(value) {
45
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
46
+ }
47
+ /**
48
+ * Checks whether a value is an array.
49
+ * @param value - Value to check
50
+ * @returns True if value is an array
51
+ */
52
+ export function isArray(value) {
53
+ return Array.isArray(value);
54
+ }
55
+ /**
56
+ * Asserts that a value is a string or throws.
57
+ * @param value - Value to check
58
+ * @param name - Name of the field for error messages
59
+ */
60
+ export function assertString(value, name) {
61
+ if (!isString(value)) {
62
+ throw new InvalidArgumentError(`Expected ${name} to be a string, got ${typeof value}`, name);
63
+ }
64
+ }
65
+ /**
66
+ * Asserts that a value is a non-null object or throws.
67
+ * @param value - Value to check
68
+ * @param name - Name of the field for error messages
69
+ */
70
+ export function assertObject(value, name) {
71
+ if (!isObject(value)) {
72
+ throw new InvalidArgumentError(`Expected ${name} to be an object, got ${typeof value}`, name);
73
+ }
74
+ }
75
+ /**
76
+ * Validates a Firefox version string.
77
+ * Accepts formats like "146.0", "146.0.1", "140.0esr", "147.0b1"
78
+ */
79
+ export function isValidFirefoxVersion(version) {
80
+ // Stable/ESR: 146.0, 146.0.1, 140.0esr, 128.0.1esr
81
+ // Beta: 147.0b1, 147.0b2
82
+ return /^[1-9]\d{0,2}\.\d+(?:b[1-9]\d*|\.\d+(?:esr)?|esr)?$/.test(version);
83
+ }
84
+ /**
85
+ * Validates a Firefox product string.
86
+ * Accepts: firefox, firefox-esr, firefox-beta
87
+ */
88
+ export function isValidFirefoxProduct(product) {
89
+ return ['firefox', 'firefox-esr', 'firefox-beta'].includes(product);
90
+ }
91
+ /**
92
+ * Valid project license SPDX identifiers.
93
+ */
94
+ export const PROJECT_LICENSES = ['EUPL-1.2', 'MPL-2.0', '0BSD', 'GPL-2.0-or-later'];
95
+ /**
96
+ * Validates a project license string.
97
+ */
98
+ export function isValidProjectLicense(license) {
99
+ return PROJECT_LICENSES.includes(license);
100
+ }
101
+ /**
102
+ * Valid patch categories.
103
+ */
104
+ export const PATCH_CATEGORIES = ['branding', 'ui', 'privacy', 'security', 'infra'];
105
+ /**
106
+ * Validates a patch category string.
107
+ */
108
+ export function isValidPatchCategory(category) {
109
+ return PATCH_CATEGORIES.includes(category);
110
+ }
111
+ /**
112
+ * Checks whether a Firefox version string has an ESR suffix.
113
+ */
114
+ export function isEsrVersion(version) {
115
+ return /esr$/i.test(version);
116
+ }
117
+ /**
118
+ * Checks whether a Firefox version string is a beta version (e.g. "147.0b1").
119
+ */
120
+ export function isBetaVersion(version) {
121
+ return /b\d+$/.test(version);
122
+ }
123
+ /**
124
+ * Infers the Firefox product type from a version string.
125
+ * Returns undefined if no clear inference can be made.
126
+ */
127
+ export function inferProductFromVersion(version) {
128
+ if (isEsrVersion(version)) {
129
+ return 'firefox-esr';
130
+ }
131
+ if (isBetaVersion(version)) {
132
+ return 'firefox-beta';
133
+ }
134
+ return undefined;
135
+ }
136
+ /**
137
+ * Validates that a Firefox product and version are compatible.
138
+ *
139
+ * Rules:
140
+ * - `firefox-esr` requires an ESR version (e.g. "140.0esr", "128.0.1esr").
141
+ * - `firefox-beta` requires a beta version (e.g. "147.0b1").
142
+ * - `firefox` (stable) rejects both ESR and beta version strings.
143
+ *
144
+ * @returns An error message if incompatible, or undefined if valid.
145
+ */
146
+ export function validateFirefoxProductVersionCompatibility(version, product) {
147
+ const versionIsEsr = isEsrVersion(version);
148
+ const versionIsBeta = isBetaVersion(version);
149
+ switch (product) {
150
+ case 'firefox-esr':
151
+ if (!versionIsEsr) {
152
+ return (`Product "firefox-esr" requires an ESR version (e.g. "128.0esr"), ` +
153
+ `but got "${version}"`);
154
+ }
155
+ break;
156
+ case 'firefox-beta':
157
+ if (!versionIsBeta) {
158
+ return (`Product "firefox-beta" requires a beta version (e.g. "147.0b1"), ` +
159
+ `but got "${version}"`);
160
+ }
161
+ break;
162
+ case 'firefox':
163
+ if (versionIsEsr) {
164
+ return (`Product "firefox" does not accept ESR versions. ` +
165
+ `Use product "firefox-esr" with version "${version}", or remove the "esr" suffix`);
166
+ }
167
+ if (versionIsBeta) {
168
+ return (`Product "firefox" does not accept beta versions. ` +
169
+ `Use product "firefox-beta" with version "${version}", or remove the beta suffix`);
170
+ }
171
+ break;
172
+ }
173
+ return undefined;
174
+ }
175
+ /**
176
+ * Validates an application ID string.
177
+ * Accepts reverse-domain format like "org.example.browser"
178
+ */
179
+ export function isValidAppId(appId) {
180
+ return /^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)+$/.test(appId);
181
+ }
182
+ /**
183
+ * Checks if a value is defined (not undefined or null).
184
+ */
185
+ export function isDefined(value) {
186
+ return value !== undefined && value !== null;
187
+ }
188
+ /**
189
+ * Validates that a string is a legal CSS custom property identifier (the part after `--`).
190
+ *
191
+ * A valid CSS custom property name requires the ident portion to:
192
+ * - Be non-empty
193
+ * - Contain no whitespace or control characters
194
+ * - Contain no sequences that would break CSS syntax
195
+ * - Consist of printable, CSS-safe characters (letters, digits, hyphens, underscores, etc.)
196
+ *
197
+ * @returns An error message if invalid, or undefined if valid.
198
+ */
199
+ export function validateTokenName(name) {
200
+ // Strip leading -- for validation (callers may pass with or without)
201
+ const ident = name.replace(/^--/, '');
202
+ if (!ident) {
203
+ return 'Token name must not be empty';
204
+ }
205
+ if (/\s/.test(ident)) {
206
+ return `Token name must not contain whitespace: "${name}"`;
207
+ }
208
+ // eslint-disable-next-line no-control-regex
209
+ if (/[\x00-\x1f\x7f]/.test(ident)) {
210
+ return `Token name must not contain control characters: "${name}"`;
211
+ }
212
+ if (ident.includes('*/')) {
213
+ return `Token name must not contain "*/" (would break CSS comments): "${name}"`;
214
+ }
215
+ // Reject characters that would break CSS declaration syntax
216
+ if (/[{}();!]/.test(ident)) {
217
+ return `Token name contains characters that would corrupt CSS syntax: "${name}"`;
218
+ }
219
+ return undefined;
220
+ }
221
+ /**
222
+ * Normalizes a CSS custom property token name.
223
+ * Strips leading `--` if present, then always prepends `--`.
224
+ * This allows users to pass either `--my-token` or `my-token`.
225
+ *
226
+ * @throws InvalidArgumentError if the resulting name is not a valid CSS custom property.
227
+ */
228
+ export function normalizeTokenName(name) {
229
+ const error = validateTokenName(name);
230
+ if (error) {
231
+ throw new InvalidArgumentError(error, 'tokenName');
232
+ }
233
+ const stripped = name.replace(/^--/, '');
234
+ return `--${stripped}`;
235
+ }
236
+ /**
237
+ * Validates a patch name.
238
+ * @param name - The patch name to validate
239
+ * @returns Error message if invalid, undefined if valid
240
+ */
241
+ export function validatePatchName(name) {
242
+ if (!name.trim())
243
+ return 'Name is required';
244
+ if (name.length > 50)
245
+ return 'Name must be 50 characters or less';
246
+ if (!/^[a-zA-Z0-9\-_ ]+$/.test(name))
247
+ return 'Name can only contain letters, numbers, hyphens, underscores, and spaces';
248
+ return undefined;
249
+ }
250
+ //# sourceMappingURL=validation.js.map
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@hominis/fireforge",
3
+ "version": "0.9.0",
4
+ "description": "FireForge — a build tool for customizing Firefox",
5
+ "type": "module",
6
+ "main": "./dist/src/index.js",
7
+ "types": "./dist/src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/src/index.d.ts",
11
+ "import": "./dist/src/index.js"
12
+ },
13
+ "./package.json": "./package.json",
14
+ "./*": null
15
+ },
16
+ "bin": {
17
+ "fireforge": "./dist/bin/fireforge.js"
18
+ },
19
+ "scripts": {
20
+ "fireforge": "tsx bin/fireforge.ts",
21
+ "build": "npm run clean && tsc -p tsconfig.build.json",
22
+ "clean": "node ./scripts/clean.mjs",
23
+ "lint": "eslint src/ bin/ scripts/ eslint.config.js vitest.config.ts",
24
+ "lint:ci": "eslint src/ bin/ scripts/ eslint.config.js vitest.config.ts --max-warnings 0",
25
+ "lint:fix": "eslint src/ bin/ scripts/ eslint.config.js vitest.config.ts --fix",
26
+ "typecheck": "tsc --noEmit -p tsconfig.json",
27
+ "test": "vitest run",
28
+ "test:package": "npm run pack:verify",
29
+ "test:watch": "vitest",
30
+ "test:coverage": "vitest run --coverage && node ./scripts/check-coverage-thresholds.mjs",
31
+ "test:firefox-full": "node ./scripts/run-full-firefox-integration.mjs",
32
+ "pack:verify": "vitest run src/__tests__/wrapper-smoke.test.ts",
33
+ "pack:dry-run": "npm pack --dry-run --json --silent",
34
+ "format": "prettier --write --ignore-unknown \"src/**/*.ts\" \"bin/**/*.ts\" \"scripts/**/*.mjs\" \"package.json\" \"eslint.config.js\" \"vitest.config.ts\" \"tsconfig.json\" \"tsconfig.build.json\" \".lintstagedrc.json\" \".prettierignore\" \".prettierrc\" \".gitignore\" \"README.md\" \"CHANGELOG.md\"",
35
+ "format:check": "prettier --check --ignore-unknown \"src/**/*.ts\" \"bin/**/*.ts\" \"scripts/**/*.mjs\" \"package.json\" \"eslint.config.js\" \"vitest.config.ts\" \"tsconfig.json\" \"tsconfig.build.json\" \".lintstagedrc.json\" \".prettierignore\" \".prettierrc\" \".gitignore\" \"README.md\" \"CHANGELOG.md\"",
36
+ "prepare": "node -e \"import('./scripts/prepare.mjs').catch((error) => { if (error && typeof error === 'object' && 'code' in error && error.code === 'ERR_MODULE_NOT_FOUND') process.exit(0); throw error; })\"",
37
+ "prepack": "npm run build",
38
+ "release:check": "npm run format:check && npm run lint:ci && npm run typecheck && npm run test:coverage && npm run pack:verify && npm run pack:dry-run",
39
+ "prepublishOnly": "npm run release:check"
40
+ },
41
+ "files": [
42
+ "dist/",
43
+ "!dist/**/*.test.*",
44
+ "!dist/**/__tests__/",
45
+ "!dist/**/test-utils/",
46
+ "!dist/**/*.js.map",
47
+ "templates/",
48
+ "README.md",
49
+ "CHANGELOG.md",
50
+ "LICENSE.md"
51
+ ],
52
+ "dependencies": {
53
+ "@clack/prompts": "^1.2.0",
54
+ "acorn": "^8.14.0",
55
+ "commander": "^14.0.0",
56
+ "estree-walker": "^3.0.3",
57
+ "magic-string": "^0.30.17",
58
+ "picocolors": "^1.1.0"
59
+ },
60
+ "devDependencies": {
61
+ "@eslint/js": "^10.0.0",
62
+ "@types/estree": "^1.0.8",
63
+ "@types/node": "^25.5.2",
64
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
65
+ "@typescript-eslint/parser": "^8.0.0",
66
+ "@vitest/coverage-v8": "^4.1.2",
67
+ "eslint": "^10.0.0",
68
+ "eslint-config-prettier": "^10.1.8",
69
+ "eslint-plugin-jsdoc": "^62.9.0",
70
+ "eslint-plugin-simple-import-sort": "^13.0.0",
71
+ "fast-check": "^4.6.0",
72
+ "husky": "^9.1.7",
73
+ "lint-staged": "^16.2.7",
74
+ "prettier": "^3.7.4",
75
+ "tsx": "^4.7.0",
76
+ "typescript": "~6.0.0",
77
+ "typescript-eslint": "^8.0.0",
78
+ "vite": "^8.0.7",
79
+ "vitest": "^4.0.18"
80
+ },
81
+ "engines": {
82
+ "node": ">=20.0.0"
83
+ },
84
+ "packageManager": "npm@11.12.1",
85
+ "license": "EUPL-1.2",
86
+ "repository": {
87
+ "type": "git",
88
+ "url": "https://github.com/topfi/fireforge.git"
89
+ },
90
+ "homepage": "https://github.com/topfi/fireforge",
91
+ "bugs": {
92
+ "url": "https://github.com/topfi/fireforge/issues"
93
+ },
94
+ "keywords": [
95
+ "fireforge",
96
+ "firefox",
97
+ "browser",
98
+ "build-tool",
99
+ "customization",
100
+ "patch-workflow"
101
+ ],
102
+ "publishConfig": {
103
+ "access": "public",
104
+ "provenance": true
105
+ }
106
+ }
@@ -0,0 +1,24 @@
1
+ # Common mozconfig for ${name}
2
+ # This file is merged with platform-specific configs
3
+
4
+ # Application identity
5
+ ac_add_options --with-app-name=${binaryName}
6
+ ac_add_options --with-branding=browser/branding/${binaryName}
7
+ export MOZ_APP_BASENAME=${binaryName}
8
+
9
+ # Build options
10
+ ac_add_options --enable-application=browser
11
+ ac_add_options --enable-bootstrap
12
+
13
+ # Optimization (override in platform configs as needed)
14
+ ac_add_options --enable-optimize
15
+ ac_add_options --disable-debug
16
+
17
+ # Disable crash reporting
18
+ ac_add_options --disable-crashreporter
19
+
20
+ # Note: To disable telemetry, set MOZ_TELEMETRY_REPORTING= in your build environment
21
+ # or configure runtime prefs in user.js
22
+
23
+ # Disable features we don't need
24
+ ac_add_options --disable-updater
@@ -0,0 +1,10 @@
1
+ # macOS-specific mozconfig for ${name}
2
+
3
+ # Note: MOZ_MACBUNDLE_ID must be set via branding/configure.sh, not mozconfig.
4
+ # It is automatically set when using --with-branding.
5
+
6
+ # Use system toolchain
7
+ ac_add_options --with-macos-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
8
+
9
+ # Code signing (disabled for development)
10
+ # ac_add_options --enable-apple-silicon (uncomment for ARM builds)
@@ -0,0 +1,12 @@
1
+ # Linux-specific mozconfig for ${name}
2
+
3
+ # Use system libraries where available
4
+ ac_add_options --with-system-zlib
5
+ ac_add_options --with-system-jpeg
6
+
7
+ # PGO disabled by default (can enable for release builds)
8
+ # ac_add_options --enable-lto=cross
9
+ # ac_add_options --enable-profile-generate
10
+
11
+ # Wayland support
12
+ ac_add_options --enable-default-toolkit=cairo-gtk3-wayland
@@ -0,0 +1,14 @@
1
+ # Windows-specific mozconfig for ${name}
2
+
3
+ # Use Visual Studio toolchain
4
+ ac_add_options --host=x86_64-pc-mingw32
5
+ ac_add_options --target=x86_64-pc-mingw32
6
+
7
+ # Windows SDK
8
+ # ac_add_options --with-windows-version=10.0.19041.0
9
+
10
+ # Clang-cl
11
+ ac_add_options --enable-clang-cl
12
+
13
+ # Disable maintenance service
14
+ ac_add_options --disable-maintenance-service
@@ -0,0 +1,14 @@
1
+ BSD Zero Clause License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.