@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.
- package/CHANGELOG.md +7 -0
- package/LICENSE.md +294 -0
- package/README.md +435 -0
- package/dist/bin/fireforge.d.ts +10 -0
- package/dist/bin/fireforge.js +29 -0
- package/dist/src/cli.d.ts +33 -0
- package/dist/src/cli.js +180 -0
- package/dist/src/commands/bootstrap.d.ts +9 -0
- package/dist/src/commands/bootstrap.js +73 -0
- package/dist/src/commands/build.d.ts +11 -0
- package/dist/src/commands/build.js +102 -0
- package/dist/src/commands/config.d.ts +13 -0
- package/dist/src/commands/config.js +135 -0
- package/dist/src/commands/discard.d.ts +12 -0
- package/dist/src/commands/discard.js +84 -0
- package/dist/src/commands/doctor.d.ts +18 -0
- package/dist/src/commands/doctor.js +356 -0
- package/dist/src/commands/download.d.ts +11 -0
- package/dist/src/commands/download.js +127 -0
- package/dist/src/commands/export-all.d.ts +11 -0
- package/dist/src/commands/export-all.js +122 -0
- package/dist/src/commands/export-shared.d.ts +48 -0
- package/dist/src/commands/export-shared.js +208 -0
- package/dist/src/commands/export.d.ts +13 -0
- package/dist/src/commands/export.js +178 -0
- package/dist/src/commands/furnace/apply.d.ts +7 -0
- package/dist/src/commands/furnace/apply.js +80 -0
- package/dist/src/commands/furnace/create.d.ts +8 -0
- package/dist/src/commands/furnace/create.js +377 -0
- package/dist/src/commands/furnace/deploy.d.ts +8 -0
- package/dist/src/commands/furnace/deploy.js +338 -0
- package/dist/src/commands/furnace/diff.d.ts +7 -0
- package/dist/src/commands/furnace/diff.js +119 -0
- package/dist/src/commands/furnace/index.d.ts +16 -0
- package/dist/src/commands/furnace/index.js +121 -0
- package/dist/src/commands/furnace/list.d.ts +5 -0
- package/dist/src/commands/furnace/list.js +65 -0
- package/dist/src/commands/furnace/override.d.ts +8 -0
- package/dist/src/commands/furnace/override.js +188 -0
- package/dist/src/commands/furnace/preview.d.ts +7 -0
- package/dist/src/commands/furnace/preview.js +96 -0
- package/dist/src/commands/furnace/remove.d.ts +8 -0
- package/dist/src/commands/furnace/remove.js +159 -0
- package/dist/src/commands/furnace/scan.d.ts +5 -0
- package/dist/src/commands/furnace/scan.js +112 -0
- package/dist/src/commands/furnace/status.d.ts +7 -0
- package/dist/src/commands/furnace/status.js +137 -0
- package/dist/src/commands/furnace/validate.d.ts +6 -0
- package/dist/src/commands/furnace/validate.js +91 -0
- package/dist/src/commands/furnace/validation-output.d.ts +7 -0
- package/dist/src/commands/furnace/validation-output.js +22 -0
- package/dist/src/commands/import.d.ts +11 -0
- package/dist/src/commands/import.js +241 -0
- package/dist/src/commands/lint.d.ts +10 -0
- package/dist/src/commands/lint.js +118 -0
- package/dist/src/commands/package.d.ts +11 -0
- package/dist/src/commands/package.js +80 -0
- package/dist/src/commands/re-export.d.ts +12 -0
- package/dist/src/commands/re-export.js +242 -0
- package/dist/src/commands/rebase/abort.d.ts +7 -0
- package/dist/src/commands/rebase/abort.js +49 -0
- package/dist/src/commands/rebase/confirm.d.ts +18 -0
- package/dist/src/commands/rebase/confirm.js +33 -0
- package/dist/src/commands/rebase/continue.d.ts +7 -0
- package/dist/src/commands/rebase/continue.js +81 -0
- package/dist/src/commands/rebase/index.d.ts +22 -0
- package/dist/src/commands/rebase/index.js +127 -0
- package/dist/src/commands/rebase/patch-loop.d.ts +9 -0
- package/dist/src/commands/rebase/patch-loop.js +135 -0
- package/dist/src/commands/rebase/summary.d.ts +12 -0
- package/dist/src/commands/rebase/summary.js +43 -0
- package/dist/src/commands/rebase.d.ts +4 -0
- package/dist/src/commands/rebase.js +6 -0
- package/dist/src/commands/register.d.ts +13 -0
- package/dist/src/commands/register.js +67 -0
- package/dist/src/commands/reset.d.ts +11 -0
- package/dist/src/commands/reset.js +83 -0
- package/dist/src/commands/resolve.d.ts +9 -0
- package/dist/src/commands/resolve.js +124 -0
- package/dist/src/commands/run.d.ts +9 -0
- package/dist/src/commands/run.js +91 -0
- package/dist/src/commands/setup-support.d.ts +23 -0
- package/dist/src/commands/setup-support.js +310 -0
- package/dist/src/commands/setup.d.ts +11 -0
- package/dist/src/commands/setup.js +94 -0
- package/dist/src/commands/status.d.ts +11 -0
- package/dist/src/commands/status.js +268 -0
- package/dist/src/commands/test.d.ts +12 -0
- package/dist/src/commands/test.js +182 -0
- package/dist/src/commands/token-coverage.d.ts +5 -0
- package/dist/src/commands/token-coverage.js +57 -0
- package/dist/src/commands/token.d.ts +14 -0
- package/dist/src/commands/token.js +121 -0
- package/dist/src/commands/watch.d.ts +9 -0
- package/dist/src/commands/watch.js +112 -0
- package/dist/src/commands/wire.d.ts +13 -0
- package/dist/src/commands/wire.js +149 -0
- package/dist/src/core/ast-utils.d.ts +47 -0
- package/dist/src/core/ast-utils.js +57 -0
- package/dist/src/core/brand-validation.d.ts +7 -0
- package/dist/src/core/brand-validation.js +15 -0
- package/dist/src/core/branding.d.ts +49 -0
- package/dist/src/core/branding.js +229 -0
- package/dist/src/core/browser-wire.d.ts +40 -0
- package/dist/src/core/browser-wire.js +66 -0
- package/dist/src/core/build-prepare.d.ts +25 -0
- package/dist/src/core/build-prepare.js +93 -0
- package/dist/src/core/config-mutate.d.ts +15 -0
- package/dist/src/core/config-mutate.js +51 -0
- package/dist/src/core/config-paths.d.ts +28 -0
- package/dist/src/core/config-paths.js +65 -0
- package/dist/src/core/config-state.d.ts +28 -0
- package/dist/src/core/config-state.js +152 -0
- package/dist/src/core/config-validate.d.ts +11 -0
- package/dist/src/core/config-validate.js +141 -0
- package/dist/src/core/config.d.ts +39 -0
- package/dist/src/core/config.js +70 -0
- package/dist/src/core/file-lock.d.ts +11 -0
- package/dist/src/core/file-lock.js +80 -0
- package/dist/src/core/firefox-archive.d.ts +40 -0
- package/dist/src/core/firefox-archive.js +63 -0
- package/dist/src/core/firefox-cache.d.ts +23 -0
- package/dist/src/core/firefox-cache.js +134 -0
- package/dist/src/core/firefox-download.d.ts +21 -0
- package/dist/src/core/firefox-download.js +129 -0
- package/dist/src/core/firefox-extract.d.ts +21 -0
- package/dist/src/core/firefox-extract.js +53 -0
- package/dist/src/core/firefox.d.ts +34 -0
- package/dist/src/core/firefox.js +78 -0
- package/dist/src/core/furnace-apply-helpers.d.ts +21 -0
- package/dist/src/core/furnace-apply-helpers.js +244 -0
- package/dist/src/core/furnace-apply.d.ts +16 -0
- package/dist/src/core/furnace-apply.js +147 -0
- package/dist/src/core/furnace-config.d.ts +94 -0
- package/dist/src/core/furnace-config.js +372 -0
- package/dist/src/core/furnace-constants.d.ts +4 -0
- package/dist/src/core/furnace-constants.js +6 -0
- package/dist/src/core/furnace-registration-ast.d.ts +24 -0
- package/dist/src/core/furnace-registration-ast.js +218 -0
- package/dist/src/core/furnace-registration-remove.d.ts +14 -0
- package/dist/src/core/furnace-registration-remove.js +89 -0
- package/dist/src/core/furnace-registration-validate.d.ts +20 -0
- package/dist/src/core/furnace-registration-validate.js +40 -0
- package/dist/src/core/furnace-registration.d.ts +29 -0
- package/dist/src/core/furnace-registration.js +96 -0
- package/dist/src/core/furnace-rollback.d.ts +20 -0
- package/dist/src/core/furnace-rollback.js +66 -0
- package/dist/src/core/furnace-scanner.d.ts +40 -0
- package/dist/src/core/furnace-scanner.js +143 -0
- package/dist/src/core/furnace-stories.d.ts +37 -0
- package/dist/src/core/furnace-stories.js +185 -0
- package/dist/src/core/furnace-validate-accessibility.d.ts +6 -0
- package/dist/src/core/furnace-validate-accessibility.js +32 -0
- package/dist/src/core/furnace-validate-checks.d.ts +4 -0
- package/dist/src/core/furnace-validate-checks.js +7 -0
- package/dist/src/core/furnace-validate-compatibility.d.ts +6 -0
- package/dist/src/core/furnace-validate-compatibility.js +57 -0
- package/dist/src/core/furnace-validate-helpers.d.ts +28 -0
- package/dist/src/core/furnace-validate-helpers.js +129 -0
- package/dist/src/core/furnace-validate-registration.d.ts +37 -0
- package/dist/src/core/furnace-validate-registration.js +220 -0
- package/dist/src/core/furnace-validate-structure.d.ts +6 -0
- package/dist/src/core/furnace-validate-structure.js +66 -0
- package/dist/src/core/furnace-validate.d.ts +16 -0
- package/dist/src/core/furnace-validate.js +103 -0
- package/dist/src/core/git-base.d.ts +47 -0
- package/dist/src/core/git-base.js +50 -0
- package/dist/src/core/git-diff.d.ts +63 -0
- package/dist/src/core/git-diff.js +246 -0
- package/dist/src/core/git-file-ops.d.ts +65 -0
- package/dist/src/core/git-file-ops.js +141 -0
- package/dist/src/core/git-status.d.ts +65 -0
- package/dist/src/core/git-status.js +163 -0
- package/dist/src/core/git.d.ts +113 -0
- package/dist/src/core/git.js +363 -0
- package/dist/src/core/license-headers.d.ts +36 -0
- package/dist/src/core/license-headers.js +83 -0
- package/dist/src/core/mach-build-artifacts.d.ts +29 -0
- package/dist/src/core/mach-build-artifacts.js +117 -0
- package/dist/src/core/mach-mozconfig.d.ts +17 -0
- package/dist/src/core/mach-mozconfig.js +50 -0
- package/dist/src/core/mach-python.d.ts +16 -0
- package/dist/src/core/mach-python.js +126 -0
- package/dist/src/core/mach.d.ts +106 -0
- package/dist/src/core/mach.js +166 -0
- package/dist/src/core/manifest-helpers.d.ts +25 -0
- package/dist/src/core/manifest-helpers.js +96 -0
- package/dist/src/core/manifest-register.d.ts +30 -0
- package/dist/src/core/manifest-register.js +65 -0
- package/dist/src/core/manifest-rules.d.ts +39 -0
- package/dist/src/core/manifest-rules.js +151 -0
- package/dist/src/core/manifest-tokenizers.d.ts +34 -0
- package/dist/src/core/manifest-tokenizers.js +84 -0
- package/dist/src/core/parser-fallback.d.ts +36 -0
- package/dist/src/core/parser-fallback.js +43 -0
- package/dist/src/core/patch-apply-fuzz.d.ts +29 -0
- package/dist/src/core/patch-apply-fuzz.js +70 -0
- package/dist/src/core/patch-apply.d.ts +46 -0
- package/dist/src/core/patch-apply.js +235 -0
- package/dist/src/core/patch-export.d.ts +99 -0
- package/dist/src/core/patch-export.js +314 -0
- package/dist/src/core/patch-files.d.ts +11 -0
- package/dist/src/core/patch-files.js +51 -0
- package/dist/src/core/patch-lint.d.ts +72 -0
- package/dist/src/core/patch-lint.js +403 -0
- package/dist/src/core/patch-lock.d.ts +8 -0
- package/dist/src/core/patch-lock.js +29 -0
- package/dist/src/core/patch-manifest-consistency.d.ts +24 -0
- package/dist/src/core/patch-manifest-consistency.js +135 -0
- package/dist/src/core/patch-manifest-io.d.ts +36 -0
- package/dist/src/core/patch-manifest-io.js +77 -0
- package/dist/src/core/patch-manifest-query.d.ts +48 -0
- package/dist/src/core/patch-manifest-query.js +124 -0
- package/dist/src/core/patch-manifest-validate.d.ts +22 -0
- package/dist/src/core/patch-manifest-validate.js +72 -0
- package/dist/src/core/patch-manifest.d.ts +11 -0
- package/dist/src/core/patch-manifest.js +12 -0
- package/dist/src/core/patch-parse.d.ts +43 -0
- package/dist/src/core/patch-parse.js +143 -0
- package/dist/src/core/patch-transform.d.ts +21 -0
- package/dist/src/core/patch-transform.js +138 -0
- package/dist/src/core/rebase-session.d.ts +47 -0
- package/dist/src/core/rebase-session.js +65 -0
- package/dist/src/core/register-browser-content.d.ts +11 -0
- package/dist/src/core/register-browser-content.js +116 -0
- package/dist/src/core/register-module.d.ts +11 -0
- package/dist/src/core/register-module.js +76 -0
- package/dist/src/core/register-shared-css.d.ts +11 -0
- package/dist/src/core/register-shared-css.js +117 -0
- package/dist/src/core/register-test-manifest.d.ts +18 -0
- package/dist/src/core/register-test-manifest.js +99 -0
- package/dist/src/core/state-file.d.ts +4 -0
- package/dist/src/core/state-file.js +25 -0
- package/dist/src/core/token-coverage.d.ts +12 -0
- package/dist/src/core/token-coverage.js +74 -0
- package/dist/src/core/token-manager.d.ts +55 -0
- package/dist/src/core/token-manager.js +387 -0
- package/dist/src/core/wire-destroy.d.ts +21 -0
- package/dist/src/core/wire-destroy.js +103 -0
- package/dist/src/core/wire-dom-fragment.d.ts +23 -0
- package/dist/src/core/wire-dom-fragment.js +129 -0
- package/dist/src/core/wire-init.d.ts +23 -0
- package/dist/src/core/wire-init.js +201 -0
- package/dist/src/core/wire-subscript.d.ts +20 -0
- package/dist/src/core/wire-subscript.js +134 -0
- package/dist/src/core/wire-targets.d.ts +7 -0
- package/dist/src/core/wire-targets.js +9 -0
- package/dist/src/core/wire-utils.d.ts +88 -0
- package/dist/src/core/wire-utils.js +279 -0
- package/dist/src/errors/base.d.ts +60 -0
- package/dist/src/errors/base.js +87 -0
- package/dist/src/errors/build.d.ts +52 -0
- package/dist/src/errors/build.js +114 -0
- package/dist/src/errors/codes.d.ts +29 -0
- package/dist/src/errors/codes.js +30 -0
- package/dist/src/errors/config.d.ts +31 -0
- package/dist/src/errors/config.js +61 -0
- package/dist/src/errors/download.d.ts +42 -0
- package/dist/src/errors/download.js +95 -0
- package/dist/src/errors/furnace.d.ts +10 -0
- package/dist/src/errors/furnace.js +22 -0
- package/dist/src/errors/git.d.ts +41 -0
- package/dist/src/errors/git.js +99 -0
- package/dist/src/errors/patch.d.ts +10 -0
- package/dist/src/errors/patch.js +26 -0
- package/dist/src/errors/rebase.d.ts +20 -0
- package/dist/src/errors/rebase.js +30 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.js +21 -0
- package/dist/src/types/cli.d.ts +14 -0
- package/dist/src/types/cli.js +2 -0
- package/dist/src/types/commands/index.d.ts +6 -0
- package/dist/src/types/commands/index.js +6 -0
- package/dist/src/types/commands/options.d.ts +239 -0
- package/dist/src/types/commands/options.js +6 -0
- package/dist/src/types/commands/patches.d.ts +89 -0
- package/dist/src/types/commands/patches.js +6 -0
- package/dist/src/types/commands/project.d.ts +71 -0
- package/dist/src/types/commands/project.js +6 -0
- package/dist/src/types/config.d.ts +101 -0
- package/dist/src/types/config.js +2 -0
- package/dist/src/types/furnace.d.ts +158 -0
- package/dist/src/types/furnace.js +2 -0
- package/dist/src/types/index.d.ts +6 -0
- package/dist/src/types/index.js +6 -0
- package/dist/src/utils/errors.d.ts +2 -0
- package/dist/src/utils/errors.js +15 -0
- package/dist/src/utils/fs.d.ts +72 -0
- package/dist/src/utils/fs.js +179 -0
- package/dist/src/utils/logger.d.ts +58 -0
- package/dist/src/utils/logger.js +120 -0
- package/dist/src/utils/options.d.ts +8 -0
- package/dist/src/utils/options.js +16 -0
- package/dist/src/utils/package-root.d.ts +10 -0
- package/dist/src/utils/package-root.js +53 -0
- package/dist/src/utils/parse.d.ts +110 -0
- package/dist/src/utils/parse.js +200 -0
- package/dist/src/utils/paths.d.ts +10 -0
- package/dist/src/utils/paths.js +43 -0
- package/dist/src/utils/platform.d.ts +38 -0
- package/dist/src/utils/platform.js +56 -0
- package/dist/src/utils/process.d.ts +80 -0
- package/dist/src/utils/process.js +188 -0
- package/dist/src/utils/regex.d.ts +24 -0
- package/dist/src/utils/regex.js +40 -0
- package/dist/src/utils/validation.d.ts +133 -0
- package/dist/src/utils/validation.js +250 -0
- package/package.json +106 -0
- package/templates/configs/common.mozconfig +24 -0
- package/templates/configs/darwin.mozconfig +10 -0
- package/templates/configs/linux.mozconfig +12 -0
- package/templates/configs/win32.mozconfig +14 -0
- package/templates/licenses/0BSD.md +14 -0
- package/templates/licenses/EUPL-1.2.md +294 -0
- package/templates/licenses/GPL-2.0-or-later.md +339 -0
- package/templates/licenses/MPL-2.0.md +383 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type * as estree from 'estree';
|
|
2
|
+
import { type AcornESTreeNode } from './ast-utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates a name for safe interpolation into generated JavaScript string literals.
|
|
5
|
+
* Rejects strings containing characters that could break out of JS strings or inject code.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateWireName(value: string, label: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* Counts net brace depth change in a single line, ignoring braces inside
|
|
10
|
+
* string literals (single, double, template), line comments (`//`), and
|
|
11
|
+
* block comments.
|
|
12
|
+
*
|
|
13
|
+
* Tracks multi-line block comment state across calls via the `inBlockComment`
|
|
14
|
+
* parameter, allowing callers to iterate over lines while preserving context.
|
|
15
|
+
*
|
|
16
|
+
* **Regex literal heuristic:** When a `/` follows an operator or keyword-boundary
|
|
17
|
+
* character (one of `= ( : , ! | & ? ; ~ ^ { [ \n + - * % < >`), it is treated
|
|
18
|
+
* as a regex literal opener and characters are skipped until the closing `/`.
|
|
19
|
+
* This heuristic can misfire on:
|
|
20
|
+
* - Division operators where the left operand is an identifier (`x / y / z`
|
|
21
|
+
* would incorrectly treat ` y ` as regex content).
|
|
22
|
+
* - Tagged template literals or unusual formatting.
|
|
23
|
+
*
|
|
24
|
+
* For Firefox source files this heuristic is sufficient because the AST-based
|
|
25
|
+
* parser (via `withParserFallback`) is tried first; this function is only
|
|
26
|
+
* used in the regex-based fallback path.
|
|
27
|
+
*
|
|
28
|
+
* @param line - A single line of source text
|
|
29
|
+
* @param inBlockComment - Whether the previous line ended inside a block comment
|
|
30
|
+
* @returns The net brace depth change and updated block comment state
|
|
31
|
+
*/
|
|
32
|
+
export declare function countBraceDepth(line: string, inBlockComment: boolean): {
|
|
33
|
+
depth: number;
|
|
34
|
+
inBlockComment: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Extracts the class/object name from an expression like "MyComponent.init()".
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractNameFromExpression(expression: string): string;
|
|
40
|
+
/** Token types for XHTML/preprocessor files */
|
|
41
|
+
export interface XhtmlToken {
|
|
42
|
+
type: 'xml' | 'macro' | 'empty';
|
|
43
|
+
raw: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Tokenize an XHTML file with Mozilla preprocessor `#include` directives
|
|
47
|
+
* into a structured array.
|
|
48
|
+
*/
|
|
49
|
+
export declare function tokenizeXhtml(lines: string[]): XhtmlToken[];
|
|
50
|
+
/**
|
|
51
|
+
* Finds the line index of a method signature matching `pattern`, then
|
|
52
|
+
* advances to the line containing the opening brace.
|
|
53
|
+
*
|
|
54
|
+
* @returns `{ methodLine, braceIndex }`, or `null` if the pattern is not found.
|
|
55
|
+
*/
|
|
56
|
+
export declare function findMethodBraceIndex(lines: string[], pattern: RegExp): {
|
|
57
|
+
methodLine: number;
|
|
58
|
+
braceIndex: number;
|
|
59
|
+
} | null;
|
|
60
|
+
/**
|
|
61
|
+
* Starting from `startLine`, walks lines using {@link countBraceDepth}
|
|
62
|
+
* until the brace depth returns to zero (i.e., the enclosing block closes).
|
|
63
|
+
*
|
|
64
|
+
* @returns The line index *after* the closing brace, or `startLine + 1` if
|
|
65
|
+
* the block never closes (defensive).
|
|
66
|
+
*/
|
|
67
|
+
export declare function walkToTryBlockEnd(lines: string[], startLine: number): number;
|
|
68
|
+
/**
|
|
69
|
+
* Looks backward from `fromLine` (exclusive) to find the nearest `try {`
|
|
70
|
+
* line. If nothing is found searching backward, also searches forward.
|
|
71
|
+
*
|
|
72
|
+
* @returns The line index of `try {`, or -1 if not found.
|
|
73
|
+
*/
|
|
74
|
+
export declare function findNearestTryLine(lines: string[], fromLine: number, lowerBound: number): number;
|
|
75
|
+
/**
|
|
76
|
+
* Scans lines starting from `startLine` for consecutive fireforge try-catch
|
|
77
|
+
* blocks (identified by init comments or typeof guards) and returns the
|
|
78
|
+
* line index just after the last such block — i.e., where a new block should
|
|
79
|
+
* be inserted.
|
|
80
|
+
*
|
|
81
|
+
* Non-fireforge, non-blank, non-comment lines terminate the scan.
|
|
82
|
+
*/
|
|
83
|
+
export declare function findInsertionAfterFireforgeBlocks(lines: string[], startLine: number, lowerBound: number): number;
|
|
84
|
+
/**
|
|
85
|
+
* Find the `Property` node for a method name like `onLoad` or `onUnload`
|
|
86
|
+
* inside the AST. Returns the function body's `BlockStatement`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function findMethodBody(ast: AcornESTreeNode<estree.Program>, methodName: string | string[]): AcornESTreeNode<estree.BlockStatement> | null;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { GeneralError } from '../errors/base.js';
|
|
2
|
+
import { walkAST } from './ast-utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates a name for safe interpolation into generated JavaScript string literals.
|
|
5
|
+
* Rejects strings containing characters that could break out of JS strings or inject code.
|
|
6
|
+
*/
|
|
7
|
+
export function validateWireName(value, label) {
|
|
8
|
+
if (!/^[a-zA-Z0-9_$][\w$.-]*(?:\(\))?$/.test(value)) {
|
|
9
|
+
throw new GeneralError(`Invalid ${label} "${value}": must contain only letters, digits, hyphens, underscores, dots, and $ signs`);
|
|
10
|
+
}
|
|
11
|
+
// Reject property chains that could reach dangerous built-in properties
|
|
12
|
+
const segments = value.replace(/\(\)$/, '').split('.');
|
|
13
|
+
const dangerous = new Set(['__proto__', 'constructor', 'prototype']);
|
|
14
|
+
for (const seg of segments) {
|
|
15
|
+
if (dangerous.has(seg)) {
|
|
16
|
+
throw new GeneralError(`Invalid ${label} "${value}": must not contain "${seg}" as a property segment`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Counts net brace depth change in a single line, ignoring braces inside
|
|
22
|
+
* string literals (single, double, template), line comments (`//`), and
|
|
23
|
+
* block comments.
|
|
24
|
+
*
|
|
25
|
+
* Tracks multi-line block comment state across calls via the `inBlockComment`
|
|
26
|
+
* parameter, allowing callers to iterate over lines while preserving context.
|
|
27
|
+
*
|
|
28
|
+
* **Regex literal heuristic:** When a `/` follows an operator or keyword-boundary
|
|
29
|
+
* character (one of `= ( : , ! | & ? ; ~ ^ { [ \n + - * % < >`), it is treated
|
|
30
|
+
* as a regex literal opener and characters are skipped until the closing `/`.
|
|
31
|
+
* This heuristic can misfire on:
|
|
32
|
+
* - Division operators where the left operand is an identifier (`x / y / z`
|
|
33
|
+
* would incorrectly treat ` y ` as regex content).
|
|
34
|
+
* - Tagged template literals or unusual formatting.
|
|
35
|
+
*
|
|
36
|
+
* For Firefox source files this heuristic is sufficient because the AST-based
|
|
37
|
+
* parser (via `withParserFallback`) is tried first; this function is only
|
|
38
|
+
* used in the regex-based fallback path.
|
|
39
|
+
*
|
|
40
|
+
* @param line - A single line of source text
|
|
41
|
+
* @param inBlockComment - Whether the previous line ended inside a block comment
|
|
42
|
+
* @returns The net brace depth change and updated block comment state
|
|
43
|
+
*/
|
|
44
|
+
export function countBraceDepth(line, inBlockComment) {
|
|
45
|
+
let depth = 0;
|
|
46
|
+
let inSingle = false;
|
|
47
|
+
let inDouble = false;
|
|
48
|
+
let inTemplate = false;
|
|
49
|
+
let inLine = false;
|
|
50
|
+
let inBlock = inBlockComment;
|
|
51
|
+
for (let i = 0; i < line.length; i++) {
|
|
52
|
+
const ch = line[i];
|
|
53
|
+
const next = line[i + 1];
|
|
54
|
+
if (inLine)
|
|
55
|
+
continue;
|
|
56
|
+
if (inBlock) {
|
|
57
|
+
if (ch === '*' && next === '/') {
|
|
58
|
+
inBlock = false;
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (ch === '\\' && (inSingle || inDouble || inTemplate)) {
|
|
64
|
+
i++;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (inSingle) {
|
|
68
|
+
if (ch === "'")
|
|
69
|
+
inSingle = false;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (inDouble) {
|
|
73
|
+
if (ch === '"')
|
|
74
|
+
inDouble = false;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (inTemplate) {
|
|
78
|
+
if (ch === '`')
|
|
79
|
+
inTemplate = false;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (ch === '/' && next === '/') {
|
|
83
|
+
inLine = true;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (ch === '/' && next === '*') {
|
|
87
|
+
inBlock = true;
|
|
88
|
+
i++;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
// Heuristic for regex literals: if / follows an operator or keyword boundary,
|
|
92
|
+
// treat it as a regex start and skip to the closing /
|
|
93
|
+
if (ch === '/' && next !== undefined) {
|
|
94
|
+
const prev = i > 0 ? line[i - 1] : undefined;
|
|
95
|
+
if (prev === undefined || /[=(:,!|&?;~^{[\n+\-*%<>]/.test(prev)) {
|
|
96
|
+
// Skip to closing /
|
|
97
|
+
i++;
|
|
98
|
+
while (i < line.length) {
|
|
99
|
+
if (line[i] === '\\') {
|
|
100
|
+
i++; // skip escaped character
|
|
101
|
+
}
|
|
102
|
+
else if (line[i] === '/') {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
i++;
|
|
106
|
+
}
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (ch === "'") {
|
|
111
|
+
inSingle = true;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (ch === '"') {
|
|
115
|
+
inDouble = true;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (ch === '`') {
|
|
119
|
+
inTemplate = true;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (ch === '{')
|
|
123
|
+
depth++;
|
|
124
|
+
if (ch === '}')
|
|
125
|
+
depth--;
|
|
126
|
+
}
|
|
127
|
+
return { depth, inBlockComment: inBlock };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Extracts the class/object name from an expression like "MyComponent.init()".
|
|
131
|
+
*/
|
|
132
|
+
export function extractNameFromExpression(expression) {
|
|
133
|
+
const match = /^(\w+)/.exec(expression);
|
|
134
|
+
return match?.[1] ?? expression;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Tokenize an XHTML file with Mozilla preprocessor `#include` directives
|
|
138
|
+
* into a structured array.
|
|
139
|
+
*/
|
|
140
|
+
export function tokenizeXhtml(lines) {
|
|
141
|
+
return lines.map((raw) => {
|
|
142
|
+
const trimmed = raw.trim();
|
|
143
|
+
if (trimmed === '') {
|
|
144
|
+
return { type: 'empty', raw };
|
|
145
|
+
}
|
|
146
|
+
if (trimmed.startsWith('#include ')) {
|
|
147
|
+
return { type: 'macro', raw };
|
|
148
|
+
}
|
|
149
|
+
return { type: 'xml', raw };
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
// Legacy (line-based) helpers — shared by fallback implementations in
|
|
154
|
+
// wire-targets.ts. Extracted to reduce duplication and make the brace-
|
|
155
|
+
// walking logic independently testable.
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
/**
|
|
158
|
+
* Finds the line index of a method signature matching `pattern`, then
|
|
159
|
+
* advances to the line containing the opening brace.
|
|
160
|
+
*
|
|
161
|
+
* @returns `{ methodLine, braceIndex }`, or `null` if the pattern is not found.
|
|
162
|
+
*/
|
|
163
|
+
export function findMethodBraceIndex(lines, pattern) {
|
|
164
|
+
let methodLine = -1;
|
|
165
|
+
for (let i = 0; i < lines.length; i++) {
|
|
166
|
+
if (pattern.test(lines[i] ?? '')) {
|
|
167
|
+
methodLine = i;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (methodLine === -1)
|
|
172
|
+
return null;
|
|
173
|
+
let braceIndex = methodLine;
|
|
174
|
+
for (let i = methodLine; i < lines.length; i++) {
|
|
175
|
+
if (lines[i]?.includes('{')) {
|
|
176
|
+
braceIndex = i;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return { methodLine, braceIndex };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Starting from `startLine`, walks lines using {@link countBraceDepth}
|
|
184
|
+
* until the brace depth returns to zero (i.e., the enclosing block closes).
|
|
185
|
+
*
|
|
186
|
+
* @returns The line index *after* the closing brace, or `startLine + 1` if
|
|
187
|
+
* the block never closes (defensive).
|
|
188
|
+
*/
|
|
189
|
+
export function walkToTryBlockEnd(lines, startLine) {
|
|
190
|
+
let depth = 0;
|
|
191
|
+
let inBlock = false;
|
|
192
|
+
for (let j = startLine; j < lines.length; j++) {
|
|
193
|
+
const r = countBraceDepth(lines[j] ?? '', inBlock);
|
|
194
|
+
depth += r.depth;
|
|
195
|
+
inBlock = r.inBlockComment;
|
|
196
|
+
if (depth <= 0 && j > startLine) {
|
|
197
|
+
return j + 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return startLine + 1;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Looks backward from `fromLine` (exclusive) to find the nearest `try {`
|
|
204
|
+
* line. If nothing is found searching backward, also searches forward.
|
|
205
|
+
*
|
|
206
|
+
* @returns The line index of `try {`, or -1 if not found.
|
|
207
|
+
*/
|
|
208
|
+
export function findNearestTryLine(lines, fromLine, lowerBound) {
|
|
209
|
+
// Backward search
|
|
210
|
+
for (let k = fromLine; k > lowerBound; k--) {
|
|
211
|
+
if (/\btry\s*\{/.test(lines[k] ?? ''))
|
|
212
|
+
return k;
|
|
213
|
+
}
|
|
214
|
+
// Forward search
|
|
215
|
+
for (let k = fromLine; k < lines.length; k++) {
|
|
216
|
+
if (/\btry\s*\{/.test(lines[k] ?? ''))
|
|
217
|
+
return k;
|
|
218
|
+
}
|
|
219
|
+
return -1;
|
|
220
|
+
}
|
|
221
|
+
/** Patterns that identify a fireforge init/destroy try-catch block. */
|
|
222
|
+
const FIREFORGE_BLOCK_PATTERN = /\/\/\s*.*init\s*—|typeof\s+\w+\s*!==\s*"undefined"/;
|
|
223
|
+
/**
|
|
224
|
+
* Scans lines starting from `startLine` for consecutive fireforge try-catch
|
|
225
|
+
* blocks (identified by init comments or typeof guards) and returns the
|
|
226
|
+
* line index just after the last such block — i.e., where a new block should
|
|
227
|
+
* be inserted.
|
|
228
|
+
*
|
|
229
|
+
* Non-fireforge, non-blank, non-comment lines terminate the scan.
|
|
230
|
+
*/
|
|
231
|
+
export function findInsertionAfterFireforgeBlocks(lines, startLine, lowerBound) {
|
|
232
|
+
let insertIndex = startLine;
|
|
233
|
+
for (let i = startLine; i < lines.length; i++) {
|
|
234
|
+
const line = lines[i] ?? '';
|
|
235
|
+
if (FIREFORGE_BLOCK_PATTERN.test(line)) {
|
|
236
|
+
const tryLine = findNearestTryLine(lines, i, lowerBound);
|
|
237
|
+
if (tryLine !== -1) {
|
|
238
|
+
const end = walkToTryBlockEnd(lines, tryLine);
|
|
239
|
+
insertIndex = end;
|
|
240
|
+
i = end - 1; // continue after this block
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (line.trim() && !line.trim().startsWith('//')) {
|
|
245
|
+
insertIndex = i;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return insertIndex;
|
|
250
|
+
}
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// AST-based helpers
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
/**
|
|
255
|
+
* Find the `Property` node for a method name like `onLoad` or `onUnload`
|
|
256
|
+
* inside the AST. Returns the function body's `BlockStatement`.
|
|
257
|
+
*/
|
|
258
|
+
export function findMethodBody(ast, methodName) {
|
|
259
|
+
const names = Array.isArray(methodName) ? methodName : [methodName];
|
|
260
|
+
let found = null;
|
|
261
|
+
walkAST(ast, {
|
|
262
|
+
enter(node) {
|
|
263
|
+
if (found)
|
|
264
|
+
return;
|
|
265
|
+
if (node.type === 'Property') {
|
|
266
|
+
const prop = node;
|
|
267
|
+
if (prop.key.type === 'Identifier' &&
|
|
268
|
+
names.includes(prop.key.name) &&
|
|
269
|
+
(prop.value.type === 'FunctionExpression' ||
|
|
270
|
+
prop.value.type === 'ArrowFunctionExpression')) {
|
|
271
|
+
const fn = prop.value;
|
|
272
|
+
found = fn.body;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
return found;
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=wire-utils.js.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ExitCode } from './codes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class for all FireForge errors.
|
|
4
|
+
* Provides structured error information with exit codes and user-friendly messages.
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class FireForgeError extends Error {
|
|
7
|
+
/** Exit code to use when this error causes process termination */
|
|
8
|
+
abstract readonly code: ExitCode;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new FireForgeError.
|
|
11
|
+
* @param message - Technical error message for logging
|
|
12
|
+
* @param cause - The underlying error that caused this error
|
|
13
|
+
*/
|
|
14
|
+
readonly cause?: unknown;
|
|
15
|
+
constructor(message: string, cause?: unknown);
|
|
16
|
+
/**
|
|
17
|
+
* User-friendly error message with context and suggested fixes.
|
|
18
|
+
* Override in subclasses to provide specific guidance.
|
|
19
|
+
*/
|
|
20
|
+
get userMessage(): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* General error for unexpected failures.
|
|
24
|
+
*/
|
|
25
|
+
export declare class GeneralError extends FireForgeError {
|
|
26
|
+
readonly code: 1;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown when a command-line argument is invalid.
|
|
30
|
+
*/
|
|
31
|
+
export declare class InvalidArgumentError extends FireForgeError {
|
|
32
|
+
readonly argument?: string | undefined;
|
|
33
|
+
readonly code: 8;
|
|
34
|
+
constructor(message: string, argument?: string | undefined, cause?: Error);
|
|
35
|
+
get userMessage(): string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when the user cancels an interactive prompt.
|
|
39
|
+
*/
|
|
40
|
+
export declare class CancellationError extends FireForgeError {
|
|
41
|
+
readonly code: 1;
|
|
42
|
+
constructor();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when patch resolution fails.
|
|
46
|
+
*/
|
|
47
|
+
export declare class ResolutionError extends FireForgeError {
|
|
48
|
+
readonly code: 10;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sentinel error used to propagate an exit code to the CLI entrypoint
|
|
52
|
+
* without calling process.exit() from shared library code.
|
|
53
|
+
*
|
|
54
|
+
* The user-visible error message has already been logged by the time this
|
|
55
|
+
* is thrown — the entrypoint only needs to read `.exitCode` and terminate.
|
|
56
|
+
*/
|
|
57
|
+
export declare class CommandError extends Error {
|
|
58
|
+
readonly exitCode: ExitCode;
|
|
59
|
+
constructor(exitCode: ExitCode);
|
|
60
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EUPL-1.2
|
|
2
|
+
import { ExitCode } from './codes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Base error class for all FireForge errors.
|
|
5
|
+
* Provides structured error information with exit codes and user-friendly messages.
|
|
6
|
+
*/
|
|
7
|
+
export class FireForgeError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new FireForgeError.
|
|
10
|
+
* @param message - Technical error message for logging
|
|
11
|
+
* @param cause - The underlying error that caused this error
|
|
12
|
+
*/
|
|
13
|
+
cause;
|
|
14
|
+
constructor(message, cause) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = this.constructor.name;
|
|
17
|
+
if (cause !== undefined) {
|
|
18
|
+
this.cause = cause;
|
|
19
|
+
}
|
|
20
|
+
// Maintains proper stack trace in V8 environments
|
|
21
|
+
if (typeof Error.captureStackTrace === 'function') {
|
|
22
|
+
Error.captureStackTrace(this, this.constructor);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* User-friendly error message with context and suggested fixes.
|
|
27
|
+
* Override in subclasses to provide specific guidance.
|
|
28
|
+
*/
|
|
29
|
+
get userMessage() {
|
|
30
|
+
return this.message;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* General error for unexpected failures.
|
|
35
|
+
*/
|
|
36
|
+
export class GeneralError extends FireForgeError {
|
|
37
|
+
code = ExitCode.GENERAL_ERROR;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Error thrown when a command-line argument is invalid.
|
|
41
|
+
*/
|
|
42
|
+
export class InvalidArgumentError extends FireForgeError {
|
|
43
|
+
argument;
|
|
44
|
+
code = ExitCode.INVALID_ARGUMENT;
|
|
45
|
+
constructor(message, argument, cause) {
|
|
46
|
+
super(message, cause);
|
|
47
|
+
this.argument = argument;
|
|
48
|
+
}
|
|
49
|
+
get userMessage() {
|
|
50
|
+
let msg = `Invalid Argument: ${this.message}`;
|
|
51
|
+
if (this.argument) {
|
|
52
|
+
msg += `\n\nArgument: ${this.argument}`;
|
|
53
|
+
}
|
|
54
|
+
return msg;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Error thrown when the user cancels an interactive prompt.
|
|
59
|
+
*/
|
|
60
|
+
export class CancellationError extends FireForgeError {
|
|
61
|
+
code = ExitCode.GENERAL_ERROR;
|
|
62
|
+
constructor() {
|
|
63
|
+
super('cancelled');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error thrown when patch resolution fails.
|
|
68
|
+
*/
|
|
69
|
+
export class ResolutionError extends FireForgeError {
|
|
70
|
+
code = ExitCode.RESOLUTION_ERROR;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Sentinel error used to propagate an exit code to the CLI entrypoint
|
|
74
|
+
* without calling process.exit() from shared library code.
|
|
75
|
+
*
|
|
76
|
+
* The user-visible error message has already been logged by the time this
|
|
77
|
+
* is thrown — the entrypoint only needs to read `.exitCode` and terminate.
|
|
78
|
+
*/
|
|
79
|
+
export class CommandError extends Error {
|
|
80
|
+
exitCode;
|
|
81
|
+
constructor(exitCode) {
|
|
82
|
+
super(`Command failed with exit code ${exitCode}`);
|
|
83
|
+
this.exitCode = exitCode;
|
|
84
|
+
this.name = 'CommandError';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FireForgeError } from './base.js';
|
|
2
|
+
import { ExitCode } from './codes.js';
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when a build operation fails.
|
|
5
|
+
*/
|
|
6
|
+
export declare class BuildError extends FireForgeError {
|
|
7
|
+
readonly command?: string | undefined;
|
|
8
|
+
readonly code: ExitCode;
|
|
9
|
+
constructor(message: string, command?: string | undefined, cause?: Error);
|
|
10
|
+
get userMessage(): string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown when mach is not available.
|
|
14
|
+
*/
|
|
15
|
+
export declare class MachNotFoundError extends BuildError {
|
|
16
|
+
readonly engineDir: string;
|
|
17
|
+
readonly code: 7;
|
|
18
|
+
constructor(engineDir: string);
|
|
19
|
+
get userMessage(): string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown when python is not available.
|
|
23
|
+
*/
|
|
24
|
+
export declare class PythonNotFoundError extends BuildError {
|
|
25
|
+
readonly minVersion: string;
|
|
26
|
+
readonly maxVersion: string;
|
|
27
|
+
readonly code: 7;
|
|
28
|
+
constructor(minVersion?: string, maxVersion?: string);
|
|
29
|
+
get userMessage(): string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Error thrown when bootstrap fails.
|
|
33
|
+
*/
|
|
34
|
+
export declare class BootstrapError extends BuildError {
|
|
35
|
+
constructor(cause?: Error);
|
|
36
|
+
get userMessage(): string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Error thrown when mozconfig generation fails.
|
|
40
|
+
*/
|
|
41
|
+
export declare class MozconfigError extends BuildError {
|
|
42
|
+
get userMessage(): string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when multiple build output directories exist and FireForge cannot
|
|
46
|
+
* safely choose one.
|
|
47
|
+
*/
|
|
48
|
+
export declare class AmbiguousBuildArtifactsError extends BuildError {
|
|
49
|
+
readonly objDirs: string[];
|
|
50
|
+
constructor(objDirs: string[]);
|
|
51
|
+
get userMessage(): string;
|
|
52
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EUPL-1.2
|
|
2
|
+
import { FireForgeError } from './base.js';
|
|
3
|
+
import { ExitCode } from './codes.js';
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a build operation fails.
|
|
6
|
+
*/
|
|
7
|
+
export class BuildError extends FireForgeError {
|
|
8
|
+
command;
|
|
9
|
+
code = ExitCode.BUILD_ERROR;
|
|
10
|
+
constructor(message, command, cause) {
|
|
11
|
+
super(message, cause);
|
|
12
|
+
this.command = command;
|
|
13
|
+
}
|
|
14
|
+
get userMessage() {
|
|
15
|
+
let msg = `Build Error: ${this.message}`;
|
|
16
|
+
if (this.command) {
|
|
17
|
+
msg += `\n\nCommand: ${this.command}`;
|
|
18
|
+
}
|
|
19
|
+
msg += '\n\nTo fix this:\n';
|
|
20
|
+
msg += ' 1. Check the build output above for specific errors\n';
|
|
21
|
+
msg += ' 2. Ensure all dependencies are installed with "fireforge bootstrap"\n';
|
|
22
|
+
msg += ' 3. Try a clean build by deleting obj-* directories';
|
|
23
|
+
return msg;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when mach is not available.
|
|
28
|
+
*/
|
|
29
|
+
export class MachNotFoundError extends BuildError {
|
|
30
|
+
engineDir;
|
|
31
|
+
code = ExitCode.MISSING_DEPENDENCY;
|
|
32
|
+
constructor(engineDir) {
|
|
33
|
+
super(`mach not found in ${engineDir}`);
|
|
34
|
+
this.engineDir = engineDir;
|
|
35
|
+
}
|
|
36
|
+
get userMessage() {
|
|
37
|
+
return ('Build Error: Firefox build system (mach) not found.\n\n' +
|
|
38
|
+
`Expected location: ${this.engineDir}/mach\n\n` +
|
|
39
|
+
'To fix this:\n' +
|
|
40
|
+
' 1. Run "fireforge download" to download Firefox source\n' +
|
|
41
|
+
' 2. Ensure the engine/ directory contains the Firefox source');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when python is not available.
|
|
46
|
+
*/
|
|
47
|
+
export class PythonNotFoundError extends BuildError {
|
|
48
|
+
minVersion;
|
|
49
|
+
maxVersion;
|
|
50
|
+
code = ExitCode.MISSING_DEPENDENCY;
|
|
51
|
+
constructor(minVersion = '3.8', maxVersion = '3.12') {
|
|
52
|
+
super(`FireForge could not find a Python interpreter supported by Firefox mach (${minVersion}-${maxVersion}).`);
|
|
53
|
+
this.minVersion = minVersion;
|
|
54
|
+
this.maxVersion = maxVersion;
|
|
55
|
+
}
|
|
56
|
+
get userMessage() {
|
|
57
|
+
return (`Build Error: Python ${this.minVersion}-${this.maxVersion} is required but not found.\n\n` +
|
|
58
|
+
'Firefox mach declares the supported Python range in engine/mach, and FireForge could not find any interpreter in that range.\n\n' +
|
|
59
|
+
'To fix this:\n' +
|
|
60
|
+
` 1. Install a supported Python version (${this.minVersion}-${this.maxVersion}) from https://python.org/\n` +
|
|
61
|
+
' 2. Ensure that interpreter is in your PATH (for example as python3.12 or python3)\n' +
|
|
62
|
+
' 3. Re-run "fireforge doctor" to confirm FireForge can see it');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Error thrown when bootstrap fails.
|
|
67
|
+
*/
|
|
68
|
+
export class BootstrapError extends BuildError {
|
|
69
|
+
constructor(cause) {
|
|
70
|
+
super('Bootstrap failed', 'python3 mach bootstrap', cause);
|
|
71
|
+
}
|
|
72
|
+
get userMessage() {
|
|
73
|
+
return ('Build Error: Bootstrap failed.\n\n' +
|
|
74
|
+
'The Firefox build dependencies could not be installed. This often happens if the Python interpreter selected for mach is missing or misconfigured.\n\n' +
|
|
75
|
+
'To fix this:\n' +
|
|
76
|
+
' 1. Check the error output above\n' +
|
|
77
|
+
' 2. Ensure you have sufficient permissions\n' +
|
|
78
|
+
' 3. Try running bootstrap manually:\n' +
|
|
79
|
+
' cd engine && python3 mach bootstrap');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Error thrown when mozconfig generation fails.
|
|
84
|
+
*/
|
|
85
|
+
export class MozconfigError extends BuildError {
|
|
86
|
+
get userMessage() {
|
|
87
|
+
return (`Build Error: ${this.message}\n\n` +
|
|
88
|
+
'To fix this:\n' +
|
|
89
|
+
' 1. Check that configs/ directory exists\n' +
|
|
90
|
+
' 2. Ensure platform-specific mozconfig exists\n' +
|
|
91
|
+
' 3. Run "fireforge setup" to regenerate configs');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Error thrown when multiple build output directories exist and FireForge cannot
|
|
96
|
+
* safely choose one.
|
|
97
|
+
*/
|
|
98
|
+
export class AmbiguousBuildArtifactsError extends BuildError {
|
|
99
|
+
objDirs;
|
|
100
|
+
constructor(objDirs) {
|
|
101
|
+
super(`Multiple build artifact directories found: ${objDirs.join(', ')}`);
|
|
102
|
+
this.objDirs = objDirs;
|
|
103
|
+
}
|
|
104
|
+
get userMessage() {
|
|
105
|
+
return ('Build Error: Multiple build artifact directories were found.\n\n' +
|
|
106
|
+
`Candidates: ${this.objDirs.join(', ')}\n\n` +
|
|
107
|
+
'FireForge will not guess which build output to use.\n\n' +
|
|
108
|
+
'To fix this:\n' +
|
|
109
|
+
' 1. Remove stale obj-* directories you no longer need\n' +
|
|
110
|
+
' 2. Keep only the active build output directory\n' +
|
|
111
|
+
' 3. Run the command again');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=build.js.map
|