v0.1.0 #1

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

View File

@ -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",

View File

@ -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
View 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
View 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,
})

3
pnpm-lock.yaml generated
View File

@ -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