@hominis/fireforge 0.15.5 → 0.15.7

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 (36) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +70 -5
  3. package/dist/src/commands/build.js +60 -3
  4. package/dist/src/commands/furnace/chrome-doc-templates.d.ts +17 -0
  5. package/dist/src/commands/furnace/chrome-doc-templates.js +18 -0
  6. package/dist/src/commands/furnace/chrome-doc-tests.d.ts +23 -0
  7. package/dist/src/commands/furnace/chrome-doc-tests.js +120 -0
  8. package/dist/src/commands/furnace/chrome-doc.d.ts +11 -0
  9. package/dist/src/commands/furnace/chrome-doc.js +37 -4
  10. package/dist/src/commands/furnace/create-dry-run.d.ts +31 -0
  11. package/dist/src/commands/furnace/create-dry-run.js +95 -0
  12. package/dist/src/commands/furnace/create-templates.js +14 -0
  13. package/dist/src/commands/furnace/create.js +28 -24
  14. package/dist/src/commands/furnace/index.js +3 -1
  15. package/dist/src/commands/lint.d.ts +17 -2
  16. package/dist/src/commands/lint.js +25 -2
  17. package/dist/src/commands/register.d.ts +1 -1
  18. package/dist/src/commands/register.js +30 -7
  19. package/dist/src/commands/test.js +16 -1
  20. package/dist/src/core/build-audit-platform.d.ts +3 -1
  21. package/dist/src/core/build-audit-platform.js +87 -20
  22. package/dist/src/core/build-audit-registration.d.ts +80 -0
  23. package/dist/src/core/build-audit-registration.js +187 -0
  24. package/dist/src/core/build-audit-transforms.d.ts +23 -0
  25. package/dist/src/core/build-audit-transforms.js +94 -0
  26. package/dist/src/core/build-audit.js +210 -3
  27. package/dist/src/core/furnace-validate-registration.d.ts +6 -4
  28. package/dist/src/core/furnace-validate-registration.js +66 -6
  29. package/dist/src/core/mach-build-artifacts.d.ts +44 -0
  30. package/dist/src/core/mach-build-artifacts.js +104 -3
  31. package/dist/src/core/mach.d.ts +1 -1
  32. package/dist/src/core/mach.js +1 -1
  33. package/dist/src/core/test-stale-check.d.ts +42 -0
  34. package/dist/src/core/test-stale-check.js +114 -0
  35. package/dist/src/types/commands/options.d.ts +16 -0
  36. package/package.json +1 -1
