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