yolobox 0.1.1 → 0.1.3
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/index.js +56 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { defineCommand as defineCommand10, runMain } from "citty";
|
|
|
5
5
|
import { defineCommand } from "citty";
|
|
6
6
|
|
|
7
7
|
// src/lib/docker.ts
|
|
8
|
-
import { execSync, spawnSync } from "child_process";
|
|
8
|
+
import { execSync, spawn, spawnSync } from "child_process";
|
|
9
9
|
import { existsSync } from "fs";
|
|
10
10
|
import { join } from "path";
|
|
11
11
|
function isDockerRunning() {
|
|
@@ -44,6 +44,45 @@ function imageExists(imageName) {
|
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
function pullImage(imageName, onProgress) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
const proc = spawn("docker", ["pull", imageName], {
|
|
50
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
51
|
+
});
|
|
52
|
+
const layers = /* @__PURE__ */ new Map();
|
|
53
|
+
let totalLayers = 0;
|
|
54
|
+
let completedLayers = 0;
|
|
55
|
+
const handleOutput = (data) => {
|
|
56
|
+
const lines = data.toString().split(/\r?\n/);
|
|
57
|
+
for (const line of lines) {
|
|
58
|
+
const trimmed = line.trim();
|
|
59
|
+
if (!trimmed) continue;
|
|
60
|
+
const match = trimmed.match(/^([a-f0-9]{12}): (.+)$/);
|
|
61
|
+
if (match) {
|
|
62
|
+
const [, layerId, status] = match;
|
|
63
|
+
const prevStatus = layers.get(layerId);
|
|
64
|
+
layers.set(layerId, status);
|
|
65
|
+
if (!prevStatus) {
|
|
66
|
+
totalLayers++;
|
|
67
|
+
}
|
|
68
|
+
if ((status === "Pull complete" || status === "Already exists") && prevStatus !== "Pull complete" && prevStatus !== "Already exists") {
|
|
69
|
+
completedLayers++;
|
|
70
|
+
}
|
|
71
|
+
if (onProgress && totalLayers > 0) {
|
|
72
|
+
onProgress(
|
|
73
|
+
`Pulling image (${completedLayers}/${totalLayers} layers)`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
proc.stdout?.on("data", handleOutput);
|
|
80
|
+
proc.stderr?.on("data", handleOutput);
|
|
81
|
+
proc.on("close", (code) => {
|
|
82
|
+
resolve(code === 0);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
47
86
|
function isYoloboxDevRepo(repoRoot) {
|
|
48
87
|
return existsSync(join(repoRoot, "docker", "Dockerfile"));
|
|
49
88
|
}
|
|
@@ -155,7 +194,7 @@ function killContainer(id) {
|
|
|
155
194
|
import * as p from "@clack/prompts";
|
|
156
195
|
import pc from "picocolors";
|
|
157
196
|
function intro2() {
|
|
158
|
-
p.intro(pc.bgCyan(pc.black(` yolobox v${"0.1.
|
|
197
|
+
p.intro(pc.bgCyan(pc.black(` yolobox v${"0.1.3"} `)));
|
|
159
198
|
}
|
|
160
199
|
function success(message) {
|
|
161
200
|
p.log.success(message);
|
|
@@ -1318,6 +1357,20 @@ async function setupContainer(options = {}) {
|
|
|
1318
1357
|
info("Tip: Run 'npm run docker:build' to use local builds");
|
|
1319
1358
|
}
|
|
1320
1359
|
}
|
|
1360
|
+
if (!imageExists(imageResolution.image)) {
|
|
1361
|
+
const spinner = p.spinner();
|
|
1362
|
+
spinner.start("Pulling image...");
|
|
1363
|
+
const pulled = await pullImage(
|
|
1364
|
+
imageResolution.image,
|
|
1365
|
+
(msg) => spinner.message(msg)
|
|
1366
|
+
);
|
|
1367
|
+
if (!pulled) {
|
|
1368
|
+
spinner.stop("Failed to pull image", 1);
|
|
1369
|
+
error("Failed to pull Docker image.");
|
|
1370
|
+
process.exit(1);
|
|
1371
|
+
}
|
|
1372
|
+
spinner.stop("Docker image pulled");
|
|
1373
|
+
}
|
|
1321
1374
|
const claudeOauthToken = resolveToken();
|
|
1322
1375
|
if (claudeOauthToken) {
|
|
1323
1376
|
success("Claude auth token configured");
|
|
@@ -1811,7 +1864,7 @@ var start_default = defineCommand9({
|
|
|
1811
1864
|
var main = defineCommand10({
|
|
1812
1865
|
meta: {
|
|
1813
1866
|
name: "yolobox",
|
|
1814
|
-
version: "0.1.
|
|
1867
|
+
version: "0.1.3",
|
|
1815
1868
|
description: "Run Claude Code in Docker containers. YOLO safely."
|
|
1816
1869
|
},
|
|
1817
1870
|
subCommands: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yolobox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Run Claude Code in a Docker container with --dangerously-skip-permissions. YOLO safely.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test": "vitest",
|
|
22
22
|
"docker:build": "docker build -t yolobox:local -f docker/Dockerfile docker/",
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
24
|
-
"
|
|
24
|
+
"prepare": "lefthook install"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@clack/prompts": "^0.9.1",
|