Open cameronmurphy opened 5 years ago
Hey @cameronmurphy. Thanks for raising this.
So I deliberately left the JSON parsing out as it seemed clunky to add JSON to the CLI, but then proceeded to do a poor job documenting it.
In future, I've considered adding a simpler CLI syntax, something like: story2sketch --stories Buttons/Primary,Buttons/Secondary
.
So options are:
--stories
syntaxIf you have a preference, please feel free to open a PR. Otherwise, I'll address when time allows.
Agreed JSON on the command line is clunky. We're exporting stories split into files by grouping. If we export all 400 odd components into the same asketch.json, Sketch likes to crash. So an alternative would be a by-group
option in addition to all
as possible values for the --stories
argument.
At the moment the way we're achieving this is by generating a story2sketch.config.js
file, running story2sketch, removing the config file, writing the config file, running story2sketch etc.
To pass stories via the command line, the
--stories
argument needs to be parsed. It is simply merged into the config as a string here: https://github.com/chrisvxd/story2sketch/blob/master/src/server/index.js#L61For it to work I had to add:
to
tidyConfig()
.This enables
story2sketch --stories '[{"kind":"Buttons/Button","stories":[{"name":"Button"}]}]'
to work.