cli rework

This commit is contained in:
Oleksandr Honcharov
2024-06-13 22:47:33 +03:00
parent 333bd9df13
commit 36c241a117
4 changed files with 79 additions and 43 deletions
+38 -9
View File
@@ -1,11 +1,40 @@
import yargs from 'yargs'
import c from 'chalk'
import { select } from '@inquirer/prompts'
import create from './commands/create'
import { checkForUpdate } from './utils/update'
import { initProject } from './commands/create'
import { downloadUpdater } from './commands/download-updater'
yargs
.usage('<cmd> [args]')
// .scriptName('rage-fw')
// .usage('$0 <cmd> [args]')
// @ts-ignore
.command(create)
.help().argv
enum Actions {
INIT_PROJECT = 'INIT_PROJECT',
UPDATER = 'UPDATER',
}
;(async () => {
await checkForUpdate()
console.log(
c.blueBright('Rage FW CLI | Powered by Entity Seven Group ️ <3'),
)
const action = await select({
message: c.gray('Select action:'),
choices: [
{
name: 'Initialize new project',
value: Actions.INIT_PROJECT,
description: 'Initialize new project and start develop',
},
{
name: 'Install RAGE:MP updater',
value: Actions.UPDATER,
description:
'Use our custom updater to download and update RAGE:MP server files.',
},
],
loop: true,
})
if (action === Actions.INIT_PROJECT) await initProject()
if (action === Actions.UPDATER) await downloadUpdater()
})()