dev-prism 0.3.0 → 0.6.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 +262 -70
- package/bin/dev-prism.js +45 -42
- package/dist/chunk-24OM3LGM.js +35 -0
- package/dist/chunk-3FYEGH2G.js +217 -0
- package/dist/chunk-3NW2OWIU.js +78 -0
- package/dist/chunk-3Q454U3I.js +71 -0
- package/dist/chunk-3TRRZEFR.js +38 -0
- package/dist/chunk-4UNCSJRM.js +70 -0
- package/dist/chunk-63II3EL4.js +98 -0
- package/dist/chunk-76LSQIZI.js +31 -0
- package/dist/chunk-7OSTLJLO.js +219 -0
- package/dist/chunk-7YEZWM6Y.js +97 -0
- package/dist/chunk-AEVARZQ4.js +203 -0
- package/dist/chunk-AIVPJ467.js +70 -0
- package/dist/chunk-AOM6BONB.js +98 -0
- package/dist/chunk-BXYXWNGH.js +30 -0
- package/dist/chunk-CUQVGZBX.js +44 -0
- package/dist/chunk-DQER5GNG.js +72 -0
- package/dist/chunk-DTE5YQMI.js +41 -0
- package/dist/chunk-EXRHG5KQ.js +60 -0
- package/dist/chunk-FKTFCSU7.js +78 -0
- package/dist/chunk-GKXXK2ZH.js +203 -0
- package/dist/chunk-H3L73URT.js +65 -0
- package/dist/chunk-H4HPDIY3.js +95 -0
- package/dist/chunk-HZBJF67X.js +60 -0
- package/dist/chunk-I3U6JK77.js +66 -0
- package/dist/chunk-JMKE3ZKI.js +61 -0
- package/dist/chunk-JZ2VPQXP.js +132 -0
- package/dist/chunk-KDYKLH6P.js +40 -0
- package/dist/chunk-KZJE62TK.js +203 -0
- package/dist/chunk-LAOWFCQL.js +21 -0
- package/dist/chunk-LNIOSGC4.js +78 -0
- package/dist/chunk-MRBTH5PL.js +66 -0
- package/dist/chunk-NNVP5F6I.js +77 -0
- package/dist/chunk-OL25TBYX.js +67 -0
- package/dist/chunk-OOJ6YOGS.js +53 -0
- package/dist/chunk-OPEZFBBI.js +219 -0
- package/dist/chunk-Q5DPX4WL.js +219 -0
- package/dist/chunk-RC2AUYZ7.js +49 -0
- package/dist/chunk-RQ245R7T.js +67 -0
- package/dist/chunk-SD3TON6N.js +32 -0
- package/dist/chunk-SEKH4ZV6.js +60 -0
- package/dist/chunk-SUMJLXT7.js +30 -0
- package/dist/chunk-UKYQN4A3.js +38 -0
- package/dist/chunk-URGGS3XM.js +95 -0
- package/dist/chunk-VUNPVDSO.js +74 -0
- package/dist/chunk-VXP2SPRI.js +51 -0
- package/dist/chunk-W54CPPSK.js +217 -0
- package/dist/chunk-X2PXZRYU.js +41 -0
- package/dist/chunk-X6FHBEAS.js +200 -0
- package/dist/chunk-YSO3IDZZ.js +40 -0
- package/dist/chunk-YY5DA35Z.js +40 -0
- package/dist/chunk-Z2ISJMLW.js +92 -0
- package/dist/chunk-ZKHNUDSL.js +119 -0
- package/dist/commands/create.d.ts +2 -1
- package/dist/commands/create.js +6 -5
- package/dist/commands/destroy.d.ts +1 -1
- package/dist/commands/destroy.js +4 -3
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.js +3 -2
- package/dist/commands/list.d.ts +1 -1
- package/dist/commands/list.js +3 -5
- package/dist/commands/logs.d.ts +8 -0
- package/dist/commands/logs.js +3 -2
- package/dist/commands/prune.d.ts +6 -0
- package/dist/commands/prune.js +4 -3
- package/dist/commands/start.d.ts +7 -0
- package/dist/commands/start.js +3 -2
- package/dist/commands/stop-all.d.ts +3 -0
- package/dist/commands/stop-all.js +3 -4
- package/dist/commands/stop.d.ts +3 -0
- package/dist/commands/stop.js +3 -2
- package/dist/index.d.ts +14 -2
- package/dist/index.js +36 -18
- package/dist/lib/compose.d.ts +12 -0
- package/dist/lib/compose.js +12 -0
- package/dist/lib/config.d.ts +4 -0
- package/dist/lib/config.test.d.ts +1 -0
- package/dist/lib/config.test.js +32 -0
- package/dist/lib/docker-inspect.d.ts +24 -0
- package/dist/lib/docker-inspect.js +16 -0
- package/dist/lib/env.d.ts +5 -4
- package/dist/lib/env.js +1 -1
- package/dist/lib/env.test.d.ts +1 -0
- package/dist/lib/env.test.js +68 -0
- package/dist/lib/ports.d.ts +3 -3
- package/dist/lib/ports.js +3 -3
- package/dist/lib/ports.test.d.ts +1 -0
- package/dist/lib/ports.test.js +61 -0
- package/dist/lib/session.d.ts +16 -0
- package/dist/lib/session.js +13 -0
- package/dist/lib/store.d.ts +46 -0
- package/dist/lib/store.js +1 -1
- package/dist/lib/store.test.d.ts +1 -0
- package/dist/lib/store.test.js +205 -0
- package/dist/lib/worktree.d.ts +3 -13
- package/dist/lib/worktree.js +1 -1
- package/dist/lib/worktree.test.d.ts +1 -0
- package/dist/lib/worktree.test.js +41 -0
- package/package.json +2 -5
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// src/lib/store.ts
|
|
2
|
+
import Database from "better-sqlite3";
|
|
3
|
+
import { existsSync, mkdirSync } from "fs";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
import { homedir } from "os";
|
|
6
|
+
var SCHEMA = `
|
|
7
|
+
CREATE TABLE IF NOT EXISTS sessions (
|
|
8
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
9
|
+
session_id TEXT NOT NULL UNIQUE,
|
|
10
|
+
project_root TEXT NOT NULL,
|
|
11
|
+
session_dir TEXT NOT NULL,
|
|
12
|
+
branch TEXT NOT NULL DEFAULT '',
|
|
13
|
+
mode TEXT NOT NULL DEFAULT 'docker',
|
|
14
|
+
in_place INTEGER NOT NULL DEFAULT 0,
|
|
15
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16
|
+
destroyed_at TEXT
|
|
17
|
+
);
|
|
18
|
+
`;
|
|
19
|
+
function defaultDbPath() {
|
|
20
|
+
return join(homedir(), ".dev-prism", "sessions.db");
|
|
21
|
+
}
|
|
22
|
+
var SessionStore = class {
|
|
23
|
+
db;
|
|
24
|
+
constructor(dbPath) {
|
|
25
|
+
const path = dbPath ?? defaultDbPath();
|
|
26
|
+
if (path !== ":memory:") {
|
|
27
|
+
const dir = dirname(path);
|
|
28
|
+
if (!existsSync(dir)) {
|
|
29
|
+
mkdirSync(dir, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
this.db = new Database(path);
|
|
33
|
+
this.db.pragma("journal_mode = WAL");
|
|
34
|
+
this.db.pragma("busy_timeout = 3000");
|
|
35
|
+
this.migrate();
|
|
36
|
+
this.db.exec(SCHEMA);
|
|
37
|
+
}
|
|
38
|
+
insert(row) {
|
|
39
|
+
const stmt = this.db.prepare(`
|
|
40
|
+
INSERT INTO sessions (session_id, project_root, session_dir, branch, mode, in_place)
|
|
41
|
+
VALUES (@session_id, @project_root, @session_dir, @branch, @mode, @in_place)
|
|
42
|
+
`);
|
|
43
|
+
const info = stmt.run({
|
|
44
|
+
session_id: row.sessionId,
|
|
45
|
+
project_root: row.projectRoot,
|
|
46
|
+
session_dir: row.sessionDir,
|
|
47
|
+
branch: row.branch ?? "",
|
|
48
|
+
mode: row.mode ?? "docker",
|
|
49
|
+
in_place: row.inPlace ? 1 : 0
|
|
50
|
+
});
|
|
51
|
+
return this.db.prepare("SELECT * FROM sessions WHERE id = ?").get(info.lastInsertRowid);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Atomically remove any old destroyed row and insert a new one.
|
|
55
|
+
* Uses a transaction so the UNIQUE constraint prevents concurrent creates
|
|
56
|
+
* from claiming the same session ID.
|
|
57
|
+
*/
|
|
58
|
+
reserve(row) {
|
|
59
|
+
return this.db.transaction(() => {
|
|
60
|
+
this.remove(row.sessionId);
|
|
61
|
+
return this.insert(row);
|
|
62
|
+
})();
|
|
63
|
+
}
|
|
64
|
+
listAll() {
|
|
65
|
+
return this.db.prepare("SELECT * FROM sessions WHERE destroyed_at IS NULL ORDER BY project_root, session_id").all();
|
|
66
|
+
}
|
|
67
|
+
findSession(sessionId) {
|
|
68
|
+
return this.db.prepare("SELECT * FROM sessions WHERE session_id = ? AND destroyed_at IS NULL").get(sessionId);
|
|
69
|
+
}
|
|
70
|
+
findByDir(sessionDir) {
|
|
71
|
+
return this.db.prepare("SELECT * FROM sessions WHERE session_dir = ? AND destroyed_at IS NULL").get(sessionDir);
|
|
72
|
+
}
|
|
73
|
+
getUsedSessionIds() {
|
|
74
|
+
const rows = this.db.prepare("SELECT session_id FROM sessions WHERE destroyed_at IS NULL").all();
|
|
75
|
+
return new Set(rows.map((r) => r.session_id));
|
|
76
|
+
}
|
|
77
|
+
markDestroyed(sessionId) {
|
|
78
|
+
const info = this.db.prepare("UPDATE sessions SET destroyed_at = datetime('now') WHERE session_id = ? AND destroyed_at IS NULL").run(sessionId);
|
|
79
|
+
return info.changes > 0;
|
|
80
|
+
}
|
|
81
|
+
remove(sessionId) {
|
|
82
|
+
const info = this.db.prepare("DELETE FROM sessions WHERE session_id = ?").run(sessionId);
|
|
83
|
+
return info.changes > 0;
|
|
84
|
+
}
|
|
85
|
+
close() {
|
|
86
|
+
this.db.close();
|
|
87
|
+
}
|
|
88
|
+
migrate() {
|
|
89
|
+
const version = this.db.pragma("user_version", { simple: true });
|
|
90
|
+
if (version < 1) {
|
|
91
|
+
const tableExists = this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='sessions'").get();
|
|
92
|
+
if (tableExists) {
|
|
93
|
+
this.db.exec(`
|
|
94
|
+
CREATE TABLE sessions_new (
|
|
95
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
96
|
+
session_id TEXT NOT NULL UNIQUE,
|
|
97
|
+
project_root TEXT NOT NULL,
|
|
98
|
+
session_dir TEXT NOT NULL,
|
|
99
|
+
branch TEXT NOT NULL DEFAULT '',
|
|
100
|
+
mode TEXT NOT NULL DEFAULT 'docker',
|
|
101
|
+
in_place INTEGER NOT NULL DEFAULT 0,
|
|
102
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
103
|
+
destroyed_at TEXT
|
|
104
|
+
);
|
|
105
|
+
INSERT OR IGNORE INTO sessions_new (id, session_id, project_root, session_dir, branch, mode, in_place, created_at, destroyed_at)
|
|
106
|
+
SELECT id, session_id, project_root, session_dir, branch, mode, in_place, created_at, destroyed_at
|
|
107
|
+
FROM sessions;
|
|
108
|
+
DROP TABLE sessions;
|
|
109
|
+
ALTER TABLE sessions_new RENAME TO sessions;
|
|
110
|
+
`);
|
|
111
|
+
}
|
|
112
|
+
this.db.pragma("user_version = 1");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
SessionStore
|
|
119
|
+
};
|
|
@@ -5,6 +5,7 @@ interface CreateOptions {
|
|
|
5
5
|
without?: string[];
|
|
6
6
|
inPlace?: boolean;
|
|
7
7
|
}
|
|
8
|
-
declare function createSession(projectRoot: string,
|
|
8
|
+
declare function createSession(projectRoot: string, _sessionId: string | undefined, // Ignored - now using working directory as session ID
|
|
9
|
+
options: CreateOptions): Promise<void>;
|
|
9
10
|
|
|
10
11
|
export { type CreateOptions, createSession };
|
package/dist/commands/create.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSession
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-Q5DPX4WL.js";
|
|
4
|
+
import "../chunk-LAOWFCQL.js";
|
|
5
|
+
import "../chunk-MRBTH5PL.js";
|
|
6
|
+
import "../chunk-HZBJF67X.js";
|
|
7
|
+
import "../chunk-3Q454U3I.js";
|
|
7
8
|
import "../chunk-GBN67HYD.js";
|
|
8
9
|
import "../chunk-25WQHUYW.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-JZ2VPQXP.js";
|
|
10
11
|
export {
|
|
11
12
|
createSession
|
|
12
13
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
interface DestroyOptions {
|
|
2
2
|
all?: boolean;
|
|
3
3
|
}
|
|
4
|
-
declare function destroySession(
|
|
4
|
+
declare function destroySession(workingDirOrProjectRoot: string | undefined, options: DestroyOptions): Promise<void>;
|
|
5
5
|
|
|
6
6
|
export { type DestroyOptions, destroySession };
|
package/dist/commands/destroy.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
destroySession
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-7YEZWM6Y.js";
|
|
4
|
+
import "../chunk-3Q454U3I.js";
|
|
5
5
|
import "../chunk-GBN67HYD.js";
|
|
6
6
|
import "../chunk-25WQHUYW.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-DQER5GNG.js";
|
|
8
|
+
import "../chunk-JZ2VPQXP.js";
|
|
8
9
|
export {
|
|
9
10
|
destroySession
|
|
10
11
|
};
|
package/dist/commands/info.js
CHANGED
package/dist/commands/list.d.ts
CHANGED
package/dist/commands/list.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listSessions
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-25WQHUYW.js";
|
|
7
|
-
import "../chunk-6YMQTISJ.js";
|
|
3
|
+
} from "../chunk-24OM3LGM.js";
|
|
4
|
+
import "../chunk-DQER5GNG.js";
|
|
5
|
+
import "../chunk-JZ2VPQXP.js";
|
|
8
6
|
export {
|
|
9
7
|
listSessions
|
|
10
8
|
};
|
package/dist/commands/logs.js
CHANGED
package/dist/commands/prune.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pruneSessions
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-Z2ISJMLW.js";
|
|
4
|
+
import "../chunk-3Q454U3I.js";
|
|
5
5
|
import "../chunk-GBN67HYD.js";
|
|
6
6
|
import "../chunk-25WQHUYW.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-DQER5GNG.js";
|
|
8
|
+
import "../chunk-JZ2VPQXP.js";
|
|
8
9
|
export {
|
|
9
10
|
pruneSessions
|
|
10
11
|
};
|
package/dist/commands/start.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startSession
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-CUQVGZBX.js";
|
|
4
4
|
import "../chunk-GBN67HYD.js";
|
|
5
5
|
import "../chunk-25WQHUYW.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-DQER5GNG.js";
|
|
7
|
+
import "../chunk-JZ2VPQXP.js";
|
|
7
8
|
export {
|
|
8
9
|
startSession
|
|
9
10
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
stopAllSessions
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-6YMQTISJ.js";
|
|
3
|
+
} from "../chunk-KDYKLH6P.js";
|
|
4
|
+
import "../chunk-DQER5GNG.js";
|
|
5
|
+
import "../chunk-JZ2VPQXP.js";
|
|
7
6
|
export {
|
|
8
7
|
stopAllSessions
|
|
9
8
|
};
|
package/dist/commands/stop.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
export { createSession } from './commands/create.js';
|
|
2
2
|
export { destroySession } from './commands/destroy.js';
|
|
3
3
|
export { listSessions } from './commands/list.js';
|
|
4
|
+
export { showInfo } from './commands/info.js';
|
|
5
|
+
export { startSession } from './commands/start.js';
|
|
6
|
+
export { stopSession } from './commands/stop.js';
|
|
7
|
+
export { stopAllSessions } from './commands/stop-all.js';
|
|
8
|
+
export { pruneSessions } from './commands/prune.js';
|
|
9
|
+
export { streamLogs } from './commands/logs.js';
|
|
10
|
+
export { ClaudeOptions, installClaude } from './commands/claude.js';
|
|
4
11
|
export { SessionConfig, loadConfig } from './lib/config.js';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
12
|
+
export { extractPorts } from './lib/ports.js';
|
|
13
|
+
export { generateDefaultBranchName } from './lib/worktree.js';
|
|
14
|
+
export { generateEnvContent, renderAppEnv, writeAppEnvFiles, writeEnvFile } from './lib/env.js';
|
|
15
|
+
export { DockerComposeOptions, logs as dockerLogs, down, isRunning, ps, up } from './lib/docker.js';
|
|
16
|
+
export { ContainerInfo, PortMapping, getPortMappings, inspectContainer, listManagedContainers, sessionExists } from './lib/docker-inspect.js';
|
|
17
|
+
export { Session, getSession, listActiveSessions } from './lib/session.js';
|
|
18
|
+
export { generateComposeFile, writeComposeFile } from './lib/compose.js';
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,49 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CUQVGZBX.js";
|
|
4
4
|
import {
|
|
5
5
|
stopAllSessions
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KDYKLH6P.js";
|
|
7
7
|
import {
|
|
8
8
|
stopSession
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-76LSQIZI.js";
|
|
10
10
|
import {
|
|
11
11
|
installClaude
|
|
12
12
|
} from "./chunk-7YGOMAJG.js";
|
|
13
13
|
import {
|
|
14
14
|
createSession
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-Q5DPX4WL.js";
|
|
16
|
+
import {
|
|
17
|
+
extractPorts
|
|
18
|
+
} from "./chunk-LAOWFCQL.js";
|
|
19
|
+
import {
|
|
20
|
+
generateComposeFile,
|
|
21
|
+
writeComposeFile
|
|
22
|
+
} from "./chunk-MRBTH5PL.js";
|
|
16
23
|
import {
|
|
17
24
|
generateEnvContent,
|
|
18
25
|
renderAppEnv,
|
|
19
26
|
writeAppEnvFiles,
|
|
20
27
|
writeEnvFile
|
|
21
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-HZBJF67X.js";
|
|
22
29
|
import {
|
|
23
30
|
destroySession
|
|
24
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-7YEZWM6Y.js";
|
|
25
32
|
import {
|
|
26
33
|
showInfo
|
|
27
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-YSO3IDZZ.js";
|
|
28
35
|
import {
|
|
29
36
|
listSessions
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import {
|
|
32
|
-
calculatePorts
|
|
33
|
-
} from "./chunk-3ATDGV4Y.js";
|
|
37
|
+
} from "./chunk-24OM3LGM.js";
|
|
34
38
|
import {
|
|
35
39
|
streamLogs
|
|
36
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-OOJ6YOGS.js";
|
|
37
41
|
import {
|
|
38
42
|
pruneSessions
|
|
39
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-Z2ISJMLW.js";
|
|
40
44
|
import {
|
|
41
45
|
generateDefaultBranchName
|
|
42
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-3Q454U3I.js";
|
|
43
47
|
import {
|
|
44
48
|
down,
|
|
45
49
|
isRunning,
|
|
@@ -51,24 +55,37 @@ import {
|
|
|
51
55
|
loadConfig
|
|
52
56
|
} from "./chunk-25WQHUYW.js";
|
|
53
57
|
import {
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
getSession,
|
|
59
|
+
listActiveSessions
|
|
60
|
+
} from "./chunk-DQER5GNG.js";
|
|
61
|
+
import {
|
|
62
|
+
getPortMappings,
|
|
63
|
+
inspectContainer,
|
|
64
|
+
listManagedContainers,
|
|
65
|
+
sessionExists
|
|
66
|
+
} from "./chunk-JZ2VPQXP.js";
|
|
56
67
|
export {
|
|
57
|
-
SessionStore,
|
|
58
|
-
calculatePorts,
|
|
59
68
|
createSession,
|
|
60
69
|
destroySession,
|
|
61
70
|
logs as dockerLogs,
|
|
62
71
|
down,
|
|
72
|
+
extractPorts,
|
|
73
|
+
generateComposeFile,
|
|
63
74
|
generateDefaultBranchName,
|
|
64
75
|
generateEnvContent,
|
|
76
|
+
getPortMappings,
|
|
77
|
+
getSession,
|
|
78
|
+
inspectContainer,
|
|
65
79
|
installClaude,
|
|
66
80
|
isRunning,
|
|
81
|
+
listActiveSessions,
|
|
82
|
+
listManagedContainers,
|
|
67
83
|
listSessions,
|
|
68
84
|
loadConfig,
|
|
69
85
|
pruneSessions,
|
|
70
86
|
ps,
|
|
71
87
|
renderAppEnv,
|
|
88
|
+
sessionExists,
|
|
72
89
|
showInfo,
|
|
73
90
|
startSession,
|
|
74
91
|
stopAllSessions,
|
|
@@ -76,5 +93,6 @@ export {
|
|
|
76
93
|
streamLogs,
|
|
77
94
|
up,
|
|
78
95
|
writeAppEnvFiles,
|
|
96
|
+
writeComposeFile,
|
|
79
97
|
writeEnvFile
|
|
80
98
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare function generateComposeFile(workingDir: string, projectName: string, services: Array<{
|
|
2
|
+
name: string;
|
|
3
|
+
internalPort: number;
|
|
4
|
+
}>): string;
|
|
5
|
+
declare function writeComposeFile(workingDir: string, projectName: string, services: Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
internalPort: number;
|
|
8
|
+
}>): string;
|
|
9
|
+
declare function generateEnvStub(workingDir: string, projectName: string): string;
|
|
10
|
+
declare function getComposeProjectName(workingDir: string, projectName: string): string;
|
|
11
|
+
|
|
12
|
+
export { generateComposeFile, generateEnvStub, getComposeProjectName, writeComposeFile };
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ interface SessionConfig {
|
|
|
7
7
|
apps?: string[];
|
|
8
8
|
envFiles?: string[];
|
|
9
9
|
setup: string[];
|
|
10
|
+
services?: Array<{
|
|
11
|
+
name: string;
|
|
12
|
+
internalPort: number;
|
|
13
|
+
}>;
|
|
10
14
|
}
|
|
11
15
|
declare function loadConfig(projectRoot: string): Promise<SessionConfig>;
|
|
12
16
|
declare function getSessionsDir(config: SessionConfig, projectRoot: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { getSessionsDir, getSessionDir } from './config.js';
|
|
3
|
+
const baseConfig = {
|
|
4
|
+
portBase: 47000,
|
|
5
|
+
sessionsDir: '../sessions',
|
|
6
|
+
ports: {},
|
|
7
|
+
setup: [],
|
|
8
|
+
};
|
|
9
|
+
describe('getSessionsDir', () => {
|
|
10
|
+
it('resolves sessions dir relative to project root', () => {
|
|
11
|
+
const result = getSessionsDir(baseConfig, '/home/user/project');
|
|
12
|
+
expect(result).toBe('/home/user/sessions');
|
|
13
|
+
});
|
|
14
|
+
it('handles absolute sessionsDir', () => {
|
|
15
|
+
const config = {
|
|
16
|
+
...baseConfig,
|
|
17
|
+
sessionsDir: '/var/sessions',
|
|
18
|
+
};
|
|
19
|
+
const result = getSessionsDir(config, '/home/user/project');
|
|
20
|
+
expect(result).toBe('/var/sessions');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('getSessionDir', () => {
|
|
24
|
+
it('returns path to specific session directory', () => {
|
|
25
|
+
const result = getSessionDir(baseConfig, '/home/user/project', '001');
|
|
26
|
+
expect(result).toBe('/home/user/sessions/session-001');
|
|
27
|
+
});
|
|
28
|
+
it('handles different session IDs', () => {
|
|
29
|
+
const result = getSessionDir(baseConfig, '/home/user/project', '042');
|
|
30
|
+
expect(result).toBe('/home/user/sessions/session-042');
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface ContainerInfo {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
state: string;
|
|
5
|
+
labels: Record<string, string>;
|
|
6
|
+
ports: Array<{
|
|
7
|
+
privatePort: number;
|
|
8
|
+
publicPort?: number;
|
|
9
|
+
type: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
interface PortMapping {
|
|
13
|
+
service: string;
|
|
14
|
+
internalPort: number;
|
|
15
|
+
externalPort: number;
|
|
16
|
+
}
|
|
17
|
+
declare function listManagedContainers(): Promise<ContainerInfo[]>;
|
|
18
|
+
declare function inspectContainer(containerId: string): Promise<ContainerInfo | null>;
|
|
19
|
+
declare function getPortMappings(workingDir: string): Promise<PortMapping[]>;
|
|
20
|
+
declare function groupContainersByWorkingDir(containers: ContainerInfo[]): Map<string, ContainerInfo[]>;
|
|
21
|
+
declare function sessionExists(workingDir: string): Promise<boolean>;
|
|
22
|
+
declare function getComposeProject(workingDir: string): Promise<string | null>;
|
|
23
|
+
|
|
24
|
+
export { type ContainerInfo, type PortMapping, getComposeProject, getPortMappings, groupContainersByWorkingDir, inspectContainer, listManagedContainers, sessionExists };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getComposeProject,
|
|
3
|
+
getPortMappings,
|
|
4
|
+
groupContainersByWorkingDir,
|
|
5
|
+
inspectContainer,
|
|
6
|
+
listManagedContainers,
|
|
7
|
+
sessionExists
|
|
8
|
+
} from "../chunk-JZ2VPQXP.js";
|
|
9
|
+
export {
|
|
10
|
+
getComposeProject,
|
|
11
|
+
getPortMappings,
|
|
12
|
+
groupContainersByWorkingDir,
|
|
13
|
+
inspectContainer,
|
|
14
|
+
listManagedContainers,
|
|
15
|
+
sessionExists
|
|
16
|
+
};
|
package/dist/lib/env.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SessionConfig } from './config.js';
|
|
2
2
|
|
|
3
|
-
declare function generateEnvContent(
|
|
4
|
-
declare function writeEnvFile(
|
|
5
|
-
declare function
|
|
3
|
+
declare function generateEnvContent(workingDir: string, ports: Record<string, number>, projectName: string): string;
|
|
4
|
+
declare function writeEnvFile(workingDir: string, ports: Record<string, number>, composeProjectName: string): string;
|
|
5
|
+
declare function renderAppEnv(template: Record<string, string>, ports: Record<string, number>): Record<string, string>;
|
|
6
|
+
declare function writeAppEnvFiles(config: SessionConfig, workingDir: string, ports: Record<string, number>): string[];
|
|
6
7
|
|
|
7
|
-
export { generateEnvContent, writeAppEnvFiles, writeEnvFile };
|
|
8
|
+
export { generateEnvContent, renderAppEnv, writeAppEnvFiles, writeEnvFile };
|
package/dist/lib/env.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|