@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,528 +1,354 @@
|
|
|
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.lintPlugin = void 0;
|
|
40
4
|
exports.lintProject = lintProject;
|
|
41
5
|
// for use in node only
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
case 1:
|
|
62
|
-
entries = _a.sent();
|
|
63
|
-
authors = Array.from(new Set(entries.map(function (entry) { return entry.author; })));
|
|
64
|
-
return [2 /*return*/, authors];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const attributeSchema_1 = require("./attributeSchema");
|
|
8
|
+
const conditionSchema_1 = require("./conditionSchema");
|
|
9
|
+
const segmentSchema_1 = require("./segmentSchema");
|
|
10
|
+
const groupSchema_1 = require("./groupSchema");
|
|
11
|
+
const featureSchema_1 = require("./featureSchema");
|
|
12
|
+
const testSchema_1 = require("./testSchema");
|
|
13
|
+
const checkCircularDependency_1 = require("./checkCircularDependency");
|
|
14
|
+
const checkPercentageExceedingSlot_1 = require("./checkPercentageExceedingSlot");
|
|
15
|
+
const printError_1 = require("./printError");
|
|
16
|
+
const cliFormat_1 = require("../tester/cliFormat");
|
|
17
|
+
const ENTITY_NAME_REGEX = /^[a-zA-Z0-9_\-./]+$/;
|
|
18
|
+
const ENTITY_NAME_REGEX_ERROR = "Names must be alphanumeric and can contain _, -, and .";
|
|
19
|
+
const ATTRIBUTE_NAME_REGEX = /^[a-zA-Z0-9_\-/]+$/;
|
|
20
|
+
const ATTRIBUTE_NAME_REGEX_ERROR = "Names must be alphanumeric and can contain _, and -";
|
|
21
|
+
async function getAuthorsOfEntity(datasource, entityType, entityKey) {
|
|
22
|
+
const entries = await datasource.listHistoryEntries(entityType, entityKey);
|
|
23
|
+
const authors = Array.from(new Set(entries.map((entry) => entry.author)));
|
|
24
|
+
return authors;
|
|
68
25
|
}
|
|
69
|
-
function lintProject(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
else if (type === "segment") {
|
|
79
|
-
fullPath = path.join(projectConfig.segmentsDirectoryPath, fileName);
|
|
80
|
-
}
|
|
81
|
-
else if (type === "feature") {
|
|
82
|
-
fullPath = path.join(projectConfig.featuresDirectoryPath, fileName);
|
|
83
|
-
}
|
|
84
|
-
else if (type === "group") {
|
|
85
|
-
fullPath = path.join(projectConfig.groupsDirectoryPath, fileName);
|
|
86
|
-
}
|
|
87
|
-
else if (type === "test") {
|
|
88
|
-
fullPath = path.join(projectConfig.testsDirectoryPath, fileName);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
throw new Error("Unknown type: ".concat(type));
|
|
92
|
-
}
|
|
93
|
-
if (relative) {
|
|
94
|
-
fullPath = path.relative(process.cwd(), fullPath);
|
|
95
|
-
}
|
|
96
|
-
return fullPath;
|
|
26
|
+
async function lintProject(deps, options = {}) {
|
|
27
|
+
const { projectConfig, datasource } = deps;
|
|
28
|
+
let hasError = false;
|
|
29
|
+
function getFullPathFromKey(type, key, relative = false) {
|
|
30
|
+
const fileName = `${key}.${datasource.getExtension()}`;
|
|
31
|
+
let fullPath = "";
|
|
32
|
+
if (type === "attribute") {
|
|
33
|
+
fullPath = path.join(projectConfig.attributesDirectoryPath, fileName);
|
|
97
34
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
35
|
+
else if (type === "segment") {
|
|
36
|
+
fullPath = path.join(projectConfig.segmentsDirectoryPath, fileName);
|
|
37
|
+
}
|
|
38
|
+
else if (type === "feature") {
|
|
39
|
+
fullPath = path.join(projectConfig.featuresDirectoryPath, fileName);
|
|
40
|
+
}
|
|
41
|
+
else if (type === "group") {
|
|
42
|
+
fullPath = path.join(projectConfig.groupsDirectoryPath, fileName);
|
|
43
|
+
}
|
|
44
|
+
else if (type === "test") {
|
|
45
|
+
fullPath = path.join(projectConfig.testsDirectoryPath, fileName);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error(`Unknown type: ${type}`);
|
|
49
|
+
}
|
|
50
|
+
if (relative) {
|
|
51
|
+
fullPath = path.relative(process.cwd(), fullPath);
|
|
52
|
+
}
|
|
53
|
+
return fullPath;
|
|
54
|
+
}
|
|
55
|
+
const keyPattern = options.keyPattern ? new RegExp(options.keyPattern) : null;
|
|
56
|
+
if (keyPattern) {
|
|
57
|
+
console.log("");
|
|
58
|
+
console.log(`Linting only keys matching pattern: ${keyPattern}`);
|
|
59
|
+
console.log("");
|
|
60
|
+
}
|
|
61
|
+
// lint attributes
|
|
62
|
+
const attributes = await datasource.listAttributes();
|
|
63
|
+
const attributeZodSchema = (0, attributeSchema_1.getAttributeZodSchema)();
|
|
64
|
+
if (!options.entityType || options.entityType === "attribute") {
|
|
65
|
+
const filteredKeys = !keyPattern
|
|
66
|
+
? attributes
|
|
67
|
+
: attributes.filter((key) => keyPattern.test(key));
|
|
68
|
+
if (filteredKeys.length > 0) {
|
|
69
|
+
console.log(`Linting ${filteredKeys.length} attributes...\n`);
|
|
70
|
+
}
|
|
71
|
+
for (const key of filteredKeys) {
|
|
72
|
+
const fullPath = getFullPathFromKey("attribute", key);
|
|
73
|
+
if (!ATTRIBUTE_NAME_REGEX.test(key)) {
|
|
74
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
75
|
+
if (options.authors) {
|
|
76
|
+
const authors = await getAuthorsOfEntity(datasource, "attribute", key);
|
|
77
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
78
|
+
}
|
|
79
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` => Error: Invalid name: "${key}"`);
|
|
80
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` ${ATTRIBUTE_NAME_REGEX_ERROR}`);
|
|
81
|
+
console.log("");
|
|
82
|
+
hasError = true;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const parsed = await datasource.readAttribute(key);
|
|
86
|
+
const result = attributeZodSchema.safeParse(parsed);
|
|
87
|
+
if (!result.success) {
|
|
149
88
|
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
155
|
-
_e.label = 8;
|
|
156
|
-
case 8:
|
|
89
|
+
if (options.authors) {
|
|
90
|
+
const authors = await getAuthorsOfEntity(datasource, "attribute", key);
|
|
91
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
92
|
+
}
|
|
157
93
|
if ("error" in result) {
|
|
158
94
|
(0, printError_1.printZodError)(result.error);
|
|
159
95
|
}
|
|
160
96
|
hasError = true;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
101
|
+
if (options.authors) {
|
|
102
|
+
const authors = await getAuthorsOfEntity(datasource, "attribute", key);
|
|
103
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
104
|
+
}
|
|
105
|
+
console.log("");
|
|
106
|
+
console.log(e);
|
|
107
|
+
hasError = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const flattenedAttributes = await datasource.listFlattenedAttributes();
|
|
112
|
+
// lint segments
|
|
113
|
+
const segments = await datasource.listSegments();
|
|
114
|
+
const conditionsZodSchema = (0, conditionSchema_1.getConditionsZodSchema)(projectConfig, flattenedAttributes);
|
|
115
|
+
const segmentZodSchema = (0, segmentSchema_1.getSegmentZodSchema)(projectConfig, conditionsZodSchema);
|
|
116
|
+
if (!options.entityType || options.entityType === "segment") {
|
|
117
|
+
const filteredKeys = !keyPattern ? segments : segments.filter((key) => keyPattern.test(key));
|
|
118
|
+
if (filteredKeys.length > 0) {
|
|
119
|
+
console.log(`Linting ${filteredKeys.length} segments...\n`);
|
|
120
|
+
}
|
|
121
|
+
for (const key of filteredKeys) {
|
|
122
|
+
const fullPath = getFullPathFromKey("segment", key);
|
|
123
|
+
if (!ENTITY_NAME_REGEX.test(key)) {
|
|
124
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
125
|
+
if (options.authors) {
|
|
126
|
+
const authors = await getAuthorsOfEntity(datasource, "segment", key);
|
|
127
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
128
|
+
}
|
|
129
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` => Error: Invalid name: "${key}"`);
|
|
130
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` ${ENTITY_NAME_REGEX_ERROR}`);
|
|
131
|
+
console.log("");
|
|
132
|
+
hasError = true;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const parsed = await datasource.readSegment(key);
|
|
136
|
+
const result = segmentZodSchema.safeParse(parsed);
|
|
137
|
+
if (!result.success) {
|
|
165
138
|
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
authors = _e.sent();
|
|
170
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
171
|
-
_e.label = 12;
|
|
172
|
-
case 12:
|
|
173
|
-
console.log("");
|
|
174
|
-
console.log(e_1);
|
|
175
|
-
hasError = true;
|
|
176
|
-
return [3 /*break*/, 13];
|
|
177
|
-
case 13:
|
|
178
|
-
_i++;
|
|
179
|
-
return [3 /*break*/, 2];
|
|
180
|
-
case 14: return [4 /*yield*/, datasource.listSegments()];
|
|
181
|
-
case 15:
|
|
182
|
-
segments = _e.sent();
|
|
183
|
-
conditionsZodSchema = (0, conditionSchema_1.getConditionsZodSchema)(projectConfig, attributes);
|
|
184
|
-
segmentZodSchema = (0, segmentSchema_1.getSegmentZodSchema)(projectConfig, conditionsZodSchema);
|
|
185
|
-
if (!(!options.entityType || options.entityType === "segment")) return [3 /*break*/, 28];
|
|
186
|
-
filteredKeys = !keyPattern ? segments : segments.filter(function (key) { return keyPattern.test(key); });
|
|
187
|
-
if (filteredKeys.length > 0) {
|
|
188
|
-
console.log("Linting ".concat(filteredKeys.length, " segments...\n"));
|
|
139
|
+
if (options.authors) {
|
|
140
|
+
const authors = await getAuthorsOfEntity(datasource, "segment", key);
|
|
141
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
189
142
|
}
|
|
190
|
-
_a = 0, filteredKeys_2 = filteredKeys;
|
|
191
|
-
_e.label = 16;
|
|
192
|
-
case 16:
|
|
193
|
-
if (!(_a < filteredKeys_2.length)) return [3 /*break*/, 28];
|
|
194
|
-
key = filteredKeys_2[_a];
|
|
195
|
-
fullPath = getFullPathFromKey("segment", key);
|
|
196
|
-
if (!!ENTITY_NAME_REGEX.test(key)) return [3 /*break*/, 19];
|
|
197
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
198
|
-
if (!options.authors) return [3 /*break*/, 18];
|
|
199
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "segment", key)];
|
|
200
|
-
case 17:
|
|
201
|
-
authors = _e.sent();
|
|
202
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
203
|
-
_e.label = 18;
|
|
204
|
-
case 18:
|
|
205
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " => Error: Invalid name: \"".concat(key, "\""));
|
|
206
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " ".concat(ENTITY_NAME_REGEX_ERROR));
|
|
207
|
-
console.log("");
|
|
208
|
-
hasError = true;
|
|
209
|
-
_e.label = 19;
|
|
210
|
-
case 19:
|
|
211
|
-
_e.trys.push([19, 24, , 27]);
|
|
212
|
-
return [4 /*yield*/, datasource.readSegment(key)];
|
|
213
|
-
case 20:
|
|
214
|
-
parsed = _e.sent();
|
|
215
|
-
result = segmentZodSchema.safeParse(parsed);
|
|
216
|
-
if (!!result.success) return [3 /*break*/, 23];
|
|
217
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
218
|
-
if (!options.authors) return [3 /*break*/, 22];
|
|
219
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "segment", key)];
|
|
220
|
-
case 21:
|
|
221
|
-
authors = _e.sent();
|
|
222
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
223
|
-
_e.label = 22;
|
|
224
|
-
case 22:
|
|
225
143
|
if ("error" in result) {
|
|
226
144
|
(0, printError_1.printZodError)(result.error);
|
|
227
145
|
}
|
|
228
146
|
hasError = true;
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
151
|
+
if (options.authors) {
|
|
152
|
+
const authors = await getAuthorsOfEntity(datasource, "segment", key);
|
|
153
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
154
|
+
}
|
|
155
|
+
console.log("");
|
|
156
|
+
console.log(e);
|
|
157
|
+
hasError = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// lint features
|
|
162
|
+
const features = await datasource.listFeatures();
|
|
163
|
+
const featureZodSchema = (0, featureSchema_1.getFeatureZodSchema)(projectConfig, conditionsZodSchema, flattenedAttributes, segments, features);
|
|
164
|
+
if (!options.entityType || options.entityType === "feature") {
|
|
165
|
+
const filteredKeys = !keyPattern ? features : features.filter((key) => keyPattern.test(key));
|
|
166
|
+
if (filteredKeys.length > 0) {
|
|
167
|
+
console.log(`Linting ${filteredKeys.length} features...\n`);
|
|
168
|
+
}
|
|
169
|
+
for (const key of filteredKeys) {
|
|
170
|
+
const fullPath = getFullPathFromKey("feature", key);
|
|
171
|
+
if (!ENTITY_NAME_REGEX.test(key)) {
|
|
172
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
173
|
+
if (options.authors) {
|
|
174
|
+
const authors = await getAuthorsOfEntity(datasource, "feature", key);
|
|
175
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
176
|
+
}
|
|
177
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` => Error: Invalid name: "${key}"`);
|
|
178
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` ${ENTITY_NAME_REGEX_ERROR}`);
|
|
179
|
+
console.log("");
|
|
180
|
+
hasError = true;
|
|
181
|
+
}
|
|
182
|
+
let parsed;
|
|
183
|
+
try {
|
|
184
|
+
parsed = await datasource.readFeature(key);
|
|
185
|
+
const result = featureZodSchema.safeParse(parsed);
|
|
186
|
+
if (!result.success) {
|
|
233
187
|
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
authors = _e.sent();
|
|
238
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
239
|
-
_e.label = 26;
|
|
240
|
-
case 26:
|
|
241
|
-
console.log("");
|
|
242
|
-
console.log(e_2);
|
|
243
|
-
hasError = true;
|
|
244
|
-
return [3 /*break*/, 27];
|
|
245
|
-
case 27:
|
|
246
|
-
_a++;
|
|
247
|
-
return [3 /*break*/, 16];
|
|
248
|
-
case 28: return [4 /*yield*/, datasource.listFeatures()];
|
|
249
|
-
case 29:
|
|
250
|
-
features = _e.sent();
|
|
251
|
-
featureZodSchema = (0, featureSchema_1.getFeatureZodSchema)(projectConfig, conditionsZodSchema, attributes, segments, features);
|
|
252
|
-
if (!(!options.entityType || options.entityType === "feature")) return [3 /*break*/, 49];
|
|
253
|
-
filteredKeys = !keyPattern ? features : features.filter(function (key) { return keyPattern.test(key); });
|
|
254
|
-
if (filteredKeys.length > 0) {
|
|
255
|
-
console.log("Linting ".concat(filteredKeys.length, " features...\n"));
|
|
188
|
+
if (options.authors) {
|
|
189
|
+
const authors = await getAuthorsOfEntity(datasource, "feature", key);
|
|
190
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
256
191
|
}
|
|
257
|
-
_b = 0, filteredKeys_3 = filteredKeys;
|
|
258
|
-
_e.label = 30;
|
|
259
|
-
case 30:
|
|
260
|
-
if (!(_b < filteredKeys_3.length)) return [3 /*break*/, 49];
|
|
261
|
-
key = filteredKeys_3[_b];
|
|
262
|
-
fullPath = getFullPathFromKey("feature", key);
|
|
263
|
-
if (!!ENTITY_NAME_REGEX.test(key)) return [3 /*break*/, 33];
|
|
264
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
265
|
-
if (!options.authors) return [3 /*break*/, 32];
|
|
266
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "feature", key)];
|
|
267
|
-
case 31:
|
|
268
|
-
authors = _e.sent();
|
|
269
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
270
|
-
_e.label = 32;
|
|
271
|
-
case 32:
|
|
272
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " => Error: Invalid name: \"".concat(key, "\""));
|
|
273
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " ".concat(ENTITY_NAME_REGEX_ERROR));
|
|
274
|
-
console.log("");
|
|
275
|
-
hasError = true;
|
|
276
|
-
_e.label = 33;
|
|
277
|
-
case 33:
|
|
278
|
-
parsed = void 0;
|
|
279
|
-
_e.label = 34;
|
|
280
|
-
case 34:
|
|
281
|
-
_e.trys.push([34, 39, , 42]);
|
|
282
|
-
return [4 /*yield*/, datasource.readFeature(key)];
|
|
283
|
-
case 35:
|
|
284
|
-
parsed = _e.sent();
|
|
285
|
-
result = featureZodSchema.safeParse(parsed);
|
|
286
|
-
if (!!result.success) return [3 /*break*/, 38];
|
|
287
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
288
|
-
if (!options.authors) return [3 /*break*/, 37];
|
|
289
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "feature", key)];
|
|
290
|
-
case 36:
|
|
291
|
-
authors = _e.sent();
|
|
292
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
293
|
-
_e.label = 37;
|
|
294
|
-
case 37:
|
|
295
192
|
if ("error" in result) {
|
|
296
193
|
(0, printError_1.printZodError)(result.error);
|
|
297
194
|
}
|
|
298
195
|
hasError = true;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (!(parsed && parsed.required)) return [3 /*break*/, 48];
|
|
317
|
-
_e.label = 43;
|
|
318
|
-
case 43:
|
|
319
|
-
_e.trys.push([43, 45, , 48]);
|
|
320
|
-
return [4 /*yield*/, (0, checkCircularDependency_1.checkForCircularDependencyInRequired)(datasource, key, parsed.required)];
|
|
321
|
-
case 44:
|
|
322
|
-
_e.sent();
|
|
323
|
-
return [3 /*break*/, 48];
|
|
324
|
-
case 45:
|
|
325
|
-
e_4 = _e.sent();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
200
|
+
if (options.authors) {
|
|
201
|
+
const authors = await getAuthorsOfEntity(datasource, "feature", key);
|
|
202
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
203
|
+
}
|
|
204
|
+
console.log("");
|
|
205
|
+
console.log(e);
|
|
206
|
+
hasError = true;
|
|
207
|
+
}
|
|
208
|
+
if (parsed && parsed.required) {
|
|
209
|
+
try {
|
|
210
|
+
await (0, checkCircularDependency_1.checkForCircularDependencyInRequired)(datasource, key, parsed.required);
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
326
213
|
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
327
|
-
if (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
authors = _e.sent();
|
|
331
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
332
|
-
_e.label = 47;
|
|
333
|
-
case 47:
|
|
334
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " => Error: ".concat(e_4.message));
|
|
335
|
-
hasError = true;
|
|
336
|
-
return [3 /*break*/, 48];
|
|
337
|
-
case 48:
|
|
338
|
-
_b++;
|
|
339
|
-
return [3 /*break*/, 30];
|
|
340
|
-
case 49: return [4 /*yield*/, datasource.listGroups()];
|
|
341
|
-
case 50:
|
|
342
|
-
groups = _e.sent();
|
|
343
|
-
groupZodSchema = (0, groupSchema_1.getGroupZodSchema)(projectConfig, datasource, features);
|
|
344
|
-
if (!(!options.entityType || options.entityType === "group")) return [3 /*break*/, 68];
|
|
345
|
-
filteredKeys = !keyPattern ? groups : groups.filter(function (key) { return keyPattern.test(key); });
|
|
346
|
-
if (filteredKeys.length > 0) {
|
|
347
|
-
console.log("Linting ".concat(filteredKeys.length, " groups...\n"));
|
|
214
|
+
if (options.authors) {
|
|
215
|
+
const authors = await getAuthorsOfEntity(datasource, "feature", key);
|
|
216
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
348
217
|
}
|
|
349
|
-
|
|
350
|
-
_e.label = 51;
|
|
351
|
-
case 51:
|
|
352
|
-
if (!(_c < filteredKeys_4.length)) return [3 /*break*/, 68];
|
|
353
|
-
key = filteredKeys_4[_c];
|
|
354
|
-
fullPath = getFullPathFromKey("group", key);
|
|
355
|
-
if (!!ENTITY_NAME_REGEX.test(key)) return [3 /*break*/, 54];
|
|
356
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
357
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " => Error: Invalid name: \"".concat(key, "\""));
|
|
358
|
-
if (!options.authors) return [3 /*break*/, 53];
|
|
359
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "group", key)];
|
|
360
|
-
case 52:
|
|
361
|
-
authors = _e.sent();
|
|
362
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
363
|
-
_e.label = 53;
|
|
364
|
-
case 53:
|
|
365
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " ".concat(ENTITY_NAME_REGEX_ERROR));
|
|
366
|
-
console.log("");
|
|
218
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` => Error: ${e.message}`);
|
|
367
219
|
hasError = true;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// lint groups
|
|
225
|
+
const groups = await datasource.listGroups();
|
|
226
|
+
const groupZodSchema = (0, groupSchema_1.getGroupZodSchema)(projectConfig, datasource, features);
|
|
227
|
+
if (!options.entityType || options.entityType === "group") {
|
|
228
|
+
const filteredKeys = !keyPattern ? groups : groups.filter((key) => keyPattern.test(key));
|
|
229
|
+
if (filteredKeys.length > 0) {
|
|
230
|
+
console.log(`Linting ${filteredKeys.length} groups...\n`);
|
|
231
|
+
}
|
|
232
|
+
for (const key of filteredKeys) {
|
|
233
|
+
const fullPath = getFullPathFromKey("group", key);
|
|
234
|
+
if (!ENTITY_NAME_REGEX.test(key)) {
|
|
235
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
236
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` => Error: Invalid name: "${key}"`);
|
|
237
|
+
if (options.authors) {
|
|
238
|
+
const authors = await getAuthorsOfEntity(datasource, "group", key);
|
|
239
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
240
|
+
}
|
|
241
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` ${ENTITY_NAME_REGEX_ERROR}`);
|
|
242
|
+
console.log("");
|
|
243
|
+
hasError = true;
|
|
244
|
+
}
|
|
245
|
+
let parsed;
|
|
246
|
+
try {
|
|
247
|
+
parsed = await datasource.readGroup(key);
|
|
248
|
+
const result = groupZodSchema.safeParse(parsed);
|
|
249
|
+
if (!result.success) {
|
|
379
250
|
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
380
|
-
if (
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
385
|
-
_e.label = 58;
|
|
386
|
-
case 58:
|
|
251
|
+
if (options.authors) {
|
|
252
|
+
const authors = await getAuthorsOfEntity(datasource, "group", key);
|
|
253
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
254
|
+
}
|
|
387
255
|
if ("error" in result) {
|
|
388
256
|
(0, printError_1.printZodError)(result.error);
|
|
389
257
|
}
|
|
390
258
|
hasError = true;
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
263
|
+
if (options.authors) {
|
|
264
|
+
const authors = await getAuthorsOfEntity(datasource, "group", key);
|
|
265
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
266
|
+
}
|
|
267
|
+
console.log("");
|
|
268
|
+
console.log(e);
|
|
269
|
+
hasError = true;
|
|
270
|
+
}
|
|
271
|
+
if (parsed) {
|
|
272
|
+
try {
|
|
273
|
+
await (0, checkPercentageExceedingSlot_1.checkForFeatureExceedingGroupSlotPercentage)(datasource, parsed, features);
|
|
274
|
+
}
|
|
275
|
+
catch (e) {
|
|
395
276
|
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
396
|
-
|
|
397
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "group", key)];
|
|
398
|
-
case 61:
|
|
399
|
-
authors = _e.sent();
|
|
400
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
401
|
-
_e.label = 62;
|
|
402
|
-
case 62:
|
|
403
|
-
console.log("");
|
|
404
|
-
console.log(e_5);
|
|
277
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` => Error: ${e.message}`);
|
|
405
278
|
hasError = true;
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// @TODO: feature cannot exist in multiple groups
|
|
284
|
+
// lint tests
|
|
285
|
+
const tests = await datasource.listTests();
|
|
286
|
+
const testsZodSchema = (0, testSchema_1.getTestsZodSchema)(projectConfig, features, segments);
|
|
287
|
+
if (!options.entityType || options.entityType === "test") {
|
|
288
|
+
const filteredKeys = !keyPattern ? tests : tests.filter((key) => keyPattern.test(key));
|
|
289
|
+
if (filteredKeys.length > 0) {
|
|
290
|
+
console.log(`Linting ${filteredKeys.length} tests...\n`);
|
|
291
|
+
}
|
|
292
|
+
for (const key of filteredKeys) {
|
|
293
|
+
const fullPath = getFullPathFromKey("test", key);
|
|
294
|
+
if (!ENTITY_NAME_REGEX.test(key)) {
|
|
295
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
296
|
+
if (options.authors) {
|
|
297
|
+
const authors = await getAuthorsOfEntity(datasource, "test", key);
|
|
298
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
299
|
+
}
|
|
300
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` => Error: Invalid name: "${key}"`);
|
|
301
|
+
console.log(cliFormat_1.CLI_FORMAT_RED, ` ${ENTITY_NAME_REGEX_ERROR}`);
|
|
302
|
+
console.log("");
|
|
303
|
+
hasError = true;
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
const parsed = await datasource.readTest(key);
|
|
307
|
+
const result = testsZodSchema.safeParse(parsed);
|
|
308
|
+
if (!result.success) {
|
|
418
309
|
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
case 67:
|
|
423
|
-
_c++;
|
|
424
|
-
return [3 /*break*/, 51];
|
|
425
|
-
case 68: return [4 /*yield*/, datasource.listTests()];
|
|
426
|
-
case 69:
|
|
427
|
-
tests = _e.sent();
|
|
428
|
-
testsZodSchema = (0, testSchema_1.getTestsZodSchema)(projectConfig, features, segments);
|
|
429
|
-
if (!(!options.entityType || options.entityType === "test")) return [3 /*break*/, 82];
|
|
430
|
-
filteredKeys = !keyPattern ? tests : tests.filter(function (key) { return keyPattern.test(key); });
|
|
431
|
-
if (filteredKeys.length > 0) {
|
|
432
|
-
console.log("Linting ".concat(filteredKeys.length, " tests...\n"));
|
|
310
|
+
if (options.authors) {
|
|
311
|
+
const authors = await getAuthorsOfEntity(datasource, "test", key);
|
|
312
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
433
313
|
}
|
|
434
|
-
_d = 0, filteredKeys_5 = filteredKeys;
|
|
435
|
-
_e.label = 70;
|
|
436
|
-
case 70:
|
|
437
|
-
if (!(_d < filteredKeys_5.length)) return [3 /*break*/, 82];
|
|
438
|
-
key = filteredKeys_5[_d];
|
|
439
|
-
fullPath = getFullPathFromKey("test", key);
|
|
440
|
-
if (!!ENTITY_NAME_REGEX.test(key)) return [3 /*break*/, 73];
|
|
441
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
442
|
-
if (!options.authors) return [3 /*break*/, 72];
|
|
443
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "test", key)];
|
|
444
|
-
case 71:
|
|
445
|
-
authors = _e.sent();
|
|
446
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
447
|
-
_e.label = 72;
|
|
448
|
-
case 72:
|
|
449
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " => Error: Invalid name: \"".concat(key, "\""));
|
|
450
|
-
console.log(cliFormat_1.CLI_FORMAT_RED, " ".concat(ENTITY_NAME_REGEX_ERROR));
|
|
451
|
-
console.log("");
|
|
452
|
-
hasError = true;
|
|
453
|
-
_e.label = 73;
|
|
454
|
-
case 73:
|
|
455
|
-
_e.trys.push([73, 78, , 81]);
|
|
456
|
-
return [4 /*yield*/, datasource.readTest(key)];
|
|
457
|
-
case 74:
|
|
458
|
-
parsed = _e.sent();
|
|
459
|
-
result = testsZodSchema.safeParse(parsed);
|
|
460
|
-
if (!!result.success) return [3 /*break*/, 77];
|
|
461
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
462
|
-
if (!options.authors) return [3 /*break*/, 76];
|
|
463
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "test", key)];
|
|
464
|
-
case 75:
|
|
465
|
-
authors = _e.sent();
|
|
466
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
467
|
-
_e.label = 76;
|
|
468
|
-
case 76:
|
|
469
314
|
if ("error" in result) {
|
|
470
315
|
(0, printError_1.printZodError)(result.error);
|
|
471
316
|
process.exit(1);
|
|
472
317
|
}
|
|
473
318
|
hasError = true;
|
|
474
|
-
|
|
475
|
-
case 77: return [3 /*break*/, 81];
|
|
476
|
-
case 78:
|
|
477
|
-
e_7 = _e.sent();
|
|
478
|
-
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
479
|
-
if (!options.authors) return [3 /*break*/, 80];
|
|
480
|
-
return [4 /*yield*/, getAuthorsOfEntity(datasource, "test", key)];
|
|
481
|
-
case 79:
|
|
482
|
-
authors = _e.sent();
|
|
483
|
-
console.log(" Authors: ".concat(authors.join(", "), "\n"));
|
|
484
|
-
_e.label = 80;
|
|
485
|
-
case 80:
|
|
486
|
-
console.log("");
|
|
487
|
-
console.log(e_7);
|
|
488
|
-
hasError = true;
|
|
489
|
-
return [3 /*break*/, 81];
|
|
490
|
-
case 81:
|
|
491
|
-
_d++;
|
|
492
|
-
return [3 /*break*/, 70];
|
|
493
|
-
case 82: return [2 /*return*/, hasError];
|
|
319
|
+
}
|
|
494
320
|
}
|
|
495
|
-
|
|
496
|
-
|
|
321
|
+
catch (e) {
|
|
322
|
+
console.log(cliFormat_1.CLI_FORMAT_BOLD_UNDERLINE, fullPath);
|
|
323
|
+
if (options.authors) {
|
|
324
|
+
const authors = await getAuthorsOfEntity(datasource, "test", key);
|
|
325
|
+
console.log(` Authors: ${authors.join(", ")}\n`);
|
|
326
|
+
}
|
|
327
|
+
console.log("");
|
|
328
|
+
console.log(e);
|
|
329
|
+
hasError = true;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return hasError;
|
|
497
334
|
}
|
|
498
335
|
exports.lintPlugin = {
|
|
499
336
|
command: "lint",
|
|
500
|
-
handler: function (options) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
options: parsed,
|
|
512
|
-
}, {
|
|
513
|
-
keyPattern: parsed.keyPattern,
|
|
514
|
-
entityType: parsed.entityType,
|
|
515
|
-
authors: parsed.authors,
|
|
516
|
-
})];
|
|
517
|
-
case 1:
|
|
518
|
-
hasError = _a.sent();
|
|
519
|
-
if (hasError) {
|
|
520
|
-
return [2 /*return*/, false];
|
|
521
|
-
}
|
|
522
|
-
return [2 /*return*/];
|
|
523
|
-
}
|
|
524
|
-
});
|
|
337
|
+
handler: async function (options) {
|
|
338
|
+
const { rootDirectoryPath, projectConfig, datasource, parsed } = options;
|
|
339
|
+
const hasError = await lintProject({
|
|
340
|
+
rootDirectoryPath,
|
|
341
|
+
projectConfig,
|
|
342
|
+
datasource,
|
|
343
|
+
options: parsed,
|
|
344
|
+
}, {
|
|
345
|
+
keyPattern: parsed.keyPattern,
|
|
346
|
+
entityType: parsed.entityType,
|
|
347
|
+
authors: parsed.authors,
|
|
525
348
|
});
|
|
349
|
+
if (hasError) {
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
526
352
|
},
|
|
527
353
|
examples: [
|
|
528
354
|
{
|
|
@@ -547,7 +373,7 @@ exports.lintPlugin = {
|
|
|
547
373
|
},
|
|
548
374
|
{
|
|
549
375
|
command: 'lint --keyPattern="abc"',
|
|
550
|
-
description:
|
|
376
|
+
description: `lint only entities with keys containing "abc"`,
|
|
551
377
|
},
|
|
552
378
|
],
|
|
553
379
|
};
|