@darkrymit/crunes-cli 0.8.5 → 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 (95) hide show
  1. package/dist/chunks/{add-CBHWFGCA.js → add-IT3IHBPO.js} +2 -2
  2. package/dist/chunks/add-MSX6XSU3.js +68 -0
  3. package/dist/chunks/{apply-J4YICV6H.js → apply-LOIJIPLR.js} +21 -12
  4. package/dist/chunks/{benchmark-AKKV7G32.js → benchmark-3IHFP3V2.js} +27 -18
  5. package/dist/chunks/{browse-JZFU52ET.js → browse-PHMBDREQ.js} +2 -2
  6. package/dist/chunks/chunk-2DNYVKBF.js +109 -0
  7. package/dist/chunks/chunk-2FI6KN3C.js +283 -0
  8. package/dist/chunks/chunk-2HM5Q52B.js +131 -0
  9. package/dist/chunks/{chunk-6MRZXASS.js → chunk-2Q3KLBE6.js} +16 -0
  10. package/dist/chunks/{chunk-ZJDKCC2Y.js → chunk-4GJMCFR6.js} +6 -3
  11. package/dist/chunks/chunk-55GTJG5I.js +1154 -0
  12. package/dist/chunks/chunk-6IC6ZJ74.js +9525 -0
  13. package/dist/chunks/chunk-7KYCYDAS.js +325 -0
  14. package/dist/chunks/chunk-DTOYFY3Z.js +578 -0
  15. package/dist/chunks/chunk-EO3CSXWK.js +70 -0
  16. package/dist/chunks/chunk-FIAFVIAN.js +79 -0
  17. package/dist/chunks/{chunk-J3GZ3DXD.js → chunk-GVMT55GH.js} +3 -2
  18. package/dist/chunks/chunk-H2OT7D6N.js +303 -0
  19. package/dist/chunks/{chunk-JOAL437H.js → chunk-I6MHDUCW.js} +16 -1
  20. package/dist/chunks/chunk-KSQDFE5N.js +85 -0
  21. package/dist/chunks/{chunk-BTIPUR5S.js → chunk-KUEMDPNG.js} +108 -91
  22. package/dist/chunks/{chunk-6XLT25GS.js → chunk-MIKWIFYR.js} +47 -0
  23. package/dist/chunks/{chunk-GTCPZ22N.js → chunk-MTJ2KW3V.js} +3 -1
  24. package/dist/chunks/chunk-MVCBPI4J.js +2354 -0
  25. package/dist/chunks/{chunk-T53L5CJW.js → chunk-PBGUKXT6.js} +2887 -1874
  26. package/dist/chunks/{chunk-KII6KW5Z.js → chunk-RVBAAXRY.js} +64 -44
  27. package/dist/chunks/chunk-SUCYDYMU.js +44 -0
  28. package/dist/chunks/chunk-UBCAZGLE.js +15 -0
  29. package/dist/chunks/{chunk-63H5VXZY.js → chunk-UEUUOAJY.js} +4 -1
  30. package/dist/chunks/chunk-VP7YLCQP.js +244 -0
  31. package/dist/chunks/{chunk-NDEYEYSU.js → chunk-WJII3LZK.js} +4 -3
  32. package/dist/chunks/chunk-XDMMSZIL.js +71 -0
  33. package/dist/chunks/chunk-YKIKJHYO.js +94 -0
  34. package/dist/chunks/{chunk-NYLRTAAA.js → chunk-YVN3VDRE.js} +1 -1
  35. package/dist/chunks/{clear-YBDIPEEH.js → clear-AT7HNUV4.js} +2 -2
  36. package/dist/chunks/{create-L6DJN4ME.js → create-DXW4YYLJ.js} +8 -8
  37. package/dist/chunks/create-LPLNCOW4.js +268 -0
  38. package/dist/chunks/{create-GPDE2YKL.js → create-Y4LHLWGL.js} +26 -18
  39. package/dist/chunks/{delete-LNOYM5KG.js → delete-2EXPFBFC.js} +2 -2
  40. package/dist/chunks/{delete-E4TEBRPX.js → delete-GKYA2W5Z.js} +4 -2
  41. package/dist/chunks/{delete-C4UJ7X5K.js → delete-MJAECXXV.js} +2 -2
  42. package/dist/chunks/disable-TITOSMXB.js +43 -0
  43. package/dist/chunks/doctor-R2Y6UAY4.js +208 -0
  44. package/dist/chunks/enable-LGTPDWPV.js +35 -0
  45. package/dist/chunks/{globals-H2WF344Y.js → globals-SNQFCHMP.js} +1 -1
  46. package/dist/chunks/{init-HU5OMHEH.js → init-KO2HLED5.js} +18 -8
  47. package/dist/chunks/install-7IRUAGSF.js +64 -0
  48. package/dist/chunks/{intro-36OLGNYN.js → intro-JNJ6A75J.js} +89 -21
  49. package/dist/chunks/{kill-2UG7PHUV.js → kill-TX3PC73P.js} +2 -1
  50. package/dist/chunks/{list-2JYMBMZC.js → list-BCCM3TLP.js} +12 -7
  51. package/dist/chunks/{list-4X3JFQGS.js → list-EHREZR6M.js} +2 -1
  52. package/dist/chunks/{list-U7PAYNAH.js → list-LC6HB3H3.js} +2 -2
  53. package/dist/chunks/list-MLKZE36K.js +92 -0
  54. package/dist/chunks/list-QVZKR3IE.js +62 -0
  55. package/dist/chunks/{list-7VHJIUDX.js → list-U4EMHQZT.js} +2 -2
  56. package/dist/chunks/{list-PTAWQYWG.js → list-V7VVD5AG.js} +2 -1
  57. package/dist/chunks/{list-A5WVDBWF.js → list-VA73WPK6.js} +2 -2
  58. package/dist/chunks/{manifest-7RVNKBOH.js → manifest-76MIEL2F.js} +3 -1
  59. package/dist/chunks/migrate-Y3EKMVP5.js +87 -0
  60. package/dist/chunks/{output-RJ6JSNY7.js → output-QN5CVJ62.js} +4 -1
  61. package/dist/chunks/{query-AW7WYILM.js → query-2US3CPYT.js} +2 -2
  62. package/dist/chunks/{registry-RG34DPD7.js → registry-IWP7JMNI.js} +2 -2
  63. package/dist/chunks/{remove-QUH2D3S5.js → remove-BCFTF23J.js} +2 -2
  64. package/dist/chunks/{repl-STBZC4P2.js → repl-2YWTHUWT.js} +4 -0
  65. package/dist/chunks/{repl-BPEWARN7.js → repl-5GDN3RAO.js} +99 -31
  66. package/dist/chunks/resolver-CA2A32AC.js +36 -0
  67. package/dist/chunks/run-WL3IZBXF.js +35 -0
  68. package/dist/chunks/rune-YA4TFHTB.js +283 -0
  69. package/dist/chunks/runner-QNZMBHQY.js +34 -0
  70. package/dist/chunks/{search-MSSDGJTF.js → search-B7IM7JRJ.js} +2 -2
  71. package/dist/chunks/shell-explain-LKBBP2BG.js +77 -0
  72. package/dist/chunks/trust-BFIDANXD.js +109 -0
  73. package/dist/chunks/uninstall-3MWZIZVA.js +58 -0
  74. package/dist/chunks/{unset-YASSMSE5.js → unset-P6IUF7SS.js} +2 -2
  75. package/dist/chunks/{update-KSC6VRMU.js → update-W4MJUTTW.js} +25 -19
  76. package/dist/chunks/{update-EWWDROKW.js → update-WXT7CHYA.js} +2 -2
  77. package/dist/chunks/{utils-3SJFSUSV.js → utils-B2QULX5J.js} +8 -4
  78. package/dist/chunks/{version-YG2M7HER.js → version-FLHI5KFS.js} +3 -3
  79. package/dist/cli.js +115 -70
  80. package/package.json +2 -2
  81. package/dist/chunks/chunk-ASZKAC24.js +0 -103
  82. package/dist/chunks/chunk-G3U4V32O.js +0 -46
  83. package/dist/chunks/chunk-GSA432UC.js +0 -90
  84. package/dist/chunks/chunk-WJRZN7BR.js +0 -77492
  85. package/dist/chunks/create-VYZRWRGQ.js +0 -170
  86. package/dist/chunks/disable-FGJ7VMPO.js +0 -47
  87. package/dist/chunks/doctor-7NWBJAH7.js +0 -53
  88. package/dist/chunks/enable-ZL6QOC2I.js +0 -47
  89. package/dist/chunks/install-FIYRMVLR.js +0 -57
  90. package/dist/chunks/list-AIYNOPNZ.js +0 -28
  91. package/dist/chunks/list-NZ5DHXJF.js +0 -111
  92. package/dist/chunks/resolver-36V72VKR.js +0 -28
  93. package/dist/chunks/run-IVL23SMW.js +0 -26
  94. package/dist/chunks/rune-XRREUL56.js +0 -186
  95. package/dist/chunks/uninstall-G56DZRFG.js +0 -49
