Skip to content

Commit ffc8950

Browse files
Fix syntax error and RuboCop violations in release.rake
- Remove extra end statement that was causing syntax error - Fix string concatenation to use interpolation - Fix operator precedence ambiguity - Convert multi-line unless blocks to modifier form - Refactor unless/else to if/else for clarity - Fix line length violation - Eliminate duplicate separator line code All RuboCop violations resolved. File now passes bundle exec rubocop with zero offenses.
1 parent 34f9363 commit ffc8950

File tree

1 file changed

+79
-29
lines changed

1 file changed

+79
-29
lines changed

rakelib/release.rake

Lines changed: 79 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,22 @@ This task depends on the gem-release ruby gem which is installed via `bundle ins
2727
1st argument: The new version in rubygem format (no dashes). Pass no argument to
2828
automatically perform a patch version bump.
2929
2nd argument: Perform a dry run by passing 'true' as a second argument.
30-
31-
Note: Accept defaults for npmjs options. Script will pause to get 2FA tokens.
32-
33-
Example: `rake release[16.2.0,false]`")
34-
task :release, %i[gem_version dry_run] do |_t, args|
30+
3rd argument: Use Verdaccio local registry by passing 'verdaccio' as a third argument.
31+
Requires Verdaccio server running on http://localhost:4873/
32+
33+
Examples:
34+
rake release[16.2.0] # Release to production
35+
rake release[16.2.0,true] # Dry run
36+
rake release[16.2.0,false,verdaccio] # Test release to Verdaccio")
37+
task :release, %i[gem_version dry_run registry] do |_t, args|
3538
include ReactOnRails::TaskHelpers
3639

3740
# Check if there are uncommitted changes
3841
ReactOnRails::GitUtils.uncommitted_changes?(RaisingMessageHandler.new)
3942
args_hash = args.to_hash
4043

4144
is_dry_run = ReactOnRails::Utils.object_to_boolean(args_hash[:dry_run])
45+
use_verdaccio = args_hash.fetch(:registry, "") == "verdaccio"
4246

4347
gem_version = args_hash.fetch(:gem_version, "")
4448

@@ -88,6 +92,22 @@ task :release, %i[gem_version dry_run] do |_t, args|
8892
# Update dummy app's Gemfile.lock
8993
bundle_install_in(dummy_app_dir)
9094

95+
# Prepare NPM registry configuration
96+
npm_registry_url = use_verdaccio ? "http://localhost:4873/" : "https://registry.npmjs.org/"
97+
npm_publish_args = use_verdaccio ? "--registry #{npm_registry_url}" : ""
98+
99+
if use_verdaccio
100+
puts "\n#{'=' * 80}"
101+
puts "VERDACCIO LOCAL REGISTRY MODE"
102+
puts "=" * 80
103+
puts "\nBefore proceeding, ensure:"
104+
puts " 1. Verdaccio server is running on http://localhost:4873/"
105+
puts " 2. You are authenticated with Verdaccio:"
106+
puts " npm adduser --registry http://localhost:4873/"
107+
puts "\nPress ENTER to continue or Ctrl+C to cancel..."
108+
$stdin.gets unless is_dry_run
109+
end
110+
91111
unless is_dry_run
92112
# Commit all version changes
93113
sh_in_dir(gem_root, "git add -A")
@@ -101,59 +121,89 @@ task :release, %i[gem_version dry_run] do |_t, args|
101121
sh_in_dir(gem_root, "git push --tags")
102122

103123
puts "\n#{'=' * 80}"
104-
puts "Publishing NPM packages..."
124+
puts "Publishing NPM packages to #{use_verdaccio ? 'Verdaccio (local)' : 'npmjs.org'}..."
105125
puts "=" * 80
106126

107127
# Publish react-on-rails NPM package
108128
puts "\nPublishing react-on-rails@#{actual_npm_version}..."
109-
puts "Carefully add your OTP for NPM when prompted."
110-
sh_in_dir(gem_root, "yarn workspace react-on-rails publish --new-version #{actual_npm_version}")
129+
puts "Carefully add your OTP for NPM when prompted." unless use_verdaccio
130+
sh_in_dir(gem_root, "yarn workspace react-on-rails publish --new-version #{actual_npm_version} #{npm_publish_args}")
111131

112132
# Publish react-on-rails-pro NPM package
113133
puts "\nPublishing react-on-rails-pro@#{actual_npm_version}..."
114-
puts "Carefully add your OTP for NPM when prompted."
115-
sh_in_dir(gem_root, "yarn workspace react-on-rails-pro publish --new-version #{actual_npm_version}")
116-
117-
puts "\n#{'=' * 80}"
118-
puts "Publishing Ruby gem..."
119-
puts "=" * 80
120-
121-
# Publish Ruby gem
122-
puts "\nCarefully add your OTP for Rubygems when prompted."
123-
sh_in_dir(gem_root, "gem release")
134+
puts "Carefully add your OTP for NPM when prompted." unless use_verdaccio
135+
sh_in_dir(gem_root,
136+
"yarn workspace react-on-rails-pro publish --new-version #{actual_npm_version} #{npm_publish_args}")
137+
138+
if use_verdaccio
139+
puts "Skipping Ruby gem publication (Verdaccio mode)"
140+
puts "=" * 80
141+
else
142+
puts "\n#{'=' * 80}"
143+
puts "Publishing Ruby gem..."
144+
puts "=" * 80
145+
146+
# Publish Ruby gem
147+
puts "\nCarefully add your OTP for Rubygems when prompted."
148+
sh_in_dir(gem_root, "gem release")
149+
end
124150
end
125151

152+
npm_registry_note = if use_verdaccio
153+
"Verdaccio (http://localhost:4873/)"
154+
else
155+
"npmjs.org"
156+
end
157+
126158
if is_dry_run
127159
puts "\n#{'=' * 80}"
128160
puts "DRY RUN COMPLETE"
129161
puts "=" * 80
130162
puts "Version would be bumped to: #{actual_gem_version} (gem) / #{actual_npm_version} (npm)"
163+
puts "NPM Registry: #{npm_registry_note}"
131164
puts "Files that would be updated:"
132165
puts " - lib/react_on_rails/version.rb"
133166
puts " - package.json (root)"
134167
puts " - packages/react-on-rails/package.json"
135168
puts " - packages/react-on-rails-pro/package.json (version + dependency)"
136169
puts " - spec/dummy/Gemfile.lock"
137-
puts "\nTo actually release, run without dry_run: rake release[#{actual_gem_version}]"
170+
registry_arg = use_verdaccio ? ",false,verdaccio" : ""
171+
puts "\nTo actually release, run: rake release[#{actual_gem_version}#{registry_arg}]"
138172
else
139173
msg = <<~MSG
140174
141175
#{'=' * 80}
142176
RELEASE COMPLETE! 🎉
143177
#{'=' * 80}
144178
145-
Published:
146-
- react-on-rails@#{actual_npm_version} (NPM)
147-
- react-on-rails-pro@#{actual_npm_version} (NPM)
148-
- react_on_rails #{actual_gem_version} (RubyGems)
179+
Published to #{npm_registry_note}:
180+
- react-on-rails@#{actual_npm_version}
181+
- react-on-rails-pro@#{actual_npm_version}
182+
MSG
183+
184+
msg += " - react_on_rails #{actual_gem_version} (RubyGems)\n" unless use_verdaccio
149185

150-
Next steps:
151-
1. Update CHANGELOG.md: bundle exec rake update_changelog
152-
2. Update dummy app: cd #{dummy_app_dir} && bundle update react_on_rails
153-
3. Commit CHANGELOG: cd #{gem_root} && git commit -a -m 'Update CHANGELOG.md and spec/dummy Gemfile.lock'
154-
4. Push changes: git push
186+
if use_verdaccio
187+
msg += <<~VERDACCIO
188+
189+
Verdaccio test packages published successfully!
190+
191+
To test installation:
192+
npm install --registry http://localhost:4873/ react-on-rails@#{actual_npm_version}
193+
npm install --registry http://localhost:4873/ react-on-rails-pro@#{actual_npm_version}
194+
195+
VERDACCIO
196+
else
197+
msg += <<~PRODUCTION
198+
199+
Next steps:
200+
1. Update CHANGELOG.md: bundle exec rake update_changelog
201+
3. Commit CHANGELOG: cd #{gem_root} && git commit -a -m 'Update CHANGELOG.md and spec/dummy Gemfile.lock'
202+
4. Push changes: git push
203+
204+
PRODUCTION
205+
end
155206

156-
MSG
157207
puts msg
158208
end
159209
end

0 commit comments

Comments
 (0)