kaven-cli 0.3.5 → 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/dist/commands/config/features.js +1026 -0
- package/dist/commands/config/index.js +1 -34
- package/dist/commands/index.js +1 -0
- package/dist/commands/init/index.js +25 -37
- package/dist/commands/marketplace/browse.js +1 -34
- package/dist/commands/module/activate.js +206 -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 +15 -3
- package/dist/core/RegistryResolver.js +3 -2
- package/dist/core/SchemaActivator.js +270 -0
- package/dist/core/ScriptRunner.js +3 -2
- package/dist/core/index.js +1 -0
- package/dist/index.js +69 -2
- package/dist/infrastructure/Container.js +2 -4
- package/dist/infrastructure/MarketplaceClient.js +5 -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/package.json +2 -1
|
@@ -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
|
};
|
|
@@ -113,7 +80,7 @@ async function configView(options) {
|
|
|
113
80
|
* C2.4: Config reset — Reset to defaults
|
|
114
81
|
*/
|
|
115
82
|
async function configReset() {
|
|
116
|
-
const { confirm } = await
|
|
83
|
+
const { confirm } = await import("@inquirer/prompts");
|
|
117
84
|
const confirmed = await confirm({
|
|
118
85
|
message: "Are you sure you want to reset config to defaults?",
|
|
119
86
|
default: false,
|
package/dist/commands/index.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
|
};
|
|
@@ -45,7 +12,7 @@ const ProjectInitializer_1 = require("../../core/ProjectInitializer");
|
|
|
45
12
|
const ConfigManager_1 = require("../../core/ConfigManager");
|
|
46
13
|
async function promptAnswers(projectName) {
|
|
47
14
|
// Dynamic import to keep startup fast and avoid issues if not installed
|
|
48
|
-
const { input, select } = await
|
|
15
|
+
const { input, select } = await import("@inquirer/prompts");
|
|
49
16
|
// Load defaults from config if available
|
|
50
17
|
await ConfigManager_1.configManager.initialize();
|
|
51
18
|
const existingDefaults = ConfigManager_1.configManager.getAll().projectDefaults || {};
|
|
@@ -83,7 +50,7 @@ async function initProject(projectName, options) {
|
|
|
83
50
|
resolvedName = "my-kaven-app";
|
|
84
51
|
}
|
|
85
52
|
else {
|
|
86
|
-
const { input } = await
|
|
53
|
+
const { input } = await import("@inquirer/prompts");
|
|
87
54
|
resolvedName = await input({
|
|
88
55
|
message: "Project name:",
|
|
89
56
|
default: "my-kaven-app",
|
|
@@ -126,7 +93,7 @@ async function initProject(projectName, options) {
|
|
|
126
93
|
// Clone template
|
|
127
94
|
const cloneSpinner = (0, ora_1.default)("Cloning kaven-template...").start();
|
|
128
95
|
try {
|
|
129
|
-
await initializer.cloneTemplate(targetDir);
|
|
96
|
+
await initializer.cloneTemplate(targetDir, options.template);
|
|
130
97
|
cloneSpinner.succeed("Template cloned successfully");
|
|
131
98
|
}
|
|
132
99
|
catch (error) {
|
|
@@ -170,6 +137,21 @@ async function initProject(projectName, options) {
|
|
|
170
137
|
console.error(chalk_1.default.gray(error instanceof Error ? error.message : String(error)));
|
|
171
138
|
}
|
|
172
139
|
}
|
|
140
|
+
// Install kaven-squad (optional, non-fatal)
|
|
141
|
+
if (options.withSquad) {
|
|
142
|
+
const squadSpinner = (0, ora_1.default)("Installing kaven-squad...").start();
|
|
143
|
+
const squadResult = await initializer.installSquad(targetDir);
|
|
144
|
+
if (squadResult.installed) {
|
|
145
|
+
squadSpinner.succeed("kaven-squad installed in squads/kaven-squad/");
|
|
146
|
+
}
|
|
147
|
+
else if (squadResult.reason === "already-exists") {
|
|
148
|
+
squadSpinner.info("kaven-squad already installed — skipping");
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
squadSpinner.warn(`Could not install kaven-squad automatically (${squadResult.reason})`);
|
|
152
|
+
console.log(chalk_1.default.yellow(" ⚠ Install manually inside the project: *download-squad kaven-squad"));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
173
155
|
// Health check
|
|
174
156
|
const healthCheckSpinner = (0, ora_1.default)("Running health check...").start();
|
|
175
157
|
const health = await initializer.healthCheck(targetDir);
|
|
@@ -192,7 +174,13 @@ async function initProject(projectName, options) {
|
|
|
192
174
|
console.log(chalk_1.default.cyan(" npx prisma migrate dev"));
|
|
193
175
|
console.log(chalk_1.default.cyan(" pnpm dev"));
|
|
194
176
|
console.log();
|
|
195
|
-
console.log(chalk_1.default.gray("For more help, visit: https://docs.kaven.
|
|
177
|
+
console.log(chalk_1.default.gray("For more help, visit: https://docs.kaven.site/getting-started"));
|
|
178
|
+
if (options.withSquad) {
|
|
179
|
+
console.log();
|
|
180
|
+
console.log(chalk_1.default.bold("AIOX Squad next step:"));
|
|
181
|
+
console.log(chalk_1.default.cyan(" node /path/to/aiox-core/bin/aiox.js install --quiet --merge"));
|
|
182
|
+
console.log(chalk_1.default.gray(" (replace /path/to/aiox-core with your AIOX installation path)"));
|
|
183
|
+
}
|
|
196
184
|
// Save project defaults to config for future use
|
|
197
185
|
await ConfigManager_1.configManager.initialize();
|
|
198
186
|
try {
|
|
@@ -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
|
};
|
|
@@ -68,7 +35,7 @@ async function marketplaceBrowse() {
|
|
|
68
35
|
selectedModule: null,
|
|
69
36
|
screen: "categories",
|
|
70
37
|
};
|
|
71
|
-
const { select } = await
|
|
38
|
+
const { select } = await import("@inquirer/prompts");
|
|
72
39
|
while (state.screen !== "exit") {
|
|
73
40
|
if (state.screen === "categories") {
|
|
74
41
|
// Step 1: Category selection
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.moduleActivate = moduleActivate;
|
|
7
|
+
exports.moduleDeactivate = moduleDeactivate;
|
|
8
|
+
exports.moduleListActivation = moduleListActivation;
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const ora_1 = __importDefault(require("ora"));
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const SchemaActivator_1 = require("../../core/SchemaActivator");
|
|
13
|
+
const TelemetryBuffer_1 = require("../../infrastructure/TelemetryBuffer");
|
|
14
|
+
// ============================================================
|
|
15
|
+
// Helpers
|
|
16
|
+
// ============================================================
|
|
17
|
+
function findModuleDef(moduleId) {
|
|
18
|
+
return SchemaActivator_1.KAVEN_MODULES.find((m) => m.id === moduleId.toLowerCase());
|
|
19
|
+
}
|
|
20
|
+
function assertSchemaExists(exists, root) {
|
|
21
|
+
if (!exists) {
|
|
22
|
+
const fullPath = node_path_1.default.join(root, "packages", "database", "prisma", "schema.extended.prisma");
|
|
23
|
+
console.error(chalk_1.default.red(`\nErro: Schema não encontrado em: ${fullPath}`));
|
|
24
|
+
console.error(chalk_1.default.gray("Certifique-se de que o caminho fornecido é a raiz de um projeto Kaven válido."));
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// ============================================================
|
|
29
|
+
// kaven module activate <name>
|
|
30
|
+
// ============================================================
|
|
31
|
+
async function moduleActivate(moduleName, projectRoot) {
|
|
32
|
+
const telemetry = TelemetryBuffer_1.TelemetryBuffer.getInstance();
|
|
33
|
+
const startTime = Date.now();
|
|
34
|
+
telemetry.capture("cli.module.activate.start", { moduleName });
|
|
35
|
+
const root = projectRoot ?? process.cwd();
|
|
36
|
+
const activator = new SchemaActivator_1.SchemaActivator(root);
|
|
37
|
+
const spinner = (0, ora_1.default)(`Ativando módulo ${moduleName}...`).start();
|
|
38
|
+
try {
|
|
39
|
+
// 1. Validar que o schema existe
|
|
40
|
+
const exists = await activator.exists();
|
|
41
|
+
spinner.stop();
|
|
42
|
+
assertSchemaExists(exists, root);
|
|
43
|
+
// 2. Validar que o módulo é conhecido
|
|
44
|
+
const def = findModuleDef(moduleName);
|
|
45
|
+
if (!def) {
|
|
46
|
+
console.error(chalk_1.default.red(`\nMódulo desconhecido: "${moduleName}".`));
|
|
47
|
+
console.error(chalk_1.default.gray(`Módulos disponíveis: ${SchemaActivator_1.KAVEN_MODULES.map((m) => m.id).join(", ")}`));
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
// 3. Verificar dependências
|
|
51
|
+
if (def.dependsOn.length > 0) {
|
|
52
|
+
spinner.start("Verificando dependências...");
|
|
53
|
+
const depStatuses = [];
|
|
54
|
+
for (const depId of def.dependsOn) {
|
|
55
|
+
const depDef = findModuleDef(depId);
|
|
56
|
+
if (!depDef)
|
|
57
|
+
continue;
|
|
58
|
+
const status = await activator.getModuleStatus(depDef);
|
|
59
|
+
depStatuses.push(status);
|
|
60
|
+
}
|
|
61
|
+
const missing = depStatuses.filter((s) => !s.active);
|
|
62
|
+
if (missing.length > 0) {
|
|
63
|
+
spinner.stop();
|
|
64
|
+
console.error(chalk_1.default.red(`\nDependências inativas para "${moduleName}": ${missing.map((m) => m.id).join(", ")}`));
|
|
65
|
+
console.error(chalk_1.default.gray(`Ative as dependências primeiro:\n${missing.map((m) => ` kaven module activate ${m.id}`).join("\n")}`));
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
spinner.stop();
|
|
69
|
+
}
|
|
70
|
+
// 4. Verificar se já está ativo
|
|
71
|
+
const current = await activator.getModuleStatus(def);
|
|
72
|
+
if (current.active) {
|
|
73
|
+
console.log(chalk_1.default.yellow(`\nMódulo "${def.label}" já está ativo.`));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// 5. Ativar
|
|
77
|
+
spinner.start(`Descomentando modelos de ${def.label} no schema...`);
|
|
78
|
+
await activator.activateModule(def);
|
|
79
|
+
spinner.succeed(chalk_1.default.green(`\nMódulo ${def.label} ativado. ${def.models.length} models adicionados: ${def.models.join(", ")}`));
|
|
80
|
+
console.log(chalk_1.default.cyan("\nSugestão: Execute `pnpm db:generate && pnpm db:migrate` para aplicar as mudanças."));
|
|
81
|
+
telemetry.capture("cli.module.activate.success", { moduleName: def.id, models: def.models.length }, Date.now() - startTime);
|
|
82
|
+
await telemetry.flush();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
spinner.fail(chalk_1.default.red(`Falha ao ativar módulo: ${error instanceof Error ? error.message : String(error)}`));
|
|
86
|
+
telemetry.capture("cli.module.activate.error", { moduleName, error: error.message }, Date.now() - startTime);
|
|
87
|
+
await telemetry.flush();
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// ============================================================
|
|
92
|
+
// kaven module deactivate <name>
|
|
93
|
+
// ============================================================
|
|
94
|
+
async function moduleDeactivate(moduleName, projectRoot) {
|
|
95
|
+
const telemetry = TelemetryBuffer_1.TelemetryBuffer.getInstance();
|
|
96
|
+
const startTime = Date.now();
|
|
97
|
+
telemetry.capture("cli.module.deactivate.start", { moduleName });
|
|
98
|
+
const root = projectRoot ?? process.cwd();
|
|
99
|
+
const activator = new SchemaActivator_1.SchemaActivator(root);
|
|
100
|
+
const spinner = (0, ora_1.default)(`Desativando módulo ${moduleName}...`).start();
|
|
101
|
+
try {
|
|
102
|
+
// 1. Validar que o schema existe
|
|
103
|
+
const exists = await activator.exists();
|
|
104
|
+
spinner.stop();
|
|
105
|
+
assertSchemaExists(exists, root);
|
|
106
|
+
// 2. Validar módulo
|
|
107
|
+
const def = findModuleDef(moduleName);
|
|
108
|
+
if (!def) {
|
|
109
|
+
console.error(chalk_1.default.red(`\nMódulo desconhecido: "${moduleName}".`));
|
|
110
|
+
console.error(chalk_1.default.gray(`Módulos disponíveis: ${SchemaActivator_1.KAVEN_MODULES.map((m) => m.id).join(", ")}`));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
// 3. Verificar se outros módulos ativos dependem deste
|
|
114
|
+
spinner.start("Verificando dependências reversas...");
|
|
115
|
+
const dependents = [];
|
|
116
|
+
for (const candidate of SchemaActivator_1.KAVEN_MODULES) {
|
|
117
|
+
if (candidate.id === def.id)
|
|
118
|
+
continue;
|
|
119
|
+
if (!candidate.dependsOn.includes(def.id))
|
|
120
|
+
continue;
|
|
121
|
+
const status = await activator.getModuleStatus(candidate);
|
|
122
|
+
if (status.active) {
|
|
123
|
+
dependents.push(candidate.id);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (dependents.length > 0) {
|
|
127
|
+
spinner.stop();
|
|
128
|
+
console.error(chalk_1.default.red(`\nNão é possível desativar "${moduleName}": os seguintes módulos dependem dele e estão ativos:`));
|
|
129
|
+
console.error(chalk_1.default.gray(` ${dependents.join(", ")}`));
|
|
130
|
+
console.error(chalk_1.default.gray(`Desative-os primeiro:\n${dependents.map((d) => ` kaven module deactivate ${d}`).join("\n")}`));
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
// 4. Verificar se já está inativo
|
|
134
|
+
const current = await activator.getModuleStatus(def);
|
|
135
|
+
if (!current.active) {
|
|
136
|
+
spinner.stop();
|
|
137
|
+
console.log(chalk_1.default.yellow(`\nMódulo "${def.label}" já está inativo.`));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// 5. Desativar
|
|
141
|
+
spinner.start(`Comentando modelos de ${def.label} no schema...`);
|
|
142
|
+
await activator.deactivateModule(def);
|
|
143
|
+
spinner.succeed(chalk_1.default.green(`\nMódulo ${def.label} desativado com sucesso.`));
|
|
144
|
+
console.log(chalk_1.default.cyan("\nSugestão: Execute `pnpm db:generate && pnpm db:migrate` para aplicar as mudanças."));
|
|
145
|
+
telemetry.capture("cli.module.deactivate.success", { moduleName: def.id }, Date.now() - startTime);
|
|
146
|
+
await telemetry.flush();
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
spinner.fail(chalk_1.default.red(`Falha ao desativar módulo: ${error instanceof Error ? error.message : String(error)}`));
|
|
150
|
+
telemetry.capture("cli.module.deactivate.error", { moduleName, error: error.message }, Date.now() - startTime);
|
|
151
|
+
await telemetry.flush();
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// ============================================================
|
|
156
|
+
// kaven module list
|
|
157
|
+
// ============================================================
|
|
158
|
+
async function moduleListActivation(projectRoot) {
|
|
159
|
+
const root = projectRoot ?? process.cwd();
|
|
160
|
+
const activator = new SchemaActivator_1.SchemaActivator(root);
|
|
161
|
+
const schemaExists = await activator.exists();
|
|
162
|
+
// Cabeçalho da tabela
|
|
163
|
+
const COL = {
|
|
164
|
+
module: 14,
|
|
165
|
+
status: 10,
|
|
166
|
+
models: 44,
|
|
167
|
+
deps: 20,
|
|
168
|
+
};
|
|
169
|
+
const header = chalk_1.default.bold("Module".padEnd(COL.module)) +
|
|
170
|
+
chalk_1.default.bold("Status".padEnd(COL.status)) +
|
|
171
|
+
chalk_1.default.bold("Models".padEnd(COL.models)) +
|
|
172
|
+
chalk_1.default.bold("Depends on");
|
|
173
|
+
const divider = "─".repeat(COL.module + COL.status + COL.models + COL.deps);
|
|
174
|
+
console.log();
|
|
175
|
+
console.log(chalk_1.default.blue("Módulos Kaven disponíveis\n"));
|
|
176
|
+
console.log(header);
|
|
177
|
+
console.log(chalk_1.default.gray(divider));
|
|
178
|
+
if (!schemaExists) {
|
|
179
|
+
for (const def of SchemaActivator_1.KAVEN_MODULES) {
|
|
180
|
+
const modCol = def.id.padEnd(COL.module);
|
|
181
|
+
const statusCol = chalk_1.default.gray("unknown".padEnd(COL.status));
|
|
182
|
+
const modelsCol = def.models.join(", ").padEnd(COL.models);
|
|
183
|
+
const depsCol = def.dependsOn.length > 0 ? def.dependsOn.join(", ") : "—";
|
|
184
|
+
console.log(`${modCol}${statusCol}${modelsCol}${depsCol}`);
|
|
185
|
+
}
|
|
186
|
+
console.log();
|
|
187
|
+
console.log(chalk_1.default.yellow("Atenção: schema.extended.prisma não encontrado. Status não pode ser determinado."));
|
|
188
|
+
console.log(chalk_1.default.gray("Execute este comando na raiz de um projeto Kaven para ver o status real."));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
for (const def of SchemaActivator_1.KAVEN_MODULES) {
|
|
192
|
+
const status = await activator.getModuleStatus(def);
|
|
193
|
+
const modCol = def.id.padEnd(COL.module);
|
|
194
|
+
const statusText = status.active ? "active" : "inactive";
|
|
195
|
+
const statusColored = status.active
|
|
196
|
+
? chalk_1.default.green(statusText.padEnd(COL.status))
|
|
197
|
+
: chalk_1.default.gray(statusText.padEnd(COL.status));
|
|
198
|
+
const modelsCol = def.models.join(", ").padEnd(COL.models);
|
|
199
|
+
const depsCol = def.dependsOn.length > 0 ? def.dependsOn.join(", ") : "—";
|
|
200
|
+
console.log(`${modCol}${statusColored}${modelsCol}${depsCol}`);
|
|
201
|
+
}
|
|
202
|
+
console.log();
|
|
203
|
+
console.log(chalk_1.default.gray("Core (sempre ativo): Tenant, User, Role, Capability, AuthSession, AuditLog"));
|
|
204
|
+
console.log();
|
|
205
|
+
console.log(chalk_1.default.gray("Para ativar: kaven module activate <name> | Para desativar: kaven module deactivate <name>"));
|
|
206
|
+
}
|
|
@@ -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
|
};
|
|
@@ -95,7 +62,7 @@ async function sha256File(filePath) {
|
|
|
95
62
|
}
|
|
96
63
|
/** Create tar.gz archive of current directory, excluding common noise. */
|
|
97
64
|
async function createTarball(sourceDir, outputPath) {
|
|
98
|
-
const tar = await
|
|
65
|
+
const tar = await import("tar");
|
|
99
66
|
await tar.create({
|
|
100
67
|
gzip: true,
|
|
101
68
|
file: outputPath,
|
|
@@ -281,7 +248,7 @@ async function modulePublish(options) {
|
|
|
281
248
|
await fs_extra_1.default.remove(tarballPath).catch(() => { });
|
|
282
249
|
console.log();
|
|
283
250
|
console.log(chalk_1.default.green(`✅ Published ${moduleJson.name} v${moduleJson.version} to the Kaven Marketplace!`));
|
|
284
|
-
console.log(chalk_1.default.gray(`View your module at: https://marketplace.kaven.
|
|
251
|
+
console.log(chalk_1.default.gray(`View your module at: https://marketplace.kaven.site/modules/${moduleJson.slug}`));
|
|
285
252
|
// Show next steps
|
|
286
253
|
console.log();
|
|
287
254
|
console.log(chalk_1.default.bold("Next steps:"));
|
|
@@ -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
|