@featurevisor/core 0.53.2 → 0.53.3

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.
Files changed (77) hide show
  1. package/.eslintcache +1 -1
  2. package/CHANGELOG.md +8 -0
  3. package/coverage/clover.xml +2 -2
  4. package/coverage/lcov-report/index.html +1 -1
  5. package/coverage/lcov-report/lib/builder/allocator.js.html +1 -1
  6. package/coverage/lcov-report/lib/builder/index.html +1 -1
  7. package/coverage/lcov-report/lib/builder/traffic.js.html +1 -1
  8. package/coverage/lcov-report/src/builder/allocator.ts.html +1 -1
  9. package/coverage/lcov-report/src/builder/index.html +1 -1
  10. package/coverage/lcov-report/src/builder/traffic.ts.html +1 -1
  11. package/lib/builder/buildDatafile.d.ts +1 -1
  12. package/lib/builder/buildDatafile.js +241 -168
  13. package/lib/builder/buildDatafile.js.map +1 -1
  14. package/lib/builder/buildProject.d.ts +1 -1
  15. package/lib/builder/buildProject.js +99 -40
  16. package/lib/builder/buildProject.js.map +1 -1
  17. package/lib/builder/getFeatureRanges.d.ts +1 -1
  18. package/lib/builder/getFeatureRanges.js +92 -31
  19. package/lib/builder/getFeatureRanges.js.map +1 -1
  20. package/lib/datasource/datasource.d.ts +16 -16
  21. package/lib/datasource/datasource.js +123 -67
  22. package/lib/datasource/datasource.js.map +1 -1
  23. package/lib/find-duplicate-segments/findDuplicateSegments.d.ts +1 -1
  24. package/lib/find-duplicate-segments/findDuplicateSegments.js +75 -18
  25. package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
  26. package/lib/find-duplicate-segments/index.d.ts +1 -1
  27. package/lib/find-duplicate-segments/index.js +56 -9
  28. package/lib/find-duplicate-segments/index.js.map +1 -1
  29. package/lib/generate-code/index.d.ts +1 -1
  30. package/lib/generate-code/index.js +67 -23
  31. package/lib/generate-code/index.js.map +1 -1
  32. package/lib/generate-code/typescript.d.ts +1 -1
  33. package/lib/generate-code/typescript.js +139 -72
  34. package/lib/generate-code/typescript.js.map +1 -1
  35. package/lib/linter/checkCircularDependency.d.ts +1 -1
  36. package/lib/linter/checkCircularDependency.js +78 -22
  37. package/lib/linter/checkCircularDependency.js.map +1 -1
  38. package/lib/linter/groupSchema.js +79 -28
  39. package/lib/linter/groupSchema.js.map +1 -1
  40. package/lib/linter/lintProject.js +122 -101
  41. package/lib/linter/lintProject.js.map +1 -1
  42. package/lib/restore.d.ts +1 -1
  43. package/lib/restore.js +53 -11
  44. package/lib/restore.js.map +1 -1
  45. package/lib/site/exportSite.d.ts +1 -1
  46. package/lib/site/exportSite.js +64 -21
  47. package/lib/site/exportSite.js.map +1 -1
  48. package/lib/site/generateSiteSearchIndex.d.ts +1 -1
  49. package/lib/site/generateSiteSearchIndex.js +203 -111
  50. package/lib/site/generateSiteSearchIndex.js.map +1 -1
  51. package/lib/tester/testFeature.d.ts +1 -1
  52. package/lib/tester/testFeature.js +127 -59
  53. package/lib/tester/testFeature.js.map +1 -1
  54. package/lib/tester/testProject.d.ts +1 -1
  55. package/lib/tester/testProject.js +105 -48
  56. package/lib/tester/testProject.js.map +1 -1
  57. package/lib/tester/testSegment.d.ts +1 -1
  58. package/lib/tester/testSegment.js +69 -21
  59. package/lib/tester/testSegment.js.map +1 -1
  60. package/package.json +2 -2
  61. package/src/builder/buildDatafile.ts +9 -9
  62. package/src/builder/buildProject.ts +2 -2
  63. package/src/builder/getFeatureRanges.ts +4 -4
  64. package/src/datasource/datasource.ts +22 -69
  65. package/src/find-duplicate-segments/findDuplicateSegments.ts +9 -6
  66. package/src/find-duplicate-segments/index.ts +5 -2
  67. package/src/generate-code/index.ts +2 -2
  68. package/src/generate-code/typescript.ts +42 -25
  69. package/src/linter/checkCircularDependency.ts +4 -4
  70. package/src/linter/groupSchema.ts +3 -3
  71. package/src/linter/lintProject.ts +39 -39
  72. package/src/restore.ts +1 -1
  73. package/src/site/exportSite.ts +2 -2
  74. package/src/site/generateSiteSearchIndex.ts +14 -14
  75. package/src/tester/testFeature.ts +8 -6
  76. package/src/tester/testProject.ts +8 -5
  77. package/src/tester/testSegment.ts +3 -3
