@featurevisor/core 1.35.3 → 2.0.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/README.md +0 -6
- package/coverage/clover.xml +321 -237
- package/coverage/coverage-final.json +8 -8
- package/coverage/lcov-report/index.html +77 -47
- package/coverage/lcov-report/lib/builder/allocator.js.html +14 -14
- package/coverage/lcov-report/lib/builder/index.html +16 -16
- package/coverage/lcov-report/lib/builder/revision.js.html +3 -3
- package/coverage/lcov-report/lib/builder/traffic.js.html +88 -64
- package/coverage/lcov-report/lib/list/index.html +116 -0
- package/coverage/lcov-report/lib/{tester → list}/matrix.js.html +90 -66
- package/coverage/lcov-report/lib/tester/helpers.js.html +295 -0
- package/coverage/lcov-report/lib/tester/index.html +20 -35
- package/coverage/lcov-report/src/builder/allocator.ts.html +2 -2
- package/coverage/lcov-report/src/builder/index.html +15 -15
- package/coverage/lcov-report/src/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/src/builder/traffic.ts.html +96 -24
- package/coverage/lcov-report/src/list/index.html +116 -0
- package/coverage/lcov-report/src/{tester → list}/matrix.ts.html +87 -21
- package/coverage/lcov-report/src/tester/helpers.ts.html +313 -0
- package/coverage/lcov-report/src/tester/index.html +20 -35
- package/coverage/lcov.info +592 -436
- package/lib/assess-distribution/index.d.ts +1 -1
- package/lib/assess-distribution/index.js +102 -162
- package/lib/assess-distribution/index.js.map +1 -1
- package/lib/benchmark/index.js +87 -143
- package/lib/benchmark/index.js.map +1 -1
- package/lib/builder/allocator.d.ts +1 -1
- package/lib/builder/allocator.js +12 -12
- package/lib/builder/allocator.js.map +1 -1
- package/lib/builder/allocator.spec.js +22 -22
- package/lib/builder/allocator.spec.js.map +1 -1
- package/lib/builder/buildDatafile.d.ts +4 -3
- package/lib/builder/buildDatafile.js +311 -388
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +2 -1
- package/lib/builder/buildProject.js +96 -183
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/convertToV1.d.ts +10 -0
- package/lib/builder/convertToV1.js +119 -0
- package/lib/builder/convertToV1.js.map +1 -0
- package/lib/builder/getFeatureRanges.d.ts +1 -1
- package/lib/builder/getFeatureRanges.js +32 -105
- package/lib/builder/getFeatureRanges.js.map +1 -1
- package/lib/builder/hashes.d.ts +4 -0
- package/lib/builder/hashes.js +70 -0
- package/lib/builder/hashes.js.map +1 -0
- package/lib/builder/revision.js +2 -2
- package/lib/builder/revision.js.map +1 -1
- package/lib/builder/revision.spec.js +1 -1
- package/lib/builder/revision.spec.js.map +1 -1
- package/lib/builder/traffic.d.ts +1 -1
- package/lib/builder/traffic.js +57 -49
- package/lib/builder/traffic.js.map +1 -1
- package/lib/builder/traffic.spec.js +14 -14
- package/lib/builder/traffic.spec.js.map +1 -1
- package/lib/cli/cli.js +60 -129
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/plugins.js +14 -16
- package/lib/cli/plugins.js.map +1 -1
- package/lib/config/parsers.js +1 -1
- package/lib/config/parsers.js.map +1 -1
- package/lib/config/projectConfig.d.ts +8 -6
- package/lib/config/projectConfig.js +31 -72
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/adapter.d.ts +1 -1
- package/lib/datasource/adapter.js +2 -5
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/datasource.d.ts +2 -1
- package/lib/datasource/datasource.js +107 -148
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/filesystemAdapter.d.ts +1 -1
- package/lib/datasource/filesystemAdapter.js +224 -360
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/evaluate/index.d.ts +1 -1
- package/lib/evaluate/index.js +120 -188
- package/lib/evaluate/index.js.map +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.d.ts +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js +40 -128
- package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
- package/lib/find-duplicate-segments/index.js +27 -82
- package/lib/find-duplicate-segments/index.js.map +1 -1
- package/lib/find-usage/index.d.ts +7 -5
- package/lib/find-usage/index.js +333 -507
- package/lib/find-usage/index.js.map +1 -1
- package/lib/generate-code/index.js +36 -91
- package/lib/generate-code/index.js.map +1 -1
- package/lib/generate-code/typescript.js +117 -157
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/info/index.js +45 -133
- package/lib/info/index.js.map +1 -1
- package/lib/init/index.d.ts +1 -1
- package/lib/init/index.js +16 -64
- package/lib/init/index.js.map +1 -1
- package/lib/linter/attributeSchema.d.ts +21 -6
- package/lib/linter/attributeSchema.js +18 -4
- package/lib/linter/attributeSchema.js.map +1 -1
- package/lib/linter/checkCircularDependency.d.ts +1 -1
- package/lib/linter/checkCircularDependency.js +22 -80
- package/lib/linter/checkCircularDependency.js.map +1 -1
- package/lib/linter/checkPercentageExceedingSlot.d.ts +1 -1
- package/lib/linter/checkPercentageExceedingSlot.js +36 -76
- package/lib/linter/checkPercentageExceedingSlot.js.map +1 -1
- package/lib/linter/conditionSchema.d.ts +1 -1
- package/lib/linter/conditionSchema.js +89 -41
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +345 -197
- package/lib/linter/featureSchema.js +313 -172
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/groupSchema.js +6 -6
- package/lib/linter/groupSchema.js.map +1 -1
- package/lib/linter/lintProject.js +306 -480
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/printError.js +7 -7
- package/lib/linter/printError.js.map +1 -1
- package/lib/linter/segmentSchema.js +2 -2
- package/lib/linter/segmentSchema.js.map +1 -1
- package/lib/linter/testSchema.d.ts +155 -3
- package/lib/linter/testSchema.js +47 -17
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/list/index.d.ts +1 -0
- package/lib/list/index.js +349 -517
- package/lib/list/index.js.map +1 -1
- package/lib/{tester → list}/matrix.d.ts +1 -1
- package/lib/{tester → list}/matrix.js +50 -42
- package/lib/list/matrix.js.map +1 -0
- package/lib/{tester → list}/matrix.spec.js +7 -7
- package/lib/list/matrix.spec.js.map +1 -0
- package/lib/site/exportSite.js +25 -71
- package/lib/site/exportSite.js.map +1 -1
- package/lib/site/generateHistory.d.ts +1 -1
- package/lib/site/generateHistory.js +26 -82
- package/lib/site/generateHistory.js.map +1 -1
- package/lib/site/generateSiteSearchIndex.d.ts +1 -1
- package/lib/site/generateSiteSearchIndex.js +182 -259
- package/lib/site/generateSiteSearchIndex.js.map +1 -1
- package/lib/site/getLastModifiedFromHistory.d.ts +1 -1
- package/lib/site/getLastModifiedFromHistory.js +2 -2
- package/lib/site/getLastModifiedFromHistory.js.map +1 -1
- package/lib/site/getOwnerAndRepoFromUrl.js +6 -6
- package/lib/site/getOwnerAndRepoFromUrl.js.map +1 -1
- package/lib/site/getRelativePaths.js +7 -7
- package/lib/site/getRelativePaths.js.map +1 -1
- package/lib/site/getRepoDetails.js +20 -20
- package/lib/site/getRepoDetails.js.map +1 -1
- package/lib/site/index.js +25 -73
- package/lib/site/index.js.map +1 -1
- package/lib/site/serveSite.js +10 -10
- package/lib/site/serveSite.js.map +1 -1
- package/lib/tester/helpers.d.ts +2 -0
- package/lib/tester/helpers.js +71 -0
- package/lib/tester/helpers.js.map +1 -0
- package/lib/tester/helpers.spec.js +115 -0
- package/lib/tester/helpers.spec.js.map +1 -0
- package/lib/tester/index.d.ts +0 -1
- package/lib/tester/index.js +0 -1
- package/lib/tester/index.js.map +1 -1
- package/lib/tester/prettyDuration.js +11 -11
- package/lib/tester/prettyDuration.js.map +1 -1
- package/lib/tester/printTestResult.d.ts +1 -1
- package/lib/tester/printTestResult.js +35 -15
- package/lib/tester/printTestResult.js.map +1 -1
- package/lib/tester/testFeature.d.ts +4 -2
- package/lib/tester/testFeature.js +264 -226
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +3 -7
- package/lib/tester/testProject.js +145 -246
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.d.ts +5 -2
- package/lib/tester/testSegment.js +65 -102
- package/lib/tester/testSegment.js.map +1 -1
- package/lib/utils/extractKeys.d.ts +2 -1
- package/lib/utils/extractKeys.js +57 -12
- package/lib/utils/extractKeys.js.map +1 -1
- package/lib/utils/git.d.ts +1 -1
- package/lib/utils/git.js +23 -23
- package/lib/utils/git.js.map +1 -1
- package/lib/utils/pretty.js +2 -4
- package/lib/utils/pretty.js.map +1 -1
- package/package.json +5 -6
- package/src/assess-distribution/index.ts +3 -2
- package/src/benchmark/index.ts +3 -3
- package/src/builder/allocator.spec.ts +1 -1
- package/src/builder/allocator.ts +1 -1
- package/src/builder/buildDatafile.ts +161 -124
- package/src/builder/buildProject.ts +6 -3
- package/src/builder/convertToV1.ts +166 -0
- package/src/builder/getFeatureRanges.ts +1 -1
- package/src/builder/hashes.ts +109 -0
- package/src/builder/traffic.ts +40 -16
- package/src/cli/cli.ts +1 -1
- package/src/cli/plugins.ts +0 -2
- package/src/config/projectConfig.ts +13 -10
- package/src/datasource/adapter.ts +1 -1
- package/src/datasource/datasource.ts +23 -2
- package/src/datasource/filesystemAdapter.ts +11 -12
- package/src/evaluate/index.ts +7 -6
- package/src/find-duplicate-segments/findDuplicateSegments.ts +1 -1
- package/src/find-usage/index.ts +111 -44
- package/src/generate-code/index.ts +1 -3
- package/src/generate-code/typescript.ts +7 -29
- package/src/index.ts +0 -1
- package/src/info/index.ts +2 -2
- package/src/init/index.ts +2 -2
- package/src/linter/attributeSchema.ts +18 -2
- package/src/linter/checkCircularDependency.ts +1 -1
- package/src/linter/checkPercentageExceedingSlot.ts +28 -8
- package/src/linter/conditionSchema.ts +66 -10
- package/src/linter/featureSchema.ts +312 -116
- package/src/linter/lintProject.ts +9 -4
- package/src/linter/testSchema.ts +42 -3
- package/src/list/index.ts +18 -30
- package/src/{tester → list}/matrix.ts +33 -11
- package/src/site/exportSite.ts +2 -4
- package/src/site/generateHistory.ts +1 -1
- package/src/site/generateSiteSearchIndex.ts +58 -50
- package/src/site/getLastModifiedFromHistory.ts +1 -1
- package/src/tester/helpers.spec.ts +149 -0
- package/src/tester/helpers.ts +76 -0
- package/src/tester/index.ts +0 -1
- package/src/tester/printTestResult.ts +25 -3
- package/src/tester/testFeature.ts +270 -124
- package/src/tester/testProject.ts +28 -49
- package/src/tester/testSegment.ts +48 -40
- package/src/utils/extractKeys.ts +58 -1
- package/src/utils/git.ts +1 -1
- package/tsconfig.cjs.json +1 -0
- package/coverage/lcov-report/lib/tester/checkIfObjectsAreEqual.js.html +0 -151
- package/coverage/lcov-report/src/tester/checkIfObjectsAreEqual.ts.html +0 -157
- package/lib/restore/index.d.ts +0 -4
- package/lib/restore/index.js +0 -91
- package/lib/restore/index.js.map +0 -1
- package/lib/tester/checkIfArraysAreEqual.d.ts +0 -1
- package/lib/tester/checkIfArraysAreEqual.js +0 -18
- package/lib/tester/checkIfArraysAreEqual.js.map +0 -1
- package/lib/tester/checkIfObjectsAreEqual.d.ts +0 -1
- package/lib/tester/checkIfObjectsAreEqual.js +0 -23
- package/lib/tester/checkIfObjectsAreEqual.js.map +0 -1
- package/lib/tester/checkIfObjectsAreEqual.spec.js +0 -26
- package/lib/tester/checkIfObjectsAreEqual.spec.js.map +0 -1
- package/lib/tester/matrix.js.map +0 -1
- package/lib/tester/matrix.spec.js.map +0 -1
- package/src/restore/index.ts +0 -42
- package/src/tester/checkIfArraysAreEqual.ts +0 -16
- package/src/tester/checkIfObjectsAreEqual.spec.ts +0 -31
- package/src/tester/checkIfObjectsAreEqual.ts +0 -24
- /package/lib/{tester → list}/matrix.spec.d.ts +0 -0
- /package/lib/tester/{checkIfObjectsAreEqual.spec.d.ts → helpers.spec.d.ts} +0 -0
- /package/src/{tester → list}/matrix.spec.ts +0 -0
|
@@ -1,108 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.testSegment = testSegment;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return [2 /*return*/, testResult];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
4
|
+
const sdk_1 = require("@featurevisor/sdk");
|
|
5
|
+
async function testSegment(datasource, test, options = {}) {
|
|
6
|
+
const testStartTime = Date.now();
|
|
7
|
+
const segmentKey = test.segment;
|
|
8
|
+
const testResult = {
|
|
9
|
+
type: "segment",
|
|
10
|
+
key: segmentKey,
|
|
11
|
+
// to be updated later
|
|
12
|
+
notFound: false,
|
|
13
|
+
duration: 0,
|
|
14
|
+
passed: true,
|
|
15
|
+
assertions: [],
|
|
16
|
+
};
|
|
17
|
+
const segmentExists = await datasource.segmentExists(segmentKey);
|
|
18
|
+
if (!segmentExists) {
|
|
19
|
+
testResult.notFound = true;
|
|
20
|
+
testResult.passed = false;
|
|
21
|
+
return testResult;
|
|
22
|
+
}
|
|
23
|
+
let logLevel = "warn";
|
|
24
|
+
if (options.verbose) {
|
|
25
|
+
logLevel = "debug";
|
|
26
|
+
}
|
|
27
|
+
else if (options.quiet) {
|
|
28
|
+
logLevel = "fatal";
|
|
29
|
+
}
|
|
30
|
+
const parsedSegment = await datasource.readSegment(segmentKey);
|
|
31
|
+
const conditions = parsedSegment.conditions;
|
|
32
|
+
const logger = (0, sdk_1.createLogger)({
|
|
33
|
+
level: logLevel,
|
|
34
|
+
});
|
|
35
|
+
const datafileReader = new sdk_1.DatafileReader({
|
|
36
|
+
datafile: {
|
|
37
|
+
schemaVersion: "2",
|
|
38
|
+
revision: "tester",
|
|
39
|
+
segments: {},
|
|
40
|
+
features: {},
|
|
41
|
+
},
|
|
42
|
+
logger,
|
|
43
|
+
});
|
|
44
|
+
test.assertions.forEach(function (assertion) {
|
|
45
|
+
const assertionStartTime = Date.now();
|
|
46
|
+
const testResultAssertion = {
|
|
47
|
+
description: assertion.description,
|
|
48
|
+
duration: 0,
|
|
49
|
+
passed: true,
|
|
50
|
+
errors: [],
|
|
51
|
+
};
|
|
52
|
+
const expected = assertion.expectedToMatch;
|
|
53
|
+
const actual = datafileReader.allConditionsAreMatched(conditions, assertion.context);
|
|
54
|
+
const passed = actual === expected;
|
|
55
|
+
if (!passed) {
|
|
56
|
+
const testResultAssertionError = {
|
|
57
|
+
type: "segment",
|
|
58
|
+
expected,
|
|
59
|
+
actual,
|
|
60
|
+
};
|
|
61
|
+
testResultAssertion.errors.push(testResultAssertionError);
|
|
62
|
+
testResult.passed = false;
|
|
63
|
+
testResultAssertion.passed = passed;
|
|
64
|
+
}
|
|
65
|
+
testResult.assertions.push(testResultAssertion);
|
|
66
|
+
testResultAssertion.duration = Date.now() - assertionStartTime;
|
|
106
67
|
});
|
|
68
|
+
testResult.duration = Date.now() - testStartTime;
|
|
69
|
+
return testResult;
|
|
107
70
|
}
|
|
108
71
|
//# sourceMappingURL=testSegment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testSegment.js","sourceRoot":"","sources":["../../src/tester/testSegment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testSegment.js","sourceRoot":"","sources":["../../src/tester/testSegment.ts"],"names":[],"mappings":";;AAWA,kCAkFC;AAtFD,2CAA2E;AAIpE,KAAK,UAAU,WAAW,CAC/B,UAAsB,EACtB,IAAiB,EACjB,UAAkD,EAAE;IAEpD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACjC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC;IAEhC,MAAM,UAAU,GAAe;QAC7B,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,UAAU;QAEf,sBAAsB;QACtB,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,CAAC;QACX,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,EAAE;KACf,CAAC;IAEF,MAAM,aAAa,GAAG,MAAM,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAEjE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,UAAU,CAAC,QAAQ,GAA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AAI,EAAE,SAAS;gBACf,QAAQ;gBACR,MAAM;aACP,CAAC;YAED,mBAAmB,CAAC,MAAqC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YAC1F,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;YAC1B,mBAAmB,CAAC,MAAM,GAAG,MAAM,CAAC;QACtC,CAAC;QAED,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAChD,mBAAmB,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,kBAAkB,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC;IAEjD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { Condition, AttributeKey, GroupSegment, SegmentKey } from "@featurevisor/types";
|
|
1
|
+
import type { Condition, AttributeKey, GroupSegment, SegmentKey, Feature } from "@featurevisor/types";
|
|
2
|
+
export declare function extractSegmentsFromFeature(feature: Feature): Set<SegmentKey>;
|
|
2
3
|
export declare function extractSegmentKeysFromGroupSegments(segments: GroupSegment | GroupSegment[]): Set<SegmentKey>;
|
|
3
4
|
export declare function extractAttributeKeysFromConditions(conditions: Condition | Condition[]): Set<AttributeKey>;
|
package/lib/utils/extractKeys.js
CHANGED
|
@@ -1,29 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractSegmentsFromFeature = extractSegmentsFromFeature;
|
|
3
4
|
exports.extractSegmentKeysFromGroupSegments = extractSegmentKeysFromGroupSegments;
|
|
4
5
|
exports.extractAttributeKeysFromConditions = extractAttributeKeysFromConditions;
|
|
6
|
+
function extractSegmentsFromFeature(feature) {
|
|
7
|
+
const result = new Set();
|
|
8
|
+
// rules
|
|
9
|
+
for (const traffic of feature.traffic) {
|
|
10
|
+
if (traffic.segments) {
|
|
11
|
+
extractSegmentKeysFromGroupSegments(traffic.segments).forEach((segmentKey) => {
|
|
12
|
+
result.add(segmentKey);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// force
|
|
17
|
+
if (feature.force) {
|
|
18
|
+
for (const f of feature.force) {
|
|
19
|
+
if (f.segments) {
|
|
20
|
+
extractSegmentKeysFromGroupSegments(f.segments).forEach((segmentKey) => {
|
|
21
|
+
result.add(segmentKey);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// variable overrides from inside variations
|
|
27
|
+
if (feature.variations) {
|
|
28
|
+
for (const variation of feature.variations) {
|
|
29
|
+
if (variation.variableOverrides) {
|
|
30
|
+
for (const variableKey in variation.variableOverrides) {
|
|
31
|
+
const overrides = variation.variableOverrides[variableKey];
|
|
32
|
+
if (overrides) {
|
|
33
|
+
for (const override of overrides) {
|
|
34
|
+
if (override.segments) {
|
|
35
|
+
extractSegmentKeysFromGroupSegments(override.segments).forEach((segmentKey) => {
|
|
36
|
+
result.add(segmentKey);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
5
47
|
function extractSegmentKeysFromGroupSegments(segments) {
|
|
6
|
-
|
|
48
|
+
const result = new Set();
|
|
7
49
|
if (Array.isArray(segments)) {
|
|
8
|
-
segments.forEach(
|
|
9
|
-
extractSegmentKeysFromGroupSegments(segment).forEach(
|
|
50
|
+
segments.forEach((segment) => {
|
|
51
|
+
extractSegmentKeysFromGroupSegments(segment).forEach((segmentKey) => {
|
|
10
52
|
result.add(segmentKey);
|
|
11
53
|
});
|
|
12
54
|
});
|
|
13
55
|
}
|
|
14
56
|
if (typeof segments === "object") {
|
|
15
57
|
if ("and" in segments) {
|
|
16
|
-
extractSegmentKeysFromGroupSegments(segments.and).forEach(
|
|
58
|
+
extractSegmentKeysFromGroupSegments(segments.and).forEach((segmentKey) => {
|
|
17
59
|
result.add(segmentKey);
|
|
18
60
|
});
|
|
19
61
|
}
|
|
20
62
|
if ("or" in segments) {
|
|
21
|
-
extractSegmentKeysFromGroupSegments(segments.or).forEach(
|
|
63
|
+
extractSegmentKeysFromGroupSegments(segments.or).forEach((segmentKey) => {
|
|
22
64
|
result.add(segmentKey);
|
|
23
65
|
});
|
|
24
66
|
}
|
|
25
67
|
if ("not" in segments) {
|
|
26
|
-
extractSegmentKeysFromGroupSegments(segments.not).forEach(
|
|
68
|
+
extractSegmentKeysFromGroupSegments(segments.not).forEach((segmentKey) => {
|
|
27
69
|
result.add(segmentKey);
|
|
28
70
|
});
|
|
29
71
|
}
|
|
@@ -34,29 +76,32 @@ function extractSegmentKeysFromGroupSegments(segments) {
|
|
|
34
76
|
return result;
|
|
35
77
|
}
|
|
36
78
|
function extractAttributeKeysFromConditions(conditions) {
|
|
37
|
-
|
|
79
|
+
const result = new Set();
|
|
38
80
|
if (Array.isArray(conditions)) {
|
|
39
|
-
conditions.forEach(
|
|
40
|
-
extractAttributeKeysFromConditions(condition).forEach(
|
|
81
|
+
conditions.forEach((condition) => {
|
|
82
|
+
extractAttributeKeysFromConditions(condition).forEach((attributeKey) => {
|
|
41
83
|
result.add(attributeKey);
|
|
42
84
|
});
|
|
43
85
|
});
|
|
44
86
|
}
|
|
87
|
+
if (typeof conditions === "string") {
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
45
90
|
if ("attribute" in conditions) {
|
|
46
91
|
result.add(conditions.attribute);
|
|
47
92
|
}
|
|
48
93
|
if ("and" in conditions) {
|
|
49
|
-
extractAttributeKeysFromConditions(conditions.and).forEach(
|
|
94
|
+
extractAttributeKeysFromConditions(conditions.and).forEach((attributeKey) => {
|
|
50
95
|
result.add(attributeKey);
|
|
51
96
|
});
|
|
52
97
|
}
|
|
53
98
|
if ("or" in conditions) {
|
|
54
|
-
extractAttributeKeysFromConditions(conditions.or).forEach(
|
|
99
|
+
extractAttributeKeysFromConditions(conditions.or).forEach((attributeKey) => {
|
|
55
100
|
result.add(attributeKey);
|
|
56
101
|
});
|
|
57
102
|
}
|
|
58
103
|
if ("not" in conditions) {
|
|
59
|
-
extractAttributeKeysFromConditions(conditions.not).forEach(
|
|
104
|
+
extractAttributeKeysFromConditions(conditions.not).forEach((attributeKey) => {
|
|
60
105
|
result.add(attributeKey);
|
|
61
106
|
});
|
|
62
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractKeys.js","sourceRoot":"","sources":["../../src/utils/extractKeys.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"extractKeys.js","sourceRoot":"","sources":["../../src/utils/extractKeys.ts"],"names":[],"mappings":";;AAQA,gEA6CC;AAED,kFAsCC;AAED,gFAwCC;AA/HD,SAAgB,0BAA0B,CAAC,OAAgB;IACzD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAc,CAAC;IAErC,QAAQ;IACR,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,mCAAmC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBAC3E,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,QAAQ;IACR,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAC9B,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;gBACf,mCAAmC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;oBACrE,MAAM,CAAC,GAAG,CAAC,UAAU,C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IAChB,CAAC;IAED,IAAI,WAAW,IAAI,UAAU,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,KAAK,IAAI,UAAU,EAAE,CAAC;QACxB,kCAAkC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC1E,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,IAAI,UAAU,EAAE,CAAC;QACvB,kCAAkC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YACzE,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,KAAK,IAAI,UAAU,EAAE,CAAC;QACxB,kCAAkC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YAC1E,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/lib/utils/git.d.ts
CHANGED
package/lib/utils/git.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCommit = getCommit;
|
|
4
|
-
|
|
4
|
+
const path = require("path");
|
|
5
5
|
function parseGitCommitShowOutput(gitShowOutput) {
|
|
6
|
-
|
|
6
|
+
const result = {
|
|
7
7
|
hash: "",
|
|
8
8
|
author: "",
|
|
9
9
|
date: "",
|
|
10
10
|
message: "",
|
|
11
11
|
diffs: {},
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
lines.forEach(
|
|
13
|
+
const lines = gitShowOutput.split("\n");
|
|
14
|
+
let currentFile = "";
|
|
15
|
+
let parsingDiffs = false;
|
|
16
|
+
let parsingMessage = false;
|
|
17
|
+
lines.forEach((line) => {
|
|
18
18
|
if (line.startsWith("commit ")) {
|
|
19
19
|
result.hash = line.replace("commit ", "").trim();
|
|
20
20
|
}
|
|
@@ -46,7 +46,7 @@ function parseGitCommitShowOutput(gitShowOutput) {
|
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
48
|
function analyzeFileChange(diff) {
|
|
49
|
-
|
|
49
|
+
let status = "updated"; // Default to 'updated'
|
|
50
50
|
// Check for file creation or deletion
|
|
51
51
|
if (diff.includes("new file mode")) {
|
|
52
52
|
status = "created";
|
|
@@ -57,21 +57,21 @@ function analyzeFileChange(diff) {
|
|
|
57
57
|
return status;
|
|
58
58
|
}
|
|
59
59
|
function getCommit(gitShowOutput, options) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const parsed = parseGitCommitShowOutput(gitShowOutput);
|
|
61
|
+
const { rootDirectoryPath, projectConfig } = options;
|
|
62
|
+
const commit = {
|
|
63
63
|
hash: parsed.hash,
|
|
64
64
|
author: parsed.author,
|
|
65
65
|
timestamp: parsed.date,
|
|
66
66
|
entities: [],
|
|
67
67
|
};
|
|
68
|
-
Object.keys(parsed.diffs).forEach(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
Object.keys(parsed.diffs).forEach((file) => {
|
|
69
|
+
const diff = parsed.diffs[file];
|
|
70
|
+
const status = analyzeFileChange(diff);
|
|
71
|
+
const absolutePath = path.join(rootDirectoryPath, file);
|
|
72
|
+
const relativeDir = path.dirname(absolutePath);
|
|
73
73
|
// get entity type
|
|
74
|
-
|
|
74
|
+
let type = "attribute";
|
|
75
75
|
if (relativeDir === projectConfig.attributesDirectoryPath) {
|
|
76
76
|
type = "attribute";
|
|
77
77
|
}
|
|
@@ -92,16 +92,16 @@ function getCommit(gitShowOutput, options) {
|
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
// get entity key
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const fileName = absolutePath.split(path.sep).pop();
|
|
96
|
+
const extensionWithDot = "." + projectConfig.parser.extension;
|
|
97
97
|
if (!fileName.endsWith(extensionWithDot)) {
|
|
98
98
|
// unknown extension
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
type
|
|
104
|
-
key
|
|
101
|
+
const key = fileName.replace(extensionWithDot, "");
|
|
102
|
+
const entityDiff = {
|
|
103
|
+
type,
|
|
104
|
+
key,
|
|
105
105
|
content: diff,
|
|
106
106
|
};
|
|
107
107
|
if (status === "created") {
|
package/lib/utils/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;AA6DA,8BAmEC;AAhID,
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;AA6DA,8BAmEC;AAhID,6BAA6B;AAM7B,SAAS,wBAAwB,CAAC,aAAqB;IACrD,MAAM,MAAM,GAAG;QACb,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,G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UAAU,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/lib/utils/pretty.js
CHANGED
|
@@ -5,9 +5,7 @@ exports.prettyPercentage = prettyPercentage;
|
|
|
5
5
|
function prettyNumber(n) {
|
|
6
6
|
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
7
7
|
}
|
|
8
|
-
function prettyPercentage(value, total, precision, suffix) {
|
|
9
|
-
|
|
10
|
-
if (suffix === void 0) { suffix = "%"; }
|
|
11
|
-
return "".concat(((value / total) * 100).toFixed(precision)).concat(suffix);
|
|
8
|
+
function prettyPercentage(value, total, precision = 2, suffix = "%") {
|
|
9
|
+
return `${((value / total) * 100).toFixed(precision)}${suffix}`;
|
|
12
10
|
}
|
|
13
11
|
//# sourceMappingURL=pretty.js.map
|
package/lib/utils/pretty.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pretty.js","sourceRoot":"","sources":["../../src/utils/pretty.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAED,4CAOC;AAXD,SAAgB,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,gBAAgB,CAC9B,KAAa,EACb,KAAa,EACb,
|
|
1
|
+
{"version":3,"file":"pretty.js","sourceRoot":"","sources":["../../src/utils/pretty.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAED,4CAOC;AAXD,SAAgB,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED,SAAgB,gBAAgB,CAC9B,KAAa,EACb,KAAa,EACb,YAAoB,CAAC,EACrB,SAAiB,GAAG;IAEpB,OAAO,GAAG,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,MAAM,EAAE,CAAC;AAClE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@featurevisor/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Core package of Featurevisor for Node.js usage",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -40,12 +40,11 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@featurevisor/sdk": "
|
|
44
|
-
"@featurevisor/site": "
|
|
45
|
-
"@featurevisor/types": "
|
|
43
|
+
"@featurevisor/sdk": "2.0.0",
|
|
44
|
+
"@featurevisor/site": "2.0.0",
|
|
45
|
+
"@featurevisor/types": "2.0.0",
|
|
46
46
|
"axios": "^1.3.4",
|
|
47
47
|
"js-yaml": "^4.1.0",
|
|
48
|
-
"mkdirp": "^2.1.3",
|
|
49
48
|
"tar": "^6.1.13",
|
|
50
49
|
"yargs": "^17.7.2",
|
|
51
50
|
"zod": "^3.22.4"
|
|
@@ -54,5 +53,5 @@
|
|
|
54
53
|
"@types/js-yaml": "^4.0.5",
|
|
55
54
|
"@types/tar": "^6.1.4"
|
|
56
55
|
},
|
|
57
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "9817e05a07735294c750ee921991509b67015afd"
|
|
58
57
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from "crypto";
|
|
2
2
|
|
|
3
|
-
import { FeatureKey, AttributeKey, Context } from "@featurevisor/types";
|
|
3
|
+
import type { FeatureKey, AttributeKey, Context, DatafileContent } from "@featurevisor/types";
|
|
4
4
|
import { createInstance } from "@featurevisor/sdk";
|
|
5
5
|
|
|
6
6
|
import { Dependencies } from "../dependencies";
|
|
@@ -107,7 +107,8 @@ export async function assessDistribution(deps: Dependencies, options: AssessDist
|
|
|
107
107
|
* Initialize SDK
|
|
108
108
|
*/
|
|
109
109
|
const f = createInstance({
|
|
110
|
-
datafile: datafileContent,
|
|
110
|
+
datafile: datafileContent as DatafileContent,
|
|
111
|
+
logLevel: "warn",
|
|
111
112
|
});
|
|
112
113
|
console.log("\n\n...SDK initialized\n");
|
|
113
114
|
|
package/src/benchmark/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context } from "@featurevisor/types";
|
|
1
|
+
import type { Context, DatafileContent } from "@featurevisor/types";
|
|
2
2
|
import { FeaturevisorInstance, createInstance } from "@featurevisor/sdk";
|
|
3
3
|
|
|
4
4
|
import { SCHEMA_VERSION } from "../config";
|
|
@@ -120,13 +120,13 @@ export async function benchmarkFeature(
|
|
|
120
120
|
console.log("");
|
|
121
121
|
console.log("Features count:", Object.keys(datafileContent.features).length);
|
|
122
122
|
console.log("Segments count:", Object.keys(datafileContent.segments).length);
|
|
123
|
-
console.log("Attributes count:", Object.keys(datafileContent.attributes).length);
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
console.log("");
|
|
127
126
|
|
|
128
127
|
const f = createInstance({
|
|
129
|
-
datafile: datafileContent,
|
|
128
|
+
datafile: datafileContent as DatafileContent,
|
|
129
|
+
logLevel: "warn",
|
|
130
130
|
});
|
|
131
131
|
console.log("...SDK initialized");
|
|
132
132
|
|
package/src/builder/allocator.ts
CHANGED