From 58db5c39b884b59e270728c8b378fbd0bd0b674a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Zorro?= Date: Tue, 19 Nov 2024 10:22:48 -0500 Subject: [PATCH] refactor: main module refactor to figure out e2e tests --- bun.lockb | Bin 108096 -> 108240 bytes lib/main.ts | 216 ++++++++++++++++++++++++++++----------------------- package.json | 5 +- 3 files changed, 121 insertions(+), 100 deletions(-) diff --git a/bun.lockb b/bun.lockb index 8ee27b98f1935fd4e14e999e09e73215dafc9260..82e44da95f4e9a52d6798dabde09fe5d7fcf0f45 100755 GIT binary patch delta 22539 zcmeHvcU)CRxAvYR2RSH$VgW%Zf+7eCQbiA7*9|H*?0|YykS-Q%976138+F@z!4|s` zW5Zr!NusDR>KlzEYSbhq8l&H{b`g?K-`~yszI*?A_m77)&y+Q@)~uO5oPF4b&sknP zZ#m1ae)PuqHwtpC=iT_$-JK8iHK+>R_K-vjHuDJ!Y*&-tZk_t*7se=J%SP8N&2q|!YB(4qk9!5hQ zU03BLNNVS;C^kDnQoHhyRUm&WFL!8u07?Co$UIjtpHd6v!)z+ZPR&5qg5ZJPNa2sj zC(E~i(*R*v)<9FXuovy9gSC*eW=%p;zWG%!2MWD*>}NzXk<(%U~P zaeyfo6WIq^s9+T&S@;ViRY-x`vjPM`v-t1xs?GNldqJp*`r7vrGd`Y1v4-DTeffq=5^NWXMYw z#Q?2cR<0>=pl`;|!CJ;=?n;9`b(G+WfW+9$rmU>=EML>8SPw;kpIWXhvp`Q}%7!Ek z^Bt6uIM@}OVnU0Bzc1_Wpoa{~^{c12x*{a{Hs8hwG2Ld-OAz2q^H-1v4|BWvN`oel zv`S7QpQdV4Su) z4VCdFW@RM}!dxFgIgMi{B#l2cF~c{#f3mOvoW{9WEq~&#=vT{gg}Z9TbhV*2PFHoD z8NMm$0}``MkO=E+p}4U!{;3EPa!{*4CA7wXQ^&W!X&`^!5VJ-l%Tby=EG4Nw>ShAg zh)=UISQ*hLs?-|N+9pNX2G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>MIdF-pp#bEO$`QRcHAxkyAB2 z94b0Z%^sDQ=}BdVjQDtF=iirn^Ot-vv>)@abH;L`KVPN=`k!Mtbzfhk$3#e@#e#lp z+CHcL%&V5E{H;{PAhuC-oz0qw+Xu7yrqZo^--*F2h&7aE$SZTy_>`>7cu%}6Gd?Co ztQ^1`#MiS}H?h@Fd{q`8S`K0!;^?8QP7mpu3@YCtGj~jUMw@EY6iq5#@TOeS%TGOH zQZo``lM_9&@e0p`jKoo?G0AudV`8S<%fX@eLT>CZ7HlfDC&r9qHlk|^a}!+#v+0WR zk6Fy22KGtuX%us%jD|IF`$K?>5yO~^=v~0VMDIb&T--B^)n~rq(~+#HtoUgdYrxvR zRn!*!hBK>b3Ue`Q_@ArPOH3V;mD$F#jU+v*>Y9s>sc3bDXUyBt>=?tYGUoTTCv&lD zENiF?_3&7BvDv<{1#B)8^FCsA_7%)#lkLq**2^=tV?90pX==9ekgoTd<;f-Zea!s- E17&eY`v3p{ diff --git a/lib/main.ts b/lib/main.ts index 966e94e..2554d2e 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -1,6 +1,7 @@ import { relative, resolve } from "node:path"; +import { basename } from "node:path"; import { select } from "@inquirer/prompts"; -import { $ } from "bun"; +import { $, main as entrypoint } from "bun"; import chalk from "chalk"; import { capitalCase } from "change-case"; import yargs from "yargs"; @@ -17,65 +18,116 @@ import { createGenerator } from "./utils/generator"; import { labelElementByName } from "./utils/labels"; import { getWorkspaceJson, getWorkspacePath } from "./utils/workspace"; -const args = await yargs(hideBin(process.argv)) - .version("version", "Show current tool version", pkg.version) - .usage( - `${capitalCase( - pkg.name, - )}: Create a Structurizr DSL scaffolding in seconds!`, - ) - .option("dest", { - default: ".", - desc: "Target architecture folder", - }) - .option("export", { - alias: "e", - type: "boolean", - default: false, - desc: "Use structurizr-cli to export the workspace to JSON", - }).argv; - -console.log( - chalk.bold(` -Welcome to ${chalk.cyan(capitalCase(pkg.name))} +type CLIArguments = { + dest: string; + version?: boolean; + export?: boolean; +}; + +async function main(args: CLIArguments = { dest: "." }) { + console.log( + chalk.bold(` +Welcome to ${chalk.cyan(capitalCase(pkg.name.replace(/@[a-z-]*\//, "")))} Create a Structurizr DSL scaffolding in seconds! `), -); + ); -const destPath = resolve(process.cwd(), args.dest); -const workspacePath = getWorkspacePath(destPath); + const destPath = resolve(process.cwd(), args.dest); + const workspacePath = getWorkspacePath(destPath); -const exportWorkspace = async (path: string) => { - if (!args.export) return; - const workspacePath = getWorkspacePath(path); - if (!workspacePath) return; + const exportWorkspace = async (path: string) => { + if (!args.export) return; + const workspacePath = getWorkspacePath(path); + if (!workspacePath) return; - // TODO: Make it compatible for Windows - return $`structurizr-cli export -w ${workspacePath}/workspace.dsl -f json -o ${workspacePath} || true`; -}; + // TODO: Make it compatible for Windows + return $`structurizr-cli export -w ${workspacePath}/workspace.dsl -f json -o ${workspacePath} || true`; + }; -const { workspaceGenerator, ...otherGenerators } = generators; + const { workspaceGenerator, ...otherGenerators } = generators; -if (!workspacePath) { - console.log(`${chalk.yellow( - 'It seems the folder you selected does not have a "workspace.dsl" file.', - )} + if (!workspacePath) { + console.log(`${chalk.yellow( + 'It seems the folder you selected does not have a "workspace.dsl" file.', + )} Destination folder: ${chalk.blue( - relative(process.cwd(), destPath) || process.cwd(), - )} + relative(process.cwd(), destPath) || process.cwd(), + )} Let's create a new one by answering the questions below. `); + try { + const generator: Generator> = + { + ...workspaceGenerator, + templates, + destPath, + }; + + await createGenerator(generator); + await exportWorkspace( + relative(process.cwd(), destPath) || process.cwd(), + ); + process.exit(0); + } catch (err) { + console.error(err); + process.exit(1); + } + } + + const workspaceInfo = await getWorkspaceJson( + getWorkspacePath(workspacePath), + ); + + console.log( + chalk.gray(`Workspace name: ${chalk.cyan(workspaceInfo?.name)}`), + ); + console.log( + chalk.gray( + `Architecture folder: ${chalk.cyan( + relative(process.cwd(), workspacePath), + )}\n`, + ), + ); + + const DEFAULT_GENERATOR_SORTING = [ + "Workspace", + "Constant", + "System", + "Person", + "External System", + "Container", + "Component", + "View", + "Relationship", + ]; + + const element = await select({ + message: "Create a new element:", + choices: Object.values(otherGenerators) + .map((g) => ({ + name: `${labelElementByName(g.name)} ${g.name}`, + value: g, + })) + .toReversed() + .toSorted((a, b) => { + const aIndex = DEFAULT_GENERATOR_SORTING.indexOf(a.value.name); + const bIndex = DEFAULT_GENERATOR_SORTING.indexOf(b.value.name); + + return aIndex - bIndex; + }), + }); + + type GeneratorAnswers = GetAnswers; + try { - const generator: Generator> = { - ...workspaceGenerator, + const generator: Generator = { + ...(element as GeneratorDefinition), templates, destPath, }; await createGenerator(generator); - await exportWorkspace( - relative(process.cwd(), destPath) || process.cwd(), - ); + await exportWorkspace(relative(process.cwd(), workspacePath)); process.exit(0); } catch (err) { console.error(err); @@ -83,58 +135,26 @@ Let's create a new one by answering the questions below. } } -const workspaceInfo = await getWorkspaceJson(getWorkspacePath(workspacePath)); - -console.log(chalk.gray(`Workspace name: ${chalk.cyan(workspaceInfo?.name)}`)); -console.log( - chalk.gray( - `Architecture folder: ${chalk.cyan( - relative(process.cwd(), workspacePath), - )}\n`, - ), -); - -const DEFAULT_GENERATOR_SORTING = [ - "Workspace", - "Constant", - "System", - "Person", - "External System", - "Container", - "Component", - "View", - "Relationship", -]; - -const element = await select({ - message: "Create a new element:", - choices: Object.values(otherGenerators) - .map((g) => ({ - name: `${labelElementByName(g.name)} ${g.name}`, - value: g, - })) - .toReversed() - .toSorted((a, b) => { - const aIndex = DEFAULT_GENERATOR_SORTING.indexOf(a.value.name); - const bIndex = DEFAULT_GENERATOR_SORTING.indexOf(b.value.name); - - return aIndex - bIndex; - }), -}); - -type GeneratorAnswers = GetAnswers; - -try { - const generator: Generator = { - ...(element as GeneratorDefinition), - templates, - destPath, - }; - - await createGenerator(generator); - await exportWorkspace(relative(process.cwd(), workspacePath)); - process.exit(0); -} catch (err) { - console.error(err); - process.exit(1); +export default main; + +if (["main.ts", "scfz"].includes(basename(entrypoint))) { + const args: CLIArguments = await yargs(hideBin(process.argv)) + .version("version", "Show current tool version", pkg.version) + .usage( + `${capitalCase( + pkg.name, + )}: Create a Structurizr DSL scaffolding in seconds!`, + ) + .option("dest", { + default: ".", + desc: "Target architecture folder", + }) + .option("export", { + alias: "e", + type: "boolean", + default: false, + desc: "Use structurizr-cli to export the workspace to JSON", + }).argv; + + main(args); } diff --git a/package.json b/package.json index 73df29b..3120769 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,14 @@ }, "scripts": { "build:dev": "bun build ./lib/main.ts --compile --watch --outfile ./dist/scfz", - "test:dev": "bun test --watch --coverage", + "test:dev": "bun test --watch", "test": "bun test", "test:ci": "bun test --coverage", "prepare": "husky" }, "trustedDependencies": [".", "@biomejs/biome"], "dependencies": { - "@inquirer/prompts": "^6.0.1", + "@inquirer/prompts": "^7.0.0", "chalk": "^5.3.0", "change-case": "^5.4.4", "handlebars": "^4.7.8", @@ -26,6 +26,7 @@ "@biomejs/biome": "^1.9.3", "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.4.1", + "@inquirer/testing": "^2.1.37", "@inquirer/type": "^1.5.5", "@types/bun": "^1.1.10", "@types/inquirer": "^9.0.7",