@rse/claudex 1.0.14 → 1.0.15
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.
- package/CHANGELOG.md +11 -0
- package/claudex.js +116 -32
- package/claudex.ts +124 -34
- package/package.json +1 -1
- package/stx.conf +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
ChangeLog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
1.0.15 (2026-08-08)
|
|
6
|
+
-------------------
|
|
7
|
+
|
|
8
|
+
- IMPROVEMENT: support more package managers
|
|
9
|
+
- IMPROVEMENT: use package manager which was used to install a tool
|
|
10
|
+
|
|
11
|
+
1.0.14 (2026-08-06)
|
|
12
|
+
-------------------
|
|
13
|
+
|
|
14
|
+
- BUGFIX: do not use sudo if not really required
|
|
15
|
+
|
|
5
16
|
1.0.13 (2026-08-04)
|
|
6
17
|
-------------------
|
|
7
18
|
|
package/claudex.js
CHANGED
|
@@ -68,46 +68,88 @@ const isPsmux = () => {
|
|
|
68
68
|
isPsmuxCached = process.platform === "win32" && findTool("psmux") !== null;
|
|
69
69
|
return isPsmuxCached;
|
|
70
70
|
};
|
|
71
|
+
/* the known package managers, in the order of their detection preference
|
|
72
|
+
(on Fedora "yum" is just an alias for "dnf", hence "dnf" comes first) */
|
|
73
|
+
const packageManagers = [
|
|
74
|
+
{ name: "winget", plat: "win32", tool: "winget", key: "windows:winget" },
|
|
75
|
+
{ name: "choco", plat: "win32", tool: "choco", key: "windows:choco" },
|
|
76
|
+
{ name: "ports", plat: "darwin", tool: "port", key: "macos:ports" },
|
|
77
|
+
{ name: "brew", plat: "darwin", tool: "brew", key: "macos:brew" },
|
|
78
|
+
{ name: "apt", plat: "linux", tool: "apt", key: "linux:apt" },
|
|
79
|
+
{ name: "dnf", plat: "linux", tool: "dnf", key: "linux:dnf" },
|
|
80
|
+
{ name: "yum", plat: "linux", tool: "yum", key: "linux:yum" },
|
|
81
|
+
{ name: "zypper", plat: "linux", tool: "zypper", key: "linux:zypper" },
|
|
82
|
+
{ name: "pacman", plat: "linux", tool: "pacman", key: "linux:pacman" },
|
|
83
|
+
{ name: "apk", plat: "linux", tool: "apk", key: "linux:apk" }
|
|
84
|
+
];
|
|
71
85
|
/* helper for detecting the platform and package manager combination */
|
|
72
86
|
const detectPlatform = () => {
|
|
73
|
-
/* helper function for finding a tool in PATH */
|
|
74
|
-
const has = (tool) => findTool(tool) !== null;
|
|
75
87
|
/* honor explicit override via CLAUDEX_PKG (e.g. "brew", "ports", "apt", ...)
|
|
76
88
|
to disambiguate hosts where multiple package managers are installed */
|
|
77
89
|
const override = process.env.CLAUDEX_PKG ?? "";
|
|
78
90
|
if (override !== "") {
|
|
79
|
-
const
|
|
80
|
-
winget: { plat: "win32", tool: "winget", key: "windows:winget" },
|
|
81
|
-
choco: { plat: "win32", tool: "choco", key: "windows:choco" },
|
|
82
|
-
ports: { plat: "darwin", tool: "port", key: "macos:ports" },
|
|
83
|
-
brew: { plat: "darwin", tool: "brew", key: "macos:brew" },
|
|
84
|
-
apt: { plat: "linux", tool: "apt", key: "linux:apt" },
|
|
85
|
-
apk: { plat: "linux", tool: "apk", key: "linux:apk" }
|
|
86
|
-
};
|
|
87
|
-
const entry = pm[override];
|
|
91
|
+
const entry = packageManagers.find((pm) => pm.name === override);
|
|
88
92
|
if (entry === undefined)
|
|
89
93
|
return fatal(`unknown CLAUDEX_PKG value "${override}" ` +
|
|
90
|
-
`(allowed: ${
|
|
94
|
+
`(allowed: ${packageManagers.map((pm) => pm.name).join(", ")})`);
|
|
91
95
|
if (process.platform !== entry.plat)
|
|
92
96
|
return fatal(`CLAUDEX_PKG="${override}" is not valid on platform "${process.platform}"`);
|
|
93
|
-
if (
|
|
97
|
+
if (findTool(entry.tool) === null)
|
|
94
98
|
return fatal(`CLAUDEX_PKG="${override}" requested but tool "${entry.tool}" not found in $PATH`);
|
|
95
99
|
return entry.key;
|
|
96
100
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return "windows:choco";
|
|
101
|
-
else if (process.platform === "darwin" && has("port"))
|
|
102
|
-
return "macos:ports";
|
|
103
|
-
else if (process.platform === "darwin" && has("brew"))
|
|
104
|
-
return "macos:brew";
|
|
105
|
-
else if (process.platform === "linux" && has("apt"))
|
|
106
|
-
return "linux:apt";
|
|
107
|
-
else if (process.platform === "linux" && has("apk"))
|
|
108
|
-
return "linux:apk";
|
|
109
|
-
else
|
|
101
|
+
/* detect the first available package manager of the current platform */
|
|
102
|
+
const entry = packageManagers.find((pm) => pm.plat === process.platform && findTool(pm.tool) !== null);
|
|
103
|
+
if (entry === undefined)
|
|
110
104
|
return fatal(`unsupported platform "${process.platform}" or no known package manager found`);
|
|
105
|
+
return entry.key;
|
|
106
|
+
};
|
|
107
|
+
/* helper for detecting the installation prefixes of the macOS package
|
|
108
|
+
managers, derived from the location of their own driver programs
|
|
109
|
+
(MacPorts: <prefix>/bin/port, Homebrew: <prefix>/bin/brew).
|
|
110
|
+
The result is cached after the first call. */
|
|
111
|
+
let macosPrefixesCached = null;
|
|
112
|
+
const macosPrefixes = () => {
|
|
113
|
+
if (macosPrefixesCached !== null)
|
|
114
|
+
return macosPrefixesCached;
|
|
115
|
+
macosPrefixesCached = [];
|
|
116
|
+
for (const pm of packageManagers.filter((pm) => pm.plat === "darwin")) {
|
|
117
|
+
const location = findTool(pm.tool);
|
|
118
|
+
if (location !== null)
|
|
119
|
+
macosPrefixesCached.push({ key: pm.key, prefix: path.dirname(path.dirname(location)) });
|
|
120
|
+
}
|
|
121
|
+
return macosPrefixesCached;
|
|
122
|
+
};
|
|
123
|
+
/* helper for detecting the package manager which provides an already
|
|
124
|
+
installed tool. On macOS, MacPorts and Homebrew can coexist and each
|
|
125
|
+
tool can originate from either of them, so the responsible manager is
|
|
126
|
+
determined by the installation prefix the tool resides in. On all
|
|
127
|
+
other platforms the single detected package manager applies. A "null"
|
|
128
|
+
result means the tool is not under control of a package manager. */
|
|
129
|
+
const detectPlatformForTool = (tool) => {
|
|
130
|
+
if (process.platform !== "darwin" || (process.env.CLAUDEX_PKG ?? "") !== "")
|
|
131
|
+
return detectPlatform();
|
|
132
|
+
const location = findTool(tool);
|
|
133
|
+
if (location === null)
|
|
134
|
+
return detectPlatform();
|
|
135
|
+
let target = location;
|
|
136
|
+
try {
|
|
137
|
+
target = fs.realpathSync(location);
|
|
138
|
+
}
|
|
139
|
+
catch (_e) {
|
|
140
|
+
/* intentionally ignored */
|
|
141
|
+
}
|
|
142
|
+
const below = (p, prefix) => p === prefix || p.startsWith(`${prefix}${path.sep}`);
|
|
143
|
+
for (const entry of macosPrefixes())
|
|
144
|
+
if (below(location, entry.prefix) || below(target, entry.prefix))
|
|
145
|
+
return entry.key;
|
|
146
|
+
/* the tool found in $PATH is none of the managed ones (it can be a
|
|
147
|
+
manually installed program or a wrapper shadowing the managed one),
|
|
148
|
+
so still check whether a package manager provides it, too */
|
|
149
|
+
for (const entry of macosPrefixes())
|
|
150
|
+
if (fs.existsSync(path.join(entry.prefix, "bin", tool)))
|
|
151
|
+
return entry.key;
|
|
152
|
+
return null;
|
|
111
153
|
};
|
|
112
154
|
/* helper to spawn a child synchronously inheriting stdio, then exit
|
|
113
155
|
with its code (the closest equivalent of Bash "exec ...") */
|
|
@@ -121,8 +163,8 @@ const execInherit = (file, args, opts = {}) => {
|
|
|
121
163
|
process.exit(r.exitCode ?? 0);
|
|
122
164
|
};
|
|
123
165
|
/* helper to execute a platform-specific command */
|
|
124
|
-
const executeCommand = (config) => {
|
|
125
|
-
const platform = detectPlatform();
|
|
166
|
+
const executeCommand = (config, platformOverride) => {
|
|
167
|
+
const platform = platformOverride ?? detectPlatform();
|
|
126
168
|
const osName = platform.split(":")[0];
|
|
127
169
|
const command = config[platform] ?? config[`${osName}:*`] ?? config["*"];
|
|
128
170
|
if (command === undefined)
|
|
@@ -137,6 +179,16 @@ const executeCommand = (config) => {
|
|
|
137
179
|
});
|
|
138
180
|
return result.exitCode;
|
|
139
181
|
};
|
|
182
|
+
/* helper to update an externally managed tool with exactly the package
|
|
183
|
+
manager which actually provides it, instead of just the preferred one */
|
|
184
|
+
const updateTool = (tool, config) => {
|
|
185
|
+
const platform = detectPlatformForTool(tool);
|
|
186
|
+
if (platform === null) {
|
|
187
|
+
info(`skip update of "${tool}" (not provided by MacPorts or Homebrew)`);
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
return executeCommand(config, platform);
|
|
191
|
+
};
|
|
140
192
|
/* helper to determine whether a global NPM installation requires sudo(8),
|
|
141
193
|
i.e., whether the target directories of the NPM global prefix are not
|
|
142
194
|
writable by us. The result is cached after the first call. */
|
|
@@ -328,6 +380,10 @@ const actionInstall = async (capsula) => {
|
|
|
328
380
|
"macos:ports": "sudo port -N install tmux",
|
|
329
381
|
"macos:brew": "brew install tmux",
|
|
330
382
|
"linux:apt": "sudo apt install -y tmux",
|
|
383
|
+
"linux:dnf": "sudo dnf install -y tmux",
|
|
384
|
+
"linux:yum": "sudo yum install -y tmux",
|
|
385
|
+
"linux:zypper": "sudo zypper --non-interactive install tmux",
|
|
386
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm tmux",
|
|
331
387
|
"linux:apk": "sudo apk add --no-interactive tmux"
|
|
332
388
|
}
|
|
333
389
|
});
|
|
@@ -341,6 +397,10 @@ const actionInstall = async (capsula) => {
|
|
|
341
397
|
"macos:ports": "sudo port -N install lazygit",
|
|
342
398
|
"macos:brew": "brew install lazygit",
|
|
343
399
|
"linux:apt": "sudo apt install -y lazygit",
|
|
400
|
+
"linux:dnf": "sudo dnf install -y lazygit",
|
|
401
|
+
"linux:yum": "sudo yum install -y lazygit",
|
|
402
|
+
"linux:zypper": "sudo zypper --non-interactive install lazygit",
|
|
403
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm lazygit",
|
|
344
404
|
"linux:apk": "sudo apk add --no-interactive lazygit"
|
|
345
405
|
}
|
|
346
406
|
});
|
|
@@ -354,6 +414,10 @@ const actionInstall = async (capsula) => {
|
|
|
354
414
|
"macos:ports": "sudo port -N install git",
|
|
355
415
|
"macos:brew": "brew install git",
|
|
356
416
|
"linux:apt": "sudo apt install -y git",
|
|
417
|
+
"linux:dnf": "sudo dnf install -y git",
|
|
418
|
+
"linux:yum": "sudo yum install -y git",
|
|
419
|
+
"linux:zypper": "sudo zypper --non-interactive install git",
|
|
420
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm git",
|
|
357
421
|
"linux:apk": "sudo apk add --no-interactive git"
|
|
358
422
|
}
|
|
359
423
|
});
|
|
@@ -366,6 +430,10 @@ const actionInstall = async (capsula) => {
|
|
|
366
430
|
"macos:ports": "sudo port -N install nodejs26 npm11",
|
|
367
431
|
"macos:brew": "brew install node",
|
|
368
432
|
"linux:apt": "curl -fsSL https://deb.nodesource.com/setup_26.x | sudo -E bash - && sudo apt install -y nodejs",
|
|
433
|
+
"linux:dnf": "sudo dnf install -y nodejs npm",
|
|
434
|
+
"linux:yum": "sudo yum install -y nodejs npm",
|
|
435
|
+
"linux:zypper": "sudo zypper --non-interactive install nodejs npm",
|
|
436
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm nodejs npm",
|
|
369
437
|
"linux:apk": "sudo apk add --no-interactive nodejs npm"
|
|
370
438
|
}
|
|
371
439
|
});
|
|
@@ -454,39 +522,55 @@ const actionUpdate = async (capsula) => {
|
|
|
454
522
|
}
|
|
455
523
|
else {
|
|
456
524
|
info("update Tmux");
|
|
457
|
-
|
|
525
|
+
updateTool("tmux", {
|
|
458
526
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e psmux",
|
|
459
527
|
"windows:choco": "choco upgrade -y --accept-license --no-progress psmux",
|
|
460
528
|
"macos:ports": "sudo port -N upgrade tmux",
|
|
461
529
|
"macos:brew": "brew upgrade tmux",
|
|
462
530
|
"linux:apt": "sudo apt install --only-upgrade -y tmux",
|
|
531
|
+
"linux:dnf": "sudo dnf upgrade -y tmux",
|
|
532
|
+
"linux:yum": "sudo yum update -y tmux",
|
|
533
|
+
"linux:zypper": "sudo zypper --non-interactive update tmux",
|
|
534
|
+
"linux:pacman": "sudo pacman -S --noconfirm tmux",
|
|
463
535
|
"linux:apk": "sudo apk upgrade --no-interactive tmux"
|
|
464
536
|
});
|
|
465
537
|
info("update LazyGit");
|
|
466
|
-
|
|
538
|
+
updateTool("lazygit", {
|
|
467
539
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e --id JesseDuffield.lazygit",
|
|
468
540
|
"windows:choco": "choco upgrade -y --accept-license --no-progress lazygit",
|
|
469
541
|
"macos:ports": "sudo port -N upgrade lazygit",
|
|
470
542
|
"macos:brew": "brew upgrade lazygit",
|
|
471
543
|
"linux:apt": "sudo apt install --only-upgrade -y lazygit",
|
|
544
|
+
"linux:dnf": "sudo dnf upgrade -y lazygit",
|
|
545
|
+
"linux:yum": "sudo yum update -y lazygit",
|
|
546
|
+
"linux:zypper": "sudo zypper --non-interactive update lazygit",
|
|
547
|
+
"linux:pacman": "sudo pacman -S --noconfirm lazygit",
|
|
472
548
|
"linux:apk": "sudo apk upgrade --no-interactive lazygit"
|
|
473
549
|
});
|
|
474
550
|
info("update Git");
|
|
475
|
-
|
|
551
|
+
updateTool("git", {
|
|
476
552
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e --id Git.Git --source winget",
|
|
477
553
|
"windows:choco": "choco upgrade -y --accept-license --no-progress git",
|
|
478
554
|
"macos:ports": "sudo port -N upgrade git",
|
|
479
555
|
"macos:brew": "brew upgrade git",
|
|
480
556
|
"linux:apt": "sudo apt install --only-upgrade -y git",
|
|
557
|
+
"linux:dnf": "sudo dnf upgrade -y git",
|
|
558
|
+
"linux:yum": "sudo yum update -y git",
|
|
559
|
+
"linux:zypper": "sudo zypper --non-interactive update git",
|
|
560
|
+
"linux:pacman": "sudo pacman -S --noconfirm git",
|
|
481
561
|
"linux:apk": "sudo apk upgrade --no-interactive git"
|
|
482
562
|
});
|
|
483
563
|
info("update Node.js");
|
|
484
|
-
|
|
564
|
+
updateTool("node", {
|
|
485
565
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e --id OpenJS.NodeJS.LTS",
|
|
486
566
|
"windows:choco": "choco upgrade -y --accept-license --no-progress nodejs",
|
|
487
567
|
"macos:ports": "sudo port -N upgrade nodejs26 npm11",
|
|
488
568
|
"macos:brew": "brew upgrade node",
|
|
489
569
|
"linux:apt": "sudo apt install --only-upgrade -y nodejs",
|
|
570
|
+
"linux:dnf": "sudo dnf upgrade -y nodejs npm",
|
|
571
|
+
"linux:yum": "sudo yum update -y nodejs npm",
|
|
572
|
+
"linux:zypper": "sudo zypper --non-interactive update nodejs npm",
|
|
573
|
+
"linux:pacman": "sudo pacman -S --noconfirm nodejs npm",
|
|
490
574
|
"linux:apk": "sudo apk upgrade --no-interactive nodejs npm"
|
|
491
575
|
});
|
|
492
576
|
info("update ANSI-Recolor");
|
package/claudex.ts
CHANGED
|
@@ -79,48 +79,95 @@ const isPsmux = (): boolean => {
|
|
|
79
79
|
return isPsmuxCached
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/* the known package managers, in the order of their detection preference
|
|
83
|
+
(on Fedora "yum" is just an alias for "dnf", hence "dnf" comes first) */
|
|
84
|
+
const packageManagers: { name: string, plat: string, tool: string, key: string }[] = [
|
|
85
|
+
{ name: "winget", plat: "win32", tool: "winget", key: "windows:winget" },
|
|
86
|
+
{ name: "choco", plat: "win32", tool: "choco", key: "windows:choco" },
|
|
87
|
+
{ name: "ports", plat: "darwin", tool: "port", key: "macos:ports" },
|
|
88
|
+
{ name: "brew", plat: "darwin", tool: "brew", key: "macos:brew" },
|
|
89
|
+
{ name: "apt", plat: "linux", tool: "apt", key: "linux:apt" },
|
|
90
|
+
{ name: "dnf", plat: "linux", tool: "dnf", key: "linux:dnf" },
|
|
91
|
+
{ name: "yum", plat: "linux", tool: "yum", key: "linux:yum" },
|
|
92
|
+
{ name: "zypper", plat: "linux", tool: "zypper", key: "linux:zypper" },
|
|
93
|
+
{ name: "pacman", plat: "linux", tool: "pacman", key: "linux:pacman" },
|
|
94
|
+
{ name: "apk", plat: "linux", tool: "apk", key: "linux:apk" }
|
|
95
|
+
]
|
|
96
|
+
|
|
82
97
|
/* helper for detecting the platform and package manager combination */
|
|
83
98
|
const detectPlatform = (): string => {
|
|
84
|
-
/* helper function for finding a tool in PATH */
|
|
85
|
-
const has = (tool: string): boolean =>
|
|
86
|
-
findTool(tool) !== null
|
|
87
|
-
|
|
88
99
|
/* honor explicit override via CLAUDEX_PKG (e.g. "brew", "ports", "apt", ...)
|
|
89
100
|
to disambiguate hosts where multiple package managers are installed */
|
|
90
101
|
const override = process.env.CLAUDEX_PKG ?? ""
|
|
91
102
|
if (override !== "") {
|
|
92
|
-
const
|
|
93
|
-
winget: { plat: "win32", tool: "winget", key: "windows:winget" },
|
|
94
|
-
choco: { plat: "win32", tool: "choco", key: "windows:choco" },
|
|
95
|
-
ports: { plat: "darwin", tool: "port", key: "macos:ports" },
|
|
96
|
-
brew: { plat: "darwin", tool: "brew", key: "macos:brew" },
|
|
97
|
-
apt: { plat: "linux", tool: "apt", key: "linux:apt" },
|
|
98
|
-
apk: { plat: "linux", tool: "apk", key: "linux:apk" }
|
|
99
|
-
}
|
|
100
|
-
const entry = pm[override]
|
|
103
|
+
const entry = packageManagers.find((pm) => pm.name === override)
|
|
101
104
|
if (entry === undefined)
|
|
102
105
|
return fatal(`unknown CLAUDEX_PKG value "${override}" ` +
|
|
103
|
-
`(allowed: ${
|
|
106
|
+
`(allowed: ${packageManagers.map((pm) => pm.name).join(", ")})`)
|
|
104
107
|
if (process.platform !== entry.plat)
|
|
105
108
|
return fatal(`CLAUDEX_PKG="${override}" is not valid on platform "${process.platform}"`)
|
|
106
|
-
if (
|
|
109
|
+
if (findTool(entry.tool) === null)
|
|
107
110
|
return fatal(`CLAUDEX_PKG="${override}" requested but tool "${entry.tool}" not found in $PATH`)
|
|
108
111
|
return entry.key
|
|
109
112
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return "macos:ports"
|
|
116
|
-
else if (process.platform === "darwin" && has("brew"))
|
|
117
|
-
return "macos:brew"
|
|
118
|
-
else if (process.platform === "linux" && has("apt"))
|
|
119
|
-
return "linux:apt"
|
|
120
|
-
else if (process.platform === "linux" && has("apk"))
|
|
121
|
-
return "linux:apk"
|
|
122
|
-
else
|
|
113
|
+
|
|
114
|
+
/* detect the first available package manager of the current platform */
|
|
115
|
+
const entry = packageManagers.find((pm) =>
|
|
116
|
+
pm.plat === process.platform && findTool(pm.tool) !== null)
|
|
117
|
+
if (entry === undefined)
|
|
123
118
|
return fatal(`unsupported platform "${process.platform}" or no known package manager found`)
|
|
119
|
+
return entry.key
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* helper for detecting the installation prefixes of the macOS package
|
|
123
|
+
managers, derived from the location of their own driver programs
|
|
124
|
+
(MacPorts: <prefix>/bin/port, Homebrew: <prefix>/bin/brew).
|
|
125
|
+
The result is cached after the first call. */
|
|
126
|
+
let macosPrefixesCached: { key: string, prefix: string }[] | null = null
|
|
127
|
+
const macosPrefixes = (): { key: string, prefix: string }[] => {
|
|
128
|
+
if (macosPrefixesCached !== null)
|
|
129
|
+
return macosPrefixesCached
|
|
130
|
+
macosPrefixesCached = []
|
|
131
|
+
for (const pm of packageManagers.filter((pm) => pm.plat === "darwin")) {
|
|
132
|
+
const location = findTool(pm.tool)
|
|
133
|
+
if (location !== null)
|
|
134
|
+
macosPrefixesCached.push({ key: pm.key, prefix: path.dirname(path.dirname(location)) })
|
|
135
|
+
}
|
|
136
|
+
return macosPrefixesCached
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* helper for detecting the package manager which provides an already
|
|
140
|
+
installed tool. On macOS, MacPorts and Homebrew can coexist and each
|
|
141
|
+
tool can originate from either of them, so the responsible manager is
|
|
142
|
+
determined by the installation prefix the tool resides in. On all
|
|
143
|
+
other platforms the single detected package manager applies. A "null"
|
|
144
|
+
result means the tool is not under control of a package manager. */
|
|
145
|
+
const detectPlatformForTool = (tool: string): string | null => {
|
|
146
|
+
if (process.platform !== "darwin" || (process.env.CLAUDEX_PKG ?? "") !== "")
|
|
147
|
+
return detectPlatform()
|
|
148
|
+
const location = findTool(tool)
|
|
149
|
+
if (location === null)
|
|
150
|
+
return detectPlatform()
|
|
151
|
+
let target = location
|
|
152
|
+
try {
|
|
153
|
+
target = fs.realpathSync(location)
|
|
154
|
+
}
|
|
155
|
+
catch (_e) {
|
|
156
|
+
/* intentionally ignored */
|
|
157
|
+
}
|
|
158
|
+
const below = (p: string, prefix: string): boolean =>
|
|
159
|
+
p === prefix || p.startsWith(`${prefix}${path.sep}`)
|
|
160
|
+
for (const entry of macosPrefixes())
|
|
161
|
+
if (below(location, entry.prefix) || below(target, entry.prefix))
|
|
162
|
+
return entry.key
|
|
163
|
+
|
|
164
|
+
/* the tool found in $PATH is none of the managed ones (it can be a
|
|
165
|
+
manually installed program or a wrapper shadowing the managed one),
|
|
166
|
+
so still check whether a package manager provides it, too */
|
|
167
|
+
for (const entry of macosPrefixes())
|
|
168
|
+
if (fs.existsSync(path.join(entry.prefix, "bin", tool)))
|
|
169
|
+
return entry.key
|
|
170
|
+
return null
|
|
124
171
|
}
|
|
125
172
|
|
|
126
173
|
/* helper to spawn a child synchronously inheriting stdio, then exit
|
|
@@ -136,8 +183,8 @@ const execInherit = (file: string, args: string[], opts: { env?: Env } = {}): ne
|
|
|
136
183
|
}
|
|
137
184
|
|
|
138
185
|
/* helper to execute a platform-specific command */
|
|
139
|
-
const executeCommand = (config: { [ platform: string ]: string[] | string }) => {
|
|
140
|
-
const platform = detectPlatform()
|
|
186
|
+
const executeCommand = (config: { [ platform: string ]: string[] | string }, platformOverride?: string) => {
|
|
187
|
+
const platform = platformOverride ?? detectPlatform()
|
|
141
188
|
const osName = platform.split(":")[0]
|
|
142
189
|
const command = config[platform] ?? config[`${osName}:*`] ?? config["*"]
|
|
143
190
|
if (command === undefined)
|
|
@@ -153,6 +200,17 @@ const executeCommand = (config: { [ platform: string ]: string[] | string }) =>
|
|
|
153
200
|
return result.exitCode
|
|
154
201
|
}
|
|
155
202
|
|
|
203
|
+
/* helper to update an externally managed tool with exactly the package
|
|
204
|
+
manager which actually provides it, instead of just the preferred one */
|
|
205
|
+
const updateTool = (tool: string, config: { [ platform: string ]: string[] | string }) => {
|
|
206
|
+
const platform = detectPlatformForTool(tool)
|
|
207
|
+
if (platform === null) {
|
|
208
|
+
info(`skip update of "${tool}" (not provided by MacPorts or Homebrew)`)
|
|
209
|
+
return 0
|
|
210
|
+
}
|
|
211
|
+
return executeCommand(config, platform)
|
|
212
|
+
}
|
|
213
|
+
|
|
156
214
|
/* helper to determine whether a global NPM installation requires sudo(8),
|
|
157
215
|
i.e., whether the target directories of the NPM global prefix are not
|
|
158
216
|
writable by us. The result is cached after the first call. */
|
|
@@ -379,6 +437,10 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
379
437
|
"macos:ports": "sudo port -N install tmux",
|
|
380
438
|
"macos:brew": "brew install tmux",
|
|
381
439
|
"linux:apt": "sudo apt install -y tmux",
|
|
440
|
+
"linux:dnf": "sudo dnf install -y tmux",
|
|
441
|
+
"linux:yum": "sudo yum install -y tmux",
|
|
442
|
+
"linux:zypper": "sudo zypper --non-interactive install tmux",
|
|
443
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm tmux",
|
|
382
444
|
"linux:apk": "sudo apk add --no-interactive tmux"
|
|
383
445
|
}
|
|
384
446
|
})
|
|
@@ -393,6 +455,10 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
393
455
|
"macos:ports": "sudo port -N install lazygit",
|
|
394
456
|
"macos:brew": "brew install lazygit",
|
|
395
457
|
"linux:apt": "sudo apt install -y lazygit",
|
|
458
|
+
"linux:dnf": "sudo dnf install -y lazygit",
|
|
459
|
+
"linux:yum": "sudo yum install -y lazygit",
|
|
460
|
+
"linux:zypper": "sudo zypper --non-interactive install lazygit",
|
|
461
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm lazygit",
|
|
396
462
|
"linux:apk": "sudo apk add --no-interactive lazygit"
|
|
397
463
|
}
|
|
398
464
|
})
|
|
@@ -407,6 +473,10 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
407
473
|
"macos:ports": "sudo port -N install git",
|
|
408
474
|
"macos:brew": "brew install git",
|
|
409
475
|
"linux:apt": "sudo apt install -y git",
|
|
476
|
+
"linux:dnf": "sudo dnf install -y git",
|
|
477
|
+
"linux:yum": "sudo yum install -y git",
|
|
478
|
+
"linux:zypper": "sudo zypper --non-interactive install git",
|
|
479
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm git",
|
|
410
480
|
"linux:apk": "sudo apk add --no-interactive git"
|
|
411
481
|
}
|
|
412
482
|
})
|
|
@@ -420,6 +490,10 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
|
|
|
420
490
|
"macos:ports": "sudo port -N install nodejs26 npm11",
|
|
421
491
|
"macos:brew": "brew install node",
|
|
422
492
|
"linux:apt": "curl -fsSL https://deb.nodesource.com/setup_26.x | sudo -E bash - && sudo apt install -y nodejs",
|
|
493
|
+
"linux:dnf": "sudo dnf install -y nodejs npm",
|
|
494
|
+
"linux:yum": "sudo yum install -y nodejs npm",
|
|
495
|
+
"linux:zypper": "sudo zypper --non-interactive install nodejs npm",
|
|
496
|
+
"linux:pacman": "sudo pacman -S --needed --noconfirm nodejs npm",
|
|
423
497
|
"linux:apk": "sudo apk add --no-interactive nodejs npm"
|
|
424
498
|
}
|
|
425
499
|
})
|
|
@@ -525,42 +599,58 @@ const actionUpdate = async (capsula: boolean): Promise<void> => {
|
|
|
525
599
|
}
|
|
526
600
|
else {
|
|
527
601
|
info("update Tmux")
|
|
528
|
-
|
|
602
|
+
updateTool("tmux", {
|
|
529
603
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e psmux",
|
|
530
604
|
"windows:choco": "choco upgrade -y --accept-license --no-progress psmux",
|
|
531
605
|
"macos:ports": "sudo port -N upgrade tmux",
|
|
532
606
|
"macos:brew": "brew upgrade tmux",
|
|
533
607
|
"linux:apt": "sudo apt install --only-upgrade -y tmux",
|
|
608
|
+
"linux:dnf": "sudo dnf upgrade -y tmux",
|
|
609
|
+
"linux:yum": "sudo yum update -y tmux",
|
|
610
|
+
"linux:zypper": "sudo zypper --non-interactive update tmux",
|
|
611
|
+
"linux:pacman": "sudo pacman -S --noconfirm tmux",
|
|
534
612
|
"linux:apk": "sudo apk upgrade --no-interactive tmux"
|
|
535
613
|
})
|
|
536
614
|
|
|
537
615
|
info("update LazyGit")
|
|
538
|
-
|
|
616
|
+
updateTool("lazygit", {
|
|
539
617
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e --id JesseDuffield.lazygit",
|
|
540
618
|
"windows:choco": "choco upgrade -y --accept-license --no-progress lazygit",
|
|
541
619
|
"macos:ports": "sudo port -N upgrade lazygit",
|
|
542
620
|
"macos:brew": "brew upgrade lazygit",
|
|
543
621
|
"linux:apt": "sudo apt install --only-upgrade -y lazygit",
|
|
622
|
+
"linux:dnf": "sudo dnf upgrade -y lazygit",
|
|
623
|
+
"linux:yum": "sudo yum update -y lazygit",
|
|
624
|
+
"linux:zypper": "sudo zypper --non-interactive update lazygit",
|
|
625
|
+
"linux:pacman": "sudo pacman -S --noconfirm lazygit",
|
|
544
626
|
"linux:apk": "sudo apk upgrade --no-interactive lazygit"
|
|
545
627
|
})
|
|
546
628
|
|
|
547
629
|
info("update Git")
|
|
548
|
-
|
|
630
|
+
updateTool("git", {
|
|
549
631
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e --id Git.Git --source winget",
|
|
550
632
|
"windows:choco": "choco upgrade -y --accept-license --no-progress git",
|
|
551
633
|
"macos:ports": "sudo port -N upgrade git",
|
|
552
634
|
"macos:brew": "brew upgrade git",
|
|
553
635
|
"linux:apt": "sudo apt install --only-upgrade -y git",
|
|
636
|
+
"linux:dnf": "sudo dnf upgrade -y git",
|
|
637
|
+
"linux:yum": "sudo yum update -y git",
|
|
638
|
+
"linux:zypper": "sudo zypper --non-interactive update git",
|
|
639
|
+
"linux:pacman": "sudo pacman -S --noconfirm git",
|
|
554
640
|
"linux:apk": "sudo apk upgrade --no-interactive git"
|
|
555
641
|
})
|
|
556
642
|
|
|
557
643
|
info("update Node.js")
|
|
558
|
-
|
|
644
|
+
updateTool("node", {
|
|
559
645
|
"windows:winget": "winget upgrade --accept-package-agreements --accept-source-agreements --silent -e --id OpenJS.NodeJS.LTS",
|
|
560
646
|
"windows:choco": "choco upgrade -y --accept-license --no-progress nodejs",
|
|
561
647
|
"macos:ports": "sudo port -N upgrade nodejs26 npm11",
|
|
562
648
|
"macos:brew": "brew upgrade node",
|
|
563
649
|
"linux:apt": "sudo apt install --only-upgrade -y nodejs",
|
|
650
|
+
"linux:dnf": "sudo dnf upgrade -y nodejs npm",
|
|
651
|
+
"linux:yum": "sudo yum update -y nodejs npm",
|
|
652
|
+
"linux:zypper": "sudo zypper --non-interactive update nodejs npm",
|
|
653
|
+
"linux:pacman": "sudo pacman -S --noconfirm nodejs npm",
|
|
564
654
|
"linux:apk": "sudo apk upgrade --no-interactive nodejs npm"
|
|
565
655
|
})
|
|
566
656
|
|
package/package.json
CHANGED
package/stx.conf
CHANGED
|
@@ -10,7 +10,7 @@ build
|
|
|
10
10
|
tsc --project tsconfig.json
|
|
11
11
|
|
|
12
12
|
# publish to github.com and npmjs.com
|
|
13
|
-
publish [hostname=en4
|
|
13
|
+
publish [hostname={en4.*,MSGMAC-M2M79300K6}]
|
|
14
14
|
increment="patch"; \
|
|
15
15
|
case "$*" in -i* ) increment=`echo "$*" | sed -e 's;^-i;;'` ;; esac; \
|
|
16
16
|
kickout "$increment" && \
|