From 495217ecd5bd992890a4bcae23910807faf263e1 Mon Sep 17 00:00:00 2001 From: Danya H Date: Wed, 30 Oct 2024 18:31:53 +0000 Subject: [PATCH] upd cli - handled process exit - updated docs + readme - typos fix --- cli/package.json | 2 +- cli/readme.md | 40 +++++++++++++++++++++++------------- cli/src/commands/create.ts | 11 +++++----- cli/src/commands/test-rpc.ts | 13 ++++++------ cli/src/index.ts | 18 ++++++++++++---- 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/cli/package.json b/cli/package.json index d701fe8..5a78add 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@entityseven/create-rage-fw", - "version": "0.1.1", + "version": "0.1.2", "bin": { "rage-fw": "dist/index.js" }, diff --git a/cli/readme.md b/cli/readme.md index cff24d6..bd2cf4a 100644 --- a/cli/readme.md +++ b/cli/readme.md @@ -1,29 +1,41 @@ -# RageFW CLI - -To make you life easier while using RageFW we created a basic CLI. At the moment automation we have only works via [pnpm](https://pnpm.io/) +To make you life easier while using RageFW we created a basic CLI. At the moment automation we have only works via [pnpm](https://pnpm.io/) and [bun](https://bun.sh/) ``pnpm create @entityseven/rage-fw@latest`` -## TL;DR +``bun create @entityseven/rage-fw@latest`` + +# TL;DR - ``Initialize new project`` - create new template project +- ``Test our RPC`` - scaffold an example for ``@entityseven/rage-fw-rpc`` - ``Install RAGE:MP updater`` - download and update RAGE:MP server files -## Options +# Options For now, you will see a few available options. They are described in detail below - ``Initialize new project`` +- ``Test our RPC`` - ``Install RAGE:MP updater`` -### Initialize new project -Using this options will forward you to common project-creation menu -- ``Enter project name`` +## Initialize new project +Using this option will forward you to common project creation menu -This option will specify a name for your project which is used as a folder name too. Defaults to **rage-fw** +- ``Enter project name`` + This option will specify a name for your project which is used as a folder name too. Defaults to **rage-fw-example** -- ``Select frontend`` +- ``Select front-end`` + Use selector menu to choose which front-end framework you want to use. We will do our best to expand this menu with various solutions -Use this selector menu to choose which frontend framework you want to use. We will do our best to expand this menu after some time. -Defaults to **React + TypeScript (Vite)** +## Test our RPC +Using this option will forward you to common project creation menu -### Install Rage:MP updater -This option will simplify installation process of Rage:MP server files required to start your server \ No newline at end of file +- ``Enter project name`` + This option will specify a name for your project which is used as a folder name too. Defaults to **rage-fw-rpc-example** + +- ``Select front-end`` + Use selector menu to choose which front-end framework you want to use. We will do our best to expand this menu with various solutions + +## Install Rage:MP updater +This option will simplify installation and update process of Rage:MP server files required to start your server + +# Contribution +If you wish to help us in expanding examples selection with different framework you are very welcome to open PRs and Issues \ No newline at end of file diff --git a/cli/src/commands/create.ts b/cli/src/commands/create.ts index 6de4cba..def31a2 100644 --- a/cli/src/commands/create.ts +++ b/cli/src/commands/create.ts @@ -18,19 +18,19 @@ export async function initProject() { if (!framework) { framework = await select({ - message: c.gray('Select frontend:'), + message: c.gray('Select front-end:'), default: 'react-18', loop: true, choices: [ { - name: 'React + TypeScript (Vite)', + name: 'React 18', value: 'react-18', - description: 'React + TypeScript (Vite) as a frontend', + description: 'React 18 + TypeScript (Vite) as a front-end', }, ], }) } else { - console.log(c.gray('Frontend:'), framework) + console.log(c.gray('Front-end:'), framework) } console.log( @@ -38,7 +38,7 @@ export async function initProject() { folder, c.gray('with'), framework, - c.gray('as a frontend..'), + c.gray('as a front-end..'), ) cloneBranch( @@ -56,5 +56,6 @@ export async function initProject() { }) .catch(e => { console.log(c.red('Error occured: \n', e)) + console.log(c.red('Please open an issue if you see this')) }) } diff --git a/cli/src/commands/test-rpc.ts b/cli/src/commands/test-rpc.ts index 9a96fb7..4d3efcd 100644 --- a/cli/src/commands/test-rpc.ts +++ b/cli/src/commands/test-rpc.ts @@ -5,14 +5,14 @@ import { cloneBranch } from '../utils/cloner' const choices = { 'rpc-react-18': { - name: 'Vite + React 18 + TypeScript', + name: 'React 18', value: 'rpc-react-18', - description: 'Vite + React 18 + TypeScript as a frontend', + description: 'Vite + React 18 + TypeScript as a front-end', }, 'rpc-svelte-5': { - name: 'Vite + Svelte 5 + TypeScript', + name: 'Svelte 5', value: 'rpc-svelte-5', - description: 'Vite + Svelte 5 + TypeScript as a frontend', + description: 'Vite + Svelte 5 + TypeScript as a front-end', }, } as const @@ -31,13 +31,13 @@ export async function testRpc() { if (!framework) { framework = await select({ - message: c.gray('Select frontend:'), + message: c.gray('Select front-end:'), default: 'rpc-react-18', loop: true, choices: Object.values(choices), }) } else { - console.log(c.gray('Frontend:'), framework) + console.log(c.gray('Front-end:'), framework) } console.log( @@ -63,5 +63,6 @@ export async function testRpc() { }) .catch(e => { console.log(c.red('Error occured: \n', e)) + console.log(c.red('Please open an issue if you see this')) }) } diff --git a/cli/src/index.ts b/cli/src/index.ts index f7414ac..9b614c5 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -12,10 +12,19 @@ enum Actions { UPDATER = 'UPDATER', } +process.on('exit', () => { + console.log(c.blueBright('\n\nRage FW CLI | Exiting..')) + process.exit(0) +}) + +process.on('SIGINT', () => { + console.log(c.blueBright('\n\nRage FW CLI | Exiting..')) + process.exit(0) +}) ;(async () => { await checkForUpdates() - console.log(c.blueBright('Rage FW CLI | Powered by Entity Seven Group ️<3')) + console.log(c.blueBright('Rage FW CLI | Powered by Entity Seven Group <3')) const action = await select({ message: c.gray('Select action:'), @@ -26,16 +35,16 @@ enum Actions { description: 'Initialize a new project and start developing', }, { - name: 'Test our RPC', + name: 'Test our Rpc', value: Actions.TEST_RPC, description: - 'Initialize a new skeleton project with our RPC set up', + 'Initialize a new skeleton project with our Rpc all set', }, { name: 'Install RAGE:MP updater', value: Actions.UPDATER, description: - 'Use our tool to download or update RAGE:MP server files in two clicks', + 'Use our tool to download or update RAGE:MP server files in just two clicks', }, ], loop: true, @@ -53,5 +62,6 @@ enum Actions { break default: console.log(c.red('Something went wrong..')) + console.log(c.red('Please open an issue if you see this')) } })()