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.
This commit is contained in:
Elena Tanasoiu
2023-04-13 09:25:36 +00:00
parent 9a2de398f8
commit 6000e72ee5
2 changed files with 7 additions and 11 deletions

View File

@@ -11,6 +11,7 @@ import {
showAndLogExceptionWithTelemetry,
isFolderAlreadyInWorkspace,
showBinaryChoiceDialog,
getFirstStoragePath,
} from "./helpers";
import { ProgressCallback, withProgress } from "./progress";
import {
@@ -676,11 +677,13 @@ export class DatabaseManager extends DisposableObject {
}
try {
const workspaceStorage = getFirstStoragePath();
const qlPackGenerator = new QlPackGenerator(
folderName,
databaseItem.language as QueryLanguage,
this.cli,
this.ctx.storageUri?.fsPath,
workspaceStorage,
);
await qlPackGenerator.generate();
} catch (e: unknown) {

View File

@@ -1,7 +1,7 @@
import { writeFile } from "fs-extra";
import { mkdir, writeFile } from "fs-extra";
import { dump } from "js-yaml";
import { join } from "path";
import { Uri, workspace } from "vscode";
import { Uri } from "vscode";
import { CodeQLCliServer } from "./cli";
import { QueryLanguage } from "./common/query-language";
@@ -44,14 +44,7 @@ export class QlPackGenerator {
}
private async createWorkspaceFolder() {
await workspace.fs.createDirectory(this.folderUri);
const end = (workspace.workspaceFolders || []).length;
workspace.updateWorkspaceFolders(end, 0, {
name: this.folderName,
uri: this.folderUri,
});
await mkdir(this.folderUri.fsPath);
}
private async createQlPackYaml() {