From e2bbc8bc742a86ce641a190c05f95c9753e5331d Mon Sep 17 00:00:00 2001 From: florianbgt Date: Mon, 4 Nov 2024 19:31:32 +0100 Subject: [PATCH] improve dependency tree and file edits --- package-lock.json | 743 ++---------------- packages/cli/package.json | 1 - packages/cli/src/api/scan.ts | 11 +- packages/cli/src/api/split.ts | 16 +- packages/cli/src/api/sync.ts | 98 +-- packages/cli/src/commands/annotate.ts | 26 +- packages/cli/src/commands/split.ts | 11 +- packages/cli/src/helper/annotations.ts | 44 ++ packages/cli/src/helper/cleanup.ts | 75 ++ packages/cli/src/helper/dependencies.ts | 86 -- packages/cli/src/helper/dependencyTree.ts | 138 ++++ packages/cli/src/helper/file.ts | 140 +--- packages/cli/src/helper/groups.ts | 19 - .../helper/languages/javascript/cleanup.ts | 6 +- packages/cli/src/helper/payloads.ts | 31 - packages/cli/src/helper/{tree.ts => split.ts} | 37 +- packages/cli/src/helper/treeSitter.ts | 17 + packages/cli/src/helper/types.ts | 6 +- 18 files changed, 420 insertions(+), 1085 deletions(-) create mode 100644 packages/cli/src/helper/annotations.ts create mode 100644 packages/cli/src/helper/cleanup.ts delete mode 100644 packages/cli/src/helper/dependencies.ts create mode 100644 packages/cli/src/helper/dependencyTree.ts delete mode 100644 packages/cli/src/helper/groups.ts delete mode 100644 packages/cli/src/helper/payloads.ts rename packages/cli/src/helper/{tree.ts => split.ts} (60%) create mode 100644 packages/cli/src/helper/treeSitter.ts diff --git a/package-lock.json b/package-lock.json index 4a16dca..5814781 100644 --- a/package-lock.json +++ b/package-lock.json @@ -196,6 +196,7 @@ "version": "7.25.7", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.7.tgz", "integrity": "sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -205,6 +206,7 @@ "version": "7.25.7", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.7.tgz", "integrity": "sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -332,6 +334,7 @@ "version": "7.25.8", "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.8.tgz", "integrity": "sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==", + "dev": true, "license": "MIT", "dependencies": { "@babel/types": "^7.25.8" @@ -423,6 +426,7 @@ "version": "7.25.8", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz", "integrity": "sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==", + "dev": true, "license": "MIT", "dependencies": { "@babel/helper-string-parser": "^7.25.7", @@ -475,19 +479,6 @@ "node": ">17.0.0" } }, - "node_modules/@dependents/detective-less": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@dependents/detective-less/-/detective-less-5.0.0.tgz", - "integrity": "sha512-D/9dozteKcutI5OdxJd8rU+fL6XgaaRg60sPPJWkT33OCiRfkCu5wO5B/yXTaaL2e6EB0lcCBGe5E0XscZCvvQ==", - "license": "MIT", - "dependencies": { - "gonzales-pe": "^4.3.0", - "node-source-walk": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -1249,6 +1240,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { @@ -1270,6 +1262,7 @@ "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "2.0.5", @@ -1283,6 +1276,7 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -1292,6 +1286,7 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.scandir": "2.1.5", @@ -3879,83 +3874,6 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/types": { - "version": "7.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.18.0.tgz", - "integrity": "sha512-iZqi+Ds1y4EDYUtlOOC+aUmxnE9xS/yCigkjA7XpTKV6nCBd3Hp/PRGGmdwnfkV2ThMyYldP1wRpm/id99spTQ==", - "license": "MIT", - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.18.0.tgz", - "integrity": "sha512-aP1v/BSPnnyhMHts8cf1qQ6Q1IFwwRvAQGRvBFkWlo3/lH29OXA3Pts+c10nxRxIBrDnoMqzhgdwVe5f2D6OzA==", - "license": "BSD-2-Clause", - "dependencies": { - "@typescript-eslint/types": "7.18.0", - "@typescript-eslint/visitor-keys": "7.18.0", - "debug": "^4.3.4", - "globby": "^11.1.0", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@typescript-eslint/utils": { "version": "8.9.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.9.0.tgz", @@ -4092,35 +4010,6 @@ "node": ">=10" } }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.18.0.tgz", - "integrity": "sha512-cDF0/Gf81QpY3xYyJKDV14Zwdmid5+uuENhjH2EqFaF0ni+yAyq/LzMaIJdhNJXZI7uLzwIlA+V7oWoyn6Curg==", - "license": "MIT", - "dependencies": { - "@typescript-eslint/types": "7.18.0", - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^18.18.0 || >=20.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/@vitejs/plugin-react": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.2.tgz", @@ -4255,74 +4144,6 @@ "url": "https://opencollective.com/vitest" } }, - "node_modules/@vue/compiler-core": { - "version": "3.5.12", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.12.tgz", - "integrity": "sha512-ISyBTRMmMYagUxhcpyEH0hpXRd/KqDU4ymofPgl2XAkY9ZhQ+h0ovEZJIiPop13UmR/54oA2cgMDjgroRelaEw==", - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.25.3", - "@vue/shared": "3.5.12", - "entities": "^4.5.0", - "estree-walker": "^2.0.2", - "source-map-js": "^1.2.0" - } - }, - "node_modules/@vue/compiler-core/node_modules/estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "license": "MIT" - }, - "node_modules/@vue/compiler-dom": { - "version": "3.5.12", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.12.tgz", - "integrity": "sha512-9G6PbJ03uwxLHKQ3P42cMTi85lDRvGLB2rSGOiQqtXELat6uI4n8cNz9yjfVHRPIu+MsK6TE418Giruvgptckg==", - "license": "MIT", - "dependencies": { - "@vue/compiler-core": "3.5.12", - "@vue/shared": "3.5.12" - } - }, - "node_modules/@vue/compiler-sfc": { - "version": "3.5.12", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.12.tgz", - "integrity": "sha512-2k973OGo2JuAa5+ZlekuQJtitI5CgLMOwgl94BzMCsKZCX/xiqzJYzapl4opFogKHqwJk34vfsaKpfEhd1k5nw==", - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.25.3", - "@vue/compiler-core": "3.5.12", - "@vue/compiler-dom": "3.5.12", - "@vue/compiler-ssr": "3.5.12", - "@vue/shared": "3.5.12", - "estree-walker": "^2.0.2", - "magic-string": "^0.30.11", - "postcss": "^8.4.47", - "source-map-js": "^1.2.0" - } - }, - "node_modules/@vue/compiler-sfc/node_modules/estree-walker": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "license": "MIT" - }, - "node_modules/@vue/compiler-ssr": { - "version": "3.5.12", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.12.tgz", - "integrity": "sha512-eLwc7v6bfGBSM7wZOGPmRavSWzNFF6+PdRhE+VFJhNCgHiF8AM7ccoqcv5kBXA2eWUfigD7byekvf/JsOfKvPA==", - "license": "MIT", - "dependencies": { - "@vue/compiler-dom": "3.5.12", - "@vue/shared": "3.5.12" - } - }, - "node_modules/@vue/shared": { - "version": "3.5.12", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.12.tgz", - "integrity": "sha512-L2RPSAwUFbgZH20etwrXyVyCBu9OxRSi8T/38QsvnkJyvq2LufW2lDCOzm7t/U9C1mkhJGWYfCuFBCmIuNivrg==", - "license": "MIT" - }, "node_modules/@xyflow/react": { "version": "12.3.2", "resolved": "https://registry.npmjs.org/@xyflow/react/-/react-12.3.2.tgz", @@ -4530,12 +4351,6 @@ "resolved": "packages/app", "link": true }, - "node_modules/app-module-path": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/app-module-path/-/app-module-path-2.2.0.tgz", - "integrity": "sha512-gkco+qxENJV+8vFcDiiFhuoSvRXb2a/QPqpSoWhVz829VNJfOTnELbBmPmNKFxf3xdNnw4DWCkzkDaavcX/1YQ==", - "license": "BSD-2-Clause" - }, "node_modules/arg": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", @@ -4572,6 +4387,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -4587,15 +4403,6 @@ "node": ">=12" } }, - "node_modules/ast-module-types": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/ast-module-types/-/ast-module-types-6.0.0.tgz", - "integrity": "sha512-LFRg7178Fw5R4FAEwZxVqiRI8IxSM+Ay2UBrHoCerXNme+kMMMfz7T3xDGV/c2fer87hcrtgJGsnSOfUrPK6ng==", - "license": "MIT", - "engines": { - "node": ">=18" - } - }, "node_modules/ast-types": { "version": "0.13.4", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", @@ -4697,6 +4504,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, "license": "MIT" }, "node_modules/base64-js": { @@ -4951,6 +4759,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -5385,19 +5194,11 @@ "node": ">= 0.8" } }, - "node_modules/commander": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", - "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", - "license": "MIT", - "engines": { - "node": ">=18" - } - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, "license": "MIT" }, "node_modules/config-chain": { @@ -5827,24 +5628,6 @@ "node": ">= 0.8" } }, - "node_modules/dependency-tree": { - "version": "11.0.1", - "resolved": "https://registry.npmjs.org/dependency-tree/-/dependency-tree-11.0.1.tgz", - "integrity": "sha512-eCt7HSKIC9NxgIykG2DRq3Aewn9UhVS14MB3rEn6l/AsEI1FBg6ZGSlCU0SZ6Tjm2kkhj6/8c2pViinuyKELhg==", - "license": "MIT", - "dependencies": { - "commander": "^12.0.0", - "filing-cabinet": "^5.0.1", - "precinct": "^12.0.2", - "typescript": "^5.4.5" - }, - "bin": { - "dependency-tree": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -5900,137 +5683,6 @@ "integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==", "license": "MIT" }, - "node_modules/detective-amd": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/detective-amd/-/detective-amd-6.0.0.tgz", - "integrity": "sha512-NTqfYfwNsW7AQltKSEaWR66hGkTeD52Kz3eRQ+nfkA9ZFZt3iifRCWh+yZ/m6t3H42JFwVFTrml/D64R2PAIOA==", - "license": "MIT", - "dependencies": { - "ast-module-types": "^6.0.0", - "escodegen": "^2.1.0", - "get-amd-module-type": "^6.0.0", - "node-source-walk": "^7.0.0" - }, - "bin": { - "detective-amd": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/detective-cjs": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/detective-cjs/-/detective-cjs-6.0.0.tgz", - "integrity": "sha512-R55jTS6Kkmy6ukdrbzY4x+I7KkXiuDPpFzUViFV/tm2PBGtTCjkh9ZmTuJc1SaziMHJOe636dtiZLEuzBL9drg==", - "license": "MIT", - "dependencies": { - "ast-module-types": "^6.0.0", - "node-source-walk": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/detective-es6": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/detective-es6/-/detective-es6-5.0.0.tgz", - "integrity": "sha512-NGTnzjvgeMW1khUSEXCzPDoraLenWbUjCFjwxReH+Ir+P6LGjYtaBbAvITWn2H0VSC+eM7/9LFOTAkrta6hNYg==", - "license": "MIT", - "dependencies": { - "node-source-walk": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/detective-postcss": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/detective-postcss/-/detective-postcss-7.0.0.tgz", - "integrity": "sha512-pSXA6dyqmBPBuERpoOKKTUUjQCZwZPLRbd1VdsTbt6W+m/+6ROl4BbE87yQBUtLoK7yX8pvXHdKyM/xNIW9F7A==", - "license": "MIT", - "dependencies": { - "is-url": "^1.2.4", - "postcss-values-parser": "^6.0.2" - }, - "engines": { - "node": "^14.0.0 || >=16.0.0" - }, - "peerDependencies": { - "postcss": "^8.4.38" - } - }, - "node_modules/detective-sass": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/detective-sass/-/detective-sass-6.0.0.tgz", - "integrity": "sha512-h5GCfFMkPm4ZUUfGHVPKNHKT8jV7cSmgK+s4dgQH4/dIUNh9/huR1fjEQrblOQNDalSU7k7g+tiW9LJ+nVEUhg==", - "license": "MIT", - "dependencies": { - "gonzales-pe": "^4.3.0", - "node-source-walk": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/detective-scss": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/detective-scss/-/detective-scss-5.0.0.tgz", - "integrity": "sha512-Y64HyMqntdsCh1qAH7ci95dk0nnpA29g319w/5d/oYcHolcGUVJbIhOirOFjfN1KnMAXAFm5FIkZ4l2EKFGgxg==", - "license": "MIT", - "dependencies": { - "gonzales-pe": "^4.3.0", - "node-source-walk": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/detective-stylus": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/detective-stylus/-/detective-stylus-5.0.0.tgz", - "integrity": "sha512-KMHOsPY6aq3196WteVhkY5FF+6Nnc/r7q741E+Gq+Ax9mhE2iwj8Hlw8pl+749hPDRDBHZ2WlgOjP+twIG61vQ==", - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/detective-typescript": { - "version": "13.0.0", - "resolved": "https://registry.npmjs.org/detective-typescript/-/detective-typescript-13.0.0.tgz", - "integrity": "sha512-tcMYfiFWoUejSbvSblw90NDt76/4mNftYCX0SMnVRYzSXv8Fvo06hi4JOPdNvVNxRtCAKg3MJ3cBJh+ygEMH+A==", - "license": "MIT", - "dependencies": { - "@typescript-eslint/typescript-estree": "^7.6.0", - "ast-module-types": "^6.0.0", - "node-source-walk": "^7.0.0" - }, - "engines": { - "node": "^14.14.0 || >=16.0.0" - }, - "peerDependencies": { - "typescript": "^5.4.4" - } - }, - "node_modules/detective-vue2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/detective-vue2/-/detective-vue2-2.0.3.tgz", - "integrity": "sha512-AgWdSfVnft8uPGnUkdvE1EDadEENDCzoSRMt2xZfpxsjqVO617zGWXbB8TGIxHaqHz/nHa6lOSgAB8/dt0yEug==", - "license": "MIT", - "dependencies": { - "@vue/compiler-sfc": "^3.4.27", - "detective-es6": "^5.0.0", - "detective-sass": "^6.0.0", - "detective-scss": "^5.0.0", - "detective-stylus": "^5.0.0", - "detective-typescript": "^13.0.0" - }, - "engines": { - "node": ">=18" - }, - "peerDependencies": { - "typescript": "^5.4.4" - } - }, "node_modules/didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", @@ -6052,6 +5704,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, "license": "MIT", "dependencies": { "path-type": "^4.0.0" @@ -6140,31 +5793,6 @@ "once": "^1.4.0" } }, - "node_modules/enhanced-resolve": { - "version": "5.17.1", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", - "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.4", - "tapable": "^2.2.0" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/env-paths": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", @@ -6290,6 +5918,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "esprima": "^4.0.1", @@ -6464,6 +6093,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, "license": "BSD-2-Clause", "bin": { "esparse": "bin/esparse.js", @@ -6503,6 +6133,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=4.0" @@ -6522,6 +6153,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=0.10.0" @@ -6674,6 +6306,7 @@ "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", @@ -6690,6 +6323,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.1" @@ -6716,6 +6350,7 @@ "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, "license": "ISC", "dependencies": { "reusify": "^1.0.4" @@ -6734,31 +6369,6 @@ "node": ">=16.0.0" } }, - "node_modules/filing-cabinet": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/filing-cabinet/-/filing-cabinet-5.0.2.tgz", - "integrity": "sha512-RZlFj8lzyu6jqtFBeXNqUjjNG6xm+gwXue3T70pRxw1W40kJwlgq0PSWAmh0nAnn5DHuBIecLXk9+1VKS9ICXA==", - "license": "MIT", - "dependencies": { - "app-module-path": "^2.2.0", - "commander": "^12.0.0", - "enhanced-resolve": "^5.16.0", - "module-definition": "^6.0.0", - "module-lookup-amd": "^9.0.1", - "resolve": "^1.22.8", - "resolve-dependency-path": "^4.0.0", - "sass-lookup": "^6.0.1", - "stylus-lookup": "^6.0.0", - "tsconfig-paths": "^4.2.0", - "typescript": "^5.4.4" - }, - "bin": { - "filing-cabinet": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -6979,6 +6589,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, "license": "ISC" }, "node_modules/fsevents": { @@ -7015,19 +6626,6 @@ "node": ">=6.9.0" } }, - "node_modules/get-amd-module-type": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/get-amd-module-type/-/get-amd-module-type-6.0.0.tgz", - "integrity": "sha512-hFM7oivtlgJ3d6XWD6G47l8Wyh/C6vFw5G24Kk1Tbq85yh5gcM8Fne5/lFhiuxB+RT6+SI7I1ThB9lG4FBh3jw==", - "license": "MIT", - "dependencies": { - "ast-module-types": "^6.0.0", - "node-source-walk": "^7.0.0" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -7078,12 +6676,6 @@ "node": ">=6" } }, - "node_modules/get-own-enumerable-property-symbols": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", - "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==", - "license": "ISC" - }, "node_modules/get-stream": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", @@ -7160,6 +6752,7 @@ "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", @@ -7232,6 +6825,7 @@ "version": "11.1.0", "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, "license": "MIT", "dependencies": { "array-union": "^2.1.0", @@ -7248,21 +6842,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/gonzales-pe": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/gonzales-pe/-/gonzales-pe-4.3.0.tgz", - "integrity": "sha512-otgSPpUmdWJ43VXyiNgEYE4luzHCL2pz4wQ0OnDluC6Eg4Ko3Vexy/SrSynglw/eR+OhkzmqFCZa/OFa/RgAOQ==", - "license": "MIT", - "dependencies": { - "minimist": "^1.2.5" - }, - "bin": { - "gonzales": "bin/gonzales.js" - }, - "engines": { - "node": ">=0.6.0" - } - }, "node_modules/gopd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", @@ -7279,6 +6858,7 @@ "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, "license": "ISC" }, "node_modules/graphemer": { @@ -7497,6 +7077,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -7541,6 +7122,7 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, "license": "ISC", "dependencies": { "once": "^1.3.0", @@ -7804,6 +7386,7 @@ "version": "2.15.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", + "dev": true, "license": "MIT", "dependencies": { "hasown": "^2.0.2" @@ -7948,15 +7531,6 @@ "node": ">=0.12.0" } }, - "node_modules/is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha512-l4RyHgRqGN4Y3+9JHVrNqO+tN0rV5My76uW5/nuO4K1b6vw5G8d/cmFjP9tRfEsdhZNt0IFdZuK/c2Vr4Nb+Qg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-path-inside": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-4.0.0.tgz", @@ -7979,15 +7553,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha512-7zjFAPO4/gwyQAAgRRmqeEeyIICSdmCqa3tsVHMdBzaXXRiqopZL4Cyghg/XulGWrtABTpbnYYzzIRffLkP4oA==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-ssh": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", @@ -8024,24 +7589,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-url": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz", - "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==", - "license": "MIT" - }, - "node_modules/is-url-superb": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-url-superb/-/is-url-superb-4.0.0.tgz", - "integrity": "sha512-GI+WjezhPPcbM+tqE9LnmsY5qqjwHzTvjJ36wxYX5ujNXefSUJ/T17r5bqDV8yLhcgB59KTPNOc9O9cmHTPWsA==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-wsl": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", @@ -8185,6 +7732,7 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, "license": "MIT", "bin": { "json5": "lib/cli.js" @@ -8445,6 +7993,7 @@ "version": "0.30.12", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.12.tgz", "integrity": "sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw==", + "dev": true, "license": "MIT", "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0" @@ -8486,6 +8035,7 @@ "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -8588,6 +8138,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -8600,6 +8151,7 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -8621,40 +8173,6 @@ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", "dev": true }, - "node_modules/module-definition": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/module-definition/-/module-definition-6.0.0.tgz", - "integrity": "sha512-sEGP5nKEXU7fGSZUML/coJbrO+yQtxcppDAYWRE9ovWsTbFoUHB2qDUx564WUzDaBHXsD46JBbIK5WVTwCyu3w==", - "license": "MIT", - "dependencies": { - "ast-module-types": "^6.0.0", - "node-source-walk": "^7.0.0" - }, - "bin": { - "module-definition": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/module-lookup-amd": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/module-lookup-amd/-/module-lookup-amd-9.0.2.tgz", - "integrity": "sha512-p7PzSVEWiW9fHRX9oM+V4aV5B2nCVddVNv4DZ/JB6t9GsXY4E+ZVhPpnwUX7bbJyGeeVZqhS8q/JZ/H77IqPFA==", - "license": "MIT", - "dependencies": { - "commander": "^12.1.0", - "glob": "^7.2.3", - "requirejs": "^2.3.7", - "requirejs-config-file": "^4.0.0" - }, - "bin": { - "lookup-amd": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -8725,6 +8243,7 @@ "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "dev": true, "funding": [ { "type": "github", @@ -8890,18 +8409,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-source-walk": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/node-source-walk/-/node-source-walk-7.0.0.tgz", - "integrity": "sha512-1uiY543L+N7Og4yswvlm5NCKgPKDEXd9AUR9Jh3gen6oOeBsesr6LqhXom1er3eRzSUcVRWXzhv8tSNrIfGHKw==", - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.24.4" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/nodemon": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", @@ -9063,6 +8570,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -9481,6 +8989,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -9500,6 +9009,7 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, "license": "MIT" }, "node_modules/path-scurry": { @@ -9536,6 +9046,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -9562,6 +9073,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, "license": "ISC" }, "node_modules/picomatch": { @@ -9767,6 +9279,7 @@ "version": "8.4.47", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", + "dev": true, "funding": [ { "type": "opencollective", @@ -9925,23 +9438,6 @@ "dev": true, "license": "MIT" }, - "node_modules/postcss-values-parser": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/postcss-values-parser/-/postcss-values-parser-6.0.2.tgz", - "integrity": "sha512-YLJpK0N1brcNJrs9WatuJFtHaV9q5aAOj+S4DI5S7jgHlRfm0PIbDCAFRYMQD5SHq7Fy6xsDhyutgS0QOAs0qw==", - "license": "MPL-2.0", - "dependencies": { - "color-name": "^1.1.4", - "is-url-superb": "^4.0.0", - "quote-unquote": "^1.0.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "postcss": "^8.2.9" - } - }, "node_modules/prebuild-install": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.1.tgz", @@ -9968,35 +9464,6 @@ "node": ">=10" } }, - "node_modules/precinct": { - "version": "12.1.2", - "resolved": "https://registry.npmjs.org/precinct/-/precinct-12.1.2.tgz", - "integrity": "sha512-x2qVN3oSOp3D05ihCd8XdkIPuEQsyte7PSxzLqiRgktu79S5Dr1I75/S+zAup8/0cwjoiJTQztE9h0/sWp9bJQ==", - "license": "MIT", - "dependencies": { - "@dependents/detective-less": "^5.0.0", - "commander": "^12.1.0", - "detective-amd": "^6.0.0", - "detective-cjs": "^6.0.0", - "detective-es6": "^5.0.0", - "detective-postcss": "^7.0.0", - "detective-sass": "^6.0.0", - "detective-scss": "^5.0.0", - "detective-stylus": "^5.0.0", - "detective-typescript": "^13.0.0", - "detective-vue2": "^2.0.3", - "module-definition": "^6.0.0", - "node-source-walk": "^7.0.0", - "postcss": "^8.4.40", - "typescript": "^5.5.4" - }, - "bin": { - "precinct": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -10227,6 +9694,7 @@ "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, "funding": [ { "type": "github", @@ -10243,12 +9711,6 @@ ], "license": "MIT" }, - "node_modules/quote-unquote": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/quote-unquote/-/quote-unquote-1.0.0.tgz", - "integrity": "sha512-twwRO/ilhlG/FIgYeKGFqyHhoEhqgnKVkcmqMKi2r524gz3ZbDTcyFt38E9xjJI2vT+KbRNHVbnJ/e0I25Azwg==", - "license": "MIT" - }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -10682,32 +10144,6 @@ "node": ">=0.10.0" } }, - "node_modules/requirejs": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.7.tgz", - "integrity": "sha512-DouTG8T1WanGok6Qjg2SXuCMzszOo0eHeH9hDZ5Y4x8Je+9JB38HdTLT4/VA8OaUhBa0JPVHJ0pyBkM1z+pDsw==", - "license": "MIT", - "bin": { - "r_js": "bin/r.js", - "r.js": "bin/r.js" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/requirejs-config-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/requirejs-config-file/-/requirejs-config-file-4.0.0.tgz", - "integrity": "sha512-jnIre8cbWOyvr8a5F2KuqBnY+SDA4NXr/hzEZJG79Mxm2WiFQz2dzhC8ibtPJS7zkmBEl1mxSwp5HhC1W4qpxw==", - "license": "MIT", - "dependencies": { - "esprima": "^4.0.0", - "stringify-object": "^3.2.1" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -10718,6 +10154,7 @@ "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, "license": "MIT", "dependencies": { "is-core-module": "^2.13.0", @@ -10731,15 +10168,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/resolve-dependency-path": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-dependency-path/-/resolve-dependency-path-4.0.0.tgz", - "integrity": "sha512-hlY1SybBGm5aYN3PC4rp15MzsJLM1w+MEA/4KU3UBPfz4S0lL3FL6mgv7JgaA8a+ZTeEQAiF1a1BuN2nkqiIlg==", - "license": "MIT", - "engines": { - "node": ">=18" - } - }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -10797,6 +10225,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, "license": "MIT", "engines": { "iojs": ">=1.0.0", @@ -10866,6 +10295,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, "funding": [ { "type": "github", @@ -10921,21 +10351,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "license": "MIT" }, - "node_modules/sass-lookup": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/sass-lookup/-/sass-lookup-6.0.1.tgz", - "integrity": "sha512-nl9Wxbj9RjEJA5SSV0hSDoU2zYGtE+ANaDS4OFUR7nYrquvBFvPKZZtQHe3lvnxCcylEDV00KUijjdMTUElcVQ==", - "license": "MIT", - "dependencies": { - "commander": "^12.0.0" - }, - "bin": { - "sass-lookup": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/scheduler": { "version": "0.23.2", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", @@ -11201,6 +10616,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -11264,6 +10680,7 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, "license": "BSD-3-Clause", "optional": true, "engines": { @@ -11274,6 +10691,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" @@ -11383,20 +10801,6 @@ "node": ">=8" } }, - "node_modules/stringify-object": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", - "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", - "license": "BSD-2-Clause", - "dependencies": { - "get-own-enumerable-property-symbols": "^3.0.0", - "is-obj": "^1.0.1", - "is-regexp": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -11423,15 +10827,6 @@ "node": ">=8" } }, - "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/strip-final-newline": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", @@ -11464,21 +10859,6 @@ "integrity": "sha512-H2N9c26eXjzL/S/K+i/RHHcFanE74dptvvjM8iwzwbVcWY/zjBbgRqF3K0DY4+OD+uTTASTBvDoxPDaPN02D7g==", "dev": true }, - "node_modules/stylus-lookup": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/stylus-lookup/-/stylus-lookup-6.0.0.tgz", - "integrity": "sha512-RaWKxAvPnIXrdby+UWCr1WRfa+lrPMSJPySte4Q6a+rWyjeJyFOLJxr5GrAVfcMCsfVlCuzTAJ/ysYT8p8do7Q==", - "license": "MIT", - "dependencies": { - "commander": "^12.0.0" - }, - "bin": { - "stylus-lookup": "bin/cli.js" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/sucrase": { "version": "3.35.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", @@ -11563,6 +10943,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -11626,15 +11007,6 @@ "node": ">=14.0.0" } }, - "node_modules/tapable": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", - "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/tar-fs": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", @@ -11768,6 +11140,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -11863,6 +11236,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=16" @@ -11929,20 +11303,6 @@ "dev": true, "license": "MIT" }, - "node_modules/tsconfig-paths": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", - "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", - "license": "MIT", - "dependencies": { - "json5": "^2.2.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/tslib": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", @@ -12004,6 +11364,7 @@ "version": "5.6.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -12767,6 +12128,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, "license": "ISC" }, "node_modules/xdg-basedir": { @@ -12935,10 +12297,9 @@ }, "packages/cli": { "name": "@nanoapi.io/napi", - "version": "0.0.10", + "version": "0.0.17", "dependencies": { "axios": "^1.7.7", - "dependency-tree": "^11.0.1", "express": "^4.21.1", "http-proxy-middleware": "^3.0.3", "openai": "^4.67.2", diff --git a/packages/cli/package.json b/packages/cli/package.json index 0883e51..def44ca 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -75,7 +75,6 @@ }, "dependencies": { "axios": "^1.7.7", - "dependency-tree": "^11.0.1", "express": "^4.21.1", "http-proxy-middleware": "^3.0.3", "openai": "^4.67.2", diff --git a/packages/cli/src/api/scan.ts b/packages/cli/src/api/scan.ts index 7410af3..39e51bb 100644 --- a/packages/cli/src/api/scan.ts +++ b/packages/cli/src/api/scan.ts @@ -1,12 +1,11 @@ import { z } from "zod"; -import { getDependencyTree } from "../helper/dependencies"; -import { ScanCodebaseResponsePayload } from "../helper/payloads"; -import { getEndpontsFromTree } from "../helper/tree"; +import { + getDependencyTree, + getEndpontsFromTree, +} from "../helper/dependencyTree"; import { scanSchema } from "./helpers/validation"; -export function scan( - payload: z.infer, -): ScanCodebaseResponsePayload { +export function scan(payload: z.infer) { const tree = getDependencyTree(payload.entrypointPath); const endpoints = getEndpontsFromTree(tree); diff --git a/packages/cli/src/api/split.ts b/packages/cli/src/api/split.ts index bcd51b9..82984ba 100644 --- a/packages/cli/src/api/split.ts +++ b/packages/cli/src/api/split.ts @@ -1,17 +1,17 @@ import fs from "fs"; import path from "path"; -import { getDependencyTree } from "../helper/dependencies"; +import { + getDependencyTree, + getEndpontsFromTree, + getGroupsFromEndpoints, +} from "../helper/dependencyTree"; import { cleanupOutputDir, createOutputDir } from "../helper/file"; -import { SplitCodebaseResponsePayload } from "../helper/payloads"; -import { getEndpontsFromTree, splitPath } from "../helper/tree"; +import { createSplit } from "../helper/split"; import { splitSchema } from "./helpers/validation"; import { z } from "zod"; import { GroupMap } from "../helper/types"; -import { getGroupsFromEndpoints } from "../helper/groups"; -export function split( - payload: z.infer, -): SplitCodebaseResponsePayload { +export function split(payload: z.infer) { let groupIndex = 0; const groupMap: GroupMap = {}; @@ -32,7 +32,7 @@ export function split( // Process each endpoint for splitting for (const group of groups) { - splitPath( + createSplit( group, payload.outputDir, payload.entrypointPath, diff --git a/packages/cli/src/api/sync.ts b/packages/cli/src/api/sync.ts index 5bcacb0..9c0d721 100644 --- a/packages/cli/src/api/sync.ts +++ b/packages/cli/src/api/sync.ts @@ -1,15 +1,17 @@ import { z } from "zod"; import { syncSchema } from "./helpers/validation"; import fs from "fs"; -import { Dependencies } from "../helper/types"; import { getNanoApiAnnotationFromCommentValue, - getParserLanguageFromFile, replaceCommentFromAnnotation, -} from "../helper/file"; -import { getDependencyTree } from "../helper/dependencies"; +} from "../helper/annotations"; +import { + getDependencyTree, + getEndpontsFromTree, +} from "../helper/dependencyTree"; import Parser from "tree-sitter"; -import { getEndpontsFromTree } from "../helper/tree"; +import { getParserLanguageFromFile } from "../helper/treeSitter"; +import { replaceIndexesFromSourceCode } from "../helper/cleanup"; export function sync(payload: z.infer) { const tree = getDependencyTree(payload.entrypointPath); @@ -31,53 +33,53 @@ export function sync(payload: z.infer) { return endpoint; }); - function iterateOverTreeAndUpdateContent(tree: Dependencies) { - for (const [filePath, value] of Object.entries(tree)) { - let sourceCode = fs.readFileSync(filePath, "utf-8"); - - updatedEndpoints.forEach((endpoint) => { - const language = getParserLanguageFromFile(filePath); - const parser = new Parser(); - parser.setLanguage(language); - - const tree = parser.parse(sourceCode); - - function traverse(node: Parser.SyntaxNode) { - if (node.type === "comment") { - const comment = node.text; - - const annotation = getNanoApiAnnotationFromCommentValue(comment); - - if (annotation) { - if ( - annotation.path === endpoint.path && - annotation.method === endpoint.method - ) { - annotation.group = endpoint.group; - const updatedComment = replaceCommentFromAnnotation( - comment, - annotation, - ); - // Replace the comment in the source code - sourceCode = sourceCode.replace(comment, updatedComment); - } - } - } - node.children.forEach((child) => traverse(child)); - } + updatedEndpoints.forEach((endpoint) => { + const language = getParserLanguageFromFile(endpoint.filePath); + const parser = new Parser(); + parser.setLanguage(language); + + let sourceCode = fs.readFileSync(endpoint.filePath, "utf-8"); + + const tree = parser.parse(sourceCode); + + const indexesToReplace: { + startIndex: number; + endIndex: number; + text: string; + }[] = []; - traverse(tree.rootNode); - }); + function traverse(node: Parser.SyntaxNode) { + if (node.type === "comment") { + const comment = node.text; - // update the file - fs.writeFileSync(filePath, sourceCode, "utf-8"); + const annotation = getNanoApiAnnotationFromCommentValue(comment); - // Recursively process the tree - if (typeof value !== "string") { - iterateOverTreeAndUpdateContent(value); + if (annotation) { + if ( + annotation.path === endpoint.path && + annotation.method === endpoint.method + ) { + annotation.group = endpoint.group; + const updatedComment = replaceCommentFromAnnotation( + comment, + annotation, + ); + + indexesToReplace.push({ + startIndex: node.startIndex, + endIndex: node.endIndex, + text: updatedComment, + }); + } + } } + node.children.forEach((child) => traverse(child)); } - } - iterateOverTreeAndUpdateContent(tree); + traverse(tree.rootNode); + + sourceCode = replaceIndexesFromSourceCode(sourceCode, indexesToReplace); + + fs.writeFileSync(endpoint.filePath, sourceCode, "utf-8"); + }); } diff --git a/packages/cli/src/commands/annotate.ts b/packages/cli/src/commands/annotate.ts index edc5bfd..02fd68f 100644 --- a/packages/cli/src/commands/annotate.ts +++ b/packages/cli/src/commands/annotate.ts @@ -1,7 +1,7 @@ import fs from "fs"; -import { getDependencyTree } from "../helper/dependencies"; +import { getDependencyTree } from "../helper/dependencyTree"; import OpenAI from "openai"; -import { Dependencies } from "../helper/types"; +import { DependencyTree } from "../helper/types"; export default async function annotateOpenAICommandHandler( entrypoint: string, // Path to the entrypoint file @@ -33,20 +33,22 @@ export default async function annotateOpenAICommandHandler( I want you to understand what the application is doing and where each endpoint is.`, }); - function iterateOverTree(tree: Dependencies) { - for (const [filePath, value] of Object.entries(tree)) { - // TODO send chunks of each file for big files to respect the openAI limits - const content = fs.readFileSync(filePath, "utf8"); + function iterateOverTree(tree: DependencyTree) { + messages.push({ + role: "user", + content: `File: ${tree.path} + Content: ${tree.sourceCode}`, + }); + + tree.children.forEach((child) => { messages.push({ role: "user", - content: `File: ${filePath} - Content: ${content}`, + content: `File: ${child.path} + Content: ${child.sourceCode}`, }); - if (typeof value !== "string") { - iterateOverTree(value); - } - } + iterateOverTree(child); + }); } iterateOverTree(tree); diff --git a/packages/cli/src/commands/split.ts b/packages/cli/src/commands/split.ts index 6cf4ced..8d1861f 100644 --- a/packages/cli/src/commands/split.ts +++ b/packages/cli/src/commands/split.ts @@ -1,10 +1,13 @@ import path from "path"; import fs from "fs"; -import { getDependencyTree } from "../helper/dependencies"; +import { + getDependencyTree, + getEndpontsFromTree, + getGroupsFromEndpoints, +} from "../helper/dependencyTree"; import { cleanupOutputDir, createOutputDir } from "../helper/file"; -import { getEndpontsFromTree, splitPath } from "../helper/tree"; +import { createSplit } from "../helper/split"; import { GroupMap } from "../helper/types"; -import { getGroupsFromEndpoints } from "../helper/groups"; export default function splitCommandHandler( entrypointPath: string, // Path to the entrypoint file @@ -26,7 +29,7 @@ export default function splitCommandHandler( // Process each endpoint for splitting for (const group of groups) { - splitPath(group, outputDir, entrypointPath, groupMap, groupIndex); + createSplit(group, outputDir, entrypointPath, groupMap, groupIndex); groupIndex++; } diff --git a/packages/cli/src/helper/annotations.ts b/packages/cli/src/helper/annotations.ts new file mode 100644 index 0000000..1bf1a64 --- /dev/null +++ b/packages/cli/src/helper/annotations.ts @@ -0,0 +1,44 @@ +import { NanoAPIAnnotation } from "./types"; + +export function getNanoApiAnnotationFromCommentValue(comment: string) { + const nanoapiRegex = /@nanoapi|((method|path|group):([^ ]+))/g; + const matches = comment.match(nanoapiRegex); + // remove first match, which is the @nanoapi identifier + matches?.shift(); + + if (matches && matches.length > 0) { + return matches.reduce((acc, match) => { + // key, first element when split with ":" + const key = match.split(":")[0]; + // value, everything else + const value = match.split(":").slice(1).join(":"); + return { ...acc, [key]: value }; + }, {} as NanoAPIAnnotation); + } + + return null; +} + +export function replaceCommentFromAnnotation( + comment: string, + annotation: NanoAPIAnnotation, +) { + const commentRegex = /@nanoapi\s*(.*)/g; + + // Construct the new annotation string + let newAnnotation = "@nanoapi"; + if (annotation.method) { + newAnnotation += ` method:${annotation.method}`; + } + if (annotation.path) { + newAnnotation += ` path:${annotation.path}`; + } + if (annotation.group) { + newAnnotation += ` group:${annotation.group}`; + } + + // Replace the old annotation with the new annotation + const updatedComment = comment.replace(commentRegex, newAnnotation); + + return updatedComment; +} diff --git a/packages/cli/src/helper/cleanup.ts b/packages/cli/src/helper/cleanup.ts new file mode 100644 index 0000000..32e974f --- /dev/null +++ b/packages/cli/src/helper/cleanup.ts @@ -0,0 +1,75 @@ +import fs from "fs"; +import Parser from "tree-sitter"; +import { cleanupJavascriptFile } from "./languages/javascript/cleanup"; +import { extractJavascriptFileImports } from "./languages/javascript/imports"; + +import { resolveFilePath } from "./file"; +import { Group } from "./types"; +import { getParserLanguageFromFile } from "./treeSitter"; + +export function cleanupFile(filePath: string, group: Group) { + const language = getParserLanguageFromFile(filePath); + const parser = new Parser(); + parser.setLanguage(language); + + const sourceCode = fs.readFileSync(filePath, "utf8"); + + let dependencies: string[] = []; + if (["javascript", "typescript"].includes(language.name)) { + dependencies = extractJavascriptFileImports(parser, sourceCode); + } else { + throw new Error(`Unsupported language: ${language.language}`); + } + + // Check if we can resolve the path for each dependency. If we cannot, we need to remove it + const invalidDependencies = dependencies.filter( + (dep) => !resolveFilePath(dep, filePath), + ); + + let updatedSourceCode: string; + + if (["javascript", "typescript"].includes(language.name)) { + updatedSourceCode = cleanupJavascriptFile( + parser, + sourceCode, + group, + invalidDependencies, + ); + } else { + throw new Error(`Unsupported language: ${language.language}`); + } + + fs.writeFileSync(filePath, updatedSourceCode, "utf8"); +} + +export function removeIndexesFromSourceCode( + sourceCode: string, + indexesToRemove: { startIndex: number; endIndex: number }[], +) { + let newSourceCode = sourceCode; + + // sort to start removing from the of the file end + indexesToRemove.sort((a, b) => b.startIndex - a.startIndex); + + indexesToRemove.forEach(({ startIndex, endIndex }) => { + newSourceCode = + newSourceCode.slice(0, startIndex) + newSourceCode.slice(endIndex); + }); + + return newSourceCode; +} + +export function replaceIndexesFromSourceCode( + sourceCode: string, + indexesToReplace: { startIndex: number; endIndex: number; text: string }[], +) { + // sort to start removing from the end of the file + indexesToReplace.sort((a, b) => b.startIndex - a.startIndex); + + indexesToReplace.forEach(({ startIndex, endIndex, text }) => { + sourceCode = + sourceCode.slice(0, startIndex) + text + sourceCode.slice(endIndex); + }); + + return sourceCode; +} diff --git a/packages/cli/src/helper/dependencies.ts b/packages/cli/src/helper/dependencies.ts deleted file mode 100644 index b6aa841..0000000 --- a/packages/cli/src/helper/dependencies.ts +++ /dev/null @@ -1,86 +0,0 @@ -import fs from "fs"; -import Parser from "tree-sitter"; -import { cleanupJavascriptFile } from "./languages/javascript/cleanup"; -import { extractJavascriptFileImports } from "./languages/javascript/imports"; - -import { getParserLanguageFromFile, resolveFilePath } from "./file"; -import { Dependencies, Group } from "./types"; - -// extract the dependencies from the AST -export function getDependencyTree(filePath: string): Dependencies { - const dependencies: Dependencies = {}; - - function buildTree( - currentFilePath: string, - visited = new Set(), - ): Dependencies { - if (visited.has(currentFilePath)) { - return {}; - } - visited.add(currentFilePath); - - const language = getParserLanguageFromFile(currentFilePath); - const parser = new Parser(); - parser.setLanguage(language); - - const sourceCode = fs.readFileSync(currentFilePath, "utf8"); - - let imports: string[] = []; - if (["javascript", "typescript"].includes(language.name)) { - imports = extractJavascriptFileImports(parser, sourceCode); - } else { - throw new Error(`Unsupported language: ${language.name}`); - } - - const currentDependencies: Dependencies = {}; - - imports.forEach((importPath) => { - const resolvedPath = resolveFilePath(importPath, currentFilePath); - if (resolvedPath && fs.existsSync(resolvedPath)) { - currentDependencies[resolvedPath] = buildTree(resolvedPath, visited); - } - }); - - return currentDependencies; - } - - // Initialize the dependency tree with the top parent file - dependencies[filePath] = buildTree(filePath); - - return dependencies; -} - -export function cleanupFile(filePath: string, group: Group) { - const language = getParserLanguageFromFile(filePath); - const parser = new Parser(); - parser.setLanguage(language); - - const sourceCode = fs.readFileSync(filePath, "utf8"); - - let dependencies: string[] = []; - if (["javascript", "typescript"].includes(language.name)) { - dependencies = extractJavascriptFileImports(parser, sourceCode); - } else { - throw new Error(`Unsupported language: ${language.language}`); - } - - // Check if we can resolve the path for each dependency. If we cannot, we need to remove it - const invalidDependencies = dependencies.filter( - (dep) => !resolveFilePath(dep, filePath), - ); - - let updatedSourceCode: string; - - if (["javascript", "typescript"].includes(language.name)) { - updatedSourceCode = cleanupJavascriptFile( - parser, - sourceCode, - group, - invalidDependencies, - ); - } else { - throw new Error(`Unsupported language: ${language.language}`); - } - - fs.writeFileSync(filePath, updatedSourceCode, "utf8"); -} diff --git a/packages/cli/src/helper/dependencyTree.ts b/packages/cli/src/helper/dependencyTree.ts new file mode 100644 index 0000000..956bf2d --- /dev/null +++ b/packages/cli/src/helper/dependencyTree.ts @@ -0,0 +1,138 @@ +import fs from "fs"; +import Parser from "tree-sitter"; +import { extractJavascriptFileImports } from "./languages/javascript/imports"; + +import { resolveFilePath } from "./file"; +import { DependencyTree, Group } from "./types"; +import { Endpoint } from "./types"; +import { getParserLanguageFromFile } from "./treeSitter"; +import { getNanoApiAnnotationFromCommentValue } from "./annotations"; + +export function getDependencyTree(filePath: string): DependencyTree { + const sourceCode = fs.readFileSync(filePath, "utf8"); + + const dependencyTree: DependencyTree = { + path: filePath, + sourceCode, + children: [], + }; + + const language = getParserLanguageFromFile(filePath); + + const parser = new Parser(); + parser.setLanguage(language); + + if (["javascript", "typescript"].includes(language.name)) { + const imports = extractJavascriptFileImports(parser, sourceCode); + + imports.forEach((importPath) => { + const resolvedPath = resolveFilePath(importPath, filePath); + if (resolvedPath && fs.existsSync(resolvedPath)) { + dependencyTree.children.push(getDependencyTree(resolvedPath)); + } + }); + } else { + throw new Error(`Unsupported language: ${language.name}`); + } + + return dependencyTree; +} + +export function getEndpontsFromTree( + tree: DependencyTree, + parentFiles: string[] = [], + endpoints: Endpoint[] = [], +) { + function getEndpointsFromFile( + parentFilePaths: string[], + dependencyTree: DependencyTree, + ) { + const language = getParserLanguageFromFile(dependencyTree.path); + const parser = new Parser(); + parser.setLanguage(language); + + const parsedTree = parser.parse(dependencyTree.sourceCode); + + const endpoints: Endpoint[] = []; + + function getFilePathsFromTree(tree: DependencyTree) { + const filePaths: string[] = []; + + tree.children.forEach((child) => { + filePaths.push(child.path); + filePaths.push(...getFilePathsFromTree(child)); + }); + + // remove duplicates + const uniqueFilePaths = [...new Set(filePaths)]; + + return uniqueFilePaths; + } + + function traverse(node: Parser.SyntaxNode) { + if (node.type === "comment") { + const comment = node.text; + + const annotation = getNanoApiAnnotationFromCommentValue(comment); + + if (annotation) { + const endpoint: Endpoint = { + path: annotation.path, + method: annotation.method, + group: annotation.group, + filePath: dependencyTree.path, + parentFilePaths, + childrenFilePaths: getFilePathsFromTree(dependencyTree), + }; + endpoints.push(endpoint); + } + } + node.children.forEach((child) => traverse(child)); + } + + traverse(parsedTree.rootNode); + + return endpoints; + } + + // Use a Set to track unique endpoints + const uniqueEndpoints = new Set(); + + // Get endpoints from the current file + const newEndpoints = getEndpointsFromFile(parentFiles, tree); + newEndpoints.forEach((endpoint) => { + const endpointKey = `${endpoint.method}-${endpoint.path}-${endpoint.group}-${endpoint.filePath}`; + if (!uniqueEndpoints.has(endpointKey)) { + uniqueEndpoints.add(endpointKey); + endpoints.push(endpoint); + } + }); + + // Update parentFiles array for the current level + const updatedParentFiles = [...parentFiles, tree.path]; + + // Recursively process the children + tree.children.forEach((child) => { + getEndpontsFromTree(child, updatedParentFiles, endpoints); + }); + + return endpoints; +} + +export function getGroupsFromEndpoints(endpoints: Endpoint[]) { + const groups: Group[] = []; + + for (const endpoint of endpoints) { + const group = groups.find((group) => group.name === endpoint.group); + if (group) { + group.endpoints.push(endpoint); + } else { + groups.push({ + name: endpoint.group || "", + endpoints: [endpoint], + }); + } + } + + return groups; +} diff --git a/packages/cli/src/helper/file.ts b/packages/cli/src/helper/file.ts index fa7d575..b3c4de4 100644 --- a/packages/cli/src/helper/file.ts +++ b/packages/cli/src/helper/file.ts @@ -1,10 +1,5 @@ -import dependencyTree from "dependency-tree"; -import { Endpoint, NanoAPIAnnotation } from "./types"; import fs from "fs"; import path from "path"; -import Javascript from "tree-sitter-javascript"; -import Typescript from "tree-sitter-typescript"; -import Parser from "tree-sitter"; export function cleanupOutputDir(outputDir: string) { if (fs.existsSync(outputDir)) { @@ -16,123 +11,7 @@ export function createOutputDir(outputDir: string) { fs.mkdirSync(outputDir, { recursive: true }); } -export function getParserLanguageFromFile(filePath: string) { - const ext = filePath.split(".").pop(); - - switch (ext) { - case "js": - return Javascript; - case "ts": - return Typescript.typescript; - case "tsx": // TODO this is untested - return Typescript.tsx; - default: - throw new Error(`Unsupported file type: ${ext}`); - } -} - -export function getEndpointsFromFile( - parentFilePaths: string[], - filePath: string, - dependencyTree: dependencyTree.TreeInnerNode, -) { - const language = getParserLanguageFromFile(filePath); - const parser = new Parser(); - parser.setLanguage(language); - - const sourceCode = fs.readFileSync(filePath, "utf8"); - const tree = parser.parse(sourceCode); - - const endpoints: Endpoint[] = []; - - function traverse(node: Parser.SyntaxNode) { - if (node.type === "comment") { - const comment = node.text; - - const annotation = getNanoApiAnnotationFromCommentValue(comment); - - if (annotation) { - const endpoint: Endpoint = { - path: annotation.path, - method: annotation.method, - group: annotation.group, - filePath, - parentFilePaths, - childrenFilePaths: getFilePathsFromTree(dependencyTree[filePath]), - }; - endpoints.push(endpoint); - } - } - node.children.forEach((child) => traverse(child)); - } - - traverse(tree.rootNode); - - return endpoints; -} - -export function getNanoApiAnnotationFromCommentValue(comment: string) { - const nanoapiRegex = /@nanoapi|((method|path|group):([^ ]+))/g; - const matches = comment.match(nanoapiRegex); - // remove first match, which is the @nanoapi identifier - matches?.shift(); - - if (matches && matches.length > 0) { - return matches.reduce((acc, match) => { - // key, first element when split with ":" - const key = match.split(":")[0]; - // value, everything else - const value = match.split(":").slice(1).join(":"); - return { ...acc, [key]: value }; - }, {} as NanoAPIAnnotation); - } - - return null; -} - -export function replaceCommentFromAnnotation( - comment: string, - annotation: NanoAPIAnnotation, -) { - const commentRegex = /@nanoapi\s*(.*)/g; - - // Construct the new annotation string - let newAnnotation = "@nanoapi"; - if (annotation.method) { - newAnnotation += ` method:${annotation.method}`; - } - if (annotation.path) { - newAnnotation += ` path:${annotation.path}`; - } - if (annotation.group) { - newAnnotation += ` group:${annotation.group}`; - } - - // Replace the old annotation with the new annotation - const updatedComment = comment.replace(commentRegex, newAnnotation); - - return updatedComment; -} - -function getFilePathsFromTree(tree: dependencyTree.Tree) { - const filePaths: string[] = []; - for (const [key, value] of Object.entries(tree)) { - filePaths.push(key); - if (typeof value !== "string") { - filePaths.push(...getFilePathsFromTree(value)); - } - } - - // remove duplicates - const uniqueFilePaths = [...new Set(filePaths)]; - - return uniqueFilePaths; -} - -export function resolveFilePath( - importPath: string, - currentFile: string, -): string | null { +export function resolveFilePath(importPath: string, currentFile: string) { const currentFileExt = path.extname(currentFile); const importExt = path.extname(importPath); if (importPath.startsWith(".")) { @@ -168,20 +47,3 @@ export function resolveFilePath( // Skip external dependencies (e.g., node_modules) return null; } - -export function removeIndexesFromSourceCode( - sourceCode: string, - indexesToRemove: { startIndex: number; endIndex: number }[], -) { - let newSourceCode = sourceCode; - - // sort to start removing from the of the file end - indexesToRemove.sort((a, b) => b.startIndex - a.startIndex); - - indexesToRemove.forEach(({ startIndex, endIndex }) => { - newSourceCode = - newSourceCode.slice(0, startIndex) + newSourceCode.slice(endIndex); - }); - - return newSourceCode; -} diff --git a/packages/cli/src/helper/groups.ts b/packages/cli/src/helper/groups.ts deleted file mode 100644 index f5d36c7..0000000 --- a/packages/cli/src/helper/groups.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Endpoint, Group } from "./types"; - -export function getGroupsFromEndpoints(endpoints: Endpoint[]) { - const groups: Group[] = []; - - for (const endpoint of endpoints) { - const group = groups.find((group) => group.name === endpoint.group); - if (group) { - group.endpoints.push(endpoint); - } else { - groups.push({ - name: endpoint.group || "", - endpoints: [endpoint], - }); - } - } - - return groups; -} diff --git a/packages/cli/src/helper/languages/javascript/cleanup.ts b/packages/cli/src/helper/languages/javascript/cleanup.ts index 0ad1ad7..9e2f9c6 100644 --- a/packages/cli/src/helper/languages/javascript/cleanup.ts +++ b/packages/cli/src/helper/languages/javascript/cleanup.ts @@ -1,9 +1,6 @@ import Parser from "tree-sitter"; import { Group } from "../../types"; -import { - getNanoApiAnnotationFromCommentValue, - removeIndexesFromSourceCode, -} from "../../file"; +import { getNanoApiAnnotationFromCommentValue } from "../../annotations"; import { getImportStatements, extractFileImportsFromImportStatements, @@ -15,6 +12,7 @@ import { extractFileImportsFromDynamicImportDeclarations, extractIdentifiersFromDynamicImportDeclaration, } from "./imports"; +import { removeIndexesFromSourceCode } from "../../cleanup"; function removeAnnotations( parser: Parser, diff --git a/packages/cli/src/helper/payloads.ts b/packages/cli/src/helper/payloads.ts deleted file mode 100644 index 6656ee6..0000000 --- a/packages/cli/src/helper/payloads.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Endpoint, Group } from "./types"; - -export interface ScanCodebaseRequestPayload { - entrypointPath: string; - targetDir?: string; -} - -export interface ScanCodebaseResponsePayload { - endpoints: Endpoint[]; -} - -export interface GroupEndpointsRequestPayload { - entrypointPath: string; - targetDir?: string; - groups: { name: string; endpoints: { method: string; path: string }[] }[]; -} - -export interface GroupEndpointsResponsePayload { - success: boolean; -} - -export interface SplitCodebaseRequestPayload { - entrypointPath: string; - targetDir?: string; - outputDir?: string; -} - -export interface SplitCodebaseResponsePayload { - groups: Group[]; - success: boolean; -} diff --git a/packages/cli/src/helper/tree.ts b/packages/cli/src/helper/split.ts similarity index 60% rename from packages/cli/src/helper/tree.ts rename to packages/cli/src/helper/split.ts index 21f5485..f0c6bf1 100644 --- a/packages/cli/src/helper/tree.ts +++ b/packages/cli/src/helper/split.ts @@ -1,41 +1,10 @@ import fs from "fs"; import path from "path"; -import { cleanupFile } from "./dependencies"; -import { getEndpointsFromFile } from "./file"; -import { Dependencies, Endpoint, Group, GroupMap } from "./types"; - -// Helper function to process the tree and gather endpoints -export function getEndpontsFromTree( - tree: Dependencies, - parentFiles: string[] = [], - endpoints: Endpoint[] = [], -) { - for (const [filePath, value] of Object.entries(tree)) { - const endpointsFromFile = getEndpointsFromFile(parentFiles, filePath, tree); - for (const endpointFromFile of endpointsFromFile) { - const endpoint = { - method: endpointFromFile.method, - path: endpointFromFile.path, - group: endpointFromFile.group, - filePath: endpointFromFile.filePath, - parentFilePaths: endpointFromFile.parentFilePaths, - childrenFilePaths: endpointFromFile.childrenFilePaths, - } as Endpoint; - endpoints.push(endpoint); - } - - // Recursively process the tree - if (typeof value !== "string") { - const updatedParentFiles = [...parentFiles, filePath]; - getEndpontsFromTree(value, updatedParentFiles, endpoints); - } - } - - return endpoints; -} +import { Group, GroupMap } from "./types"; +import { cleanupFile } from "./cleanup"; // Function to handle splitting and storing paths based on the split command logic -export function splitPath( +export function createSplit( group: Group, outputDirectory: string, entrypointPath: string, diff --git a/packages/cli/src/helper/treeSitter.ts b/packages/cli/src/helper/treeSitter.ts new file mode 100644 index 0000000..63722bb --- /dev/null +++ b/packages/cli/src/helper/treeSitter.ts @@ -0,0 +1,17 @@ +import Javascript from "tree-sitter-javascript"; +import Typescript from "tree-sitter-typescript"; + +export function getParserLanguageFromFile(filePath: string) { + const ext = filePath.split(".").pop(); + + switch (ext) { + case "js": + return Javascript; + case "ts": + return Typescript.typescript; + case "tsx": // TODO this is untested + return Typescript.tsx; + default: + throw new Error(`Unsupported file type: ${ext}`); + } +} diff --git a/packages/cli/src/helper/types.ts b/packages/cli/src/helper/types.ts index fc48c3e..a8f2f2a 100644 --- a/packages/cli/src/helper/types.ts +++ b/packages/cli/src/helper/types.ts @@ -20,6 +20,8 @@ export interface NanoAPIAnnotation { group?: string; } -export interface Dependencies { - [key: string]: Dependencies; +export interface DependencyTree { + path: string; + sourceCode: string; + children: DependencyTree[]; }