Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] Provide the option for a user to create a new directory to contain template code on azd init/up #181

Open
savannahostrowski opened this issue Jul 26, 2022 · 8 comments

Comments

@savannahostrowski
Copy link
Contributor

Right now, a developer has to manually to create a new directory, cd into the directory and then run azd init/up. If you don't follow this pattern, you can inadvertently download the template code into the current directory. I have personally done this many times and ended up with all the files/folders scattered across the wrong directory on my local machine 😩.

On azd init/up, we should ask the developer if they'd like to create a new directory when downloading the template code (which is a common CLI pattern). If y/yes is input, we create a new directory and download the code in there (mirroring a git clone behaviour). If n/no is input, we assume that the user has already created their own directory and cd'd into it. The goal here would be to guide the developer more through the init/up process.

@karolz-ms
Copy link
Contributor

Love this idea. We should also have the option of specifying the target directory via an invocation parameter.

@savannahostrowski
Copy link
Contributor Author

+1 !

@jongio
Copy link
Member

jongio commented Jul 27, 2022

The technical reason for requiring the folder to be created first is because we were having issues with creating a directory and then changing the cwd to that dir. If we do this, then we need to ensure that either:

  1. We execute all commands in that new directory
  2. Find a way to CD to that dir in script
  3. Ask the user to CD to that dir

@puicchan
Copy link
Contributor

We have seen this repeatedly, it's a step that can be easily missed. Even for developers who read the Get Started/Readme.

@vhvb1989
Copy link
Member

vhvb1989 commented Aug 2, 2022

We already have the option -cwd or -C to set the working directory. So, you can run azd up -C ./build to use the build folder from the current directory.
Yes, the folder must be there in order for this to work.
If the folder is not there, we thow exception.

We can improve the experience of using -cwd to detect if the folder is not there and ask user if they want to create it.

When not using -cwd, we could detect if the current directory is not empty, and ask customer to confirm using that path or offering the option of creating a new folder. This way we would not impact people who are already entering the right folder by always making the confirmation/question. We'd do it only when folder is not empty.

What do you think

@savannahostrowski
Copy link
Contributor Author

My impression is that this should be part of the core flow for project initialization or running up. Especially for new developers, using -cwd is less discoverable and complicates the command (which they might be more prone to malforming).

My preferred user flow would be:

  • Developer runs azd init
  • Developer is presented with template options
  • Developer selects a non-empty template
  • Developer sees a prompt to either enter a new directory name (to be created as a subdirectory) or they can hit enter to select the current directory
  • Developer has code downloaded into the proper directory
  • Developer enters new environment name, selects region, selects subscription.
  • If developer created a new subdirectory during this flow, we tell them to cd into the directory at the end to continue

@pamelafox
Copy link
Member

We're running into this today during our AI App template usability, and multiple folks did not create a folder, and then got a rude awakening to see that it copied into their current folder instead (and ran git init in it!)

@codeazon
Copy link

codeazon commented Oct 7, 2024

Hi! I am running into same issue too. I would like to help with this if needed. Maybe I can add option to create the folder during azd init flow, and prompt user to choose folder or use current one. Let me know if I can contribute PR! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants