@devquest/cli 1.0.2 → 1.0.3
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/clone.js +21 -7
- package/dist/utils/env.js +5 -5
- package/package.json +1 -1
package/dist/commands/clone.js
CHANGED
|
@@ -24,7 +24,6 @@ exports.cloneCommand = new commander_1.Command('clone')
|
|
|
24
24
|
console.log(chalk_1.default.blue(`🚀 Iniciando o desafio: ${id}`));
|
|
25
25
|
try {
|
|
26
26
|
// 1. Requisitar a URL do repositório para este usuário/desafio do Backend
|
|
27
|
-
// Isso criaria um "provisionamento" do repositório no backend
|
|
28
27
|
const response = await axios_1.default.post(`${env_1.API_BASE}/challenges/${id}/clone`, {}, {
|
|
29
28
|
headers: { Authorization: `Bearer ${token}` }
|
|
30
29
|
});
|
|
@@ -35,16 +34,31 @@ exports.cloneCommand = new commander_1.Command('clone')
|
|
|
35
34
|
process.exit(1);
|
|
36
35
|
}
|
|
37
36
|
let finalUrl = cloneUrl;
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
// Lógica dinâmica sugerida pelo usuário:
|
|
38
|
+
// Se estiver local (IS_DEV) e o link for file://, resolvemos para o caminho local do monorepo
|
|
39
|
+
if (env_1.IS_DEV && cloneUrl.startsWith('file://')) {
|
|
40
|
+
// Assume que estamos no monorepo e templates estão em ../../../../templates
|
|
41
|
+
const repoRoot = path_1.default.resolve(__dirname, '../../../..');
|
|
42
|
+
const templateName = cloneUrl.replace('file://../../templates/', '');
|
|
43
|
+
const localPath = path_1.default.join(repoRoot, 'templates', templateName);
|
|
44
|
+
if (fs_1.default.existsSync(localPath)) {
|
|
45
|
+
finalUrl = `file://${localPath}`;
|
|
46
|
+
console.log(chalk_1.default.cyan(`🏠 Ambiente de desenvolvimento detectado. Usando template local.`));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Se não achar local mesmo em dev, tenta o fallback remoto
|
|
50
|
+
finalUrl = `https://github.com/kalmonj/devquest-template-${id}.git`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Se não estiver em dev e for um link de arquivo (que veio do banco do monorepo),
|
|
54
|
+
// ou se o link do banco for inválido para produção
|
|
55
|
+
else if (!env_1.IS_DEV && cloneUrl.startsWith('file://')) {
|
|
56
|
+
finalUrl = `https://github.com/kalmonj/devquest-template-${id}.git`;
|
|
57
|
+
console.log(chalk_1.default.cyan(`🌐 CLI em produção. Usando repositório remoto oficial.`));
|
|
42
58
|
}
|
|
43
59
|
console.log(chalk_1.default.gray(`Clonando de ${finalUrl} para ${destPath}...`));
|
|
44
60
|
const git = (0, simple_git_1.default)();
|
|
45
61
|
await git.clone(finalUrl, destPath);
|
|
46
|
-
// 2. O boilerplate baixado deverá ter o origin já devidamente setado
|
|
47
|
-
// O remote será algo como http://git.plataforma.com/hash.git (servidor git interno)
|
|
48
62
|
console.log(chalk_1.default.green(`✅ Desafio clonado com sucesso em ./${targetDir || id}`));
|
|
49
63
|
console.log(chalk_1.default.yellow(`\nPróximos passos:`));
|
|
50
64
|
console.log(` cd ${targetDir || id}`);
|
package/dist/utils/env.js
CHANGED
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SSE_BASE = exports.API_BASE = exports.DASHBOARD_URL = void 0;
|
|
6
|
+
exports.SSE_BASE = exports.API_BASE = exports.DASHBOARD_URL = exports.IS_DEV = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
exports.DASHBOARD_URL =
|
|
11
|
-
exports.API_BASE =
|
|
12
|
-
exports.SSE_BASE =
|
|
9
|
+
exports.IS_DEV = fs_1.default.existsSync(path_1.default.join(__dirname, '..', 'src')) || fs_1.default.existsSync(path_1.default.join(__dirname, '..', '..', 'src'));
|
|
10
|
+
exports.DASHBOARD_URL = exports.IS_DEV ? 'http://localhost:3000' : 'https://devquest-web.vercel.app';
|
|
11
|
+
exports.API_BASE = exports.IS_DEV ? 'http://localhost:8787' : 'https://api.devkalmon.workers.dev';
|
|
12
|
+
exports.SSE_BASE = exports.IS_DEV ? 'http://localhost:8787/challenges/sse' : 'https://api.devkalmon.workers.dev/challenges/sse';
|