Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
424513dd56 | ||
|
|
36c241a117 | ||
|
|
333bd9df13 | ||
|
|
6be93daa2d | ||
|
|
06f93e61a8 | ||
|
|
7357038c42 | ||
|
|
04412d7cbc | ||
|
|
9204eb81be | ||
|
|
1fd65c6b86 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rage-fw-cef",
|
||||
"version": "0.0.23-alpha.0",
|
||||
"version": "0.0.28-alpha.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/src/index.d.ts",
|
||||
"files": [
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# build
|
||||
bin/
|
||||
|
||||
# deps
|
||||
node_modules/
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
||||
|
||||
# dev
|
||||
.vscode/
|
||||
.idea/
|
||||
+7
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rage-fw",
|
||||
"version": "0.0.23",
|
||||
"name": "create-rage-fw",
|
||||
"version": "0.0.28-alpha.0",
|
||||
"bin": {
|
||||
"rage-fw": "dist/index.js"
|
||||
},
|
||||
@@ -10,16 +10,19 @@
|
||||
"build": "tsup",
|
||||
"start": "npx ./dist create"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"description": "CLI to scaffold a template project for RageFW",
|
||||
"keywords": [],
|
||||
"author": "rilaxik",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@inquirer/prompts": "^5.0.5",
|
||||
"axios": "^1.7.2",
|
||||
"chalk": "4.1.2",
|
||||
"git-clone": "^0.2.0",
|
||||
"yargs": "^17.7.2",
|
||||
"axios": "^1.7.2"
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/git-clone": "^0.2.4",
|
||||
|
||||
+15
-16
@@ -1,17 +1,23 @@
|
||||
import type { CommandModule } 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({
|
||||
export async function initProject() {
|
||||
let folder
|
||||
let framework
|
||||
|
||||
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 +34,9 @@ async function handler() {
|
||||
// },
|
||||
],
|
||||
})
|
||||
} else {
|
||||
console.log(c.gray('Frontend:'), framework)
|
||||
}
|
||||
|
||||
console.log(
|
||||
c.gray('\nScaffolding template project into'),
|
||||
@@ -55,13 +64,3 @@ async function handler() {
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
// name and description for our command module
|
||||
const init: CommandModule = {
|
||||
command: 'create [template]',
|
||||
aliases: 'c',
|
||||
describe: 'Scaffold a template project using RageFW',
|
||||
handler,
|
||||
}
|
||||
|
||||
export default init
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import axios from 'axios'
|
||||
import * as fs from 'node:fs'
|
||||
|
||||
const latestReleases =
|
||||
'https://git.entityseven.com/api/v1/repos/entityseven/rage-server-downloader/releases?page=1&limit=1'
|
||||
|
||||
type Release = {
|
||||
id: number
|
||||
}
|
||||
|
||||
type Asset = {
|
||||
browser_download_url: string
|
||||
}
|
||||
|
||||
export async function downloadUpdater(): Promise<void> {
|
||||
const id = await getLatestReleaseID()
|
||||
|
||||
const latestAssets = `https://git.entityseven.com/api/v1/repos/entityseven/rage-server-downloader/releases/${id}/assets?page=1&limit=1`
|
||||
|
||||
axios.get<Asset[]>(latestAssets).then(async ({ data }) => {
|
||||
const downloadURL = data[0].browser_download_url
|
||||
|
||||
const file = await axios.get(data[0].browser_download_url, {
|
||||
responseType: 'arraybuffer',
|
||||
})
|
||||
const fileData = Buffer.from(file.data, 'binary')
|
||||
|
||||
const fileSplit = downloadURL.split('/')
|
||||
const fileName = fileSplit[fileSplit.length - 1]
|
||||
|
||||
fs.writeFileSync(`./${fileName}`, fileData)
|
||||
})
|
||||
}
|
||||
|
||||
async function getLatestReleaseID() {
|
||||
return axios.get<Release[]>(latestReleases).then(({ data }) => data[0].id)
|
||||
}
|
||||
+36
-9
@@ -1,13 +1,40 @@
|
||||
import yargs from 'yargs'
|
||||
import c from 'chalk'
|
||||
import { select } from '@inquirer/prompts'
|
||||
|
||||
import create from './commands/create'
|
||||
import { checkForUpdate } from './utils/update'
|
||||
import { initProject } from './commands/create'
|
||||
import { downloadUpdater } from './commands/download-updater'
|
||||
|
||||
yargs.middleware(checkForUpdate)
|
||||
enum Actions {
|
||||
INIT_PROJECT = 'INIT_PROJECT',
|
||||
UPDATER = 'UPDATER',
|
||||
}
|
||||
|
||||
yargs
|
||||
.usage('<cmd> [args]')
|
||||
// .scriptName('rage-fw')
|
||||
// .usage('$0 <cmd> [args]')
|
||||
.command(create)
|
||||
.help().argv
|
||||
;(async () => {
|
||||
await checkForUpdate()
|
||||
|
||||
console.log(
|
||||
c.blueBright('Rage FW CLI | Powered by Entity Seven Group ️ <3'),
|
||||
)
|
||||
|
||||
const action = await select({
|
||||
message: c.gray('Select action:'),
|
||||
choices: [
|
||||
{
|
||||
name: 'Initialize new project',
|
||||
value: Actions.INIT_PROJECT,
|
||||
description: 'Initialize new project and start develop',
|
||||
},
|
||||
{
|
||||
name: 'Install RAGE:MP updater',
|
||||
value: Actions.UPDATER,
|
||||
description:
|
||||
'Use our custom updater to download and update RAGE:MP server files.',
|
||||
},
|
||||
],
|
||||
loop: true,
|
||||
})
|
||||
|
||||
if (action === Actions.INIT_PROJECT) await initProject()
|
||||
if (action === Actions.UPDATER) await downloadUpdater()
|
||||
})()
|
||||
|
||||
@@ -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))
|
||||
if (latestVersion !== `v${version}`)
|
||||
notifyUserAboutUpdate(latestVersion)
|
||||
|
||||
return
|
||||
}),
|
||||
})
|
||||
.then(() => res()),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function notifyUserAboutUpdate(version: string) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rage-fw-client",
|
||||
"version": "0.0.23-alpha.0",
|
||||
"version": "0.0.28-alpha.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/src/index.d.ts",
|
||||
"files": [
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||
"version": "0.0.23-alpha.0",
|
||||
"version": "0.0.28-alpha.0",
|
||||
"npmClient": "pnpm"
|
||||
}
|
||||
|
||||
Generated
+3076
-772
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rage-fw-server",
|
||||
"version": "0.0.23-alpha.0",
|
||||
"version": "0.0.28-alpha.0",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/src/index.d.ts",
|
||||
"files": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rage-fw-shared-types",
|
||||
"version": "0.0.23-alpha.0",
|
||||
"version": "0.0.28-alpha.0",
|
||||
"types": "types/types/index.d.ts",
|
||||
"files": [
|
||||
"types/**/*"
|
||||
|
||||
Reference in New Issue
Block a user