feat(updates): added update-ide to update command
This commit is contained in:
@@ -7,7 +7,6 @@ var pkg = require('../package.json');
|
||||
var initCmd = require('../src/commands/init');
|
||||
var updateCmd = require('../src/commands/update');
|
||||
var docsCmd = require('../src/commands/docs');
|
||||
var updateIdeCmd = require('../src/commands/update-ide');
|
||||
|
||||
var program = new Command();
|
||||
|
||||
@@ -19,6 +18,5 @@ program
|
||||
initCmd.register(program);
|
||||
updateCmd.register(program);
|
||||
docsCmd.register(program);
|
||||
updateIdeCmd.register(program);
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
+44
-58
@@ -176,66 +176,52 @@ function installJetBrains(ideEntry, repoRoot) {
|
||||
console.log('Acesse Settings → Plugins → Install Plugin from Disk e selecione o arquivo .jar.');
|
||||
}
|
||||
|
||||
// ── Command ───────────────────────────────────────────────────────────────────
|
||||
// ── Run ───────────────────────────────────────────────────────────────────────
|
||||
|
||||
function register(program) {
|
||||
program
|
||||
.command('update-ide')
|
||||
.description('Instala ou atualiza a extensão Vitruvio e os snippets na IDE escolhida')
|
||||
.action(function () {
|
||||
console.log('Buscando repositório ide-config...');
|
||||
function run() {
|
||||
console.log(' Buscando repositório ide-config...');
|
||||
|
||||
var tmpDir = null;
|
||||
try {
|
||||
tmpDir = cloneWithFallback(SSH_URL, HTTPS_URL);
|
||||
} catch (e) {
|
||||
console.error('Erro: não foi possível clonar o repositório ide-config.');
|
||||
console.error(e.message);
|
||||
process.exit(1);
|
||||
var tmpDir;
|
||||
try {
|
||||
tmpDir = cloneWithFallback(SSH_URL, HTTPS_URL);
|
||||
} catch (e) {
|
||||
throw new Error('não foi possível clonar o repositório ide-config: ' + e.message);
|
||||
}
|
||||
|
||||
var manifest;
|
||||
try {
|
||||
var manifestPath = path.join(tmpDir, 'ide-manifest.json');
|
||||
if (!fs.existsSync(manifestPath)) {
|
||||
throw new Error('ide-manifest.json não encontrado no repositório ide-config.');
|
||||
}
|
||||
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
} catch (e) {
|
||||
cleanupTemp(tmpDir);
|
||||
throw e;
|
||||
}
|
||||
|
||||
var ideKeys = Object.keys(manifest);
|
||||
if (ideKeys.length === 0) {
|
||||
cleanupTemp(tmpDir);
|
||||
throw new Error('nenhuma IDE encontrada no manifesto.');
|
||||
}
|
||||
|
||||
return promptIde(ideKeys, manifest).then(function (ideKey) {
|
||||
var ideEntry = manifest[ideKey];
|
||||
console.log(' IDE selecionada: ' + ideEntry.label);
|
||||
|
||||
try {
|
||||
if (ideEntry.type === 'vscode-fork') {
|
||||
installVscodeFork(ideEntry, tmpDir);
|
||||
} else if (ideEntry.type === 'jetbrains') {
|
||||
installJetBrains(ideEntry, tmpDir);
|
||||
} else {
|
||||
throw new Error('tipo de IDE desconhecido: ' + ideEntry.type);
|
||||
}
|
||||
|
||||
var manifest;
|
||||
try {
|
||||
var manifestPath = path.join(tmpDir, 'ide-manifest.json');
|
||||
if (!fs.existsSync(manifestPath)) {
|
||||
throw new Error('ide-manifest.json não encontrado no repositório ide-config.');
|
||||
}
|
||||
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
} catch (e) {
|
||||
cleanupTemp(tmpDir);
|
||||
console.error('Erro ao ler o manifesto de IDEs: ' + e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var ideKeys = Object.keys(manifest);
|
||||
if (ideKeys.length === 0) {
|
||||
cleanupTemp(tmpDir);
|
||||
console.error('Nenhuma IDE encontrada no manifesto.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
promptIde(ideKeys, manifest).then(function (ideKey) {
|
||||
var ideEntry = manifest[ideKey];
|
||||
console.log('IDE selecionada: ' + ideEntry.label);
|
||||
console.log('');
|
||||
|
||||
try {
|
||||
if (ideEntry.type === 'vscode-fork') {
|
||||
installVscodeFork(ideEntry, tmpDir);
|
||||
} else if (ideEntry.type === 'jetbrains') {
|
||||
installJetBrains(ideEntry, tmpDir);
|
||||
} else {
|
||||
console.error('Tipo de IDE desconhecido: ' + ideEntry.type);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('');
|
||||
console.log('Configuração da IDE concluída.');
|
||||
} finally {
|
||||
cleanupTemp(tmpDir);
|
||||
}
|
||||
});
|
||||
});
|
||||
} finally {
|
||||
cleanupTemp(tmpDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { register: register };
|
||||
module.exports = { run: run };
|
||||
|
||||
+32
-11
@@ -3,10 +3,11 @@
|
||||
var updateBase = require('./update-base');
|
||||
var updateRepo = require('./update-repo');
|
||||
var updateCli = require('./update-cli');
|
||||
var updateIde = require('./update-ide');
|
||||
|
||||
var TARGETS = ['base', 'repo', 'cli'];
|
||||
var TARGETS = ['base', 'repo', 'cli', 'ide'];
|
||||
|
||||
function runTarget(name) {
|
||||
function runSync(name) {
|
||||
console.log('\n[' + name + ']');
|
||||
if (name === 'base') updateBase.run();
|
||||
else if (name === 'repo') updateRepo.run();
|
||||
@@ -17,12 +18,12 @@ function runTarget(name) {
|
||||
function register(program) {
|
||||
program
|
||||
.command('update [alvo]')
|
||||
.description('Atualiza componentes do Vitruvio (alvo: base | repo | cli). Sem alvo, atualiza tudo.')
|
||||
.description('Atualiza componentes do Vitruvio (alvo: base | repo | cli | ide). Sem alvo, atualiza tudo.')
|
||||
.action(function (alvo) {
|
||||
if (alvo) {
|
||||
var key = alvo.toLowerCase();
|
||||
if (!TARGETS.includes(key)) {
|
||||
console.error('Alvo inválido: "' + alvo + '". Use: base, repo ou cli.');
|
||||
console.error('Alvo inválido: "' + alvo + '". Use: base, repo, cli ou ide.');
|
||||
process.exit(1);
|
||||
}
|
||||
if (key === 'repo' && !updateRepo.isVitruvioRepo(process.cwd())) {
|
||||
@@ -30,8 +31,18 @@ function register(program) {
|
||||
console.error('Execute este comando dentro de um repositório Vitruvio.');
|
||||
process.exit(1);
|
||||
}
|
||||
if (key === 'ide') {
|
||||
console.log('\n[ide]');
|
||||
updateIde.run()
|
||||
.then(function () { console.log(' Concluído.'); })
|
||||
.catch(function (e) {
|
||||
console.error('Erro: ' + e.message);
|
||||
process.exit(1);
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
runTarget(key);
|
||||
runSync(key);
|
||||
} catch (e) {
|
||||
console.error('Erro: ' + e.message);
|
||||
process.exit(1);
|
||||
@@ -45,7 +56,7 @@ function register(program) {
|
||||
|
||||
['base', 'cli'].forEach(function (name) {
|
||||
try {
|
||||
runTarget(name);
|
||||
runSync(name);
|
||||
} catch (e) {
|
||||
errors.push(name + ': ' + e.message);
|
||||
}
|
||||
@@ -53,20 +64,30 @@ function register(program) {
|
||||
|
||||
if (inRepo) {
|
||||
try {
|
||||
runTarget('repo');
|
||||
runSync('repo');
|
||||
} catch (e) {
|
||||
errors.push('repo: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('');
|
||||
if (errors.length > 0) {
|
||||
console.error('Atualização concluída com erros:');
|
||||
console.error('\nAtualização concluída com erros:');
|
||||
errors.forEach(function (msg) { console.error(' ' + msg); });
|
||||
process.exit(1);
|
||||
console.log('\nAtualizando IDE...');
|
||||
} else {
|
||||
console.log('Tudo atualizado com sucesso.');
|
||||
console.log('\nTudo atualizado. Atualizando IDE...');
|
||||
}
|
||||
|
||||
console.log('\n[ide]');
|
||||
updateIde.run()
|
||||
.then(function () {
|
||||
console.log(' Concluído.');
|
||||
if (errors.length > 0) process.exit(1);
|
||||
})
|
||||
.catch(function (e) {
|
||||
console.error(' ide: ' + e.message);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user