[rubygems/rubygems] Allow installing plugins from path via CLI

Also bring the man page up to date.

https://github.com/rubygems/rubygems/commit/a849bd6947
This commit is contained in:
Cody Cutrer 2023-09-14 11:35:50 -06:00 committed by git
parent cbc11bcb63
commit 44b5c912da
35 changed files with 97 additions and 50 deletions

View File

@ -5,7 +5,7 @@ module Bundler
class CLI::Plugin < Thor class CLI::Plugin < Thor
desc "install PLUGINS", "Install the plugin from the source" desc "install PLUGINS", "Install the plugin from the source"
long_desc <<-D long_desc <<-D
Install plugins either from the rubygems source provided (with --source option) or from a git source provided with --git. If no sources are provided, it uses Gem.sources Install plugins either from the rubygems source provided (with --source option), from a git source provided with --git, or a local path provided with --path. If no sources are provided, it uses Gem.sources
D D
method_option "source", type: :string, default: nil, banner: "URL of the RubyGems source to fetch the plugin from" method_option "source", type: :string, default: nil, banner: "URL of the RubyGems source to fetch the plugin from"
method_option "version", type: :string, default: nil, banner: "The version of the plugin to fetch" method_option "version", type: :string, default: nil, banner: "The version of the plugin to fetch"
@ -13,6 +13,7 @@ module Bundler
method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (deprecated)" method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (deprecated)"
method_option "branch", type: :string, default: nil, banner: "The git branch to checkout" method_option "branch", type: :string, default: nil, banner: "The git branch to checkout"
method_option "ref", type: :string, default: nil, banner: "The git revision to check out" method_option "ref", type: :string, default: nil, banner: "The git revision to check out"
method_option "path", type: :string, default: nil, banner: "Path of a local gem to directly use"
def install(*plugins) def install(*plugins)
Bundler::Plugin.install(plugins, options) Bundler::Plugin.install(plugins, options)
end end

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-ADD" "1" "February 2024" "" .TH "BUNDLE\-ADD" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-BINSTUBS" "1" "February 2024" "" .TH "BUNDLE\-BINSTUBS" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems \fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CACHE" "1" "February 2024" "" .TH "BUNDLE\-CACHE" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application \fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CHECK" "1" "February 2024" "" .TH "BUNDLE\-CHECK" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems \fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CLEAN" "1" "February 2024" "" .TH "BUNDLE\-CLEAN" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory \fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CONFIG" "1" "February 2024" "" .TH "BUNDLE\-CONFIG" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options \fBbundle\-config\fR \- Set bundler configuration options
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-CONSOLE" "1" "February 2024" "" .TH "BUNDLE\-CONSOLE" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-console\fR \- Deprecated way to open an IRB session with the bundle pre\-loaded \fBbundle\-console\fR \- Deprecated way to open an IRB session with the bundle pre\-loaded
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-DOCTOR" "1" "February 2024" "" .TH "BUNDLE\-DOCTOR" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-doctor\fR \- Checks the bundle for common problems \fBbundle\-doctor\fR \- Checks the bundle for common problems
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-EXEC" "1" "February 2024" "" .TH "BUNDLE\-EXEC" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-exec\fR \- Execute a command in the context of the bundle \fBbundle\-exec\fR \- Execute a command in the context of the bundle
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-GEM" "1" "February 2024" "" .TH "BUNDLE\-GEM" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem \fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-HELP" "1" "February 2024" "" .TH "BUNDLE\-HELP" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-help\fR \- Displays detailed help for each subcommand \fBbundle\-help\fR \- Displays detailed help for each subcommand
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INFO" "1" "February 2024" "" .TH "BUNDLE\-INFO" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-info\fR \- Show information for the given gem in your bundle \fBbundle\-info\fR \- Show information for the given gem in your bundle
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INIT" "1" "February 2024" "" .TH "BUNDLE\-INIT" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-init\fR \- Generates a Gemfile into the current working directory \fBbundle\-init\fR \- Generates a Gemfile into the current working directory
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INJECT" "1" "February 2024" "" .TH "BUNDLE\-INJECT" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile \fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-INSTALL" "1" "February 2024" "" .TH "BUNDLE\-INSTALL" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-install\fR \- Install the dependencies specified in your Gemfile \fBbundle\-install\fR \- Install the dependencies specified in your Gemfile
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-LIST" "1" "February 2024" "" .TH "BUNDLE\-LIST" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-list\fR \- List all the gems in the bundle \fBbundle\-list\fR \- List all the gems in the bundle
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-LOCK" "1" "February 2024" "" .TH "BUNDLE\-LOCK" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing \fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-OPEN" "1" "February 2024" "" .TH "BUNDLE\-OPEN" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-open\fR \- Opens the source directory for a gem in your bundle \fBbundle\-open\fR \- Opens the source directory for a gem in your bundle
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-OUTDATED" "1" "February 2024" "" .TH "BUNDLE\-OUTDATED" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-outdated\fR \- List installed gems with newer versions available \fBbundle\-outdated\fR \- List installed gems with newer versions available
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-PLATFORM" "1" "February 2024" "" .TH "BUNDLE\-PLATFORM" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-platform\fR \- Displays platform compatibility information \fBbundle\-platform\fR \- Displays platform compatibility information
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,10 +1,10 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-PLUGIN" "1" "February 2024" "" .TH "BUNDLE\-PLUGIN" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-plugin\fR \- Manage Bundler plugins \fBbundle\-plugin\fR \- Manage Bundler plugins
.SH "SYNOPSIS" .SH "SYNOPSIS"
\fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR] \fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR] [\-\-path=\fIpath\fR]
.br .br
\fBbundle plugin\fR uninstall PLUGINS \fBbundle plugin\fR uninstall PLUGINS
.br .br
@ -37,7 +37,10 @@ Install bundler\-graph gem from Git repository\. You can use standard Git URLs l
.br .br
\fBfile:///path/to/repo\fR \fBfile:///path/to/repo\fR
.IP .IP
When you specify \fB\-\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\. When you specify both, only the latter is used\. When you specify \fB\-\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\.
.TP
\fBbundle plugin install bundler\-graph \-\-path \.\./bundler\-graph\fR
Install bundler\-graph gem from a local path\.
.SS "uninstall" .SS "uninstall"
Uninstall the plugin(s) specified in PLUGINS\. Uninstall the plugin(s) specified in PLUGINS\.
.SS "list" .SS "list"

