v0.1.0 #1

Merged
sashagoncharov19 merged 32 commits from dev into unstable 2024-06-15 13:48:41 +00:00
3 changed files with 16 additions and 13 deletions
Showing only changes of commit 04412d7cbc - Show all commits

View File

@ -4,6 +4,8 @@ import { input, select } from '@inquirer/prompts'
import clone from 'git-clone'
import path from 'node:path'
import { checkForUpdate } from '../utils/update'
function builder(yargs: Argv) {
return yargs
.option('projectName', {
@ -18,6 +20,7 @@ function builder(yargs: Argv) {
type: 'string',
demandOption: false,
})
.middleware(async () => await checkForUpdate())
}
async function handler(args: ArgumentsCamelCase) {

View File

@ -1,9 +1,6 @@
import yargs from 'yargs'
import create from './commands/create'
import { checkForUpdate } from './utils/update'
yargs.middleware(checkForUpdate)
yargs
.usage('<cmd> [args]')

View File

@ -10,17 +10,20 @@ type Version = {
message: string
}
export async function checkForUpdate() {
yargs.showVersion(version =>
axios.get<Version[]>(latestVersionURL).then(({ data }) => {
const latestVersion = data[0].name
export async function checkForUpdate(): Promise<void> {
return new Promise(res => {
yargs.showVersion(version =>
axios
.get<Version[]>(latestVersionURL)
.then(({ data }) => {
const latestVersion = data[0].name
if (!(latestVersion === version))
notifyUserAboutUpdate(latestVersion)
return
}),
)
if (!(latestVersion === version))
notifyUserAboutUpdate(latestVersion)
})
.then(() => res()),
)
})
}
function notifyUserAboutUpdate(version: string) {