lapidist 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +37 -0
- data/README.adoc +44 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/lapidist +107 -0
- data/lapidist.gemspec +40 -0
- data/lib/lapidist.rb +40 -0
- data/lib/lapidist/cli/command.rb +192 -0
- data/lib/lapidist/version.rb +3 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9fc5ae63afead95bedeacb3bfeeea0936bc40bdaacc56349ff35bd4dd55c549a
|
4
|
+
data.tar.gz: ebe06f83cd53b2173fb37a1ec739094cd856e3e07207dafef7fadc622a79864e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8884c32ef89f516a8411e9496f33dce6de54ae04f6dfd37c1e31f63fe8f8301b8606a6bf6cddfabc90ecda3e2a9d84d352ae4cd6fda9880f297f3ef450f9b12
|
7
|
+
data.tar.gz: d6254f7de0c65f96e651a09df170f15845a509805a56660f9b03c6880c2b8d927461f486cb39bf2726f2e43d130cf9ff0a28aec28759e0c2d1d2546a237f6aed
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at abobrikovich@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lapidist (0.1.0)
|
5
|
+
gem-release
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
gem-release (2.0.3)
|
12
|
+
rake (10.5.0)
|
13
|
+
rspec (3.8.0)
|
14
|
+
rspec-core (~> 3.8.0)
|
15
|
+
rspec-expectations (~> 3.8.0)
|
16
|
+
rspec-mocks (~> 3.8.0)
|
17
|
+
rspec-core (3.8.2)
|
18
|
+
rspec-support (~> 3.8.0)
|
19
|
+
rspec-expectations (3.8.4)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.8.0)
|
22
|
+
rspec-mocks (3.8.1)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.8.0)
|
25
|
+
rspec-support (3.8.2)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (~> 2.0)
|
32
|
+
lapidist!
|
33
|
+
rake (~> 10.0)
|
34
|
+
rspec (~> 3.0)
|
35
|
+
|
36
|
+
BUNDLED WITH
|
37
|
+
2.0.1
|
data/README.adoc
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
= Lapidist: synchronized gem releases
|
2
|
+
|
3
|
+
TODO.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
[source,ruby]
|
10
|
+
----
|
11
|
+
gem 'lapidist'
|
12
|
+
----
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
[source,sh]
|
17
|
+
----
|
18
|
+
$ bundle
|
19
|
+
----
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
[source,sh]
|
24
|
+
----
|
25
|
+
$ gem install lapidist
|
26
|
+
----
|
27
|
+
|
28
|
+
== Usage
|
29
|
+
|
30
|
+
TODO: Write usage instructions here
|
31
|
+
|
32
|
+
== Development
|
33
|
+
|
34
|
+
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.
|
35
|
+
|
36
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
== Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/metanorma/lapidist. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the http://contributor-covenant.org[Contributor Covenant] code of conduct.
|
41
|
+
|
42
|
+
== Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Lapidist project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the https://github.com/metanorma/lapidist/blob/master/CODE_OF_CONDUCT.md[code of conduct].
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "lapidist"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/lapidist
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
require_relative '../lib/lapidist/cli/command'
|
7
|
+
|
8
|
+
options = {
|
9
|
+
dry_run: false,
|
10
|
+
verbose: false,
|
11
|
+
silent: false,
|
12
|
+
branch: nil,
|
13
|
+
gems: nil,
|
14
|
+
gems_path: Dir.pwd
|
15
|
+
}
|
16
|
+
|
17
|
+
command_name = 'lapidist'
|
18
|
+
top_help = <<HELP
|
19
|
+
List of supported sub-scommands:
|
20
|
+
start : create branch for listed gems
|
21
|
+
test : run test for all gems in branch
|
22
|
+
bump : increment version
|
23
|
+
do : do release changed gems
|
24
|
+
See '#{command_name} SUB-COMMAND --help' for more information on a specific command.
|
25
|
+
HELP
|
26
|
+
|
27
|
+
global = OptionParser.new do |opts|
|
28
|
+
opts.banner = "Usage: #{command_name} [options] [sub-command [options]]"
|
29
|
+
opts.separator ''
|
30
|
+
opts.separator top_help
|
31
|
+
end
|
32
|
+
|
33
|
+
def common_opts(opts, options)
|
34
|
+
opts.on("--[no-]verbose", "Run verbosely") do |v|
|
35
|
+
options[:verbose] = v
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on("-d", "--[no-]dry-run", "Dry-run don't modify anything") do |v|
|
39
|
+
options[:dry_run] = v
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on("-p", "--gems-path=PATH", String, "Gem path") do |path|
|
43
|
+
options[:gems_path] = File.expand_path(path)
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on("-s", "--silent", "Accept all interactive dialogs") do |v|
|
47
|
+
options[:silent] = v
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
subcommands = {
|
52
|
+
'start' => OptionParser.new do |opts|
|
53
|
+
opts.banner = "Usage: ci-master sync [options]"
|
54
|
+
|
55
|
+
common_opts opts, options
|
56
|
+
|
57
|
+
opts.on("-bBRANCH", "--branch=BRANCH", String, "Branch to create") do |branch|
|
58
|
+
options[:branch] = branch
|
59
|
+
end
|
60
|
+
opts.on("-gGEMS_TMPL1,GEMS_TMPL2,GEMS_TMPLX", "--gems=GEMS_TMPL1,GEMS_TMPL2,GEMS_TMPLX", Array, "Gems to include in feature") do |gems|
|
61
|
+
options[:gems] = gems
|
62
|
+
end
|
63
|
+
end,
|
64
|
+
'rake' => OptionParser.new do |opts|
|
65
|
+
opts.banner = "Usage: ci-master rake [options]"
|
66
|
+
|
67
|
+
common_opts opts, options
|
68
|
+
|
69
|
+
opts.on("-bBRANCH", "--branch=BRANCH", String, "Branch to test") do |branch|
|
70
|
+
options[:branch] = branch
|
71
|
+
end
|
72
|
+
end,
|
73
|
+
'finish' => OptionParser.new do |opts|
|
74
|
+
opts.banner = "Usage: ci-master bump [options]"
|
75
|
+
|
76
|
+
common_opts(opts, options)
|
77
|
+
|
78
|
+
opts.on("-bBRANCH", "--branch=BRANCH", String, "Branch to push to master") do |branch|
|
79
|
+
options[:branch] = branch
|
80
|
+
end
|
81
|
+
end,
|
82
|
+
'release' => OptionParser.new do |opts|
|
83
|
+
opts.banner = "Usage: ci-master do [options]"
|
84
|
+
|
85
|
+
common_opts(opts, options)
|
86
|
+
|
87
|
+
opts.on("-gGEMS_TMPL1,GEMS_TMPL2,GEMS_TMPLX", "--gems=GEMS_TMPL1,GEMS_TMPL2,GEMS_TMPLX", Array, "Gems to release") do |gems|
|
88
|
+
options[:gems] = gems
|
89
|
+
end
|
90
|
+
|
91
|
+
opts.on("-vVERSION", "--version=VERSION", String, "Version part to increment, accepted values: major|minor|patch|pre|release|1.2.3") do |version|
|
92
|
+
options[:version] = version
|
93
|
+
end
|
94
|
+
end
|
95
|
+
}
|
96
|
+
|
97
|
+
global.order!
|
98
|
+
command = ARGV.shift
|
99
|
+
subcommands[command].order!
|
100
|
+
|
101
|
+
begin
|
102
|
+
Lapidist::Cli::Command.new.send(command.gsub('-', '_'), options)
|
103
|
+
exit 0
|
104
|
+
rescue => e
|
105
|
+
puts "Error: #{e.message}"
|
106
|
+
exit 1
|
107
|
+
end
|
data/lapidist.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "lapidist/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lapidist"
|
8
|
+
spec.version = Lapidist::VERSION
|
9
|
+
spec.authors = ['Ribose Inc.']
|
10
|
+
spec.email = ['open.source@ribose.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Synchronized gem releases}
|
13
|
+
spec.description = %q{Synchronized gem releases}
|
14
|
+
spec.homepage = "https://github.com/metanorma/lapidist"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/metanorma/lapidist"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_dependency "gem-release"
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
end
|
data/lib/lapidist.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "rubygems/commands/dependency_command"
|
3
|
+
|
4
|
+
module Lapidist
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
def self.gems(path)
|
8
|
+
if File.exist?(path)
|
9
|
+
@gems ||= Pathname.new(path).children.select { |child|
|
10
|
+
child.directory? && (child + ".git").directory? && !child.glob("*.gemspec").empty?
|
11
|
+
}.map { |e| File.basename(e) }
|
12
|
+
else
|
13
|
+
raise "#{gitmodules_path} not found make sure that -p/--gems-path correctly specified"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.gem_deps(path)
|
18
|
+
gems = self.gems(path)
|
19
|
+
@gem_deps ||= gems.map { |g|
|
20
|
+
begin
|
21
|
+
gemspec_path = File.join(path, g, "#{g}.gemspec")
|
22
|
+
deps = File.open(File.join(path, g, "#{g}.gemspec"), 'r:UTF-8').each_line.map { |line|
|
23
|
+
line.match(/add_(development_|runtime_)?dependency\s+.([\w_-]+)/)
|
24
|
+
}.compact.map { |m| m[2]}.keep_if { |d| gems.include?(d) }.uniq
|
25
|
+
rescue Errno::ENOENT => e
|
26
|
+
puts "[!] gemspec #{gemspec_path} not found for #{g} gem"
|
27
|
+
end
|
28
|
+
|
29
|
+
[g, deps]
|
30
|
+
}.to_h
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.gem_tests(path)
|
34
|
+
# https://stackoverflow.com/q/28655221/902217
|
35
|
+
@gem_tests ||= self.gem_deps(path).inject(Hash.new([])) { |memo, (key, values)|
|
36
|
+
values.each { |value| memo[value] += [key] }
|
37
|
+
memo
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
require_relative "../../tool"
|
2
|
+
|
3
|
+
module Lapidist
|
4
|
+
module Cli
|
5
|
+
class Command
|
6
|
+
DEVEL_GEMFILE = 'Gemfile.devel'
|
7
|
+
|
8
|
+
# FIXME: generalize!!
|
9
|
+
def gem_repo_path_with_opts(gemname, org = "metanorma")
|
10
|
+
":github => '#{org}/#{gemname}'"
|
11
|
+
end
|
12
|
+
|
13
|
+
def start(options)
|
14
|
+
validate 'start', options
|
15
|
+
|
16
|
+
branch_name = options[:branch]
|
17
|
+
path = options[:gems_path]
|
18
|
+
|
19
|
+
leaf_gems = options[:gems] || Lapidist.gems(path)
|
20
|
+
gem_deps = Lapidist.gem_deps(path)
|
21
|
+
|
22
|
+
log("start feature branch [#{branch_name}] for #{gems} gems", options)
|
23
|
+
|
24
|
+
leaf_gems.each do |mn_gem|
|
25
|
+
gem_project_path = File.join(path, mn_gem.to_s)
|
26
|
+
|
27
|
+
log("create branch [#{branch_name}] for [#{mn_gem}] gem", options)
|
28
|
+
|
29
|
+
Dir.chdir(gem_project_path) do
|
30
|
+
run_cmd("git checkout -b #{branch_name}", options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
leaf_gems.each do |mn_gem|
|
35
|
+
gem_project_path = File.expand_path(File.join(path, mn_gem.to_s))
|
36
|
+
|
37
|
+
log("setup local dependencies for [#{mn_gem}] gem", options)
|
38
|
+
|
39
|
+
Dir.chdir(gem_project_path) do
|
40
|
+
File.open(DEVEL_GEMFILE, 'w') { |file|
|
41
|
+
gem_deps[mn_gem.to_s].each do |d|
|
42
|
+
file.write("gem '#{d}', #{gem_repo_path_with_opts(d)}, :branch => '#{branch_name}'\n")
|
43
|
+
end
|
44
|
+
}
|
45
|
+
|
46
|
+
Bundler.with_clean_env do
|
47
|
+
gem_deps[mn_gem.to_s].each do |d|
|
48
|
+
run_cmd("bundle config --local local.#{d} #{File.join(path, d)}", options)
|
49
|
+
end
|
50
|
+
|
51
|
+
run_cmd("bundle install", options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if yesno("push [#{branch_name}] branch to remote right now", options)
|
57
|
+
leaf_gems.each do |mn_gem|
|
58
|
+
gem_project_path = File.join(path, mn_gem.to_s)
|
59
|
+
Dir.chdir(gem_project_path) do
|
60
|
+
run_cmd("git push origin #{branch_name}", options)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def rake(options)
|
67
|
+
validate 'rake', options
|
68
|
+
|
69
|
+
path = options[:gems_path]
|
70
|
+
branch_name = options[:branch]
|
71
|
+
|
72
|
+
log("start tests for branch [#{branch_name}]", options)
|
73
|
+
|
74
|
+
Lapidist.gems(path).each do |mn_gem|
|
75
|
+
gem_project_path = File.expand_path(File.join(path, mn_gem.to_s))
|
76
|
+
|
77
|
+
Dir.chdir(gem_project_path) do
|
78
|
+
if git_branch_is(branch_name)
|
79
|
+
log("run tests for [#{mn_gem}] gem...", options)
|
80
|
+
Bundler.with_clean_env do
|
81
|
+
run_cmd("bundle exec rake", options)
|
82
|
+
end
|
83
|
+
else
|
84
|
+
log("ignore tests for [#{mn_gem}] gem because branch isn't [#{branch_name}]", options)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def finish(options)
|
91
|
+
validate 'finish', options
|
92
|
+
|
93
|
+
branch_name = options[:branch]
|
94
|
+
path = options[:gems_path]
|
95
|
+
|
96
|
+
log("merge branch [#{branch_name}] to master", options)
|
97
|
+
|
98
|
+
if yesno("please confirm that all PRs for [#{branch_name}] are 'green'", options)
|
99
|
+
leaf_gems = Lapidist.gems(path)
|
100
|
+
gem_deps = Lapidist.gem_deps(path)
|
101
|
+
|
102
|
+
leaf_gems.each do |mn_gem|
|
103
|
+
gem_project_path = File.join(path, mn_gem.to_s)
|
104
|
+
gem_devel_gemfile = File.join(gem_project_path, DEVEL_GEMFILE)
|
105
|
+
|
106
|
+
Dir.chdir(gem_project_path) do
|
107
|
+
next unless git_branch_is(branch_name)
|
108
|
+
|
109
|
+
File.delete(gem_devel_gemfile) unless options[:dry_run]
|
110
|
+
|
111
|
+
Bundler.with_clean_env do
|
112
|
+
gem_deps[mn_gem].each do |d|
|
113
|
+
run_cmd("bundle config --delete local.#{d} #{File.join(path, d)}", options)
|
114
|
+
end
|
115
|
+
|
116
|
+
run_cmd("bundle install", options)
|
117
|
+
end
|
118
|
+
|
119
|
+
run_cmd("git add -u #{DEVEL_GEMFILE} Gemfile.lock", options)
|
120
|
+
run_cmd("git commit -m \"Feature #{branch_name}\" done", options)
|
121
|
+
run_cmd("git push origin #{branch_name}", options)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
else
|
125
|
+
puts "[!] please fix all issues before finish [#{branch_name}] branch"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def release(options)
|
130
|
+
validate 'release', options
|
131
|
+
|
132
|
+
leaf_gems = options[:gems]
|
133
|
+
version = options[:version]
|
134
|
+
path = options[:gems_path]
|
135
|
+
|
136
|
+
log("release #{leaf_gems} gems...", options)
|
137
|
+
|
138
|
+
leaf_gems.each { |mn_gem|
|
139
|
+
gem_project_path = File.expand_path(File.join(path, mn_gem.to_s))
|
140
|
+
|
141
|
+
Dir.chdir(gem_project_path) do
|
142
|
+
if git_branch_is('master')
|
143
|
+
log("do version bump for [#{mn_gem}] gem...", options)
|
144
|
+
run_cmd("gem bump --tag --push --release --version #{version}", options)
|
145
|
+
else
|
146
|
+
raise "Stop release for [#{mn_gem}] gem because current branch isn't [master]"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
}
|
150
|
+
end
|
151
|
+
|
152
|
+
@private
|
153
|
+
|
154
|
+
def run_cmd(cmd, options)
|
155
|
+
if options[:dry_run] || options[:verbose]
|
156
|
+
puts "run system(#{cmd}) pwd:#{Dir.pwd}"
|
157
|
+
end
|
158
|
+
|
159
|
+
if !options[:dry_run]
|
160
|
+
system(cmd, chdir: Dir.pwd)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def validate(action, options)
|
165
|
+
case action
|
166
|
+
when 'start', 'rake', 'finish'
|
167
|
+
raise OptionParser::MissingArgument, "Missing -b/--branch [value]" if options[:branch].nil?
|
168
|
+
raise OptionParser::MissingArgument, "Missing -p/--gems-path [path]" if options[:gems_path].nil?
|
169
|
+
when 'release'
|
170
|
+
raise OptionParser::MissingArgument, "Missing -p/--gems-path [path]" if options[:gems_path].nil?
|
171
|
+
raise OptionParser::MissingArgument, "Missing -g/--gems [value]" if options[:gems].nil?
|
172
|
+
raise OptionParser::MissingArgument, "Missing --version [value]" if options[:version].nil?
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def log(message, options)
|
177
|
+
puts "[v] #{message}" if options[:verbose]
|
178
|
+
end
|
179
|
+
|
180
|
+
def git_branch_is(branch_name)
|
181
|
+
`git branch --show-current`.strip == branch_name
|
182
|
+
end
|
183
|
+
|
184
|
+
def yesno(message, options)
|
185
|
+
true if options[:silent]
|
186
|
+
printf "[?] #{message} - press 'y' to continue: "
|
187
|
+
prompt = STDIN.gets.chomp
|
188
|
+
return prompt == 'y'
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lapidist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gem-release
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Synchronized gem releases
|
70
|
+
email:
|
71
|
+
- open.source@ribose.com
|
72
|
+
executables:
|
73
|
+
- lapidist
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- README.adoc
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- exe/lapidist
|
88
|
+
- lapidist.gemspec
|
89
|
+
- lib/lapidist.rb
|
90
|
+
- lib/lapidist/cli/command.rb
|
91
|
+
- lib/lapidist/version.rb
|
92
|
+
homepage: https://github.com/metanorma/lapidist
|
93
|
+
licenses: []
|
94
|
+
metadata:
|
95
|
+
homepage_uri: https://github.com/metanorma/lapidist
|
96
|
+
source_code_uri: https://github.com/metanorma/lapidist
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubygems_version: 3.0.3
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Synchronized gem releases
|
116
|
+
test_files: []
|