vladx 1.1.1 → 1.2.1
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/package.json +1 -1
- package/programs/1/index.vx +3 -0
- package/programs/1/vladx-lock.json +5 -0
- package/programs/1/vladx.json +14 -0
- package/src/pm/cli.js +21 -0
- package/src/pm/commands/run.js +77 -0
package/package.json
CHANGED
package/src/pm/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ const uninstall = require('./commands/uninstall.js');
|
|
|
11
11
|
const search = require('./commands/search.js');
|
|
12
12
|
const list = require('./commands/list.js');
|
|
13
13
|
const config = require('./commands/config.js');
|
|
14
|
+
const runCmd = require('./commands/run.js');
|
|
14
15
|
|
|
15
16
|
const VERSION = '1.0.0';
|
|
16
17
|
|
|
@@ -40,6 +41,10 @@ ${colorize('Uso:', 'cyan')}
|
|
|
40
41
|
vladpm uninstall <pkg> Rimuove un pacchetto
|
|
41
42
|
vladpm search <query> Cerca pacchetti
|
|
42
43
|
vladpm list Lista pacchetti installati
|
|
44
|
+
vladpm run <script> Esegue uno script definito in vladx.json
|
|
45
|
+
vladpm start Scorciatoia per "vladpm run start"
|
|
46
|
+
vladpm test Scorciatoia per "vladpm run test"
|
|
47
|
+
vladpm dev Scorciatoia per "vladpm run dev"
|
|
43
48
|
vladpm --help, -h Mostra questo aiuto
|
|
44
49
|
vladpm --version, -v Mostra la versione
|
|
45
50
|
|
|
@@ -116,6 +121,22 @@ async function run(args) {
|
|
|
116
121
|
await config.execute(args.slice(1));
|
|
117
122
|
break;
|
|
118
123
|
|
|
124
|
+
case 'run':
|
|
125
|
+
await runCmd.execute(args.slice(1));
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case 'start':
|
|
129
|
+
await runCmd.execute(['start', ...args.slice(1)]);
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case 'test':
|
|
133
|
+
await runCmd.execute(['test', ...args.slice(1)]);
|
|
134
|
+
break;
|
|
135
|
+
|
|
136
|
+
case 'dev':
|
|
137
|
+
await runCmd.execute(['dev', ...args.slice(1)]);
|
|
138
|
+
break;
|
|
139
|
+
|
|
119
140
|
default:
|
|
120
141
|
console.error(colorize(`✗ Comando sconosciuto: ${command}`, 'red'));
|
|
121
142
|
console.log('Usa "vladpm --help" per vedere i comandi disponibili.');
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VladPM - run command
|
|
3
|
+
* Esegue script definiti in vladx.json
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
const { getVladxJson } = require('../utils/config.js');
|
|
8
|
+
|
|
9
|
+
const COLORS = {
|
|
10
|
+
reset: '\x1b[0m',
|
|
11
|
+
bright: '\x1b[1m',
|
|
12
|
+
red: '\x1b[31m',
|
|
13
|
+
green: '\x1b[32m',
|
|
14
|
+
yellow: '\x1b[33m',
|
|
15
|
+
cyan: '\x1b[36m'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function colorize(text, color) {
|
|
19
|
+
return `${COLORS[color]}${text}${COLORS.reset}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function execute(args) {
|
|
23
|
+
if (args.length === 0) {
|
|
24
|
+
console.error(colorize('✗ Errore: Specificare il nome dello script da eseguire.', 'red'));
|
|
25
|
+
console.log('Uso: vladpm run <script>');
|
|
26
|
+
showScripts();
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const scriptName = args[0];
|
|
31
|
+
const vladxJson = getVladxJson();
|
|
32
|
+
|
|
33
|
+
if (!vladxJson) {
|
|
34
|
+
console.error(colorize('✗ Errore: vladx.json non trovato.', 'red'));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const scripts = vladxJson.scripts || {};
|
|
39
|
+
const command = scripts[scriptName];
|
|
40
|
+
|
|
41
|
+
if (!command) {
|
|
42
|
+
console.error(colorize(`✗ Errore: Script "${scriptName}" non trovato in vladx.json.`, 'red'));
|
|
43
|
+
showScripts(scripts);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`\n> ${vladxJson.name}@${vladxJson.version} ${scriptName}`);
|
|
48
|
+
console.log(`> ${command}\n`);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
// Aggiungiamo il path della bin di vladx locale all'ambiente se necessario
|
|
52
|
+
// Ma per ora assumiamo che vladx sia nel path o eseguito tramite node
|
|
53
|
+
|
|
54
|
+
execSync(command, {
|
|
55
|
+
stdio: 'inherit',
|
|
56
|
+
env: { ...process.env, PATH: `${process.env.PATH}:${process.cwd()}/node_modules/.bin` }
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
process.exit(error.status || 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function showScripts(scripts) {
|
|
64
|
+
if (!scripts) {
|
|
65
|
+
const vladxJson = getVladxJson();
|
|
66
|
+
scripts = vladxJson ? vladxJson.scripts : null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (scripts && Object.keys(scripts).length > 0) {
|
|
70
|
+
console.log('\nScript disponibili:');
|
|
71
|
+
for (const name of Object.keys(scripts)) {
|
|
72
|
+
console.log(` - ${colorize(name, 'cyan')}: ${scripts[name]}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { execute };
|