@smoothbricks/nx-plugin 0.4.15 → 0.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/README.md +17 -0
  2. package/dist/deploy-policy.d.ts +26 -0
  3. package/dist/deploy-policy.d.ts.map +1 -0
  4. package/dist/deploy-policy.js +36 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +153 -14
  7. package/dist/managed-assets.d.ts +3 -0
  8. package/dist/managed-assets.d.ts.map +1 -0
  9. package/dist/managed-assets.js +3 -0
  10. package/dist/managed-files/ci-workflow.d.ts +215 -0
  11. package/dist/managed-files/ci-workflow.d.ts.map +1 -0
  12. package/dist/managed-files/ci-workflow.js +1082 -0
  13. package/dist/managed-files/context.d.ts +51 -0
  14. package/dist/managed-files/context.d.ts.map +1 -0
  15. package/dist/managed-files/context.js +206 -0
  16. package/dist/managed-files/files.d.ts +53 -0
  17. package/dist/managed-files/files.d.ts.map +1 -0
  18. package/dist/managed-files/files.js +248 -0
  19. package/dist/managed-files/generator.d.ts +16 -0
  20. package/dist/managed-files/generator.d.ts.map +1 -0
  21. package/dist/managed-files/generator.js +41 -0
  22. package/dist/managed-files/github-runs-on.d.ts +19 -0
  23. package/dist/managed-files/github-runs-on.d.ts.map +1 -0
  24. package/dist/managed-files/github-runs-on.js +48 -0
  25. package/dist/managed-files/managed-content.d.ts +45 -0
  26. package/dist/managed-files/managed-content.d.ts.map +1 -0
  27. package/dist/managed-files/managed-content.js +102 -0
  28. package/dist/managed-files/managed-format.d.ts +37 -0
  29. package/dist/managed-files/managed-format.d.ts.map +1 -0
  30. package/dist/managed-files/managed-format.js +94 -0
  31. package/dist/managed-files/paths.d.ts +8 -0
  32. package/dist/managed-files/paths.d.ts.map +1 -0
  33. package/dist/managed-files/paths.js +46 -0
  34. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts +5 -0
  35. package/dist/managed-files/pr-preview-cleanup-workflow.d.ts.map +1 -0
  36. package/dist/managed-files/pr-preview-cleanup-workflow.js +38 -0
  37. package/dist/managed-files/private-npm-policy.d.ts +7 -0
  38. package/dist/managed-files/private-npm-policy.d.ts.map +1 -0
  39. package/dist/managed-files/private-npm-policy.js +51 -0
  40. package/dist/managed-files/publish-workflow.d.ts +150 -0
  41. package/dist/managed-files/publish-workflow.d.ts.map +1 -0
  42. package/dist/managed-files/publish-workflow.js +989 -0
  43. package/dist/managed-files/tree.d.ts +30 -0
  44. package/dist/managed-files/tree.d.ts.map +1 -0
  45. package/dist/managed-files/tree.js +91 -0
  46. package/dist/platform-targets.d.ts +5 -0
  47. package/dist/platform-targets.d.ts.map +1 -0
  48. package/dist/platform-targets.js +4 -0
  49. package/dist/typecheck-test-policy.d.ts +5 -9
  50. package/dist/typecheck-test-policy.d.ts.map +1 -1
  51. package/dist/typecheck-test-policy.js +69 -99
  52. package/dist/workspace-config-policy.d.ts +2 -3
  53. package/dist/workspace-config-policy.d.ts.map +1 -1
  54. package/dist/workspace-config-policy.js +8 -3
  55. package/dist/workspace-manifest.d.ts +291 -0
  56. package/dist/workspace-manifest.d.ts.map +1 -0
  57. package/dist/workspace-manifest.js +6 -0
  58. package/dist/workspace-package-policy.d.ts +13 -0
  59. package/dist/workspace-package-policy.d.ts.map +1 -0
  60. package/dist/workspace-package-policy.js +24 -0
  61. package/generators.json +5 -0
  62. package/managed/raw/envrc +20 -0
  63. package/managed/raw/git-format-staged.yml +82 -0
  64. package/managed/raw/gitattributes +8 -0
  65. package/managed/raw/tooling/devenv +83 -0
  66. package/managed/raw/tooling/direnv/devenv.smoo.nix +422 -0
  67. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +251 -0
  68. package/managed/raw/tooling/direnv/merge-newer-pins.sh +48 -0
  69. package/managed/raw/tooling/direnv/repo-path +34 -0
  70. package/managed/raw/tooling/direnv/secret-references.ts +636 -0
  71. package/managed/raw/tooling/direnv/setup-environment.ts +585 -0
  72. package/managed/raw/tooling/direnv/toolchain-stamp.ts +88 -0
  73. package/managed/raw/tooling/git-hooks/commit-msg.sh +9 -0
  74. package/managed/raw/tooling/git-hooks/post-commit.sh +71 -0
  75. package/managed/raw/tooling/git-hooks/pre-commit.sh +18 -0
  76. package/managed/raw/tooling/git-hooks/pre-push.sh +48 -0
  77. package/managed/raw/tsconfig.lib.json +28 -0
  78. package/managed/templates/github/actions/cache-nix-devenv/action.yml +45 -0
  79. package/managed/templates/github/actions/cache-node-modules/action.yml +17 -0
  80. package/managed/templates/github/actions/cache-nx/action.yml +21 -0
  81. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
  82. package/managed/templates/github/actions/save-nix-devenv/action.yml +32 -0
  83. package/managed/templates/github/actions/setup-devenv/action.yml +241 -0
  84. package/managed/templates/github/workflows/managed-files.yml +127 -0
  85. package/package.json +89 -5
  86. package/src/bun-bootstrap.test.ts +0 -6
  87. package/src/deploy-policy.ts +40 -0
  88. package/src/index.test.ts +225 -2
  89. package/src/index.ts +180 -14
  90. package/src/managed-assets.ts +4 -0
  91. package/src/managed-files/ci-workflow.ts +1365 -0
  92. package/src/managed-files/context.ts +240 -0
  93. package/src/managed-files/files.ts +324 -0
  94. package/src/managed-files/generator.test.ts +151 -0
  95. package/src/managed-files/generator.ts +60 -0
  96. package/src/managed-files/github-runs-on.ts +51 -0
  97. package/src/managed-files/managed-content.test.ts +147 -0
  98. package/src/managed-files/managed-content.ts +121 -0
  99. package/src/managed-files/managed-format.ts +102 -0
  100. package/src/managed-files/paths.ts +44 -0
  101. package/src/managed-files/pr-preview-cleanup-workflow.ts +44 -0
  102. package/src/managed-files/private-npm-policy.ts +62 -0
  103. package/src/managed-files/publish-workflow.ts +1523 -0
  104. package/src/managed-files/schema.json +8 -0
  105. package/src/managed-files/tree-permissions.test.ts +109 -0
  106. package/src/managed-files/tree.test.ts +123 -0
  107. package/src/managed-files/tree.ts +118 -0
  108. package/src/platform-targets.ts +4 -0
  109. package/src/typecheck-test-policy.test.ts +28 -3
  110. package/src/typecheck-test-policy.ts +46 -121
  111. package/src/workspace-config-policy.test.ts +14 -2
  112. package/src/workspace-config-policy.ts +9 -3
  113. package/src/workspace-manifest.ts +327 -0
  114. package/src/workspace-package-policy.ts +32 -0
