@devquest/cli 1.0.5 → 1.0.6
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 +13 -0
- package/package.json +1 -1
package/dist/commands/clone.js
CHANGED
|
@@ -11,6 +11,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
11
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
12
|
const axios_1 = __importDefault(require("axios"));
|
|
13
13
|
const auth_1 = require("./auth");
|
|
14
|
+
const child_process_1 = require("child_process");
|
|
14
15
|
const env_1 = require("../utils/env");
|
|
15
16
|
exports.cloneCommand = new commander_1.Command('clone')
|
|
16
17
|
.argument('<id>', 'ID do desafio (ex: build-your-own-redis)')
|
|
@@ -81,6 +82,18 @@ exports.cloneCommand = new commander_1.Command('clone')
|
|
|
81
82
|
const git = (0, simple_git_1.default)();
|
|
82
83
|
await git.clone(finalUrl, destPath);
|
|
83
84
|
}
|
|
85
|
+
// 3. Instalar dependências se houver um package.json
|
|
86
|
+
if (fs_1.default.existsSync(path_1.default.join(destPath, 'package.json'))) {
|
|
87
|
+
console.log(chalk_1.default.gray(`\n📦 Instalando dependências...`));
|
|
88
|
+
try {
|
|
89
|
+
// Usamos stdio: 'inherit' para mostrar o progresso para o usuário
|
|
90
|
+
(0, child_process_1.execSync)('npm install', { cwd: destPath, stdio: 'inherit' });
|
|
91
|
+
console.log(chalk_1.default.green(`✅ Dependências instaladas com sucesso.`));
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
console.log(chalk_1.default.yellow(`\n⚠️ Aviso: Não foi possível instalar as dependências automaticamente. Tente rodar 'npm install' manualmente.`));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
84
97
|
console.log(chalk_1.default.green(`✅ Desafio clonado com sucesso em ./${targetFolderName}`));
|
|
85
98
|
console.log(chalk_1.default.yellow(`\nPróximos passos:`));
|
|
86
99
|
console.log(` cd ${targetFolderName}`);
|