gem_toys 0.7.1 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 061a23d19180942f3cb7ca6f4b43bfc5e48b5247e1ca45ec77969c0308cdf3aa
4
- data.tar.gz: b57ac1d9e07c4a7f72ffaa3ff0e9d366160a47ffb2695232a7b928821ee0484c
3
+ metadata.gz: 112ee3b1f0047eb32d9beedccc1249e000164a10513365de206c8d1bf06a0691
4
+ data.tar.gz: 9876889866f9d38eeceb03ea04303845088e5fc429e7f8a9e5312dc0a35cce83
5
5
  SHA512:
6
- metadata.gz: cec712bb01c015ba34dde170c5d7d855f56008e7234da72df02d8ed342dd9eb458ee06d7e4175e473dad213bba8f0229ca356fbc28a16ef06b42fe92186ea1b6
7
- data.tar.gz: 5f0475c31feef1a52e77f59f4e30965c55401baa04fc425ca5a8864e9d6c0900d85e5fa06eac8936e2b09af0c498651e013e513cc1138b03f30e638c2678f540
6
+ metadata.gz: 4e6342e7bb1b2485caa3b08a9c0bda86961f47626f7236d808c5bfebd15fb37b4f28021ed43b9faaccd669b9f0b66cd237842301bc28578d48d35d258a3f3b98
7
+ data.tar.gz: 6ba75096de3694778131890372df8b5ba4fad5a3d3f1386635d6b86f75efa7dae98bda97be352998d246656b271cfcdc3549071a22508424c197a6f7828cc230
data/CHANGELOG.md CHANGED
@@ -1,6 +1,38 @@
1
1
  # Changelog
2
2
 
3
- ## master (unreleased)
3
+ ## Unreleased
4
+
5
+ ## 0.11.2 (2021-11-07)
6
+
7
+ * Fix version for gem staff after manual refresh too.
8
+
9
+ ## 0.11.1 (2021-11-07)
10
+
11
+ * Fix new version for git staff after manual refresh.
12
+
13
+ ## 0.11.0 (2021-10-29)
14
+
15
+ * Revert version and changelog files changes at rejection.
16
+ * Revert version file changes at changelog fails.
17
+ * Update development dependencies.
18
+
19
+ ## 0.10.0 (2021-10-15)
20
+
21
+ * Process cases with non-JSON String from RubyGems.org.
22
+ * Update development dependencies.
23
+ * Resolve new offenses from RuboCop.
24
+ * Change default for unreleased in Changelog.
25
+
26
+ ## 0.9.0 (2021-08-26)
27
+
28
+ * Fix built gem version after `refresh` answer.
29
+ * Update development dependencies.
30
+ * Lock RuboCop version better.
31
+ * Resolve new RuboCop offenses.
32
+
33
+ ## 0.8.0 (2021-04-16)
34
+
35
+ * Add `refresh` answer for release confirmation.
4
36
 
5
37
  ## 0.7.1 (2021-03-04)
6
38
 
data/README.md CHANGED
@@ -38,8 +38,8 @@ require 'gem_toys'
38
38
  expand GemToys::Template,
39
39
  ## default is `CHANGELOG.md`
40
40
  changelog_file_name: 'ChangeLog.md',
41
- ## default is `## master (unreleased)`
42
- unreleased_title: '## Unreleased',
41
+ ## default is `## Unreleased`
42
+ unreleased_title: '## main (unreleased)',
43
43
  ## default is `"lib/#{project_name_with_slashes_instead_dashes}/version.rb"`
44
44
  version_file_path: 'lib/my-awesome_gem.rb',
45
45
  ## default is `v`, so tags are like `v4.1.0`
@@ -63,7 +63,7 @@ alias_tool :g, :gem
63
63
 
64
64
  1. Update `lib/*gem_name*/version.rb` file.
65
65
  Can be refined with `:version_file_path` option on `expand`.