@@ -0,0 +1,114 @@
1
+ // SPDX-License-Identifier: EUPL-1.2
2
+ /*
3
+ * Stale-build preflight for `fireforge test`.
4
+ *
5
+ * Without this preflight, an operator who edits engine chrome / packaged
6
+ * resources (`jar.mn` entries, `.xhtml`/`.mjs`/`.css` under chrome trees,
7
+ * pref files) and then runs `fireforge test <path>` only discovers the
8
+ * build is stale AFTER xpcshell / mach test starts and errors out with
9
+ * `NS_ERROR_FILE_NOT_FOUND` against a `chrome://browser/content/…` URI
10
+ * — which reads as a test bug, not a rebuild prompt. The motivating case
11
+ * was scaffolding a new top-level chrome document + BrowserGlue-style
12
+ * xpcshell test: the test file existed, the manifests were registered,
13
+ * but `dist/` still held the pre-edit bundle and chrome URIs resolved
14
+ * to nothing.
15
+ *
16
+ * This preflight diffs engine HEAD (or workdir) against the last-build
17
+ * baseline (`.fireforge/last-build.json`), filters to paths that imply
18
+ * packaging, and returns a compact summary. `fireforge test` prints a
19
+ * warning up-front so the operator sees "you edited X, Y, Z since the
20
+ * last build — rerun with `--build` to refresh" BEFORE mach test
21
+ * launches. Detection stays advisory (warn-only) because a fork that
22
+ * rebuilds out-of-band (a separate `./mach build` invocation, an IDE
23
+ * plugin, etc.) can legitimately have a fresh `dist/` with no
24
+ * FireForge-recorded baseline update.
25
+ */
26
+ import { toError } from '../utils/errors.js';
27
+ import { verbose } from '../utils/logger.js';
28
+ import { isPackageablePath } from './build-audit.js';
29
+ import { readBuildBaseline } from './build-baseline.js';
30
+ import { hasChanges, isMissingHeadError } from './git.js';
31
+ import { git } from './git-base.js';
32
+ import { getUntrackedFiles } from './git-status.js';
33
+ /** Cap on the number of changed paths rendered inline. */
34
+ const STALE_PATHS_LIMIT = 10;
35
+ /**
36
+ * Collects engine paths that changed since the baseline SHA plus any
37
+ * workdir modifications. Mirrors the helper inside `build-prepare.ts` but
38
+ * is kept separate so the test-side preflight does not need to pull in
39
+ * the full build-prepare dependency graph (mozconfig generation, furnace
40
+ * apply hooks, …).
41
+ */
42
+ async function collectChangedEnginePaths(engineDir, baseline) {
43
+ const collected = new Set();
44
+ if (baseline.engineHeadSha) {
45
+ try {
46
+ const diff = await git(['diff', '--name-only', `${baseline.engineHeadSha}..HEAD`], engineDir);
47
+ for (const line of diff.split('\n')) {
48
+ const trimmed = line.trim();
49
+ if (trimmed)
50
+ collected.add(trimmed);
51
+ }
52
+ }
53
+ catch (error) {
54
+ if (!isMissingHeadError(error)) {
55
+ verbose(`Stale-build preflight: could not diff engine against baseline — ${toError(error).message}`);
56
+ }
57
+ }
58
+ }
59
+ try {
60
+ if (await hasChanges(engineDir)) {
61
+ const worktreeDiff = await git(['diff', '--name-only', 'HEAD'], engineDir);
62
+ for (const line of worktreeDiff.split('\n')) {
63
+ const trimmed = line.trim();
64
+ if (trimmed)
65
+ collected.add(trimmed);
66
+ }
67
+ for (const untracked of await getUntrackedFiles(engineDir)) {
68
+ collected.add(untracked);
69
+ }
70
+ }
71
+ }
72
+ catch (error) {
73
+ verbose(`Stale-build preflight: could not enumerate workdir changes — ${toError(error).message}`);
74
+ }
75
+ return [...collected];
76
+ }
77
+ /**
78
+ * Probes the engine tree for packageable changes since the last successful
79
+ * `fireforge build`. Returns a summary the `fireforge test` handler renders
80
+ * as an up-front warning when `--build` was NOT passed. The probe never
81
+ * throws; git failures and a missing baseline both degrade to `stale: false`
82
+ * so a broken probe cannot block a test run.
83
+ *
84
+ * @param projectRoot Root directory of the project.
85
+ * @param engineDir Path to the engine directory.
86
+ */
87
+ export async function checkStaleBuildForTest(projectRoot, engineDir) {
88
+ const baseline = await readBuildBaseline(projectRoot);
89
+ if (!baseline) {
90
+ return { stale: false, changedPaths: [], truncated: 0, baseline: undefined };
91
+ }
92
+ const changed = await collectChangedEnginePaths(engineDir, baseline);
93
+ const packageable = changed.filter((path) => isPackageablePath(path)).sort();
94
+ if (packageable.length === 0) {
95
+ return { stale: false, changedPaths: [], truncated: 0, baseline };
96
+ }
97
+ const head = packageable.slice(0, STALE_PATHS_LIMIT);
98
+ const truncated = Math.max(0, packageable.length - head.length);
99
+ return { stale: true, changedPaths: head, truncated, baseline };
100
+ }
101
+ /**
102
+ * Formats a human-readable warning body from a {@link StaleBuildResult}.
103
+ * Kept separate from the probe so test code can assert on the structured
104
+ * result without matching the rendered copy.
105
+ */
106
+ export function formatStaleBuildWarning(result) {
107
+ const tail = result.truncated > 0 ? `, … (+${result.truncated} more)` : '';
108
+ const list = result.changedPaths.join(', ') + tail;
109
+ return (`Engine tree has changed since the last successful fireforge build (${list}).\n` +
110
+ 'The current obj-*/dist/ bundle may not reflect those edits. If your test reads ' +
111
+ 'packaged chrome / jar.mn resources, rerun with "fireforge test --build" (or ' +
112
+ '"fireforge build --ui") first. Passing --build skips this check.');
113
+ }
114
+ //# sourceMappingURL=test-stale-check.js.map
@@ -41,6 +41,14 @@ export interface BuildOptions {
41
41
  jobs?: number;
42
42
  /** Brand to build (stable, esr, etc.) */
43
43
  brand?: string;
44
+ /**
45
+ * When a mozinfo mismatch is detected that looks like a safe path
46
+ * relocation (same structure, different prefix), patch mozinfo paths
47
+ * in place and run `mach configure` rather than aborting with a
48
+ * full-rebuild instruction. Falls back to the original abort message
49
+ * for any mismatch the rewriter cannot prove safe.
50
+ */
51
+ rewriteMozinfo?: boolean;
44
52
  }
45
53
  /**
46
54
  * Options for the export command.
@@ -298,6 +306,14 @@ export interface FurnaceCreateOptions {
298
306
  testStyle?: 'mochikit' | 'browser-chrome' | 'xpcshell';
299
307
  /** Stock component tag names composed internally by this component */
300
308
  compose?: string[];
309
+ /**
310
+ * Show the planned file set and furnace.json changes without writing
311
+ * anything. All validation that does not require disk writes (tag name
312
+ * shape, name conflicts, engine pre-existence, `--compose` targets, cycle
313
+ * detection, prefix warning) runs before the plan is emitted, so a
314
+ * dry-run faithfully previews the real command's outcome.
315
+ */
316
+ dryRun?: boolean;
301
317
  }
302
318
  /**
303
319
  * Options for the wire command.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hominis/fireforge",
3
- "version": "0.15.5",
3
+ "version": "0.15.7",
4
4
  "description": "FireForge — a build tool for customizing Firefox",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",