kaven-cli 0.4.0-alpha.1 → 0.4.1-alpha.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 +147 -84
- package/README.pt-BR.md +334 -0
- package/dist/EnvManager-GQMEZ6NV.js +158 -0
- package/dist/MarketplaceClient-IJGRQRC4.js +7 -0
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-GHZX5OAA.js +455 -0
- package/dist/commands/aiox/index.js +20 -0
- package/dist/commands/config/features.js +110 -1008
- package/dist/commands/config/index.js +1 -34
- package/dist/commands/index.js +1 -0
- package/dist/commands/init/aiox-bootstrap.js +83 -0
- package/dist/commands/init/index.js +20 -40
- package/dist/commands/marketplace/browse.js +1 -34
- package/dist/commands/module/activate.js +89 -48
- package/dist/commands/module/list.js +51 -0
- package/dist/commands/module/publish.js +2 -35
- package/dist/commands/upgrade/index.js +6 -39
- package/dist/core/AuthService.js +2 -34
- package/dist/core/CacheManager.js +3 -0
- package/dist/core/ConfigManager.js +8 -7
- package/dist/core/ErrorRecovery.js +1 -0
- package/dist/core/LicenseService.js +3 -38
- package/dist/core/ModuleDoctor.js +3 -0
- package/dist/core/ModuleInstaller.js +5 -36
- package/dist/core/ProjectInitializer.js +43 -5
- package/dist/core/RegistryResolver.js +3 -2
- package/dist/core/SchemaActivator.js +29 -8
- package/dist/core/ScriptRunner.js +3 -2
- package/dist/core/index.js +1 -0
- package/dist/index.js +30 -9
- package/dist/infrastructure/Container.js +2 -4
- package/dist/infrastructure/MarketplaceClient.js +31 -3
- package/dist/infrastructure/TelemetryBuffer.js +3 -1
- package/dist/infrastructure/TransactionalFileSystem.js +4 -1
- package/dist/infrastructure/errors.js +2 -0
- package/dist/infrastructure/index.js +1 -0
- package/dist/lib/capabilities-catalog.js +73 -0
- package/dist/lib/module-registry.js +47 -0
- package/dist/lib/schema-modifier.js +40 -0
- package/dist/tier-table-LAL6PAVW.js +52 -0
- package/package.json +11 -3
- package/dist/commands/modules/add.js +0 -53
- package/dist/commands/modules/list.js +0 -40
- package/dist/commands/modules/remove.js +0 -54
- package/dist/core/api/KavenApiClient.js +0 -61
- package/dist/core/auth/AuthManager.js +0 -91
- package/dist/core/modules/Injector.js +0 -86
- package/dist/core/modules/ModuleInstaller.js +0 -63
- package/dist/core/modules/ModuleManager.js +0 -59
- package/dist/core/modules/ModuleRemover.js +0 -60
- package/dist/lib/config.js +0 -66
- package/dist/lib/errors.js +0 -32
- package/dist/lib/logger.js +0 -70
- package/dist/types/module.js +0 -49
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -57,7 +24,7 @@ const TIER_LABELS = {
|
|
|
57
24
|
pro: "Pro",
|
|
58
25
|
enterprise: "Enterprise",
|
|
59
26
|
};
|
|
60
|
-
const POLL_INTERVAL_MS =
|
|
27
|
+
const POLL_INTERVAL_MS = 5_000;
|
|
61
28
|
const MAX_POLLS = 120; // 10 minutes
|
|
62
29
|
async function loadLicenseKey() {
|
|
63
30
|
if (!(await fs_extra_1.default.pathExists(LICENSE_PATH)))
|
|
@@ -120,15 +87,15 @@ async function upgradeCommand(options) {
|
|
|
120
87
|
return;
|
|
121
88
|
}
|
|
122
89
|
// 4. Show tier comparison table (imported from license command)
|
|
123
|
-
const { printTierComparisonTable } = await
|
|
90
|
+
const { printTierComparisonTable } = await import("../license/tier-table.js");
|
|
124
91
|
printTierComparisonTable(currentTier, "pro");
|
|
125
92
|
console.log();
|
|
126
93
|
// 5. Prompt target tier (exclude current tier)
|
|
127
|
-
const { select } = await
|
|
94
|
+
const { select } = await import("@inquirer/prompts");
|
|
128
95
|
const availableTiers = TIERS.filter((t) => t !== currentTier && t !== "enterprise");
|
|
129
96
|
if (availableTiers.length === 0) {
|
|
130
97
|
console.log(chalk_1.default.yellow(`You're already on the highest available tier (${TIER_LABELS[currentTier] || currentTier}).`));
|
|
131
|
-
console.log(chalk_1.default.gray("For Enterprise plans, contact: enterprise@kaven.
|
|
98
|
+
console.log(chalk_1.default.gray("For Enterprise plans, contact: enterprise@kaven.site"));
|
|
132
99
|
return;
|
|
133
100
|
}
|
|
134
101
|
const targetTier = await select({
|
|
@@ -200,7 +167,7 @@ async function upgradeCommand(options) {
|
|
|
200
167
|
}
|
|
201
168
|
if (status.status === "failed") {
|
|
202
169
|
pollSpinner.fail("Payment failed.");
|
|
203
|
-
console.log(chalk_1.default.gray("Please try again or contact support@kaven.
|
|
170
|
+
console.log(chalk_1.default.gray("Please try again or contact support@kaven.site"));
|
|
204
171
|
process.exit(1);
|
|
205
172
|
return;
|
|
206
173
|
}
|
|
@@ -214,5 +181,5 @@ async function upgradeCommand(options) {
|
|
|
214
181
|
pollSpinner.warn("Timed out waiting for payment confirmation.");
|
|
215
182
|
console.log();
|
|
216
183
|
console.log(chalk_1.default.yellow("If you completed payment, your upgrade may take a few minutes to activate."));
|
|
217
|
-
console.log(chalk_1.default.gray("Check your upgrade status at: https://dashboard.kaven.
|
|
184
|
+
console.log(chalk_1.default.gray("Check your upgrade status at: https://dashboard.kaven.site/billing"));
|
|
218
185
|
}
|
package/dist/core/AuthService.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -71,6 +38,7 @@ function formatExpiryRelative(expiresAt) {
|
|
|
71
38
|
return `expires in ${minutes}m`;
|
|
72
39
|
}
|
|
73
40
|
class AuthService {
|
|
41
|
+
configPath;
|
|
74
42
|
constructor() {
|
|
75
43
|
this.configPath = path_1.default.join(os_1.default.homedir(), ".kaven", "auth.json");
|
|
76
44
|
}
|
|
@@ -156,7 +124,7 @@ class AuthService {
|
|
|
156
124
|
// Attempt refresh
|
|
157
125
|
try {
|
|
158
126
|
// Lazy import to avoid circular dependency at module level
|
|
159
|
-
const { MarketplaceClient } = await
|
|
127
|
+
const { MarketplaceClient } = await import("../infrastructure/MarketplaceClient.js");
|
|
160
128
|
const client = new MarketplaceClient(this);
|
|
161
129
|
const refreshed = await client.refreshToken(auth.refresh_token);
|
|
162
130
|
// Update stored auth with new tokens
|
|
@@ -9,6 +9,9 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const os_1 = __importDefault(require("os"));
|
|
11
11
|
class CacheManager {
|
|
12
|
+
cacheDir;
|
|
13
|
+
maxSizeBytes;
|
|
14
|
+
indexPath;
|
|
12
15
|
constructor(cacheDir, maxSizeBytes) {
|
|
13
16
|
this.cacheDir = cacheDir ?? path_1.default.join(os_1.default.homedir(), ".kaven", "cache");
|
|
14
17
|
this.maxSizeBytes = maxSizeBytes ?? 50 * 1024 * 1024; // 50MB
|
|
@@ -11,7 +11,7 @@ const zod_1 = require("zod");
|
|
|
11
11
|
const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), ".kaven");
|
|
12
12
|
const CONFIG_PATH = path_1.default.join(CONFIG_DIR, "config.json");
|
|
13
13
|
exports.configSchema = zod_1.z.object({
|
|
14
|
-
registry: zod_1.z.string().url().default("https://marketplace.kaven.
|
|
14
|
+
registry: zod_1.z.string().url().default("https://marketplace.kaven.site"),
|
|
15
15
|
telemetry: zod_1.z.boolean().default(true),
|
|
16
16
|
theme: zod_1.z.enum(["light", "dark"]).default("dark"),
|
|
17
17
|
locale: zod_1.z.string().default("en-US"),
|
|
@@ -29,9 +29,10 @@ exports.configSchema = zod_1.z.object({
|
|
|
29
29
|
.optional(),
|
|
30
30
|
});
|
|
31
31
|
class ConfigManager {
|
|
32
|
+
config;
|
|
32
33
|
constructor() {
|
|
33
34
|
this.config = {
|
|
34
|
-
registry: "https://marketplace.kaven.
|
|
35
|
+
registry: "https://marketplace.kaven.site",
|
|
35
36
|
telemetry: true,
|
|
36
37
|
theme: "dark",
|
|
37
38
|
locale: "en-US",
|
|
@@ -49,7 +50,7 @@ class ConfigManager {
|
|
|
49
50
|
else {
|
|
50
51
|
// If validation fails, use defaults
|
|
51
52
|
this.config = {
|
|
52
|
-
registry: "https://marketplace.kaven.
|
|
53
|
+
registry: "https://marketplace.kaven.site",
|
|
53
54
|
telemetry: true,
|
|
54
55
|
theme: "dark",
|
|
55
56
|
locale: "en-US",
|
|
@@ -59,7 +60,7 @@ class ConfigManager {
|
|
|
59
60
|
catch {
|
|
60
61
|
// If file is corrupted, start fresh
|
|
61
62
|
this.config = {
|
|
62
|
-
registry: "https://marketplace.kaven.
|
|
63
|
+
registry: "https://marketplace.kaven.site",
|
|
63
64
|
telemetry: true,
|
|
64
65
|
theme: "dark",
|
|
65
66
|
locale: "en-US",
|
|
@@ -69,7 +70,7 @@ class ConfigManager {
|
|
|
69
70
|
else {
|
|
70
71
|
// Initialize with defaults
|
|
71
72
|
this.config = {
|
|
72
|
-
registry: "https://marketplace.kaven.
|
|
73
|
+
registry: "https://marketplace.kaven.site",
|
|
73
74
|
telemetry: true,
|
|
74
75
|
theme: "dark",
|
|
75
76
|
locale: "en-US",
|
|
@@ -124,7 +125,7 @@ class ConfigManager {
|
|
|
124
125
|
*/
|
|
125
126
|
async reset() {
|
|
126
127
|
this.config = {
|
|
127
|
-
registry: "https://marketplace.kaven.
|
|
128
|
+
registry: "https://marketplace.kaven.site",
|
|
128
129
|
telemetry: true,
|
|
129
130
|
theme: "dark",
|
|
130
131
|
locale: "en-US",
|
|
@@ -142,7 +143,7 @@ class ConfigManager {
|
|
|
142
143
|
* Get registry URL (custom or default)
|
|
143
144
|
*/
|
|
144
145
|
getRegistry() {
|
|
145
|
-
return (this.config.customRegistry || this.config.registry || "https://marketplace.kaven.
|
|
146
|
+
return (this.config.customRegistry || this.config.registry || "https://marketplace.kaven.site");
|
|
146
147
|
}
|
|
147
148
|
/**
|
|
148
149
|
* Check if telemetry is enabled (can be overridden by env var)
|
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -43,9 +10,7 @@ const os_1 = __importDefault(require("os"));
|
|
|
43
10
|
const CACHE_FILE = path_1.default.join(os_1.default.homedir(), '.kaven', 'cache', 'licenses.json');
|
|
44
11
|
const CACHE_TTL_MS = 60 * 60 * 1000; // 1 hour
|
|
45
12
|
class LicenseService {
|
|
46
|
-
|
|
47
|
-
this.cacheDir = path_1.default.join(os_1.default.homedir(), '.kaven', 'cache');
|
|
48
|
-
}
|
|
13
|
+
cacheDir = path_1.default.join(os_1.default.homedir(), '.kaven', 'cache');
|
|
49
14
|
/** Luhn mod-31 checksum format check (KAVEN-{TIER}-{8RANDOM}-{CHECKSUM}) */
|
|
50
15
|
isValidFormat(licenseKey) {
|
|
51
16
|
const pattern = /^KAVEN-(STARTER|COMPLETE|PRO|ENTERPRISE)-[A-Z0-9]{8}-[A-Z0-9]{2}$/;
|
|
@@ -90,7 +55,7 @@ class LicenseService {
|
|
|
90
55
|
throw new Error('Invalid license key format');
|
|
91
56
|
}
|
|
92
57
|
// 3. API validation
|
|
93
|
-
const { MarketplaceClient } = await
|
|
58
|
+
const { MarketplaceClient } = await import('../infrastructure/MarketplaceClient.js');
|
|
94
59
|
const client = new MarketplaceClient();
|
|
95
60
|
const result = await client.validateLicense(licenseKey, requiredTier);
|
|
96
61
|
// Cache on success
|
|
@@ -103,7 +68,7 @@ class LicenseService {
|
|
|
103
68
|
return { ...result, source: 'api' };
|
|
104
69
|
}
|
|
105
70
|
async getLicenseStatus(licenseKey) {
|
|
106
|
-
const { MarketplaceClient } = await
|
|
71
|
+
const { MarketplaceClient } = await import('../infrastructure/MarketplaceClient.js');
|
|
107
72
|
const client = new MarketplaceClient();
|
|
108
73
|
return client.getLicenseStatus(licenseKey);
|
|
109
74
|
}
|
|
@@ -8,6 +8,9 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const os_1 = __importDefault(require("os"));
|
|
10
10
|
class ModuleDoctor {
|
|
11
|
+
projectRoot;
|
|
12
|
+
markerService;
|
|
13
|
+
manifestParser;
|
|
11
14
|
constructor(projectRoot, markerService, manifestParser) {
|
|
12
15
|
this.projectRoot = projectRoot;
|
|
13
16
|
this.markerService = markerService;
|
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
@@ -43,6 +10,8 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
43
10
|
const path_1 = __importDefault(require("path"));
|
|
44
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
45
12
|
class ModuleInstaller {
|
|
13
|
+
projectRoot;
|
|
14
|
+
markerService;
|
|
46
15
|
constructor(projectRoot, markerService) {
|
|
47
16
|
this.projectRoot = projectRoot;
|
|
48
17
|
this.markerService = markerService;
|
|
@@ -73,7 +42,7 @@ class ModuleInstaller {
|
|
|
73
42
|
}
|
|
74
43
|
/** Find text-based project source files to check for markers. */
|
|
75
44
|
async findProjectFiles() {
|
|
76
|
-
const { glob } = await
|
|
45
|
+
const { glob } = await import("glob");
|
|
77
46
|
const patterns = ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"];
|
|
78
47
|
const ignore = ["**/node_modules/**", "**/.next/**", "**/dist/**", "**/build/**"];
|
|
79
48
|
const files = [];
|
|
@@ -112,7 +81,7 @@ class ModuleInstaller {
|
|
|
112
81
|
}
|
|
113
82
|
// Inject environment variables if defined in module.json
|
|
114
83
|
if (!options?.skipEnv && moduleJson?.env?.length) {
|
|
115
|
-
const { EnvManager } = await
|
|
84
|
+
const { EnvManager } = await import('./EnvManager.js');
|
|
116
85
|
const envManager = new EnvManager();
|
|
117
86
|
const envVarDefs = moduleJson.env.map((e) => ({
|
|
118
87
|
name: e.key,
|
|
@@ -141,7 +110,7 @@ class ModuleInstaller {
|
|
|
141
110
|
const filesToModify = Array.from(new Set(manifest.injections.map((inj) => inj.file)));
|
|
142
111
|
await tx.backup(filesToModify);
|
|
143
112
|
// Remove environment variables before removing files
|
|
144
|
-
const { EnvManager } = await
|
|
113
|
+
const { EnvManager } = await import('./EnvManager.js');
|
|
145
114
|
const envManager = new EnvManager();
|
|
146
115
|
envManager.removeEnvVars(manifest.name, {
|
|
147
116
|
projectDir: this.projectRoot,
|
|
@@ -40,9 +40,21 @@ class ProjectInitializer {
|
|
|
40
40
|
}
|
|
41
41
|
return { valid: true };
|
|
42
42
|
}
|
|
43
|
-
/** Clone the template
|
|
44
|
-
async cloneTemplate(targetDir) {
|
|
45
|
-
const
|
|
43
|
+
/** Clone the template (from Git or local path) into targetDir. */
|
|
44
|
+
async cloneTemplate(targetDir, templateSource) {
|
|
45
|
+
const source = templateSource || TEMPLATE_REPO;
|
|
46
|
+
console.log(`[INIT] Clone Source: ${source}`);
|
|
47
|
+
console.log(`[INIT] Target Dir: ${targetDir}`);
|
|
48
|
+
// If it's a local path that exists, copy it instead of cloning
|
|
49
|
+
if (await fs_extra_1.default.pathExists(source) && (source.startsWith("/") || source.startsWith("./") || source.startsWith("../"))) {
|
|
50
|
+
console.log(`[INIT] Local Path Detected. Copying...`);
|
|
51
|
+
await fs_extra_1.default.copy(source, targetDir, {
|
|
52
|
+
filter: (src) => !src.includes("node_modules") && !src.includes(".git") && !src.includes(".turbo")
|
|
53
|
+
});
|
|
54
|
+
console.log(`[INIT] Local Copy Done.`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const exitCode = await runCommand("git", ["clone", "--depth", "1", source, targetDir], process.cwd());
|
|
46
58
|
if (exitCode !== 0) {
|
|
47
59
|
throw new Error(`git clone failed with exit code ${exitCode}`);
|
|
48
60
|
}
|
|
@@ -65,10 +77,13 @@ class ProjectInitializer {
|
|
|
65
77
|
const filesToProcess = [
|
|
66
78
|
"package.json",
|
|
67
79
|
".env.example",
|
|
68
|
-
"prisma/schema.prisma",
|
|
80
|
+
"packages/database/prisma/schema.prisma",
|
|
69
81
|
"apps/api/package.json",
|
|
70
82
|
"apps/admin/package.json",
|
|
71
83
|
"apps/tenant/package.json",
|
|
84
|
+
"docs/architecture/tech-stack.md",
|
|
85
|
+
"docs/architecture/source-tree.md",
|
|
86
|
+
"docs/architecture/coding-standards.md",
|
|
72
87
|
];
|
|
73
88
|
for (const relFile of filesToProcess) {
|
|
74
89
|
const filePath = path_1.default.join(targetDir, relFile);
|
|
@@ -80,6 +95,15 @@ class ProjectInitializer {
|
|
|
80
95
|
}
|
|
81
96
|
await fs_extra_1.default.writeFile(filePath, content, "utf-8");
|
|
82
97
|
}
|
|
98
|
+
// Safety net: directly update root package.json name field regardless of placeholder
|
|
99
|
+
const pkgPath = path_1.default.join(targetDir, "package.json");
|
|
100
|
+
if (await fs_extra_1.default.pathExists(pkgPath)) {
|
|
101
|
+
const pkg = await fs_extra_1.default.readJson(pkgPath);
|
|
102
|
+
if (pkg.name !== values.projectName) {
|
|
103
|
+
pkg.name = values.projectName;
|
|
104
|
+
await fs_extra_1.default.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
83
107
|
}
|
|
84
108
|
/** Run pnpm install in the target directory. */
|
|
85
109
|
async runInstall(targetDir) {
|
|
@@ -121,11 +145,25 @@ class ProjectInitializer {
|
|
|
121
145
|
}
|
|
122
146
|
return { installed: true };
|
|
123
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Install AIOX Core runtime into the project via npx.
|
|
150
|
+
* Non-fatal — if it fails, user gets instructions to run manually.
|
|
151
|
+
*/
|
|
152
|
+
async installAIOXCore(targetDir) {
|
|
153
|
+
const exitCode = await runCommand('npx', ['aiox-core@5.0.3', 'install', '--quiet'], targetDir);
|
|
154
|
+
if (exitCode !== 0) {
|
|
155
|
+
return {
|
|
156
|
+
installed: false,
|
|
157
|
+
reason: `npx aiox-core exited with code ${exitCode}`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return { installed: true };
|
|
161
|
+
}
|
|
124
162
|
/** Health check after project initialization. */
|
|
125
163
|
async healthCheck(targetDir) {
|
|
126
164
|
const issues = [];
|
|
127
165
|
// Check key files exist
|
|
128
|
-
const requiredFiles = ["package.json", ".env.example", "prisma/schema.prisma"];
|
|
166
|
+
const requiredFiles = ["package.json", ".env.example", "packages/database/prisma/schema.prisma"];
|
|
129
167
|
for (const file of requiredFiles) {
|
|
130
168
|
if (!(await fs_extra_1.default.pathExists(path_1.default.join(targetDir, file)))) {
|
|
131
169
|
issues.push(`Missing required file: ${file}`);
|
|
@@ -8,6 +8,7 @@ const AuthService_1 = require("./AuthService");
|
|
|
8
8
|
* C2.5: Registry resolver — handles both official and custom registries
|
|
9
9
|
*/
|
|
10
10
|
class RegistryResolver {
|
|
11
|
+
authService;
|
|
11
12
|
constructor(authService) {
|
|
12
13
|
this.authService = authService || new AuthService_1.AuthService();
|
|
13
14
|
}
|
|
@@ -25,7 +26,7 @@ class RegistryResolver {
|
|
|
25
26
|
const registry = await this.getActiveRegistry();
|
|
26
27
|
const client = new MarketplaceClient_1.MarketplaceClient(this.authService);
|
|
27
28
|
// Set custom registry if configured
|
|
28
|
-
if (registry !== "https://marketplace.kaven.
|
|
29
|
+
if (registry !== "https://marketplace.kaven.site") {
|
|
29
30
|
client.baseUrl = registry;
|
|
30
31
|
}
|
|
31
32
|
return client;
|
|
@@ -85,7 +86,7 @@ class RegistryResolver {
|
|
|
85
86
|
await ConfigManager_1.configManager.initialize();
|
|
86
87
|
const config = ConfigManager_1.configManager.getAll();
|
|
87
88
|
return {
|
|
88
|
-
default: config.registry || "https://marketplace.kaven.
|
|
89
|
+
default: config.registry || "https://marketplace.kaven.site",
|
|
89
90
|
custom: config.customRegistry,
|
|
90
91
|
active: await this.getActiveRegistry(),
|
|
91
92
|
};
|
|
@@ -7,6 +7,14 @@ exports.SchemaActivator = exports.KAVEN_MODULES = void 0;
|
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
exports.KAVEN_MODULES = [
|
|
10
|
+
{
|
|
11
|
+
id: "auth",
|
|
12
|
+
label: "Auth & Identity",
|
|
13
|
+
description: "Gestão de usuários, permissões e sessões",
|
|
14
|
+
models: ["User", "Role", "Capability", "AuthSession", "AuditLog"],
|
|
15
|
+
enums: ["UserRole"],
|
|
16
|
+
dependsOn: [],
|
|
17
|
+
},
|
|
10
18
|
{
|
|
11
19
|
id: "billing",
|
|
12
20
|
label: "Billing",
|
|
@@ -31,6 +39,22 @@ exports.KAVEN_MODULES = [
|
|
|
31
39
|
enums: [],
|
|
32
40
|
dependsOn: [],
|
|
33
41
|
},
|
|
42
|
+
{
|
|
43
|
+
id: "marketing-tracking",
|
|
44
|
+
label: "Marketing Tracking",
|
|
45
|
+
description: "Observabilidade de anúncios, GTM, GA4 e Meta CAPI",
|
|
46
|
+
models: ["TrackingEvent"],
|
|
47
|
+
enums: ["TrackingSource"],
|
|
48
|
+
dependsOn: [],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "service-tokens",
|
|
52
|
+
label: "Service Tokens",
|
|
53
|
+
description: "Agent authentication tokens for AIOX integration",
|
|
54
|
+
models: ["ServiceToken"],
|
|
55
|
+
enums: [],
|
|
56
|
+
dependsOn: [],
|
|
57
|
+
},
|
|
34
58
|
];
|
|
35
59
|
// ============================================================
|
|
36
60
|
// Marcadores de seção no schema
|
|
@@ -41,6 +65,7 @@ const END_MARKER = (moduleId) => `// [KAVEN_MODULE:${moduleId.toUpperCase()} END
|
|
|
41
65
|
// SchemaActivator — lê/escreve schema.extended.prisma
|
|
42
66
|
// ============================================================
|
|
43
67
|
class SchemaActivator {
|
|
68
|
+
schemaPath;
|
|
44
69
|
constructor(projectRoot) {
|
|
45
70
|
this.schemaPath = path_1.default.join(projectRoot, "packages", "database", "prisma", "schema.extended.prisma");
|
|
46
71
|
}
|
|
@@ -234,14 +259,10 @@ class SchemaActivator {
|
|
|
234
259
|
continue;
|
|
235
260
|
}
|
|
236
261
|
if (inBlock) {
|
|
237
|
-
// Remove exatamente um nível de comentário
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
result.push(
|
|
241
|
-
}
|
|
242
|
-
else if (line.trimStart().startsWith("//")) {
|
|
243
|
-
const indent = line.length - line.trimStart().length;
|
|
244
|
-
result.push(line.slice(0, indent) + line.trimStart().slice(2));
|
|
262
|
+
// Remove exatamente um nível de comentário preservando identação
|
|
263
|
+
const match = line.match(/^(\s*)\/\/\s?(.*)$/);
|
|
264
|
+
if (match) {
|
|
265
|
+
result.push(match[1] + match[2]);
|
|
245
266
|
}
|
|
246
267
|
else {
|
|
247
268
|
result.push(line);
|
|
@@ -8,7 +8,8 @@ const child_process_1 = require("child_process");
|
|
|
8
8
|
const readline_1 = __importDefault(require("readline"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
class ScriptRunner {
|
|
11
|
-
|
|
11
|
+
timeoutMs;
|
|
12
|
+
constructor(timeoutMs = 60_000) {
|
|
12
13
|
this.timeoutMs = timeoutMs;
|
|
13
14
|
}
|
|
14
15
|
async runScript(script, label, skipConfirmation = false) {
|
|
@@ -37,7 +38,7 @@ class ScriptRunner {
|
|
|
37
38
|
child.kill('SIGTERM');
|
|
38
39
|
setTimeout(() => {
|
|
39
40
|
child.kill('SIGKILL');
|
|
40
|
-
},
|
|
41
|
+
}, 5_000);
|
|
41
42
|
}, this.timeoutMs);
|
|
42
43
|
child.on('close', (code) => {
|
|
43
44
|
clearTimeout(timer);
|
package/dist/core/index.js
CHANGED