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

New CLI onboarding #913

Merged
merged 109 commits into from
Jun 30, 2023
Merged

New CLI onboarding #913

merged 109 commits into from
Jun 30, 2023

Conversation

frandiox
Copy link
Contributor

@frandiox frandiox commented May 19, 2023

Working here on the new CLI onboarding. Design here.

Todos

  • Added h2 setup css-unstable <strategy> command to setup tailwind, postcss, css-modules or vanilla-extract.
  • Added h2 setup i18n-unstable <strategy> command to setup internationalization with subfolders, domains or subdomains strategy.
  • New flow for the init command:
    • demo-store template is downloaded from the Hydrogen repo and cannot be customized beyond the JS/TS choice.
    • hello-world template is now bundled in the CLI release and can be modified during the init flow:
      • Setup mock.shop Support mock.shop as a storeDomain #986
      • Integrate new login flow
      • Ability to create + link storefronts
      • Ask about location/language/install deps
      • Ask to setup CSS strategies.
      • Ask to setup i18n strategies.
      • Ask to generate routes.
      • Ask to create the h2 alias.
      • Split initial commit in multiple commits
    • Aggregate work to do it in the background before showing loaders.
    • Add flags to pre-populate steps (e.g. --i18n subfolders --css tailwind)
    • Unhappy paths / error handling + abort signals
    • Ensure generate route respects i18n subfolders setup
    • Add h2 setup command to continue setup later
  • Default Tailwind classes / better raw routes => in another PR

🎩 Tophat/feedback

Would like to ensure it all works since this is 80% done and will be ready to merge soon.

  1. Pull code, install deps at the root, run npm run build:pkg.
  2. cd templates, then run h2 init and try the flow with different options. This command will prompt to choose a package manager for installing deps. This is automatically inferred if you use npm|yarn|pnpm create @shopify/hydrogen@latest once the new version is published.
  3. Check if there's any issue, wrong files, etc.

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

@frandiox frandiox merged commit ed9782b into 2023-04 Jun 30, 2023
@frandiox frandiox deleted the fd-new-onboarding branch June 30, 2023 15:27
juanpprieto pushed a commit that referenced this pull request Jul 10, 2023
* Refactor: extract format-code utilities

* Add setup-assets

* Add file utils and tests

* Setup Tailwind

* Fix paths and add renderTask

* Install Tailwind deps

* Update package-lock

* Fix asset replacement

* Refactor: extract common build paths

* Copy hello-world template to dist folder

* Make hello-world the default starter

* Fix timezone in CLI tests

* Refactor: extract admin requests

* Cleanup

* Setup local starter

* Refactor: split workflows

* Prompt for package maanger when unknown

* Change shop prompt

* Group tasks

* Remove .env variables when linking to shop

* Make setupTailwind more modular

* Add setup CSS step

* Merge branch '2023-04' into fd-new-onboarding

* Move CSS setup logic around and fix test

* Ensure promises are chained

* Prompt for creating h2 alias

* Ensure promises are chained

* Copilot comments

* Refactor: extract ast replacers

* Improve types and move files around

* Support PostCSS setup

* Prettify css strategy names

* Fix type of flagsToCamelObject

* Add install-deps flag to css-unstable

* Make root links replacer more flexible

* Add support for CSS modules setup

* Prettify output

* Extract css bundling injection

* Add support for vanilla-extract setup

* Update oclif manifest

* Prompt for styling library when no arg is passed

* Adjust prompts

* Add prompts for i18n and routes

* Add i18n setups

* Export I18nLocale type

* Fix TS version of domain and subdomains i18n setups

* Add I18nLocale type to remix.env.d.ts

* Adjust success message

* Force choosing a CSS strategy

* Adjust success message

* Show helpful commands at the end

* Adjust success message spacing

* Fix AST grep for JS

* Fix init test

* Refactor generate route command

* Hoist work to improve perf in route generation; add more tests

* Improve output logs

* Fix generate route

* Allow passing locale prefix

* Figure out locale prefix automatically

* Make the locale variable optional in path

* Scaffold all routes

* Simplify prompts format

* Add option to use mock.shop

* Init git and create initial commit

* Error handling

* Show errors properly in at the end

* Throw errors from replacers

* Fix tests

* Merge branch '2023-04' into fd-new-onboarding

* Feedback update

* Use AbortSignal in prompts

* Minor adjustments

* Align with design updates

* Disable i18n and routes setup for now

* Oclif manifest

* Remove all variables from .env when linking the store

* Update package-lock

* Integrate init with login flow

