@hyperfrontend/project-scope 0.2.0 → 0.2.2
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 +13 -15
- 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/stat/index.cjs.js +46 -0
- package/_shared/core/fs/stat/index.esm.js +40 -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 +1699 -2040
- package/cli/index.d.ts +273 -7
- package/cli/index.d.ts.map +1 -1
- package/cli/index.esm.js +1603 -1944
- package/core/encoding/index.cjs.js +88 -424
- package/core/encoding/index.d.ts +186 -3
- package/core/encoding/index.d.ts.map +1 -1
- package/core/encoding/index.esm.js +80 -415
- package/core/fs/index.cjs.js +231 -595
- package/core/fs/index.d.ts +479 -6
- package/core/fs/index.d.ts.map +1 -1
- package/core/fs/index.esm.js +221 -585
- package/core/index.cjs.js +518 -1804
- package/core/index.d.ts +486 -9
- package/core/index.d.ts.map +1 -1
- package/core/index.esm.js +501 -1784
- package/core/path/index.cjs.js +6 -235
- package/core/path/index.d.ts +306 -5
- package/core/path/index.d.ts.map +1 -1
- package/core/path/index.esm.js +4 -233
- package/core/platform/index.cjs.js +5 -226
- package/core/platform/index.d.ts +185 -3
- package/core/platform/index.d.ts.map +1 -1
- package/core/platform/index.esm.js +3 -222
- package/heuristics/dependencies/index.cjs.js +95 -509
- package/heuristics/dependencies/index.d.ts +99 -2
- package/heuristics/dependencies/index.d.ts.map +1 -1
- package/heuristics/dependencies/index.esm.js +69 -483
- package/heuristics/entry-points/index.cjs.js +93 -825
- 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 -806
- package/heuristics/framework/index.cjs.js +1482 -1473
- package/heuristics/framework/index.d.ts +104 -2
- package/heuristics/framework/index.d.ts.map +1 -1
- package/heuristics/framework/index.esm.js +1418 -1409
- package/heuristics/index.cjs.js +3207 -3383
- package/heuristics/index.d.ts +4 -5
- package/heuristics/index.d.ts.map +1 -1
- package/heuristics/index.esm.js +3234 -3410
- package/heuristics/project-type/index.cjs.js +1488 -1500
- 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 +1417 -1429
- package/index.cjs.js +3064 -3765
- package/index.d.ts +44 -10
- package/index.d.ts.map +1 -1
- package/index.esm.js +2923 -3612
- 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 +163 -606
- package/nx/index.d.ts +279 -4
- package/nx/index.d.ts.map +1 -1
- package/nx/index.esm.js +145 -583
- package/package.json +13 -12
- package/project/config/index.cjs.js +122 -1104
- package/project/config/index.d.ts +202 -4
- package/project/config/index.d.ts.map +1 -1
- package/project/config/index.esm.js +105 -1085
- package/project/index.cjs.js +323 -1143
- package/project/index.d.ts +4 -5
- package/project/index.d.ts.map +1 -1
- package/project/index.esm.js +302 -1119
- package/project/package/index.cjs.js +191 -483
- package/project/package/index.d.ts +280 -3
- package/project/package/index.d.ts.map +1 -1
- package/project/package/index.esm.js +178 -469
- package/project/root/index.cjs.js +107 -427
- package/project/root/index.d.ts +83 -2
- package/project/root/index.d.ts.map +1 -1
- package/project/root/index.esm.js +96 -416
- package/project/traversal/index.cjs.js +94 -645
- package/project/traversal/index.d.ts +165 -3
- package/project/traversal/index.d.ts.map +1 -1
- package/project/traversal/index.esm.js +80 -631
- package/tech/backend/index.cjs.js +221 -524
- package/tech/backend/index.d.ts +205 -8
- package/tech/backend/index.d.ts.map +1 -1
- package/tech/backend/index.esm.js +200 -503
- package/tech/build/index.cjs.js +348 -647
- package/tech/build/index.d.ts +276 -10
- package/tech/build/index.d.ts.map +1 -1
- package/tech/build/index.esm.js +326 -625
- package/tech/frontend/index.cjs.js +505 -700
- package/tech/frontend/index.d.ts +379 -15
- package/tech/frontend/index.d.ts.map +1 -1
- package/tech/frontend/index.esm.js +481 -676
- package/tech/index.cjs.js +1580 -1482
- package/tech/index.d.ts +55 -32
- package/tech/index.d.ts.map +1 -1
- package/tech/index.esm.js +1513 -1415
- package/tech/legacy/index.cjs.js +97 -474
- package/tech/legacy/index.d.ts +125 -7
- package/tech/legacy/index.d.ts.map +1 -1
- package/tech/legacy/index.esm.js +79 -456
- package/tech/linting/index.cjs.js +136 -536
- package/tech/linting/index.d.ts +129 -7
- package/tech/linting/index.d.ts.map +1 -1
- package/tech/linting/index.esm.js +116 -516
- package/tech/monorepo/index.cjs.js +244 -584
- package/tech/monorepo/index.d.ts +241 -10
- package/tech/monorepo/index.d.ts.map +1 -1
- package/tech/monorepo/index.esm.js +224 -564
- package/tech/testing/index.cjs.js +214 -582
- package/tech/testing/index.d.ts +176 -8
- package/tech/testing/index.d.ts.map +1 -1
- package/tech/testing/index.esm.js +196 -564
- package/tech/types/index.cjs.js +121 -532
- package/tech/types/index.d.ts +120 -2
- package/tech/types/index.d.ts.map +1 -1
- package/tech/types/index.esm.js +99 -510
- package/vfs/index.cjs.js +647 -1187
- package/vfs/index.d.ts +360 -6
- package/vfs/index.d.ts.map +1 -1
- package/vfs/index.esm.js +672 -1212
- 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 -20
- package/cli/commands/analyze.d.ts.map +0 -1
- package/cli/commands/config.d.ts +0 -20
- package/cli/commands/config.d.ts.map +0 -1
- package/cli/commands/deps.d.ts +0 -18
- package/cli/commands/deps.d.ts.map +0 -1
- package/cli/commands/tree.d.ts +0 -24
- 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 -157
- 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 -86
- 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 -64
- package/core/errors/structured-errors.d.ts.map +0 -1
- package/core/fs/directory.d.ts +0 -88
- 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 -86
- 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 -46
- 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 -86
- 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 -109
- 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 -66
- 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 -178
- package/vfs/types.d.ts.map +0 -1
package/project/index.esm.js
CHANGED
|
@@ -1,412 +1,20 @@
|
|
|
1
|
-
import { join as join$1, resolve, parse
|
|
1
|
+
import { join as join$1, resolve, parse, dirname, basename } from 'node:path';
|
|
2
|
+
import { freeze, entries, keys, defineProperties, values } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.esm.js';
|
|
3
|
+
import { createMap } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.esm.js';
|
|
4
|
+
import { createSet } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.esm.js';
|
|
2
5
|
import { existsSync, readFileSync, statSync, lstatSync, readdirSync } from 'node:fs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// Capture references at module initialization time
|
|
16
|
-
const _Error = globalThis.Error;
|
|
17
|
-
const _Reflect$2 = globalThis.Reflect;
|
|
18
|
-
/**
|
|
19
|
-
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
20
|
-
* Use this instead of `new Error()`.
|
|
21
|
-
*
|
|
22
|
-
* @param message - Optional error message.
|
|
23
|
-
* @param options - Optional error options.
|
|
24
|
-
* @returns A new Error instance.
|
|
25
|
-
*/
|
|
26
|
-
const createError = (message, options) => _Reflect$2.construct(_Error, [message, options]);
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Safe copies of JSON built-in methods.
|
|
30
|
-
*
|
|
31
|
-
* These references are captured at module initialization time to protect against
|
|
32
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
33
|
-
*
|
|
34
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/json
|
|
35
|
-
*/
|
|
36
|
-
// Capture references at module initialization time
|
|
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
|
-
// Capture references at module initialization time
|
|
56
|
-
const _Object = globalThis.Object;
|
|
57
|
-
/**
|
|
58
|
-
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
59
|
-
* and prevents the addition of new properties.
|
|
60
|
-
*/
|
|
61
|
-
const freeze = _Object.freeze;
|
|
62
|
-
/**
|
|
63
|
-
* (Safe copy) Returns the names of the enumerable string properties and methods of an object.
|
|
64
|
-
*/
|
|
65
|
-
const keys = _Object.keys;
|
|
66
|
-
/**
|
|
67
|
-
* (Safe copy) Returns an array of key/values of the enumerable own properties of an object.
|
|
68
|
-
*/
|
|
69
|
-
const entries = _Object.entries;
|
|
70
|
-
/**
|
|
71
|
-
* (Safe copy) Returns an array of values of the enumerable own properties of an object.
|
|
72
|
-
*/
|
|
73
|
-
const values = _Object.values;
|
|
74
|
-
/**
|
|
75
|
-
* (Safe copy) Adds one or more properties to an object, and/or modifies attributes of existing properties.
|
|
76
|
-
*/
|
|
77
|
-
const defineProperties = _Object.defineProperties;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Safe copies of Array built-in static methods.
|
|
81
|
-
*
|
|
82
|
-
* These references are captured at module initialization time to protect against
|
|
83
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
84
|
-
*
|
|
85
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
86
|
-
*/
|
|
87
|
-
// Capture references at module initialization time
|
|
88
|
-
const _Array = globalThis.Array;
|
|
89
|
-
/**
|
|
90
|
-
* (Safe copy) Determines whether the passed value is an Array.
|
|
91
|
-
*/
|
|
92
|
-
const isArray = _Array.isArray;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Safe copies of Console built-in methods.
|
|
96
|
-
*
|
|
97
|
-
* These references are captured at module initialization time to protect against
|
|
98
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
99
|
-
*
|
|
100
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/console
|
|
101
|
-
*/
|
|
102
|
-
// Capture references at module initialization time
|
|
103
|
-
const _console = globalThis.console;
|
|
104
|
-
/**
|
|
105
|
-
* (Safe copy) Outputs a message to the console.
|
|
106
|
-
*/
|
|
107
|
-
const log = _console.log.bind(_console);
|
|
108
|
-
/**
|
|
109
|
-
* (Safe copy) Outputs a warning message to the console.
|
|
110
|
-
*/
|
|
111
|
-
const warn = _console.warn.bind(_console);
|
|
112
|
-
/**
|
|
113
|
-
* (Safe copy) Outputs an error message to the console.
|
|
114
|
-
*/
|
|
115
|
-
const error = _console.error.bind(_console);
|
|
116
|
-
/**
|
|
117
|
-
* (Safe copy) Outputs an informational message to the console.
|
|
118
|
-
*/
|
|
119
|
-
const info = _console.info.bind(_console);
|
|
120
|
-
/**
|
|
121
|
-
* (Safe copy) Outputs a debug message to the console.
|
|
122
|
-
*/
|
|
123
|
-
const debug = _console.debug.bind(_console);
|
|
124
|
-
/**
|
|
125
|
-
* (Safe copy) Outputs a stack trace to the console.
|
|
126
|
-
*/
|
|
127
|
-
_console.trace.bind(_console);
|
|
128
|
-
/**
|
|
129
|
-
* (Safe copy) Displays an interactive listing of the properties of a specified object.
|
|
130
|
-
*/
|
|
131
|
-
_console.dir.bind(_console);
|
|
132
|
-
/**
|
|
133
|
-
* (Safe copy) Displays tabular data as a table.
|
|
134
|
-
*/
|
|
135
|
-
_console.table.bind(_console);
|
|
136
|
-
/**
|
|
137
|
-
* (Safe copy) Writes an error message to the console if the assertion is false.
|
|
138
|
-
*/
|
|
139
|
-
_console.assert.bind(_console);
|
|
140
|
-
/**
|
|
141
|
-
* (Safe copy) Clears the console.
|
|
142
|
-
*/
|
|
143
|
-
_console.clear.bind(_console);
|
|
144
|
-
/**
|
|
145
|
-
* (Safe copy) Logs the number of times that this particular call to count() has been called.
|
|
146
|
-
*/
|
|
147
|
-
_console.count.bind(_console);
|
|
148
|
-
/**
|
|
149
|
-
* (Safe copy) Resets the counter used with console.count().
|
|
150
|
-
*/
|
|
151
|
-
_console.countReset.bind(_console);
|
|
152
|
-
/**
|
|
153
|
-
* (Safe copy) Creates a new inline group in the console.
|
|
154
|
-
*/
|
|
155
|
-
_console.group.bind(_console);
|
|
156
|
-
/**
|
|
157
|
-
* (Safe copy) Creates a new inline group in the console that is initially collapsed.
|
|
158
|
-
*/
|
|
159
|
-
_console.groupCollapsed.bind(_console);
|
|
160
|
-
/**
|
|
161
|
-
* (Safe copy) Exits the current inline group.
|
|
162
|
-
*/
|
|
163
|
-
_console.groupEnd.bind(_console);
|
|
164
|
-
/**
|
|
165
|
-
* (Safe copy) Starts a timer with a name specified as an input parameter.
|
|
166
|
-
*/
|
|
167
|
-
_console.time.bind(_console);
|
|
168
|
-
/**
|
|
169
|
-
* (Safe copy) Stops a timer that was previously started.
|
|
170
|
-
*/
|
|
171
|
-
_console.timeEnd.bind(_console);
|
|
172
|
-
/**
|
|
173
|
-
* (Safe copy) Logs the current value of a timer that was previously started.
|
|
174
|
-
*/
|
|
175
|
-
_console.timeLog.bind(_console);
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Safe copies of Set built-in via factory function.
|
|
179
|
-
*
|
|
180
|
-
* Since constructors cannot be safely captured via Object.assign, this module
|
|
181
|
-
* provides a factory function that uses Reflect.construct internally.
|
|
182
|
-
*
|
|
183
|
-
* These references are captured at module initialization time to protect against
|
|
184
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
185
|
-
*
|
|
186
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
187
|
-
*/
|
|
188
|
-
// Capture references at module initialization time
|
|
189
|
-
const _Set = globalThis.Set;
|
|
190
|
-
const _Reflect$1 = globalThis.Reflect;
|
|
191
|
-
/**
|
|
192
|
-
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
193
|
-
* Use this instead of `new Set()`.
|
|
194
|
-
*
|
|
195
|
-
* @param iterable - Optional iterable of values.
|
|
196
|
-
* @returns A new Set instance.
|
|
197
|
-
*/
|
|
198
|
-
const createSet = (iterable) => _Reflect$1.construct(_Set, iterable ? [iterable] : []);
|
|
199
|
-
|
|
200
|
-
const registeredClasses = [];
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Returns the data type of the target.
|
|
204
|
-
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
205
|
-
* Also, when classes are registered via `registerClass`, it checks if objects are instance of any known registered class.
|
|
206
|
-
*
|
|
207
|
-
* @param target - The target to get the data type of.
|
|
208
|
-
* @returns The data type of the target.
|
|
209
|
-
*/
|
|
210
|
-
const getType = (target) => {
|
|
211
|
-
if (target === null)
|
|
212
|
-
return 'null';
|
|
213
|
-
const nativeDataType = typeof target;
|
|
214
|
-
if (nativeDataType === 'object') {
|
|
215
|
-
if (isArray(target))
|
|
216
|
-
return 'array';
|
|
217
|
-
for (const registeredClass of registeredClasses) {
|
|
218
|
-
if (target instanceof registeredClass)
|
|
219
|
-
return registeredClass.name;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return nativeDataType;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Safe copies of Map built-in via factory function.
|
|
227
|
-
*
|
|
228
|
-
* Since constructors cannot be safely captured via Object.assign, this module
|
|
229
|
-
* provides a factory function that uses Reflect.construct internally.
|
|
230
|
-
*
|
|
231
|
-
* These references are captured at module initialization time to protect against
|
|
232
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
233
|
-
*
|
|
234
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/map
|
|
235
|
-
*/
|
|
236
|
-
// Capture references at module initialization time
|
|
237
|
-
const _Map = globalThis.Map;
|
|
238
|
-
const _Reflect = globalThis.Reflect;
|
|
239
|
-
/**
|
|
240
|
-
* (Safe copy) Creates a new Map using the captured Map constructor.
|
|
241
|
-
* Use this instead of `new Map()`.
|
|
242
|
-
*
|
|
243
|
-
* @param iterable - Optional iterable of key-value pairs.
|
|
244
|
-
* @returns A new Map instance.
|
|
245
|
-
*/
|
|
246
|
-
const createMap = (iterable) => _Reflect.construct(_Map, iterable ? [iterable] : []);
|
|
247
|
-
|
|
248
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
249
|
-
/**
|
|
250
|
-
* Creates a wrapper function that only executes the wrapped function if the condition function returns true.
|
|
251
|
-
*
|
|
252
|
-
* @param func - The function to be conditionally executed.
|
|
253
|
-
* @param conditionFunc - A function that returns a boolean, determining if `func` should be executed.
|
|
254
|
-
* @returns A wrapped version of `func` that executes conditionally.
|
|
255
|
-
*/
|
|
256
|
-
function createConditionalExecutionFunction(func, conditionFunc) {
|
|
257
|
-
return function (...args) {
|
|
258
|
-
if (conditionFunc()) {
|
|
259
|
-
return func(...args);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
265
|
-
/**
|
|
266
|
-
* Creates a wrapper function that silently ignores any errors thrown by the wrapped void function.
|
|
267
|
-
* This function is specifically for wrapping functions that do not return a value (void functions).
|
|
268
|
-
* Exceptions are swallowed without any logging or handling.
|
|
269
|
-
*
|
|
270
|
-
* @param func - The void function to be wrapped.
|
|
271
|
-
* @returns A wrapped version of the input function that ignores errors.
|
|
272
|
-
*/
|
|
273
|
-
function createErrorIgnoringFunction(func) {
|
|
274
|
-
return function (...args) {
|
|
275
|
-
try {
|
|
276
|
-
func(...args);
|
|
277
|
-
}
|
|
278
|
-
catch {
|
|
279
|
-
// Deliberately swallowing/ignoring the exception
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
285
|
-
/**
|
|
286
|
-
* A no-operation function (noop) that does nothing regardless of the arguments passed.
|
|
287
|
-
* It is designed to be as permissive as possible in its typing without using the `Function` keyword.
|
|
288
|
-
*
|
|
289
|
-
* @param args - Any arguments passed to the function (ignored)
|
|
290
|
-
*/
|
|
291
|
-
const noop = (...args) => {
|
|
292
|
-
// Intentionally does nothing
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
const logLevels = ['none', 'error', 'warn', 'log', 'info', 'debug'];
|
|
296
|
-
const priority = {
|
|
297
|
-
error: 4,
|
|
298
|
-
warn: 3,
|
|
299
|
-
log: 2,
|
|
300
|
-
info: 1,
|
|
301
|
-
debug: 0,
|
|
302
|
-
};
|
|
303
|
-
/**
|
|
304
|
-
* Validates whether a given string is a valid log level.
|
|
305
|
-
*
|
|
306
|
-
* @param level - The log level to validate
|
|
307
|
-
* @returns True if the level is valid, false otherwise
|
|
308
|
-
*/
|
|
309
|
-
function isValidLogLevel(level) {
|
|
310
|
-
return logLevels.includes(level);
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Creates a log level configuration manager for controlling logging behavior.
|
|
314
|
-
* Provides methods to get, set, and evaluate log levels based on priority.
|
|
315
|
-
*
|
|
316
|
-
* @param level - The initial log level (defaults to 'error')
|
|
317
|
-
* @returns A configuration object with log level management methods
|
|
318
|
-
* @throws {Error} When the provided level is not a valid log level
|
|
319
|
-
*/
|
|
320
|
-
function createLogLevelConfig(level = 'error') {
|
|
321
|
-
if (!isValidLogLevel(level)) {
|
|
322
|
-
throw createError('Cannot create log level configuration with a valid default log level');
|
|
323
|
-
}
|
|
324
|
-
const state = { level };
|
|
325
|
-
const getLogLevel = () => state.level;
|
|
326
|
-
const setLogLevel = (level) => {
|
|
327
|
-
if (!isValidLogLevel(level)) {
|
|
328
|
-
throw createError(`Cannot set value '${level}' level. Expected levels are ${logLevels}.`);
|
|
329
|
-
}
|
|
330
|
-
state.level = level;
|
|
331
|
-
};
|
|
332
|
-
const shouldLog = (level) => {
|
|
333
|
-
if (state.level === 'none' || level === 'none' || !isValidLogLevel(level)) {
|
|
334
|
-
return false;
|
|
335
|
-
}
|
|
336
|
-
return priority[level] >= priority[state.level];
|
|
337
|
-
};
|
|
338
|
-
return freeze({
|
|
339
|
-
getLogLevel,
|
|
340
|
-
setLogLevel,
|
|
341
|
-
shouldLog,
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Creates a logger instance with configurable log level filtering.
|
|
347
|
-
* Each log function is wrapped to respect the current log level setting.
|
|
348
|
-
*
|
|
349
|
-
* @param error - Function to handle error-level logs (required)
|
|
350
|
-
* @param warn - Function to handle warning-level logs (optional, defaults to noop)
|
|
351
|
-
* @param log - Function to handle standard logs (optional, defaults to noop)
|
|
352
|
-
* @param info - Function to handle info-level logs (optional, defaults to noop)
|
|
353
|
-
* @param debug - Function to handle debug-level logs (optional, defaults to noop)
|
|
354
|
-
* @returns A frozen logger object with log methods and level control
|
|
355
|
-
* @throws {ErrorLevelFn} When any provided log function is invalid
|
|
356
|
-
*/
|
|
357
|
-
function createLogger(error, warn = noop, log = noop, info = noop, debug = noop) {
|
|
358
|
-
if (notValidLogFn(error)) {
|
|
359
|
-
throw createError(notFnMsg('error'));
|
|
360
|
-
}
|
|
361
|
-
if (notValidLogFn(warn)) {
|
|
362
|
-
throw createError(notFnMsg('warn'));
|
|
363
|
-
}
|
|
364
|
-
if (notValidLogFn(log)) {
|
|
365
|
-
throw createError(notFnMsg('log'));
|
|
366
|
-
}
|
|
367
|
-
if (notValidLogFn(info)) {
|
|
368
|
-
throw createError(notFnMsg('info'));
|
|
369
|
-
}
|
|
370
|
-
if (notValidLogFn(debug)) {
|
|
371
|
-
throw createError(notFnMsg('debug'));
|
|
372
|
-
}
|
|
373
|
-
const { setLogLevel, getLogLevel, shouldLog } = createLogLevelConfig();
|
|
374
|
-
const wrapLogFn = (fn, level) => {
|
|
375
|
-
if (fn === noop)
|
|
376
|
-
return fn;
|
|
377
|
-
const condition = () => shouldLog(level);
|
|
378
|
-
return createConditionalExecutionFunction(createErrorIgnoringFunction(fn), condition);
|
|
379
|
-
};
|
|
380
|
-
return freeze({
|
|
381
|
-
error: wrapLogFn(error, 'error'),
|
|
382
|
-
warn: wrapLogFn(warn, 'warn'),
|
|
383
|
-
log: wrapLogFn(log, 'log'),
|
|
384
|
-
info: wrapLogFn(info, 'info'),
|
|
385
|
-
debug: wrapLogFn(debug, 'debug'),
|
|
386
|
-
setLogLevel,
|
|
387
|
-
getLogLevel,
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Validates whether a given value is a valid log function.
|
|
392
|
-
*
|
|
393
|
-
* @param fn - The value to validate
|
|
394
|
-
* @returns True if the value is not a function (invalid), false if it is valid
|
|
395
|
-
*/
|
|
396
|
-
function notValidLogFn(fn) {
|
|
397
|
-
return getType(fn) !== 'function' && fn !== noop;
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Generates an error message for invalid log function parameters.
|
|
401
|
-
*
|
|
402
|
-
* @param label - The name of the log function that failed validation
|
|
403
|
-
* @returns A formatted error message string
|
|
404
|
-
*/
|
|
405
|
-
function notFnMsg(label) {
|
|
406
|
-
return `Cannot create a logger when ${label} is not a function`;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
createLogger(error, warn, log, info, debug);
|
|
6
|
+
import { isArray } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.esm.js';
|
|
7
|
+
import { error, warn, log, info, debug } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.esm.js';
|
|
8
|
+
import { stringify, parse as parse$1 } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.esm.js';
|
|
9
|
+
import { createLogger } from '../_dependencies/@hyperfrontend/logging/index.esm.js';
|
|
10
|
+
import { createError } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.esm.js';
|
|
11
|
+
import { parseInt, parseFloat } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/number/index.esm.js';
|
|
12
|
+
import { isDirectory, exists } from '../_shared/core/fs/stat/index.esm.js';
|
|
13
|
+
import { join } from '../_shared/core/path/join/index.esm.js';
|
|
14
|
+
import { createConfigError } from '../_shared/core/errors/structured-errors/index.esm.js';
|
|
15
|
+
import { createCache } from '../_shared/core/cache/index.esm.js';
|
|
16
|
+
import { matchGlobPattern } from '../_shared/core/patterns/glob/index.esm.js';
|
|
17
|
+
import { CONFIG_PATTERNS, getConfigPatternsByType } from '../_shared/project/config/patterns/index.esm.js';
|
|
410
18
|
|
|
411
19
|
/**
|
|
412
20
|
* Global log level registry.
|
|
@@ -446,6 +54,13 @@ function isSensitiveKey(key) {
|
|
|
446
54
|
*
|
|
447
55
|
* @param obj - Object to sanitize
|
|
448
56
|
* @returns New object with sensitive values redacted
|
|
57
|
+
*
|
|
58
|
+
* @example Sanitizing sensitive data
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
|
|
61
|
+
* const safe = sanitize(config)
|
|
62
|
+
* // => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }
|
|
63
|
+
* ```
|
|
449
64
|
*/
|
|
450
65
|
function sanitize(obj) {
|
|
451
66
|
if (obj === null || obj === undefined) {
|
|
@@ -496,7 +111,7 @@ function formatMessage(namespace, message, meta) {
|
|
|
496
111
|
* @param options - Logger configuration options
|
|
497
112
|
* @returns A configured scoped logger instance
|
|
498
113
|
*
|
|
499
|
-
* @example
|
|
114
|
+
* @example Creating a scoped logger
|
|
500
115
|
* ```typescript
|
|
501
116
|
* const logger = createScopedLogger('project-scope')
|
|
502
117
|
* logger.setLogLevel('debug')
|
|
@@ -511,14 +126,11 @@ function formatMessage(namespace, message, meta) {
|
|
|
511
126
|
*/
|
|
512
127
|
function createScopedLogger(namespace, options = {}) {
|
|
513
128
|
const { level = 'error', sanitizeSecrets = true } = options;
|
|
514
|
-
// Create wrapper functions that add namespace prefix and sanitization
|
|
515
129
|
const createLogFn = (baseFn) => (message, meta) => {
|
|
516
130
|
const processedMeta = sanitizeSecrets && meta ? sanitize(meta) : meta;
|
|
517
131
|
baseFn(formatMessage(namespace, message, processedMeta));
|
|
518
132
|
};
|
|
519
|
-
// Create base logger with wrapped functions
|
|
520
133
|
const baseLogger = createLogger(createLogFn(error), createLogFn(warn), createLogFn(log), createLogFn(info), createLogFn(debug));
|
|
521
|
-
// Set initial log level (use global override if set)
|
|
522
134
|
baseLogger.setLogLevel(level);
|
|
523
135
|
const scopedLogger = freeze({
|
|
524
136
|
error: (message, meta) => baseLogger.error(message, meta),
|
|
@@ -529,7 +141,6 @@ function createScopedLogger(namespace, options = {}) {
|
|
|
529
141
|
setLogLevel: baseLogger.setLogLevel,
|
|
530
142
|
getLogLevel: baseLogger.getLogLevel,
|
|
531
143
|
});
|
|
532
|
-
// Register logger for global level management
|
|
533
144
|
loggerRegistry.add(scopedLogger);
|
|
534
145
|
return scopedLogger;
|
|
535
146
|
}
|
|
@@ -537,7 +148,7 @@ function createScopedLogger(namespace, options = {}) {
|
|
|
537
148
|
* Default logger instance for the project-scope library.
|
|
538
149
|
* Use this for general logging within the library.
|
|
539
150
|
*
|
|
540
|
-
* @example
|
|
151
|
+
* @example Using the default logger
|
|
541
152
|
* ```typescript
|
|
542
153
|
* import { logger } from '@hyperfrontend/project-scope/core'
|
|
543
154
|
*
|
|
@@ -555,6 +166,15 @@ const fsLogger = createScopedLogger('project-scope:fs');
|
|
|
555
166
|
* @param code - The category code for this type of filesystem failure
|
|
556
167
|
* @param context - Additional context including path, operation, and cause
|
|
557
168
|
* @returns A configured Error object with code and context properties
|
|
169
|
+
*
|
|
170
|
+
* @example Creating a file system error
|
|
171
|
+
* ```typescript
|
|
172
|
+
* throw createFileSystemError(
|
|
173
|
+
* 'Cannot read file',
|
|
174
|
+
* 'FS_READ_ERROR',
|
|
175
|
+
* { path: './missing.txt', operation: 'read' }
|
|
176
|
+
* )
|
|
177
|
+
* ```
|
|
558
178
|
*/
|
|
559
179
|
function createFileSystemError(message, code, context) {
|
|
560
180
|
const error = createError(message);
|
|
@@ -572,7 +192,7 @@ function createFileSystemError(message, code, context) {
|
|
|
572
192
|
* @returns File contents as string
|
|
573
193
|
* @throws {Error} If file doesn't exist or can't be read
|
|
574
194
|
*
|
|
575
|
-
* @example
|
|
195
|
+
* @example Reading file contents
|
|
576
196
|
* ```typescript
|
|
577
197
|
* import { readFileContent } from '@hyperfrontend/project-scope'
|
|
578
198
|
*
|
|
@@ -599,6 +219,14 @@ function readFileContent(filePath, encoding = 'utf-8') {
|
|
|
599
219
|
* @param filePath - Path to file
|
|
600
220
|
* @param encoding - File encoding (default: utf-8)
|
|
601
221
|
* @returns File contents or null if file doesn't exist
|
|
222
|
+
*
|
|
223
|
+
* @example Reading file if it exists
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const content = readFileIfExists('./optional-config.json')
|
|
226
|
+
* if (content) {
|
|
227
|
+
* // File existed, use content
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
602
230
|
*/
|
|
603
231
|
function readFileIfExists(filePath, encoding = 'utf-8') {
|
|
604
232
|
if (!existsSync(filePath)) {
|
|
@@ -612,56 +240,6 @@ function readFileIfExists(filePath, encoding = 'utf-8') {
|
|
|
612
240
|
}
|
|
613
241
|
}
|
|
614
242
|
|
|
615
|
-
createScopedLogger('project-scope:fs:write');
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* Get file stats with error handling.
|
|
619
|
-
*
|
|
620
|
-
* @param filePath - Path to file
|
|
621
|
-
* @param followSymlinks - Whether to follow symlinks (default: true)
|
|
622
|
-
* @returns File stats or null if path doesn't exist
|
|
623
|
-
*/
|
|
624
|
-
function getFileStat(filePath, followSymlinks = true) {
|
|
625
|
-
if (!existsSync(filePath)) {
|
|
626
|
-
return null;
|
|
627
|
-
}
|
|
628
|
-
try {
|
|
629
|
-
const stat = followSymlinks ? statSync(filePath) : lstatSync(filePath);
|
|
630
|
-
return {
|
|
631
|
-
isFile: stat.isFile(),
|
|
632
|
-
isDirectory: stat.isDirectory(),
|
|
633
|
-
isSymlink: stat.isSymbolicLink(),
|
|
634
|
-
size: stat.size,
|
|
635
|
-
created: stat.birthtime,
|
|
636
|
-
modified: stat.mtime,
|
|
637
|
-
accessed: stat.atime,
|
|
638
|
-
mode: stat.mode,
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
catch {
|
|
642
|
-
return null;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
/**
|
|
646
|
-
* Check if path is a directory.
|
|
647
|
-
*
|
|
648
|
-
* @param dirPath - Path to check
|
|
649
|
-
* @returns True if path is a directory
|
|
650
|
-
*/
|
|
651
|
-
function isDirectory(dirPath) {
|
|
652
|
-
const stats = getFileStat(dirPath);
|
|
653
|
-
return stats?.isDirectory ?? false;
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Check if path exists.
|
|
657
|
-
*
|
|
658
|
-
* @param filePath - Path to check
|
|
659
|
-
* @returns True if path exists
|
|
660
|
-
*/
|
|
661
|
-
function exists(filePath) {
|
|
662
|
-
return existsSync(filePath);
|
|
663
|
-
}
|
|
664
|
-
|
|
665
243
|
const fsDirLogger = createScopedLogger('project-scope:fs:dir');
|
|
666
244
|
/**
|
|
667
245
|
* List immediate contents of a directory.
|
|
@@ -670,7 +248,7 @@ const fsDirLogger = createScopedLogger('project-scope:fs:dir');
|
|
|
670
248
|
* @returns Array of entries with metadata for each file/directory
|
|
671
249
|
* @throws {Error} If directory doesn't exist or isn't a directory
|
|
672
250
|
*
|
|
673
|
-
* @example
|
|
251
|
+
* @example Listing directory contents
|
|
674
252
|
* ```typescript
|
|
675
253
|
* import { readDirectory } from '@hyperfrontend/project-scope'
|
|
676
254
|
*
|
|
@@ -711,17 +289,6 @@ function readDirectory(dirPath) {
|
|
|
711
289
|
}
|
|
712
290
|
}
|
|
713
291
|
|
|
714
|
-
/**
|
|
715
|
-
* Join path segments.
|
|
716
|
-
* Uses platform-specific separators (e.g., / or \).
|
|
717
|
-
*
|
|
718
|
-
* @param paths - Path segments to join
|
|
719
|
-
* @returns Joined path
|
|
720
|
-
*/
|
|
721
|
-
function join(...paths) {
|
|
722
|
-
return join$1(...paths);
|
|
723
|
-
}
|
|
724
|
-
|
|
725
292
|
const fsTraversalLogger = createScopedLogger('project-scope:fs:traversal');
|
|
726
293
|
/**
|
|
727
294
|
* Generic upward directory traversal.
|
|
@@ -730,11 +297,20 @@ const fsTraversalLogger = createScopedLogger('project-scope:fs:traversal');
|
|
|
730
297
|
* @param startPath - Starting directory
|
|
731
298
|
* @param predicate - Function to test each directory
|
|
732
299
|
* @returns First matching directory or null
|
|
300
|
+
*
|
|
301
|
+
* @example Finding directory containing README
|
|
302
|
+
* ```typescript
|
|
303
|
+
* // Find first directory containing a README
|
|
304
|
+
* const readmeDir = traverseUpward('./src/utils', (dir) =>
|
|
305
|
+
* existsSync(join(dir, 'README.md'))
|
|
306
|
+
* )
|
|
307
|
+
* // => '/project' or null
|
|
308
|
+
* ```
|
|
733
309
|
*/
|
|
734
310
|
function traverseUpward(startPath, predicate) {
|
|
735
311
|
fsTraversalLogger.debug('Starting upward traversal', { startPath });
|
|
736
312
|
let currentPath = resolve(startPath);
|
|
737
|
-
const rootPath = parse
|
|
313
|
+
const rootPath = parse(currentPath).root;
|
|
738
314
|
while (currentPath !== rootPath) {
|
|
739
315
|
if (predicate(currentPath)) {
|
|
740
316
|
fsTraversalLogger.debug('Upward traversal found match', { startPath, foundPath: currentPath });
|
|
@@ -742,7 +318,6 @@ function traverseUpward(startPath, predicate) {
|
|
|
742
318
|
}
|
|
743
319
|
currentPath = dirname(currentPath);
|
|
744
320
|
}
|
|
745
|
-
// Check root directory
|
|
746
321
|
if (predicate(rootPath)) {
|
|
747
322
|
fsTraversalLogger.debug('Upward traversal found match at root', { startPath, foundPath: rootPath });
|
|
748
323
|
return rootPath;
|
|
@@ -756,6 +331,17 @@ function traverseUpward(startPath, predicate) {
|
|
|
756
331
|
* @param startPath - Starting directory
|
|
757
332
|
* @param markers - Array of marker file names to search for
|
|
758
333
|
* @returns First directory containing any marker, or null
|
|
334
|
+
*
|
|
335
|
+
* @example Finding project root by marker files
|
|
336
|
+
* ```typescript
|
|
337
|
+
* // Find project root by looking for common marker files
|
|
338
|
+
* const projectRoot = locateByMarkers('./src/components', [
|
|
339
|
+
* 'package.json',
|
|
340
|
+
* 'nx.json',
|
|
341
|
+
* 'tsconfig.base.json'
|
|
342
|
+
* ])
|
|
343
|
+
* // => '/workspace/my-project'
|
|
344
|
+
* ```
|
|
759
345
|
*/
|
|
760
346
|
function locateByMarkers(startPath, markers) {
|
|
761
347
|
fsTraversalLogger.debug('Locating by markers', { startPath, markers });
|
|
@@ -771,217 +357,21 @@ function locateByMarkers(startPath, markers) {
|
|
|
771
357
|
* @param startPath - Starting directory
|
|
772
358
|
* @param test - Function to test if directory matches criteria
|
|
773
359
|
* @returns Matching directory path or null
|
|
360
|
+
*
|
|
361
|
+
* @example Finding directory with specific config
|
|
362
|
+
* ```typescript
|
|
363
|
+
* // Find directory with a specific config
|
|
364
|
+
* const configDir = findUpwardWhere('./deep/nested/path', (dir) =>
|
|
365
|
+
* existsSync(join(dir, '.eslintrc.js'))
|
|
366
|
+
* )
|
|
367
|
+
* ```
|
|
774
368
|
*/
|
|
775
369
|
function findUpwardWhere(startPath, test) {
|
|
776
370
|
fsTraversalLogger.debug('Finding upward where condition met', { startPath });
|
|
777
371
|
return traverseUpward(startPath, test);
|
|
778
372
|
}
|
|
779
373
|
|
|
780
|
-
|
|
781
|
-
* Pattern matching utilities with ReDoS protection.
|
|
782
|
-
* Uses character-by-character matching instead of regex where possible.
|
|
783
|
-
*/
|
|
784
|
-
/**
|
|
785
|
-
* Match path against glob pattern using safe character iteration.
|
|
786
|
-
* Avoids regex to prevent ReDoS attacks.
|
|
787
|
-
*
|
|
788
|
-
* Supported patterns:
|
|
789
|
-
* - * matches any characters except /
|
|
790
|
-
* - ** matches any characters including /
|
|
791
|
-
* - ? matches exactly one character except /
|
|
792
|
-
* - {a,b,c} matches any of the alternatives
|
|
793
|
-
*
|
|
794
|
-
* @param path - The filesystem path to test against the pattern
|
|
795
|
-
* @param pattern - The glob pattern to match against
|
|
796
|
-
* @returns True if path matches pattern
|
|
797
|
-
*
|
|
798
|
-
* @example
|
|
799
|
-
* ```typescript
|
|
800
|
-
* import { matchGlobPattern } from '@hyperfrontend/project-scope'
|
|
801
|
-
*
|
|
802
|
-
* matchGlobPattern('src/utils/helper.ts', '\*\*\/*.ts') // true
|
|
803
|
-
* matchGlobPattern('test.spec.ts', '\*.spec.ts') // true
|
|
804
|
-
* matchGlobPattern('config.json', '\*.{json,yaml}') // true
|
|
805
|
-
* matchGlobPattern('src/index.ts', 'src/\*.ts') // true
|
|
806
|
-
* ```
|
|
807
|
-
*/
|
|
808
|
-
function matchGlobPattern(path, pattern) {
|
|
809
|
-
return matchSegments(path.split('/'), pattern.split('/'), 0, 0);
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* Internal recursive function to match path segments against pattern segments.
|
|
813
|
-
*
|
|
814
|
-
* @param pathParts - Array of path segments split by '/'
|
|
815
|
-
* @param patternParts - Array of pattern segments split by '/'
|
|
816
|
-
* @param pathIdx - Current index in pathParts being examined
|
|
817
|
-
* @param patternIdx - Current index in patternParts being examined
|
|
818
|
-
* @returns True if remaining segments match
|
|
819
|
-
*/
|
|
820
|
-
function matchSegments(pathParts, patternParts, pathIdx, patternIdx) {
|
|
821
|
-
// Base cases
|
|
822
|
-
if (pathIdx === pathParts.length && patternIdx === patternParts.length) {
|
|
823
|
-
return true; // Both exhausted = match
|
|
824
|
-
}
|
|
825
|
-
if (patternIdx >= patternParts.length) {
|
|
826
|
-
return false; // Pattern exhausted but path remains
|
|
827
|
-
}
|
|
828
|
-
const patternPart = patternParts[patternIdx];
|
|
829
|
-
// Handle ** (globstar) - matches zero or more directories
|
|
830
|
-
if (patternPart === '**') {
|
|
831
|
-
// Try matching rest of pattern against current position and all future positions
|
|
832
|
-
for (let i = pathIdx; i <= pathParts.length; i++) {
|
|
833
|
-
if (matchSegments(pathParts, patternParts, i, patternIdx + 1)) {
|
|
834
|
-
return true;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
return false;
|
|
838
|
-
}
|
|
839
|
-
if (pathIdx >= pathParts.length) {
|
|
840
|
-
return false; // Path exhausted but pattern remains (and it's not **)
|
|
841
|
-
}
|
|
842
|
-
const pathPart = pathParts[pathIdx];
|
|
843
|
-
// Match current segment
|
|
844
|
-
if (matchSegment(pathPart, patternPart)) {
|
|
845
|
-
return matchSegments(pathParts, patternParts, pathIdx + 1, patternIdx + 1);
|
|
846
|
-
}
|
|
847
|
-
return false;
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Match a single path segment against a pattern segment.
|
|
851
|
-
* Handles *, ?, and {a,b,c} patterns.
|
|
852
|
-
*
|
|
853
|
-
* @param text - The path segment text to match
|
|
854
|
-
* @param pattern - The pattern segment to match against
|
|
855
|
-
* @returns True if the text matches the pattern
|
|
856
|
-
*/
|
|
857
|
-
function matchSegment(text, pattern) {
|
|
858
|
-
let textIdx = 0;
|
|
859
|
-
let patternIdx = 0;
|
|
860
|
-
while (patternIdx < pattern.length) {
|
|
861
|
-
const char = pattern[patternIdx];
|
|
862
|
-
if (char === '*') {
|
|
863
|
-
// * matches zero or more characters
|
|
864
|
-
patternIdx++;
|
|
865
|
-
if (patternIdx === pattern.length) {
|
|
866
|
-
return true; // * at end matches rest of string
|
|
867
|
-
}
|
|
868
|
-
// Try matching rest of pattern at each position in text
|
|
869
|
-
for (let i = textIdx; i <= text.length; i++) {
|
|
870
|
-
if (matchSegmentFrom(text, i, pattern, patternIdx)) {
|
|
871
|
-
return true;
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
return false;
|
|
875
|
-
}
|
|
876
|
-
else if (char === '?') {
|
|
877
|
-
// ? matches exactly one character
|
|
878
|
-
if (textIdx >= text.length) {
|
|
879
|
-
return false;
|
|
880
|
-
}
|
|
881
|
-
textIdx++;
|
|
882
|
-
patternIdx++;
|
|
883
|
-
}
|
|
884
|
-
else if (char === '{') {
|
|
885
|
-
// {a,b,c} matches any alternative
|
|
886
|
-
const closeIdx = findClosingBrace(pattern, patternIdx);
|
|
887
|
-
if (closeIdx === -1) {
|
|
888
|
-
// Unmatched brace, treat as literal
|
|
889
|
-
if (textIdx >= text.length || text[textIdx] !== char) {
|
|
890
|
-
return false;
|
|
891
|
-
}
|
|
892
|
-
textIdx++;
|
|
893
|
-
patternIdx++;
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
const alternatives = extractAlternatives(pattern.slice(patternIdx + 1, closeIdx));
|
|
897
|
-
for (const alt of alternatives) {
|
|
898
|
-
if (matchSegmentFrom(text, textIdx, text.slice(0, textIdx) + alt + pattern.slice(closeIdx + 1), textIdx)) {
|
|
899
|
-
return true;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
return false;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
else {
|
|
906
|
-
// Literal character
|
|
907
|
-
if (textIdx >= text.length || text[textIdx] !== char) {
|
|
908
|
-
return false;
|
|
909
|
-
}
|
|
910
|
-
textIdx++;
|
|
911
|
-
patternIdx++;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
return textIdx === text.length;
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* Helper to match from a specific position.
|
|
918
|
-
*
|
|
919
|
-
* @param text - The full text being matched
|
|
920
|
-
* @param textIdx - The starting index in text to match from
|
|
921
|
-
* @param pattern - The full pattern being matched
|
|
922
|
-
* @param patternIdx - The starting index in pattern to match from
|
|
923
|
-
* @returns True if the text matches the pattern from the given positions
|
|
924
|
-
*/
|
|
925
|
-
function matchSegmentFrom(text, textIdx, pattern, patternIdx) {
|
|
926
|
-
const remainingText = text.slice(textIdx);
|
|
927
|
-
const remainingPattern = pattern.slice(patternIdx);
|
|
928
|
-
return matchSegment(remainingText, remainingPattern);
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* Find closing brace for {a,b,c} pattern.
|
|
932
|
-
*
|
|
933
|
-
* @param pattern - The pattern string to search within
|
|
934
|
-
* @param startIdx - The index of the opening brace
|
|
935
|
-
* @returns The index of the matching closing brace, or -1 if not found
|
|
936
|
-
*/
|
|
937
|
-
function findClosingBrace(pattern, startIdx) {
|
|
938
|
-
let depth = 0;
|
|
939
|
-
for (let i = startIdx; i < pattern.length; i++) {
|
|
940
|
-
if (pattern[i] === '{') {
|
|
941
|
-
depth++;
|
|
942
|
-
}
|
|
943
|
-
else if (pattern[i] === '}') {
|
|
944
|
-
depth--;
|
|
945
|
-
if (depth === 0) {
|
|
946
|
-
return i;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
return -1;
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* Extract alternatives from {a,b,c} pattern content.
|
|
954
|
-
*
|
|
955
|
-
* @param content - The content between braces (without the braces themselves)
|
|
956
|
-
* @returns Array of alternative strings split by commas at depth 0
|
|
957
|
-
*/
|
|
958
|
-
function extractAlternatives(content) {
|
|
959
|
-
const alternatives = [];
|
|
960
|
-
let current = '';
|
|
961
|
-
let depth = 0;
|
|
962
|
-
for (let i = 0; i < content.length; i++) {
|
|
963
|
-
const char = content[i];
|
|
964
|
-
if (char === '{') {
|
|
965
|
-
depth++;
|
|
966
|
-
current += char;
|
|
967
|
-
}
|
|
968
|
-
else if (char === '}') {
|
|
969
|
-
depth--;
|
|
970
|
-
current += char;
|
|
971
|
-
}
|
|
972
|
-
else if (char === ',' && depth === 0) {
|
|
973
|
-
alternatives.push(current);
|
|
974
|
-
current = '';
|
|
975
|
-
}
|
|
976
|
-
else {
|
|
977
|
-
current += char;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
if (current) {
|
|
981
|
-
alternatives.push(current);
|
|
982
|
-
}
|
|
983
|
-
return alternatives;
|
|
984
|
-
}
|
|
374
|
+
createScopedLogger('project-scope:fs:write');
|
|
985
375
|
|
|
986
376
|
const walkLogger = createScopedLogger('project-scope:project:walk');
|
|
987
377
|
/**
|
|
@@ -1048,6 +438,18 @@ function matchPattern(path, pattern) {
|
|
|
1048
438
|
* @param startPath - Root directory to begin traversal
|
|
1049
439
|
* @param visitor - Callback function invoked for each file system entry
|
|
1050
440
|
* @param options - Configuration for traversal behavior
|
|
441
|
+
*
|
|
442
|
+
* @example Walking a directory tree
|
|
443
|
+
* ```typescript
|
|
444
|
+
* import { walkDirectory } from '@hyperfrontend/project-scope'
|
|
445
|
+
*
|
|
446
|
+
* const tsFiles: string[] = []
|
|
447
|
+
* walkDirectory('./src', (entry) => {
|
|
448
|
+
* if (entry.isFile && entry.name.endsWith('.ts')) {
|
|
449
|
+
* tsFiles.push(entry.relativePath)
|
|
450
|
+
* }
|
|
451
|
+
* }, { maxDepth: 5, respectGitignore: true })
|
|
452
|
+
* ```
|
|
1051
453
|
*/
|
|
1052
454
|
function walkDirectory(startPath, visitor, options) {
|
|
1053
455
|
walkLogger.debug('Starting directory walk', {
|
|
@@ -1130,6 +532,19 @@ function walkDirectory(startPath, visitor, options) {
|
|
|
1130
532
|
* @param startPath - Root path within the tree to begin traversal
|
|
1131
533
|
* @param visitor - Callback function invoked for each tree entry
|
|
1132
534
|
* @param options - Configuration for traversal behavior
|
|
535
|
+
*
|
|
536
|
+
* @example Walking a virtual tree
|
|
537
|
+
* ```typescript
|
|
538
|
+
* import { createTree, walkTree } from '@hyperfrontend/project-scope'
|
|
539
|
+
*
|
|
540
|
+
* const tree = createTree('/workspace')
|
|
541
|
+
* walkTree(tree, 'src', (entry) => {
|
|
542
|
+
* if (entry.isDirectory) {
|
|
543
|
+
* console.log('Dir:', entry.relativePath)
|
|
544
|
+
* return 'skip' // Don't recurse into this directory
|
|
545
|
+
* }
|
|
546
|
+
* })
|
|
547
|
+
* ```
|
|
1133
548
|
*/
|
|
1134
549
|
function walkTree(tree, startPath, visitor, options) {
|
|
1135
550
|
const maxDepth = options?.maxDepth ?? -1;
|
|
@@ -1210,7 +625,7 @@ function matchesPatterns(path, patterns) {
|
|
|
1210
625
|
* @param options - Configuration for search behavior
|
|
1211
626
|
* @returns List of relative file paths that match the patterns
|
|
1212
627
|
*
|
|
1213
|
-
* @example
|
|
628
|
+
* @example Finding files by pattern
|
|
1214
629
|
* ```typescript
|
|
1215
630
|
* import { findFiles } from '@hyperfrontend/project-scope'
|
|
1216
631
|
*
|
|
@@ -1255,6 +670,15 @@ function findFiles(startPath, patterns, options) {
|
|
|
1255
670
|
* @param patterns - Glob patterns (e.g., '*.ts', '**\/*.json') to filter files
|
|
1256
671
|
* @param options - Configuration for search behavior
|
|
1257
672
|
* @returns List of virtual file paths that match the patterns
|
|
673
|
+
*
|
|
674
|
+
* @example Finding files in a virtual tree
|
|
675
|
+
* ```typescript
|
|
676
|
+
* import { createTree, findFilesInTree } from '@hyperfrontend/project-scope'
|
|
677
|
+
*
|
|
678
|
+
* const tree = createTree('/workspace')
|
|
679
|
+
* const tsFiles = findFilesInTree(tree, '**\/*.ts', { maxDepth: 3 })
|
|
680
|
+
* // => ['src/index.ts', 'src/utils/helpers.ts']
|
|
681
|
+
* ```
|
|
1258
682
|
*/
|
|
1259
683
|
function findFilesInTree(tree, patterns, options) {
|
|
1260
684
|
const normalizedPatterns = isArray(patterns) ? patterns : [patterns];
|
|
@@ -1282,6 +706,14 @@ function findFilesInTree(tree, patterns, options) {
|
|
|
1282
706
|
* @param patterns - Glob patterns to filter directories (supports wildcards)
|
|
1283
707
|
* @param options - Configuration for search behavior
|
|
1284
708
|
* @returns List of relative directory paths that match the patterns
|
|
709
|
+
*
|
|
710
|
+
* @example Finding directories by pattern
|
|
711
|
+
* ```typescript
|
|
712
|
+
* import { findDirectories } from '@hyperfrontend/project-scope'
|
|
713
|
+
*
|
|
714
|
+
* const componentDirs = findDirectories('./src', 'components')
|
|
715
|
+
* // => ['features/auth/components', 'features/dashboard/components']
|
|
716
|
+
* ```
|
|
1285
717
|
*/
|
|
1286
718
|
function findDirectories(startPath, patterns, options) {
|
|
1287
719
|
const normalizedPatterns = isArray(patterns) ? patterns : [patterns];
|
|
@@ -1302,324 +734,6 @@ function findDirectories(startPath, patterns, options) {
|
|
|
1302
734
|
return results;
|
|
1303
735
|
}
|
|
1304
736
|
|
|
1305
|
-
/**
|
|
1306
|
-
* Known configuration file patterns organized by type.
|
|
1307
|
-
*/
|
|
1308
|
-
const CONFIG_PATTERNS = {
|
|
1309
|
-
// Package Management
|
|
1310
|
-
'package.json': {
|
|
1311
|
-
patterns: ['package.json'],
|
|
1312
|
-
format: 'json',
|
|
1313
|
-
description: 'NPM package manifest',
|
|
1314
|
-
},
|
|
1315
|
-
'package-lock.json': {
|
|
1316
|
-
patterns: ['package-lock.json'],
|
|
1317
|
-
format: 'json',
|
|
1318
|
-
description: 'NPM lockfile',
|
|
1319
|
-
},
|
|
1320
|
-
'pnpm-lock.yaml': {
|
|
1321
|
-
patterns: ['pnpm-lock.yaml'],
|
|
1322
|
-
format: 'yaml',
|
|
1323
|
-
description: 'PNPM lockfile',
|
|
1324
|
-
},
|
|
1325
|
-
'yarn.lock': {
|
|
1326
|
-
patterns: ['yarn.lock'],
|
|
1327
|
-
format: 'text',
|
|
1328
|
-
description: 'Yarn lockfile',
|
|
1329
|
-
},
|
|
1330
|
-
'.npmrc': {
|
|
1331
|
-
patterns: ['.npmrc'],
|
|
1332
|
-
format: 'ini',
|
|
1333
|
-
description: 'NPM configuration',
|
|
1334
|
-
sensitive: true,
|
|
1335
|
-
},
|
|
1336
|
-
// TypeScript
|
|
1337
|
-
tsconfig: {
|
|
1338
|
-
patterns: ['tsconfig.json', 'tsconfig.*.json'],
|
|
1339
|
-
format: 'jsonc',
|
|
1340
|
-
description: 'TypeScript configuration',
|
|
1341
|
-
canExtend: true,
|
|
1342
|
-
},
|
|
1343
|
-
// Monorepo
|
|
1344
|
-
nx: {
|
|
1345
|
-
patterns: ['nx.json'],
|
|
1346
|
-
format: 'json',
|
|
1347
|
-
description: 'NX workspace configuration',
|
|
1348
|
-
},
|
|
1349
|
-
'project.json': {
|
|
1350
|
-
patterns: ['project.json', '**/project.json'],
|
|
1351
|
-
format: 'json',
|
|
1352
|
-
description: 'NX project configuration',
|
|
1353
|
-
},
|
|
1354
|
-
'workspace.json': {
|
|
1355
|
-
patterns: ['workspace.json'],
|
|
1356
|
-
format: 'json',
|
|
1357
|
-
description: 'NX workspace projects (deprecated)',
|
|
1358
|
-
},
|
|
1359
|
-
turbo: {
|
|
1360
|
-
patterns: ['turbo.json'],
|
|
1361
|
-
format: 'jsonc',
|
|
1362
|
-
description: 'TurboRepo configuration',
|
|
1363
|
-
},
|
|
1364
|
-
lerna: {
|
|
1365
|
-
patterns: ['lerna.json'],
|
|
1366
|
-
format: 'json',
|
|
1367
|
-
description: 'Lerna configuration',
|
|
1368
|
-
},
|
|
1369
|
-
// Build Tools
|
|
1370
|
-
webpack: {
|
|
1371
|
-
patterns: ['webpack.config.js', 'webpack.config.ts', 'webpack.config.cjs', 'webpack.config.mjs'],
|
|
1372
|
-
format: 'js',
|
|
1373
|
-
description: 'Webpack configuration',
|
|
1374
|
-
},
|
|
1375
|
-
rollup: {
|
|
1376
|
-
patterns: ['rollup.config.js', 'rollup.config.ts', 'rollup.config.mjs'],
|
|
1377
|
-
format: 'js',
|
|
1378
|
-
description: 'Rollup configuration',
|
|
1379
|
-
},
|
|
1380
|
-
vite: {
|
|
1381
|
-
patterns: ['vite.config.js', 'vite.config.ts', 'vite.config.mjs'],
|
|
1382
|
-
format: 'js',
|
|
1383
|
-
description: 'Vite configuration',
|
|
1384
|
-
},
|
|
1385
|
-
esbuild: {
|
|
1386
|
-
patterns: ['esbuild.config.js', 'esbuild.config.ts', 'esbuild.config.mjs'],
|
|
1387
|
-
format: 'js',
|
|
1388
|
-
description: 'esbuild configuration',
|
|
1389
|
-
},
|
|
1390
|
-
babel: {
|
|
1391
|
-
patterns: ['babel.config.js', 'babel.config.json', '.babelrc', '.babelrc.js', '.babelrc.json'],
|
|
1392
|
-
format: 'json',
|
|
1393
|
-
description: 'Babel configuration',
|
|
1394
|
-
},
|
|
1395
|
-
swc: {
|
|
1396
|
-
patterns: ['.swcrc'],
|
|
1397
|
-
format: 'json',
|
|
1398
|
-
description: 'SWC configuration',
|
|
1399
|
-
},
|
|
1400
|
-
// Testing
|
|
1401
|
-
jest: {
|
|
1402
|
-
patterns: ['jest.config.js', 'jest.config.ts', 'jest.config.mjs'],
|
|
1403
|
-
description: 'Jest configuration',
|
|
1404
|
-
},
|
|
1405
|
-
vitest: {
|
|
1406
|
-
patterns: ['vitest.config.js', 'vitest.config.ts'],
|
|
1407
|
-
description: 'Vitest configuration',
|
|
1408
|
-
},
|
|
1409
|
-
cypress: {
|
|
1410
|
-
patterns: ['cypress.config.js', 'cypress.config.ts'],
|
|
1411
|
-
description: 'Cypress configuration',
|
|
1412
|
-
},
|
|
1413
|
-
playwright: {
|
|
1414
|
-
patterns: ['playwright.config.js', 'playwright.config.ts'],
|
|
1415
|
-
description: 'Playwright configuration',
|
|
1416
|
-
},
|
|
1417
|
-
// Framework configs
|
|
1418
|
-
next: {
|
|
1419
|
-
patterns: ['next.config.js', 'next.config.mjs', 'next.config.ts'],
|
|
1420
|
-
format: 'js',
|
|
1421
|
-
description: 'Next.js configuration',
|
|
1422
|
-
},
|
|
1423
|
-
angular: {
|
|
1424
|
-
patterns: ['angular.json'],
|
|
1425
|
-
format: 'json',
|
|
1426
|
-
description: 'Angular CLI configuration',
|
|
1427
|
-
},
|
|
1428
|
-
nuxt: {
|
|
1429
|
-
patterns: ['nuxt.config.js', 'nuxt.config.ts'],
|
|
1430
|
-
format: 'js',
|
|
1431
|
-
description: 'Nuxt.js configuration',
|
|
1432
|
-
},
|
|
1433
|
-
svelte: {
|
|
1434
|
-
patterns: ['svelte.config.js', 'svelte.config.ts'],
|
|
1435
|
-
format: 'js',
|
|
1436
|
-
description: 'SvelteKit configuration',
|
|
1437
|
-
},
|
|
1438
|
-
astro: {
|
|
1439
|
-
patterns: ['astro.config.js', 'astro.config.ts', 'astro.config.mjs'],
|
|
1440
|
-
format: 'js',
|
|
1441
|
-
description: 'Astro configuration',
|
|
1442
|
-
},
|
|
1443
|
-
// Linting & Formatting
|
|
1444
|
-
eslint: {
|
|
1445
|
-
patterns: [
|
|
1446
|
-
'eslint.config.js',
|
|
1447
|
-
'eslint.config.cjs',
|
|
1448
|
-
'eslint.config.mjs',
|
|
1449
|
-
'.eslintrc',
|
|
1450
|
-
'.eslintrc.js',
|
|
1451
|
-
'.eslintrc.json',
|
|
1452
|
-
'.eslintrc.yml',
|
|
1453
|
-
],
|
|
1454
|
-
format: 'js',
|
|
1455
|
-
description: 'ESLint configuration',
|
|
1456
|
-
},
|
|
1457
|
-
prettier: {
|
|
1458
|
-
patterns: ['prettier.config.js', 'prettier.config.cjs', '.prettierrc', '.prettierrc.js', '.prettierrc.json', '.prettierrc.yml'],
|
|
1459
|
-
format: 'json',
|
|
1460
|
-
description: 'Prettier configuration',
|
|
1461
|
-
},
|
|
1462
|
-
// Environment (sensitive)
|
|
1463
|
-
env: {
|
|
1464
|
-
patterns: ['.env', '.env.*', '*.env'],
|
|
1465
|
-
format: 'dotenv',
|
|
1466
|
-
description: 'Environment variables',
|
|
1467
|
-
sensitive: true,
|
|
1468
|
-
},
|
|
1469
|
-
// Git
|
|
1470
|
-
'.gitignore': {
|
|
1471
|
-
patterns: ['.gitignore'],
|
|
1472
|
-
format: 'text',
|
|
1473
|
-
description: 'Git ignore patterns',
|
|
1474
|
-
},
|
|
1475
|
-
'.gitattributes': {
|
|
1476
|
-
patterns: ['.gitattributes'],
|
|
1477
|
-
format: 'text',
|
|
1478
|
-
description: 'Git attributes',
|
|
1479
|
-
},
|
|
1480
|
-
};
|
|
1481
|
-
/**
|
|
1482
|
-
* Get patterns for specific config types.
|
|
1483
|
-
*
|
|
1484
|
-
* @param types - Array of config types to get patterns for
|
|
1485
|
-
* @returns Array of file patterns
|
|
1486
|
-
*/
|
|
1487
|
-
function getConfigPatternsByType(types) {
|
|
1488
|
-
return types.flatMap((type) => CONFIG_PATTERNS[type]?.patterns ?? []);
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
/**
|
|
1492
|
-
* Global registry of all caches for bulk operations.
|
|
1493
|
-
*/
|
|
1494
|
-
const cacheRegistry = createSet();
|
|
1495
|
-
/**
|
|
1496
|
-
* Create a cache with optional TTL and size limits.
|
|
1497
|
-
*
|
|
1498
|
-
* The cache provides a simple key-value store with:
|
|
1499
|
-
* - Optional TTL (time-to-live) for automatic expiration
|
|
1500
|
-
* - Optional maxSize for limiting cache size with FIFO eviction
|
|
1501
|
-
* - Lazy expiration (entries are checked on access)
|
|
1502
|
-
*
|
|
1503
|
-
* @param options - Cache configuration options
|
|
1504
|
-
* @returns Cache instance
|
|
1505
|
-
*
|
|
1506
|
-
* @example
|
|
1507
|
-
* ```typescript
|
|
1508
|
-
* // Basic cache
|
|
1509
|
-
* const cache = createCache<string, number>()
|
|
1510
|
-
* cache.set('answer', 42)
|
|
1511
|
-
* cache.get('answer') // 42
|
|
1512
|
-
*
|
|
1513
|
-
* // Cache with TTL (expires after 60 seconds)
|
|
1514
|
-
* const ttlCache = createCache<string, object>({ ttl: 60000 })
|
|
1515
|
-
*
|
|
1516
|
-
* // Cache with max size (evicts oldest when full)
|
|
1517
|
-
* const lruCache = createCache<string, object>({ maxSize: 100 })
|
|
1518
|
-
*
|
|
1519
|
-
* // Combined options
|
|
1520
|
-
* const configCache = createCache<string, object>({
|
|
1521
|
-
* ttl: 30000,
|
|
1522
|
-
* maxSize: 50
|
|
1523
|
-
* })
|
|
1524
|
-
* ```
|
|
1525
|
-
*/
|
|
1526
|
-
function createCache(options) {
|
|
1527
|
-
const { ttl, maxSize } = options ?? {};
|
|
1528
|
-
const store = createMap();
|
|
1529
|
-
// Track insertion order for FIFO eviction
|
|
1530
|
-
const insertionOrder = [];
|
|
1531
|
-
/**
|
|
1532
|
-
* Check if an entry is expired.
|
|
1533
|
-
*
|
|
1534
|
-
* @param entry - Cache entry to check
|
|
1535
|
-
* @returns True if entry is expired
|
|
1536
|
-
*/
|
|
1537
|
-
function isExpired(entry) {
|
|
1538
|
-
if (ttl === undefined)
|
|
1539
|
-
return false;
|
|
1540
|
-
// eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
|
|
1541
|
-
return Date.now() - entry.timestamp > ttl;
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Evict oldest entries to make room for new ones.
|
|
1545
|
-
*/
|
|
1546
|
-
function evictIfNeeded() {
|
|
1547
|
-
if (maxSize === undefined)
|
|
1548
|
-
return;
|
|
1549
|
-
while (store.size >= maxSize && insertionOrder.length > 0) {
|
|
1550
|
-
const oldestKey = insertionOrder.shift();
|
|
1551
|
-
if (oldestKey !== undefined) {
|
|
1552
|
-
store.delete(oldestKey);
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
/**
|
|
1557
|
-
* Remove key from insertion order tracking.
|
|
1558
|
-
*
|
|
1559
|
-
* @param key - Key to remove from order tracking
|
|
1560
|
-
*/
|
|
1561
|
-
function removeFromOrder(key) {
|
|
1562
|
-
const index = insertionOrder.indexOf(key);
|
|
1563
|
-
if (index !== -1) {
|
|
1564
|
-
insertionOrder.splice(index, 1);
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
const cache = {
|
|
1568
|
-
get(key) {
|
|
1569
|
-
const entry = store.get(key);
|
|
1570
|
-
if (!entry)
|
|
1571
|
-
return undefined;
|
|
1572
|
-
if (isExpired(entry)) {
|
|
1573
|
-
store.delete(key);
|
|
1574
|
-
removeFromOrder(key);
|
|
1575
|
-
return undefined;
|
|
1576
|
-
}
|
|
1577
|
-
return entry.value;
|
|
1578
|
-
},
|
|
1579
|
-
set(key, value) {
|
|
1580
|
-
// If key exists, remove from order first
|
|
1581
|
-
if (store.has(key)) {
|
|
1582
|
-
removeFromOrder(key);
|
|
1583
|
-
}
|
|
1584
|
-
else {
|
|
1585
|
-
// Evict if needed before adding new entry
|
|
1586
|
-
evictIfNeeded();
|
|
1587
|
-
}
|
|
1588
|
-
// eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
|
|
1589
|
-
store.set(key, { value, timestamp: Date.now() });
|
|
1590
|
-
insertionOrder.push(key);
|
|
1591
|
-
},
|
|
1592
|
-
has(key) {
|
|
1593
|
-
const entry = store.get(key);
|
|
1594
|
-
if (!entry)
|
|
1595
|
-
return false;
|
|
1596
|
-
if (isExpired(entry)) {
|
|
1597
|
-
store.delete(key);
|
|
1598
|
-
removeFromOrder(key);
|
|
1599
|
-
return false;
|
|
1600
|
-
}
|
|
1601
|
-
return true;
|
|
1602
|
-
},
|
|
1603
|
-
delete(key) {
|
|
1604
|
-
removeFromOrder(key);
|
|
1605
|
-
return store.delete(key);
|
|
1606
|
-
},
|
|
1607
|
-
clear() {
|
|
1608
|
-
store.clear();
|
|
1609
|
-
insertionOrder.length = 0;
|
|
1610
|
-
},
|
|
1611
|
-
size() {
|
|
1612
|
-
return store.size;
|
|
1613
|
-
},
|
|
1614
|
-
keys() {
|
|
1615
|
-
return [...insertionOrder];
|
|
1616
|
-
},
|
|
1617
|
-
};
|
|
1618
|
-
// Register cache for global operations
|
|
1619
|
-
cacheRegistry.add(cache);
|
|
1620
|
-
return freeze(cache);
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
737
|
const configLogger = createScopedLogger('project-scope:config');
|
|
1624
738
|
/**
|
|
1625
739
|
* Cache for config detection results.
|
|
@@ -1637,7 +751,7 @@ const configDetectionCache = createCache({ ttl: 30000, maxSize: 50 });
|
|
|
1637
751
|
* @param options - Detection options
|
|
1638
752
|
* @returns Array of detected configuration files
|
|
1639
753
|
*
|
|
1640
|
-
* @example
|
|
754
|
+
* @example Detecting configuration files
|
|
1641
755
|
* ```typescript
|
|
1642
756
|
* import { detectConfigs } from '@hyperfrontend/project-scope'
|
|
1643
757
|
*
|
|
@@ -1717,6 +831,14 @@ function detectConfigs(rootPath, types, options) {
|
|
|
1717
831
|
* Clear the config detection cache.
|
|
1718
832
|
*
|
|
1719
833
|
* Useful for testing or when the project files have changed.
|
|
834
|
+
*
|
|
835
|
+
* @example Clearing the config detection cache
|
|
836
|
+
* ```typescript
|
|
837
|
+
* import { clearConfigDetectionCache } from '@hyperfrontend/project-scope'
|
|
838
|
+
*
|
|
839
|
+
* // Reset cache after modifying config files
|
|
840
|
+
* clearConfigDetectionCache()
|
|
841
|
+
* ```
|
|
1720
842
|
*/
|
|
1721
843
|
function clearConfigDetectionCache() {
|
|
1722
844
|
configDetectionCache.clear();
|
|
@@ -1727,6 +849,17 @@ function clearConfigDetectionCache() {
|
|
|
1727
849
|
* @param rootPath - Project root directory
|
|
1728
850
|
* @param type - Config type to find
|
|
1729
851
|
* @returns Full path to config file or null if not found
|
|
852
|
+
*
|
|
853
|
+
* @example Finding a specific config file
|
|
854
|
+
* ```typescript
|
|
855
|
+
* import { findConfigFile } from '@hyperfrontend/project-scope'
|
|
856
|
+
*
|
|
857
|
+
* const tsConfig = findConfigFile('/project', 'typescript')
|
|
858
|
+
* // => '/project/tsconfig.json'
|
|
859
|
+
*
|
|
860
|
+
* const eslint = findConfigFile('/project', 'eslint')
|
|
861
|
+
* // => '/project/.eslintrc.js' or null if not found
|
|
862
|
+
* ```
|
|
1730
863
|
*/
|
|
1731
864
|
function findConfigFile(rootPath, type) {
|
|
1732
865
|
const info = CONFIG_PATTERNS[type];
|
|
@@ -1750,76 +883,6 @@ function findConfigFile(rootPath, type) {
|
|
|
1750
883
|
}
|
|
1751
884
|
return null;
|
|
1752
885
|
}
|
|
1753
|
-
/**
|
|
1754
|
-
* Get all known config file patterns for a given configuration type.
|
|
1755
|
-
*
|
|
1756
|
-
* @param type - Configuration type identifier
|
|
1757
|
-
* @returns Array of glob patterns for matching config files
|
|
1758
|
-
*/
|
|
1759
|
-
function getConfigPaths(type) {
|
|
1760
|
-
const info = CONFIG_PATTERNS[type];
|
|
1761
|
-
return info?.patterns ?? [];
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
/**
|
|
1765
|
-
* Safe copies of Number built-in methods and constants.
|
|
1766
|
-
*
|
|
1767
|
-
* These references are captured at module initialization time to protect against
|
|
1768
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
1769
|
-
*
|
|
1770
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/number
|
|
1771
|
-
*/
|
|
1772
|
-
// Capture references at module initialization time
|
|
1773
|
-
const _parseInt = globalThis.parseInt;
|
|
1774
|
-
const _parseFloat = globalThis.parseFloat;
|
|
1775
|
-
// ============================================================================
|
|
1776
|
-
// Parsing
|
|
1777
|
-
// ============================================================================
|
|
1778
|
-
/**
|
|
1779
|
-
* (Safe copy) Parses a string and returns an integer.
|
|
1780
|
-
*/
|
|
1781
|
-
const parseInt = _parseInt;
|
|
1782
|
-
/**
|
|
1783
|
-
* (Safe copy) Parses a string and returns a floating point number.
|
|
1784
|
-
*/
|
|
1785
|
-
const parseFloat = _parseFloat;
|
|
1786
|
-
|
|
1787
|
-
/**
|
|
1788
|
-
* Create a structured error with code and optional context.
|
|
1789
|
-
*
|
|
1790
|
-
* @param message - The human-readable error message
|
|
1791
|
-
* @param code - The machine-readable error code for programmatic handling
|
|
1792
|
-
* @param context - Additional contextual information about the error
|
|
1793
|
-
* @returns Structured error instance with code and context properties
|
|
1794
|
-
*
|
|
1795
|
-
* @example
|
|
1796
|
-
* ```typescript
|
|
1797
|
-
* import { createStructuredError } from '@hyperfrontend/project-scope'
|
|
1798
|
-
*
|
|
1799
|
-
* throw createStructuredError(
|
|
1800
|
-
* 'Configuration file not found',
|
|
1801
|
-
* 'CONFIG_NOT_FOUND',
|
|
1802
|
-
* { path: './config.json', searched: ['./config.json', './settings.json'] }
|
|
1803
|
-
* )
|
|
1804
|
-
* ```
|
|
1805
|
-
*/
|
|
1806
|
-
function createStructuredError(message, code, context) {
|
|
1807
|
-
const error = createError(message);
|
|
1808
|
-
error.code = code;
|
|
1809
|
-
error.context = context ?? {};
|
|
1810
|
-
return error;
|
|
1811
|
-
}
|
|
1812
|
-
/**
|
|
1813
|
-
* Create a configuration-related error.
|
|
1814
|
-
*
|
|
1815
|
-
* @param message - The human-readable error message
|
|
1816
|
-
* @param code - The machine-readable error code for programmatic handling
|
|
1817
|
-
* @param context - Additional contextual information (e.g., file path, config key)
|
|
1818
|
-
* @returns Structured error instance tagged with type 'config'
|
|
1819
|
-
*/
|
|
1820
|
-
function createConfigError(message, code, context) {
|
|
1821
|
-
return createStructuredError(message, code, { ...context, type: 'config' });
|
|
1822
|
-
}
|
|
1823
886
|
|
|
1824
887
|
/**
|
|
1825
888
|
* Detect config type from file name.
|
|
@@ -2032,11 +1095,23 @@ function parseDotenv(content) {
|
|
|
2032
1095
|
* @param type - Category of configuration (e.g., typescript, eslint)
|
|
2033
1096
|
* @param format - Whether to strip comments (jsonc) or parse strictly (json)
|
|
2034
1097
|
* @returns Configuration object with parsed data and extends references
|
|
1098
|
+
*
|
|
1099
|
+
* @example Parsing JSON configuration
|
|
1100
|
+
* ```typescript
|
|
1101
|
+
* import { parseJsonConfig } from '@hyperfrontend/project-scope'
|
|
1102
|
+
*
|
|
1103
|
+
* const config = parseJsonConfig(
|
|
1104
|
+
* 'tsconfig.json',
|
|
1105
|
+
* '{ "extends": "./base.json", "compilerOptions": {} }',
|
|
1106
|
+
* 'typescript'
|
|
1107
|
+
* )
|
|
1108
|
+
* // => { type: 'typescript', path: 'tsconfig.json', data: {...}, extends: ['./base.json'] }
|
|
1109
|
+
* ```
|
|
2035
1110
|
*/
|
|
2036
1111
|
function parseJsonConfig(filePath, content, type, format = 'json') {
|
|
2037
1112
|
const cleanContent = format === 'jsonc' ? stripJsonComments(content) : content;
|
|
2038
1113
|
try {
|
|
2039
|
-
const data = parse(cleanContent);
|
|
1114
|
+
const data = parse$1(cleanContent);
|
|
2040
1115
|
let extendsPath;
|
|
2041
1116
|
if (typeof data['extends'] === 'string') {
|
|
2042
1117
|
extendsPath = [data['extends']];
|
|
@@ -2067,6 +1142,14 @@ function parseJsonConfig(filePath, content, type, format = 'json') {
|
|
|
2067
1142
|
* @param content - Raw file content to parse
|
|
2068
1143
|
* @param type - Category of configuration (e.g., github-actions, docker-compose)
|
|
2069
1144
|
* @returns Configuration object with parsed YAML data
|
|
1145
|
+
*
|
|
1146
|
+
* @example Parsing YAML configuration
|
|
1147
|
+
* ```typescript
|
|
1148
|
+
* import { parseYamlConfig } from '@hyperfrontend/project-scope'
|
|
1149
|
+
*
|
|
1150
|
+
* const config = parseYamlConfig('.github/workflows/ci.yml', yamlContent, 'github-actions')
|
|
1151
|
+
* // => { type: 'github-actions', path: '...', format: 'yaml', data: {...} }
|
|
1152
|
+
* ```
|
|
2070
1153
|
*/
|
|
2071
1154
|
function parseYamlConfig(filePath, content, type) {
|
|
2072
1155
|
const data = parseSimpleYaml(content);
|
|
@@ -2083,6 +1166,14 @@ function parseYamlConfig(filePath, content, type) {
|
|
|
2083
1166
|
* @param filePath - Path to config file
|
|
2084
1167
|
* @param type - Optional config type (auto-detected if not provided)
|
|
2085
1168
|
* @returns Parsed configuration
|
|
1169
|
+
*
|
|
1170
|
+
* @example Parsing a configuration file
|
|
1171
|
+
* ```typescript
|
|
1172
|
+
* import { parseConfig } from '@hyperfrontend/project-scope'
|
|
1173
|
+
*
|
|
1174
|
+
* const tsConfig = parseConfig('/project/tsconfig.json')
|
|
1175
|
+
* const eslintConfig = parseConfig('/project/.eslintrc.yml', 'eslint')
|
|
1176
|
+
* ```
|
|
2086
1177
|
*/
|
|
2087
1178
|
function parseConfig(filePath, type) {
|
|
2088
1179
|
const content = readFileContent(filePath);
|
|
@@ -2127,33 +1218,6 @@ function parseConfig(filePath, type) {
|
|
|
2127
1218
|
};
|
|
2128
1219
|
}
|
|
2129
1220
|
}
|
|
2130
|
-
/**
|
|
2131
|
-
* Read and parse config file if it exists.
|
|
2132
|
-
*
|
|
2133
|
-
* @param configPath - Path to config file
|
|
2134
|
-
* @returns Parsed config or null if file doesn't exist
|
|
2135
|
-
*/
|
|
2136
|
-
function readConfigIfExists(configPath) {
|
|
2137
|
-
const content = readFileIfExists(configPath);
|
|
2138
|
-
if (!content)
|
|
2139
|
-
return null;
|
|
2140
|
-
try {
|
|
2141
|
-
const format = detectFormat(configPath);
|
|
2142
|
-
switch (format) {
|
|
2143
|
-
case 'json':
|
|
2144
|
-
return parse(content);
|
|
2145
|
-
case 'jsonc':
|
|
2146
|
-
return parse(stripJsonComments(content));
|
|
2147
|
-
case 'yaml':
|
|
2148
|
-
return parseSimpleYaml(content);
|
|
2149
|
-
default:
|
|
2150
|
-
return null;
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
catch {
|
|
2154
|
-
return null;
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
1221
|
|
|
2158
1222
|
const packageLogger = createScopedLogger('project-scope:project:package');
|
|
2159
1223
|
/**
|
|
@@ -2225,13 +1289,21 @@ function validatePackageJson(data) {
|
|
|
2225
1289
|
* @param projectPath - Project directory path or path to package.json
|
|
2226
1290
|
* @returns Parsed package.json
|
|
2227
1291
|
* @throws {Error} Error if file doesn't exist or is invalid
|
|
1292
|
+
*
|
|
1293
|
+
* @example Reading package.json
|
|
1294
|
+
* ```typescript
|
|
1295
|
+
* import { readPackageJson } from '@hyperfrontend/project-scope'
|
|
1296
|
+
*
|
|
1297
|
+
* const pkg = readPackageJson('/path/to/project')
|
|
1298
|
+
* console.log(pkg.name, pkg.version)
|
|
1299
|
+
* ```
|
|
2228
1300
|
*/
|
|
2229
1301
|
function readPackageJson(projectPath) {
|
|
2230
1302
|
const packageJsonPath = projectPath.endsWith('package.json') ? projectPath : join$1(projectPath, 'package.json');
|
|
2231
1303
|
packageLogger.debug('Reading package.json', { path: packageJsonPath });
|
|
2232
1304
|
const content = readFileContent(packageJsonPath);
|
|
2233
1305
|
try {
|
|
2234
|
-
const data = parse(content);
|
|
1306
|
+
const data = parse$1(content);
|
|
2235
1307
|
const validated = validatePackageJson(data);
|
|
2236
1308
|
packageLogger.debug('Package.json read successfully', { path: packageJsonPath, name: validated.name });
|
|
2237
1309
|
return validated;
|
|
@@ -2253,6 +1325,16 @@ function readPackageJson(projectPath) {
|
|
|
2253
1325
|
*
|
|
2254
1326
|
* @param projectPath - Project directory path or path to package.json
|
|
2255
1327
|
* @returns Parsed package.json or null if not found
|
|
1328
|
+
*
|
|
1329
|
+
* @example Reading package.json if it exists
|
|
1330
|
+
* ```typescript
|
|
1331
|
+
* import { readPackageJsonIfExists } from '@hyperfrontend/project-scope'
|
|
1332
|
+
*
|
|
1333
|
+
* const pkg = readPackageJsonIfExists('/path/to/project')
|
|
1334
|
+
* if (pkg) {
|
|
1335
|
+
* console.log('Found:', pkg.name)
|
|
1336
|
+
* }
|
|
1337
|
+
* ```
|
|
2256
1338
|
*/
|
|
2257
1339
|
function readPackageJsonIfExists(projectPath) {
|
|
2258
1340
|
const packageJsonPath = projectPath.endsWith('package.json') ? projectPath : join$1(projectPath, 'package.json');
|
|
@@ -2262,7 +1344,7 @@ function readPackageJsonIfExists(projectPath) {
|
|
|
2262
1344
|
return null;
|
|
2263
1345
|
}
|
|
2264
1346
|
try {
|
|
2265
|
-
const validated = validatePackageJson(parse(content));
|
|
1347
|
+
const validated = validatePackageJson(parse$1(content));
|
|
2266
1348
|
packageLogger.debug('Package.json loaded', { path: packageJsonPath, name: validated.name });
|
|
2267
1349
|
return validated;
|
|
2268
1350
|
}
|
|
@@ -2276,6 +1358,14 @@ function readPackageJsonIfExists(projectPath) {
|
|
|
2276
1358
|
*
|
|
2277
1359
|
* @param startPath - Starting path
|
|
2278
1360
|
* @returns Path to directory containing package.json, or null if not found
|
|
1361
|
+
*
|
|
1362
|
+
* @example Finding nearest package.json
|
|
1363
|
+
* ```typescript
|
|
1364
|
+
* import { findNearestPackageJson } from '@hyperfrontend/project-scope'
|
|
1365
|
+
*
|
|
1366
|
+
* const pkgDir = findNearestPackageJson('./src/deep/nested/file.ts')
|
|
1367
|
+
* // => '/path/to/project'
|
|
1368
|
+
* ```
|
|
2279
1369
|
*/
|
|
2280
1370
|
function findNearestPackageJson(startPath) {
|
|
2281
1371
|
return locateByMarkers(startPath, ['package.json']);
|
|
@@ -2286,6 +1376,15 @@ function findNearestPackageJson(startPath) {
|
|
|
2286
1376
|
*
|
|
2287
1377
|
* @param packageJson - Parsed package.json
|
|
2288
1378
|
* @returns All dependencies categorized
|
|
1379
|
+
*
|
|
1380
|
+
* @example Extracting all dependencies
|
|
1381
|
+
* ```typescript
|
|
1382
|
+
* import { getDependencies } from '@hyperfrontend/project-scope'
|
|
1383
|
+
*
|
|
1384
|
+
* const deps = getDependencies(packageJson)
|
|
1385
|
+
* console.log('Runtime:', Object.keys(deps.dependencies))
|
|
1386
|
+
* console.log('Dev:', Object.keys(deps.devDependencies))
|
|
1387
|
+
* ```
|
|
2289
1388
|
*/
|
|
2290
1389
|
function getDependencies(packageJson) {
|
|
2291
1390
|
return {
|
|
@@ -2300,6 +1399,14 @@ function getDependencies(packageJson) {
|
|
|
2300
1399
|
*
|
|
2301
1400
|
* @param packageJson - Parsed package.json
|
|
2302
1401
|
* @returns Map of dependency name to version for runtime dependencies
|
|
1402
|
+
*
|
|
1403
|
+
* @example Getting production dependencies
|
|
1404
|
+
* ```typescript
|
|
1405
|
+
* import { getProductionDependencies } from '@hyperfrontend/project-scope'
|
|
1406
|
+
*
|
|
1407
|
+
* const prodDeps = getProductionDependencies(packageJson)
|
|
1408
|
+
* // => { 'express': '^4.18.0', 'lodash': '^4.17.21' }
|
|
1409
|
+
* ```
|
|
2303
1410
|
*/
|
|
2304
1411
|
function getProductionDependencies(packageJson) {
|
|
2305
1412
|
return packageJson.dependencies ?? {};
|
|
@@ -2309,6 +1416,14 @@ function getProductionDependencies(packageJson) {
|
|
|
2309
1416
|
*
|
|
2310
1417
|
* @param packageJson - Parsed package.json
|
|
2311
1418
|
* @returns Map of dependency name to version for dev-time dependencies
|
|
1419
|
+
*
|
|
1420
|
+
* @example Getting development dependencies
|
|
1421
|
+
* ```typescript
|
|
1422
|
+
* import { getDevDependencies } from '@hyperfrontend/project-scope'
|
|
1423
|
+
*
|
|
1424
|
+
* const devDeps = getDevDependencies(packageJson)
|
|
1425
|
+
* // => { 'jest': '^29.0.0', 'typescript': '^5.0.0' }
|
|
1426
|
+
* ```
|
|
2312
1427
|
*/
|
|
2313
1428
|
function getDevDependencies(packageJson) {
|
|
2314
1429
|
return packageJson.devDependencies ?? {};
|
|
@@ -2318,6 +1433,14 @@ function getDevDependencies(packageJson) {
|
|
|
2318
1433
|
*
|
|
2319
1434
|
* @param packageJson - Parsed package.json
|
|
2320
1435
|
* @returns Map of dependency name to version for peer requirements
|
|
1436
|
+
*
|
|
1437
|
+
* @example Getting peer dependencies
|
|
1438
|
+
* ```typescript
|
|
1439
|
+
* import { getPeerDependencies } from '@hyperfrontend/project-scope'
|
|
1440
|
+
*
|
|
1441
|
+
* const peerDeps = getPeerDependencies(packageJson)
|
|
1442
|
+
* // => { 'react': '^18.0.0', 'react-dom': '^18.0.0' }
|
|
1443
|
+
* ```
|
|
2321
1444
|
*/
|
|
2322
1445
|
function getPeerDependencies(packageJson) {
|
|
2323
1446
|
return packageJson.peerDependencies ?? {};
|
|
@@ -2327,6 +1450,16 @@ function getPeerDependencies(packageJson) {
|
|
|
2327
1450
|
*
|
|
2328
1451
|
* @param packageJson - Parsed package.json
|
|
2329
1452
|
* @returns All dependencies merged
|
|
1453
|
+
*
|
|
1454
|
+
* @example Getting all merged dependencies
|
|
1455
|
+
* ```typescript
|
|
1456
|
+
* import { getAllDependencies } from '@hyperfrontend/project-scope'
|
|
1457
|
+
*
|
|
1458
|
+
* const allDeps = getAllDependencies(packageJson)
|
|
1459
|
+
* if ('typescript' in allDeps) {
|
|
1460
|
+
* console.log('TypeScript version:', allDeps['typescript'])
|
|
1461
|
+
* }
|
|
1462
|
+
* ```
|
|
2330
1463
|
*/
|
|
2331
1464
|
function getAllDependencies(packageJson) {
|
|
2332
1465
|
return {
|
|
@@ -2343,6 +1476,17 @@ function getAllDependencies(packageJson) {
|
|
|
2343
1476
|
* @param name - Name of the dependency to check
|
|
2344
1477
|
* @param depTypes - Optional array of dependency types to check (defaults to all)
|
|
2345
1478
|
* @returns True if dependency exists in specified categories
|
|
1479
|
+
*
|
|
1480
|
+
* @example Checking for a dependency
|
|
1481
|
+
* ```typescript
|
|
1482
|
+
* import { hasDependency } from '@hyperfrontend/project-scope'
|
|
1483
|
+
*
|
|
1484
|
+
* // Check any dependency type
|
|
1485
|
+
* hasDependency(packageJson, 'lodash')
|
|
1486
|
+
*
|
|
1487
|
+
* // Check only production dependencies
|
|
1488
|
+
* hasDependency(packageJson, 'lodash', ['dependencies'])
|
|
1489
|
+
* ```
|
|
2346
1490
|
*/
|
|
2347
1491
|
function hasDependency(packageJson, name, depTypes) {
|
|
2348
1492
|
const typesToCheck = depTypes ?? ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
|
|
@@ -2359,6 +1503,14 @@ function hasDependency(packageJson, name, depTypes) {
|
|
|
2359
1503
|
* @param packageJson - Parsed package.json content
|
|
2360
1504
|
* @param name - Name of the dependency to look up
|
|
2361
1505
|
* @returns Version string or null if not found
|
|
1506
|
+
*
|
|
1507
|
+
* @example Getting dependency version
|
|
1508
|
+
* ```typescript
|
|
1509
|
+
* import { getDependencyVersion } from '@hyperfrontend/project-scope'
|
|
1510
|
+
*
|
|
1511
|
+
* const version = getDependencyVersion(packageJson, 'react')
|
|
1512
|
+
* // => '^18.2.0' or null
|
|
1513
|
+
* ```
|
|
2362
1514
|
*/
|
|
2363
1515
|
function getDependencyVersion(packageJson, name) {
|
|
2364
1516
|
const deps = getDependencies(packageJson);
|
|
@@ -2369,6 +1521,14 @@ function getDependencyVersion(packageJson, name) {
|
|
|
2369
1521
|
*
|
|
2370
1522
|
* @param packageJson - Parsed package.json
|
|
2371
1523
|
* @returns Array of workspace patterns or empty array
|
|
1524
|
+
*
|
|
1525
|
+
* @example Getting workspace patterns
|
|
1526
|
+
* ```typescript
|
|
1527
|
+
* import { getWorkspaces } from '@hyperfrontend/project-scope'
|
|
1528
|
+
*
|
|
1529
|
+
* const patterns = getWorkspaces(packageJson)
|
|
1530
|
+
* // => ['packages/*', 'apps/*']
|
|
1531
|
+
* ```
|
|
2372
1532
|
*/
|
|
2373
1533
|
function getWorkspaces(packageJson) {
|
|
2374
1534
|
if (!packageJson.workspaces)
|
|
@@ -2386,6 +1546,15 @@ function getWorkspaces(packageJson) {
|
|
|
2386
1546
|
*
|
|
2387
1547
|
* @param packageJson - Parsed package.json
|
|
2388
1548
|
* @returns True if workspaces are defined
|
|
1549
|
+
*
|
|
1550
|
+
* @example Checking for workspaces
|
|
1551
|
+
* ```typescript
|
|
1552
|
+
* import { hasWorkspaces } from '@hyperfrontend/project-scope'
|
|
1553
|
+
*
|
|
1554
|
+
* if (hasWorkspaces(packageJson)) {
|
|
1555
|
+
* console.log('This is a monorepo')
|
|
1556
|
+
* }
|
|
1557
|
+
* ```
|
|
2389
1558
|
*/
|
|
2390
1559
|
function hasWorkspaces(packageJson) {
|
|
2391
1560
|
return getWorkspaces(packageJson).length > 0;
|
|
@@ -2396,22 +1565,20 @@ function hasWorkspaces(packageJson) {
|
|
|
2396
1565
|
* @param projectPath - Project root directory
|
|
2397
1566
|
* @param packageName - Package name to check
|
|
2398
1567
|
* @returns Boolean indicating whether the package exists in node_modules
|
|
1568
|
+
*
|
|
1569
|
+
* @example Checking installed packages
|
|
1570
|
+
* ```typescript
|
|
1571
|
+
* import { hasInstalledPackage } from '@hyperfrontend/project-scope'
|
|
1572
|
+
*
|
|
1573
|
+
* if (hasInstalledPackage('/project', 'typescript')) {
|
|
1574
|
+
* console.log('TypeScript is installed')
|
|
1575
|
+
* }
|
|
1576
|
+
* ```
|
|
2399
1577
|
*/
|
|
2400
1578
|
function hasInstalledPackage(projectPath, packageName) {
|
|
2401
1579
|
const pkgPath = join$1(projectPath, 'node_modules', packageName, 'package.json');
|
|
2402
1580
|
return readPackageJsonIfExists(pkgPath) !== null;
|
|
2403
1581
|
}
|
|
2404
|
-
/**
|
|
2405
|
-
* Get installed package version from node_modules.
|
|
2406
|
-
*
|
|
2407
|
-
* @param projectPath - Project root directory
|
|
2408
|
-
* @param packageName - Name of the npm package to look up
|
|
2409
|
-
* @returns Installed version or null if not found
|
|
2410
|
-
*/
|
|
2411
|
-
function getInstalledVersion(projectPath, packageName) {
|
|
2412
|
-
const pkg = readPackageJsonIfExists(join$1(projectPath, 'node_modules', packageName, 'package.json'));
|
|
2413
|
-
return pkg?.version ?? null;
|
|
2414
|
-
}
|
|
2415
1582
|
|
|
2416
1583
|
const rootLogger = createScopedLogger('project-scope:root');
|
|
2417
1584
|
/**
|
|
@@ -2451,7 +1618,7 @@ function looksLikeProjectDir(dirPath) {
|
|
|
2451
1618
|
* @param startPath - Starting path
|
|
2452
1619
|
* @returns Project root path or null
|
|
2453
1620
|
*
|
|
2454
|
-
* @example
|
|
1621
|
+
* @example Finding project root
|
|
2455
1622
|
* ```typescript
|
|
2456
1623
|
* import { findProjectRoot } from '@hyperfrontend/project-scope'
|
|
2457
1624
|
*
|
|
@@ -2491,7 +1658,7 @@ function findProjectRoot(startPath) {
|
|
|
2491
1658
|
* @param startPath - Starting path
|
|
2492
1659
|
* @returns Workspace root path or null
|
|
2493
1660
|
*
|
|
2494
|
-
* @example
|
|
1661
|
+
* @example Finding workspace root
|
|
2495
1662
|
* ```typescript
|
|
2496
1663
|
* import { findWorkspaceRoot } from '@hyperfrontend/project-scope'
|
|
2497
1664
|
*
|
|
@@ -2531,6 +1698,15 @@ function findWorkspaceRoot(startPath) {
|
|
|
2531
1698
|
* @param startPath - Starting path
|
|
2532
1699
|
* @param markers - Files to search for
|
|
2533
1700
|
* @returns Root directory path or null
|
|
1701
|
+
*
|
|
1702
|
+
* @example Finding root by marker files
|
|
1703
|
+
* ```typescript
|
|
1704
|
+
* import { findRootDirectory } from '@hyperfrontend/project-scope'
|
|
1705
|
+
*
|
|
1706
|
+
* // Find monorepo root by looking for nx.json or lerna.json
|
|
1707
|
+
* const root = findRootDirectory('./libs/my-lib', ['nx.json', 'lerna.json'])
|
|
1708
|
+
* // => '/path/to/monorepo'
|
|
1709
|
+
* ```
|
|
2534
1710
|
*/
|
|
2535
1711
|
function findRootDirectory(startPath, markers) {
|
|
2536
1712
|
return locateByMarkers(startPath, markers);
|
|
@@ -2540,10 +1716,17 @@ function findRootDirectory(startPath, markers) {
|
|
|
2540
1716
|
*
|
|
2541
1717
|
* @param startPath - Starting path
|
|
2542
1718
|
* @returns Git root path or null
|
|
1719
|
+
*
|
|
1720
|
+
* @example Finding Git repository root
|
|
1721
|
+
* ```typescript
|
|
1722
|
+
* import { findGitRoot } from '@hyperfrontend/project-scope'
|
|
1723
|
+
*
|
|
1724
|
+
* const gitRoot = findGitRoot('./src/deep/nested/file.ts')
|
|
1725
|
+
* // => '/path/to/repository'
|
|
1726
|
+
* ```
|
|
2543
1727
|
*/
|
|
2544
1728
|
function findGitRoot(startPath) {
|
|
2545
1729
|
return locateByMarkers(startPath, ['.git']);
|
|
2546
1730
|
}
|
|
2547
1731
|
|
|
2548
|
-
export { CONFIG_PATTERNS, ROOT_MARKERS, WORKSPACE_MARKERS, clearConfigDetectionCache, detectConfigs, findConfigFile, findDirectories, findFiles, findFilesInTree, findGitRoot, findNearestPackageJson, findProjectRoot, findRootDirectory, findWorkspaceRoot, getAllDependencies,
|
|
2549
|
-
//# sourceMappingURL=index.esm.js.map
|
|
1732
|
+
export { CONFIG_PATTERNS, ROOT_MARKERS, WORKSPACE_MARKERS, clearConfigDetectionCache, detectConfigs, findConfigFile, findDirectories, findFiles, findFilesInTree, findGitRoot, findNearestPackageJson, findProjectRoot, findRootDirectory, findWorkspaceRoot, getAllDependencies, getConfigPatternsByType, getDependencies, getDependencyVersion, getDevDependencies, getPeerDependencies, getProductionDependencies, getWorkspaces, hasDependency, hasInstalledPackage, hasWorkspaces, parseConfig, parseJsonConfig, parseYamlConfig, readPackageJson, readPackageJsonIfExists, walkDirectory, walkTree };
|