diff --git a/package.json b/package.json index cf8ad89..682394e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "intuita", - "version": "0.7.1", + "version": "0.7.2", "description": "A codemod engine for Node.js libraries (jscodeshift, ts-morph, etc.)", "type": "module", "exports": null, @@ -39,7 +39,7 @@ "axios": "^1.4.0", "cosmiconfig": "^8.3.6", "form-data": "^4.0.0", - "glob": "10.3.10", + "fast-glob": "3.3.2", "jscodeshift": "^0.14.0", "mdast-util-from-markdown": "^2.0.0", "mdast-util-mdx": "^3.0.0", @@ -82,7 +82,7 @@ }, "packageManager": "pnpm@8.6.7", "scripts": { - "build": "esbuild ./src/index.ts --define:__INTUITA_CLI_VERSION__=\\\"0.7.1\\\" --bundle --platform=node --target=node16 --minify --format=cjs --legal-comments=inline --outfile=./dist/index.cjs", + "build": "esbuild ./src/index.ts --define:__INTUITA_CLI_VERSION__=\\\"0.7.2\\\" --bundle --platform=node --target=node16 --minify --format=cjs --legal-comments=inline --outfile=./dist/index.cjs", "lint:eslint": "eslint src --fix --ext ts", "lint:prettier": "prettier --write .", "package": "pkg --compress GZip .", @@ -102,4 +102,4 @@ "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0ce698..e0e2e72 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,12 +41,12 @@ dependencies: cosmiconfig: specifier: ^8.3.6 version: 8.3.6(typescript@5.2.2) + fast-glob: + specifier: 3.3.2 + version: 3.3.2 form-data: specifier: ^4.0.0 version: 4.0.0 - glob: - specifier: 10.3.10 - version: 10.3.10 jscodeshift: specifier: ^0.14.0 version: 0.14.0(@babel/preset-env@7.20.2) @@ -2018,18 +2018,6 @@ packages: - fast-check dev: false - /@isaacs/cliui@8.0.2: - resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} - engines: {node: '>=12'} - dependencies: - string-width: 5.1.2 - string-width-cjs: /string-width@4.2.3 - strip-ansi: 7.1.0 - strip-ansi-cjs: /strip-ansi@6.0.1 - wrap-ansi: 8.1.0 - wrap-ansi-cjs: /wrap-ansi@7.0.0 - dev: false - /@istanbuljs/schema@0.1.3: resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} engines: {node: '>=8'} @@ -2163,13 +2151,6 @@ packages: engines: {node: '>=14'} dev: false - /@pkgjs/parseargs@0.11.0: - resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} - engines: {node: '>=14'} - requiresBuild: true - dev: false - optional: true - /@rollup/rollup-android-arm-eabi@4.9.0: resolution: {integrity: sha512-+1ge/xmaJpm1KVBuIH38Z94zj9fBD+hp+/5WLaHgyY8XLq1ibxk/zj6dTXaqM2cAbYKq8jYlhHd6k05If1W5xA==} cpu: [arm] @@ -2330,7 +2311,7 @@ packages: /@ts-morph/common@0.19.0: resolution: {integrity: sha512-Unz/WHmd4pGax91rdIKWi51wnVUW11QttMEPpBiBgIewnc9UQIX7UDLxr5vRlqeByXCwhkF6VabSsI0raWcyAQ==} dependencies: - fast-glob: 3.2.12 + fast-glob: 3.3.2 minimatch: 7.4.6 mkdirp: 2.1.6 path-browserify: 1.0.1 @@ -2719,11 +2700,6 @@ packages: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - /ansi-regex@6.0.1: - resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} - engines: {node: '>=12'} - dev: false - /ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} @@ -2742,11 +2718,6 @@ packages: engines: {node: '>=10'} dev: true - /ansi-styles@6.2.1: - resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} - engines: {node: '>=12'} - dev: false - /applicationinsights@2.9.1: resolution: {integrity: sha512-hrpe/OvHFZlq+SQERD1fxaYICyunxzEBh9SolJebzYnIXkyA9zxIR87dZAh+F3+weltbqdIP8W038cvtpMNhQg==} engines: {node: '>=8.0.0'} @@ -3112,6 +3083,7 @@ packages: path-key: 3.1.1 shebang-command: 2.0.0 which: 2.0.2 + dev: true /debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} @@ -3200,10 +3172,6 @@ packages: esutils: 2.0.3 dev: true - /eastasianwidth@0.2.0: - resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - dev: false - /effect@2.0.0-next.59: resolution: {integrity: sha512-EE87vFl0/zIN5lKDtFccU3YCnbPqjxg9rY72obNN65/GE4JOJsXciyX8XC4pIDr3lE6KeJ0le8IXf+A7d92ntQ==} dev: false @@ -3222,10 +3190,6 @@ packages: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: false - /emoji-regex@9.2.2: - resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} - dev: false - /entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} @@ -3502,8 +3466,8 @@ packages: /fast-diff@1.3.0: resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} - /fast-glob@3.2.12: - resolution: {integrity: sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==} + /fast-glob@3.3.2: + resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} engines: {node: '>=8.6.0'} dependencies: '@nodelib/fs.stat': 2.0.5 @@ -3589,14 +3553,6 @@ packages: optional: true dev: false - /foreground-child@3.1.1: - resolution: {integrity: sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==} - engines: {node: '>=14'} - dependencies: - cross-spawn: 7.0.3 - signal-exit: 4.1.0 - dev: false - /form-data@4.0.0: resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} engines: {node: '>= 6'} @@ -3660,18 +3616,6 @@ packages: is-glob: 4.0.3 dev: true - /glob@10.3.10: - resolution: {integrity: sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==} - engines: {node: '>=16 || 14 >=14.17'} - hasBin: true - dependencies: - foreground-child: 3.1.1 - jackspeak: 2.3.6 - minimatch: 9.0.3 - minipass: 6.0.2 - path-scurry: 1.10.1 - dev: false - /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} dependencies: @@ -3700,7 +3644,7 @@ packages: dependencies: array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.2.12 + fast-glob: 3.3.2 ignore: 5.2.4 merge2: 1.4.1 slash: 3.0.0 @@ -3912,6 +3856,7 @@ packages: /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + dev: true /isobject@3.0.1: resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==} @@ -3951,15 +3896,6 @@ packages: istanbul-lib-report: 3.0.1 dev: true - /jackspeak@2.3.6: - resolution: {integrity: sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==} - engines: {node: '>=14'} - dependencies: - '@isaacs/cliui': 8.0.2 - optionalDependencies: - '@pkgjs/parseargs': 0.11.0 - dev: false - /js-sdsl@4.4.1: resolution: {integrity: sha512-6Gsx8R0RucyePbWqPssR8DyfuXmLBooYN5cZFZKjHGnQuaf7pEzhtpceagJxVu4LqhYY5EYA7nko3FmeHZ1KbA==} dev: true @@ -4127,11 +4063,6 @@ packages: get-func-name: 2.0.2 dev: true - /lru-cache@10.0.0: - resolution: {integrity: sha512-svTf/fzsKHffP42sujkO/Rjs37BCIsQVRCeNYIm9WN8rgT7ffoUnRtZCqU+6BqcSBdv8gwJeTz8knJpgACeQMw==} - engines: {node: 14 || >=16.14} - dev: false - /lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} dependencies: @@ -4625,11 +4556,6 @@ packages: engines: {node: '>=8'} dev: false - /minipass@6.0.2: - resolution: {integrity: sha512-MzWSV5nYVT7mVyWCwn2o7JH13w2TBRmmSqSRCKzTw+lmft9X4z+3wjvs06Tzijo5z4W/kahUCDpRXTF+ZrmF/w==} - engines: {node: '>=16 || 14 >=14.17'} - dev: false - /minizlib@2.1.2: resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} engines: {node: '>= 8'} @@ -4826,6 +4752,7 @@ packages: /path-key@3.1.1: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} + dev: true /path-key@4.0.0: resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} @@ -4836,14 +4763,6 @@ packages: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: false - /path-scurry@1.10.1: - resolution: {integrity: sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==} - engines: {node: '>=16 || 14 >=14.17'} - dependencies: - lru-cache: 10.0.0 - minipass: 6.0.2 - dev: false - /path-to-regexp@1.8.0: resolution: {integrity: sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==} dependencies: @@ -5144,10 +5063,12 @@ packages: engines: {node: '>=8'} dependencies: shebang-regex: 3.0.0 + dev: true /shebang-regex@3.0.0: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} + dev: true /shimmer@1.2.1: resolution: {integrity: sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==} @@ -5164,6 +5085,7 @@ packages: /signal-exit@4.1.0: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + dev: true /sinon@17.0.0: resolution: {integrity: sha512-p4lJiYKBoOEVUxxVIC9H1MM2znG1/c8gud++I2BauJA5hsz7hHsst35eurNWXTusBsIq66FzOQbZ/uMdpvbPIQ==} @@ -5222,15 +5144,6 @@ packages: strip-ansi: 6.0.1 dev: false - /string-width@5.1.2: - resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} - engines: {node: '>=12'} - dependencies: - eastasianwidth: 0.2.0 - emoji-regex: 9.2.2 - strip-ansi: 7.1.0 - dev: false - /stringify-entities@4.0.3: resolution: {integrity: sha512-BP9nNHMhhfcMbiuQKCqMjhDP5yBCAxsPu4pHFFzJ6Alo9dZgY4VLDPutXqIjpRiMoKdp7Av85Gr73Q5uH9k7+g==} dependencies: @@ -5244,13 +5157,6 @@ packages: dependencies: ansi-regex: 5.0.1 - /strip-ansi@7.1.0: - resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==} - engines: {node: '>=12'} - dependencies: - ansi-regex: 6.0.1 - dev: false - /strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} @@ -5733,6 +5639,7 @@ packages: hasBin: true dependencies: isexe: 2.0.0 + dev: true /why-is-node-running@2.2.2: resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==} @@ -5752,15 +5659,6 @@ packages: strip-ansi: 6.0.1 dev: false - /wrap-ansi@8.1.0: - resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} - engines: {node: '>=12'} - dependencies: - ansi-styles: 6.2.1 - string-width: 5.1.2 - strip-ansi: 7.1.0 - dev: false - /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} diff --git a/src/handleListCliCommand.ts b/src/handleListCliCommand.ts index 7e47383..2110ca7 100644 --- a/src/handleListCliCommand.ts +++ b/src/handleListCliCommand.ts @@ -1,6 +1,6 @@ import { isNeitherNullNorUndefined } from '@intuita-inc/utilities'; import * as fs from 'fs'; -import { glob } from 'glob'; +import { glob } from 'fast-glob'; import { mkdir, readFile } from 'node:fs/promises'; import { homedir } from 'node:os'; import { join } from 'node:path'; @@ -16,7 +16,7 @@ export const handleListNamesCommand = async (printer: PrinterBlueprint) => { absolute: true, cwd: intuitaDirectoryPath, fs, - nodir: true, + onlyFiles: true, }); const codemodNames = await Promise.allSettled( diff --git a/src/runCodemod.ts b/src/runCodemod.ts index 407dc79..4ec2177 100644 --- a/src/runCodemod.ts +++ b/src/runCodemod.ts @@ -4,7 +4,8 @@ import { modifyFileSystemUponCommand, } from './fileCommands.js'; import { Dependencies, runRepomod } from './runRepomod.js'; -import { escape, glob, Glob } from 'glob'; +import { FileSystemAdapter, glob, globStream } from 'fast-glob'; +export { escape } from 'minimatch'; import { Filemod } from '@intuita-inc/filemod'; import { PrinterBlueprint } from './printer.js'; import { Codemod } from './codemod.js'; @@ -29,6 +30,8 @@ export const buildPaths = async ( ): Promise> => { const patterns = flowSettings.files ?? flowSettings.include ?? []; + const fileSystemAdapter = fileSystem as Partial; + if ( (codemod.engine === 'repomod-engine' || codemod.engine === 'filemod') && filemod !== null @@ -38,20 +41,20 @@ export const buildPaths = async ( { absolute: true, cwd: flowSettings.targetPath, - // @ts-expect-error type inconsistency - fs: fileSystem, ignore: filemod.excludePatterns?.slice(), - nodir: true, + onlyFiles: true, + fs: fileSystemAdapter, + dot: true, }, ); const flowPaths = await glob(patterns.slice(), { absolute: true, cwd: flowSettings.targetPath, - // @ts-expect-error type inconsistency - fs: fileSystem, ignore: flowSettings.exclude.slice(), - nodir: true, + onlyFiles: true, + fs: fileSystemAdapter, + dot: true, }); return filemodPaths @@ -63,10 +66,10 @@ export const buildPaths = async ( const paths = await glob(patterns.slice(), { absolute: true, cwd: flowSettings.targetPath, - // @ts-expect-error type inconsistency - fs: fileSystem, + fs: fileSystemAdapter, ignore: flowSettings.exclude.slice(), - nodir: true, + onlyFiles: true, + dot: true, }); return paths.slice(0, flowSettings.fileLimit); @@ -82,40 +85,30 @@ async function* buildPathGenerator( ? flowSettings.exclude.slice() : undefined; - const controller = new AbortController(); + const fileSystemAdapter = fileSystem as Partial; - const glob = new Glob(patterns.slice(), { + const stream = globStream(patterns.slice(), { absolute: true, cwd: flowSettings.targetPath, - // @ts-expect-error type inconsistency - fs: fileSystem, + fs: fileSystemAdapter, ignore, - nodir: true, - withFileTypes: false, - signal: controller.signal, + onlyFiles: true, + dot: true, }); - const asyncGenerator = glob.iterate(); - let fileCount = 0; - while (fileCount < flowSettings.fileLimit) { - const iteratorResult = await asyncGenerator.next(); - - if (iteratorResult.done) { - return; + for await (const chunk of stream) { + if (fileCount >= flowSettings.fileLimit) { + break; } - const { value } = iteratorResult; - - const path = typeof value === 'string' ? value : value.fullpath(); - - yield path; + yield chunk.toString(); ++fileCount; } - controller.abort(); + stream.emit('close'); } export const runCodemod = async ( diff --git a/src/runRepomod.ts b/src/runRepomod.ts index b5c5c31..a2aa9bb 100644 --- a/src/runRepomod.ts +++ b/src/runRepomod.ts @@ -25,7 +25,7 @@ import { IFs } from 'memfs'; import { SafeArgumentRecord } from './safeArgumentRecord.js'; import { createHash } from 'node:crypto'; import { OperationMessage } from './messages.js'; -import { FSOption, GlobOptionsWithFileTypesUnset, glob } from 'glob'; +import { FileSystemAdapter, glob } from 'fast-glob'; import { basename, dirname, join } from 'node:path'; const parseMdx = (data: string) => @@ -91,8 +91,9 @@ export const runRepomod = async ( absolute: true, cwd: globArguments.currentWorkingDirectory, ignore: globArguments.excludePatterns.slice(), - fs: fileSystem as FSOption, - } satisfies GlobOptionsWithFileTypesUnset); + fs: fileSystem as Partial, + dot: true, + }); }; const readDirectory = async (