diff --git a/src/actions/dev.ts b/src/actions/dev.ts index 91e8741..4afaeea 100644 --- a/src/actions/dev.ts +++ b/src/actions/dev.ts @@ -67,8 +67,6 @@ const showInfo = () => { console.log() } - - const send = async (config: Config, dayNum: number, part: 1 | 2) => { console.log(`\nPart ${part}:`) const dayData = diff --git a/src/actions/init.ts b/src/actions/init.ts index 508a9b6..7247b15 100644 --- a/src/actions/init.ts +++ b/src/actions/init.ts @@ -9,6 +9,7 @@ import copy from "../io/copy.js" import packageJSON from "../configs/packageJSON.js" import tsconfigJSON from "../configs/tsconfigJSON.js" import prettierJSON from "../configs/prettierJSON.js" +import launchJSON from "../configs/launchJSON.js" import gitignoreTXT from "../configs/gitignoreTXT.js" import prettierignoreTXT from "../configs/prettierignoreTXT.js" import runnerJSON from "../configs/runnerJSON.js" @@ -69,6 +70,12 @@ const init = async () => { save(dir, "tsconfig.json", tsconfigJSON(setup)) } + if (setup.vscodeSettings) { + const vscodeSettingsDir = path.join(dir, ".vscode") + fs.mkdirSync(vscodeSettingsDir, { recursive: true }) + save(vscodeSettingsDir, "launch.json", launchJSON(setup)) + } + const templatesDir = path.resolve( dirname, "..", diff --git a/src/cli.ts b/src/cli.ts index e17e8ed..b3f0235 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -38,7 +38,7 @@ switch (String(command || "").toLowerCase()) { } case "update:readme": { updateReadme() - break; + break } default: { console.log("Command not supported") diff --git a/src/configs/launchJSON.ts b/src/configs/launchJSON.ts new file mode 100644 index 0000000..31a6367 --- /dev/null +++ b/src/configs/launchJSON.ts @@ -0,0 +1,27 @@ +import type { Setup } from "../types/common" + +const launchJSON = ({ packageManager }: Setup) => { + return { + configurations: [ + { + name: "Advent of Code Runner: Start", + type: "node", + request: "launch", + trace: "true", + runtimeExecutable: packageManager, + runtimeArgs: ["start", "${input:day}"], + console: "integratedTerminal", + }, + ], + inputs: [ + { + id: "day", + type: "promptString", + description: "Enter the day number", + default: "1", + }, + ], + } +} + +export default launchJSON diff --git a/src/prompts/initPrompt.ts b/src/prompts/initPrompt.ts index 3340ce7..59ae0fa 100644 --- a/src/prompts/initPrompt.ts +++ b/src/prompts/initPrompt.ts @@ -80,6 +80,15 @@ const initPrompt = () => { ], initial: 0, }, + { + type: "toggle", + name: "vscodeSettings", + message: + "(Optional) Would you like to include the default launch.json configuration ? ", + initial: false, + active: "yes", + inactive: "no", + }, ], { onCancel }, ) diff --git a/src/types/common.ts b/src/types/common.ts index da41392..5bbfd12 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -6,6 +6,7 @@ export type Setup = { author: string semicolons: boolean strict: boolean + vscodeSettings: boolean } type DayConfig = { diff --git a/src/version.ts b/src/version.ts index 440d85f..9e533e9 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ /* This file is auto-generated - do not modify */ -export default "1.9.5" \ No newline at end of file +export default "1.9.5"