Open cody-dot-js opened 5 years ago
@dev-cprice how much have you battle-tested this on "real" Gemfiles? I'm adding Bundler support to Renovate and trying to decide whether to parse Gemfiles by calling out to ruby/bundler via child_process, or a Node.js parser like this.
@rarkins I've run it against gemfiles with multiple groups and 10-100 dependencies. It seems to work fine so far, but now that I have some free time I can better test it.
@rarkins unfortunately though, as it stands it only really works for non-nested groups, so something a little complicated like the rails Gemfile will not be parsed properly
@dev-cprice thanks for the reply. Do you mean this type of nested group?
platforms :jruby do
if ENV["AR_JDBC"]
gem "activerecord-jdbcsqlite3-adapter", github: "jruby/activerecord-jdbc-adapter", branch: "master"
group :db do
gem "activerecord-jdbcmysql-adapter", github: "jruby/activerecord-jdbc-adapter", branch: "master"
gem "activerecord-jdbcpostgresql-adapter", github: "jruby/activerecord-jdbc-adapter", branch: "master"
end
else
gem "activerecord-jdbcsqlite3-adapter", ">= 1.3.0"
group :db do
gem "activerecord-jdbcmysql-adapter", ">= 1.3.0"
gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.0"
end
end
end
For Renovate we only care ultimately about (a) the gem
lines, and (b) any group names that apply to it, and (c) sources.
A quick question for you, do you know if there are any "genuine" syntaxes for Gemfile where the gem name and version won't be on the same line? e.g. won't be like this:
gem "activerecord-jdbcpostgresql-adapter", ">= 1.3.0"
?
Also, do you know if there’s any restrictions on the levels or order of nesting? Eg platforms first, then group names, etc? Or is there no practical limit if you wanted to create weird nesting for fun?
@rarkins I'm not aware of any gemfiles where the name and version aren't on the same line. According to the bundler docs,
A Gemfile is evaluated as Ruby code, in a context which makes available a number of methods used to describe the gem requirements.
So, each line is essentially a method call in Ruby.. they could be multi-line, but I haven't necessarily come across any in practice.
And yes, from your example, that's what I mean by nested groups. I guess it isn't really nested groups, but more like nested blocks. Groups within blocks, I suppose. For my use case so far, it's just been to find all gems and their versions/sources and assume that they're on the same line. I definitely plan on making it more robust to support more advanced features, like platform blocks, etc.
Setup Jest and add test coverage for all methods.