Hydrogen CLI #94
Replies: 5 comments 4 replies
-
Neat-o. I like the thinking and where this is headed. What kind of feedback are you looking for at this stage? In the meantime, naive question: one beef I've had with many starter CLIs is that they get you going fast but then you're on your own whenever you want to change your starting state. It feels like the pattern you're proposing has the potential to be "re-entrant"... As in, I could init my repo without Tailwind do some hacking, but then go "oh wow, now I see why Tailwind is helpful" and rerun the CLI with this new option and on the existing project to drop it in? Hope that's coherent. |
Beta Was this translation helpful? Give feedback.
-
@igrigorik yes exactly. Adding tailwind (as an example) either in an existing app or new would be the same under the hood as each would be broken up into a plugin that knows how to operate on an AST. As long as we can locate their main style sheet to add the directives But with that said, I need to prototype more use cases to see how viable this is for us to manage in the long term. What does adding sanity to an Hydrogen site look like? I18n? Bugsnag? Etc... to be more sure this model for code transformation is viable. More prototypes are for this flow are the next steps in the works. I think it will be hard for us to unring this bell if we release it, so I'm trying to be cautious here.
I have been focused on other tasks necessary for developer preview, but with that behind us now, I am coming back to this work. One major hesitation from me is how this meshes with our push for the best defaults for commerce. Does investing in tooling that unlocks a wider array of configuration push us away from that philosophy? Does this counter our ability to ship a well supported commerce framework? My goal here is to enable developers, but like anything, there are tradeoffs and I'd be curious if you feel those are worth accepting. The other feedback I'd be looking for your opinion on is how this integrates with our existing Shopify CLI. I need to define what those touch points are and how we coordinate that. Do you have any thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
@cartogram this looks awesome, I want to try the CLI commands but the reference implementation links above give 404, can you share the branch names to pull it? |
Beta Was this translation helpful? Give feedback.
-
A few thoughts.
|
Beta Was this translation helpful? Give feedback.
-
Some updates for folks following this discussion:
|
Beta Was this translation helpful? Give feedback.
-
Summary
hydrogen/cli
provides interactive project scaffolding for hydrogen apps.Reference implementations:
Motivation
If you prefer to see a demo before reading on, you can watch my initial recording in videobin.
Problems with existing solutions
If we take a look at Next.js, they provide a large
examples
directory showing various apps with a base Next.js structure plus one tool (with-jest
,with-eslint
, etc...). Some glaring limitations exist in this approach and this is why I think we shouldn't follow suit.I believe there is some value in having the physical examples exist (rather than generated), but we can be support and manage a smaller selection of "starter-templates" to accomplish this.
Core Framework
The core framework of
hydrogen/cli
consists of the following:Commands
These are the scripts that the CLI will run and are responsible for orchestrating the project scaffolding. They are simple functions that receive instances of UI, FS and WS (defined above).
Templates
In this initial iteration, templates are functions. These functions receive utility helper methods for common tasks and return markup as a string.
Next steps
The next iteration of this tool will replace these functions with static files that will be parsed into an Abstract Syntax Tree (AST) and passed through file transformations (using something like babel). This provides 2 benefits:
Test Framework
The success of this tool will largely be determined by our ability to maintain it and so a robust test framework is vital. In this iteration, a command is tested in the following phases:
H2CLI.-.Demo.2.-.Testing.utilities.mp4
Phase 2
The next iteration of this tool goes one step further by actually installing the dependencies in the sandbox and running the project. We can then inspect the result using Playwright in a headless browser.
H2CLI.-.Demo.3.-.Browser.tests.mp4
The Future
My vision for this is far reaching and based on brief conversations with the google Aurora team, that vision for this type of developer tooling is shared. In addition to any Next Steps defined above, some other obvious features we could add are things like:
.rc
file).fixer
function for each issue that could be run to perform corrections.Issues will be created for further discussion as follow up to this RFC.
Try it!
yarn
yarn test create
to run the existing test suite.yarn hydrogen create
oryarn h2 create
to run the CLI yourself and generate a new app.Beta Was this translation helpful? Give feedback.
All reactions