@featurevisor/core 2.22.1 → 2.24.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 +22 -0
- package/coverage/clover.xml +164 -274
- package/coverage/coverage-final.json +3 -6
- package/coverage/lcov-report/builder/allocator.ts.html +1 -1
- package/coverage/lcov-report/builder/buildDatafile.ts.html +8 -2
- package/coverage/lcov-report/builder/buildScopedConditions.ts.html +1 -1
- package/coverage/lcov-report/builder/buildScopedDatafile.ts.html +1 -1
- package/coverage/lcov-report/builder/buildScopedSegments.ts.html +1 -1
- package/coverage/lcov-report/builder/convertToV1.ts.html +1 -1
- package/coverage/lcov-report/builder/getFeatureRanges.ts.html +1 -1
- package/coverage/lcov-report/builder/hashes.ts.html +1 -1
- package/coverage/lcov-report/builder/index.html +1 -1
- package/coverage/lcov-report/builder/mutateVariables.ts.html +1 -1
- package/coverage/lcov-report/builder/mutator.ts.html +1 -1
- package/coverage/lcov-report/builder/revision.ts.html +1 -1
- package/coverage/lcov-report/builder/traffic.ts.html +1 -1
- package/coverage/lcov-report/config/index.html +1 -1
- package/coverage/lcov-report/config/index.ts.html +1 -1
- package/coverage/lcov-report/config/projectConfig.ts.html +3 -3
- package/coverage/lcov-report/datasource/adapter.ts.html +1 -1
- package/coverage/lcov-report/datasource/datasource.ts.html +2 -2
- package/coverage/lcov-report/datasource/filesystemAdapter.ts.html +3 -3
- package/coverage/lcov-report/datasource/index.html +1 -1
- package/coverage/lcov-report/datasource/index.ts.html +1 -1
- package/coverage/lcov-report/generate-code/index.html +1 -1
- package/coverage/lcov-report/generate-code/typescript.ts.html +1 -1
- package/coverage/lcov-report/index.html +9 -24
- package/coverage/lcov-report/linter/attributeSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/checkCircularDependency.ts.html +1 -1
- package/coverage/lcov-report/linter/checkPercentageExceedingSlot.ts.html +1 -1
- package/coverage/lcov-report/linter/conditionSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/featureSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/groupSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/index.html +1 -1
- package/coverage/lcov-report/linter/lintProject.ts.html +1 -1
- package/coverage/lcov-report/linter/mutationNotation.ts.html +1 -1
- package/coverage/lcov-report/linter/printError.ts.html +1 -1
- package/coverage/lcov-report/linter/schema.ts.html +1 -1
- package/coverage/lcov-report/linter/segmentSchema.ts.html +1 -1
- package/coverage/lcov-report/linter/testSchema.ts.html +1 -1
- package/coverage/lcov-report/list/index.html +1 -1
- package/coverage/lcov-report/list/matrix.ts.html +1 -1
- package/coverage/lcov-report/tester/cliFormat.ts.html +1 -1
- package/coverage/lcov-report/tester/helpers.ts.html +1 -1
- package/coverage/lcov-report/tester/index.html +1 -1
- package/coverage/lcov-report/utils/extractKeys.ts.html +1 -1
- package/coverage/lcov-report/utils/git.ts.html +2 -2
- package/coverage/lcov-report/utils/index.html +1 -1
- package/coverage/lcov-report/utils/index.ts.html +1 -1
- package/coverage/lcov-report/utils/pretty.ts.html +1 -1
- package/coverage/lcov.info +281 -491
- package/lib/builder/buildDatafile.d.ts +1 -0
- package/lib/builder/buildDatafile.js +1 -0
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildDatafile.spec.js +1 -1
- package/lib/builder/buildDatafile.spec.js.map +1 -1
- package/lib/builder/buildProject.js +13 -0
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/config/projectConfig.d.ts +1 -1
- package/lib/config/projectConfig.js +1 -1
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +8 -8
- package/package.json +5 -6
- package/src/builder/buildDatafile.spec.ts +1 -1
- package/src/builder/buildDatafile.ts +2 -0
- package/src/builder/buildProject.ts +14 -0
- package/src/config/projectConfig.ts +1 -1
- package/src/datasource/datasource.ts +1 -1
- package/src/datasource/filesystemAdapter.ts +1 -1
- package/src/index.ts +2 -1
- package/src/utils/git.ts +1 -1
- package/coverage/lcov-report/parsers/index.html +0 -146
- package/coverage/lcov-report/parsers/index.ts.html +0 -151
- package/coverage/lcov-report/parsers/json.ts.html +0 -118
- package/coverage/lcov-report/parsers/yml.ts.html +0 -589
- package/lib/parsers/index.d.ts +0 -15
- package/lib/parsers/index.js +0 -15
- package/lib/parsers/index.js.map +0 -1
- package/lib/parsers/json.d.ts +0 -2
- package/lib/parsers/json.js +0 -13
- package/lib/parsers/json.js.map +0 -1
- package/lib/parsers/json.spec.d.ts +0 -1
- package/lib/parsers/json.spec.js +0 -35
- package/lib/parsers/json.spec.js.map +0 -1
- package/lib/parsers/yml.d.ts +0 -2
- package/lib/parsers/yml.js +0 -154
- package/lib/parsers/yml.js.map +0 -1
- package/lib/parsers/yml.spec.d.ts +0 -1
- package/lib/parsers/yml.spec.js +0 -143
- package/lib/parsers/yml.spec.js.map +0 -1
- package/src/parsers/index.ts +0 -22
- package/src/parsers/json.spec.ts +0 -36
- package/src/parsers/json.ts +0 -11
- package/src/parsers/yml.spec.ts +0 -174
- package/src/parsers/yml.ts +0 -168
package/src/parsers/yml.ts
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
|
|
3
|
-
import { parse, parseDocument, stringify } from "yaml";
|
|
4
|
-
import type { Pair, YAMLMap, YAMLSeq } from "yaml/types";
|
|
5
|
-
import { Scalar as ScalarCtor } from "yaml/types";
|
|
6
|
-
|
|
7
|
-
import type { CustomParser } from "./index";
|
|
8
|
-
|
|
9
|
-
function getKeyString(keyNode: unknown): string | undefined {
|
|
10
|
-
if (keyNode == null) return undefined;
|
|
11
|
-
if (typeof (keyNode as { value?: unknown }).value !== "undefined") {
|
|
12
|
-
return String((keyNode as { value: unknown }).value);
|
|
13
|
-
}
|
|
14
|
-
return typeof keyNode === "string" ? keyNode : undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function copyComments(source: Pair, target: Pair): void {
|
|
18
|
-
if (source.comment != null) target.comment = source.comment;
|
|
19
|
-
if (source.commentBefore != null) target.commentBefore = source.commentBefore;
|
|
20
|
-
const srcVal = source.value as
|
|
21
|
-
| { comment?: string | null; commentBefore?: string | null }
|
|
22
|
-
| undefined;
|
|
23
|
-
const tgtVal = target.value;
|
|
24
|
-
if (srcVal && tgtVal && typeof tgtVal === "object" && tgtVal !== null) {
|
|
25
|
-
const t = tgtVal as { comment?: string | null; commentBefore?: string | null };
|
|
26
|
-
if (srcVal.comment != null) t.comment = srcVal.comment;
|
|
27
|
-
if (srcVal.commentBefore != null) t.commentBefore = srcVal.commentBefore;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function isYamlMap(node: unknown): node is YAMLMap {
|
|
32
|
-
return node != null && typeof node === "object" && Array.isArray((node as YAMLMap).items);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function isYamlSeq(node: unknown): node is YAMLSeq {
|
|
36
|
-
return node != null && typeof node === "object" && Array.isArray((node as YAMLSeq).items);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function seqItemValueKey(item: unknown): string {
|
|
40
|
-
if (item == null) return String(item);
|
|
41
|
-
const n = item as { value?: unknown; toJSON?: () => unknown };
|
|
42
|
-
if (typeof n.value !== "undefined") return JSON.stringify(n.value);
|
|
43
|
-
if (typeof n.toJSON === "function") return JSON.stringify(n.toJSON());
|
|
44
|
-
return JSON.stringify(item);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function primitiveValueKey(v: unknown): string {
|
|
48
|
-
return JSON.stringify(v);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function createValueWithComments(
|
|
52
|
-
schema: { createNode: (v: unknown) => unknown; createPair: (k: unknown, v: unknown) => Pair },
|
|
53
|
-
oldNode: unknown,
|
|
54
|
-
newValue: unknown,
|
|
55
|
-
): unknown {
|
|
56
|
-
if (newValue === null || typeof newValue !== "object") {
|
|
57
|
-
const node = new ScalarCtor(newValue);
|
|
58
|
-
const old = oldNode as { comment?: string | null; commentBefore?: string | null } | undefined;
|
|
59
|
-
if (old) {
|
|
60
|
-
if (old.comment != null) node.comment = old.comment;
|
|
61
|
-
if (old.commentBefore != null) node.commentBefore = old.commentBefore;
|
|
62
|
-
}
|
|
63
|
-
return node;
|
|
64
|
-
}
|
|
65
|
-
if (Array.isArray(newValue)) {
|
|
66
|
-
const oldSeq = isYamlSeq(oldNode) ? (oldNode as YAMLSeq) : null;
|
|
67
|
-
const oldItemsByValue = new Map<string, unknown>();
|
|
68
|
-
if (oldSeq && oldSeq.items) {
|
|
69
|
-
for (const item of oldSeq.items) {
|
|
70
|
-
oldItemsByValue.set(seqItemValueKey(item), item);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const newSeq = schema.createNode([]) as YAMLSeq;
|
|
74
|
-
for (const el of newValue) {
|
|
75
|
-
const oldItem = oldItemsByValue.get(primitiveValueKey(el));
|
|
76
|
-
const itemNode = createValueWithComments(schema, oldItem, el);
|
|
77
|
-
newSeq.add(itemNode);
|
|
78
|
-
}
|
|
79
|
-
return newSeq;
|
|
80
|
-
}
|
|
81
|
-
// newValue is a plain object; preserve comments from old map if present
|
|
82
|
-
const oldMap = isYamlMap(oldNode) ? (oldNode as YAMLMap) : null;
|
|
83
|
-
const oldPairsByKey = new Map<string, Pair>();
|
|
84
|
-
if (oldMap) {
|
|
85
|
-
for (const pair of (oldMap.items || []) as Pair[]) {
|
|
86
|
-
const keyStr = getKeyString(pair.key);
|
|
87
|
-
if (keyStr !== undefined) oldPairsByKey.set(keyStr, pair);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const newMap = schema.createNode({}) as YAMLMap;
|
|
91
|
-
const obj = newValue as Record<string, unknown>;
|
|
92
|
-
for (const k of Object.keys(obj)) {
|
|
93
|
-
const oldPair = oldPairsByKey.get(k);
|
|
94
|
-
const childOldNode = oldPair ? oldPair.value : undefined;
|
|
95
|
-
const childNewValue = createValueWithComments(schema, childOldNode, obj[k]);
|
|
96
|
-
const newPair = schema.createPair(k, childNewValue);
|
|
97
|
-
if (oldPair) copyComments(oldPair, newPair);
|
|
98
|
-
newMap.add(newPair);
|
|
99
|
-
}
|
|
100
|
-
const result = newMap as { comment?: string | null; commentBefore?: string | null };
|
|
101
|
-
const oldVal = oldNode as { comment?: string | null; commentBefore?: string | null } | undefined;
|
|
102
|
-
if (oldVal && result) {
|
|
103
|
-
if (oldVal.comment != null) result.comment = oldVal.comment;
|
|
104
|
-
if (oldVal.commentBefore != null) result.commentBefore = oldVal.commentBefore;
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function replaceContentsPreservingComments(
|
|
110
|
-
doc: {
|
|
111
|
-
contents: unknown;
|
|
112
|
-
schema: { createNode: (v: unknown) => unknown; createPair: (k: unknown, v: unknown) => Pair };
|
|
113
|
-
},
|
|
114
|
-
newContent: Record<string, unknown>,
|
|
115
|
-
): void {
|
|
116
|
-
const oldRoot = doc.contents as YAMLMap | null | undefined;
|
|
117
|
-
if (!oldRoot || !Array.isArray((oldRoot as YAMLMap).items)) {
|
|
118
|
-
doc.contents = doc.schema.createNode(newContent) as typeof doc.contents;
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const schema = doc.schema;
|
|
123
|
-
const oldPairsByKey = new Map<string, Pair>();
|
|
124
|
-
for (const pair of (oldRoot as YAMLMap).items as Pair[]) {
|
|
125
|
-
const keyStr = getKeyString(pair.key);
|
|
126
|
-
if (keyStr !== undefined) oldPairsByKey.set(keyStr, pair);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const newMap = schema.createNode({}) as YAMLMap;
|
|
130
|
-
for (const key of Object.keys(newContent)) {
|
|
131
|
-
const oldPair = oldPairsByKey.get(key);
|
|
132
|
-
const valueNode = createValueWithComments(schema, oldPair?.value, newContent[key]);
|
|
133
|
-
const newPair = schema.createPair(key, valueNode);
|
|
134
|
-
if (oldPair) copyComments(oldPair, newPair);
|
|
135
|
-
newMap.add(newPair);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
(doc as { contents: unknown }).contents = newMap;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export const ymlParser: CustomParser = {
|
|
142
|
-
extension: "yml",
|
|
143
|
-
parse: function <T>(content: string): T {
|
|
144
|
-
return parse(content) as T;
|
|
145
|
-
},
|
|
146
|
-
stringify: function (content: any, filePath?: string) {
|
|
147
|
-
if (!filePath || !fs.existsSync(filePath)) {
|
|
148
|
-
return stringify(content);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const fileContent = fs.readFileSync(filePath, "utf8");
|
|
152
|
-
if (!fileContent.trim()) {
|
|
153
|
-
return stringify(content);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// newObject is the final saved object; existing file is only for ordering/comments
|
|
157
|
-
if (content === null || typeof content !== "object" || Array.isArray(content)) {
|
|
158
|
-
throw new Error("Cannot set root document to a primitive value");
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const doc = parseDocument(fileContent) as {
|
|
162
|
-
contents: unknown;
|
|
163
|
-
schema: { createNode: (v: unknown) => unknown; createPair: (k: unknown, v: unknown) => Pair };
|
|
164
|
-
};
|
|
165
|
-
replaceContentsPreservingComments(doc, content);
|
|
166
|
-
return doc.toString();
|
|
167
|
-
},
|
|
168
|
-
};
|