@stackweld/core 0.3.0 → 0.4.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 +1 -1
- 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 -31
- package/dist/engine/compose-generator.js +1 -15
- 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/license-manager.d.ts +29 -0
- package/dist/engine/license-manager.js +130 -0
- 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-engine.d.ts +0 -20
- package/dist/engine/stack-engine.js +0 -24
- 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/index.d.ts +2 -0
- package/dist/index.js +1 -0
- 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
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @stackweld/core
|
|
2
2
|
|
|
3
|
-
[](https://github.com/mundowise/Stackweld/releases)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
6
|
The core engine for Stackweld. Handles stack persistence, compatibility rules, scaffolding orchestration, Docker lifecycle, and all analysis modules.
|
|
@@ -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
|
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compose Generator — Pure function that generates docker-compose.yml content.
|
|
3
|
-
* No disk I/O — returns structured data for preview or writing.
|
|
4
|
-
*/
|
|
5
1
|
export interface ComposePreviewResult {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
yaml: string;
|
|
3
|
+
services: string[];
|
|
4
|
+
ports: Record<string, number>;
|
|
5
|
+
volumes: string[];
|
|
10
6
|
}
|
|
11
7
|
interface ComposeTechnology {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
category?: string;
|
|
11
|
+
dockerImage?: string;
|
|
12
|
+
defaultPort?: number;
|
|
13
|
+
envVars?: Record<string, string>;
|
|
14
|
+
healthCheck?: {
|
|
15
|
+
endpoint?: string;
|
|
16
|
+
command?: string;
|
|
17
|
+
interval?: string;
|
|
18
|
+
timeout?: string;
|
|
19
|
+
retries?: number;
|
|
20
|
+
};
|
|
21
|
+
port?: number;
|
|
26
22
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
export declare function generateComposePreview(
|
|
32
|
-
technologies: ComposeTechnology[],
|
|
33
|
-
projectName: string,
|
|
34
|
-
): ComposePreviewResult;
|
|
35
|
-
//# sourceMappingURL=compose-generator.d.ts.map
|
|
23
|
+
export declare function generateComposePreview(technologies: ComposeTechnology[], projectName: string): ComposePreviewResult;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=compose-generator.d.ts.map
|
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* Compose Generator — Pure function that generates docker-compose.yml content.
|
|
3
|
-
* No disk I/O — returns structured data for preview or writing.
|
|
4
|
-
*/
|
|
1
|
+
// No disk I/O — returns structured data, caller decides what to write.
|
|
5
2
|
const DATA_MOUNTS = {
|
|
6
3
|
postgresql: "/var/lib/postgresql/data",
|
|
7
4
|
mysql: "/var/lib/mysql",
|
|
8
5
|
mongodb: "/data/db",
|
|
9
6
|
redis: "/data",
|
|
10
7
|
};
|
|
11
|
-
/**
|
|
12
|
-
* Generate a docker-compose.yml preview from a list of technologies.
|
|
13
|
-
* Only includes technologies that have a `dockerImage`.
|
|
14
|
-
*/
|
|
15
8
|
export function generateComposePreview(technologies, projectName) {
|
|
16
9
|
const services = [];
|
|
17
10
|
const ports = {};
|
|
@@ -26,13 +19,11 @@ export function generateComposePreview(technologies, projectName) {
|
|
|
26
19
|
lines.push(` ${tech.id}:`);
|
|
27
20
|
lines.push(` image: ${tech.dockerImage}`);
|
|
28
21
|
lines.push(" restart: unless-stopped");
|
|
29
|
-
// Ports
|
|
30
22
|
if (port) {
|
|
31
23
|
lines.push(" ports:");
|
|
32
24
|
lines.push(` - "${port}:${port}"`);
|
|
33
25
|
ports[tech.id] = port;
|
|
34
26
|
}
|
|
35
|
-
// Environment variables
|
|
36
27
|
const envVars = tech.envVars ? Object.entries(tech.envVars) : [];
|
|
37
28
|
if (envVars.length > 0) {
|
|
38
29
|
lines.push(" environment:");
|
|
@@ -40,7 +31,6 @@ export function generateComposePreview(technologies, projectName) {
|
|
|
40
31
|
lines.push(` ${key}: "${value}"`);
|
|
41
32
|
}
|
|
42
33
|
}
|
|
43
|
-
// Health check
|
|
44
34
|
if (tech.healthCheck) {
|
|
45
35
|
lines.push(" healthcheck:");
|
|
46
36
|
if (tech.healthCheck.command) {
|
|
@@ -59,7 +49,6 @@ export function generateComposePreview(technologies, projectName) {
|
|
|
59
49
|
lines.push(` retries: ${tech.healthCheck.retries}`);
|
|
60
50
|
}
|
|
61
51
|
}
|
|
62
|
-
// Volumes for databases
|
|
63
52
|
const mountPath = DATA_MOUNTS[tech.id];
|
|
64
53
|
if (mountPath && tech.category === "database") {
|
|
65
54
|
const volName = `${tech.id}_data`;
|
|
@@ -67,12 +56,10 @@ export function generateComposePreview(technologies, projectName) {
|
|
|
67
56
|
lines.push(` - ${volName}:${mountPath}`);
|
|
68
57
|
volumes.push(volName);
|
|
69
58
|
}
|
|
70
|
-
// Network
|
|
71
59
|
lines.push(" networks:");
|
|
72
60
|
lines.push(` - ${networkName}`);
|
|
73
61
|
lines.push("");
|
|
74
62
|
}
|
|
75
|
-
// Named volumes
|
|
76
63
|
if (volumes.length > 0) {
|
|
77
64
|
lines.push("volumes:");
|
|
78
65
|
for (const vol of volumes) {
|
|
@@ -80,7 +67,6 @@ export function generateComposePreview(technologies, projectName) {
|
|
|
80
67
|
}
|
|
81
68
|
lines.push("");
|
|
82
69
|
}
|
|
83
|
-
// Network
|
|
84
70
|
lines.push("networks:");
|
|
85
71
|
lines.push(` ${networkName}:`);
|
|
86
72
|
lines.push(" driver: bridge");
|
|
@@ -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
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type LicenseTier = "community" | "pro" | "enterprise";
|
|
2
|
+
export interface LicenseInfo {
|
|
3
|
+
tier: LicenseTier;
|
|
4
|
+
email: string | null;
|
|
5
|
+
validUntil: string | null;
|
|
6
|
+
active: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface FeatureGate {
|
|
9
|
+
feature: string;
|
|
10
|
+
requiredTier: LicenseTier;
|
|
11
|
+
description: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function activateLicense(key: string, email: string): {
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function deactivateLicense(): {
|
|
18
|
+
success: boolean;
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function getLicenseInfo(): LicenseInfo;
|
|
22
|
+
export declare function checkFeatureAccess(feature: string): {
|
|
23
|
+
allowed: boolean;
|
|
24
|
+
requiredTier: LicenseTier;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function listFeatures(): FeatureGate[];
|
|
28
|
+
export declare function getFeatureTier(feature: string): LicenseTier;
|
|
29
|
+
//# sourceMappingURL=license-manager.d.ts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
const PRO_FEATURES = [
|
|
5
|
+
{
|
|
6
|
+
feature: "ai",
|
|
7
|
+
requiredTier: "pro",
|
|
8
|
+
description: "AI-powered suggestions, README generation, and architecture explanations",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
feature: "infra",
|
|
12
|
+
requiredTier: "pro",
|
|
13
|
+
description: "Infrastructure as Code generation (VPS, AWS, GCP)",
|
|
14
|
+
},
|
|
15
|
+
{ feature: "cost", requiredTier: "pro", description: "Hosting cost estimation across providers" },
|
|
16
|
+
{ feature: "benchmark", requiredTier: "pro", description: "Stack performance profiling" },
|
|
17
|
+
{ feature: "migrate", requiredTier: "pro", description: "Technology migration planner" },
|
|
18
|
+
{ feature: "deploy", requiredTier: "pro", description: "Deployment configuration generation" },
|
|
19
|
+
{ feature: "plugin-install", requiredTier: "pro", description: "Install community plugins" },
|
|
20
|
+
{ feature: "cloud-sync", requiredTier: "enterprise", description: "Sync stacks across machines" },
|
|
21
|
+
{
|
|
22
|
+
feature: "team-standards",
|
|
23
|
+
requiredTier: "enterprise",
|
|
24
|
+
description: "Enforce team-wide stack standards",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
feature: "audit-log",
|
|
28
|
+
requiredTier: "enterprise",
|
|
29
|
+
description: "Detailed audit trail of all operations",
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
const TIER_HIERARCHY = {
|
|
33
|
+
community: 0,
|
|
34
|
+
pro: 1,
|
|
35
|
+
enterprise: 2,
|
|
36
|
+
};
|
|
37
|
+
function getLicensePath() {
|
|
38
|
+
const home = process.env.HOME || process.env.USERPROFILE || "~";
|
|
39
|
+
return path.join(home, ".stackweld", "license.json");
|
|
40
|
+
}
|
|
41
|
+
function hashKey(key) {
|
|
42
|
+
return createHash("sha256").update(key).digest("hex");
|
|
43
|
+
}
|
|
44
|
+
function validateKeyFormat(key) {
|
|
45
|
+
// Format: SW-PRO-XXXX-XXXX-XXXX or SW-ENT-XXXX-XXXX-XXXX
|
|
46
|
+
return /^SW-(PRO|ENT)-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$/.test(key);
|
|
47
|
+
}
|
|
48
|
+
function tierFromKey(key) {
|
|
49
|
+
if (key.startsWith("SW-ENT-"))
|
|
50
|
+
return "enterprise";
|
|
51
|
+
if (key.startsWith("SW-PRO-"))
|
|
52
|
+
return "pro";
|
|
53
|
+
return "community";
|
|
54
|
+
}
|
|
55
|
+
export function activateLicense(key, email) {
|
|
56
|
+
if (!validateKeyFormat(key)) {
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
message: "Invalid license key format. Expected: SW-PRO-XXXX-XXXX-XXXX",
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const tier = tierFromKey(key);
|
|
63
|
+
const licensePath = getLicensePath();
|
|
64
|
+
const dir = path.dirname(licensePath);
|
|
65
|
+
if (!fs.existsSync(dir))
|
|
66
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
67
|
+
const license = {
|
|
68
|
+
keyHash: hashKey(key),
|
|
69
|
+
tier,
|
|
70
|
+
email,
|
|
71
|
+
activatedAt: new Date().toISOString(),
|
|
72
|
+
validUntil: null,
|
|
73
|
+
};
|
|
74
|
+
fs.writeFileSync(licensePath, JSON.stringify(license, null, 2), "utf-8");
|
|
75
|
+
return {
|
|
76
|
+
success: true,
|
|
77
|
+
message: `${tier.charAt(0).toUpperCase() + tier.slice(1)} license activated for ${email}`,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function deactivateLicense() {
|
|
81
|
+
const licensePath = getLicensePath();
|
|
82
|
+
if (fs.existsSync(licensePath)) {
|
|
83
|
+
fs.unlinkSync(licensePath);
|
|
84
|
+
return { success: true, message: "License deactivated. Reverted to Community tier." };
|
|
85
|
+
}
|
|
86
|
+
return { success: false, message: "No active license found." };
|
|
87
|
+
}
|
|
88
|
+
export function getLicenseInfo() {
|
|
89
|
+
const licensePath = getLicensePath();
|
|
90
|
+
if (!fs.existsSync(licensePath)) {
|
|
91
|
+
return { tier: "community", email: null, validUntil: null, active: false };
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const data = JSON.parse(fs.readFileSync(licensePath, "utf-8"));
|
|
95
|
+
const expired = data.validUntil ? new Date(data.validUntil) < new Date() : false;
|
|
96
|
+
return {
|
|
97
|
+
tier: expired ? "community" : data.tier,
|
|
98
|
+
email: data.email,
|
|
99
|
+
validUntil: data.validUntil,
|
|
100
|
+
active: !expired,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return { tier: "community", email: null, validUntil: null, active: false };
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function checkFeatureAccess(feature) {
|
|
108
|
+
const gate = PRO_FEATURES.find((f) => f.feature === feature);
|
|
109
|
+
if (!gate)
|
|
110
|
+
return { allowed: true, requiredTier: "community", message: "" };
|
|
111
|
+
const license = getLicenseInfo();
|
|
112
|
+
const userLevel = TIER_HIERARCHY[license.tier];
|
|
113
|
+
const requiredLevel = TIER_HIERARCHY[gate.requiredTier];
|
|
114
|
+
if (userLevel >= requiredLevel) {
|
|
115
|
+
return { allowed: true, requiredTier: gate.requiredTier, message: "" };
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
allowed: false,
|
|
119
|
+
requiredTier: gate.requiredTier,
|
|
120
|
+
message: `"${gate.description}" requires a ${gate.requiredTier} license. Upgrade at https://stackweld.dev/pro`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export function listFeatures() {
|
|
124
|
+
return PRO_FEATURES;
|
|
125
|
+
}
|
|
126
|
+
export function getFeatureTier(feature) {
|
|
127
|
+
const gate = PRO_FEATURES.find((f) => f.feature === feature);
|
|
128
|
+
return gate?.requiredTier ?? "community";
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=license-manager.js.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
|