From 965e4dd0a6c7526647d94ff12f5df37381fcb024 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:15:38 +0000 Subject: [PATCH 1/3] feat: Updated index.ts --- index.ts | 95 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 30 deletions(-) diff --git a/index.ts b/index.ts index 15472a6..69f425a 100644 --- a/index.ts +++ b/index.ts @@ -2,19 +2,21 @@ import { $ } from "zx"; import { exec } from "child_process"; - import { writeFile } from "./lib"; +import { consola } from "./utils"; -let isInstalled = false; -try { - await $`cspell --version`; - isInstalled = true; -} catch (error) { - console.error( - "cSpell is not installed. Please install with your package manager.", - ); - // Print hint to console with cmd: npm install -g cspell@latest - console.info("Hint: npm install -g cspell@latest"); +async function main() { + let isInstalled = false; + try { + await $`cspell --version`; + isInstalled = true; + } catch (error) { + console.error( + "cSpell is not installed. Please install with your package manager.", + ); + // Print hint to console with cmd: npm install -g cspell@latest + console.info("Hint: npm install -g cspell@latest"); + } } // Extract project name from current directory @@ -41,27 +43,60 @@ const cSpellContent = { // Create a project-name.txt file with the project name writeFile(`./${projectName}.txt`, ""); -writeFile("./cspell.json", JSON.stringify(cSpellContent, null, 2)); + const projectName = await consola.prompt("What is your project name?", { + placeholder: "Not sure", + initial: "java", + }); + + const confirmed = await consola.prompt("Do you want to continue?", { + type: "confirm", + }); + + if (!confirmed) { + process.exit(0); + } + + const projectType = await consola.prompt("Pick a project type.", { + type: "select", + options: [ + "md", + "ts", + "json", + ], + }); + + const tools = await consola.prompt("Select additional tools.", { + type: "multiselect", + required: false, + options: [ + { value: "eslint", label: "ESLint", hint: "recommended" }, + { value: "prettier", label: "Prettier" }, + { value: "gh-action", label: "GitHub Action" }, + ], + }); -// TODO: Support other file types -// Run cspell on Markdown files to get unknown words -const cmd = `${ - isInstalled ? "" : "npx " -}cspell --words-only --unique --no-progress --show-context "**/**/*.md" "**/**/*.ts" "**/**/*.json"`; -const unknownWords = await new Promise((resolve) => { - exec(cmd, (error: any, stdout: string) => { - if (error) { - console.error(`Error running cspell: ${error}`); - } + consola.start("Creating project..."); - const words = stdout ? stdout.split("\n").filter((word: any) => word) : []; - resolve(words); + const cmd = `${ + isInstalled ? "" : "npx " + }cspell --words-only --unique --no-progress --show-context "**/**/*.${projectType}"`; + const unknownWords = await new Promise((resolve) => { + exec(cmd, (error: any, stdout: string) => { + if (error) { + console.error(`Error running cspell: ${error}`); + } + + const words = stdout ? stdout.split("\n").filter((word: any) => word) : []; + resolve(words); + }); }); -}); -console.log(`Found ${unknownWords.length} unknown words.`); + console.log(`Found ${unknownWords.length} unknown words.`); + + // Save unknown words in project-name.txt + writeFile(`./${projectName}.txt`, unknownWords.join("\n")); + console.log("cSpell setup completed."); + process.exit(0); +} -// Save unknown words in project-name.txt -writeFile(`./${projectName}.txt`, unknownWords.join("\n")); -console.log("cSpell setup completed."); -process.exit(0); +main(); From 52669d4c601c0097ea0d40d3979f1e4e59fcba76 Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:16:15 +0000 Subject: [PATCH 2/3] feat: Updated package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 78c2506..322fdd4 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "dev": "bun run --watch index.ts" }, "dependencies": { - "zx": "7.2.3" + "zx": "7.2.3", + "consola": "latest" }, "devDependencies": { "@skypack/package-check": "0.2.2", From 3b2b6dba577c1cc4d95faeb8d5c85df0448856bd Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 17:17:36 +0000 Subject: [PATCH 3/3] feat: Updated index.ts --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 69f425a..b750705 100644 --- a/index.ts +++ b/index.ts @@ -3,7 +3,7 @@ import { $ } from "zx"; import { exec } from "child_process"; import { writeFile } from "./lib"; -import { consola } from "./utils"; +import consola from 'consola'; async function main() { let isInstalled = false;