diff --git a/.github/workflows/ruby-backward-compatibility.yml b/.github/workflows/ruby-backward-compatibility.yml index 6a27de0b5..871a9df13 100644 --- a/.github/workflows/ruby-backward-compatibility.yml +++ b/.github/workflows/ruby-backward-compatibility.yml @@ -15,7 +15,7 @@ jobs: - gemfiles/Gemfile-rails.6.1.x - gemfiles/Gemfile-rails.7.0.x # Uncomment the following line only to ensure compatibility with the - # upcomming Rails versions, maybe before a release. + # upcoming Rails versions, maybe before a release. #- gemfiles/Gemfile-rails-edge exclude: - ruby: 2.6 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f455af81..aef8a56ba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ Thank you for your interest in contributing to Shakapacker! We welcome all contr - [Testing the generator](#testing-the-generator) ## Reporting Issues -If you encounter any issues with the project, please first check the exisiting issues (including closed ones). If the issues is not reported before, please opening an issue on our GitHub repository. Please provide a clear and detailed description of the issue, including steps to reproduce it. Creating a demo repository to demonstrate the issue would be ideal (and in some cases necessary). +If you encounter any issues with the project, please first check the existing issues (including closed ones). If the issues is not reported before, please opening an issue on our GitHub repository. Please provide a clear and detailed description of the issue, including steps to reproduce it. Creating a demo repository to demonstrate the issue would be ideal (and in some cases necessary). If looking to contribute to the project by fixing existing issues, we recommend looking at issues, particularly with the "[help wanted](https://github.com/shakacode/shakapacker/issues?q=is%3Aissue+label%3A%22help+wanted%22)" label. @@ -41,7 +41,7 @@ We welcome pull requests that fix bugs, add new features, or improve existing on # In Rails app for testing yalc link shakapacker - # After every chagnes in shakapacker, run the folloing in Shakapacker directory + # After every change in shakapacker, run the following in Shakapacker directory yalc push # or yalc publish --push ``` 3. Run the following commands to set up the development environment. @@ -101,7 +101,7 @@ bundle exec rake run_spec:gem ``` #### 4.4 Run only Shakapacker gem specs for backward compatibility -These specs are to check Shakapcker v7 backward compatibility with v6.x +These specs are to check Shakapacker v7 backward compatibility with v6.x ``` bundle exec rake run_spec:gem_bc @@ -125,4 +125,3 @@ To ensure that your installer works as expected, either you can run `bundle exec 3. Run `bundle exec rails shakapacker:install` to confirm that you got the right changes. **Note:** Ensure that you use bundle exec otherwise the installed shakapacker gem will run and not the one you are working on. - diff --git a/README.md b/README.md index 03d787c95..be3ec04b4 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ _Official, actively maintained successor to [rails/webpacker](https://github.com [![Gem](https://img.shields.io/gem/v/shakapacker.svg)](https://rubygems.org/gems/shakapacker) [![npm version](https://badge.fury.io/js/shakapacker.svg)](https://badge.fury.io/js/shakapacker) -Shakpacker makes it easy to use the JavaScript pre-processor and bundler [Webpack v5+](https://webpack.js.org/) +Shakapacker makes it easy to use the JavaScript pre-processor and bundler [Webpack v5+](https://webpack.js.org/) to manage frontend JavaScript in Rails. It can coexist with the asset pipeline, leaving Webpack responsible solely for frontend JavaScript, or can be used exclusively, making it also responsible for images, fonts, and CSS. Check out 6.1.1+ for [SWC](https://swc.rs/) and [esbuild-loader](https://github.com/privatenumber/esbuild-loader) support! They are faster than Babel! -See a comparison of [Shakapacker with jsbundling-rails](https://github.com/rails/jsbundling-rails/blob/main/docs/comparison_with_webpacker.md). For a in-depth discussion of choosing between `shakapacker` and `jsbundling-rails`, see the discussion [Webpacker alternatives - which path should we go to? #8783](https://github.com/decidim/decidim/discussions/8783) and the resulting PR [Switch away from Webpacker to Shakapacker #10389](https://github.com/decidim/decidim/pull/10389). +See a comparison of [Shakapacker with jsbundling-rails](https://github.com/rails/jsbundling-rails/blob/main/docs/comparison_with_webpacker.md). For an in-depth discussion of choosing between `shakapacker` and `jsbundling-rails`, see the discussion [Webpacker alternatives - which path should we go to? #8783](https://github.com/decidim/decidim/discussions/8783) and the resulting PR [Switch away from Webpacker to Shakapacker #10389](https://github.com/decidim/decidim/pull/10389). For discussions, see our [Slack Channel](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE). diff --git a/docs/deployment.md b/docs/deployment.md index 530d941ad..be51f8cdf 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -94,7 +94,7 @@ If you are using a CDN setup, Shakapacker does NOT use the `ASSET_HOST` environm ### Assets compiling on every deployment even if JavaScript and CSS files are not changed -Make sure you have your public outputh path (default `public/packs`), the shakapacker cache path (default `tmp/shakapacker`) and `node_modules` in `:linked_dirs` +Make sure you have your public output path (default `public/packs`), the shakapacker cache path (default `tmp/shakapacker`) and `node_modules` in `:linked_dirs` ```ruby append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "tmp/shakapacker", "public/packs", ".bundle", "node_modules" diff --git a/docs/using_esbuild_loader.md b/docs/using_esbuild_loader.md index 98f6efced..38cbed228 100644 --- a/docs/using_esbuild_loader.md +++ b/docs/using_esbuild_loader.md @@ -8,7 +8,7 @@ If you face any issues, please report them at https://github.com/shakacode/shaka [esbuild](https://esbuild.github.io/) is a Go-based bundler tool that can offer [significant improvement](https://esbuild.github.io/faq/#benchmark-details) over other similar tools. -While esbuild is a complete bundler, through the usage of [esbuild-loader](https://github.com/privatenumber/esbuild-loader), you can still leverage esbuild's speedy transpilation and minifcation in your Webpack-based configs. +While esbuild is a complete bundler, through the usage of [esbuild-loader](https://github.com/privatenumber/esbuild-loader), you can still leverage esbuild's speedy transpilation and minification in your Webpack-based configs. Please note, that unlike Babel or SWC loader, esbuild-loader has got no support for things like: - React Hot Module reload diff --git a/docs/v6_upgrade.md b/docs/v6_upgrade.md index a81f72c8f..f3927ac9c 100644 --- a/docs/v6_upgrade.md +++ b/docs/v6_upgrade.md @@ -97,7 +97,7 @@ _If you're on webpacker v5, follow [how to upgrade to webpacker v6.0.0.rc.6 from ``` If you prefer this configuration, then you will move your `app/javascript/packs/*` (including `application.js`) to `app/javascript/` and update the configuration file. - Note, moving your files is optional, as you can stil keep your entries in a separate directory, called something like `packs`, or `entries`. This directory is defined with the `source_path`. + Note, moving your files is optional, as you can still keep your entries in a separate directory, called something like `packs`, or `entries`. This directory is defined with the `source_path`. 1. Update `webpack-dev-server` to the current version, greater than 4.2, updating `package.json`. diff --git a/docs/v7_upgrade.md b/docs/v7_upgrade.md index 5eea8c926..c9a415219 100644 --- a/docs/v7_upgrade.md +++ b/docs/v7_upgrade.md @@ -45,7 +45,7 @@ If you started with: const { webpackConfig } = require('shakapacker') ``` -Swtich to: +Switch to: ```js const { generateWebpackConfig } = require('shakapacker') diff --git a/lib/tasks/shakapacker/check_binstubs.rake b/lib/tasks/shakapacker/check_binstubs.rake index e4a6820d3..2e16d6777 100644 --- a/lib/tasks/shakapacker/check_binstubs.rake +++ b/lib/tasks/shakapacker/check_binstubs.rake @@ -1,12 +1,17 @@ namespace :shakapacker do desc "Verifies that bin/shakapacker is present" task :check_binstubs do - verify_file_existance("bin/shakapacker", "bin/webpacker") - verify_file_existance("bin/shakapacker-dev-server", "bin/webpacker-dev-server") + verify_file_existence("bin/shakapacker", "bin/webpacker") + verify_file_existence("bin/shakapacker-dev-server", "bin/webpacker-dev-server") end end def verify_file_existance(main_file, alternative_file) + puts "verify_file_existance is deprecated - use verify_file_existence instead" + verify_file_existence(main_file, alternative_file) +end + +def verify_file_existence(main_file, alternative_file) unless File.exist?(Rails.root.join(main_file)) if File.exist?(Rails.root.join(alternative_file)) Shakapacker.puts_deprecation_message( diff --git a/package/environments/__tests__/base-bc.js b/package/environments/__tests__/base-bc.js index bfb53f597..9acae97ef 100644 --- a/package/environments/__tests__/base-bc.js +++ b/package/environments/__tests__/base-bc.js @@ -1,6 +1,6 @@ /* global test expect, describe, afterAll, beforeEach */ -// environment.js expects to find config/webapacker.yml and resolved modules from +// environment.js expects to find config/webpacker.yml and resolved modules from // the root of a Rails project const { resetEnv, chdirWebpackerTestApp } = require('../../utils/helpers') diff --git a/package/environments/__tests__/development.js b/package/environments/__tests__/development.js index 8684ee952..08be5a0c4 100644 --- a/package/environments/__tests__/development.js +++ b/package/environments/__tests__/development.js @@ -16,10 +16,10 @@ describe('Development specific config', () => { test('sets filename to use contentHash', () => { const config = require("../../config"); config.useContentHash = true - const environmnetConfig = require('../development') + const environmentConfig = require('../development') - expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js') - expect(environmnetConfig.output.chunkFilename).toEqual( + expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js') + expect(environmentConfig.output.chunkFilename).toEqual( 'js/[name]-[contenthash].chunk.js' ) }) @@ -29,10 +29,10 @@ describe('Development specific config', () => { test('sets filename without using contentHash', () => { const config = require("../../config"); config.useContentHash = false - const environmnetConfig = require('../development') + const environmentConfig = require('../development') - expect(environmnetConfig.output.filename).toEqual('js/[name].js') - expect(environmnetConfig.output.chunkFilename).toEqual( + expect(environmentConfig.output.filename).toEqual('js/[name].js') + expect(environmentConfig.output.chunkFilename).toEqual( 'js/[name].chunk.js' ) }) @@ -42,10 +42,10 @@ describe('Development specific config', () => { test('sets filename without using contentHash', () => { const config = require("../../config"); delete config.useContentHash - const environmnetConfig = require('../development') + const environmentConfig = require('../development') - expect(environmnetConfig.output.filename).toEqual('js/[name].js') - expect(environmnetConfig.output.chunkFilename).toEqual( + expect(environmentConfig.output.filename).toEqual('js/[name].js') + expect(environmentConfig.output.chunkFilename).toEqual( 'js/[name].chunk.js' ) }) diff --git a/package/environments/__tests__/production.js b/package/environments/__tests__/production.js index 1352a0fb9..521e1a5fc 100644 --- a/package/environments/__tests__/production.js +++ b/package/environments/__tests__/production.js @@ -16,10 +16,10 @@ describe('Production specific config', () => { test('sets filename to use contentHash', () => { const config = require("../../config"); config.useContentHash = true - const environmnetConfig = require('../production') + const environmentConfig = require('../production') - expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js') - expect(environmnetConfig.output.chunkFilename).toEqual( + expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js') + expect(environmentConfig.output.chunkFilename).toEqual( 'js/[name]-[contenthash].chunk.js' ) }) @@ -28,7 +28,7 @@ describe('Production specific config', () => { const consoleWarnSpy = jest.spyOn(console, 'warn'); const config = require("../../config"); config.useContentHash = true - const environmnetConfig = require('../production') + const environmentConfig = require('../production') expect(consoleWarnSpy).not.toHaveBeenCalledWith( expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/) @@ -42,10 +42,10 @@ describe('Production specific config', () => { test('sets filename to use contentHash', () => { const config = require("../../config"); config.useContentHash = false - const environmnetConfig = require('../production') + const environmentConfig = require('../production') - expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js') - expect(environmnetConfig.output.chunkFilename).toEqual( + expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js') + expect(environmentConfig.output.chunkFilename).toEqual( 'js/[name]-[contenthash].chunk.js' ) }) @@ -54,7 +54,7 @@ describe('Production specific config', () => { const consoleWarnSpy = jest.spyOn(console, 'warn'); const config = require("../../config"); config.useContentHash = false - const environmnetConfig = require('../production') + const environmentConfig = require('../production') expect(consoleWarnSpy).toHaveBeenCalledWith( expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/) @@ -68,10 +68,10 @@ describe('Production specific config', () => { test('sets filename to use contentHash', () => { const config = require("../../config"); delete config.useContentHash - const environmnetConfig = require('../production') + const environmentConfig = require('../production') - expect(environmnetConfig.output.filename).toEqual('js/[name]-[contenthash].js') - expect(environmnetConfig.output.chunkFilename).toEqual( + expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js') + expect(environmentConfig.output.chunkFilename).toEqual( 'js/[name]-[contenthash].chunk.js' ) }) @@ -80,7 +80,7 @@ describe('Production specific config', () => { const consoleWarnSpy = jest.spyOn(console, 'warn'); const config = require("../../config"); delete config.useContentHash - const environmnetConfig = require('../production') + const environmentConfig = require('../production') expect(consoleWarnSpy).not.toHaveBeenCalledWith( expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/) diff --git a/rakelib/release.rake b/rakelib/release.rake index 43f96b2f2..bfe159836 100644 --- a/rakelib/release.rake +++ b/rakelib/release.rake @@ -25,7 +25,7 @@ Note, accept defaults for npmjs options. Script will pause to get 2FA tokens. Example: `rake release[2.1.0,false]`") task :create_release, %i[gem_version dry_run] do |_t, args| - # Check if there are uncommited changes + # Check if there are uncommitted changes Shakapacker::Utils::Misc.uncommitted_changes?(RaisingMessageHandler.new) args_hash = args.to_hash diff --git a/spec/backward_compatibility_specs/compiler_spec.rb b/spec/backward_compatibility_specs/compiler_spec.rb index bfdb931aa..9bdd98dce 100644 --- a/spec/backward_compatibility_specs/compiler_spec.rb +++ b/spec/backward_compatibility_specs/compiler_spec.rb @@ -26,7 +26,7 @@ allow(Webpacker.compiler).to receive(:strategy).and_return(mocked_strategy) status = OpenStruct.new(success?: true) - allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status]) + allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status]) expect(Webpacker.compiler.compile).to be true expect(mocked_strategy).to have_received(:after_compile_hook) @@ -40,7 +40,7 @@ allow(Webpacker.compiler).to receive(:strategy).and_return(mocked_strategy) status = OpenStruct.new(success?: false) - allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status]) + allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status]) expect(Webpacker.compiler.compile).to be false expect(mocked_strategy).to have_received(:after_compile_hook) diff --git a/spec/backward_compatibility_specs/configuration_spec.rb b/spec/backward_compatibility_specs/configuration_spec.rb index ebfacff66..f4faa001e 100644 --- a/spec/backward_compatibility_specs/configuration_spec.rb +++ b/spec/backward_compatibility_specs/configuration_spec.rb @@ -56,7 +56,7 @@ expect(config.cache_manifest?).to be true end - it "returns false in developemnt environemnt" do + it "returns false in development environment" do with_rails_env("development") do expect(Webpacker.config.cache_manifest?).to be false end @@ -74,13 +74,13 @@ expect(config.compile?).to be false end - it "returns true in developemnt environemnt" do + it "returns true in development environment" do with_rails_env("development") do expect(Webpacker.config.compile?).to be true end end - it "returns true in test environemnt" do + it "returns true in test environment" do with_rails_env("test") do expect(Webpacker.config.compile?).to be true end @@ -190,7 +190,7 @@ end end - context "with webpacker config file containing manifext_path entry" do + context "with webpacker config file containing manifest_path entry" do config = Webpacker::Configuration.new( root_path: ROOT_PATH, config_path: Pathname.new(File.expand_path("./webpacker_test_app/config/webpacker_manifest_path.yml", __dir__)), diff --git a/spec/generator_specs/generator_spec.rb b/spec/generator_specs/generator_spec.rb index 99a78adaf..4ed038160 100644 --- a/spec/generator_specs/generator_spec.rb +++ b/spec/generator_specs/generator_spec.rb @@ -65,8 +65,8 @@ ] Dir.chdir(path_in_the_app("config/webpack")) do - exisiting_files_in_config_webpack_dir = Dir.glob("*") - expect(exisiting_files_in_config_webpack_dir).to eq expected_files + existing_files_in_config_webpack_dir = Dir.glob("*") + expect(existing_files_in_config_webpack_dir).to eq expected_files end end @@ -94,12 +94,12 @@ expect(actual_content).to match '<%= javascript_pack_tag "application" %>' end - it "updates `bin/setup" do + it "updates `bin/setup`" do setup_file_content = read(path_in_the_app("bin/setup")) expect(setup_file_content).to match %r(^\s*system!\(['"]bin/yarn['"]\)) end - it "adds relevant shakapacker version in package.json depending on gem version," do + it "adds relevant shakapacker version in package.json depending on gem version" do npm_version = Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(Shakapacker::VERSION) actual_content = read(path_in_the_app("package.json")) diff --git a/spec/shakapacker/compiler_spec.rb b/spec/shakapacker/compiler_spec.rb index 12a57973d..e81888e3b 100644 --- a/spec/shakapacker/compiler_spec.rb +++ b/spec/shakapacker/compiler_spec.rb @@ -26,7 +26,7 @@ allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy) status = OpenStruct.new(success?: true) - allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status]) + allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status]) expect(Shakapacker.compiler.compile).to be true expect(mocked_strategy).to have_received(:after_compile_hook) @@ -40,7 +40,7 @@ allow(Shakapacker.compiler).to receive(:strategy).and_return(mocked_strategy) status = OpenStruct.new(success?: false) - allow(Open3).to receive(:capture3).and_return([:sterr, :stdout, status]) + allow(Open3).to receive(:capture3).and_return([:stderr, :stdout, status]) expect(Shakapacker.compiler.compile).to be false expect(mocked_strategy).to have_received(:after_compile_hook) diff --git a/spec/shakapacker/configuration_spec.rb b/spec/shakapacker/configuration_spec.rb index 1483266ad..a2abfe13a 100644 --- a/spec/shakapacker/configuration_spec.rb +++ b/spec/shakapacker/configuration_spec.rb @@ -56,7 +56,7 @@ expect(config.cache_manifest?).to be true end - it "returns false in developemnt environemnt" do + it "returns false in development environment" do with_rails_env("development") do expect(Shakapacker.config.cache_manifest?).to be false end @@ -74,13 +74,13 @@ expect(config.compile?).to be false end - it "returns true in developemnt environemnt" do + it "returns true in development environment" do with_rails_env("development") do expect(Shakapacker.config.compile?).to be true end end - it "returns true in test environemnt" do + it "returns true in test environment" do with_rails_env("test") do expect(Shakapacker.config.compile?).to be true end @@ -189,7 +189,7 @@ end end - context "with shakapacker config file containing manifext_path entry" do + context "with shakapacker config file containing manifest_path entry" do config = Shakapacker::Configuration.new( root_path: ROOT_PATH, config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker_manifest_path.yml", __dir__)), diff --git a/spec/shakapacker/rake_tasks_spec.rb b/spec/shakapacker/rake_tasks_spec.rb index 7b78ff983..22f11eef3 100644 --- a/spec/shakapacker/rake_tasks_spec.rb +++ b/spec/shakapacker/rake_tasks_spec.rb @@ -44,7 +44,7 @@ def with_temporary_file(file_name, &block) Dir.chdir(TEST_APP_PATH) end - context "with existing `./bin/shapapacker` and `./bin/shapapacker-dev-server`" do + context "with existing `./bin/shakapacker` and `./bin/shakapacker-dev-server`" do it "passes" do expect { system("bundle exec rake shakapacker:check_binstubs") }.to output("").to_stdout_from_any_process end diff --git a/spec/shakapacker/version_checker_spec.rb b/spec/shakapacker/version_checker_spec.rb index 9bfb8c44c..96ad599a5 100644 --- a/spec/shakapacker/version_checker_spec.rb +++ b/spec/shakapacker/version_checker_spec.rb @@ -451,19 +451,19 @@ def node_package_version(fixture_version:) context "from exact semantic version" do let(:node_package_version_from_semver_exact) { node_package_version(fixture_version: "semver_exact") } - it "#raw retruns version" do + it "#raw returns version" do expect(node_package_version_from_semver_exact.raw).to eq "6.0.0" end - it "#major_minor_patch retruns version array" do + it "#major_minor_patch returns version array" do expect(node_package_version_from_semver_exact.major_minor_patch).to eq ["6", "0", "0"] end - it "#skip_processing? retruns false" do + it "#skip_processing? returns false" do expect(node_package_version_from_semver_exact.skip_processing?).to be false end - it "#semver_wildcard? retruns false" do + it "#semver_wildcard? returns false" do expect(node_package_version_from_semver_exact.semver_wildcard?).to be false end end