dev-prism 0.6.0 → 0.7.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.
- package/README.md +143 -286
- package/bin/dev-prism.js +65 -87
- package/dist/{chunk-7YGOMAJG.js → chunk-3CIXBEXK.js} +22 -28
- package/dist/chunk-AHC6CD7F.js +92 -0
- package/dist/chunk-FQTS57VO.js +64 -0
- package/dist/chunk-GWQPK7MZ.js +50 -0
- package/dist/chunk-HDGBJGIH.js +55 -0
- package/dist/chunk-ILICQAU7.js +60 -0
- package/dist/chunk-IWZN6P6M.js +155 -0
- package/dist/chunk-KP56QH72.js +133 -0
- package/dist/{chunk-3Q454U3I.js → chunk-NJAITOCG.js} +0 -10
- package/dist/{chunk-25WQHUYW.js → chunk-TSNFAXVQ.js} +5 -12
- package/dist/chunk-VAPRJUC7.js +67 -0
- package/dist/chunk-VL56YPMK.js +45 -0
- package/dist/commands/claude.js +1 -1
- package/dist/commands/create.d.ts +1 -5
- package/dist/commands/create.js +5 -8
- package/dist/commands/destroy.d.ts +1 -1
- package/dist/commands/destroy.js +4 -6
- package/dist/commands/env.d.ts +7 -0
- package/dist/commands/env.js +9 -0
- package/dist/commands/info.js +4 -3
- package/dist/commands/list.js +2 -3
- package/dist/commands/prune.js +2 -6
- package/dist/commands/with-env.d.ts +3 -0
- package/dist/commands/with-env.js +9 -0
- package/dist/index.d.ts +9 -14
- package/dist/index.js +57 -73
- package/dist/lib/config.d.ts +4 -11
- package/dist/lib/config.js +1 -3
- package/dist/lib/db.d.ts +26 -0
- package/dist/lib/db.js +28 -0
- package/dist/lib/env.d.ts +7 -5
- package/dist/lib/env.js +9 -9
- package/dist/lib/worktree.d.ts +1 -2
- package/dist/lib/worktree.js +1 -3
- package/package.json +9 -6
- package/dist/chunk-24OM3LGM.js +0 -35
- package/dist/chunk-35SHBLIZ.js +0 -69
- package/dist/chunk-3ATDGV4Y.js +0 -22
- package/dist/chunk-3FYEGH2G.js +0 -217
- package/dist/chunk-3MSC3CGG.js +0 -78
- package/dist/chunk-3NW2OWIU.js +0 -78
- package/dist/chunk-3TRRZEFR.js +0 -38
- package/dist/chunk-4UNCSJRM.js +0 -70
- package/dist/chunk-5KDDYO6Y.js +0 -168
- package/dist/chunk-63II3EL4.js +0 -98
- package/dist/chunk-6YMQTISJ.js +0 -84
- package/dist/chunk-76LSQIZI.js +0 -31
- package/dist/chunk-7OSTLJLO.js +0 -219
- package/dist/chunk-7YEZWM6Y.js +0 -97
- package/dist/chunk-AEVARZQ4.js +0 -203
- package/dist/chunk-AIVPJ467.js +0 -70
- package/dist/chunk-AOM6BONB.js +0 -98
- package/dist/chunk-AW2FJGXA.js +0 -38
- package/dist/chunk-BXYXWNGH.js +0 -30
- package/dist/chunk-C4WLIOBR.js +0 -67
- package/dist/chunk-CUQVGZBX.js +0 -44
- package/dist/chunk-D6QWWXZD.js +0 -49
- package/dist/chunk-DQER5GNG.js +0 -72
- package/dist/chunk-DTE5YQMI.js +0 -41
- package/dist/chunk-EXRHG5KQ.js +0 -60
- package/dist/chunk-FKTFCSU7.js +0 -78
- package/dist/chunk-GBN67HYD.js +0 -57
- package/dist/chunk-GKXXK2ZH.js +0 -203
- package/dist/chunk-GWDGC2OE.js +0 -116
- package/dist/chunk-H3L73URT.js +0 -65
- package/dist/chunk-H4HPDIY3.js +0 -95
- package/dist/chunk-HCCZKLC4.js +0 -64
- package/dist/chunk-HZBJF67X.js +0 -60
- package/dist/chunk-HZUN6NRB.js +0 -70
- package/dist/chunk-I3U6JK77.js +0 -66
- package/dist/chunk-J36LRUXM.js +0 -60
- package/dist/chunk-JHR4WADC.js +0 -200
- package/dist/chunk-JIU574KX.js +0 -41
- package/dist/chunk-JMKE3ZKI.js +0 -61
- package/dist/chunk-JZ2VPQXP.js +0 -132
- package/dist/chunk-KDYKLH6P.js +0 -40
- package/dist/chunk-KZJE62TK.js +0 -203
- package/dist/chunk-LAOWFCQL.js +0 -21
- package/dist/chunk-LDK6QMR6.js +0 -67
- package/dist/chunk-LEHA65A7.js +0 -59
- package/dist/chunk-LNIOSGC4.js +0 -78
- package/dist/chunk-LOVO4P3Y.js +0 -41
- package/dist/chunk-MRBTH5PL.js +0 -66
- package/dist/chunk-NNVP5F6I.js +0 -77
- package/dist/chunk-OL25TBYX.js +0 -67
- package/dist/chunk-OOJ6YOGS.js +0 -53
- package/dist/chunk-OPEZFBBI.js +0 -219
- package/dist/chunk-P3ETW2KK.js +0 -166
- package/dist/chunk-PJKUD2N2.js +0 -22
- package/dist/chunk-PKC2ZED2.js +0 -168
- package/dist/chunk-PS76Q3HD.js +0 -168
- package/dist/chunk-Q5DPX4WL.js +0 -219
- package/dist/chunk-QSG5CXPX.js +0 -171
- package/dist/chunk-QUMZI5KK.js +0 -98
- package/dist/chunk-RC2AUYZ7.js +0 -49
- package/dist/chunk-RQ245R7T.js +0 -67
- package/dist/chunk-SD3TON6N.js +0 -32
- package/dist/chunk-SEKH4ZV6.js +0 -60
- package/dist/chunk-SMFAL2VP.js +0 -69
- package/dist/chunk-SSQ7XBY2.js +0 -30
- package/dist/chunk-SUMJLXT7.js +0 -30
- package/dist/chunk-UHI2QJFI.js +0 -200
- package/dist/chunk-UKYQN4A3.js +0 -38
- package/dist/chunk-URGGS3XM.js +0 -95
- package/dist/chunk-VR3QWHHB.js +0 -57
- package/dist/chunk-VUNPVDSO.js +0 -74
- package/dist/chunk-VXP2SPRI.js +0 -51
- package/dist/chunk-W54CPPSK.js +0 -217
- package/dist/chunk-X2PXZRYU.js +0 -41
- package/dist/chunk-X5A6H4Q7.js +0 -70
- package/dist/chunk-X6FHBEAS.js +0 -200
- package/dist/chunk-XUWQUDLT.js +0 -67
- package/dist/chunk-Y3GR6XK7.js +0 -71
- package/dist/chunk-YSO3IDZZ.js +0 -40
- package/dist/chunk-YY5DA35Z.js +0 -40
- package/dist/chunk-Z2ISJMLW.js +0 -92
- package/dist/chunk-ZKHNUDSL.js +0 -119
- package/dist/commands/logs.d.ts +0 -8
- package/dist/commands/logs.js +0 -9
- package/dist/commands/start.d.ts +0 -7
- package/dist/commands/start.js +0 -10
- package/dist/commands/stop-all.d.ts +0 -3
- package/dist/commands/stop-all.js +0 -8
- package/dist/commands/stop.d.ts +0 -3
- package/dist/commands/stop.js +0 -8
- package/dist/lib/compose.d.ts +0 -12
- package/dist/lib/compose.js +0 -12
- package/dist/lib/config.test.d.ts +0 -1
- package/dist/lib/config.test.js +0 -32
- package/dist/lib/docker-inspect.d.ts +0 -24
- package/dist/lib/docker-inspect.js +0 -16
- package/dist/lib/docker.d.ts +0 -12
- package/dist/lib/docker.js +0 -14
- package/dist/lib/env.test.d.ts +0 -1
- package/dist/lib/env.test.js +0 -68
- package/dist/lib/ports.d.ts +0 -6
- package/dist/lib/ports.js +0 -8
- package/dist/lib/ports.test.d.ts +0 -1
- package/dist/lib/ports.test.js +0 -61
- package/dist/lib/session.d.ts +0 -16
- package/dist/lib/session.js +0 -13
- package/dist/lib/store.d.ts +0 -46
- package/dist/lib/store.js +0 -6
- package/dist/lib/store.test.d.ts +0 -1
- package/dist/lib/store.test.js +0 -205
- package/dist/lib/worktree.test.d.ts +0 -1
- package/dist/lib/worktree.test.js +0 -41
package/dist/chunk-UHI2QJFI.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
writeAppEnvFiles,
|
|
3
|
-
writeEnvFile
|
|
4
|
-
} from "./chunk-J36LRUXM.js";
|
|
5
|
-
import {
|
|
6
|
-
calculatePorts,
|
|
7
|
-
formatPortsTable
|
|
8
|
-
} from "./chunk-PJKUD2N2.js";
|
|
9
|
-
import {
|
|
10
|
-
createWorktree,
|
|
11
|
-
findNextSessionId,
|
|
12
|
-
generateDefaultBranchName,
|
|
13
|
-
removeWorktree
|
|
14
|
-
} from "./chunk-Y3GR6XK7.js";
|
|
15
|
-
import {
|
|
16
|
-
down,
|
|
17
|
-
logs,
|
|
18
|
-
up
|
|
19
|
-
} from "./chunk-GBN67HYD.js";
|
|
20
|
-
import {
|
|
21
|
-
getSessionDir,
|
|
22
|
-
getSessionsDir,
|
|
23
|
-
loadConfig
|
|
24
|
-
} from "./chunk-25WQHUYW.js";
|
|
25
|
-
import {
|
|
26
|
-
SessionStore
|
|
27
|
-
} from "./chunk-6YMQTISJ.js";
|
|
28
|
-
|
|
29
|
-
// src/commands/create.ts
|
|
30
|
-
import { existsSync, mkdirSync, copyFileSync, readFileSync, writeFileSync } from "fs";
|
|
31
|
-
import { basename, join } from "path";
|
|
32
|
-
import chalk from "chalk";
|
|
33
|
-
import { execa } from "execa";
|
|
34
|
-
function updateEnvDatabaseUrl(envPath, newDbUrl) {
|
|
35
|
-
if (!existsSync(envPath)) return;
|
|
36
|
-
let content = readFileSync(envPath, "utf-8");
|
|
37
|
-
if (content.includes("DATABASE_URL=")) {
|
|
38
|
-
content = content.replace(/^DATABASE_URL=.*/m, `DATABASE_URL=${newDbUrl}`);
|
|
39
|
-
} else {
|
|
40
|
-
content += `
|
|
41
|
-
DATABASE_URL=${newDbUrl}
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
writeFileSync(envPath, content);
|
|
45
|
-
}
|
|
46
|
-
async function createSession(projectRoot, sessionId, options) {
|
|
47
|
-
const config = await loadConfig(projectRoot);
|
|
48
|
-
const sessionsDir = getSessionsDir(config, projectRoot);
|
|
49
|
-
const store = new SessionStore();
|
|
50
|
-
try {
|
|
51
|
-
if (!sessionId) {
|
|
52
|
-
sessionId = findNextSessionId(store.getUsedSessionIds(projectRoot));
|
|
53
|
-
console.log(chalk.gray(`Auto-assigned session ID: ${sessionId}`));
|
|
54
|
-
}
|
|
55
|
-
if (!/^\d{3}$/.test(sessionId)) {
|
|
56
|
-
console.error(chalk.red("Error: Session ID must be exactly 3 digits (001-999)"));
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
const inPlace = options.inPlace ?? false;
|
|
60
|
-
const branchName = options.branch || generateDefaultBranchName(sessionId);
|
|
61
|
-
const mode = options.mode || "docker";
|
|
62
|
-
console.log(chalk.blue(`Creating session ${sessionId} (${mode} mode${inPlace ? ", in-place" : ""})...`));
|
|
63
|
-
if (!inPlace) {
|
|
64
|
-
console.log(chalk.gray(`Branch: ${branchName}`));
|
|
65
|
-
}
|
|
66
|
-
const ports = calculatePorts(config, sessionId);
|
|
67
|
-
console.log(chalk.gray("\nPorts:"));
|
|
68
|
-
console.log(chalk.gray(formatPortsTable(ports)));
|
|
69
|
-
let sessionDir;
|
|
70
|
-
if (inPlace) {
|
|
71
|
-
sessionDir = projectRoot;
|
|
72
|
-
console.log(chalk.blue("\nUsing current directory (in-place mode)..."));
|
|
73
|
-
console.log(chalk.green(` Directory: ${sessionDir}`));
|
|
74
|
-
} else {
|
|
75
|
-
if (!existsSync(sessionsDir)) {
|
|
76
|
-
mkdirSync(sessionsDir, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
sessionDir = getSessionDir(config, projectRoot, sessionId);
|
|
79
|
-
console.log(chalk.blue("\nCreating git worktree..."));
|
|
80
|
-
await createWorktree(projectRoot, sessionDir, branchName);
|
|
81
|
-
console.log(chalk.green(` Created: ${sessionDir}`));
|
|
82
|
-
const sessionDbUrl = `postgresql://postgres:postgres@localhost:${ports.POSTGRES_PORT}/postgres`;
|
|
83
|
-
const envFilesToCopy = config.envFiles ?? [];
|
|
84
|
-
for (const envFile of envFilesToCopy) {
|
|
85
|
-
const srcPath = join(projectRoot, envFile);
|
|
86
|
-
const destPath = join(sessionDir, envFile);
|
|
87
|
-
if (existsSync(srcPath)) {
|
|
88
|
-
copyFileSync(srcPath, destPath);
|
|
89
|
-
updateEnvDatabaseUrl(destPath, sessionDbUrl);
|
|
90
|
-
console.log(chalk.green(` Copied: ${envFile} (updated DATABASE_URL)`));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
console.log(chalk.blue("\nGenerating .env.session..."));
|
|
95
|
-
const projectName = config.projectName ?? basename(projectRoot);
|
|
96
|
-
const envPath = writeEnvFile(sessionDir, sessionId, ports, projectName);
|
|
97
|
-
console.log(chalk.green(` Written: ${envPath}`));
|
|
98
|
-
const appEnvFiles = writeAppEnvFiles(config, sessionDir, sessionId, ports);
|
|
99
|
-
for (const file of appEnvFiles) {
|
|
100
|
-
console.log(chalk.green(` Written: ${file}`));
|
|
101
|
-
}
|
|
102
|
-
console.log(chalk.blue("\nStarting Docker services..."));
|
|
103
|
-
let profiles;
|
|
104
|
-
if (mode === "docker") {
|
|
105
|
-
const allApps = config.apps ?? [];
|
|
106
|
-
const excludeApps = options.without ?? [];
|
|
107
|
-
profiles = allApps.filter((app) => !excludeApps.includes(app));
|
|
108
|
-
if (excludeApps.length > 0) {
|
|
109
|
-
console.log(chalk.gray(` Excluding apps: ${excludeApps.join(", ")}`));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
await up({ cwd: sessionDir, profiles });
|
|
113
|
-
console.log(chalk.blue("Waiting for services to be ready..."));
|
|
114
|
-
await new Promise((resolve) => setTimeout(resolve, 3e3));
|
|
115
|
-
if (config.setup.length > 0) {
|
|
116
|
-
console.log(chalk.blue("\nRunning setup commands..."));
|
|
117
|
-
const setupEnv = {
|
|
118
|
-
...process.env,
|
|
119
|
-
SESSION_ID: sessionId,
|
|
120
|
-
// Add DATABASE_URL for db commands
|
|
121
|
-
DATABASE_URL: `postgresql://postgres:postgres@localhost:${ports.POSTGRES_PORT}/postgres`
|
|
122
|
-
};
|
|
123
|
-
for (const [name, port] of Object.entries(ports)) {
|
|
124
|
-
setupEnv[name] = String(port);
|
|
125
|
-
}
|
|
126
|
-
for (const cmd of config.setup) {
|
|
127
|
-
console.log(chalk.gray(` Running: ${cmd}`));
|
|
128
|
-
const [command, ...args] = cmd.split(" ");
|
|
129
|
-
try {
|
|
130
|
-
await execa(command, args, {
|
|
131
|
-
cwd: sessionDir,
|
|
132
|
-
stdio: "inherit",
|
|
133
|
-
env: setupEnv
|
|
134
|
-
});
|
|
135
|
-
} catch {
|
|
136
|
-
console.warn(chalk.yellow(` Warning: Command failed: ${cmd}`));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
store.remove(projectRoot, sessionId);
|
|
141
|
-
try {
|
|
142
|
-
store.insert({
|
|
143
|
-
sessionId,
|
|
144
|
-
projectRoot,
|
|
145
|
-
sessionDir,
|
|
146
|
-
branch: inPlace ? "" : branchName,
|
|
147
|
-
mode,
|
|
148
|
-
inPlace
|
|
149
|
-
});
|
|
150
|
-
} catch (dbErr) {
|
|
151
|
-
console.error(chalk.red("Failed to record session in database. Cleaning up..."));
|
|
152
|
-
try {
|
|
153
|
-
await down({ cwd: sessionDir });
|
|
154
|
-
} catch {
|
|
155
|
-
}
|
|
156
|
-
if (!inPlace) {
|
|
157
|
-
try {
|
|
158
|
-
await removeWorktree(projectRoot, sessionDir, branchName);
|
|
159
|
-
} catch {
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
throw dbErr;
|
|
163
|
-
}
|
|
164
|
-
console.log(chalk.green(`
|
|
165
|
-
Session ${sessionId} ready!`));
|
|
166
|
-
console.log(chalk.gray(`Directory: ${sessionDir}`));
|
|
167
|
-
if (mode === "docker") {
|
|
168
|
-
console.log(chalk.gray("\nDocker mode - all services in containers."));
|
|
169
|
-
console.log(chalk.gray("View logs: docker compose -f docker-compose.session.yml logs -f"));
|
|
170
|
-
} else {
|
|
171
|
-
console.log(chalk.gray("\nNative mode - run apps with: pnpm dev"));
|
|
172
|
-
}
|
|
173
|
-
console.log(chalk.gray("\nPorts:"));
|
|
174
|
-
for (const [name, port] of Object.entries(ports)) {
|
|
175
|
-
console.log(chalk.cyan(` ${name}: ${port}`));
|
|
176
|
-
}
|
|
177
|
-
if (options.detach === false) {
|
|
178
|
-
console.log(chalk.blue("\nStreaming logs (Ctrl+C to stop)..."));
|
|
179
|
-
console.log(chalk.gray("\u2500".repeat(60)));
|
|
180
|
-
try {
|
|
181
|
-
await logs({ cwd: sessionDir, profiles });
|
|
182
|
-
} catch (error) {
|
|
183
|
-
const execaError = error;
|
|
184
|
-
if (execaError.signal === "SIGINT") {
|
|
185
|
-
console.log(chalk.gray("\n\u2500".repeat(60)));
|
|
186
|
-
console.log(chalk.yellow("\nLog streaming stopped. Services are still running."));
|
|
187
|
-
console.log(chalk.gray(`Resume logs: cd ${sessionDir} && docker compose -f docker-compose.session.yml --env-file .env.session logs -f`));
|
|
188
|
-
} else {
|
|
189
|
-
throw error;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} finally {
|
|
194
|
-
store.close();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export {
|
|
199
|
-
createSession
|
|
200
|
-
};
|
package/dist/chunk-UKYQN4A3.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadConfig
|
|
3
|
-
} from "./chunk-25WQHUYW.js";
|
|
4
|
-
import {
|
|
5
|
-
getSession
|
|
6
|
-
} from "./chunk-DQER5GNG.js";
|
|
7
|
-
|
|
8
|
-
// src/commands/stop.ts
|
|
9
|
-
import { existsSync, unlinkSync } from "fs";
|
|
10
|
-
import { resolve } from "path";
|
|
11
|
-
import chalk from "chalk";
|
|
12
|
-
import { execa } from "execa";
|
|
13
|
-
async function stopSession(workingDir) {
|
|
14
|
-
const session = await getSession(workingDir);
|
|
15
|
-
if (!session) {
|
|
16
|
-
console.error(chalk.red(`Error: No session found in directory: ${workingDir}`));
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
console.log(chalk.blue(`Stopping session in ${workingDir}...`));
|
|
20
|
-
const config = await loadConfig(workingDir);
|
|
21
|
-
const allApps = config.apps ?? [];
|
|
22
|
-
const composeArgs = ["compose", "-f", "docker-compose.session.yml", "--env-file", ".env.session"];
|
|
23
|
-
for (const profile of allApps) {
|
|
24
|
-
composeArgs.push("--profile", profile);
|
|
25
|
-
}
|
|
26
|
-
composeArgs.push("stop");
|
|
27
|
-
await execa("docker", composeArgs, { cwd: workingDir, stdio: "inherit" });
|
|
28
|
-
const envPath = resolve(workingDir, ".env.session");
|
|
29
|
-
if (existsSync(envPath)) {
|
|
30
|
-
unlinkSync(envPath);
|
|
31
|
-
console.log(chalk.gray(`Deleted: ${envPath}`));
|
|
32
|
-
}
|
|
33
|
-
console.log(chalk.green("Session stopped."));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
stopSession
|
|
38
|
-
};
|
package/dist/chunk-URGGS3XM.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
removeWorktree
|
|
3
|
-
} from "./chunk-Y3GR6XK7.js";
|
|
4
|
-
import {
|
|
5
|
-
down,
|
|
6
|
-
isRunning
|
|
7
|
-
} from "./chunk-GBN67HYD.js";
|
|
8
|
-
import {
|
|
9
|
-
SessionStore
|
|
10
|
-
} from "./chunk-ZKHNUDSL.js";
|
|
11
|
-
|
|
12
|
-
// src/commands/prune.ts
|
|
13
|
-
import { existsSync } from "fs";
|
|
14
|
-
import { resolve } from "path";
|
|
15
|
-
import { createInterface } from "readline";
|
|
16
|
-
import chalk from "chalk";
|
|
17
|
-
async function pruneSessions(options) {
|
|
18
|
-
const store = new SessionStore();
|
|
19
|
-
try {
|
|
20
|
-
const sessions = store.listAll();
|
|
21
|
-
if (sessions.length === 0) {
|
|
22
|
-
console.log(chalk.gray("No sessions found."));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const stoppedSessions = [];
|
|
26
|
-
for (const session of sessions) {
|
|
27
|
-
const envFile = resolve(session.session_dir, ".env.session");
|
|
28
|
-
let running = false;
|
|
29
|
-
if (existsSync(envFile)) {
|
|
30
|
-
running = await isRunning({ cwd: session.session_dir });
|
|
31
|
-
}
|
|
32
|
-
if (!running) {
|
|
33
|
-
stoppedSessions.push({
|
|
34
|
-
sessionId: session.session_id,
|
|
35
|
-
path: session.session_dir,
|
|
36
|
-
branch: session.branch,
|
|
37
|
-
inPlace: session.in_place === 1,
|
|
38
|
-
projectRoot: session.project_root
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (stoppedSessions.length === 0) {
|
|
43
|
-
console.log(chalk.gray("No stopped sessions to prune."));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
console.log(chalk.yellow(`
|
|
47
|
-
Found ${stoppedSessions.length} stopped session(s) to prune:`));
|
|
48
|
-
for (const session of stoppedSessions) {
|
|
49
|
-
console.log(chalk.gray(` - Session ${session.sessionId} (${session.branch})`));
|
|
50
|
-
}
|
|
51
|
-
console.log("");
|
|
52
|
-
if (!options.yes) {
|
|
53
|
-
const rl = createInterface({
|
|
54
|
-
input: process.stdin,
|
|
55
|
-
output: process.stdout
|
|
56
|
-
});
|
|
57
|
-
const answer = await new Promise((resolve2) => {
|
|
58
|
-
rl.question(chalk.red("Are you sure you want to delete these sessions? This cannot be undone. [y/N] "), resolve2);
|
|
59
|
-
});
|
|
60
|
-
rl.close();
|
|
61
|
-
if (answer.toLowerCase() !== "y" && answer.toLowerCase() !== "yes") {
|
|
62
|
-
console.log(chalk.gray("Cancelled."));
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
console.log(chalk.blue("\nPruning stopped sessions...\n"));
|
|
67
|
-
for (const session of stoppedSessions) {
|
|
68
|
-
console.log(chalk.gray(` Removing session ${session.sessionId}...`));
|
|
69
|
-
try {
|
|
70
|
-
const envFile = resolve(session.path, ".env.session");
|
|
71
|
-
if (existsSync(envFile)) {
|
|
72
|
-
try {
|
|
73
|
-
await down({ cwd: session.path });
|
|
74
|
-
} catch {
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (!session.inPlace) {
|
|
78
|
-
await removeWorktree(session.projectRoot, session.path, session.branch);
|
|
79
|
-
}
|
|
80
|
-
store.markDestroyed(session.sessionId);
|
|
81
|
-
console.log(chalk.green(` Session ${session.sessionId} removed.`));
|
|
82
|
-
} catch {
|
|
83
|
-
console.log(chalk.yellow(` Warning: Could not fully remove session ${session.sessionId}`));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
console.log(chalk.green(`
|
|
87
|
-
Pruned ${stoppedSessions.length} session(s).`));
|
|
88
|
-
} finally {
|
|
89
|
-
store.close();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export {
|
|
94
|
-
pruneSessions
|
|
95
|
-
};
|
package/dist/chunk-VR3QWHHB.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// src/lib/docker.ts
|
|
2
|
-
import { execa } from "execa";
|
|
3
|
-
var COMPOSE_FILE = "docker-compose.session.yml";
|
|
4
|
-
var ENV_FILE = ".env.session";
|
|
5
|
-
async function compose(args, options) {
|
|
6
|
-
const profileFlags = options.profiles?.flatMap((p) => ["--profile", p]) ?? [];
|
|
7
|
-
const fullArgs = [
|
|
8
|
-
"compose",
|
|
9
|
-
"-f",
|
|
10
|
-
COMPOSE_FILE,
|
|
11
|
-
"--env-file",
|
|
12
|
-
ENV_FILE,
|
|
13
|
-
...profileFlags,
|
|
14
|
-
...args
|
|
15
|
-
];
|
|
16
|
-
return execa("docker", fullArgs, {
|
|
17
|
-
cwd: options.cwd,
|
|
18
|
-
stdio: "inherit"
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
async function up(options) {
|
|
22
|
-
const detach = options.detach !== false;
|
|
23
|
-
const args = detach ? ["up", "-d"] : ["up"];
|
|
24
|
-
await compose(args, options);
|
|
25
|
-
}
|
|
26
|
-
async function logs(options) {
|
|
27
|
-
await compose(["logs", "-f", "--tail=50"], options);
|
|
28
|
-
}
|
|
29
|
-
async function down(options) {
|
|
30
|
-
await compose(["down", "-v"], options);
|
|
31
|
-
}
|
|
32
|
-
async function ps(options) {
|
|
33
|
-
const result = await execa(
|
|
34
|
-
"docker",
|
|
35
|
-
["compose", "-f", COMPOSE_FILE, "--env-file", ENV_FILE, "ps", "--format", "json"],
|
|
36
|
-
{ cwd: options.cwd, reject: false }
|
|
37
|
-
);
|
|
38
|
-
return result.stdout;
|
|
39
|
-
}
|
|
40
|
-
async function isRunning(options) {
|
|
41
|
-
try {
|
|
42
|
-
const output = await ps(options);
|
|
43
|
-
if (!output.trim()) return false;
|
|
44
|
-
const services = output.trim().split("\n").map((line) => JSON.parse(line));
|
|
45
|
-
return services.some((s) => s.State === "running");
|
|
46
|
-
} catch {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export {
|
|
52
|
-
up,
|
|
53
|
-
logs,
|
|
54
|
-
down,
|
|
55
|
-
ps,
|
|
56
|
-
isRunning
|
|
57
|
-
};
|
package/dist/chunk-VUNPVDSO.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
removeWorktree
|
|
3
|
-
} from "./chunk-Y3GR6XK7.js";
|
|
4
|
-
import {
|
|
5
|
-
down
|
|
6
|
-
} from "./chunk-GBN67HYD.js";
|
|
7
|
-
import {
|
|
8
|
-
SessionStore
|
|
9
|
-
} from "./chunk-ZKHNUDSL.js";
|
|
10
|
-
|
|
11
|
-
// src/commands/destroy.ts
|
|
12
|
-
import { existsSync } from "fs";
|
|
13
|
-
import { resolve } from "path";
|
|
14
|
-
import chalk from "chalk";
|
|
15
|
-
async function destroySession(sessionId, options) {
|
|
16
|
-
const store = new SessionStore();
|
|
17
|
-
try {
|
|
18
|
-
if (options.all) {
|
|
19
|
-
console.log(chalk.blue("Destroying all sessions..."));
|
|
20
|
-
const sessions = store.listAll();
|
|
21
|
-
if (sessions.length === 0) {
|
|
22
|
-
console.log(chalk.gray("No sessions found."));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
for (const session2 of sessions) {
|
|
26
|
-
await destroySingleSession(session2.project_root, session2.session_id, session2.session_dir, session2.branch, session2.in_place === 1);
|
|
27
|
-
store.markDestroyed(session2.session_id);
|
|
28
|
-
}
|
|
29
|
-
console.log(chalk.green(`
|
|
30
|
-
Destroyed ${sessions.length} session(s).`));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (!sessionId) {
|
|
34
|
-
console.error(chalk.red("Error: Session ID required. Use --all to destroy all sessions."));
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
if (!/^\d{3}$/.test(sessionId)) {
|
|
38
|
-
console.error(chalk.red("Error: Session ID must be exactly 3 digits (001-999)"));
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
const session = store.findSession(sessionId);
|
|
42
|
-
if (!session) {
|
|
43
|
-
console.error(chalk.red(`Error: Session ${sessionId} not found.`));
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
await destroySingleSession(session.project_root, sessionId, session.session_dir, session.branch, session.in_place === 1);
|
|
47
|
-
store.markDestroyed(sessionId);
|
|
48
|
-
console.log(chalk.green(`
|
|
49
|
-
Session ${sessionId} destroyed.`));
|
|
50
|
-
} finally {
|
|
51
|
-
store.close();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async function destroySingleSession(projectRoot, sessionId, sessionDir, branchName, inPlace) {
|
|
55
|
-
console.log(chalk.blue(`
|
|
56
|
-
Destroying session ${sessionId}...`));
|
|
57
|
-
const envFile = resolve(sessionDir, ".env.session");
|
|
58
|
-
if (existsSync(envFile)) {
|
|
59
|
-
console.log(chalk.gray(" Stopping Docker containers..."));
|
|
60
|
-
try {
|
|
61
|
-
await down({ cwd: sessionDir });
|
|
62
|
-
} catch {
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (!inPlace) {
|
|
66
|
-
console.log(chalk.gray(" Removing git worktree..."));
|
|
67
|
-
await removeWorktree(projectRoot, sessionDir, branchName);
|
|
68
|
-
}
|
|
69
|
-
console.log(chalk.green(` Session ${sessionId} destroyed.`));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export {
|
|
73
|
-
destroySession
|
|
74
|
-
};
|
package/dist/chunk-VXP2SPRI.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadConfig
|
|
3
|
-
} from "./chunk-25WQHUYW.js";
|
|
4
|
-
import {
|
|
5
|
-
SessionStore
|
|
6
|
-
} from "./chunk-ZKHNUDSL.js";
|
|
7
|
-
|
|
8
|
-
// src/commands/logs.ts
|
|
9
|
-
import chalk from "chalk";
|
|
10
|
-
import { execa } from "execa";
|
|
11
|
-
async function streamLogs(sessionId, options) {
|
|
12
|
-
const store = new SessionStore();
|
|
13
|
-
let sessionDir;
|
|
14
|
-
let projectRoot;
|
|
15
|
-
try {
|
|
16
|
-
const session = store.findSession(sessionId);
|
|
17
|
-
if (!session) {
|
|
18
|
-
console.error(chalk.red(`Error: Session ${sessionId} not found.`));
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
sessionDir = session.session_dir;
|
|
22
|
-
projectRoot = session.project_root;
|
|
23
|
-
} finally {
|
|
24
|
-
store.close();
|
|
25
|
-
}
|
|
26
|
-
const config = await loadConfig(projectRoot);
|
|
27
|
-
let profileFlags = [];
|
|
28
|
-
if (options.mode === "docker") {
|
|
29
|
-
const allApps = config.apps ?? [];
|
|
30
|
-
const excludeApps = options.without ?? [];
|
|
31
|
-
const profiles = allApps.filter((app) => !excludeApps.includes(app));
|
|
32
|
-
profileFlags = profiles.flatMap((p) => ["--profile", p]);
|
|
33
|
-
}
|
|
34
|
-
const args = [
|
|
35
|
-
"compose",
|
|
36
|
-
"-f",
|
|
37
|
-
"docker-compose.session.yml",
|
|
38
|
-
"--env-file",
|
|
39
|
-
".env.session",
|
|
40
|
-
...profileFlags,
|
|
41
|
-
"logs",
|
|
42
|
-
"-f",
|
|
43
|
-
"--tail",
|
|
44
|
-
options.tail ?? "50"
|
|
45
|
-
];
|
|
46
|
-
await execa("docker", args, { cwd: sessionDir, stdio: "inherit" });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
streamLogs
|
|
51
|
-
};
|