@hominis/fireforge 0.37.0 → 0.38.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 +13 -0
- package/README.md +1 -1
- package/dist/src/commands/build.js +5 -5
- package/dist/src/commands/config.js +1 -0
- package/dist/src/commands/download.js +5 -2
- package/dist/src/commands/export-flow.d.ts +5 -1
- package/dist/src/commands/export-flow.js +10 -7
- package/dist/src/commands/export-placement-gate.js +3 -5
- package/dist/src/commands/export-placement-policy.d.ts +11 -3
- package/dist/src/commands/export-placement-policy.js +32 -29
- package/dist/src/commands/export.js +5 -5
- package/dist/src/commands/furnace/index.js +23 -18
- package/dist/src/commands/patch/move-files-create.d.ts +19 -0
- package/dist/src/commands/patch/move-files-create.js +116 -0
- package/dist/src/commands/patch/move-files.d.ts +3 -1
- package/dist/src/commands/patch/move-files.js +49 -4
- package/dist/src/commands/patch/split.d.ts +11 -1
- package/dist/src/commands/patch/split.js +6 -5
- package/dist/src/commands/re-export-scan.d.ts +17 -0
- package/dist/src/commands/re-export-scan.js +51 -0
- package/dist/src/commands/re-export.js +17 -6
- package/dist/src/commands/source.js +28 -3
- package/dist/src/commands/test-register.js +6 -5
- package/dist/src/commands/test-stale-gate.d.ts +44 -0
- package/dist/src/commands/test-stale-gate.js +81 -0
- package/dist/src/commands/test.js +15 -50
- package/dist/src/core/build-audit.d.ts +12 -0
- package/dist/src/core/build-audit.js +14 -0
- package/dist/src/core/build-baseline-types.d.ts +34 -0
- package/dist/src/core/build-baseline.d.ts +6 -1
- package/dist/src/core/build-baseline.js +47 -7
- package/dist/src/core/config-paths.d.ts +1 -1
- package/dist/src/core/config-paths.js +1 -0
- package/dist/src/core/config-validate.js +6 -1
- package/dist/src/core/engine-session-lock.d.ts +10 -1
- package/dist/src/core/engine-session-lock.js +28 -2
- package/dist/src/core/file-lock.d.ts +33 -0
- package/dist/src/core/file-lock.js +32 -6
- package/dist/src/core/firefox-archive.d.ts +2 -1
- package/dist/src/core/firefox-archive.js +32 -8
- package/dist/src/core/firefox.d.ts +8 -3
- package/dist/src/core/firefox.js +11 -6
- package/dist/src/core/furnace-validate-helpers.js +28 -1
- package/dist/src/core/license-headers.d.ts +12 -0
- package/dist/src/core/license-headers.js +76 -1
- package/dist/src/core/patch-lint.d.ts +3 -0
- package/dist/src/core/patch-lint.js +25 -7
- package/dist/src/core/status-classify.d.ts +11 -2
- package/dist/src/core/status-classify.js +49 -25
- package/dist/src/core/test-stale-check.d.ts +41 -1
- package/dist/src/core/test-stale-check.js +77 -3
- package/dist/src/types/commands/options.d.ts +57 -3
- package/dist/src/types/config.d.ts +7 -0
- package/dist/src/utils/options.d.ts +20 -0
- package/dist/src/utils/options.js +39 -0
- package/dist/src/utils/validation.d.ts +5 -0
- package/dist/src/utils/validation.js +7 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.38.0
|
|
4
|
+
|
|
5
|
+
- **`status --ownership` reports a furnace-deployed file whose owning patch body went stale as drift** (friction-log item 1, bug — after `furnace deploy` refreshed 12 deployed widget copies, the pre-export "consult ownership" step read clean while the composed gate caught the staleness later on the re-export path): the classifier no longer short-circuits every furnace-prefixed path into the `furnace` bucket — a furnace path claimed by exactly ONE patch now runs the same expected-content comparison as any patch-owned file (`computePatchedContent` vs the deployed copy, deletion and error branches included), classifying as `patch-owned-drift` on divergence and staying `furnace` on a match. Multi-owner and unowned furnace paths keep the old bucket (cross-patch conflicts are already surfaced independently), so the only behavioral change is that stale widget patches now show as drift in the table and in `--json` (machine consumers see those paths move from `"furnace"` to `"patch-owned-drift"`). An integration test pins the exact observed sequence: deploy, export the patch, edit the component source, deploy again, and `status --ownership` reports the owning patch drifted.
|
|
6
|
+
- **Scoped `test --build` and build-less runs refuse a `components.conf` changed since the last FULL build** (friction-log item 2, bug — a new about: module packaged fine under a scoped `test --build` but the child process resolved `NS_ERROR_MALFORMED_URI`, because `components.conf` entries bake into the compiled StaticComponents table that only a full build regenerates; the failure was silent and read as a test bug): the baseline gains `staticComponentsBaseline` (`engineHeadSha` + per-manifest content fingerprints), written fresh only by full-coverage builds and carried forward verbatim through scoped `test --build` writes — so the guard always anchors to the last full build, not the last scoped one. Any scoped `test --build` or non-`--build` run over a changed `components.conf` is refused up front with a message naming the manifest(s), explaining the compiled-table mechanism and the misleading error shape, and advising `fireforge build`; `--allow-stale-build` deliberately does NOT bypass it (it accepts stale packaged content, not a stale compiled registration), while the new `--allow-stale-components` downgrades the refusal to a warning for out-of-band rebuilds. Detection keys on the `components.conf` basename (`isXpcomManifestPath` is the single documented extension point; parsing `moz.build` `XPCOM_MANIFESTS` wiring is out of scope), pre-0.38.0 baselines lack the anchor and degrade to fresh, and probe failures never block a run.
|
|
7
|
+
- **Per-patch size lint agrees with `wc -l` and fires only ABOVE the soft limit** (friction-log item 3, lint bug — three independent recurrences: a file counted one line more than `wc -l` from patch-hunk trailing-newline accounting, and `file-too-large` fired at "750 lines (soft limit: 750)" while a wc-1499 patch reported 1500/1500, each costing 1–2 trim/re-export/lint cycles): line counting now drops the phantom element a trailing newline adds (`countContentLines` for on-disk content, the same correction inside `countNonBinaryDiffLines` for patch bodies, with binary-hunk subtraction kept consistent), and every tier of `file-too-large` and `large-patch-lines` compares strictly (`>`), matching the already-strict `large-patch-files`, so a file or patch sitting exactly AT a notice/soft/hard limit is clean. Boundary tests pin limit−1 / limit / limit+1 for both rules across the general, test, and branding tiers, plus the trailing-newline agreement cases.
|
|
8
|
+
- **Patch-lint accepts both established upstream MPL header wraps** (friction-log item 4, lint — derived files keeping the genuine upstream header of files like `ext-browser.js`, which wrap after "file," instead of the canonical break after "this", were flagged `missing EUPL-1.2 license header`): the upstream-MPL acceptance in `hasAnyLicenseHeader`/`hasUpstreamMplBlockHeader` keeps its exact-prefix fast path and adds a whitespace-normalized fallback — the leading comment span (line-comment run, first block comment, or hash run; anything else never matches) is collapsed to single spaces and must still begin with the full canonical MPL sentence including the URL — so any line-break position within the verbatim text passes while altered wording still fails. Both wraps are tested on JS and CSS comment styles, with and without leading editor directives.
|
|
9
|
+
- **The packaged-test coverage guard accepts same-manifest siblings instead of demanding the exact recorded path set** (friction-log item 5, test inefficiency — a run scoped to `…/hominis-webext/file_A.js` refused `file_B.js` of the SAME manifest, forcing a ~1–2 min repackage per alternation): coverage is now matched at manifest granularity — mozbuild manifests are per-directory and mach stages support-files per manifest, so a request whose manifest granule (a file's containing directory; a directory itself) equals a covered entry's granule is accepted, as are subset paths of a covered directory; genuinely uncovered manifests keep the existing refusal verbatim, and the recorded baseline format is unchanged so 0.37.0 and 0.38.0 baselines interoperate both ways. The entry's second suggestion — unioning covered sets across successive scoped builds to stop concurrent-session ping-pong — was evaluated and rejected as UNSOUND: every baseline write refreshes content fingerprints for ALL dirty packageable paths, so a union would whitewash an earlier scope's edited fixtures while `obj-*/_tests/` still holds that scope's stale staging — precisely the silent-hang class the guard exists to refuse. The verdict is recorded on `testPackagingCoverage`'s doc contract; coverage REPLACES.
|
|
10
|
+
- **Positional inserts refuse with ONE actionable error when they would renumber a reserved range, `patch move-files --create --order <n>` bootstraps a split in one step, and `re-export --scan` refuses forward-import adoptions** (friction-log item 6, patch-tooling ergonomics, three parts): (a) `patch split --before` / positional `export` on a dense queue that would shift patches through a `patchPolicy.reservedRanges` block no longer sprays per-patch reserved-range findings — the placement plan is gated up front (`assertPlacementAvoidsReservedRanges`, subsuming the old inside-range check) with a single error naming the range and computing the remedy: `pass --order <first free number below the reserved block>`, or explicit guidance when no free order exists. (b) `patch move-files` gains `--create --order <n>`: creating the target patch and moving the files is one transaction through the split pipeline (same placement gate, projected cross-patch lint, and staged-dependency owner repointing the manual shrink-then-export dance needed by hand), while the flag-less preview behavior is unchanged. (c) `re-export --scan`/`--scan-file`/`--scan-files` run the forward-import check per adoption candidate BEFORE adopting: a candidate importing a module created by a LATER patch is refused with the later patch and closest legal ordinal named, advising `export --order` / `patch split --order` / `patch staged-dependency --add`; declared staged dependencies and lint-ignores are honored because the gate runs the real cross-patch rule on a projected queue.
|
|
11
|
+
- **Engine-mutating commands can wait for the engine lock instead of failing fast** (friction-log item 7, missing-feature — two sessions on one engine tree had operators hand-rolling `for i in $(seq 1 60); do CMD; sleep 25; done` around "Another FireForge engine-mutating command is already running"): `test`, `build`, `export`, `re-export`, and the engine-locked furnace subcommands gain `--wait-lock [seconds]` (bare flag = 60, validated 1–3600), which polls the lock with exponential backoff (100 ms doubling to a 2 s cap) up to the bound, printing a progress line about every 5 s identifying the holder from the lock's owner metadata (`Waiting for the FireForge engine lock held by PID … (command=…, started=…) — 10s of up to 60s.`), then proceeds when the lock frees or fails with the unchanged standard message. Without the flag, behavior is byte-identical to the 1 s fail-fast; the lock-ownership invariants and their doc (`docs/lifecycle-invariants.md`) are updated to cover the bounded wait.
|
|
12
|
+
- **`furnace validate` credits the implicit wrapping `<label>` association** (friction-log item 8, false positive — `[unlabelled-form-input]` fired on the accessible `<label><input type="radio">…</label>` pattern although the control has an accessible name per the HTML spec): an input/select/textarea nested inside a `<label>` whose content includes real text (tags stripped; a `${…}` binding deliberately counts as text since it is legitimate dynamic label content) is now treated as labelled; a bare input, or one wrapped in an empty or tags-only `<label>`, still warns, and the explicit `for`/`aria-label`/`aria-labelledby` paths are unchanged.
|
|
13
|
+
- **`furnace create --shared-ftl <path>` was already shipped; its validation is now pinned by tests** (friction-log item 9, missing-feature — verified already implemented on current main: the flag sets `sharedFtl` in furnace.json, skips the component-local FTL scaffold, emits the `insertFTLIfNeeded` line for the given path verbatim, and rejects the contradictory `--no-localized` combination): 0.38.0 adds the previously missing direct unit tests for `validateSharedFtl` (trimming, empty/non-string rejection, unsafe-character rejection, localized requirement) and a command-level test pinning the exact CLI rejection wording.
|
|
14
|
+
- **`source set --candidate <buildN>` fetches release-candidate archives** (friction-log item 10, missing-feature — `resolveArchive` hardcoded `pub/firefox/releases/`, so a `candidates/<version>-candidates/buildN/` source, the normal shape for pre-release verification, forced hand-seeding `.fireforge/cache/` with an independently verified tarball + sidecar): `firefox.candidate` (validated `buildN`, also settable via `fireforge config firefox.candidate` and cleared with `--clear-candidate`) switches resolution to `pub/<product>/candidates/<version>-candidates/<buildN>/source/…` with the matching `SHA256SUMS` alongside the build directory; devedition and ESR fall out of the existing product/version handling, cache filenames gain a `-<buildN>` suffix so candidate artifacts never collide with release artifacts, and the sha256-pin trust model is unchanged (an explicit `firefox.sha256` pin still fails closed and takes precedence over the published checksums). Recording the candidate in exported patches' source provenance was considered and deferred — it cascades into `PatchMetadata` schema/validation churn across the manifest round-trip surface.
|
|
15
|
+
|
|
3
16
|
## 0.37.0
|
|
4
17
|
|
|
5
18
|
- **`fireforge test --build` now records the stale-build baseline** (friction-log item 1, inefficiency — "stale-build guard re-arms across invocation shapes"): a green pre-test build refreshes `.fireforge/last-build.json` through the same `writeBuildBaseline` path as `fireforge build`/`build --ui`, so after one `test --build` over a set of edited files, a subsequent plain `fireforge test` over the same files — per-file, per-directory, or full suite — passes the gate without a second redundant `--build` round trip. The baseline is content-fingerprint-based and project-scoped, which is also per-obj-dir (multi-objdir checkouts are already refused up front), so no per-invocation-shape keying is needed; both directions (file-scoped rebuild → full-suite run, and full/directory rebuild → file run) are covered by tests.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](LICENSE.md)
|
|
5
5
|
[](package.json)
|
|
6
6
|
|
|
7
|
-
FireForge is a CLI tool for maintaining Firefox-based browser forks. It downloads Firefoxs source code, lets you export changes as patches, helps apply them and has some neat/mad code quality enforcement, built by taking a lot of learnings from the existing Firefox source code and trying to make the process as robust as can be. Ideally, FireForge makes everything from managing custom UI components to enforcing some rudimentary typechecking much easier, but I'll be honest, there is only so much one can do, so understanding upstream is advised, especially once future updates come into the mix. I cannot guarantee how reliably these will apply, but I did try to assist in that process as much as I can by learning from prior Firefox versions which had major changes made to them, though this is of course still no guarantee for future success or that the methods will remain reliable. Beware of that.
|
|
7
|
+
FireForge is a CLI tool for maintaining Firefox-based browser forks. It downloads Firefoxs source code, lets you export changes as patches, helps apply them and has some neat/mad code quality enforcement, built by taking a lot of learnings from the existing Firefox source code and trying to make the process as robust as can be. Ideally, FireForge makes everything from managing custom UI components to enforcing some rudimentary typechecking much easier, but I'll be honest, there is only so much one can do, so understanding upstream is advised, especially once future updates come into the mix. ~~I cannot guarantee how reliably these will apply, but I did try to assist in that process as much as I can by learning from prior Firefox versions which had major changes made to them, though this is of course still no guarantee for future success or that the methods will remain reliable. Beware of that.~~ Edit 16.07.2026: I have now upgraded and downgraded and sidegraded, really all the graded, across all the versions in many scenarios with modifications so far removed from upstream that I think it's fair to say upgrading is fairly reliable.
|
|
8
8
|
|
|
9
9
|
Inspired by [fern.js](https://github.com/ghostery/user-agent-desktop) and [Melon](https://github.com/dothq/melon).
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ import { AmbiguousBuildArtifactsError, BuildError } from '../errors/build.js';
|
|
|
14
14
|
import { toError } from '../utils/errors.js';
|
|
15
15
|
import { checkDiskSpace, pathExists } from '../utils/fs.js';
|
|
16
16
|
import { error, info, intro, outro, spinner, verbose, warn } from '../utils/logger.js';
|
|
17
|
-
import { pickDefined } from '../utils/options.js';
|
|
17
|
+
import { addWaitLockOption, pickDefined, resolveWaitLockSeconds } from '../utils/options.js';
|
|
18
18
|
import { isPositiveInteger } from '../utils/validation.js';
|
|
19
19
|
function parseJobCount(value) {
|
|
20
20
|
const parsed = Number(value);
|
|
@@ -336,7 +336,7 @@ export async function buildCommand(projectRoot, options) {
|
|
|
336
336
|
}
|
|
337
337
|
/** Registers the build command on the CLI program. */
|
|
338
338
|
export function registerBuild(program, { getProjectRoot, withErrorHandling }) {
|
|
339
|
-
program
|
|
339
|
+
const build = program
|
|
340
340
|
.command('build')
|
|
341
341
|
.description('Build the browser (auto-applies Furnace components first)')
|
|
342
342
|
.option('--ui', 'Fast UI-only rebuild')
|
|
@@ -360,9 +360,9 @@ export function registerBuild(program, { getProjectRoot, withErrorHandling }) {
|
|
|
360
360
|
'and runs mach configure — preserving up to ~20 GB of obj-* artefacts on',
|
|
361
361
|
'a relocation. The rewriter refuses any change that is not a pure prefix',
|
|
362
362
|
'move, in which case a clean rebuild is still required.',
|
|
363
|
-
].join('\n'))
|
|
364
|
-
|
|
363
|
+
].join('\n'));
|
|
364
|
+
addWaitLockOption(build).action(withErrorHandling(async (options) => {
|
|
365
365
|
const projectRoot = getProjectRoot();
|
|
366
|
-
await withEngineSessionLock(projectRoot, 'build', () => buildCommand(projectRoot, pickDefined(options)));
|
|
366
|
+
await withEngineSessionLock(projectRoot, 'build', () => buildCommand(projectRoot, pickDefined(options)), { waitLockSeconds: resolveWaitLockSeconds(options.waitLock) });
|
|
367
367
|
}));
|
|
368
368
|
}
|
|
@@ -160,7 +160,7 @@ async function restorePreviousEngine(args) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
async function downloadAndExtractFirefox(args) {
|
|
163
|
-
const { version, product, engineDir, cacheDir, sha256 } = args;
|
|
163
|
+
const { version, product, engineDir, cacheDir, sha256, candidate } = args;
|
|
164
164
|
let s = spinner(`Downloading Firefox ${version}...`);
|
|
165
165
|
let lastPercent = 0;
|
|
166
166
|
const phaseState = { value: 'download' };
|
|
@@ -181,7 +181,7 @@ async function downloadAndExtractFirefox(args) {
|
|
|
181
181
|
}
|
|
182
182
|
}, sha256, (message) => {
|
|
183
183
|
s.message(message);
|
|
184
|
-
});
|
|
184
|
+
}, candidate);
|
|
185
185
|
s.stop(phaseState.value === 'extract'
|
|
186
186
|
? `Firefox ${version} extracted`
|
|
187
187
|
: `Firefox ${version} downloaded`);
|
|
@@ -402,6 +402,9 @@ export async function downloadCommand(projectRoot, options) {
|
|
|
402
402
|
engineDir: installEngineDir,
|
|
403
403
|
cacheDir,
|
|
404
404
|
...(config.firefox.sha256 !== undefined ? { sha256: config.firefox.sha256 } : {}),
|
|
405
|
+
...(config.firefox.candidate !== undefined
|
|
406
|
+
? { candidate: config.firefox.candidate }
|
|
407
|
+
: {}),
|
|
405
408
|
});
|
|
406
409
|
if (replacementEngineDir && backupEngineDir) {
|
|
407
410
|
warn('Activating replacement engine directory...');
|
|
@@ -39,8 +39,12 @@ export declare function computePlacementPlan(manifestPatches: PatchMetadata[], n
|
|
|
39
39
|
export declare function computeExactPlacementPlan(manifestPatches: PatchMetadata[], newPatchCategory: PatchCategory, newPatchName: string, requestedOrder: number): PlacementPlan;
|
|
40
40
|
/**
|
|
41
41
|
* Resolves a placement plan from CLI flags against the current manifest.
|
|
42
|
+
* When `config` is provided, positional plans (`--before`/`--after`) are
|
|
43
|
+
* refused up front if their renumber would touch a reserved range — one
|
|
44
|
+
* error for the whole shift instead of per-patch policy findings. The
|
|
45
|
+
* exact `--order` branch never renames, so it bypasses that gate.
|
|
42
46
|
*/
|
|
43
|
-
export declare function resolvePlacementPlan(patchesDir: string, options: ExportOptions, category: PatchCategory, name: string): Promise<PlacementPlan>;
|
|
47
|
+
export declare function resolvePlacementPlan(patchesDir: string, options: ExportOptions, category: PatchCategory, name: string, config?: FireForgeConfig): Promise<PlacementPlan>;
|
|
44
48
|
/**
|
|
45
49
|
* Projects the placement through cross-patch lint to detect forward-imports
|
|
46
50
|
* the renumber would introduce *or* that the new patch itself would
|
|
@@ -20,7 +20,7 @@ import { GeneralError, InvalidArgumentError } from '../errors/base.js';
|
|
|
20
20
|
import { toError } from '../utils/errors.js';
|
|
21
21
|
import { pathExists, readText, removeFile, writeText } from '../utils/fs.js';
|
|
22
22
|
import { info, warn } from '../utils/logger.js';
|
|
23
|
-
import {
|
|
23
|
+
import { assertPlacementAvoidsReservedRanges } from './export-placement-policy.js';
|
|
24
24
|
import { findPartialOwnershipOverlap } from './export-shared.js';
|
|
25
25
|
function buildFilenameForPlacement(category, name, order, width) {
|
|
26
26
|
const padded = String(order).padStart(Math.max(3, width), '0');
|
|
@@ -113,8 +113,12 @@ export function computeExactPlacementPlan(manifestPatches, newPatchCategory, new
|
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Resolves a placement plan from CLI flags against the current manifest.
|
|
116
|
+
* When `config` is provided, positional plans (`--before`/`--after`) are
|
|
117
|
+
* refused up front if their renumber would touch a reserved range — one
|
|
118
|
+
* error for the whole shift instead of per-patch policy findings. The
|
|
119
|
+
* exact `--order` branch never renames, so it bypasses that gate.
|
|
116
120
|
*/
|
|
117
|
-
export async function resolvePlacementPlan(patchesDir, options, category, name) {
|
|
121
|
+
export async function resolvePlacementPlan(patchesDir, options, category, name, config) {
|
|
118
122
|
// ForWrite: placement planning feeds a manifest rewrite; a corrupt
|
|
119
123
|
// manifest read as empty would allocate colliding orders.
|
|
120
124
|
const manifest = await loadPatchesManifestForWrite(patchesDir);
|
|
@@ -147,7 +151,9 @@ export async function resolvePlacementPlan(patchesDir, options, category, name)
|
|
|
147
151
|
}
|
|
148
152
|
targetOrder = anchor.order + 1;
|
|
149
153
|
}
|
|
150
|
-
|
|
154
|
+
const plan = computePlacementPlan(existingPatches, category, name, targetOrder);
|
|
155
|
+
assertPlacementAvoidsReservedRanges(plan, existingPatches, config);
|
|
156
|
+
return plan;
|
|
151
157
|
}
|
|
152
158
|
/**
|
|
153
159
|
* Extracts the newly-created files a diff would produce and builds the
|
|
@@ -225,7 +231,7 @@ export function placementSummary(plan) {
|
|
|
225
231
|
*/
|
|
226
232
|
export async function commitPlacementExport(input) {
|
|
227
233
|
return withPatchDirectoryLock(input.patchesDir, async () => {
|
|
228
|
-
const currentPlan = await resolvePlacementPlan(input.patchesDir, input.options, input.category, input.name);
|
|
234
|
+
const currentPlan = await resolvePlacementPlan(input.patchesDir, input.options, input.category, input.name, input.config);
|
|
229
235
|
if (!placementPlansEqual(currentPlan, input.expectedPlan)) {
|
|
230
236
|
throw new InvalidArgumentError('Patch queue changed while waiting for export confirmation. Re-run the command to recompute placement.', 'export placement');
|
|
231
237
|
}
|
|
@@ -237,9 +243,6 @@ export async function commitPlacementExport(input) {
|
|
|
237
243
|
'do NOT bypass with --force-unsafe. Pass --force-unsafe only for a reviewed placement conflict.', '--force-unsafe');
|
|
238
244
|
}
|
|
239
245
|
const originalManifest = await loadPatchesManifestForWrite(input.patchesDir);
|
|
240
|
-
if (originalManifest !== null) {
|
|
241
|
-
assertPlacementPreservesReservedRanges(currentPlan, originalManifest.patches, input.config, input.category);
|
|
242
|
-
}
|
|
243
246
|
if (input.config !== undefined) {
|
|
244
247
|
const renamed = originalManifest !== null
|
|
245
248
|
? applyRenameMapToManifest(originalManifest, currentPlan.renameMap)
|
|
@@ -12,7 +12,6 @@ import { buildPatchSourceMetadata } from '../core/patch-source-metadata.js';
|
|
|
12
12
|
import { InvalidArgumentError } from '../errors/base.js';
|
|
13
13
|
import { outro } from '../utils/logger.js';
|
|
14
14
|
import { placementSummary, projectPlacementForLint, resolvePlacementPlan, } from './export-flow.js';
|
|
15
|
-
import { assertPlacementPreservesReservedRanges } from './export-placement-policy.js';
|
|
16
15
|
/**
|
|
17
16
|
* Spreadable optional metadata (`tier`, `lintIgnore`) derived from the
|
|
18
17
|
* export flags. Every manifest-row construction site in this command
|
|
@@ -41,11 +40,10 @@ export async function gatePlacementPlan(args) {
|
|
|
41
40
|
if (options.supersede) {
|
|
42
41
|
throw new InvalidArgumentError('Placement flags (--order/--before/--after) cannot be combined with --supersede.', 'export placement');
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
// resolvePlacementPlan runs the reserved-range gate itself when config
|
|
44
|
+
// is passed — one up-front error per run instead of per-patch findings.
|
|
45
|
+
const placementPlan = await resolvePlacementPlan(patchesDir, options, selectedCategory, patchName, config);
|
|
45
46
|
const currentManifest = await loadPatchesManifest(patchesDir);
|
|
46
|
-
if (currentManifest !== null) {
|
|
47
|
-
assertPlacementPreservesReservedRanges(placementPlan, currentManifest.patches, config, selectedCategory);
|
|
48
|
-
}
|
|
49
47
|
const conflicts = await projectPlacementForLint(patchesDir, placementPlan, diff);
|
|
50
48
|
const renamed = currentManifest !== null
|
|
51
49
|
? applyRenameMapToManifest(currentManifest, placementPlan.renameMap)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Policy-aware checks for export placement plans.
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
4
|
+
import type { PatchMetadata } from '../types/commands/index.js';
|
|
5
5
|
import type { FireForgeConfig } from '../types/config.js';
|
|
6
6
|
export interface PlacementPolicyPlan {
|
|
7
7
|
insertionOrder: number;
|
|
@@ -10,5 +10,13 @@ export interface PlacementPolicyPlan {
|
|
|
10
10
|
newOrder: number;
|
|
11
11
|
}>;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Refuses positional placement plans whose renumber would touch a
|
|
15
|
+
* `patchPolicy.reservedRanges` block — either by moving a patch INTO a
|
|
16
|
+
* reserved range or by moving a patch that currently sits inside one.
|
|
17
|
+
* Throws a single up-front error for the first reserved range hit (the
|
|
18
|
+
* per-patch alternative surfaced one confusing finding per shifted
|
|
19
|
+
* patch), suggesting the first free `--order` below the block when one
|
|
20
|
+
* exists. Exact `--order` plans have an empty rename map and pass.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertPlacementAvoidsReservedRanges(plan: PlacementPolicyPlan, manifestPatches: readonly PatchMetadata[], config: FireForgeConfig | undefined): void;
|
|
@@ -10,44 +10,47 @@ function findReservedRange(config, order) {
|
|
|
10
10
|
return (config.patchPolicy?.reservedRanges?.find((range) => order >= range.from && order <= range.to) ??
|
|
11
11
|
null);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Scans downward from just below the reserved block for the first order
|
|
15
|
+
* not occupied by an existing patch. Returns null when every positive
|
|
16
|
+
* order below the block is taken.
|
|
17
|
+
*/
|
|
18
|
+
function firstFreeOrderBelowReservedRange(patches, range) {
|
|
17
19
|
const occupied = new Set(patches.map((patch) => patch.order));
|
|
18
|
-
for (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return order;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
for (const range of ranges) {
|
|
25
|
-
for (let order = range.from; order <= range.to; order++) {
|
|
26
|
-
if (!occupied.has(order) && findReservedRange(config, order) === null)
|
|
27
|
-
return order;
|
|
28
|
-
}
|
|
20
|
+
for (let order = range.from - 1; order >= 1; order--) {
|
|
21
|
+
if (!occupied.has(order))
|
|
22
|
+
return order;
|
|
29
23
|
}
|
|
30
24
|
return null;
|
|
31
25
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Refuses positional placement plans whose renumber would touch a
|
|
28
|
+
* `patchPolicy.reservedRanges` block — either by moving a patch INTO a
|
|
29
|
+
* reserved range or by moving a patch that currently sits inside one.
|
|
30
|
+
* Throws a single up-front error for the first reserved range hit (the
|
|
31
|
+
* per-patch alternative surfaced one confusing finding per shifted
|
|
32
|
+
* patch), suggesting the first free `--order` below the block when one
|
|
33
|
+
* exists. Exact `--order` plans have an empty rename map and pass.
|
|
34
|
+
*/
|
|
35
|
+
export function assertPlacementAvoidsReservedRanges(plan, manifestPatches, config) {
|
|
34
36
|
if (config?.patchPolicy === undefined || plan.renameMap.size === 0)
|
|
35
37
|
return;
|
|
36
38
|
const byFilename = new Map(manifestPatches.map((patch) => [patch.filename, patch]));
|
|
37
39
|
for (const [filename, rename] of plan.renameMap) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const reserved = findReservedRange(config, patch.order);
|
|
40
|
+
const oldOrder = byFilename.get(filename)?.order;
|
|
41
|
+
const reserved = findReservedRange(config, rename.newOrder) ??
|
|
42
|
+
(oldOrder !== undefined ? findReservedRange(config, oldOrder) : null);
|
|
42
43
|
if (reserved === null)
|
|
43
44
|
continue;
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
const label = reservedRangeLabel(reserved);
|
|
46
|
+
const freeOrder = firstFreeOrderBelowReservedRange(manifestPatches, reserved);
|
|
47
|
+
if (freeOrder !== null) {
|
|
48
|
+
throw new InvalidArgumentError(`Positional insert would renumber the reserved range ${label}; ` +
|
|
49
|
+
`pass --order ${String(freeOrder).padStart(3, '0')} (first free order below the ` +
|
|
50
|
+
'reserved block) to place the new patch without renumbering reserved patches.', 'export placement');
|
|
51
|
+
}
|
|
52
|
+
throw new InvalidArgumentError(`Positional insert would renumber the reserved range ${label}; ` +
|
|
53
|
+
'no free order exists below the reserved block. Choose an unused --order outside ' +
|
|
54
|
+
'the reserved range or adjust patchPolicy.reservedRanges.', 'export placement');
|
|
52
55
|
}
|
|
53
56
|
}
|
|
@@ -20,7 +20,7 @@ import { GeneralError, InvalidArgumentError } from '../errors/base.js';
|
|
|
20
20
|
import { toError } from '../utils/errors.js';
|
|
21
21
|
import { ensureDir, pathExists } from '../utils/fs.js';
|
|
22
22
|
import { info, intro, outro, spinner, verbose, warn } from '../utils/logger.js';
|
|
23
|
-
import { commanderArgParser, pickDefined } from '../utils/options.js';
|
|
23
|
+
import { addWaitLockOption, commanderArgParser, pickDefined, resolveWaitLockSeconds, } from '../utils/options.js';
|
|
24
24
|
import { stripEnginePrefix } from '../utils/paths.js';
|
|
25
25
|
import { parsePositiveIntegerFlag } from '../utils/validation.js';
|
|
26
26
|
import { commitPlacementExport, renderDryRunPreview } from './export-flow.js';
|
|
@@ -400,7 +400,7 @@ export async function exportCommand(projectRoot, files, options) {
|
|
|
400
400
|
}
|
|
401
401
|
/** Registers the export command on the CLI program. */
|
|
402
402
|
export function registerExport(program, { getProjectRoot, withErrorHandling }) {
|
|
403
|
-
program
|
|
403
|
+
const exportCmd = program
|
|
404
404
|
.command('export <paths...>')
|
|
405
405
|
.description('Export new changes as a patch (use re-export to update existing patches)')
|
|
406
406
|
.option('-n, --name <name>', 'Name for the patch')
|
|
@@ -418,8 +418,8 @@ export function registerExport(program, { getProjectRoot, withErrorHandling }) {
|
|
|
418
418
|
.option('--allow-stale-furnace', 'Export the deployed engine copy even when the components/ source changed since the last furnace apply')
|
|
419
419
|
.option('--allow-overlap', 'Acknowledge cross-patch ownership overlap (default mode only; the resulting queue fails verify)')
|
|
420
420
|
.addOption(new Option('--tier <tier>', 'Force a tier override on the new patch (only "branding" recognised)').choices(['branding']))
|
|
421
|
-
.option('--lint-ignore <check-id>', 'Suppress a lint check on this patch (writes to PatchMetadata.lintIgnore; repeatable)', (value, prev) => [...prev, value], [])
|
|
422
|
-
|
|
421
|
+
.option('--lint-ignore <check-id>', 'Suppress a lint check on this patch (writes to PatchMetadata.lintIgnore; repeatable)', (value, prev) => [...prev, value], []);
|
|
422
|
+
addWaitLockOption(exportCmd).action(withErrorHandling(async (paths, options) => {
|
|
423
423
|
const { category, tier, lintIgnore, ...rest } = options;
|
|
424
424
|
const projectRoot = getProjectRoot();
|
|
425
425
|
await withEngineSessionLock(projectRoot, 'export', () => exportCommand(projectRoot, paths, {
|
|
@@ -427,6 +427,6 @@ export function registerExport(program, { getProjectRoot, withErrorHandling }) {
|
|
|
427
427
|
...(category !== undefined ? { category } : {}),
|
|
428
428
|
...(tier !== undefined ? { tier: tier } : {}),
|
|
429
429
|
...(lintIgnore !== undefined && lintIgnore.length > 0 ? { lintIgnore } : {}),
|
|
430
|
-
}));
|
|
430
|
+
}), { waitLockSeconds: resolveWaitLockSeconds(options.waitLock) });
|
|
431
431
|
}));
|
|
432
432
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EUPL-1.2
|
|
2
2
|
import { Command, Option } from 'commander';
|
|
3
3
|
import { withEngineSessionLock } from '../../core/engine-session-lock.js';
|
|
4
|
-
import { pickDefined } from '../../utils/options.js';
|
|
4
|
+
import { addWaitLockOption, pickDefined, resolveWaitLockSeconds } from '../../utils/options.js';
|
|
5
5
|
import { furnaceApplyCommand } from './apply.js';
|
|
6
6
|
import { furnaceChromeDocCreateCommand } from './chrome-doc.js';
|
|
7
7
|
import { furnaceChromeDocRemoveCommand } from './chrome-doc-remove.js';
|
|
@@ -19,61 +19,66 @@ import { furnaceScanCommand } from './scan.js';
|
|
|
19
19
|
import { furnaceStatusCommand } from './status.js';
|
|
20
20
|
import { furnaceSyncCommand } from './sync.js';
|
|
21
21
|
import { furnaceValidateCommand } from './validate.js';
|
|
22
|
-
async function runEngineLockedFurnaceCommand(context, command, operation) {
|
|
22
|
+
async function runEngineLockedFurnaceCommand(context, command, operation, waitLockSeconds) {
|
|
23
23
|
const projectRoot = context.getProjectRoot();
|
|
24
|
-
await withEngineSessionLock(projectRoot, command, () => operation(projectRoot)
|
|
24
|
+
await withEngineSessionLock(projectRoot, command, () => operation(projectRoot), {
|
|
25
|
+
waitLockSeconds,
|
|
26
|
+
});
|
|
25
27
|
}
|
|
26
28
|
function registerFurnaceApplyCommand(furnace, context) {
|
|
27
29
|
const { getProjectRoot, withErrorHandling } = context;
|
|
28
|
-
furnace
|
|
30
|
+
const apply = furnace
|
|
29
31
|
.command('apply [name]')
|
|
30
32
|
.description('Apply components to the engine (optionally a single component)')
|
|
31
33
|
.option('--dry-run', 'Show what would be changed without writing (reads may overlap concurrent mutations)')
|
|
32
34
|
.option('--force', 'Proceed despite baseVersion drift (stale overrides)')
|
|
33
|
-
.option('-w, --watch', 'Watch component directories and re-apply on changes')
|
|
34
|
-
|
|
35
|
-
const
|
|
35
|
+
.option('-w, --watch', 'Watch component directories and re-apply on changes');
|
|
36
|
+
addWaitLockOption(apply).action(withErrorHandling(async (name, options) => {
|
|
37
|
+
const { waitLock, ...rest } = options ?? {};
|
|
38
|
+
const parsed = pickDefined(rest);
|
|
36
39
|
const run = (projectRoot) => furnaceApplyCommand(projectRoot, name, parsed);
|
|
37
40
|
if (parsed.dryRun === true) {
|
|
38
41
|
await run(getProjectRoot());
|
|
39
42
|
return;
|
|
40
43
|
}
|
|
41
|
-
await runEngineLockedFurnaceCommand(context, 'furnace apply', run);
|
|
44
|
+
await runEngineLockedFurnaceCommand(context, 'furnace apply', run, resolveWaitLockSeconds(waitLock));
|
|
42
45
|
}));
|
|
43
46
|
}
|
|
44
47
|
function registerFurnaceDeployCommand(furnace, context) {
|
|
45
48
|
const { getProjectRoot, withErrorHandling } = context;
|
|
46
|
-
furnace
|
|
49
|
+
const deploy = furnace
|
|
47
50
|
.command('deploy [name]')
|
|
48
51
|
.description('Apply components and validate in one step')
|
|
49
52
|
.option('--dry-run', 'Show what would be changed without writing (reads may overlap concurrent mutations)')
|
|
50
53
|
.option('--force', 'Proceed despite baseVersion drift (stale overrides)')
|
|
51
|
-
.option('--skip-validate', 'Skip the validation step (apply only)')
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
+
.option('--skip-validate', 'Skip the validation step (apply only)');
|
|
55
|
+
addWaitLockOption(deploy).action(withErrorHandling(async (name, options) => {
|
|
56
|
+
const { waitLock, ...rest } = options ?? {};
|
|
57
|
+
const parsed = pickDefined(rest);
|
|
54
58
|
const run = (projectRoot) => furnaceDeployCommand(projectRoot, name, parsed);
|
|
55
59
|
if (parsed.dryRun === true) {
|
|
56
60
|
await run(getProjectRoot());
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
59
|
-
await runEngineLockedFurnaceCommand(context, 'furnace deploy', run);
|
|
63
|
+
await runEngineLockedFurnaceCommand(context, 'furnace deploy', run, resolveWaitLockSeconds(waitLock));
|
|
60
64
|
}));
|
|
61
65
|
}
|
|
62
66
|
function registerFurnaceSyncCommand(furnace, context) {
|
|
63
67
|
const { getProjectRoot, withErrorHandling } = context;
|
|
64
|
-
furnace
|
|
68
|
+
const sync = furnace
|
|
65
69
|
.command('sync')
|
|
66
70
|
.description('Refresh drifted overrides and re-apply all components (recommended after fireforge download)')
|
|
67
71
|
.option('--dry-run', 'Show what would change without modifying files (reads may overlap concurrent mutations)')
|
|
68
|
-
.addOption(new Option('-s, --strategy <strategy>', 'Auto-resolve merge conflicts (ours = keep local, theirs = accept upstream)').choices(['ours', 'theirs']))
|
|
69
|
-
|
|
70
|
-
const
|
|
72
|
+
.addOption(new Option('-s, --strategy <strategy>', 'Auto-resolve merge conflicts (ours = keep local, theirs = accept upstream)').choices(['ours', 'theirs']));
|
|
73
|
+
addWaitLockOption(sync).action(withErrorHandling(async (options) => {
|
|
74
|
+
const { waitLock, ...rest } = options;
|
|
75
|
+
const parsed = pickDefined(rest);
|
|
71
76
|
const run = (projectRoot) => furnaceSyncCommand(projectRoot, parsed);
|
|
72
77
|
if (parsed.dryRun === true) {
|
|
73
78
|
await run(getProjectRoot());
|
|
74
79
|
return;
|
|
75
80
|
}
|
|
76
|
-
await runEngineLockedFurnaceCommand(context, 'furnace sync', run);
|
|
81
|
+
await runEngineLockedFurnaceCommand(context, 'furnace sync', run, resolveWaitLockSeconds(waitLock));
|
|
77
82
|
}));
|
|
78
83
|
}
|
|
79
84
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fireforge patch move-files <from> <to> --create --order <n>` — creates
|
|
3
|
+
* the target patch at the requested sparse order and moves the files into
|
|
4
|
+
* it as one transaction. This is the transactional bootstrap of a split:
|
|
5
|
+
* without it, moving files into a not-yet-existing patch required a manual
|
|
6
|
+
* shrink-then-export dance with hand-repointed staged-dependency owners.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors `patch split` end-to-end (same planning, projection lint,
|
|
9
|
+
* policy enforcement, and locked commit); the `<to>` argument becomes the
|
|
10
|
+
* new patch's name/slug the way `split --name` does.
|
|
11
|
+
*/
|
|
12
|
+
import type { PatchMoveFilesOptions } from '../../types/commands/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* Runs `patch move-files --create --order <n>`: plans the create+move as a
|
|
15
|
+
* split, lints the projection, confirms, and commits transactionally.
|
|
16
|
+
*/
|
|
17
|
+
export declare function patchMoveFilesCreateCommand(projectRoot: string, fromIdentifier: string, newPatchName: string, options: PatchMoveFilesOptions & {
|
|
18
|
+
order: number;
|
|
19
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EUPL-1.2
|
|
2
|
+
/**
|
|
3
|
+
* `fireforge patch move-files <from> <to> --create --order <n>` — creates
|
|
4
|
+
* the target patch at the requested sparse order and moves the files into
|
|
5
|
+
* it as one transaction. This is the transactional bootstrap of a split:
|
|
6
|
+
* without it, moving files into a not-yet-existing patch required a manual
|
|
7
|
+
* shrink-then-export dance with hand-repointed staged-dependency owners.
|
|
8
|
+
*
|
|
9
|
+
* Mirrors `patch split` end-to-end (same planning, projection lint,
|
|
10
|
+
* policy enforcement, and locked commit); the `<to>` argument becomes the
|
|
11
|
+
* new patch's name/slug the way `split --name` does.
|
|
12
|
+
*/
|
|
13
|
+
import { getProjectPaths, loadConfig } from '../../core/config.js';
|
|
14
|
+
import { confirmDestructive } from '../../core/destructive.js';
|
|
15
|
+
import { formatPatchNotFoundError } from '../../core/patch-identifier-suggest.js';
|
|
16
|
+
import { loadPatchesManifest, resolvePatchIdentifier } from '../../core/patch-manifest.js';
|
|
17
|
+
import { enforcePatchPolicy } from '../../core/patch-policy.js';
|
|
18
|
+
import { GeneralError, InvalidArgumentError } from '../../errors/base.js';
|
|
19
|
+
import { info, intro, outro, success } from '../../utils/logger.js';
|
|
20
|
+
import { resolvePlacementPlan } from '../export-flow.js';
|
|
21
|
+
import { runPatchLint } from '../export-shared.js';
|
|
22
|
+
import { commitPatchSplit } from './split.js';
|
|
23
|
+
import { assertSourceOwnsFiles, buildNewPatchMetadata, buildSplitDiff, buildSplitSummary, findOwnerRewriteHolders, projectSplitManifest, runProjectedSplitLint, } from './split-plan.js';
|
|
24
|
+
/**
|
|
25
|
+
* Runs `patch move-files --create --order <n>`: plans the create+move as a
|
|
26
|
+
* split, lints the projection, confirms, and commits transactionally.
|
|
27
|
+
*/
|
|
28
|
+
export async function patchMoveFilesCreateCommand(projectRoot, fromIdentifier, newPatchName, options) {
|
|
29
|
+
intro(options.dryRun === true
|
|
30
|
+
? 'FireForge patch move-files --create (dry run)'
|
|
31
|
+
: 'FireForge patch move-files --create');
|
|
32
|
+
const paths = getProjectPaths(projectRoot);
|
|
33
|
+
const config = await loadConfig(projectRoot);
|
|
34
|
+
const manifest = await loadPatchesManifest(paths.patches);
|
|
35
|
+
if (!manifest || manifest.patches.length === 0) {
|
|
36
|
+
throw new GeneralError('No patches in manifest.');
|
|
37
|
+
}
|
|
38
|
+
const source = resolvePatchIdentifier(fromIdentifier, manifest.patches);
|
|
39
|
+
if (!source) {
|
|
40
|
+
throw new InvalidArgumentError(formatPatchNotFoundError(fromIdentifier, manifest.patches), 'patch move-files');
|
|
41
|
+
}
|
|
42
|
+
const existingTarget = resolvePatchIdentifier(newPatchName, manifest.patches);
|
|
43
|
+
if (existingTarget) {
|
|
44
|
+
throw new InvalidArgumentError(`--create target "${newPatchName}" already exists as ${existingTarget.filename}. ` +
|
|
45
|
+
'Omit --create to preview a move into the existing patch, or pick a new patch name.', '--create');
|
|
46
|
+
}
|
|
47
|
+
const movedFiles = [...new Set((options.file ?? []).map((f) => f.trim()).filter(Boolean))].sort();
|
|
48
|
+
if (movedFiles.length === 0) {
|
|
49
|
+
throw new InvalidArgumentError('Specify at least one --file path to move.', '--file');
|
|
50
|
+
}
|
|
51
|
+
assertSourceOwnsFiles(source, movedFiles);
|
|
52
|
+
const movedSet = new Set(movedFiles);
|
|
53
|
+
const remainingFiles = source.filesAffected.filter((f) => !movedSet.has(f));
|
|
54
|
+
if (remainingFiles.length === 0) {
|
|
55
|
+
throw new InvalidArgumentError(`Moving every file out of ${source.filename} would leave it empty. ` +
|
|
56
|
+
'Use "fireforge patch rename" / "fireforge patch reorder" to repurpose or move the whole patch instead.', '--file');
|
|
57
|
+
}
|
|
58
|
+
const movedDiff = await buildSplitDiff(paths.engine, movedFiles, 'moved', source.filename);
|
|
59
|
+
const remainingDiff = await buildSplitDiff(paths.engine, remainingFiles, 'remaining', source.filename);
|
|
60
|
+
const category = options.category ?? source.category;
|
|
61
|
+
const placementOptions = { order: options.order };
|
|
62
|
+
const placement = await resolvePlacementPlan(paths.patches, placementOptions, category, newPatchName, config);
|
|
63
|
+
const plan = {
|
|
64
|
+
source,
|
|
65
|
+
movedFiles,
|
|
66
|
+
remainingFiles,
|
|
67
|
+
movedDiff,
|
|
68
|
+
remainingDiff,
|
|
69
|
+
placement,
|
|
70
|
+
placementOptions,
|
|
71
|
+
category,
|
|
72
|
+
name: newPatchName,
|
|
73
|
+
description: options.description ?? '',
|
|
74
|
+
ownerRewrites: findOwnerRewriteHolders(manifest.patches, source.filename, movedSet),
|
|
75
|
+
// Populated by runProjectedSplitLint below (forward edges into the new patch).
|
|
76
|
+
stagedDependencyAdditions: new Map(),
|
|
77
|
+
};
|
|
78
|
+
// Per-patch lint both projected bodies, threading the source patch's
|
|
79
|
+
// tier/lintIgnore so an intentional-advisory patch can still move files.
|
|
80
|
+
const ignoreChecks = source.lintIgnore ? new Set(source.lintIgnore) : undefined;
|
|
81
|
+
await runPatchLint(paths.engine, remainingFiles, remainingDiff, config, options.skipLint, undefined, ignoreChecks, source.tier);
|
|
82
|
+
await runPatchLint(paths.engine, movedFiles, movedDiff, config, options.skipLint, undefined, ignoreChecks, source.tier);
|
|
83
|
+
const { conflicts, stagedDependencyAdditions } = await runProjectedSplitLint(paths.patches, plan);
|
|
84
|
+
plan.stagedDependencyAdditions = stagedDependencyAdditions;
|
|
85
|
+
const newMetadata = buildNewPatchMetadata(plan, config);
|
|
86
|
+
enforcePatchPolicy({
|
|
87
|
+
config,
|
|
88
|
+
manifest: projectSplitManifest(manifest, plan, newMetadata),
|
|
89
|
+
command: 'patch move-files --create',
|
|
90
|
+
forceUnsafe: options.forceUnsafe === true,
|
|
91
|
+
});
|
|
92
|
+
const decision = await confirmDestructive({
|
|
93
|
+
operation: 'patch-move-files-create',
|
|
94
|
+
title: `Create ${placement.newFilename} (order ${placement.insertionOrder}) and move ${movedFiles.length} file(s) out of ${source.filename}`,
|
|
95
|
+
summary: buildSplitSummary(plan),
|
|
96
|
+
yes: options.yes === true,
|
|
97
|
+
dryRun: options.dryRun === true,
|
|
98
|
+
unsafeOverride: options.forceUnsafe === true,
|
|
99
|
+
conflicts,
|
|
100
|
+
});
|
|
101
|
+
if (decision === 'dry-run') {
|
|
102
|
+
outro('Dry run complete — no changes made');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (decision === 'cancelled') {
|
|
106
|
+
outro('Move cancelled');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
await commitPatchSplit(paths.patches, plan, newMetadata, options, config);
|
|
110
|
+
success(`Created ${placement.newFilename} (order ${String(placement.insertionOrder).padStart(3, '0')}) ` +
|
|
111
|
+
`and moved ${plan.movedFiles.length} file(s) out of ${source.filename}`);
|
|
112
|
+
if (plan.ownerRewrites.length > 0) {
|
|
113
|
+
info(`Re-pointed staged-dependency owners in: ${plan.ownerRewrites.join(', ')}`);
|
|
114
|
+
}
|
|
115
|
+
outro('Move complete');
|
|
116
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `fireforge patch move-files <from> <to>` previews the explicit
|
|
3
|
-
* re-export choreography needed to move file ownership between two
|
|
3
|
+
* re-export choreography needed to move file ownership between two
|
|
4
|
+
* patches. With `--create --order <n>` the target patch is created and
|
|
5
|
+
* the files move into it as one transaction (see move-files-create.ts).
|
|
4
6
|
*/
|
|
5
7
|
import { Command } from 'commander';
|
|
6
8
|
import type { CommandContext } from '../../types/cli.js';
|