Skip to content

Commit 6000e72

Browse files
committed
Stop pushing QL pack as top level folder to avoid confusing the user
In the original flow for creating skeleton packs, we were starting out by choosing a database (e.g. github/codeql) and having the extension create the QL pack for us. At that point, we were storing the QL pack together with the database in the extension storage because we weren't interested in committing it to the repo. This means we weren't able to see it in the file explorer so in order to make it visible, we decided to push it as a top-level folder in the workspace. Hindsight is 20/20. Let's change this original flow by just creating the folder in the workspace storage instead of the extension storage (which will make it visible in the file explorer) and stop pushing it as an extra top level folder in the workspace. NB: For this flow, we exit early in the `createSkeletonPacks` method if the folder already exists so we don't need to check this again.
1 parent 9a2de39 commit 6000e72

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

extensions/ql-vscode/src/local-databases.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
showAndLogExceptionWithTelemetry,
1212
isFolderAlreadyInWorkspace,
1313
showBinaryChoiceDialog,
14+
getFirstStoragePath,
1415
} from "./helpers";
1516
import { ProgressCallback, withProgress } from "./progress";
1617
import {
@@ -676,11 +677,13 @@ export class DatabaseManager extends DisposableObject {
676677
}
677678

678679
try {
680+
const workspaceStorage = getFirstStoragePath();
681+
679682
const qlPackGenerator = new QlPackGenerator(
680683
folderName,
681684
databaseItem.language as QueryLanguage,
682685
this.cli,
683-
this.ctx.storageUri?.fsPath,
686+
workspaceStorage,
684687
);
685688
await qlPackGenerator.generate();
686689
} catch (e: unknown) {

extensions/ql-vscode/src/qlpack-generator.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { writeFile } from "fs-extra";
1+
import { mkdir, writeFile } from "fs-extra";
22
import { dump } from "js-yaml";
33
import { join } from "path";
4-
import { Uri, workspace } from "vscode";
4+
import { Uri } from "vscode";
55
import { CodeQLCliServer } from "./cli";
66
import { QueryLanguage } from "./common/query-language";
77

@@ -44,14 +44,7 @@ export class QlPackGenerator {
4444
}
4545

4646
private async createWorkspaceFolder() {
47-
await workspace.fs.createDirectory(this.folderUri);
48-
49-
const end = (workspace.workspaceFolders || []).length;
50-
51-
workspace.updateWorkspaceFolders(end, 0, {
52-
name: this.folderName,
53-
uri: this.folderUri,
54-
});
47+
await mkdir(this.folderUri.fsPath);
5548
}
5649

5750
private async createQlPackYaml() {

0 commit comments

Comments
 (0)