feat(cli): new commands build, prepare, dev
This commit is contained in:
parent
2be9bfec7f
commit
877a45a44f
9 changed files with 396 additions and 1185 deletions
1501
package-lock.json
generated
1501
package-lock.json
generated
File diff suppressed because it is too large
Load diff
23
packages/cli/commands/build.mjs
Normal file
23
packages/cli/commands/build.mjs
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { consola } from "consola";
|
||||
import { defineCommand } from "citty";
|
||||
import { commonArgs } from "../common.mjs";
|
||||
import { execSync as exec } from "child_process";
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
name: "prepare",
|
||||
description: "Generates the build files for the McFly app.",
|
||||
},
|
||||
args: {
|
||||
...commonArgs,
|
||||
},
|
||||
async run({ args }) {
|
||||
try {
|
||||
exec(`npx nitropack build`, { stdio: "inherit" });
|
||||
} catch (e) {
|
||||
consola.error(e);
|
||||
}
|
||||
},
|
||||
});
|
23
packages/cli/commands/dev.mjs
Normal file
23
packages/cli/commands/dev.mjs
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { consola } from "consola";
|
||||
import { defineCommand } from "citty";
|
||||
import { commonArgs } from "../common.mjs";
|
||||
import { execSync as exec } from "child_process";
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
name: "prepare",
|
||||
description: "Runs the dev server.",
|
||||
},
|
||||
args: {
|
||||
...commonArgs,
|
||||
},
|
||||
async run({ args }) {
|
||||
try {
|
||||
exec(`npx nitropack dev`, { stdio: "inherit" });
|
||||
} catch (e) {
|
||||
consola.error(e);
|
||||
}
|
||||
},
|
||||
});
|
|
@ -13,6 +13,6 @@ export default defineCommand({
|
|||
...commonArgs,
|
||||
},
|
||||
async run({ args }) {
|
||||
consola.box("Generate a McFly building block");
|
||||
consola.box("Generate a McFly building block (In-progress)");
|
||||
},
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import { consola } from "consola";
|
|||
import { defineCommand } from "citty";
|
||||
import { commonArgs } from "../common.mjs";
|
||||
import { existsSync, writeFileSync, appendFileSync } from "node:fs";
|
||||
import { execSync as exec } from "child_process";
|
||||
|
||||
export default defineCommand({
|
||||
meta: {
|
||||
|
@ -17,6 +18,12 @@ export default defineCommand({
|
|||
const typeDefinition = `\n/// <reference path="./mcfly-imports.d.ts" />`;
|
||||
const globalDefinition = `import {WebComponent as W} from "web-component-base/WebComponent.mjs"; declare global {const WebComponent: typeof W;}export {WebComponent};`;
|
||||
|
||||
try {
|
||||
exec("npx nitropack prepare", { stdio: "inherit" });
|
||||
} catch (e) {
|
||||
consola.error(e);
|
||||
}
|
||||
|
||||
if (existsSync(".nitro/types/nitro.d.ts")) {
|
||||
try {
|
||||
writeFileSync(".nitro/types/mcfly-imports.d.ts", globalDefinition);
|
||||
|
|
|
@ -9,9 +9,11 @@ const main = defineCommand({
|
|||
version: pkg.version,
|
||||
},
|
||||
subCommands: {
|
||||
new: () => import("./commands/new.mjs").then((r) => r.default),
|
||||
dev: () => import("./commands/dev.mjs").then((r) => r.default),
|
||||
build: () => import("./commands/build.mjs").then((r) => r.default),
|
||||
prepare: () => import("./commands/prepare.mjs").then((r) => r.default),
|
||||
generate: () => import("./commands/generate.mjs").then((r) => r.default),
|
||||
new: () => import("./commands/new.mjs").then((r) => r.default),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mcflyjs/cli",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"description": "McFly CLI tools",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
"description": "McFly is a full-stack no-framework framework that assists developers in leveraging the web platform.",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "nitropack dev",
|
||||
"prepare": "nitropack prepare && mcfly prepare",
|
||||
"dev": "nitropack dev",
|
||||
"build": "nitropack build",
|
||||
"start": "mcfly dev",
|
||||
"prepare": "mcfly prepare",
|
||||
"dev": "mcfly dev",
|
||||
"build": "mcfly build",
|
||||
"preview": "node .output/server/index.mjs",
|
||||
"build:preview": "npm run build && npm run preview"
|
||||
},
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
"name": "@templates/basic",
|
||||
"description": "McFly starter project; see more on https://ayco.io/gh/McFly",
|
||||
"scripts": {
|
||||
"start": "nitropack dev",
|
||||
"prepare": "nitropack prepare",
|
||||
"dev": "nitropack dev",
|
||||
"build": "nitropack build",
|
||||
"preview": "node .output/server/index.mjs"
|
||||
"start": "mcfly dev",
|
||||
"prepare": "mcfly prepare",
|
||||
"dev": "mcfly dev",
|
||||
"build": "mcfly build",
|
||||
"preview": "node .output/server/index.mjs",
|
||||
"build:preview": "npm run build && npm run preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mcflyjs/cli": "latest",
|
||||
|
|
Loading…
Reference in a new issue