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

Support project directories containing underscores #6206

Open
1 task done
mbomb007 opened this issue May 17, 2024 · 6 comments
Open
1 task done

Support project directories containing underscores #6206

mbomb007 opened this issue May 17, 2024 · 6 comments

Comments

@mbomb007
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem?

Drupal modules frequently contain underscores in the project names. It's annoying to have to specify a different project name, or manually convert underscores to hyphens, each time I create a DDEV project for one. It seems a bit arbitrary that underscores aren't allowed.

Describe your solution

Allow underscores in project names.

Describe alternatives

Automatically convert underscores to hyphens and use that as the default project name when running ddev config.

Additional context

No response

@rfay
Copy link
Member

rfay commented May 17, 2024

As you see in the error message, underscores cannot be used in domain names, and so are excluded for that reason. You can easily change the name of your project with ddev config --project-name=module-name instead of module_name

@mbomb007
Copy link
Contributor Author

mbomb007 commented May 17, 2024

I have aliases that run a bunch of commands at once when creating a project. But they don't work when the folder name has underscores in it.

alias ddev-new='ddev config --project-type=drupal10 --docroot=web --php-version=8.3 --database=mariadb:10.11'

I still think it'd be helpful if the command could auto-replace underscores with hyphens.

@rfay
Copy link
Member

rfay commented May 17, 2024

I don't see any harm in the suggestion of swapping underscore for hyphen in the default project name. A PR would be welcome.

Note that you can also improve your alias to do this quite trivially.

Also note that mariadb:10.11 is the current default, so you don't need that in there. Also note that if your project is already populated with code and it's a Drupal 10 project, it will autodetect the docroot and project type if that's useful to you.

@mbomb007
Copy link
Contributor Author

Also note that mariadb:10.11 is the current default, so you don't need that in there. Also note that if your project is already populated with code and it's a Drupal 10 project, it will autodetect the docroot and project type if that's useful to you.

10.11 wasn't the default at the time I created the alias, but good to know. I do mostly use it for populated projects, but this way I can use it for a brand new repo as well if I want to.

Note that you can also improve your alias to do this quite trivially.

Something like this?

alias ddev-new='ddev config --project-type=drupal10 --docroot=web --php-version=8.3 --database=mariadb:10.11 --project-name=$(basename $(pwd) | tr "_" "-")'

@mbomb007
Copy link
Contributor Author

The pull request has all checks passing. Please review.

Also note that I do not have much experience at all with Go or with this codebase.

@rfay
Copy link
Member

rfay commented May 20, 2024

No worries, it will get reviewed. It may need some improvement to tests to make sure this permutation gets tested.

@rfay rfay changed the title Support project names containing underscores Support project directories containing underscores Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants