@darkrymit/crunes-cli 0.9.0 → 0.10.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.
Files changed (59) hide show
  1. package/dist/chunks/add-MSX6XSU3.js +68 -0
  2. package/dist/chunks/{apply-YY7MIM64.js → apply-LOIJIPLR.js} +18 -9
  3. package/dist/chunks/{benchmark-BQNMULOO.js → benchmark-3IHFP3V2.js} +21 -15
  4. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  5. package/dist/chunks/chunk-2FI6KN3C.js +283 -0
  6. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  7. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  8. package/dist/chunks/chunk-6IC6ZJ74.js +9525 -0
  9. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  10. package/dist/chunks/chunk-DTOYFY3Z.js +578 -0
  11. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  12. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  13. package/dist/chunks/chunk-H2OT7D6N.js +303 -0
  14. package/dist/chunks/{chunk-MRNZFUXZ.js → chunk-KSQDFE5N.js} +22 -7
  15. package/dist/chunks/{chunk-SNC7AOT7.js → chunk-KUEMDPNG.js} +45 -94
  16. package/dist/chunks/{chunk-VST6HAB6.js → chunk-MTJ2KW3V.js} +2 -0
  17. package/dist/chunks/{chunk-CY6C6ADU.js → chunk-MVCBPI4J.js} +45 -478
  18. package/dist/chunks/{chunk-34F4ZURL.js → chunk-RVBAAXRY.js} +29 -12
  19. package/dist/chunks/{chunk-X7PZN73N.js → chunk-SUCYDYMU.js} +1 -1
  20. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  21. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  22. package/dist/chunks/chunk-XDMMSZIL.js +71 -0
  23. package/dist/chunks/chunk-YKIKJHYO.js +94 -0
  24. package/dist/chunks/{create-TLPM7HJE.js → create-DXW4YYLJ.js} +5 -5
  25. package/dist/chunks/{create-LM7U3CJS.js → create-LPLNCOW4.js} +100 -6
  26. package/dist/chunks/{create-ET6DT5ZE.js → create-Y4LHLWGL.js} +6 -2
  27. package/dist/chunks/{disable-TNTEIAKO.js → disable-TITOSMXB.js} +6 -2
  28. package/dist/chunks/doctor-R2Y6UAY4.js +208 -0
  29. package/dist/chunks/{enable-GUQCB4CU.js → enable-LGTPDWPV.js} +7 -3
  30. package/dist/chunks/{init-PJSCFOC6.js → init-KO2HLED5.js} +6 -2
  31. package/dist/chunks/{install-4YP7FALO.js → install-7IRUAGSF.js} +10 -5
  32. package/dist/chunks/{intro-SA7MWV3Z.js → intro-JNJ6A75J.js} +44 -18
  33. package/dist/chunks/{list-WKNPZZOV.js → list-BCCM3TLP.js} +10 -6
  34. package/dist/chunks/{list-7R6NASFI.js → list-MLKZE36K.js} +19 -19
  35. package/dist/chunks/list-QVZKR3IE.js +62 -0
  36. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  37. package/dist/chunks/migrate-Y3EKMVP5.js +87 -0
  38. package/dist/chunks/{registry-K5DV5NAK.js → registry-IWP7JMNI.js} +1 -1
  39. package/dist/chunks/{repl-ZB3DIJ4K.js → repl-5GDN3RAO.js} +30 -20
  40. package/dist/chunks/resolver-CA2A32AC.js +36 -0
  41. package/dist/chunks/{run-22B65ZWZ.js → run-WL3IZBXF.js} +17 -11
  42. package/dist/chunks/rune-YA4TFHTB.js +283 -0
  43. package/dist/chunks/runner-QNZMBHQY.js +34 -0
  44. package/dist/chunks/{shell-explain-QLITLHW7.js → shell-explain-LKBBP2BG.js} +5 -2
  45. package/dist/chunks/trust-BFIDANXD.js +109 -0
  46. package/dist/chunks/{uninstall-4WR5IHLC.js → uninstall-3MWZIZVA.js} +10 -5
  47. package/dist/chunks/{update-ACLDK6E6.js → update-W4MJUTTW.js} +10 -5
  48. package/dist/chunks/{version-EULYWNXN.js → version-FLHI5KFS.js} +2 -2
  49. package/dist/cli.js +51 -34
  50. package/package.json +2 -2
  51. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  52. package/dist/chunks/chunk-QYRF3R35.js +0 -154
  53. package/dist/chunks/chunk-YXCHIMLW.js +0 -75308
  54. package/dist/chunks/doctor-VXAQYMTR.js +0 -101
  55. package/dist/chunks/list-OMMZAQ23.js +0 -28
  56. package/dist/chunks/resolver-QIYYFIDX.js +0 -34
  57. package/dist/chunks/rune-SYK4N642.js +0 -425
  58. package/dist/chunks/{delete-5R3WBLVD.js → delete-2EXPFBFC.js} +4 -4
  59. package/dist/chunks/{delete-U4STA2QZ.js → delete-MJAECXXV.js} +4 -4
