del: node modle
This commit is contained in:
+21
-3
@@ -13,8 +13,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const { values } = parseArgs({
|
||||
args: process.argv.slice(3),
|
||||
options: {
|
||||
server: { type: "string", short: "s", multiple: true },
|
||||
type: { type: "string", short: "t" },
|
||||
server: { type: "string", short: "s", multiple: true }, // 服务名称
|
||||
type: { type: "string", short: "t" }, // 生成类型:api, rpc, docker
|
||||
imageName: { type: "string", short: "i" }, // 镜像名字
|
||||
}
|
||||
})
|
||||
|
||||
@@ -145,7 +146,7 @@ async function searchSelector(chooses, message) {
|
||||
async function generateHandle() {
|
||||
const type = values.type;
|
||||
if (!type || !GenerateConfig[type]) {
|
||||
console.log("Please specify valid -t <api|rpc|docker>");
|
||||
console.error("Please specify valid -t <api|rpc|docker>");
|
||||
return;
|
||||
}
|
||||
const config = GenerateConfig[type];
|
||||
@@ -157,6 +158,10 @@ async function generateHandle() {
|
||||
await config.generate(input);
|
||||
}
|
||||
|
||||
async function buildImage(imageName) {
|
||||
await run("docker", ["build", "-t", imageName, "."])
|
||||
}
|
||||
|
||||
|
||||
export const init = task({
|
||||
name: "init",
|
||||
@@ -174,6 +179,19 @@ export const tidy = task({
|
||||
})
|
||||
|
||||
|
||||
export const build = task({
|
||||
name: "build",
|
||||
desc: "build docker image",
|
||||
run: async () => {
|
||||
if (values.imageName) {
|
||||
buildImage(values.imageName);
|
||||
} else {
|
||||
console.error("Please specify image name with -i <imageName>");
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
export const gen = task({
|
||||
name: "gen",
|
||||
desc: "generate API/RPC service code",
|
||||
|
||||
Reference in New Issue
Block a user