diff --git a/index.ts b/index.ts index 80acd8f..686c295 100755 --- a/index.ts +++ b/index.ts @@ -115,8 +115,8 @@ const runPrompt = async () => { } }; - // Compiles ts so that the parse-imports package can parse the example pattern - // and know which packages will need to be installed later on + // Collects all js/ts files and checks all of their imports + // and gets only the external packages const readExampleImports = async () => { const fileList = await readdir(finalDestination, { recursive: true }); const allJSAndTSFiles = []; @@ -138,10 +138,12 @@ const runPrompt = async () => { if (allJSAndTSFiles.length > 0) { const foundExternalPackages = []; + // Gets imports for each js/ts file allJSAndTSFiles.forEach((filePath) => { const fileImports = getImports(filePath); if (fileImports.length > 0) { fileImports.map((i) => { + // Checks if import is from an external package if (isExternalImport(filePath, i)) { foundExternalPackages.push(i); } @@ -210,10 +212,6 @@ const runPrompt = async () => { } }; - const removeDuplicatesFromArr = (data, key) => [ - ...new Map(data.map((x) => [key(x), x])).values(), - ]; - const buildInlinePattern = () => { // inline pattern generation step chosen console.log('Building inline pattern 🛠️'); diff --git a/package.json b/package.json index 8abe4ef..cd3e62c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "dependencies": { "@inquirer/prompts": "^7.1.0", "cli-table": "^0.3.11", - "tiged": "^2.12.7" + "tiged": "^2.12.7", + "typescript": "^5.6.3" }, "devDependencies": { "@commitlint/cli": "^18.0.0", @@ -36,8 +37,7 @@ "lint-staged": "^15.0.0", "prettier": "^3.3.3", "rimraf": "^6.0.1", - "semantic-release": "^24.2.0", - "typescript": "^5.6.3" + "semantic-release": "^24.2.0" }, "bin": { "generate-pattern": "dist/index.js"