@stackweld/core 0.3.0 → 0.3.1
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/__tests__/compatibility-scorer.test.d.ts +1 -1
- package/dist/__tests__/rules-engine.test.d.ts +1 -1
- package/dist/__tests__/scaffold-orchestrator.test.d.ts +1 -1
- package/dist/__tests__/stack-engine.test.d.ts +1 -1
- package/dist/db/database.d.ts +1 -1
- package/dist/engine/compatibility-scorer.d.ts +16 -19
- package/dist/engine/compose-generator.d.ts +21 -23
- package/dist/engine/cost-estimator.d.ts +13 -13
- package/dist/engine/env-analyzer.d.ts +14 -14
- package/dist/engine/health-checker.d.ts +12 -12
- package/dist/engine/health-checker.js +14 -6
- package/dist/engine/infra-generator.d.ts +14 -17
- package/dist/engine/migration-planner.d.ts +18 -22
- package/dist/engine/performance-profiler.d.ts +13 -13
- package/dist/engine/preferences.d.ts +7 -7
- package/dist/engine/runtime-manager.d.ts +46 -56
- package/dist/engine/runtime-manager.js +24 -10
- package/dist/engine/scaffold-orchestrator.js +42 -6
- package/dist/engine/stack-detector.d.ts +10 -10
- package/dist/engine/stack-differ.d.ts +15 -15
- package/dist/engine/stack-differ.js +76 -72
- package/dist/engine/stack-serializer.d.ts +8 -8
- package/dist/engine/tech-installer.d.ts +12 -12
- package/dist/engine/tech-installer.js +3 -2
- package/dist/types/project.d.ts +19 -19
- package/dist/types/project.js +1 -1
- package/dist/types/stack.d.ts +18 -18
- package/dist/types/stack.js +1 -1
- package/dist/types/technology.d.ts +28 -37
- package/dist/types/technology.js +1 -1
- package/dist/types/template.d.ts +22 -22
- package/dist/types/template.js +1 -1
- package/dist/types/validation.d.ts +12 -12
- package/dist/types/validation.js +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=compatibility-scorer.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=compatibility-scorer.test.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=rules-engine.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=rules-engine.test.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=scaffold-orchestrator.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=scaffold-orchestrator.test.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=stack-engine.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=stack-engine.test.d.ts.map
|
package/dist/db/database.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ import Database from "better-sqlite3";
|
|
|
6
6
|
export declare function getDatabase(dbPath?: string): Database.Database;
|
|
7
7
|
export declare function closeDatabase(): void;
|
|
8
8
|
export declare function getDefaultDbPath(): string;
|
|
9
|
-
//# sourceMappingURL=database.d.ts.map
|
|
9
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -4,34 +4,31 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Technology } from "../types/index.js";
|
|
6
6
|
export interface CompatibilityResult {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
score: number;
|
|
8
|
+
grade: "S" | "A" | "B" | "C" | "D" | "F";
|
|
9
|
+
factors: CompatibilityFactor[];
|
|
10
|
+
recommendation: string;
|
|
11
11
|
}
|
|
12
12
|
export interface CompatibilityFactor {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
label: string;
|
|
14
|
+
points: number;
|
|
15
|
+
description: string;
|
|
16
16
|
}
|
|
17
17
|
export interface StackScoreResult {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
overall: number;
|
|
19
|
+
grade: string;
|
|
20
|
+
pairs: Array<{
|
|
21
|
+
a: string;
|
|
22
|
+
b: string;
|
|
23
|
+
score: number;
|
|
24
|
+
}>;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Score the compatibility between two technologies (0-100).
|
|
28
28
|
*/
|
|
29
|
-
export declare function scoreCompatibility(
|
|
30
|
-
techA: Technology,
|
|
31
|
-
techB: Technology,
|
|
32
|
-
): CompatibilityResult;
|
|
29
|
+
export declare function scoreCompatibility(techA: Technology, techB: Technology): CompatibilityResult;
|
|
33
30
|
/**
|
|
34
31
|
* Score an entire stack by evaluating all unique pairs.
|
|
35
32
|
*/
|
|
36
33
|
export declare function scoreStack(technologies: Technology[]): StackScoreResult;
|
|
37
|
-
//# sourceMappingURL=compatibility-scorer.d.ts.map
|
|
34
|
+
//# sourceMappingURL=compatibility-scorer.d.ts.map
|
|
@@ -3,33 +3,31 @@
|
|
|
3
3
|
* No disk I/O — returns structured data for preview or writing.
|
|
4
4
|
*/
|
|
5
5
|
export interface ComposePreviewResult {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
yaml: string;
|
|
7
|
+
services: string[];
|
|
8
|
+
ports: Record<string, number>;
|
|
9
|
+
volumes: string[];
|
|
10
10
|
}
|
|
11
11
|
interface ComposeTechnology {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
dockerImage?: string;
|
|
16
|
+
defaultPort?: number;
|
|
17
|
+
envVars?: Record<string, string>;
|
|
18
|
+
healthCheck?: {
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
command?: string;
|
|
21
|
+
interval?: string;
|
|
22
|
+
timeout?: string;
|
|
23
|
+
retries?: number;
|
|
24
|
+
};
|
|
25
|
+
port?: number;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Generate a docker-compose.yml preview from a list of technologies.
|
|
29
29
|
* Only includes technologies that have a `dockerImage`.
|
|
30
30
|
*/
|
|
31
|
-
export declare function generateComposePreview(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
): ComposePreviewResult;
|
|
35
|
-
//# sourceMappingURL=compose-generator.d.ts.map
|
|
31
|
+
export declare function generateComposePreview(technologies: ComposeTechnology[], projectName: string): ComposePreviewResult;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=compose-generator.d.ts.map
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Technology } from "../types/technology.js";
|
|
5
5
|
export interface CostItem {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
service: string;
|
|
7
|
+
provider: string;
|
|
8
|
+
monthlyCost: string;
|
|
9
|
+
notes: string;
|
|
10
10
|
}
|
|
11
11
|
export interface CostEstimate {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
monthly: {
|
|
13
|
+
min: number;
|
|
14
|
+
max: number;
|
|
15
|
+
currency: string;
|
|
16
|
+
};
|
|
17
|
+
breakdown: CostItem[];
|
|
18
|
+
tier: "free" | "budget" | "standard" | "premium";
|
|
19
|
+
notes: string[];
|
|
20
20
|
}
|
|
21
21
|
export declare function estimateCost(technologies: Technology[]): CostEstimate;
|
|
22
|
-
//# sourceMappingURL=cost-estimator.d.ts.map
|
|
22
|
+
//# sourceMappingURL=cost-estimator.d.ts.map
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
* Environment Analyzer — Sync .env files and detect dangerous values.
|
|
3
3
|
*/
|
|
4
4
|
export interface EnvVar {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
line: number;
|
|
8
8
|
}
|
|
9
9
|
export interface EnvSyncResult {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
missing: string[];
|
|
11
|
+
extra: string[];
|
|
12
|
+
dangerous: EnvDangerousVar[];
|
|
13
|
+
total: {
|
|
14
|
+
example: number;
|
|
15
|
+
actual: number;
|
|
16
|
+
};
|
|
17
17
|
}
|
|
18
18
|
export interface EnvDangerousVar {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
key: string;
|
|
20
|
+
value: string;
|
|
21
|
+
reason: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Parse a .env file content into an array of key/value pairs.
|
|
@@ -33,4 +33,4 @@ export declare function syncEnv(exampleContent: string, actualContent: string):
|
|
|
33
33
|
* Detect environment variables with insecure or placeholder values.
|
|
34
34
|
*/
|
|
35
35
|
export declare function checkDangerous(vars: EnvVar[]): EnvDangerousVar[];
|
|
36
|
-
//# sourceMappingURL=env-analyzer.d.ts.map
|
|
36
|
+
//# sourceMappingURL=env-analyzer.d.ts.map
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Stack Health Monitor — Checks project health across multiple dimensions.
|
|
3
3
|
*/
|
|
4
4
|
export interface HealthReport {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
overall: "healthy" | "warning" | "critical";
|
|
6
|
+
checks: HealthCheck[];
|
|
7
|
+
summary: {
|
|
8
|
+
passed: number;
|
|
9
|
+
warnings: number;
|
|
10
|
+
critical: number;
|
|
11
|
+
};
|
|
12
12
|
}
|
|
13
13
|
export interface HealthCheck {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
name: string;
|
|
15
|
+
status: "pass" | "warn" | "fail";
|
|
16
|
+
message: string;
|
|
17
|
+
suggestion?: string;
|
|
18
18
|
}
|
|
19
19
|
export declare function checkProjectHealth(projectPath: string): HealthReport;
|
|
20
|
-
//# sourceMappingURL=health-checker.d.ts.map
|
|
20
|
+
//# sourceMappingURL=health-checker.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Stack Health Monitor — Checks project health across multiple dimensions.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { execFileSync } from "node:child_process";
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as path from "node:path";
|
|
7
7
|
// ─── Helpers ──────────────────────────────────────────
|
|
@@ -18,18 +18,26 @@ function readFileContent(filePath) {
|
|
|
18
18
|
}
|
|
19
19
|
function execQuiet(command, cwd) {
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
const parts = command.split(/\s+/).filter(Boolean);
|
|
22
|
+
return execFileSync(parts[0], parts.slice(1), { stdio: "pipe", timeout: 10000, cwd })
|
|
23
|
+
.toString()
|
|
24
|
+
.trim();
|
|
22
25
|
}
|
|
23
26
|
catch {
|
|
24
27
|
return null;
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
function getDirSizeMB(dirPath) {
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
try {
|
|
32
|
+
const result = execFileSync("du", ["-sm", dirPath], { stdio: "pipe", timeout: 10000 })
|
|
33
|
+
.toString()
|
|
34
|
+
.trim();
|
|
35
|
+
const match = result.match(/^(\d+)/);
|
|
36
|
+
return match ? parseInt(match[1], 10) : null;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
30
39
|
return null;
|
|
31
|
-
|
|
32
|
-
return match ? parseInt(match[1], 10) : null;
|
|
40
|
+
}
|
|
33
41
|
}
|
|
34
42
|
// ─── Individual Checks ───────────────────────────────
|
|
35
43
|
function checkLockFile(projectPath) {
|
|
@@ -4,23 +4,20 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type DeployTarget = "vps" | "aws" | "gcp";
|
|
6
6
|
export interface InfraOutput {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
target: DeployTarget;
|
|
8
|
+
files: Array<{
|
|
9
|
+
path: string;
|
|
10
|
+
content: string;
|
|
11
|
+
}>;
|
|
12
|
+
instructions: string[];
|
|
13
13
|
}
|
|
14
14
|
interface InfraTechnology {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
category: string;
|
|
18
|
+
dockerImage?: string;
|
|
19
|
+
defaultPort?: number;
|
|
20
20
|
}
|
|
21
|
-
export declare function generateInfra(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
target: DeployTarget,
|
|
25
|
-
): InfraOutput;
|
|
26
|
-
//# sourceMappingURL=infra-generator.d.ts.map
|
|
21
|
+
export declare function generateInfra(technologies: InfraTechnology[], projectName: string, target: DeployTarget): InfraOutput;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=infra-generator.d.ts.map
|
|
@@ -3,32 +3,28 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Technology } from "../types/technology.js";
|
|
5
5
|
export interface MigrationStep {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
order: number;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
commands?: string[];
|
|
10
|
+
files?: string[];
|
|
11
11
|
}
|
|
12
12
|
export interface MigrationPlan {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
from: {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
to: {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
steps: MigrationStep[];
|
|
22
|
+
difficulty: "easy" | "moderate" | "hard" | "expert";
|
|
23
|
+
estimatedTime: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Generate a migration plan between two technologies.
|
|
27
27
|
* Uses known migration paths when available, otherwise generates generic steps.
|
|
28
28
|
*/
|
|
29
|
-
export declare function planMigration(
|
|
30
|
-
|
|
31
|
-
toId: string,
|
|
32
|
-
techs: Technology[],
|
|
33
|
-
): MigrationPlan;
|
|
34
|
-
//# sourceMappingURL=migration-planner.d.ts.map
|
|
29
|
+
export declare function planMigration(fromId: string, toId: string, techs: Technology[]): MigrationPlan;
|
|
30
|
+
//# sourceMappingURL=migration-planner.d.ts.map
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Technology, TechnologyCategory } from "../types/technology.js";
|
|
5
5
|
export interface TechPerformance {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
category: TechnologyCategory;
|
|
9
|
+
perf: "fast" | "moderate" | "heavy";
|
|
10
|
+
note: string;
|
|
11
11
|
}
|
|
12
12
|
export interface PerformanceProfile {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
stackName: string;
|
|
14
|
+
rating: "blazing" | "fast" | "moderate" | "heavy";
|
|
15
|
+
estimatedReqPerSec: string;
|
|
16
|
+
estimatedColdStart: string;
|
|
17
|
+
estimatedMemory: string;
|
|
18
|
+
notes: string[];
|
|
19
|
+
techProfiles: TechPerformance[];
|
|
20
20
|
}
|
|
21
21
|
export declare function profilePerformance(technologies: Technology[]): PerformanceProfile;
|
|
22
|
-
//# sourceMappingURL=performance-profiler.d.ts.map
|
|
22
|
+
//# sourceMappingURL=performance-profiler.d.ts.map
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Preferences — Persistent user preferences stored in SQLite.
|
|
3
3
|
*/
|
|
4
4
|
export interface UserPreferences {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
editor: string;
|
|
6
|
+
packageManager: string;
|
|
7
|
+
shell: string;
|
|
8
|
+
dockerMode: string;
|
|
9
|
+
defaultProfile: string;
|
|
10
|
+
theme: string;
|
|
11
11
|
}
|
|
12
12
|
/** Get all preferences, merged with defaults. */
|
|
13
13
|
export declare function getPreferences(): UserPreferences;
|
|
@@ -21,4 +21,4 @@ export declare function resetPreferences(): void;
|
|
|
21
21
|
export declare function getPreferenceKeys(): (keyof UserPreferences)[];
|
|
22
22
|
/** Get default values. */
|
|
23
23
|
export declare function getDefaultPreferences(): UserPreferences;
|
|
24
|
-
//# sourceMappingURL=preferences.d.ts.map
|
|
24
|
+
//# sourceMappingURL=preferences.d.ts.map
|
|
@@ -4,62 +4,52 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { RuntimeState, ServiceStatus, Technology } from "../types/index.js";
|
|
6
6
|
export interface RuntimeOptions {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
composePath: string;
|
|
8
|
+
projectDir: string;
|
|
9
9
|
}
|
|
10
10
|
export declare class RuntimeManager {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
opts: RuntimeOptions
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*/
|
|
55
|
-
getRuntimeState(projectId: string, opts: RuntimeOptions): RuntimeState;
|
|
56
|
-
/**
|
|
57
|
-
* Check if docker compose file exists at path.
|
|
58
|
-
*/
|
|
59
|
-
composeExists(projectDir: string): string | null;
|
|
60
|
-
/**
|
|
61
|
-
* Check if Docker is available.
|
|
62
|
-
*/
|
|
63
|
-
isDockerAvailable(): boolean;
|
|
11
|
+
private technologies;
|
|
12
|
+
constructor(technologies: Technology[]);
|
|
13
|
+
/**
|
|
14
|
+
* Start all services with docker compose up.
|
|
15
|
+
*/
|
|
16
|
+
up(opts: RuntimeOptions, detach?: boolean): {
|
|
17
|
+
success: boolean;
|
|
18
|
+
output: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Stop all services.
|
|
22
|
+
*/
|
|
23
|
+
down(opts: RuntimeOptions, volumes?: boolean): {
|
|
24
|
+
success: boolean;
|
|
25
|
+
output: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Get status of all services in the compose file.
|
|
29
|
+
*/
|
|
30
|
+
status(opts: RuntimeOptions): ServiceStatus[];
|
|
31
|
+
/**
|
|
32
|
+
* Get logs for a specific service or all services.
|
|
33
|
+
*/
|
|
34
|
+
logs(opts: RuntimeOptions, service?: string, tail?: number, follow?: boolean): string;
|
|
35
|
+
/**
|
|
36
|
+
* Wait for all services to be healthy.
|
|
37
|
+
*/
|
|
38
|
+
waitForHealthy(opts: RuntimeOptions, timeoutMs?: number, intervalMs?: number): Promise<{
|
|
39
|
+
healthy: boolean;
|
|
40
|
+
services: ServiceStatus[];
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Build RuntimeState from current container status.
|
|
44
|
+
*/
|
|
45
|
+
getRuntimeState(projectId: string, opts: RuntimeOptions): RuntimeState;
|
|
46
|
+
/**
|
|
47
|
+
* Check if docker compose file exists at path.
|
|
48
|
+
*/
|
|
49
|
+
composeExists(projectDir: string): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Check if Docker is available.
|
|
52
|
+
*/
|
|
53
|
+
isDockerAvailable(): boolean;
|
|
64
54
|
}
|
|
65
|
-
//# sourceMappingURL=runtime-manager.d.ts.map
|
|
55
|
+
//# sourceMappingURL=runtime-manager.d.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Runtime Manager — Manages Docker Compose lifecycle for stacks.
|
|
3
3
|
* Handles up, down, status, logs, and health check waiting.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { execFileSync } from "node:child_process";
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
export class RuntimeManager {
|
|
@@ -14,9 +14,11 @@ export class RuntimeManager {
|
|
|
14
14
|
* Start all services with docker compose up.
|
|
15
15
|
*/
|
|
16
16
|
up(opts, detach = true) {
|
|
17
|
-
const
|
|
17
|
+
const args = ["compose", "-f", opts.composePath, "up"];
|
|
18
|
+
if (detach)
|
|
19
|
+
args.push("-d");
|
|
18
20
|
try {
|
|
19
|
-
const output =
|
|
21
|
+
const output = execFileSync("docker", args, {
|
|
20
22
|
cwd: opts.projectDir,
|
|
21
23
|
stdio: "pipe",
|
|
22
24
|
timeout: 120_000,
|
|
@@ -32,9 +34,11 @@ export class RuntimeManager {
|
|
|
32
34
|
* Stop all services.
|
|
33
35
|
*/
|
|
34
36
|
down(opts, volumes = false) {
|
|
37
|
+
const args = ["compose", "-f", opts.composePath, "down"];
|
|
38
|
+
if (volumes)
|
|
39
|
+
args.push("--volumes");
|
|
35
40
|
try {
|
|
36
|
-
const
|
|
37
|
-
const output = execSync(`docker compose -f "${opts.composePath}" down${volumesFlag}`, {
|
|
41
|
+
const output = execFileSync("docker", args, {
|
|
38
42
|
cwd: opts.projectDir,
|
|
39
43
|
stdio: "pipe",
|
|
40
44
|
timeout: 60_000,
|
|
@@ -51,7 +55,7 @@ export class RuntimeManager {
|
|
|
51
55
|
*/
|
|
52
56
|
status(opts) {
|
|
53
57
|
try {
|
|
54
|
-
const raw =
|
|
58
|
+
const raw = execFileSync("docker", ["compose", "-f", opts.composePath, "ps", "--format", "json"], {
|
|
55
59
|
cwd: opts.projectDir,
|
|
56
60
|
stdio: "pipe",
|
|
57
61
|
timeout: 10_000,
|
|
@@ -112,10 +116,20 @@ export class RuntimeManager {
|
|
|
112
116
|
* Get logs for a specific service or all services.
|
|
113
117
|
*/
|
|
114
118
|
logs(opts, service, tail = 50, follow = false) {
|
|
119
|
+
if (service && !/^[a-zA-Z0-9_-]+$/.test(service)) {
|
|
120
|
+
throw new Error(`Invalid service name: ${service}`);
|
|
121
|
+
}
|
|
122
|
+
const args = ["compose", "-f", opts.composePath, "logs", "--tail", String(tail)];
|
|
123
|
+
if (follow)
|
|
124
|
+
args.push("-f");
|
|
125
|
+
if (service)
|
|
126
|
+
args.push(service);
|
|
115
127
|
try {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
return execFileSync("docker", args, {
|
|
129
|
+
cwd: opts.projectDir,
|
|
130
|
+
stdio: follow ? "inherit" : "pipe",
|
|
131
|
+
timeout: follow ? 0 : 10_000,
|
|
132
|
+
}).toString();
|
|
119
133
|
}
|
|
120
134
|
catch (err) {
|
|
121
135
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -170,7 +184,7 @@ export class RuntimeManager {
|
|
|
170
184
|
*/
|
|
171
185
|
isDockerAvailable() {
|
|
172
186
|
try {
|
|
173
|
-
|
|
187
|
+
execFileSync("docker", ["info"], { stdio: "pipe", timeout: 5_000 });
|
|
174
188
|
return true;
|
|
175
189
|
}
|
|
176
190
|
catch {
|