Skip to content

Commit fe90f38

Browse files
authored
Merge pull request #1709 from github/charis-nora/validate-db-config-file
Validate workspace-databases.json
2 parents c0ba9c5 + f6b50bb commit fe90f38

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

extensions/ql-vscode/gulpfile.ts/deploy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const packageFiles = [
1515
'snippets.json',
1616
'media',
1717
'node_modules',
18-
'out'
18+
'out',
19+
'workspace-databases-schema.json'
1920
];
2021

2122
async function copyPackage(sourcePath: string, destPath: string): Promise<void> {

extensions/ql-vscode/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
"editor.wordBasedSuggestions": false
8585
}
8686
},
87+
"jsonValidation": [
88+
{
89+
"fileMatch": "workspace-databases.json",
90+
"url": "./workspace-databases-schema.json"
91+
}
92+
],
8793
"languages": [
8894
{
8995
"id": "ql",

extensions/ql-vscode/src/databases/db-config-store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class DbConfigStore extends DisposableObject {
1212

1313
public constructor(workspaceStoragePath: string) {
1414
super();
15+
1516
this.configPath = path.join(workspaceStoragePath, 'workspace-databases.json');
1617

1718
this.config = this.createEmptyConfig();
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"$schema": {
5+
"type": "string"
6+
},
7+
"remote": {
8+
"type": "object",
9+
"properties": {
10+
"repositoryLists": {
11+
"type": "array",
12+
"items": {
13+
"type": "object",
14+
"properties": {
15+
"name": {
16+
"type": "string"
17+
},
18+
"repositories": {
19+
"type": "array",
20+
"items": {
21+
"type": "string",
22+
"pattern": "^[a-zA-Z0-9-_\\.]+/[a-zA-Z0-9-_\\.]+$"
23+
}
24+
}
25+
},
26+
"required": ["name", "repositories"],
27+
"additionalProperties": false
28+
}
29+
},
30+
"owners": {
31+
"type": "array",
32+
"items": {
33+
"type": "string",
34+
"pattern": "^[a-zA-Z0-9-_\\.]+$"
35+
}
36+
},
37+
"repositories": {
38+
"type": "array",
39+
"items": {
40+
"type": "string",
41+
"pattern": "^[a-zA-Z0-9-_\\.]+/[a-zA-Z0-9-_\\.]+$"
42+
}
43+
}
44+
},
45+
"required": ["repositoryLists", "owners", "repositories"],
46+
"additionalProperties": false
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)