@featurevisor/core 2.5.0 → 2.6.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 +11 -0
- package/coverage/clover.xml +444 -78
- package/coverage/coverage-final.json +9 -3
- package/coverage/lcov-report/index.html +42 -42
- package/coverage/lcov-report/lib/builder/allocator.js.html +1 -1
- package/coverage/lcov-report/lib/builder/buildScopedConditions.js.html +373 -0
- package/coverage/lcov-report/lib/builder/buildScopedDatafile.js.html +403 -0
- package/coverage/lcov-report/lib/builder/buildScopedSegments.js.html +379 -0
- package/coverage/lcov-report/lib/builder/index.html +53 -8
- package/coverage/lcov-report/lib/builder/revision.js.html +1 -1
- package/coverage/lcov-report/lib/builder/traffic.js.html +1 -1
- package/coverage/lcov-report/lib/list/index.html +14 -14
- package/coverage/lcov-report/lib/list/matrix.js.html +23 -8
- package/coverage/lcov-report/lib/tester/helpers.js.html +1 -1
- package/coverage/lcov-report/lib/tester/index.html +1 -1
- package/coverage/lcov-report/src/builder/allocator.ts.html +1 -1
- package/coverage/lcov-report/src/builder/buildScopedConditions.ts.html +487 -0
- package/coverage/lcov-report/src/builder/buildScopedDatafile.ts.html +604 -0
- package/coverage/lcov-report/src/builder/buildScopedSegments.ts.html +544 -0
- package/coverage/lcov-report/src/builder/index.html +55 -10
- package/coverage/lcov-report/src/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/src/builder/traffic.ts.html +3 -3
- package/coverage/lcov-report/src/list/index.html +14 -14
- package/coverage/lcov-report/src/list/matrix.ts.html +33 -12
- package/coverage/lcov-report/src/tester/helpers.ts.html +1 -1
- package/coverage/lcov-report/src/tester/index.html +1 -1
- package/coverage/lcov.info +810 -129
- package/jest.config.js +8 -0
- package/lib/builder/buildDatafile.d.ts +10 -0
- package/lib/builder/buildDatafile.js +27 -0
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +2 -0
- package/lib/builder/buildProject.js +38 -4
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/buildScopedConditions.d.ts +5 -0
- package/lib/builder/buildScopedConditions.js +97 -0
- package/lib/builder/buildScopedConditions.js.map +1 -0
- package/lib/builder/buildScopedConditions.spec.d.ts +1 -0
- package/lib/builder/buildScopedConditions.spec.js +2167 -0
- package/lib/builder/buildScopedConditions.spec.js.map +1 -0
- package/lib/builder/buildScopedDatafile.d.ts +2 -0
- package/lib/builder/buildScopedDatafile.js +107 -0
- package/lib/builder/buildScopedDatafile.js.map +1 -0
- package/lib/builder/buildScopedDatafile.spec.d.ts +1 -0
- package/lib/builder/buildScopedDatafile.spec.js +1988 -0
- package/lib/builder/buildScopedDatafile.spec.js.map +1 -0
- package/lib/builder/buildScopedSegments.d.ts +5 -0
- package/lib/builder/buildScopedSegments.js +99 -0
- package/lib/builder/buildScopedSegments.js.map +1 -0
- package/lib/builder/buildScopedSegments.spec.d.ts +1 -0
- package/lib/builder/buildScopedSegments.spec.js +1062 -0
- package/lib/builder/buildScopedSegments.spec.js.map +1 -0
- package/lib/builder/index.d.ts +1 -0
- package/lib/builder/index.js +1 -0
- package/lib/builder/index.js.map +1 -1
- package/lib/config/projectConfig.d.ts +9 -1
- package/lib/config/projectConfig.js +1 -0
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/adapter.d.ts +3 -1
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/filesystemAdapter.js +3 -1
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/linter/testSchema.d.ts +5 -0
- package/lib/linter/testSchema.js +8 -0
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/list/matrix.js +5 -0
- package/lib/list/matrix.js.map +1 -1
- package/lib/tester/testFeature.d.ts +5 -3
- package/lib/tester/testFeature.js +34 -9
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +3 -2
- package/lib/tester/testProject.js +40 -6
- package/lib/tester/testProject.js.map +1 -1
- package/package.json +5 -5
- package/src/builder/buildDatafile.ts +47 -0
- package/src/builder/buildProject.ts +58 -3
- package/src/builder/buildScopedConditions.spec.ts +2659 -0
- package/src/builder/buildScopedConditions.ts +134 -0
- package/src/builder/buildScopedDatafile.spec.ts +2236 -0
- package/src/builder/buildScopedDatafile.ts +173 -0
- package/src/builder/buildScopedSegments.spec.ts +1573 -0
- package/src/builder/buildScopedSegments.ts +153 -0
- package/src/builder/index.ts +1 -0
- package/src/config/projectConfig.ts +11 -1
- package/src/datasource/adapter.ts +4 -1
- package/src/datasource/filesystemAdapter.ts +4 -1
- package/src/linter/testSchema.ts +12 -0
- package/src/list/matrix.ts +7 -0
- package/src/tester/testFeature.ts +50 -16
- package/src/tester/testProject.ts +68 -8
|
@@ -12,7 +12,7 @@ const printTestResult_1 = require("./printTestResult");
|
|
|
12
12
|
const builder_1 = require("../builder");
|
|
13
13
|
const config_1 = require("../config");
|
|
14
14
|
const list_1 = require("../list");
|
|
15
|
-
async function executeTest(test, deps, options,
|
|
15
|
+
async function executeTest(test, deps, options, datafileContentByKey) {
|
|
16
16
|
const { datasource, projectConfig, rootDirectoryPath } = deps;
|
|
17
17
|
const extension = datasource.getExtension();
|
|
18
18
|
const relativeTestFilePath = test.key + (extension ? `.${extension}` : "");
|
|
@@ -37,7 +37,7 @@ async function executeTest(test, deps, options, datafileContentByEnvironment) {
|
|
|
37
37
|
testResult = await (0, testSegment_1.testSegment)(datasource, tAsSegment, options);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
testResult = await (0, testFeature_1.testFeature)(datasource, projectConfig, tAsFeature, options,
|
|
40
|
+
testResult = await (0, testFeature_1.testFeature)(datasource, projectConfig, tAsFeature, options, datafileContentByKey);
|
|
41
41
|
}
|
|
42
42
|
if (!options.onlyFailures) {
|
|
43
43
|
// show all
|
|
@@ -73,7 +73,7 @@ async function testProject(deps, testOptions = {}) {
|
|
|
73
73
|
let failedTestsCount = 0;
|
|
74
74
|
let passedAssertionsCount = 0;
|
|
75
75
|
let failedAssertionsCount = 0;
|
|
76
|
-
const
|
|
76
|
+
const datafileContentByKey = new Map();
|
|
77
77
|
// with environments
|
|
78
78
|
if (Array.isArray(projectConfig.environments)) {
|
|
79
79
|
for (const environment of projectConfig.environments) {
|
|
@@ -84,7 +84,24 @@ async function testProject(deps, testOptions = {}) {
|
|
|
84
84
|
environment: environment,
|
|
85
85
|
inflate: options.inflate,
|
|
86
86
|
}, existingState);
|
|
87
|
-
|
|
87
|
+
datafileContentByKey.set(environment, datafileContent);
|
|
88
|
+
// by scope
|
|
89
|
+
if (projectConfig.scopes && options.withScopes) {
|
|
90
|
+
for (const scope of projectConfig.scopes) {
|
|
91
|
+
const existingState = await datasource.readState(environment);
|
|
92
|
+
const datafileContent = await (0, builder_1.buildDatafile)(projectConfig, datasource, {
|
|
93
|
+
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
|
|
94
|
+
revision: "include-scoped-features",
|
|
95
|
+
environment: environment,
|
|
96
|
+
inflate: options.inflate,
|
|
97
|
+
tag: scope.tag,
|
|
98
|
+
tags: scope.tags,
|
|
99
|
+
}, existingState);
|
|
100
|
+
const scopedDatafileContent = (0, builder_1.buildScopedDatafile)(datafileContent, scope.context);
|
|
101
|
+
datafileContentByKey.set(`${environment}-scope-${scope.name}`, scopedDatafileContent);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// @TODO: by tag
|
|
88
105
|
}
|
|
89
106
|
}
|
|
90
107
|
// no environments
|
|
@@ -96,7 +113,24 @@ async function testProject(deps, testOptions = {}) {
|
|
|
96
113
|
environment: false,
|
|
97
114
|
inflate: options.inflate,
|
|
98
115
|
}, existingState);
|
|
99
|
-
|
|
116
|
+
datafileContentByKey.set(false, datafileContent);
|
|
117
|
+
// by scope
|
|
118
|
+
if (projectConfig.scopes && options.withScopes) {
|
|
119
|
+
for (const scope of projectConfig.scopes) {
|
|
120
|
+
const existingState = await datasource.readState(false);
|
|
121
|
+
const datafileContent = await (0, builder_1.buildDatafile)(projectConfig, datasource, {
|
|
122
|
+
schemaVersion: options.schemaVersion || config_1.SCHEMA_VERSION,
|
|
123
|
+
revision: "include-scoped-features",
|
|
124
|
+
environment: false,
|
|
125
|
+
inflate: options.inflate,
|
|
126
|
+
tag: scope.tag,
|
|
127
|
+
tags: scope.tags,
|
|
128
|
+
}, existingState);
|
|
129
|
+
const scopedDatafileContent = (0, builder_1.buildScopedDatafile)(datafileContent, scope.context);
|
|
130
|
+
datafileContentByKey.set(`scope-${scope.name}`, scopedDatafileContent);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// @TODO: by tag
|
|
100
134
|
}
|
|
101
135
|
const tests = await (0, list_1.listEntities)({
|
|
102
136
|
rootDirectoryPath,
|
|
@@ -108,7 +142,7 @@ async function testProject(deps, testOptions = {}) {
|
|
|
108
142
|
},
|
|
109
143
|
}, "test");
|
|
110
144
|
for (const test of tests) {
|
|
111
|
-
const executionResult = await executeTest(test, deps, options,
|
|
145
|
+
const executionResult = await executeTest(test, deps, options, datafileContentByKey);
|
|
112
146
|
if (!executionResult) {
|
|
113
147
|
continue;
|
|
114
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testProject.js","sourceRoot":"","sources":["../../src/tester/testProject.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"testProject.js","sourceRoot":"","sources":["../../src/tester/testProject.ts"],"names":[],"mappings":";;;AAsCA,kCAiEC;AAED,kCA4KC;AArRD,yBAAyB;AAIzB,+CAA4C;AAC5C,+CAA4C;AAC5C,2CAAgF;AAEhF,qDAAkD;AAClD,uDAAoD;AAEpD,wCAAgE;AAChE,sCAA2C;AAE3C,kCAAuC;AAwBhC,KAAK,UAAU,WAAW,CAC/B,IAAU,EACV,IAAkB,EAClB,OAA2B,EAC3B,oBAA0C;IAE1C,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IAE9D,MAAM,SAAS,GAAG,UAAU,CA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|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.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",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@featurevisor/sdk": "2.
|
|
44
|
-
"@featurevisor/site": "2.
|
|
45
|
-
"@featurevisor/types": "2.
|
|
43
|
+
"@featurevisor/sdk": "2.6.0",
|
|
44
|
+
"@featurevisor/site": "2.6.0",
|
|
45
|
+
"@featurevisor/types": "2.6.0",
|
|
46
46
|
"axios": "^1.3.4",
|
|
47
47
|
"js-yaml": "^4.1.0",
|
|
48
48
|
"tar": "^6.1.13",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"@types/js-yaml": "^4.0.5",
|
|
54
54
|
"@types/tar": "^6.1.4"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e5dafb8a51d7653e35fe17cacc0c14d7e95f69d0"
|
|
57
57
|
}
|
|
@@ -38,6 +38,8 @@ export interface CustomDatafileOptions {
|
|
|
38
38
|
revision?: string;
|
|
39
39
|
schemaVersion?: string;
|
|
40
40
|
inflate?: number;
|
|
41
|
+
tag?: string;
|
|
42
|
+
tags?: BuildTags;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export async function getCustomDatafile(
|
|
@@ -60,6 +62,8 @@ export async function getCustomDatafile(
|
|
|
60
62
|
environment: options.environment,
|
|
61
63
|
features: featuresToInclude,
|
|
62
64
|
inflate: options.inflate,
|
|
65
|
+
tag: options.tag,
|
|
66
|
+
tags: options.tags,
|
|
63
67
|
},
|
|
64
68
|
existingState,
|
|
65
69
|
);
|
|
@@ -67,12 +71,23 @@ export async function getCustomDatafile(
|
|
|
67
71
|
return datafileContent;
|
|
68
72
|
}
|
|
69
73
|
|
|
74
|
+
export interface BuildOrTags {
|
|
75
|
+
or: string[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface BuildAndTags {
|
|
79
|
+
and: string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type BuildTags = BuildOrTags | BuildAndTags | string[];
|
|
83
|
+
|
|
70
84
|
export interface BuildOptions {
|
|
71
85
|
schemaVersion: string;
|
|
72
86
|
revision: string;
|
|
73
87
|
revisionFromHash?: boolean;
|
|
74
88
|
environment: string | false;
|
|
75
89
|
tag?: string;
|
|
90
|
+
tags?: BuildTags;
|
|
76
91
|
features?: FeatureKey[];
|
|
77
92
|
inflate?: number;
|
|
78
93
|
}
|
|
@@ -105,6 +120,38 @@ export async function buildDatafile(
|
|
|
105
120
|
continue;
|
|
106
121
|
}
|
|
107
122
|
|
|
123
|
+
if (options.tags) {
|
|
124
|
+
// plain array of tags: treat as OR tags
|
|
125
|
+
if (Array.isArray(options.tags)) {
|
|
126
|
+
if (
|
|
127
|
+
options.tags.some((searchTag) => parsedFeature.tags.indexOf(searchTag) !== -1) === false
|
|
128
|
+
) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
// OR tags
|
|
133
|
+
const orTags = options.tags as BuildOrTags;
|
|
134
|
+
if (orTags.or) {
|
|
135
|
+
if (
|
|
136
|
+
orTags.or.some((searchTag) => parsedFeature.tags.indexOf(searchTag) !== -1) === false
|
|
137
|
+
) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// AND tags
|
|
143
|
+
const andTags = options.tags as BuildAndTags;
|
|
144
|
+
if (andTags.and) {
|
|
145
|
+
if (
|
|
146
|
+
andTags.and.every((searchTag) => parsedFeature.tags.indexOf(searchTag) !== -1) ===
|
|
147
|
+
false
|
|
148
|
+
) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
108
155
|
if (options.features && options.features.indexOf(featureKey) === -1) {
|
|
109
156
|
continue;
|
|
110
157
|
}
|
|
@@ -3,8 +3,11 @@ import { Datasource } from "../datasource";
|
|
|
3
3
|
|
|
4
4
|
import { getNextRevision } from "./revision";
|
|
5
5
|
import { buildDatafile, getCustomDatafile } from "./buildDatafile";
|
|
6
|
+
import { buildScopedDatafile } from "./buildScopedDatafile";
|
|
6
7
|
import { Dependencies } from "../dependencies";
|
|
7
8
|
import { Plugin } from "../cli";
|
|
9
|
+
import type { Scope } from "../config";
|
|
10
|
+
|
|
8
11
|
import type { DatafileContent } from "@featurevisor/types";
|
|
9
12
|
|
|
10
13
|
export interface BuildCLIOptions {
|
|
@@ -20,6 +23,9 @@ export interface BuildCLIOptions {
|
|
|
20
23
|
stateFiles?: boolean; // --no-state-files in CLI
|
|
21
24
|
inflate?: number;
|
|
22
25
|
datafilesDir?: string;
|
|
26
|
+
|
|
27
|
+
tag?: string;
|
|
28
|
+
scope?: string; // scope name only
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
async function buildForEnvironment({
|
|
@@ -28,6 +34,7 @@ async function buildForEnvironment({
|
|
|
28
34
|
nextRevision,
|
|
29
35
|
environment,
|
|
30
36
|
tags,
|
|
37
|
+
scopes,
|
|
31
38
|
cliOptions,
|
|
32
39
|
}: {
|
|
33
40
|
projectConfig: ProjectConfig;
|
|
@@ -35,12 +42,14 @@ async function buildForEnvironment({
|
|
|
35
42
|
nextRevision: string;
|
|
36
43
|
environment: string | false;
|
|
37
44
|
tags: string[];
|
|
45
|
+
scopes?: Scope[];
|
|
38
46
|
cliOptions: BuildCLIOptions;
|
|
39
47
|
}) {
|
|
40
48
|
console.log(`\nBuilding datafiles for environment: ${environment}`);
|
|
41
49
|
|
|
42
50
|
const existingState = await datasource.readState(environment);
|
|
43
51
|
|
|
52
|
+
// by tag
|
|
44
53
|
for (const tag of tags) {
|
|
45
54
|
console.log(`\n => Tag: ${tag}`);
|
|
46
55
|
|
|
@@ -66,6 +75,41 @@ async function buildForEnvironment({
|
|
|
66
75
|
});
|
|
67
76
|
}
|
|
68
77
|
|
|
78
|
+
// by scope
|
|
79
|
+
if (scopes) {
|
|
80
|
+
for (const scope of scopes) {
|
|
81
|
+
console.log(`\n => Scope: ${scope.name}`);
|
|
82
|
+
|
|
83
|
+
const datafileContent = await buildDatafile(
|
|
84
|
+
projectConfig,
|
|
85
|
+
datasource,
|
|
86
|
+
{
|
|
87
|
+
schemaVersion: cliOptions.schemaVersion || SCHEMA_VERSION,
|
|
88
|
+
revision: nextRevision,
|
|
89
|
+
revisionFromHash: cliOptions.revisionFromHash,
|
|
90
|
+
environment: environment,
|
|
91
|
+
tag: scope.tag,
|
|
92
|
+
tags: scope.tags,
|
|
93
|
+
inflate: cliOptions.inflate,
|
|
94
|
+
},
|
|
95
|
+
existingState,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const scopedDatafileContent = buildScopedDatafile(
|
|
99
|
+
datafileContent as DatafileContent,
|
|
100
|
+
scope.context,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// write scoped datafile
|
|
104
|
+
await datasource.writeDatafile(scopedDatafileContent, {
|
|
105
|
+
environment,
|
|
106
|
+
tag: scope.tag,
|
|
107
|
+
scope: scope,
|
|
108
|
+
datafilesDir: cliOptions.datafilesDir,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
69
113
|
if (typeof cliOptions.stateFiles === "undefined" || cliOptions.stateFiles) {
|
|
70
114
|
// write state for environment
|
|
71
115
|
await datasource.writeState(environment, existingState);
|
|
@@ -89,15 +133,25 @@ export async function buildProject(deps: Dependencies, cliOptions: BuildCLIOptio
|
|
|
89
133
|
* while tests can be run anywhere else.
|
|
90
134
|
*/
|
|
91
135
|
if (cliOptions.environment && cliOptions.json) {
|
|
92
|
-
const
|
|
136
|
+
const scope = cliOptions.scope
|
|
137
|
+
? projectConfig.scopes?.find((scope) => scope.name === cliOptions.scope)
|
|
138
|
+
: undefined;
|
|
139
|
+
|
|
140
|
+
let datafileContent = await getCustomDatafile({
|
|
93
141
|
featureKey: cliOptions.feature,
|
|
94
142
|
environment: cliOptions.environment,
|
|
95
143
|
projectConfig,
|
|
96
144
|
datasource,
|
|
97
145
|
revision: cliOptions.revision,
|
|
98
146
|
schemaVersion: cliOptions.schemaVersion,
|
|
147
|
+
tag: cliOptions.tag,
|
|
148
|
+
tags: scope?.tags,
|
|
99
149
|
});
|
|
100
150
|
|
|
151
|
+
if (scope) {
|
|
152
|
+
datafileContent = buildScopedDatafile(datafileContent as DatafileContent, scope.context);
|
|
153
|
+
}
|
|
154
|
+
|
|
101
155
|
if (cliOptions.pretty) {
|
|
102
156
|
console.log(JSON.stringify(datafileContent, null, 2));
|
|
103
157
|
} else {
|
|
@@ -110,8 +164,7 @@ export async function buildProject(deps: Dependencies, cliOptions: BuildCLIOptio
|
|
|
110
164
|
/**
|
|
111
165
|
* Regular build process that writes to disk.
|
|
112
166
|
*/
|
|
113
|
-
const tags = projectConfig
|
|
114
|
-
const environments = projectConfig.environments;
|
|
167
|
+
const { tags, environments, scopes } = projectConfig;
|
|
115
168
|
|
|
116
169
|
const currentRevision = await datasource.readRevision();
|
|
117
170
|
console.log("\nCurrent revision:", currentRevision);
|
|
@@ -128,6 +181,7 @@ export async function buildProject(deps: Dependencies, cliOptions: BuildCLIOptio
|
|
|
128
181
|
nextRevision,
|
|
129
182
|
environment,
|
|
130
183
|
tags,
|
|
184
|
+
scopes,
|
|
131
185
|
cliOptions,
|
|
132
186
|
});
|
|
133
187
|
}
|
|
@@ -141,6 +195,7 @@ export async function buildProject(deps: Dependencies, cliOptions: BuildCLIOptio
|
|
|
141
195
|
nextRevision,
|
|
142
196
|
environment: false,
|
|
143
197
|
tags,
|
|
198
|
+
scopes,
|
|
144
199
|
cliOptions,
|
|
145
200
|
});
|
|
146
201
|
}
|