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

[feat] Make the add-on "Laravel-aware" #5

Open
torenware opened this issue Oct 6, 2022 · 4 comments
Open

[feat] Make the add-on "Laravel-aware" #5

torenware opened this issue Oct 6, 2022 · 4 comments

Comments

@torenware
Copy link
Owner

I'm experimenting with making the add-on change its behavior when used in projects of type: laravel. Changes would include at least:

  1. Changing the javascript directory to ".", which seems to be the laravel default.
  2. Making the choice of the package manager more intelligent. New behavior will be:
  • Check for a setting in .ddev/.env
  • Otherwise: see if npm, yarn or pnpm has installed its lock-file and node_modules/ exists.
  • Otherwise: ask the user which of these package managers to use.

This issue is the tracking issue for the PRs relevant to this issue.

torenware added a commit that referenced this issue Oct 6, 2022
@rfay
Copy link
Contributor

rfay commented Oct 6, 2022

You should be able to compare $DDEV_PROJECT_TYPE to laravel. That gets the Laravel users that use the project type. But there are others that use project type 'php'

@torenware
Copy link
Owner Author

You should be able to compare $DDEV_PROJECT_TYPE to laravel. That gets the Laravel users that use the project type. But there are others that use project type 'php'

OK, easier than munging config.yaml myself. I'll try this to see if it works where I'm doing that.

@torenware
Copy link
Owner Author

For folks like @tyler36 to try to make sure this does what it needs to do:

Here's what the UI looks like when you do not set a package manager and do not do npm install or its yarn/pnpm equivalent:

  1. Get the current code by doing ddev get https://github.com/torenware/ddev-viteserve/tarball/laravel-aware-5
  2. ddev restart
  3. If you now call ddev vite-serve on a completely fresh project, without modifying the generated .ddev/.env file, you'll see something like this:
$ ddev vite-serve
1) npm
2) yarn
3) pnpm
Choose the package manager to use: 
  1. Start by choosing "1" for npm. vite-serve will run npm install for you, and start vite for you.
Choose the package manager to use: 1
'npm'
Using package manager npm

added 26 packages, and audited 27 packages in 18s

6 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm notice 
npm notice New minor version of npm available! 8.11.0 -> 8.19.2
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.19.2
npm notice Run npm install -g [email protected] to update!
npm notice 
Vite now serving .
  1. To see the "already installed state", run ddev vite-serve stop, and then run ddev vite-serve again:
$ ddev vite-serve stop
stopping vite
$ ddev vite-serve
'npm'
Using package manager npm

up to date, audited 27 packages in 1s

6 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Vite now serving .
  1. Note that vite-serve auto-detected the previous npm install, but reran npm install to make sure things haven't changed in your package.json and lock file.
  2. Delete node_modules/ and the lock file, and you'll be able to see the selection menu come up again when you restart vite-serve.
  3. Try this with yarn or pnpm to see this also works.
  4. Then, on a clean install of the stock Laravel project, use the procedure in the current CMS Quickstart Guide, to confirm that I haven't broken that path either.

@torenware
Copy link
Owner Author

torenware commented Oct 8, 2022

You should be able to compare $DDEV_PROJECT_TYPE to laravel. That gets the Laravel users that use the project type. But there are others that use project type 'php'

This works fine, and the code is refactored accordingly. For the php type, it probably does not make sense to do this; in my own use of it, I still tend to put the vite project in a sub-directory, and there's no reason to suppose that people would mix the php and js code as has become Laravel's preference. For everybody else, laissez les bons temps rouler, non?

torenware added a commit that referenced this issue Oct 8, 2022
Issue #5: Laravel related additions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants