ndr_dev_support 6.0.2 → 6.0.3
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
- data/CHANGELOG.md +4 -0
- data/code_safety.yml +8 -4
- data/lib/ndr_dev_support/tasks.rb +1 -0
- data/lib/ndr_dev_support/version.rb +1 -1
- data/lib/tasks/audit_bundle.rake +170 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ddf993378e5cd98d65313341b0af15677fb8934c42eebb91875d49b66b1ff27
|
4
|
+
data.tar.gz: fceda29b2a92b42b2d480926e9079c6f0f7cf2cfb42c6d7c1263fc58308a7bc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22b80f92debe98a7092b9b7a1322792142e459e33b8d2cdc7dbaecbcbd3f4e8fa1757eeb033c0d1c98b36c5f2411130b6f7aa7a6c4a4ec13f06bf20436746290
|
7
|
+
data.tar.gz: be6721ab8d9ea0e37035cd593748f6d15ce7f958cf5fe5e934c13db2c9a8b61c7dbc751c1b217b47f18c9b3950272496af013190fd7e81f752367839d1b9af55
|
data/CHANGELOG.md
CHANGED
data/code_safety.yml
CHANGED
@@ -27,7 +27,7 @@ file safety:
|
|
27
27
|
CHANGELOG.md:
|
28
28
|
comments:
|
29
29
|
reviewed_by: brian.shand
|
30
|
-
safe_revision:
|
30
|
+
safe_revision: 5943e1a2ef7095e44858806ad16713cffc67c31b
|
31
31
|
CODE_OF_CONDUCT.md:
|
32
32
|
comments:
|
33
33
|
reviewed_by: timgentry
|
@@ -226,12 +226,16 @@ file safety:
|
|
226
226
|
safe_revision: ad38e92c6e56b9d81fdab10681d8f2924eeadf5a
|
227
227
|
lib/ndr_dev_support/tasks.rb:
|
228
228
|
comments:
|
229
|
-
reviewed_by:
|
230
|
-
safe_revision:
|
229
|
+
reviewed_by: brian.shand
|
230
|
+
safe_revision: 93f9ed210c6a19eee4884ea8a906067c65ee67f6
|
231
231
|
lib/ndr_dev_support/version.rb:
|
232
232
|
comments:
|
233
233
|
reviewed_by: brian.shand
|
234
|
-
safe_revision:
|
234
|
+
safe_revision: 5943e1a2ef7095e44858806ad16713cffc67c31b
|
235
|
+
lib/tasks/audit_bundle.rake:
|
236
|
+
comments:
|
237
|
+
reviewed_by: brian.shand
|
238
|
+
safe_revision: 93f9ed210c6a19eee4884ea8a906067c65ee67f6
|
235
239
|
lib/tasks/audit_code.rake:
|
236
240
|
comments: Identical to the version reviewed by josh.pencheon when contained within
|
237
241
|
ndr_support
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# A rake task to update the bundled version of a gem
|
2
|
+
|
3
|
+
# Assumes constant SAFETY_FILE and function repository_type are defined in another rake task.
|
4
|
+
|
5
|
+
namespace :bundle do
|
6
|
+
desc <<~USAGE
|
7
|
+
Update to a later version of a gem interactively.
|
8
|
+
|
9
|
+
Usage: bundle:update gem=rails [version=6.0.4.7]
|
10
|
+
|
11
|
+
Updates the bundled gem (e.g. rails) version to e.g. 6.0.4.7
|
12
|
+
and provides instructions for committing changes.
|
13
|
+
It will attempt to modify a hardcoded version in the Gemfile if necessary.
|
14
|
+
USAGE
|
15
|
+
task(:update) do
|
16
|
+
unless %w[git git-svn].include?(repository_type)
|
17
|
+
warn 'Error: Requires a git working copy. Aborting.'
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
gem = ENV['gem']
|
22
|
+
if gem.blank? || gem !~ /\A[a-zA-Z0-9_.-]+\z/
|
23
|
+
warn "Error: missing or invalid required 'gem' parameter. Aborting.\n\n"
|
24
|
+
system('rake -D bundle:update')
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
gem_list = Bundler.with_unbundled_env { `bundle exec gem list ^#{gem}$` }
|
29
|
+
# Needs to match e.g. "nokogiri (1.12.5 x86_64-darwin)"
|
30
|
+
old_gem_version = gem_list.match(/ \(([0-9.]+)( [a-z0-9_-]*)?\)$/).to_a&.second
|
31
|
+
unless old_gem_version
|
32
|
+
warn <<~MSG.chomp
|
33
|
+
Cannot determine gem version for gem=#{gem}. Aborting. Output from bundle exec gem list:
|
34
|
+
#{gem_list}
|
35
|
+
MSG
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
puts "Old #{gem} version from bundle: #{old_gem_version}"
|
39
|
+
|
40
|
+
new_gem_version = ENV['version'].presence
|
41
|
+
if new_gem_version && new_gem_version !~ /\A[0-9.a-zA-Z-]+\z/
|
42
|
+
warn "Error: invalid 'version' parameter. Aborting.\n\n"
|
43
|
+
system('rake -D bundle:update')
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
|
47
|
+
unless Bundler.with_unbundled_env { system('bundle check 2> /dev/null') }
|
48
|
+
warn('Error: bundle check fails before doing anything.')
|
49
|
+
warn('Please clean up the Gemfile before running this. Aborting.')
|
50
|
+
exit 1
|
51
|
+
end
|
52
|
+
|
53
|
+
if gem == 'rails'
|
54
|
+
# If updating Rails and using activemodel-caution, prompt to put
|
55
|
+
# activemodel-caution gem in place, unless it's already installed for this rails version.
|
56
|
+
activemodel_caution = Bundler.
|
57
|
+
with_unbundled_env { `bundle exec gem list activemodel-caution` }.
|
58
|
+
match?(/^activemodel-caution \([0-9.]+\)$/)
|
59
|
+
if activemodel_caution && new_gem_version
|
60
|
+
file_pattern = "activemodel-caution-#{new_gem_version}*.gem"
|
61
|
+
unless Dir.glob("vendor/cache/#{file_pattern}").any? ||
|
62
|
+
Bundler.with_unbundled_env do
|
63
|
+
`gem list ^activemodel-caution$ -i -v #{new_gem_version}`
|
64
|
+
end.match?(/^true$/)
|
65
|
+
warn("Error: missing #{file_pattern} file in vendor/cache")
|
66
|
+
warn('Copy this file to vendor/cache, then run this command again.')
|
67
|
+
exit 1
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
related_gems = if gem == 'rails'
|
73
|
+
gem_list2 = Bundler.with_unbundled_env do
|
74
|
+
`bundle exec gem list`
|
75
|
+
end
|
76
|
+
gem_list2.split("\n").
|
77
|
+
grep(/[ (]#{old_gem_version}(.0)*[,)]/).
|
78
|
+
collect { |row| row.split.first }
|
79
|
+
else
|
80
|
+
[gem]
|
81
|
+
end
|
82
|
+
puts "Gems to update: #{related_gems.join(' ')}"
|
83
|
+
|
84
|
+
if new_gem_version
|
85
|
+
puts 'Tweaking Gemfile for new gem version'
|
86
|
+
cmd = ['sed', '-i', '.bak', '-E']
|
87
|
+
related_gems.each do |rgem|
|
88
|
+
cmd += ['-e', "s/(gem '(#{rgem})', '(~> )?)#{old_gem_version}(')/\\1#{new_gem_version}\\4/"]
|
89
|
+
end
|
90
|
+
cmd += %w[Gemfile]
|
91
|
+
system(*cmd)
|
92
|
+
File.delete('Gemfile.bak')
|
93
|
+
|
94
|
+
system('git diff Gemfile')
|
95
|
+
end
|
96
|
+
|
97
|
+
cmd = "bundle update --conservative --minor #{related_gems.join(' ')}"
|
98
|
+
puts "Running: #{cmd}"
|
99
|
+
Bundler.with_unbundled_env do
|
100
|
+
system(cmd)
|
101
|
+
end
|
102
|
+
|
103
|
+
unless Bundler.with_unbundled_env { system('bundle check 2> /dev/null') }
|
104
|
+
warn <<~MSG
|
105
|
+
Error: bundle check fails after trying to update Rails version. Aborting.
|
106
|
+
You will need to check your working copy, especially Gemfile, Gemfile.lock, vendor/cache
|
107
|
+
MSG
|
108
|
+
exit 1
|
109
|
+
end
|
110
|
+
|
111
|
+
if File.exist?(SAFETY_FILE)
|
112
|
+
# Remove references to unused files in code_safety.yml
|
113
|
+
system('rake audit:tidy_code_safety_file')
|
114
|
+
end
|
115
|
+
|
116
|
+
gem_list = Bundler.with_unbundled_env { `bundle exec gem list ^#{gem}$` }
|
117
|
+
new_gem_version2 = gem_list.match(/ \(([0-9.]+)( [a-z0-9_-]*)?\)$/).to_a&.second
|
118
|
+
|
119
|
+
if new_gem_version && new_gem_version != new_gem_version2
|
120
|
+
puts <<~MSG
|
121
|
+
Error: Tried to update gem #{gem} to version #{new_gem_version} but ended up at version #{new_gem_version2}. Aborting.
|
122
|
+
You will need to check your working copy, especially Gemfile, Gemfile.lock, vendor/cache
|
123
|
+
Try running:
|
124
|
+
bundle exec rake bundle:update gem=#{gem} version=#{new_gem_version2}
|
125
|
+
MSG
|
126
|
+
exit 1
|
127
|
+
end
|
128
|
+
|
129
|
+
# At this point, we have successfully updated all the local files.
|
130
|
+
# All that remains is to set up a branch, if necessary, and inform the user what to commit.
|
131
|
+
|
132
|
+
puts "Looking for changed files using git status\n\n"
|
133
|
+
files_to_git_rm = `git status vendor/cache/|grep 'deleted: ' | \
|
134
|
+
grep -o ': .*' | sed -e 's/^: *//'`.split("\n")
|
135
|
+
files_to_git_add = `git status Gemfile Gemfile.lock code_safety.yml|grep 'modified: ' | \
|
136
|
+
grep -o ': .*' | sed -e 's/^: *//'`.split("\n")
|
137
|
+
files_to_git_add += `git status vendor/cache|expand|grep '^\s*vendor/cache' | \
|
138
|
+
sed -e 's/^ *//'`.split("\n")
|
139
|
+
|
140
|
+
if files_to_git_rm.empty? && files_to_git_add.empty?
|
141
|
+
puts <<~MSG
|
142
|
+
No changes were made. Please manually update the Gemfile, run
|
143
|
+
bundle update --conservative --minor #{related_gems.join(' ')}
|
144
|
+
MSG
|
145
|
+
puts ' rake audit:tidy_code_safety_file' if File.exist?(SAFETY_FILE)
|
146
|
+
puts <<~MSG
|
147
|
+
then run tests and git rm / git add any changes
|
148
|
+
including vendor/cache Gemfile Gemfile.lock code_safety.yml
|
149
|
+
then git commit
|
150
|
+
MSG
|
151
|
+
exit
|
152
|
+
end
|
153
|
+
|
154
|
+
if repository_type == 'git'
|
155
|
+
# Check out a fresh branch, if a git working copy (but not git-svn)
|
156
|
+
branch_name = "#{gem}_#{new_gem_version2.gsub('.', '_')}"
|
157
|
+
system('git', 'checkout', '-b', branch_name) # Create a new git branch
|
158
|
+
end
|
159
|
+
|
160
|
+
puts <<~MSG
|
161
|
+
Gemfile updated. Please use "git status" and "git diff" to check the local changes,
|
162
|
+
manually add any additional platform-specific gems required (e.g. for nokogiri),
|
163
|
+
re-run tests locally, then run the following to commit the changes:
|
164
|
+
|
165
|
+
$ git rm #{files_to_git_rm.join(' ')}
|
166
|
+
$ git add #{files_to_git_add.join(' ')}
|
167
|
+
$ git commit -m '# Bump #{gem} to #{new_gem_version2}'
|
168
|
+
MSG
|
169
|
+
end
|
170
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ndr_dev_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NCRS Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -450,6 +450,7 @@ files:
|
|
450
450
|
- lib/ndr_dev_support/slack_message_publisher.rb
|
451
451
|
- lib/ndr_dev_support/tasks.rb
|
452
452
|
- lib/ndr_dev_support/version.rb
|
453
|
+
- lib/tasks/audit_bundle.rake
|
453
454
|
- lib/tasks/audit_code.rake
|
454
455
|
- lib/tasks/ci/brakeman.rake
|
455
456
|
- lib/tasks/ci/bundle_audit.rake
|