Merge pull request #1968 from github/nora/rename-db-config-file

Rename DbConfigFile and Schema
This commit is contained in:
Nora
2023-01-16 17:46:54 +01:00
committed by GitHub
12 changed files with 51 additions and 21 deletions

View File

@@ -23,7 +23,7 @@ const packageFiles = [
"snippets.json",
"media",
"out",
"workspace-databases-schema.json",
"databases-schema.json",
];
async function copyDirectory(

View File

@@ -92,8 +92,8 @@
},
"jsonValidation": [
{
"fileMatch": "workspace-databases.json",
"url": "./workspace-databases-schema.json"
"fileMatch": "GitHub.vscode-codeql/databases.json",
"url": "./databases-schema.json"
}
],
"languages": [

View File

@@ -32,6 +32,8 @@ import {
} from "../db-item";
export class DbConfigStore extends DisposableObject {
public static readonly databaseConfigFileName = "databases.json";
public readonly onDidChangeConfig: AppEvent<void>;
private readonly onDidChangeConfigEventEmitter: AppEventEmitter<void>;
@@ -49,7 +51,7 @@ export class DbConfigStore extends DisposableObject {
super();
const storagePath = app.workspaceStoragePath || app.globalStoragePath;
this.configPath = join(storagePath, "workspace-databases.json");
this.configPath = join(storagePath, DbConfigStore.databaseConfigFileName);
this.config = this.createEmptyConfig();
this.configErrors = [];

View File

@@ -12,10 +12,7 @@ export class DbConfigValidator {
private readonly schema: any;
constructor(extensionPath: string) {
const schemaPath = resolve(
extensionPath,
"workspace-databases-schema.json",
);
const schemaPath = resolve(extensionPath, "databases-schema.json");
this.schema = readJsonSync(schemaPath);
}

View File

@@ -42,7 +42,7 @@ describe("db config store", () => {
const configPath = join(
tempWorkspaceStoragePath,
"workspace-databases.json",
DbConfigStore.databaseConfigFileName,
);
const configStore = new DbConfigStore(app, false);
@@ -195,7 +195,10 @@ describe("db config store", () => {
workspaceStoragePath: tempWorkspaceStoragePath,
});
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
configPath = join(
tempWorkspaceStoragePath,
DbConfigStore.databaseConfigFileName,
);
});
it("should add a remote repository", async () => {
@@ -320,7 +323,10 @@ describe("db config store", () => {
workspaceStoragePath: tempWorkspaceStoragePath,
});
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
configPath = join(
tempWorkspaceStoragePath,
DbConfigStore.databaseConfigFileName,
);
});
it("should allow renaming a remote list", async () => {
@@ -492,7 +498,10 @@ describe("db config store", () => {
workspaceStoragePath: tempWorkspaceStoragePath,
});
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
configPath = join(
tempWorkspaceStoragePath,
DbConfigStore.databaseConfigFileName,
);
});
it("should remove a single db item", async () => {
@@ -612,7 +621,10 @@ describe("db config store", () => {
workspaceStoragePath: tempWorkspaceStoragePath,
});
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
configPath = join(
tempWorkspaceStoragePath,
DbConfigStore.databaseConfigFileName,
);
});
it("should set the selected item", async () => {
@@ -648,7 +660,10 @@ describe("db config store", () => {
workspaceStoragePath: tempWorkspaceStoragePath,
});
configPath = join(tempWorkspaceStoragePath, "workspace-databases.json");
configPath = join(
tempWorkspaceStoragePath,
DbConfigStore.databaseConfigFileName,
);
});
it("should return true if a remote owner exists", async () => {

View File

@@ -50,7 +50,7 @@ describe("db manager", () => {
dbConfigFilePath = join(
tempWorkspaceStoragePath,
"workspace-databases.json",
DbConfigStore.databaseConfigFileName,
);
});

View File

@@ -14,6 +14,7 @@ import {
import { DbListKind } from "../../../../src/databases/db-item";
import { createDbTreeViewItemSystemDefinedList } from "../../../../src/databases/ui/db-tree-view-item";
import { createRemoteSystemDefinedListDbItem } from "../../../factories/db-item-factories";
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
jest.setTimeout(60_000);
@@ -43,7 +44,10 @@ describe("Db panel UI commands", () => {
);
// Check db config
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
const dbConfigFilePath = path.join(
storagePath,
DbConfigStore.databaseConfigFileName,
);
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
expect(dbConfig.databases.variantAnalysis.repositoryLists).toHaveLength(1);
expect(dbConfig.databases.variantAnalysis.repositoryLists[0].name).toBe(
@@ -62,7 +66,10 @@ describe("Db panel UI commands", () => {
);
// Check db config
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
const dbConfigFilePath = path.join(
storagePath,
DbConfigStore.databaseConfigFileName,
);
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
expect(dbConfig.databases.local.lists).toHaveLength(1);
expect(dbConfig.databases.local.lists[0].name).toBe("my-list-1");
@@ -80,7 +87,10 @@ describe("Db panel UI commands", () => {
);
// Check db config
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
const dbConfigFilePath = path.join(
storagePath,
DbConfigStore.databaseConfigFileName,
);
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
expect(dbConfig.databases.variantAnalysis.repositories).toHaveLength(1);
expect(dbConfig.databases.variantAnalysis.repositories[0]).toBe(
@@ -100,7 +110,10 @@ describe("Db panel UI commands", () => {
);
// Check db config
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
const dbConfigFilePath = path.join(
storagePath,
DbConfigStore.databaseConfigFileName,
);
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
expect(dbConfig.databases.variantAnalysis.owners).toHaveLength(1);
expect(dbConfig.databases.variantAnalysis.owners[0]).toBe("owner1");
@@ -120,7 +133,10 @@ describe("Db panel UI commands", () => {
);
// Check db config
const dbConfigFilePath = path.join(storagePath, "workspace-databases.json");
const dbConfigFilePath = path.join(
storagePath,
DbConfigStore.databaseConfigFileName,
);
const dbConfig: DbConfig = await readJson(dbConfigFilePath);
expect(dbConfig.selected).toBeDefined();
expect(dbConfig.selected).toEqual({

View File

@@ -27,7 +27,7 @@ describe("db panel", () => {
const extensionPath = join(__dirname, "../../../../");
const dbConfigFilePath = join(
workspaceStoragePath,
"workspace-databases.json",
DbConfigStore.databaseConfigFileName,
);
let dbTreeDataProvider: DbTreeDataProvider;
let dbManager: DbManager;