@hominis/fireforge 0.17.0 → 0.18.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.
- package/CHANGELOG.md +53 -0
- package/README.md +60 -33
- package/dist/src/commands/build.js +18 -4
- package/dist/src/commands/doctor-furnace-manifest-sync.d.ts +18 -0
- package/dist/src/commands/doctor-furnace-manifest-sync.js +159 -0
- package/dist/src/commands/doctor-furnace.js +2 -0
- package/dist/src/commands/doctor-working-tree.d.ts +29 -0
- package/dist/src/commands/doctor-working-tree.js +93 -0
- package/dist/src/commands/doctor.js +22 -12
- package/dist/src/commands/export-all.js +74 -4
- package/dist/src/commands/export-shared.d.ts +7 -1
- package/dist/src/commands/export-shared.js +21 -3
- package/dist/src/commands/furnace/create-xpcshell.js +4 -2
- package/dist/src/commands/furnace/override.js +23 -13
- package/dist/src/commands/furnace/preview.js +38 -0
- package/dist/src/commands/furnace/remove.js +75 -1
- package/dist/src/commands/furnace/rename-xpcshell.d.ts +35 -0
- package/dist/src/commands/furnace/rename-xpcshell.js +97 -0
- package/dist/src/commands/furnace/rename.js +32 -4
- package/dist/src/commands/lint.js +19 -6
- package/dist/src/commands/patch/delete.js +4 -1
- package/dist/src/commands/patch/reorder.js +4 -1
- package/dist/src/commands/re-export-files.js +3 -1
- package/dist/src/commands/re-export.js +4 -1
- package/dist/src/commands/rebase/index.js +19 -1
- package/dist/src/commands/register.js +11 -0
- package/dist/src/commands/status.js +44 -5
- package/dist/src/commands/test.js +68 -16
- package/dist/src/commands/token-coverage.js +10 -3
- package/dist/src/commands/verify.js +81 -6
- package/dist/src/commands/watch.js +43 -7
- package/dist/src/commands/wire.js +16 -0
- package/dist/src/core/browser-wire.js +21 -4
- package/dist/src/core/build-audit.js +10 -0
- package/dist/src/core/furnace-constants.d.ts +14 -0
- package/dist/src/core/furnace-constants.js +16 -0
- package/dist/src/core/furnace-validate.js +67 -1
- package/dist/src/core/git-base.d.ts +27 -2
- package/dist/src/core/git-base.js +41 -3
- package/dist/src/core/git-diff.js +21 -2
- package/dist/src/core/git.js +53 -14
- package/dist/src/core/mach.d.ts +26 -8
- package/dist/src/core/mach.js +24 -8
- package/dist/src/core/manifest-rules.js +10 -1
- package/dist/src/core/manifest-tokenizers.d.ts +6 -0
- package/dist/src/core/manifest-tokenizers.js +28 -0
- package/dist/src/core/marionette-preflight.d.ts +16 -0
- package/dist/src/core/marionette-preflight.js +19 -0
- package/dist/src/core/patch-lint-diff-tag.d.ts +20 -0
- package/dist/src/core/patch-lint-diff-tag.js +25 -0
- package/dist/src/core/patch-lint.d.ts +47 -2
- package/dist/src/core/patch-lint.js +94 -18
- package/dist/src/core/patch-manifest-consistency.js +15 -2
- package/dist/src/core/patch-manifest-io.js +10 -0
- package/dist/src/core/patch-manifest-resolve.d.ts +20 -1
- package/dist/src/core/patch-manifest-resolve.js +29 -2
- package/dist/src/core/patch-manifest-validate.js +25 -1
- package/dist/src/core/patch-registration-refs.d.ts +42 -0
- package/dist/src/core/patch-registration-refs.js +117 -0
- package/dist/src/core/token-coverage.js +24 -0
- package/dist/src/core/wire-destroy.d.ts +7 -3
- package/dist/src/core/wire-destroy.js +11 -6
- package/dist/src/core/wire-init.d.ts +9 -3
- package/dist/src/core/wire-init.js +18 -6
- package/dist/src/core/wire-subscript.d.ts +7 -3
- package/dist/src/core/wire-subscript.js +11 -4
- package/dist/src/core/xpcshell-appdir.d.ts +19 -5
- package/dist/src/core/xpcshell-appdir.js +46 -20
- package/dist/src/errors/git.d.ts +20 -0
- package/dist/src/errors/git.js +39 -0
- package/dist/src/types/commands/patches.d.ts +23 -0
- package/dist/src/types/furnace.d.ts +9 -0
- package/dist/src/utils/parse.d.ts +7 -0
- package/dist/src/utils/parse.js +15 -0
- package/package.json +1 -1
|
@@ -14,19 +14,74 @@
|
|
|
14
14
|
* Exits non-zero when any error-severity finding is reported so CI can
|
|
15
15
|
* treat the output as pass/fail.
|
|
16
16
|
*/
|
|
17
|
+
import { join } from 'node:path';
|
|
17
18
|
import { getProjectPaths } from '../core/config.js';
|
|
18
19
|
import { buildPatchQueueContext, lintPatchQueue } from '../core/patch-lint.js';
|
|
19
20
|
import { loadPatchesManifest, validatePatchesManifestConsistency } from '../core/patch-manifest.js';
|
|
21
|
+
import { collectPatchRegistrationReferences } from '../core/patch-registration-refs.js';
|
|
20
22
|
import { GeneralError } from '../errors/base.js';
|
|
21
|
-
import { pathExists } from '../utils/fs.js';
|
|
23
|
+
import { pathExists, readText } from '../utils/fs.js';
|
|
22
24
|
import { info, intro, outro, success, warn } from '../utils/logger.js';
|
|
23
25
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* Walks each patch body in the manifest, extracts the set of
|
|
27
|
+
* component-shaped registration references it adds (widget paths
|
|
28
|
+
* implied by jar.mn + customElements.js; FTL paths implied by locale
|
|
29
|
+
* jar.mn), and confirms every reference is either created by some
|
|
30
|
+
* patch in the queue OR present as a tracked file in engine/. Any
|
|
31
|
+
* unreachable reference is a dangling-registration error — the patch
|
|
32
|
+
* registers a file that nothing in the world supplies, which fails at
|
|
33
|
+
* install time.
|
|
29
34
|
*/
|
|
35
|
+
async function detectDanglingRegistrations(patchesDir, engineDir, patches) {
|
|
36
|
+
// Aggregate the set of all paths that any patch in the queue is
|
|
37
|
+
// responsible for (per `filesAffected`). We deliberately do NOT parse
|
|
38
|
+
// individual patch bodies for new-file creations here: `filesAffected`
|
|
39
|
+
// is already the contract manifest callers rely on, and
|
|
40
|
+
// `validatePatchesManifestConsistency` has already ensured the two
|
|
41
|
+
// are in sync. Using that list keeps this validator fast.
|
|
42
|
+
const coveredByPatches = new Set();
|
|
43
|
+
for (const patch of patches) {
|
|
44
|
+
for (const file of patch.filesAffected) {
|
|
45
|
+
coveredByPatches.add(file);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const issues = [];
|
|
49
|
+
for (const patch of patches) {
|
|
50
|
+
const patchPath = join(patchesDir, patch.filename);
|
|
51
|
+
if (!(await pathExists(patchPath)))
|
|
52
|
+
continue;
|
|
53
|
+
let body;
|
|
54
|
+
try {
|
|
55
|
+
body = await readText(patchPath);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Bad file read is surfaced by the manifest consistency check
|
|
59
|
+
// already — skipping here avoids double-reporting the same issue.
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const refs = collectPatchRegistrationReferences(body);
|
|
63
|
+
if (refs.length === 0)
|
|
64
|
+
continue;
|
|
65
|
+
for (const ref of refs) {
|
|
66
|
+
if (coveredByPatches.has(ref.targetPath))
|
|
67
|
+
continue;
|
|
68
|
+
// Engine existence check: if the target file is already present
|
|
69
|
+
// in engine/ (e.g. upstream Firefox ships it, or a separate
|
|
70
|
+
// baseline branch has it), the registration is not dangling.
|
|
71
|
+
// We cannot sanely probe "is this tracked by git" without a git
|
|
72
|
+
// round-trip; existence on disk is a close-enough proxy for
|
|
73
|
+
// verify's read-only context.
|
|
74
|
+
if (await pathExists(join(engineDir, ref.targetPath)))
|
|
75
|
+
continue;
|
|
76
|
+
issues.push({
|
|
77
|
+
patchFilename: patch.filename,
|
|
78
|
+
targetPath: ref.targetPath,
|
|
79
|
+
source: ref.source,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return issues;
|
|
84
|
+
}
|
|
30
85
|
function detectCrossPatchFileClaims(manifestPatches) {
|
|
31
86
|
const claims = new Map();
|
|
32
87
|
for (const patch of manifestPatches) {
|
|
@@ -97,6 +152,26 @@ export async function verifyCommand(projectRoot) {
|
|
|
97
152
|
warningCount += 1;
|
|
98
153
|
}
|
|
99
154
|
}
|
|
155
|
+
// 4. Registration-consequence consistency: walk each patch body and
|
|
156
|
+
// confirm that every widget / locale registration it adds has a
|
|
157
|
+
// corresponding file body covered by the patch queue OR present in
|
|
158
|
+
// the engine working tree. 2026-04-24 eval Finding 1: a patch
|
|
159
|
+
// produced by `export-all --exclude-furnace` referenced
|
|
160
|
+
// `toolkit/content/widgets/moz-qa-panel/*.mjs` via jar.mn /
|
|
161
|
+
// customElements.js edits, but the source files themselves were
|
|
162
|
+
// excluded from the patch. `verify` used to report "clean"; it now
|
|
163
|
+
// flags each dangling reference as a `dangling-registration` error
|
|
164
|
+
// naming the specific patch and target path.
|
|
165
|
+
if (manifest) {
|
|
166
|
+
const registrationIssues = await detectDanglingRegistrations(paths.patches, paths.engine, manifest.patches);
|
|
167
|
+
if (registrationIssues.length > 0) {
|
|
168
|
+
warn(`Dangling registration references (${registrationIssues.length}):`);
|
|
169
|
+
for (const issue of registrationIssues) {
|
|
170
|
+
warn(` ${issue.patchFilename}: registers ${issue.targetPath} via ${issue.source}, but no patch body or engine file supplies it`);
|
|
171
|
+
errorCount += 1;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
100
175
|
if (errorCount === 0 && warningCount === 0) {
|
|
101
176
|
success('Patch queue is consistent.');
|
|
102
177
|
outro('Verify clean');
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EUPL-1.2
|
|
2
|
+
import { delimiter, dirname } from 'node:path';
|
|
1
3
|
import { getProjectPaths, loadConfig } from '../core/config.js';
|
|
2
4
|
import { warnIfFurnaceStale } from '../core/furnace-staleness.js';
|
|
3
5
|
import { buildArtifactMismatchMessage, generateMozconfig, hasBuildArtifacts, hasRunnableBundle, watchWithOutput, } from '../core/mach.js';
|
|
@@ -5,8 +7,8 @@ import { GeneralError } from '../errors/base.js';
|
|
|
5
7
|
import { AmbiguousBuildArtifactsError, BuildError } from '../errors/build.js';
|
|
6
8
|
import { toError } from '../utils/errors.js';
|
|
7
9
|
import { pathExists } from '../utils/fs.js';
|
|
8
|
-
import { info, intro, outro, spinner } from '../utils/logger.js';
|
|
9
|
-
import { exec,
|
|
10
|
+
import { info, intro, outro, spinner, verbose } from '../utils/logger.js';
|
|
11
|
+
import { exec, findExecutable } from '../utils/process.js';
|
|
10
12
|
const WATCHMAN_PROBE_TIMEOUT_MS = 5000;
|
|
11
13
|
/**
|
|
12
14
|
* Probes watchman by running `watchman --version`. A binary that exists
|
|
@@ -55,14 +57,21 @@ function buildWatchmanConfigureTimeMessage() {
|
|
|
55
57
|
/**
|
|
56
58
|
* Builds the generic unsupported-watch failure message.
|
|
57
59
|
* @param exitCode - Exit code returned by `mach watch`
|
|
60
|
+
* @param watchmanPath - Optional absolute path to the resolved watchman binary; surfaced in the guidance so the operator can see whether FireForge actually found one.
|
|
58
61
|
* @returns User-facing failure guidance
|
|
59
62
|
*/
|
|
60
|
-
function buildUnsupportedWatchMessage(exitCode) {
|
|
63
|
+
function buildUnsupportedWatchMessage(exitCode, watchmanPath) {
|
|
64
|
+
const watchmanLine = watchmanPath
|
|
65
|
+
? ` - FireForge resolved watchman at ${watchmanPath} and prepended its directory to the mach subprocess PATH. If mach still did not see it, ensure that path is stable between runs.\n`
|
|
66
|
+
: '';
|
|
61
67
|
return (`Watch failed with exit code ${exitCode}. Check the output above for details.\n\n` +
|
|
62
68
|
'Common causes:\n' +
|
|
63
69
|
' - watchman is not installed or not in PATH right now\n' +
|
|
64
70
|
' - watchman was installed only after the current obj-* directory was configured; delete obj-* and rebuild\n' +
|
|
65
|
-
' - mach watch is unsupported in the current objdir or build environment'
|
|
71
|
+
' - mach watch is unsupported in the current objdir or build environment\n' +
|
|
72
|
+
watchmanLine +
|
|
73
|
+
'\n' +
|
|
74
|
+
'If the failure referenced `watch-project` / `FasterBuildException: timed out`, watchman is likely reachable via `which watchman` from your shell but missing from the subprocess PATH. FireForge now prepends the resolved watchman directory automatically; confirm your watchman install is on a stable path (e.g. /opt/homebrew/bin/watchman on macOS).');
|
|
66
75
|
}
|
|
67
76
|
/**
|
|
68
77
|
* Detects the Firefox-side output produced when watchman was missing at configure time.
|
|
@@ -86,7 +95,17 @@ export async function watchCommand(projectRoot) {
|
|
|
86
95
|
if (!(await pathExists(paths.engine))) {
|
|
87
96
|
throw new GeneralError('Firefox source not found. Run "fireforge download" first.');
|
|
88
97
|
}
|
|
89
|
-
|
|
98
|
+
// Resolve the watchman binary to an absolute path up-front so we can
|
|
99
|
+
// (a) refuse fast when it is missing AND (b) prepend its directory to
|
|
100
|
+
// the mach subprocess PATH. 2026-04-24 eval Finding 12: on macOS,
|
|
101
|
+
// `which watchman` from the interactive shell returns
|
|
102
|
+
// `/opt/homebrew/bin/watchman`, but the Node subprocess PATH
|
|
103
|
+
// frequently omits `/opt/homebrew/bin`, so the shell probe passed and
|
|
104
|
+
// mach's `watch-project` call then timed out because its own PATH
|
|
105
|
+
// lookup for watchman failed. Threading the directory through the
|
|
106
|
+
// subprocess env fixes it.
|
|
107
|
+
const watchmanPath = await findExecutable('watchman');
|
|
108
|
+
if (!watchmanPath) {
|
|
90
109
|
throw new GeneralError('Watch mode requires watchman to be installed and available in PATH.\n\n' +
|
|
91
110
|
'Install watchman first, then rerun "fireforge watch".');
|
|
92
111
|
}
|
|
@@ -145,9 +164,26 @@ export async function watchCommand(projectRoot) {
|
|
|
145
164
|
}
|
|
146
165
|
info('Starting watch mode...');
|
|
147
166
|
info('Press Ctrl+C to stop\n');
|
|
167
|
+
// Compose the subprocess env: start from the parent process env, then
|
|
168
|
+
// prepend the resolved watchman directory to PATH so the mach
|
|
169
|
+
// subprocess sees the same binary our probe just validated. Without
|
|
170
|
+
// this, a watchman install on `/opt/homebrew/bin` (the default
|
|
171
|
+
// homebrew prefix on Apple Silicon) is absent from the PATH Node
|
|
172
|
+
// inherits on spawn, and `mach watch` fails at the `watch-project`
|
|
173
|
+
// subscription step.
|
|
174
|
+
const watchmanDir = dirname(watchmanPath);
|
|
175
|
+
const existingPath = process.env['PATH'] ?? '';
|
|
176
|
+
const pathSegments = existingPath.split(delimiter).filter((segment) => segment.length > 0);
|
|
177
|
+
const watchmanEnv = pathSegments.includes(watchmanDir)
|
|
178
|
+
? { ...process.env }
|
|
179
|
+
: {
|
|
180
|
+
...process.env,
|
|
181
|
+
PATH: [watchmanDir, ...pathSegments].join(delimiter),
|
|
182
|
+
};
|
|
183
|
+
verbose(`watch: resolved watchman at ${watchmanPath}; forwarding directory in subprocess PATH.`);
|
|
148
184
|
let result;
|
|
149
185
|
try {
|
|
150
|
-
result = await watchWithOutput(paths.engine);
|
|
186
|
+
result = await watchWithOutput(paths.engine, { env: watchmanEnv });
|
|
151
187
|
}
|
|
152
188
|
catch (error) {
|
|
153
189
|
throw new BuildError('Watch process failed to start', 'mach watch', error instanceof Error ? error : undefined);
|
|
@@ -158,7 +194,7 @@ export async function watchCommand(projectRoot) {
|
|
|
158
194
|
throw new GeneralError(buildWatchmanConfigureTimeMessage());
|
|
159
195
|
}
|
|
160
196
|
// 130 is SIGINT (Ctrl+C), which is expected
|
|
161
|
-
throw new BuildError(buildUnsupportedWatchMessage(result.exitCode), 'mach watch');
|
|
197
|
+
throw new BuildError(buildUnsupportedWatchMessage(result.exitCode, watchmanPath), 'mach watch');
|
|
162
198
|
}
|
|
163
199
|
outro('Watch mode stopped');
|
|
164
200
|
}
|
|
@@ -226,6 +226,15 @@ export async function wireCommand(projectRoot, name, options = {}) {
|
|
|
226
226
|
// dry-run is meant to preview the mutation plan without requiring
|
|
227
227
|
// the subscript to already exist, matching the "plan before write"
|
|
228
228
|
// pattern operators rely on for setup scripts).
|
|
229
|
+
//
|
|
230
|
+
// Dry-run keeps the existence check advisory rather than fatal: the
|
|
231
|
+
// "wire first, create file after" workflow is a legitimate use of
|
|
232
|
+
// preview, but operators who run dry-run over a typo were surprised
|
|
233
|
+
// when the real command then refused with `Subscript file not
|
|
234
|
+
// found`. 2026-04-23 eval (Finding in eval 2): dry-run produced a
|
|
235
|
+
// plausible plan and the non-dry-run invocation then errored. The
|
|
236
|
+
// info line surfaces the mismatch in preview mode so the operator
|
|
237
|
+
// can act on the warning before re-running without --dry-run.
|
|
229
238
|
if (!options.dryRun) {
|
|
230
239
|
const paths = getProjectPaths(projectRoot);
|
|
231
240
|
const subscriptPath = join(paths.engine, subscriptDir, `${name}.js`);
|
|
@@ -234,6 +243,13 @@ export async function wireCommand(projectRoot, name, options = {}) {
|
|
|
234
243
|
'Create the file in engine/ before wiring.', 'name');
|
|
235
244
|
}
|
|
236
245
|
}
|
|
246
|
+
else {
|
|
247
|
+
const paths = getProjectPaths(projectRoot);
|
|
248
|
+
const subscriptPath = join(paths.engine, subscriptDir, `${name}.js`);
|
|
249
|
+
if (!(await pathExists(subscriptPath))) {
|
|
250
|
+
info(`Note: ${subscriptDir}/${name}.js does not exist yet — the real wire command will require it before writing. Create the file before re-running without --dry-run.`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
237
253
|
if (options.dryRun) {
|
|
238
254
|
printWireDryRun(getProjectPaths(projectRoot).engine, name, subscriptDir, domFilePath, domTargetPath, options);
|
|
239
255
|
return;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { join, relative } from 'node:path';
|
|
3
3
|
import { GeneralError } from '../errors/base.js';
|
|
4
4
|
import { toError } from '../utils/errors.js';
|
|
5
|
+
import { verbose } from '../utils/logger.js';
|
|
5
6
|
import { toRootRelativePath } from '../utils/paths.js';
|
|
6
|
-
import { getProjectPaths } from './config.js';
|
|
7
|
+
import { getProjectPaths, loadConfig } from './config.js';
|
|
7
8
|
import { createRollbackJournal, restoreRollbackJournal, snapshotFile } from './furnace-rollback.js';
|
|
8
9
|
import { registerBrowserContent } from './manifest-register.js';
|
|
9
10
|
import { DEFAULT_DOM_TARGET } from './wire-dom-fragment.js';
|
|
@@ -63,18 +64,34 @@ export async function wireSubscript(root, name, options = {}) {
|
|
|
63
64
|
await snapshotFile(journal, join(engineDir, effectiveDomTargetPath));
|
|
64
65
|
}
|
|
65
66
|
await snapshotFile(journal, join(engineDir, 'browser/base/jar.mn'));
|
|
67
|
+
// Compute the project-scoped patch-lint marker (`// <BINARY>:`) so
|
|
68
|
+
// every wire mutator can stamp it into the emitted comment block.
|
|
69
|
+
// Without this, `lintModificationComments` trips
|
|
70
|
+
// `missing-modification-comment` on wire-generated edits the next
|
|
71
|
+
// time the operator exports — the same tool wrote the code and a
|
|
72
|
+
// sibling tool then rejected it (eval 1 Finding #9). A broken config
|
|
73
|
+
// should not block the wire, so the fallback marker keeps the
|
|
74
|
+
// previous lint-friendly default when the config cannot be loaded.
|
|
75
|
+
let marker = 'FIREFORGE:';
|
|
76
|
+
try {
|
|
77
|
+
const config = await loadConfig(root);
|
|
78
|
+
marker = `${config.binaryName.toUpperCase()}:`;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
verbose(`Using default wire marker because fireforge.json could not be loaded: ${toError(error).message}`);
|
|
82
|
+
}
|
|
66
83
|
try {
|
|
67
84
|
// 1. Add subscript to browser-main.js
|
|
68
|
-
const subscriptAdded = await addSubscriptToBrowserMain(engineDir, name);
|
|
85
|
+
const subscriptAdded = await addSubscriptToBrowserMain(engineDir, name, marker);
|
|
69
86
|
// 2. Add init expression to browser-init.js (if provided)
|
|
70
87
|
let initAdded = false;
|
|
71
88
|
if (options.init) {
|
|
72
|
-
initAdded = await addInitToBrowserInit(engineDir, options.init, options.after);
|
|
89
|
+
initAdded = await addInitToBrowserInit(engineDir, options.init, options.after, marker);
|
|
73
90
|
}
|
|
74
91
|
// 3. Add destroy expression to browser-init.js onUnload() (if provided)
|
|
75
92
|
let destroyAdded = false;
|
|
76
93
|
if (options.destroy) {
|
|
77
|
-
destroyAdded = await addDestroyToBrowserInit(engineDir, options.destroy);
|
|
94
|
+
destroyAdded = await addDestroyToBrowserInit(engineDir, options.destroy, marker);
|
|
78
95
|
}
|
|
79
96
|
// 4. Add #include directive to the top-level chrome document (if provided)
|
|
80
97
|
let domInserted = false;
|
|
@@ -94,6 +94,16 @@ export function isPackageablePath(sourcePath) {
|
|
|
94
94
|
}
|
|
95
95
|
if (BUILD_INPUT_BASENAMES.has(basename(sourcePath)))
|
|
96
96
|
return false;
|
|
97
|
+
// `.inc.xhtml` fragments are consumed via `#include` from a registered
|
|
98
|
+
// chrome document and resolved at packaging time — they never ship as
|
|
99
|
+
// a standalone packaged artifact. 2026-04-21 eval (Finding #11):
|
|
100
|
+
// `fireforge build --ui` after `wire --dom` flagged the wired
|
|
101
|
+
// `*.inc.xhtml` as "missing packaged artifact" even though
|
|
102
|
+
// `register` correctly refuses to register it and the operator
|
|
103
|
+
// followed the documented workflow. Mirror the same carve-out the
|
|
104
|
+
// register rules apply.
|
|
105
|
+
if (sourcePath.endsWith('.inc.xhtml'))
|
|
106
|
+
return false;
|
|
97
107
|
for (const ext of PACKAGEABLE_EXTENSIONS) {
|
|
98
108
|
if (sourcePath.endsWith(ext))
|
|
99
109
|
return true;
|
|
@@ -4,6 +4,20 @@ export declare const CUSTOM_ELEMENTS_JS = "toolkit/content/customElements.js";
|
|
|
4
4
|
export declare const JAR_MN = "toolkit/content/jar.mn";
|
|
5
5
|
/** Default Fluent localization directory for toolkit global components, relative to engine root */
|
|
6
6
|
export declare const FTL_DIR = "toolkit/locales/en-US/toolkit/global";
|
|
7
|
+
/**
|
|
8
|
+
* Suffix for the per-binary xpcshell scaffold parent directory. Components
|
|
9
|
+
* created with `furnace create --with-tests --xpcshell` land at
|
|
10
|
+
* `browser/base/content/test/<binaryName>${XPCSHELL_TEST_DIR_SUFFIX}/<component>/`.
|
|
11
|
+
* Centralised so `create` / `remove` / `rename` / `validate` all agree on
|
|
12
|
+
* the path template (2026-04-24 eval Finding 5).
|
|
13
|
+
*/
|
|
14
|
+
export declare const XPCSHELL_TEST_DIR_SUFFIX = "-xpcshell";
|
|
15
|
+
/**
|
|
16
|
+
* Returns the engine-relative directory that holds xpcshell scaffolds for
|
|
17
|
+
* a given binary. Matches the form `create-xpcshell.ts` writes and the
|
|
18
|
+
* path `remove.ts` / `rename.ts` / `validate.ts` must clean up.
|
|
19
|
+
*/
|
|
20
|
+
export declare function xpcshellTestParentDir(binaryName: string): string;
|
|
7
21
|
/** File extensions that constitute a Furnace component's source files. */
|
|
8
22
|
export declare const COMPONENT_FILE_EXTENSIONS: readonly [".mjs", ".css", ".ftl"];
|
|
9
23
|
/** Returns true when `fileName` has one of the standard component file extensions. */
|
|
@@ -5,6 +5,22 @@ export const CUSTOM_ELEMENTS_JS = 'toolkit/content/customElements.js';
|
|
|
5
5
|
export const JAR_MN = 'toolkit/content/jar.mn';
|
|
6
6
|
/** Default Fluent localization directory for toolkit global components, relative to engine root */
|
|
7
7
|
export const FTL_DIR = 'toolkit/locales/en-US/toolkit/global';
|
|
8
|
+
/**
|
|
9
|
+
* Suffix for the per-binary xpcshell scaffold parent directory. Components
|
|
10
|
+
* created with `furnace create --with-tests --xpcshell` land at
|
|
11
|
+
* `browser/base/content/test/<binaryName>${XPCSHELL_TEST_DIR_SUFFIX}/<component>/`.
|
|
12
|
+
* Centralised so `create` / `remove` / `rename` / `validate` all agree on
|
|
13
|
+
* the path template (2026-04-24 eval Finding 5).
|
|
14
|
+
*/
|
|
15
|
+
export const XPCSHELL_TEST_DIR_SUFFIX = '-xpcshell';
|
|
16
|
+
/**
|
|
17
|
+
* Returns the engine-relative directory that holds xpcshell scaffolds for
|
|
18
|
+
* a given binary. Matches the form `create-xpcshell.ts` writes and the
|
|
19
|
+
* path `remove.ts` / `rename.ts` / `validate.ts` must clean up.
|
|
20
|
+
*/
|
|
21
|
+
export function xpcshellTestParentDir(binaryName) {
|
|
22
|
+
return `browser/base/content/test/${binaryName}${XPCSHELL_TEST_DIR_SUFFIX}`;
|
|
23
|
+
}
|
|
8
24
|
/** File extensions that constitute a Furnace component's source files. */
|
|
9
25
|
export const COMPONENT_FILE_EXTENSIONS = ['.mjs', '.css', '.ftl'];
|
|
10
26
|
/** Returns true when `fileName` has one of the standard component file extensions. */
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EUPL-1.2
|
|
2
|
+
import { readdir } from 'node:fs/promises';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import { pathExists } from '../utils/fs.js';
|
|
4
|
-
import { loadConfig } from './config.js';
|
|
5
|
+
import { getProjectPaths, loadConfig } from './config.js';
|
|
5
6
|
import { getFurnacePaths, loadFurnaceConfig } from './furnace-config.js';
|
|
7
|
+
import { xpcshellTestParentDir } from './furnace-constants.js';
|
|
6
8
|
import { detectComposesCycles, validateComposesReferences } from './furnace-graph-utils.js';
|
|
7
9
|
import { validateAccessibility, validateCompatibility, validateJarMnEntries, validateRegistrationPatterns, validateStructure, validateTokenLink, } from './furnace-validate-checks.js';
|
|
8
10
|
import { findOverrideBaseVersionDrift, } from './furnace-version-drift.js';
|
|
@@ -175,6 +177,70 @@ export async function validateAllComponents(root) {
|
|
|
175
177
|
existing.push(issue);
|
|
176
178
|
results.set(issue.component, existing);
|
|
177
179
|
}
|
|
180
|
+
// 2026-04-24 eval Finding 5: orphan xpcshell scaffold detection.
|
|
181
|
+
// `furnace create --with-tests --xpcshell` scaffolds a test directory
|
|
182
|
+
// at `browser/base/content/test/<binary>-xpcshell/<name>/`, and prior
|
|
183
|
+
// `furnace remove` + `furnace rename` flows did not touch that tree.
|
|
184
|
+
// A leftover scaffold whose `<name>` is not in furnace.json is almost
|
|
185
|
+
// always the aftermath of one of those incomplete flows; flag it as
|
|
186
|
+
// an `orphan-xpcshell-scaffold` error so operators know to delete or
|
|
187
|
+
// re-create the scaffold instead of discovering the mismatch only at
|
|
188
|
+
// test run time. Missing engine or missing scaffold parent directory
|
|
189
|
+
// both degrade silently — this check never introduces noise on a
|
|
190
|
+
// project that never used xpcshell scaffolding.
|
|
191
|
+
try {
|
|
192
|
+
const orphanIssues = await findOrphanXpcshellScaffolds(root, config);
|
|
193
|
+
for (const issue of orphanIssues) {
|
|
194
|
+
const existing = results.get(issue.component) ?? [];
|
|
195
|
+
existing.push(issue);
|
|
196
|
+
results.set(issue.component, existing);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
// Validation degrades gracefully — the absence of an engine
|
|
201
|
+
// directory, permission denial reading the scaffold tree, or any
|
|
202
|
+
// other transient fs issue should never cascade into false
|
|
203
|
+
// "orphan" reports.
|
|
204
|
+
}
|
|
178
205
|
return results;
|
|
179
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Scans the per-binary xpcshell scaffold directory for entries whose
|
|
209
|
+
* component name is not present in furnace.json, and returns an
|
|
210
|
+
* `orphan-xpcshell-scaffold` issue for each one.
|
|
211
|
+
*/
|
|
212
|
+
async function findOrphanXpcshellScaffolds(root, config) {
|
|
213
|
+
const forgeConfig = await loadConfig(root);
|
|
214
|
+
const paths = getProjectPaths(root);
|
|
215
|
+
const parentRel = xpcshellTestParentDir(forgeConfig.binaryName);
|
|
216
|
+
const parentAbs = join(paths.engine, parentRel);
|
|
217
|
+
if (!(await pathExists(parentAbs)))
|
|
218
|
+
return [];
|
|
219
|
+
let entries;
|
|
220
|
+
try {
|
|
221
|
+
const dirents = await readdir(parentAbs, { withFileTypes: true });
|
|
222
|
+
entries = dirents.filter((d) => d.isDirectory()).map((d) => d.name);
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
const known = new Set([
|
|
228
|
+
...Object.keys(config.custom),
|
|
229
|
+
...Object.keys(config.overrides),
|
|
230
|
+
...config.stock,
|
|
231
|
+
]);
|
|
232
|
+
const issues = [];
|
|
233
|
+
for (const entry of entries) {
|
|
234
|
+
if (known.has(entry))
|
|
235
|
+
continue;
|
|
236
|
+
issues.push({
|
|
237
|
+
component: entry,
|
|
238
|
+
severity: 'error',
|
|
239
|
+
check: 'orphan-xpcshell-scaffold',
|
|
240
|
+
message: `Stale xpcshell test scaffold at ${parentRel}/${entry}/ — no matching component is declared in furnace.json. ` +
|
|
241
|
+
'Delete the scaffold directory manually, or re-run `fireforge furnace create --with-tests --xpcshell` for an existing component with the same name.',
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return issues;
|
|
245
|
+
}
|
|
180
246
|
//# sourceMappingURL=furnace-validate.js.map
|
|
@@ -1,6 +1,31 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable that overrides the monolithic `git add -A` timeout
|
|
3
|
+
* (milliseconds). 2026-04-24 eval Finding 10: operators on slow or loaded
|
|
4
|
+
* filesystems legitimately exceeded the 10-minute default during a
|
|
5
|
+
* 140.10.0esr baseline indexing pass; making the cap overridable lets
|
|
6
|
+
* them retry without recompiling.
|
|
7
|
+
*/
|
|
8
|
+
export declare const GIT_ADD_TIMEOUT_ENV_VAR = "FIREFORGE_GIT_ADD_TIMEOUT_MS";
|
|
9
|
+
/**
|
|
10
|
+
* Environment variable that overrides the per-chunk `git add -- <dir>`
|
|
11
|
+
* timeout (milliseconds). Paired with {@link GIT_ADD_TIMEOUT_ENV_VAR} so
|
|
12
|
+
* both the monolithic attempt and the chunked fallback can be extended.
|
|
13
|
+
*/
|
|
14
|
+
export declare const GIT_ADD_CHUNK_TIMEOUT_ENV_VAR = "FIREFORGE_GIT_ADD_CHUNK_TIMEOUT_MS";
|
|
15
|
+
/**
|
|
16
|
+
* Resolved timeout for monolithic `git add -A`. Prefers
|
|
17
|
+
* {@link GIT_ADD_TIMEOUT_ENV_VAR} when present (and a positive
|
|
18
|
+
* integer) so operators on slow hosts can extend the default without
|
|
19
|
+
* rebuilding FireForge.
|
|
20
|
+
*/
|
|
2
21
|
export declare const GIT_ADD_TIMEOUT_MS: number;
|
|
3
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Resolved timeout for each chunk of the chunked fallback path. Grew
|
|
24
|
+
* from 20 to 30 minutes in 0.18.1 because the fallback is already the
|
|
25
|
+
* last line of defence before aborting — erring on the side of "complete
|
|
26
|
+
* the indexing" over "fail fast" matches the real-world recovery
|
|
27
|
+
* workflow.
|
|
28
|
+
*/
|
|
4
29
|
export declare const GIT_ADD_CHUNK_TIMEOUT_MS: number;
|
|
5
30
|
/**
|
|
6
31
|
* Structured git status entry derived from `git status --porcelain=v1 -z`.
|
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EUPL-1.2
|
|
2
2
|
import { GitError, GitNotFoundError } from '../errors/git.js';
|
|
3
3
|
import { exec, executableExists } from '../utils/process.js';
|
|
4
|
+
/**
|
|
5
|
+
* Environment variable that overrides the monolithic `git add -A` timeout
|
|
6
|
+
* (milliseconds). 2026-04-24 eval Finding 10: operators on slow or loaded
|
|
7
|
+
* filesystems legitimately exceeded the 10-minute default during a
|
|
8
|
+
* 140.10.0esr baseline indexing pass; making the cap overridable lets
|
|
9
|
+
* them retry without recompiling.
|
|
10
|
+
*/
|
|
11
|
+
export const GIT_ADD_TIMEOUT_ENV_VAR = 'FIREFORGE_GIT_ADD_TIMEOUT_MS';
|
|
12
|
+
/**
|
|
13
|
+
* Environment variable that overrides the per-chunk `git add -- <dir>`
|
|
14
|
+
* timeout (milliseconds). Paired with {@link GIT_ADD_TIMEOUT_ENV_VAR} so
|
|
15
|
+
* both the monolithic attempt and the chunked fallback can be extended.
|
|
16
|
+
*/
|
|
17
|
+
export const GIT_ADD_CHUNK_TIMEOUT_ENV_VAR = 'FIREFORGE_GIT_ADD_CHUNK_TIMEOUT_MS';
|
|
4
18
|
/** Default timeout for `git add -A` on large trees (10 minutes). */
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
19
|
+
const DEFAULT_GIT_ADD_TIMEOUT_MS = 10 * 60_000;
|
|
20
|
+
/** Default timeout for chunked `git add` per top-level directory (30 minutes). */
|
|
21
|
+
const DEFAULT_GIT_ADD_CHUNK_TIMEOUT_MS = 30 * 60_000;
|
|
22
|
+
function resolveTimeoutFromEnv(envVar, fallbackMs) {
|
|
23
|
+
const raw = process.env[envVar];
|
|
24
|
+
if (raw === undefined || raw.length === 0)
|
|
25
|
+
return fallbackMs;
|
|
26
|
+
const parsed = Number.parseInt(raw, 10);
|
|
27
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
28
|
+
return fallbackMs;
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolved timeout for monolithic `git add -A`. Prefers
|
|
33
|
+
* {@link GIT_ADD_TIMEOUT_ENV_VAR} when present (and a positive
|
|
34
|
+
* integer) so operators on slow hosts can extend the default without
|
|
35
|
+
* rebuilding FireForge.
|
|
36
|
+
*/
|
|
37
|
+
export const GIT_ADD_TIMEOUT_MS = resolveTimeoutFromEnv(GIT_ADD_TIMEOUT_ENV_VAR, DEFAULT_GIT_ADD_TIMEOUT_MS);
|
|
38
|
+
/**
|
|
39
|
+
* Resolved timeout for each chunk of the chunked fallback path. Grew
|
|
40
|
+
* from 20 to 30 minutes in 0.18.1 because the fallback is already the
|
|
41
|
+
* last line of defence before aborting — erring on the side of "complete
|
|
42
|
+
* the indexing" over "fail fast" matches the real-world recovery
|
|
43
|
+
* workflow.
|
|
44
|
+
*/
|
|
45
|
+
export const GIT_ADD_CHUNK_TIMEOUT_MS = resolveTimeoutFromEnv(GIT_ADD_CHUNK_TIMEOUT_ENV_VAR, DEFAULT_GIT_ADD_CHUNK_TIMEOUT_MS);
|
|
8
46
|
/**
|
|
9
47
|
* Ensures git is available in the system.
|
|
10
48
|
* @throws GitNotFoundError if git is not installed
|
|
@@ -9,7 +9,7 @@ import { verbose } from '../utils/logger.js';
|
|
|
9
9
|
import { exec } from '../utils/process.js';
|
|
10
10
|
import { ensureGit, git } from './git-base.js';
|
|
11
11
|
import { fileExistsInHead } from './git-file-ops.js';
|
|
12
|
-
import { getUntrackedFiles } from './git-status.js';
|
|
12
|
+
import { getUntrackedFiles, getUntrackedFilesInDir } from './git-status.js';
|
|
13
13
|
async function execGitWithAllowedExitCodes(repoDir, args, allowedExitCodes = [0]) {
|
|
14
14
|
const result = await exec('git', args, { cwd: repoDir });
|
|
15
15
|
if (allowedExitCodes.includes(result.exitCode)) {
|
|
@@ -183,7 +183,26 @@ export async function getAllDiff(repoDir) {
|
|
|
183
183
|
*/
|
|
184
184
|
export async function getDiffForFilesAgainstHead(repoDir, files) {
|
|
185
185
|
await ensureGit();
|
|
186
|
-
|
|
186
|
+
// Expand any directory entries (paths ending with `/`) into their
|
|
187
|
+
// individual untracked files before diffing. `git status --porcelain=v1`
|
|
188
|
+
// reports collapsed untracked directories as `?? dir/`, and every caller
|
|
189
|
+
// that feeds the aggregate working-tree state into this function must
|
|
190
|
+
// not trigger an EISDIR when the diff pass reads `dir/` as if it were a
|
|
191
|
+
// file. Belt-and-suspenders: the caller-side expansion in `lint.ts`
|
|
192
|
+
// and `export-all.ts` covers the common path, but a single bad call
|
|
193
|
+
// site re-introduced the bug in 0.17.0 — guarding here makes the
|
|
194
|
+
// regression impossible at this layer.
|
|
195
|
+
const expandedFiles = [];
|
|
196
|
+
for (const file of files) {
|
|
197
|
+
if (file.endsWith('/')) {
|
|
198
|
+
const inner = await getUntrackedFilesInDir(repoDir, file);
|
|
199
|
+
for (const entry of inner)
|
|
200
|
+
expandedFiles.push(entry);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
expandedFiles.push(file);
|
|
204
|
+
}
|
|
205
|
+
const uniqueFiles = [...new Set(expandedFiles)].sort();
|
|
187
206
|
const diffs = [];
|
|
188
207
|
for (const file of uniqueFiles) {
|
|
189
208
|
if (await fileExistsInHead(repoDir, file)) {
|