@getmonoceros/workbench 1.6.6 → 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 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";
@@ -2255,6 +2303,7 @@ function providerSetupHint(host, provider) {
2255
2303
  const install = installCommandForOS({
2256
2304
  brew: "brew install gh",
2257
2305
  winget: "winget install --id GitHub.cli",
2306
+ linuxBrew: "brew install gh",
2258
2307
  linuxDocsUrl: "https://github.com/cli/cli#installation"
2259
2308
  });
2260
2309
  return {
@@ -2920,7 +2969,7 @@ function warnOnDeprecatedFeatureRefs(containerFeatures, globalConfig, logger) {
2920
2969
  }
2921
2970
 
2922
2971
  // src/version.ts
2923
- var CLI_VERSION = true ? "1.6.6" : "dev";
2972
+ var CLI_VERSION = true ? "1.6.8" : "dev";
2924
2973
 
2925
2974
  // src/commands/_dispatch.ts
2926
2975
  import { consola as consola11 } from "consola";
@@ -4717,6 +4766,7 @@ var main = defineCommand25({
4717
4766
  });
4718
4767
 
4719
4768
  // src/bin.ts
4769
+ bootstrapDockerGroup();
4720
4770
  consumeInnerArgsFromProcessArgv();
4721
4771
  async function entry() {
4722
4772
  if (await maybeRenderHelp(process.argv.slice(2), main)) {