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

Add bundle install to jekyll new command #5237

Merged
merged 2 commits into from Sep 20, 2016
Merged

Conversation

ashmaroli
Copy link
Member

@ashmaroli ashmaroli commented Aug 12, 2016

This PR proposes to extend the jekyll new command with following:

  • Automatically cd my_blog and initiate bundle install

After you run jekyll new my_blog the command shell automatically cd into the new directory and runs bundle install.
If bundler is not installed, an exception is raised gracefully.
The user may choose to skip 'bundle install' if they plan to edit their new gemfile and change the theme gem, or if they want to inspect the new directory before running the bundle install command by using the new switch --skip-bundle

ref: #5225


def bundle_install(path)
Jekyll::External.require_with_graceful_fail "bundler"
$stdout.print "\nRun 'bundle install' with default theme? (Y/N) "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the Jekyll Logger.

Copy link
Member Author

@ashmaroli ashmaroli Aug 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jekyll logger inserts a newline at the end.. I proposed print to have gets on same line.
Is that fine?

@ashmaroli ashmaroli force-pushed the bundle2new branch 3 times, most recently from 4e58e89 to a244819 Compare August 12, 2016 08:32
@ashmaroli
Copy link
Member Author

Add bundler as a runtime dependency to gemspec?

@envygeeks
Copy link
Contributor

I don't think that's a good idea, that could lead to problems on a system.

@parkr
Copy link
Member

parkr commented Aug 22, 2016

Thanks for this PR! I'm not sure how I feel about this either. The current code is interactive, which I'm not such a big fan of. rails new always ran bundle install which I liked as a newcomer, but the Rails community is pretty different from the Jekyll community, I think. Not sure how I feel about this.

In general, we are headed in the direction of "always use bundler" so this isn't problematic from that perspective. But we should gracefully fail if bundler isn't available and mention that the user should run bundle install before running jekyll. 😄

@ashmaroli
Copy link
Member Author

Hi @parkr, I'm pretty confused..

But we should gracefully fail if bundler isn't available

PR does that already..

mention that the user should run bundle install before running jekyll.

??
There wont be a Gemfile to run bundle against until jekyll new has been called.
Running bundle after blog install will install minima theme gem for first time users; update minima if necessary for existing customers on J3.2.
Running bundle interactively lets the user edit their Gemfile / view the installed directory contents before having a request sent to rubygems.org. Once they make their decision, the new theme has to be bundled before being served.

@ashmaroli ashmaroli mentioned this pull request Sep 9, 2016
@mattr-
Copy link
Member

mattr- commented Sep 9, 2016

I'm 👍 with the idea of running bundler when you create a new Jekyll site. Let's just run it all the time though, instead of asking the user if we should run it. I see no use case where a user would not want to run bundler after getting a new site.

@ashmaroli
Copy link
Member Author

@mattr- Thanks for the +1. 😃

I see no use case where a user would not want to run bundler after getting a new site.

I mentioned a possible scenario in the PR desc.:
The user may choose to skip 'bundle install' if they plan to edit their new gemfile and change the theme gem, or if they want to inspect the new directory before running the bundle install command

@mattr-
Copy link
Member

mattr- commented Sep 9, 2016

Those are technical use cases that I don't want to solve for, especially the directory inspection. While I expect that a large set of Jekyll's users are going to be on the more technical side, it's ridiculously easy to run bundle after we've done it as part of site generation after editing the Gemfile. I see where you're coming from on this, but I feel like it's only going to be used in a tiny set of cases and I'd rather come back and add it later if it's a highly requested feature.

@ashmaroli
Copy link
Member Author

Okay. I'll modify the PR.

@ghost
Copy link

ghost commented Sep 9, 2016

I'd prefer the simple option of an argument --no-bundler, there's no need to have an interactive prompt, Jekyll doesn't do this already for anything AFAIK. Other that that, 👍!

@ashmaroli
Copy link
Member Author

ashmaroli commented Sep 12, 2016

Replaced interactive bundle with running bundle install by default. Can be skipped by using a switch
--skip_bundle

Jekyll.logger.info "Running bundle install in #{path.cyan}..."
Dir.chdir(path) do
unless ENV["CI"] || ENV["TEST"] # skip `bundle` during local tests
system("bundle install")
Copy link
Member Author

@ashmaroli ashmaroli Sep 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to skip bundle install when running tests. Couldn't find the appropriate ENV key/value..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about all that but that should be system("bundle", "install")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, actually, tbh, it doesn't matter. I mix the two anyways I wouldn't blame you if you don't care to change it either.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really matter until you start passing arguments dynamically 😉 Although I do prefer the variadic argument form

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works.. so leaving it as is..
Thanks for the info, anyways 😃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spudowiar it's that kind of terrible logic that leads to security issues in software. It always matters. Whether it works or not is irrelevant to the point, the statement stands and the option was left to leave it as is out of ease, not out of it "not mattering."

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@envygeeks I'm saying that although you should always use the variadic form, in this case not changing it doesn't matter too much. I always use the variadic form

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer system("bundle", "install") as well. You may also have to specify the BUNDLER_GEMFILE variable as well.

 - automatically run `bundle install` from within the newly generated blog
   directory by default.
 - add a new switch to skip this default behaviour.
@ashmaroli
Copy link
Member Author

@jekyll/ecosystem : Since, this PR adds bundle install by default, should script/default-site be modified to avoid switching directories and then executing bundle install, as well?

@ashmaroli
Copy link
Member Author

Updates:

  • changed skip switch to --skip-bundle
  • system(bundle install) replaced with system("bundle", "install")
  • modified test/test_new_command to test bundle-install-action and skip-switch


def after_install(path, options = {})
Jekyll.logger.info "New jekyll site installed in #{path.cyan}."
Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems superfluous since --skip-bundle is an explicitly chosen command line option, unaffected by the environment in any way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. Would love another review from someone in @jekyll/core or @benbalter.

@benbalter
Copy link
Contributor

LGTM.

@parkr
Copy link
Member

parkr commented Sep 20, 2016

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit 504411e into jekyll:master Sep 20, 2016
jekyllbot added a commit that referenced this pull request Sep 20, 2016
@parkr parkr added this to the 3.3 milestone Sep 20, 2016
@ashmaroli
Copy link
Member Author

ashmaroli commented Sep 21, 2016

TODO:

  • Update online documentation regarding this new feature. :
    • add a para under Quickstart

/cc @DirtyF
Whatsay? Is there any other place I should update?
Or will it be updated alongwith the Release Notes for 3.3?

@ashmaroli
Copy link
Member Author

@parkr et al, All those bundle (show) reports in test logs might get frustrating at some point in future..
Your opinion?

@parkr
Copy link
Member

parkr commented Sep 21, 2016

All those bundle (show) reports in test logs might get frustrating at some point in future..
Your opinion?

Yeah definitely. If you can capture those and output them using Jekyll.logger then our current capture_stdout should ensure they're not written to actual stdout.

@DirtyF
Copy link
Member

DirtyF commented Sep 21, 2016

@ashmaroli yeah, homepage snippet will also be affected by this change, be sure to reflect changes here too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants