@featurevisor/core 0.53.5 → 0.55.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/.eslintcache +1 -1
- package/CHANGELOG.md +22 -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/traffic.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/traffic.ts.html +1 -1
- package/lib/config/index.d.ts +2 -0
- package/lib/config/index.js +19 -0
- package/lib/config/index.js.map +1 -0
- package/lib/{datasource → config}/parsers.d.ts +3 -3
- package/lib/config/parsers.js +32 -0
- package/lib/config/parsers.js.map +1 -0
- package/lib/{config.d.ts → config/projectConfig.d.ts} +2 -1
- package/lib/{config.js → config/projectConfig.js} +16 -5
- package/lib/config/projectConfig.js.map +1 -0
- package/lib/datasource/adapter.d.ts +10 -0
- package/lib/datasource/adapter.js +10 -0
- package/lib/datasource/adapter.js.map +1 -0
- package/lib/datasource/datasource.d.ts +11 -18
- package/lib/datasource/datasource.js +32 -130
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/filesystemAdapter.d.ts +20 -0
- package/lib/datasource/filesystemAdapter.js +170 -0
- package/lib/datasource/filesystemAdapter.js.map +1 -0
- package/lib/datasource/index.d.ts +2 -1
- package/lib/datasource/index.js +2 -1
- package/lib/datasource/index.js.map +1 -1
- package/lib/{init.js → init/index.js} +1 -1
- package/lib/init/index.js.map +1 -0
- package/lib/linter/checkCircularDependency.js +1 -1
- package/lib/linter/checkCircularDependency.js.map +1 -1
- package/lib/{restore.d.ts → restore/index.d.ts} +1 -1
- package/lib/{restore.js → restore/index.js} +1 -1
- package/lib/restore/index.js.map +1 -0
- package/lib/tester/testProject.js +1 -1
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.js +1 -1
- package/lib/tester/testSegment.js.map +1 -1
- package/package.json +5 -5
- package/src/config/index.ts +2 -0
- package/src/config/parsers.ts +40 -0
- package/src/{config.ts → config/projectConfig.ts} +20 -5
- package/src/datasource/adapter.ts +15 -0
- package/src/datasource/datasource.ts +44 -131
- package/src/datasource/filesystemAdapter.ts +109 -0
- package/src/datasource/index.ts +2 -1
- package/src/linter/checkCircularDependency.ts +1 -1
- package/src/{restore.ts → restore/index.ts} +1 -1
- package/src/tester/testProject.ts +1 -1
- package/src/tester/testSegment.ts +1 -1
- package/lib/config.js.map +0 -1
- package/lib/datasource/parsers.js +0 -19
- package/lib/datasource/parsers.js.map +0 -1
- package/lib/init.js.map +0 -1
- package/lib/restore.js.map +0 -1
- package/src/datasource/parsers.ts +0 -26
- /package/lib/{init.d.ts → init/index.d.ts} +0 -0
- /package/src/{init.ts → init/index.ts} +0 -0
|
@@ -36,143 +36,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.Datasource =
|
|
40
|
-
var path = require("path");
|
|
41
|
-
var fs = require("fs");
|
|
42
|
-
var mkdirp = require("mkdirp");
|
|
43
|
-
var parsers_1 = require("./parsers");
|
|
44
|
-
function getExistingStateFilePath(projectConfig, environment) {
|
|
45
|
-
return path.join(projectConfig.stateDirectoryPath, "existing-state-".concat(environment, ".json"));
|
|
46
|
-
}
|
|
47
|
-
exports.getExistingStateFilePath = getExistingStateFilePath;
|
|
39
|
+
exports.Datasource = void 0;
|
|
48
40
|
var Datasource = /** @class */ (function () {
|
|
49
41
|
function Datasource(config) {
|
|
50
42
|
this.config = config;
|
|
51
|
-
|
|
52
|
-
// built-in parsers
|
|
53
|
-
if (typeof parsers_1.parsers[config.parser] !== "function") {
|
|
54
|
-
throw new Error("Invalid parser: ".concat(config.parser));
|
|
55
|
-
}
|
|
56
|
-
this.extension = config.parser;
|
|
57
|
-
this.parse = parsers_1.parsers[config.parser];
|
|
58
|
-
}
|
|
59
|
-
else if (typeof config.parser === "object") {
|
|
60
|
-
// custom parser
|
|
61
|
-
if (typeof config.parser.extension !== "string") {
|
|
62
|
-
throw new Error("Invalid parser extension: ".concat(config.parser.extension));
|
|
63
|
-
}
|
|
64
|
-
if (typeof config.parser.parse !== "function") {
|
|
65
|
-
throw new Error("Invalid parser parse function: ".concat(config.parser.parse));
|
|
66
|
-
}
|
|
67
|
-
this.extension = config.parser.extension;
|
|
68
|
-
this.parse = config.parser.parse;
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
throw new Error("Invalid parser: ".concat(config.parser));
|
|
72
|
-
}
|
|
43
|
+
this.adapter = new config.adapter(config);
|
|
73
44
|
}
|
|
45
|
+
// @TODO: only site generator needs it, find a way to get it out of here later
|
|
74
46
|
Datasource.prototype.getExtension = function () {
|
|
75
|
-
return this.extension;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Common methods for entities
|
|
79
|
-
*/
|
|
80
|
-
Datasource.prototype.listEntities = function (entityType) {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
-
var directoryPath;
|
|
83
|
-
var _this = this;
|
|
84
|
-
return __generator(this, function (_a) {
|
|
85
|
-
directoryPath = this.getEntityDirectoryPath(entityType);
|
|
86
|
-
if (!fs.existsSync(directoryPath)) {
|
|
87
|
-
return [2 /*return*/, []];
|
|
88
|
-
}
|
|
89
|
-
return [2 /*return*/, fs
|
|
90
|
-
.readdirSync(directoryPath)
|
|
91
|
-
.filter(function (fileName) { return fileName.endsWith(".".concat(_this.extension)); })
|
|
92
|
-
.map(function (fileName) { return fileName.replace(".".concat(_this.extension), ""); })];
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
Datasource.prototype.getEntityDirectoryPath = function (entityType) {
|
|
97
|
-
if (entityType === "feature") {
|
|
98
|
-
return this.config.featuresDirectoryPath;
|
|
99
|
-
}
|
|
100
|
-
else if (entityType === "group") {
|
|
101
|
-
return this.config.groupsDirectoryPath;
|
|
102
|
-
}
|
|
103
|
-
else if (entityType === "segment") {
|
|
104
|
-
return this.config.segmentsDirectoryPath;
|
|
105
|
-
}
|
|
106
|
-
else if (entityType === "test") {
|
|
107
|
-
return this.config.testsDirectoryPath;
|
|
108
|
-
}
|
|
109
|
-
return this.config.attributesDirectoryPath;
|
|
110
|
-
};
|
|
111
|
-
Datasource.prototype.getEntityPath = function (entityType, entityKey) {
|
|
112
|
-
var basePath = this.getEntityDirectoryPath(entityType);
|
|
113
|
-
return path.join(basePath, "".concat(entityKey, ".").concat(this.extension));
|
|
114
|
-
};
|
|
115
|
-
Datasource.prototype.entityExists = function (entityType, entityKey) {
|
|
116
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
-
var entityPath;
|
|
118
|
-
return __generator(this, function (_a) {
|
|
119
|
-
entityPath = this.getEntityPath(entityType, entityKey);
|
|
120
|
-
return [2 /*return*/, fs.existsSync(entityPath)];
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
Datasource.prototype.readEntity = function (entityType, entityKey) {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
-
var filePath;
|
|
127
|
-
return __generator(this, function (_a) {
|
|
128
|
-
filePath = this.getEntityPath(entityType, entityKey);
|
|
129
|
-
return [2 /*return*/, fs.readFileSync(filePath, "utf8")];
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
Datasource.prototype.parseEntity = function (entityType, entityKey) {
|
|
134
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
135
|
-
var entityContent;
|
|
136
|
-
return __generator(this, function (_a) {
|
|
137
|
-
switch (_a.label) {
|
|
138
|
-
case 0: return [4 /*yield*/, this.readEntity(entityType, entityKey)];
|
|
139
|
-
case 1:
|
|
140
|
-
entityContent = _a.sent();
|
|
141
|
-
return [2 /*return*/, this.parse(entityContent)];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
});
|
|
47
|
+
return this.config.parser.extension;
|
|
145
48
|
};
|
|
146
49
|
/**
|
|
147
50
|
* State
|
|
148
51
|
*/
|
|
149
52
|
Datasource.prototype.readState = function (environment) {
|
|
150
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
-
var filePath;
|
|
152
54
|
return __generator(this, function (_a) {
|
|
153
|
-
|
|
154
|
-
if (!fs.existsSync(filePath)) {
|
|
155
|
-
return [2 /*return*/, {
|
|
156
|
-
features: {},
|
|
157
|
-
}];
|
|
158
|
-
}
|
|
159
|
-
return [2 /*return*/, require(filePath)];
|
|
55
|
+
return [2 /*return*/, this.adapter.readState(environment)];
|
|
160
56
|
});
|
|
161
57
|
});
|
|
162
58
|
};
|
|
163
59
|
Datasource.prototype.writeState = function (environment, existingState) {
|
|
164
60
|
return __awaiter(this, void 0, void 0, function () {
|
|
165
|
-
var filePath;
|
|
166
61
|
return __generator(this, function (_a) {
|
|
167
|
-
|
|
168
|
-
if (!fs.existsSync(this.config.stateDirectoryPath)) {
|
|
169
|
-
mkdirp.sync(this.config.stateDirectoryPath);
|
|
170
|
-
}
|
|
171
|
-
fs.writeFileSync(filePath, this.config.prettyState
|
|
172
|
-
? JSON.stringify(existingState, null, 2)
|
|
173
|
-
: JSON.stringify(existingState));
|
|
174
|
-
fs.writeFileSync(filePath, JSON.stringify(existingState, null, 2));
|
|
175
|
-
return [2 /*return*/];
|
|
62
|
+
return [2 /*return*/, this.adapter.writeState(environment, existingState)];
|
|
176
63
|
});
|
|
177
64
|
});
|
|
178
65
|
};
|
|
@@ -184,14 +71,17 @@ var Datasource = /** @class */ (function () {
|
|
|
184
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
185
72
|
return __generator(this, function (_a) {
|
|
186
73
|
switch (_a.label) {
|
|
187
|
-
case 0: return [4 /*yield*/, this.listEntities("feature")];
|
|
74
|
+
case 0: return [4 /*yield*/, this.adapter.listEntities("feature")];
|
|
188
75
|
case 1: return [2 /*return*/, _a.sent()];
|
|
189
76
|
}
|
|
190
77
|
});
|
|
191
78
|
});
|
|
192
79
|
};
|
|
80
|
+
Datasource.prototype.featureExists = function (featureKey) {
|
|
81
|
+
return this.adapter.entityExists("feature", featureKey);
|
|
82
|
+
};
|
|
193
83
|
Datasource.prototype.readFeature = function (featureKey) {
|
|
194
|
-
return this.parseEntity("feature", featureKey);
|
|
84
|
+
return this.adapter.parseEntity("feature", featureKey);
|
|
195
85
|
};
|
|
196
86
|
Datasource.prototype.getRequiredFeaturesChain = function (featureKey, chain) {
|
|
197
87
|
if (chain === void 0) { chain = new Set(); }
|
|
@@ -201,7 +91,7 @@ var Datasource = /** @class */ (function () {
|
|
|
201
91
|
switch (_b.label) {
|
|
202
92
|
case 0:
|
|
203
93
|
chain.add(featureKey);
|
|
204
|
-
if (!this.entityExists("feature", featureKey)) {
|
|
94
|
+
if (!this.adapter.entityExists("feature", featureKey)) {
|
|
205
95
|
throw new Error("Feature not found: ".concat(featureKey));
|
|
206
96
|
}
|
|
207
97
|
return [4 /*yield*/, this.readFeature(featureKey)];
|
|
@@ -233,35 +123,47 @@ var Datasource = /** @class */ (function () {
|
|
|
233
123
|
};
|
|
234
124
|
// segments
|
|
235
125
|
Datasource.prototype.listSegments = function () {
|
|
236
|
-
return this.listEntities("segment");
|
|
126
|
+
return this.adapter.listEntities("segment");
|
|
127
|
+
};
|
|
128
|
+
Datasource.prototype.segmentExists = function (segmentKey) {
|
|
129
|
+
return this.adapter.entityExists("segment", segmentKey);
|
|
237
130
|
};
|
|
238
131
|
Datasource.prototype.readSegment = function (segmentKey) {
|
|
239
|
-
return this.parseEntity("segment", segmentKey);
|
|
132
|
+
return this.adapter.parseEntity("segment", segmentKey);
|
|
240
133
|
};
|
|
241
134
|
// attributes
|
|
242
135
|
Datasource.prototype.listAttributes = function () {
|
|
243
|
-
return this.listEntities("attribute");
|
|
136
|
+
return this.adapter.listEntities("attribute");
|
|
137
|
+
};
|
|
138
|
+
Datasource.prototype.attributeExists = function (attributeKey) {
|
|
139
|
+
return this.adapter.entityExists("attribute", attributeKey);
|
|
244
140
|
};
|
|
245
141
|
Datasource.prototype.readAttribute = function (attributeKey) {
|
|
246
|
-
return this.parseEntity("attribute", attributeKey);
|
|
142
|
+
return this.adapter.parseEntity("attribute", attributeKey);
|
|
247
143
|
};
|
|
248
144
|
// groups
|
|
249
145
|
Datasource.prototype.listGroups = function () {
|
|
250
146
|
return __awaiter(this, void 0, void 0, function () {
|
|
251
147
|
return __generator(this, function (_a) {
|
|
252
|
-
return [2 /*return*/, this.listEntities("group")];
|
|
148
|
+
return [2 /*return*/, this.adapter.listEntities("group")];
|
|
253
149
|
});
|
|
254
150
|
});
|
|
255
151
|
};
|
|
152
|
+
Datasource.prototype.groupExists = function (groupKey) {
|
|
153
|
+
return this.adapter.entityExists("group", groupKey);
|
|
154
|
+
};
|
|
256
155
|
Datasource.prototype.readGroup = function (groupKey) {
|
|
257
|
-
return this.parseEntity("group", groupKey);
|
|
156
|
+
return this.adapter.parseEntity("group", groupKey);
|
|
258
157
|
};
|
|
259
158
|
// tests
|
|
260
159
|
Datasource.prototype.listTests = function () {
|
|
261
|
-
return this.listEntities("test");
|
|
160
|
+
return this.adapter.listEntities("test");
|
|
262
161
|
};
|
|
263
162
|
Datasource.prototype.readTest = function (testKey) {
|
|
264
|
-
return this.parseEntity("test", testKey);
|
|
163
|
+
return this.adapter.parseEntity("test", testKey);
|
|
164
|
+
};
|
|
165
|
+
Datasource.prototype.getTestSpecName = function (testKey) {
|
|
166
|
+
return "".concat(testKey, ".").concat(this.getExtension());
|
|
265
167
|
};
|
|
266
168
|
return Datasource;
|
|
267
169
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../src/datasource/datasource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;IAChD,CAAC;IAED,oCAAe,GAAf,UAAgB,YAA0B;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC;IAED,kCAAa,GAAb,UAAc,YAA0B;QACtC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAY,WAAW,EAAE,YAAY,CAAC,CAAC;IACxE,CAAC;IAED,SAAS;IACH,+BAAU,GAAhB;;;gBACE,sBAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,EAAC;;;KAC3C;IAED,gCAAW,GAAX,UAAY,QAAgB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,8BAAS,GAAT,UAAU,QAAgB;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAQ,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC5D,CAAC;IAED,QAAQ;IACR,8BAAS,GAAT;QACE,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,6BAAQ,GAAR,UAAS,OAAe;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAO,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;IAED,oCAAe,GAAf,UAAgB,OAAe;QAC7B,OAAO,UAAG,OAAO,cAAI,IAAI,CAAC,YAAY,EAAE,CAAE,CAAC;IAC7C,CAAC;IACH,iBAAC;AAAD,CAAC,AAxHD,IAwHC;AAxHY,gCAAU"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ExistingState, EnvironmentKey } from "@featurevisor/types";
|
|
2
|
+
import { Adapter, EntityType } from "./adapter";
|
|
3
|
+
import { ProjectConfig } from "../config";
|
|
4
|
+
export declare function getExistingStateFilePath(projectConfig: ProjectConfig, environment: EnvironmentKey): string;
|
|
5
|
+
export declare class FilesystemAdapter extends Adapter {
|
|
6
|
+
private config;
|
|
7
|
+
private parser;
|
|
8
|
+
constructor(config: ProjectConfig);
|
|
9
|
+
getEntityDirectoryPath(entityType: EntityType): string;
|
|
10
|
+
getEntityPath(entityType: EntityType, entityKey: string): string;
|
|
11
|
+
listEntities(entityType: EntityType): Promise<string[]>;
|
|
12
|
+
entityExists(entityType: EntityType, entityKey: string): Promise<boolean>;
|
|
13
|
+
readEntity(entityType: EntityType, entityKey: string): Promise<string>;
|
|
14
|
+
parseEntity<T>(entityType: EntityType, entityKey: string): Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* State
|
|
17
|
+
*/
|
|
18
|
+
readState(environment: EnvironmentKey): Promise<ExistingState>;
|
|
19
|
+
writeState(environment: EnvironmentKey, existingState: ExistingState): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
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;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.FilesystemAdapter = exports.getExistingStateFilePath = void 0;
|
|
55
|
+
var fs = require("fs");
|
|
56
|
+
var path = require("path");
|
|
57
|
+
var mkdirp = require("mkdirp");
|
|
58
|
+
var adapter_1 = require("./adapter");
|
|
59
|
+
function getExistingStateFilePath(projectConfig, environment) {
|
|
60
|
+
return path.join(projectConfig.stateDirectoryPath, "existing-state-".concat(environment, ".json"));
|
|
61
|
+
}
|
|
62
|
+
exports.getExistingStateFilePath = getExistingStateFilePath;
|
|
63
|
+
var FilesystemAdapter = /** @class */ (function (_super) {
|
|
64
|
+
__extends(FilesystemAdapter, _super);
|
|
65
|
+
function FilesystemAdapter(config) {
|
|
66
|
+
var _this = _super.call(this) || this;
|
|
67
|
+
_this.config = config;
|
|
68
|
+
_this.parser = config.parser;
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
FilesystemAdapter.prototype.getEntityDirectoryPath = function (entityType) {
|
|
72
|
+
if (entityType === "feature") {
|
|
73
|
+
return this.config.featuresDirectoryPath;
|
|
74
|
+
}
|
|
75
|
+
else if (entityType === "group") {
|
|
76
|
+
return this.config.groupsDirectoryPath;
|
|
77
|
+
}
|
|
78
|
+
else if (entityType === "segment") {
|
|
79
|
+
return this.config.segmentsDirectoryPath;
|
|
80
|
+
}
|
|
81
|
+
else if (entityType === "test") {
|
|
82
|
+
return this.config.testsDirectoryPath;
|
|
83
|
+
}
|
|
84
|
+
return this.config.attributesDirectoryPath;
|
|
85
|
+
};
|
|
86
|
+
FilesystemAdapter.prototype.getEntityPath = function (entityType, entityKey) {
|
|
87
|
+
var basePath = this.getEntityDirectoryPath(entityType);
|
|
88
|
+
return path.join(basePath, "".concat(entityKey, ".").concat(this.parser.extension));
|
|
89
|
+
};
|
|
90
|
+
FilesystemAdapter.prototype.listEntities = function (entityType) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var directoryPath;
|
|
93
|
+
var _this = this;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
directoryPath = this.getEntityDirectoryPath(entityType);
|
|
96
|
+
if (!fs.existsSync(directoryPath)) {
|
|
97
|
+
return [2 /*return*/, []];
|
|
98
|
+
}
|
|
99
|
+
return [2 /*return*/, fs
|
|
100
|
+
.readdirSync(directoryPath)
|
|
101
|
+
.filter(function (fileName) { return fileName.endsWith(".".concat(_this.parser.extension)); })
|
|
102
|
+
.map(function (fileName) { return fileName.replace(".".concat(_this.parser.extension), ""); })];
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
FilesystemAdapter.prototype.entityExists = function (entityType, entityKey) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
var entityPath;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
entityPath = this.getEntityPath(entityType, entityKey);
|
|
111
|
+
return [2 /*return*/, fs.existsSync(entityPath)];
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
FilesystemAdapter.prototype.readEntity = function (entityType, entityKey) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
var filePath;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
filePath = this.getEntityPath(entityType, entityKey);
|
|
120
|
+
return [2 /*return*/, fs.readFileSync(filePath, "utf8")];
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
FilesystemAdapter.prototype.parseEntity = function (entityType, entityKey) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var filePath, entityContent;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
filePath = this.getEntityPath(entityType, entityKey);
|
|
129
|
+
entityContent = fs.readFileSync(filePath, "utf8");
|
|
130
|
+
return [2 /*return*/, this.parser.parse(entityContent, filePath)];
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* State
|
|
136
|
+
*/
|
|
137
|
+
FilesystemAdapter.prototype.readState = function (environment) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
+
var filePath;
|
|
140
|
+
return __generator(this, function (_a) {
|
|
141
|
+
filePath = getExistingStateFilePath(this.config, environment);
|
|
142
|
+
if (!fs.existsSync(filePath)) {
|
|
143
|
+
return [2 /*return*/, {
|
|
144
|
+
features: {},
|
|
145
|
+
}];
|
|
146
|
+
}
|
|
147
|
+
return [2 /*return*/, require(filePath)];
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
FilesystemAdapter.prototype.writeState = function (environment, existingState) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
+
var filePath;
|
|
154
|
+
return __generator(this, function (_a) {
|
|
155
|
+
filePath = getExistingStateFilePath(this.config, environment);
|
|
156
|
+
if (!fs.existsSync(this.config.stateDirectoryPath)) {
|
|
157
|
+
mkdirp.sync(this.config.stateDirectoryPath);
|
|
158
|
+
}
|
|
159
|
+
fs.writeFileSync(filePath, this.config.prettyState
|
|
160
|
+
? JSON.stringify(existingState, null, 2)
|
|
161
|
+
: JSON.stringify(existingState));
|
|
162
|
+
fs.writeFileSync(filePath, JSON.stringify(existingState, null, 2));
|
|
163
|
+
return [2 /*return*/];
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
return FilesystemAdapter;
|
|
168
|
+
}(adapter_1.Adapter));
|
|
169
|
+
exports.FilesystemAdapter = FilesystemAdapter;
|
|
170
|
+
//# sourceMappingURL=filesystemAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystemAdapter.js","sourceRoot":"","sources":["../../src/datasource/filesystemAdapter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAyB;AACzB,2BAA6B;AAE7B,+BAAiC;AAIjC,qCAAgD;AAGhD,SAAgB,wBAAwB,CACtC,aAA4B,EAC5B,WAA2B;IAE3B,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,kBAAkB,EAAE,yBAAkB,WAAW,UAAO,CAAC,CAAC;AAC3F,CAAC;AALD,4DAKC;AAED;IAAuC,qCAAO;IAG5C,2BAAoB,MAAqB;QAAzC,YACE,iBAAO,SAGR;QAJmB,YAAM,GAAN,MAAM,CAAe;QAGvC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAsB,CAAC;;IAC9C,CAAC;IAED,kDAAsB,GAAtB,UAAuB,UAAsB;QAC3C,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC;SAC1C;aAAM,IAAI,UAAU,KAAK,OAAO,EAAE;YACjC,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC;SACxC;aAAM,IAAI,UAAU,KAAK,SAAS,EAAE;YACnC,OAAO,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC;SAC1C;aAAM,IAAI,UAAU,KAAK,MAAM,EAAE;YAChC,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;SACvC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC;IAC7C,CAAC;IAED,yCAAa,GAAb,UAAc,UAAsB,EAAE,SAAiB;QACrD,IAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,UA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this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./datasource"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./adapter"), exports);
|
|
19
|
+
__exportStar(require("./filesystemAdapter"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4CAA0B;AAC1B,sDAAoC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/init/index.ts"],"names":[],"mappings":";;;AAAA,+BAA0B;AAC1B,yBAA2B;AAEd,QAAA,eAAe,GAAG,aAAa,CAAC;AAEhC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAC9B,QAAA,kBAAkB,GAAG,cAAc,CAAC;AACpC,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAE9B,QAAA,gBAAgB,GAAG,sCAA+B,yBAAiB,cAAI,0BAAkB,qBAAW,4BAAoB,CAAE,CAAC;AAExI,SAAS,cAAc,CAAC,WAAmB;IACzC,OAAO,UAAG,0BAAkB,cAAI,4BAAoB,uBAAa,WAAW,MAAG,CAAC;AAClF,CAAC;AAED,SAAgB,WAAW,CACzB,aAAqB,EACrB,WAAqC;IAArC,4BAAA,EAAA,cAAsB,uBAAe;IAErC,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO;QAClC,eAAK,CAAC,GAAG,CAAC,wBAAgB,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,UAAC,QAAQ;YACpE,QAAQ,CAAC,IAAI;iBACV,IAAI,CACH,GAAG,CAAC,CAAC,CAAC;gBACJ,CAAC,EAAE,aAAa;gBAChB,MAAM,EAAE,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,EAA/C,CAA+C;gBACjE,KAAK,EAAE,CAAC;aACT,CAAC,CACH;iBACA,EAAE,CAAC,OAAO,EAAE,UAAC,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAEjB,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,CAAC;iBACD,EAAE,CAAC,QAAQ,EAAE;gBACZ,OAAO,CAAC,GAAG,CAAC,gCAAyB,aAAa,CAAE,CAAC,CAAC;gBACtD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAChB,OAAO,CAAC,GAAG,CAAC,oDAAkD,CAAC,CAAC;gBAEhE,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA5BD,kCA4BC"}
|
|
@@ -60,7 +60,7 @@ function checkForCircularDependencyInRequired(datasource, featureKey, required,
|
|
|
60
60
|
if (chain.indexOf(featureKey) > -1) {
|
|
61
61
|
throw new Error("circular dependency found: ".concat(chain.join(" -> ")));
|
|
62
62
|
}
|
|
63
|
-
return [4 /*yield*/, datasource.
|
|
63
|
+
return [4 /*yield*/, datasource.featureExists(featureKey)];
|
|
64
64
|
case 2:
|
|
65
65
|
requiredFeatureExists = _a.sent();
|
|
66
66
|
if (!requiredFeatureExists) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkCircularDependency.js","sourceRoot":"","sources":["../../src/linter/checkCircularDependency.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SA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,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;wBAC7B,sBAAO;qBACR;0BAEqC,EAAZ,6BAAY;;;yBAAZ,CAAA,0BAAY,CAAA;oBAA3B,WAAW;oBACpB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAExB,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE;wBAClC,MAAM,IAAI,KAAK,CAAC,qCAA8B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAE,CAAC,CAAC;qBACrE;oBAE6B,qBAAM,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,EAAA;;oBAAlE,qBAAqB,GAAG,SAA0C;oBAExE,IAAI,CAAC,qBAAqB,EAAE;wBAC1B,MAAM,IAAI,KAAK,CAAC,6BAAqB,WAAW,iBAAa,CAAC,CAAC;qBAChE;oBAE6B,qBAAM,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,EAAA;;oBAAjE,qBAAqB,GAAG,SAAyC;yBAEnE,qBAAqB,CAAC,QAAQ,EAA9B,wBAA8B;oBAChC,qBAAM,oCAAoC,CACxC,UAAU,EACV,UAAU,EACV,qBAAqB,CAAC,QAAQ,EAC9B,KAAK,CACN,EAAA;;oBALD,SAKC,CAAC;;;oBArBoB,IAAY,CAAA;;;;;;CAwBvC;AAxCD,oFAwCC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Dependencies } from "
|
|
1
|
+
import { Dependencies } from "../dependencies";
|
|
2
2
|
export declare function restoreProject(deps: Dependencies): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/restore/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,+CAAyC;AAIzC,SAAsB,cAAc,CAAC,IAAkB;;;;YAC7C,iBAAiB,GAAoB,IAAI,kBAAxB,EAAE,aAAa,GAAK,IAAI,cAAT,CAAU;YAE5C,oBAAoB,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;YAC1F,GAAG,GAAG,0BAAmB,oBAAoB,SAAG,IAAI,CAAC,GAAG,CAAE,CAAC;YAEjE,IAAI;gBACF,IAAA,wBAAQ,EAAC,GAAG,EAAE;oBACZ,GAAG,EAAE,iBAAiB;iBACvB,CAAC,CAAC;gBAEH,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;aACnD;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;gBAEjC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;aACnD;;;;CACF;AAjBD,wCAiBC"}
|
|
@@ -67,7 +67,7 @@ function testProject(deps) {
|
|
|
67
67
|
case 2:
|
|
68
68
|
if (!(_i < testFiles_1.length)) return [3 /*break*/, 9];
|
|
69
69
|
testFile = testFiles_1[_i];
|
|
70
|
-
testFilePath = datasource.
|
|
70
|
+
testFilePath = datasource.getTestSpecName(testFile);
|
|
71
71
|
console.log("");
|
|
72
72
|
console.log(cliFormat_1.CLI_FORMAT_BOLD, "Testing: ".concat(testFilePath.replace(rootDirectoryPath, "")));
|
|
73
73
|
return [4 /*yield*/, datasource.readTest(testFile)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testProject.js","sourceRoot":"","sources":["../../src/tester/testProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uBAAyB;AAIzB,6CAA4C;AAC5C,6CAA4C;AAC5C,yCAAgF;AAGhF,SAAsB,WAAW,CAAC,IAAkB;;;;;;oBAC1C,iBAAiB,GAAgC,IAAI,kBAApC,EAAE,aAAa,GAAiB,IAAI,cAArB,EAAE,UAAU,GAAK,IAAI,WA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,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;AA9DD,kCA8DC"}
|
|
@@ -48,7 +48,7 @@ function testSegment(datasource, test) {
|
|
|
48
48
|
hasError = false;
|
|
49
49
|
segmentKey = test.segment;
|
|
50
50
|
console.log(cliFormat_1.CLI_FORMAT_BOLD, " Segment \"".concat(segmentKey, "\":"));
|
|
51
|
-
return [4 /*yield*/, datasource.
|
|
51
|
+
return [4 /*yield*/, datasource.segmentExists(segmentKey)];
|
|
52
52
|
case 1:
|
|
53
53
|
segmentExists = _a.sent();
|
|
54
54
|
if (!segmentExists) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testSegment.js","sourceRoot":"","sources":["../../src/tester/testSegment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA4D;AAI5D,yCAA8D;AAE9D,SAAsB,WAAW,CAAC,UAAsB,EAAE,IAAiB;;;;;;oBACrE,QAAQ,GAAG,KAAK,CAAC;oBAEf,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC;oBAEhC,OAAO,CAAC,GAAG,CAAC,2BAAe,EAAE,sBAAc,UAAU,QAAI,CAAC,CAAC;oBAErC,qBAAM,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"testSegment.js","sourceRoot":"","sources":["../../src/tester/testSegment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA4D;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B;AAnCD,kCAmCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@featurevisor/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0",
|
|
4
4
|
"description": "Core package of Featurevisor for Node.js usage",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
},
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@featurevisor/sdk": "^0.
|
|
48
|
-
"@featurevisor/site": "^0.
|
|
49
|
-
"@featurevisor/types": "^0.
|
|
47
|
+
"@featurevisor/sdk": "^0.55.0",
|
|
48
|
+
"@featurevisor/site": "^0.55.0",
|
|
49
|
+
"@featurevisor/types": "^0.55.0",
|
|
50
50
|
"axios": "^1.3.4",
|
|
51
51
|
"joi": "^17.8.3",
|
|
52
52
|
"js-yaml": "^4.1.0",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"@types/js-yaml": "^4.0.5",
|
|
58
58
|
"@types/tar": "^6.1.4"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "b736fb93a9e8bdf76f84a71c482182ab42505b63"
|
|
61
61
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as YAML from "js-yaml";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* If we want to add more built-in parsers,
|
|
5
|
+
* add them to this object with new file extension as the key,
|
|
6
|
+
* and a function that takes file content as string and returns parsed object as the value.
|
|
7
|
+
*/
|
|
8
|
+
export const parsers: { [key: string]: CustomParser } = {
|
|
9
|
+
// YAML
|
|
10
|
+
yml: {
|
|
11
|
+
extension: "yml",
|
|
12
|
+
parse: function <T>(content: string): T {
|
|
13
|
+
return YAML.load(content) as T;
|
|
14
|
+
},
|
|
15
|
+
stringify: function (content: any) {
|
|
16
|
+
return YAML.dump(content);
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
// JSON
|
|
21
|
+
json: {
|
|
22
|
+
extension: "json",
|
|
23
|
+
parse: function <T>(content: string): T {
|
|
24
|
+
return JSON.parse(content) as T;
|
|
25
|
+
},
|
|
26
|
+
stringify: function (content: any) {
|
|
27
|
+
return JSON.stringify(content, null, 2);
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type BuiltInParser = keyof typeof parsers; // keys of parsers object
|
|
33
|
+
|
|
34
|
+
export interface CustomParser {
|
|
35
|
+
extension: string;
|
|
36
|
+
parse: <T>(content: string, filePath?: string) => T;
|
|
37
|
+
stringify: (content: any) => string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Parser = BuiltInParser | CustomParser;
|