bake-modernize 0.62.0 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/modernize/gemspec.rb +2 -1
- data/bake/modernize/license.rb +1 -44
- data/bake/modernize/signing.rb +3 -3
- data/context/index.yaml +1 -0
- data/lib/bake/modernize/license.rb +49 -0
- data/lib/bake/modernize/signing.rb +85 -0
- data/lib/bake/modernize/version.rb +1 -1
- data/lib/bake/modernize.rb +1 -0
- data/readme.md +4 -0
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +3 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1aadc6454ab0888d86a24dd830c3923d6aad289ad86feb368f24c7bfb53e211
|
|
4
|
+
data.tar.gz: 7c80f3d12f4d215a56b2eefad74a0157a97a4d1add74ea14cea17ed70413df33
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f99b9120cb5cb55ea2d6dbb7f652b364a86d7c32cfe55e21b66f50fe8180e7779e330496d3c61bd909c5e794c8e938a87c550d21205ced641b5043a5c5a92fd
|
|
7
|
+
data.tar.gz: 0a2aa4783d673e20fbb7c778e385cbfe6c2c49e3c768deeaa01451eea65b75bc85148d68df3e080a194feba9e7fdc6159bbefe17cbf404f6e48ff5727eca9644
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/bake/modernize/gemspec.rb
CHANGED
|
@@ -24,6 +24,7 @@ def update(path: default_gemspec_path, output: $stdout)
|
|
|
24
24
|
spec = ::Gem::Specification.load(path)
|
|
25
25
|
|
|
26
26
|
root = File.dirname(path)
|
|
27
|
+
signing = Bake::Modernize::Signing.new(spec)
|
|
27
28
|
version_path = version_path(root, spec.name)
|
|
28
29
|
|
|
29
30
|
constant = File.read(File.join(root, version_path))
|
|
@@ -56,7 +57,7 @@ def update(path: default_gemspec_path, output: $stdout)
|
|
|
56
57
|
if File.exist?(certificate_path)
|
|
57
58
|
output.puts "\t"
|
|
58
59
|
output.puts "\tspec.cert_chain = [\"release.cert\"]"
|
|
59
|
-
output.puts "\tspec.signing_key =
|
|
60
|
+
output.puts "\tspec.signing_key = #{signing.private_key_expression}"
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
if spec.homepage and !spec.homepage.empty?
|
data/bake/modernize/license.rb
CHANGED
|
@@ -66,50 +66,7 @@ private
|
|
|
66
66
|
|
|
67
67
|
def update_source_file_authors(authorship, path, modifications)
|
|
68
68
|
copyrights = authorship.copyrights_for_modifications(modifications)
|
|
69
|
-
|
|
70
|
-
input = File.readlines(path)
|
|
71
|
-
output = []
|
|
72
|
-
|
|
73
|
-
if input.first =~ /^\#!/
|
|
74
|
-
output.push input.shift
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Drop any old copyright statements.
|
|
78
|
-
while input.first =~ /Copyright/i
|
|
79
|
-
input.shift
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
if input.first =~ /^\#.*?\:/
|
|
83
|
-
output.push input.shift
|
|
84
|
-
if input.first.chomp.empty?
|
|
85
|
-
input.shift
|
|
86
|
-
end
|
|
87
|
-
output << "\n"
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# Remove any existing license:
|
|
91
|
-
while input.first =~ /^#.*$/
|
|
92
|
-
input.shift
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# Remove any empty lines:
|
|
96
|
-
while input.first&.chomp&.empty?
|
|
97
|
-
input.shift
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
output << "# Released under the MIT License.\n"
|
|
101
|
-
|
|
102
|
-
copyrights.each do |copyright|
|
|
103
|
-
output << "# #{copyright.statement}\n"
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
output << "\n"
|
|
107
|
-
|
|
108
|
-
output.concat(input)
|
|
109
|
-
|
|
110
|
-
File.open(path, "w") do |file|
|
|
111
|
-
file.puts(output)
|
|
112
|
-
end
|
|
69
|
+
Bake::Modernize::License::SourceFile.update(path, copyrights: copyrights.map(&:statement))
|
|
113
70
|
end
|
|
114
71
|
|
|
115
72
|
def remove_license(readme_path)
|
data/bake/modernize/signing.rb
CHANGED
|
@@ -10,10 +10,10 @@ def signing(root: Dir.pwd)
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def update(root:)
|
|
13
|
-
|
|
13
|
+
signing = Bake::Modernize::Signing.load(root)
|
|
14
14
|
certificate_path = File.expand_path("release.cert", root)
|
|
15
15
|
|
|
16
|
-
if
|
|
17
|
-
FileUtils.cp(
|
|
16
|
+
if signing.certificate_path
|
|
17
|
+
FileUtils.cp(signing.certificate_path, certificate_path)
|
|
18
18
|
end
|
|
19
19
|
end
|
data/context/index.yaml
CHANGED
|
@@ -7,6 +7,7 @@ metadata:
|
|
|
7
7
|
changelog_uri: https://github.com/ioquatix/bake-modernize/blob/main/releases.md
|
|
8
8
|
documentation_uri: https://ioquatix.github.io/bake-modernize/
|
|
9
9
|
funding_uri: https://github.com/sponsors/ioquatix/
|
|
10
|
+
signing_owner: socketry
|
|
10
11
|
source_code_uri: https://github.com/ioquatix/bake-modernize.git
|
|
11
12
|
files:
|
|
12
13
|
- path: getting-started.md
|
|
@@ -12,6 +12,55 @@ module Bake
|
|
|
12
12
|
module License
|
|
13
13
|
GIT_BLAME_IGNORE_REVS = ".git-blame-ignore-revs"
|
|
14
14
|
|
|
15
|
+
# Updates Ruby source headers without removing documentation comments.
|
|
16
|
+
class SourceFile
|
|
17
|
+
MAGIC_COMMENT = /\A#\s*(?:-\*-\s*)?(?:coding|encoding|frozen_string_literal|warn_indent|shareable_constant_value)\s*[:=]/i
|
|
18
|
+
LICENSE_COMMENT = /\A#\s*(?:Released under\b|Copyright\b|SPDX-License-Identifier:)/i
|
|
19
|
+
|
|
20
|
+
# Replace the license and copyright header for a Ruby source file.
|
|
21
|
+
# @parameter path [String] The source file path.
|
|
22
|
+
# @parameter copyrights [Array(String)] The copyright statements to write.
|
|
23
|
+
def self.update(path, copyrights:)
|
|
24
|
+
input = File.readlines(path)
|
|
25
|
+
prefix = []
|
|
26
|
+
|
|
27
|
+
prefix << input.shift if input.first&.start_with?("#!")
|
|
28
|
+
while input.first&.match?(MAGIC_COMMENT)
|
|
29
|
+
prefix << input.shift
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Keep the complete leading comment block, removing only known license metadata.
|
|
33
|
+
documentation = []
|
|
34
|
+
while line = input.first
|
|
35
|
+
break unless line.match?(/\A\s*#/) || line.strip.empty?
|
|
36
|
+
|
|
37
|
+
input.shift
|
|
38
|
+
next if line.match?(LICENSE_COMMENT)
|
|
39
|
+
|
|
40
|
+
documentation << line
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
while documentation.first&.strip&.empty?
|
|
44
|
+
documentation.shift
|
|
45
|
+
end
|
|
46
|
+
while documentation.last&.strip&.empty?
|
|
47
|
+
documentation.pop
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
output = prefix.dup
|
|
51
|
+
output << "\n" if output.any?
|
|
52
|
+
output << "# Released under the MIT License.\n"
|
|
53
|
+
copyrights.each do |copyright|
|
|
54
|
+
output << "# #{copyright}\n"
|
|
55
|
+
end
|
|
56
|
+
output << "\n"
|
|
57
|
+
output.concat(documentation)
|
|
58
|
+
output.concat(input)
|
|
59
|
+
|
|
60
|
+
File.write(path, output.join)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
15
64
|
# Represents revisions to skip when analyzing authorship.
|
|
16
65
|
class SkipList
|
|
17
66
|
# Load the skip list from a directory.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2026, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
module Bake
|
|
7
|
+
module Modernize
|
|
8
|
+
# Resolve the RubyGems signing certificate and private key for a project.
|
|
9
|
+
class Signing
|
|
10
|
+
GEM_CREDENTIALS_PATH = File.expand_path("~/.gem")
|
|
11
|
+
GITHUB_OWNER = %r{\Ahttps?://github\.com/([\w.-]+)/}
|
|
12
|
+
|
|
13
|
+
# Load signing configuration from a project's gemspec.
|
|
14
|
+
# @parameter root [String] The project root.
|
|
15
|
+
# @returns [Signing] The signing configuration.
|
|
16
|
+
def self.load(root)
|
|
17
|
+
gemspec_path = Dir["*.gemspec", base: root].first
|
|
18
|
+
gemspec = Gem::Specification.load(File.join(root, gemspec_path)) if gemspec_path
|
|
19
|
+
|
|
20
|
+
return new(gemspec)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @parameter gemspec [Gem::Specification | Nil] The project gemspec.
|
|
24
|
+
def initialize(gemspec)
|
|
25
|
+
@gemspec = gemspec
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# The preferred certificate, if available.
|
|
29
|
+
# @returns [String | Nil] The certificate path.
|
|
30
|
+
def certificate_path
|
|
31
|
+
paths = []
|
|
32
|
+
|
|
33
|
+
if owner = signing_owner
|
|
34
|
+
paths << File.join(GEM_CREDENTIALS_PATH, "#{owner}-release.cert")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
paths << File.join(GEM_CREDENTIALS_PATH, "release.cert")
|
|
38
|
+
return paths.find{|path| File.file?(path)}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# The private key path, preserving an existing gemspec setting.
|
|
42
|
+
# @returns [String] The private key path.
|
|
43
|
+
def private_key_path
|
|
44
|
+
return @gemspec.signing_key if @gemspec&.signing_key
|
|
45
|
+
|
|
46
|
+
if certificate_path = self.certificate_path
|
|
47
|
+
return certificate_path.sub(/\.cert\z/, ".pem")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
return File.join(GEM_CREDENTIALS_PATH, "release.pem")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Format a private key path for use in a gemspec.
|
|
54
|
+
# @returns [String] A Ruby expression.
|
|
55
|
+
def private_key_expression
|
|
56
|
+
prefix = GEM_CREDENTIALS_PATH + File::SEPARATOR
|
|
57
|
+
path = self.private_key_path
|
|
58
|
+
|
|
59
|
+
if path.start_with?(prefix)
|
|
60
|
+
relative_path = path.delete_prefix(prefix)
|
|
61
|
+
path = "~/.gem/#{relative_path}"
|
|
62
|
+
return "File.expand_path(#{path.inspect})"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
return path.inspect
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def signing_owner
|
|
71
|
+
return unless @gemspec
|
|
72
|
+
|
|
73
|
+
owner = @gemspec.metadata["signing_owner"]
|
|
74
|
+
return owner if owner&.match?(/\A[\w.-]+\z/)
|
|
75
|
+
|
|
76
|
+
urls = [@gemspec.metadata["source_code_uri"], @gemspec.homepage].compact
|
|
77
|
+
urls.each do |url|
|
|
78
|
+
if match = GITHUB_OWNER.match(url)
|
|
79
|
+
return match[1]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
data/lib/bake/modernize.rb
CHANGED
data/readme.md
CHANGED
|
@@ -14,6 +14,10 @@ Please see the [project documentation](https://ioquatix.github.io/bake-modernize
|
|
|
14
14
|
|
|
15
15
|
Please see the [project releases](https://ioquatix.github.io/bake-modernize/releases/index) for all releases.
|
|
16
16
|
|
|
17
|
+
### v0.64.0
|
|
18
|
+
|
|
19
|
+
- Prefer the configured signing owner or GitHub owner when selecting RubyGems signing certificates and private keys.
|
|
20
|
+
|
|
17
21
|
### v0.62.0
|
|
18
22
|
|
|
19
23
|
- Refresh `license.md` and Ruby copyright headers with `modernize:license` after version increments in generated release hooks.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.64.0
|
|
4
|
+
|
|
5
|
+
- Prefer the configured signing owner or GitHub owner when selecting RubyGems signing certificates and private keys.
|
|
6
|
+
|
|
3
7
|
## v0.62.0
|
|
4
8
|
|
|
5
9
|
- Refresh `license.md` and Ruby copyright headers with `modernize:license` after version increments in generated release hooks.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bake-modernize
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.64.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -158,6 +158,7 @@ files:
|
|
|
158
158
|
- lib/bake/modernize.rb
|
|
159
159
|
- lib/bake/modernize/git.rb
|
|
160
160
|
- lib/bake/modernize/license.rb
|
|
161
|
+
- lib/bake/modernize/signing.rb
|
|
161
162
|
- lib/bake/modernize/version.rb
|
|
162
163
|
- license.md
|
|
163
164
|
- readme.md
|
|
@@ -186,6 +187,7 @@ metadata:
|
|
|
186
187
|
changelog_uri: https://github.com/ioquatix/bake-modernize/blob/main/releases.md
|
|
187
188
|
documentation_uri: https://ioquatix.github.io/bake-modernize/
|
|
188
189
|
funding_uri: https://github.com/sponsors/ioquatix/
|
|
190
|
+
signing_owner: socketry
|
|
189
191
|
source_code_uri: https://github.com/ioquatix/bake-modernize.git
|
|
190
192
|
rdoc_options: []
|
|
191
193
|
require_paths:
|
metadata.gz.sig
CHANGED
|
Binary file
|