Add schema validation for collection files #369

This commit improves collection file editing and error detection
directly in the IDE. It adds YAML schema, IDE configuration and
automatic tests to validate it.

- Introduce a YAML schema for collection file.
- Use `yaml-language-server` for enhanced YAML support in VSCode.
- Add telemetry disabling in `configure_vscode.py` to respect user
  privacy.
- Add automated checks to validate YAML file structure against the
  schema.
- Remove unused properties and do not allow them in compiler.
This commit is contained in:
undergroundwires
2024-06-17 14:01:07 +02:00
parent e9a52859f6
commit dc03bff324
19 changed files with 383 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ describe('ScriptingDefinitionParser', () => {
const expectedAssertion: ObjectAssertion<ScriptingDefinitionData> = {
value: data,
valueName: 'scripting definition',
allowedProperties: ['language', 'fileExtension', 'startCode', 'endCode'],
allowedProperties: ['language', 'startCode', 'endCode'],
};
const validatorStub = new TypeValidatorStub();
const context = new TestContext()

View File

@@ -72,6 +72,7 @@ function createTestCases(collectionsDirFromRoot: string): ITestCase[] {
throw new Error(`Could not find any collection in ${collectionsDir}`);
}
const collectionFilePaths = fileNames
.filter((name) => !name.startsWith('.'))
.filter((name) => name.endsWith('.yaml'))
.map((name) => join(collectionsDir, name));
return collectionFilePaths.map((path) => ({

View File

@@ -47,7 +47,6 @@ export function getCategoryStub(scriptPrefix = 'testScript'): CategoryData {
function getTestDefinitionStub(): ScriptingDefinitionData {
return {
fileExtension: '.bat',
language: ScriptingLanguage[ScriptingLanguage.batchfile],
startCode: 'start',
endCode: 'end',

View File

@@ -19,7 +19,7 @@ export function createScriptDataWithCall(
} else {
instance = instance.withMockCall();
}
return instance;
return instance as ScriptDataStub & CallScriptData;
}
export function createScriptDataWithoutCallOrCodes(): ScriptDataStub {
@@ -50,12 +50,12 @@ class ScriptDataStub implements CallScriptData, CodeScriptData {
return this;
}
public withCode(code: string): this {
public withCode(code: string): this & CodeScriptData {
this.code = code;
return this;
}
public withRevertCode(revertCode: string | undefined): this {
public withRevertCode(revertCode: string | undefined): this & CodeScriptData {
this.revertCode = revertCode;
return this;
}