@@ -1,4 +1,40 @@
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;
13
+ return g = { next: verb(0), "throw": verb(1), "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
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.testFeature = void 0;
4
40
  var fs = require("fs");
@@ -9,67 +45,99 @@ var checkIfArraysAreEqual_1 = require("./checkIfArraysAreEqual");
9
45
  var checkIfObjectsAreEqual_1 = require("./checkIfObjectsAreEqual");
10
46
  var cliFormat_1 = require("./cliFormat");
11
47
  function testFeature(datasource, projectConfig, test) {
12
- var hasError = false;
13
- var featureKey = test.feature;
14
- console.log(cliFormat_1.CLI_FORMAT_BOLD, " Feature \"".concat(featureKey, "\":"));
15
- test.assertions.forEach(function (assertion, aIndex) {
16
- var description = assertion.description || "at ".concat(assertion.at, "%");
17
- console.log(" Assertion #".concat(aIndex + 1, ": (").concat(assertion.environment, ") ").concat(description));
18
- var featuresToInclude = Array.from(datasource.getRequiredFeaturesChain(test.feature));
19
- var datafileContent = (0, builder_1.buildDatafile)(projectConfig, datasource, {
20
- schemaVersion: config_1.SCHEMA_VERSION,
21
- revision: "testing",
22
- environment: assertion.environment,
23
- features: featuresToInclude,
24
- }, JSON.parse(fs.readFileSync((0, builder_1.getExistingStateFilePath)(projectConfig, assertion.environment), "utf8")));
25
- var sdk = (0, sdk_1.createInstance)({
26
- datafile: datafileContent,
27
- configureBucketValue: function () {
28
- return assertion.at * (sdk_1.MAX_BUCKETED_NUMBER / 100);
29
- },
30
- // logger: createLogger({
31
- // levels: ["debug", "info", "warn", "error"],
32
- // }),
33
- });
34
- // isEnabled
35
- if ("expectedToBeEnabled" in assertion) {
36
- var isEnabled = sdk.isEnabled(featureKey, assertion.context);
37
- if (isEnabled !== assertion.expectedToBeEnabled) {
38
- hasError = true;
39
- console.error(cliFormat_1.CLI_FORMAT_RED, " isEnabled failed: expected \"".concat(assertion.expectedToBeEnabled, "\", got \"").concat(isEnabled, "\""));
48
+ return __awaiter(this, void 0, void 0, function () {
49
+ var hasError, featureKey, _loop_1, aIndex;
50
+ return __generator(this, function (_a) {
51
+ switch (_a.label) {
52
+ case 0:
53
+ hasError = false;
54
+ featureKey = test.feature;
55
+ console.log(cliFormat_1.CLI_FORMAT_BOLD, " Feature \"".concat(featureKey, "\":"));
56
+ _loop_1 = function (aIndex) {
57
+ var assertion, description, requiredChain, featuresToInclude, datafileContent, sdk, isEnabled, variation;
58
+ return __generator(this, function (_b) {
59
+ switch (_b.label) {
60
+ case 0:
61
+ assertion = test.assertions[aIndex];
62
+ description = assertion.description || "at ".concat(assertion.at, "%");
63
+ console.log(" Assertion #".concat(aIndex + 1, ": (").concat(assertion.environment, ") ").concat(description));
64
+ return [4 /*yield*/, datasource.getRequiredFeaturesChain(test.feature)];
65
+ case 1:
66
+ requiredChain = _b.sent();
67
+ featuresToInclude = Array.from(requiredChain);
68
+ return [4 /*yield*/, (0, builder_1.buildDatafile)(projectConfig, datasource, {
69
+ schemaVersion: config_1.SCHEMA_VERSION,
70
+ revision: "testing",
71
+ environment: assertion.environment,
72
+ features: featuresToInclude,
73
+ }, JSON.parse(fs.readFileSync((0, builder_1.getExistingStateFilePath)(projectConfig, assertion.environment), "utf8")))];
74
+ case 2:
75
+ datafileContent = _b.sent();
76
+ sdk = (0, sdk_1.createInstance)({
77
+ datafile: datafileContent,
78
+ configureBucketValue: function () {
79
+ return assertion.at * (sdk_1.MAX_BUCKETED_NUMBER / 100);
80
+ },
81
+ // logger: createLogger({
82
+ // levels: ["debug", "info", "warn", "error"],
83
+ // }),
84
+ });
85
+ // isEnabled
86
+ if ("expectedToBeEnabled" in assertion) {
87
+ isEnabled = sdk.isEnabled(featureKey, assertion.context);
88
+ if (isEnabled !== assertion.expectedToBeEnabled) {
89
+ hasError = true;
90
+ console.error(cliFormat_1.CLI_FORMAT_RED, " isEnabled failed: expected \"".concat(assertion.expectedToBeEnabled, "\", got \"").concat(isEnabled, "\""));
91
+ }
92
+ }
93
+ // variation
94
+ if ("expectedVariation" in assertion) {
95
+ variation = sdk.getVariation(featureKey, assertion.context);
96
+ if (variation !== assertion.expectedVariation) {
97
+ hasError = true;
98
+ console.error(cliFormat_1.CLI_FORMAT_RED, " Variation failed: expected \"".concat(assertion.expectedVariation, "\", got \"").concat(variation, "\""));
99
+ }
100
+ }
101
+ // variables
102
+ if (typeof assertion.expectedVariables === "object") {
103
+ Object.keys(assertion.expectedVariables).forEach(function (variableKey) {
104
+ var expectedValue = assertion.expectedVariables && assertion.expectedVariables[variableKey];
105
+ var actualValue = sdk.getVariable(featureKey, variableKey, assertion.context);
106
+ var passed;
107
+ if (typeof expectedValue === "object") {
108
+ passed = (0, checkIfObjectsAreEqual_1.checkIfObjectsAreEqual)(expectedValue, actualValue);
109
+ }
110
+ else if (Array.isArray(expectedValue)) {
111
+ passed = (0, checkIfArraysAreEqual_1.checkIfArraysAreEqual)(expectedValue, actualValue);
112
+ }
113
+ else {
114
+ passed = expectedValue === actualValue;
115
+ }
116
+ if (!passed) {
117
+ hasError = true;
118
+ console.error(cliFormat_1.CLI_FORMAT_RED, " Variable \"".concat(variableKey, "\" failed: expected ").concat(JSON.stringify(expectedValue), ", got \"").concat(JSON.stringify(actualValue), "\""));
119
+ }
120
+ });
121
+ }
122
+ return [2 /*return*/];
123
+ }
124
+ });
125
+ };
126
+ aIndex = 0;
127
+ _a.label = 1;
128
+ case 1:
129
+ if (!(aIndex < test.assertions.length)) return [3 /*break*/, 4];
130
+ return [5 /*yield**/, _loop_1(aIndex)];
131
+ case 2:
132
+ _a.sent();
133
+ _a.label = 3;
134
+ case 3:
135
+ aIndex++;
136
+ return [3 /*break*/, 1];
137
+ case 4: return [2 /*return*/, hasError];
40
138
  }
41
- }
42
- // variation
43
- if ("expectedVariation" in assertion) {
44
- var variation = sdk.getVariation(featureKey, assertion.context);
45
- if (variation !== assertion.expectedVariation) {
46
- hasError = true;
47
- console.error(cliFormat_1.CLI_FORMAT_RED, " Variation failed: expected \"".concat(assertion.expectedVariation, "\", got \"").concat(variation, "\""));
48
- }
49
- }
50
- // variables
51
- if (typeof assertion.expectedVariables === "object") {
52
- Object.keys(assertion.expectedVariables).forEach(function (variableKey) {
53
- var expectedValue = assertion.expectedVariables && assertion.expectedVariables[variableKey];
54
- var actualValue = sdk.getVariable(featureKey, variableKey, assertion.context);
55
- var passed;
56
- if (typeof expectedValue === "object") {
57
- passed = (0, checkIfObjectsAreEqual_1.checkIfObjectsAreEqual)(expectedValue, actualValue);
58
- }
59
- else if (Array.isArray(expectedValue)) {
60
- passed = (0, checkIfArraysAreEqual_1.checkIfArraysAreEqual)(expectedValue, actualValue);
61
- }
62
- else {
63
- passed = expectedValue === actualValue;
64
- }
65
- if (!passed) {
66
- hasError = true;
67
- console.error(cliFormat_1.CLI_FORMAT_RED, " Variable \"".concat(variableKey, "\" failed: expected ").concat(JSON.stringify(expectedValue), ", got \"").concat(JSON.stringify(actualValue), "\""));
68
- }
69
- });
70
- }
139
+ });
71
140
  });
72
- return hasError;
73
141
  }
74
142
  exports.testFeature = testFeature;
75
143
  //# sourceMappingURL=testFeature.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testFeature.js","sourceRoot":"","sources":["../../src/tester/testFeature.ts"],"names":[],"mappings":";;;AAAA,uBAAyB;AAGzB,yCAAwE;AAIxE,sCAAqE;AACrE,oCAA2C;AAE3C,iEAAgE;AAChE,mEAAkE;AAClE,yCAA8D;AAE9D,SAAgB,WAAW,CACzB,UAAsB,EACtB,aAA4B,EAC5B,IAAiB;IAEjB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC;IAEhC,OAAO,CAAC,GAAG,CAAC,2BAAe,EAAE,sBAAc,UAAU,QAAI,CAAC,CAAC;IAE3D,IA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C,OAAO,CAAC,UAAU,WAAW;4CACpE,IAAM,aAAa,GACjB,SAAS,CAAC,iBAAiB,IAAI,SAAS,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;4CAC1E,IAAM,WAAW,GAAG,GAAG,CAAC,WAAW,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;4CAEhF,IAAI,MAAM,CAAC;4CAEX,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;gDACrC,MAAM,GAAG,IAAA,+CAAsB,EAAC,aAAa,EAAE,WAAW,CAAC,CAAC;6CAC7D;iDAAM,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;gDACvC,MAAM,GAAG,IAAA,6CAAqB,EAAC,aAAa,EAAE,WAAW,CAAC,CAAC;6CAC5D;iDAAM;gDACL,MAAM,GAAG,aAAa,KAAK,WAAW,CAAC;6CACxC;4CAED,IAAI,CAAC,MAAM,EAAE;gDACX,QAAQ,GAAG,IAAI,CAAC;gDAEhB,OAAO,CAAC,KAAK,CACX,0BAAc,EACd,yBAAiB,WAAW,iCAAsB,IAAI,CAAC,SAAS,CAC9D,aAAa,CACd,qBAAU,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,OAAG,CAC1C,CAAC;6CACH;wCACH,CAAC,CAAC,CAAC;qCACJ;;;;;oBAzFM,MAAM,GAAG,CAAC;;;yBAAE,CAAA,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAA;kDAA3C,MAAM;;;;;oBAAuC,MAAM,EAAE,CAAA;;wBA4F9D,sBAAO,QAAQ,EAAC;;;;CACjB;AAvGD,kCAuGC"}
@@ -1,2 +1,2 @@
1
1
  import { ProjectConfig } from "../config";
2
- export declare function testProject(rootDirectoryPath: string, projectConfig: ProjectConfig): boolean;
2
+ export declare function testProject(rootDirectoryPath: string, projectConfig: ProjectConfig): Promise<boolean>;
@@ -1,4 +1,40 @@
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;
13
+ return g = { next: verb(0), "throw": verb(1), "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
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.testProject = void 0;
4
40
  var fs = require("fs");
@@ -7,55 +43,76 @@ var testSegment_1 = require("./testSegment");
7
43
  var testFeature_1 = require("./testFeature");
8
44
  var cliFormat_1 = require("./cliFormat");
9
45
  function testProject(rootDirectoryPath, projectConfig) {
10
- var hasError = false;
11
- var datasource = new datasource_1.Datasource(projectConfig);
12
- if (!fs.existsSync(projectConfig.testsDirectoryPath)) {
13
- console.error("Tests directory does not exist: ".concat(projectConfig.testsDirectoryPath));
14
- hasError = true;
15
- return hasError;
16
- }
17
- var testFiles = datasource.listTests();
18
- if (testFiles.length === 0) {
19
- console.error("No tests found in: ".concat(projectConfig.testsDirectoryPath));
20
- hasError = true;
21
- return hasError;
22
- }
23
- for (var _i = 0, testFiles_1 = testFiles; _i < testFiles_1.length; _i++) {
24
- var testFile = testFiles_1[_i];
25
- var testFilePath = datasource.getEntityPath("test", testFile);
26
- console.log("");
27
- console.log(cliFormat_1.CLI_FORMAT_BOLD, "Testing: ".concat(testFilePath.replace(rootDirectoryPath, "")));
28
- var t = datasource.readTest(testFile);
29
- if (t.segment) {
30
- // segment testing
31
- var test_1 = t;
32
- var segmentHasError = (0, testSegment_1.testSegment)(datasource, test_1);
33
- if (segmentHasError) {
34
- hasError = true;
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ var hasError, datasource, testFiles, _i, testFiles_1, testFile, testFilePath, t, test_1, segmentHasError, test_2, featureHasError;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
+ case 0:
51
+ hasError = false;
52
+ datasource = new datasource_1.Datasource(projectConfig);
53
+ if (!fs.existsSync(projectConfig.testsDirectoryPath)) {
54
+ console.error("Tests directory does not exist: ".concat(projectConfig.testsDirectoryPath));
55
+ hasError = true;
56
+ return [2 /*return*/, hasError];
57
+ }
58
+ return [4 /*yield*/, datasource.listTests()];
59
+ case 1:
60
+ testFiles = _a.sent();
61
+ if (testFiles.length === 0) {
62
+ console.error("No tests found in: ".concat(projectConfig.testsDirectoryPath));
63
+ hasError = true;
64
+ return [2 /*return*/, hasError];
65
+ }
66
+ _i = 0, testFiles_1 = testFiles;
67
+ _a.label = 2;
68
+ case 2:
69
+ if (!(_i < testFiles_1.length)) return [3 /*break*/, 9];
70
+ testFile = testFiles_1[_i];
71
+ testFilePath = datasource.getEntityPath("test", testFile);
72
+ console.log("");
73
+ console.log(cliFormat_1.CLI_FORMAT_BOLD, "Testing: ".concat(testFilePath.replace(rootDirectoryPath, "")));
74
+ return [4 /*yield*/, datasource.readTest(testFile)];
75
+ case 3:
76
+ t = _a.sent();
77
+ if (!t.segment) return [3 /*break*/, 5];
78
+ test_1 = t;
79
+ return [4 /*yield*/, (0, testSegment_1.testSegment)(datasource, test_1)];
80
+ case 4:
81
+ segmentHasError = _a.sent();
82
+ if (segmentHasError) {
83
+ hasError = true;
84
+ }
85
+ return [3 /*break*/, 8];
86
+ case 5:
87
+ if (!t.feature) return [3 /*break*/, 7];
88
+ test_2 = t;
89
+ return [4 /*yield*/, (0, testFeature_1.testFeature)(datasource, projectConfig, test_2)];
90
+ case 6:
91
+ featureHasError = _a.sent();
92
+ if (featureHasError) {
93
+ hasError = true;
94
+ }
95
+ return [3 /*break*/, 8];
96
+ case 7:
97
+ console.error(" => Invalid test: ".concat(JSON.stringify(test)));
98
+ hasError = true;
99
+ _a.label = 8;
100
+ case 8:
101
+ _i++;
102
+ return [3 /*break*/, 2];
103
+ case 9:
104
+ console.log("");
105
+ if (hasError) {
106
+ console.log(cliFormat_1.CLI_FORMAT_RED, "Some tests failed");
107
+ }
108
+ else {
109
+ console.log(cliFormat_1.CLI_FORMAT_GREEN, "All tests passed");
110
+ }
111
+ console.log("");
112
+ return [2 /*return*/, hasError];
35
113
  }
36
- }
37
- else if (t.feature) {
38
- // feature testing
39
- var test_2 = t;
40
- var featureHasError = (0, testFeature_1.testFeature)(datasource, projectConfig, test_2);
41
- if (featureHasError) {
42
- hasError = true;
43
- }
44
- }
45
- else {
46
- console.error(" => Invalid test: ".concat(JSON.stringify(test)));
47
- hasError = true;
48
- }
49
- }
50
- console.log("");
51
- if (hasError) {
52
- console.log(cliFormat_1.CLI_FORMAT_RED, "Some tests failed");
53
- }
54
- else {
55
- console.log(cliFormat_1.CLI_FORMAT_GREEN, "All tests passed");
56
- }
57
- console.log("");
58
- return hasError;
114
+ });
115
+ });
59
116
  }
60
117
  exports.testProject = testProject;
61
118
  //# sourceMappingURL=testProject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testProject.js","sourceRoot":"","sources":["../../src/tester/testProject.ts"],"names":[],"mappings":";;;AAAA,uBAAyB;AAKzB,4CAA2C;AAE3C,6CAA4C;AAC5C,6CAA4C;AAC5C,yCAAgF;AAEhF,SAAgB,WAAW,CAAC,iBAAyB,EAAE,aAA4B;IACjF,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,aAAa,CAAC,CAAC;IAEjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAAE;QACpD,OAAO,CAAC,KAAK,CAAC,0CAAmC,aAAa,CAAC,kBAAkB,CAAE,CAAC,CAAC;QACrF,QAAQ,GAAG,IAAI,CAAC;QAEhB,OAAO,QAAQ,CAAC;KACjB;IAED,IAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IAEzC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,6BAAsB,aAAa,CAAC,kBAAkB,CAAE,CAAC,CAAC;QACxE,QAAQ,GAAG,IAAI,CAAC;QAEhB,OAAO,QAAQ,CAAC;KACjB;IAED,KAAuB,UAAS,EAAT,u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BAE9E,qBAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAA;;oBAAvC,CAAC,GAAG,SAAmC;yBAExC,CAAiB,CAAC,OAAO,EAA1B,wBAA0B;oBAEtB,SAAO,CAAgB,CAAC;oBAEN,qBAAM,IAAA,yBAAW,EAAC,UAAU,EAAE,MAAI,CAAC,EAAA;;oBAArD,eAAe,GAAG,SAAmC;oBAE3D,IAAI,eAAe,EAAE;wBACnB,QAAQ,GAAG,IAAI,CAAC;qBACjB;;;yBACS,CAAiB,CAAC,OAAO,EAA1B,wBAA0B;oBAE7B,SAAO,CAAgB,CAAC;oBAEN,qBAAM,IAAA,yBAAW,EAAC,UAAU,EAAE,aAAa,EAAE,MAAI,CAAC,EAAA;;oBAApE,eAAe,GAAG,SAAkD;oBAE1E,IAAI,eAAe,EAAE;wBACnB,QAAQ,GAAG,IAAI,CAAC;qBACjB;;;oBAED,OAAO,CAAC,KAAK,CAAC,6BAAsB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAE,CAAC,CAAC;oBAC5D,QAAQ,GAAG,IAAI,CAAC;;;oBA5BG,IAAS,CAAA;;;oBAgChC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBAChB,IAAI,QAAQ,EAAE;wBACZ,OAAO,CAAC,GAAG,CAAC,0BAAc,EAAE,mBAAmB,CAAC,CAAC;qBAClD;yBAAM;wBACL,OAAO,CAAC,GAAG,CAAC,4BAAgB,EAAE,kBAAkB,CAAC,CAAC;qBACnD;oBACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;oBAEhB,sBAAO,QAAQ,EAAC;;;;CACjB;AAhED,kCAgEC"}
@@ -1,3 +1,3 @@
1
1
  import { TestSegment } from "@featurevisor/types";
2
2
  import { Datasource } from "../datasource";
3
- export declare function testSegment(datasource: Datasource, test: TestSegment): boolean;
3
+ export declare function testSegment(datasource: Datasource, test: TestSegment): Promise<boolean>;
@@ -1,31 +1,79 @@
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;
13
+ return g = { next: verb(0), "throw": verb(1), "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
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.testSegment = void 0;
4
40
  var sdk_1 = require("@featurevisor/sdk");
5
41
  var cliFormat_1 = require("./cliFormat");
6
42
  function testSegment(datasource, test) {
7
- var hasError = false;
8
- var segmentKey = test.segment;
9
- console.log(cliFormat_1.CLI_FORMAT_BOLD, " Segment \"".concat(segmentKey, "\":"));
10
- var segmentExists = datasource.entityExists("segment", segmentKey);
11
- if (!segmentExists) {
12
- console.error(cliFormat_1.CLI_FORMAT_RED, " Segment does not exist: ".concat(segmentKey));
13
- hasError = true;
14
- return hasError;
15
- }
16
- var parsedSegment = datasource.readSegment(segmentKey);
17
- var conditions = parsedSegment.conditions;
18
- test.assertions.forEach(function (assertion, aIndex) {
19
- var description = assertion.description || "#".concat(aIndex + 1);
20
- console.log(" Assertion #".concat(aIndex + 1, ": ").concat(description));
21
- var expected = assertion.expectedToMatch;
22
- var actual = (0, sdk_1.allConditionsAreMatched)(conditions, assertion.context);
23
- if (actual !== expected) {
24
- hasError = true;
25
- console.error(cliFormat_1.CLI_FORMAT_RED, " Segment failed: expected \"".concat(expected, "\", got \"").concat(actual, "\""));
26
- }
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ var hasError, segmentKey, segmentExists, parsedSegment, conditions;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ hasError = false;
49
+ segmentKey = test.segment;
50
+ console.log(cliFormat_1.CLI_FORMAT_BOLD, " Segment \"".concat(segmentKey, "\":"));
51
+ return [4 /*yield*/, datasource.entityExists("segment", segmentKey)];
52
+ case 1:
53
+ segmentExists = _a.sent();
54
+ if (!segmentExists) {
55
+ console.error(cliFormat_1.CLI_FORMAT_RED, " Segment does not exist: ".concat(segmentKey));
56
+ hasError = true;
57
+ return [2 /*return*/, hasError];
58
+ }
59
+ return [4 /*yield*/, datasource.readSegment(segmentKey)];
60
+ case 2:
61
+ parsedSegment = _a.sent();
62
+ conditions = parsedSegment.conditions;
63
+ test.assertions.forEach(function (assertion, aIndex) {
64
+ var description = assertion.description || "#".concat(aIndex + 1);
65
+ console.log(" Assertion #".concat(aIndex + 1, ": ").concat(description));
66
+ var expected = assertion.expectedToMatch;
67
+ var actual = (0, sdk_1.allConditionsAreMatched)(conditions, assertion.context);
68
+ if (actual !== expected) {
69
+ hasError = true;
70
+ console.error(cliFormat_1.CLI_FORMAT_RED, " Segment failed: expected \"".concat(expected, "\", got \"").concat(actual, "\""));
71
+ }
72
+ });
73
+ return [2 /*return*/, hasError];
74
+ }
75
+ });
27
76
  });
