@getmonoceros/workbench 1.6.7 → 1.6.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.
- package/dist/bin.js +50 -1
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
3
3
|
// src/bin.ts
|
|
4
4
|
import { runMain } from "citty";
|
|
5
5
|
|
|
6
|
+
// src/devcontainer/docker-group-bootstrap.ts
|
|
7
|
+
import { spawnSync } from "child_process";
|
|
8
|
+
import { userInfo } from "os";
|
|
9
|
+
var REEXEC_MARKER = "MONOCEROS_DOCKER_GROUP_REEXEC";
|
|
10
|
+
function bootstrapDockerGroup(opts = {}) {
|
|
11
|
+
const platform = opts.platform ?? process.platform;
|
|
12
|
+
if (platform !== "linux") return;
|
|
13
|
+
const marker = opts.marker ?? process.env[REEXEC_MARKER];
|
|
14
|
+
if (marker === "1") return;
|
|
15
|
+
const probe = opts.runProbe ?? defaultProbe;
|
|
16
|
+
if (probe("docker", ["--version"]) !== 0) return;
|
|
17
|
+
if (probe("docker", ["info"]) === 0) return;
|
|
18
|
+
const username = opts.username ?? userInfo().username;
|
|
19
|
+
if (!isInDockerGroupViaEtcGroup(username, probe)) return;
|
|
20
|
+
const reexec = opts.reexec ?? defaultReexec;
|
|
21
|
+
const exitCode = reexec(process.argv);
|
|
22
|
+
process.exit(exitCode);
|
|
23
|
+
}
|
|
24
|
+
function isInDockerGroupViaEtcGroup(username, probe) {
|
|
25
|
+
const result = spawnSync("getent", ["group", "docker"], {
|
|
26
|
+
encoding: "utf8",
|
|
27
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
28
|
+
});
|
|
29
|
+
void probe;
|
|
30
|
+
if (result.status !== 0) return false;
|
|
31
|
+
const fields = result.stdout.split(":");
|
|
32
|
+
if (fields.length < 4) return false;
|
|
33
|
+
const members = (fields[3] ?? "").trim().split(",").map((m) => m.trim()).filter(Boolean);
|
|
34
|
+
return members.includes(username);
|
|
35
|
+
}
|
|
36
|
+
function defaultProbe(cmd, args) {
|
|
37
|
+
const result = spawnSync(cmd, [...args], { stdio: "ignore" });
|
|
38
|
+
return result.status ?? 1;
|
|
39
|
+
}
|
|
40
|
+
function defaultReexec(argv) {
|
|
41
|
+
const quoted = argv.map(shellQuote).join(" ");
|
|
42
|
+
const env = { ...process.env, [REEXEC_MARKER]: "1" };
|
|
43
|
+
const result = spawnSync("sg", ["docker", "-c", quoted], {
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
env
|
|
46
|
+
});
|
|
47
|
+
return result.status ?? 1;
|
|
48
|
+
}
|
|
49
|
+
function shellQuote(arg) {
|
|
50
|
+
if (/^[\w./@:=,+-]+$/.test(arg)) return arg;
|
|
51
|
+
return `'${arg.replace(/'/g, "'\\''")}'`;
|
|
52
|
+
}
|
|
53
|
+
|
|
6
54
|
// src/help.ts
|
|
7
55
|
var ANSI_BOLD = "\x1B[1m";
|
|
8
56
|
var ANSI_UNDERLINE = "\x1B[4m";
|
|
@@ -2921,7 +2969,7 @@ function warnOnDeprecatedFeatureRefs(containerFeatures, globalConfig, logger) {
|
|
|
2921
2969
|
}
|
|
2922
2970
|
|
|
2923
2971
|
// src/version.ts
|
|
2924
|
-
var CLI_VERSION = true ? "1.6.
|
|
2972
|
+
var CLI_VERSION = true ? "1.6.8" : "dev";
|
|
2925
2973
|
|
|
2926
2974
|
// src/commands/_dispatch.ts
|
|
2927
2975
|
import { consola as consola11 } from "consola";
|
|
@@ -4718,6 +4766,7 @@ var main = defineCommand25({
|
|
|
4718
4766
|
});
|
|
4719
4767
|
|
|
4720
4768
|
// src/bin.ts
|
|
4769
|
+
bootstrapDockerGroup();
|
|
4721
4770
|
consumeInnerArgsFromProcessArgv();
|
|
4722
4771
|
async function entry() {
|
|
4723
4772
|
if (await maybeRenderHelp(process.argv.slice(2), main)) {
|