-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
40 lines (34 loc) · 1.12 KB
/
cli.js
File metadata and controls
40 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
const { Command } = require('commander');
const chalk = require('chalk');
const upgrades = {
'1.0.0': require('./upgrades/1.0.0'),
'2.0.0': require('./upgrades/2.0.0'),
};
const program = new Command();
program
.name('platform-upgrader')
.description('CLI to upgrade the core platform projects')
.version('1.0.0');
program
.command('upgrade')
.argument('<version>', 'Target platform release version')
.option('--dry-run', 'Show what would change without writing files')
.action(async (version, options) => {
const upgradeFn = upgrades[version];
if (!upgradeFn) {
console.error(`No upgrade defined for version ${version}`);
process.exit(1);
}
try {
const dryRun = !!options.dryRun;
console.log(`🔧 Running upgrade to ${version} ${dryRun ? '(dry-run)' : ''}`);
await upgradeFn({ dryRun });
if (dryRun) console.log('🧪 Dry-run complete. No files were modified.');
else console.log('✅ Upgrade complete.');
} catch (err) {
console.error('❌ Upgrade failed:', err.message);
process.exit(1);
}
});
program.parse();