feat(cli): better info on prepare script

This commit is contained in:
Ayo 2023-10-26 22:20:36 +02:00
parent 9c7cd8c43c
commit 969a9ddd76
3 changed files with 16 additions and 8 deletions

8
package-lock.json generated
View file

@ -3970,7 +3970,7 @@
}, },
"packages/cli": { "packages/cli": {
"name": "@mcflyjs/cli", "name": "@mcflyjs/cli",
"version": "0.0.9", "version": "0.0.11",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"citty": "^0.1.4", "citty": "^0.1.4",
@ -4031,9 +4031,9 @@
} }
}, },
"templates/basic/node_modules/@mcflyjs/cli": { "templates/basic/node_modules/@mcflyjs/cli": {
"version": "0.0.9", "version": "0.0.10",
"resolved": "https://registry.npmjs.org/@mcflyjs/cli/-/cli-0.0.9.tgz", "resolved": "https://registry.npmjs.org/@mcflyjs/cli/-/cli-0.0.10.tgz",
"integrity": "sha512-3U49X0CZD8lF2okURNos6OUmyvJkOLClsQ/kssLElN2hotm6csmg7XQc3dxA9KYZctouPbbBqOUPDVw86p1CVQ==", "integrity": "sha512-Nhig+bnQbgwX5IYoIMYjZzdWsMAfPpwx0edzvgHdtU87zLcJsPU/k4PfXl6t/rIwLwviIieHyNqZlImlj289gA==",
"dependencies": { "dependencies": {
"citty": "^0.1.4", "citty": "^0.1.4",
"consola": "^3.2.3", "consola": "^3.2.3",

View file

@ -17,13 +17,14 @@ export default defineCommand({
async run({ args }) { async run({ args }) {
const typeDefinition = `\n/// <reference path="./mcfly-imports.d.ts" />`; const typeDefinition = `\n/// <reference path="./mcfly-imports.d.ts" />`;
const globalDefinition = `import {WebComponent as W} from "web-component-base/WebComponent.mjs"; declare global {class WebComponent extends W {}}export {WebComponent} from 'web-component-base/WebComponent.mjs';`; const globalDefinition = `import {WebComponent as W} from "web-component-base/WebComponent.mjs"; declare global {class WebComponent extends W {}}export {WebComponent} from 'web-component-base/WebComponent.mjs';`;
let hasErrors = false;
consola.info("ola"); consola.start("Preparing McFly workspace...");
try { try {
exec("npx nitropack prepare", { stdio: "inherit" }); exec("npx nitropack prepare", { stdio: "inherit" });
} catch (e) { } catch (e) {
consola.error(e); consola.error(e);
hasErrors = true;
} }
if (existsSync(".nitro/types/nitro.d.ts")) { if (existsSync(".nitro/types/nitro.d.ts")) {
@ -31,16 +32,23 @@ export default defineCommand({
writeFileSync(".nitro/types/mcfly-imports.d.ts", globalDefinition); writeFileSync(".nitro/types/mcfly-imports.d.ts", globalDefinition);
} catch (e) { } catch (e) {
consola.error(e); consola.error(e);
hasErrors = true;
} }
try { try {
appendFileSync(".nitro/types/nitro.d.ts", typeDefinition); appendFileSync(".nitro/types/nitro.d.ts", typeDefinition);
} catch (e) { } catch (e) {
consola.error(e); consola.error(e);
hasErrors = true;
} }
} else { } else {
consola.log( consola.fail(
"Preparation Failed. Please run:\n> npx nitropack prepare && npx mcfly prepare" "Preparation Failed. Please run:\n> npx nitropack prepare && npx mcfly prepare"
); );
hasErrors = true;
}
if (!hasErrors) {
consola.success("Done!");
} }
}, },
}); });

View file

@ -1,6 +1,6 @@
{ {
"name": "@mcflyjs/cli", "name": "@mcflyjs/cli",
"version": "0.0.9", "version": "0.0.11",
"description": "McFly CLI tools", "description": "McFly CLI tools",
"type": "module", "type": "module",
"main": "index.mjs", "main": "index.mjs",