CloudCannon / bookshop

📚 A component development workflow for static websites.
MIT License
249 stars 22 forks source link

refactor(bookshop-init): Refactored bookshop init code to save format… #172

Open adon-cloudcannon opened 1 year ago

adon-cloudcannon commented 1 year ago

Context

This came about from wanting to use .css files to style bookshop components over .scss. Changing the file extension manually works ok, but having the option when creating a new component would be nice.

That led to adding CSS as an option into bookshop/init - but THAT led to a consideration about whether or not a user would want to specify different formats (yml, toml, etc) per component, or just once across a project... which led to the addition of saving options into the bookshop config file.

THEN... exploring the code, it looked to be 90% set up to prompt the user for all options upon running --new or --component (e.g. project directory, component name, format, style)... so rather than erroring out if the user runs --new or --component without supplied arguments, it prompts them for the required value.

Changes

Testing (tester)

The reviewer should check on this branch:

bglw commented 1 year ago

Nice!

Re: the failing tests, you'll find these files in /javascript-modules/integration-tests/features/init/, and they should be intuitive enough to edit. To run the tests:

  1. Navigate to /javascript-modules/integration-tests/
  2. Run yarn run itest --name "Creating a new Jekyll Bookshop" (where name is the name of a Scenario from any file)
  3. To run all the tests, run yarn run itest-slow in the same directory (as you might expect, it's slow)

First up — if we're prompting people that .css is a valid option for a component, we need the whole stack to understand CSS files as well as SCSS files. Currently if they pick CSS, their framework Bookshop integration won't pick it up.

Tests:

Packages:

adon-cloudcannon commented 1 year ago

@bglw Totally... agree with all the things...

Re: CSS in Bookshop - I do have a solution that I would love to run by you sometime using postCSS (processes SCSS or CSS or a combination with support for future CSS, etc, etc...) - would be great to get an opinion on it sometime when you have time (which I know is never....)

Re: this PR... would it be worth removing the CSS-specific stuff from the PR for now, but still retaining the 'save options into the config' part? Like the yml format stuff? Because that's useful on its own maybe?