@featurevisor/core 3.1.0 → 3.3.0
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/lib/datasource/datasource.d.ts +1 -1
- package/lib/datasource/datasource.js +4 -14
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/requiredFeatures.d.ts +7 -0
- package/lib/datasource/requiredFeatures.js +38 -0
- package/lib/datasource/requiredFeatures.js.map +1 -0
- package/lib/linter/checkCircularDependency.d.ts +1 -1
- package/lib/linter/checkCircularDependency.js +3 -22
- package/lib/linter/checkCircularDependency.js.map +1 -1
- package/lib/linter/conditionSchema.js +27 -3
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/testSchema.d.ts +4 -0
- package/lib/linter/testSchema.js +46 -4
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/promoter/index.js +62 -1
- package/lib/promoter/index.js.map +1 -1
- package/lib/tester/testFeature.js +17 -16
- package/lib/tester/testFeature.js.map +1 -1
- package/package.json +10 -7
- package/CHANGELOG.md +0 -2246
- package/coverage/clover.xml +0 -5456
- package/coverage/coverage-final.json +0 -64
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -371
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/src/assess-distribution/index.html +0 -116
- package/coverage/lcov-report/src/assess-distribution/index.ts.html +0 -754
- package/coverage/lcov-report/src/benchmark/index.html +0 -116
- package/coverage/lcov-report/src/benchmark/index.ts.html +0 -793
- package/coverage/lcov-report/src/builder/allocator.ts.html +0 -220
- package/coverage/lcov-report/src/builder/applyContextToConditions.ts.html +0 -502
- package/coverage/lcov-report/src/builder/applyContextToDatafile.ts.html +0 -772
- package/coverage/lcov-report/src/builder/applyContextToSegments.ts.html +0 -580
- package/coverage/lcov-report/src/builder/buildDatafile.ts.html +0 -2053
- package/coverage/lcov-report/src/builder/buildProject.ts.html +0 -1117
- package/coverage/lcov-report/src/builder/buildRuntimeDatafiles.ts.html +0 -256
- package/coverage/lcov-report/src/builder/getFeatureRanges.ts.html +0 -268
- package/coverage/lcov-report/src/builder/hashes.ts.html +0 -412
- package/coverage/lcov-report/src/builder/index.html +0 -311
- package/coverage/lcov-report/src/builder/index.ts.html +0 -91
- package/coverage/lcov-report/src/builder/mutateVariables.ts.html +0 -421
- package/coverage/lcov-report/src/builder/mutator.ts.html +0 -796
- package/coverage/lcov-report/src/builder/revision.ts.html +0 -151
- package/coverage/lcov-report/src/builder/traffic.ts.html +0 -661
- package/coverage/lcov-report/src/cli/cli.ts.html +0 -400
- package/coverage/lcov-report/src/cli/index.html +0 -131
- package/coverage/lcov-report/src/cli/plugins.ts.html +0 -214
- package/coverage/lcov-report/src/config/index.html +0 -131
- package/coverage/lcov-report/src/config/index.ts.html +0 -88
- package/coverage/lcov-report/src/config/projectConfig.ts.html +0 -925
- package/coverage/lcov-report/src/datasource/adapter.ts.html +0 -253
- package/coverage/lcov-report/src/datasource/datasource.ts.html +0 -1000
- package/coverage/lcov-report/src/datasource/filesystemAdapter.ts.html +0 -1576
- package/coverage/lcov-report/src/datasource/index.html +0 -161
- package/coverage/lcov-report/src/datasource/index.ts.html +0 -94
- package/coverage/lcov-report/src/evaluate/index.html +0 -116
- package/coverage/lcov-report/src/evaluate/index.ts.html +0 -814
- package/coverage/lcov-report/src/find-duplicate-segments/findDuplicateSegments.ts.html +0 -313
- package/coverage/lcov-report/src/find-duplicate-segments/index.html +0 -131
- package/coverage/lcov-report/src/find-duplicate-segments/index.ts.html +0 -307
- package/coverage/lcov-report/src/find-usage/index.html +0 -116
- package/coverage/lcov-report/src/find-usage/index.ts.html +0 -1780
- package/coverage/lcov-report/src/generate-code/index.html +0 -131
- package/coverage/lcov-report/src/generate-code/index.ts.html +0 -403
- package/coverage/lcov-report/src/generate-code/typescript.ts.html +0 -1909
- package/coverage/lcov-report/src/index.html +0 -131
- package/coverage/lcov-report/src/info/index.html +0 -116
- package/coverage/lcov-report/src/info/index.ts.html +0 -472
- package/coverage/lcov-report/src/init/index.html +0 -116
- package/coverage/lcov-report/src/init/index.ts.html +0 -280
- package/coverage/lcov-report/src/linter/attributeSchema.ts.html +0 -1963
- package/coverage/lcov-report/src/linter/checkCircularDependency.ts.html +0 -220
- package/coverage/lcov-report/src/linter/checkPercentageExceedingSlot.ts.html +0 -268
- package/coverage/lcov-report/src/linter/conditionSchema.ts.html +0 -2224
- package/coverage/lcov-report/src/linter/featureSchema.ts.html +0 -5851
- package/coverage/lcov-report/src/linter/groupSchema.ts.html +0 -226
- package/coverage/lcov-report/src/linter/index.html +0 -326
- package/coverage/lcov-report/src/linter/index.ts.html +0 -88
- package/coverage/lcov-report/src/linter/lintProject.ts.html +0 -2704
- package/coverage/lcov-report/src/linter/mutationNotation.ts.html +0 -1411
- package/coverage/lcov-report/src/linter/printError.ts.html +0 -289
- package/coverage/lcov-report/src/linter/schema.ts.html +0 -1558
- package/coverage/lcov-report/src/linter/segmentSchema.ts.html +0 -139
- package/coverage/lcov-report/src/linter/targetSchema.ts.html +0 -223
- package/coverage/lcov-report/src/linter/testSchema.ts.html +0 -529
- package/coverage/lcov-report/src/linter/zodHelpers.ts.html +0 -133
- package/coverage/lcov-report/src/list/index.html +0 -131
- package/coverage/lcov-report/src/list/index.ts.html +0 -2065
- package/coverage/lcov-report/src/list/matrix.ts.html +0 -721
- package/coverage/lcov-report/src/promoter/index.html +0 -116
- package/coverage/lcov-report/src/promoter/index.ts.html +0 -3883
- package/coverage/lcov-report/src/sets.ts.html +0 -313
- package/coverage/lcov-report/src/targeting.ts.html +0 -403
- package/coverage/lcov-report/src/tester/cliFormat.ts.html +0 -133
- package/coverage/lcov-report/src/tester/helpers.ts.html +0 -313
- package/coverage/lcov-report/src/tester/index.html +0 -206
- package/coverage/lcov-report/src/tester/prettyDuration.ts.html +0 -187
- package/coverage/lcov-report/src/tester/printTestResult.ts.html +0 -337
- package/coverage/lcov-report/src/tester/testFeature.ts.html +0 -1186
- package/coverage/lcov-report/src/tester/testProject.ts.html +0 -1018
- package/coverage/lcov-report/src/tester/testSegment.ts.html +0 -316
- package/coverage/lcov-report/src/utils/extractKeys.ts.html +0 -493
- package/coverage/lcov-report/src/utils/git.ts.html +0 -559
- package/coverage/lcov-report/src/utils/index.html +0 -161
- package/coverage/lcov-report/src/utils/index.ts.html +0 -94
- package/coverage/lcov-report/src/utils/pretty.ts.html +0 -121
- package/coverage/lcov.info +0 -11615
- package/jest.config.js +0 -22
- package/json-schema/README.md +0 -5
- package/json-schema/attribute.json +0 -40
- package/json-schema/feature.json +0 -394
- package/json-schema/segment.json +0 -137
- package/src/assess-distribution/index.ts +0 -223
- package/src/benchmark/index.ts +0 -236
- package/src/builder/allocator.spec.ts +0 -105
- package/src/builder/allocator.ts +0 -45
- package/src/builder/applyContextToConditions.spec.ts +0 -2677
- package/src/builder/applyContextToConditions.ts +0 -139
- package/src/builder/applyContextToDatafile.spec.ts +0 -2626
- package/src/builder/applyContextToDatafile.ts +0 -229
- package/src/builder/applyContextToSegments.spec.ts +0 -1593
- package/src/builder/applyContextToSegments.ts +0 -165
- package/src/builder/buildDatafile.spec.ts +0 -445
- package/src/builder/buildDatafile.ts +0 -656
- package/src/builder/buildProject.ts +0 -344
- package/src/builder/buildRuntimeDatafiles.ts +0 -57
- package/src/builder/getFeatureRanges.ts +0 -61
- package/src/builder/hashes.ts +0 -109
- package/src/builder/index.ts +0 -2
- package/src/builder/mutateVariables.spec.ts +0 -1179
- package/src/builder/mutateVariables.ts +0 -112
- package/src/builder/mutator.spec.ts +0 -413
- package/src/builder/mutator.ts +0 -237
- package/src/builder/revision.spec.ts +0 -22
- package/src/builder/revision.ts +0 -22
- package/src/builder/traffic.spec.ts +0 -946
- package/src/builder/traffic.ts +0 -192
- package/src/cli/cli.ts +0 -105
- package/src/cli/index.ts +0 -2
- package/src/cli/plugins.ts +0 -43
- package/src/config/index.ts +0 -1
- package/src/config/projectConfig.spec.ts +0 -194
- package/src/config/projectConfig.ts +0 -280
- package/src/datasource/adapter.ts +0 -56
- package/src/datasource/datasource.ts +0 -305
- package/src/datasource/filesystemAdapter.spec.ts +0 -212
- package/src/datasource/filesystemAdapter.ts +0 -497
- package/src/datasource/index.ts +0 -3
- package/src/dependencies.ts +0 -13
- package/src/evaluate/index.ts +0 -243
- package/src/find-duplicate-segments/findDuplicateSegments.ts +0 -76
- package/src/find-duplicate-segments/index.ts +0 -74
- package/src/find-usage/index.ts +0 -565
- package/src/generate-code/index.ts +0 -106
- package/src/generate-code/typescript.spec.ts +0 -214
- package/src/generate-code/typescript.ts +0 -608
- package/src/index.ts +0 -20
- package/src/info/index.ts +0 -129
- package/src/init/index.ts +0 -65
- package/src/linter/attributeSchema.spec.ts +0 -342
- package/src/linter/attributeSchema.ts +0 -626
- package/src/linter/checkCircularDependency.ts +0 -45
- package/src/linter/checkPercentageExceedingSlot.ts +0 -61
- package/src/linter/conditionSchema.spec.ts +0 -510
- package/src/linter/conditionSchema.ts +0 -713
- package/src/linter/featureSchema.spec.ts +0 -1985
- package/src/linter/featureSchema.ts +0 -1922
- package/src/linter/groupSchema.ts +0 -47
- package/src/linter/index.ts +0 -1
- package/src/linter/lintProject.spec.ts +0 -336
- package/src/linter/lintProject.ts +0 -873
- package/src/linter/mutationNotation.spec.ts +0 -704
- package/src/linter/mutationNotation.ts +0 -442
- package/src/linter/printError.ts +0 -68
- package/src/linter/schema.spec.ts +0 -690
- package/src/linter/schema.ts +0 -491
- package/src/linter/segmentSchema.spec.ts +0 -358
- package/src/linter/segmentSchema.ts +0 -18
- package/src/linter/targetSchema.spec.ts +0 -159
- package/src/linter/targetSchema.ts +0 -46
- package/src/linter/testSchema.spec.ts +0 -258
- package/src/linter/testSchema.ts +0 -148
- package/src/linter/zodHelpers.ts +0 -16
- package/src/list/index.spec.ts +0 -135
- package/src/list/index.ts +0 -660
- package/src/list/matrix.spec.ts +0 -49
- package/src/list/matrix.ts +0 -212
- package/src/promoter/index.spec.ts +0 -617
- package/src/promoter/index.ts +0 -1266
- package/src/sets.ts +0 -76
- package/src/targeting.spec.ts +0 -74
- package/src/targeting.ts +0 -106
- package/src/tester/cliFormat.ts +0 -16
- package/src/tester/helpers.spec.ts +0 -149
- package/src/tester/helpers.ts +0 -76
- package/src/tester/index.ts +0 -2
- package/src/tester/prettyDuration.ts +0 -34
- package/src/tester/printTestResult.ts +0 -84
- package/src/tester/testFeature.ts +0 -367
- package/src/tester/testProject.spec.ts +0 -50
- package/src/tester/testProject.ts +0 -311
- package/src/tester/testSegment.ts +0 -77
- package/src/utils/extractKeys.ts +0 -136
- package/src/utils/git.ts +0 -158
- package/src/utils/index.ts +0 -3
- package/src/utils/pretty.ts +0 -12
- package/tsconfig.cjs.json +0 -13
- package/tsconfig.typecheck.json +0 -9
package/src/list/matrix.ts
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import type { AssertionMatrix, FeatureAssertion, SegmentAssertion } from "@featurevisor/types";
|
|
2
|
-
|
|
3
|
-
function generateCombinations(
|
|
4
|
-
keys: string[],
|
|
5
|
-
matrix: AssertionMatrix,
|
|
6
|
-
idx: number,
|
|
7
|
-
prev: any,
|
|
8
|
-
combinations: any[],
|
|
9
|
-
) {
|
|
10
|
-
const key = keys[idx];
|
|
11
|
-
const values = matrix[key];
|
|
12
|
-
|
|
13
|
-
for (let i = 0; i < values.length; i++) {
|
|
14
|
-
const combination = { ...prev, [key]: values[i] };
|
|
15
|
-
|
|
16
|
-
if (idx === keys.length - 1) {
|
|
17
|
-
combinations.push(combination);
|
|
18
|
-
} else {
|
|
19
|
-
generateCombinations(keys, matrix, idx + 1, combination, combinations);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function getMatrixCombinations(matrix: AssertionMatrix) {
|
|
25
|
-
const keys = Object.keys(matrix);
|
|
26
|
-
|
|
27
|
-
if (!keys.length) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const combinations: any[] = [];
|
|
32
|
-
generateCombinations(keys, matrix, 0, {}, combinations);
|
|
33
|
-
|
|
34
|
-
return combinations;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function applyCombinationToValue(value: any, combination: any) {
|
|
38
|
-
if (typeof value === "string") {
|
|
39
|
-
const variableKeysInValue = value.match(/\${{(.+?)}}/g);
|
|
40
|
-
|
|
41
|
-
// no variables found
|
|
42
|
-
if (!variableKeysInValue) {
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// only 1 variable found, so we can insert the value directly
|
|
47
|
-
if (variableKeysInValue.length === 1 && value.startsWith("${{") && value.endsWith("}}")) {
|
|
48
|
-
const key = value.replace("${{", "").replace("}}", "").trim();
|
|
49
|
-
|
|
50
|
-
return combination[key];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// multiple variables found, so we can replace each as a whole string
|
|
54
|
-
return value.replace(/\${{(.+?)}}/g, (_, key) => combination[key.trim()]);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return value;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Features
|
|
62
|
-
*/
|
|
63
|
-
export function applyCombinationToFeatureAssertion(
|
|
64
|
-
combination: any,
|
|
65
|
-
assertion: FeatureAssertion,
|
|
66
|
-
): FeatureAssertion {
|
|
67
|
-
const flattenedAssertion = { ...assertion };
|
|
68
|
-
|
|
69
|
-
// environment
|
|
70
|
-
flattenedAssertion.environment = applyCombinationToValue(
|
|
71
|
-
flattenedAssertion.environment,
|
|
72
|
-
combination,
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
// context
|
|
76
|
-
flattenedAssertion.context = Object.keys(flattenedAssertion.context || {}).reduce((acc, key) => {
|
|
77
|
-
acc[key] = applyCombinationToValue(flattenedAssertion.context?.[key], combination);
|
|
78
|
-
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
|
|
82
|
-
// at
|
|
83
|
-
flattenedAssertion.at = applyCombinationToValue(flattenedAssertion.at, combination);
|
|
84
|
-
if (typeof flattenedAssertion.at === "string") {
|
|
85
|
-
flattenedAssertion.at =
|
|
86
|
-
(flattenedAssertion.at as string).indexOf(".") > -1
|
|
87
|
-
? parseFloat(flattenedAssertion.at)
|
|
88
|
-
: parseInt(flattenedAssertion.at, 10);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// description
|
|
92
|
-
if (flattenedAssertion.description) {
|
|
93
|
-
flattenedAssertion.description = applyCombinationToValue(
|
|
94
|
-
flattenedAssertion.description,
|
|
95
|
-
combination,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// target
|
|
100
|
-
if (flattenedAssertion.target) {
|
|
101
|
-
flattenedAssertion.target = applyCombinationToValue(flattenedAssertion.target, combination);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return flattenedAssertion;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function getFeatureAssertionsFromMatrix(
|
|
108
|
-
aIndex,
|
|
109
|
-
assertionWithMatrix: FeatureAssertion,
|
|
110
|
-
): FeatureAssertion[] {
|
|
111
|
-
if (!assertionWithMatrix.matrix) {
|
|
112
|
-
const assertion = { ...assertionWithMatrix };
|
|
113
|
-
|
|
114
|
-
let suffix;
|
|
115
|
-
|
|
116
|
-
if (assertion.environment) {
|
|
117
|
-
suffix = ` (${assertion.environment})`;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (assertion.description) {
|
|
121
|
-
suffix = `: ${assertion.description}`;
|
|
122
|
-
} else {
|
|
123
|
-
suffix = `: at ${assertion.at}%`;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
assertion.description = `Assertion #${aIndex + 1}${suffix}`;
|
|
127
|
-
|
|
128
|
-
return [assertion];
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const assertions: FeatureAssertion[] = [];
|
|
132
|
-
const combinations = getMatrixCombinations(assertionWithMatrix.matrix);
|
|
133
|
-
|
|
134
|
-
for (let cIndex = 0; cIndex < combinations.length; cIndex++) {
|
|
135
|
-
const combination = combinations[cIndex];
|
|
136
|
-
const assertion = applyCombinationToFeatureAssertion(combination, assertionWithMatrix);
|
|
137
|
-
|
|
138
|
-
let suffix;
|
|
139
|
-
|
|
140
|
-
if (assertion.environment) {
|
|
141
|
-
suffix = ` (${assertion.environment})`;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (assertion.description) {
|
|
145
|
-
suffix = `: ${assertion.description}`;
|
|
146
|
-
} else {
|
|
147
|
-
suffix = `: at ${assertion.at}%`;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
assertion.description = `Assertion #${aIndex + 1}${suffix}`;
|
|
151
|
-
|
|
152
|
-
assertions.push(assertion);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return assertions;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Segments
|
|
160
|
-
*/
|
|
161
|
-
export function applyCombinationToSegmentAssertion(
|
|
162
|
-
combination: any,
|
|
163
|
-
assertion: SegmentAssertion,
|
|
164
|
-
): SegmentAssertion {
|
|
165
|
-
const flattenedAssertion = { ...assertion };
|
|
166
|
-
|
|
167
|
-
// context
|
|
168
|
-
flattenedAssertion.context = Object.keys(flattenedAssertion.context).reduce((acc, key) => {
|
|
169
|
-
acc[key] = applyCombinationToValue(flattenedAssertion.context[key], combination);
|
|
170
|
-
|
|
171
|
-
return acc;
|
|
172
|
-
}, {});
|
|
173
|
-
|
|
174
|
-
// description
|
|
175
|
-
if (flattenedAssertion.description) {
|
|
176
|
-
flattenedAssertion.description = applyCombinationToValue(
|
|
177
|
-
flattenedAssertion.description,
|
|
178
|
-
combination,
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return flattenedAssertion;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function getSegmentAssertionsFromMatrix(
|
|
186
|
-
aIndex,
|
|
187
|
-
assertionWithMatrix: SegmentAssertion,
|
|
188
|
-
): SegmentAssertion[] {
|
|
189
|
-
if (!assertionWithMatrix.matrix) {
|
|
190
|
-
const assertion = { ...assertionWithMatrix };
|
|
191
|
-
assertion.description = `Assertion #${aIndex + 1}${
|
|
192
|
-
assertion.description ? `: ${assertion.description}` : ""
|
|
193
|
-
}`;
|
|
194
|
-
|
|
195
|
-
return [assertion];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const assertions: SegmentAssertion[] = [];
|
|
199
|
-
const combinations = getMatrixCombinations(assertionWithMatrix.matrix);
|
|
200
|
-
|
|
201
|
-
for (let cIndex = 0; cIndex < combinations.length; cIndex++) {
|
|
202
|
-
const combination = combinations[cIndex];
|
|
203
|
-
const assertion = applyCombinationToSegmentAssertion(combination, assertionWithMatrix);
|
|
204
|
-
assertion.description = `Assertion #${aIndex + 1}: ${
|
|
205
|
-
assertion.description || `#${aIndex + 1}`
|
|
206
|
-
}`;
|
|
207
|
-
|
|
208
|
-
assertions.push(assertion);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return assertions;
|
|
212
|
-
}
|