From acc1962589f04385421f75d601e06854eacc2c09 Mon Sep 17 00:00:00 2001 From: Compey Date: Mon, 21 Nov 2022 14:43:02 +0530 Subject: [PATCH] feat(cli): javascript template download & unpacking mechanism --- packages/cli/src/index.ts | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 5008662..4236bc5 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -51,26 +51,33 @@ inquirer let packageManager = getPackageManager() + const start = async (TEMPLATE_DOWNLOAD_URL) => { + const download = stream(TEMPLATE_DOWNLOAD_URL, { isStream: true }).pipe(createWriteStream(`${answers.location}/create-guilded-bot_ts.zip`)); + download.on("finish", () => { + fs.createReadStream(`${answers.location}/create-guilded-bot_ts.zip`) + .pipe(unzip.Extract({ path: `${answers.location}` })) + .on("finish", () => { + removeSync(`${answers.location}/create-guilded-bot_ts.zip`) + logger.success("🚀 Let's get started.") + }) + }); + }; + if (answers.flavor == "typescript") { const TEMPLATE_DOWNLOAD_URL = "https://files.devcomp.xyz/r/create-guilded-app_ts.zip" - const start = () => { - const download = stream(TEMPLATE_DOWNLOAD_URL, { isStream: true }).pipe(createWriteStream(`${answers.location}/create-guilded-bot_ts.zip`)); - download.on("finish", () => { - fs.createReadStream(`${answers.location}/create-guilded-bot_ts.zip`) - .pipe(unzip.Extract({ path: `${answers.location}` })) - .on("finish", () => { - removeSync(`${answers.location}/create-guilded-bot_ts.zip`) - logger.success("🚀 Let's get started.") - }) - }); - }; + start(TEMPLATE_DOWNLOAD_URL).then(() => { + install(packageManager as "npm" | "pnpm" | "yarn" | null, answers.location) + }) + } + + if (answers.flavor == "javascript") { + const TEMPLATE_DOWNLOAD_URL = "https://files.devcomp.xyz/r/create-guilded-app_js.zip" - - start(); - - install(packageManager as "npm" | "pnpm" | "yarn" | null, answers.location) + start(TEMPLATE_DOWNLOAD_URL).then(() => { + install(packageManager as "npm" | "pnpm" | "yarn" | null, answers.location) + }) } });