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