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

Scaffold examples #1608

Merged
merged 33 commits into from
Jan 11, 2024
Merged

Scaffold examples #1608

merged 33 commits into from
Jan 11, 2024

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented Jan 4, 2024

Depends on #1549

Adds support for scaffolding projects based on examples (templates were already supported):

h2 init --template multipass
npm create @shopify/hydrogen -- --template multipass

h2 init --template demo-store

If the example uses the --diff flag, then it applies it on top of the skeleton template.

Note: examples are downloaded from the latest release, not from main branch. Therefore, it currently only works with express, multipass or customer-api until we make a new release with the new examples.

@frandiox frandiox requested a review from a team January 4, 2024 16:15
@benjaminsehl
Copy link
Member

Do you have a flag here for supporting JavaScript instead of scaffolding TS? Or will that be a separate PR?

Did we decide on whether we want to use the full config flow or not? Or with this command is that all a part of it (e.g. this command kicks off the config flow, but uses this to modify the skeleton)

@benjaminsehl
Copy link
Member

benjaminsehl commented Jan 5, 2024

If the example uses the --diff flag, then it applies it on top of the skeleton template.

It feels like --diff should do the diff, but we should default to doing it with the skeleton … or else the flag should be like --verbose or something. Weird that diff would mean "I don't want the diff"… or am I misunderstanding?

Note: examples are downloaded from the latest release, not from main branch. Therefore, it currently only works with express, multipass or customer-api until we make a new release with the new examples.

Is this a decision or a constraint? Is it possible for us to change that?

@blittle
Copy link
Contributor

blittle commented Jan 5, 2024

Is this a decision or a constraint? Is it possible for us to change that?

I don't think the examples are published to npm, so the only way to get them is by downloading them from Github.

Copy link
Contributor

@blittle blittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running h2 init --template express --language=js doesn't actually produce a project in JS

@frandiox
Copy link
Contributor Author

frandiox commented Jan 8, 2024

@benjaminsehl

Do you have a flag here for supporting JavaScript instead of scaffolding TS? Or will that be a separate PR?

It prompts if you want TS or JS, or you can pass --language js to skip the prompt.

Did we decide on whether we want to use the full config flow or not? Or with this command is that all a part of it (e.g. this command kicks off the config flow, but uses this to modify the skeleton)

It uses the prompts we had for --template demo-store originally, which is only JS/TS and install deps. The other ones are not guaranteed to work (although very likely they should work since it's skeleton-based).

If the example uses the --diff flag, then it applies it on top of the skeleton template.

It feels like --diff should do the diff, but we should default to doing it with the skeleton … or else the flag should be like --verbose or something. Weird that diff would mean "I don't want the diff"… or am I misunderstanding?

I'm not sure I understand what you're saying. The --diff flag is only for us, Hydrogen developers, to use in our examples folder. It shouldn't really be needed by users. It basically tells our CLI "run the dev command for a project that is already a diff and should be applied on top of skeleton".

Note: examples are downloaded from the latest release, not from main branch. Therefore, it currently only works with express, multipass or customer-api until we make a new release with the new examples.

Is this a decision or a constraint? Is it possible for us to change that?

Both, really. This comes from the time we had --template demo-store. It basically allows us to download the compressed tarballs that GitHub creates for releases (like this one) instead of downloading the whole monorepo using Git. Also, it allows us to ensure templates/examples are working before we release them as a way of versioning, instead of making them available to download with each commit to main branch. It's only a problem for the first time they are released, really. From there we shouldn't notice any issue.


Running h2 init --template express --language=js doesn't actually produce a project in JS

@blittle Oh, the express example is a bit weird because it uses server.js and tsconfig.json. Will fix it for this one 👍

It works with the other examples already (those with server.ts and tsconfig.json) -- we keep d.ts even in JS projects:

image image

Base automatically changed from fd-diff-examples to main January 11, 2024 09:13
@frandiox frandiox merged commit 92840e5 into main Jan 11, 2024
10 checks passed
@frandiox frandiox deleted the fd-scaffold-examples branch January 11, 2024 09:51
This was referenced Jan 11, 2024
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

Successfully merging this pull request may close these issues.

3 participants