@hominis/fireforge 0.32.0 → 0.34.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 (81) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/src/commands/build.js +9 -1
  3. package/dist/src/commands/doctor-furnace-jar.d.ts +16 -0
  4. package/dist/src/commands/doctor-furnace-jar.js +47 -0
  5. package/dist/src/commands/doctor-furnace.js +2 -0
  6. package/dist/src/commands/export-flow.js +4 -1
  7. package/dist/src/commands/export-placement-gate.js +4 -1
  8. package/dist/src/commands/export.js +61 -4
  9. package/dist/src/commands/furnace/chrome-doc-templates.d.ts +20 -0
  10. package/dist/src/commands/furnace/chrome-doc-templates.js +52 -0
  11. package/dist/src/commands/furnace/chrome-doc.d.ts +10 -0
  12. package/dist/src/commands/furnace/chrome-doc.js +31 -4
  13. package/dist/src/commands/furnace/create-browser-test.d.ts +30 -0
  14. package/dist/src/commands/furnace/create-browser-test.js +180 -0
  15. package/dist/src/commands/furnace/create-mochikit.js +11 -4
  16. package/dist/src/commands/furnace/create-xpcshell.d.ts +1 -1
  17. package/dist/src/commands/furnace/create-xpcshell.js +38 -12
  18. package/dist/src/commands/furnace/create.js +7 -114
  19. package/dist/src/commands/furnace/index.js +6 -1
  20. package/dist/src/commands/furnace/scan.d.ts +1 -0
  21. package/dist/src/commands/furnace/scan.js +57 -27
  22. package/dist/src/commands/furnace/validate.js +17 -1
  23. package/dist/src/commands/patch/split-plan.d.ts +18 -2
  24. package/dist/src/commands/patch/split-plan.js +90 -16
  25. package/dist/src/commands/patch/split.js +12 -3
  26. package/dist/src/commands/re-export-options.d.ts +26 -0
  27. package/dist/src/commands/re-export-options.js +48 -1
  28. package/dist/src/commands/re-export.js +4 -1
  29. package/dist/src/commands/register.js +10 -1
  30. package/dist/src/commands/test-diagnose.js +12 -0
  31. package/dist/src/commands/test.js +29 -22
  32. package/dist/src/commands/token.js +12 -1
  33. package/dist/src/commands/typecheck.js +35 -0
  34. package/dist/src/core/build-prepare.js +23 -3
  35. package/dist/src/core/config-validate.js +26 -0
  36. package/dist/src/core/furnace-apply-dry-run.d.ts +17 -0
  37. package/dist/src/core/furnace-apply-dry-run.js +105 -0
  38. package/dist/src/core/furnace-apply-ftl.d.ts +12 -0
  39. package/dist/src/core/furnace-apply-ftl.js +97 -1
  40. package/dist/src/core/furnace-apply-helpers.js +10 -80
  41. package/dist/src/core/furnace-registration.d.ts +24 -0
  42. package/dist/src/core/furnace-registration.js +56 -3
  43. package/dist/src/core/furnace-validate-registration.js +18 -0
  44. package/dist/src/core/mach-resource-shim.d.ts +58 -0
  45. package/dist/src/core/mach-resource-shim.js +290 -0
  46. package/dist/src/core/mach.d.ts +51 -10
  47. package/dist/src/core/mach.js +76 -25
  48. package/dist/src/core/manifest-helpers.d.ts +13 -0
  49. package/dist/src/core/manifest-helpers.js +29 -4
  50. package/dist/src/core/manifest-rules.d.ts +13 -3
  51. package/dist/src/core/manifest-rules.js +44 -17
  52. package/dist/src/core/patch-export.d.ts +10 -0
  53. package/dist/src/core/patch-export.js +23 -2
  54. package/dist/src/core/patch-lint-cross.d.ts +31 -0
  55. package/dist/src/core/patch-lint-cross.js +83 -63
  56. package/dist/src/core/patch-lint-reexports.d.ts +1 -1
  57. package/dist/src/core/patch-lint-reexports.js +1 -1
  58. package/dist/src/core/register-module.d.ts +1 -1
  59. package/dist/src/core/register-module.js +15 -2
  60. package/dist/src/core/register-result.d.ts +9 -0
  61. package/dist/src/core/register-scaffold.d.ts +55 -0
  62. package/dist/src/core/register-scaffold.js +146 -0
  63. package/dist/src/core/register-test-manifest.js +3 -1
  64. package/dist/src/core/register-xpcshell-test.d.ts +30 -0
  65. package/dist/src/core/register-xpcshell-test.js +96 -0
  66. package/dist/src/core/test-harness-crash.d.ts +32 -4
  67. package/dist/src/core/test-harness-crash.js +152 -14
  68. package/dist/src/core/token-dark-mode.d.ts +9 -0
  69. package/dist/src/core/token-dark-mode.js +1 -1
  70. package/dist/src/core/token-docs.d.ts +32 -0
  71. package/dist/src/core/token-docs.js +101 -0
  72. package/dist/src/core/token-manager.d.ts +8 -0
  73. package/dist/src/core/token-manager.js +77 -95
  74. package/dist/src/core/token-variant.d.ts +39 -0
  75. package/dist/src/core/token-variant.js +141 -0
  76. package/dist/src/core/typecheck.js +56 -28
  77. package/dist/src/core/xpcshell-appdir.d.ts +7 -0
  78. package/dist/src/core/xpcshell-appdir.js +12 -3
  79. package/dist/src/types/commands/options.d.ts +17 -0
  80. package/dist/src/types/config.d.ts +13 -0
  81. package/package.json +4 -4
