Merge pull request #3044 from github/koesie10/fix-query-storage-path
Fix queries always being created in qlpack root
This commit is contained in:
@@ -248,8 +248,10 @@ export class DatabaseManager extends DisposableObject {
|
||||
const firstWorkspaceFolder = getFirstWorkspaceFolder();
|
||||
const folderName = `codeql-custom-queries-${databaseItem.language}`;
|
||||
|
||||
const qlpackStoragePath = join(firstWorkspaceFolder, folderName);
|
||||
|
||||
if (
|
||||
existsSync(join(firstWorkspaceFolder, folderName)) ||
|
||||
existsSync(qlpackStoragePath) ||
|
||||
isFolderAlreadyInWorkspace(folderName)
|
||||
) {
|
||||
return;
|
||||
@@ -276,7 +278,8 @@ export class DatabaseManager extends DisposableObject {
|
||||
const qlPackGenerator = new QlPackGenerator(
|
||||
databaseItem.language,
|
||||
this.cli,
|
||||
join(firstWorkspaceFolder, folderName),
|
||||
qlpackStoragePath,
|
||||
qlpackStoragePath,
|
||||
);
|
||||
await qlPackGenerator.generate();
|
||||
} catch (e: unknown) {
|
||||
|
||||
@@ -18,6 +18,7 @@ export class QlPackGenerator {
|
||||
private readonly queryLanguage: QueryLanguage,
|
||||
private readonly cliServer: CodeQLCliServer,
|
||||
private readonly storagePath: string,
|
||||
private readonly queryStoragePath: string,
|
||||
private readonly includeFolderNameInQlpackName: boolean = false,
|
||||
) {
|
||||
this.qlpackVersion = "1.0.0";
|
||||
@@ -91,7 +92,7 @@ export class QlPackGenerator {
|
||||
}
|
||||
|
||||
public async createExampleQlFile(fileName = "example.ql") {
|
||||
const exampleQlFilePath = join(this.folderUri.fsPath, fileName);
|
||||
const exampleQlFilePath = join(this.queryStoragePath, fileName);
|
||||
|
||||
const exampleQl = `
|
||||
/**
|
||||
|
||||
@@ -455,7 +455,10 @@ export class SkeletonQueryWizard {
|
||||
|
||||
private createQlPackGenerator() {
|
||||
if (this.qlPackStoragePath === undefined) {
|
||||
throw new Error("Query pack storage path is undefined");
|
||||
throw new Error("QL pack storage path is undefined");
|
||||
}
|
||||
if (this.queryStoragePath === undefined) {
|
||||
throw new Error("Query storage path is undefined");
|
||||
}
|
||||
if (this.language === undefined) {
|
||||
throw new Error("Language is undefined");
|
||||
@@ -472,6 +475,7 @@ export class SkeletonQueryWizard {
|
||||
this.language,
|
||||
this.cliServer,
|
||||
this.qlPackStoragePath,
|
||||
this.queryStoragePath,
|
||||
includeFolderNameInQlpackName,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ describe("QlPackGenerator", () => {
|
||||
language as QueryLanguage,
|
||||
mockCli,
|
||||
packFolderPath,
|
||||
packFolderPath,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -128,6 +129,7 @@ describe("QlPackGenerator", () => {
|
||||
language as QueryLanguage,
|
||||
mockCli,
|
||||
packFolderPath,
|
||||
packFolderPath,
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -161,6 +163,7 @@ describe("QlPackGenerator", () => {
|
||||
language as QueryLanguage,
|
||||
mockCli,
|
||||
packFolderPath,
|
||||
packFolderPath,
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -195,6 +198,7 @@ describe("QlPackGenerator", () => {
|
||||
language as QueryLanguage,
|
||||
mockCli,
|
||||
packFolderPath,
|
||||
packFolderPath,
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user