Skip to content

Commit

Permalink
still fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Judahmeek committed Jun 14, 2024
1 parent 8a0003e commit 15db710
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/rspec-package-specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ jobs:
run: echo "gem 'shakapacker', '~> ${{ matrix.versions == 'oldest' && '6.6.0' || '8.0.0' }}'" >> Gemfile
- name: Install Ruby Gems for package
run: bundle check --path=vendor/bundle || bundle _2.5.9_ install --path=vendor/bundle --jobs=4 --retry=3
- run: git commit -am "to stop generators from complaining about uncommitted code"
- name: Git Stuff
run: |
git config user.email "[email protected]"
git config user.name "Your Name"
git commit -am "stop generators from complaining about uncommitted code"
- name: Run rspec tests
run: bundle exec rspec spec/react_on_rails
- name: Store test results
Expand Down
10 changes: 0 additions & 10 deletions rakelib/example_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "rake"
require "pathname"

require_relative "task_helpers"

Expand Down Expand Up @@ -42,15 +41,6 @@ def gemfile
File.join(dir, "Gemfile")
end

# Gems we need to add to the Gemfile before bundle installing
def required_gems
relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir))
[
"gem 'react_on_rails', path: '#{relative_gem_root}'",
"gem 'shakapacker'"
]
end

# Options we pass when running `rails new` from the command-line.
attr_writer :rails_options

Expand Down
21 changes: 12 additions & 9 deletions rakelib/examples.rake
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

require "yaml"
require "rails/version"
require "pathname"

require_relative "example_type"
require_relative "task_helpers"

namespace :examples do # rubocop:disable Metrics/BlockLength
namespace :examples [:packer_type] do # rubocop:disable Metrics/BlockLength
include ReactOnRails::TaskHelpers
# Loads data from examples_config.yml and instantiates corresponding ExampleType objects
examples_config_file = File.expand_path("examples_config.yml", __dir__)
Expand All @@ -33,13 +34,9 @@ namespace :examples do # rubocop:disable Metrics/BlockLength
example_type.rails_options += "--skip-javascript"
sh_in_dir(examples_dir, "rails new #{example_type.name} #{example_type.rails_options}")
sh_in_dir(example_type.dir, "touch .gitignore")
append_to_gemfile(example_type.gemfile, example_type.required_gems)
append_to_gemfile(packer_type, example_type.gemfile)
bundle_install_in(example_type.dir)
begin
sh_in_dir(example_type.dir, "rake webpacker:install")
rescue
sh_in_dir(example_type.dir, "rake shakapacker:install")
end
sh_in_dir(example_type.dir, "rake #{packer_type.to_s}:install")
sh_in_dir(example_type.dir, example_type.generator_shell_commands)
sh_in_dir(example_type.dir, "yarn")
end
Expand All @@ -55,13 +52,19 @@ namespace :examples do # rubocop:disable Metrics/BlockLength
end

desc "Generates all example apps. Run `rake -D examples` to see all available options"
task examples: ["examples:gen_all"]
task :examples, [:packer_type] => "examples:gen_all"

private

# Appends each string in an array as a new line of text in the given Gemfile.
# Automatically adds line returns.
def append_to_gemfile(gemfile, lines)
def append_to_gemfile(packer_type, gemfile)
relative_gem_root = Pathname(gem_root).relative_path_from(Pathname(dir))
shakapacker_version = packer_type.to_s == 'webpacker' ? '6.6.0' : '8.0.0'
lines = [
"gem 'react_on_rails', path: '#{relative_gem_root}'",
"gem 'shakapacker', '~> #{shakapacker_version}'"
]
old_text = File.read(gemfile)
new_text = lines.reduce(old_text) { |a, e| a << "#{e}\n" }
File.open(gemfile, "w") { |f| f.puts(new_text) }
Expand Down
9 changes: 5 additions & 4 deletions spec/dummy/config/webpack/commonWebpackConfig.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Common configuration applying to client and server configuration
const { generateWebpackConfig, v6WebpackConfig, merge } = require('shakapacker');
const webpack = require('webpack');

const aliasConfig = require('./alias.js');
const { generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker');

const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined

const baseClientWebpackConfig = v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias();

const webpack = require('webpack');

const aliasConfig = require('./alias.js');

const commonOptions = {
resolve: {
extensions: ['.css', '.ts', '.tsx'],
Expand Down
7 changes: 5 additions & 2 deletions spec/dummy/config/webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const { env, generateWebpackConfig, v6WebpackConfig } = require('shakapacker');
const { generateWebpackConfig, webpackConfig: v6WebpackConfig, merge } = require('shakapacker');

const generateWebpackConfigAlias = generateWebpackConfig ? generateWebpackConfig : () => undefined

const { existsSync } = require('fs');
const { resolve } = require('path');

Expand All @@ -8,7 +11,7 @@ const envSpecificConfig = () => {
console.log(`Loading ENV specific webpack configuration file ${path}`);
return require(path);
} else {
return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfig();
return v6WebpackConfig ? v6WebpackConfig : generateWebpackConfigAlias();;
}
};

Expand Down

0 comments on commit 15db710

Please sign in to comment.