@@ -38,7 +38,7 @@
38
38
  * test.ts; we skip injection when `--app-path=` already appears in the
39
39
  * forwarded args).
40
40
  */
41
- import { readdir } from 'node:fs/promises';
41
+ import { readdir, stat } from 'node:fs/promises';
42
42
  import { dirname, join, resolve, sep } from 'node:path';
43
43
  import { pathExists, readJson, readText } from '../utils/fs.js';
44
44
  import { isObject, isString } from '../utils/validation.js';
@@ -110,19 +110,28 @@ function stripQuotes(raw) {
110
110
  *
111
111
  * Special-cases `startPath` itself when it already ends with
112
112
  * `xpcshell.toml` — operators sometimes pass a manifest path directly.
113
+ *
114
+ * When `startPath` is a DIRECTORY, the walk starts at the directory itself
115
+ * (checking `<dir>/xpcshell.toml` first) rather than at its parent. Field
116
+ * report (0.34.0 cycle): a directory whose own manifest is an
117
+ * `xpcshell.toml` was classified non-xpcshell — the walk began at the
118
+ * parent, missed the manifest, and `fireforge test <dir>` dispatched to
119
+ * the mochitest runner, which found no mochitests.
113
120
  */
114
121
  export async function findNearestXpcshellManifest(engineDir, startPath) {
115
122
  const absStart = resolve(engineDir, startPath);
116
123
  if (absStart.toLowerCase().endsWith(`${sep}xpcshell.toml`)) {
117
124
  return (await pathExists(absStart)) ? absStart : null;
118
125
  }
126
+ const startIsDirectory = await stat(absStart).then((stats) => stats.isDirectory(), () => false);
119
127
  const engineAbs = resolve(engineDir);
120
128
  let current = absStart;
121
- // First iteration walks down to a directory; subsequent ones walk up.
129
+ // First iteration resolves the starting directory (the path itself for a
130
+ // directory argument, its parent for a file); subsequent ones walk up.
122
131
  // Cap iterations defensively — a pathological symlink loop would
123
132
  // otherwise spin until the call stack overflows.
124
133
  for (let i = 0; i < 64; i += 1) {
125
- const dir = i === 0 ? dirname(absStart) : dirname(current);
134
+ const dir = i === 0 ? (startIsDirectory ? absStart : dirname(absStart)) : dirname(current);
126
135
  const candidate = join(dir, 'xpcshell.toml');
127
136
  if (await pathExists(candidate))
128
137
  return candidate;
@@ -530,6 +530,16 @@ export interface FurnaceRemoveOptions {
530
530
  export interface FurnaceCreateOptions {
531
531
  /** Component description */
532
532
  description?: string;
533
+ /**
534
+ * Engine-relative directory the test scaffold writes into, instead of
535
+ * the default `browser/base/content/test/<binaryName>/` (browser-chrome)
536
+ * or `browser/base/content/test/<binaryName>-xpcshell/<component>/`
537
+ * (xpcshell). Must stay under `browser/base/content/test/` so the
538
+ * manifest registration keeps working. Not supported for
539
+ * `--test-style=mochikit` (that harness lives in the upstream
540
+ * toolkit/content/tests/widgets tree).
541
+ */
542
+ testDir?: string;
533
543
  /** Include Fluent l10n support */
534
544
  localized?: boolean;
535
545
  /** Register in customElements.js (default: true) */
@@ -614,6 +624,8 @@ export interface WireOptions {
614
624
  export interface RegisterOptions {
615
625
  dryRun?: boolean;
616
626
  after?: string;
627
+ /** Scaffold a missing manifest (moz.build / xpcshell.toml) and wire the parent chain. */
628
+ createManifest?: boolean;
617
629
  }
618
630
  /**
619
631
  * Options for the patch delete command.
@@ -705,6 +717,11 @@ export interface TokenAddOptions {
705
717
  dryRun?: boolean;
706
718
  /** Declare the category banner in the tokens CSS when it does not exist yet. */
707
719
  createCategory?: boolean;
720
+ /**
721
+ * Attribute selector fragment (e.g. `[data-skin=precision]` or
722
+ * `[data-private]`) routing the declaration into a `:root<variant>` block.
723
+ */
724
+ variant?: string;
708
725
  }
709
726
  /**
710
727
  * Options for the doctor command.
@@ -129,6 +129,19 @@ export interface TypecheckConfig {
129
129
  * built-in shim first, extraShim second — augment, don't redeclare.
130
130
  */
131
131
  extraShim?: string;
132
+ /**
133
+ * Per-project override of {@link extraShim}, keyed by the project's path
134
+ * exactly as it appears in {@link projects}. A string value points the
135
+ * project at a different `.d.ts`; `null` opts the project out of the shared
136
+ * extra shim entirely (it absorbs only the built-in Firefox globals shim).
137
+ *
138
+ * Needed because the shared shim is injected into every project: a shim hub
139
+ * that references Gecko declaration libs (`lib.gecko.dom.d.ts`, …) is wanted
140
+ * by projects that include it but collides with a project that narrows
141
+ * `lib: ["ES2024", "DOM"]` (Element/Node identity splits, nsIPrincipal
142
+ * mismatch). A narrowed project sets `null` here to stay clean.
143
+ */
144
+ projectOverrides?: Record<string, string | null>;
132
145
  }
133
146
  /**
134
147
  * Wire command configuration.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hominis/fireforge",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "FireForge — a build tool for customizing Firefox",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -63,7 +63,7 @@
63
63
  "devDependencies": {
64
64
  "@eslint/js": "^10.0.0",
65
65
  "@types/estree": "^1.0.8",
66
- "@types/node": "^25.5.2",
66
+ "@types/node": "^26.0.0",
67
67
  "@vitest/coverage-v8": "^4.1.2",
68
68
  "dpdm": "4.2.0",
69
69
  "eslint": "^10.0.0",
@@ -72,9 +72,9 @@
72
72
  "eslint-plugin-simple-import-sort": "^13.0.0",
73
73
  "fast-check": "^4.6.0",
74
74
  "husky": "^9.1.7",
75
- "knip": "6.16.1",
75
+ "knip": "6.23.0",
76
76
  "lint-staged": "^17.0.4",
77
- "prettier": "^3.7.4",
77
+ "prettier": "3.9.4",
78
78
  "tsx": "^4.7.0",
79
79
  "typescript": "~6.0.0",
80
80
  "typescript-eslint": "^8.0.0",