Compare commits
No commits in common. "04412d7cbc198e959e38bbcf2694f9cd83239b78" and "396e9c0ee61ed14dc09557b9fb7b776530c04754" have entirely different histories.
04412d7cbc
...
396e9c0ee6
@ -1,62 +1,33 @@
|
|||||||
import type { CommandModule, Argv, ArgumentsCamelCase } from 'yargs'
|
import type { CommandModule } from 'yargs'
|
||||||
import c from 'chalk'
|
import c from 'chalk'
|
||||||
import { input, select } from '@inquirer/prompts'
|
import { input, select } from '@inquirer/prompts'
|
||||||
import clone from 'git-clone'
|
import clone from 'git-clone'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
|
||||||
import { checkForUpdate } from '../utils/update'
|
// the handler function will be called when our command is executed
|
||||||
|
// it will receive the command line arguments parsed by yargs
|
||||||
function builder(yargs: Argv) {
|
async function handler() {
|
||||||
return yargs
|
const folder = await input({
|
||||||
.option('projectName', {
|
message: c.gray('Enter project name:'),
|
||||||
alias: 'p',
|
default: 'rage-fw',
|
||||||
description: 'Name of the folder to scaffold a project to',
|
})
|
||||||
type: 'string',
|
const framework = await select({
|
||||||
demandOption: false,
|
message: c.gray('Select frontend:'),
|
||||||
})
|
default: 'react',
|
||||||
.option('template', {
|
loop: true,
|
||||||
alias: 't',
|
choices: [
|
||||||
description: 'Frontend framework to use for CEF',
|
{
|
||||||
type: 'string',
|
name: 'React + TypeScript (Vite)',
|
||||||
demandOption: false,
|
value: 'react',
|
||||||
})
|
description: 'React + TypeScript (Vite) as a frontend',
|
||||||
.middleware(async () => await checkForUpdate())
|
},
|
||||||
}
|
// {
|
||||||
|
// name: 'vue',
|
||||||
async function handler(args: ArgumentsCamelCase) {
|
// value: 'vue',
|
||||||
let folder = (args.projectName as string) ?? args.p
|
// description: 'npm is the most popular package manager',
|
||||||
let framework = (args.template as string) ?? args.t
|
// },
|
||||||
|
],
|
||||||
if (!folder) {
|
})
|
||||||
folder = await input({
|
|
||||||
message: c.gray('Enter project name:'),
|
|
||||||
default: 'rage-fw',
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
console.log(c.gray('Project name:'), folder)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!framework) {
|
|
||||||
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',
|
|
||||||
// },
|
|
||||||
],
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
console.log(c.gray('Frontend:'), framework)
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
c.gray('\nScaffolding template project into'),
|
c.gray('\nScaffolding template project into'),
|
||||||
@ -85,11 +56,11 @@ async function handler(args: ArgumentsCamelCase) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// name and description for our command module
|
||||||
const init: CommandModule = {
|
const init: CommandModule = {
|
||||||
command: 'create [folderName] [template]',
|
command: 'create [template]',
|
||||||
aliases: 'c',
|
aliases: 'c',
|
||||||
describe: 'Scaffold a template project using RageFW',
|
describe: 'Scaffold a template project using RageFW',
|
||||||
builder,
|
|
||||||
handler,
|
handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import yargs from 'yargs'
|
import yargs from 'yargs'
|
||||||
|
|
||||||
import create from './commands/create'
|
import create from './commands/create'
|
||||||
|
import { checkForUpdate } from './utils/update'
|
||||||
|
|
||||||
|
yargs.middleware(checkForUpdate)
|
||||||
|
|
||||||
yargs
|
yargs
|
||||||
.usage('<cmd> [args]')
|
.usage('<cmd> [args]')
|
||||||
// .scriptName('rage-fw')
|
// .scriptName('rage-fw')
|
||||||
// .usage('$0 <cmd> [args]')
|
// .usage('$0 <cmd> [args]')
|
||||||
// @ts-ignore
|
|
||||||
.command(create)
|
.command(create)
|
||||||
.help().argv
|
.help().argv
|
||||||
|
@ -10,20 +10,17 @@ type Version = {
|
|||||||
message: string
|
message: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkForUpdate(): Promise<void> {
|
export async function checkForUpdate() {
|
||||||
return new Promise(res => {
|
yargs.showVersion(version =>
|
||||||
yargs.showVersion(version =>
|
axios.get<Version[]>(latestVersionURL).then(({ data }) => {
|
||||||
axios
|
const latestVersion = data[0].name
|
||||||
.get<Version[]>(latestVersionURL)
|
|
||||||
.then(({ data }) => {
|
|
||||||
const latestVersion = data[0].name
|
|
||||||
|
|
||||||
if (!(latestVersion === version))
|
if (!(latestVersion === version))
|
||||||
notifyUserAboutUpdate(latestVersion)
|
notifyUserAboutUpdate(latestVersion)
|
||||||
})
|
|
||||||
.then(() => res()),
|
return
|
||||||
)
|
}),
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifyUserAboutUpdate(version: string) {
|
function notifyUserAboutUpdate(version: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user