It'd be nice to be able to do bsb --init . and have bsb simply add a bsconfig.json.
This would help adopting bsb on existent projects.
Right now that'll error if you already have a src folder for example. It'l also error if you've install bsb locally.
It looks like bsb -init is designed to set up a template project instead of prepping an existing project to interop with Reason.
$ bsb --help
-init Init sample project to get started. Note (`bsb -init sample` will create a sample project while `bsb -init .` will reuse current directory)
I think having init create a template makes sense and has its place, perhaps there could be a separate command for adding config files and dependencies to an existing project so we don't confuse the two -- maybe something like -setup?
relevant to #2498
Right now that'll error if you already have a src folder for example.
Shall we scan the directory? what's the expected behavior? Note currently if it is an empty directory, it should work
Based on @nickzuber's really cool tool add-reason, here's what seems to be the simplest setup without being too magical. When one calls bsb --init . we check if there's a package.json or not.
If there's a package.json:
src/reason/index.re (with the necessary folders if not there)node_modules/bs-platform there.const reason = require("src/reason") easy require.If there isn't a package.json simply do what we currently do with bsb --init projectName but in the current dir.
If the user does bsb --init projectName we do the same as we currently do.
I think this would bring the easy setup from add-reason directly into bsb with little added complexity :)
Thanks for the outline @bsansouci, I think this looks really good so far.
Do you think the config file should default to in-source compilation w/ .bs.js suffix (this would be outlined clearly in docs if so)? I think these options produce the least amount of interop friction personally, but would like to hear other thoughts.
I'd love to take this task on too 馃槃
Edit: I'm currently working on this!
It would also be nice to be able to call --init on a directory that already exists. With the @angular/cli I can create an empty repo on github with readme and license, clone it, (git clone http://.../blog) and call ng new blog and it will fill in the files in the directory that already exists.
Doing this w/ reason results in:
blog already existed
@mgmarlow Is there any reason you can't cd into the directory and then call bsb -init . (after this change is made)? Or is it just for the sake of convenience?
Done in master, it will try to add new files and if it is already there, it will ignore
Most helpful comment
Based on @nickzuber's really cool tool
add-reason, here's what seems to be the simplest setup without being too magical. When one callsbsb --init .we check if there's apackage.jsonor not.If there's a
package.json:src/reason/index.re(with the necessary folders if not there)node_modules/bs-platformthere.This should allow the same
const reason = require("src/reason")easy require.If there isn't a
package.jsonsimply do what we currently do withbsb --init projectNamebut in the current dir.If the user does
bsb --init projectNamewe do the same as we currently do.I think this would bring the easy setup from
add-reasondirectly into bsb with little added complexity :)