@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
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DatafileContentV1,
|
|
3
|
-
FeatureV1,
|
|
4
|
-
VariableSchema,
|
|
5
|
-
VariationV1,
|
|
6
|
-
Variation,
|
|
7
|
-
VariableV1,
|
|
8
|
-
Feature,
|
|
9
|
-
Segment,
|
|
10
|
-
Attribute,
|
|
11
|
-
} from "@featurevisor/types";
|
|
12
|
-
|
|
13
|
-
import { ProjectConfig } from "../config";
|
|
14
|
-
|
|
15
|
-
export interface ConvertToV1Options {
|
|
16
|
-
revision: string;
|
|
17
|
-
projectConfig: ProjectConfig;
|
|
18
|
-
attributes: Attribute[];
|
|
19
|
-
features: Feature[];
|
|
20
|
-
segments: Segment[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function convertToV1(options: ConvertToV1Options): DatafileContentV1 {
|
|
24
|
-
const datafileContent: DatafileContentV1 = {
|
|
25
|
-
schemaVersion: "1",
|
|
26
|
-
revision: options.revision,
|
|
27
|
-
attributes: options.attributes,
|
|
28
|
-
segments: options.segments,
|
|
29
|
-
features: [],
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const { features, projectConfig } = options;
|
|
33
|
-
|
|
34
|
-
for (const feature of features) {
|
|
35
|
-
const featureV1: FeatureV1 = {
|
|
36
|
-
key: feature.key,
|
|
37
|
-
deprecated: feature.deprecated,
|
|
38
|
-
bucketBy: feature.bucketBy,
|
|
39
|
-
required: feature.required,
|
|
40
|
-
traffic: feature.traffic,
|
|
41
|
-
force: feature.force,
|
|
42
|
-
ranges: feature.ranges,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
if (feature.variablesSchema && !Array.isArray(feature.variablesSchema)) {
|
|
46
|
-
const variablesSchemaObject = feature.variablesSchema;
|
|
47
|
-
const variablesSchemaArray: VariableSchema[] = [];
|
|
48
|
-
const variableKeys = Object.keys(variablesSchemaObject);
|
|
49
|
-
|
|
50
|
-
for (const variableKey of variableKeys) {
|
|
51
|
-
const v = variablesSchemaObject[variableKey];
|
|
52
|
-
variablesSchemaArray.push({
|
|
53
|
-
key: variableKey,
|
|
54
|
-
type: v.type,
|
|
55
|
-
defaultValue: v.defaultValue,
|
|
56
|
-
deprecated: v.deprecated === true ? true : undefined,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
featureV1.variablesSchema = variablesSchemaArray;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (feature.variations) {
|
|
64
|
-
const variationsV1: VariationV1[] = feature.variations.map((variation: Variation) => {
|
|
65
|
-
const variationV1: VariationV1 = {
|
|
66
|
-
value: variation.value,
|
|
67
|
-
weight: variation.weight || 0, // weight is not used in v1 datafile, but needed for state files
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// variables
|
|
71
|
-
const variablesResult: { [key: string]: VariableV1 } = {};
|
|
72
|
-
|
|
73
|
-
if (variation.variables) {
|
|
74
|
-
const variableKeys = Object.keys(variation.variables);
|
|
75
|
-
|
|
76
|
-
for (const variableKey of variableKeys) {
|
|
77
|
-
const variableValue = variation.variables[variableKey];
|
|
78
|
-
|
|
79
|
-
variablesResult[variableKey] = {
|
|
80
|
-
key: variableKey,
|
|
81
|
-
value: variableValue,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (variation.variableOverrides) {
|
|
87
|
-
const variableKeys = Object.keys(variation.variableOverrides);
|
|
88
|
-
|
|
89
|
-
for (const variableKey of variableKeys) {
|
|
90
|
-
const overrides = variation.variableOverrides[variableKey];
|
|
91
|
-
|
|
92
|
-
if (typeof variablesResult[variableKey] === "undefined") {
|
|
93
|
-
const variableSchema = feature.variablesSchema?.[variableKey];
|
|
94
|
-
|
|
95
|
-
variablesResult[variableKey] = {
|
|
96
|
-
key: variableKey,
|
|
97
|
-
value: variableSchema?.defaultValue, // default value if no variable is defined
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
variablesResult[variableKey].overrides = overrides.map((override) => {
|
|
102
|
-
if (typeof override.conditions !== "undefined") {
|
|
103
|
-
return {
|
|
104
|
-
conditions: projectConfig.stringify
|
|
105
|
-
? JSON.stringify(override.conditions)
|
|
106
|
-
: override.conditions,
|
|
107
|
-
value: override.value,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (typeof override.segments !== "undefined") {
|
|
112
|
-
return {
|
|
113
|
-
segments:
|
|
114
|
-
typeof override.segments !== "string" && projectConfig.stringify
|
|
115
|
-
? JSON.stringify(override.segments)
|
|
116
|
-
: override.segments,
|
|
117
|
-
value: override.value,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
value: override.value,
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
variationV1.variables = Object.keys(variablesResult).map((variableKey) => {
|
|
129
|
-
const variable = variablesResult[variableKey];
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
key: variable.key,
|
|
133
|
-
value: variable.value,
|
|
134
|
-
overrides: variable.overrides,
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
return variationV1;
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
featureV1.variations = variationsV1;
|
|
142
|
-
|
|
143
|
-
if (featureV1.force) {
|
|
144
|
-
featureV1.force = featureV1.force.map((force) => {
|
|
145
|
-
if (
|
|
146
|
-
force.conditions &&
|
|
147
|
-
typeof force.conditions === "string" &&
|
|
148
|
-
force.conditions !== "*"
|
|
149
|
-
) {
|
|
150
|
-
force.conditions = JSON.parse(force.conditions);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (force.segments && typeof force.segments === "string" && force.segments !== "*") {
|
|
154
|
-
force.segments = JSON.parse(force.segments);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return force;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
datafileContent.features.push(featureV1);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return datafileContent;
|
|
166
|
-
}
|
package/src/site/exportSite.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
|
|
4
|
-
import { generateHistory } from "./generateHistory";
|
|
5
|
-
import { getRepoDetails } from "./getRepoDetails";
|
|
6
|
-
import { generateSiteSearchIndex } from "./generateSiteSearchIndex";
|
|
7
|
-
import { Dependencies } from "../dependencies";
|
|
8
|
-
|
|
9
|
-
export async function exportSite(deps: Dependencies) {
|
|
10
|
-
const { projectConfig } = deps;
|
|
11
|
-
|
|
12
|
-
const hasError = false;
|
|
13
|
-
|
|
14
|
-
fs.mkdirSync(projectConfig.siteExportDirectoryPath, { recursive: true });
|
|
15
|
-
|
|
16
|
-
const sitePackagePath = path.dirname(require.resolve("@featurevisor/site/package.json"));
|
|
17
|
-
|
|
18
|
-
// copy site dist
|
|
19
|
-
const siteDistPath = path.join(sitePackagePath, "dist");
|
|
20
|
-
fs.cpSync(siteDistPath, projectConfig.siteExportDirectoryPath, { recursive: true });
|
|
21
|
-
|
|
22
|
-
console.log("Site dist copied to:", projectConfig.siteExportDirectoryPath);
|
|
23
|
-
|
|
24
|
-
// generate history
|
|
25
|
-
const fullHistory = await generateHistory(deps);
|
|
26
|
-
|
|
27
|
-
// site search index
|
|
28
|
-
const repoDetails = getRepoDetails();
|
|
29
|
-
const searchIndex = await generateSiteSearchIndex(deps, fullHistory, repoDetails);
|
|
30
|
-
const searchIndexFilePath = path.join(projectConfig.siteExportDirectoryPath, "search-index.json");
|
|
31
|
-
fs.writeFileSync(searchIndexFilePath, JSON.stringify(searchIndex));
|
|
32
|
-
console.log(`Site search index written at: ${searchIndexFilePath}`);
|
|
33
|
-
|
|
34
|
-
// copy datafiles
|
|
35
|
-
fs.cpSync(
|
|
36
|
-
projectConfig.datafilesDirectoryPath,
|
|
37
|
-
path.join(projectConfig.siteExportDirectoryPath, "datafiles"),
|
|
38
|
-
{ recursive: true },
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
return hasError;
|
|
42
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
|
|
4
|
-
import type { HistoryEntry } from "@featurevisor/types";
|
|
5
|
-
import { Dependencies } from "../dependencies";
|
|
6
|
-
|
|
7
|
-
export async function generateHistory(deps: Dependencies): Promise<HistoryEntry[]> {
|
|
8
|
-
const { projectConfig, datasource } = deps;
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
const fullHistory = await datasource.listHistoryEntries();
|
|
12
|
-
|
|
13
|
-
const filteredHistory = fullHistory
|
|
14
|
-
.map((historyEntry) => {
|
|
15
|
-
return {
|
|
16
|
-
...historyEntry,
|
|
17
|
-
entities: historyEntry.entities.filter((entity) => {
|
|
18
|
-
// ignore test specs
|
|
19
|
-
return entity.type !== "test";
|
|
20
|
-
}),
|
|
21
|
-
};
|
|
22
|
-
})
|
|
23
|
-
.filter((historyEntry) => historyEntry.entities.length > 0);
|
|
24
|
-
|
|
25
|
-
const fullHistoryFilePath = path.join(
|
|
26
|
-
projectConfig.siteExportDirectoryPath,
|
|
27
|
-
"history-full.json",
|
|
28
|
-
);
|
|
29
|
-
fs.writeFileSync(fullHistoryFilePath, JSON.stringify(filteredHistory));
|
|
30
|
-
console.log(`History (full) generated at: ${fullHistoryFilePath}`);
|
|
31
|
-
|
|
32
|
-
return filteredHistory;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error(
|
|
35
|
-
`Error when generating history from git: ${error.status}\n${error.stderr.toString()}`,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
HistoryEntry,
|
|
3
|
-
SearchIndex,
|
|
4
|
-
AttributeKey,
|
|
5
|
-
FeatureKey,
|
|
6
|
-
SegmentKey,
|
|
7
|
-
Condition,
|
|
8
|
-
} from "@featurevisor/types";
|
|
9
|
-
|
|
10
|
-
import { extractAttributeKeysFromConditions, extractSegmentKeysFromGroupSegments } from "../utils";
|
|
11
|
-
|
|
12
|
-
import { getRelativePaths } from "./getRelativePaths";
|
|
13
|
-
import { getLastModifiedFromHistory } from "./getLastModifiedFromHistory";
|
|
14
|
-
import { RepoDetails } from "./getRepoDetails";
|
|
15
|
-
import { Dependencies } from "../dependencies";
|
|
16
|
-
|
|
17
|
-
export async function generateSiteSearchIndex(
|
|
18
|
-
deps: Dependencies,
|
|
19
|
-
fullHistory: HistoryEntry[],
|
|
20
|
-
repoDetails: RepoDetails | undefined,
|
|
21
|
-
): Promise<SearchIndex> {
|
|
22
|
-
const { rootDirectoryPath, projectConfig, datasource } = deps;
|
|
23
|
-
|
|
24
|
-
const result: SearchIndex = {
|
|
25
|
-
links: undefined,
|
|
26
|
-
projectConfig: {
|
|
27
|
-
tags: projectConfig.tags,
|
|
28
|
-
environments: projectConfig.environments,
|
|
29
|
-
},
|
|
30
|
-
entities: {
|
|
31
|
-
attributes: [],
|
|
32
|
-
segments: [],
|
|
33
|
-
features: [],
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Links
|
|
39
|
-
*/
|
|
40
|
-
if (repoDetails) {
|
|
41
|
-
const { relativeAttributesPath, relativeSegmentsPath, relativeFeaturesPath } = getRelativePaths(
|
|
42
|
-
rootDirectoryPath,
|
|
43
|
-
projectConfig,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
let prefix = "";
|
|
47
|
-
if (repoDetails.topLevelPath !== rootDirectoryPath) {
|
|
48
|
-
prefix = rootDirectoryPath.replace(repoDetails.topLevelPath + "/", "") + "/";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
result.links = {
|
|
52
|
-
attribute: repoDetails.blobUrl.replace(
|
|
53
|
-
"{{blobPath}}",
|
|
54
|
-
prefix + relativeAttributesPath + "/{{key}}." + datasource.getExtension(),
|
|
55
|
-
),
|
|
56
|
-
segment: repoDetails.blobUrl.replace(
|
|
57
|
-
"{{blobPath}}",
|
|
58
|
-
prefix + relativeSegmentsPath + "/{{key}}." + datasource.getExtension(),
|
|
59
|
-
),
|
|
60
|
-
feature: repoDetails.blobUrl.replace(
|
|
61
|
-
"{{blobPath}}",
|
|
62
|
-
prefix + relativeFeaturesPath + "/{{key}}." + datasource.getExtension(),
|
|
63
|
-
),
|
|
64
|
-
commit: repoDetails.commitUrl,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Entities
|
|
70
|
-
*/
|
|
71
|
-
// usage
|
|
72
|
-
const attributesUsedInFeatures: {
|
|
73
|
-
[key: AttributeKey]: Set<FeatureKey>;
|
|
74
|
-
} = {};
|
|
75
|
-
const attributesUsedInSegments: {
|
|
76
|
-
[key: AttributeKey]: Set<SegmentKey>;
|
|
77
|
-
} = {};
|
|
78
|
-
const segmentsUsedInFeatures: {
|
|
79
|
-
[key: SegmentKey]: Set<FeatureKey>;
|
|
80
|
-
} = {};
|
|
81
|
-
|
|
82
|
-
// features
|
|
83
|
-
const featureFiles = await datasource.listFeatures();
|
|
84
|
-
|
|
85
|
-
for (const entityName of featureFiles) {
|
|
86
|
-
const parsed = await datasource.readFeature(entityName);
|
|
87
|
-
|
|
88
|
-
if (Array.isArray(parsed.variations)) {
|
|
89
|
-
parsed.variations.forEach((variation) => {
|
|
90
|
-
if (!variation.variableOverrides) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
Object.keys(variation.variableOverrides).forEach((variableKey) => {
|
|
95
|
-
const overrides = variation.variableOverrides?.[variableKey];
|
|
96
|
-
|
|
97
|
-
if (overrides) {
|
|
98
|
-
overrides.forEach((o) => {
|
|
99
|
-
if (o.conditions) {
|
|
100
|
-
extractAttributeKeysFromConditions(o.conditions).forEach((attributeKey) => {
|
|
101
|
-
if (!attributesUsedInFeatures[attributeKey]) {
|
|
102
|
-
attributesUsedInFeatures[attributeKey] = new Set();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
attributesUsedInFeatures[attributeKey].add(entityName);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (o.segments && o.segments !== "*") {
|
|
110
|
-
extractSegmentKeysFromGroupSegments(o.segments).forEach((segmentKey) => {
|
|
111
|
-
if (!segmentsUsedInFeatures[segmentKey]) {
|
|
112
|
-
segmentsUsedInFeatures[segmentKey] = new Set();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
segmentsUsedInFeatures[segmentKey].add(entityName);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// rules
|
|
125
|
-
if (parsed.rules) {
|
|
126
|
-
if (!Array.isArray(parsed.rules)) {
|
|
127
|
-
// with environments
|
|
128
|
-
Object.keys(parsed.rules).forEach((environmentKey) => {
|
|
129
|
-
const rules = parsed.rules?.[environmentKey];
|
|
130
|
-
|
|
131
|
-
rules.forEach((rule) => {
|
|
132
|
-
if (rule.segments && rule.segments !== "*") {
|
|
133
|
-
extractSegmentKeysFromGroupSegments(rule.segments).forEach((segmentKey) => {
|
|
134
|
-
if (!segmentsUsedInFeatures[segmentKey]) {
|
|
135
|
-
segmentsUsedInFeatures[segmentKey] = new Set();
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
segmentsUsedInFeatures[segmentKey].add(entityName);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
} else {
|
|
144
|
-
// no environments
|
|
145
|
-
parsed.rules.forEach((rule) => {
|
|
146
|
-
if (rule.segments && rule.segments !== "*") {
|
|
147
|
-
extractSegmentKeysFromGroupSegments(rule.segments).forEach((segmentKey) => {
|
|
148
|
-
if (!segmentsUsedInFeatures[segmentKey]) {
|
|
149
|
-
segmentsUsedInFeatures[segmentKey] = new Set();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
segmentsUsedInFeatures[segmentKey].add(entityName);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// force
|
|
160
|
-
if (parsed.force) {
|
|
161
|
-
if (!Array.isArray(parsed.force)) {
|
|
162
|
-
// with environments
|
|
163
|
-
Object.keys(parsed.force).forEach((environmentKey) => {
|
|
164
|
-
parsed.force?.[environmentKey].forEach((force) => {
|
|
165
|
-
if (force.segments && force.segments !== "*") {
|
|
166
|
-
extractSegmentKeysFromGroupSegments(force.segments).forEach((segmentKey) => {
|
|
167
|
-
if (!segmentsUsedInFeatures[segmentKey]) {
|
|
168
|
-
segmentsUsedInFeatures[segmentKey] = new Set();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
segmentsUsedInFeatures[segmentKey].add(entityName);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (force.conditions) {
|
|
176
|
-
extractAttributeKeysFromConditions(force.conditions).forEach((attributeKey) => {
|
|
177
|
-
if (!attributesUsedInFeatures[attributeKey]) {
|
|
178
|
-
attributesUsedInFeatures[attributeKey] = new Set();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
attributesUsedInFeatures[attributeKey].add(entityName);
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
// no environments
|
|
188
|
-
parsed.force.forEach((force) => {
|
|
189
|
-
if (force.segments && force.segments !== "*") {
|
|
190
|
-
extractSegmentKeysFromGroupSegments(force.segments).forEach((segmentKey) => {
|
|
191
|
-
if (!segmentsUsedInFeatures[segmentKey]) {
|
|
192
|
-
segmentsUsedInFeatures[segmentKey] = new Set();
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
segmentsUsedInFeatures[segmentKey].add(entityName);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (force.conditions) {
|
|
200
|
-
extractAttributeKeysFromConditions(force.conditions).forEach((attributeKey) => {
|
|
201
|
-
if (!attributesUsedInFeatures[attributeKey]) {
|
|
202
|
-
attributesUsedInFeatures[attributeKey] = new Set();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
attributesUsedInFeatures[attributeKey].add(entityName);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// push
|
|
213
|
-
result.entities.features.push({
|
|
214
|
-
...parsed,
|
|
215
|
-
key: entityName,
|
|
216
|
-
lastModified: getLastModifiedFromHistory(fullHistory, "feature", entityName),
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// segments
|
|
221
|
-
const segmentFiles = await datasource.listSegments();
|
|
222
|
-
for (const entityName of segmentFiles) {
|
|
223
|
-
const parsed = await datasource.readSegment(entityName);
|
|
224
|
-
|
|
225
|
-
extractAttributeKeysFromConditions(parsed.conditions as Condition | Condition[]).forEach(
|
|
226
|
-
(attributeKey) => {
|
|
227
|
-
if (!attributesUsedInSegments[attributeKey]) {
|
|
228
|
-
attributesUsedInSegments[attributeKey] = new Set();
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
attributesUsedInSegments[attributeKey].add(entityName);
|
|
232
|
-
},
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
result.entities.segments.push({
|
|
236
|
-
...parsed,
|
|
237
|
-
key: entityName,
|
|
238
|
-
lastModified: getLastModifiedFromHistory(fullHistory, "segment", entityName),
|
|
239
|
-
usedInFeatures: Array.from(segmentsUsedInFeatures[entityName] || []),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// attributes
|
|
244
|
-
const attributeFiles = await datasource.listAttributes();
|
|
245
|
-
for (const entityName of attributeFiles) {
|
|
246
|
-
const parsed = await datasource.readAttribute(entityName);
|
|
247
|
-
|
|
248
|
-
result.entities.attributes.push({
|
|
249
|
-
...parsed,
|
|
250
|
-
key: entityName,
|
|
251
|
-
lastModified: getLastModifiedFromHistory(fullHistory, "attribute", entityName),
|
|
252
|
-
usedInFeatures: Array.from(attributesUsedInFeatures[entityName] || []),
|
|
253
|
-
usedInSegments: Array.from(attributesUsedInSegments[entityName] || []),
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return result;
|
|
258
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { HistoryEntry, LastModified } from "@featurevisor/types";
|
|
2
|
-
|
|
3
|
-
export function getLastModifiedFromHistory(
|
|
4
|
-
fullHistory: HistoryEntry[],
|
|
5
|
-
type,
|
|
6
|
-
key,
|
|
7
|
-
): LastModified | undefined {
|
|
8
|
-
const lastModified = fullHistory.find((entry) => {
|
|
9
|
-
return entry.entities.find((entity) => {
|
|
10
|
-
return entity.type === type && entity.key === key;
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
if (lastModified) {
|
|
15
|
-
return {
|
|
16
|
-
commit: lastModified.commit,
|
|
17
|
-
timestamp: lastModified.timestamp,
|
|
18
|
-
author: lastModified.author,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function getOwnerAndRepoFromUrl(url: string): { owner: string; repo: string } {
|
|
2
|
-
let owner;
|
|
3
|
-
let repo;
|
|
4
|
-
|
|
5
|
-
if (url.startsWith("https://")) {
|
|
6
|
-
const parts = url.split("/");
|
|
7
|
-
repo = (parts.pop() as string).replace(".git", "");
|
|
8
|
-
owner = parts.pop();
|
|
9
|
-
} else if (url.startsWith("git@")) {
|
|
10
|
-
const urlParts = url.split(":");
|
|
11
|
-
const parts = urlParts[1].split("/");
|
|
12
|
-
repo = (parts.pop() as string).replace(".git", "");
|
|
13
|
-
owner = parts.pop();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return { owner, repo };
|
|
17
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
|
|
3
|
-
import { ProjectConfig } from "../config";
|
|
4
|
-
|
|
5
|
-
export function getRelativePaths(rootDirectoryPath, projectConfig: ProjectConfig) {
|
|
6
|
-
const relativeFeaturesPath = path.relative(
|
|
7
|
-
rootDirectoryPath,
|
|
8
|
-
projectConfig.featuresDirectoryPath,
|
|
9
|
-
);
|
|
10
|
-
const relativeSegmentsPath = path.relative(
|
|
11
|
-
rootDirectoryPath,
|
|
12
|
-
projectConfig.segmentsDirectoryPath,
|
|
13
|
-
);
|
|
14
|
-
const relativeAttributesPath = path.relative(
|
|
15
|
-
rootDirectoryPath,
|
|
16
|
-
projectConfig.attributesDirectoryPath,
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
relativeFeaturesPath,
|
|
21
|
-
relativeSegmentsPath,
|
|
22
|
-
relativeAttributesPath,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
|
-
|
|
3
|
-
import { getOwnerAndRepoFromUrl } from "./getOwnerAndRepoFromUrl";
|
|
4
|
-
|
|
5
|
-
export interface RepoDetails {
|
|
6
|
-
branch: string;
|
|
7
|
-
remoteUrl: string;
|
|
8
|
-
blobUrl: string;
|
|
9
|
-
commitUrl: string;
|
|
10
|
-
topLevelPath: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function getRepoDetails(): RepoDetails | undefined {
|
|
14
|
-
try {
|
|
15
|
-
const topLevelPathOutput = execSync(`git rev-parse --show-toplevel`);
|
|
16
|
-
const topLevelPath = topLevelPathOutput.toString().trim();
|
|
17
|
-
|
|
18
|
-
const remoteUrlOutput = execSync(`git remote get-url origin`);
|
|
19
|
-
const remoteUrl = remoteUrlOutput.toString().trim();
|
|
20
|
-
|
|
21
|
-
const branchOutput = execSync(`git rev-parse --abbrev-ref HEAD`);
|
|
22
|
-
const branch = branchOutput.toString().trim();
|
|
23
|
-
|
|
24
|
-
if (!remoteUrl || !branch) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const { owner, repo } = getOwnerAndRepoFromUrl(remoteUrl);
|
|
29
|
-
|
|
30
|
-
if (!owner || !repo) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let blobUrl;
|
|
35
|
-
let commitUrl;
|
|
36
|
-
|
|
37
|
-
if (remoteUrl.indexOf("github.com") > -1) {
|
|
38
|
-
blobUrl = `https://github.com/${owner}/${repo}/blob/${branch}/{{blobPath}}`;
|
|
39
|
-
commitUrl = `https://github.com/${owner}/${repo}/commit/{{hash}}`;
|
|
40
|
-
} else if (remoteUrl.indexOf("bitbucket.org") > -1) {
|
|
41
|
-
blobUrl = `https://bitbucket.org/${owner}/${repo}/src/${branch}/{{blobPath}}`;
|
|
42
|
-
commitUrl = `https://bitbucket.org/${owner}/${repo}/commits/{{hash}}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!blobUrl || !commitUrl) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
branch,
|
|
51
|
-
remoteUrl,
|
|
52
|
-
blobUrl,
|
|
53
|
-
commitUrl,
|
|
54
|
-
topLevelPath,
|
|
55
|
-
};
|
|
56
|
-
} catch (e) {
|
|
57
|
-
console.error(e);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return;
|
|
62
|
-
}
|
package/src/site/index.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Plugin } from "../cli";
|
|
2
|
-
import { exportSite } from "./exportSite";
|
|
3
|
-
import { serveSite } from "./serveSite";
|
|
4
|
-
|
|
5
|
-
export const sitePlugin: Plugin = {
|
|
6
|
-
command: "site [subcommand]",
|
|
7
|
-
handler: async function ({ rootDirectoryPath, projectConfig, datasource, parsed }) {
|
|
8
|
-
const deps = {
|
|
9
|
-
rootDirectoryPath,
|
|
10
|
-
projectConfig,
|
|
11
|
-
datasource,
|
|
12
|
-
options: parsed,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const allowedSubcommands = ["export", "serve"];
|
|
16
|
-
|
|
17
|
-
if (!allowedSubcommands.includes(parsed.subcommand)) {
|
|
18
|
-
console.log("Please specify a subcommand: `export` or `serve`");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// export
|
|
23
|
-
if (parsed.subcommand === "export") {
|
|
24
|
-
const hasError = await exportSite(deps);
|
|
25
|
-
|
|
26
|
-
if (hasError) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// serve
|
|
32
|
-
if (parsed.subcommand === "serve") {
|
|
33
|
-
serveSite(deps);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
examples: [
|
|
37
|
-
{
|
|
38
|
-
command: "site export",
|
|
39
|
-
description: "generate static site with project data",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
command: "site serve",
|
|
43
|
-
description: "serve already exported site locally",
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
};
|