@featurevisor/core 2.11.0 → 2.13.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 +1410 -11
- package/coverage/coverage-final.json +21 -2
- package/coverage/lcov-report/builder/allocator.ts.html +1 -1
- 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/index.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 +116 -0
- package/coverage/lcov-report/config/projectConfig.ts.html +676 -0
- package/coverage/lcov-report/datasource/adapter.ts.html +235 -0
- package/coverage/lcov-report/datasource/datasource.ts.html +862 -0
- package/coverage/lcov-report/datasource/filesystemAdapter.ts.html +1354 -0
- package/coverage/lcov-report/datasource/index.html +161 -0
- package/coverage/lcov-report/datasource/index.ts.html +94 -0
- package/coverage/lcov-report/index.html +80 -20
- package/coverage/lcov-report/linter/attributeSchema.ts.html +175 -0
- package/coverage/lcov-report/linter/checkCircularDependency.ts.html +220 -0
- package/coverage/lcov-report/linter/checkPercentageExceedingSlot.ts.html +268 -0
- package/coverage/lcov-report/linter/conditionSchema.ts.html +775 -0
- package/coverage/lcov-report/linter/featureSchema.ts.html +4924 -0
- package/coverage/lcov-report/linter/groupSchema.ts.html +226 -0
- package/coverage/lcov-report/linter/index.html +266 -0
- package/coverage/lcov-report/linter/lintProject.ts.html +1840 -0
- package/coverage/lcov-report/linter/printError.ts.html +238 -0
- package/coverage/lcov-report/linter/schema.ts.html +1471 -0
- package/coverage/lcov-report/linter/segmentSchema.ts.html +130 -0
- package/coverage/lcov-report/linter/testSchema.ts.html +550 -0
- package/coverage/lcov-report/list/index.html +1 -1
- package/coverage/lcov-report/list/matrix.ts.html +1 -1
- package/coverage/lcov-report/parsers/index.html +20 -5
- package/coverage/lcov-report/parsers/index.ts.html +151 -0
- package/coverage/lcov-report/parsers/json.ts.html +2 -2
- package/coverage/lcov-report/parsers/yml.ts.html +6 -6
- package/coverage/lcov-report/tester/cliFormat.ts.html +103 -0
- package/coverage/lcov-report/tester/helpers.ts.html +1 -1
- package/coverage/lcov-report/tester/index.html +20 -5
- package/coverage/lcov-report/utils/git.ts.html +481 -0
- package/coverage/lcov-report/utils/index.html +116 -0
- package/coverage/lcov.info +2798 -7
- package/lib/builder/buildDatafile.js +15 -1
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/config/projectConfig.d.ts +2 -0
- package/lib/config/projectConfig.js +3 -1
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/datasource.d.ts +6 -1
- package/lib/datasource/datasource.js +16 -0
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/filesystemAdapter.js +10 -0
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/generate-code/typescript.js +280 -46
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/linter/conditionSchema.spec.d.ts +1 -0
- package/lib/linter/conditionSchema.spec.js +331 -0
- package/lib/linter/conditionSchema.spec.js.map +1 -0
- package/lib/linter/featureSchema.d.ts +129 -20
- package/lib/linter/featureSchema.js +489 -48
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/featureSchema.spec.d.ts +1 -0
- package/lib/linter/featureSchema.spec.js +978 -0
- package/lib/linter/featureSchema.spec.js.map +1 -0
- package/lib/linter/lintProject.d.ts +17 -1
- package/lib/linter/lintProject.js +228 -169
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/lintProject.spec.d.ts +1 -0
- package/lib/linter/lintProject.spec.js +86 -0
- package/lib/linter/lintProject.spec.js.map +1 -0
- package/lib/linter/printError.d.ts +7 -0
- package/lib/linter/printError.js +30 -15
- package/lib/linter/printError.js.map +1 -1
- package/lib/linter/schema.d.ts +42 -0
- package/lib/linter/schema.js +417 -0
- package/lib/linter/schema.js.map +1 -0
- package/lib/linter/schema.spec.d.ts +1 -0
- package/lib/linter/schema.spec.js +483 -0
- package/lib/linter/schema.spec.js.map +1 -0
- package/lib/linter/segmentSchema.spec.d.ts +1 -0
- package/lib/linter/segmentSchema.spec.js +231 -0
- package/lib/linter/segmentSchema.spec.js.map +1 -0
- package/lib/tester/testFeature.js +5 -3
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/utils/git.js +3 -0
- package/lib/utils/git.js.map +1 -1
- package/package.json +5 -5
- package/src/builder/buildDatafile.ts +17 -1
- package/src/config/projectConfig.ts +3 -0
- package/src/datasource/datasource.ts +23 -0
- package/src/datasource/filesystemAdapter.ts +7 -0
- package/src/generate-code/typescript.ts +330 -49
- package/src/linter/conditionSchema.spec.ts +446 -0
- package/src/linter/featureSchema.spec.ts +1218 -0
- package/src/linter/featureSchema.ts +671 -69
- package/src/linter/lintProject.spec.ts +115 -0
- package/src/linter/lintProject.ts +303 -217
- package/src/linter/printError.ts +40 -16
- package/src/linter/schema.spec.ts +617 -0
- package/src/linter/schema.ts +462 -0
- package/src/linter/segmentSchema.spec.ts +273 -0
- package/src/tester/testFeature.ts +5 -3
- package/src/utils/git.ts +2 -0
- package/lib/linter/propertySchema.d.ts +0 -5
- package/lib/linter/propertySchema.js +0 -43
- package/lib/linter/propertySchema.js.map +0 -1
- package/src/linter/propertySchema.ts +0 -47
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as os from "os";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
|
|
5
|
+
import { getProjectConfig } from "../config/projectConfig";
|
|
6
|
+
import { Datasource } from "../datasource";
|
|
7
|
+
import { lintPlugin, lintProject, type LintResult } from "./lintProject";
|
|
8
|
+
|
|
9
|
+
function createTempProjectFromExample1() {
|
|
10
|
+
const fixturePath = path.resolve(__dirname, "../../../../examples/example-1");
|
|
11
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "featurevisor-lint-"));
|
|
12
|
+
|
|
13
|
+
fs.cpSync(fixturePath, tempRoot, { recursive: true });
|
|
14
|
+
|
|
15
|
+
return tempRoot;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getDeps(rootDirectoryPath: string) {
|
|
19
|
+
const projectConfig = getProjectConfig(rootDirectoryPath);
|
|
20
|
+
const datasource = new Datasource(projectConfig, rootDirectoryPath);
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
rootDirectoryPath,
|
|
24
|
+
projectConfig,
|
|
25
|
+
datasource,
|
|
26
|
+
options: {},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe("core: lintProject", function () {
|
|
31
|
+
let tempProjectPath: string;
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
tempProjectPath = createTempProjectFromExample1();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(() => {
|
|
38
|
+
fs.rmSync(tempProjectPath, { recursive: true, force: true });
|
|
39
|
+
jest.restoreAllMocks();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("returns JSON-friendly empty errors array for a valid project", async () => {
|
|
43
|
+
const result = await lintProject(getDeps(tempProjectPath) as any, { json: true });
|
|
44
|
+
|
|
45
|
+
expect(result).toEqual({
|
|
46
|
+
hasError: false,
|
|
47
|
+
errors: [],
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("returns structured errors in JSON mode", async () => {
|
|
52
|
+
fs.writeFileSync(
|
|
53
|
+
path.join(tempProjectPath, "attributes", "invalid name.yml"),
|
|
54
|
+
"description: this has an invalid key name\ntype: string\n",
|
|
55
|
+
"utf8",
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const result = await lintProject(getDeps(tempProjectPath) as any, {
|
|
59
|
+
json: true,
|
|
60
|
+
entityType: "attribute",
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
expect(result.hasError).toBe(true);
|
|
64
|
+
expect(result.errors.length).toBeGreaterThan(0);
|
|
65
|
+
|
|
66
|
+
expect(result.errors[0]).toMatchObject({
|
|
67
|
+
entityType: "attribute",
|
|
68
|
+
key: "invalid name",
|
|
69
|
+
message: 'Invalid name: "invalid name"',
|
|
70
|
+
code: "invalid_name",
|
|
71
|
+
path: [],
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(result.errors[0].filePath).toContain("attributes");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("plugin prints pretty JSON only once in --json --pretty mode", async () => {
|
|
78
|
+
const consoleLogSpy = jest.spyOn(console, "log").mockImplementation(() => {});
|
|
79
|
+
|
|
80
|
+
const pluginResult = await lintPlugin.handler({
|
|
81
|
+
...getDeps(tempProjectPath),
|
|
82
|
+
parsed: {
|
|
83
|
+
json: true,
|
|
84
|
+
pretty: true,
|
|
85
|
+
},
|
|
86
|
+
} as any);
|
|
87
|
+
|
|
88
|
+
expect(pluginResult).toBeUndefined();
|
|
89
|
+
expect(consoleLogSpy).toHaveBeenCalledTimes(1);
|
|
90
|
+
|
|
91
|
+
const output = consoleLogSpy.mock.calls[0][0] as string;
|
|
92
|
+
expect(output).toContain('\n "errors": []\n');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("does not call process.exit for zod validation errors while linting tests", async () => {
|
|
96
|
+
fs.writeFileSync(
|
|
97
|
+
path.join(tempProjectPath, "tests", "broken.spec.yml"),
|
|
98
|
+
"feature: foo\n",
|
|
99
|
+
"utf8",
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const processExitSpy = jest
|
|
103
|
+
.spyOn(process, "exit")
|
|
104
|
+
.mockImplementation((() => undefined) as unknown as typeof process.exit);
|
|
105
|
+
|
|
106
|
+
const result: LintResult = await lintProject(getDeps(tempProjectPath) as any, {
|
|
107
|
+
json: true,
|
|
108
|
+
entityType: "test",
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(result.hasError).toBe(true);
|
|
112
|
+
expect(result.errors.length).toBeGreaterThan(0);
|
|
113
|
+
expect(processExitSpy).not.toHaveBeenCalled();
|
|
114
|
+
});
|
|
115
|
+
});
|