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

Make bsb --init . work #2500

bsansouci opened this issue Feb 7, 2018 · 7 comments

Make bsb --init . work #2500

bsansouci opened this issue Feb 7, 2018 · 7 comments


Copy link

@bsansouci bsansouci commented Feb 7, 2018

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.

Copy link

@nickzuber nickzuber commented Feb 8, 2018

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?

Copy link

@bobzhang bobzhang commented Feb 8, 2018

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

Copy link
Contributor Author

@bsansouci bsansouci commented Feb 8, 2018

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:

  • add a bsconfig.json
  • add src/reason/ (with the necessary folders if not there)
  • conditionally symlink the global bsb if bsb was installed globally. Right now bsb will error when it's already installed locally. I'd propose simply checking if there's already something called node_modules/bs-platform there.
    This should allow the same 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 :)

Copy link

@nickzuber nickzuber commented Feb 9, 2018

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!

Copy link

@mgmarlow mgmarlow commented Feb 10, 2018

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
Copy link

@nickzuber nickzuber commented Mar 29, 2018

@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?

@bobzhang bobzhang added the BUILD label Jul 23, 2018
bobzhang added a commit that referenced this issue Jul 24, 2018
when file or dir already exists it will continue initialization with some needed checks
fix #2945 #2500
Copy link

@bobzhang bobzhang commented Jul 27, 2018

Done in master, it will try to add new files and if it is already there, it will ignore

@bobzhang bobzhang closed this Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants