cli check for update
This commit is contained in:
parent
839dff9b78
commit
396e9c0ee6
@ -1,12 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "rage-framework-cli",
|
"name": "rage-fw",
|
||||||
"version": "0.0.23",
|
"version": "0.0.23",
|
||||||
"bin": {
|
"bin": {
|
||||||
"rage-fw": "bin/index.js"
|
"rage-fw": "dist/index.js"
|
||||||
},
|
},
|
||||||
"main": "bin/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "tsc -w"
|
"watch": "tsc -w",
|
||||||
|
"build": "tsup",
|
||||||
|
"start": "npx ./dist create"
|
||||||
},
|
},
|
||||||
"description": "CLI to scaffold a template project for RageFW",
|
"description": "CLI to scaffold a template project for RageFW",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
@ -16,7 +18,8 @@
|
|||||||
"@inquirer/prompts": "^5.0.5",
|
"@inquirer/prompts": "^5.0.5",
|
||||||
"chalk": "4.1.2",
|
"chalk": "4.1.2",
|
||||||
"git-clone": "^0.2.0",
|
"git-clone": "^0.2.0",
|
||||||
"yargs": "^17.7.2"
|
"yargs": "^17.7.2",
|
||||||
|
"axios": "^1.7.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/git-clone": "^0.2.4",
|
"@types/git-clone": "^0.2.4",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import type { CommandModule, 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'
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
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]')
|
||||||
|
28
cli/src/utils/update.ts
Normal file
28
cli/src/utils/update.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import c from 'chalk'
|
||||||
|
import yargs from 'yargs'
|
||||||
|
|
||||||
|
const latestVersionURL =
|
||||||
|
'https://git.entityseven.com/api/v1/repos/entityseven/rage-framework/tags?page=1&limit=1'
|
||||||
|
|
||||||
|
type Version = {
|
||||||
|
name: string
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function checkForUpdate() {
|
||||||
|
yargs.showVersion(version =>
|
||||||
|
axios.get<Version[]>(latestVersionURL).then(({ data }) => {
|
||||||
|
const latestVersion = data[0].name
|
||||||
|
|
||||||
|
if (!(latestVersion === version))
|
||||||
|
notifyUserAboutUpdate(latestVersion)
|
||||||
|
|
||||||
|
return
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function notifyUserAboutUpdate(version: string) {
|
||||||
|
console.log(c.green(`Update available. New version: ${version}`))
|
||||||
|
}
|
10
cli/tsup.config.ts
Normal file
10
cli/tsup.config.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { defineConfig } from 'tsup'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ['src/index.ts'],
|
||||||
|
outDir: './dist',
|
||||||
|
bundle: true,
|
||||||
|
splitting: false,
|
||||||
|
sourcemap: false,
|
||||||
|
clean: true,
|
||||||
|
})
|
@ -65,6 +65,9 @@ importers:
|
|||||||
'@inquirer/prompts':
|
'@inquirer/prompts':
|
||||||
specifier: ^5.0.5
|
specifier: ^5.0.5
|
||||||
version: 5.0.5
|
version: 5.0.5
|
||||||
|
axios:
|
||||||
|
specifier: ^1.7.2
|
||||||
|
version: 1.7.2
|
||||||
chalk:
|
chalk:
|
||||||
specifier: 4.1.2
|
specifier: 4.1.2
|
||||||
version: 4.1.2
|
version: 4.1.2
|
||||||
|
Loading…
Reference in New Issue
Block a user