28
- return hasError;
29
77
  }
30
78
  exports.testSegment = testSegment;
31
79
  //# sourceMappingURL=testSegment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testSegment.js","sourceRoot":"","sources":["../../src/tester/testSegment.ts"],"names":[],"mappings":";;;AACA,yCAA4D;AAI5D,yCAA8D;AAE9D,SAAgB,WAAW,CAAC,UAAsB,EAAE,IAAiB;IACnE,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC;IAEhC,OAAO,CAAC,GAAG,CAAC,2BAAe,EAAE,sBAAc,UAAU,QAAI,CAAC,CAAC;IAE3D,IAAM,aAAa,GAAG,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAErE,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,CAAC,KAAK,CAAC,0BAAc,EAAE,oCAA6B,UAAU,CAAE,CAAC,CAAC;QACzE,QAAQ,GAAG,IAAI,CAAC;QAEhB,OAAO,QAAQ,CAAC;KACjB;IAED,IAAM,aAAa,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACzD,IA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QAAQ,GAAG,IAAI,CAAC;wBAEhB,sBAAO,QAAQ,EAAC;qBACjB;oBAEqB,qBAAM,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,EAAA;;oBAAxD,aAAa,GAAG,SAAwC;oBACxD,UAAU,GAAG,aAAa,CAAC,UAAqC,CAAC;oBAEvE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,SAAS,EAAE,MAAM;wBACjD,IAAM,WAAW,GAAG,SAAS,CAAC,WAAW,IAAI,WAAI,MAAM,GAAG,CAAC,CAAE,CAAC;wBAE9D,OAAO,CAAC,GAAG,CAAC,uBAAgB,MAAM,GAAG,CAAC,eAAK,WAAW,CAAE,CAAC,CAAC;wBAE1D,IAAM,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;wBAC3C,IAAM,MAAM,GAAG,IAAA,6BAAuB,EAAC,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;wBAEtE,IAAI,MAAM,KAAK,QAAQ,EAAE;4BACvB,QAAQ,GAAG,IAAI,CAAC;4BAEhB,OAAO,CAAC,KAAK,CAAC,0BAAc,EAAE,yCAAiC,QAAQ,uBAAW,MAAM,OAAG,CAAC,CAAC;yBAC9F;oBACH,CAAC,CAAC,CAAC;oBAEH,sBAAO,QAAQ,EAAC;;;;CACjB;AAnCD,kCAmCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featurevisor/core",
