Compare commits

..
Author SHA1 Message Date
Oleksandr Honcharov 630c06bb91 v0.0.30-alpha.0 2024-06-13 23:08:00 +03:00
Oleksandr Honcharov 31136ad7e0 some fixes 2024-06-13 23:07:43 +03:00
Oleksandr Honcharov e9f77bf88d v0.0.29-alpha.0 2024-06-13 22:57:52 +03:00
Oleksandr Honcharov 424513dd56 v0.0.28-alpha.0 2024-06-13 22:48:02 +03:00
Oleksandr Honcharov 36c241a117 cli rework 2024-06-13 22:47:33 +03:00
Oleksandr Honcharov 333bd9df13 v0.0.27-alpha.0 2024-06-13 22:03:27 +03:00
Oleksandr Honcharov 6be93daa2d v0.0.26-alpha.0 2024-06-13 21:59:06 +03:00
Oleksandr Honcharov 06f93e61a8 v0.0.25-alpha.0 2024-06-13 21:50:40 +03:00
11 changed files with 92 additions and 65 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rage-fw-cef", "name": "rage-fw-cef",
"version": "0.0.24-alpha.0", "version": "0.0.30-alpha.0",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/src/index.d.ts", "types": "dist/src/index.d.ts",
"files": [ "files": [
-12
View File
@@ -1,12 +0,0 @@
# build
bin/
# deps
node_modules/
package-lock.json
yarn.lock
pnpm-lock.yaml
# dev
.vscode/
.idea/
+5 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "rage-fw", "name": "create-rage-fw",
"version": "0.0.24-alpha.0", "version": "0.0.30-alpha.0",
"bin": { "bin": {
"rage-fw": "dist/index.js" "rage-fw": "dist/index.js"
}, },
@@ -10,6 +10,9 @@
"build": "tsup", "build": "tsup",
"start": "npx ./dist create" "start": "npx ./dist create"
}, },
"files": [
"dist/**/*"
],
"description": "CLI to scaffold a template project for RageFW", "description": "CLI to scaffold a template project for RageFW",
"keywords": [], "keywords": [],
"author": "rilaxik", "author": "rilaxik",
+6 -36
View File
@@ -1,31 +1,11 @@
import type { CommandModule, Argv, ArgumentsCamelCase } 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' export async function initProject() {
let folder
function builder(yargs: Argv) { let framework
return yargs
.option('projectName', {
alias: 'p',
description: 'Name of the folder to scaffold a project to',
type: 'string',
demandOption: false,
})
.option('template', {
alias: 't',
description: 'Frontend framework to use for CEF',
type: 'string',
demandOption: false,
})
.middleware(async () => await checkForUpdate())
}
async function handler(args: ArgumentsCamelCase) {
let folder = (args.projectName as string) ?? args.p
let framework = (args.template as string) ?? args.t
if (!folder) { if (!folder) {
folder = await input({ folder = await input({
@@ -68,7 +48,7 @@ async function handler(args: ArgumentsCamelCase) {
clone( clone(
'https://git.entityseven.com/entityseven/rage-framework-example', 'https://git.entityseven.com/entityseven/rage-framework-example',
path.join(__dirname, folder), path.join(process.cwd(), folder),
{}, {},
err => { err => {
if (err) { if (err) {
@@ -77,20 +57,10 @@ async function handler(args: ArgumentsCamelCase) {
} }
console.log(c.gray('Scaffolded project into'), folder) console.log(c.gray('Scaffolded project into'), folder)
console.log( console.log(
c.blueBright( c.gray(
'Working on Rage Framework. RageFW © Powered by Entity Seven Group', `Project was created ar dir: ${path.join(process.cwd(), folder)}`,
), ),
) )
}, },
) )
} }
const init: CommandModule = {
command: 'create [folderName] [template]',
aliases: 'c',
describe: 'Scaffold a template project using RageFW',
builder,
handler,
}
export default init
+37
View File
@@ -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)
}
+38 -9
View File
@@ -1,11 +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 enum Actions {
.usage('<cmd> [args]') INIT_PROJECT = 'INIT_PROJECT',
// .scriptName('rage-fw') UPDATER = 'UPDATER',
// .usage('$0 <cmd> [args]') }
// @ts-ignore
.command(create) ;(async () => {
.help().argv 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()
})()
+1 -1
View File
@@ -18,7 +18,7 @@ export async function checkForUpdate(): Promise<void> {
.then(({ data }) => { .then(({ data }) => {
const latestVersion = data[0].name const latestVersion = data[0].name
if (!(latestVersion === version)) if (latestVersion !== `v${version}`)
notifyUserAboutUpdate(latestVersion) notifyUserAboutUpdate(latestVersion)
}) })
.then(() => res()), .then(() => res()),
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rage-fw-client", "name": "rage-fw-client",
"version": "0.0.24-alpha.0", "version": "0.0.30-alpha.0",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/src/index.d.ts", "types": "dist/src/index.d.ts",
"files": [ "files": [
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"$schema": "node_modules/lerna/schemas/lerna-schema.json", "$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.0.24-alpha.0", "version": "0.0.30-alpha.0",
"npmClient": "pnpm" "npmClient": "pnpm"
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rage-fw-server", "name": "rage-fw-server",
"version": "0.0.24-alpha.0", "version": "0.0.30-alpha.0",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/src/index.d.ts", "types": "dist/src/index.d.ts",
"files": [ "files": [
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "rage-fw-shared-types", "name": "rage-fw-shared-types",
"version": "0.0.24-alpha.0", "version": "0.0.30-alpha.0",
"types": "types/types/index.d.ts", "types": "types/types/index.d.ts",
"files": [ "files": [
"types/**/*" "types/**/*"