-
Notifications
You must be signed in to change notification settings - Fork 125
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
Clear cache on app init #4186
Clear cache on app init #4186
Conversation
Thanks for your contribution! Depending on what you are working on, you may want to request a review from a Shopify team:
|
Coverage report
Test suite run success1736 tests passing in 800 suites. Report generated by 🧪jest coverage report action from 00d80ea |
/snapit |
🫰✨ Thanks @isaacroldan! Your snapshot has been published to npm. Test the snapshot by intalling the CLI globally: pnpm i -g @shopify/[email protected]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit concerned about this approach, as it creates an implicit coupling between the app
package's implementation of local storage and this package. If app
were ever to change, this would have to be changed, but nothing would make that obvious.
I suspect this is going to be a continuing trend, where create-app
needs to reference some general app
ideas, and a generalized solution would be worthwhile.
I don't think this information belongs in cli-kit
, app
is still the right place, but maybe we should consider exporting certain shared concepts.
In the past, create-app
couldn't assume app
was present, but now with global CLI it should always be present, right? So if we had an export, we could do something like:
import {clearCachedAppInfo} from '@shopify/app/local-storage'
// ...
// Remove cache from previous projects in the same directory
await clearCachedAppInfo(outputDirectory)
which would make the connection more explicit.
I presume this wouldn't work exactly this way with bundled CLI, so maybe @isaacroldan could help clarify if this approach is possible?
If this is going to be more trouble than it's worth, I'm OK with merging as is, since it's a rare bug anyway, so the effects of breakage are limited. But I think it would be nice to solve this in a clean, repeatable way.
Agree that is not the ideal approach having the local storage defined in two places but thought that the simplification was worth it.
|
Good point, I had the same concern. Let me check if adding the dependency doesn't include everything. |
There is another problem, |
Yes, it is 😅:
|
I can't find a better solution now... I've created a new issue here, so I'm merging and hopefully we will revisit this soon. |
The solution would be to move the init command to |
WHY are these changes introduced?
If you create a new project in a previously used folder, it doesn't run link because the folder may be cached, so the TOML doesn't get updated.
WHAT is this pull request doing?
Clear cache on app init
How to test your changes?
p shopify app init --name test-project --template none
p shopify app dev --path test-project
cat ~/Library/Preferences/shopify-cli-app-nodejs/config.json | grep test-project -A 3
=> The cache should be thererm -r test-project
p shopify app init --name test-project --template none
cat ~/Library/Preferences/shopify-cli-app-nodejs/config.json | grep test-project -A 3
=> No cachep shopify app dev --path test-project
cat test-project/shopify.app.toml
=> The TOML should be populatedMeasuring impact
How do we know this change was effective? Please choose one:
Checklist