@@ -0,0 +1,131 @@
1
+ import {
2
+ init_require_shim
3
+ } from "./chunk-TPK5AGRA.js";
4
+
5
+ // src/rune/api/shell-resolve.js
6
+ init_require_shim();
7
+ import { existsSync } from "node:fs";
8
+ import path from "node:path";
9
+ var ShellResolutionError = class extends Error {
10
+ constructor(message, { mode, tried }) {
11
+ super(message);
12
+ this.name = "ShellResolutionError";
13
+ this.mode = mode;
14
+ this.tried = tried;
15
+ }
16
+ };
17
+ function isWslLauncher(candidate, env) {
18
+ const systemRoot = (env.SystemRoot ?? "C:\\Windows").replace(/\\/g, "/").toLowerCase();
19
+ const p = String(candidate).replace(/\\/g, "/").toLowerCase();
20
+ return p.startsWith(`${systemRoot}/system32/`);
21
+ }
22
+ function bashCandidates(deps) {
23
+ const { platform, env, pathDirs } = deps;
24
+ if (platform !== "win32") {
25
+ return ["/bin/bash", "/usr/bin/bash", ...pathDirs.map((d) => path.posix.join(d, "bash"))];
26
+ }
27
+ const out = [];
28
+ if (env.ProgramFiles) out.push(path.win32.join(env.ProgramFiles, "Git", "bin", "bash.exe"));
29
+ if (env["ProgramFiles(x86)"]) out.push(path.win32.join(env["ProgramFiles(x86)"], "Git", "bin", "bash.exe"));
30
+ if (env.LOCALAPPDATA) out.push(path.win32.join(env.LOCALAPPDATA, "Programs", "Git", "bin", "bash.exe"));
31
+ for (const dir of pathDirs) {
32
+ const candidate = path.win32.join(dir, "bash.exe");
33
+ if (isWslLauncher(candidate, env)) continue;
34
+ out.push(candidate);
35
+ }
36
+ return out;
37
+ }
38
+ function findBash(deps) {
39
+ const { env, exists } = deps;
40
+ const tried = bashCandidates(deps);
41
+ for (const candidate of tried) {
42
+ if (exists(candidate)) return { path: candidate, tried };
43
+ }
44
+ const override = env.CRUNES_BASH;
45
+ if (override && exists(override) && !isWslLauncher(override, env)) {
46
+ return { path: override, tried: [...tried, override] };
47
+ }
48
+ return { path: null, tried: override ? [...tried, override] : tried };
49
+ }
50
+ function findSh(deps) {
51
+ if (deps.platform === "win32") return null;
52
+ return deps.exists("/bin/sh") ? "/bin/sh" : null;
53
+ }
54
+ function findCmd(deps) {
55
+ if (deps.platform !== "win32") return null;
56
+ return deps.env.ComSpec ?? "C:\\Windows\\System32\\cmd.exe";
57
+ }
58
+ var cached = null;
59
+ function defaultDeps() {
60
+ const sep = process.platform === "win32" ? ";" : ":";
61
+ return {
62
+ platform: process.platform,
63
+ env: process.env,
64
+ exists: (p) => {
65
+ try {
66
+ return existsSync(p);
67
+ } catch {
68
+ return false;
69
+ }
70
+ },
71
+ pathDirs: (process.env.PATH ?? "").split(sep).filter(Boolean)
72
+ };
73
+ }
74
+ function resolveShell(mode, deps = null) {
75
+ const d = deps ?? defaultDeps();
76
+ const useCache = deps === null;
77
+ if (mode !== void 0 && mode !== "bash" && mode !== "cmd") {
78
+ throw new ShellResolutionError(`Unknown shell mode: '${mode}'. Expected 'bash', 'cmd', or undefined.`, { mode, tried: [] });
79
+ }
80
+ if (useCache && cached && cached[String(mode)]) return cached[String(mode)];
81
+ let result;
82
+ if (mode === "bash") {
83
+ const { path: bash, tried } = findBash(d);
84
+ if (!bash) {
85
+ throw new ShellResolutionError(
86
+ `shell: 'bash' was requested but no bash was found. Tried:
87
+ ${tried.join("\n ")}
88
+ Set CRUNES_BASH to an absolute bash path if it is installed elsewhere.`,
89
+ { mode, tried }
90
+ );
91
+ }
92
+ result = { kind: "bash", path: bash };
93
+ } else if (mode === "cmd") {
94
+ const cmd = findCmd(d);
95
+ if (!cmd) {
96
+ throw new ShellResolutionError(`shell: 'cmd' is only available on Windows (platform is '${d.platform}').`, { mode, tried: [] });
97
+ }
98
+ result = { kind: "cmd", path: cmd };
99
+ } else {
100
+ const { path: bash, tried } = findBash(d);
101
+ if (bash) {
102
+ result = { kind: "bash", path: bash };
103
+ } else {
104
+ const sh = findSh(d);
105
+ if (sh) {
106
+ result = { kind: "sh", path: sh };
107
+ } else {
108
+ const cmd = findCmd(d);
109
+ if (!cmd) {
110
+ throw new ShellResolutionError(
111
+ `No usable shell found. Tried bash:
112
+ ${tried.join("\n ")}
113
+ then /bin/sh.`,
114
+ { mode, tried: [...tried, "/bin/sh"] }
115
+ );
116
+ }
117
+ result = { kind: "cmd", path: cmd };
118
+ }
119
+ }
120
+ }
121
+ if (useCache) {
122
+ cached ??= {};
123
+ cached[String(mode)] = result;
124
+ }
125
+ return result;
126
+ }
127
+
128
+ export {
129
+ defaultDeps,
130
+ resolveShell
131
+ };