@antelopejs/tooling-configs 0.5.7 → 0.5.8

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 (32) hide show
  1. package/dist/bin/api-diff.mjs +9 -7
  2. package/dist/bin/body-check.mjs +3 -3
  3. package/dist/bin/capture.mjs +12 -4
  4. package/dist/bin/check-size.mjs +6 -4
  5. package/dist/bin/checks.mjs +2 -2
  6. package/dist/bin/comment-proof.mjs +3 -3
  7. package/dist/bin/garden.mjs +151 -15
  8. package/dist/bin/lease.mjs +142 -20
  9. package/dist/bin/ratchet.mjs +5 -5
  10. package/dist/bin/readme-strip.mjs +1 -1
  11. package/dist/bin/suppressions.mjs +9 -10
  12. package/dist/bin/sync.mjs +66 -22
  13. package/dist/bin/verify.mjs +61 -36
  14. package/dist/{checks-CD2oFGrt.mjs → checks-BC-F8bsv.mjs} +2 -66
  15. package/dist/{files-DJ0TeaTU.mjs → files-C-JJhExM.mjs} +1 -1
  16. package/dist/launch-D5cylwvb.mjs +76 -0
  17. package/dist/{map-DRyYz_Fw.mjs → map-BYkmnvNw.mjs} +42 -10
  18. package/dist/oxc/fmt.mjs +1 -1
  19. package/dist/oxc/guardrails/index.mjs +1 -1
  20. package/dist/oxc/lint.mjs +1 -1
  21. package/dist/{oxlint-BbpTFFmf.mjs → oxlint-CCOJqj3d.mjs} +6 -2
  22. package/dist/{proof-stamp-Kg-tkM6G.mjs → proof-stamp-lyD84zmj.mjs} +4 -4
  23. package/dist/{ratchet-1O8k4Dxu.mjs → ratchet-SQ7vTR0i.mjs} +4 -4
  24. package/dist/run-command-BlFRPORx.mjs +95 -0
  25. package/dist/{shared-igPpEDpS.mjs → shared-BCFFyp3l.mjs} +9 -2
  26. package/dist/{size-DBatLT-F.mjs → size-CCGLY4Ke.mjs} +1 -1
  27. package/dist/slash-BEgSnfYw.mjs +12 -0
  28. package/dist/{suppression-base-DZgUDXiI.mjs → suppression-base-whhvw-IJ.mjs} +3 -3
  29. package/dist/{suppression-budget-DgYdu6JK.mjs → suppression-budget-CtIYSoDO.mjs} +2 -2
  30. package/dist/{suppressions-CQTcKCi1.mjs → suppressions-C79kRvYI.mjs} +1 -1
  31. package/dist/{typescript-CqcOaci8.mjs → typescript--_8og8AM.mjs} +1 -1
  32. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
3
3
  import { a as closeServer, c as LOCK_PORT, d as isRole, f as leaseHome, i as claimPort, l as PORT_ROLES, m as parseRecord, n as bindable, o as listenerPids, p as leaseId, r as chooseBlock, s as listensOn, t as accepting, u as isLeaseId } from "../ports-DGP6bPJy.mjs";
4
4
  import { a as isServerRole, l as unmarked, o as leaseEnv, s as leaseMarker } from "../env-DT0UJNeL.mjs";
5
5
  import { accessSync, closeSync, constants, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
6
- import { delimiter, join } from "node:path";
6
+ import { delimiter, join, win32 } from "node:path";
7
7
  import { execFileSync, spawn } from "node:child_process";
8
8
  import { homedir } from "node:os";
9
9
  import { parseArgs } from "node:util";
@@ -94,22 +94,109 @@ function locate(name, env) {
94
94
  }
95
95
  return refused ?? NOT_FOUND;
96
96
  }
