gem-release 1.0.0 → 2.0.0.dev.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +13 -0
- data/Gemfile.lock +72 -0
- data/{lib/gem_release/templates/LICENSE → MIT-LICENSE.md} +3 -2
- data/README.md +646 -0
- data/README.md.erb +159 -0
- data/TODO.txt +194 -0
- data/lib/gem/release.rb +13 -0
- data/lib/gem/release/cmds.rb +16 -0
- data/lib/gem/release/cmds/base.rb +101 -0
- data/lib/gem/release/cmds/bootstrap.rb +222 -0
- data/lib/gem/release/cmds/bump.rb +165 -0
- data/lib/gem/release/cmds/gemspec.rb +85 -0
- data/lib/gem/release/cmds/release.rb +100 -0
- data/lib/gem/release/cmds/runner.rb +52 -0
- data/lib/gem/release/cmds/tag.rb +93 -0
- data/lib/gem/release/config.rb +42 -0
- data/lib/gem/release/config/env.rb +49 -0
- data/lib/gem/release/config/files.rb +35 -0
- data/lib/gem/release/context.rb +76 -0
- data/lib/gem/release/context/gem.rb +28 -0
- data/lib/gem/release/context/gemspec.rb +41 -0
- data/lib/gem/release/context/paths.rb +87 -0
- data/lib/gem/release/context/system.rb +36 -0
- data/lib/gem/release/data.rb +60 -0
- data/lib/gem/release/files/template.rb +61 -0
- data/lib/gem/release/files/template/context.rb +30 -0
- data/lib/gem/release/files/templates.rb +59 -0
- data/lib/gem/release/files/templates/group.rb +47 -0
- data/lib/gem/release/files/version.rb +68 -0
- data/lib/gem/release/helper.rb +45 -0
- data/lib/gem/release/helper/hash.rb +35 -0
- data/lib/gem/release/helper/string.rb +43 -0
- data/lib/gem/release/support/gem_command.rb +67 -0
- data/lib/gem/release/support/registry.rb +59 -0
- data/lib/gem/release/templates/.gitignore +8 -0
- data/lib/gem/release/templates/Gemfile +3 -0
- data/lib/gem/release/templates/gemspec +19 -0
- data/lib/gem/release/templates/licenses/mit.md +21 -0
- data/lib/gem/release/templates/licenses/mpl-2.md +373 -0
- data/lib/gem/release/templates/main.rb +1 -0
- data/lib/gem/release/templates/rspec/.rspec +3 -0
- data/lib/gem/release/templates/rspec/spec/spec_helper.rb +4 -0
- data/lib/gem/release/templates/travis/.travis.yml +1 -0
- data/lib/gem/release/templates/version.rb +1 -0
- data/lib/gem/release/version.rb +5 -0
- data/lib/gem/release/version/number.rb +102 -0
- data/lib/rubygems/commands/bootstrap_command.rb +4 -93
- data/lib/rubygems/commands/bump_command.rb +4 -110
- data/lib/rubygems/commands/gemspec_command.rb +5 -29
- data/lib/rubygems/commands/release_command.rb +4 -70
- data/lib/rubygems/commands/tag_command.rb +5 -46
- data/lib/rubygems_plugin.rb +8 -2
- metadata +56 -83
- data/lib/core_ext/hash/symbolize_keys.rb +0 -13
- data/lib/core_ext/kernel/silence.rb +0 -18
- data/lib/core_ext/string/camelize.rb +0 -5
- data/lib/gem_release.rb +0 -10
- data/lib/gem_release/command_options.rb +0 -31
- data/lib/gem_release/configuration.rb +0 -33
- data/lib/gem_release/gemspec_template.rb +0 -35
- data/lib/gem_release/helpers.rb +0 -104
- data/lib/gem_release/template.rb +0 -52
- data/lib/gem_release/templates/Gemfile +0 -3
- data/lib/gem_release/templates/README.md +0 -1
- data/lib/gem_release/templates/Rakefile +0 -10
- data/lib/gem_release/templates/gemspec +0 -18
- data/lib/gem_release/templates/gitignore +0 -25
- data/lib/gem_release/templates/test/test_helper.rb +0 -2
- data/lib/gem_release/templates/version.rb +0 -12
- data/lib/gem_release/version.rb +0 -3
- data/lib/gem_release/version_file.rb +0 -115
- data/lib/gem_release/version_template.rb +0 -14
data/README.md.erb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# gem release [![Build Status](https://secure.travis-ci.org/svenfuchs/gem-release.png)](http://travis-ci.org/svenfuchs/gem-release)
|
2
|
+
|
3
|
+
This gem plugin aims at making gem development easier by automating repetitive work based on conventions, configuration, and templates.
|
4
|
+
|
5
|
+
It adds the commands `bootstrap`, `gemspec`, `bump`, `tag` and a `release` to the rubygems `gem` command.
|
6
|
+
|
7
|
+
| Project | Gem Release |
|
8
|
+
| ---------------------- | ------------ |
|
9
|
+
| Gem name | gem-release |
|
10
|
+
| License | [MIT](https://github.com/svenfuchs/gem-release/blob/master/LICENSE.md) |
|
11
|
+
| Version | [![Gem Version](https://badge.fury.io/rb/gem-release.png)](http://badge.fury.io/rb/gem-release) |
|
12
|
+
| Continuous integration | [![Build Status](https://secure.travis-ci.org/svenfuchs/gem-release.png?branch=master)](https://travis-ci.org/svenfuchs/gem-release) |
|
13
|
+
| Test coverage | [![Coverage Status](https://coveralls.io/repos/svenfuchs/gem-release/badge.png)](https://coveralls.io/r/svenfuchs/gem-release) |
|
14
|
+
| Documentation | [Documentation](http://rdoc.info/github/svenfuchs/gem-release/frames) |
|
15
|
+
| Credits | [Contributors](https://github.com/svenfuchs/gem-release/graphs/contributors) |
|
16
|
+
|
17
|
+
# Table of contents
|
18
|
+
|
19
|
+
* [Demo](#demo)
|
20
|
+
* [Installation](#installation)
|
21
|
+
* [Configuration](#configuration)
|
22
|
+
* [Conventions](#conventions)
|
23
|
+
* [Reference](#reference)
|
24
|
+
* [Scenarios](#scenarios)
|
25
|
+
* [Development](#development)
|
26
|
+
|
27
|
+
# Demo
|
28
|
+
|
29
|
+
This gif demos some of the things you can do with this plugin:
|
30
|
+
|
31
|
+
![gem-relase-demo](https://cloud.githubusercontent.com/assets/2208/25568627/12a3b468-2e07-11e7-8d7b-055b5d7c71b9.gif)
|
32
|
+
|
33
|
+
## Installation
|
34
|
+
|
35
|
+
The gem provides a rubygems plugin, so it's just:
|
36
|
+
|
37
|
+
```
|
38
|
+
gem install gem-release
|
39
|
+
```
|
40
|
+
|
41
|
+
|
42
|
+
# Configuration
|
43
|
+
|
44
|
+
Defaults for all options can be specified in a config file at either one of
|
45
|
+
these locations:
|
46
|
+
|
47
|
+
* `~/.gem_release/config.yml`
|
48
|
+
* `~/.gem_release.yml`
|
49
|
+
* `./.gem_release/config.yml`
|
50
|
+
* `./.gem_release.yml`
|
51
|
+
|
52
|
+
Config files must be in the [YAML](http://www.yaml.org/) format, and list
|
53
|
+
options per command. Common options can be set on the root.
|
54
|
+
|
55
|
+
For instance, the following entries will set the `quiet` flag for all commands,
|
56
|
+
and a custom host name with `gem release`:
|
57
|
+
|
58
|
+
```yaml
|
59
|
+
quiet: true
|
60
|
+
|
61
|
+
release:
|
62
|
+
host: https://example.com
|
63
|
+
```
|
64
|
+
|
65
|
+
Defaults for all options also can be specified as environment variables, for
|
66
|
+
example `GEM_RELEASE_PRETEND=true`.
|
67
|
+
|
68
|
+
Defaults specified in config files and environment variables can be overridden
|
69
|
+
as command line options when issuing the respective `gem` command.
|
70
|
+
|
71
|
+
Only the first config file found in the locations given above will be used, if
|
72
|
+
any, and defaults from this config file will be merged with both environment
|
73
|
+
variables and given command line options.
|
74
|
+
|
75
|
+
|
76
|
+
# Conventions
|
77
|
+
|
78
|
+
When bootstrapping a new gem:
|
79
|
+
|
80
|
+
* A gem name `gem_name` is left untouched when mapped to the path `lib/gem_name`, and the Ruby constant name `GemName`.
|
81
|
+
* A gem name `gem-name` is mapped to the path `lib/gem/name`, and the Ruby constant name `Gem::Name`
|
82
|
+
|
83
|
+
When bumping the version of an existing gem `gem-name` the following locations are checked:
|
84
|
+
|
85
|
+
* `lib/gem/name/version.rb`
|
86
|
+
* `lib/gem-name/version.rb`
|
87
|
+
|
88
|
+
|
89
|
+
# Reference
|
90
|
+
|
91
|
+
The gem `gem-release` adds the following commands to the rubygems `gem` command:
|
92
|
+
|
93
|
+
<% cmds.each do |name, help| -%>
|
94
|
+
* [gem <%= name %>](#gem-<%= name %>) - <%= help[:summary] %>
|
95
|
+
<% end -%>
|
96
|
+
|
97
|
+
<% cmds.each do |name, help| -%>
|
98
|
+
## gem <%= name %>
|
99
|
+
|
100
|
+
<%= help[:summary] %>
|
101
|
+
|
102
|
+
<% if help[:arguments] -%>
|
103
|
+
### Arguments
|
104
|
+
|
105
|
+
```
|
106
|
+
<%= help[:arguments] %>
|
107
|
+
```
|
108
|
+
|
109
|
+
<% end -%>
|
110
|
+
<% if help[:options] -%>
|
111
|
+
### Options
|
112
|
+
|
113
|
+
```
|
114
|
+
<%= help[:options] %>
|
115
|
+
```
|
116
|
+
<% end -%>
|
117
|
+
|
118
|
+
<% if help[:description] -%>
|
119
|
+
### Description
|
120
|
+
|
121
|
+
<%= help[:description] %>
|
122
|
+
|
123
|
+
<% end -%>
|
124
|
+
<% end -%>
|
125
|
+
|
126
|
+
# Scenarios
|
127
|
+
|
128
|
+
<% scenarios.each do |scenario| -%>
|
129
|
+
* [<%= scenario[:title] %>](#<%= scenario[:id] %>)
|
130
|
+
<% end -%>
|
131
|
+
|
132
|
+
<% scenarios.each do |scenario| -%>
|
133
|
+
<%= scenario[:text] %>
|
134
|
+
<% end -%>
|
135
|
+
|
136
|
+
# Development
|
137
|
+
|
138
|
+
Running tests:
|
139
|
+
|
140
|
+
```
|
141
|
+
bundle install
|
142
|
+
bundle exec rspec
|
143
|
+
```
|
144
|
+
|
145
|
+
Testing commands against a [Geminabox](https://github.com/geminabox/geminabox) instance:
|
146
|
+
|
147
|
+
```
|
148
|
+
# start geminabox
|
149
|
+
bundle install
|
150
|
+
bundle exec rackup
|
151
|
+
|
152
|
+
# workaround rubygems issue with a missing key
|
153
|
+
# see https://github.com/geminabox/geminabox/issues/153
|
154
|
+
echo ':localhost: none' >> ~/.gem/credentials
|
155
|
+
|
156
|
+
# test release
|
157
|
+
bundle exec gem release --host=http://localhost:9292 --key localhost
|
158
|
+
```
|
159
|
+
|
data/TODO.txt
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
# Todo
|
2
|
+
|
3
|
+
* Make it so that if no arg is given, we fallback to the first gemspec file
|
4
|
+
first. only if there's no gemspec file we use the dirname?
|
5
|
+
|
6
|
+
* Add a changelog
|
7
|
+
|
8
|
+
* Release and tag should fail if there are uncommitted changes
|
9
|
+
https://github.com/svenfuchs/gem-release/issues/34
|
10
|
+
|
11
|
+
* Make sure we don't double tag the same repo when several args are given
|
12
|
+
|
13
|
+
# Fix
|
14
|
+
|
15
|
+
* Misleading success message
|
16
|
+
https://github.com/svenfuchs/gem-release/issues/60
|
17
|
+
|
18
|
+
# Double check
|
19
|
+
|
20
|
+
- Issues with in-repo gems [1]
|
21
|
+
https://github.com/svenfuchs/gem-release/issues/58
|
22
|
+
|
23
|
+
x bump fails when there is a space in the path to project done:2017-05-01 [2]
|
24
|
+
https://github.com/svenfuchs/gem-release/issues/33
|
25
|
+
looks like this is fixed. this did not result in any errors:
|
26
|
+
cd /tmp
|
27
|
+
mkdir -p '/tmp/seanmackesey/Google Drive/code/lib/ruby'
|
28
|
+
cd /tmp/seanmackesey/Google\ Drive/code/lib/ruby
|
29
|
+
gem bootstrap foo
|
30
|
+
gem bump --no-push
|
31
|
+
|
32
|
+
- gem bump --tag --release pushes the wrong version [3]
|
33
|
+
https://github.com/svenfuchs/gem-release/issues/36
|
34
|
+
|
35
|
+
# Refactor
|
36
|
+
|
37
|
+
should create the directory foo, and cd into it
|
38
|
+
|
39
|
+
cd tmp
|
40
|
+
gem bootstrap foo
|
41
|
+
|
42
|
+
|
43
|
+
should bootstrap a gem foo
|
44
|
+
|
45
|
+
cd foo
|
46
|
+
gem bootstrap
|
47
|
+
|
48
|
+
should fail, as there's no foo.gemspec
|
49
|
+
|
50
|
+
cd tmp
|
51
|
+
gem bump foo
|
52
|
+
|
53
|
+
should bump the first gemspec's gem, no matter the dir name
|
54
|
+
|
55
|
+
cd foo
|
56
|
+
gem bump
|
57
|
+
|
58
|
+
# Scenario: Nested gem with conventional directory name
|
59
|
+
|
60
|
+
### Setup
|
61
|
+
|
62
|
+
```
|
63
|
+
export GEM_RELEASE_PUSH=false
|
64
|
+
cd /tmp
|
65
|
+
rm -rf sinja
|
66
|
+
gem bootstrap sinja
|
67
|
+
cd sinja
|
68
|
+
mkdir extensions
|
69
|
+
cd extensions
|
70
|
+
gem bootstrap sinja-sequel
|
71
|
+
cd /tmp/sinja
|
72
|
+
tree
|
73
|
+
```
|
74
|
+
|
75
|
+
### Directory structure
|
76
|
+
|
77
|
+
```
|
78
|
+
.
|
79
|
+
├── Gemfile
|
80
|
+
├── LICENSE.md
|
81
|
+
├── extensions
|
82
|
+
│ └── sinja-sequel
|
83
|
+
│ ├── Gemfile
|
84
|
+
│ ├── LICENSE.md
|
85
|
+
│ ├── lib
|
86
|
+
│ │ └── sinja
|
87
|
+
│ │ ├── sequel
|
88
|
+
│ │ │ └── version.rb
|
89
|
+
│ │ └── sequel.rb
|
90
|
+
│ └── sinja-sequel.gemspec
|
91
|
+
├── lib
|
92
|
+
│ ├── sinja
|
93
|
+
│ │ └── version.rb
|
94
|
+
│ └── sinja.rb
|
95
|
+
└── sinja.gemspec
|
96
|
+
```
|
97
|
+
|
98
|
+
### Behaviour
|
99
|
+
|
100
|
+
```
|
101
|
+
# this bumps both sinja and sinja-sequel
|
102
|
+
cd /tmp/sinja
|
103
|
+
gem bump --recurse
|
104
|
+
|
105
|
+
# this bumps sinja
|
106
|
+
cd /tmp/sinja
|
107
|
+
gem bump
|
108
|
+
|
109
|
+
# this also bumps sinja
|
110
|
+
cd /tmp/sinja
|
111
|
+
gem bump sinja
|
112
|
+
|
113
|
+
# this bumps sinja-sequel only
|
114
|
+
cd /tmp/sinja
|
115
|
+
gem bump sinja-sequel
|
116
|
+
|
117
|
+
# this also bumps sinja-sequel only
|
118
|
+
cd /tmp/sinja/extensions/sinja-sequel
|
119
|
+
gem bump
|
120
|
+
|
121
|
+
# this also bumps sinja-sequel only
|
122
|
+
cd /tmp/sinja/extensions/sinja-sequel
|
123
|
+
gem bump sinja-sequel
|
124
|
+
```
|
125
|
+
|
126
|
+
## Nested gem with irregular directory name
|
127
|
+
|
128
|
+
### Setup
|
129
|
+
|
130
|
+
```
|
131
|
+
export GEM_RELEASE_PUSH=false
|
132
|
+
cd /tmp
|
133
|
+
rm -rf sinja
|
134
|
+
gem bootstrap sinja
|
135
|
+
cd sinja
|
136
|
+
mkdir -p extensions
|
137
|
+
cd extensions
|
138
|
+
gem bootstrap sinja-sequel
|
139
|
+
mv sinja-sequel sequel
|
140
|
+
cd /tmp/sinja
|
141
|
+
tree
|
142
|
+
```
|
143
|
+
|
144
|
+
### Directory structure
|
145
|
+
|
146
|
+
```
|
147
|
+
.
|
148
|
+
├── Gemfile
|
149
|
+
├── LICENSE.md
|
150
|
+
├── extensions
|
151
|
+
│ └── sequel
|
152
|
+
│ ├── Gemfile
|
153
|
+
│ ├── LICENSE.md
|
154
|
+
│ ├── lib
|
155
|
+
│ │ └── sinja
|
156
|
+
│ │ ├── sequel
|
157
|
+
│ │ │ └── version.rb
|
158
|
+
│ │ └── sequel.rb
|
159
|
+
│ └── sinja-sequel.gemspec
|
160
|
+
├── lib
|
161
|
+
│ ├── sinja
|
162
|
+
│ │ └── version.rb
|
163
|
+
│ └── sinja.rb
|
164
|
+
└── sinja.gemspec
|
165
|
+
```
|
166
|
+
|
167
|
+
### Behaviour
|
168
|
+
|
169
|
+
```
|
170
|
+
# this bumps both sinja and sinja-sequel
|
171
|
+
cd /tmp/sinja
|
172
|
+
gem bump --recurse
|
173
|
+
|
174
|
+
# this bumps sinja
|
175
|
+
cd /tmp/sinja
|
176
|
+
gem bump
|
177
|
+
|
178
|
+
# this also bumps sinja
|
179
|
+
cd /tmp/sinja
|
180
|
+
gem bump sinja
|
181
|
+
|
182
|
+
# this bumps sinja-sequel only
|
183
|
+
cd /tmp/sinja
|
184
|
+
gem bump sinja-sequel
|
185
|
+
|
186
|
+
# this also bumps sinja-sequel only
|
187
|
+
cd /tmp/sinja/extensions/sinja-sequel
|
188
|
+
gem bump
|
189
|
+
|
190
|
+
# this also bumps sinja-sequel only
|
191
|
+
cd /tmp/sinja/extensions/sinja-sequel
|
192
|
+
gem bump sinja-sequel
|
193
|
+
```
|
194
|
+
|
data/lib/gem/release.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'gem/release/cmds/bootstrap'
|
2
|
+
require 'gem/release/cmds/bump'
|
3
|
+
require 'gem/release/cmds/gemspec'
|
4
|
+
require 'gem/release/cmds/release'
|
5
|
+
require 'gem/release/cmds/runner'
|
6
|
+
require 'gem/release/cmds/tag'
|
7
|
+
|
8
|
+
module Gem
|
9
|
+
module Release
|
10
|
+
module Cmds
|
11
|
+
def self.[](cmd)
|
12
|
+
Base[cmd]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'gem/release/helper'
|
2
|
+
require 'gem/release/helper/hash'
|
3
|
+
require 'gem/release/helper/string'
|
4
|
+
require 'gem/release/support/registry'
|
5
|
+
|
6
|
+
module Gem
|
7
|
+
module Release
|
8
|
+
module Cmds
|
9
|
+
class Base < Struct.new(:context, :args, :opts)
|
10
|
+
include Helper, Helper::Hash, Helper::String, Registry
|
11
|
+
|
12
|
+
class << self
|
13
|
+
include Helper::String
|
14
|
+
|
15
|
+
def inherited(cmd)
|
16
|
+
cmd.register underscore(cmd.name.split('::').last)
|
17
|
+
end
|
18
|
+
|
19
|
+
def arg(name, summary)
|
20
|
+
args << [name, summary]
|
21
|
+
end
|
22
|
+
|
23
|
+
def args
|
24
|
+
@args ||= []
|
25
|
+
end
|
26
|
+
|
27
|
+
def opt(*args, &block)
|
28
|
+
opts << [args, block]
|
29
|
+
end
|
30
|
+
|
31
|
+
def opts
|
32
|
+
@opts ||= superclass != self.class && superclass.respond_to?(:opts) ? superclass.opts.dup : []
|
33
|
+
end
|
34
|
+
|
35
|
+
def usage(usage = nil)
|
36
|
+
usage ? @usage = usage : @usage || '[usage]'
|
37
|
+
end
|
38
|
+
|
39
|
+
WIDTH = 70
|
40
|
+
|
41
|
+
def summary(summary = nil)
|
42
|
+
summary ? @summary = wrap(summary, WIDTH) : @summary || '[summary]'
|
43
|
+
end
|
44
|
+
|
45
|
+
def description(description = nil)
|
46
|
+
description ? @description = wrap(description, WIDTH) : @description
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
opt '--pretend' do
|
51
|
+
opts[:pretend] = true
|
52
|
+
end
|
53
|
+
|
54
|
+
opt '--quiet' do
|
55
|
+
opts[:quiet] = true
|
56
|
+
end
|
57
|
+
|
58
|
+
attr_reader :gem
|
59
|
+
|
60
|
+
def initialize(context, args, opts)
|
61
|
+
opts = defaults.merge(opts)
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
def in_dirs
|
66
|
+
context.in_dirs(args, opts) do |name|
|
67
|
+
@gem = Context::Gem.new(name)
|
68
|
+
yield
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def in_gem_dirs
|
73
|
+
context.in_gem_dirs(args, opts) do |name|
|
74
|
+
@gem = Context::Gem.new(name)
|
75
|
+
yield
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def pretend?
|
80
|
+
!!opts[:pretend]
|
81
|
+
end
|
82
|
+
|
83
|
+
def quiet?
|
84
|
+
opts[:quiet] || opts[:silent]
|
85
|
+
end
|
86
|
+
|
87
|
+
def opts
|
88
|
+
@opts ||= config.merge(super)
|
89
|
+
end
|
90
|
+
|
91
|
+
def config
|
92
|
+
context.config.for(registry_key)
|
93
|
+
end
|
94
|
+
|
95
|
+
def defaults
|
96
|
+
self.class.const_defined?(:DEFAULTS) ? self.class::DEFAULTS : {}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|