* Integrate create-storefront with new onboarding (#1058)

* Integrate create storefront in init

* Minor refactoring

* Add tests for create-storefront

* Infer path from storefront title

* Defer create-storefront integration

* Fix changesets

* Make shopName and email required fields in local config

* setUserAccount in init

* New onboarding - extra setup (#1050)

* Improve implementation of i18n templates

* Enable extra setup in init

* Add --styling flag

* Add --mock-shop flag

* Add --i18n flag

* Add --routes flag

* Allow negated flags

* Update summary to latest design

* Throw early when flags have invalid values

* Rename pathname to subfolders

* Show shortcut prompt earlier

* Align with design updates

* Add storefront name to package.json

* Show storefront name in dev command

* Update next steps

* Oclif manifest

* Skip some tests for now

* Add HR as dev dependency for types on CI

* Revert "Add HR as dev dependency for types on CI"

This reverts commit 7ded27f.

* Align with design updates

* Fix race condition

* Fix project overwrite

* Fix detecting TS in i18n setup

* Avoid importing types from HR directly

* Show login banner

* Refactor shortcut code files

* Refactor generate route code files

* Fix shortcut tests

* Refactor: split init command in multiple files

* Extra common prompts

* Rename types

* Refactor route generate input

* Extract renderRoutePrompt

* Disable dts in CLI to avoid Tsup bug copying d.ts files in templates

* Make renderProjectReady more flexible

* Extract flags

* Refactor handleCliShortcut

* Minor refactoring

* Add 'setup' command

* Ensure Remix versions are the same when copying assets

* Fix name added to package.json

* Changesets
FrcPpe pushed a commit to FrcPpe/hydrogen that referenced this pull request Aug 13, 2023
* Refactor: extract format-code utilities

* Add setup-assets

* Add file utils and tests

* Setup Tailwind

* Fix paths and add renderTask

* Install Tailwind deps

* Update package-lock

* Fix asset replacement

* Refactor: extract common build paths

* Copy hello-world template to dist folder

* Make hello-world the default starter

* Fix timezone in CLI tests

* Refactor: extract admin requests

* Cleanup

* Setup local starter

* Refactor: split workflows

* Prompt for package maanger when unknown

* Change shop prompt

* Group tasks

* Remove .env variables when linking to shop

* Make setupTailwind more modular

* Add setup CSS step

* Merge branch '2023-04' into fd-new-onboarding

* Move CSS setup logic around and fix test

* Ensure promises are chained

* Prompt for creating h2 alias

* Ensure promises are chained

* Copilot comments

* Refactor: extract ast replacers

* Improve types and move files around

* Support PostCSS setup

* Prettify css strategy names

* Fix type of flagsToCamelObject

* Add install-deps flag to css-unstable

* Make root links replacer more flexible

* Add support for CSS modules setup

* Prettify output

* Extract css bundling injection

* Add support for vanilla-extract setup

* Update oclif manifest

* Prompt for styling library when no arg is passed

* Adjust prompts

* Add prompts for i18n and routes

* Add i18n setups

* Export I18nLocale type

* Fix TS version of domain and subdomains i18n setups

* Add I18nLocale type to remix.env.d.ts

* Adjust success message

* Force choosing a CSS strategy

* Adjust success message

* Show helpful commands at the end

* Adjust success message spacing

* Fix AST grep for JS

* Fix init test

* Refactor generate route command

* Hoist work to improve perf in route generation; add more tests

* Improve output logs

* Fix generate route

* Allow passing locale prefix

* Figure out locale prefix automatically

* Make the locale variable optional in path

* Scaffold all routes

* Simplify prompts format

* Add option to use mock.shop

* Init git and create initial commit

* Error handling

* Show errors properly in at the end

* Throw errors from replacers

* Fix tests

* Merge branch '2023-04' into fd-new-onboarding

* Feedback update

* Use AbortSignal in prompts

* Minor adjustments

* Align with design updates

* Disable i18n and routes setup for now

* Oclif manifest

* Remove all variables from .env when linking the store

* Update package-lock

* Integrate init with login flow

* Integrate create-storefront with new onboarding (Shopify#1058)

* Integrate create storefront in init

* Minor refactoring

* Add tests for create-storefront

* Infer path from storefront title

* Defer create-storefront integration

* Fix changesets

* Make shopName and email required fields in local config

* setUserAccount in init

* New onboarding - extra setup (Shopify#1050)

* Improve implementation of i18n templates

* Enable extra setup in init

* Add --styling flag

* Add --mock-shop flag

* Add --i18n flag

* Add --routes flag

* Allow negated flags

* Update summary to latest design

* Throw early when flags have invalid values

* Rename pathname to subfolders

* Show shortcut prompt earlier

* Align with design updates

* Add storefront name to package.json

* Show storefront name in dev command

* Update next steps

* Oclif manifest

* Skip some tests for now

* Add HR as dev dependency for types on CI

* Revert "Add HR as dev dependency for types on CI"

This reverts commit 7ded27f.

* Align with design updates

* Fix race condition

* Fix project overwrite

* Fix detecting TS in i18n setup

* Avoid importing types from HR directly

* Show login banner

* Refactor shortcut code files

* Refactor generate route code files

* Fix shortcut tests

* Refactor: split init command in multiple files

* Extra common prompts

* Rename types

* Refactor route generate input

* Extract renderRoutePrompt

* Disable dts in CLI to avoid Tsup bug copying d.ts files in templates

* Make renderProjectReady more flexible

* Extract flags

* Refactor handleCliShortcut

* Minor refactoring

* Add 'setup' command

* Ensure Remix versions are the same when copying assets

* Fix name added to package.json

* Changesets
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.

4 participants