From 992cb0e7dd718c104f9879dacc43afccae5586fb Mon Sep 17 00:00:00 2001 From: jb Date: Fri, 17 Apr 2026 14:49:58 -0300 Subject: [PATCH] feat(update): update cli command --- bin/vitruvio.js | 2 ++ src/commands/docs.js | 11 +++---- src/commands/update-cli.js | 59 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 src/commands/update-cli.js diff --git a/bin/vitruvio.js b/bin/vitruvio.js index b6c8709..860382c 100755 --- a/bin/vitruvio.js +++ b/bin/vitruvio.js @@ -9,6 +9,7 @@ var updateRepoCmd = require('../src/commands/update-repo'); var updateBaseCmd = require('../src/commands/update-base'); var docsCmd = require('../src/commands/docs'); var updateIdeCmd = require('../src/commands/update-ide'); +var updateCliCmd = require('../src/commands/update-cli'); var program = new Command(); @@ -22,5 +23,6 @@ updateRepoCmd.register(program); updateBaseCmd.register(program); docsCmd.register(program); updateIdeCmd.register(program); +updateCliCmd.register(program); program.parse(process.argv); diff --git a/src/commands/docs.js b/src/commands/docs.js index f6a0d6e..e4ad154 100644 --- a/src/commands/docs.js +++ b/src/commands/docs.js @@ -94,7 +94,8 @@ function buildSelectionPage(javaPath, reactNativePath) { gap: 14px; padding: 18px 22px; border-radius: 12px; - text-decoration: none; + border: none; + cursor: pointer; font-weight: 600; font-size: 1rem; transition: transform 0.15s, box-shadow 0.15s; @@ -163,7 +164,7 @@ function buildSelectionPage(javaPath, reactNativePath) {

Selecione abaixo qual documentação você deseja consultar.

- + - +
diff --git a/src/commands/update-cli.js b/src/commands/update-cli.js new file mode 100644 index 0000000..6ae811f --- /dev/null +++ b/src/commands/update-cli.js @@ -0,0 +1,59 @@ +'use strict'; + +var path = require('path'); +var os = require('os'); +var fs = require('fs'); +var fse = require('fs-extra'); +var { execSync } = require('child_process'); +var { cloneWithFallback, cleanupTemp } = require('../utils/git'); + +var SSH_URL = 'ssh://git@git.davinti.com.br:2222/davinTI/vitruvio-cli.git'; +var HTTPS_URL = 'https://git.davinti.com.br/davinTI/vitruvio-cli.git'; + +var INSTALL_DIR = path.join(os.homedir(), '.local', 'share', 'vitruvio-cli'); + +function register(program) { + program + .command('update-cli') + .description('Atualiza o Vitruvio CLI para a versão mais recente') + .action(function () { + console.log('Buscando versão mais recente do Vitruvio CLI...'); + + var tmpDir = null; + try { + tmpDir = cloneWithFallback(SSH_URL, HTTPS_URL); + } catch (e) { + console.error('Erro: não foi possível baixar o repositório do CLI.'); + console.error(e.message); + process.exit(1); + } + + try { + // Replace stable install dir with fresh clone + if (fs.existsSync(INSTALL_DIR)) { + fse.removeSync(INSTALL_DIR); + } + fse.copySync(tmpDir, INSTALL_DIR); + } finally { + cleanupTemp(tmpDir); + } + + try { + console.log('Instalando dependências...'); + execSync('npm install', { cwd: INSTALL_DIR, stdio: 'inherit' }); + + console.log('Vinculando comando vitruvio...'); + try { execSync('npm unlink -g vitruvio', { stdio: 'pipe' }); } catch (_) { } + execSync('npm link', { cwd: INSTALL_DIR, stdio: 'inherit' }); + + console.log(''); + console.log('Vitruvio CLI atualizado com sucesso.'); + console.log('Origem: ' + INSTALL_DIR); + } catch (e) { + console.error('Erro ao instalar o CLI: ' + e.message); + process.exit(1); + } + }); +} + +module.exports = { register: register };