View File

@ -4,7 +4,8 @@ bundle-plugin(1) -- Manage Bundler plugins
## SYNOPSIS ## SYNOPSIS
`bundle plugin` install PLUGINS [--source=<SOURCE>] [--version=<version>] `bundle plugin` install PLUGINS [--source=<SOURCE>] [--version=<version>]
[--git=<git-url>] [--branch=<branch>|--ref=<rev>]<br> [--git=<git-url>] [--branch=<branch>|--ref=<rev>]
[--path=<path>]<br>
`bundle plugin` uninstall PLUGINS<br> `bundle plugin` uninstall PLUGINS<br>
`bundle plugin` list<br> `bundle plugin` list<br>
`bundle plugin` help [COMMAND] `bundle plugin` help [COMMAND]
@ -36,7 +37,10 @@ Install the given plugin(s).
`/path/to/repo`<br> `/path/to/repo`<br>
`file:///path/to/repo` `file:///path/to/repo`
When you specify `--git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use. When you specify both, only the latter is used. When you specify `--git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use.
* `bundle plugin install bundler-graph --path ../bundler-graph`:
Install bundler-graph gem from a local path.
### uninstall ### uninstall

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-PRISTINE" "1" "February 2024" "" .TH "BUNDLE\-PRISTINE" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-pristine\fR \- Restores installed gems to their pristine condition \fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-REMOVE" "1" "February 2024" "" .TH "BUNDLE\-REMOVE" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-remove\fR \- Removes gems from the Gemfile \fBbundle\-remove\fR \- Removes gems from the Gemfile
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-SHOW" "1" "February 2024" "" .TH "BUNDLE\-SHOW" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem \fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-UPDATE" "1" "February 2024" "" .TH "BUNDLE\-UPDATE" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-update\fR \- Update your gems to the latest available versions \fBbundle\-update\fR \- Update your gems to the latest available versions
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-VERSION" "1" "February 2024" "" .TH "BUNDLE\-VERSION" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-version\fR \- Prints Bundler version information \fBbundle\-version\fR \- Prints Bundler version information
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE\-VIZ" "1" "February 2024" "" .TH "BUNDLE\-VIZ" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile \fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "BUNDLE" "1" "February 2024" "" .TH "BUNDLE" "1" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBbundle\fR \- Ruby Dependency Management \fBbundle\fR \- Ruby Dependency Management
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -1,6 +1,6 @@
.\" generated with nRonn/v0.11.1 .\" generated with nRonn/v0.11.1
.\" https://github.com/n-ronn/nronn/tree/0.11.1 .\" https://github.com/n-ronn/nronn/tree/0.11.1
.TH "GEMFILE" "5" "February 2024" "" .TH "GEMFILE" "5" "March 2024" ""
.SH "NAME" .SH "NAME"
\fBGemfile\fR \- A format for describing gem dependencies for Ruby programs \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
.SH "SYNOPSIS" .SH "SYNOPSIS"

View File