@@ -0,0 +1,251 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Resolve from this script's location, not the caller's cwd. GitHub Actions
5
+ # runs this from tooling/direnv today, but direct cwd-changing helpers are easy
6
+ # to misuse and break on repeated calls.
7
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ repo_root="$(cd "$script_dir/../.." && pwd)"
9
+ # Host CI supplies its bind-mounted cache through the runner profile. Ephemeral
10
+ # runners must use the same repository path restored by cache-ttsc-plugins.
11
+ # A separate name on purpose: assigning to TTSC_CACHE_DIR itself would mutate
12
+ # the (possibly exported) environment that persist_devenv_environment later
13
+ # fingerprints as the pre-shell baseline.
14
+ ttsc_cache_dir_default="${TTSC_CACHE_DIR:-$repo_root/.cache/ttsc}"
15
+
16
+ add_repo_paths() {
17
+ "$repo_root/tooling/direnv/repo-path" --github-path
18
+ }
19
+
20
+ # The CLI that evaluates the shell must be the commit whose modules the shell is
21
+ # locked to. devenv writes its own source rev into devenv.lock's `devenv` node,
22
+ # so the lock already names one coherent pair (CLI 2.3.1+190959a evaluating the
23
+ # 190959a modules) and nothing here restates it. Note `original` carries no rev:
24
+ # that node is HEAD-at-lock-time rather than a release tag, so this pin buys
25
+ # coherence, not blessing.
26
+ #
27
+ # An unpinned `github:cachix/devenv` instead installs whatever HEAD is on the day
28
+ # a cold runner misses the store cache — a version that moves with no commit
29
+ # behind it, so it cannot be reviewed or bisected, and a CLI newer than the
30
+ # locked modules breaks eval-cache or flag compatibility with no diff to blame.
31
+ # `--accept-flake-config` makes it worse than untidy: it pre-trusts the
32
+ # substituters declared by a commit nobody looked at.
33
+ #
34
+ # Resolved lazily, on the paths that need it, because a host runner never does
35
+ # and that is the one branch which must not pay for a `nix eval`.
36
+ devenv_locked_rev() {
37
+ local lock="$repo_root/tooling/direnv/devenv.lock" rev
38
+ # nix, not jq: jq arrives with the shell this script is about to build, while
39
+ # nix is guaranteed by the install step before it. fromJSON also beats
40
+ # hand-rolled parsing of a file whose key order is not ours to assume.
41
+ # Absolute-path readFile needs --impure; nix's own error is left on stderr
42
+ # rather than swallowed, because an unresolvable pin is the failure these
43
+ # functions exist to prevent.
44
+ rev="$(nix eval --raw --impure --expr \
45
+ "(builtins.fromJSON (builtins.readFile \"$lock\")).nodes.devenv.locked.rev")" || rev=""
46
+ if [ -z "$rev" ]; then
47
+ echo "install-devenv: cannot resolve .nodes.devenv.locked.rev from $lock" >&2
48
+ echo " set DEVENV_FLAKE to install a devenv explicitly" >&2
49
+ return 1
50
+ fi
51
+ printf '%s' "$rev"
52
+ }
53
+
54
+ # Whether a devenv binary is the commit the lock names. `devenv version` prints
55
+ # "devenv <semver>+<short rev> (<system>)", so the abbreviated commit is right
56
+ # there and a prefix test against the full rev is the entire comparison — no
57
+ # assumption about how many characters devenv chooses to abbreviate to. A build
58
+ # with no "+<rev>" at all cannot prefix a 40-char hex rev, so it reads as a
59
+ # mismatch, which is the safe direction.
60
+ devenv_matches_lock() {
61
+ local bin="$1" rev="$2" printed
62
+ printed="$("$bin" version 2>/dev/null)" || return 1
63
+ printed="${printed#*+}"
64
+ printed="${printed%% *}"
65
+ [ -n "$printed" ] || return 1
66
+ case "$rev" in
67
+ "$printed"*) return 0 ;;
68
+ esac
69
+ return 1
70
+ }
71
+
72
+ install_devenv() {
73
+ local rev flake found=""
74
+ # Host runners own their Nix profile, and that profile roots a /nix/store the
75
+ # whole fleet shares, so an image-provided devenv is authoritative here
76
+ # whatever commit it is — and a wrong one is never REPLACED, because
77
+ # `nix profile remove --all` on a host would take the fleet's other roots with
78
+ # it. SMOO_HOST_RUNNER comes from setup-devenv's runner-kind detection.
79
+ #
80
+ # With none present these runners install from the FLOATING branch, not the
81
+ # locked rev, which is the one place this script deliberately accepts drift.
82
+ # The pin exists to make the ephemeral runners' cached devenv reproducible;
83
+ # a host installs into a long-lived shared profile whose blast radius is the
84
+ # whole fleet, and pinning it down to an older CLI than the fleet had been
85
+ # running broke it: run 34374650577 segfaulted the Rust linker
86
+ # (devenv-rust-linker, clang exit 139) building cowshed-cli tests, where run
87
+ # 34371205556 on the same commit range was green with floating 2a399e9.
88
+ # 190959a is TWO COMMITS OLDER than what these hosts had been getting, so the
89
+ # pin was moving them backwards. A host's toolchain moves when its image or
90
+ # the lock moves, not when a repository decides to hold it back.
91
+ if [ "${SMOO_HOST_RUNNER:-false}" = true ]; then
92
+ if command -v devenv >/dev/null 2>&1; then
93
+ echo "using host devenv: $(command -v devenv) ($(devenv version))"
94
+ else
95
+ flake="${DEVENV_FLAKE:-github:cachix/devenv}"
96
+ echo "host runner has no devenv; nix profile add ${flake}"
97
+ nix profile add --accept-flake-config "$flake"
98
+ fi
99
+ devenv_path_and_caches
100
+ return 0
101
+ fi
102
+
103
+ rev="$(devenv_locked_rev)"
104
+ # The store cache carries content only, never the Nix profiles, so the normal
105
+ # ephemeral case is that nothing is installed yet and this profile-adds the
106
+ # locked rev against an already-warm /nix — an evaluation and a link, not a
107
+ # download. Anything that does turn up on PATH is still checked rather than
108
+ # trusted, because "a devenv exists" was never the question.
109
+ if command -v devenv >/dev/null 2>&1; then
110
+ found="$(command -v devenv)"
111
+ elif [ -x "$HOME/.nix-profile/bin/devenv" ]; then
112
+ found="$HOME/.nix-profile/bin/devenv"
113
+ fi
114
+
115
+ if [ -n "$found" ] && devenv_matches_lock "$found" "$rev"; then
116
+ echo "using locked devenv: $found ($("$found" version))"
117
+ else
118
+ flake="${DEVENV_FLAKE:-github:cachix/devenv/$rev}"
119
+ if [ -n "$found" ]; then
120
+ # Replacing needs the old entry gone first: `nix profile add` would
121
+ # otherwise refuse on a bin/devenv collision at equal priority. --all is
122
+ # exact rather than blunt, because devenv is the only thing this script
123
+ # ever profile-adds, so a wrong devenv means a wrong profile.
124
+ echo "replacing devenv $("$found" version 2>/dev/null) — lock names ${rev:0:7}"
125
+ nix profile remove --all
126
+ fi
127
+ echo "nix profile add ${flake}"
128
+ nix profile add --accept-flake-config "$flake"
129
+ fi
130
+ devenv_path_and_caches
131
+ }
132
+
133
+ devenv_path_and_caches() {
134
+ if [ -d "$HOME/.nix-profile/bin" ]; then
135
+ echo "$HOME/.nix-profile/bin" >> "${GITHUB_PATH:-/dev/null}"
136
+ fi
137
+ if [ -n "$ttsc_cache_dir_default" ]; then
138
+ mkdir -p "$ttsc_cache_dir_default"
139
+ fi
140
+ }
141
+
142
+ build_devenv_shell() {
143
+ local since
144
+ since="$(date +%s)"
145
+ # One evaluation: the shell that captures the environment is the shell
146
+ # build. A separate `devenv shell -- date` evaluated everything twice.
147
+ persist_devenv_environment
148
+ # Only the ephemeral-runner path of setup-devenv opts in: the scan walks the
149
+ # whole store, which on a developer host or a host runner is large and not
150
+ # ours to root.
151
+ if [ "${SMOO_ROOT_BUILD_INPUTS:-false}" = true ]; then
152
+ root_build_inputs "$since"
153
+ fi
154
+ # Add repo-local tools only after the shell exists; cleanup steps use an
155
+ # explicit PATH because failures before this point must still refresh caches.
156
+ add_repo_paths
157
+ }
158
+
159
+ # The store cache's post phase collects garbage down to the live roots before
160
+ # it saves, and the shell's own root (.devenv/gc/shell) covers only the build
161
+ # closure. What evaluation fetched and built - flake input sources, the
162
+ # import-from-derivation outputs devenv-nixpkgs-patched and cabal2nix-* - has
163
+ # no root, so it was collected on the miss run and every hit run rebuilt it
164
+ # (measured at ~80s of a 150s setup on hosted macOS, run 34427309827). devenv
165
+ # records no store paths in its eval cache, so the exact set is the paths this
166
+ # build registered: root them under .devenv/gc, which the devenv cache carries
167
+ # and /nix/var/nix/gcroots/auto (inside the store cache) points at.
168
+ root_build_inputs() {
169
+ local since="$1" gcdir="$PWD/.devenv/gc/build-inputs" paths
170
+ rm -rf "$gcdir"
171
+ mkdir -p "$gcdir"
172
+ # `nix path-info --all --json` is an object keyed by path on Nix >= 2.19 and
173
+ # an array of {path} objects before that.
174
+ paths="$(nix path-info --all --json 2>/dev/null | jq -r --argjson since "$since" '
175
+ (if type == "array" then map({key: .path, value: .}) | from_entries else . end)
176
+ | to_entries[] | select(.value.registrationTime >= $since) | select(.key | endswith(".drv") | not) | .key')"
177
+ if [ -z "$paths" ]; then
178
+ echo "no store paths registered since $since; nothing to root"
179
+ return 0
180
+ fi
181
+ # Store paths are installables; --out-link names the first link and numbers
182
+ # the rest, each an indirect gc root. Derivations are excluded: keep-derivations
183
+ # retains the ones whose outputs are rooted, and realising a .drv would build it.
184
+ # shellcheck disable=SC2086
185
+ nix build --out-link "$gcdir/path" $paths
186
+ echo "rooted $(printf '%s\n' "$paths" | wc -l | tr -d ' ') store paths registered during the shell build under $gcdir"
187
+ }
188
+
189
+ # Workflow steps run their commands directly — never through `devenv shell` —
190
+ # so nothing the shell hooks export survives this composite action on its own.
191
+ # Persisting a hand-picked list here proved to be whack-a-mole: the TTSC
192
+ # variables were copied while LD_LIBRARY_PATH was not, and Bun-spawned native
193
+ # bindings dlopen-failed on NixOS runners (Bun has no Nix RUNPATH, unlike the
194
+ # patched Node, so it resolves libstdc++ only through that variable). Instead,
195
+ # capture the exported environment the devenv shell actually produces and
196
+ # persist everything it added or changed, minus what belongs to the runner
197
+ # step itself or to shell-session bookkeeping.
198
+ persist_devenv_environment() {
199
+ [ -n "${GITHUB_ENV:-}" ] || return 0
200
+ local name entry value captured bkey persisted=""
201
+ # Baseline: this step's own exported variables, before shell influence.
202
+ # Stored as smoo_baseline_<name> pseudo-map entries (printf -v), not a
203
+ # bash-4 associative array — macOS runners still ship bash 3.2. compgen -e
204
+ # only lists names that are valid identifiers, so the composed variable
205
+ # name is always valid too.
206
+ while IFS= read -r name; do
207
+ printf -v "smoo_baseline_$name" '%s' "${!name}"
208
+ done < <(compgen -e)
209
+ # NUL separators keep multi-line values intact, and compgen -e lists
210
+ # exported variables only (no BASH_FUNC_* noise). bash is the one
211
+ # interpreter every devenv shell provides, so this needs no coreutils.
212
+ # The capture writes to a file, NOT stdout: enterShell hooks print their
213
+ # own progress to stdout and would corrupt an inline capture.
214
+ captured="$(mktemp)"
215
+ SMOO_ENV_CAPTURE_OUT="$captured" devenv shell -- bash -c \
216
+ 'while IFS= read -r n; do printf "%s=%s\0" "$n" "${!n}"; done < <(compgen -e) > "$SMOO_ENV_CAPTURE_OUT"'
217
+ while IFS= read -r -d '' entry; do
218
+ name="${entry%%=*}"
219
+ value="${entry#*=}"
220
+ case "$name" in
221
+ # The runner step owns these; PATH persistence is add_repo_paths' job.
222
+ PATH | PWD | OLDPWD | SHLVL | SHELL | HOME | USER | LOGNAME | HOSTNAME | TERM | TMPDIR | TMP | TEMP | _ | PS1) continue ;;
223
+ GITHUB_* | RUNNER_* | ACTIONS_* | CI) continue ;;
224
+ # Shell-session bookkeeping, meaningful only inside the shell itself.
225
+ DIRENV_* | DEVENV_* | NIX_* | BASH* | XDG_* | IN_NIX_SHELL | SMOO_ENV_CAPTURE_OUT) continue ;;
226
+ esac
227
+ bkey="smoo_baseline_$name"
228
+ if [ "${!bkey+set}" = set ] && [ "${!bkey}" = "$value" ]; then
229
+ continue
230
+ fi
231
+ if [ "${value#*$'\n'}" != "$value" ]; then
232
+ # GITHUB_ENV heredoc form for multi-line values; the delimiter only has
233
+ # to never appear as a full line inside the value.
234
+ printf '%s<<__SMOO_DEVENV_ENV__\n%s\n__SMOO_DEVENV_ENV__\n' "$name" "$value" >> "$GITHUB_ENV"
235
+ else
236
+ printf '%s=%s\n' "$name" "$value" >> "$GITHUB_ENV"
237
+ fi
238
+ persisted="$persisted $name"
239
+ done < "$captured"
240
+ rm -f "$captured"
241
+ echo "devenv environment persisted for later steps:${persisted:- (none)}"
242
+ }
243
+
244
+ case "${1:-}" in
245
+ install-devenv) install_devenv ;;
246
+ build-shell) build_devenv_shell ;;
247
+ *)
248
+ echo "Usage: $0 {install-devenv|build-shell}" >&2
249
+ exit 1
250
+ ;;
251
+ esac
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+ # smoo-managed git merge driver: keep whichever side pins the NEWER version.
3
+ #
4
+ # Runtime version pins (nvfetcher overlay _sources/generated.{json,nix}) and the
5
+ # devenv/flake lock (devenv.lock) frequently differ across branches or across a
6
+ # mirror sync's `git am --3way`. Instead of stalling on a conflict, keep the
7
+ # higher pin wholesale so the tree always converges to the newest runtime.
8
+ # Repair package.json engine/packageManager pins explicitly with
9
+ # `smoo monorepo init --runtime-only` when needed.
10
+ #
11
+ # Wired by `smoo` (managed .gitattributes -> merge=smoo-newer-pins, and
12
+ # `git config merge.smoo-newer-pins.driver` installed by applyWorkspaceGitConfig).
13
+ # git invokes it as: merge-newer-pins.sh %O %A %B %P
14
+ # %O base, %A ours (result written here), %B theirs, %P pathname.
15
+ set -euo pipefail
16
+
17
+ ours="$2"
18
+ theirs="$3"
19
+
20
+ # Flake locks are ordered by lastModified (unix seconds); nvfetcher outputs by
21
+ # the semver in their version fields. A given file is one kind or the other.
22
+ max_last_modified() {
23
+ grep -oE '"lastModified"[[:space:]]*:[[:space:]]*[0-9]+' "$1" \
24
+ | grep -oE '[0-9]+' | sort -n | tail -1
25
+ }
26
+ max_semver() {
27
+ grep -oE 'version[[:space:]":=]*[0-9]+\.[0-9]+\.[0-9]+' "$1" \
28
+ | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -1
29
+ }
30
+
31
+ ours_lm="$(max_last_modified "$ours" || true)"
32
+ theirs_lm="$(max_last_modified "$theirs" || true)"
33
+
34
+ if [ -n "${ours_lm}${theirs_lm}" ]; then
35
+ # Flake lock: numeric lastModified comparison.
36
+ if [ -n "$theirs_lm" ] && [ "${theirs_lm:-0}" -gt "${ours_lm:-0}" ]; then
37
+ cp "$theirs" "$ours"
38
+ fi
39
+ else
40
+ # nvfetcher / version-pinned file: semver comparison.
41
+ ov="$(max_semver "$ours" || true)"
42
+ tv="$(max_semver "$theirs" || true)"
43
+ newest="$(printf '%s\n%s\n' "${ov:-0.0.0}" "${tv:-0.0.0}" | sort -V | tail -1)"
44
+ if [ -n "$tv" ] && [ "$newest" = "$tv" ] && [ "$tv" != "${ov:-}" ]; then
45
+ cp "$theirs" "$ours"
46
+ fi
47
+ fi
48
+ exit 0
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+ # Single source of truth for repo-local PATH entries.
3
+ # All tooling that sets up PATH must call this instead of hardcoding paths.
4
+ #
5
+ # Usage:
6
+ # export PATH="$(tooling/direnv/repo-path)" # shell
7
+ # tooling/direnv/repo-path --github-path # CI — appends to $GITHUB_PATH
8
+ # tooling/direnv/repo-path --print # debug — one entry per line
9
+ set -euo pipefail
10
+
11
+ root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
12
+
13
+ # Order: most-specific → least-specific.
14
+ entries=(
15
+ "$root/tooling/direnv/.devenv/profile/bin"
16
+ "$root/tooling/git-hooks"
17
+ "$root/tooling"
18
+ "$root/tooling/node_modules/.bin"
19
+ "$root/node_modules/.bin"
20
+ )
21
+
22
+ case "${1:-}" in
23
+ --github-path)
24
+ # GITHUB_PATH prepends entries; last line written = first in PATH.
25
+ # Reverse so most-specific directories are searched first.
26
+ for (( i=${#entries[@]}-1; i>=0; i-- )); do
27
+ echo "${entries[i]}"
28
+ done >> "$GITHUB_PATH" ;;
29
+ --print)
30
+ printf '%s\n' "${entries[@]}" ;;
31
+ *)
32
+ IFS=:
33
+ echo "${entries[*]}:$PATH" ;;
34
+ esac