@@ -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
+ };
@@ -5,11 +5,25 @@ import {
5
5
  // src/store/index.js
6
6
  init_require_shim();
7
7
  import fs from "node:fs/promises";
8
+ import { existsSync } from "node:fs";
8
9
  import os from "node:os";
9
10
  import path from "node:path";
11
+ import { createHash } from "node:crypto";
10
12
  function getStorePath() {
11
13
  return process.env.CRUNES_STORE ?? path.join(os.homedir(), ".crunes");
12
14
  }
15
+ function shortHash(str) {
16
+ return createHash("sha1").update(str).digest("hex").slice(0, 8);
17
+ }
18
+ function isRootless(projectDir) {
19
+ return !existsSync(path.join(projectDir, ".crunes", "config.json"));
20
+ }
21
+ function getRootlessBase(projectDir) {
22
+ return path.join(getStorePath(), "rootless", shortHash(projectDir));
23
+ }
24
+ function getLocalBase(projectDir) {
25
+ return isRootless(projectDir) ? getRootlessBase(projectDir) : path.join(projectDir, ".crunes");
26
+ }
13
27
  function getProjectsJsonPath() {
14
28
  return path.join(getStorePath(), "projects.json");
15
29
  }
@@ -49,6 +63,8 @@ async function ensureStoreDirs() {
49
63
 
50
64
  export {
51
65
  getStorePath,
66
+ isRootless,
67
+ getLocalBase,
52
68
  getProjectsJsonPath,
53
69
  getPluginsJsonPath,
54
70
  getPluginCacheDir,
@@ -1,3 +1,6 @@
1
+ import {
2
+ getLocalBase
3
+ } from "./chunk-2Q3KLBE6.js";
1
4
  import {
2
5
  init_require_shim
3
6
  } from "./chunk-TPK5AGRA.js";
@@ -8,7 +11,7 @@ import { readFile, writeFile, mkdir, readdir, rm } from "node:fs/promises";
8
11
  import { join } from "node:path";
9
12
  import { randomUUID } from "node:crypto";
10
13
  function jobDir(projectDir, id) {
11
- return join(projectDir, ".crunes", "jobs", id);
14
+ return join(getLocalBase(projectDir), "jobs", id);
12
15
  }
13
16
  function jobStdoutPath(projectDir, id) {
14
17
  return join(jobDir(projectDir, id), "stdout.log");
@@ -42,7 +45,7 @@ async function getJob(projectDir, id) {
42
45
  }
43
46
  }
44
47
  async function listJobs(projectDir) {
45
- const base = join(projectDir, ".crunes", "jobs");
48
+ const base = join(getLocalBase(projectDir), "jobs");
46
49
  let entries;
47
50
  try {
48
51
  entries = await readdir(base, { withFileTypes: true });
@@ -58,7 +61,7 @@ async function deleteJob(projectDir, id) {
58
61
  await rm(jobDir(projectDir, id), { recursive: true, force: true });
59
62
  }
60
63
  async function cleanJobs(projectDir) {
61
- const base = join(projectDir, ".crunes", "jobs");
64
+ const base = join(getLocalBase(projectDir), "jobs");
62
65
  let entries;
63
66
  try {
64
67
  entries = await readdir(base, { withFileTypes: true });