Skip to content

Commit 9b7c3bc

Browse files
committed
Install dependencies for tutorial query in codespace
When a user goes through the Code Tour, we select a dummy `csv` database for them to get them up and running. Once they complete the code tour and would like to continue writing queries, they will need to add their own database. After they do that, we check the language of their new database and generate a skeleton QL pack for them so that they don't need to create these files by hand. See [1] for details. This skeleton pack folder will be called `codeql-custom-queries-<language>` and it comes with its own example query: `example.ql`. When we try to run this example query, the query gets confused about which `dbscheme` to pick, as it sees a `qlpack.yml` file in the new skeleton pack folder, as well as one in the existing `tutorial-lib` folder. So we'll need to get rid of the `tutorial-lib` folder in order to make room for new queries to be run once the tour is complete. This commit introduces a `handleTourDependencies` step which will trigger a `codeql pack install` command in order to install real library dependencies for `tutorial-queries`, since we no longer have the dummy library in `tutorial-lib`.
1 parent 56e8d8a commit 9b7c3bc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ export class DatabaseUI extends DisposableObject {
390390
);
391391
}
392392
await this.databaseManager.setCurrentDatabaseItem(databaseItem);
393+
await this.handleTourDependencies();
393394
}
394395
} catch (e) {
395396
// rethrow and let this be handled by default error handling.
@@ -401,6 +402,23 @@ export class DatabaseUI extends DisposableObject {
401402
}
402403
};
403404

405+
private handleTourDependencies = async (): Promise<void> => {
406+
// find workspace root folder
407+
if (!workspace.workspaceFolders?.length) {
408+
throw new Error("No workspace folder is open.");
409+
} else {
410+
// find tutorial queries folder
411+
const tutorialQueriesPath = Uri.parse(
412+
`${workspace.workspaceFolders?.[0].uri}/tutorial-queries`,
413+
);
414+
const cli = this.queryServer?.cliServer;
415+
if (!cli) {
416+
throw new Error("No CLI server found");
417+
}
418+
await cli.packInstall(tutorialQueriesPath.fsPath);
419+
}
420+
};
421+
404422
handleRemoveOrphanedDatabases = async (): Promise<void> => {
405423
void extLogger.log("Removing orphaned databases from workspace storage.");
406424
let dbDirs = undefined;

0 commit comments

Comments
 (0)