@hyperfrontend/project-scope 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/README.md +3 -4
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.cjs.js +7 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.esm.js +5 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.cjs.js +13 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.esm.js +8 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/date/index.cjs.js +10 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/date/index.esm.js +8 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.cjs.js +6 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.esm.js +5 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.cjs.js +7 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.esm.js +5 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.cjs.js +6 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.esm.js +5 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/math/index.cjs.js +9 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/math/index.esm.js +6 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/number/index.cjs.js +7 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/number/index.esm.js +7 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.cjs.js +15 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.esm.js +9 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.cjs.js +6 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.esm.js +5 -0
- package/_dependencies/@hyperfrontend/logging/index.cjs.js +191 -0
- package/_dependencies/@hyperfrontend/logging/index.d.ts +151 -0
- package/_dependencies/@hyperfrontend/logging/index.esm.js +186 -0
- package/_shared/core/cache/index.cjs.js +135 -0
- package/_shared/core/cache/index.esm.js +128 -0
- package/_shared/core/errors/structured-errors/index.cjs.js +28 -0
- package/_shared/core/errors/structured-errors/index.esm.js +23 -0
- package/_shared/core/fs/guard/index.cjs.js +7 -0
- package/_shared/core/fs/guard/index.esm.js +5 -0
- package/_shared/core/fs/stat/index.cjs.js +47 -0
- package/_shared/core/fs/stat/index.esm.js +41 -0
- package/_shared/core/path/confine/index.cjs.js +22 -0
- package/_shared/core/path/confine/index.esm.js +19 -0
- package/_shared/core/path/join/index.cjs.js +13 -0
- package/_shared/core/path/join/index.esm.js +10 -0
- package/_shared/core/path/normalize/index.cjs.js +37 -0
- package/_shared/core/path/normalize/index.esm.js +31 -0
- package/_shared/core/path/resolve/index.cjs.js +47 -0
- package/_shared/core/path/resolve/index.esm.js +41 -0
- package/_shared/core/path/segments/index.cjs.js +38 -0
- package/_shared/core/path/segments/index.esm.js +31 -0
- package/_shared/core/patterns/glob/index.cjs.js +145 -0
- package/_shared/core/patterns/glob/index.esm.js +136 -0
- package/_shared/core/platform/detect/index.cjs.js +103 -0
- package/_shared/core/platform/detect/index.esm.js +95 -0
- package/_shared/core/platform/line-endings/index.cjs.js +52 -0
- package/_shared/core/platform/line-endings/index.esm.js +44 -0
- package/_shared/project/config/patterns/index.cjs.js +172 -0
- package/_shared/project/config/patterns/index.esm.js +169 -0
- package/_shared/tech/monorepo/pnpm-workspaces/index.cjs.js +33 -0
- package/_shared/tech/monorepo/pnpm-workspaces/index.esm.js +31 -0
- package/_shared/tech/shared-utils/detector-helpers/index.cjs.js +48 -0
- package/_shared/tech/shared-utils/detector-helpers/index.esm.js +43 -0
- package/_shared/vfs/types/index.cjs.js +14 -0
- package/_shared/vfs/types/index.esm.js +12 -0
- package/cli/index.cjs.js +1706 -1910
- package/cli/index.d.ts +273 -7
- package/cli/index.d.ts.map +1 -1
- package/cli/index.esm.js +1593 -1797
- package/core/encoding/index.cjs.js +86 -401
- package/core/encoding/index.d.ts +186 -3
- package/core/encoding/index.d.ts.map +1 -1
- package/core/encoding/index.esm.js +78 -392
- package/core/fs/index.cjs.js +243 -583
- package/core/fs/index.d.ts +479 -6
- package/core/fs/index.d.ts.map +1 -1
- package/core/fs/index.esm.js +233 -573
- package/core/index.cjs.js +526 -1746
- package/core/index.d.ts +486 -9
- package/core/index.d.ts.map +1 -1
- package/core/index.esm.js +515 -1732
- package/core/path/index.cjs.js +8 -234
- package/core/path/index.d.ts +327 -5
- package/core/path/index.d.ts.map +1 -1
- package/core/path/index.esm.js +8 -235
- package/core/platform/index.cjs.js +5 -216
- package/core/platform/index.d.ts +185 -3
- package/core/platform/index.d.ts.map +1 -1
- package/core/platform/index.esm.js +3 -212
- package/heuristics/dependencies/index.cjs.js +105 -493
- package/heuristics/dependencies/index.d.ts +99 -2
- package/heuristics/dependencies/index.d.ts.map +1 -1
- package/heuristics/dependencies/index.esm.js +81 -469
- package/heuristics/entry-points/index.cjs.js +93 -796
- package/heuristics/entry-points/index.d.ts +123 -2
- package/heuristics/entry-points/index.d.ts.map +1 -1
- package/heuristics/entry-points/index.esm.js +74 -777
- package/heuristics/framework/index.cjs.js +1483 -1411
- package/heuristics/framework/index.d.ts +104 -2
- package/heuristics/framework/index.d.ts.map +1 -1
- package/heuristics/framework/index.esm.js +1419 -1347
- package/heuristics/index.cjs.js +3220 -3306
- package/heuristics/index.d.ts +4 -5
- package/heuristics/index.d.ts.map +1 -1
- package/heuristics/index.esm.js +3244 -3330
- package/heuristics/project-type/index.cjs.js +1489 -1438
- package/heuristics/project-type/index.d.ts +64 -2
- package/heuristics/project-type/index.d.ts.map +1 -1
- package/heuristics/project-type/index.esm.js +1419 -1368
- package/index.cjs.js +3058 -3532
- package/index.d.ts +44 -10
- package/index.d.ts.map +1 -1
- package/index.esm.js +2914 -3376
- package/models/index.cjs.js +0 -1
- package/models/index.d.ts +20 -14
- package/models/index.d.ts.map +1 -1
- package/models/index.esm.js +0 -1
- package/nx/index.cjs.js +166 -579
- package/nx/index.d.ts +279 -4
- package/nx/index.d.ts.map +1 -1
- package/nx/index.esm.js +148 -556
- package/package.json +13 -12
- package/project/config/index.cjs.js +127 -1063
- package/project/config/index.d.ts +202 -4
- package/project/config/index.d.ts.map +1 -1
- package/project/config/index.esm.js +110 -1044
- package/project/index.cjs.js +328 -1101
- package/project/index.d.ts +4 -5
- package/project/index.d.ts.map +1 -1
- package/project/index.esm.js +307 -1077
- package/project/package/index.cjs.js +196 -473
- package/project/package/index.d.ts +280 -3
- package/project/package/index.d.ts.map +1 -1
- package/project/package/index.esm.js +183 -459
- package/project/root/index.cjs.js +109 -417
- package/project/root/index.d.ts +83 -2
- package/project/root/index.d.ts.map +1 -1
- package/project/root/index.esm.js +98 -406
- package/project/traversal/index.cjs.js +96 -622
- package/project/traversal/index.d.ts +165 -3
- package/project/traversal/index.d.ts.map +1 -1
- package/project/traversal/index.esm.js +82 -608
- package/tech/backend/index.cjs.js +223 -508
- package/tech/backend/index.d.ts +205 -8
- package/tech/backend/index.d.ts.map +1 -1
- package/tech/backend/index.esm.js +202 -487
- package/tech/build/index.cjs.js +350 -636
- package/tech/build/index.d.ts +276 -10
- package/tech/build/index.d.ts.map +1 -1
- package/tech/build/index.esm.js +328 -614
- package/tech/frontend/index.cjs.js +507 -685
- package/tech/frontend/index.d.ts +379 -15
- package/tech/frontend/index.d.ts.map +1 -1
- package/tech/frontend/index.esm.js +483 -661
- package/tech/index.cjs.js +1581 -1420
- package/tech/index.d.ts +55 -32
- package/tech/index.d.ts.map +1 -1
- package/tech/index.esm.js +1515 -1354
- package/tech/legacy/index.cjs.js +99 -449
- package/tech/legacy/index.d.ts +125 -7
- package/tech/legacy/index.d.ts.map +1 -1
- package/tech/legacy/index.esm.js +81 -431
- package/tech/linting/index.cjs.js +138 -523
- package/tech/linting/index.d.ts +129 -7
- package/tech/linting/index.d.ts.map +1 -1
- package/tech/linting/index.esm.js +118 -503
- package/tech/monorepo/index.cjs.js +246 -573
- package/tech/monorepo/index.d.ts +241 -10
- package/tech/monorepo/index.d.ts.map +1 -1
- package/tech/monorepo/index.esm.js +226 -553
- package/tech/testing/index.cjs.js +216 -571
- package/tech/testing/index.d.ts +176 -8
- package/tech/testing/index.d.ts.map +1 -1
- package/tech/testing/index.esm.js +198 -553
- package/tech/types/index.cjs.js +123 -506
- package/tech/types/index.d.ts +120 -2
- package/tech/types/index.d.ts.map +1 -1
- package/tech/types/index.esm.js +101 -484
- package/vfs/index.cjs.js +647 -1142
- package/vfs/index.d.ts +360 -6
- package/vfs/index.d.ts.map +1 -1
- package/vfs/index.esm.js +672 -1167
- package/ARCHITECTURE.md +0 -370
- package/analyze.d.ts +0 -33
- package/analyze.d.ts.map +0 -1
- package/cli/commands/analyze.d.ts +0 -28
- package/cli/commands/analyze.d.ts.map +0 -1
- package/cli/commands/config.d.ts +0 -27
- package/cli/commands/config.d.ts.map +0 -1
- package/cli/commands/deps.d.ts +0 -24
- package/cli/commands/deps.d.ts.map +0 -1
- package/cli/commands/tree.d.ts +0 -36
- package/cli/commands/tree.d.ts.map +0 -1
- package/cli/index.cjs.js.map +0 -1
- package/cli/index.esm.js.map +0 -1
- package/cli/run.d.ts +0 -25
- package/cli/run.d.ts.map +0 -1
- package/cli/types.d.ts +0 -55
- package/cli/types.d.ts.map +0 -1
- package/core/cache.d.ts +0 -158
- package/core/cache.d.ts.map +0 -1
- package/core/encoding/convert.d.ts +0 -32
- package/core/encoding/convert.d.ts.map +0 -1
- package/core/encoding/detect.d.ts +0 -91
- package/core/encoding/detect.d.ts.map +0 -1
- package/core/encoding/index.cjs.js.map +0 -1
- package/core/encoding/index.esm.js.map +0 -1
- package/core/errors/structured-errors.d.ts +0 -66
- package/core/errors/structured-errors.d.ts.map +0 -1
- package/core/fs/directory.d.ts +0 -91
- package/core/fs/directory.d.ts.map +0 -1
- package/core/fs/index.cjs.js.map +0 -1
- package/core/fs/index.esm.js.map +0 -1
- package/core/fs/read.d.ts +0 -94
- package/core/fs/read.d.ts.map +0 -1
- package/core/fs/stat.d.ts +0 -58
- package/core/fs/stat.d.ts.map +0 -1
- package/core/fs/traversal.d.ts +0 -26
- package/core/fs/traversal.d.ts.map +0 -1
- package/core/fs/write.d.ts +0 -75
- package/core/fs/write.d.ts.map +0 -1
- package/core/index.cjs.js.map +0 -1
- package/core/index.esm.js.map +0 -1
- package/core/logger.d.ts +0 -111
- package/core/logger.d.ts.map +0 -1
- package/core/path/index.cjs.js.map +0 -1
- package/core/path/index.esm.js.map +0 -1
- package/core/path/join.d.ts +0 -17
- package/core/path/join.d.ts.map +0 -1
- package/core/path/normalize.d.ts +0 -37
- package/core/path/normalize.d.ts.map +0 -1
- package/core/path/resolve.d.ts +0 -52
- package/core/path/resolve.d.ts.map +0 -1
- package/core/path/segments.d.ts +0 -59
- package/core/path/segments.d.ts.map +0 -1
- package/core/patterns/glob.d.ts +0 -42
- package/core/patterns/glob.d.ts.map +0 -1
- package/core/platform/detect.d.ts +0 -66
- package/core/platform/detect.d.ts.map +0 -1
- package/core/platform/index.cjs.js.map +0 -1
- package/core/platform/index.esm.js.map +0 -1
- package/core/platform/line-endings.d.ts +0 -48
- package/core/platform/line-endings.d.ts.map +0 -1
- package/heuristics/dependencies/analyze.d.ts +0 -77
- package/heuristics/dependencies/analyze.d.ts.map +0 -1
- package/heuristics/dependencies/index.cjs.js.map +0 -1
- package/heuristics/dependencies/index.esm.js.map +0 -1
- package/heuristics/entry-points/discover.d.ts +0 -113
- package/heuristics/entry-points/discover.d.ts.map +0 -1
- package/heuristics/entry-points/index.cjs.js.map +0 -1
- package/heuristics/entry-points/index.esm.js.map +0 -1
- package/heuristics/framework/identify.d.ts +0 -84
- package/heuristics/framework/identify.d.ts.map +0 -1
- package/heuristics/framework/index.cjs.js.map +0 -1
- package/heuristics/framework/index.esm.js.map +0 -1
- package/heuristics/index.cjs.js.map +0 -1
- package/heuristics/index.esm.js.map +0 -1
- package/heuristics/project-type/detect.d.ts +0 -61
- package/heuristics/project-type/detect.d.ts.map +0 -1
- package/heuristics/project-type/index.cjs.js.map +0 -1
- package/heuristics/project-type/index.esm.js.map +0 -1
- package/index.cjs.js.map +0 -1
- package/index.esm.js.map +0 -1
- package/models/index.cjs.js.map +0 -1
- package/models/index.esm.js.map +0 -1
- package/nx/detect.d.ts +0 -105
- package/nx/detect.d.ts.map +0 -1
- package/nx/devkit-loader.d.ts +0 -62
- package/nx/devkit-loader.d.ts.map +0 -1
- package/nx/index.cjs.js.map +0 -1
- package/nx/index.esm.js.map +0 -1
- package/nx/project-config.d.ts +0 -111
- package/nx/project-config.d.ts.map +0 -1
- package/project/config/detect.d.ts +0 -77
- package/project/config/detect.d.ts.map +0 -1
- package/project/config/index.cjs.js.map +0 -1
- package/project/config/index.esm.js.map +0 -1
- package/project/config/parse.d.ts +0 -53
- package/project/config/parse.d.ts.map +0 -1
- package/project/config/patterns.d.ts +0 -31
- package/project/config/patterns.d.ts.map +0 -1
- package/project/index.cjs.js.map +0 -1
- package/project/index.esm.js.map +0 -1
- package/project/package/dependencies.d.ts +0 -101
- package/project/package/dependencies.d.ts.map +0 -1
- package/project/package/index.cjs.js.map +0 -1
- package/project/package/index.esm.js.map +0 -1
- package/project/package/read.d.ts +0 -67
- package/project/package/read.d.ts.map +0 -1
- package/project/root/detect.d.ts +0 -65
- package/project/root/detect.d.ts.map +0 -1
- package/project/root/index.cjs.js.map +0 -1
- package/project/root/index.esm.js.map +0 -1
- package/project/traversal/index.cjs.js.map +0 -1
- package/project/traversal/index.esm.js.map +0 -1
- package/project/traversal/search.d.ts +0 -59
- package/project/traversal/search.d.ts.map +0 -1
- package/project/traversal/walk.d.ts +0 -63
- package/project/traversal/walk.d.ts.map +0 -1
- package/tech/backend/detect-all.d.ts +0 -13
- package/tech/backend/detect-all.d.ts.map +0 -1
- package/tech/backend/express.d.ts +0 -11
- package/tech/backend/express.d.ts.map +0 -1
- package/tech/backend/fastify.d.ts +0 -11
- package/tech/backend/fastify.d.ts.map +0 -1
- package/tech/backend/hono.d.ts +0 -11
- package/tech/backend/hono.d.ts.map +0 -1
- package/tech/backend/index.cjs.js.map +0 -1
- package/tech/backend/index.esm.js.map +0 -1
- package/tech/backend/koa.d.ts +0 -11
- package/tech/backend/koa.d.ts.map +0 -1
- package/tech/backend/nestjs.d.ts +0 -11
- package/tech/backend/nestjs.d.ts.map +0 -1
- package/tech/backend/types.d.ts +0 -31
- package/tech/backend/types.d.ts.map +0 -1
- package/tech/build/babel.d.ts +0 -13
- package/tech/build/babel.d.ts.map +0 -1
- package/tech/build/detect-all.d.ts +0 -13
- package/tech/build/detect-all.d.ts.map +0 -1
- package/tech/build/esbuild.d.ts +0 -11
- package/tech/build/esbuild.d.ts.map +0 -1
- package/tech/build/index.cjs.js.map +0 -1
- package/tech/build/index.esm.js.map +0 -1
- package/tech/build/parcel.d.ts +0 -13
- package/tech/build/parcel.d.ts.map +0 -1
- package/tech/build/rollup.d.ts +0 -13
- package/tech/build/rollup.d.ts.map +0 -1
- package/tech/build/swc.d.ts +0 -13
- package/tech/build/swc.d.ts.map +0 -1
- package/tech/build/types.d.ts +0 -31
- package/tech/build/types.d.ts.map +0 -1
- package/tech/build/vite.d.ts +0 -13
- package/tech/build/vite.d.ts.map +0 -1
- package/tech/build/webpack.d.ts +0 -13
- package/tech/build/webpack.d.ts.map +0 -1
- package/tech/frontend/angular.d.ts +0 -11
- package/tech/frontend/angular.d.ts.map +0 -1
- package/tech/frontend/astro.d.ts +0 -11
- package/tech/frontend/astro.d.ts.map +0 -1
- package/tech/frontend/detect-all.d.ts +0 -13
- package/tech/frontend/detect-all.d.ts.map +0 -1
- package/tech/frontend/gatsby.d.ts +0 -11
- package/tech/frontend/gatsby.d.ts.map +0 -1
- package/tech/frontend/index.cjs.js.map +0 -1
- package/tech/frontend/index.esm.js.map +0 -1
- package/tech/frontend/nextjs.d.ts +0 -11
- package/tech/frontend/nextjs.d.ts.map +0 -1
- package/tech/frontend/nuxt.d.ts +0 -11
- package/tech/frontend/nuxt.d.ts.map +0 -1
- package/tech/frontend/qwik.d.ts +0 -11
- package/tech/frontend/qwik.d.ts.map +0 -1
- package/tech/frontend/react.d.ts +0 -11
- package/tech/frontend/react.d.ts.map +0 -1
- package/tech/frontend/remix.d.ts +0 -11
- package/tech/frontend/remix.d.ts.map +0 -1
- package/tech/frontend/solid.d.ts +0 -11
- package/tech/frontend/solid.d.ts.map +0 -1
- package/tech/frontend/svelte.d.ts +0 -11
- package/tech/frontend/svelte.d.ts.map +0 -1
- package/tech/frontend/sveltekit.d.ts +0 -11
- package/tech/frontend/sveltekit.d.ts.map +0 -1
- package/tech/frontend/types.d.ts +0 -35
- package/tech/frontend/types.d.ts.map +0 -1
- package/tech/frontend/vue.d.ts +0 -11
- package/tech/frontend/vue.d.ts.map +0 -1
- package/tech/index.cjs.js.map +0 -1
- package/tech/index.esm.js.map +0 -1
- package/tech/legacy/angularjs.d.ts +0 -12
- package/tech/legacy/angularjs.d.ts.map +0 -1
- package/tech/legacy/backbone.d.ts +0 -11
- package/tech/legacy/backbone.d.ts.map +0 -1
- package/tech/legacy/detect-all.d.ts +0 -13
- package/tech/legacy/detect-all.d.ts.map +0 -1
- package/tech/legacy/ember.d.ts +0 -11
- package/tech/legacy/ember.d.ts.map +0 -1
- package/tech/legacy/index.cjs.js.map +0 -1
- package/tech/legacy/index.esm.js.map +0 -1
- package/tech/legacy/jquery.d.ts +0 -11
- package/tech/legacy/jquery.d.ts.map +0 -1
- package/tech/legacy/types.d.ts +0 -33
- package/tech/legacy/types.d.ts.map +0 -1
- package/tech/linting/biome.d.ts +0 -11
- package/tech/linting/biome.d.ts.map +0 -1
- package/tech/linting/detect-all.d.ts +0 -13
- package/tech/linting/detect-all.d.ts.map +0 -1
- package/tech/linting/eslint.d.ts +0 -13
- package/tech/linting/eslint.d.ts.map +0 -1
- package/tech/linting/index.cjs.js.map +0 -1
- package/tech/linting/index.esm.js.map +0 -1
- package/tech/linting/prettier.d.ts +0 -13
- package/tech/linting/prettier.d.ts.map +0 -1
- package/tech/linting/stylelint.d.ts +0 -13
- package/tech/linting/stylelint.d.ts.map +0 -1
- package/tech/linting/types.d.ts +0 -31
- package/tech/linting/types.d.ts.map +0 -1
- package/tech/monorepo/detect-all.d.ts +0 -13
- package/tech/monorepo/detect-all.d.ts.map +0 -1
- package/tech/monorepo/index.cjs.js.map +0 -1
- package/tech/monorepo/index.esm.js.map +0 -1
- package/tech/monorepo/lerna.d.ts +0 -11
- package/tech/monorepo/lerna.d.ts.map +0 -1
- package/tech/monorepo/npm-workspaces.d.ts +0 -11
- package/tech/monorepo/npm-workspaces.d.ts.map +0 -1
- package/tech/monorepo/nx.d.ts +0 -11
- package/tech/monorepo/nx.d.ts.map +0 -1
- package/tech/monorepo/pnpm-workspaces.d.ts +0 -9
- package/tech/monorepo/pnpm-workspaces.d.ts.map +0 -1
- package/tech/monorepo/rush.d.ts +0 -11
- package/tech/monorepo/rush.d.ts.map +0 -1
- package/tech/monorepo/turborepo.d.ts +0 -11
- package/tech/monorepo/turborepo.d.ts.map +0 -1
- package/tech/monorepo/types.d.ts +0 -39
- package/tech/monorepo/types.d.ts.map +0 -1
- package/tech/monorepo/yarn-workspaces.d.ts +0 -11
- package/tech/monorepo/yarn-workspaces.d.ts.map +0 -1
- package/tech/shared-utils/detector-helpers.d.ts +0 -52
- package/tech/shared-utils/detector-helpers.d.ts.map +0 -1
- package/tech/shared-utils/types.d.ts +0 -41
- package/tech/shared-utils/types.d.ts.map +0 -1
- package/tech/testing/cypress.d.ts +0 -13
- package/tech/testing/cypress.d.ts.map +0 -1
- package/tech/testing/detect-all.d.ts +0 -13
- package/tech/testing/detect-all.d.ts.map +0 -1
- package/tech/testing/index.cjs.js.map +0 -1
- package/tech/testing/index.esm.js.map +0 -1
- package/tech/testing/jest.d.ts +0 -13
- package/tech/testing/jest.d.ts.map +0 -1
- package/tech/testing/mocha.d.ts +0 -13
- package/tech/testing/mocha.d.ts.map +0 -1
- package/tech/testing/playwright.d.ts +0 -13
- package/tech/testing/playwright.d.ts.map +0 -1
- package/tech/testing/types.d.ts +0 -35
- package/tech/testing/types.d.ts.map +0 -1
- package/tech/testing/vitest.d.ts +0 -13
- package/tech/testing/vitest.d.ts.map +0 -1
- package/tech/types/detectors.d.ts +0 -67
- package/tech/types/detectors.d.ts.map +0 -1
- package/tech/types/index.cjs.js.map +0 -1
- package/tech/types/index.esm.js.map +0 -1
- package/vfs/commit.d.ts +0 -32
- package/vfs/commit.d.ts.map +0 -1
- package/vfs/diff.d.ts +0 -73
- package/vfs/diff.d.ts.map +0 -1
- package/vfs/factory.d.ts +0 -37
- package/vfs/factory.d.ts.map +0 -1
- package/vfs/fs-tree.d.ts +0 -13
- package/vfs/fs-tree.d.ts.map +0 -1
- package/vfs/index.cjs.js.map +0 -1
- package/vfs/index.esm.js.map +0 -1
- package/vfs/types.d.ts +0 -179
- package/vfs/types.d.ts.map +0 -1
package/project/index.esm.js
CHANGED
|
@@ -1,405 +1,21 @@
|
|
|
1
|
-
import { join as join$1, resolve, parse
|
|
1
|
+
import { join as join$1, resolve, parse, dirname, basename } from 'node:path';
|
|
2
|
+
import { freeze, entries, keys, defineProperties, values } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.esm.js';
|
|
3
|
+
import { createMap } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.esm.js';
|
|
4
|
+
import { createSet } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.esm.js';
|
|
2
5
|
import { existsSync, readFileSync, statSync, lstatSync, readdirSync } from 'node:fs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const _Reflect$2 = globalThis.Reflect;
|
|
17
|
-
/**
|
|
18
|
-
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
19
|
-
* Use this instead of `new Error()`.
|
|
20
|
-
*
|
|
21
|
-
* @param message - Optional error message.
|
|
22
|
-
* @param options - Optional error options.
|
|
23
|
-
* @returns A new Error instance.
|
|
24
|
-
*/
|
|
25
|
-
const createError = (message, options) => _Reflect$2.construct(_Error, [message, options]);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Safe copies of JSON built-in methods.
|
|
29
|
-
*
|
|
30
|
-
* These references are captured at module initialization time to protect against
|
|
31
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
32
|
-
*
|
|
33
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/json
|
|
34
|
-
*/
|
|
35
|
-
const _JSON = globalThis.JSON;
|
|
36
|
-
/**
|
|
37
|
-
* (Safe copy) Converts a JavaScript Object Notation (JSON) string into an object.
|
|
38
|
-
*/
|
|
39
|
-
const parse = _JSON.parse;
|
|
40
|
-
/**
|
|
41
|
-
* (Safe copy) Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
42
|
-
*/
|
|
43
|
-
const stringify = _JSON.stringify;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Safe copies of Object built-in methods.
|
|
47
|
-
*
|
|
48
|
-
* These references are captured at module initialization time to protect against
|
|
49
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
50
|
-
*
|
|
51
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/object
|
|
52
|
-
*/
|
|
53
|
-
const _Object = globalThis.Object;
|
|
54
|
-
/**
|
|
55
|
-
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
56
|
-
* and prevents the addition of new properties.
|
|
57
|
-
*/
|
|
58
|
-
const freeze = _Object.freeze;
|
|
59
|
-
/**
|
|
60
|
-
* (Safe copy) Returns the names of the enumerable string properties and methods of an object.
|
|
61
|
-
*/
|
|
62
|
-
const keys = _Object.keys;
|
|
63
|
-
/**
|
|
64
|
-
* (Safe copy) Returns an array of key/values of the enumerable own properties of an object.
|
|
65
|
-
*/
|
|
66
|
-
const entries = _Object.entries;
|
|
67
|
-
/**
|
|
68
|
-
* (Safe copy) Returns an array of values of the enumerable own properties of an object.
|
|
69
|
-
*/
|
|
70
|
-
const values = _Object.values;
|
|
71
|
-
/**
|
|
72
|
-
* (Safe copy) Adds one or more properties to an object, and/or modifies attributes of existing properties.
|
|
73
|
-
*/
|
|
74
|
-
const defineProperties = _Object.defineProperties;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Safe copies of Array built-in static methods.
|
|
78
|
-
*
|
|
79
|
-
* These references are captured at module initialization time to protect against
|
|
80
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
81
|
-
*
|
|
82
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
83
|
-
*/
|
|
84
|
-
const _Array = globalThis.Array;
|
|
85
|
-
/**
|
|
86
|
-
* (Safe copy) Determines whether the passed value is an Array.
|
|
87
|
-
*/
|
|
88
|
-
const isArray = _Array.isArray;
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Safe copies of Console built-in methods.
|
|
92
|
-
*
|
|
93
|
-
* These references are captured at module initialization time to protect against
|
|
94
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
95
|
-
*
|
|
96
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/console
|
|
97
|
-
*/
|
|
98
|
-
const _console = globalThis.console;
|
|
99
|
-
/**
|
|
100
|
-
* (Safe copy) Outputs a message to the console.
|
|
101
|
-
*/
|
|
102
|
-
const log = _console.log.bind(_console);
|
|
103
|
-
/**
|
|
104
|
-
* (Safe copy) Outputs a warning message to the console.
|
|
105
|
-
*/
|
|
106
|
-
const warn = _console.warn.bind(_console);
|
|
107
|
-
/**
|
|
108
|
-
* (Safe copy) Outputs an error message to the console.
|
|
109
|
-
*/
|
|
110
|
-
const error = _console.error.bind(_console);
|
|
111
|
-
/**
|
|
112
|
-
* (Safe copy) Outputs an informational message to the console.
|
|
113
|
-
*/
|
|
114
|
-
const info = _console.info.bind(_console);
|
|
115
|
-
/**
|
|
116
|
-
* (Safe copy) Outputs a debug message to the console.
|
|
117
|
-
*/
|
|
118
|
-
const debug = _console.debug.bind(_console);
|
|
119
|
-
/**
|
|
120
|
-
* (Safe copy) Outputs a stack trace to the console.
|
|
121
|
-
*/
|
|
122
|
-
_console.trace.bind(_console);
|
|
123
|
-
/**
|
|
124
|
-
* (Safe copy) Displays an interactive listing of the properties of a specified object.
|
|
125
|
-
*/
|
|
126
|
-
_console.dir.bind(_console);
|
|
127
|
-
/**
|
|
128
|
-
* (Safe copy) Displays tabular data as a table.
|
|
129
|
-
*/
|
|
130
|
-
_console.table.bind(_console);
|
|
131
|
-
/**
|
|
132
|
-
* (Safe copy) Writes an error message to the console if the assertion is false.
|
|
133
|
-
*/
|
|
134
|
-
_console.assert.bind(_console);
|
|
135
|
-
/**
|
|
136
|
-
* (Safe copy) Clears the console.
|
|
137
|
-
*/
|
|
138
|
-
_console.clear.bind(_console);
|
|
139
|
-
/**
|
|
140
|
-
* (Safe copy) Logs the number of times that this particular call to count() has been called.
|
|
141
|
-
*/
|
|
142
|
-
_console.count.bind(_console);
|
|
143
|
-
/**
|
|
144
|
-
* (Safe copy) Resets the counter used with console.count().
|
|
145
|
-
*/
|
|
146
|
-
_console.countReset.bind(_console);
|
|
147
|
-
/**
|
|
148
|
-
* (Safe copy) Creates a new inline group in the console.
|
|
149
|
-
*/
|
|
150
|
-
_console.group.bind(_console);
|
|
151
|
-
/**
|
|
152
|
-
* (Safe copy) Creates a new inline group in the console that is initially collapsed.
|
|
153
|
-
*/
|
|
154
|
-
_console.groupCollapsed.bind(_console);
|
|
155
|
-
/**
|
|
156
|
-
* (Safe copy) Exits the current inline group.
|
|
157
|
-
*/
|
|
158
|
-
_console.groupEnd.bind(_console);
|
|
159
|
-
/**
|
|
160
|
-
* (Safe copy) Starts a timer with a name specified as an input parameter.
|
|
161
|
-
*/
|
|
162
|
-
_console.time.bind(_console);
|
|
163
|
-
/**
|
|
164
|
-
* (Safe copy) Stops a timer that was previously started.
|
|
165
|
-
*/
|
|
166
|
-
_console.timeEnd.bind(_console);
|
|
167
|
-
/**
|
|
168
|
-
* (Safe copy) Logs the current value of a timer that was previously started.
|
|
169
|
-
*/
|
|
170
|
-
_console.timeLog.bind(_console);
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Safe copies of Set built-in via factory function.
|
|
174
|
-
*
|
|
175
|
-
* Since constructors cannot be safely captured via Object.assign, this module
|
|
176
|
-
* provides a factory function that uses Reflect.construct internally.
|
|
177
|
-
*
|
|
178
|
-
* These references are captured at module initialization time to protect against
|
|
179
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
180
|
-
*
|
|
181
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
182
|
-
*/
|
|
183
|
-
const _Set = globalThis.Set;
|
|
184
|
-
const _Reflect$1 = globalThis.Reflect;
|
|
185
|
-
/**
|
|
186
|
-
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
187
|
-
* Use this instead of `new Set()`.
|
|
188
|
-
*
|
|
189
|
-
* @param iterable - Optional iterable of values.
|
|
190
|
-
* @returns A new Set instance.
|
|
191
|
-
*/
|
|
192
|
-
const createSet = (iterable) => _Reflect$1.construct(_Set, iterable ? [iterable] : []);
|
|
193
|
-
|
|
194
|
-
const registeredClasses = [];
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Returns the data type of the target.
|
|
198
|
-
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
199
|
-
* Also, when classes are registered via `registerClass`, it checks if objects are instance of any known registered class.
|
|
200
|
-
*
|
|
201
|
-
* @param target - The target to get the data type of.
|
|
202
|
-
* @returns The data type of the target.
|
|
203
|
-
*/
|
|
204
|
-
const getType = (target) => {
|
|
205
|
-
if (target === null)
|
|
206
|
-
return 'null';
|
|
207
|
-
const nativeDataType = typeof target;
|
|
208
|
-
if (nativeDataType === 'object') {
|
|
209
|
-
if (isArray(target))
|
|
210
|
-
return 'array';
|
|
211
|
-
for (const registeredClass of registeredClasses) {
|
|
212
|
-
if (target instanceof registeredClass)
|
|
213
|
-
return registeredClass.name;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
return nativeDataType;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Safe copies of Map built-in via factory function.
|
|
221
|
-
*
|
|
222
|
-
* Since constructors cannot be safely captured via Object.assign, this module
|
|
223
|
-
* provides a factory function that uses Reflect.construct internally.
|
|
224
|
-
*
|
|
225
|
-
* These references are captured at module initialization time to protect against
|
|
226
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
227
|
-
*
|
|
228
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/map
|
|
229
|
-
*/
|
|
230
|
-
const _Map = globalThis.Map;
|
|
231
|
-
const _Reflect = globalThis.Reflect;
|
|
232
|
-
/**
|
|
233
|
-
* (Safe copy) Creates a new Map using the captured Map constructor.
|
|
234
|
-
* Use this instead of `new Map()`.
|
|
235
|
-
*
|
|
236
|
-
* @param iterable - Optional iterable of key-value pairs.
|
|
237
|
-
* @returns A new Map instance.
|
|
238
|
-
*/
|
|
239
|
-
const createMap = (iterable) => _Reflect.construct(_Map, iterable ? [iterable] : []);
|
|
240
|
-
|
|
241
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
242
|
-
/**
|
|
243
|
-
* Creates a wrapper function that only executes the wrapped function if the condition function returns true.
|
|
244
|
-
*
|
|
245
|
-
* @param func - The function to be conditionally executed.
|
|
246
|
-
* @param conditionFunc - A function that returns a boolean, determining if `func` should be executed.
|
|
247
|
-
* @returns A wrapped version of `func` that executes conditionally.
|
|
248
|
-
*/
|
|
249
|
-
function createConditionalExecutionFunction(func, conditionFunc) {
|
|
250
|
-
return function (...args) {
|
|
251
|
-
if (conditionFunc()) {
|
|
252
|
-
return func(...args);
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
258
|
-
/**
|
|
259
|
-
* Creates a wrapper function that silently ignores any errors thrown by the wrapped void function.
|
|
260
|
-
* This function is specifically for wrapping functions that do not return a value (void functions).
|
|
261
|
-
* Exceptions are swallowed without any logging or handling.
|
|
262
|
-
*
|
|
263
|
-
* @param func - The void function to be wrapped.
|
|
264
|
-
* @returns A wrapped version of the input function that ignores errors.
|
|
265
|
-
*/
|
|
266
|
-
function createErrorIgnoringFunction(func) {
|
|
267
|
-
return function (...args) {
|
|
268
|
-
try {
|
|
269
|
-
func(...args);
|
|
270
|
-
}
|
|
271
|
-
catch {
|
|
272
|
-
// Deliberately swallowing/ignoring the exception
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
278
|
-
/**
|
|
279
|
-
* A no-operation function (noop) that does nothing regardless of the arguments passed.
|
|
280
|
-
* It is designed to be as permissive as possible in its typing without using the `Function` keyword.
|
|
281
|
-
*
|
|
282
|
-
* @param args - Any arguments passed to the function (ignored)
|
|
283
|
-
*/
|
|
284
|
-
const noop = (...args) => {
|
|
285
|
-
// Intentionally does nothing
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const logLevels = ['none', 'error', 'warn', 'log', 'info', 'debug'];
|
|
289
|
-
const priority = {
|
|
290
|
-
error: 4,
|
|
291
|
-
warn: 3,
|
|
292
|
-
log: 2,
|
|
293
|
-
info: 1,
|
|
294
|
-
debug: 0,
|
|
295
|
-
};
|
|
296
|
-
/**
|
|
297
|
-
* Validates whether a given string is a valid log level.
|
|
298
|
-
*
|
|
299
|
-
* @param level - The log level to validate
|
|
300
|
-
* @returns True if the level is valid, false otherwise
|
|
301
|
-
*/
|
|
302
|
-
function isValidLogLevel(level) {
|
|
303
|
-
return logLevels.includes(level);
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Creates a log level configuration manager for controlling logging behavior.
|
|
307
|
-
* Provides methods to get, set, and evaluate log levels based on priority.
|
|
308
|
-
*
|
|
309
|
-
* @param level - The initial log level (defaults to 'error')
|
|
310
|
-
* @returns A configuration object with log level management methods
|
|
311
|
-
* @throws {Error} When the provided level is not a valid log level
|
|
312
|
-
*/
|
|
313
|
-
function createLogLevelConfig(level = 'error') {
|
|
314
|
-
if (!isValidLogLevel(level)) {
|
|
315
|
-
throw createError('Cannot create log level configuration with a valid default log level');
|
|
316
|
-
}
|
|
317
|
-
const state = { level };
|
|
318
|
-
const getLogLevel = () => state.level;
|
|
319
|
-
const setLogLevel = (level) => {
|
|
320
|
-
if (!isValidLogLevel(level)) {
|
|
321
|
-
throw createError(`Cannot set value '${level}' level. Expected levels are ${logLevels}.`);
|
|
322
|
-
}
|
|
323
|
-
state.level = level;
|
|
324
|
-
};
|
|
325
|
-
const shouldLog = (level) => {
|
|
326
|
-
if (state.level === 'none' || level === 'none' || !isValidLogLevel(level)) {
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
return priority[level] >= priority[state.level];
|
|
330
|
-
};
|
|
331
|
-
return freeze({
|
|
332
|
-
getLogLevel,
|
|
333
|
-
setLogLevel,
|
|
334
|
-
shouldLog,
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Creates a logger instance with configurable log level filtering.
|
|
340
|
-
* Each log function is wrapped to respect the current log level setting.
|
|
341
|
-
*
|
|
342
|
-
* @param error - Function to handle error-level logs (required)
|
|
343
|
-
* @param warn - Function to handle warning-level logs (optional, defaults to noop)
|
|
344
|
-
* @param log - Function to handle standard logs (optional, defaults to noop)
|
|
345
|
-
* @param info - Function to handle info-level logs (optional, defaults to noop)
|
|
346
|
-
* @param debug - Function to handle debug-level logs (optional, defaults to noop)
|
|
347
|
-
* @returns A frozen logger object with log methods and level control
|
|
348
|
-
* @throws {ErrorLevelFn} When any provided log function is invalid
|
|
349
|
-
*/
|
|
350
|
-
function createLogger(error, warn = noop, log = noop, info = noop, debug = noop) {
|
|
351
|
-
if (notValidLogFn(error)) {
|
|
352
|
-
throw createError(notFnMsg('error'));
|
|
353
|
-
}
|
|
354
|
-
if (notValidLogFn(warn)) {
|
|
355
|
-
throw createError(notFnMsg('warn'));
|
|
356
|
-
}
|
|
357
|
-
if (notValidLogFn(log)) {
|
|
358
|
-
throw createError(notFnMsg('log'));
|
|
359
|
-
}
|
|
360
|
-
if (notValidLogFn(info)) {
|
|
361
|
-
throw createError(notFnMsg('info'));
|
|
362
|
-
}
|
|
363
|
-
if (notValidLogFn(debug)) {
|
|
364
|
-
throw createError(notFnMsg('debug'));
|
|
365
|
-
}
|
|
366
|
-
const { setLogLevel, getLogLevel, shouldLog } = createLogLevelConfig();
|
|
367
|
-
const wrapLogFn = (fn, level) => {
|
|
368
|
-
if (fn === noop)
|
|
369
|
-
return fn;
|
|
370
|
-
const condition = () => shouldLog(level);
|
|
371
|
-
return createConditionalExecutionFunction(createErrorIgnoringFunction(fn), condition);
|
|
372
|
-
};
|
|
373
|
-
return freeze({
|
|
374
|
-
error: wrapLogFn(error, 'error'),
|
|
375
|
-
warn: wrapLogFn(warn, 'warn'),
|
|
376
|
-
log: wrapLogFn(log, 'log'),
|
|
377
|
-
info: wrapLogFn(info, 'info'),
|
|
378
|
-
debug: wrapLogFn(debug, 'debug'),
|
|
379
|
-
setLogLevel,
|
|
380
|
-
getLogLevel,
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Validates whether a given value is a valid log function.
|
|
385
|
-
*
|
|
386
|
-
* @param fn - The value to validate
|
|
387
|
-
* @returns True if the value is not a function (invalid), false if it is valid
|
|
388
|
-
*/
|
|
389
|
-
function notValidLogFn(fn) {
|
|
390
|
-
return getType(fn) !== 'function' && fn !== noop;
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Generates an error message for invalid log function parameters.
|
|
394
|
-
*
|
|
395
|
-
* @param label - The name of the log function that failed validation
|
|
396
|
-
* @returns A formatted error message string
|
|
397
|
-
*/
|
|
398
|
-
function notFnMsg(label) {
|
|
399
|
-
return `Cannot create a logger when ${label} is not a function`;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
createLogger(error, warn, log, info, debug);
|
|
6
|
+
import { isArray } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.esm.js';
|
|
7
|
+
import { error, warn, log, info, debug } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.esm.js';
|
|
8
|
+
import { stringify, parse as parse$1 } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.esm.js';
|
|
9
|
+
import { createLogger } from '../_dependencies/@hyperfrontend/logging/index.esm.js';
|
|
10
|
+
import { createError } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.esm.js';
|
|
11
|
+
import { parseInt, parseFloat } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/number/index.esm.js';
|
|
12
|
+
import { isSafePath } from '../_shared/core/fs/guard/index.esm.js';
|
|
13
|
+
import { isDirectory, exists } from '../_shared/core/fs/stat/index.esm.js';
|
|
14
|
+
import { join } from '../_shared/core/path/join/index.esm.js';
|
|
15
|
+
import { createConfigError } from '../_shared/core/errors/structured-errors/index.esm.js';
|
|
16
|
+
import { createCache } from '../_shared/core/cache/index.esm.js';
|
|
17
|
+
import { matchGlobPattern } from '../_shared/core/patterns/glob/index.esm.js';
|
|
18
|
+
import { CONFIG_PATTERNS, getConfigPatternsByType } from '../_shared/project/config/patterns/index.esm.js';
|
|
403
19
|
|
|
404
20
|
/**
|
|
405
21
|
* Global log level registry.
|
|
@@ -439,6 +55,13 @@ function isSensitiveKey(key) {
|
|
|
439
55
|
*
|
|
440
56
|
* @param obj - Object to sanitize
|
|
441
57
|
* @returns New object with sensitive values redacted
|
|
58
|
+
*
|
|
59
|
+
* @example Sanitizing sensitive data
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
|
|
62
|
+
* const safe = sanitize(config)
|
|
63
|
+
* // => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }
|
|
64
|
+
* ```
|
|
442
65
|
*/
|
|
443
66
|
function sanitize(obj) {
|
|
444
67
|
if (obj === null || obj === undefined) {
|
|
@@ -489,7 +112,7 @@ function formatMessage(namespace, message, meta) {
|
|
|
489
112
|
* @param options - Logger configuration options
|
|
490
113
|
* @returns A configured scoped logger instance
|
|
491
114
|
*
|
|
492
|
-
* @example
|
|
115
|
+
* @example Creating a scoped logger
|
|
493
116
|
* ```typescript
|
|
494
117
|
* const logger = createScopedLogger('project-scope')
|
|
495
118
|
* logger.setLogLevel('debug')
|
|
@@ -526,7 +149,7 @@ function createScopedLogger(namespace, options = {}) {
|
|
|
526
149
|
* Default logger instance for the project-scope library.
|
|
527
150
|
* Use this for general logging within the library.
|
|
528
151
|
*
|
|
529
|
-
* @example
|
|
152
|
+
* @example Using the default logger
|
|
530
153
|
* ```typescript
|
|
531
154
|
* import { logger } from '@hyperfrontend/project-scope/core'
|
|
532
155
|
*
|
|
@@ -544,6 +167,15 @@ const fsLogger = createScopedLogger('project-scope:fs');
|
|
|
544
167
|
* @param code - The category code for this type of filesystem failure
|
|
545
168
|
* @param context - Additional context including path, operation, and cause
|
|
546
169
|
* @returns A configured Error object with code and context properties
|
|
170
|
+
*
|
|
171
|
+
* @example Creating a file system error
|
|
172
|
+
* ```typescript
|
|
173
|
+
* throw createFileSystemError(
|
|
174
|
+
* 'Cannot read file',
|
|
175
|
+
* 'FS_READ_ERROR',
|
|
176
|
+
* { path: './missing.txt', operation: 'read' }
|
|
177
|
+
* )
|
|
178
|
+
* ```
|
|
547
179
|
*/
|
|
548
180
|
function createFileSystemError(message, code, context) {
|
|
549
181
|
const error = createError(message);
|
|
@@ -561,7 +193,7 @@ function createFileSystemError(message, code, context) {
|
|
|
561
193
|
* @returns File contents as string
|
|
562
194
|
* @throws {Error} If file doesn't exist or can't be read
|
|
563
195
|
*
|
|
564
|
-
* @example
|
|
196
|
+
* @example Reading file contents
|
|
565
197
|
* ```typescript
|
|
566
198
|
* import { readFileContent } from '@hyperfrontend/project-scope'
|
|
567
199
|
*
|
|
@@ -570,6 +202,9 @@ function createFileSystemError(message, code, context) {
|
|
|
570
202
|
* ```
|
|
571
203
|
*/
|
|
572
204
|
function readFileContent(filePath, encoding = 'utf-8') {
|
|
205
|
+
if (!isSafePath(filePath)) {
|
|
206
|
+
throw createFileSystemError(`Unsafe file path: ${filePath}`, 'FS_READ_ERROR', { path: filePath, operation: 'read' });
|
|
207
|
+
}
|
|
573
208
|
if (!existsSync(filePath)) {
|
|
574
209
|
fsLogger.debug('File not found', { path: filePath });
|
|
575
210
|
throw createFileSystemError(`File not found: ${filePath}`, 'FS_NOT_FOUND', { path: filePath, operation: 'read' });
|
|
@@ -588,9 +223,17 @@ function readFileContent(filePath, encoding = 'utf-8') {
|
|
|
588
223
|
* @param filePath - Path to file
|
|
589
224
|
* @param encoding - File encoding (default: utf-8)
|
|
590
225
|
* @returns File contents or null if file doesn't exist
|
|
226
|
+
*
|
|
227
|
+
* @example Reading file if it exists
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const content = readFileIfExists('./optional-config.json')
|
|
230
|
+
* if (content) {
|
|
231
|
+
* // File existed, use content
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
591
234
|
*/
|
|
592
235
|
function readFileIfExists(filePath, encoding = 'utf-8') {
|
|
593
|
-
if (!existsSync(filePath)) {
|
|
236
|
+
if (!isSafePath(filePath) || !existsSync(filePath)) {
|
|
594
237
|
return null;
|
|
595
238
|
}
|
|
596
239
|
try {
|
|
@@ -601,56 +244,6 @@ function readFileIfExists(filePath, encoding = 'utf-8') {
|
|
|
601
244
|
}
|
|
602
245
|
}
|
|
603
246
|
|
|
604
|
-
createScopedLogger('project-scope:fs:write');
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* Get file stats with error handling.
|
|
608
|
-
*
|
|
609
|
-
* @param filePath - Path to file
|
|
610
|
-
* @param followSymlinks - Whether to follow symlinks (default: true)
|
|
611
|
-
* @returns File stats or null if path doesn't exist
|
|
612
|
-
*/
|
|
613
|
-
function getFileStat(filePath, followSymlinks = true) {
|
|
614
|
-
if (!existsSync(filePath)) {
|
|
615
|
-
return null;
|
|
616
|
-
}
|
|
617
|
-
try {
|
|
618
|
-
const stat = followSymlinks ? statSync(filePath) : lstatSync(filePath);
|
|
619
|
-
return {
|
|
620
|
-
isFile: stat.isFile(),
|
|
621
|
-
isDirectory: stat.isDirectory(),
|
|
622
|
-
isSymlink: stat.isSymbolicLink(),
|
|
623
|
-
size: stat.size,
|
|
624
|
-
created: stat.birthtime,
|
|
625
|
-
modified: stat.mtime,
|
|
626
|
-
accessed: stat.atime,
|
|
627
|
-
mode: stat.mode,
|
|
628
|
-
};
|
|
629
|
-
}
|
|
630
|
-
catch {
|
|
631
|
-
return null;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
/**
|
|
635
|
-
* Check if path is a directory.
|
|
636
|
-
*
|
|
637
|
-
* @param dirPath - Path to check
|
|
638
|
-
* @returns True if path is a directory
|
|
639
|
-
*/
|
|
640
|
-
function isDirectory(dirPath) {
|
|
641
|
-
const stats = getFileStat(dirPath);
|
|
642
|
-
return stats?.isDirectory ?? false;
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Check if path exists.
|
|
646
|
-
*
|
|
647
|
-
* @param filePath - Path to check
|
|
648
|
-
* @returns True if path exists
|
|
649
|
-
*/
|
|
650
|
-
function exists(filePath) {
|
|
651
|
-
return existsSync(filePath);
|
|
652
|
-
}
|
|
653
|
-
|
|
654
247
|
const fsDirLogger = createScopedLogger('project-scope:fs:dir');
|
|
655
248
|
/**
|
|
656
249
|
* List immediate contents of a directory.
|
|
@@ -659,7 +252,7 @@ const fsDirLogger = createScopedLogger('project-scope:fs:dir');
|
|
|
659
252
|
* @returns Array of entries with metadata for each file/directory
|
|
660
253
|
* @throws {Error} If directory doesn't exist or isn't a directory
|
|
661
254
|
*
|
|
662
|
-
* @example
|
|
255
|
+
* @example Listing directory contents
|
|
663
256
|
* ```typescript
|
|
664
257
|
* import { readDirectory } from '@hyperfrontend/project-scope'
|
|
665
258
|
*
|
|
@@ -700,17 +293,6 @@ function readDirectory(dirPath) {
|
|
|
700
293
|
}
|
|
701
294
|
}
|
|
702
295
|
|
|
703
|
-
/**
|
|
704
|
-
* Join path segments.
|
|
705
|
-
* Uses platform-specific separators (e.g., / or \).
|
|
706
|
-
*
|
|
707
|
-
* @param paths - Path segments to join
|
|
708
|
-
* @returns Joined path
|
|
709
|
-
*/
|
|
710
|
-
function join(...paths) {
|
|
711
|
-
return join$1(...paths);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
296
|
const fsTraversalLogger = createScopedLogger('project-scope:fs:traversal');
|
|
715
297
|
/**
|
|
716
298
|
* Generic upward directory traversal.
|
|
@@ -719,11 +301,20 @@ const fsTraversalLogger = createScopedLogger('project-scope:fs:traversal');
|
|
|
719
301
|
* @param startPath - Starting directory
|
|
720
302
|
* @param predicate - Function to test each directory
|
|
721
303
|
* @returns First matching directory or null
|
|
304
|
+
*
|
|
305
|
+
* @example Finding directory containing README
|
|
306
|
+
* ```typescript
|
|
307
|
+
* // Find first directory containing a README
|
|
308
|
+
* const readmeDir = traverseUpward('./src/utils', (dir) =>
|
|
309
|
+
* existsSync(join(dir, 'README.md'))
|
|
310
|
+
* )
|
|
311
|
+
* // => '/project' or null
|
|
312
|
+
* ```
|
|
722
313
|
*/
|
|
723
314
|
function traverseUpward(startPath, predicate) {
|
|
724
315
|
fsTraversalLogger.debug('Starting upward traversal', { startPath });
|
|
725
316
|
let currentPath = resolve(startPath);
|
|
726
|
-
const rootPath = parse
|
|
317
|
+
const rootPath = parse(currentPath).root;
|
|
727
318
|
while (currentPath !== rootPath) {
|
|
728
319
|
if (predicate(currentPath)) {
|
|
729
320
|
fsTraversalLogger.debug('Upward traversal found match', { startPath, foundPath: currentPath });
|
|
@@ -744,6 +335,17 @@ function traverseUpward(startPath, predicate) {
|
|
|
744
335
|
* @param startPath - Starting directory
|
|
745
336
|
* @param markers - Array of marker file names to search for
|
|
746
337
|
* @returns First directory containing any marker, or null
|
|
338
|
+
*
|
|
339
|
+
* @example Finding project root by marker files
|
|
340
|
+
* ```typescript
|
|
341
|
+
* // Find project root by looking for common marker files
|
|
342
|
+
* const projectRoot = locateByMarkers('./src/components', [
|
|
343
|
+
* 'package.json',
|
|
344
|
+
* 'nx.json',
|
|
345
|
+
* 'tsconfig.base.json'
|
|
346
|
+
* ])
|
|
347
|
+
* // => '/workspace/my-project'
|
|
348
|
+
* ```
|
|
747
349
|
*/
|
|
748
350
|
function locateByMarkers(startPath, markers) {
|
|
749
351
|
fsTraversalLogger.debug('Locating by markers', { startPath, markers });
|
|
@@ -759,203 +361,21 @@ function locateByMarkers(startPath, markers) {
|
|
|
759
361
|
* @param startPath - Starting directory
|
|
760
362
|
* @param test - Function to test if directory matches criteria
|
|
761
363
|
* @returns Matching directory path or null
|
|
364
|
+
*
|
|
365
|
+
* @example Finding directory with specific config
|
|
366
|
+
* ```typescript
|
|
367
|
+
* // Find directory with a specific config
|
|
368
|
+
* const configDir = findUpwardWhere('./deep/nested/path', (dir) =>
|
|
369
|
+
* existsSync(join(dir, '.eslintrc.js'))
|
|
370
|
+
* )
|
|
371
|
+
* ```
|
|
762
372
|
*/
|
|
763
373
|
function findUpwardWhere(startPath, test) {
|
|
764
374
|
fsTraversalLogger.debug('Finding upward where condition met', { startPath });
|
|
765
375
|
return traverseUpward(startPath, test);
|
|
766
376
|
}
|
|
767
377
|
|
|
768
|
-
|
|
769
|
-
* Match path against glob pattern using safe character iteration.
|
|
770
|
-
* Avoids regex to prevent ReDoS attacks.
|
|
771
|
-
*
|
|
772
|
-
* Supported patterns:
|
|
773
|
-
* - * matches any characters except /
|
|
774
|
-
* - ** matches any characters including /
|
|
775
|
-
* - ? matches exactly one character except /
|
|
776
|
-
* - {a,b,c} matches any of the alternatives
|
|
777
|
-
*
|
|
778
|
-
* @param path - The filesystem path to test against the pattern
|
|
779
|
-
* @param pattern - The glob pattern to match against
|
|
780
|
-
* @returns True if path matches pattern
|
|
781
|
-
*
|
|
782
|
-
* @example
|
|
783
|
-
* ```typescript
|
|
784
|
-
* import { matchGlobPattern } from '@hyperfrontend/project-scope'
|
|
785
|
-
*
|
|
786
|
-
* matchGlobPattern('src/utils/helper.ts', '\*\*\/*.ts') // true
|
|
787
|
-
* matchGlobPattern('test.spec.ts', '\*.spec.ts') // true
|
|
788
|
-
* matchGlobPattern('config.json', '\*.{json,yaml}') // true
|
|
789
|
-
* matchGlobPattern('src/index.ts', 'src/\*.ts') // true
|
|
790
|
-
* ```
|
|
791
|
-
*/
|
|
792
|
-
function matchGlobPattern(path, pattern) {
|
|
793
|
-
return matchSegments(path.split('/'), pattern.split('/'), 0, 0);
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* Internal recursive function to match path segments against pattern segments.
|
|
797
|
-
*
|
|
798
|
-
* @param pathParts - Array of path segments split by '/'
|
|
799
|
-
* @param patternParts - Array of pattern segments split by '/'
|
|
800
|
-
* @param pathIdx - Current index in pathParts being examined
|
|
801
|
-
* @param patternIdx - Current index in patternParts being examined
|
|
802
|
-
* @returns True if remaining segments match
|
|
803
|
-
*/
|
|
804
|
-
function matchSegments(pathParts, patternParts, pathIdx, patternIdx) {
|
|
805
|
-
if (pathIdx === pathParts.length && patternIdx === patternParts.length) {
|
|
806
|
-
return true;
|
|
807
|
-
}
|
|
808
|
-
if (patternIdx >= patternParts.length) {
|
|
809
|
-
return false;
|
|
810
|
-
}
|
|
811
|
-
const patternPart = patternParts[patternIdx];
|
|
812
|
-
if (patternPart === '**') {
|
|
813
|
-
for (let i = pathIdx; i <= pathParts.length; i++) {
|
|
814
|
-
if (matchSegments(pathParts, patternParts, i, patternIdx + 1)) {
|
|
815
|
-
return true;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
return false;
|
|
819
|
-
}
|
|
820
|
-
if (pathIdx >= pathParts.length) {
|
|
821
|
-
return false;
|
|
822
|
-
}
|
|
823
|
-
const pathPart = pathParts[pathIdx];
|
|
824
|
-
if (matchSegment(pathPart, patternPart)) {
|
|
825
|
-
return matchSegments(pathParts, patternParts, pathIdx + 1, patternIdx + 1);
|
|
826
|
-
}
|
|
827
|
-
return false;
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* Match a single path segment against a pattern segment.
|
|
831
|
-
* Handles *, ?, and {a,b,c} patterns.
|
|
832
|
-
*
|
|
833
|
-
* @param text - The path segment text to match
|
|
834
|
-
* @param pattern - The pattern segment to match against
|
|
835
|
-
* @returns True if the text matches the pattern
|
|
836
|
-
*/
|
|
837
|
-
function matchSegment(text, pattern) {
|
|
838
|
-
let textIdx = 0;
|
|
839
|
-
let patternIdx = 0;
|
|
840
|
-
while (patternIdx < pattern.length) {
|
|
841
|
-
const char = pattern[patternIdx];
|
|
842
|
-
if (char === '*') {
|
|
843
|
-
patternIdx++;
|
|
844
|
-
if (patternIdx === pattern.length) {
|
|
845
|
-
return true;
|
|
846
|
-
}
|
|
847
|
-
for (let i = textIdx; i <= text.length; i++) {
|
|
848
|
-
if (matchSegmentFrom(text, i, pattern, patternIdx)) {
|
|
849
|
-
return true;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
return false;
|
|
853
|
-
}
|
|
854
|
-
else if (char === '?') {
|
|
855
|
-
if (textIdx >= text.length) {
|
|
856
|
-
return false;
|
|
857
|
-
}
|
|
858
|
-
textIdx++;
|
|
859
|
-
patternIdx++;
|
|
860
|
-
}
|
|
861
|
-
else if (char === '{') {
|
|
862
|
-
const closeIdx = findClosingBrace(pattern, patternIdx);
|
|
863
|
-
if (closeIdx === -1) {
|
|
864
|
-
if (textIdx >= text.length || text[textIdx] !== char) {
|
|
865
|
-
return false;
|
|
866
|
-
}
|
|
867
|
-
textIdx++;
|
|
868
|
-
patternIdx++;
|
|
869
|
-
}
|
|
870
|
-
else {
|
|
871
|
-
const alternatives = extractAlternatives(pattern.slice(patternIdx + 1, closeIdx));
|
|
872
|
-
for (const alt of alternatives) {
|
|
873
|
-
if (matchSegmentFrom(text, textIdx, text.slice(0, textIdx) + alt + pattern.slice(closeIdx + 1), textIdx)) {
|
|
874
|
-
return true;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
else {
|
|
881
|
-
if (textIdx >= text.length || text[textIdx] !== char) {
|
|
882
|
-
return false;
|
|
883
|
-
}
|
|
884
|
-
textIdx++;
|
|
885
|
-
patternIdx++;
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
return textIdx === text.length;
|
|
889
|
-
}
|
|
890
|
-
/**
|
|
891
|
-
* Helper to match from a specific position.
|
|
892
|
-
*
|
|
893
|
-
* @param text - The full text being matched
|
|
894
|
-
* @param textIdx - The starting index in text to match from
|
|
895
|
-
* @param pattern - The full pattern being matched
|
|
896
|
-
* @param patternIdx - The starting index in pattern to match from
|
|
897
|
-
* @returns True if the text matches the pattern from the given positions
|
|
898
|
-
*/
|
|
899
|
-
function matchSegmentFrom(text, textIdx, pattern, patternIdx) {
|
|
900
|
-
const remainingText = text.slice(textIdx);
|
|
901
|
-
const remainingPattern = pattern.slice(patternIdx);
|
|
902
|
-
return matchSegment(remainingText, remainingPattern);
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Find closing brace for {a,b,c} pattern.
|
|
906
|
-
*
|
|
907
|
-
* @param pattern - The pattern string to search within
|
|
908
|
-
* @param startIdx - The index of the opening brace
|
|
909
|
-
* @returns The index of the matching closing brace, or -1 if not found
|
|
910
|
-
*/
|
|
911
|
-
function findClosingBrace(pattern, startIdx) {
|
|
912
|
-
let depth = 0;
|
|
913
|
-
for (let i = startIdx; i < pattern.length; i++) {
|
|
914
|
-
if (pattern[i] === '{') {
|
|
915
|
-
depth++;
|
|
916
|
-
}
|
|
917
|
-
else if (pattern[i] === '}') {
|
|
918
|
-
depth--;
|
|
919
|
-
if (depth === 0) {
|
|
920
|
-
return i;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
return -1;
|
|
925
|
-
}
|
|
926
|
-
/**
|
|
927
|
-
* Extract alternatives from {a,b,c} pattern content.
|
|
928
|
-
*
|
|
929
|
-
* @param content - The content between braces (without the braces themselves)
|
|
930
|
-
* @returns Array of alternative strings split by commas at depth 0
|
|
931
|
-
*/
|
|
932
|
-
function extractAlternatives(content) {
|
|
933
|
-
const alternatives = [];
|
|
934
|
-
let current = '';
|
|
935
|
-
let depth = 0;
|
|
936
|
-
for (let i = 0; i < content.length; i++) {
|
|
937
|
-
const char = content[i];
|
|
938
|
-
if (char === '{') {
|
|
939
|
-
depth++;
|
|
940
|
-
current += char;
|
|
941
|
-
}
|
|
942
|
-
else if (char === '}') {
|
|
943
|
-
depth--;
|
|
944
|
-
current += char;
|
|
945
|
-
}
|
|
946
|
-
else if (char === ',' && depth === 0) {
|
|
947
|
-
alternatives.push(current);
|
|
948
|
-
current = '';
|
|
949
|
-
}
|
|
950
|
-
else {
|
|
951
|
-
current += char;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
if (current) {
|
|
955
|
-
alternatives.push(current);
|
|
956
|
-
}
|
|
957
|
-
return alternatives;
|
|
958
|
-
}
|
|
378
|
+
createScopedLogger('project-scope:fs:write');
|
|
959
379
|
|
|
960
380
|
const walkLogger = createScopedLogger('project-scope:project:walk');
|
|
961
381
|
/**
|
|
@@ -1022,6 +442,18 @@ function matchPattern(path, pattern) {
|
|
|
1022
442
|
* @param startPath - Root directory to begin traversal
|
|
1023
443
|
* @param visitor - Callback function invoked for each file system entry
|
|
1024
444
|
* @param options - Configuration for traversal behavior
|
|
445
|
+
*
|
|
446
|
+
* @example Walking a directory tree
|
|
447
|
+
* ```typescript
|
|
448
|
+
* import { walkDirectory } from '@hyperfrontend/project-scope'
|
|
449
|
+
*
|
|
450
|
+
* const tsFiles: string[] = []
|
|
451
|
+
* walkDirectory('./src', (entry) => {
|
|
452
|
+
* if (entry.isFile && entry.name.endsWith('.ts')) {
|
|
453
|
+
* tsFiles.push(entry.relativePath)
|
|
454
|
+
* }
|
|
455
|
+
* }, { maxDepth: 5, respectGitignore: true })
|
|
456
|
+
* ```
|
|
1025
457
|
*/
|
|
1026
458
|
function walkDirectory(startPath, visitor, options) {
|
|
1027
459
|
walkLogger.debug('Starting directory walk', {
|
|
@@ -1104,6 +536,19 @@ function walkDirectory(startPath, visitor, options) {
|
|
|
1104
536
|
* @param startPath - Root path within the tree to begin traversal
|
|
1105
537
|
* @param visitor - Callback function invoked for each tree entry
|
|
1106
538
|
* @param options - Configuration for traversal behavior
|
|
539
|
+
*
|
|
540
|
+
* @example Walking a virtual tree
|
|
541
|
+
* ```typescript
|
|
542
|
+
* import { createTree, walkTree } from '@hyperfrontend/project-scope'
|
|
543
|
+
*
|
|
544
|
+
* const tree = createTree('/workspace')
|
|
545
|
+
* walkTree(tree, 'src', (entry) => {
|
|
546
|
+
* if (entry.isDirectory) {
|
|
547
|
+
* console.log('Dir:', entry.relativePath)
|
|
548
|
+
* return 'skip' // Don't recurse into this directory
|
|
549
|
+
* }
|
|
550
|
+
* })
|
|
551
|
+
* ```
|
|
1107
552
|
*/
|
|
1108
553
|
function walkTree(tree, startPath, visitor, options) {
|
|
1109
554
|
const maxDepth = options?.maxDepth ?? -1;
|
|
@@ -1184,7 +629,7 @@ function matchesPatterns(path, patterns) {
|
|
|
1184
629
|
* @param options - Configuration for search behavior
|
|
1185
630
|
* @returns List of relative file paths that match the patterns
|
|
1186
631
|
*
|
|
1187
|
-
* @example
|
|
632
|
+
* @example Finding files by pattern
|
|
1188
633
|
* ```typescript
|
|
1189
634
|
* import { findFiles } from '@hyperfrontend/project-scope'
|
|
1190
635
|
*
|
|
@@ -1229,6 +674,15 @@ function findFiles(startPath, patterns, options) {
|
|
|
1229
674
|
* @param patterns - Glob patterns (e.g., '*.ts', '**\/*.json') to filter files
|
|
1230
675
|
* @param options - Configuration for search behavior
|
|
1231
676
|
* @returns List of virtual file paths that match the patterns
|
|
677
|
+
*
|
|
678
|
+
* @example Finding files in a virtual tree
|
|
679
|
+
* ```typescript
|
|
680
|
+
* import { createTree, findFilesInTree } from '@hyperfrontend/project-scope'
|
|
681
|
+
*
|
|
682
|
+
* const tree = createTree('/workspace')
|
|
683
|
+
* const tsFiles = findFilesInTree(tree, '**\/*.ts', { maxDepth: 3 })
|
|
684
|
+
* // => ['src/index.ts', 'src/utils/helpers.ts']
|
|
685
|
+
* ```
|
|
1232
686
|
*/
|
|
1233
687
|
function findFilesInTree(tree, patterns, options) {
|
|
1234
688
|
const normalizedPatterns = isArray(patterns) ? patterns : [patterns];
|
|
@@ -1256,6 +710,14 @@ function findFilesInTree(tree, patterns, options) {
|
|
|
1256
710
|
* @param patterns - Glob patterns to filter directories (supports wildcards)
|
|
1257
711
|
* @param options - Configuration for search behavior
|
|
1258
712
|
* @returns List of relative directory paths that match the patterns
|
|
713
|
+
*
|
|
714
|
+
* @example Finding directories by pattern
|
|
715
|
+
* ```typescript
|
|
716
|
+
* import { findDirectories } from '@hyperfrontend/project-scope'
|
|
717
|
+
*
|
|
718
|
+
* const componentDirs = findDirectories('./src', 'components')
|
|
719
|
+
* // => ['features/auth/components', 'features/dashboard/components']
|
|
720
|
+
* ```
|
|
1259
721
|
*/
|
|
1260
722
|
function findDirectories(startPath, patterns, options) {
|
|
1261
723
|
const normalizedPatterns = isArray(patterns) ? patterns : [patterns];
|
|
@@ -1276,311 +738,6 @@ function findDirectories(startPath, patterns, options) {
|
|
|
1276
738
|
return results;
|
|
1277
739
|
}
|
|
1278
740
|
|
|
1279
|
-
/**
|
|
1280
|
-
* Known configuration file patterns organized by type.
|
|
1281
|
-
*/
|
|
1282
|
-
const CONFIG_PATTERNS = {
|
|
1283
|
-
'package.json': {
|
|
1284
|
-
patterns: ['package.json'],
|
|
1285
|
-
format: 'json',
|
|
1286
|
-
description: 'NPM package manifest',
|
|
1287
|
-
},
|
|
1288
|
-
'package-lock.json': {
|
|
1289
|
-
patterns: ['package-lock.json'],
|
|
1290
|
-
format: 'json',
|
|
1291
|
-
description: 'NPM lockfile',
|
|
1292
|
-
},
|
|
1293
|
-
'pnpm-lock.yaml': {
|
|
1294
|
-
patterns: ['pnpm-lock.yaml'],
|
|
1295
|
-
format: 'yaml',
|
|
1296
|
-
description: 'PNPM lockfile',
|
|
1297
|
-
},
|
|
1298
|
-
'yarn.lock': {
|
|
1299
|
-
patterns: ['yarn.lock'],
|
|
1300
|
-
format: 'text',
|
|
1301
|
-
description: 'Yarn lockfile',
|
|
1302
|
-
},
|
|
1303
|
-
'.npmrc': {
|
|
1304
|
-
patterns: ['.npmrc'],
|
|
1305
|
-
format: 'ini',
|
|
1306
|
-
description: 'NPM configuration',
|
|
1307
|
-
sensitive: true,
|
|
1308
|
-
},
|
|
1309
|
-
tsconfig: {
|
|
1310
|
-
patterns: ['tsconfig.json', 'tsconfig.*.json'],
|
|
1311
|
-
format: 'jsonc',
|
|
1312
|
-
description: 'TypeScript configuration',
|
|
1313
|
-
canExtend: true,
|
|
1314
|
-
},
|
|
1315
|
-
nx: {
|
|
1316
|
-
patterns: ['nx.json'],
|
|
1317
|
-
format: 'json',
|
|
1318
|
-
description: 'NX workspace configuration',
|
|
1319
|
-
},
|
|
1320
|
-
'project.json': {
|
|
1321
|
-
patterns: ['project.json', '**/project.json'],
|
|
1322
|
-
format: 'json',
|
|
1323
|
-
description: 'NX project configuration',
|
|
1324
|
-
},
|
|
1325
|
-
'workspace.json': {
|
|
1326
|
-
patterns: ['workspace.json'],
|
|
1327
|
-
format: 'json',
|
|
1328
|
-
description: 'NX workspace projects (deprecated)',
|
|
1329
|
-
},
|
|
1330
|
-
turbo: {
|
|
1331
|
-
patterns: ['turbo.json'],
|
|
1332
|
-
format: 'jsonc',
|
|
1333
|
-
description: 'TurboRepo configuration',
|
|
1334
|
-
},
|
|
1335
|
-
lerna: {
|
|
1336
|
-
patterns: ['lerna.json'],
|
|
1337
|
-
format: 'json',
|
|
1338
|
-
description: 'Lerna configuration',
|
|
1339
|
-
},
|
|
1340
|
-
webpack: {
|
|
1341
|
-
patterns: ['webpack.config.js', 'webpack.config.ts', 'webpack.config.cjs', 'webpack.config.mjs'],
|
|
1342
|
-
format: 'js',
|
|
1343
|
-
description: 'Webpack configuration',
|
|
1344
|
-
},
|
|
1345
|
-
rollup: {
|
|
1346
|
-
patterns: ['rollup.config.js', 'rollup.config.ts', 'rollup.config.mjs'],
|
|
1347
|
-
format: 'js',
|
|
1348
|
-
description: 'Rollup configuration',
|
|
1349
|
-
},
|
|
1350
|
-
vite: {
|
|
1351
|
-
patterns: ['vite.config.js', 'vite.config.ts', 'vite.config.mjs'],
|
|
1352
|
-
format: 'js',
|
|
1353
|
-
description: 'Vite configuration',
|
|
1354
|
-
},
|
|
1355
|
-
esbuild: {
|
|
1356
|
-
patterns: ['esbuild.config.js', 'esbuild.config.ts', 'esbuild.config.mjs'],
|
|
1357
|
-
format: 'js',
|
|
1358
|
-
description: 'esbuild configuration',
|
|
1359
|
-
},
|
|
1360
|
-
babel: {
|
|
1361
|
-
patterns: ['babel.config.js', 'babel.config.json', '.babelrc', '.babelrc.js', '.babelrc.json'],
|
|
1362
|
-
format: 'json',
|
|
1363
|
-
description: 'Babel configuration',
|
|
1364
|
-
},
|
|
1365
|
-
swc: {
|
|
1366
|
-
patterns: ['.swcrc'],
|
|
1367
|
-
format: 'json',
|
|
1368
|
-
description: 'SWC configuration',
|
|
1369
|
-
},
|
|
1370
|
-
jest: {
|
|
1371
|
-
patterns: ['jest.config.js', 'jest.config.ts', 'jest.config.mjs'],
|
|
1372
|
-
description: 'Jest configuration',
|
|
1373
|
-
},
|
|
1374
|
-
vitest: {
|
|
1375
|
-
patterns: ['vitest.config.js', 'vitest.config.ts'],
|
|
1376
|
-
description: 'Vitest configuration',
|
|
1377
|
-
},
|
|
1378
|
-
cypress: {
|
|
1379
|
-
patterns: ['cypress.config.js', 'cypress.config.ts'],
|
|
1380
|
-
description: 'Cypress configuration',
|
|
1381
|
-
},
|
|
1382
|
-
playwright: {
|
|
1383
|
-
patterns: ['playwright.config.js', 'playwright.config.ts'],
|
|
1384
|
-
description: 'Playwright configuration',
|
|
1385
|
-
},
|
|
1386
|
-
next: {
|
|
1387
|
-
patterns: ['next.config.js', 'next.config.mjs', 'next.config.ts'],
|
|
1388
|
-
format: 'js',
|
|
1389
|
-
description: 'Next.js configuration',
|
|
1390
|
-
},
|
|
1391
|
-
angular: {
|
|
1392
|
-
patterns: ['angular.json'],
|
|
1393
|
-
format: 'json',
|
|
1394
|
-
description: 'Angular CLI configuration',
|
|
1395
|
-
},
|
|
1396
|
-
nuxt: {
|
|
1397
|
-
patterns: ['nuxt.config.js', 'nuxt.config.ts'],
|
|
1398
|
-
format: 'js',
|
|
1399
|
-
description: 'Nuxt.js configuration',
|
|
1400
|
-
},
|
|
1401
|
-
svelte: {
|
|
1402
|
-
patterns: ['svelte.config.js', 'svelte.config.ts'],
|
|
1403
|
-
format: 'js',
|
|
1404
|
-
description: 'SvelteKit configuration',
|
|
1405
|
-
},
|
|
1406
|
-
astro: {
|
|
1407
|
-
patterns: ['astro.config.js', 'astro.config.ts', 'astro.config.mjs'],
|
|
1408
|
-
format: 'js',
|
|
1409
|
-
description: 'Astro configuration',
|
|
1410
|
-
},
|
|
1411
|
-
eslint: {
|
|
1412
|
-
patterns: [
|
|
1413
|
-
'eslint.config.js',
|
|
1414
|
-
'eslint.config.cjs',
|
|
1415
|
-
'eslint.config.mjs',
|
|
1416
|
-
'.eslintrc',
|
|
1417
|
-
'.eslintrc.js',
|
|
1418
|
-
'.eslintrc.json',
|
|
1419
|
-
'.eslintrc.yml',
|
|
1420
|
-
],
|
|
1421
|
-
format: 'js',
|
|
1422
|
-
description: 'ESLint configuration',
|
|
1423
|
-
},
|
|
1424
|
-
prettier: {
|
|
1425
|
-
patterns: ['prettier.config.js', 'prettier.config.cjs', '.prettierrc', '.prettierrc.js', '.prettierrc.json', '.prettierrc.yml'],
|
|
1426
|
-
format: 'json',
|
|
1427
|
-
description: 'Prettier configuration',
|
|
1428
|
-
},
|
|
1429
|
-
env: {
|
|
1430
|
-
patterns: ['.env', '.env.*', '*.env'],
|
|
1431
|
-
format: 'dotenv',
|
|
1432
|
-
description: 'Environment variables',
|
|
1433
|
-
sensitive: true,
|
|
1434
|
-
},
|
|
1435
|
-
'.gitignore': {
|
|
1436
|
-
patterns: ['.gitignore'],
|
|
1437
|
-
format: 'text',
|
|
1438
|
-
description: 'Git ignore patterns',
|
|
1439
|
-
},
|
|
1440
|
-
'.gitattributes': {
|
|
1441
|
-
patterns: ['.gitattributes'],
|
|
1442
|
-
format: 'text',
|
|
1443
|
-
description: 'Git attributes',
|
|
1444
|
-
},
|
|
1445
|
-
};
|
|
1446
|
-
/**
|
|
1447
|
-
* Get patterns for specific config types.
|
|
1448
|
-
*
|
|
1449
|
-
* @param types - Array of config types to get patterns for
|
|
1450
|
-
* @returns Array of file patterns
|
|
1451
|
-
*/
|
|
1452
|
-
function getConfigPatternsByType(types) {
|
|
1453
|
-
return types.flatMap((type) => CONFIG_PATTERNS[type]?.patterns ?? []);
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
/**
|
|
1457
|
-
* Global registry of all caches for bulk operations.
|
|
1458
|
-
*/
|
|
1459
|
-
const cacheRegistry = createSet();
|
|
1460
|
-
/**
|
|
1461
|
-
* Create a cache with optional TTL and size limits.
|
|
1462
|
-
*
|
|
1463
|
-
* The cache provides a simple key-value store with:
|
|
1464
|
-
* - Optional TTL (time-to-live) for automatic expiration
|
|
1465
|
-
* - Optional maxSize for limiting cache size with FIFO eviction
|
|
1466
|
-
* - Lazy expiration (entries are checked on access)
|
|
1467
|
-
*
|
|
1468
|
-
* @param options - Cache configuration options
|
|
1469
|
-
* @returns Cache instance
|
|
1470
|
-
*
|
|
1471
|
-
* @example
|
|
1472
|
-
* ```typescript
|
|
1473
|
-
* // Basic cache
|
|
1474
|
-
* const cache = createCache<string, number>()
|
|
1475
|
-
* cache.set('answer', 42)
|
|
1476
|
-
* cache.get('answer') // 42
|
|
1477
|
-
*
|
|
1478
|
-
* // Cache with TTL (expires after 60 seconds)
|
|
1479
|
-
* const ttlCache = createCache<string, object>({ ttl: 60000 })
|
|
1480
|
-
*
|
|
1481
|
-
* // Cache with max size (evicts oldest when full)
|
|
1482
|
-
* const lruCache = createCache<string, object>({ maxSize: 100 })
|
|
1483
|
-
*
|
|
1484
|
-
* // Combined options
|
|
1485
|
-
* const configCache = createCache<string, object>({
|
|
1486
|
-
* ttl: 30000,
|
|
1487
|
-
* maxSize: 50
|
|
1488
|
-
* })
|
|
1489
|
-
* ```
|
|
1490
|
-
*/
|
|
1491
|
-
function createCache(options) {
|
|
1492
|
-
const { ttl, maxSize } = options ?? {};
|
|
1493
|
-
const store = createMap();
|
|
1494
|
-
const insertionOrder = [];
|
|
1495
|
-
/**
|
|
1496
|
-
* Check if an entry is expired.
|
|
1497
|
-
*
|
|
1498
|
-
* @param entry - Cache entry to check
|
|
1499
|
-
* @returns True if entry is expired
|
|
1500
|
-
*/
|
|
1501
|
-
function isExpired(entry) {
|
|
1502
|
-
if (ttl === undefined)
|
|
1503
|
-
return false;
|
|
1504
|
-
// eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
|
|
1505
|
-
return Date.now() - entry.timestamp > ttl;
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Evict oldest entries to make room for new ones.
|
|
1509
|
-
*/
|
|
1510
|
-
function evictIfNeeded() {
|
|
1511
|
-
if (maxSize === undefined)
|
|
1512
|
-
return;
|
|
1513
|
-
while (store.size >= maxSize && insertionOrder.length > 0) {
|
|
1514
|
-
const oldestKey = insertionOrder.shift();
|
|
1515
|
-
if (oldestKey !== undefined) {
|
|
1516
|
-
store.delete(oldestKey);
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
/**
|
|
1521
|
-
* Remove key from insertion order tracking.
|
|
1522
|
-
*
|
|
1523
|
-
* @param key - Key to remove from order tracking
|
|
1524
|
-
*/
|
|
1525
|
-
function removeFromOrder(key) {
|
|
1526
|
-
const index = insertionOrder.indexOf(key);
|
|
1527
|
-
if (index !== -1) {
|
|
1528
|
-
insertionOrder.splice(index, 1);
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
const cache = {
|
|
1532
|
-
get(key) {
|
|
1533
|
-
const entry = store.get(key);
|
|
1534
|
-
if (!entry)
|
|
1535
|
-
return undefined;
|
|
1536
|
-
if (isExpired(entry)) {
|
|
1537
|
-
store.delete(key);
|
|
1538
|
-
removeFromOrder(key);
|
|
1539
|
-
return undefined;
|
|
1540
|
-
}
|
|
1541
|
-
return entry.value;
|
|
1542
|
-
},
|
|
1543
|
-
set(key, value) {
|
|
1544
|
-
if (store.has(key)) {
|
|
1545
|
-
removeFromOrder(key);
|
|
1546
|
-
}
|
|
1547
|
-
else {
|
|
1548
|
-
evictIfNeeded();
|
|
1549
|
-
}
|
|
1550
|
-
// eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
|
|
1551
|
-
store.set(key, { value, timestamp: Date.now() });
|
|
1552
|
-
insertionOrder.push(key);
|
|
1553
|
-
},
|
|
1554
|
-
has(key) {
|
|
1555
|
-
const entry = store.get(key);
|
|
1556
|
-
if (!entry)
|
|
1557
|
-
return false;
|
|
1558
|
-
if (isExpired(entry)) {
|
|
1559
|
-
store.delete(key);
|
|
1560
|
-
removeFromOrder(key);
|
|
1561
|
-
return false;
|
|
1562
|
-
}
|
|
1563
|
-
return true;
|
|
1564
|
-
},
|
|
1565
|
-
delete(key) {
|
|
1566
|
-
removeFromOrder(key);
|
|
1567
|
-
return store.delete(key);
|
|
1568
|
-
},
|
|
1569
|
-
clear() {
|
|
1570
|
-
store.clear();
|
|
1571
|
-
insertionOrder.length = 0;
|
|
1572
|
-
},
|
|
1573
|
-
size() {
|
|
1574
|
-
return store.size;
|
|
1575
|
-
},
|
|
1576
|
-
keys() {
|
|
1577
|
-
return [...insertionOrder];
|
|
1578
|
-
},
|
|
1579
|
-
};
|
|
1580
|
-
cacheRegistry.add(cache);
|
|
1581
|
-
return freeze(cache);
|
|
1582
|
-
}
|
|
1583
|
-
|
|
1584
741
|
const configLogger = createScopedLogger('project-scope:config');
|
|
1585
742
|
/**
|
|
1586
743
|
* Cache for config detection results.
|
|
@@ -1598,7 +755,7 @@ const configDetectionCache = createCache({ ttl: 30000, maxSize: 50 });
|
|
|
1598
755
|
* @param options - Detection options
|
|
1599
756
|
* @returns Array of detected configuration files
|
|
1600
757
|
*
|
|
1601
|
-
* @example
|
|
758
|
+
* @example Detecting configuration files
|
|
1602
759
|
* ```typescript
|
|
1603
760
|
* import { detectConfigs } from '@hyperfrontend/project-scope'
|
|
1604
761
|
*
|
|
@@ -1678,6 +835,14 @@ function detectConfigs(rootPath, types, options) {
|
|
|
1678
835
|
* Clear the config detection cache.
|
|
1679
836
|
*
|
|
1680
837
|
* Useful for testing or when the project files have changed.
|
|
838
|
+
*
|
|
839
|
+
* @example Clearing the config detection cache
|
|
840
|
+
* ```typescript
|
|
841
|
+
* import { clearConfigDetectionCache } from '@hyperfrontend/project-scope'
|
|
842
|
+
*
|
|
843
|
+
* // Reset cache after modifying config files
|
|
844
|
+
* clearConfigDetectionCache()
|
|
845
|
+
* ```
|
|
1681
846
|
*/
|
|
1682
847
|
function clearConfigDetectionCache() {
|
|
1683
848
|
configDetectionCache.clear();
|
|
@@ -1688,6 +853,17 @@ function clearConfigDetectionCache() {
|
|
|
1688
853
|
* @param rootPath - Project root directory
|
|
1689
854
|
* @param type - Config type to find
|
|
1690
855
|
* @returns Full path to config file or null if not found
|
|
856
|
+
*
|
|
857
|
+
* @example Finding a specific config file
|
|
858
|
+
* ```typescript
|
|
859
|
+
* import { findConfigFile } from '@hyperfrontend/project-scope'
|
|
860
|
+
*
|
|
861
|
+
* const tsConfig = findConfigFile('/project', 'typescript')
|
|
862
|
+
* // => '/project/tsconfig.json'
|
|
863
|
+
*
|
|
864
|
+
* const eslint = findConfigFile('/project', 'eslint')
|
|
865
|
+
* // => '/project/.eslintrc.js' or null if not found
|
|
866
|
+
* ```
|
|
1691
867
|
*/
|
|
1692
868
|
function findConfigFile(rootPath, type) {
|
|
1693
869
|
const info = CONFIG_PATTERNS[type];
|
|
@@ -1711,72 +887,6 @@ function findConfigFile(rootPath, type) {
|
|
|
1711
887
|
}
|
|
1712
888
|
return null;
|
|
1713
889
|
}
|
|
1714
|
-
/**
|
|
1715
|
-
* Get all known config file patterns for a given configuration type.
|
|
1716
|
-
*
|
|
1717
|
-
* @param type - Configuration type identifier
|
|
1718
|
-
* @returns Array of glob patterns for matching config files
|
|
1719
|
-
*/
|
|
1720
|
-
function getConfigPaths(type) {
|
|
1721
|
-
const info = CONFIG_PATTERNS[type];
|
|
1722
|
-
return info?.patterns ?? [];
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
/**
|
|
1726
|
-
* Safe copies of Number built-in methods and constants.
|
|
1727
|
-
*
|
|
1728
|
-
* These references are captured at module initialization time to protect against
|
|
1729
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
1730
|
-
*
|
|
1731
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/number
|
|
1732
|
-
*/
|
|
1733
|
-
const _parseInt = globalThis.parseInt;
|
|
1734
|
-
const _parseFloat = globalThis.parseFloat;
|
|
1735
|
-
/**
|
|
1736
|
-
* (Safe copy) Parses a string and returns an integer.
|
|
1737
|
-
*/
|
|
1738
|
-
const parseInt = _parseInt;
|
|
1739
|
-
/**
|
|
1740
|
-
* (Safe copy) Parses a string and returns a floating point number.
|
|
1741
|
-
*/
|
|
1742
|
-
const parseFloat = _parseFloat;
|
|
1743
|
-
|
|
1744
|
-
/**
|
|
1745
|
-
* Create a structured error with code and optional context.
|
|
1746
|
-
*
|
|
1747
|
-
* @param message - The human-readable error message
|
|
1748
|
-
* @param code - The machine-readable error code for programmatic handling
|
|
1749
|
-
* @param context - Additional contextual information about the error
|
|
1750
|
-
* @returns Structured error instance with code and context properties
|
|
1751
|
-
*
|
|
1752
|
-
* @example
|
|
1753
|
-
* ```typescript
|
|
1754
|
-
* import { createStructuredError } from '@hyperfrontend/project-scope'
|
|
1755
|
-
*
|
|
1756
|
-
* throw createStructuredError(
|
|
1757
|
-
* 'Configuration file not found',
|
|
1758
|
-
* 'CONFIG_NOT_FOUND',
|
|
1759
|
-
* { path: './config.json', searched: ['./config.json', './settings.json'] }
|
|
1760
|
-
* )
|
|
1761
|
-
* ```
|
|
1762
|
-
*/
|
|
1763
|
-
function createStructuredError(message, code, context) {
|
|
1764
|
-
const error = createError(message);
|
|
1765
|
-
error.code = code;
|
|
1766
|
-
error.context = context ?? {};
|
|
1767
|
-
return error;
|
|
1768
|
-
}
|
|
1769
|
-
/**
|
|
1770
|
-
* Create a configuration-related error.
|
|
1771
|
-
*
|
|
1772
|
-
* @param message - The human-readable error message
|
|
1773
|
-
* @param code - The machine-readable error code for programmatic handling
|
|
1774
|
-
* @param context - Additional contextual information (e.g., file path, config key)
|
|
1775
|
-
* @returns Structured error instance tagged with type 'config'
|
|
1776
|
-
*/
|
|
1777
|
-
function createConfigError(message, code, context) {
|
|
1778
|
-
return createStructuredError(message, code, { ...context, type: 'config' });
|
|
1779
|
-
}
|
|
1780
890
|
|
|
1781
891
|
/**
|
|
1782
892
|
* Detect config type from file name.
|
|
@@ -1989,11 +1099,23 @@ function parseDotenv(content) {
|
|
|
1989
1099
|
* @param type - Category of configuration (e.g., typescript, eslint)
|
|
1990
1100
|
* @param format - Whether to strip comments (jsonc) or parse strictly (json)
|
|
1991
1101
|
* @returns Configuration object with parsed data and extends references
|
|
1102
|
+
*
|
|
1103
|
+
* @example Parsing JSON configuration
|
|
1104
|
+
* ```typescript
|
|
1105
|
+
* import { parseJsonConfig } from '@hyperfrontend/project-scope'
|
|
1106
|
+
*
|
|
1107
|
+
* const config = parseJsonConfig(
|
|
1108
|
+
* 'tsconfig.json',
|
|
1109
|
+
* '{ "extends": "./base.json", "compilerOptions": {} }',
|
|
1110
|
+
* 'typescript'
|
|
1111
|
+
* )
|
|
1112
|
+
* // => { type: 'typescript', path: 'tsconfig.json', data: {...}, extends: ['./base.json'] }
|
|
1113
|
+
* ```
|
|
1992
1114
|
*/
|
|
1993
1115
|
function parseJsonConfig(filePath, content, type, format = 'json') {
|
|
1994
1116
|
const cleanContent = format === 'jsonc' ? stripJsonComments(content) : content;
|
|
1995
1117
|
try {
|
|
1996
|
-
const data = parse(cleanContent);
|
|
1118
|
+
const data = parse$1(cleanContent);
|
|
1997
1119
|
let extendsPath;
|
|
1998
1120
|
if (typeof data['extends'] === 'string') {
|
|
1999
1121
|
extendsPath = [data['extends']];
|
|
@@ -2024,6 +1146,14 @@ function parseJsonConfig(filePath, content, type, format = 'json') {
|
|
|
2024
1146
|
* @param content - Raw file content to parse
|
|
2025
1147
|
* @param type - Category of configuration (e.g., github-actions, docker-compose)
|
|
2026
1148
|
* @returns Configuration object with parsed YAML data
|
|
1149
|
+
*
|
|
1150
|
+
* @example Parsing YAML configuration
|
|
1151
|
+
* ```typescript
|
|
1152
|
+
* import { parseYamlConfig } from '@hyperfrontend/project-scope'
|
|
1153
|
+
*
|
|
1154
|
+
* const config = parseYamlConfig('.github/workflows/ci.yml', yamlContent, 'github-actions')
|
|
1155
|
+
* // => { type: 'github-actions', path: '...', format: 'yaml', data: {...} }
|
|
1156
|
+
* ```
|
|
2027
1157
|
*/
|
|
2028
1158
|
function parseYamlConfig(filePath, content, type) {
|
|
2029
1159
|
const data = parseSimpleYaml(content);
|
|
@@ -2040,6 +1170,14 @@ function parseYamlConfig(filePath, content, type) {
|
|
|
2040
1170
|
* @param filePath - Path to config file
|
|
2041
1171
|
* @param type - Optional config type (auto-detected if not provided)
|
|
2042
1172
|
* @returns Parsed configuration
|
|
1173
|
+
*
|
|
1174
|
+
* @example Parsing a configuration file
|
|
1175
|
+
* ```typescript
|
|
1176
|
+
* import { parseConfig } from '@hyperfrontend/project-scope'
|
|
1177
|
+
*
|
|
1178
|
+
* const tsConfig = parseConfig('/project/tsconfig.json')
|
|
1179
|
+
* const eslintConfig = parseConfig('/project/.eslintrc.yml', 'eslint')
|
|
1180
|
+
* ```
|
|
2043
1181
|
*/
|
|
2044
1182
|
function parseConfig(filePath, type) {
|
|
2045
1183
|
const content = readFileContent(filePath);
|
|
@@ -2084,33 +1222,6 @@ function parseConfig(filePath, type) {
|
|
|
2084
1222
|
};
|
|
2085
1223
|
}
|
|
2086
1224
|
}
|
|
2087
|
-
/**
|
|
2088
|
-
* Read and parse config file if it exists.
|
|
2089
|
-
*
|
|
2090
|
-
* @param configPath - Path to config file
|
|
2091
|
-
* @returns Parsed config or null if file doesn't exist
|
|
2092
|
-
*/
|
|
2093
|
-
function readConfigIfExists(configPath) {
|
|
2094
|
-
const content = readFileIfExists(configPath);
|
|
2095
|
-
if (!content)
|
|
2096
|
-
return null;
|
|
2097
|
-
try {
|
|
2098
|
-
const format = detectFormat(configPath);
|
|
2099
|
-
switch (format) {
|
|
2100
|
-
case 'json':
|
|
2101
|
-
return parse(content);
|
|
2102
|
-
case 'jsonc':
|
|
2103
|
-
return parse(stripJsonComments(content));
|
|
2104
|
-
case 'yaml':
|
|
2105
|
-
return parseSimpleYaml(content);
|
|
2106
|
-
default:
|
|
2107
|
-
return null;
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
catch {
|
|
2111
|
-
return null;
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
1225
|
|
|
2115
1226
|
const packageLogger = createScopedLogger('project-scope:project:package');
|
|
2116
1227
|
/**
|
|
@@ -2182,13 +1293,21 @@ function validatePackageJson(data) {
|
|
|
2182
1293
|
* @param projectPath - Project directory path or path to package.json
|
|
2183
1294
|
* @returns Parsed package.json
|
|
2184
1295
|
* @throws {Error} Error if file doesn't exist or is invalid
|
|
1296
|
+
*
|
|
1297
|
+
* @example Reading package.json
|
|
1298
|
+
* ```typescript
|
|
1299
|
+
* import { readPackageJson } from '@hyperfrontend/project-scope'
|
|
1300
|
+
*
|
|
1301
|
+
* const pkg = readPackageJson('/path/to/project')
|
|
1302
|
+
* console.log(pkg.name, pkg.version)
|
|
1303
|
+
* ```
|
|
2185
1304
|
*/
|
|
2186
1305
|
function readPackageJson(projectPath) {
|
|
2187
1306
|
const packageJsonPath = projectPath.endsWith('package.json') ? projectPath : join$1(projectPath, 'package.json');
|
|
2188
1307
|
packageLogger.debug('Reading package.json', { path: packageJsonPath });
|
|
2189
1308
|
const content = readFileContent(packageJsonPath);
|
|
2190
1309
|
try {
|
|
2191
|
-
const data = parse(content);
|
|
1310
|
+
const data = parse$1(content);
|
|
2192
1311
|
const validated = validatePackageJson(data);
|
|
2193
1312
|
packageLogger.debug('Package.json read successfully', { path: packageJsonPath, name: validated.name });
|
|
2194
1313
|
return validated;
|
|
@@ -2210,6 +1329,16 @@ function readPackageJson(projectPath) {
|
|
|
2210
1329
|
*
|
|
2211
1330
|
* @param projectPath - Project directory path or path to package.json
|
|
2212
1331
|
* @returns Parsed package.json or null if not found
|
|
1332
|
+
*
|
|
1333
|
+
* @example Reading package.json if it exists
|
|
1334
|
+
* ```typescript
|
|
1335
|
+
* import { readPackageJsonIfExists } from '@hyperfrontend/project-scope'
|
|
1336
|
+
*
|
|
1337
|
+
* const pkg = readPackageJsonIfExists('/path/to/project')
|
|
1338
|
+
* if (pkg) {
|
|
1339
|
+
* console.log('Found:', pkg.name)
|
|
1340
|
+
* }
|
|
1341
|
+
* ```
|
|
2213
1342
|
*/
|
|
2214
1343
|
function readPackageJsonIfExists(projectPath) {
|
|
2215
1344
|
const packageJsonPath = projectPath.endsWith('package.json') ? projectPath : join$1(projectPath, 'package.json');
|
|
@@ -2219,7 +1348,7 @@ function readPackageJsonIfExists(projectPath) {
|
|
|
2219
1348
|
return null;
|
|
2220
1349
|
}
|
|
2221
1350
|
try {
|
|
2222
|
-
const validated = validatePackageJson(parse(content));
|
|
1351
|
+
const validated = validatePackageJson(parse$1(content));
|
|
2223
1352
|
packageLogger.debug('Package.json loaded', { path: packageJsonPath, name: validated.name });
|
|
2224
1353
|
return validated;
|
|
2225
1354
|
}
|
|
@@ -2233,6 +1362,14 @@ function readPackageJsonIfExists(projectPath) {
|
|
|
2233
1362
|
*
|
|
2234
1363
|
* @param startPath - Starting path
|
|
2235
1364
|
* @returns Path to directory containing package.json, or null if not found
|
|
1365
|
+
*
|
|
1366
|
+
* @example Finding nearest package.json
|
|
1367
|
+
* ```typescript
|
|
1368
|
+
* import { findNearestPackageJson } from '@hyperfrontend/project-scope'
|
|
1369
|
+
*
|
|
1370
|
+
* const pkgDir = findNearestPackageJson('./src/deep/nested/file.ts')
|
|
1371
|
+
* // => '/path/to/project'
|
|
1372
|
+
* ```
|
|
2236
1373
|
*/
|
|
2237
1374
|
function findNearestPackageJson(startPath) {
|
|
2238
1375
|
return locateByMarkers(startPath, ['package.json']);
|
|
@@ -2243,6 +1380,15 @@ function findNearestPackageJson(startPath) {
|
|
|
2243
1380
|
*
|
|
2244
1381
|
* @param packageJson - Parsed package.json
|
|
2245
1382
|
* @returns All dependencies categorized
|
|
1383
|
+
*
|
|
1384
|
+
* @example Extracting all dependencies
|
|
1385
|
+
* ```typescript
|
|
1386
|
+
* import { getDependencies } from '@hyperfrontend/project-scope'
|
|
1387
|
+
*
|
|
1388
|
+
* const deps = getDependencies(packageJson)
|
|
1389
|
+
* console.log('Runtime:', Object.keys(deps.dependencies))
|
|
1390
|
+
* console.log('Dev:', Object.keys(deps.devDependencies))
|
|
1391
|
+
* ```
|
|
2246
1392
|
*/
|
|
2247
1393
|
function getDependencies(packageJson) {
|
|
2248
1394
|
return {
|
|
@@ -2257,6 +1403,14 @@ function getDependencies(packageJson) {
|
|
|
2257
1403
|
*
|
|
2258
1404
|
* @param packageJson - Parsed package.json
|
|
2259
1405
|
* @returns Map of dependency name to version for runtime dependencies
|
|
1406
|
+
*
|
|
1407
|
+
* @example Getting production dependencies
|
|
1408
|
+
* ```typescript
|
|
1409
|
+
* import { getProductionDependencies } from '@hyperfrontend/project-scope'
|
|
1410
|
+
*
|
|
1411
|
+
* const prodDeps = getProductionDependencies(packageJson)
|
|
1412
|
+
* // => { 'express': '^4.18.0', 'lodash': '^4.17.21' }
|
|
1413
|
+
* ```
|
|
2260
1414
|
*/
|
|
2261
1415
|
function getProductionDependencies(packageJson) {
|
|
2262
1416
|
return packageJson.dependencies ?? {};
|
|
@@ -2266,6 +1420,14 @@ function getProductionDependencies(packageJson) {
|
|
|
2266
1420
|
*
|
|
2267
1421
|
* @param packageJson - Parsed package.json
|
|
2268
1422
|
* @returns Map of dependency name to version for dev-time dependencies
|
|
1423
|
+
*
|
|
1424
|
+
* @example Getting development dependencies
|
|
1425
|
+
* ```typescript
|
|
1426
|
+
* import { getDevDependencies } from '@hyperfrontend/project-scope'
|
|
1427
|
+
*
|
|
1428
|
+
* const devDeps = getDevDependencies(packageJson)
|
|
1429
|
+
* // => { 'jest': '^29.0.0', 'typescript': '^5.0.0' }
|
|
1430
|
+
* ```
|
|
2269
1431
|
*/
|
|
2270
1432
|
function getDevDependencies(packageJson) {
|
|
2271
1433
|
return packageJson.devDependencies ?? {};
|
|
@@ -2275,6 +1437,14 @@ function getDevDependencies(packageJson) {
|
|
|
2275
1437
|
*
|
|
2276
1438
|
* @param packageJson - Parsed package.json
|
|
2277
1439
|
* @returns Map of dependency name to version for peer requirements
|
|
1440
|
+
*
|
|
1441
|
+
* @example Getting peer dependencies
|
|
1442
|
+
* ```typescript
|
|
1443
|
+
* import { getPeerDependencies } from '@hyperfrontend/project-scope'
|
|
1444
|
+
*
|
|
1445
|
+
* const peerDeps = getPeerDependencies(packageJson)
|
|
1446
|
+
* // => { 'react': '^18.0.0', 'react-dom': '^18.0.0' }
|
|
1447
|
+
* ```
|
|
2278
1448
|
*/
|
|
2279
1449
|
function getPeerDependencies(packageJson) {
|
|
2280
1450
|
return packageJson.peerDependencies ?? {};
|
|
@@ -2284,6 +1454,16 @@ function getPeerDependencies(packageJson) {
|
|
|
2284
1454
|
*
|
|
2285
1455
|
* @param packageJson - Parsed package.json
|
|
2286
1456
|
* @returns All dependencies merged
|
|
1457
|
+
*
|
|
1458
|
+
* @example Getting all merged dependencies
|
|
1459
|
+
* ```typescript
|
|
1460
|
+
* import { getAllDependencies } from '@hyperfrontend/project-scope'
|
|
1461
|
+
*
|
|
1462
|
+
* const allDeps = getAllDependencies(packageJson)
|
|
1463
|
+
* if ('typescript' in allDeps) {
|
|
1464
|
+
* console.log('TypeScript version:', allDeps['typescript'])
|
|
1465
|
+
* }
|
|
1466
|
+
* ```
|
|
2287
1467
|
*/
|
|
2288
1468
|
function getAllDependencies(packageJson) {
|
|
2289
1469
|
return {
|
|
@@ -2300,6 +1480,17 @@ function getAllDependencies(packageJson) {
|
|
|
2300
1480
|
* @param name - Name of the dependency to check
|
|
2301
1481
|
* @param depTypes - Optional array of dependency types to check (defaults to all)
|
|
2302
1482
|
* @returns True if dependency exists in specified categories
|
|
1483
|
+
*
|
|
1484
|
+
* @example Checking for a dependency
|
|
1485
|
+
* ```typescript
|
|
1486
|
+
* import { hasDependency } from '@hyperfrontend/project-scope'
|
|
1487
|
+
*
|
|
1488
|
+
* // Check any dependency type
|
|
1489
|
+
* hasDependency(packageJson, 'lodash')
|
|
1490
|
+
*
|
|
1491
|
+
* // Check only production dependencies
|
|
1492
|
+
* hasDependency(packageJson, 'lodash', ['dependencies'])
|
|
1493
|
+
* ```
|
|
2303
1494
|
*/
|
|
2304
1495
|
function hasDependency(packageJson, name, depTypes) {
|
|
2305
1496
|
const typesToCheck = depTypes ?? ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
|
|
@@ -2316,6 +1507,14 @@ function hasDependency(packageJson, name, depTypes) {
|
|
|
2316
1507
|
* @param packageJson - Parsed package.json content
|
|
2317
1508
|
* @param name - Name of the dependency to look up
|
|
2318
1509
|
* @returns Version string or null if not found
|
|
1510
|
+
*
|
|
1511
|
+
* @example Getting dependency version
|
|
1512
|
+
* ```typescript
|
|
1513
|
+
* import { getDependencyVersion } from '@hyperfrontend/project-scope'
|
|
1514
|
+
*
|
|
1515
|
+
* const version = getDependencyVersion(packageJson, 'react')
|
|
1516
|
+
* // => '^18.2.0' or null
|
|
1517
|
+
* ```
|
|
2319
1518
|
*/
|
|
2320
1519
|
function getDependencyVersion(packageJson, name) {
|
|
2321
1520
|
const deps = getDependencies(packageJson);
|
|
@@ -2326,6 +1525,14 @@ function getDependencyVersion(packageJson, name) {
|
|
|
2326
1525
|
*
|
|
2327
1526
|
* @param packageJson - Parsed package.json
|
|
2328
1527
|
* @returns Array of workspace patterns or empty array
|
|
1528
|
+
*
|
|
1529
|
+
* @example Getting workspace patterns
|
|
1530
|
+
* ```typescript
|
|
1531
|
+
* import { getWorkspaces } from '@hyperfrontend/project-scope'
|
|
1532
|
+
*
|
|
1533
|
+
* const patterns = getWorkspaces(packageJson)
|
|
1534
|
+
* // => ['packages/*', 'apps/*']
|
|
1535
|
+
* ```
|
|
2329
1536
|
*/
|
|
2330
1537
|
function getWorkspaces(packageJson) {
|
|
2331
1538
|
if (!packageJson.workspaces)
|
|
@@ -2343,6 +1550,15 @@ function getWorkspaces(packageJson) {
|
|
|
2343
1550
|
*
|
|
2344
1551
|
* @param packageJson - Parsed package.json
|
|
2345
1552
|
* @returns True if workspaces are defined
|
|
1553
|
+
*
|
|
1554
|
+
* @example Checking for workspaces
|
|
1555
|
+
* ```typescript
|
|
1556
|
+
* import { hasWorkspaces } from '@hyperfrontend/project-scope'
|
|
1557
|
+
*
|
|
1558
|
+
* if (hasWorkspaces(packageJson)) {
|
|
1559
|
+
* console.log('This is a monorepo')
|
|
1560
|
+
* }
|
|
1561
|
+
* ```
|
|
2346
1562
|
*/
|
|
2347
1563
|
function hasWorkspaces(packageJson) {
|
|
2348
1564
|
return getWorkspaces(packageJson).length > 0;
|
|
@@ -2353,22 +1569,20 @@ function hasWorkspaces(packageJson) {
|
|
|
2353
1569
|
* @param projectPath - Project root directory
|
|
2354
1570
|
* @param packageName - Package name to check
|
|
2355
1571
|
* @returns Boolean indicating whether the package exists in node_modules
|
|
1572
|
+
*
|
|
1573
|
+
* @example Checking installed packages
|
|
1574
|
+
* ```typescript
|
|
1575
|
+
* import { hasInstalledPackage } from '@hyperfrontend/project-scope'
|
|
1576
|
+
*
|
|
1577
|
+
* if (hasInstalledPackage('/project', 'typescript')) {
|
|
1578
|
+
* console.log('TypeScript is installed')
|
|
1579
|
+
* }
|
|
1580
|
+
* ```
|
|
2356
1581
|
*/
|
|
2357
1582
|
function hasInstalledPackage(projectPath, packageName) {
|
|
2358
1583
|
const pkgPath = join$1(projectPath, 'node_modules', packageName, 'package.json');
|
|
2359
1584
|
return readPackageJsonIfExists(pkgPath) !== null;
|
|
2360
1585
|
}
|
|
2361
|
-
/**
|
|
2362
|
-
* Get installed package version from node_modules.
|
|
2363
|
-
*
|
|
2364
|
-
* @param projectPath - Project root directory
|
|
2365
|
-
* @param packageName - Name of the npm package to look up
|
|
2366
|
-
* @returns Installed version or null if not found
|
|
2367
|
-
*/
|
|
2368
|
-
function getInstalledVersion(projectPath, packageName) {
|
|
2369
|
-
const pkg = readPackageJsonIfExists(join$1(projectPath, 'node_modules', packageName, 'package.json'));
|
|
2370
|
-
return pkg?.version ?? null;
|
|
2371
|
-
}
|
|
2372
1586
|
|
|
2373
1587
|
const rootLogger = createScopedLogger('project-scope:root');
|
|
2374
1588
|
/**
|
|
@@ -2408,7 +1622,7 @@ function looksLikeProjectDir(dirPath) {
|
|
|
2408
1622
|
* @param startPath - Starting path
|
|
2409
1623
|
* @returns Project root path or null
|
|
2410
1624
|
*
|
|
2411
|
-
* @example
|
|
1625
|
+
* @example Finding project root
|
|
2412
1626
|
* ```typescript
|
|
2413
1627
|
* import { findProjectRoot } from '@hyperfrontend/project-scope'
|
|
2414
1628
|
*
|
|
@@ -2448,7 +1662,7 @@ function findProjectRoot(startPath) {
|
|
|
2448
1662
|
* @param startPath - Starting path
|
|
2449
1663
|
* @returns Workspace root path or null
|
|
2450
1664
|
*
|
|
2451
|
-
* @example
|
|
1665
|
+
* @example Finding workspace root
|
|
2452
1666
|
* ```typescript
|
|
2453
1667
|
* import { findWorkspaceRoot } from '@hyperfrontend/project-scope'
|
|
2454
1668
|
*
|
|
@@ -2488,6 +1702,15 @@ function findWorkspaceRoot(startPath) {
|
|
|
2488
1702
|
* @param startPath - Starting path
|
|
2489
1703
|
* @param markers - Files to search for
|
|
2490
1704
|
* @returns Root directory path or null
|
|
1705
|
+
*
|
|
1706
|
+
* @example Finding root by marker files
|
|
1707
|
+
* ```typescript
|
|
1708
|
+
* import { findRootDirectory } from '@hyperfrontend/project-scope'
|
|
1709
|
+
*
|
|
1710
|
+
* // Find monorepo root by looking for nx.json or lerna.json
|
|
1711
|
+
* const root = findRootDirectory('./libs/my-lib', ['nx.json', 'lerna.json'])
|
|
1712
|
+
* // => '/path/to/monorepo'
|
|
1713
|
+
* ```
|
|
2491
1714
|
*/
|
|
2492
1715
|
function findRootDirectory(startPath, markers) {
|
|
2493
1716
|
return locateByMarkers(startPath, markers);
|
|
@@ -2497,10 +1720,17 @@ function findRootDirectory(startPath, markers) {
|
|
|
2497
1720
|
*
|
|
2498
1721
|
* @param startPath - Starting path
|
|
2499
1722
|
* @returns Git root path or null
|
|
1723
|
+
*
|
|
1724
|
+
* @example Finding Git repository root
|
|
1725
|
+
* ```typescript
|
|
1726
|
+
* import { findGitRoot } from '@hyperfrontend/project-scope'
|
|
1727
|
+
*
|
|
1728
|
+
* const gitRoot = findGitRoot('./src/deep/nested/file.ts')
|
|
1729
|
+
* // => '/path/to/repository'
|
|
1730
|
+
* ```
|
|
2500
1731
|
*/
|
|
2501
1732
|
function findGitRoot(startPath) {
|
|
2502
1733
|
return locateByMarkers(startPath, ['.git']);
|
|
2503
1734
|
}
|
|
2504
1735
|
|
|
2505
|
-
export { CONFIG_PATTERNS, ROOT_MARKERS, WORKSPACE_MARKERS, clearConfigDetectionCache, detectConfigs, findConfigFile, findDirectories, findFiles, findFilesInTree, findGitRoot, findNearestPackageJson, findProjectRoot, findRootDirectory, findWorkspaceRoot, getAllDependencies,
|
|
2506
|
-
//# sourceMappingURL=index.esm.js.map
|
|
1736
|
+
export { CONFIG_PATTERNS, ROOT_MARKERS, WORKSPACE_MARKERS, clearConfigDetectionCache, detectConfigs, findConfigFile, findDirectories, findFiles, findFilesInTree, findGitRoot, findNearestPackageJson, findProjectRoot, findRootDirectory, findWorkspaceRoot, getAllDependencies, getConfigPatternsByType, getDependencies, getDependencyVersion, getDevDependencies, getPeerDependencies, getProductionDependencies, getWorkspaces, hasDependency, hasInstalledPackage, hasWorkspaces, parseConfig, parseJsonConfig, parseYamlConfig, readPackageJson, readPackageJsonIfExists, walkDirectory, walkTree };
|