Skip to content

Commit 9013a13

Browse files
ihabadhamclaudeJudahmeek
authored
Fix rake tasks after workspace structure merge (PR #1830) (#1839)
## Summary Fixes two rake tasks that were broken/discovered after the workspace structure changes in PR #1830: • **`node_package.rake`**: Fixed `yalc publish` → `yarn yalc publish` to work with private workspace root • **`shakapacker_examples.rake`**: Fixed missing space in rails command + updated to use `npm install` instead of `yarn` ## Issues Found 1. **`yalc publish` fails with private workspace root**: After PR #1830 made root package.json private (standard practice), `yalc publish` fails with "Will not publish package with `private: true`" - **Fix**: Use `yarn yalc publish` which delegates to the publishable workspace package 2. **Rails command syntax error**: Missing space in `rails_options += "--skip-javascript"` caused `webpack--skip-javascript` - **Fix**: Add space: `rails_options += " --skip-javascript"` 3. **Package manager mismatch**: Rake task runs `yarn` but Shakapacker now defaults to `npm` when no lockfiles exist - **Fix**: Use `npm install` to match Shakapacker's choice ## Test Plan - [x] `rake node_package` - Successfully builds and publishes with yalc - [x] `rake shakapacker_examples:gen_basic` - Successfully generates Rails app with React on Rails - [x] Manual testing confirmed all three fixes work together ## Root Cause The workspace restructuring in PR #1830 was correct and follows standard practices. These rake tasks simply needed updates to work with the new structure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/shakacode/react_on_rails/1839) <!-- Reviewable:end --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - Bug Fixes - Fixed example generator so CLI options (e.g., skipping JavaScript) are applied reliably during project creation. - Chores - Switched example project dependency installation from Yarn to npm for consistency. - Standardized package publishing to run via Yarn after the build step. These updates improve example generation reliability and align tooling across workflows. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Judah Meek <[email protected]>
1 parent 12151f9 commit 9013a13

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

rakelib/node_package.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace :node_package do
77

88
task :build do
99
puts "Building Node Package and running 'yalc publish'"
10-
sh "yarn run build && yalc publish"
10+
sh "yarn run build && yarn yalc publish"
1111
end
1212
end
1313

rakelib/shakapacker_examples.rake

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,15 @@ namespace :shakapacker_examples do # rubocop:disable Metrics/BlockLength
2929
task example_type.gen_task_name_short => example_type.clobber_task_name do
3030
puts "Running shakapacker_examples:#{example_type.gen_task_name_short}"
3131
mkdir_p(example_type.dir)
32-
example_type.rails_options += "--skip-javascript"
33-
sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}")
32+
sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options} --skip-javascript")
3433
sh_in_dir(example_type.dir, "touch .gitignore")
3534
sh_in_dir(example_type.dir,
3635
"echo \"gem 'react_on_rails', path: '#{relative_gem_root}'\" >> #{example_type.gemfile}")
3736
sh_in_dir(example_type.dir, "echo \"gem 'shakapacker', '>= 8.2.0'\" >> #{example_type.gemfile}")
3837
bundle_install_in(example_type.dir)
3938
sh_in_dir(example_type.dir, "rake shakapacker:install")
40-
41-
# Skip validation during generator run since npm package isn't installed yet
42-
#
43-
# ENV Variable Scope: We prefix each shell command with the ENV variable rather than
44-
# setting it in the Ruby process for these reasons:
45-
#
46-
# 1. Each command spawns a new shell process with its own environment
47-
# 2. The ENV variable is automatically scoped to each command (no cleanup needed)
48-
# 3. This differs from the generator approach in lib/generators/react_on_rails/install_generator.rb
49-
# which sets ENV in the Ruby process and requires explicit cleanup
50-
#
51-
# This approach is simpler and safer for rake tasks that invoke shell commands.
52-
generator_commands = example_type.generator_shell_commands.map do |cmd|
53-
"REACT_ON_RAILS_SKIP_VALIDATION=true #{cmd}"
54-
end
55-
sh_in_dir(example_type.dir, generator_commands)
56-
sh_in_dir(example_type.dir, "yarn")
39+
sh_in_dir(example_type.dir, example_type.generator_shell_commands)
40+
sh_in_dir(example_type.dir, "npm install")
5741
end
5842
end
5943

0 commit comments

Comments
 (0)