@featurevisor/core 1.35.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +0 -6
- package/coverage/clover.xml +321 -237
- package/coverage/coverage-final.json +8 -8
- package/coverage/lcov-report/index.html +77 -47
- package/coverage/lcov-report/lib/builder/allocator.js.html +14 -14
- package/coverage/lcov-report/lib/builder/index.html +16 -16
- package/coverage/lcov-report/lib/builder/revision.js.html +3 -3
- package/coverage/lcov-report/lib/builder/traffic.js.html +90 -63
- package/coverage/lcov-report/lib/list/index.html +116 -0
- package/coverage/lcov-report/lib/{tester → list}/matrix.js.html +90 -66
- package/coverage/lcov-report/lib/tester/helpers.js.html +295 -0
- package/coverage/lcov-report/lib/tester/index.html +20 -35
- package/coverage/lcov-report/src/builder/allocator.ts.html +2 -2
- package/coverage/lcov-report/src/builder/index.html +15 -15
- package/coverage/lcov-report/src/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/src/builder/traffic.ts.html +101 -23
- package/coverage/lcov-report/src/list/index.html +116 -0
- package/coverage/lcov-report/src/{tester → list}/matrix.ts.html +87 -21
- package/coverage/lcov-report/src/tester/helpers.ts.html +313 -0
- package/coverage/lcov-report/src/tester/index.html +20 -35
- package/coverage/lcov.info +592 -436
- package/lib/assess-distribution/index.d.ts +1 -1
- package/lib/assess-distribution/index.js +102 -162
- package/lib/assess-distribution/index.js.map +1 -1
- package/lib/benchmark/index.js +87 -143
- package/lib/benchmark/index.js.map +1 -1
- package/lib/builder/allocator.d.ts +1 -1
- package/lib/builder/allocator.js +12 -12
- package/lib/builder/allocator.js.map +1 -1
- package/lib/builder/allocator.spec.js +22 -22
- package/lib/builder/allocator.spec.js.map +1 -1
- package/lib/builder/buildDatafile.d.ts +4 -3
- package/lib/builder/buildDatafile.js +311 -388
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +2 -1
- package/lib/builder/buildProject.js +96 -183
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/convertToV1.d.ts +10 -0
- package/lib/builder/convertToV1.js +119 -0
- package/lib/builder/convertToV1.js.map +1 -0
- package/lib/builder/getFeatureRanges.d.ts +1 -1
- package/lib/builder/getFeatureRanges.js +32 -105
- package/lib/builder/getFeatureRanges.js.map +1 -1
- package/lib/builder/hashes.d.ts +4 -0
- package/lib/builder/hashes.js +70 -0
- package/lib/builder/hashes.js.map +1 -0
- package/lib/builder/revision.js +2 -2
- package/lib/builder/revision.js.map +1 -1
- package/lib/builder/revision.spec.js +1 -1
- package/lib/builder/revision.spec.js.map +1 -1
- package/lib/builder/traffic.d.ts +1 -1
- package/lib/builder/traffic.js +57 -48
- package/lib/builder/traffic.js.map +1 -1
- package/lib/builder/traffic.spec.js +14 -14
- package/lib/builder/traffic.spec.js.map +1 -1
- package/lib/cli/cli.js +60 -129
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/plugins.js +14 -16
- package/lib/cli/plugins.js.map +1 -1
- package/lib/config/parsers.js +1 -1
- package/lib/config/parsers.js.map +1 -1
- package/lib/config/projectConfig.d.ts +8 -6
- package/lib/config/projectConfig.js +31 -72
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/adapter.d.ts +1 -1
- package/lib/datasource/adapter.js +2 -5
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/datasource.d.ts +2 -1
- package/lib/datasource/datasource.js +107 -148
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/filesystemAdapter.d.ts +1 -1
- package/lib/datasource/filesystemAdapter.js +224 -360
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/evaluate/index.d.ts +1 -1
- package/lib/evaluate/index.js +120 -188
- package/lib/evaluate/index.js.map +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.d.ts +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js +40 -128
- package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
- package/lib/find-duplicate-segments/index.js +27 -82
- package/lib/find-duplicate-segments/index.js.map +1 -1
- package/lib/find-usage/index.d.ts +7 -5
- package/lib/find-usage/index.js +333 -507
- package/lib/find-usage/index.js.map +1 -1
- package/lib/generate-code/index.js +36 -91
- package/lib/generate-code/index.js.map +1 -1
- package/lib/generate-code/typescript.js +117 -157
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/info/index.js +45 -133
- package/lib/info/index.js.map +1 -1
- package/lib/init/index.d.ts +1 -1
- package/lib/init/index.js +16 -64
- package/lib/init/index.js.map +1 -1
- package/lib/linter/attributeSchema.d.ts +21 -6
- package/lib/linter/attributeSchema.js +18 -4
- package/lib/linter/attributeSchema.js.map +1 -1
- package/lib/linter/checkCircularDependency.d.ts +1 -1
- package/lib/linter/checkCircularDependency.js +22 -80
- package/lib/linter/checkCircularDependency.js.map +1 -1
- package/lib/linter/checkPercentageExceedingSlot.d.ts +1 -1
- package/lib/linter/checkPercentageExceedingSlot.js +36 -76
- package/lib/linter/checkPercentageExceedingSlot.js.map +1 -1
- package/lib/linter/conditionSchema.d.ts +1 -1
- package/lib/linter/conditionSchema.js +89 -41
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +345 -197
- package/lib/linter/featureSchema.js +313 -172
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/groupSchema.js +6 -6
- package/lib/linter/groupSchema.js.map +1 -1
- package/lib/linter/lintProject.js +306 -480
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/printError.js +7 -7
- package/lib/linter/printError.js.map +1 -1
- package/lib/linter/segmentSchema.js +2 -2
- package/lib/linter/segmentSchema.js.map +1 -1
- package/lib/linter/testSchema.d.ts +155 -3
- package/lib/linter/testSchema.js +47 -17
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/list/index.d.ts +1 -0
- package/lib/list/index.js +349 -517
- package/lib/list/index.js.map +1 -1
- package/lib/{tester → list}/matrix.d.ts +1 -1
- package/lib/{tester → list}/matrix.js +50 -42
- package/lib/list/matrix.js.map +1 -0
- package/lib/{tester → list}/matrix.spec.js +7 -7
- package/lib/list/matrix.spec.js.map +1 -0
- package/lib/site/exportSite.js +25 -71
- package/lib/site/exportSite.js.map +1 -1
- package/lib/site/generateHistory.d.ts +1 -1
- package/lib/site/generateHistory.js +26 -82
- package/lib/site/generateHistory.js.map +1 -1
- package/lib/site/generateSiteSearchIndex.d.ts +1 -1
- package/lib/site/generateSiteSearchIndex.js +182 -259
- package/lib/site/generateSiteSearchIndex.js.map +1 -1
- package/lib/site/getLastModifiedFromHistory.d.ts +1 -1
- package/lib/site/getLastModifiedFromHistory.js +2 -2
- package/lib/site/getLastModifiedFromHistory.js.map +1 -1
- package/lib/site/getOwnerAndRepoFromUrl.js +6 -6
- package/lib/site/getOwnerAndRepoFromUrl.js.map +1 -1
- package/lib/site/getRelativePaths.js +7 -7
- package/lib/site/getRelativePaths.js.map +1 -1
- package/lib/site/getRepoDetails.js +20 -20
- package/lib/site/getRepoDetails.js.map +1 -1
- package/lib/site/index.js +25 -73
- package/lib/site/index.js.map +1 -1
- package/lib/site/serveSite.js +10 -10
- package/lib/site/serveSite.js.map +1 -1
- package/lib/tester/helpers.d.ts +2 -0
- package/lib/tester/helpers.js +71 -0
- package/lib/tester/helpers.js.map +1 -0
- package/lib/tester/helpers.spec.js +115 -0
- package/lib/tester/helpers.spec.js.map +1 -0
- package/lib/tester/index.d.ts +0 -1
- package/lib/tester/index.js +0 -1
- package/lib/tester/index.js.map +1 -1
- package/lib/tester/prettyDuration.js +11 -11
- package/lib/tester/prettyDuration.js.map +1 -1
- package/lib/tester/printTestResult.d.ts +1 -1
- package/lib/tester/printTestResult.js +35 -15
- package/lib/tester/printTestResult.js.map +1 -1
- package/lib/tester/testFeature.d.ts +4 -2
- package/lib/tester/testFeature.js +264 -226
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +3 -7
- package/lib/tester/testProject.js +145 -246
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.d.ts +5 -2
- package/lib/tester/testSegment.js +65 -102
- package/lib/tester/testSegment.js.map +1 -1
- package/lib/utils/extractKeys.d.ts +2 -1
- package/lib/utils/extractKeys.js +57 -12
- package/lib/utils/extractKeys.js.map +1 -1
- package/lib/utils/git.d.ts +1 -1
- package/lib/utils/git.js +23 -23
- package/lib/utils/git.js.map +1 -1
- package/lib/utils/pretty.js +2 -4
- package/lib/utils/pretty.js.map +1 -1
- package/package.json +5 -6
- package/src/assess-distribution/index.ts +3 -2
- package/src/benchmark/index.ts +3 -3
- package/src/builder/allocator.spec.ts +1 -1
- package/src/builder/allocator.ts +1 -1
- package/src/builder/buildDatafile.ts +161 -124
- package/src/builder/buildProject.ts +6 -3
- package/src/builder/convertToV1.ts +166 -0
- package/src/builder/getFeatureRanges.ts +1 -1
- package/src/builder/hashes.ts +109 -0
- package/src/builder/traffic.ts +41 -15
- package/src/cli/cli.ts +1 -1
- package/src/cli/plugins.ts +0 -2
- package/src/config/projectConfig.ts +13 -10
- package/src/datasource/adapter.ts +1 -1
- package/src/datasource/datasource.ts +23 -2
- package/src/datasource/filesystemAdapter.ts +11 -12
- package/src/evaluate/index.ts +7 -6
- package/src/find-duplicate-segments/findDuplicateSegments.ts +1 -1
- package/src/find-usage/index.ts +111 -44
- package/src/generate-code/index.ts +1 -3
- package/src/generate-code/typescript.ts +7 -29
- package/src/index.ts +0 -1
- package/src/info/index.ts +2 -2
- package/src/init/index.ts +2 -2
- package/src/linter/attributeSchema.ts +18 -2
- package/src/linter/checkCircularDependency.ts +1 -1
- package/src/linter/checkPercentageExceedingSlot.ts +28 -8
- package/src/linter/conditionSchema.ts +66 -10
- package/src/linter/featureSchema.ts +312 -116
- package/src/linter/lintProject.ts +9 -4
- package/src/linter/testSchema.ts +42 -3
- package/src/list/index.ts +18 -30
- package/src/{tester → list}/matrix.ts +33 -11
- package/src/site/exportSite.ts +2 -4
- package/src/site/generateHistory.ts +1 -1
- package/src/site/generateSiteSearchIndex.ts +58 -50
- package/src/site/getLastModifiedFromHistory.ts +1 -1
- package/src/tester/helpers.spec.ts +149 -0
- package/src/tester/helpers.ts +76 -0
- package/src/tester/index.ts +0 -1
- package/src/tester/printTestResult.ts +25 -3
- package/src/tester/testFeature.ts +270 -124
- package/src/tester/testProject.ts +28 -49
- package/src/tester/testSegment.ts +48 -40
- package/src/utils/extractKeys.ts +58 -1
- package/src/utils/git.ts +1 -1
- package/tsconfig.cjs.json +1 -0
- package/coverage/lcov-report/lib/tester/checkIfObjectsAreEqual.js.html +0 -151
- package/coverage/lcov-report/src/tester/checkIfObjectsAreEqual.ts.html +0 -157
- package/lib/restore/index.d.ts +0 -4
- package/lib/restore/index.js +0 -91
- package/lib/restore/index.js.map +0 -1
- package/lib/tester/checkIfArraysAreEqual.d.ts +0 -1
- package/lib/tester/checkIfArraysAreEqual.js +0 -18
- package/lib/tester/checkIfArraysAreEqual.js.map +0 -1
- package/lib/tester/checkIfObjectsAreEqual.d.ts +0 -1
- package/lib/tester/checkIfObjectsAreEqual.js +0 -23
- package/lib/tester/checkIfObjectsAreEqual.js.map +0 -1
- package/lib/tester/checkIfObjectsAreEqual.spec.js +0 -26
- package/lib/tester/checkIfObjectsAreEqual.spec.js.map +0 -1
- package/lib/tester/matrix.js.map +0 -1
- package/lib/tester/matrix.spec.js.map +0 -1
- package/src/restore/index.ts +0 -42
- package/src/tester/checkIfArraysAreEqual.ts +0 -16
- package/src/tester/checkIfObjectsAreEqual.spec.ts +0 -31
- package/src/tester/checkIfObjectsAreEqual.ts +0 -24
- /package/lib/{tester → list}/matrix.spec.d.ts +0 -0
- /package/lib/tester/{checkIfObjectsAreEqual.spec.d.ts → helpers.spec.d.ts} +0 -0
- /package/src/{tester → list}/matrix.spec.ts +0 -0
|
@@ -1,102 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
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);
|
|
28
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.FilesystemAdapter = void 0;
|
|
55
4
|
exports.getExistingStateFilePath = getExistingStateFilePath;
|
|
56
5
|
exports.getRevisionFilePath = getRevisionFilePath;
|
|
57
6
|
exports.getAllEntityFilePathsRecursively = getAllEntityFilePathsRecursively;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var git_1 = require("../utils/git");
|
|
64
|
-
var commitRegex = /^commit (\w+)\nAuthor: (.+) <(.+)>\nDate: (.+)\n\n(.+)/gm;
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const adapter_1 = require("./adapter");
|
|
11
|
+
const git_1 = require("../utils/git");
|
|
65
12
|
function getExistingStateFilePath(projectConfig, environment) {
|
|
66
|
-
|
|
13
|
+
const fileName = environment ? `existing-state-${environment}.json` : `existing-state.json`;
|
|
67
14
|
return path.join(projectConfig.stateDirectoryPath, fileName);
|
|
68
15
|
}
|
|
69
16
|
function getRevisionFilePath(projectConfig) {
|
|
70
|
-
return path.join(projectConfig.stateDirectoryPath,
|
|
17
|
+
return path.join(projectConfig.stateDirectoryPath, `REVISION`);
|
|
71
18
|
}
|
|
72
19
|
function getAllEntityFilePathsRecursively(directoryPath, extension) {
|
|
73
|
-
|
|
20
|
+
let entities = [];
|
|
74
21
|
if (!fs.existsSync(directoryPath)) {
|
|
75
22
|
return entities;
|
|
76
23
|
}
|
|
77
|
-
|
|
78
|
-
for (
|
|
79
|
-
|
|
80
|
-
|
|
24
|
+
const files = fs.readdirSync(directoryPath);
|
|
25
|
+
for (let i = 0; i < files.length; i++) {
|
|
26
|
+
const file = files[i];
|
|
27
|
+
const filePath = path.join(directoryPath, file);
|
|
81
28
|
if (fs.statSync(filePath).isDirectory()) {
|
|
82
29
|
entities = entities.concat(getAllEntityFilePathsRecursively(filePath, extension));
|
|
83
30
|
}
|
|
84
|
-
else if (file.endsWith(
|
|
31
|
+
else if (file.endsWith(`.${extension}`)) {
|
|
85
32
|
entities.push(filePath);
|
|
86
33
|
}
|
|
87
34
|
}
|
|
88
35
|
return entities;
|
|
89
36
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
_this.parser = config.parser;
|
|
97
|
-
return _this;
|
|
37
|
+
class FilesystemAdapter extends adapter_1.Adapter {
|
|
38
|
+
constructor(config, rootDirectoryPath) {
|
|
39
|
+
super();
|
|
40
|
+
this.config = config;
|
|
41
|
+
this.rootDirectoryPath = rootDirectoryPath;
|
|
42
|
+
this.parser = config.parser;
|
|
98
43
|
}
|
|
99
|
-
|
|
44
|
+
getEntityDirectoryPath(entityType) {
|
|
100
45
|
if (entityType === "feature") {
|
|
101
46
|
return this.config.featuresDirectoryPath;
|
|
102
47
|
}
|
|
@@ -110,226 +55,161 @@ var FilesystemAdapter = /** @class */ (function (_super) {
|
|
|
110
55
|
return this.config.testsDirectoryPath;
|
|
111
56
|
}
|
|
112
57
|
return this.config.attributesDirectoryPath;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
58
|
+
}
|
|
59
|
+
getEntityPath(entityType, entityKey) {
|
|
60
|
+
const basePath = this.getEntityDirectoryPath(entityType);
|
|
116
61
|
// taking care of windows paths
|
|
117
|
-
|
|
118
|
-
return path.join(basePath,
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
158
|
-
FilesystemAdapter.prototype.writeEntity = function (entityType, entityKey, entity) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
-
var filePath;
|
|
161
|
-
return __generator(this, function (_a) {
|
|
162
|
-
filePath = this.getEntityPath(entityType, entityKey);
|
|
163
|
-
if (!fs.existsSync(this.getEntityDirectoryPath(entityType))) {
|
|
164
|
-
mkdirp.sync(this.getEntityDirectoryPath(entityType));
|
|
165
|
-
}
|
|
166
|
-
fs.writeFileSync(filePath, this.parser.stringify(entity));
|
|
167
|
-
return [2 /*return*/, entity];
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
};
|
|
171
|
-
FilesystemAdapter.prototype.deleteEntity = function (entityType, entityKey) {
|
|
172
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
-
var filePath;
|
|
174
|
-
return __generator(this, function (_a) {
|
|
175
|
-
filePath = this.getEntityPath(entityType, entityKey);
|
|
176
|
-
if (!fs.existsSync(filePath)) {
|
|
177
|
-
return [2 /*return*/];
|
|
178
|
-
}
|
|
179
|
-
fs.unlinkSync(filePath);
|
|
180
|
-
return [2 /*return*/];
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
};
|
|
62
|
+
const relativeEntityPath = entityKey.replace(/\//g, path.sep);
|
|
63
|
+
return path.join(basePath, `${relativeEntityPath}.${this.parser.extension}`);
|
|
64
|
+
}
|
|
65
|
+
async listEntities(entityType) {
|
|
66
|
+
const directoryPath = this.getEntityDirectoryPath(entityType);
|
|
67
|
+
const filePaths = getAllEntityFilePathsRecursively(directoryPath, this.parser.extension);
|
|
68
|
+
return (filePaths
|
|
69
|
+
// keep only the files with the right extension
|
|
70
|
+
.filter((filterPath) => filterPath.endsWith(`.${this.parser.extension}`))
|
|
71
|
+
// remove the entity directory path from beginning
|
|
72
|
+
.map((filePath) => filePath.replace(directoryPath + path.sep, ""))
|
|
73
|
+
// remove the extension from the end
|
|
74
|
+
.map((filterPath) => filterPath.replace(`.${this.parser.extension}`, ""))
|
|
75
|
+
// take care of windows paths
|
|
76
|
+
.map((filterPath) => filterPath.replace(/\\/g, "/")));
|
|
77
|
+
}
|
|
78
|
+
async entityExists(entityType, entityKey) {
|
|
79
|
+
const entityPath = this.getEntityPath(entityType, entityKey);
|
|
80
|
+
return fs.existsSync(entityPath);
|
|
81
|
+
}
|
|
82
|
+
async readEntity(entityType, entityKey) {
|
|
83
|
+
const filePath = this.getEntityPath(entityType, entityKey);
|
|
84
|
+
const entityContent = fs.readFileSync(filePath, "utf8");
|
|
85
|
+
return this.parser.parse(entityContent, filePath);
|
|
86
|
+
}
|
|
87
|
+
async writeEntity(entityType, entityKey, entity) {
|
|
88
|
+
const filePath = this.getEntityPath(entityType, entityKey);
|
|
89
|
+
if (!fs.existsSync(this.getEntityDirectoryPath(entityType))) {
|
|
90
|
+
fs.mkdirSync(this.getEntityDirectoryPath(entityType), { recursive: true });
|
|
91
|
+
}
|
|
92
|
+
fs.writeFileSync(filePath, this.parser.stringify(entity));
|
|
93
|
+
return entity;
|
|
94
|
+
}
|
|
95
|
+
async deleteEntity(entityType, entityKey) {
|
|
96
|
+
const filePath = this.getEntityPath(entityType, entityKey);
|
|
97
|
+
if (!fs.existsSync(filePath)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
fs.unlinkSync(filePath);
|
|
101
|
+
}
|
|
184
102
|
/**
|
|
185
103
|
* State
|
|
186
104
|
*/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (!fs.existsSync(this.config.stateDirectoryPath)) {
|
|
207
|
-
mkdirp.sync(this.config.stateDirectoryPath);
|
|
208
|
-
}
|
|
209
|
-
fs.writeFileSync(filePath, this.config.prettyState
|
|
210
|
-
? JSON.stringify(existingState, null, 2)
|
|
211
|
-
: JSON.stringify(existingState));
|
|
212
|
-
fs.writeFileSync(filePath, JSON.stringify(existingState, null, 2));
|
|
213
|
-
return [2 /*return*/];
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
};
|
|
105
|
+
async readState(environment) {
|
|
106
|
+
const filePath = getExistingStateFilePath(this.config, environment);
|
|
107
|
+
if (!fs.existsSync(filePath)) {
|
|
108
|
+
return {
|
|
109
|
+
features: {},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return require(filePath);
|
|
113
|
+
}
|
|
114
|
+
async writeState(environment, existingState) {
|
|
115
|
+
const filePath = getExistingStateFilePath(this.config, environment);
|
|
116
|
+
if (!fs.existsSync(this.config.stateDirectoryPath)) {
|
|
117
|
+
fs.mkdirSync(this.config.stateDirectoryPath, { recursive: true });
|
|
118
|
+
}
|
|
119
|
+
fs.writeFileSync(filePath, this.config.prettyState
|
|
120
|
+
? JSON.stringify(existingState, null, 2)
|
|
121
|
+
: JSON.stringify(existingState));
|
|
122
|
+
fs.writeFileSync(filePath, JSON.stringify(existingState, null, 2));
|
|
123
|
+
}
|
|
217
124
|
/**
|
|
218
125
|
* Revision
|
|
219
126
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
return
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
var filePath;
|
|
247
|
-
return __generator(this, function (_a) {
|
|
248
|
-
filePath = getRevisionFilePath(this.config);
|
|
249
|
-
if (!fs.existsSync(this.config.stateDirectoryPath)) {
|
|
250
|
-
mkdirp.sync(this.config.stateDirectoryPath);
|
|
251
|
-
}
|
|
252
|
-
fs.writeFileSync(filePath, revision);
|
|
253
|
-
return [2 /*return*/];
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
};
|
|
127
|
+
async readRevision() {
|
|
128
|
+
const filePath = getRevisionFilePath(this.config);
|
|
129
|
+
if (fs.existsSync(filePath)) {
|
|
130
|
+
return fs.readFileSync(filePath, "utf8");
|
|
131
|
+
}
|
|
132
|
+
// maintain backwards compatibility
|
|
133
|
+
try {
|
|
134
|
+
const pkg = require(path.join(this.rootDirectoryPath, "package.json"));
|
|
135
|
+
const pkgVersion = pkg.version;
|
|
136
|
+
if (pkgVersion) {
|
|
137
|
+
return pkgVersion;
|
|
138
|
+
}
|
|
139
|
+
return "0";
|
|
140
|
+
// eslint-disable-next-line
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
return "0";
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async writeRevision(revision) {
|
|
147
|
+
const filePath = getRevisionFilePath(this.config);
|
|
148
|
+
if (!fs.existsSync(this.config.stateDirectoryPath)) {
|
|
149
|
+
fs.mkdirSync(this.config.stateDirectoryPath, { recursive: true });
|
|
150
|
+
}
|
|
151
|
+
fs.writeFileSync(filePath, revision);
|
|
152
|
+
}
|
|
257
153
|
/**
|
|
258
154
|
* Datafile
|
|
259
155
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
156
|
+
getDatafilePath(options) {
|
|
157
|
+
const pattern = this.config.datafileNamePattern || "featurevisor-%s.json";
|
|
158
|
+
const fileName = pattern.replace("%s", `tag-${options.tag}`);
|
|
159
|
+
const dir = options.datafilesDir || this.config.datafilesDirectoryPath;
|
|
263
160
|
if (options.environment) {
|
|
264
161
|
return path.join(dir, options.environment, fileName);
|
|
265
162
|
}
|
|
266
163
|
return path.join(dir, fileName);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
outputFilePath = this.getDatafilePath(options);
|
|
289
|
-
fs.writeFileSync(outputFilePath, this.config.prettyDatafile
|
|
290
|
-
? JSON.stringify(datafileContent, null, 2)
|
|
291
|
-
: JSON.stringify(datafileContent));
|
|
292
|
-
root = path.resolve(dir, "..");
|
|
293
|
-
shortPath = outputFilePath.replace(root + path.sep, "");
|
|
294
|
-
console.log(" Datafile generated: ".concat(shortPath));
|
|
295
|
-
return [2 /*return*/];
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
};
|
|
164
|
+
}
|
|
165
|
+
async readDatafile(options) {
|
|
166
|
+
const filePath = this.getDatafilePath(options);
|
|
167
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
168
|
+
const datafileContent = JSON.parse(content);
|
|
169
|
+
return datafileContent;
|
|
170
|
+
}
|
|
171
|
+
async writeDatafile(datafileContent, options) {
|
|
172
|
+
const dir = options.datafilesDir || this.config.datafilesDirectoryPath;
|
|
173
|
+
const outputEnvironmentDirPath = options.environment
|
|
174
|
+
? path.join(dir, options.environment)
|
|
175
|
+
: dir;
|
|
176
|
+
fs.mkdirSync(outputEnvironmentDirPath, { recursive: true });
|
|
177
|
+
const outputFilePath = this.getDatafilePath(options);
|
|
178
|
+
fs.writeFileSync(outputFilePath, this.config.prettyDatafile
|
|
179
|
+
? JSON.stringify(datafileContent, null, 2)
|
|
180
|
+
: JSON.stringify(datafileContent));
|
|
181
|
+
const root = path.resolve(dir, "..");
|
|
182
|
+
const shortPath = outputFilePath.replace(root + path.sep, "");
|
|
183
|
+
console.log(` Datafile generated: ${shortPath}`);
|
|
184
|
+
}
|
|
299
185
|
/**
|
|
300
186
|
* History
|
|
301
187
|
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
else {
|
|
323
|
-
reject(code);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
})];
|
|
188
|
+
async getRawHistory(pathPatterns) {
|
|
189
|
+
const gitPaths = pathPatterns.join(" ");
|
|
190
|
+
const logCommand = `git log --name-only --pretty=format:"%h|%an|%aI" --relative --no-merges -- ${gitPaths}`;
|
|
191
|
+
const fullCommand = `(cd ${this.rootDirectoryPath} && ${logCommand})`;
|
|
192
|
+
return new Promise(function (resolve, reject) {
|
|
193
|
+
const child = (0, child_process_1.spawn)(fullCommand, { shell: true });
|
|
194
|
+
let result = "";
|
|
195
|
+
child.stdout.on("data", function (data) {
|
|
196
|
+
result += data.toString();
|
|
197
|
+
});
|
|
198
|
+
child.stderr.on("data", function (data) {
|
|
199
|
+
console.error(data.toString());
|
|
200
|
+
});
|
|
201
|
+
child.on("close", function (code) {
|
|
202
|
+
if (code === 0) {
|
|
203
|
+
resolve(result);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
reject(code);
|
|
207
|
+
}
|
|
327
208
|
});
|
|
328
209
|
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
var pathPatterns = [];
|
|
210
|
+
}
|
|
211
|
+
getPathPatterns(entityType, entityKey) {
|
|
212
|
+
let pathPatterns = [];
|
|
333
213
|
if (entityType && entityKey) {
|
|
334
214
|
pathPatterns = [this.getEntityPath(entityType, entityKey)];
|
|
335
215
|
}
|
|
@@ -359,93 +239,77 @@ var FilesystemAdapter = /** @class */ (function (_super) {
|
|
|
359
239
|
this.config.testsDirectoryPath,
|
|
360
240
|
];
|
|
361
241
|
}
|
|
362
|
-
return pathPatterns.map(
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
absolutePath = path.join(this.rootDirectoryPath, relativePath);
|
|
389
|
-
fileName = absolutePath.split(path.sep).pop();
|
|
390
|
-
relativeDir = path.dirname(absolutePath);
|
|
391
|
-
key = fileName.replace("." + this.parser.extension, "");
|
|
392
|
-
type = "attribute";
|
|
393
|
-
if (relativeDir === this.config.attributesDirectoryPath) {
|
|
394
|
-
type = "attribute";
|
|
395
|
-
}
|
|
396
|
-
else if (relativeDir === this.config.segmentsDirectoryPath) {
|
|
397
|
-
type = "segment";
|
|
398
|
-
}
|
|
399
|
-
else if (relativeDir === this.config.featuresDirectoryPath) {
|
|
400
|
-
type = "feature";
|
|
401
|
-
}
|
|
402
|
-
else if (relativeDir === this.config.groupsDirectoryPath) {
|
|
403
|
-
type = "group";
|
|
404
|
-
}
|
|
405
|
-
else if (relativeDir === this.config.testsDirectoryPath) {
|
|
406
|
-
type = "test";
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
entities.push({
|
|
412
|
-
type: type,
|
|
413
|
-
key: key,
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
if (entities.length === 0) {
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
fullHistory.push({
|
|
420
|
-
commit: commitHash,
|
|
421
|
-
author: author,
|
|
422
|
-
timestamp: timestamp,
|
|
423
|
-
entities: entities,
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
return [2 /*return*/, fullHistory];
|
|
242
|
+
return pathPatterns.map((p) => p.replace(this.rootDirectoryPath + path.sep, ""));
|
|
243
|
+
}
|
|
244
|
+
async listHistoryEntries(entityType, entityKey) {
|
|
245
|
+
const pathPatterns = this.getPathPatterns(entityType, entityKey);
|
|
246
|
+
const rawHistory = await this.getRawHistory(pathPatterns);
|
|
247
|
+
const fullHistory = [];
|
|
248
|
+
const blocks = rawHistory.split("\n\n");
|
|
249
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
250
|
+
const block = blocks[i];
|
|
251
|
+
if (block.length === 0) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const lines = block.split("\n");
|
|
255
|
+
const commitLine = lines[0];
|
|
256
|
+
const [commitHash, author, timestamp] = commitLine.split("|");
|
|
257
|
+
const entities = [];
|
|
258
|
+
const filePathLines = lines.slice(1);
|
|
259
|
+
for (let j = 0; j < filePathLines.length; j++) {
|
|
260
|
+
const relativePath = filePathLines[j];
|
|
261
|
+
const absolutePath = path.join(this.rootDirectoryPath, relativePath);
|
|
262
|
+
const fileName = absolutePath.split(path.sep).pop();
|
|
263
|
+
const relativeDir = path.dirname(absolutePath);
|
|
264
|
+
const key = fileName.replace("." + this.parser.extension, "");
|
|
265
|
+
let type = "attribute";
|
|
266
|
+
if (relativeDir === this.config.attributesDirectoryPath) {
|
|
267
|
+
type = "attribute";
|
|
427
268
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
269
|
+
else if (relativeDir === this.config.segmentsDirectoryPath) {
|
|
270
|
+
type = "segment";
|
|
271
|
+
}
|
|
272
|
+
else if (relativeDir === this.config.featuresDirectoryPath) {
|
|
273
|
+
type = "feature";
|
|
274
|
+
}
|
|
275
|
+
else if (relativeDir === this.config.groupsDirectoryPath) {
|
|
276
|
+
type = "group";
|
|
277
|
+
}
|
|
278
|
+
else if (relativeDir === this.config.testsDirectoryPath) {
|
|
279
|
+
type = "test";
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
entities.push({
|
|
285
|
+
type,
|
|
286
|
+
key,
|
|
443
287
|
});
|
|
444
|
-
|
|
288
|
+
}
|
|
289
|
+
if (entities.length === 0) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
fullHistory.push({
|
|
293
|
+
commit: commitHash,
|
|
294
|
+
author,
|
|
295
|
+
timestamp,
|
|
296
|
+
entities,
|
|
445
297
|
});
|
|
298
|
+
}
|
|
299
|
+
return fullHistory;
|
|
300
|
+
}
|
|
301
|
+
async readCommit(commitHash, entityType, entityKey) {
|
|
302
|
+
const pathPatterns = this.getPathPatterns(entityType, entityKey);
|
|
303
|
+
const gitPaths = pathPatterns.join(" ");
|
|
304
|
+
const logCommand = `git show ${commitHash} --relative -- ${gitPaths}`;
|
|
305
|
+
const fullCommand = `(cd ${this.rootDirectoryPath} && ${logCommand})`;
|
|
306
|
+
const gitShowOutput = (0, child_process_1.execSync)(fullCommand, { encoding: "utf8" }).toString();
|
|
307
|
+
const commit = (0, git_1.getCommit)(gitShowOutput, {
|
|
308
|
+
rootDirectoryPath: this.rootDirectoryPath,
|
|
309
|
+
projectConfig: this.config,
|
|
446
310
|
});
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
}
|
|
311
|
+
return commit;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
450
314
|
exports.FilesystemAdapter = FilesystemAdapter;
|
|
451
315
|
//# sourceMappingURL=filesystemAdapter.js.map
|