66
- 2. Insert Markdown title with changes from `## master (unreleased)` in a `CHANGELOG.md` file.
66
+ 2. Insert Markdown title with changes from `## Unreleased` in a `CHANGELOG.md` file.
67
67
  Can be refined with `:unreleased_title` option on `expand`.
68
68
  3. [Builds](#build) a gem.
69
69
  4. Ask you for manual check, if you want (print anything of OK).
@@ -28,6 +28,10 @@ module GemToys
28
28
  end
29
29
 
30
30
  memoize def current_version
31
+ parse_version_from_file
32
+ end
33
+
34
+ def parse_version_from_file
31
35
  version_file_content.match(/VERSION = '(.+)'/)[1]
32
36
  end
33
37
 
@@ -51,13 +55,21 @@ module GemToys
51
55
  require 'faraday'
52
56
  require 'faraday_middleware'
53
57
 
54
- Faraday.new 'https://rubygems.org/api/v1' do |conn|
55
- conn.response :json, parser_options: { symbolize_names: true }
58
+ Faraday.new 'https://rubygems.org/api/v1' do |connection|
59
+ connection.response :json,
60
+ content_type: /\bjson$/,
61
+ parser_options: { symbolize_names: true }
56
62
  end
57
63
  end
58
64
 
59
65
  memoize def rubygems_versions
60
- rubygems_connection.get("versions/#{project_name}.json").body
66
+ response = rubygems_connection.get("versions/#{project_name}.json").body
67
+
68
+ return response if response.is_a?(Array)
69
+
70
+ return [] if response == 'This rubygem could not be found.'
71
+
72
+ raise "Unexpected response from RubyGems.org: #{response.inspect}"
61
73
  end
62
74
 
63
75
  def current_version_hash
@@ -28,11 +28,14 @@ module GemToys
28
28
 
29
29
  unreleased_title_index = @changelog_lines.index("#{unreleased_title}\n")
30
30
 
31
- abort_without_unreleased_title unless unreleased_title_index
31
+ unless unreleased_title_index
32
+ sh "git restore --worktree #{version_file_path}"
33
+ abort_without_unreleased_title
34
+ end
32
35
 
33
36
  @changelog_lines.insert(
34
37
  unreleased_title_index + 2,
35
- '#' * unreleased_title.scan(/^#+/).first.size + " #{@new_version} (#{@today})\n\n"
38
+ ('#' * unreleased_title.scan(/^#+/).first.size) + " #{@new_version} (#{@today})\n\n"
36
39
  ).join
37
40
  end
38
41
 
@@ -8,16 +8,17 @@ module GemToys
8
8
  private
9
9
 
10
10
  def process_git
11
- new_version_git_tag = "#{@template.version_tag_prefix}#{@new_version}"
11
+ ## `current_version` should be refreshed before this method invocation
12
+ version_git_tag = "#{@template.version_tag_prefix}#{current_version}"
12
13
 
13
14
  ## Checkout to a new git branch, required for protected `master` with CI
14
- # sh "git switch -c #{new_version_git_tag}"
15
+ # sh "git switch -c #{version_git_tag}"
15
16
 
16
17
  commit_changes
17
18
 
18
19
  ## Tag commit
19
20
  puts 'Tagging the commit...'
20
- sh "git tag -a #{new_version_git_tag} -m 'Version #{@new_version}'"
21
+ sh "git tag -a #{version_git_tag} -m 'Version #{current_version}'"
21
22
 
22
23
  ## Push commit
23
24
  puts 'Pushing commit...'
@@ -33,7 +34,7 @@ module GemToys
33
34
 
34
35
  sh "git add #{version_file_path} #{changelog_file_path}"
35
36
 
36
- sh "git commit -m 'Update version to #{@new_version}'"
37
+ sh "git commit -m 'Update version to #{current_version}'"
37
38
  end
38
39
  end
39
40
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'highline'
4
+
3
5
  require_relative 'release/changelog'
4
6
  require_relative 'release/git'
5
7
 
@@ -44,11 +46,11 @@ module GemToys
44
46
  ## Update CHANGELOG
45
47
  update_changelog_file
46
48
 
49
+ wait_for_manual_check
50
+
47
51
  ## Build new gem file
48
52
  exec_tool 'gem build'
49
53
 
50
- wait_for_manual_check
51
-
52
54
  ## Commit, tag, push
53
55
  process_git
54
56
 
@@ -74,8 +76,6 @@ module GemToys
74
76
  else
75
77
  new_version
76
78
  end
77
-
78
- clear_memery_cache! :current_version
79
79
  end
80
80
 
81
81
  def handle_keyword_in_new_version(current_version_parts, version_index)
@@ -100,12 +100,39 @@ module GemToys
100
100
  end
101
101
 
102
102
  def wait_for_manual_check
103
+ print_files_diff
104
+
105
+ manual_check_menu
106
+ end
107
+
108
+ def print_files_diff
103
109
  $stdout.puts
104
110
  sh "git diff #{version_file_path} #{changelog_file_path}"
105
111
  $stdout.puts
106
- $stdout.puts 'Please, validate files before committing and pushing!'
107
- $stdout.puts 'Press anything to continue, Ctrl+C to cancel.'
108
- $stdin.gets
112
+ end
113
+
114
+ def manual_check_menu
115
+ HighLine.new.choose do |menu|
116
+ menu.layout = :one_line
117
+
118
+ menu.prompt = 'Are these changes correct? '
119
+
120
+ menu.choice(:yes) do
121
+ ## `current_version` is using in `git` and `gem` commands
122
+ clear_memery_cache! :current_version
123
+ end
124
+ menu.choice(:no) { handle_refusing_to_continue }
125
+ menu.choice(:refresh) do
126
+ wait_for_manual_check
127
+ end
128
+ end
129
+ end
130
+
131
+ def handle_refusing_to_continue
132
+ [version_file_path, changelog_file_path].each do |file_path|
133
+ sh "git restore --worktree #{file_path}"
134
+ end
135
+ abort
109
136
  end
110
137
  end
111
138
  end
@@ -19,7 +19,9 @@ module GemToys
19
19
 
20
20
  versions = rubygems_versions
21
21
 
22
- versions.unshift current_version_hash if current_version != versions.first[:number]
22
+ if versions.empty? || current_version != versions.first[:number]
23
+ versions.unshift current_version_hash
24
+ end
23
25
 
24
26
  puts_versions versions
25
27
  end
@@ -15,7 +15,7 @@ module GemToys
15
15
  changelog_file_name: 'CHANGELOG.md',
16
16
  version_file_path: nil,
17
17
  version_tag_prefix: 'v',
18
- unreleased_title: '## master (unreleased)'
18
+ unreleased_title: '## Unreleased'
19
19
  )
20
20
  @changelog_file_name = changelog_file_name
21
21
  @version_file_path = version_file_path
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GemToys
4
- VERSION = '0.7.1'
4
+ VERSION = '0.11.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_toys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-03 00:00:00.000000000 Z
11
+ date: 2021-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alt_memery
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: highline
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry-byebug
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +100,28 @@ dependencies:
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 0.11.0
103
+ version: 0.12.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 0.11.0
110
+ version: 0.12.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: codecov
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 0.4.2
117
+ version: 0.6.0
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 0.4.2
124
+ version: 0.6.0
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rspec
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +156,14 @@ dependencies:
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: '1.2'
159
+ version: 1.22.2
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: '1.2'
166
+ version: 1.22.2
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: rubocop-performance
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -223,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
237
  - !ruby/object:Gem::Version
224
238
  version: '0'
225
239
  requirements: []
226
- rubygems_version: 3.2.3
240
+ rubygems_version: 3.2.22
227
241
  signing_key:
228
242
  specification_version: 4
229
243
  summary: Toys template for gems