97
+ const DEFAULT_PATHEXT = ".COM;.EXE;.BAT;.CMD";
98
+ const WINDOWS_PROGRAMS = /* @__PURE__ */ new Set([".com", ".exe"]);
99
+ const WINDOWS_SCRIPTS = /* @__PURE__ */ new Set([".bat", ".cmd"]);
100
+ const WINDOWS_PATH_SEPARATOR = ";";
101
+ const WINDOWS_DRIVE_OR_DIRECTORY = /^[A-Za-z]:|[\\/]/u;
102
+ const UNQUOTABLE_FOR_CMD = /["%\r\n]/u;
103
+ const WINDOWS_STARTABLE = "a .exe, .com, .bat or .cmd file";
104
+ const CONSOLE_SIGNALS = [
105
+ "SIGINT",
106
+ "SIGBREAK",
107
+ "SIGHUP"
108
+ ];
109
+ function isStartable(extension) {
110
+ return WINDOWS_PROGRAMS.has(extension) || WINDOWS_SCRIPTS.has(extension);
111
+ }
112
+ /** The value of the variable `name` however `env` spells its case, as Windows reads it. */
113
+ function windowsVariable(env, name) {
114
+ const key = Object.keys(env).find((each) => each.toUpperCase() === name);
115
+ return key === void 0 ? void 0 : env[key];
116
+ }
117
+ function isRegularFile(path) {
118
+ try {
119
+ return statSync(path).isFile();
120
+ } catch {
121
+ return false;
122
+ }
123
+ }
124
+ /** The files `base` may name: itself when it ends in a startable extension, else it plus each `PATHEXT` one. */
125
+ function withExtensions(base, extensions) {
126
+ return isStartable(win32.extname(base).toLowerCase()) ? [base] : extensions.map((extension) => base + extension);
127
+ }
97
128
  /**
98
- * Replaces this process with `command` under exactly `env`. The command keeps this pid and is the
99
- * only process, so a signal from a terminal, a process-group kill or `kill <pid>` reaches it once,
100
- * and its exit status, 128 plus the signal included, is the caller's. Node ignores SIGPIPE and
101
- * SIGXFSZ, and an ignored signal stays ignored across `execve`, so both get a handler first, which
102
- * `execve` resets to the default. Returns only when the command cannot start: after printing why,
103
- * with 127 when it is not found and 126 when it is found but cannot run, as a shell exits.
129
+ * The program `name` names on Windows, found the way `cmd.exe` finds it: as a path when it holds a
130
+ * drive or a directory, else in each directory of `Path` in `env` in turn, trying each `PATHEXT`
131
+ * extension a name without one needs. Only `.exe`, `.com`, `.bat` and `.cmd` start; any other
132
+ * extension in `PATHEXT` is ignored, and a file with one is refused with 126.
104
133
  */
105
- function launch(command, env) {
134
+ function locateWindows(name, env, isFile = isRegularFile) {
135
+ if (name === "") return NOT_FOUND;
136
+ const extensions = (windowsVariable(env, "PATHEXT") ?? DEFAULT_PATHEXT).split(WINDOWS_PATH_SEPARATOR).map((extension) => extension.trim().toLowerCase()).filter(isStartable);
137
+ const bases = WINDOWS_DRIVE_OR_DIRECTORY.test(name) ? [name] : (windowsVariable(env, "PATH") ?? "").split(WINDOWS_PATH_SEPARATOR).map((directory) => directory.trim().replaceAll("\"", "")).filter(Boolean).map((directory) => win32.join(directory, name));
138
+ for (const base of bases) for (const file of withExtensions(base, extensions)) if (isFile(file)) return {
139
+ kind: "start",
140
+ file,
141
+ script: WINDOWS_SCRIPTS.has(win32.extname(file).toLowerCase())
142
+ };
143
+ const plain = bases.find(isFile);
144
+ return plain === void 0 ? NOT_FOUND : refusal(126, `${plain} is not ${WINDOWS_STARTABLE}`);
145
+ }
146
+ function quoteForCmd(word) {
147
+ return `"${word.replace(/(\\+)$/u, "$1$1")}"`;
148
+ }
149
+ /** The `cmd.exe` command line that runs the script `file` with `args`, or why none can carry them unchanged. */
150
+ function cmdLine(file, args) {
151
+ const words = [file, ...args];
152
+ return words.some((word) => UNQUOTABLE_FOR_CMD.test(word)) ? refusal(126, `${file} runs under cmd.exe, which cannot pass a double quote, a percent sign or a line break in a path or argument unchanged`) : {
153
+ kind: "line",
154
+ line: `"${words.map(quoteForCmd).join(" ")}"`
155
+ };
156
+ }
157
+ function waitFor(name, file, args, env, verbatim) {
158
+ for (const signal of CONSOLE_SIGNALS) process.on(signal, () => void 0);
159
+ return new Promise((resolve) => {
160
+ const started = spawn(file, args, {
161
+ env,
162
+ stdio: "inherit",
163
+ windowsVerbatimArguments: verbatim
164
+ });
165
+ started.once("error", (error) => {
166
+ process.stderr.write(`antelopejs-lease: cannot run ${name}: ${error.message}\n`);
167
+ resolve(error.code === "ENOENT" ? 127 : 126);
168
+ });
169
+ started.once("exit", (code) => resolve(code ?? 1));
170
+ });
171
+ }
172
+ /**
173
+ * Runs `command` as a child on Windows, which has no `execve`, and answers its exit code. The
174
+ * child shares this console, so Ctrl+C and Ctrl+Break reach it directly; this process ignores
175
+ * them and outlives it by only the time to pass its code on.
176
+ */
177
+ async function launchWindows(command, env) {
178
+ const [name = "", ...args] = command;
179
+ const verdict = locateWindows(name, env);
180
+ if (verdict.kind === "refuse") return report$1(name, verdict);
181
+ if (!verdict.script) return waitFor(name, verdict.file, args, env, false);
182
+ const built = cmdLine(verdict.file, args);
183
+ if (built.kind === "refuse") return report$1(name, built);
184
+ return waitFor(name, windowsVariable(env, "COMSPEC") ?? "cmd.exe", [
185
+ "/d",
186
+ "/s",
187
+ "/c",
188
+ built.line
189
+ ], env, true);
190
+ }
191
+ function report$1(name, verdict) {
192
+ process.stderr.write(`antelopejs-lease: cannot run ${name}: ${verdict.reason}\n`);
193
+ return verdict.code;
194
+ }
195
+ function replaceWith(command, env) {
106
196
  if (process.execve === void 0) throw new Error("antelopejs-lease: run needs process.execve, from Node 22.15 on Linux or macOS");
107
197
  const [name = "", ...args] = command;
108
198
  const verdict = locate(name, env);
109
- if (verdict.kind === "refuse") {
110
- process.stderr.write(`antelopejs-lease: cannot run ${name}: ${verdict.reason}\n`);
111
- return verdict.code;
112
- }
199
+ if (verdict.kind === "refuse") return report$1(name, verdict);
113
200
  for (const signal of IGNORED_BY_NODE) process.on(signal, () => void 0);
114
201
  return verdict.viaShell ? process.execve(SHELL, [
115
202
  SHELL,
@@ -117,6 +204,20 @@ function launch(command, env) {
117
204
  ...args
118
205
  ], env) : process.execve(verdict.file, [name, ...args], env);
119
206
  }
207
+ /**
208
+ * Runs `command` under exactly `env` and answers its exit code. On Linux and macOS it replaces
209
+ * this process: the command keeps this pid and is the only process, so a signal from a terminal, a
210
+ * process-group kill or `kill <pid>` reaches it once, and its exit status, 128 plus the signal
211
+ * included, is the caller's. Node ignores SIGPIPE and SIGXFSZ, and an ignored signal stays ignored
212
+ * across `execve`, so both get a handler first, which `execve` resets to the default. That path
213
+ * returns only when the command cannot start. On Windows, which has no `execve`, the command runs
214
+ * as a child of this process, found through `Path` and `PATHEXT`. Either way a command that
215
+ * cannot start prints why and answers 127 when it is not found and 126 when it is found but cannot
216
+ * run, as a shell exits.
217
+ */
218
+ function launch(command, env) {
219
+ return process.platform === "win32" ? launchWindows(command, env) : Promise.resolve(replaceWith(command, env));
220
+ }
120
221
  //#endregion
121
222
  //#region src/lease/procs.ts
122
223
  const STAT_AFTER_COMM = 2;
@@ -378,6 +479,7 @@ async function ready(port, paths, exited) {
378
479
  * worktree's lease, so only `down` of its own lease stops it.
379
480
  */
380
481
  async function ensureMongod(port, paths, env) {
482
+ if (process.platform === "win32") throw new Error("antelopejs-lease: a lease's own mongod is not supported on Windows, where mongod has no --fork and holds its mongod.lock exclusively; set DMS_MONGO_URL to a server you run");
381
483
  if (mongodPid(paths.dbpath) !== void 0) return ready(port, paths, () => true);
382
484
  const binary = findMongod(env);
383
485
  if (binary === void 0) throw new Error("antelopejs-lease: no mongod on PATH or in ~/.cache/mongodb-binaries; install MongoDB, or set DMS_MONGO_URL to a server you run");
@@ -410,6 +512,12 @@ async function ensureMongod(port, paths, env) {
410
512
  const LOCK_WAIT_MS = 15e3;
411
513
  const RECORD_FILE = "lease.json";
412
514
  const RUNS_DIR = "runs";
515
+ const NODE_FS = {
516
+ readdir: (path) => {
517
+ readdirSync(path);
518
+ },
519
+ stat: (path) => statSync(path, { throwIfNoEntry: false })
520
+ };
413
521
  function staleReason(record, git) {
414
522
  if (git === void 0) return "missing";
415
523
  if (git.inode !== record.gitInode) return "recreated";
@@ -431,9 +539,11 @@ function leaseState(parsed, facts) {
431
539
  reason
432
540
  };
433
541
  }
434
- function probeGit(worktree) {
542
+ /** Lists `worktree`, then stats its `.git`, and reports what the two reads found. */
543
+ function probeGit(worktree, fs = NODE_FS) {
435
544
  try {
436
- const stat = statSync(join(worktree, ".git"), { throwIfNoEntry: false });
545
+ fs.readdir(worktree);
546
+ const stat = fs.stat(join(worktree, ".git"));
437
547
  if (stat === void 0) return { kind: "gone" };
438
548
  return {
439
549
  kind: "present",
@@ -443,13 +553,19 @@ function probeGit(worktree) {
443
553
  }
444
554
  };
445
555
  } catch (error) {
556
+ const code = error instanceof Error && "code" in error ? String(error.code) : "";
557
+ if (code === "ENOENT" || code === "ENOTDIR") return { kind: "gone" };
446
558
  return {
447
559
  kind: "unreadable",
448
- code: (error instanceof Error && "code" in error ? String(error.code) : "") || "unknown"
560
+ code: code || "unknown"
449
561
  };
450
562
  }
451
563
  }
452
- /** The worktree containing `cwd`, by the real path of `git rev-parse --show-toplevel`. */
564
+ /**
565
+ * The worktree containing `cwd`, by the real path of `git rev-parse --show-toplevel`. The native
566
+ * real path expands a Windows 8.3 short name such as `RUNNER~1`, so the id does not depend on how
567
+ * the caller spelled the directory.
568
+ */
453
569
  function locateWorktree(cwd) {
454
570
  let top;
455
571
  try {
@@ -465,7 +581,7 @@ function locateWorktree(cwd) {
465
581
  } catch {
466
582
  throw new Error(`antelopejs-lease: ${cwd} is not inside a git worktree`);
467
583
  }
468
- const path = realpathSync(top);
584
+ const path = realpathSync.native(top);
469
585
  const git = probeGit(path);
470
586
  if (git.kind !== "present") throw new Error(`antelopejs-lease: ${path} has no .git entry`);
471
587
  return {
@@ -745,6 +861,10 @@ async function terminate(found, report) {
745
861
  for (const target of found) if (!survivors.includes(target)) report(`stopped pid ${target.pid} (${target.command})`);
746
862
  if (survivors.length > 0) throw new Error(`antelopejs-lease: pid ${survivors.map((target) => target.pid).join(", ")} still running ${KILL_WAIT_MS / 1e3} s after SIGKILL`);
747
863
  }
864
+ /** Throws unless this platform is Linux, the only one where a process's environment can be read to find a lease's processes. */
865
+ function assertStopSupported() {
866
+ if (process.platform !== "linux") throw new Error("antelopejs-lease: down --stop reads /proc and runs on Linux only; stop your servers with their own stop command, then run down");
867
+ }
748
868
  /**
749
869
  * Stops every process of this user whose environment holds `ANTELOPEJS_LEASE=<id>`, which `run`
750
870
  * exports and every descendant inherits, except this process and its ancestors. Signals each pid
@@ -754,7 +874,7 @@ async function terminate(found, report) {
754
874
  * throws when one outlives the kill or new ones keep appearing. Linux only: it reads `/proc`.
755
875
  */
756
876
  async function stopOwn(id, report) {
757
- if (process.platform !== "linux") throw new Error("antelopejs-lease: down --stop reads /proc and runs on Linux only; stop your servers with their own stop command, then run down");
877
+ assertStopSupported();
758
878
  const marker = leaseMarker(id);
759
879
  const shield = ancestry();
760
880
  for (let round = 0; round < ROUNDS; round += 1) {
@@ -772,8 +892,9 @@ const DAY_MS = 864e5;
772
892
  const ROLES = Object.keys(PORT_ROLES).filter(isRole);
773
893
  /**
774
894
  * Opens this worktree's lease, makes sure its mongod runs unless `DMS_MONGO_URL` names another
775
- * server, and replaces this process with `command` under the lease's environment. Answers 127 or
776
- * 126, as a shell does, only when the command is not found or cannot run.
895
+ * server, and runs `command` under the lease's environment: as this process on Linux and macOS, as
896
+ * a child of it on Windows. Answers 127 or 126, as a shell does, when the command is not found or
897
+ * cannot run, and the command's own exit code on Windows.
777
898
  */
778
899
  async function run(command, as, env) {
779
900
  const worktree = locateWorktree(process.cwd());
@@ -865,6 +986,7 @@ async function down(env, options) {
865
986
  const worktree = locateWorktree(process.cwd());
866
987
  const entry = readEntries(leaseHome(env)).find((candidate) => candidate.id === worktree.id);
867
988
  if (entry === void 0) return;
989
+ if (options.stop !== void 0) assertStopSupported();
868
990
  if (entry.parsed?.kind === "foreign") throw foreignRecord(entry.dir);
869
991
  const record = entry.parsed?.kind === "current" ? entry.parsed.record : void 0;
870
992
  if (record !== void 0 && options.stop !== void 0) await stopOwn(record.id, options.stop);
@@ -2,11 +2,11 @@
2
2
  import { c as parseCeilings, l as readCeilings, t as CEILINGS_FILE } from "../ceilings-B7KayYIG.mjs";
3
3
  import { n as renamedPaths } from "../renames-L2owF5GD.mjs";
4
4
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
5
- import { c as repositoryRoot, l as resolveRevision, t as LINT_CONFIG } from "../files-DJ0TeaTU.mjs";
6
- import { n as ratchet, r as withPreviousTree } from "../ratchet-1O8k4Dxu.mjs";
7
- import { t as lintDiagnostics } from "../oxlint-BbpTFFmf.mjs";
8
- import { d as stagedAdditions, f as stagedChanges, u as previousLine } from "../suppression-budget-DgYdu6JK.mjs";
9
- import { n as suppressionBase } from "../suppression-base-DZgUDXiI.mjs";
5
+ import { c as repositoryRoot, l as resolveRevision, t as LINT_CONFIG } from "../files-C-JJhExM.mjs";
6
+ import { n as ratchet, r as withPreviousTree } from "../ratchet-SQ7vTR0i.mjs";
7
+ import { t as lintDiagnostics } from "../oxlint-CCOJqj3d.mjs";
8
+ import { d as stagedAdditions, f as stagedChanges, u as previousLine } from "../suppression-budget-CtIYSoDO.mjs";
9
+ import { n as suppressionBase } from "../suppression-base-whhvw-IJ.mjs";
10
10
  import { existsSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import { execFileSync, spawnSync } from "node:child_process";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { d as toolingRoot } from "../package-DnxZ2CXZ.mjs";
3
3
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
4
- import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
4
+ import { c as repositoryRoot } from "../files-C-JJhExM.mjs";
5
5
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { parseArgs } from "node:util";
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
- import { c as repositoryRoot, r as changedFiles } from "../files-DJ0TeaTU.mjs";
4
- import { n as unusedDirectives } from "../oxlint-BbpTFFmf.mjs";
5
- import { c as stagedSuppressions, i as checkSuppressions, l as checkPolicy, s as stagedNames } from "../suppression-budget-DgYdu6JK.mjs";
6
- import { c as suppressionsIn, i as inWorktree } from "../suppressions-CQTcKCi1.mjs";
7
- import { n as suppressionBase, t as raisedCeilings } from "../suppression-base-DZgUDXiI.mjs";
3
+ import { c as repositoryRoot, r as changedFiles } from "../files-C-JJhExM.mjs";
4
+ import { n as unusedDirectives } from "../oxlint-CCOJqj3d.mjs";
5
+ import { c as stagedSuppressions, i as checkSuppressions, l as checkPolicy, s as stagedNames } from "../suppression-budget-CtIYSoDO.mjs";
6
+ import { c as suppressionsIn, i as inWorktree } from "../suppressions-C79kRvYI.mjs";
7
+ import { n as suppressionBase, t as raisedCeilings } from "../suppression-base-whhvw-IJ.mjs";
8
8
  import { readdirSync } from "node:fs";
9
- import { dirname, join } from "node:path";
9
+ import { join, posix } from "node:path";
10
10
  import { execFileSync, spawnSync } from "node:child_process";
11
11
  import { parseArgs } from "node:util";
12
12
  //#region src/guardrails/dead-directives.ts
@@ -38,11 +38,10 @@ function written(directive, rules = directive.rules) {
38
38
  }
39
39
  /** Whether an ESLint config sits in the file's directory or above it, so ESLint may run the rules an `eslint-` directive names. */
40
40
  function lintedByEslint(root, file) {
41
- for (let directory = dirname(join(root, file)); directory.startsWith(root); directory = dirname(directory)) {
42
- if (readdirSync(directory).some((name) => ESLINT_CONFIG.test(name))) return true;
43
- if (directory === root) break;
41
+ for (let directory = posix.dirname(file);; directory = posix.dirname(directory)) {
42
+ if (readdirSync(join(root, directory)).some((name) => ESLINT_CONFIG.test(name))) return true;
43
+ if (directory === ".") return false;
44
44
  }
45
- return false;
46
45
  }
47
46
  /** The directive oxlint's report is about: on its line, else the nearest earlier block disable it ends at an `-enable` on that line, naming the dead rule when oxlint names one. */
48
47
  function reported(directives, unused) {
package/dist/bin/sync.mjs CHANGED
@@ -3,17 +3,18 @@ import { a as formatCeilings, l as readCeilings, s as isRetired, t as CEILINGS_F
3
3
  import { a as managedPackage, c as repositoryTools, f as toolingVersions, l as serializeManifest, m as usesNuxt, n as bootstrapDependencies, o as packageManager, p as usesCaptures, r as bootstrappedManifest, s as parseManifest, t as addedDevDependencies, u as templatePackage } from "../package-DnxZ2CXZ.mjs";
4
4
  import { t as admits } from "../semver-BDxeEcP_.mjs";
5
5
  import { i as presetConfig, n as SETUP_SCRIPT, r as lefthook, t as PRESET_CONFIGS } from "../templates-Dg188oRC.mjs";
6
- import { a as VERIFY_KINDS, c as isVerifyKind, i as SYNCED_SKILL_FILES, l as skillFolder, o as claudeLink, s as claudeLinkTarget, u as planDocsSkills } from "../shared-igPpEDpS.mjs";
6
+ import { a as VERIFY_KINDS, c as isVerifyKind, d as linkPointsAt, i as SYNCED_SKILL_FILES, l as skillFolder, o as claudeLink, s as claudeLinkTarget, u as planDocsSkills } from "../shared-BCFFyp3l.mjs";
7
7
  import { r as localVersions, t as checkInterfaceRanges } from "../interface-ranges-CcVSr59f.mjs";
8
8
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
9
9
  import { c as CI_CONTEXT, f as ciWorkflow, i as hasChecksWorkflow, n as ciNodeCallers, p as placeholderTestScript, r as ciRenovateSyncCallers, s as renovateArtifacts, t as MISSING_CHECKS_WORKFLOW, u as CI_PATH } from "../workflow-CPcNc8KL.mjs";
10
- import { a as gitFiles, c as repositoryRoot, u as trackedManifests } from "../files-DJ0TeaTU.mjs";
10
+ import { a as gitFiles, c as repositoryRoot, u as trackedManifests } from "../files-C-JJhExM.mjs";
11
11
  import { n as workspaceDirectories, r as workspacePatterns, t as planDocs } from "../docs-compat-Ft1r2sf0.mjs";
12
- import { i as recordedRelease, t as measureBaseline } from "../ratchet-1O8k4Dxu.mjs";
13
- import { a as stepsOf, i as matchingScripts, n as droppedChecksSteps } from "../checks-CD2oFGrt.mjs";
14
- import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-DgYdu6JK.mjs";
15
- import { u as typescript } from "../suppressions-CQTcKCi1.mjs";
16
- import { t as DEFAULT_SHARED } from "../map-DRyYz_Fw.mjs";
12
+ import { n as shimInvocation } from "../run-command-BlFRPORx.mjs";
13
+ import { i as recordedRelease, t as measureBaseline } from "../ratchet-SQ7vTR0i.mjs";
14
+ import { a as stepsOf, i as matchingScripts, n as droppedChecksSteps } from "../checks-BC-F8bsv.mjs";
15
+ import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-CtIYSoDO.mjs";
16
+ import { u as typescript } from "../suppressions-C79kRvYI.mjs";
17
+ import { t as DEFAULT_SHARED } from "../map-BYkmnvNw.mjs";
17
18
  import { createRequire } from "node:module";
18
19
  import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, rmdirSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
19
20
  import { basename, dirname, join, posix, resolve } from "node:path";
@@ -93,9 +94,11 @@ function untypedDocsFiles(root) {
93
94
  /** Runs pnpm, the only manager the pack's CI installs with, with `args` quietly; returns its output only when it failed. */
94
95
  function runPnpm(root, args) {
95
96
  const command = ["pnpm", ...args].join(" ");
96
- const result = spawnSync("pnpm", args, {
97
+ const pnpm = shimInvocation("pnpm", args);
98
+ const result = spawnSync(pnpm.command, pnpm.args, {
97
99
  cwd: root,
98
- encoding: "utf8"
100
+ encoding: "utf8",
101
+ shell: pnpm.shell
99
102
  });
100
103
  if (result.error) return `${command} failed: ${result.error.message}`;
101
104
  if (result.status === 0) return void 0;
@@ -271,6 +274,45 @@ function agentsBlock(context) {
271
274
  ].join("\n");
272
275
  }
273
276
  //#endregion
277
+ //#region src/guardrails/exec-bit.ts
278
+ function git(root, args) {
279
+ const result = spawnSync("git", args, {
280
+ cwd: root,
281
+ encoding: "utf8"
282
+ });
283
+ return result.status === 0 ? result.stdout : void 0;
284
+ }
285
+ /** Whether git ignores the filesystem's exec bit in the checkout at `root`, as Git for Windows does by setting `core.fileMode` to false. */
286
+ function ignoresFileMode(root) {
287
+ return git(root, [
288
+ "config",
289
+ "--bool",
290
+ "core.fileMode"
291
+ ])?.trim() === "false";
292
+ }
293
+ /** Whether `file` under `root` is executable: its filesystem exec bit, or, where git ignores that bit, the `100755` mode git's index records for it. */
294
+ function isExecutable(root, file) {
295
+ if ((statSync(join(root, file)).mode & 73) !== 0) return true;
296
+ return ignoresFileMode(root) && git(root, [
297
+ "ls-files",
298
+ "--stage",
299
+ "--",
300
+ file
301
+ ])?.startsWith("100755 ") === true;
302
+ }
303
+ /** Sets `file`'s mode; where the filesystem drops the exec bit, as on Windows, and git ignores it, also stages the file with mode `100755`, the only place such a checkout keeps that bit. */
304
+ function makeExecutable(root, file, mode) {
305
+ const path = join(root, file);
306
+ chmodSync(path, mode);
307
+ if ((statSync(path).mode & 73) === 0 && ignoresFileMode(root)) execFileSync("git", [
308
+ "update-index",
309
+ "--add",
310
+ "--chmod=+x",
311
+ "--",
312
+ file
313
+ ], { cwd: root });
314
+ }
315
+ //#endregion
274
316
  //#region src/guardrails/pnpm-workspace.ts
275
317
  const PATH = "pnpm-workspace.yaml";
276
318
  /** The first pnpm that keeps `pnpm --dir <nested> install` in the nested project when the root `pnpm-workspace.yaml` has no `packages`. Earlier pnpm installs the root instead. */
@@ -512,7 +554,7 @@ function backendBoundaryArtifacts(root) {
512
554
  cwd: root,
513
555
  encoding: "utf8"
514
556
  }).split("\0").filter((path) => path && dirname(dirname(path)) !== ".").map((path) => {
515
- const manifest = join(dirname(dirname(dirname(path))), "package.json");
557
+ const manifest = posix.join(posix.dirname(posix.dirname(posix.dirname(path))), "package.json");
516
558
  const name = existsSync(join(root, manifest)) ? parseManifest(readFileSync(join(root, manifest), "utf8")).name : void 0;
517
559
  if (!name) return {
518
560
  kind: "error",
@@ -1227,7 +1269,7 @@ function planLink(root, link, target) {
1227
1269
  actions: [],
1228
1270
  errors: [`${link} is not a symlink. Move it away, then rerun antelopejs-sync.`]
1229
1271
  };
1230
- if (readlinkSync(join(root, link)) !== target) return {
1272
+ if (!linkPointsAt(root, link, target)) return {
1231
1273
  actions: [{
1232
1274
  kind: "link",
1233
1275
  path: link,
@@ -1421,7 +1463,7 @@ const MANAGED_ARTIFACTS = [
1421
1463
  })
1422
1464
  }
1423
1465
  ];
1424
- function planSync(current, modes, context) {
1466
+ function planSync(current, executables, context) {
1425
1467
  const plan = [];
1426
1468
  for (const preset of PRESET_CONFIGS) for (const file of preset.legacy) if (current.has(file)) plan.push({
1427
1469
  kind: "error",
@@ -1434,7 +1476,7 @@ function planSync(current, modes, context) {
1434
1476
  if (artifact.path === ".github/workflows/ci.yml" && !context.managesCi) continue;
1435
1477
  try {
1436
1478
  const { content, notes } = artifact.desired(current.get(artifact.path), context);
1437
- const changed = current.get(artifact.path) !== content || artifact.mode !== void 0 && (artifact.mode & 73) !== 0 && ((modes.get(artifact.path) ?? 0) & 73) === 0;
1479
+ const changed = current.get(artifact.path) !== content || artifact.mode !== void 0 && (artifact.mode & 73) !== 0 && !executables.has(artifact.path);
1438
1480
  if (notes.length) plan.push({
1439
1481
  kind: "migrated",
1440
1482
  path: artifact.path,
@@ -1481,17 +1523,17 @@ function plannedDocs(docs) {
1481
1523
  }
1482
1524
  function repositorySnapshot(root) {
1483
1525
  const current = /* @__PURE__ */ new Map();
1484
- const modes = /* @__PURE__ */ new Map();
1526
+ const executables = /* @__PURE__ */ new Set();
1485
1527
  for (const file of [...MANAGED_ARTIFACTS.map(({ path }) => path), ...PRESET_CONFIGS.flatMap(({ legacy }) => legacy)]) {
1486
1528
  const path = join(root, file);
1487
1529
  if (existsSync(path)) {
1488
1530
  current.set(file, readFileSync(path, "utf8"));
1489
- modes.set(file, statSync(path).mode & 511);
1531
+ if (isExecutable(root, file)) executables.add(file);
1490
1532
  }
1491
1533
  }
1492
1534
  return {
1493
1535
  current,
1494
- modes
1536
+ executables
1495
1537
  };
1496
1538
  }
1497
1539
  function linksTo(root, link, target) {
@@ -1534,7 +1576,7 @@ function writeArtifacts(root, artifacts) {
1534
1576
  mkdirSync(dirname(path), { recursive: true });
1535
1577
  if (lstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink()) unlinkSync(path);
1536
1578
  writeFileSync(path, artifact.content);
1537
- if (artifact.mode !== void 0) chmodSync(path, artifact.mode);
1579
+ if (artifact.mode !== void 0) makeExecutable(root, artifact.path, artifact.mode);
1538
1580
  }
1539
1581
  }
1540
1582
  function repositoryNotices(root, context) {
@@ -1551,7 +1593,7 @@ function repositoryNotices(root, context) {
1551
1593
  */
1552
1594
  function syncRepository(root, options = {}) {
1553
1595
  const profile = options.profile ?? "full";
1554
- const { current, modes } = repositorySnapshot(root);
1596
+ const { current, executables } = repositorySnapshot(root);
1555
1597
  const manifest = parseManifest(current.get("package.json") ?? "{}");
1556
1598
  const verify = planVerify(root, {
1557
1599
  flag: options.verify,
@@ -1566,7 +1608,7 @@ function syncRepository(root, options = {}) {
1566
1608
  ...renovateArtifacts(root, manifest, profile === "full" || verify.kind === "template"),
1567
1609
  ...pnpmWorkspaceArtifacts(root, manifest, profile === "full")
1568
1610
  ];
1569
- let plan = [...planSync(current, modes, context), ...standalone];
1611
+ let plan = [...planSync(current, executables, context), ...standalone];
1570
1612
  const errors = plan.filter((artifact) => artifact.kind === "error").map(({ message }) => message);
1571
1613
  const entryOnly = checkEntryOnlyConfiguration(root);
1572
1614
  const coverage = checkTypecheckCoverage(root, Boolean(options.check));
@@ -1583,7 +1625,7 @@ function syncRepository(root, options = {}) {
1583
1625
  ...baseline,
1584
1626
  pack: recordedRelease(void 0)
1585
1627
  });
1586
- plan = [...planSync(current, modes, context), ...standalone];
1628
+ plan = [...planSync(current, executables, context), ...standalone];
1587
1629
  }
1588
1630
  const writes = plan.filter((artifact) => artifact.kind === "write" || artifact.kind === "migrated");
1589
1631
  if (!options.check && !errors.length) {
@@ -1931,9 +1973,11 @@ function failureText(result) {
1931
1973
  return result.stderr.trim().split("\n")[0] || `gh exited with ${result.status ?? result.signal}`;
1932
1974
  }
1933
1975
  function gh(root, args) {
1934
- return spawnSync("gh", args, {
1976
+ const invocation = shimInvocation("gh", args);
1977
+ return spawnSync(invocation.command, invocation.args, {
1935
1978
  cwd: root,
1936
- encoding: "utf8"
1979
+ encoding: "utf8",
1980
+ shell: invocation.shell
1937
1981
  });
1938
1982
  }
1939
1983
  /** Turns `delete_branch_on_merge` on through `gh`, reading it first so a repository that has it on is never written. */