@@ -2,12 +2,9 @@ import { join, relative, resolve, sep } from "path";
22import { outputFile , pathExists , readFile } from "fs-extra" ;
33import { dump as dumpYaml , load as loadYaml } from "js-yaml" ;
44import { minimatch } from "minimatch" ;
5- import { CancellationToken , window , WorkspaceFolder } from "vscode" ;
5+ import { CancellationToken , window } from "vscode" ;
66import { CodeQLCliServer , QlpacksInfo } from "../codeql-cli/cli" ;
7- import {
8- getOnDiskWorkspaceFolders ,
9- getOnDiskWorkspaceFoldersObjects ,
10- } from "../common/vscode/workspace-folders" ;
7+ import { getOnDiskWorkspaceFolders } from "../common/vscode/workspace-folders" ;
118import { ProgressCallback } from "../common/vscode/progress" ;
129import { DatabaseItem } from "../databases/local-databases" ;
1310import { getQlPackPath , QLPACK_FILENAMES } from "../pure/ql" ;
@@ -23,6 +20,10 @@ import {
2320 parsePackName ,
2421 validatePackName ,
2522} from "./extension-pack-name" ;
23+ import {
24+ askForWorkspaceFolder ,
25+ autoPickWorkspaceFolder ,
26+ } from "./extensions-workspace-folder" ;
2627
2728const maxStep = 3 ;
2829
@@ -395,57 +396,6 @@ async function autoCreateExtensionPack(
395396 return writeExtensionPack ( packPath , packName , language ) ;
396397}
397398
398- async function autoPickWorkspaceFolder (
399- language : string ,
400- ) : Promise < WorkspaceFolder | undefined > {
401- const workspaceFolders = getOnDiskWorkspaceFoldersObjects ( ) ;
402-
403- // If there's only 1 workspace folder, use that
404- if ( workspaceFolders . length === 1 ) {
405- return workspaceFolders [ 0 ] ;
406- }
407-
408- // In the vscode-codeql-starter repository, all workspace folders are named "codeql-custom-queries-<language>",
409- // so we can use that to find the workspace folder for the language
410- const starterWorkspaceFolderForLanguage = workspaceFolders . find (
411- ( folder ) => folder . name === `codeql-custom-queries-${ language } ` ,
412- ) ;
413- if ( starterWorkspaceFolderForLanguage ) {
414- return starterWorkspaceFolderForLanguage ;
415- }
416-
417- // Otherwise, try to find one that ends with "-<language>"
418- const workspaceFolderForLanguage = workspaceFolders . find ( ( folder ) =>
419- folder . name . endsWith ( `-${ language } ` ) ,
420- ) ;
421- if ( workspaceFolderForLanguage ) {
422- return workspaceFolderForLanguage ;
423- }
424-
425- // If we can't find one, just ask the user
426- return askForWorkspaceFolder ( ) ;
427- }
428-
429- async function askForWorkspaceFolder ( ) : Promise < WorkspaceFolder | undefined > {
430- const workspaceFolders = getOnDiskWorkspaceFoldersObjects ( ) ;
431- const workspaceFolderOptions = workspaceFolders . map ( ( folder ) => ( {
432- label : folder . name ,
433- detail : folder . uri . fsPath ,
434- folder,
435- } ) ) ;
436-
437- // We're not using window.showWorkspaceFolderPick because that also includes the database source folders while
438- // we only want to include on-disk workspace folders.
439- const workspaceFolder = await window . showQuickPick ( workspaceFolderOptions , {
440- title : "Select workspace folder to create extension pack in" ,
441- } ) ;
442- if ( ! workspaceFolder ) {
443- return undefined ;
444- }
445-
446- return workspaceFolder . folder ;
447- }
448-
449399async function writeExtensionPack (
450400 packPath : string ,
451401 packName : ExtensionPackName ,
0 commit comments