rage-fw-cli create command
This commit is contained in:
@@ -13,10 +13,13 @@
|
||||
"author": "rilaxik",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@inquirer/prompts": "^5.0.5",
|
||||
"chalk": "4.1.2",
|
||||
"git-clone": "^0.2.0",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/git-clone": "^0.2.4",
|
||||
"@types/node": "^20.14.2",
|
||||
"@types/yargs": "^17.0.32",
|
||||
"prettier": "^3.3.2",
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import type { CommandModule, ArgumentsCamelCase } from 'yargs'
|
||||
import c from 'chalk'
|
||||
import { input, select } from '@inquirer/prompts'
|
||||
import clone from 'git-clone'
|
||||
import path from 'node:path'
|
||||
|
||||
// the handler function will be called when our command is executed
|
||||
// it will receive the command line arguments parsed by yargs
|
||||
async function handler() {
|
||||
const folder = await input({
|
||||
message: c.gray('Enter project name:'),
|
||||
default: 'rage-fw',
|
||||
})
|
||||
const framework = await select({
|
||||
message: c.gray('Select frontend:'),
|
||||
default: 'react',
|
||||
loop: true,
|
||||
choices: [
|
||||
{
|
||||
name: 'React + TypeScript (Vite)',
|
||||
value: 'react',
|
||||
description: 'React + TypeScript (Vite) as a frontend',
|
||||
},
|
||||
// {
|
||||
// name: 'vue',
|
||||
// value: 'vue',
|
||||
// description: 'npm is the most popular package manager',
|
||||
// },
|
||||
],
|
||||
})
|
||||
|
||||
console.log(
|
||||
c.gray('\nScaffolding template project into'),
|
||||
folder,
|
||||
c.gray('with'),
|
||||
framework,
|
||||
c.gray('as a frontend..'),
|
||||
)
|
||||
|
||||
clone(
|
||||
'https://git.entityseven.com/entityseven/rage-framework-example',
|
||||
path.join(__dirname, folder),
|
||||
{},
|
||||
err => {
|
||||
if (err) {
|
||||
console.log(c.red('Error occured: \n', err))
|
||||
return
|
||||
}
|
||||
console.log(c.gray('Scaffolded project into'), folder)
|
||||
console.log(
|
||||
c.blueBright(
|
||||
'Working on Rage Framework. RageFW © Powered by Entity Seven Group',
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// name and description for our command module
|
||||
const init: CommandModule = {
|
||||
command: 'create [template]',
|
||||
aliases: 'c',
|
||||
describe: 'Scaffold a template project using RageFW',
|
||||
handler,
|
||||
}
|
||||
|
||||
export default init
|
||||
+8
-2
@@ -1,4 +1,10 @@
|
||||
import yargs from 'yargs'
|
||||
import { hideBin } from 'yargs/helpers'
|
||||
|
||||
yargs(hideBin(process.argv)).help().argv
|
||||
import create from './commands/create'
|
||||
|
||||
yargs
|
||||
.usage('<cmd> [args]')
|
||||
// .scriptName('rage-fw')
|
||||
// .usage('$0 <cmd> [args]')
|
||||
.command(create)
|
||||
.help().argv
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
|
||||
"lib": ["DOM", "ES6"],
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
@@ -16,7 +16,7 @@
|
||||
"noImplicitAny": true
|
||||
},
|
||||
"include": [
|
||||
"src/index.ts"
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
||||
Reference in New Issue
Block a user