feat(cli): changed cli update to new npm way

This commit is contained in:
jb
2026-04-23 15:02:04 -03:00
parent eae4b1291b
commit 8a0a99b2cf
+2 -25
View File
@@ -1,35 +1,12 @@
'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');
var NPM_URL = 'git+https://gitea.vitruvio.com.br/davinti/vitruvio-cli.git';
function run() {
console.log(' Buscando versão mais recente do Vitruvio CLI...');
var tmpDir = cloneWithFallback(SSH_URL, HTTPS_URL);
try {
if (fs.existsSync(INSTALL_DIR)) fse.removeSync(INSTALL_DIR);
fse.copySync(tmpDir, INSTALL_DIR);
} finally {
cleanupTemp(tmpDir);
}
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' });
execSync('npm install -g ' + NPM_URL, { stdio: 'inherit' });
}
module.exports = { run: run };