@featurevisor/core 1.35.2 → 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/CHANGELOG.md +8 -0
- 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 +90 -63
- 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 +101 -23
- 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 -48
- 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 +41 -15
- 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
package/lib/list/index.js
CHANGED
|
@@ -1,548 +1,380 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
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);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
3
|
exports.listPlugin = void 0;
|
|
4
|
+
exports.listEntities = listEntities;
|
|
51
5
|
exports.listProject = listProject;
|
|
52
|
-
|
|
53
|
-
function getEntitiesWithTests(deps) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
6
|
+
const matrix_1 = require("./matrix");
|
|
7
|
+
async function getEntitiesWithTests(deps) {
|
|
8
|
+
const { datasource } = deps;
|
|
9
|
+
const featuresWithTests = new Set();
|
|
10
|
+
const segmentsWithTests = new Set();
|
|
11
|
+
const tests = await datasource.listTests();
|
|
12
|
+
for (const testKey of tests) {
|
|
13
|
+
const test = await datasource.readTest(testKey);
|
|
14
|
+
if (test.feature) {
|
|
15
|
+
featuresWithTests.add(test.feature);
|
|
16
|
+
}
|
|
17
|
+
if (test.segment) {
|
|
18
|
+
segmentsWithTests.add(test.segment);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
features: Array.from(featuresWithTests),
|
|
23
|
+
segments: Array.from(segmentsWithTests),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function listEntities(deps, entityType) {
|
|
27
|
+
const { datasource, options } = deps;
|
|
28
|
+
const result = [];
|
|
29
|
+
let entityKeys = [];
|
|
30
|
+
if (entityType === "feature") {
|
|
31
|
+
entityKeys = await datasource.listFeatures();
|
|
32
|
+
}
|
|
33
|
+
else if (entityType === "segment") {
|
|
34
|
+
entityKeys = await datasource.listSegments();
|
|
35
|
+
}
|
|
36
|
+
else if (entityType === "attribute") {
|
|
37
|
+
entityKeys = await datasource.listAttributes();
|
|
38
|
+
}
|
|
39
|
+
else if (entityType === "test") {
|
|
40
|
+
entityKeys = await datasource.listTests();
|
|
41
|
+
}
|
|
42
|
+
if (entityKeys.length === 0) {
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
let entitiesWithTests = {
|
|
46
|
+
features: [],
|
|
47
|
+
segments: [],
|
|
48
|
+
};
|
|
49
|
+
let entitiesWithTestsInitialized = false;
|
|
50
|
+
async function initializeEntitiesWithTests() {
|
|
51
|
+
if (entitiesWithTestsInitialized) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
entitiesWithTests = await getEntitiesWithTests(deps);
|
|
55
|
+
entitiesWithTestsInitialized = true;
|
|
56
|
+
}
|
|
57
|
+
for (const key of entityKeys) {
|
|
58
|
+
let entity = {};
|
|
59
|
+
if (entityType === "feature") {
|
|
60
|
+
entity = (await datasource.readFeature(key));
|
|
61
|
+
}
|
|
62
|
+
else if (entityType === "segment") {
|
|
63
|
+
entity = (await datasource.readSegment(key));
|
|
64
|
+
}
|
|
65
|
+
else if (entityType === "attribute") {
|
|
66
|
+
entity = (await datasource.readAttribute(key));
|
|
67
|
+
}
|
|
68
|
+
else if (entityType === "test") {
|
|
69
|
+
entity = (await datasource.readTest(key));
|
|
70
|
+
}
|
|
71
|
+
// filter
|
|
72
|
+
if (entityType === "feature") {
|
|
73
|
+
const parsedFeature = entity;
|
|
74
|
+
// --archived=true|false
|
|
75
|
+
if (parsedFeature.archived) {
|
|
76
|
+
const archivedStatus = options.archived === "false";
|
|
77
|
+
if (parsedFeature.archived !== archivedStatus) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// --description=<pattern>
|
|
82
|
+
if (options.description) {
|
|
83
|
+
const description = parsedFeature.description || "";
|
|
84
|
+
const regex = new RegExp(options.description, "i");
|
|
85
|
+
if (!regex.test(description)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// --disabledIn=<environment>
|
|
90
|
+
if (options.disabledIn && parsedFeature.rules && parsedFeature.rules[options.disabledIn]) {
|
|
91
|
+
const disabledInEnvironment = parsedFeature.rules[options.disabledIn].every((rule) => {
|
|
92
|
+
return rule.percentage === 0;
|
|
93
|
+
});
|
|
94
|
+
if (!disabledInEnvironment) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// --enabledIn=<environment>
|
|
99
|
+
if (options.enabledIn && parsedFeature.rules && parsedFeature.rules[options.enabledIn]) {
|
|
100
|
+
const enabledInEnvironment = parsedFeature.rules[options.enabledIn].some((rule) => {
|
|
101
|
+
return rule.percentage > 0;
|
|
102
|
+
});
|
|
103
|
+
if (!enabledInEnvironment) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// --keyPattern=<pattern>
|
|
108
|
+
if (options.keyPattern) {
|
|
109
|
+
const regex = new RegExp(options.keyPattern, "i");
|
|
110
|
+
if (!regex.test(key)) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// --tag=<tag>
|
|
115
|
+
if (options.tag) {
|
|
116
|
+
const tags = Array.isArray(options.tag) ? options.tag : [options.tag];
|
|
117
|
+
const hasTags = tags.every((tag) => parsedFeature.tags.includes(tag));
|
|
118
|
+
if (!hasTags) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// --variable=<variableKey>
|
|
123
|
+
if (options.variable) {
|
|
124
|
+
const lookForVariables = Array.isArray(options.variable)
|
|
125
|
+
? options.variable
|
|
126
|
+
: [options.variable];
|
|
127
|
+
let variablesInFeature = Object.keys(parsedFeature.variablesSchema || {});
|
|
128
|
+
const hasVariables = lookForVariables.every((variable) => variablesInFeature.includes(variable));
|
|
129
|
+
if (!hasVariables) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// --variation=<variationValue>
|
|
134
|
+
if (options.variation) {
|
|
135
|
+
const lookForVariations = Array.isArray(options.variation)
|
|
136
|
+
? options.variation
|
|
137
|
+
: [options.variation];
|
|
138
|
+
let variationsInFeature = parsedFeature.variations
|
|
139
|
+
? parsedFeature.variations.map((v) => v.value)
|
|
140
|
+
: [];
|
|
141
|
+
const hasVariations = lookForVariations.every((variation) => variationsInFeature.includes(variation));
|
|
142
|
+
if (!hasVariations) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// --with-tests
|
|
147
|
+
if (options.withTests) {
|
|
148
|
+
await initializeEntitiesWithTests();
|
|
149
|
+
if (!entitiesWithTests.features.includes(key)) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// --with-variables
|
|
154
|
+
if (options.withVariables) {
|
|
155
|
+
const hasVariables = parsedFeature.variablesSchema;
|
|
156
|
+
if (!hasVariables) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// --with-variations
|
|
161
|
+
if (options.withVariations) {
|
|
162
|
+
const hasVariations = parsedFeature.variations;
|
|
163
|
+
if (!hasVariations) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// --without-tests
|
|
168
|
+
if (options.withoutTests) {
|
|
169
|
+
await initializeEntitiesWithTests();
|
|
170
|
+
if (entitiesWithTests.features.includes(key)) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// --without-variables
|
|
175
|
+
if (options.withoutVariables) {
|
|
176
|
+
const hasVariables = parsedFeature.variablesSchema;
|
|
177
|
+
if (hasVariables) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// --without-variations
|
|
182
|
+
if (options.withoutVariations) {
|
|
183
|
+
const hasVariations = parsedFeature.variations;
|
|
184
|
+
if (hasVariations) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else if (entityType === "segment") {
|
|
190
|
+
const segment = entity;
|
|
191
|
+
// --archived=true|false
|
|
192
|
+
if (segment.archived) {
|
|
193
|
+
const archivedStatus = options.archived === "false";
|
|
194
|
+
if (segment.archived !== archivedStatus) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// --description=<pattern>
|
|
199
|
+
if (options.description) {
|
|
200
|
+
const description = segment.description || "";
|
|
201
|
+
const regex = new RegExp(options.description, "i");
|
|
202
|
+
if (!regex.test(description)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// --keyPattern=<pattern>
|
|
207
|
+
if (options.keyPattern) {
|
|
208
|
+
const regex = new RegExp(options.keyPattern, "i");
|
|
209
|
+
if (!regex.test(key)) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// --with-tests
|
|
214
|
+
if (options.withTests) {
|
|
215
|
+
await initializeEntitiesWithTests();
|
|
216
|
+
if (!entitiesWithTests.segments.includes(key)) {
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// --without-tests
|
|
221
|
+
if (options.withoutTests) {
|
|
222
|
+
await initializeEntitiesWithTests();
|
|
223
|
+
if (entitiesWithTests.segments.includes(key)) {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else if (entityType === "attribute") {
|
|
229
|
+
const attribute = entity;
|
|
230
|
+
// --archived=true|false
|
|
231
|
+
if (options.archived) {
|
|
232
|
+
const archivedStatus = options.archived === "false";
|
|
233
|
+
if (attribute.archived !== archivedStatus) {
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// --description=<pattern>
|
|
238
|
+
if (options.description) {
|
|
239
|
+
const description = attribute.description || "";
|
|
240
|
+
const regex = new RegExp(options.description, "i");
|
|
241
|
+
if (!regex.test(description)) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// --keyPattern=<pattern>
|
|
246
|
+
if (options.keyPattern) {
|
|
247
|
+
const regex = new RegExp(options.keyPattern, "i");
|
|
248
|
+
if (!regex.test(key)) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (entityType === "test") {
|
|
254
|
+
let test = entity;
|
|
255
|
+
const testEntityKey = test.feature || test.segment;
|
|
256
|
+
const testEntityType = test.segment ? "segment" : "feature";
|
|
257
|
+
let testAssertions = test.assertions;
|
|
258
|
+
// --entityType=<type>
|
|
259
|
+
if (options.entityType && options.entityType !== testEntityType) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
// --apply-matrix
|
|
263
|
+
if (options.applyMatrix) {
|
|
264
|
+
if (testEntityType === "feature") {
|
|
265
|
+
let assertionsAfterApplyingMatrix = [];
|
|
266
|
+
for (let aIndex = 0; aIndex < testAssertions.length; aIndex++) {
|
|
267
|
+
const processedAssertions = (0, matrix_1.getFeatureAssertionsFromMatrix)(aIndex, testAssertions[aIndex]);
|
|
268
|
+
assertionsAfterApplyingMatrix =
|
|
269
|
+
assertionsAfterApplyingMatrix.concat(processedAssertions);
|
|
75
270
|
}
|
|
76
|
-
|
|
77
|
-
|
|
271
|
+
testAssertions = assertionsAfterApplyingMatrix;
|
|
272
|
+
}
|
|
273
|
+
else if (testEntityType === "segment") {
|
|
274
|
+
let assertionsAfterApplyingMatrix = [];
|
|
275
|
+
for (let aIndex = 0; aIndex < testAssertions.length; aIndex++) {
|
|
276
|
+
const processedAssertions = (0, matrix_1.getSegmentAssertionsFromMatrix)(aIndex, testAssertions[aIndex]);
|
|
277
|
+
assertionsAfterApplyingMatrix =
|
|
278
|
+
assertionsAfterApplyingMatrix.concat(processedAssertions);
|
|
78
279
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
_i++;
|
|
82
|
-
return [3 /*break*/, 2];
|
|
83
|
-
case 5: return [2 /*return*/, {
|
|
84
|
-
features: Array.from(featuresWithTests),
|
|
85
|
-
segments: Array.from(segmentsWithTests),
|
|
86
|
-
}];
|
|
280
|
+
testAssertions = assertionsAfterApplyingMatrix;
|
|
281
|
+
}
|
|
87
282
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return [4 /*yield*/, getEntitiesWithTests(deps)];
|
|
102
|
-
case 1:
|
|
103
|
-
entitiesWithTests = _a.sent();
|
|
104
|
-
entitiesWithTestsInitialized = true;
|
|
105
|
-
return [2 /*return*/];
|
|
283
|
+
// --keyPattern=<pattern>
|
|
284
|
+
if (options.keyPattern) {
|
|
285
|
+
const regex = new RegExp(options.keyPattern, "i");
|
|
286
|
+
if (!regex.test(testEntityKey)) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// --assertionPattern=<pattern>
|
|
291
|
+
if (options.assertionPattern) {
|
|
292
|
+
const regex = new RegExp(options.assertionPattern, "i");
|
|
293
|
+
testAssertions = testAssertions.filter((assertion) => {
|
|
294
|
+
if (!assertion.description) {
|
|
295
|
+
return false;
|
|
106
296
|
}
|
|
297
|
+
return regex.test(assertion.description);
|
|
107
298
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return __generator(this, function (_a) {
|
|
112
|
-
switch (_a.label) {
|
|
113
|
-
case 0:
|
|
114
|
-
datasource = deps.datasource, options = deps.options;
|
|
115
|
-
result = [];
|
|
116
|
-
entityKeys = [];
|
|
117
|
-
if (!(entityType === "feature")) return [3 /*break*/, 2];
|
|
118
|
-
return [4 /*yield*/, datasource.listFeatures()];
|
|
119
|
-
case 1:
|
|
120
|
-
entityKeys = _a.sent();
|
|
121
|
-
return [3 /*break*/, 8];
|
|
122
|
-
case 2:
|
|
123
|
-
if (!(entityType === "segment")) return [3 /*break*/, 4];
|
|
124
|
-
return [4 /*yield*/, datasource.listSegments()];
|
|
125
|
-
case 3:
|
|
126
|
-
entityKeys = _a.sent();
|
|
127
|
-
return [3 /*break*/, 8];
|
|
128
|
-
case 4:
|
|
129
|
-
if (!(entityType === "attribute")) return [3 /*break*/, 6];
|
|
130
|
-
return [4 /*yield*/, datasource.listAttributes()];
|
|
131
|
-
case 5:
|
|
132
|
-
entityKeys = _a.sent();
|
|
133
|
-
return [3 /*break*/, 8];
|
|
134
|
-
case 6:
|
|
135
|
-
if (!(entityType === "test")) return [3 /*break*/, 8];
|
|
136
|
-
return [4 /*yield*/, datasource.listTests()];
|
|
137
|
-
case 7:
|
|
138
|
-
entityKeys = _a.sent();
|
|
139
|
-
_a.label = 8;
|
|
140
|
-
case 8:
|
|
141
|
-
if (entityKeys.length === 0) {
|
|
142
|
-
return [2 /*return*/, result];
|
|
143
|
-
}
|
|
144
|
-
entitiesWithTests = {
|
|
145
|
-
features: [],
|
|
146
|
-
segments: [],
|
|
147
|
-
};
|
|
148
|
-
entitiesWithTestsInitialized = false;
|
|
149
|
-
_loop_1 = function (key) {
|
|
150
|
-
var entity, parsedFeature_1, archivedStatus, description, regex, disabledInEnvironment, enabledInEnvironment, regex, tags, hasTags, lookForVariables, variablesInFeature_1, hasVariables, lookForVariations, variationsInFeature_1, hasVariations, hasVariables, hasVariations, hasVariables, hasVariations, segment, archivedStatus, description, regex, regex, attribute, archivedStatus, description, regex, regex, test_2, testEntityKey, testEntityType, testAssertions, assertionsAfterApplyingMatrix, aIndex, processedAssertions, assertionsAfterApplyingMatrix, aIndex, processedAssertions, regex, regex_1;
|
|
151
|
-
return __generator(this, function (_b) {
|
|
152
|
-
switch (_b.label) {
|
|
153
|
-
case 0:
|
|
154
|
-
entity = {};
|
|
155
|
-
if (!(entityType === "feature")) return [3 /*break*/, 2];
|
|
156
|
-
return [4 /*yield*/, datasource.readFeature(key)];
|
|
157
|
-
case 1:
|
|
158
|
-
entity = (_b.sent());
|
|
159
|
-
return [3 /*break*/, 8];
|
|
160
|
-
case 2:
|
|
161
|
-
if (!(entityType === "segment")) return [3 /*break*/, 4];
|
|
162
|
-
return [4 /*yield*/, datasource.readSegment(key)];
|
|
163
|
-
case 3:
|
|
164
|
-
entity = (_b.sent());
|
|
165
|
-
return [3 /*break*/, 8];
|
|
166
|
-
case 4:
|
|
167
|
-
if (!(entityType === "attribute")) return [3 /*break*/, 6];
|
|
168
|
-
return [4 /*yield*/, datasource.readAttribute(key)];
|
|
169
|
-
case 5:
|
|
170
|
-
entity = (_b.sent());
|
|
171
|
-
return [3 /*break*/, 8];
|
|
172
|
-
case 6:
|
|
173
|
-
if (!(entityType === "test")) return [3 /*break*/, 8];
|
|
174
|
-
return [4 /*yield*/, datasource.readTest(key)];
|
|
175
|
-
case 7:
|
|
176
|
-
entity = (_b.sent());
|
|
177
|
-
_b.label = 8;
|
|
178
|
-
case 8:
|
|
179
|
-
if (!(entityType === "feature")) return [3 /*break*/, 13];
|
|
180
|
-
parsedFeature_1 = entity;
|
|
181
|
-
// --archived=true|false
|
|
182
|
-
if (parsedFeature_1.archived) {
|
|
183
|
-
archivedStatus = options.archived === "false";
|
|
184
|
-
if (parsedFeature_1.archived !== archivedStatus) {
|
|
185
|
-
return [2 /*return*/, "continue"];
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// --description=<pattern>
|
|
189
|
-
if (options.description) {
|
|
190
|
-
description = parsedFeature_1.description || "";
|
|
191
|
-
regex = new RegExp(options.description, "i");
|
|
192
|
-
if (!regex.test(description)) {
|
|
193
|
-
return [2 /*return*/, "continue"];
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
// --disabledIn=<environment>
|
|
197
|
-
if (options.disabledIn &&
|
|
198
|
-
parsedFeature_1.environments &&
|
|
199
|
-
parsedFeature_1.environments[options.disabledIn]) {
|
|
200
|
-
disabledInEnvironment = parsedFeature_1.environments[options.disabledIn].rules.every(function (rule) {
|
|
201
|
-
return rule.percentage === 0;
|
|
202
|
-
});
|
|
203
|
-
if (!disabledInEnvironment) {
|
|
204
|
-
return [2 /*return*/, "continue"];
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
// --enabledIn=<environment>
|
|
208
|
-
if (options.enabledIn &&
|
|
209
|
-
parsedFeature_1.environments &&
|
|
210
|
-
parsedFeature_1.environments[options.enabledIn]) {
|
|
211
|
-
enabledInEnvironment = parsedFeature_1.environments[options.enabledIn].rules.some(function (rule) {
|
|
212
|
-
return rule.percentage > 0;
|
|
213
|
-
});
|
|
214
|
-
if (!enabledInEnvironment) {
|
|
215
|
-
return [2 /*return*/, "continue"];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// --keyPattern=<pattern>
|
|
219
|
-
if (options.keyPattern) {
|
|
220
|
-
regex = new RegExp(options.keyPattern, "i");
|
|
221
|
-
if (!regex.test(key)) {
|
|
222
|
-
return [2 /*return*/, "continue"];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// --tag=<tag>
|
|
226
|
-
if (options.tag) {
|
|
227
|
-
tags = Array.isArray(options.tag) ? options.tag : [options.tag];
|
|
228
|
-
hasTags = tags.every(function (tag) { return parsedFeature_1.tags.includes(tag); });
|
|
229
|
-
if (!hasTags) {
|
|
230
|
-
return [2 /*return*/, "continue"];
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// --variable=<variableKey>
|
|
234
|
-
if (options.variable) {
|
|
235
|
-
lookForVariables = Array.isArray(options.variable)
|
|
236
|
-
? options.variable
|
|
237
|
-
: [options.variable];
|
|
238
|
-
variablesInFeature_1 = [];
|
|
239
|
-
if (Array.isArray(parsedFeature_1.variablesSchema)) {
|
|
240
|
-
variablesInFeature_1 = parsedFeature_1.variablesSchema.map(function (variable) { return variable.key; });
|
|
241
|
-
}
|
|
242
|
-
else if (parsedFeature_1.variablesSchema) {
|
|
243
|
-
variablesInFeature_1 = Object.keys(parsedFeature_1.variablesSchema);
|
|
244
|
-
}
|
|
245
|
-
hasVariables = lookForVariables.every(function (variable) {
|
|
246
|
-
return variablesInFeature_1.includes(variable);
|
|
247
|
-
});
|
|
248
|
-
if (!hasVariables) {
|
|
249
|
-
return [2 /*return*/, "continue"];
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
// --variation=<variationValue>
|
|
253
|
-
if (options.variation) {
|
|
254
|
-
lookForVariations = Array.isArray(options.variation)
|
|
255
|
-
? options.variation
|
|
256
|
-
: [options.variation];
|
|
257
|
-
variationsInFeature_1 = parsedFeature_1.variations
|
|
258
|
-
? parsedFeature_1.variations.map(function (v) { return v.value; })
|
|
259
|
-
: [];
|
|
260
|
-
hasVariations = lookForVariations.every(function (variation) {
|
|
261
|
-
return variationsInFeature_1.includes(variation);
|
|
262
|
-
});
|
|
263
|
-
if (!hasVariations) {
|
|
264
|
-
return [2 /*return*/, "continue"];
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (!options.withTests) return [3 /*break*/, 10];
|
|
268
|
-
return [4 /*yield*/, initializeEntitiesWithTests()];
|
|
269
|
-
case 9:
|
|
270
|
-
_b.sent();
|
|
271
|
-
if (!entitiesWithTests.features.includes(key)) {
|
|
272
|
-
return [2 /*return*/, "continue"];
|
|
273
|
-
}
|
|
274
|
-
_b.label = 10;
|
|
275
|
-
case 10:
|
|
276
|
-
// --with-variables
|
|
277
|
-
if (options.withVariables) {
|
|
278
|
-
hasVariables = parsedFeature_1.variablesSchema;
|
|
279
|
-
if (!hasVariables) {
|
|
280
|
-
return [2 /*return*/, "continue"];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// --with-variations
|
|
284
|
-
if (options.withVariations) {
|
|
285
|
-
hasVariations = parsedFeature_1.variations;
|
|
286
|
-
if (!hasVariations) {
|
|
287
|
-
return [2 /*return*/, "continue"];
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (!options.withoutTests) return [3 /*break*/, 12];
|
|
291
|
-
return [4 /*yield*/, initializeEntitiesWithTests()];
|
|
292
|
-
case 11:
|
|
293
|
-
_b.sent();
|
|
294
|
-
if (entitiesWithTests.features.includes(key)) {
|
|
295
|
-
return [2 /*return*/, "continue"];
|
|
296
|
-
}
|
|
297
|
-
_b.label = 12;
|
|
298
|
-
case 12:
|
|
299
|
-
// --without-variables
|
|
300
|
-
if (options.withoutVariables) {
|
|
301
|
-
hasVariables = parsedFeature_1.variablesSchema;
|
|
302
|
-
if (hasVariables) {
|
|
303
|
-
return [2 /*return*/, "continue"];
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
// --without-variations
|
|
307
|
-
if (options.withoutVariations) {
|
|
308
|
-
hasVariations = parsedFeature_1.variations;
|
|
309
|
-
if (hasVariations) {
|
|
310
|
-
return [2 /*return*/, "continue"];
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return [3 /*break*/, 19];
|
|
314
|
-
case 13:
|
|
315
|
-
if (!(entityType === "segment")) return [3 /*break*/, 18];
|
|
316
|
-
segment = entity;
|
|
317
|
-
// --archived=true|false
|
|
318
|
-
if (segment.archived) {
|
|
319
|
-
archivedStatus = options.archived === "false";
|
|
320
|
-
if (segment.archived !== archivedStatus) {
|
|
321
|
-
return [2 /*return*/, "continue"];
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
// --description=<pattern>
|
|
325
|
-
if (options.description) {
|
|
326
|
-
description = segment.description || "";
|
|
327
|
-
regex = new RegExp(options.description, "i");
|
|
328
|
-
if (!regex.test(description)) {
|
|
329
|
-
return [2 /*return*/, "continue"];
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
// --keyPattern=<pattern>
|
|
333
|
-
if (options.keyPattern) {
|
|
334
|
-
regex = new RegExp(options.keyPattern, "i");
|
|
335
|
-
if (!regex.test(key)) {
|
|
336
|
-
return [2 /*return*/, "continue"];
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
if (!options.withTests) return [3 /*break*/, 15];
|
|
340
|
-
return [4 /*yield*/, initializeEntitiesWithTests()];
|
|
341
|
-
case 14:
|
|
342
|
-
_b.sent();
|
|
343
|
-
if (!entitiesWithTests.segments.includes(key)) {
|
|
344
|
-
return [2 /*return*/, "continue"];
|
|
345
|
-
}
|
|
346
|
-
_b.label = 15;
|
|
347
|
-
case 15:
|
|
348
|
-
if (!options.withoutTests) return [3 /*break*/, 17];
|
|
349
|
-
return [4 /*yield*/, initializeEntitiesWithTests()];
|
|
350
|
-
case 16:
|
|
351
|
-
_b.sent();
|
|
352
|
-
if (entitiesWithTests.segments.includes(key)) {
|
|
353
|
-
return [2 /*return*/, "continue"];
|
|
354
|
-
}
|
|
355
|
-
_b.label = 17;
|
|
356
|
-
case 17: return [3 /*break*/, 19];
|
|
357
|
-
case 18:
|
|
358
|
-
if (entityType === "attribute") {
|
|
359
|
-
attribute = entity;
|
|
360
|
-
// --archived=true|false
|
|
361
|
-
if (options.archived) {
|
|
362
|
-
archivedStatus = options.archived === "false";
|
|
363
|
-
if (attribute.archived !== archivedStatus) {
|
|
364
|
-
return [2 /*return*/, "continue"];
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
// --description=<pattern>
|
|
368
|
-
if (options.description) {
|
|
369
|
-
description = attribute.description || "";
|
|
370
|
-
regex = new RegExp(options.description, "i");
|
|
371
|
-
if (!regex.test(description)) {
|
|
372
|
-
return [2 /*return*/, "continue"];
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// --keyPattern=<pattern>
|
|
376
|
-
if (options.keyPattern) {
|
|
377
|
-
regex = new RegExp(options.keyPattern, "i");
|
|
378
|
-
if (!regex.test(key)) {
|
|
379
|
-
return [2 /*return*/, "continue"];
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
else if (entityType === "test") {
|
|
384
|
-
test_2 = entity;
|
|
385
|
-
testEntityKey = test_2.feature || test_2.segment;
|
|
386
|
-
testEntityType = test_2.segment ? "segment" : "feature";
|
|
387
|
-
testAssertions = test_2.assertions;
|
|
388
|
-
// --apply-matrix
|
|
389
|
-
if (options.applyMatrix) {
|
|
390
|
-
if (testEntityType === "feature") {
|
|
391
|
-
assertionsAfterApplyingMatrix = [];
|
|
392
|
-
for (aIndex = 0; aIndex < testAssertions.length; aIndex++) {
|
|
393
|
-
processedAssertions = (0, tester_1.getFeatureAssertionsFromMatrix)(aIndex, testAssertions[aIndex]);
|
|
394
|
-
assertionsAfterApplyingMatrix =
|
|
395
|
-
assertionsAfterApplyingMatrix.concat(processedAssertions);
|
|
396
|
-
}
|
|
397
|
-
testAssertions = assertionsAfterApplyingMatrix;
|
|
398
|
-
}
|
|
399
|
-
else if (testEntityType === "segment") {
|
|
400
|
-
assertionsAfterApplyingMatrix = [];
|
|
401
|
-
for (aIndex = 0; aIndex < testAssertions.length; aIndex++) {
|
|
402
|
-
processedAssertions = (0, tester_1.getSegmentAssertionsFromMatrix)(aIndex, testAssertions[aIndex]);
|
|
403
|
-
assertionsAfterApplyingMatrix =
|
|
404
|
-
assertionsAfterApplyingMatrix.concat(processedAssertions);
|
|
405
|
-
}
|
|
406
|
-
testAssertions = assertionsAfterApplyingMatrix;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
// --keyPattern=<pattern>
|
|
410
|
-
if (options.keyPattern) {
|
|
411
|
-
regex = new RegExp(options.keyPattern, "i");
|
|
412
|
-
if (!regex.test(testEntityKey)) {
|
|
413
|
-
return [2 /*return*/, "continue"];
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
// --assertionPattern=<pattern>
|
|
417
|
-
if (options.assertionPattern) {
|
|
418
|
-
regex_1 = new RegExp(options.assertionPattern, "i");
|
|
419
|
-
testAssertions = testAssertions.filter(function (assertion) {
|
|
420
|
-
if (!assertion.description) {
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
return regex_1.test(assertion.description);
|
|
424
|
-
});
|
|
425
|
-
if (testAssertions.length === 0) {
|
|
426
|
-
return [2 /*return*/, "continue"];
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
entity.assertions = testAssertions;
|
|
430
|
-
}
|
|
431
|
-
_b.label = 19;
|
|
432
|
-
case 19:
|
|
433
|
-
result.push(__assign(__assign({}, entity), { key: key }));
|
|
434
|
-
return [2 /*return*/];
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
};
|
|
438
|
-
_i = 0, entityKeys_1 = entityKeys;
|
|
439
|
-
_a.label = 9;
|
|
440
|
-
case 9:
|
|
441
|
-
if (!(_i < entityKeys_1.length)) return [3 /*break*/, 12];
|
|
442
|
-
key = entityKeys_1[_i];
|
|
443
|
-
return [5 /*yield**/, _loop_1(key)];
|
|
444
|
-
case 10:
|
|
445
|
-
_a.sent();
|
|
446
|
-
_a.label = 11;
|
|
447
|
-
case 11:
|
|
448
|
-
_i++;
|
|
449
|
-
return [3 /*break*/, 9];
|
|
450
|
-
case 12: return [2 /*return*/, result];
|
|
299
|
+
if (testAssertions.length === 0) {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
451
302
|
}
|
|
303
|
+
entity.assertions = testAssertions;
|
|
304
|
+
}
|
|
305
|
+
result.push({
|
|
306
|
+
...entity,
|
|
307
|
+
key,
|
|
452
308
|
});
|
|
453
|
-
}
|
|
309
|
+
}
|
|
310
|
+
return result;
|
|
454
311
|
}
|
|
455
312
|
function ucfirst(str) {
|
|
456
313
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
457
314
|
}
|
|
458
|
-
function printResult(
|
|
459
|
-
var result = _a.result, entityType = _a.entityType, options = _a.options;
|
|
315
|
+
function printResult({ result, entityType, options }) {
|
|
460
316
|
if (options.json) {
|
|
461
317
|
console.log(options.pretty ? JSON.stringify(result, null, 2) : JSON.stringify(result));
|
|
462
318
|
return;
|
|
463
319
|
}
|
|
464
320
|
if (result.length === 0) {
|
|
465
|
-
console.log(
|
|
321
|
+
console.log(`No ${entityType}s found.`);
|
|
466
322
|
return;
|
|
467
323
|
}
|
|
468
|
-
console.log(
|
|
469
|
-
for (
|
|
470
|
-
|
|
471
|
-
console.log("- ".concat(item.key));
|
|
324
|
+
console.log(`\n${ucfirst(entityType)}s:\n`);
|
|
325
|
+
for (const item of result) {
|
|
326
|
+
console.log(`- ${item.key}`);
|
|
472
327
|
}
|
|
473
|
-
console.log(
|
|
328
|
+
console.log(`\n\nFound ${result.length} ${entityType}s.`);
|
|
474
329
|
}
|
|
475
|
-
function listProject(deps) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
case 1:
|
|
485
|
-
result = _a.sent();
|
|
486
|
-
return [2 /*return*/, printResult({
|
|
487
|
-
result: result,
|
|
488
|
-
entityType: "feature",
|
|
489
|
-
options: options,
|
|
490
|
-
})];
|
|
491
|
-
case 2:
|
|
492
|
-
if (!options.segments) return [3 /*break*/, 4];
|
|
493
|
-
return [4 /*yield*/, listEntities(deps, "segment")];
|
|
494
|
-
case 3:
|
|
495
|
-
result = _a.sent();
|
|
496
|
-
return [2 /*return*/, printResult({
|
|
497
|
-
result: result,
|
|
498
|
-
entityType: "segment",
|
|
499
|
-
options: options,
|
|
500
|
-
})];
|
|
501
|
-
case 4:
|
|
502
|
-
if (!options.attributes) return [3 /*break*/, 6];
|
|
503
|
-
return [4 /*yield*/, listEntities(deps, "attribute")];
|
|
504
|
-
case 5:
|
|
505
|
-
result = _a.sent();
|
|
506
|
-
return [2 /*return*/, printResult({
|
|
507
|
-
result: result,
|
|
508
|
-
entityType: "attribute",
|
|
509
|
-
options: options,
|
|
510
|
-
})];
|
|
511
|
-
case 6:
|
|
512
|
-
if (!options.tests) return [3 /*break*/, 8];
|
|
513
|
-
return [4 /*yield*/, listEntities(deps, "test")];
|
|
514
|
-
case 7:
|
|
515
|
-
result = _a.sent();
|
|
516
|
-
return [2 /*return*/, printResult({
|
|
517
|
-
result: result,
|
|
518
|
-
entityType: "test",
|
|
519
|
-
options: options,
|
|
520
|
-
})];
|
|
521
|
-
case 8:
|
|
522
|
-
console.log("\nNothing to list. \n\nPlease pass `--features`, `--segments`, or `--attributes`.");
|
|
523
|
-
return [2 /*return*/];
|
|
524
|
-
}
|
|
330
|
+
async function listProject(deps) {
|
|
331
|
+
const { options } = deps;
|
|
332
|
+
// features
|
|
333
|
+
if (options.features) {
|
|
334
|
+
const result = await listEntities(deps, "feature");
|
|
335
|
+
return printResult({
|
|
336
|
+
result,
|
|
337
|
+
entityType: "feature",
|
|
338
|
+
options,
|
|
525
339
|
});
|
|
526
|
-
}
|
|
340
|
+
}
|
|
341
|
+
// segments
|
|
342
|
+
if (options.segments) {
|
|
343
|
+
const result = await listEntities(deps, "segment");
|
|
344
|
+
return printResult({
|
|
345
|
+
result,
|
|
346
|
+
entityType: "segment",
|
|
347
|
+
options,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
// attributes
|
|
351
|
+
if (options.attributes) {
|
|
352
|
+
const result = await listEntities(deps, "attribute");
|
|
353
|
+
return printResult({
|
|
354
|
+
result,
|
|
355
|
+
entityType: "attribute",
|
|
356
|
+
options,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
// tests
|
|
360
|
+
if (options.tests) {
|
|
361
|
+
const result = await listEntities(deps, "test");
|
|
362
|
+
return printResult({
|
|
363
|
+
result,
|
|
364
|
+
entityType: "test",
|
|
365
|
+
options,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
console.log("\nNothing to list. \n\nPlease pass `--features`, `--segments`, or `--attributes`.");
|
|
527
369
|
}
|
|
528
370
|
exports.listPlugin = {
|
|
529
371
|
command: "list",
|
|
530
|
-
handler: function (
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
rootDirectoryPath: rootDirectoryPath,
|
|
537
|
-
projectConfig: projectConfig,
|
|
538
|
-
datasource: datasource,
|
|
539
|
-
options: parsed,
|
|
540
|
-
})];
|
|
541
|
-
case 1:
|
|
542
|
-
_c.sent();
|
|
543
|
-
return [2 /*return*/];
|
|
544
|
-
}
|
|
545
|
-
});
|
|
372
|
+
handler: async function ({ rootDirectoryPath, projectConfig, datasource, parsed }) {
|
|
373
|
+
await listProject({
|
|
374
|
+
rootDirectoryPath,
|
|
375
|
+
projectConfig,
|
|
376
|
+
datasource,
|
|
377
|
+
options: parsed,
|
|
546
378
|
});
|
|
547
379
|
},
|
|
548
380
|
examples: [
|