bundler-compose 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +2 -0
- data/.rspec +3 -0
- data/.rubocop.yml +32 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +39 -0
- data/exe/bundler-compose +52 -0
- data/lib/bundler/compose/cli.rb +208 -0
- data/lib/bundler/compose/composer.rb +145 -0
- data/lib/bundler/compose/version.rb +7 -0
- data/lib/bundler/compose.rb +16 -0
- data/sig/bundler/compose.rbs +6 -0
- data/tool/bundler/Gemfile +11 -0
- data/tool/bundler/Gemfile.lock +63 -0
- metadata +62 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 55937db52a3f81327cb8ec5bfb0a23a1be03acaec1c0eaadf8b0855d88d56baf
|
4
|
+
data.tar.gz: '084c592f6492606ebdddd24627cadbc61dfe9d5c525cb16d0258b82afc1cd6b1'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b2302ef5f9f7fa874c195514eca350777f1300b81478f6b5ee370f33fe17e38ebf83e3cfe0edfeff2d7ed9d22c33c3eca11f0d9c1bcac2559b9904a577eb2b0
|
7
|
+
data.tar.gz: 113bc116ead192a50ff3261450534b0e7c14b9f6def701ed51a5f335e4f73a6b3090ec546d20380cb2569ec83dd8cc3cfb5cec1e2d597f54e4daf97fc33c0fe6
|
data/.bundle/config
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.2
|
3
|
+
|
4
|
+
require:
|
5
|
+
- rubocop-rake
|
6
|
+
- rubocop-rspec
|
7
|
+
|
8
|
+
Style/StringLiterals:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Style/StringLiteralsInInterpolation:
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyle: double_quotes
|
15
|
+
|
16
|
+
Layout/LineLength:
|
17
|
+
Max: 120
|
18
|
+
|
19
|
+
Metrics:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/MultilineBlockChain:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
RSpec/MultipleExpectations:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
RSpec/ExampleLength:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/Documentation:
|
32
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at segiddins@segiddins.me. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Samuel Giddins
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Bundler::Compose
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bundler/compose`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bundler-compose. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/bundler-compose/blob/main/CODE_OF_CONDUCT.md).
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
36
|
+
|
37
|
+
## Code of Conduct
|
38
|
+
|
39
|
+
Everyone interacting in the Bundler::Compose project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bundler-compose/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "spec/support/rubygems_ext"
|
4
|
+
require "bundler/gem_tasks"
|
5
|
+
|
6
|
+
desc "Run specs"
|
7
|
+
task :spec do
|
8
|
+
sh("bin/rspec")
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :dev do
|
12
|
+
desc "Ensure dev dependencies are installed"
|
13
|
+
task :deps do
|
14
|
+
Spec::Rubygems.dev_setup
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Ensure dev dependencies are installed, and make sure no lockfile changes are generated"
|
18
|
+
task frozen_deps: :deps do
|
19
|
+
Spec::Rubygems.check_source_control_changes(
|
20
|
+
success_message: "Development dependencies were installed and the lockfile is in sync",
|
21
|
+
error_message: "Development dependencies were installed but the lockfile is out of sync. " \
|
22
|
+
"Commit the updated lockfile and try again"
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
namespace :spec do
|
28
|
+
desc "Ensure spec dependencies are installed"
|
29
|
+
task deps: "dev:deps" do
|
30
|
+
Spec::Rubygems.install_test_deps
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Run rubocop"
|
35
|
+
task :rubocop do
|
36
|
+
sh "bin/rubocop"
|
37
|
+
end
|
38
|
+
|
39
|
+
task default: %i[spec rubocop]
|
data/exe/bundler-compose
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Exit cleanly from an early interrupt
|
5
|
+
Signal.trap("INT") do
|
6
|
+
Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
base_path = File.expand_path("../lib", __dir__)
|
11
|
+
|
12
|
+
if File.exist?(base_path)
|
13
|
+
require_relative "../lib/bundler/compose"
|
14
|
+
else
|
15
|
+
require "bundler/compose"
|
16
|
+
end
|
17
|
+
require "bundler/friendly_errors"
|
18
|
+
|
19
|
+
# Bundler.with_friendly_errors do
|
20
|
+
require "bundler/cli"
|
21
|
+
|
22
|
+
command_aliases = Bundler::CLI.send :remove_const, :COMMAND_ALIASES
|
23
|
+
Bundler::CLI::COMMAND_ALIASES = command_aliases.merge("exec" => %w[compose]) { |_, l, r| l + r }
|
24
|
+
|
25
|
+
Bundler::CLI.map.reject! { |_, v| v == :help }
|
26
|
+
|
27
|
+
help_flags = %w[--help -h]
|
28
|
+
help_flag_used = ARGV.any? { |a| help_flags.include? a }
|
29
|
+
args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
|
30
|
+
|
31
|
+
Bundler::CLI.send :remove_const, :COMMAND_ALIASES
|
32
|
+
Bundler::CLI::COMMAND_ALIASES = command_aliases
|
33
|
+
|
34
|
+
pc = Bundler::CLI.send :remove_const, :PARSEABLE_COMMANDS
|
35
|
+
Bundler::CLI::PARSEABLE_COMMANDS = (pc + ["compose"]).freeze
|
36
|
+
|
37
|
+
Bundler.ui.level = "error"
|
38
|
+
|
39
|
+
Bundler::CLI.register Bundler::Compose::CLI, :compose, "compose", "Runs the thing"
|
40
|
+
Bundler::CLI.remove_method(:compose)
|
41
|
+
Bundler::CLI.define_method(:compose) do |*compose_args|
|
42
|
+
compose_args, opts = Bundler::Thor::Arguments.split(compose_args)
|
43
|
+
invoke_args = [compose_args, opts, { invoked_via_subcommand: true, class_options: options }]
|
44
|
+
invoke Bundler::Compose::CLI, *invoke_args
|
45
|
+
end
|
46
|
+
Bundler::CLI.check_unknown_options[:except] << :compose
|
47
|
+
Bundler::CLI.stop_on_unknown_option! :compose
|
48
|
+
Bundler::Thor.singleton_class.define_method(:basename) { "bundle" }
|
49
|
+
|
50
|
+
Bundler.with_friendly_errors do
|
51
|
+
Bundler::CLI.start %w[compose] + args, debug: true
|
52
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
module Compose
|
5
|
+
class CLI < Bundler::Thor
|
6
|
+
map.reject! { |_, v| v == :help }
|
7
|
+
(@class_options ||= {}).merge!(Bundler::CLI.class_options)
|
8
|
+
|
9
|
+
module Common
|
10
|
+
def self.included(klass)
|
11
|
+
# klass.strict_args_position!
|
12
|
+
klass.singleton_class.define_method(:handle_argument_error, lambda do |*args, **kwargs, &blk|
|
13
|
+
Bundler::Thor.method(:handle_argument_error).call(*args, **kwargs, &blk)
|
14
|
+
end)
|
15
|
+
|
16
|
+
klass.singleton_class.define_method(:dispatch) do |command, given_args, given_opts, config, **kwargs, &blk|
|
17
|
+
level = Bundler.ui.level
|
18
|
+
|
19
|
+
separator = given_opts.index("--")
|
20
|
+
if separator
|
21
|
+
extra_opts = given_opts[separator.succ..]
|
22
|
+
given_opts = given_opts[0...separator]
|
23
|
+
end
|
24
|
+
if extra_opts
|
25
|
+
if extra_opts == given_args[-extra_opts.size...]
|
26
|
+
given_args = given_args[...-extra_opts.size]
|
27
|
+
given_args.pop if given_args.last == "--"
|
28
|
+
end
|
29
|
+
elsif given_opts == given_args[-given_opts.size...]
|
30
|
+
given_args = given_args[...-given_opts.size]
|
31
|
+
end
|
32
|
+
|
33
|
+
super(command, given_args, given_opts, config, **kwargs) do |i|
|
34
|
+
blk.call(i)
|
35
|
+
i.args += extra_opts if extra_opts
|
36
|
+
Bundler.ui.level = "silent" unless i.options["verbose"]
|
37
|
+
end
|
38
|
+
ensure
|
39
|
+
Bundler.ui.level = level if Bundler.ui.level == "silent"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def set_ui_level
|
44
|
+
Bundler.ui.level = "silent" unless options["verbose"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def check_equivalence
|
48
|
+
Bundler.definition.ensure_equivalent_gemfile_and_lockfile
|
49
|
+
end
|
50
|
+
|
51
|
+
def use_path(file_name)
|
52
|
+
@path = Bundler.app_config_path.join("bundler-compose", file_name)
|
53
|
+
@gemfile = @path.join("gems.#{file_name}.rb")
|
54
|
+
@lockfile = @path.join("gems.#{file_name}.rb.lock")
|
55
|
+
Bundler.mkdir_p @path
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_comment
|
59
|
+
@comment = [
|
60
|
+
"# lockfile",
|
61
|
+
Bundler.default_gemfile.relative_path_from(@gemfile.dirname),
|
62
|
+
Bundler::SharedHelpers.digest(:SHA256).hexdigest(Bundler.read_file(Bundler.default_lockfile))
|
63
|
+
].join(":")
|
64
|
+
end
|
65
|
+
|
66
|
+
def copy_lockfile
|
67
|
+
lockfile_up_to_date = Bundler::SharedHelpers.filesystem_access(@gemfile, :read) do
|
68
|
+
File.read(@gemfile, @comment.length, external_encoding: "UTF-8") == @comment
|
69
|
+
rescue Errno::ENOENT
|
70
|
+
false
|
71
|
+
end
|
72
|
+
|
73
|
+
Bundler::FileUtils.cp(Bundler.default_lockfile, @lockfile) unless lockfile_up_to_date
|
74
|
+
end
|
75
|
+
|
76
|
+
def bundle_exec(executable)
|
77
|
+
Bundler.reset!
|
78
|
+
Bundler.with_unbundled_env do
|
79
|
+
Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler.definition.locked_gems.bundler_version.to_s
|
80
|
+
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", @gemfile.to_path
|
81
|
+
ENV["BUNDLE_PATH"] = Bundler.settings.path.use_system_gems? ? nil : path.to_path
|
82
|
+
ENV["BUNDLE_DISABLE_EXEC_LOAD"] = "true"
|
83
|
+
ENV["BUNDLE_AUTO_INSTALL"] = "true"
|
84
|
+
|
85
|
+
Bundler.reset!
|
86
|
+
Bundler.reset_settings_and_root!
|
87
|
+
|
88
|
+
Bundler.ui.debug "Running `#{["bundle", "exec", executable, *args].join(" ")}`"
|
89
|
+
Bundler::CLI.start(["exec", executable, *args], debug: true)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
gems = Class.new(Bundler::Thor::Group) do
|
95
|
+
desc "compose gems into the current gemfile"
|
96
|
+
|
97
|
+
argument :gem_names, type: :array, default: []
|
98
|
+
|
99
|
+
class_option :exec, desc: "what to exec", type: :string
|
100
|
+
|
101
|
+
include Common
|
102
|
+
|
103
|
+
def before
|
104
|
+
set_ui_level
|
105
|
+
check_equivalence
|
106
|
+
end
|
107
|
+
|
108
|
+
def validate_args
|
109
|
+
return unless gem_names.empty?
|
110
|
+
|
111
|
+
self.class.handle_argument_error(
|
112
|
+
@_initializer.last[:current_command],
|
113
|
+
"must give at least one gem to compose", gem_names,
|
114
|
+
-1
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
def use_path
|
119
|
+
super(gem_names.join("_").tr(":", "@"))
|
120
|
+
end
|
121
|
+
|
122
|
+
def lockfile
|
123
|
+
set_comment
|
124
|
+
copy_lockfile
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_composer
|
128
|
+
gems_to_add = gem_names.map do
|
129
|
+
n, v = extract_gem_name_and_version(_1)
|
130
|
+
Bundler::Dependency.new(n, v)
|
131
|
+
end
|
132
|
+
@composer = Bundler::Compose::Composer.new(@comment, Bundler.definition, gems_to_add, [], @gemfile)
|
133
|
+
end
|
134
|
+
|
135
|
+
def do
|
136
|
+
@composer.write!
|
137
|
+
bundle_exec(options[:exec] || extract_gem_name_and_version(gem_names.first).first)
|
138
|
+
end
|
139
|
+
|
140
|
+
no_commands do
|
141
|
+
def extract_gem_name_and_version(name)
|
142
|
+
if /\A(.*):(#{Gem::Requirement::PATTERN_RAW})\z/ =~ name
|
143
|
+
[::Regexp.last_match(1), ::Regexp.last_match(2)]
|
144
|
+
else
|
145
|
+
[name]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
register gems, :gems, "gems GEM_NAMES...", "compose gems into the current gemfile"
|
152
|
+
map "gem" => :gems
|
153
|
+
|
154
|
+
stop_on_unknown_option! :gems
|
155
|
+
|
156
|
+
gemfiles = Class.new(Bundler::Thor::Group) do
|
157
|
+
desc "compose local gemfiles into the current gemfile"
|
158
|
+
|
159
|
+
argument :gemfiles, type: :array, default: []
|
160
|
+
|
161
|
+
class_option :exec, desc: "what to exec", type: :string, required: true
|
162
|
+
|
163
|
+
include Common
|
164
|
+
|
165
|
+
def before
|
166
|
+
set_ui_level
|
167
|
+
check_equivalence
|
168
|
+
end
|
169
|
+
|
170
|
+
def validate_args
|
171
|
+
return unless gemfiles.empty?
|
172
|
+
|
173
|
+
self.class.handle_argument_error(
|
174
|
+
@_initializer.last[:current_command],
|
175
|
+
"must give at least one gemfile to compose", gemfiles,
|
176
|
+
-1
|
177
|
+
)
|
178
|
+
end
|
179
|
+
|
180
|
+
def use_path
|
181
|
+
super(gemfiles.join("_"))
|
182
|
+
end
|
183
|
+
|
184
|
+
def lockfile
|
185
|
+
set_comment
|
186
|
+
copy_lockfile
|
187
|
+
end
|
188
|
+
|
189
|
+
def set_composer
|
190
|
+
gemfiles_to_add = gemfiles.map do |gemfile|
|
191
|
+
Pathname(gemfile).expand_path.relative_path_from(@gemfile.dirname).to_path
|
192
|
+
end
|
193
|
+
@composer = Bundler::Compose::Composer.new(@comment, Bundler.definition, [], gemfiles_to_add, @gemfile)
|
194
|
+
end
|
195
|
+
|
196
|
+
def do
|
197
|
+
@composer.write!
|
198
|
+
bundle_exec(options[:exec])
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
register gemfiles, :gemfiles, "gemfiles GEMFILES...", "compose gemfiles into the current gemfile"
|
203
|
+
map "gemfile" => :gemfiles
|
204
|
+
|
205
|
+
stop_on_unknown_option! :gemfiles
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
module Compose
|
5
|
+
class Composer
|
6
|
+
attr_reader :definition
|
7
|
+
|
8
|
+
def initialize(comment, definition, gems_to_add, gemfiles_to_eval, gemfile)
|
9
|
+
@comment = comment
|
10
|
+
@definition = definition
|
11
|
+
@gems_to_add = gems_to_add
|
12
|
+
@gemfiles_to_eval = gemfiles_to_eval
|
13
|
+
@gemfile = gemfile
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
[
|
18
|
+
@comment,
|
19
|
+
commented(platforms, "Platforms found in the lockfile"),
|
20
|
+
commented(global_sources, "Global sources from gemfile"),
|
21
|
+
commented(composed_gems, "Composed dependencies"),
|
22
|
+
commented(composed_gemfiles, "Composed gemfiles"),
|
23
|
+
commented(explicit_deps, "Original deps from gemfile"),
|
24
|
+
commented(implicit_deps, "Deps from Gemfile.lock")
|
25
|
+
].compact.map { Array(_1).join("\n") }.join("\n\n") << "\n"
|
26
|
+
end
|
27
|
+
|
28
|
+
def write!
|
29
|
+
Bundler::SharedHelpers.write_to_gemfile(@gemfile, to_s)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def platforms
|
35
|
+
@definition.platforms.map do |p|
|
36
|
+
"platform(#{p.to_s.dump}) {}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def global_sources
|
41
|
+
@definition.send(:sources).global_rubygems_source.remotes.map { %(source #{_1.to_s.dump}) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def composed_gems
|
45
|
+
dependencies_to_gemfile(@gems_to_add)
|
46
|
+
end
|
47
|
+
|
48
|
+
def composed_gemfiles
|
49
|
+
@gemfiles_to_eval.map do |g|
|
50
|
+
%(eval_gemfile #{g.to_s.dump})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def explicit_deps
|
55
|
+
dependencies_to_gemfile(@definition.dependencies)
|
56
|
+
end
|
57
|
+
|
58
|
+
def implicit_deps
|
59
|
+
dependency_names = @definition.dependencies.group_by(&:name)
|
60
|
+
dependencies_to_gemfile(@definition.resolve.map do |s|
|
61
|
+
next if dependency_names.key?(s.name)
|
62
|
+
|
63
|
+
Bundler::Dependency.new(s.name, s.version, "platform" => s.platform, "source" => s.source,
|
64
|
+
"group" => %i[bundler_compose])
|
65
|
+
end.compact)
|
66
|
+
end
|
67
|
+
|
68
|
+
def dependencies_to_gemfile(dependencies)
|
69
|
+
dependencies.group_by(&:groups).each_key(&:sort!).sort_by(&:first).each
|
70
|
+
.with_object([]) do |(groups, deps), lines|
|
71
|
+
groups = nil if groups.empty? || groups == %i[default]
|
72
|
+
optional = groups == %i[bundler_compose] ? ", optional: true" : nil
|
73
|
+
lines << "group #{groups.map(&:inspect).join(", ")}#{optional} do" if groups
|
74
|
+
|
75
|
+
deps.sort_by(&:name).each do |d|
|
76
|
+
spec = Bundler.definition.resolve[d.name].first
|
77
|
+
|
78
|
+
da = []
|
79
|
+
da << " " if groups
|
80
|
+
|
81
|
+
unless d.source.is_a?(Bundler::Source::Gemspec)
|
82
|
+
da << "gem "
|
83
|
+
da << d.name.dump
|
84
|
+
if spec
|
85
|
+
da << ", #{Gem::Requirement.new(spec.version).as_list.map(&:inspect).join(", ")}"
|
86
|
+
elsif !d.requirement.none? # rubocop:disable Style/InverseMethods
|
87
|
+
da << ", #{d.requirement.as_list.map(&:inspect).join(", ")}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
da << if d.source.nil? && spec
|
92
|
+
source_to_options(spec.source)
|
93
|
+
else
|
94
|
+
source_to_options(d.source)
|
95
|
+
end
|
96
|
+
da << ", platforms: " << d.platforms.inspect unless d.platforms.empty?
|
97
|
+
if (env = d.instance_variable_get(:@env))
|
98
|
+
da << ", env: " << env.inspect
|
99
|
+
end
|
100
|
+
if ((req = d.autorequire)) && !req.empty?
|
101
|
+
req = req.first if req.size == 1
|
102
|
+
da << ", require: " << req.inspect
|
103
|
+
end
|
104
|
+
|
105
|
+
lines << da.join
|
106
|
+
end
|
107
|
+
|
108
|
+
lines << "end" if groups
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def source_to_options(source)
|
113
|
+
case source
|
114
|
+
when nil
|
115
|
+
nil
|
116
|
+
when Bundler::Source::Rubygems
|
117
|
+
if source.remotes.size == 1
|
118
|
+
%(, source: #{source.send(:suppress_configured_credentials,
|
119
|
+
source.remotes.first).to_s.dump})
|
120
|
+
end
|
121
|
+
when Bundler::Source::Gemspec
|
122
|
+
path = source.options["root_path"].join(source.options["path"])
|
123
|
+
.relative_path_from(@gemfile.dirname).to_path.dump
|
124
|
+
s = "gemspec path: #{path}, " \
|
125
|
+
"name: #{source.options["gemspec"].name.dump}"
|
126
|
+
s << ", glob: #{source.options["glob"].dump}" if source.options["glob"]
|
127
|
+
s
|
128
|
+
else
|
129
|
+
raise Error, "Unhandled source type #{source.inspect}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def commented(section, comment)
|
134
|
+
return unless section
|
135
|
+
|
136
|
+
section = Array(section)
|
137
|
+
return if section.empty?
|
138
|
+
|
139
|
+
comment = "#{"#" * 80}\n#{comment.gsub(/(.{1,#{80 - 4}})(\s+|$)/, "# \\1\n")}#{"#" * 80}"
|
140
|
+
|
141
|
+
section.insert(0, comment, nil)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler"
|
4
|
+
require "bundler/cli"
|
5
|
+
require_relative "compose/cli"
|
6
|
+
require_relative "compose/composer"
|
7
|
+
require_relative "compose/version"
|
8
|
+
|
9
|
+
module Bundler
|
10
|
+
module Compose
|
11
|
+
class Error < BundlerError
|
12
|
+
status_code 99
|
13
|
+
end
|
14
|
+
# Your code goes here...
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ast (2.4.2)
|
5
|
+
diff-lcs (1.5.0)
|
6
|
+
json (2.6.3)
|
7
|
+
parallel (1.22.1)
|
8
|
+
parser (3.2.1.1)
|
9
|
+
ast (~> 2.4.1)
|
10
|
+
rainbow (3.1.1)
|
11
|
+
rake (13.0.1)
|
12
|
+
regexp_parser (2.7.0)
|
13
|
+
rexml (3.2.5)
|
14
|
+
rspec (3.12.0)
|
15
|
+
rspec-core (~> 3.12.0)
|
16
|
+
rspec-expectations (~> 3.12.0)
|
17
|
+
rspec-mocks (~> 3.12.0)
|
18
|
+
rspec-core (3.12.1)
|
19
|
+
rspec-support (~> 3.12.0)
|
20
|
+
rspec-expectations (3.12.2)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.12.0)
|
23
|
+
rspec-mocks (3.12.4)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.12.0)
|
26
|
+
rspec-support (3.12.0)
|
27
|
+
rubocop (1.48.1)
|
28
|
+
json (~> 2.3)
|
29
|
+
parallel (~> 1.10)
|
30
|
+
parser (>= 3.2.0.0)
|
31
|
+
rainbow (>= 2.2.2, < 4.0)
|
32
|
+
regexp_parser (>= 1.8, < 3.0)
|
33
|
+
rexml (>= 3.2.5, < 4.0)
|
34
|
+
rubocop-ast (>= 1.26.0, < 2.0)
|
35
|
+
ruby-progressbar (~> 1.7)
|
36
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
37
|
+
rubocop-ast (1.27.0)
|
38
|
+
parser (>= 3.2.1.0)
|
39
|
+
rubocop-capybara (2.17.1)
|
40
|
+
rubocop (~> 1.41)
|
41
|
+
rubocop-rake (0.6.0)
|
42
|
+
rubocop (~> 1.0)
|
43
|
+
rubocop-rspec (2.19.0)
|
44
|
+
rubocop (~> 1.33)
|
45
|
+
rubocop-capybara (~> 2.17)
|
46
|
+
ruby-progressbar (1.13.0)
|
47
|
+
unicode-display_width (2.4.2)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
arm64-darwin-22
|
51
|
+
ruby
|
52
|
+
x86_64-linux
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
bundler
|
56
|
+
rake (= 13.0.1)
|
57
|
+
rspec (~> 3.0)
|
58
|
+
rubocop (~> 1.21)
|
59
|
+
rubocop-rake (~> 0.6.0)
|
60
|
+
rubocop-rspec (~> 2.19)
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
2.4.9
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler-compose
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Giddins
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- segiddins@segiddins.me
|
16
|
+
executables:
|
17
|
+
- bundler-compose
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".bundle/config"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
24
|
+
- CHANGELOG.md
|
25
|
+
- CODE_OF_CONDUCT.md
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- exe/bundler-compose
|
30
|
+
- lib/bundler/compose.rb
|
31
|
+
- lib/bundler/compose/cli.rb
|
32
|
+
- lib/bundler/compose/composer.rb
|
33
|
+
- lib/bundler/compose/version.rb
|
34
|
+
- sig/bundler/compose.rbs
|
35
|
+
- tool/bundler/Gemfile
|
36
|
+
- tool/bundler/Gemfile.lock
|
37
|
+
homepage: https://github.com/segiddins/bundler-compose
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata:
|
41
|
+
homepage_uri: https://github.com/segiddins/bundler-compose
|
42
|
+
source_code_uri: https://github.com/segiddins/bundler-compose
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 3.2.0
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubygems_version: 3.4.9
|
59
|
+
signing_key:
|
60
|
+
specification_version: 4
|
61
|
+
summary: Ok
|
62
|
+
test_files: []
|