feat(update): update cli command
This commit is contained in:
@@ -9,6 +9,7 @@ var updateRepoCmd = require('../src/commands/update-repo');
|
|||||||
var updateBaseCmd = require('../src/commands/update-base');
|
var updateBaseCmd = require('../src/commands/update-base');
|
||||||
var docsCmd = require('../src/commands/docs');
|
var docsCmd = require('../src/commands/docs');
|
||||||
var updateIdeCmd = require('../src/commands/update-ide');
|
var updateIdeCmd = require('../src/commands/update-ide');
|
||||||
|
var updateCliCmd = require('../src/commands/update-cli');
|
||||||
|
|
||||||
var program = new Command();
|
var program = new Command();
|
||||||
|
|
||||||
@@ -22,5 +23,6 @@ updateRepoCmd.register(program);
|
|||||||
updateBaseCmd.register(program);
|
updateBaseCmd.register(program);
|
||||||
docsCmd.register(program);
|
docsCmd.register(program);
|
||||||
updateIdeCmd.register(program);
|
updateIdeCmd.register(program);
|
||||||
|
updateCliCmd.register(program);
|
||||||
|
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ function buildSelectionPage(javaPath, reactNativePath) {
|
|||||||
gap: 14px;
|
gap: 14px;
|
||||||
padding: 18px 22px;
|
padding: 18px 22px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
text-decoration: none;
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
transition: transform 0.15s, box-shadow 0.15s;
|
transition: transform 0.15s, box-shadow 0.15s;
|
||||||
@@ -163,7 +164,7 @@ function buildSelectionPage(javaPath, reactNativePath) {
|
|||||||
<p class="subtitle">Selecione abaixo qual documentação você deseja consultar.</p>
|
<p class="subtitle">Selecione abaixo qual documentação você deseja consultar.</p>
|
||||||
|
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a class="btn btn-primary" href="file://${javaPath}">
|
<button class="btn btn-primary" onclick="window.location.href='file://${javaPath}'">
|
||||||
<span class="btn-icon">
|
<span class="btn-icon">
|
||||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M20 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1zm-1 16H5V5h14v14zM7 12h2v5H7zm4-3h2v8h-2zm4-3h2v11h-2z"/>
|
<path d="M20 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1zm-1 16H5V5h14v14zM7 12h2v5H7zm4-3h2v8h-2zm4-3h2v11h-2z"/>
|
||||||
@@ -173,9 +174,9 @@ function buildSelectionPage(javaPath, reactNativePath) {
|
|||||||
Desktop (Java)
|
Desktop (Java)
|
||||||
<small>API do módulo desktop / back-end</small>
|
<small>API do módulo desktop / back-end</small>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</button>
|
||||||
|
|
||||||
<a class="btn btn-secondary" href="file://${reactNativePath}">
|
<button class="btn btn-secondary" onclick="window.location.href='file://${reactNativePath}'">
|
||||||
<span class="btn-icon">
|
<span class="btn-icon">
|
||||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M17 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zm0 15H7V5h10v12zm-4 3h-2v-1h2v1z"/>
|
<path d="M17 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zm0 15H7V5h10v12zm-4 3h-2v-1h2v1z"/>
|
||||||
@@ -185,7 +186,7 @@ function buildSelectionPage(javaPath, reactNativePath) {
|
|||||||
Mobile (React Native)
|
Mobile (React Native)
|
||||||
<small>API do módulo mobile</small>
|
<small>API do módulo mobile</small>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>Vitruvio CLI — documentação local</footer>
|
<footer>Vitruvio CLI — documentação local</footer>
|
||||||
|
|||||||
@@ -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 };
|
||||||
Reference in New Issue
Block a user