Commit 3fdfd68
committed
Replaces the script work of two prior PRs that independently solved
"add an existing scratchfoundation repo to the monorepo":
scripts/add-repo.sh — collapses add-to-monorepo.sh (#434) and add-repo.sh
(#505) into a single canonical entry point. Takes the CLI shape and
auto-CI-regen from #505 and the source-branch auto-detect (develop ->
main -> master), normalization (sort-package-json), and clean-tree
pre-flight from #434.
scripts/update-gha-workflows.ts — replaces the CircleCI-era
build-gha-workflows.ts and workspace-template.yml. Regenerates
.github/path-filters.yml and incrementally updates publish.yml.
Open review comments on #505 are addressed:
- sed -i portability bug: rewrites now use perl -pi -e (works on macOS,
NixOS, Ubuntu/Debian/Arch, WSL). Perl is added to the explicit prereq
check next to git-filter-repo, sponge, and jq.
- Arg parser now rejects flag-stealing: --source-branch --org foo errors
instead of silently using --org as the branch name.
- npm-install failures hard-fail by default. --continue-on-error opts
into the prior soft-fail behavior; failures are still logged to
add-repo.errors.log when continuing. Scoped to per-dep package.json
rewrite failures in the rewire step; the final lockfile install
always hard-fails by design.
- The submodules-aware branch in move_repository_subdirectory keeps a
TODO comment marking that it has never been exercised against a real
submodules-bearing repo and should be run carefully when one lands.
Cross-workspace dep handling: rewires both bare-name and already-prefixed
@scratch/<name> deps in the new package to exact-pinned current monorepo
versions. Matches the existing convention in scratch-gui/scratch-vm/
scratch-render. npm's workspace: protocol would be the ideal here but
npm does not actually support it (npm/cli#8845 - EUNSUPPORTEDPROTOCOL
at install time).
Workspaces array ordering: the new package is inserted just after the
latest existing workspace it depends on, so 'npm run --workspaces build'
builds its deps first. Falls back to position 0 (prepend) when the new
package has no monorepo deps. This is a "last dep wins" heuristic, not
a full topological sort; it relies on the existing workspaces array
already being in valid build order. A real topo sort can be added later
(e.g. by extending update-gha-workflows.ts) if it ever becomes necessary.
bash 3.2 compatibility: macOS ships bash 3.2 at /bin/bash, which lacks
the 'mapfile' builtin. The find/grep output is collected via a 'while
IFS= read -r' loop so the script runs on macOS as well as Linux.
Bare-clone alternates path: bare clones store the alternates file at
objects/info/alternates, not .git/objects/info/alternates. The previous
path was a no-op; the working disconnection comes from --dissociate in
the clone command. Path corrected so the line is defensive belt-and-
braces rather than dead code.
update-gha-workflows.ts: throws with a clear error if npm query returns
a workspace not present in the root "workspaces" array (previously
would silently misorder via indexOf returning -1). The comment in
resolveWorkspaces is corrected to reflect that the function returns
Map insertion order, with the caller re-sorting into declared order.
The npm query exec call now requests a 64 MiB maxBuffer; Node's
default 1 MiB is fine for the current repo size but would silently
truncate as the monorepo grows.
Path anchoring: BUILD_TMP, BUILD_CACHE, and any user-supplied
--cache-dir value are resolved to absolute paths up front. A
CWD-relative default would have put add-repo.tmp outside the repo
(and outside the .gitignore pattern) if the script were run from a
subdirectory of the monorepo.
No repo additions are included; this PR is script-tooling only.
1 parent 8a32020 commit 3fdfd68
7 files changed
Lines changed: 816 additions & 774 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
| 29 | + | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
| |||
0 commit comments