3
- "version": "0.53.2",
3
+ "version": "0.53.3",
4
4
  "description": "Core package of Featurevisor for Node.js usage",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -57,5 +57,5 @@
57
57
  "@types/js-yaml": "^4.0.5",
58
58
  "@types/tar": "^6.1.4"
59
59
  },
60
- "gitHead": "f63fbcebd97cea554e1c408784d1991fead6ba8e"
60
+ "gitHead": "960212388b35efddc800561167f72ade7b18db19"
61
61
  }
@@ -33,12 +33,12 @@ export interface BuildOptions {
33
33
  features?: FeatureKey[];
34
34
  }
35
35
 
36
- export function buildDatafile(
36
+ export async function buildDatafile(
37
37
  projectConfig: ProjectConfig,
38
38
  datasource: Datasource,
39
39
  options: BuildOptions,
40
40
  existingState: ExistingState,
41
- ): DatafileContent {
41
+ ): Promise<DatafileContent> {
42
42
  const datafileContent: DatafileContent = {
43
43
  schemaVersion: options.schemaVersion,
44
44
  revision: options.revision,
@@ -49,17 +49,17 @@ export function buildDatafile(
49
49
 
50
50
  const segmentKeysUsedByTag = new Set<SegmentKey>();
51
51
  const attributeKeysUsedByTag = new Set<AttributeKey>();
52
- const { featureRanges, featureIsInGroup } = getFeatureRanges(projectConfig, datasource);
52
+ const { featureRanges, featureIsInGroup } = await getFeatureRanges(projectConfig, datasource);
53
53
 
54
54
  // features
55
55
  const features: Feature[] = [];
56
56
  const featuresDirectory = projectConfig.featuresDirectoryPath;
57
57
 
58
58
  if (fs.existsSync(featuresDirectory)) {
59
- const featureFiles = datasource.listFeatures();
59
+ const featureFiles = await datasource.listFeatures();
60
60
 
61
61
  for (const featureKey of featureFiles) {
62
- const parsedFeature = datasource.readFeature(featureKey);
62
+ const parsedFeature = await datasource.readFeature(featureKey);
63
63
 
64
64
  if (parsedFeature.archived === true) {
65
65
  continue;
@@ -200,10 +200,10 @@ export function buildDatafile(
200
200
  const segmentsDirectory = projectConfig.segmentsDirectoryPath;
201
201
 
202
202
  if (fs.existsSync(segmentsDirectory)) {
203
- const segmentFiles = datasource.listSegments();
203
+ const segmentFiles = await datasource.listSegments();
204
204
 
205
205
  for (const segmentKey of segmentFiles) {
206
- const parsedSegment = datasource.readSegment(segmentKey);
206
+ const parsedSegment = await datasource.readSegment(segmentKey);
207
207
 
208
208
  if (parsedSegment.archived === true) {
209
209
  continue;
@@ -235,10 +235,10 @@ export function buildDatafile(
235
235
  const attributesDirectory = projectConfig.attributesDirectoryPath;
236
236
 
237
237
  if (fs.existsSync(attributesDirectory)) {
238
- const attributeFiles = datasource.listAttributes();
238
+ const attributeFiles = await datasource.listAttributes();
239
239
 
240
240
  for (const attributeKey of attributeFiles) {
241
- const parsedAttribute = datasource.readAttribute(attributeKey);
241
+ const parsedAttribute = await datasource.readAttribute(attributeKey);
242
242
 
243
243
  if (parsedAttribute.archived === true) {
244
244
  continue;
@@ -31,7 +31,7 @@ export interface BuildCLIOptions {
31
31
  revision?: string;
32
32
  }
33
33
 
34
- export function buildProject(
34
+ export async function buildProject(
35
35
  rootDirectoryPath,
36
36
  projectConfig: ProjectConfig,
37
37
  cliOptions: BuildCLIOptions = {},
@@ -54,7 +54,7 @@ export function buildProject(
54
54
 
55
55
  for (const tag of tags) {
56
56
  console.log(`\n => Tag: ${tag}`);
57
- const datafileContent = buildDatafile(
57
+ const datafileContent = await buildDatafile(
58
58
  projectConfig,
59
59
  datasource,
60
60
  {