ADD: Theme and module scaffolding templates - #49
Merged
Conversation
The files for mage new theme and mage new module now live in the templates folder instead of being built as strings, so files can be added or removed without a rebuild. The module template follows the hyva-module-template, with a Hyva overlay copied on top when the module is a Hyva module. The templates folder is synced in one download, which replaces the per file cache, and the shared prompts of both generators moved to mage_ask_new_package and mage_confirm. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up on #48.
mage new themeandmage new modulenow scaffold a complete package from thetemplatesfolder, instead of echoing a handful of strings built in the script.Templates
The module template follows hyva-module-template and keeps its placeholder names, so files can move between the two projects with only a
<VENDOR>to{{VENDOR}}swap.mage new moduleasks whether this is a Hyvä module, defaulting to what the project has installed. When it is,module-hyvais copied on top of the base template and the module sequencesHyva_Themeinstead ofMagento_Theme. Keeping the Hyvä parts in a separate folder means the base template stays usable for a plain Magento module, and no file exists twice.Two deliberate deviations from the source repo:
setup_versionis dropped frommodule.xml, deprecated since 2.3 in favour of declarative schema, and the.gitignoreusesnode_modules/rather than/node_modules, since a Hyvä module keeps its tailwind underview/frontend/tailwind.Fetching
Per file downloads would need a hardcoded file list in the script, which defeats the point of templates as files.
mage_sync_templatesnow pulls the repo tarball once and swaps the wholetemplatesfolder into~/.config/mage/templates, refreshed after 30 days. A failed sync leaves the previous folder in place, so it still works offline.mage_cached_fileis replaced bymage_templates_dir,mage_template_fileandmage_copy_template, and the gitignore from #48 now reads through the same path.Shared prompts
Both generators asked for a vendor and name in the same way, so that moved to
mage_ask_new_package. The three hand rolled yes/no questions moved tomage_confirm, which renders[y/N]or[Y/n]from the default it is given.That also fixes a real bug.
mage_new_in_folderruns inside a command substitution, so the blank line it printed for spacing was captured into the folder name. It went unnoticed because every use was unquoted and word splitting dropped the empty field, but the quoted paths in this PR would have created a directory whose name starts with a newline.mage_confirmwrites its spacing to stderr.Verified
Both generators run end to end against a temporary project.
php -lon the generated PHP,xmllinton the XML, and a JSON parse of bothcomposer.jsonfiles.Not included
mageis not rebuilt, following the convention that the built artifact is regenerated on Release commits. The sync pulls frommain, so template changes only reach users after merge.