@featurevisor/core 2.26.1 → 3.0.1
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 +8 -0
- package/coverage/clover.xml +4991 -3130
- package/coverage/coverage-final.json +63 -39
- package/coverage/lcov-report/block-navigation.js +1 -1
- package/coverage/lcov-report/index.html +248 -98
- package/coverage/lcov-report/sorter.js +21 -7
- package/coverage/lcov-report/src/assess-distribution/index.html +116 -0
- package/coverage/lcov-report/src/assess-distribution/index.ts.html +754 -0
- package/coverage/lcov-report/{list → src/benchmark}/index.html +30 -30
- package/coverage/lcov-report/src/benchmark/index.ts.html +793 -0
- package/coverage/lcov-report/{builder → src/builder}/allocator.ts.html +38 -38
- package/coverage/lcov-report/{builder/buildScopedConditions.ts.html → src/builder/applyContextToConditions.ts.html} +80 -65
- package/coverage/lcov-report/{builder/buildScopedDatafile.ts.html → src/builder/applyContextToDatafile.ts.html} +92 -92
- package/coverage/lcov-report/{builder/buildScopedSegments.ts.html → src/builder/applyContextToSegments.ts.html} +103 -67
- package/coverage/lcov-report/{builder → src/builder}/buildDatafile.ts.html +336 -306
- package/coverage/lcov-report/src/builder/buildProject.ts.html +1117 -0
- package/coverage/lcov-report/src/builder/buildRuntimeDatafiles.ts.html +256 -0
- package/coverage/lcov-report/{builder → src/builder}/getFeatureRanges.ts.html +22 -22
- package/coverage/lcov-report/{builder → src/builder}/hashes.ts.html +50 -50
- package/coverage/lcov-report/{builder → src/builder}/index.html +114 -84
- package/coverage/lcov-report/{tester/cliFormat.ts.html → src/builder/index.ts.html} +17 -29
- package/coverage/lcov-report/{builder → src/builder}/mutateVariables.ts.html +55 -55
- package/coverage/lcov-report/{builder → src/builder}/mutator.ts.html +118 -118
- package/coverage/lcov-report/{builder → src/builder}/revision.ts.html +15 -15
- package/coverage/lcov-report/{builder → src/builder}/traffic.ts.html +86 -86
- package/coverage/lcov-report/src/cli/cli.ts.html +400 -0
- package/coverage/lcov-report/{tester → src/cli}/index.html +41 -41
- package/coverage/lcov-report/src/cli/plugins.ts.html +214 -0
- package/coverage/lcov-report/{config → src/config}/index.html +31 -31
- package/coverage/lcov-report/{config → src/config}/index.ts.html +12 -12
- package/coverage/lcov-report/{config → src/config}/projectConfig.ts.html +312 -96
- package/coverage/lcov-report/{datasource → src/datasource}/adapter.ts.html +28 -73
- package/coverage/lcov-report/{datasource → src/datasource}/datasource.ts.html +191 -104
- package/coverage/lcov-report/{datasource → src/datasource}/filesystemAdapter.ts.html +233 -635
- package/coverage/lcov-report/{datasource → src/datasource}/index.html +48 -48
- package/coverage/lcov-report/{datasource → src/datasource}/index.ts.html +14 -14
- package/coverage/lcov-report/src/evaluate/index.html +116 -0
- package/coverage/lcov-report/src/evaluate/index.ts.html +814 -0
- package/coverage/lcov-report/src/find-duplicate-segments/findDuplicateSegments.ts.html +313 -0
- package/coverage/lcov-report/src/find-duplicate-segments/index.html +131 -0
- package/coverage/lcov-report/src/find-duplicate-segments/index.ts.html +307 -0
- package/coverage/lcov-report/src/find-usage/index.html +116 -0
- package/coverage/lcov-report/src/find-usage/index.ts.html +1780 -0
- package/coverage/lcov-report/src/generate-code/index.html +131 -0
- package/coverage/lcov-report/src/generate-code/index.ts.html +403 -0
- package/coverage/lcov-report/{generate-code → src/generate-code}/typescript.ts.html +266 -1361
- package/coverage/lcov-report/{generate-code → src}/index.html +38 -23
- package/coverage/lcov-report/src/info/index.html +116 -0
- package/coverage/lcov-report/src/info/index.ts.html +472 -0
- package/coverage/lcov-report/src/init/index.html +116 -0
- package/coverage/lcov-report/src/init/index.ts.html +280 -0
- package/coverage/lcov-report/{linter → src/linter}/attributeSchema.ts.html +160 -157
- package/coverage/lcov-report/{linter → src/linter}/checkCircularDependency.ts.html +25 -25
- package/coverage/lcov-report/{linter → src/linter}/checkPercentageExceedingSlot.ts.html +42 -42
- package/coverage/lcov-report/{linter → src/linter}/conditionSchema.ts.html +207 -207
- package/coverage/lcov-report/{linter → src/linter}/featureSchema.ts.html +462 -471
- package/coverage/lcov-report/{linter → src/linter}/groupSchema.ts.html +25 -22
- package/coverage/lcov-report/{linter → src/linter}/index.html +129 -99
- package/coverage/lcov-report/src/linter/index.ts.html +88 -0
- package/coverage/lcov-report/{linter → src/linter}/lintProject.ts.html +740 -332
- package/coverage/lcov-report/{linter → src/linter}/mutationNotation.ts.html +130 -130
- package/coverage/lcov-report/{linter → src/linter}/printError.ts.html +27 -27
- package/coverage/lcov-report/{linter → src/linter}/schema.ts.html +153 -150
- package/coverage/lcov-report/{linter → src/linter}/segmentSchema.ts.html +18 -15
- package/coverage/lcov-report/src/linter/targetSchema.ts.html +223 -0
- package/coverage/lcov-report/{linter → src/linter}/testSchema.ts.html +54 -48
- package/coverage/lcov-report/{linter → src/linter}/zodHelpers.ts.html +17 -17
- package/coverage/lcov-report/src/list/index.html +131 -0
- package/coverage/lcov-report/src/list/index.ts.html +2065 -0
- package/coverage/lcov-report/{list → src/list}/matrix.ts.html +43 -58
- package/coverage/lcov-report/src/promoter/index.html +116 -0
- package/coverage/lcov-report/src/promoter/index.ts.html +3883 -0
- package/coverage/lcov-report/src/sets.ts.html +313 -0
- package/coverage/lcov-report/src/targeting.ts.html +403 -0
- package/coverage/lcov-report/src/tester/cliFormat.ts.html +133 -0
- package/coverage/lcov-report/{tester → src/tester}/helpers.ts.html +15 -15
- package/coverage/lcov-report/src/tester/index.html +206 -0
- package/coverage/lcov-report/src/tester/prettyDuration.ts.html +187 -0
- package/coverage/lcov-report/src/tester/printTestResult.ts.html +337 -0
- package/coverage/lcov-report/src/tester/testFeature.ts.html +1186 -0
- package/coverage/lcov-report/src/tester/testProject.ts.html +1018 -0
- package/coverage/lcov-report/src/tester/testSegment.ts.html +316 -0
- package/coverage/lcov-report/{utils → src/utils}/extractKeys.ts.html +68 -68
- package/coverage/lcov-report/{utils → src/utils}/git.ts.html +44 -68
- package/coverage/lcov-report/{utils → src/utils}/index.html +44 -44
- package/coverage/lcov-report/{utils → src/utils}/index.ts.html +14 -14
- package/coverage/lcov-report/{utils → src/utils}/pretty.ts.html +20 -20
- package/coverage/lcov.info +10121 -5723
- package/jest.config.js +13 -4
- package/lib/assess-distribution/index.d.ts +1 -1
- package/lib/assess-distribution/index.js +59 -40
- package/lib/assess-distribution/index.js.map +1 -1
- package/lib/benchmark/index.d.ts +8 -5
- package/lib/benchmark/index.js +82 -65
- package/lib/benchmark/index.js.map +1 -1
- package/lib/builder/applyContextToConditions.d.ts +5 -0
- package/lib/builder/{buildScopedConditions.js → applyContextToConditions.js} +19 -14
- package/lib/builder/applyContextToConditions.js.map +1 -0
- package/lib/builder/applyContextToDatafile.d.ts +2 -0
- package/lib/builder/{buildScopedDatafile.js → applyContextToDatafile.js} +26 -26
- package/lib/builder/applyContextToDatafile.js.map +1 -0
- package/lib/builder/applyContextToSegments.d.ts +5 -0
- package/lib/builder/{buildScopedSegments.js → applyContextToSegments.js} +19 -14
- package/lib/builder/applyContextToSegments.js.map +1 -0
- package/lib/builder/buildDatafile.d.ts +9 -6
- package/lib/builder/buildDatafile.js +86 -51
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +17 -3
- package/lib/builder/buildProject.js +151 -59
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/buildRuntimeDatafiles.d.ts +12 -0
- package/lib/builder/buildRuntimeDatafiles.js +35 -0
- package/lib/builder/buildRuntimeDatafiles.js.map +1 -0
- package/lib/builder/getFeatureRanges.js +34 -1
- package/lib/builder/getFeatureRanges.js.map +1 -1
- package/lib/builder/hashes.js +34 -1
- package/lib/builder/hashes.js.map +1 -1
- package/lib/builder/index.d.ts +0 -1
- package/lib/builder/index.js +0 -1
- package/lib/builder/index.js.map +1 -1
- package/lib/cli/cli.js +0 -4
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/plugins.js +7 -2
- package/lib/cli/plugins.js.map +1 -1
- package/lib/config/projectConfig.d.ts +17 -17
- package/lib/config/projectConfig.js +101 -15
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/adapter.d.ts +7 -9
- package/lib/datasource/adapter.js +0 -7
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/datasource.d.ts +15 -5
- package/lib/datasource/datasource.js +37 -9
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/filesystemAdapter.d.ts +4 -10
- package/lib/datasource/filesystemAdapter.js +111 -149
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/evaluate/index.d.ts +1 -7
- package/lib/evaluate/index.js +81 -67
- package/lib/evaluate/index.js.map +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js +34 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
- package/lib/find-duplicate-segments/index.js +21 -13
- package/lib/find-duplicate-segments/index.js.map +1 -1
- package/lib/find-usage/index.js +57 -41
- package/lib/find-usage/index.js.map +1 -1
- package/lib/generate-code/index.d.ts +1 -1
- package/lib/generate-code/index.js +64 -21
- package/lib/generate-code/index.js.map +1 -1
- package/lib/generate-code/typescript.d.ts +1 -1
- package/lib/generate-code/typescript.js +59 -333
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/info/index.js +57 -16
- package/lib/info/index.js.map +1 -1
- package/lib/init/index.d.ts +2 -2
- package/lib/init/index.js +39 -3
- package/lib/init/index.js.map +1 -1
- package/lib/linter/attributeSchema.d.ts +1 -0
- package/lib/linter/attributeSchema.js +1 -0
- package/lib/linter/attributeSchema.js.map +1 -1
- package/lib/linter/conditionSchema.js +5 -5
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +4 -1
- package/lib/linter/featureSchema.js +15 -13
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/groupSchema.d.ts +1 -0
- package/lib/linter/groupSchema.js +1 -0
- package/lib/linter/groupSchema.js.map +1 -1
- package/lib/linter/lintProject.d.ts +1 -3
- package/lib/linter/lintProject.js +198 -68
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/schema.js +1 -0
- package/lib/linter/schema.js.map +1 -1
- package/lib/linter/segmentSchema.d.ts +1 -0
- package/lib/linter/segmentSchema.js +1 -0
- package/lib/linter/segmentSchema.js.map +1 -1
- package/lib/linter/targetSchema.d.ts +16 -0
- package/lib/linter/targetSchema.js +40 -0
- package/lib/linter/targetSchema.js.map +1 -0
- package/lib/linter/testSchema.d.ts +4 -3
- package/lib/linter/testSchema.js +9 -4
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/list/index.d.ts +1 -0
- package/lib/list/index.js +131 -12
- package/lib/list/index.js.map +1 -1
- package/lib/list/matrix.js +3 -7
- package/lib/list/matrix.js.map +1 -1
- package/lib/promoter/index.d.ts +50 -0
- package/lib/promoter/index.js +880 -0
- package/lib/promoter/index.js.map +1 -0
- package/lib/sets.d.ts +11 -0
- package/lib/sets.js +81 -0
- package/lib/sets.js.map +1 -0
- package/lib/targeting.d.ts +14 -0
- package/lib/targeting.js +82 -0
- package/lib/targeting.js.map +1 -0
- package/lib/tester/cliFormat.d.ts +7 -1
- package/lib/tester/cliFormat.js +11 -2
- package/lib/tester/cliFormat.js.map +1 -1
- package/lib/tester/printTestResult.js +2 -2
- package/lib/tester/printTestResult.js.map +1 -1
- package/lib/tester/testFeature.d.ts +0 -1
- package/lib/tester/testFeature.js +8 -25
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +2 -3
- package/lib/tester/testProject.js +93 -86
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.d.ts +1 -1
- package/lib/tester/testSegment.js +3 -21
- package/lib/tester/testSegment.js.map +1 -1
- package/lib/utils/git.js +45 -19
- package/lib/utils/git.js.map +1 -1
- package/package.json +12 -12
- package/src/assess-distribution/index.ts +72 -52
- package/src/benchmark/index.ts +124 -91
- package/src/builder/{buildScopedConditions.spec.ts → applyContextToConditions.spec.ts} +160 -142
- package/src/builder/{buildScopedConditions.ts → applyContextToConditions.ts} +19 -14
- package/src/builder/{buildScopedDatafile.spec.ts → applyContextToDatafile.spec.ts} +141 -81
- package/src/builder/{buildScopedDatafile.ts → applyContextToDatafile.ts} +33 -33
- package/src/builder/{buildScopedSegments.spec.ts → applyContextToSegments.spec.ts} +171 -151
- package/src/builder/{buildScopedSegments.ts → applyContextToSegments.ts} +26 -14
- package/src/builder/buildDatafile.spec.ts +192 -14
- package/src/builder/buildDatafile.ts +74 -64
- package/src/builder/buildProject.ts +171 -86
- package/src/builder/buildRuntimeDatafiles.ts +57 -0
- package/src/builder/index.ts +0 -1
- package/src/cli/cli.ts +0 -5
- package/src/cli/plugins.ts +7 -2
- package/src/config/projectConfig.spec.ts +171 -8
- package/src/config/projectConfig.ts +100 -28
- package/src/datasource/adapter.ts +8 -23
- package/src/datasource/datasource.ts +50 -21
- package/src/datasource/filesystemAdapter.spec.ts +133 -74
- package/src/datasource/filesystemAdapter.ts +93 -227
- package/src/evaluate/index.ts +109 -97
- package/src/find-duplicate-segments/index.ts +34 -16
- package/src/find-usage/index.ts +89 -44
- package/src/generate-code/index.ts +36 -24
- package/src/generate-code/typescript.spec.ts +106 -0
- package/src/generate-code/typescript.ts +33 -398
- package/src/index.ts +2 -1
- package/src/info/index.ts +72 -16
- package/src/init/index.ts +1 -1
- package/src/linter/attributeSchema.ts +1 -0
- package/src/linter/conditionSchema.spec.ts +23 -3
- package/src/linter/conditionSchema.ts +5 -5
- package/src/linter/featureSchema.spec.ts +107 -18
- package/src/linter/featureSchema.ts +25 -28
- package/src/linter/groupSchema.ts +1 -0
- package/src/linter/lintProject.spec.ts +131 -92
- package/src/linter/lintProject.ts +233 -97
- package/src/linter/schema.ts +1 -0
- package/src/linter/segmentSchema.spec.ts +5 -3
- package/src/linter/segmentSchema.ts +1 -0
- package/src/linter/targetSchema.spec.ts +159 -0
- package/src/linter/targetSchema.ts +46 -0
- package/src/linter/testSchema.spec.ts +70 -5
- package/src/linter/testSchema.ts +12 -10
- package/src/list/index.spec.ts +135 -0
- package/src/list/index.ts +188 -12
- package/src/list/matrix.ts +3 -8
- package/src/promoter/index.spec.ts +617 -0
- package/src/promoter/index.ts +1266 -0
- package/src/sets.ts +76 -0
- package/src/targeting.spec.ts +74 -0
- package/src/targeting.ts +106 -0
- package/src/tester/cliFormat.ts +11 -1
- package/src/tester/printTestResult.ts +12 -3
- package/src/tester/testFeature.ts +10 -36
- package/src/tester/testProject.spec.ts +50 -0
- package/src/tester/testProject.ts +89 -140
- package/src/tester/testSegment.ts +5 -22
- package/src/utils/git.ts +13 -21
- package/tsconfig.cjs.json +5 -1
- package/tsconfig.typecheck.json +9 -0
- package/coverage/lcov-report/builder/convertToV1.ts.html +0 -583
- package/lib/builder/allocator.spec.d.ts +0 -1
- package/lib/builder/allocator.spec.js +0 -85
- package/lib/builder/allocator.spec.js.map +0 -1
- package/lib/builder/buildDatafile.spec.d.ts +0 -1
- package/lib/builder/buildDatafile.spec.js +0 -233
- package/lib/builder/buildDatafile.spec.js.map +0 -1
- package/lib/builder/buildScopedConditions.d.ts +0 -5
- package/lib/builder/buildScopedConditions.js.map +0 -1
- package/lib/builder/buildScopedConditions.spec.d.ts +0 -1
- package/lib/builder/buildScopedConditions.spec.js +0 -2167
- package/lib/builder/buildScopedConditions.spec.js.map +0 -1
- package/lib/builder/buildScopedDatafile.d.ts +0 -2
- package/lib/builder/buildScopedDatafile.js.map +0 -1
- package/lib/builder/buildScopedDatafile.spec.d.ts +0 -1
- package/lib/builder/buildScopedDatafile.spec.js +0 -2277
- package/lib/builder/buildScopedDatafile.spec.js.map +0 -1
- package/lib/builder/buildScopedSegments.d.ts +0 -5
- package/lib/builder/buildScopedSegments.js.map +0 -1
- package/lib/builder/buildScopedSegments.spec.d.ts +0 -1
- package/lib/builder/buildScopedSegments.spec.js +0 -1062
- package/lib/builder/buildScopedSegments.spec.js.map +0 -1
- package/lib/builder/convertToV1.d.ts +0 -10
- package/lib/builder/convertToV1.js +0 -119
- package/lib/builder/convertToV1.js.map +0 -1
- package/lib/builder/mutateVariables.spec.d.ts +0 -1
- package/lib/builder/mutateVariables.spec.js +0 -1074
- package/lib/builder/mutateVariables.spec.js.map +0 -1
- package/lib/builder/mutator.spec.d.ts +0 -1
- package/lib/builder/mutator.spec.js +0 -368
- package/lib/builder/mutator.spec.js.map +0 -1
- package/lib/builder/revision.spec.d.ts +0 -1
- package/lib/builder/revision.spec.js +0 -21
- package/lib/builder/revision.spec.js.map +0 -1
- package/lib/builder/traffic.spec.d.ts +0 -1
- package/lib/builder/traffic.spec.js +0 -872
- package/lib/builder/traffic.spec.js.map +0 -1
- package/lib/config/projectConfig.spec.d.ts +0 -1
- package/lib/config/projectConfig.spec.js +0 -24
- package/lib/config/projectConfig.spec.js.map +0 -1
- package/lib/datasource/filesystemAdapter.spec.d.ts +0 -1
- package/lib/datasource/filesystemAdapter.spec.js +0 -88
- package/lib/datasource/filesystemAdapter.spec.js.map +0 -1
- package/lib/generate-code/typescript.spec.d.ts +0 -1
- package/lib/generate-code/typescript.spec.js +0 -78
- package/lib/generate-code/typescript.spec.js.map +0 -1
- package/lib/linter/attributeSchema.spec.d.ts +0 -1
- package/lib/linter/attributeSchema.spec.js +0 -266
- package/lib/linter/attributeSchema.spec.js.map +0 -1
- package/lib/linter/conditionSchema.spec.d.ts +0 -1
- package/lib/linter/conditionSchema.spec.js +0 -380
- package/lib/linter/conditionSchema.spec.js.map +0 -1
- package/lib/linter/featureSchema.spec.d.ts +0 -1
- package/lib/linter/featureSchema.spec.js +0 -1552
- package/lib/linter/featureSchema.spec.js.map +0 -1
- package/lib/linter/lintProject.spec.d.ts +0 -1
- package/lib/linter/lintProject.spec.js +0 -211
- package/lib/linter/lintProject.spec.js.map +0 -1
- package/lib/linter/mutationNotation.spec.d.ts +0 -1
- package/lib/linter/mutationNotation.spec.js +0 -598
- package/lib/linter/mutationNotation.spec.js.map +0 -1
- package/lib/linter/schema.spec.d.ts +0 -1
- package/lib/linter/schema.spec.js +0 -535
- package/lib/linter/schema.spec.js.map +0 -1
- package/lib/linter/segmentSchema.spec.d.ts +0 -1
- package/lib/linter/segmentSchema.spec.js +0 -303
- package/lib/linter/segmentSchema.spec.js.map +0 -1
- package/lib/linter/testSchema.spec.d.ts +0 -1
- package/lib/linter/testSchema.spec.js +0 -162
- package/lib/linter/testSchema.spec.js.map +0 -1
- package/lib/list/matrix.spec.d.ts +0 -1
- package/lib/list/matrix.spec.js +0 -42
- package/lib/list/matrix.spec.js.map +0 -1
- package/lib/site/exportSite.d.ts +0 -2
- package/lib/site/exportSite.js +0 -30
- package/lib/site/exportSite.js.map +0 -1
- package/lib/site/generateHistory.d.ts +0 -3
- package/lib/site/generateHistory.js +0 -31
- package/lib/site/generateHistory.js.map +0 -1
- package/lib/site/generateSiteSearchIndex.d.ts +0 -4
- package/lib/site/generateSiteSearchIndex.js +0 -195
- package/lib/site/generateSiteSearchIndex.js.map +0 -1
- package/lib/site/getLastModifiedFromHistory.d.ts +0 -2
- package/lib/site/getLastModifiedFromHistory.js +0 -18
- package/lib/site/getLastModifiedFromHistory.js.map +0 -1
- package/lib/site/getOwnerAndRepoFromUrl.d.ts +0 -4
- package/lib/site/getOwnerAndRepoFromUrl.js +0 -20
- package/lib/site/getOwnerAndRepoFromUrl.js.map +0 -1
- package/lib/site/getRelativePaths.d.ts +0 -6
- package/lib/site/getRelativePaths.js +0 -15
- package/lib/site/getRelativePaths.js.map +0 -1
- package/lib/site/getRepoDetails.d.ts +0 -8
- package/lib/site/getRepoDetails.js +0 -48
- package/lib/site/getRepoDetails.js.map +0 -1
- package/lib/site/index.d.ts +0 -2
- package/lib/site/index.js +0 -43
- package/lib/site/index.js.map +0 -1
- package/lib/site/serveSite.d.ts +0 -2
- package/lib/site/serveSite.js +0 -54
- package/lib/site/serveSite.js.map +0 -1
- package/lib/tester/helpers.spec.d.ts +0 -1
- package/lib/tester/helpers.spec.js +0 -115
- package/lib/tester/helpers.spec.js.map +0 -1
- package/src/builder/convertToV1.ts +0 -166
- package/src/site/exportSite.ts +0 -42
- package/src/site/generateHistory.ts +0 -40
- package/src/site/generateSiteSearchIndex.ts +0 -258
- package/src/site/getLastModifiedFromHistory.ts +0 -21
- package/src/site/getOwnerAndRepoFromUrl.ts +0 -17
- package/src/site/getRelativePaths.ts +0 -24
- package/src/site/getRepoDetails.ts +0 -62
- package/src/site/index.ts +0 -46
- package/src/site/serveSite.ts +0 -58
package/lib/evaluate/index.js
CHANGED
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.evaluatePlugin = void 0;
|
|
4
4
|
exports.evaluateFeature = evaluateFeature;
|
|
5
5
|
const sdk_1 = require("@featurevisor/sdk");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const buildRuntimeDatafiles_1 = require("../builder/buildRuntimeDatafiles");
|
|
7
|
+
const sets_1 = require("../sets");
|
|
8
|
+
const cliFormat_1 = require("../tester/cliFormat");
|
|
8
9
|
function printEvaluationDetails(evaluation) {
|
|
9
10
|
const ignoreKeys = ["featureKey", "variableKey", "traffic", "force"];
|
|
10
11
|
for (const [key, value] of Object.entries(evaluation)) {
|
|
@@ -12,59 +13,44 @@ function printEvaluationDetails(evaluation) {
|
|
|
12
13
|
continue;
|
|
13
14
|
}
|
|
14
15
|
if (key === "variation") {
|
|
15
|
-
console.log(
|
|
16
|
+
console.log(` ${(0, cliFormat_1.colorize)(key, cliFormat_1.CLI_COLOR_CYAN)}:`, value?.value);
|
|
16
17
|
continue;
|
|
17
18
|
}
|
|
18
19
|
if (key === "variableSchema") {
|
|
19
|
-
console.log(
|
|
20
|
-
console.log(
|
|
20
|
+
console.log(` ${(0, cliFormat_1.colorize)("variableType", cliFormat_1.CLI_COLOR_CYAN)}:`, value.type);
|
|
21
|
+
console.log(` ${(0, cliFormat_1.colorize)("defaultValue", cliFormat_1.CLI_COLOR_CYAN)}:`, value.defaultValue);
|
|
21
22
|
continue;
|
|
22
23
|
}
|
|
23
|
-
console.log(
|
|
24
|
+
console.log(` ${(0, cliFormat_1.colorize)(key, cliFormat_1.CLI_COLOR_CYAN)}:`, value);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
function printDiagnostics(diagnostics) {
|
|
28
|
+
diagnostics.forEach((diagnostic) => {
|
|
29
|
+
const levelColor = diagnostic.level === "error" ? 31 : diagnostic.level === "warn" ? 33 : 2;
|
|
30
|
+
console.log(`${(0, cliFormat_1.colorize)(`[${diagnostic.level}]`, levelColor)} ${diagnostic.message}`, diagnostic);
|
|
29
31
|
console.log("");
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
function printHeader(message) {
|
|
33
|
-
console.log("
|
|
34
|
-
console.log(
|
|
35
|
-
console.log("
|
|
35
|
+
console.log("");
|
|
36
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, message);
|
|
37
|
+
console.log("");
|
|
36
38
|
}
|
|
37
|
-
async function
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const datafileContent = await (0, builder_1.buildDatafile)(projectConfig, datasource, {
|
|
41
|
-
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
|
|
42
|
-
revision: "include-all-features",
|
|
43
|
-
environment: options.environment || false,
|
|
44
|
-
inflate: options.inflate,
|
|
45
|
-
}, existingState);
|
|
46
|
-
let logs = [];
|
|
47
|
-
const f = (0, sdk_1.createInstance)({
|
|
39
|
+
async function evaluateFeatureWithDatafile(datafileContent, options, target) {
|
|
40
|
+
let diagnostics = [];
|
|
41
|
+
const f = (0, sdk_1.createFeaturevisor)({
|
|
48
42
|
datafile: datafileContent,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
handler: (level, message, details) => {
|
|
52
|
-
logs.push({
|
|
53
|
-
level,
|
|
54
|
-
message,
|
|
55
|
-
details,
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
43
|
+
logLevel: "debug",
|
|
44
|
+
onDiagnostic: (diagnostic) => diagnostics.push(diagnostic),
|
|
59
45
|
});
|
|
60
46
|
const flagEvaluation = f.evaluateFlag(options.feature, options.context);
|
|
61
|
-
const
|
|
62
|
-
|
|
47
|
+
const flagEvaluationDiagnostics = [...diagnostics];
|
|
48
|
+
diagnostics = [];
|
|
63
49
|
const variationEvaluation = f.evaluateVariation(options.feature, options.context);
|
|
64
|
-
const
|
|
65
|
-
|
|
50
|
+
const variationEvaluationDiagnostics = [...diagnostics];
|
|
51
|
+
diagnostics = [];
|
|
66
52
|
const variableEvaluations = {};
|
|
67
|
-
const
|
|
53
|
+
const variableEvaluationDiagnostics = {};
|
|
68
54
|
const feature = f.getFeature(options.feature);
|
|
69
55
|
if (feature?.variablesSchema) {
|
|
70
56
|
const variableKeys = Array.isArray(feature.variablesSchema)
|
|
@@ -72,8 +58,8 @@ async function evaluateFeature(deps, options) {
|
|
|
72
58
|
: Object.keys(feature.variablesSchema);
|
|
73
59
|
variableKeys.forEach((variableKey) => {
|
|
74
60
|
const variableEvaluation = f.evaluateVariable(options.feature, variableKey, options.context);
|
|
75
|
-
|
|
76
|
-
|
|
61
|
+
variableEvaluationDiagnostics[variableKey] = [...diagnostics];
|
|
62
|
+
diagnostics = [];
|
|
77
63
|
variableEvaluations[variableKey] = variableEvaluation;
|
|
78
64
|
});
|
|
79
65
|
}
|
|
@@ -83,69 +69,97 @@ async function evaluateFeature(deps, options) {
|
|
|
83
69
|
variables: variableEvaluations,
|
|
84
70
|
};
|
|
85
71
|
if (options.json) {
|
|
86
|
-
|
|
87
|
-
return;
|
|
72
|
+
return allEvaluations;
|
|
88
73
|
}
|
|
89
74
|
console.log("");
|
|
90
|
-
console.log(
|
|
91
|
-
console.log(`
|
|
75
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, "Evaluating Featurevisor feature");
|
|
76
|
+
console.log(` ${(0, cliFormat_1.colorize)("Feature", cliFormat_1.CLI_COLOR_CYAN)}: ${options.feature}`);
|
|
77
|
+
console.log(` ${(0, cliFormat_1.colorize)("Environment", cliFormat_1.CLI_COLOR_CYAN)}: ${options.environment || false}`);
|
|
78
|
+
if (target)
|
|
79
|
+
console.log(` ${(0, cliFormat_1.colorize)("Target", cliFormat_1.CLI_COLOR_CYAN)}: ${target}`);
|
|
80
|
+
console.log(` ${(0, cliFormat_1.colorize)("Context", cliFormat_1.CLI_COLOR_CYAN)}: ${JSON.stringify(options.context)}`);
|
|
92
81
|
// flag
|
|
93
82
|
printHeader("Is enabled?");
|
|
94
83
|
if (options.verbose) {
|
|
95
|
-
|
|
84
|
+
printDiagnostics(flagEvaluationDiagnostics);
|
|
96
85
|
}
|
|
97
|
-
console.log(
|
|
86
|
+
console.log(flagEvaluation.enabled ? cliFormat_1.CLI_FORMAT_GREEN : cliFormat_1.CLI_FORMAT_YELLOW, `Value: ${flagEvaluation.enabled}`);
|
|
98
87
|
console.log("\nDetails:\n");
|
|
99
88
|
printEvaluationDetails(flagEvaluation);
|
|
100
89
|
// variation
|
|
101
90
|
printHeader("Variation");
|
|
102
91
|
if (feature?.variations) {
|
|
103
92
|
if (options.verbose) {
|
|
104
|
-
|
|
93
|
+
printDiagnostics(variationEvaluationDiagnostics);
|
|
105
94
|
}
|
|
106
|
-
console.log(
|
|
95
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, `Value: ${JSON.stringify(variationEvaluation.variation?.value)}`);
|
|
107
96
|
console.log("\nDetails:\n");
|
|
108
97
|
printEvaluationDetails(variationEvaluation);
|
|
109
98
|
}
|
|
110
99
|
else {
|
|
111
|
-
console.log("No variations defined.");
|
|
100
|
+
console.log(cliFormat_1.CLI_FORMAT_YELLOW, "No variations defined.");
|
|
112
101
|
}
|
|
113
102
|
// variables
|
|
114
103
|
if (feature?.variablesSchema) {
|
|
115
104
|
for (const [key, value] of Object.entries(variableEvaluations)) {
|
|
116
105
|
printHeader(`Variable: ${key}`);
|
|
117
106
|
if (options.verbose) {
|
|
118
|
-
|
|
107
|
+
printDiagnostics(variableEvaluationDiagnostics[key]);
|
|
119
108
|
}
|
|
120
|
-
|
|
109
|
+
const variableValue = typeof value.variableValue !== "undefined"
|
|
121
110
|
? JSON.stringify(value.variableValue)
|
|
122
|
-
: value.variableValue
|
|
111
|
+
: value.variableValue;
|
|
112
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, `Value: ${variableValue}`);
|
|
123
113
|
console.log("\nDetails:\n");
|
|
124
114
|
printEvaluationDetails(value);
|
|
125
115
|
}
|
|
126
116
|
}
|
|
127
117
|
else {
|
|
128
118
|
printHeader("Variables");
|
|
129
|
-
console.log("No variables defined.");
|
|
119
|
+
console.log(cliFormat_1.CLI_FORMAT_YELLOW, "No variables defined.");
|
|
120
|
+
}
|
|
121
|
+
return allEvaluations;
|
|
122
|
+
}
|
|
123
|
+
async function evaluateFeature(deps, options) {
|
|
124
|
+
const datafiles = await (0, buildRuntimeDatafiles_1.buildRuntimeDatafiles)(deps, {
|
|
125
|
+
environment: options.environment || false,
|
|
126
|
+
target: options.target,
|
|
127
|
+
revision: "include-all-features",
|
|
128
|
+
inflate: options.inflate,
|
|
129
|
+
});
|
|
130
|
+
const results = [];
|
|
131
|
+
for (const entry of datafiles) {
|
|
132
|
+
const evaluations = await evaluateFeatureWithDatafile(entry.datafile, options, entry.target);
|
|
133
|
+
results.push({ target: entry.target, evaluations });
|
|
134
|
+
}
|
|
135
|
+
if (options.json) {
|
|
136
|
+
const output = results.length === 1 ? results[0].evaluations : results;
|
|
137
|
+
console.log(options.pretty ? JSON.stringify(output, null, 2) : JSON.stringify(output));
|
|
130
138
|
}
|
|
131
139
|
}
|
|
132
140
|
exports.evaluatePlugin = {
|
|
133
141
|
command: "evaluate",
|
|
134
142
|
handler: async ({ rootDirectoryPath, projectConfig, datasource, parsed }) => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
(0, sets_1.assertProjectSetJsonSelection)(projectConfig, parsed.set, parsed.json);
|
|
144
|
+
const executions = await (0, sets_1.getProjectSetExecutions)(projectConfig, datasource, parsed.set);
|
|
145
|
+
for (const execution of executions) {
|
|
146
|
+
(0, sets_1.printSetHeader)(projectConfig, execution.set, parsed.json);
|
|
147
|
+
await evaluateFeature({
|
|
148
|
+
rootDirectoryPath,
|
|
149
|
+
projectConfig: execution.projectConfig,
|
|
150
|
+
datasource: execution.datasource,
|
|
151
|
+
options: parsed,
|
|
152
|
+
}, {
|
|
153
|
+
environment: parsed.environment,
|
|
154
|
+
feature: parsed.feature,
|
|
155
|
+
context: parsed.context ? JSON.parse(parsed.context) : {},
|
|
156
|
+
// @NOTE: introduce optional --at?
|
|
157
|
+
json: parsed.json,
|
|
158
|
+
pretty: parsed.pretty,
|
|
159
|
+
verbose: parsed.verbose,
|
|
160
|
+
target: parsed.target,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
149
163
|
},
|
|
150
164
|
examples: [
|
|
151
165
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/evaluate/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/evaluate/index.ts"],"names":[],"mappings":";;;AAyLA,0CAkBC;AA1MD,2CAAuD;AAIvD,4EAAyE;AAEzE,kCAAiG;AACjG,mDAM6B;AAE7B,SAAS,sBAAsB,CAAC,UAAsB;IACpD,MAAM,UAAU,GAAG,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAErE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,IAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAA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CAAC;QACJ,CAAC;IACH,CAAC;IACD,QAAQ,EAAE;QACR;YACE,OAAO,EACL,wFAAwF;YAC1F,WAAW,EAAE,6CAA6C;SAC3D;KACF;CACF,CAAC"}
|
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.findDuplicateSegments = findDuplicateSegments;
|
|
4
|
-
const crypto = require("crypto");
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
5
38
|
async function findDuplicateSegments(deps, options = {}) {
|
|
6
39
|
const { datasource } = deps;
|
|
7
40
|
const segments = await datasource.listSegments();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findDuplicateSegments.js","sourceRoot":"","sources":["../../src/find-duplicate-segments/findDuplicateSegments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findDuplicateSegments.js","sourceRoot":"","sources":["../../src/find-duplicate-segments/findDuplicateSegments.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,sDA4DC;AA3ED,+CAAiC;AAe1B,KAAK,UAAU,qBAAqB,CACzC,IAAkB,EAClB,UAAoC,EAAE;IAEtC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAE5B,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,YAAY,EAAE,CAAC;IAEjD,MAAM,gBAAgB,GAA+C,EAAE,CAAC;IACxE,KAAK,MAAM,UAAU,IAAI,QAAQ,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE1E,gBAAgB,CAAC,IAAI,CAAC;YACpB,UAAU;YACV,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,MAAM,eAAe,GAAqC,gBAAgB,CAAC,MAAM,CAC/E,CAAC,GAAG,EAAE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MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -3,36 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.findDuplicateSegmentsPlugin = void 0;
|
|
4
4
|
exports.findDuplicateSegmentsInProject = findDuplicateSegmentsInProject;
|
|
5
5
|
const findDuplicateSegments_1 = require("./findDuplicateSegments");
|
|
6
|
+
const sets_1 = require("../sets");
|
|
7
|
+
const cliFormat_1 = require("../tester/cliFormat");
|
|
6
8
|
async function findDuplicateSegmentsInProject(deps, options = {}) {
|
|
7
9
|
const duplicates = await (0, findDuplicateSegments_1.findDuplicateSegments)(deps, options);
|
|
8
10
|
console.log("");
|
|
11
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, "Finding duplicate Featurevisor segments");
|
|
9
12
|
if (duplicates.length === 0) {
|
|
10
|
-
console.log("No duplicate segments found");
|
|
13
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, "No duplicate segments found");
|
|
11
14
|
return;
|
|
12
15
|
}
|
|
13
|
-
console.log(`Found ${duplicates.length} duplicate(s)
|
|
16
|
+
console.log(cliFormat_1.CLI_FORMAT_YELLOW, `Found ${duplicates.length} duplicate(s):`);
|
|
17
|
+
console.log("");
|
|
14
18
|
duplicates.forEach((entry) => {
|
|
15
19
|
if (options.authors) {
|
|
16
|
-
console.log(`
|
|
17
|
-
console.log(` Authors: ${entry.authors && entry.authors.join(", ")}`);
|
|
20
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} Segments: ${entry.segments.join(", ")}`);
|
|
21
|
+
console.log(` ${(0, cliFormat_1.colorize)("Authors", cliFormat_1.CLI_COLOR_CYAN)}: ${entry.authors && entry.authors.join(", ")}`);
|
|
18
22
|
console.log("");
|
|
19
23
|
}
|
|
20
24
|
else {
|
|
21
|
-
console.log(`
|
|
25
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${entry.segments.join(", ")}`);
|
|
22
26
|
}
|
|
23
27
|
});
|
|
24
28
|
}
|
|
25
29
|
exports.findDuplicateSegmentsPlugin = {
|
|
26
30
|
command: "find-duplicate-segments",
|
|
27
31
|
handler: async ({ rootDirectoryPath, projectConfig, datasource, parsed }) => {
|
|
28
|
-
await
|
|
29
|
-
|
|
30
|
-
projectConfig,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
const executions = await (0, sets_1.getProjectSetExecutions)(projectConfig, datasource, parsed.set);
|
|
33
|
+
for (const execution of executions) {
|
|
34
|
+
(0, sets_1.printSetHeader)(projectConfig, execution.set);
|
|
35
|
+
await findDuplicateSegmentsInProject({
|
|
36
|
+
rootDirectoryPath,
|
|
37
|
+
projectConfig: execution.projectConfig,
|
|
38
|
+
datasource: execution.datasource,
|
|
39
|
+
options: parsed,
|
|
40
|
+
}, {
|
|
41
|
+
authors: parsed.authors,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
36
44
|
},
|
|
37
45
|
examples: [
|
|
38
46
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/find-duplicate-segments/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/find-duplicate-segments/index.ts"],"names":[],"mappings":";;;AAYA,wEA4BC;AAxCD,mEAA0F;AAG1F,kCAAkE;AAClE,mDAM6B;AAEtB,KAAK,UAAU,8BAA8B,CAClD,IAAkB,EAClB,UAAoC,EAAE;IAEtC,MAAM,UAAU,GAAG,MAAM,IAAA,6CAAqB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE9D,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,2BAAe,EAAE,yCAAyC,CAAC,CAAC;IAExE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAA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AAA,qBAAc,EAAC,aAAa,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;YAE7C,MAAM,8BAA8B,CAClC;gBACE,iBAAiB;gBACjB,aAAa,EAAE,SAAS,CAAC,aAAa;gBACtC,UAAU,EAAE,SAAS,CAAC,UAAU;gBAChC,OAAO,EAAE,MAAM;aAChB,EACD;gBACE,OAAO,EAAE,MAAM,CAAC,OAAO;aACxB,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,QAAQ,EAAE;QACR;YACE,OAAO,EAAE,yBAAyB;YAClC,WAAW,EAAE,wCAAwC;SACtD;QACD;YACE,OAAO,EAAE,mCAAmC;YAC5C,WAAW,EAAE,yDAAyD;SACvE;KACF;CACF,CAAC"}
|
package/lib/find-usage/index.js
CHANGED
|
@@ -10,6 +10,8 @@ exports.findUnusedSegments = findUnusedSegments;
|
|
|
10
10
|
exports.findUnusedAttributes = findUnusedAttributes;
|
|
11
11
|
exports.findUsageInProject = findUsageInProject;
|
|
12
12
|
const extractKeys_1 = require("../utils/extractKeys");
|
|
13
|
+
const sets_1 = require("../sets");
|
|
14
|
+
const cliFormat_1 = require("../tester/cliFormat");
|
|
13
15
|
async function findAllUsageInFeatures(deps) {
|
|
14
16
|
const { datasource, projectConfig } = deps;
|
|
15
17
|
const usageInFeatures = {};
|
|
@@ -87,7 +89,7 @@ async function findAllUsageInFeatures(deps) {
|
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
91
|
// no environments
|
|
90
|
-
if (projectConfig.environments
|
|
92
|
+
if (!Array.isArray(projectConfig.environments)) {
|
|
91
93
|
// force
|
|
92
94
|
if (Array.isArray(feature.force)) {
|
|
93
95
|
feature.force.forEach((force) => {
|
|
@@ -201,24 +203,27 @@ async function findUnusedAttributes(deps, usageInFeatures, usageInSegments) {
|
|
|
201
203
|
async function findUsageInProject(deps, options) {
|
|
202
204
|
const { datasource } = deps;
|
|
203
205
|
console.log("");
|
|
206
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, "Finding Featurevisor usage");
|
|
207
|
+
console.log("");
|
|
204
208
|
const usageInFeatures = await findAllUsageInFeatures(deps);
|
|
205
209
|
const usageInSegments = await findAllUsageInSegments(deps);
|
|
206
210
|
// feature
|
|
207
211
|
if (options.feature) {
|
|
208
212
|
const usedInFeatures = await findFeatureUsage(usageInFeatures, options.feature);
|
|
209
213
|
if (usedInFeatures.size === 0) {
|
|
210
|
-
console.log(`Feature "${options.feature}" is not used in any features.`);
|
|
214
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, `Feature "${options.feature}" is not used in any features.`);
|
|
211
215
|
}
|
|
212
216
|
else {
|
|
213
|
-
console.log(`Feature "${options.feature}" is used in
|
|
217
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, `Feature "${options.feature}" is used in these features`);
|
|
218
|
+
console.log("");
|
|
214
219
|
for (const featureKey of Array.from(usedInFeatures)) {
|
|
215
220
|
if (options.authors) {
|
|
216
221
|
const entries = await datasource.listHistoryEntries("feature", featureKey);
|
|
217
222
|
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
218
|
-
console.log(`
|
|
223
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey} ${(0, cliFormat_1.colorize)(`(Authors: ${authors.join(", ")})`, cliFormat_1.CLI_COLOR_DIM)}`);
|
|
219
224
|
}
|
|
220
225
|
else {
|
|
221
|
-
console.log(`
|
|
226
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey}`);
|
|
222
227
|
}
|
|
223
228
|
}
|
|
224
229
|
}
|
|
@@ -228,18 +233,19 @@ async function findUsageInProject(deps, options) {
|
|
|
228
233
|
if (options.segment) {
|
|
229
234
|
const usedInFeatures = await findSegmentUsage(usageInFeatures, options.segment);
|
|
230
235
|
if (usedInFeatures.size === 0) {
|
|
231
|
-
console.log(`Segment "${options.segment}" is not used in any features.`);
|
|
236
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, `Segment "${options.segment}" is not used in any features.`);
|
|
232
237
|
}
|
|
233
238
|
else {
|
|
234
|
-
console.log(`Segment "${options.segment}" is used in
|
|
239
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, `Segment "${options.segment}" is used in these features`);
|
|
240
|
+
console.log("");
|
|
235
241
|
for (const featureKey of Array.from(usedInFeatures)) {
|
|
236
242
|
if (options.authors) {
|
|
237
243
|
const entries = await datasource.listHistoryEntries("feature", featureKey);
|
|
238
244
|
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
239
|
-
console.log(`
|
|
245
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey} ${(0, cliFormat_1.colorize)(`(Authors: ${authors.join(", ")})`, cliFormat_1.CLI_COLOR_DIM)}`);
|
|
240
246
|
}
|
|
241
247
|
else {
|
|
242
|
-
console.log(`
|
|
248
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey}`);
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
}
|
|
@@ -249,19 +255,20 @@ async function findUsageInProject(deps, options) {
|
|
|
249
255
|
if (options.attribute) {
|
|
250
256
|
const usedIn = await findAttributeUsage(usageInFeatures, usageInSegments, options.attribute);
|
|
251
257
|
if (usedIn.features.size === 0 && usedIn.segments.size === 0) {
|
|
252
|
-
console.log(`Attribute "${options.attribute}" is not used in any features or segments.`);
|
|
258
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, `Attribute "${options.attribute}" is not used in any features or segments.`);
|
|
253
259
|
return;
|
|
254
260
|
}
|
|
255
261
|
if (usedIn.segments.size > 0) {
|
|
256
|
-
console.log(`Attribute "${options.attribute}" is used in
|
|
262
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, `Attribute "${options.attribute}" is used in these segments`);
|
|
263
|
+
console.log("");
|
|
257
264
|
for (const segmentKey of Array.from(usedIn.segments)) {
|
|
258
265
|
if (options.authors) {
|
|
259
266
|
const entries = await datasource.listHistoryEntries("segment", segmentKey);
|
|
260
267
|
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
261
|
-
console.log(`
|
|
268
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${segmentKey} ${(0, cliFormat_1.colorize)(`(Authors: ${authors.join(", ")})`, cliFormat_1.CLI_COLOR_DIM)}`);
|
|
262
269
|
}
|
|
263
270
|
else {
|
|
264
|
-
console.log(`
|
|
271
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${segmentKey}`);
|
|
265
272
|
}
|
|
266
273
|
}
|
|
267
274
|
// features affected by above segments
|
|
@@ -271,30 +278,33 @@ async function findUsageInProject(deps, options) {
|
|
|
271
278
|
featureKeys.forEach((featureKey) => affectedFeatures.add(featureKey));
|
|
272
279
|
}
|
|
273
280
|
if (affectedFeatures.size > 0) {
|
|
274
|
-
console.log(
|
|
281
|
+
console.log("");
|
|
282
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, "Segments above are used in these features");
|
|
283
|
+
console.log("");
|
|
275
284
|
for (const featureKey of Array.from(affectedFeatures)) {
|
|
276
285
|
if (options.authors) {
|
|
277
286
|
const entries = await datasource.listHistoryEntries("feature", featureKey);
|
|
278
287
|
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
279
|
-
console.log(`
|
|
288
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey} ${(0, cliFormat_1.colorize)(`(Authors: ${authors.join(", ")})`, cliFormat_1.CLI_COLOR_DIM)}`);
|
|
280
289
|
}
|
|
281
290
|
else {
|
|
282
|
-
console.log(`
|
|
291
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey}`);
|
|
283
292
|
}
|
|
284
293
|
}
|
|
285
294
|
console.log("");
|
|
286
295
|
}
|
|
287
296
|
}
|
|
288
297
|
if (usedIn.features.size > 0) {
|
|
289
|
-
console.log(`Attribute "${options.attribute}" is used directly in
|
|
298
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD, `Attribute "${options.attribute}" is used directly in these features`);
|
|
299
|
+
console.log("");
|
|
290
300
|
for (const featureKey of Array.from(usedIn.features)) {
|
|
291
301
|
if (options.authors) {
|
|
292
302
|
const entries = await datasource.listHistoryEntries("feature", featureKey);
|
|
293
303
|
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
294
|
-
console.log(`
|
|
304
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey} ${(0, cliFormat_1.colorize)(`(Authors: ${authors.join(", ")})`, cliFormat_1.CLI_COLOR_DIM)}`);
|
|
295
305
|
}
|
|
296
306
|
else {
|
|
297
|
-
console.log(`
|
|
307
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${featureKey}`);
|
|
298
308
|
}
|
|
299
309
|
}
|
|
300
310
|
console.log("");
|
|
@@ -305,18 +315,19 @@ async function findUsageInProject(deps, options) {
|
|
|
305
315
|
if (options.unusedSegments) {
|
|
306
316
|
const unusedSegments = await findUnusedSegments(deps, usageInFeatures);
|
|
307
317
|
if (unusedSegments.size === 0) {
|
|
308
|
-
console.log("No unused segments found.");
|
|
318
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, "No unused segments found.");
|
|
309
319
|
}
|
|
310
320
|
else {
|
|
311
|
-
console.log("Unused segments
|
|
321
|
+
console.log(cliFormat_1.CLI_FORMAT_YELLOW, "Unused segments");
|
|
322
|
+
console.log("");
|
|
312
323
|
for (const segmentKey of Array.from(unusedSegments)) {
|
|
313
324
|
if (options.authors) {
|
|
314
325
|
const entries = await datasource.listHistoryEntries("segment", segmentKey);
|
|
315
326
|
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
316
|
-
console.log(`
|
|
327
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${segmentKey} ${(0, cliFormat_1.colorize)(`(Authors: ${authors.join(", ")})`, cliFormat_1.CLI_COLOR_DIM)}`);
|
|
317
328
|
}
|
|
318
329
|
else {
|
|
319
|
-
console.log(`
|
|
330
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${segmentKey}`);
|
|
320
331
|
}
|
|
321
332
|
}
|
|
322
333
|
}
|
|
@@ -326,41 +337,46 @@ async function findUsageInProject(deps, options) {
|
|
|
326
337
|
if (options.unusedAttributes) {
|
|
327
338
|
const unusedAttributes = await findUnusedAttributes(deps, usageInFeatures, usageInSegments);
|
|
328
339
|
if (unusedAttributes.size === 0) {
|
|
329
|
-
console.log("No unused attributes found.");
|
|
340
|
+
console.log(cliFormat_1.CLI_FORMAT_GREEN, "No unused attributes found.");
|
|
330
341
|
}
|
|
331
342
|
else {
|
|
332
|
-
console.log("Unused attributes
|
|
343
|
+
console.log(cliFormat_1.CLI_FORMAT_YELLOW, "Unused attributes");
|
|
344
|
+
console.log("");
|
|
333
345
|
for (const attributeKey of Array.from(unusedAttributes)) {
|
|
334
346
|
if (options.authors) {
|
|
335
347
|
const entries = await datasource.listHistoryEntries("attribute", attributeKey);
|
|
336
348
|
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
337
|
-
console.log(`
|
|
349
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${attributeKey} ${(0, cliFormat_1.colorize)(`(Authors: ${authors.join(", ")})`, cliFormat_1.CLI_COLOR_DIM)}`);
|
|
338
350
|
}
|
|
339
351
|
else {
|
|
340
|
-
console.log(`
|
|
352
|
+
console.log(` ${(0, cliFormat_1.colorize)("•", cliFormat_1.CLI_COLOR_CYAN)} ${attributeKey}`);
|
|
341
353
|
}
|
|
342
354
|
}
|
|
343
355
|
}
|
|
344
356
|
return;
|
|
345
357
|
}
|
|
346
|
-
console.log("Please specify a segment or
|
|
358
|
+
console.log(cliFormat_1.CLI_FORMAT_YELLOW, "Please specify a feature, segment, attribute, or unused query.");
|
|
347
359
|
}
|
|
348
360
|
exports.findUsagePlugin = {
|
|
349
361
|
command: "find-usage",
|
|
350
362
|
handler: async ({ rootDirectoryPath, projectConfig, datasource, parsed }) => {
|
|
351
|
-
await
|
|
352
|
-
|
|
353
|
-
projectConfig,
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
363
|
+
const executions = await (0, sets_1.getProjectSetExecutions)(projectConfig, datasource, parsed.set);
|
|
364
|
+
for (const execution of executions) {
|
|
365
|
+
(0, sets_1.printSetHeader)(projectConfig, execution.set);
|
|
366
|
+
await findUsageInProject({
|
|
367
|
+
rootDirectoryPath,
|
|
368
|
+
projectConfig: execution.projectConfig,
|
|
369
|
+
datasource: execution.datasource,
|
|
370
|
+
options: parsed,
|
|
371
|
+
}, {
|
|
372
|
+
feature: parsed.feature,
|
|
373
|
+
segment: parsed.segment,
|
|
374
|
+
attribute: parsed.attribute,
|
|
375
|
+
unusedSegments: parsed.unusedSegments,
|
|
376
|
+
unusedAttributes: parsed.unusedAttributes,
|
|
377
|
+
authors: parsed.authors,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
364
380
|
},
|
|
365
381
|
examples: [
|
|
366
382
|
{
|