@@ -6,8 +6,8 @@ import { CreateEnvironmentOptions, EnvironmentManager } from '../../api';
66import { traceVerbose } from '../../common/logging' ;
77
88/**
9- * Prompts the user to choose whether to create a new venv for a package.
10- * Returns true if the user selects 'Yes', false if 'No', and undefined if cancelled.
9+ * Prompts the user to choose whether to create a new virtual environment ( venv) for a package.
10+ * @returns { Promise<boolean | undefined> } Resolves to true if 'Yes' is selected , false if 'No', or undefined if cancelled.
1111 */
1212export async function promptForVenv ( ) : Promise < boolean | undefined > {
1313 const venvChoice = await window . showQuickPick ( [ 'Yes' , 'No' ] , {
@@ -21,15 +21,16 @@ export async function promptForVenv(): Promise<boolean | undefined> {
2121}
2222
2323/**
24- * Returns true if GitHub Copilot extension is installed, false otherwise.
24+ * Checks if the GitHub Copilot extension is installed in the current VS Code environment.
25+ * @returns {boolean } True if Copilot is installed, false otherwise.
2526 */
2627export function isCopilotInstalled ( ) : boolean {
2728 return ! ! extensions . getExtension ( 'GitHub.copilot' ) ;
2829}
2930
3031/**
3132 * Prompts the user to choose whether to create a Copilot instructions file, only if Copilot is installed.
32- * Returns true if the user selects 'Yes', false if 'No', and undefined if cancelled or Copilot not installed.
33+ * @returns { Promise<boolean | undefined> } Resolves to true if 'Yes' is selected , false if 'No', or undefined if cancelled or Copilot is not installed.
3334 */
3435export async function promptForCopilotInstructions ( ) : Promise < boolean | undefined > {
3536 if ( ! isCopilotInstalled ( ) ) {
@@ -45,13 +46,25 @@ export async function promptForCopilotInstructions(): Promise<boolean | undefine
4546 return copilotChoice === 'Yes' ;
4647}
4748
49+ /**
50+ * Removes the .github Copilot instructions folder from the specified destination folder, if it exists.
51+ * @param destFolder - The absolute path to the destination folder where the .github folder may exist.
52+ * @returns {Promise<void> } Resolves when the folder is removed or if it does not exist.
53+ */
4854export async function removeCopilotInstructions ( destFolder : string ) {
4955 const copilotFolder = path . join ( destFolder , '.github' ) ;
5056 if ( await fs . pathExists ( copilotFolder ) ) {
5157 await fs . remove ( copilotFolder ) ;
5258 }
5359}
5460
61+ /**
62+ * Quickly creates a new Python virtual environment (venv) in the specified destination folder using the available environment managers.
63+ * Attempts to use the venv manager if available, otherwise falls back to any manager that supports environment creation.
64+ * @param envManagers - The collection of available environment managers.
65+ * @param destFolder - The absolute path to the destination folder where the environment should be created.
66+ * @returns {Promise<void> } Resolves when the environment is created or an error is shown.
67+ */
5568export async function quickCreateNewVenv ( envManagers : EnvironmentManagers , destFolder : string ) {
5669 try {
5770 // get the environment manager for venv
@@ -86,10 +99,11 @@ export async function quickCreateNewVenv(envManagers: EnvironmentManagers, destF
8699}
87100
88101/**
89- * Replaces all occurrences of a string in a single file's contents, handling special regex characters in the search value.
90- * @param filePath The path to the file to update.
91- * @param searchValue The string to search for (will be escaped for regex).
92- * @param replaceValue The string to replace with.
102+ * Replaces all occurrences of a string in a single file's contents, safely handling special regex characters in the search value.
103+ * @param filePath - The absolute path to the file to update.
104+ * @param searchValue - The string to search for (will be escaped for regex).
105+ * @param replaceValue - The string to replace with.
106+ * @returns {Promise<void> } Resolves when the file has been updated.
93107 */
94108export async function replaceInFile ( filePath : string , searchValue : string , replaceValue : string ) {
95109 // Escape special regex characters in searchValue
@@ -102,7 +116,13 @@ export async function replaceInFile(filePath: string, searchValue: string, repla
102116 }
103117}
104118
105- // Helper to recursively replace all occurrences of a string in file/folder names and file contents
119+ /**
120+ * Recursively replaces all occurrences of a string in file and folder names, as well as file contents, within a directory tree.
121+ * @param dir - The root directory to start the replacement from.
122+ * @param searchValue - The string to search for in names and contents.
123+ * @param replaceValue - The string to replace with.
124+ * @returns {Promise<void> } Resolves when all replacements are complete.
125+ */
106126export async function replaceInFilesAndNames ( dir : string , searchValue : string , replaceValue : string ) {
107127 const entries = await fs . readdir ( dir , { withFileTypes : true } ) ;
108128 for ( const entry of entries ) {
0 commit comments