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

[Themes] Add template generation with liquid and json support #5099

Merged
merged 4 commits into from
Dec 16, 2024

Conversation

jamesmengo
Copy link
Contributor

WHY are these changes introduced?

Fixes #0000

WHAT is this pull request doing?

How to test your changes?

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@jamesmengo jamesmengo mentioned this pull request Dec 12, 2024
5 tasks
Copy link
Contributor

Unused types (3)

Filename types
packages/theme/src/cli/services/generate/blocks.ts BlockGeneratorOptions
packages/theme/src/cli/services/generate/sections.ts SectionGeneratorOptions
packages/theme/src/cli/services/generate/templates.ts TemplateGeneratorOptions

Copy link
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 75.27% 8780/11664
🟡 Branches 70.57% 4280/6065
🟡 Functions 74.98% 2295/3061
🟡 Lines 75.83% 8301/10947

Test suite run success

1981 tests passing in 896 suites.

Report generated by 🧪jest coverage report action from 1bc4bba

@david-w-shopify
Copy link

david-w-shopify commented Dec 13, 2024

I really like that if a template doesn't already exist you skip the "Name of the template" question. Good thinking there!

On that note though - if a template doesn't already exist and you generate a Liquid one, it provides a section schema. It should be empty as templates don't have schemas.

Also this is scope creep, but I deleted gift_card.liquid and generated that as a JSON template. The default content looks fine, but includes the section main-gift_card which doesn't exist in my sections folder. I wonder if we could check if such a section exists and if not, prompt to generate that too?

Another thought - I appreciate at the moment we're just appending the template name to main- for the first section in a template, but I think main-gift_card should probably be main-gift-card for a consistent naming convention. gift_card is the only liquid file required to use an underscore and I think all official themes use kebab case everywhere else.

Finally moving on from gift_card - on selecting robots, robots.txt.liquid should be generated every time

@david-w-shopify
Copy link

Since you can already use separate flags I'm not certain if this is necessary, but it would be really nice and even faster to use if I could let the cli parse my decisions from a filename

shopify theme generate template --filename=page.landing.json

@david-w-shopify
Copy link

david-w-shopify commented Dec 13, 2024

Metaobject templates are missing

Also customers is a directory, so should have templates like customers/login

Base automatically changed from jm/section_generator to jm/generators December 16, 2024 21:57
@jamesmengo jamesmengo merged commit 1bc4bba into jm/generators Dec 16, 2024
24 of 27 checks passed
@jamesmengo jamesmengo deleted the jm/template_generator branch December 16, 2024 21:58
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.

2 participants