feat(cli): serve to show mcfly & nitro version

This commit is contained in:
Ayo 2023-11-03 22:31:29 +01:00
parent 92e468e717
commit 52b0c69db7
3 changed files with 29 additions and 10 deletions

14
package-lock.json generated
View file

@ -3970,11 +3970,12 @@
},
"packages/cli": {
"name": "@mcflyjs/cli",
"version": "0.0.19",
"version": "0.0.20",
"license": "MIT",
"dependencies": {
"citty": "^0.1.4",
"consola": "^3.2.3"
"consola": "^3.2.3",
"pathe": "^1.1.1"
},
"bin": {
"mcfly": "index.js"
@ -4043,13 +4044,12 @@
}
},
"templates/basic/node_modules/@mcflyjs/cli": {
"version": "0.0.18",
"resolved": "https://registry.npmjs.org/@mcflyjs/cli/-/cli-0.0.18.tgz",
"integrity": "sha512-ILYAL1wkZALucplgahIcRW8eExoiRzPC4+/i8cCcEaDU2TGJOxWDS3FKyiRoNfjNwmHlCnXEAvT1AqaNvHRrIg==",
"version": "0.0.19",
"resolved": "https://registry.npmjs.org/@mcflyjs/cli/-/cli-0.0.19.tgz",
"integrity": "sha512-dVicZeoL9Gkggbj2qQhXd7dzK7ZOLvh/fBwGVeHoCGEDzZAOIxgaqXl3wYrGcZIGTO6wGmLIqnaO3y3ZykLzPg==",
"dependencies": {
"citty": "^0.1.4",
"consola": "^3.2.3",
"web-component-base": "^1.9.5"
"consola": "^3.2.3"
},
"bin": {
"mcfly": "index.js"

View file

@ -1,8 +1,10 @@
#!/usr/bin/env node
import { consola } from "consola";
import { colorize } from "consola/utils";
import { defineCommand } from "citty";
import { execSync as exec } from "child_process";
import { execSync as exec } from "node:child_process";
import { createRequire } from "node:module";
export default defineCommand({
meta: {
@ -10,6 +12,22 @@ export default defineCommand({
description: "Runs the dev server.",
},
async run() {
try {
const _require = createRequire(import.meta.url);
const mcflyPkg = await _require("@mcflyjs/core/package.json");
const mcflyPkgVersion = `McFly ${mcflyPkg.version}`;
const nitroPkg = await _require("nitropack/package.json");
const nitroPkgVersion = `Nitro ${nitroPkg.version}`;
consola.log(
`${colorize("blue", mcflyPkgVersion)} ${colorize(
"dim",
nitroPkgVersion
)}`
);
} catch (e) {
consola.error(e);
}
try {
exec(`npx nitropack dev`, { stdio: "inherit" });
} catch (e) {

View file

@ -1,6 +1,6 @@
{
"name": "@mcflyjs/cli",
"version": "0.0.19",
"version": "0.0.20",
"description": "McFly CLI tools",
"type": "module",
"main": "index.js",
@ -23,6 +23,7 @@
"homepage": "https://github.com/ayoayco/McFly#readme",
"dependencies": {
"citty": "^0.1.4",
"consola": "^3.2.3"
"consola": "^3.2.3",
"pathe": "^1.1.1"
}
}