11import * as fs from 'fs-extra' ;
22import * as path from 'path' ;
3- import { Uri , workspace , MarkdownString , window } from 'vscode' ;
3+ import { MarkdownString , Uri , window , workspace } from 'vscode' ;
44import { PythonProject , PythonProjectCreator , PythonProjectCreatorOptions } from '../../api' ;
5+ import { NEW_PROJECT_TEMPLATES_FOLDER } from '../../common/constants' ;
6+ import { showInputBoxWithButtons } from '../../common/window.apis' ;
7+ import { EnvironmentManagers } from '../../internal.api' ;
58import {
6- promptForVenv ,
7- promptForCopilotInstructions ,
89 isCopilotInstalled ,
9- quickCreateNewVenv ,
10- replaceInFilesAndNames ,
1110 manageCopilotInstructionsFile ,
1211 manageLaunchJsonFile ,
12+ promptForCopilotInstructions ,
13+ promptForVenv ,
14+ quickCreateNewVenv ,
15+ replaceInFilesAndNames ,
1316} from './creationHelpers' ;
14- import { NEW_PROJECT_TEMPLATES_FOLDER } from '../../common/constants' ;
15- import { EnvironmentManagers } from '../../internal.api' ;
16- import { showInputBoxWithButtons } from '../../common/window.apis' ;
1717
1818export class NewPackageProject implements PythonProjectCreator {
1919 public readonly name = 'newPackage' ;
@@ -24,33 +24,40 @@ export class NewPackageProject implements PythonProjectCreator {
2424 constructor ( private readonly envManagers : EnvironmentManagers ) { }
2525
2626 async create ( options ?: PythonProjectCreatorOptions ) : Promise < PythonProject | undefined > {
27- // Prompt for package name if not provided
2827 let packageName = options ?. name ;
29- if ( ! packageName ) {
30- packageName = await showInputBoxWithButtons ( {
31- prompt : 'What is the name of the package? (e.g. my_package)' ,
32- ignoreFocusOut : true ,
33- showBackButton : true ,
34- } ) ;
35- }
36- if ( ! packageName ) {
37- return undefined ;
38- }
39-
40- // Use helper to prompt for virtual environment creation
41- const createVenv = await promptForVenv ( ) ;
42- if ( createVenv === undefined ) {
43- return undefined ;
44- }
45-
46- // Only prompt for Copilot instructions if Copilot is installed
47- let createCopilotInstructions = false ;
48- if ( isCopilotInstalled ( ) ) {
49- const copilotResult = await promptForCopilotInstructions ( ) ;
50- if ( copilotResult === undefined ) {
28+ let createVenv : boolean | undefined ;
29+ let createCopilotInstructions : boolean | undefined ;
30+ if ( options ?. quickCreate === true ) {
31+ // If quickCreate is true, we should not prompt for any input
32+ if ( ! packageName ) {
33+ throw new Error ( 'Package name is required in quickCreate mode.' ) ;
34+ }
35+ createVenv = true ;
36+ createCopilotInstructions = true ;
37+ } else {
38+ //Prompt as quickCreate is false
39+ if ( ! packageName ) {
40+ packageName = await showInputBoxWithButtons ( {
41+ prompt : 'What is the name of the package? (e.g. my_package)' ,
42+ ignoreFocusOut : true ,
43+ showBackButton : true ,
44+ } ) ;
45+ }
46+ if ( ! packageName ) {
5147 return undefined ;
5248 }
53- createCopilotInstructions = copilotResult === true ;
49+ // Use helper to prompt for virtual environment creation
50+ createVenv = await promptForVenv ( ) ;
51+ if ( createVenv === undefined ) {
52+ return undefined ;
53+ }
54+ if ( isCopilotInstalled ( ) ) {
55+ const copilotResult = await promptForCopilotInstructions ( ) ;
56+ if ( copilotResult === undefined ) {
57+ return undefined ;
58+ }
59+ createCopilotInstructions = copilotResult === true ;
60+ }
5461 }
5562
5663 window . showInformationMessage (
@@ -65,7 +72,7 @@ export class NewPackageProject implements PythonProjectCreator {
6572 }
6673
6774 // Check if the destination folder is provided, otherwise use the first workspace folder
68- let destRoot = options ?. uri ? .fsPath ;
75+ let destRoot = options ?. rootUri . fsPath ;
6976 if ( ! destRoot ) {
7077 const workspaceFolders = workspace . workspaceFolders ;
7178 if ( ! workspaceFolders || workspaceFolders . length === 0 ) {
0 commit comments