Compare commits
	
		
			3 Commits
		
	
	
		
			396e9c0ee6
			...
			04412d7cbc
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 04412d7cbc | |||
| 9204eb81be | |||
| 1fd65c6b86 | 
| @ -1,17 +1,43 @@ | ||||
| import type { CommandModule } from 'yargs' | ||||
| import type { CommandModule, Argv, 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({ | ||||
| import { checkForUpdate } from '../utils/update' | ||||
| 
 | ||||
| function builder(yargs: Argv) { | ||||
|     return yargs | ||||
|         .option('projectName', { | ||||
|             alias: 'p', | ||||
|             description: 'Name of the folder to scaffold a project to', | ||||
|             type: 'string', | ||||
|             demandOption: false, | ||||
|         }) | ||||
|         .option('template', { | ||||
|             alias: 't', | ||||
|             description: 'Frontend framework to use for CEF', | ||||
|             type: 'string', | ||||
|             demandOption: false, | ||||
|         }) | ||||
|         .middleware(async () => await checkForUpdate()) | ||||
| } | ||||
| 
 | ||||
| async function handler(args: ArgumentsCamelCase) { | ||||
|     let folder = (args.projectName as string) ?? args.p | ||||
|     let framework = (args.template as string) ?? args.t | ||||
| 
 | ||||
|     if (!folder) { | ||||
|         folder = await input({ | ||||
|             message: c.gray('Enter project name:'), | ||||
|             default: 'rage-fw', | ||||
|         }) | ||||
|     const framework = await select({ | ||||
|     } else { | ||||
|         console.log(c.gray('Project name:'), folder) | ||||
|     } | ||||
| 
 | ||||
|     if (!framework) { | ||||
|         framework = await select({ | ||||
|             message: c.gray('Select frontend:'), | ||||
|             default: 'react', | ||||
|             loop: true, | ||||
| @ -28,6 +54,9 @@ async function handler() { | ||||
|                 // },
 | ||||
|             ], | ||||
|         }) | ||||
|     } else { | ||||
|         console.log(c.gray('Frontend:'), framework) | ||||
|     } | ||||
| 
 | ||||
|     console.log( | ||||
|         c.gray('\nScaffolding template project into'), | ||||
| @ -56,11 +85,11 @@ async function handler() { | ||||
|     ) | ||||
| } | ||||
| 
 | ||||
| // name and description for our command module
 | ||||
| const init: CommandModule = { | ||||
|     command: 'create [template]', | ||||
|     command: 'create [folderName] [template]', | ||||
|     aliases: 'c', | ||||
|     describe: 'Scaffold a template project using RageFW', | ||||
|     builder, | ||||
|     handler, | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -1,13 +1,11 @@ | ||||
| import yargs from 'yargs' | ||||
| 
 | ||||
| import create from './commands/create' | ||||
| import { checkForUpdate } from './utils/update' | ||||
| 
 | ||||
| yargs.middleware(checkForUpdate) | ||||
| 
 | ||||
| yargs | ||||
|     .usage('<cmd> [args]') | ||||
|     // .scriptName('rage-fw')
 | ||||
|     //     .usage('$0 <cmd> [args]')
 | ||||
|     // @ts-ignore
 | ||||
|     .command(create) | ||||
|     .help().argv | ||||
|  | ||||
| @ -10,17 +10,20 @@ type Version = { | ||||
|     message: string | ||||
| } | ||||
| 
 | ||||
| export async function checkForUpdate() { | ||||
| export async function checkForUpdate(): Promise<void> { | ||||
|     return new Promise(res => { | ||||
|         yargs.showVersion(version => | ||||
|         axios.get<Version[]>(latestVersionURL).then(({ data }) => { | ||||
|             axios | ||||
|                 .get<Version[]>(latestVersionURL) | ||||
|                 .then(({ data }) => { | ||||
|                     const latestVersion = data[0].name | ||||
| 
 | ||||
|                     if (!(latestVersion === version)) | ||||
|                         notifyUserAboutUpdate(latestVersion) | ||||
| 
 | ||||
|             return | ||||
|         }), | ||||
|                 }) | ||||
|                 .then(() => res()), | ||||
|         ) | ||||
|     }) | ||||
| } | ||||
| 
 | ||||
| function notifyUserAboutUpdate(version: string) { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user