-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fetch metafield definitions on start-up #597
Conversation
const isWin = process.platform === 'win32'; | ||
|
||
export async function fetchMetafieldDefinitions() { | ||
const path = getShopifyCliPath(); |
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.
The current CLI does not have the ability to pull metafields, so tophat this build the CLI PR here and hardcode this value to the path.
E.g.
const path = '<where-ever-you-cloned-it>/cli/packages/cli/bin/dev.js'
@@ -10,6 +11,7 @@ const fileSystems: Record<string, AbstractFileSystem> = { | |||
}; | |||
|
|||
startServer(connection, new VsCodeFileSystem(connection, fileSystems)); | |||
fetchMetafieldDefinitions(); |
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 think this should somehow be injected in startServer's fetchMetafieldsForURI
injection.
IIRC the metafields should be loaded per theme root, not per workspace.
I don't 100% know how the shopify cli works and if there's an auth per theme, but I don't think someone running a monorepo will necessarily have the same metafield definitions for shop A & shop B
@charlespwd Should we also only do this if we're working with themes, and not theme app extensions? |
I think so. At least until we validate we have a solution for them. Can they even use metafields? Probably? We do have a |
dedbbb8
to
2235083
Compare
Update
|
2235083
to
cbdffd4
Compare
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.
Should we be adding .shopify/metafields.json as part of gitignore for themes?
Ideally the whole .shopify
folder is ignored similar to how Hydrogen does it https://github.com/Shopify/hydrogen/blob/main/.gitignore#L8
but we might be a little late to that party now. I wonder if there's a way we could warn the user somehow? Or maybe the CLI itself takes care of that flow? Hmmmm, none of those options are great.
I think that the generated file should not be added to a user's repo but I also don't have a good suggestion on ensuring that other than through an interactive call in the CLI itself (ie, not via theme-tools
).
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 talked to @karreiro about this before the break. We can add it to Shopify-manged themes' .gitignore files, but we concluded that it'd be the merchant's responsibility to do so. Having it in their repo isn't going to break anything - If someone accidentally pushes it into their repo, they can easily remove it (just like a node_modules
directory).
While checking out theme app extensions, i realized that shopify app dev
command also generates a .shopify
folder inside their repo. TAEs explicitly have .shopify
in .gitignore
, so if we wanted to follow them, we could do the same for Shopify-managed themes.
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 think we should do two things:
- Add
.shopify
to.gitignore
in our 1P themes - Update the CLI to warn if there is a
.shopify
folder that isn't ignored duringtheme dev
What do you think?
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 think we should do two things:
- Add
.shopify
to.gitignore
in our 1P themes - Update the CLI to warn if there is a
.shopify
folder that isn't ignored duringtheme dev
What do you think?
Yes, pls. A nice error is a great way to be hinted at how things work! |
|
||
const shopifyCliPathPromise = getShopifyCliPath(); | ||
|
||
export async function fetchMetafieldDefinitionsForURI(uri: string) { |
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 have the exact same need for a different CLI command (here).
Could you pull the logic into some kind of ShopifyCLI caller where I could pass my command and get back the result?
seems like the only difference is that you're calling theme metafields pull
and I want to call theme profile
!
Note: my code is in another package (vscode-extension
)
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.
This feature needs to go in asap so I will refactor in a follow-up PR.
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.
LGTM! 🙏
@graygilmore @jeffreyguenther we went with a different approach where when the command is run, we automatically add it to |
What are you adding in this PR?
Part of #502
Tophat
Unfortunately, the CLI does not contain the metafield definitions pull command yet. To tophat the change override the
path
variable to use a locally built version of CLI of the main branch.E.g.
UPDATE: CLI version 3.73 has
shopify theme metafields pull
command so you can just update your CLI and it should work if you're logged in.What's next? Any followup issues?
.shopify/metafields.json
as part of gitignore for themes?Before you deploy
changeset