@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
|
@@ -1,734 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
description: 'NPM lockfile',
|
|
20
|
-
},
|
|
21
|
-
'pnpm-lock.yaml': {
|
|
22
|
-
patterns: ['pnpm-lock.yaml'],
|
|
23
|
-
format: 'yaml',
|
|
24
|
-
description: 'PNPM lockfile',
|
|
25
|
-
},
|
|
26
|
-
'yarn.lock': {
|
|
27
|
-
patterns: ['yarn.lock'],
|
|
28
|
-
format: 'text',
|
|
29
|
-
description: 'Yarn lockfile',
|
|
30
|
-
},
|
|
31
|
-
'.npmrc': {
|
|
32
|
-
patterns: ['.npmrc'],
|
|
33
|
-
format: 'ini',
|
|
34
|
-
description: 'NPM configuration',
|
|
35
|
-
sensitive: true,
|
|
36
|
-
},
|
|
37
|
-
// TypeScript
|
|
38
|
-
tsconfig: {
|
|
39
|
-
patterns: ['tsconfig.json', 'tsconfig.*.json'],
|
|
40
|
-
format: 'jsonc',
|
|
41
|
-
description: 'TypeScript configuration',
|
|
42
|
-
canExtend: true,
|
|
43
|
-
},
|
|
44
|
-
// Monorepo
|
|
45
|
-
nx: {
|
|
46
|
-
patterns: ['nx.json'],
|
|
47
|
-
format: 'json',
|
|
48
|
-
description: 'NX workspace configuration',
|
|
49
|
-
},
|
|
50
|
-
'project.json': {
|
|
51
|
-
patterns: ['project.json', '**/project.json'],
|
|
52
|
-
format: 'json',
|
|
53
|
-
description: 'NX project configuration',
|
|
54
|
-
},
|
|
55
|
-
'workspace.json': {
|
|
56
|
-
patterns: ['workspace.json'],
|
|
57
|
-
format: 'json',
|
|
58
|
-
description: 'NX workspace projects (deprecated)',
|
|
59
|
-
},
|
|
60
|
-
turbo: {
|
|
61
|
-
patterns: ['turbo.json'],
|
|
62
|
-
format: 'jsonc',
|
|
63
|
-
description: 'TurboRepo configuration',
|
|
64
|
-
},
|
|
65
|
-
lerna: {
|
|
66
|
-
patterns: ['lerna.json'],
|
|
67
|
-
format: 'json',
|
|
68
|
-
description: 'Lerna configuration',
|
|
69
|
-
},
|
|
70
|
-
// Build Tools
|
|
71
|
-
webpack: {
|
|
72
|
-
patterns: ['webpack.config.js', 'webpack.config.ts', 'webpack.config.cjs', 'webpack.config.mjs'],
|
|
73
|
-
format: 'js',
|
|
74
|
-
description: 'Webpack configuration',
|
|
75
|
-
},
|
|
76
|
-
rollup: {
|
|
77
|
-
patterns: ['rollup.config.js', 'rollup.config.ts', 'rollup.config.mjs'],
|
|
78
|
-
format: 'js',
|
|
79
|
-
description: 'Rollup configuration',
|
|
80
|
-
},
|
|
81
|
-
vite: {
|
|
82
|
-
patterns: ['vite.config.js', 'vite.config.ts', 'vite.config.mjs'],
|
|
83
|
-
format: 'js',
|
|
84
|
-
description: 'Vite configuration',
|
|
85
|
-
},
|
|
86
|
-
esbuild: {
|
|
87
|
-
patterns: ['esbuild.config.js', 'esbuild.config.ts', 'esbuild.config.mjs'],
|
|
88
|
-
format: 'js',
|
|
89
|
-
description: 'esbuild configuration',
|
|
90
|
-
},
|
|
91
|
-
babel: {
|
|
92
|
-
patterns: ['babel.config.js', 'babel.config.json', '.babelrc', '.babelrc.js', '.babelrc.json'],
|
|
93
|
-
format: 'json',
|
|
94
|
-
description: 'Babel configuration',
|
|
95
|
-
},
|
|
96
|
-
swc: {
|
|
97
|
-
patterns: ['.swcrc'],
|
|
98
|
-
format: 'json',
|
|
99
|
-
description: 'SWC configuration',
|
|
100
|
-
},
|
|
101
|
-
// Testing
|
|
102
|
-
jest: {
|
|
103
|
-
patterns: ['jest.config.js', 'jest.config.ts', 'jest.config.mjs'],
|
|
104
|
-
description: 'Jest configuration',
|
|
105
|
-
},
|
|
106
|
-
vitest: {
|
|
107
|
-
patterns: ['vitest.config.js', 'vitest.config.ts'],
|
|
108
|
-
description: 'Vitest configuration',
|
|
109
|
-
},
|
|
110
|
-
cypress: {
|
|
111
|
-
patterns: ['cypress.config.js', 'cypress.config.ts'],
|
|
112
|
-
description: 'Cypress configuration',
|
|
113
|
-
},
|
|
114
|
-
playwright: {
|
|
115
|
-
patterns: ['playwright.config.js', 'playwright.config.ts'],
|
|
116
|
-
description: 'Playwright configuration',
|
|
117
|
-
},
|
|
118
|
-
// Framework configs
|
|
119
|
-
next: {
|
|
120
|
-
patterns: ['next.config.js', 'next.config.mjs', 'next.config.ts'],
|
|
121
|
-
format: 'js',
|
|
122
|
-
description: 'Next.js configuration',
|
|
123
|
-
},
|
|
124
|
-
angular: {
|
|
125
|
-
patterns: ['angular.json'],
|
|
126
|
-
format: 'json',
|
|
127
|
-
description: 'Angular CLI configuration',
|
|
128
|
-
},
|
|
129
|
-
nuxt: {
|
|
130
|
-
patterns: ['nuxt.config.js', 'nuxt.config.ts'],
|
|
131
|
-
format: 'js',
|
|
132
|
-
description: 'Nuxt.js configuration',
|
|
133
|
-
},
|
|
134
|
-
svelte: {
|
|
135
|
-
patterns: ['svelte.config.js', 'svelte.config.ts'],
|
|
136
|
-
format: 'js',
|
|
137
|
-
description: 'SvelteKit configuration',
|
|
138
|
-
},
|
|
139
|
-
astro: {
|
|
140
|
-
patterns: ['astro.config.js', 'astro.config.ts', 'astro.config.mjs'],
|
|
141
|
-
format: 'js',
|
|
142
|
-
description: 'Astro configuration',
|
|
143
|
-
},
|
|
144
|
-
// Linting & Formatting
|
|
145
|
-
eslint: {
|
|
146
|
-
patterns: [
|
|
147
|
-
'eslint.config.js',
|
|
148
|
-
'eslint.config.cjs',
|
|
149
|
-
'eslint.config.mjs',
|
|
150
|
-
'.eslintrc',
|
|
151
|
-
'.eslintrc.js',
|
|
152
|
-
'.eslintrc.json',
|
|
153
|
-
'.eslintrc.yml',
|
|
154
|
-
],
|
|
155
|
-
format: 'js',
|
|
156
|
-
description: 'ESLint configuration',
|
|
157
|
-
},
|
|
158
|
-
prettier: {
|
|
159
|
-
patterns: ['prettier.config.js', 'prettier.config.cjs', '.prettierrc', '.prettierrc.js', '.prettierrc.json', '.prettierrc.yml'],
|
|
160
|
-
format: 'json',
|
|
161
|
-
description: 'Prettier configuration',
|
|
162
|
-
},
|
|
163
|
-
// Environment (sensitive)
|
|
164
|
-
env: {
|
|
165
|
-
patterns: ['.env', '.env.*', '*.env'],
|
|
166
|
-
format: 'dotenv',
|
|
167
|
-
description: 'Environment variables',
|
|
168
|
-
sensitive: true,
|
|
169
|
-
},
|
|
170
|
-
// Git
|
|
171
|
-
'.gitignore': {
|
|
172
|
-
patterns: ['.gitignore'],
|
|
173
|
-
format: 'text',
|
|
174
|
-
description: 'Git ignore patterns',
|
|
175
|
-
},
|
|
176
|
-
'.gitattributes': {
|
|
177
|
-
patterns: ['.gitattributes'],
|
|
178
|
-
format: 'text',
|
|
179
|
-
description: 'Git attributes',
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
/**
|
|
183
|
-
* Get patterns for specific config types.
|
|
184
|
-
*
|
|
185
|
-
* @param types - Array of config types to get patterns for
|
|
186
|
-
* @returns Array of file patterns
|
|
187
|
-
*/
|
|
188
|
-
function getConfigPatternsByType(types) {
|
|
189
|
-
return types.flatMap((type) => CONFIG_PATTERNS[type]?.patterns ?? []);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Safe copies of Object built-in methods.
|
|
194
|
-
*
|
|
195
|
-
* These references are captured at module initialization time to protect against
|
|
196
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
197
|
-
*
|
|
198
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/object
|
|
199
|
-
*/
|
|
200
|
-
// Capture references at module initialization time
|
|
201
|
-
const _Object = globalThis.Object;
|
|
202
|
-
/**
|
|
203
|
-
* (Safe copy) Prevents modification of existing property attributes and values,
|
|
204
|
-
* and prevents the addition of new properties.
|
|
205
|
-
*/
|
|
206
|
-
const freeze = _Object.freeze;
|
|
207
|
-
/**
|
|
208
|
-
* (Safe copy) Returns the names of the enumerable string properties and methods of an object.
|
|
209
|
-
*/
|
|
210
|
-
const keys = _Object.keys;
|
|
211
|
-
/**
|
|
212
|
-
* (Safe copy) Returns an array of key/values of the enumerable own properties of an object.
|
|
213
|
-
*/
|
|
214
|
-
const entries = _Object.entries;
|
|
215
|
-
/**
|
|
216
|
-
* (Safe copy) Adds one or more properties to an object, and/or modifies attributes of existing properties.
|
|
217
|
-
*/
|
|
218
|
-
const defineProperties = _Object.defineProperties;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Safe copies of Map built-in via factory function.
|
|
222
|
-
*
|
|
223
|
-
* Since constructors cannot be safely captured via Object.assign, this module
|
|
224
|
-
* provides a factory function that uses Reflect.construct internally.
|
|
225
|
-
*
|
|
226
|
-
* These references are captured at module initialization time to protect against
|
|
227
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
228
|
-
*
|
|
229
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/map
|
|
230
|
-
*/
|
|
231
|
-
// Capture references at module initialization time
|
|
232
|
-
const _Map = globalThis.Map;
|
|
233
|
-
const _Reflect$2 = globalThis.Reflect;
|
|
234
|
-
/**
|
|
235
|
-
* (Safe copy) Creates a new Map using the captured Map constructor.
|
|
236
|
-
* Use this instead of `new Map()`.
|
|
237
|
-
*
|
|
238
|
-
* @param iterable - Optional iterable of key-value pairs.
|
|
239
|
-
* @returns A new Map instance.
|
|
240
|
-
*/
|
|
241
|
-
const createMap = (iterable) => _Reflect$2.construct(_Map, iterable ? [iterable] : []);
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Safe copies of Set built-in via factory function.
|
|
245
|
-
*
|
|
246
|
-
* Since constructors cannot be safely captured via Object.assign, this module
|
|
247
|
-
* provides a factory function that uses Reflect.construct internally.
|
|
248
|
-
*
|
|
249
|
-
* These references are captured at module initialization time to protect against
|
|
250
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
251
|
-
*
|
|
252
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/set
|
|
253
|
-
*/
|
|
254
|
-
// Capture references at module initialization time
|
|
255
|
-
const _Set = globalThis.Set;
|
|
256
|
-
const _Reflect$1 = globalThis.Reflect;
|
|
257
|
-
/**
|
|
258
|
-
* (Safe copy) Creates a new Set using the captured Set constructor.
|
|
259
|
-
* Use this instead of `new Set()`.
|
|
260
|
-
*
|
|
261
|
-
* @param iterable - Optional iterable of values.
|
|
262
|
-
* @returns A new Set instance.
|
|
263
|
-
*/
|
|
264
|
-
const createSet = (iterable) => _Reflect$1.construct(_Set, iterable ? [iterable] : []);
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Global registry of all caches for bulk operations.
|
|
268
|
-
*/
|
|
269
|
-
const cacheRegistry = createSet();
|
|
270
|
-
/**
|
|
271
|
-
* Create a cache with optional TTL and size limits.
|
|
272
|
-
*
|
|
273
|
-
* The cache provides a simple key-value store with:
|
|
274
|
-
* - Optional TTL (time-to-live) for automatic expiration
|
|
275
|
-
* - Optional maxSize for limiting cache size with FIFO eviction
|
|
276
|
-
* - Lazy expiration (entries are checked on access)
|
|
277
|
-
*
|
|
278
|
-
* @param options - Cache configuration options
|
|
279
|
-
* @returns Cache instance
|
|
280
|
-
*
|
|
281
|
-
* @example
|
|
282
|
-
* ```typescript
|
|
283
|
-
* // Basic cache
|
|
284
|
-
* const cache = createCache<string, number>()
|
|
285
|
-
* cache.set('answer', 42)
|
|
286
|
-
* cache.get('answer') // 42
|
|
287
|
-
*
|
|
288
|
-
* // Cache with TTL (expires after 60 seconds)
|
|
289
|
-
* const ttlCache = createCache<string, object>({ ttl: 60000 })
|
|
290
|
-
*
|
|
291
|
-
* // Cache with max size (evicts oldest when full)
|
|
292
|
-
* const lruCache = createCache<string, object>({ maxSize: 100 })
|
|
293
|
-
*
|
|
294
|
-
* // Combined options
|
|
295
|
-
* const configCache = createCache<string, object>({
|
|
296
|
-
* ttl: 30000,
|
|
297
|
-
* maxSize: 50
|
|
298
|
-
* })
|
|
299
|
-
* ```
|
|
300
|
-
*/
|
|
301
|
-
function createCache(options) {
|
|
302
|
-
const { ttl, maxSize } = options ?? {};
|
|
303
|
-
const store = createMap();
|
|
304
|
-
// Track insertion order for FIFO eviction
|
|
305
|
-
const insertionOrder = [];
|
|
306
|
-
/**
|
|
307
|
-
* Check if an entry is expired.
|
|
308
|
-
*
|
|
309
|
-
* @param entry - Cache entry to check
|
|
310
|
-
* @returns True if entry is expired
|
|
311
|
-
*/
|
|
312
|
-
function isExpired(entry) {
|
|
313
|
-
if (ttl === undefined)
|
|
314
|
-
return false;
|
|
315
|
-
// eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
|
|
316
|
-
return Date.now() - entry.timestamp > ttl;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Evict oldest entries to make room for new ones.
|
|
320
|
-
*/
|
|
321
|
-
function evictIfNeeded() {
|
|
322
|
-
if (maxSize === undefined)
|
|
323
|
-
return;
|
|
324
|
-
while (store.size >= maxSize && insertionOrder.length > 0) {
|
|
325
|
-
const oldestKey = insertionOrder.shift();
|
|
326
|
-
if (oldestKey !== undefined) {
|
|
327
|
-
store.delete(oldestKey);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Remove key from insertion order tracking.
|
|
333
|
-
*
|
|
334
|
-
* @param key - Key to remove from order tracking
|
|
335
|
-
*/
|
|
336
|
-
function removeFromOrder(key) {
|
|
337
|
-
const index = insertionOrder.indexOf(key);
|
|
338
|
-
if (index !== -1) {
|
|
339
|
-
insertionOrder.splice(index, 1);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
const cache = {
|
|
343
|
-
get(key) {
|
|
344
|
-
const entry = store.get(key);
|
|
345
|
-
if (!entry)
|
|
346
|
-
return undefined;
|
|
347
|
-
if (isExpired(entry)) {
|
|
348
|
-
store.delete(key);
|
|
349
|
-
removeFromOrder(key);
|
|
350
|
-
return undefined;
|
|
351
|
-
}
|
|
352
|
-
return entry.value;
|
|
353
|
-
},
|
|
354
|
-
set(key, value) {
|
|
355
|
-
// If key exists, remove from order first
|
|
356
|
-
if (store.has(key)) {
|
|
357
|
-
removeFromOrder(key);
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
// Evict if needed before adding new entry
|
|
361
|
-
evictIfNeeded();
|
|
362
|
-
}
|
|
363
|
-
// eslint-disable-next-line workspace/no-unsafe-builtin-methods -- Date.now() is needed for Jest fake timers compatibility
|
|
364
|
-
store.set(key, { value, timestamp: Date.now() });
|
|
365
|
-
insertionOrder.push(key);
|
|
366
|
-
},
|
|
367
|
-
has(key) {
|
|
368
|
-
const entry = store.get(key);
|
|
369
|
-
if (!entry)
|
|
370
|
-
return false;
|
|
371
|
-
if (isExpired(entry)) {
|
|
372
|
-
store.delete(key);
|
|
373
|
-
removeFromOrder(key);
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
return true;
|
|
377
|
-
},
|
|
378
|
-
delete(key) {
|
|
379
|
-
removeFromOrder(key);
|
|
380
|
-
return store.delete(key);
|
|
381
|
-
},
|
|
382
|
-
clear() {
|
|
383
|
-
store.clear();
|
|
384
|
-
insertionOrder.length = 0;
|
|
385
|
-
},
|
|
386
|
-
size() {
|
|
387
|
-
return store.size;
|
|
388
|
-
},
|
|
389
|
-
keys() {
|
|
390
|
-
return [...insertionOrder];
|
|
391
|
-
},
|
|
392
|
-
};
|
|
393
|
-
// Register cache for global operations
|
|
394
|
-
cacheRegistry.add(cache);
|
|
395
|
-
return freeze(cache);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Safe copies of Error built-ins via factory functions.
|
|
400
|
-
*
|
|
401
|
-
* Since constructors cannot be safely captured via Object.assign, this module
|
|
402
|
-
* provides factory functions that use Reflect.construct internally.
|
|
403
|
-
*
|
|
404
|
-
* These references are captured at module initialization time to protect against
|
|
405
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
406
|
-
*
|
|
407
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/error
|
|
408
|
-
*/
|
|
409
|
-
// Capture references at module initialization time
|
|
410
|
-
const _Error = globalThis.Error;
|
|
411
|
-
const _Reflect = globalThis.Reflect;
|
|
412
|
-
/**
|
|
413
|
-
* (Safe copy) Creates a new Error using the captured Error constructor.
|
|
414
|
-
* Use this instead of `new Error()`.
|
|
415
|
-
*
|
|
416
|
-
* @param message - Optional error message.
|
|
417
|
-
* @param options - Optional error options.
|
|
418
|
-
* @returns A new Error instance.
|
|
419
|
-
*/
|
|
420
|
-
const createError = (message, options) => _Reflect.construct(_Error, [message, options]);
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Safe copies of JSON built-in methods.
|
|
424
|
-
*
|
|
425
|
-
* These references are captured at module initialization time to protect against
|
|
426
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
427
|
-
*
|
|
428
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/json
|
|
429
|
-
*/
|
|
430
|
-
// Capture references at module initialization time
|
|
431
|
-
const _JSON = globalThis.JSON;
|
|
432
|
-
/**
|
|
433
|
-
* (Safe copy) Converts a JavaScript Object Notation (JSON) string into an object.
|
|
434
|
-
*/
|
|
435
|
-
const parse = _JSON.parse;
|
|
436
|
-
/**
|
|
437
|
-
* (Safe copy) Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
|
438
|
-
*/
|
|
439
|
-
const stringify = _JSON.stringify;
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Safe copies of Array built-in static methods.
|
|
443
|
-
*
|
|
444
|
-
* These references are captured at module initialization time to protect against
|
|
445
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
446
|
-
*
|
|
447
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/array
|
|
448
|
-
*/
|
|
449
|
-
// Capture references at module initialization time
|
|
450
|
-
const _Array = globalThis.Array;
|
|
451
|
-
/**
|
|
452
|
-
* (Safe copy) Determines whether the passed value is an Array.
|
|
453
|
-
*/
|
|
454
|
-
const isArray = _Array.isArray;
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Safe copies of Console built-in methods.
|
|
458
|
-
*
|
|
459
|
-
* These references are captured at module initialization time to protect against
|
|
460
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
461
|
-
*
|
|
462
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/console
|
|
463
|
-
*/
|
|
464
|
-
// Capture references at module initialization time
|
|
465
|
-
const _console = globalThis.console;
|
|
466
|
-
/**
|
|
467
|
-
* (Safe copy) Outputs a message to the console.
|
|
468
|
-
*/
|
|
469
|
-
const log = _console.log.bind(_console);
|
|
470
|
-
/**
|
|
471
|
-
* (Safe copy) Outputs a warning message to the console.
|
|
472
|
-
*/
|
|
473
|
-
const warn = _console.warn.bind(_console);
|
|
474
|
-
/**
|
|
475
|
-
* (Safe copy) Outputs an error message to the console.
|
|
476
|
-
*/
|
|
477
|
-
const error = _console.error.bind(_console);
|
|
478
|
-
/**
|
|
479
|
-
* (Safe copy) Outputs an informational message to the console.
|
|
480
|
-
*/
|
|
481
|
-
const info = _console.info.bind(_console);
|
|
482
|
-
/**
|
|
483
|
-
* (Safe copy) Outputs a debug message to the console.
|
|
484
|
-
*/
|
|
485
|
-
const debug = _console.debug.bind(_console);
|
|
486
|
-
/**
|
|
487
|
-
* (Safe copy) Outputs a stack trace to the console.
|
|
488
|
-
*/
|
|
489
|
-
_console.trace.bind(_console);
|
|
490
|
-
/**
|
|
491
|
-
* (Safe copy) Displays an interactive listing of the properties of a specified object.
|
|
492
|
-
*/
|
|
493
|
-
_console.dir.bind(_console);
|
|
494
|
-
/**
|
|
495
|
-
* (Safe copy) Displays tabular data as a table.
|
|
496
|
-
*/
|
|
497
|
-
_console.table.bind(_console);
|
|
498
|
-
/**
|
|
499
|
-
* (Safe copy) Writes an error message to the console if the assertion is false.
|
|
500
|
-
*/
|
|
501
|
-
_console.assert.bind(_console);
|
|
502
|
-
/**
|
|
503
|
-
* (Safe copy) Clears the console.
|
|
504
|
-
*/
|
|
505
|
-
_console.clear.bind(_console);
|
|
506
|
-
/**
|
|
507
|
-
* (Safe copy) Logs the number of times that this particular call to count() has been called.
|
|
508
|
-
*/
|
|
509
|
-
_console.count.bind(_console);
|
|
510
|
-
/**
|
|
511
|
-
* (Safe copy) Resets the counter used with console.count().
|
|
512
|
-
*/
|
|
513
|
-
_console.countReset.bind(_console);
|
|
514
|
-
/**
|
|
515
|
-
* (Safe copy) Creates a new inline group in the console.
|
|
516
|
-
*/
|
|
517
|
-
_console.group.bind(_console);
|
|
518
|
-
/**
|
|
519
|
-
* (Safe copy) Creates a new inline group in the console that is initially collapsed.
|
|
520
|
-
*/
|
|
521
|
-
_console.groupCollapsed.bind(_console);
|
|
522
|
-
/**
|
|
523
|
-
* (Safe copy) Exits the current inline group.
|
|
524
|
-
*/
|
|
525
|
-
_console.groupEnd.bind(_console);
|
|
526
|
-
/**
|
|
527
|
-
* (Safe copy) Starts a timer with a name specified as an input parameter.
|
|
528
|
-
*/
|
|
529
|
-
_console.time.bind(_console);
|
|
530
|
-
/**
|
|
531
|
-
* (Safe copy) Stops a timer that was previously started.
|
|
532
|
-
*/
|
|
533
|
-
_console.timeEnd.bind(_console);
|
|
534
|
-
/**
|
|
535
|
-
* (Safe copy) Logs the current value of a timer that was previously started.
|
|
536
|
-
*/
|
|
537
|
-
_console.timeLog.bind(_console);
|
|
538
|
-
|
|
539
|
-
const registeredClasses = [];
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Returns the data type of the target.
|
|
543
|
-
* Uses native `typeof` operator, however, makes distinction between `null`, `array`, and `object`.
|
|
544
|
-
* Also, when classes are registered via `registerClass`, it checks if objects are instance of any known registered class.
|
|
545
|
-
*
|
|
546
|
-
* @param target - The target to get the data type of.
|
|
547
|
-
* @returns The data type of the target.
|
|
548
|
-
*/
|
|
549
|
-
const getType = (target) => {
|
|
550
|
-
if (target === null)
|
|
551
|
-
return 'null';
|
|
552
|
-
const nativeDataType = typeof target;
|
|
553
|
-
if (nativeDataType === 'object') {
|
|
554
|
-
if (isArray(target))
|
|
555
|
-
return 'array';
|
|
556
|
-
for (const registeredClass of registeredClasses) {
|
|
557
|
-
if (target instanceof registeredClass)
|
|
558
|
-
return registeredClass.name;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return nativeDataType;
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
565
|
-
/**
|
|
566
|
-
* Creates a wrapper function that only executes the wrapped function if the condition function returns true.
|
|
567
|
-
*
|
|
568
|
-
* @param func - The function to be conditionally executed.
|
|
569
|
-
* @param conditionFunc - A function that returns a boolean, determining if `func` should be executed.
|
|
570
|
-
* @returns A wrapped version of `func` that executes conditionally.
|
|
571
|
-
*/
|
|
572
|
-
function createConditionalExecutionFunction(func, conditionFunc) {
|
|
573
|
-
return function (...args) {
|
|
574
|
-
if (conditionFunc()) {
|
|
575
|
-
return func(...args);
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
581
|
-
/**
|
|
582
|
-
* Creates a wrapper function that silently ignores any errors thrown by the wrapped void function.
|
|
583
|
-
* This function is specifically for wrapping functions that do not return a value (void functions).
|
|
584
|
-
* Exceptions are swallowed without any logging or handling.
|
|
585
|
-
*
|
|
586
|
-
* @param func - The void function to be wrapped.
|
|
587
|
-
* @returns A wrapped version of the input function that ignores errors.
|
|
588
|
-
*/
|
|
589
|
-
function createErrorIgnoringFunction(func) {
|
|
590
|
-
return function (...args) {
|
|
591
|
-
try {
|
|
592
|
-
func(...args);
|
|
593
|
-
}
|
|
594
|
-
catch {
|
|
595
|
-
// Deliberately swallowing/ignoring the exception
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
601
|
-
/**
|
|
602
|
-
* A no-operation function (noop) that does nothing regardless of the arguments passed.
|
|
603
|
-
* It is designed to be as permissive as possible in its typing without using the `Function` keyword.
|
|
604
|
-
*
|
|
605
|
-
* @param args - Any arguments passed to the function (ignored)
|
|
606
|
-
*/
|
|
607
|
-
const noop = (...args) => {
|
|
608
|
-
// Intentionally does nothing
|
|
609
|
-
};
|
|
610
|
-
|
|
611
|
-
const logLevels = ['none', 'error', 'warn', 'log', 'info', 'debug'];
|
|
612
|
-
const priority = {
|
|
613
|
-
error: 4,
|
|
614
|
-
warn: 3,
|
|
615
|
-
log: 2,
|
|
616
|
-
info: 1,
|
|
617
|
-
debug: 0,
|
|
618
|
-
};
|
|
619
|
-
/**
|
|
620
|
-
* Validates whether a given string is a valid log level.
|
|
621
|
-
*
|
|
622
|
-
* @param level - The log level to validate
|
|
623
|
-
* @returns True if the level is valid, false otherwise
|
|
624
|
-
*/
|
|
625
|
-
function isValidLogLevel(level) {
|
|
626
|
-
return logLevels.includes(level);
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Creates a log level configuration manager for controlling logging behavior.
|
|
630
|
-
* Provides methods to get, set, and evaluate log levels based on priority.
|
|
631
|
-
*
|
|
632
|
-
* @param level - The initial log level (defaults to 'error')
|
|
633
|
-
* @returns A configuration object with log level management methods
|
|
634
|
-
* @throws {Error} When the provided level is not a valid log level
|
|
635
|
-
*/
|
|
636
|
-
function createLogLevelConfig(level = 'error') {
|
|
637
|
-
if (!isValidLogLevel(level)) {
|
|
638
|
-
throw createError('Cannot create log level configuration with a valid default log level');
|
|
639
|
-
}
|
|
640
|
-
const state = { level };
|
|
641
|
-
const getLogLevel = () => state.level;
|
|
642
|
-
const setLogLevel = (level) => {
|
|
643
|
-
if (!isValidLogLevel(level)) {
|
|
644
|
-
throw createError(`Cannot set value '${level}' level. Expected levels are ${logLevels}.`);
|
|
645
|
-
}
|
|
646
|
-
state.level = level;
|
|
647
|
-
};
|
|
648
|
-
const shouldLog = (level) => {
|
|
649
|
-
if (state.level === 'none' || level === 'none' || !isValidLogLevel(level)) {
|
|
650
|
-
return false;
|
|
651
|
-
}
|
|
652
|
-
return priority[level] >= priority[state.level];
|
|
653
|
-
};
|
|
654
|
-
return freeze({
|
|
655
|
-
getLogLevel,
|
|
656
|
-
setLogLevel,
|
|
657
|
-
shouldLog,
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Creates a logger instance with configurable log level filtering.
|
|
663
|
-
* Each log function is wrapped to respect the current log level setting.
|
|
664
|
-
*
|
|
665
|
-
* @param error - Function to handle error-level logs (required)
|
|
666
|
-
* @param warn - Function to handle warning-level logs (optional, defaults to noop)
|
|
667
|
-
* @param log - Function to handle standard logs (optional, defaults to noop)
|
|
668
|
-
* @param info - Function to handle info-level logs (optional, defaults to noop)
|
|
669
|
-
* @param debug - Function to handle debug-level logs (optional, defaults to noop)
|
|
670
|
-
* @returns A frozen logger object with log methods and level control
|
|
671
|
-
* @throws {ErrorLevelFn} When any provided log function is invalid
|
|
672
|
-
*/
|
|
673
|
-
function createLogger(error, warn = noop, log = noop, info = noop, debug = noop) {
|
|
674
|
-
if (notValidLogFn(error)) {
|
|
675
|
-
throw createError(notFnMsg('error'));
|
|
676
|
-
}
|
|
677
|
-
if (notValidLogFn(warn)) {
|
|
678
|
-
throw createError(notFnMsg('warn'));
|
|
679
|
-
}
|
|
680
|
-
if (notValidLogFn(log)) {
|
|
681
|
-
throw createError(notFnMsg('log'));
|
|
682
|
-
}
|
|
683
|
-
if (notValidLogFn(info)) {
|
|
684
|
-
throw createError(notFnMsg('info'));
|
|
685
|
-
}
|
|
686
|
-
if (notValidLogFn(debug)) {
|
|
687
|
-
throw createError(notFnMsg('debug'));
|
|
688
|
-
}
|
|
689
|
-
const { setLogLevel, getLogLevel, shouldLog } = createLogLevelConfig();
|
|
690
|
-
const wrapLogFn = (fn, level) => {
|
|
691
|
-
if (fn === noop)
|
|
692
|
-
return fn;
|
|
693
|
-
const condition = () => shouldLog(level);
|
|
694
|
-
return createConditionalExecutionFunction(createErrorIgnoringFunction(fn), condition);
|
|
695
|
-
};
|
|
696
|
-
return freeze({
|
|
697
|
-
error: wrapLogFn(error, 'error'),
|
|
698
|
-
warn: wrapLogFn(warn, 'warn'),
|
|
699
|
-
log: wrapLogFn(log, 'log'),
|
|
700
|
-
info: wrapLogFn(info, 'info'),
|
|
701
|
-
debug: wrapLogFn(debug, 'debug'),
|
|
702
|
-
setLogLevel,
|
|
703
|
-
getLogLevel,
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
/**
|
|
707
|
-
* Validates whether a given value is a valid log function.
|
|
708
|
-
*
|
|
709
|
-
* @param fn - The value to validate
|
|
710
|
-
* @returns True if the value is not a function (invalid), false if it is valid
|
|
711
|
-
*/
|
|
712
|
-
function notValidLogFn(fn) {
|
|
713
|
-
return getType(fn) !== 'function' && fn !== noop;
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Generates an error message for invalid log function parameters.
|
|
717
|
-
*
|
|
718
|
-
* @param label - The name of the log function that failed validation
|
|
719
|
-
* @returns A formatted error message string
|
|
720
|
-
*/
|
|
721
|
-
function notFnMsg(label) {
|
|
722
|
-
return `Cannot create a logger when ${label} is not a function`;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
createLogger(error, warn, log, info, debug);
|
|
3
|
+
const node_path = require('node:path');
|
|
4
|
+
const index_cjs_js$2 = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.cjs.js');
|
|
5
|
+
const index_cjs_js$1 = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/map/index.cjs.js');
|
|
6
|
+
const index_cjs_js = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/set/index.cjs.js');
|
|
7
|
+
const node_fs = require('node:fs');
|
|
8
|
+
const index_cjs_js$5 = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.cjs.js');
|
|
9
|
+
const index_cjs_js$4 = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/console/index.cjs.js');
|
|
10
|
+
const index_cjs_js$6 = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.cjs.js');
|
|
11
|
+
const index_cjs_js$3 = require('../../_dependencies/@hyperfrontend/logging/index.cjs.js');
|
|
12
|
+
const index_cjs_js$7 = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/error/index.cjs.js');
|
|
13
|
+
const index_cjs_js$8 = require('../../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/number/index.cjs.js');
|
|
14
|
+
const { isDirectory, exists } = require('../../_shared/core/fs/stat/index.cjs.js');
|
|
15
|
+
const { createConfigError } = require('../../_shared/core/errors/structured-errors/index.cjs.js');
|
|
16
|
+
const { createCache } = require('../../_shared/core/cache/index.cjs.js');
|
|
17
|
+
const { matchGlobPattern } = require('../../_shared/core/patterns/glob/index.cjs.js');
|
|
18
|
+
const { CONFIG_PATTERNS, getConfigPatternsByType } = require('../../_shared/project/config/patterns/index.cjs.js');
|
|
726
19
|
|
|
727
20
|
/**
|
|
728
21
|
* Global log level registry.
|
|
729
22
|
* Tracks all created scoped loggers to allow global log level changes.
|
|
730
23
|
*/
|
|
731
|
-
const loggerRegistry = createSet();
|
|
24
|
+
const loggerRegistry = index_cjs_js.createSet();
|
|
732
25
|
/** Redacted placeholder for sensitive values */
|
|
733
26
|
const REDACTED = '[REDACTED]';
|
|
734
27
|
/**
|
|
@@ -762,17 +55,24 @@ function isSensitiveKey(key) {
|
|
|
762
55
|
*
|
|
763
56
|
* @param obj - Object to sanitize
|
|
764
57
|
* @returns New object with sensitive values redacted
|
|
58
|
+
*
|
|
59
|
+
* @example Sanitizing sensitive data
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
|
|
62
|
+
* const safe = sanitize(config)
|
|
63
|
+
* // => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }
|
|
64
|
+
* ```
|
|
765
65
|
*/
|
|
766
66
|
function sanitize(obj) {
|
|
767
67
|
if (obj === null || obj === undefined) {
|
|
768
68
|
return obj;
|
|
769
69
|
}
|
|
770
|
-
if (isArray(obj)) {
|
|
70
|
+
if (index_cjs_js$5.isArray(obj)) {
|
|
771
71
|
return obj.map((item) => sanitize(item));
|
|
772
72
|
}
|
|
773
73
|
if (typeof obj === 'object') {
|
|
774
74
|
const result = {};
|
|
775
|
-
for (const [key, value] of entries(obj)) {
|
|
75
|
+
for (const [key, value] of index_cjs_js$2.entries(obj)) {
|
|
776
76
|
if (isSensitiveKey(key)) {
|
|
777
77
|
result[key] = REDACTED;
|
|
778
78
|
}
|
|
@@ -797,9 +97,9 @@ function sanitize(obj) {
|
|
|
797
97
|
*/
|
|
798
98
|
function formatMessage(namespace, message, meta) {
|
|
799
99
|
const prefix = `[${namespace}]`;
|
|
800
|
-
if (meta && keys(meta).length > 0) {
|
|
100
|
+
if (meta && index_cjs_js$2.keys(meta).length > 0) {
|
|
801
101
|
const sanitizedMeta = sanitize(meta);
|
|
802
|
-
return `${prefix} ${message} ${stringify(sanitizedMeta)}`;
|
|
102
|
+
return `${prefix} ${message} ${index_cjs_js$6.stringify(sanitizedMeta)}`;
|
|
803
103
|
}
|
|
804
104
|
return `${prefix} ${message}`;
|
|
805
105
|
}
|
|
@@ -812,7 +112,7 @@ function formatMessage(namespace, message, meta) {
|
|
|
812
112
|
* @param options - Logger configuration options
|
|
813
113
|
* @returns A configured scoped logger instance
|
|
814
114
|
*
|
|
815
|
-
* @example
|
|
115
|
+
* @example Creating a scoped logger
|
|
816
116
|
* ```typescript
|
|
817
117
|
* const logger = createScopedLogger('project-scope')
|
|
818
118
|
* logger.setLogLevel('debug')
|
|
@@ -827,16 +127,13 @@ function formatMessage(namespace, message, meta) {
|
|
|
827
127
|
*/
|
|
828
128
|
function createScopedLogger(namespace, options = {}) {
|
|
829
129
|
const { level = 'error', sanitizeSecrets = true } = options;
|
|
830
|
-
// Create wrapper functions that add namespace prefix and sanitization
|
|
831
130
|
const createLogFn = (baseFn) => (message, meta) => {
|
|
832
131
|
const processedMeta = sanitizeSecrets && meta ? sanitize(meta) : meta;
|
|
833
132
|
baseFn(formatMessage(namespace, message, processedMeta));
|
|
834
133
|
};
|
|
835
|
-
|
|
836
|
-
const baseLogger = createLogger(createLogFn(error), createLogFn(warn), createLogFn(log), createLogFn(info), createLogFn(debug));
|
|
837
|
-
// Set initial log level (use global override if set)
|
|
134
|
+
const baseLogger = index_cjs_js$3.createLogger(createLogFn(index_cjs_js$4.error), createLogFn(index_cjs_js$4.warn), createLogFn(index_cjs_js$4.log), createLogFn(index_cjs_js$4.info), createLogFn(index_cjs_js$4.debug));
|
|
838
135
|
baseLogger.setLogLevel(level);
|
|
839
|
-
const scopedLogger = freeze({
|
|
136
|
+
const scopedLogger = index_cjs_js$2.freeze({
|
|
840
137
|
error: (message, meta) => baseLogger.error(message, meta),
|
|
841
138
|
warn: (message, meta) => baseLogger.warn(message, meta),
|
|
842
139
|
log: (message, meta) => baseLogger.log(message, meta),
|
|
@@ -845,7 +142,6 @@ function createScopedLogger(namespace, options = {}) {
|
|
|
845
142
|
setLogLevel: baseLogger.setLogLevel,
|
|
846
143
|
getLogLevel: baseLogger.getLogLevel,
|
|
847
144
|
});
|
|
848
|
-
// Register logger for global level management
|
|
849
145
|
loggerRegistry.add(scopedLogger);
|
|
850
146
|
return scopedLogger;
|
|
851
147
|
}
|
|
@@ -853,7 +149,7 @@ function createScopedLogger(namespace, options = {}) {
|
|
|
853
149
|
* Default logger instance for the project-scope library.
|
|
854
150
|
* Use this for general logging within the library.
|
|
855
151
|
*
|
|
856
|
-
* @example
|
|
152
|
+
* @example Using the default logger
|
|
857
153
|
* ```typescript
|
|
858
154
|
* import { logger } from '@hyperfrontend/project-scope/core'
|
|
859
155
|
*
|
|
@@ -871,10 +167,19 @@ const fsLogger = createScopedLogger('project-scope:fs');
|
|
|
871
167
|
* @param code - The category code for this type of filesystem failure
|
|
872
168
|
* @param context - Additional context including path, operation, and cause
|
|
873
169
|
* @returns A configured Error object with code and context properties
|
|
170
|
+
*
|
|
171
|
+
* @example Creating a file system error
|
|
172
|
+
* ```typescript
|
|
173
|
+
* throw createFileSystemError(
|
|
174
|
+
* 'Cannot read file',
|
|
175
|
+
* 'FS_READ_ERROR',
|
|
176
|
+
* { path: './missing.txt', operation: 'read' }
|
|
177
|
+
* )
|
|
178
|
+
* ```
|
|
874
179
|
*/
|
|
875
180
|
function createFileSystemError(message, code, context) {
|
|
876
|
-
const error = createError(message);
|
|
877
|
-
defineProperties(error, {
|
|
181
|
+
const error = index_cjs_js$7.createError(message);
|
|
182
|
+
index_cjs_js$2.defineProperties(error, {
|
|
878
183
|
code: { value: code, enumerable: true },
|
|
879
184
|
context: { value: context, enumerable: true },
|
|
880
185
|
});
|
|
@@ -888,7 +193,7 @@ function createFileSystemError(message, code, context) {
|
|
|
888
193
|
* @returns File contents as string
|
|
889
194
|
* @throws {Error} If file doesn't exist or can't be read
|
|
890
195
|
*
|
|
891
|
-
* @example
|
|
196
|
+
* @example Reading file contents
|
|
892
197
|
* ```typescript
|
|
893
198
|
* import { readFileContent } from '@hyperfrontend/project-scope'
|
|
894
199
|
*
|
|
@@ -915,6 +220,14 @@ function readFileContent(filePath, encoding = 'utf-8') {
|
|
|
915
220
|
* @param filePath - Path to file
|
|
916
221
|
* @param encoding - File encoding (default: utf-8)
|
|
917
222
|
* @returns File contents or null if file doesn't exist
|
|
223
|
+
*
|
|
224
|
+
* @example Reading file if it exists
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const content = readFileIfExists('./optional-config.json')
|
|
227
|
+
* if (content) {
|
|
228
|
+
* // File existed, use content
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
918
231
|
*/
|
|
919
232
|
function readFileIfExists(filePath, encoding = 'utf-8') {
|
|
920
233
|
if (!node_fs.existsSync(filePath)) {
|
|
@@ -928,56 +241,6 @@ function readFileIfExists(filePath, encoding = 'utf-8') {
|
|
|
928
241
|
}
|
|
929
242
|
}
|
|
930
243
|
|
|
931
|
-
createScopedLogger('project-scope:fs:write');
|
|
932
|
-
|
|
933
|
-
/**
|
|
934
|
-
* Get file stats with error handling.
|
|
935
|
-
*
|
|
936
|
-
* @param filePath - Path to file
|
|
937
|
-
* @param followSymlinks - Whether to follow symlinks (default: true)
|
|
938
|
-
* @returns File stats or null if path doesn't exist
|
|
939
|
-
*/
|
|
940
|
-
function getFileStat(filePath, followSymlinks = true) {
|
|
941
|
-
if (!node_fs.existsSync(filePath)) {
|
|
942
|
-
return null;
|
|
943
|
-
}
|
|
944
|
-
try {
|
|
945
|
-
const stat = followSymlinks ? node_fs.statSync(filePath) : node_fs.lstatSync(filePath);
|
|
946
|
-
return {
|
|
947
|
-
isFile: stat.isFile(),
|
|
948
|
-
isDirectory: stat.isDirectory(),
|
|
949
|
-
isSymlink: stat.isSymbolicLink(),
|
|
950
|
-
size: stat.size,
|
|
951
|
-
created: stat.birthtime,
|
|
952
|
-
modified: stat.mtime,
|
|
953
|
-
accessed: stat.atime,
|
|
954
|
-
mode: stat.mode,
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
catch {
|
|
958
|
-
return null;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Check if path is a directory.
|
|
963
|
-
*
|
|
964
|
-
* @param dirPath - Path to check
|
|
965
|
-
* @returns True if path is a directory
|
|
966
|
-
*/
|
|
967
|
-
function isDirectory(dirPath) {
|
|
968
|
-
const stats = getFileStat(dirPath);
|
|
969
|
-
return stats?.isDirectory ?? false;
|
|
970
|
-
}
|
|
971
|
-
/**
|
|
972
|
-
* Check if path exists.
|
|
973
|
-
*
|
|
974
|
-
* @param filePath - Path to check
|
|
975
|
-
* @returns True if path exists
|
|
976
|
-
*/
|
|
977
|
-
function exists(filePath) {
|
|
978
|
-
return node_fs.existsSync(filePath);
|
|
979
|
-
}
|
|
980
|
-
|
|
981
244
|
const fsDirLogger = createScopedLogger('project-scope:fs:dir');
|
|
982
245
|
/**
|
|
983
246
|
* List immediate contents of a directory.
|
|
@@ -986,7 +249,7 @@ const fsDirLogger = createScopedLogger('project-scope:fs:dir');
|
|
|
986
249
|
* @returns Array of entries with metadata for each file/directory
|
|
987
250
|
* @throws {Error} If directory doesn't exist or isn't a directory
|
|
988
251
|
*
|
|
989
|
-
* @example
|
|
252
|
+
* @example Listing directory contents
|
|
990
253
|
* ```typescript
|
|
991
254
|
* import { readDirectory } from '@hyperfrontend/project-scope'
|
|
992
255
|
*
|
|
@@ -1029,211 +292,7 @@ function readDirectory(dirPath) {
|
|
|
1029
292
|
|
|
1030
293
|
createScopedLogger('project-scope:fs:traversal');
|
|
1031
294
|
|
|
1032
|
-
|
|
1033
|
-
* Pattern matching utilities with ReDoS protection.
|
|
1034
|
-
* Uses character-by-character matching instead of regex where possible.
|
|
1035
|
-
*/
|
|
1036
|
-
/**
|
|
1037
|
-
* Match path against glob pattern using safe character iteration.
|
|
1038
|
-
* Avoids regex to prevent ReDoS attacks.
|
|
1039
|
-
*
|
|
1040
|
-
* Supported patterns:
|
|
1041
|
-
* - * matches any characters except /
|
|
1042
|
-
* - ** matches any characters including /
|
|
1043
|
-
* - ? matches exactly one character except /
|
|
1044
|
-
* - {a,b,c} matches any of the alternatives
|
|
1045
|
-
*
|
|
1046
|
-
* @param path - The filesystem path to test against the pattern
|
|
1047
|
-
* @param pattern - The glob pattern to match against
|
|
1048
|
-
* @returns True if path matches pattern
|
|
1049
|
-
*
|
|
1050
|
-
* @example
|
|
1051
|
-
* ```typescript
|
|
1052
|
-
* import { matchGlobPattern } from '@hyperfrontend/project-scope'
|
|
1053
|
-
*
|
|
1054
|
-
* matchGlobPattern('src/utils/helper.ts', '\*\*\/*.ts') // true
|
|
1055
|
-
* matchGlobPattern('test.spec.ts', '\*.spec.ts') // true
|
|
1056
|
-
* matchGlobPattern('config.json', '\*.{json,yaml}') // true
|
|
1057
|
-
* matchGlobPattern('src/index.ts', 'src/\*.ts') // true
|
|
1058
|
-
* ```
|
|
1059
|
-
*/
|
|
1060
|
-
function matchGlobPattern(path, pattern) {
|
|
1061
|
-
return matchSegments(path.split('/'), pattern.split('/'), 0, 0);
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Internal recursive function to match path segments against pattern segments.
|
|
1065
|
-
*
|
|
1066
|
-
* @param pathParts - Array of path segments split by '/'
|
|
1067
|
-
* @param patternParts - Array of pattern segments split by '/'
|
|
1068
|
-
* @param pathIdx - Current index in pathParts being examined
|
|
1069
|
-
* @param patternIdx - Current index in patternParts being examined
|
|
1070
|
-
* @returns True if remaining segments match
|
|
1071
|
-
*/
|
|
1072
|
-
function matchSegments(pathParts, patternParts, pathIdx, patternIdx) {
|
|
1073
|
-
// Base cases
|
|
1074
|
-
if (pathIdx === pathParts.length && patternIdx === patternParts.length) {
|
|
1075
|
-
return true; // Both exhausted = match
|
|
1076
|
-
}
|
|
1077
|
-
if (patternIdx >= patternParts.length) {
|
|
1078
|
-
return false; // Pattern exhausted but path remains
|
|
1079
|
-
}
|
|
1080
|
-
const patternPart = patternParts[patternIdx];
|
|
1081
|
-
// Handle ** (globstar) - matches zero or more directories
|
|
1082
|
-
if (patternPart === '**') {
|
|
1083
|
-
// Try matching rest of pattern against current position and all future positions
|
|
1084
|
-
for (let i = pathIdx; i <= pathParts.length; i++) {
|
|
1085
|
-
if (matchSegments(pathParts, patternParts, i, patternIdx + 1)) {
|
|
1086
|
-
return true;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
return false;
|
|
1090
|
-
}
|
|
1091
|
-
if (pathIdx >= pathParts.length) {
|
|
1092
|
-
return false; // Path exhausted but pattern remains (and it's not **)
|
|
1093
|
-
}
|
|
1094
|
-
const pathPart = pathParts[pathIdx];
|
|
1095
|
-
// Match current segment
|
|
1096
|
-
if (matchSegment(pathPart, patternPart)) {
|
|
1097
|
-
return matchSegments(pathParts, patternParts, pathIdx + 1, patternIdx + 1);
|
|
1098
|
-
}
|
|
1099
|
-
return false;
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* Match a single path segment against a pattern segment.
|
|
1103
|
-
* Handles *, ?, and {a,b,c} patterns.
|
|
1104
|
-
*
|
|
1105
|
-
* @param text - The path segment text to match
|
|
1106
|
-
* @param pattern - The pattern segment to match against
|
|
1107
|
-
* @returns True if the text matches the pattern
|
|
1108
|
-
*/
|
|
1109
|
-
function matchSegment(text, pattern) {
|
|
1110
|
-
let textIdx = 0;
|
|
1111
|
-
let patternIdx = 0;
|
|
1112
|
-
while (patternIdx < pattern.length) {
|
|
1113
|
-
const char = pattern[patternIdx];
|
|
1114
|
-
if (char === '*') {
|
|
1115
|
-
// * matches zero or more characters
|
|
1116
|
-
patternIdx++;
|
|
1117
|
-
if (patternIdx === pattern.length) {
|
|
1118
|
-
return true; // * at end matches rest of string
|
|
1119
|
-
}
|
|
1120
|
-
// Try matching rest of pattern at each position in text
|
|
1121
|
-
for (let i = textIdx; i <= text.length; i++) {
|
|
1122
|
-
if (matchSegmentFrom(text, i, pattern, patternIdx)) {
|
|
1123
|
-
return true;
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
return false;
|
|
1127
|
-
}
|
|
1128
|
-
else if (char === '?') {
|
|
1129
|
-
// ? matches exactly one character
|
|
1130
|
-
if (textIdx >= text.length) {
|
|
1131
|
-
return false;
|
|
1132
|
-
}
|
|
1133
|
-
textIdx++;
|
|
1134
|
-
patternIdx++;
|
|
1135
|
-
}
|
|
1136
|
-
else if (char === '{') {
|
|
1137
|
-
// {a,b,c} matches any alternative
|
|
1138
|
-
const closeIdx = findClosingBrace(pattern, patternIdx);
|
|
1139
|
-
if (closeIdx === -1) {
|
|
1140
|
-
// Unmatched brace, treat as literal
|
|
1141
|
-
if (textIdx >= text.length || text[textIdx] !== char) {
|
|
1142
|
-
return false;
|
|
1143
|
-
}
|
|
1144
|
-
textIdx++;
|
|
1145
|
-
patternIdx++;
|
|
1146
|
-
}
|
|
1147
|
-
else {
|
|
1148
|
-
const alternatives = extractAlternatives(pattern.slice(patternIdx + 1, closeIdx));
|
|
1149
|
-
for (const alt of alternatives) {
|
|
1150
|
-
if (matchSegmentFrom(text, textIdx, text.slice(0, textIdx) + alt + pattern.slice(closeIdx + 1), textIdx)) {
|
|
1151
|
-
return true;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
return false;
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
else {
|
|
1158
|
-
// Literal character
|
|
1159
|
-
if (textIdx >= text.length || text[textIdx] !== char) {
|
|
1160
|
-
return false;
|
|
1161
|
-
}
|
|
1162
|
-
textIdx++;
|
|
1163
|
-
patternIdx++;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
return textIdx === text.length;
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* Helper to match from a specific position.
|
|
1170
|
-
*
|
|
1171
|
-
* @param text - The full text being matched
|
|
1172
|
-
* @param textIdx - The starting index in text to match from
|
|
1173
|
-
* @param pattern - The full pattern being matched
|
|
1174
|
-
* @param patternIdx - The starting index in pattern to match from
|
|
1175
|
-
* @returns True if the text matches the pattern from the given positions
|
|
1176
|
-
*/
|
|
1177
|
-
function matchSegmentFrom(text, textIdx, pattern, patternIdx) {
|
|
1178
|
-
const remainingText = text.slice(textIdx);
|
|
1179
|
-
const remainingPattern = pattern.slice(patternIdx);
|
|
1180
|
-
return matchSegment(remainingText, remainingPattern);
|
|
1181
|
-
}
|
|
1182
|
-
/**
|
|
1183
|
-
* Find closing brace for {a,b,c} pattern.
|
|
1184
|
-
*
|
|
1185
|
-
* @param pattern - The pattern string to search within
|
|
1186
|
-
* @param startIdx - The index of the opening brace
|
|
1187
|
-
* @returns The index of the matching closing brace, or -1 if not found
|
|
1188
|
-
*/
|
|
1189
|
-
function findClosingBrace(pattern, startIdx) {
|
|
1190
|
-
let depth = 0;
|
|
1191
|
-
for (let i = startIdx; i < pattern.length; i++) {
|
|
1192
|
-
if (pattern[i] === '{') {
|
|
1193
|
-
depth++;
|
|
1194
|
-
}
|
|
1195
|
-
else if (pattern[i] === '}') {
|
|
1196
|
-
depth--;
|
|
1197
|
-
if (depth === 0) {
|
|
1198
|
-
return i;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
return -1;
|
|
1203
|
-
}
|
|
1204
|
-
/**
|
|
1205
|
-
* Extract alternatives from {a,b,c} pattern content.
|
|
1206
|
-
*
|
|
1207
|
-
* @param content - The content between braces (without the braces themselves)
|
|
1208
|
-
* @returns Array of alternative strings split by commas at depth 0
|
|
1209
|
-
*/
|
|
1210
|
-
function extractAlternatives(content) {
|
|
1211
|
-
const alternatives = [];
|
|
1212
|
-
let current = '';
|
|
1213
|
-
let depth = 0;
|
|
1214
|
-
for (let i = 0; i < content.length; i++) {
|
|
1215
|
-
const char = content[i];
|
|
1216
|
-
if (char === '{') {
|
|
1217
|
-
depth++;
|
|
1218
|
-
current += char;
|
|
1219
|
-
}
|
|
1220
|
-
else if (char === '}') {
|
|
1221
|
-
depth--;
|
|
1222
|
-
current += char;
|
|
1223
|
-
}
|
|
1224
|
-
else if (char === ',' && depth === 0) {
|
|
1225
|
-
alternatives.push(current);
|
|
1226
|
-
current = '';
|
|
1227
|
-
}
|
|
1228
|
-
else {
|
|
1229
|
-
current += char;
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
if (current) {
|
|
1233
|
-
alternatives.push(current);
|
|
1234
|
-
}
|
|
1235
|
-
return alternatives;
|
|
1236
|
-
}
|
|
295
|
+
createScopedLogger('project-scope:fs:write');
|
|
1237
296
|
|
|
1238
297
|
const walkLogger = createScopedLogger('project-scope:project:walk');
|
|
1239
298
|
/**
|
|
@@ -1300,6 +359,18 @@ function matchPattern(path, pattern) {
|
|
|
1300
359
|
* @param startPath - Root directory to begin traversal
|
|
1301
360
|
* @param visitor - Callback function invoked for each file system entry
|
|
1302
361
|
* @param options - Configuration for traversal behavior
|
|
362
|
+
*
|
|
363
|
+
* @example Walking a directory tree
|
|
364
|
+
* ```typescript
|
|
365
|
+
* import { walkDirectory } from '@hyperfrontend/project-scope'
|
|
366
|
+
*
|
|
367
|
+
* const tsFiles: string[] = []
|
|
368
|
+
* walkDirectory('./src', (entry) => {
|
|
369
|
+
* if (entry.isFile && entry.name.endsWith('.ts')) {
|
|
370
|
+
* tsFiles.push(entry.relativePath)
|
|
371
|
+
* }
|
|
372
|
+
* }, { maxDepth: 5, respectGitignore: true })
|
|
373
|
+
* ```
|
|
1303
374
|
*/
|
|
1304
375
|
function walkDirectory(startPath, visitor, options) {
|
|
1305
376
|
walkLogger.debug('Starting directory walk', {
|
|
@@ -1396,7 +467,7 @@ function matchesPatterns(path, patterns) {
|
|
|
1396
467
|
* @param options - Configuration for search behavior
|
|
1397
468
|
* @returns List of relative file paths that match the patterns
|
|
1398
469
|
*
|
|
1399
|
-
* @example
|
|
470
|
+
* @example Finding files by pattern
|
|
1400
471
|
* ```typescript
|
|
1401
472
|
* import { findFiles } from '@hyperfrontend/project-scope'
|
|
1402
473
|
*
|
|
@@ -1414,7 +485,7 @@ function matchesPatterns(path, patterns) {
|
|
|
1414
485
|
* ```
|
|
1415
486
|
*/
|
|
1416
487
|
function findFiles(startPath, patterns, options) {
|
|
1417
|
-
const normalizedPatterns = isArray(patterns) ? patterns : [patterns];
|
|
488
|
+
const normalizedPatterns = index_cjs_js$5.isArray(patterns) ? patterns : [patterns];
|
|
1418
489
|
searchLogger.debug('Finding files', { startPath, patterns: normalizedPatterns, maxResults: options?.maxResults });
|
|
1419
490
|
const results = [];
|
|
1420
491
|
const maxResults = options?.maxResults ?? Infinity;
|
|
@@ -1451,7 +522,7 @@ const configDetectionCache = createCache({ ttl: 30000, maxSize: 50 });
|
|
|
1451
522
|
* @param options - Detection options
|
|
1452
523
|
* @returns Array of detected configuration files
|
|
1453
524
|
*
|
|
1454
|
-
* @example
|
|
525
|
+
* @example Detecting configuration files
|
|
1455
526
|
* ```typescript
|
|
1456
527
|
* import { detectConfigs } from '@hyperfrontend/project-scope'
|
|
1457
528
|
*
|
|
@@ -1470,7 +541,7 @@ const configDetectionCache = createCache({ ttl: 30000, maxSize: 50 });
|
|
|
1470
541
|
* ```
|
|
1471
542
|
*/
|
|
1472
543
|
function detectConfigs(rootPath, types, options) {
|
|
1473
|
-
const typesToCheck = types ?? keys(CONFIG_PATTERNS);
|
|
544
|
+
const typesToCheck = types ?? index_cjs_js$2.keys(CONFIG_PATTERNS);
|
|
1474
545
|
const results = [];
|
|
1475
546
|
const maxDepth = options?.maxDepth ?? 10;
|
|
1476
547
|
const includeHidden = options?.includeHidden ?? true;
|
|
@@ -1531,6 +602,14 @@ function detectConfigs(rootPath, types, options) {
|
|
|
1531
602
|
* Clear the config detection cache.
|
|
1532
603
|
*
|
|
1533
604
|
* Useful for testing or when the project files have changed.
|
|
605
|
+
*
|
|
606
|
+
* @example Clearing the config detection cache
|
|
607
|
+
* ```typescript
|
|
608
|
+
* import { clearConfigDetectionCache } from '@hyperfrontend/project-scope'
|
|
609
|
+
*
|
|
610
|
+
* // Reset cache after modifying config files
|
|
611
|
+
* clearConfigDetectionCache()
|
|
612
|
+
* ```
|
|
1534
613
|
*/
|
|
1535
614
|
function clearConfigDetectionCache() {
|
|
1536
615
|
configDetectionCache.clear();
|
|
@@ -1541,6 +620,17 @@ function clearConfigDetectionCache() {
|
|
|
1541
620
|
* @param rootPath - Project root directory
|
|
1542
621
|
* @param type - Config type to find
|
|
1543
622
|
* @returns Full path to config file or null if not found
|
|
623
|
+
*
|
|
624
|
+
* @example Finding a specific config file
|
|
625
|
+
* ```typescript
|
|
626
|
+
* import { findConfigFile } from '@hyperfrontend/project-scope'
|
|
627
|
+
*
|
|
628
|
+
* const tsConfig = findConfigFile('/project', 'typescript')
|
|
629
|
+
* // => '/project/tsconfig.json'
|
|
630
|
+
*
|
|
631
|
+
* const eslint = findConfigFile('/project', 'eslint')
|
|
632
|
+
* // => '/project/.eslintrc.js' or null if not found
|
|
633
|
+
* ```
|
|
1544
634
|
*/
|
|
1545
635
|
function findConfigFile(rootPath, type) {
|
|
1546
636
|
const info = CONFIG_PATTERNS[type];
|
|
@@ -1564,76 +654,6 @@ function findConfigFile(rootPath, type) {
|
|
|
1564
654
|
}
|
|
1565
655
|
return null;
|
|
1566
656
|
}
|
|
1567
|
-
/**
|
|
1568
|
-
* Get all known config file patterns for a given configuration type.
|
|
1569
|
-
*
|
|
1570
|
-
* @param type - Configuration type identifier
|
|
1571
|
-
* @returns Array of glob patterns for matching config files
|
|
1572
|
-
*/
|
|
1573
|
-
function getConfigPaths(type) {
|
|
1574
|
-
const info = CONFIG_PATTERNS[type];
|
|
1575
|
-
return info?.patterns ?? [];
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
/**
|
|
1579
|
-
* Safe copies of Number built-in methods and constants.
|
|
1580
|
-
*
|
|
1581
|
-
* These references are captured at module initialization time to protect against
|
|
1582
|
-
* prototype pollution attacks. Import only what you need for tree-shaking.
|
|
1583
|
-
*
|
|
1584
|
-
* @module @hyperfrontend/immutable-api-utils/built-in-copy/number
|
|
1585
|
-
*/
|
|
1586
|
-
// Capture references at module initialization time
|
|
1587
|
-
const _parseInt = globalThis.parseInt;
|
|
1588
|
-
const _parseFloat = globalThis.parseFloat;
|
|
1589
|
-
// ============================================================================
|
|
1590
|
-
// Parsing
|
|
1591
|
-
// ============================================================================
|
|
1592
|
-
/**
|
|
1593
|
-
* (Safe copy) Parses a string and returns an integer.
|
|
1594
|
-
*/
|
|
1595
|
-
const parseInt = _parseInt;
|
|
1596
|
-
/**
|
|
1597
|
-
* (Safe copy) Parses a string and returns a floating point number.
|
|
1598
|
-
*/
|
|
1599
|
-
const parseFloat = _parseFloat;
|
|
1600
|
-
|
|
1601
|
-
/**
|
|
1602
|
-
* Create a structured error with code and optional context.
|
|
1603
|
-
*
|
|
1604
|
-
* @param message - The human-readable error message
|
|
1605
|
-
* @param code - The machine-readable error code for programmatic handling
|
|
1606
|
-
* @param context - Additional contextual information about the error
|
|
1607
|
-
* @returns Structured error instance with code and context properties
|
|
1608
|
-
*
|
|
1609
|
-
* @example
|
|
1610
|
-
* ```typescript
|
|
1611
|
-
* import { createStructuredError } from '@hyperfrontend/project-scope'
|
|
1612
|
-
*
|
|
1613
|
-
* throw createStructuredError(
|
|
1614
|
-
* 'Configuration file not found',
|
|
1615
|
-
* 'CONFIG_NOT_FOUND',
|
|
1616
|
-
* { path: './config.json', searched: ['./config.json', './settings.json'] }
|
|
1617
|
-
* )
|
|
1618
|
-
* ```
|
|
1619
|
-
*/
|
|
1620
|
-
function createStructuredError(message, code, context) {
|
|
1621
|
-
const error = createError(message);
|
|
1622
|
-
error.code = code;
|
|
1623
|
-
error.context = context ?? {};
|
|
1624
|
-
return error;
|
|
1625
|
-
}
|
|
1626
|
-
/**
|
|
1627
|
-
* Create a configuration-related error.
|
|
1628
|
-
*
|
|
1629
|
-
* @param message - The human-readable error message
|
|
1630
|
-
* @param code - The machine-readable error code for programmatic handling
|
|
1631
|
-
* @param context - Additional contextual information (e.g., file path, config key)
|
|
1632
|
-
* @returns Structured error instance tagged with type 'config'
|
|
1633
|
-
*/
|
|
1634
|
-
function createConfigError(message, code, context) {
|
|
1635
|
-
return createStructuredError(message, code, { ...context, type: 'config' });
|
|
1636
|
-
}
|
|
1637
657
|
|
|
1638
658
|
/**
|
|
1639
659
|
* Detect config type from file name.
|
|
@@ -1644,7 +664,7 @@ function createConfigError(message, code, context) {
|
|
|
1644
664
|
*/
|
|
1645
665
|
function detectConfigType(filePath) {
|
|
1646
666
|
const fileName = node_path.basename(filePath);
|
|
1647
|
-
for (const [type, info] of entries(CONFIG_PATTERNS)) {
|
|
667
|
+
for (const [type, info] of index_cjs_js$2.entries(CONFIG_PATTERNS)) {
|
|
1648
668
|
for (const pattern of info.patterns) {
|
|
1649
669
|
if (matchGlobPattern(fileName, pattern)) {
|
|
1650
670
|
return type;
|
|
@@ -1765,10 +785,10 @@ function parseSimpleYaml(content) {
|
|
|
1765
785
|
result[key] = null;
|
|
1766
786
|
}
|
|
1767
787
|
else if (/^-?\d+$/.test(value)) {
|
|
1768
|
-
result[key] = parseInt(value, 10);
|
|
788
|
+
result[key] = index_cjs_js$8.parseInt(value, 10);
|
|
1769
789
|
}
|
|
1770
790
|
else if (/^-?\d+\.\d+$/.test(value)) {
|
|
1771
|
-
result[key] = parseFloat(value);
|
|
791
|
+
result[key] = index_cjs_js$8.parseFloat(value);
|
|
1772
792
|
}
|
|
1773
793
|
else {
|
|
1774
794
|
result[key] = value.replace(/^["']|["']$/g, '');
|
|
@@ -1846,16 +866,28 @@ function parseDotenv(content) {
|
|
|
1846
866
|
* @param type - Category of configuration (e.g., typescript, eslint)
|
|
1847
867
|
* @param format - Whether to strip comments (jsonc) or parse strictly (json)
|
|
1848
868
|
* @returns Configuration object with parsed data and extends references
|
|
869
|
+
*
|
|
870
|
+
* @example Parsing JSON configuration
|
|
871
|
+
* ```typescript
|
|
872
|
+
* import { parseJsonConfig } from '@hyperfrontend/project-scope'
|
|
873
|
+
*
|
|
874
|
+
* const config = parseJsonConfig(
|
|
875
|
+
* 'tsconfig.json',
|
|
876
|
+
* '{ "extends": "./base.json", "compilerOptions": {} }',
|
|
877
|
+
* 'typescript'
|
|
878
|
+
* )
|
|
879
|
+
* // => { type: 'typescript', path: 'tsconfig.json', data: {...}, extends: ['./base.json'] }
|
|
880
|
+
* ```
|
|
1849
881
|
*/
|
|
1850
882
|
function parseJsonConfig(filePath, content, type, format = 'json') {
|
|
1851
883
|
const cleanContent = format === 'jsonc' ? stripJsonComments(content) : content;
|
|
1852
884
|
try {
|
|
1853
|
-
const data = parse(cleanContent);
|
|
885
|
+
const data = index_cjs_js$6.parse(cleanContent);
|
|
1854
886
|
let extendsPath;
|
|
1855
887
|
if (typeof data['extends'] === 'string') {
|
|
1856
888
|
extendsPath = [data['extends']];
|
|
1857
889
|
}
|
|
1858
|
-
else if (isArray(data['extends'])) {
|
|
890
|
+
else if (index_cjs_js$5.isArray(data['extends'])) {
|
|
1859
891
|
extendsPath = data['extends'];
|
|
1860
892
|
}
|
|
1861
893
|
return {
|
|
@@ -1881,6 +913,14 @@ function parseJsonConfig(filePath, content, type, format = 'json') {
|
|
|
1881
913
|
* @param content - Raw file content to parse
|
|
1882
914
|
* @param type - Category of configuration (e.g., github-actions, docker-compose)
|
|
1883
915
|
* @returns Configuration object with parsed YAML data
|
|
916
|
+
*
|
|
917
|
+
* @example Parsing YAML configuration
|
|
918
|
+
* ```typescript
|
|
919
|
+
* import { parseYamlConfig } from '@hyperfrontend/project-scope'
|
|
920
|
+
*
|
|
921
|
+
* const config = parseYamlConfig('.github/workflows/ci.yml', yamlContent, 'github-actions')
|
|
922
|
+
* // => { type: 'github-actions', path: '...', format: 'yaml', data: {...} }
|
|
923
|
+
* ```
|
|
1884
924
|
*/
|
|
1885
925
|
function parseYamlConfig(filePath, content, type) {
|
|
1886
926
|
const data = parseSimpleYaml(content);
|
|
@@ -1897,6 +937,14 @@ function parseYamlConfig(filePath, content, type) {
|
|
|
1897
937
|
* @param filePath - Path to config file
|
|
1898
938
|
* @param type - Optional config type (auto-detected if not provided)
|
|
1899
939
|
* @returns Parsed configuration
|
|
940
|
+
*
|
|
941
|
+
* @example Parsing a configuration file
|
|
942
|
+
* ```typescript
|
|
943
|
+
* import { parseConfig } from '@hyperfrontend/project-scope'
|
|
944
|
+
*
|
|
945
|
+
* const tsConfig = parseConfig('/project/tsconfig.json')
|
|
946
|
+
* const eslintConfig = parseConfig('/project/.eslintrc.yml', 'eslint')
|
|
947
|
+
* ```
|
|
1900
948
|
*/
|
|
1901
949
|
function parseConfig(filePath, type) {
|
|
1902
950
|
const content = readFileContent(filePath);
|
|
@@ -1941,42 +989,12 @@ function parseConfig(filePath, type) {
|
|
|
1941
989
|
};
|
|
1942
990
|
}
|
|
1943
991
|
}
|
|
1944
|
-
/**
|
|
1945
|
-
* Read and parse config file if it exists.
|
|
1946
|
-
*
|
|
1947
|
-
* @param configPath - Path to config file
|
|
1948
|
-
* @returns Parsed config or null if file doesn't exist
|
|
1949
|
-
*/
|
|
1950
|
-
function readConfigIfExists(configPath) {
|
|
1951
|
-
const content = readFileIfExists(configPath);
|
|
1952
|
-
if (!content)
|
|
1953
|
-
return null;
|
|
1954
|
-
try {
|
|
1955
|
-
const format = detectFormat(configPath);
|
|
1956
|
-
switch (format) {
|
|
1957
|
-
case 'json':
|
|
1958
|
-
return parse(content);
|
|
1959
|
-
case 'jsonc':
|
|
1960
|
-
return parse(stripJsonComments(content));
|
|
1961
|
-
case 'yaml':
|
|
1962
|
-
return parseSimpleYaml(content);
|
|
1963
|
-
default:
|
|
1964
|
-
return null;
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
catch {
|
|
1968
|
-
return null;
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
992
|
|
|
1972
993
|
exports.CONFIG_PATTERNS = CONFIG_PATTERNS;
|
|
1973
994
|
exports.clearConfigDetectionCache = clearConfigDetectionCache;
|
|
1974
995
|
exports.detectConfigs = detectConfigs;
|
|
1975
996
|
exports.findConfigFile = findConfigFile;
|
|
1976
|
-
exports.getConfigPaths = getConfigPaths;
|
|
1977
997
|
exports.getConfigPatternsByType = getConfigPatternsByType;
|
|
1978
998
|
exports.parseConfig = parseConfig;
|
|
1979
999
|
exports.parseJsonConfig = parseJsonConfig;
|
|
1980
1000
|
exports.parseYamlConfig = parseYamlConfig;
|
|
1981
|
-
exports.readConfigIfExists = readConfigIfExists;
|
|
1982
|
-
//# sourceMappingURL=index.cjs.js.map
|