@ -10,6 +10,7 @@ module Bundler
class Installer class Installer
autoload :Rubygems, File.expand_path("installer/rubygems", __dir__) autoload :Rubygems, File.expand_path("installer/rubygems", __dir__)
autoload :Git, File.expand_path("installer/git", __dir__) autoload :Git, File.expand_path("installer/git", __dir__)
autoload :Path, File.expand_path("installer/path", __dir__)
def install(names, options) def install(names, options)
check_sources_consistency!(options) check_sources_consistency!(options)
@ -18,6 +19,8 @@ module Bundler
if options[:git] if options[:git]
install_git(names, version, options) install_git(names, version, options)
elsif options[:path]
install_path(names, version, options[:path])
else else
sources = options[:source] || Gem.sources sources = options[:source] || Gem.sources
install_rubygems(names, version, sources) install_rubygems(names, version, sources)
@ -50,8 +53,8 @@ module Bundler
options[:git] = options.delete(:local_git) options[:git] = options.delete(:local_git)
end end
if (options.keys & [:source, :git]).length > 1 if (options.keys & [:source, :git, :path]).length > 1
raise InvalidOption, "Only one of --source, or --git may be specified" raise InvalidOption, "Only one of --source, --git, or --path may be specified"
end end
if (options.key?(:branch) || options.key?(:ref)) && !options.key?(:git) if (options.key?(:branch) || options.key?(:ref)) && !options.key?(:git)
@ -64,10 +67,19 @@ module Bundler
end end
def install_git(names, version, options) def install_git(names, version, options)
uri = options.delete(:git) source_list = SourceList.new
options["uri"] = uri source = source_list.add_git_source({ "uri" => options[:git],
"branch" => options[:branch],
"ref" => options[:ref] })
install_all_sources(names, version, options, options[:source]) install_all_sources(names, version, source_list, source)
end
def install_path(names, version, path)
source_list = SourceList.new
source = source_list.add_path_source({ "path" => path })
install_all_sources(names, version, source_list, source)
end end
# Installs the plugin from rubygems source and returns the path where the # Installs the plugin from rubygems source and returns the path where the
@ -79,16 +91,15 @@ module Bundler
# #
# @return [Hash] map of names to the specs of plugins installed # @return [Hash] map of names to the specs of plugins installed
def install_rubygems(names, version, sources) def install_rubygems(names, version, sources)
install_all_sources(names, version, nil, sources)
end
def install_all_sources(names, version, git_source_options, rubygems_source)
source_list = SourceList.new source_list = SourceList.new
source_list.add_git_source(git_source_options) if git_source_options Array(sources).each {|remote| source_list.add_global_rubygems_remote(remote) }
Array(rubygems_source).each {|remote| source_list.add_global_rubygems_remote(remote) } if rubygems_source
deps = names.map {|name| Dependency.new name, version } install_all_sources(names, version, source_list)
end
def install_all_sources(names, version, source_list, source = nil)
deps = names.map {|name| Dependency.new(name, version, { "source" => source }) }
Bundler.configure_gem_home_and_path(Plugin.root) Bundler.configure_gem_home_and_path(Plugin.root)

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
module Bundler
module Plugin
class Installer
class Path < Bundler::Source::Path
def root
Plugin.root
end
def generate_bin(spec, disable_extensions = false)
# Need to find a way without code duplication
# For now, we can ignore this
end
end
end
end
end

View File

@ -9,6 +9,10 @@ module Bundler
add_source_to_list Plugin::Installer::Git.new(options), git_sources add_source_to_list Plugin::Installer::Git.new(options), git_sources
end end
def add_path_source(options = {})
add_source_to_list Plugin::Installer::Path.new(options), path_sources
end
def add_rubygems_source(options = {}) def add_rubygems_source(options = {})
add_source_to_list Plugin::Installer::Rubygems.new(options), @rubygems_sources add_source_to_list Plugin::Installer::Rubygems.new(options), @rubygems_sources
end end
@ -17,10 +21,6 @@ module Bundler
path_sources + git_sources + rubygems_sources + [metadata_source] path_sources + git_sources + rubygems_sources + [metadata_source]
end end
def default_source
git_sources.first || global_rubygems_source
end
private private
def rubygems_aggregate_class def rubygems_aggregate_class

View File

@ -212,6 +212,16 @@ RSpec.describe "bundler plugin install" do
end end
end end
it "installs from a path source" do
build_lib "path_plugin" do |s|
s.write "plugins.rb"
end
bundle "plugin install path_plugin --path #{lib_path("path_plugin-1.0")}"
expect(out).to include("Installed plugin path_plugin")
plugin_should_be_installed("path_plugin")
end
context "Gemfile eval" do context "Gemfile eval" do
before do before do
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)