Skip to content

Commit e8927e0

Browse files
authored
Wrap up version 7 changes (shakacode#301)
* Improve contributing guideline * Rename webpacker to shakapcker spec * Rename backward compatiblity specs to follow rspec naming convention * Use Thor for printing colorful warning * Set CIs to run only with push * Rename doc file for developing the gem * Remove Rails 5 from CI * Remove node 12 and add 18 in CI * Improve readability of compile task * Move test_app into gem spec directory * Update contributing docs related to help wanted issues * Reorganize Changelog * Improve PR template
1 parent 83c42e8 commit e8927e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+103
-101
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
### Summary
22

3-
_Remove this paragraph and provide a general description of the code changes in your pull
4-
request... were there any bugs you had fixed? If so, mention them. If
5-
these bugs have open GitHub issues, be sure to tag them here as well,
6-
to keep the conversation linked together._
3+
_Remove this paragraph and describe the code changes in your pull request... were there any bugs you had fixed? If so, mention them. If these bugs have open GitHub issues, tag them here as well to keep the conversation linked._
74

85
### Pull Request checklist
9-
_Remove this line after checking all the items here. If the item is not applicable to the PR, both check it out and wrap it by `~`._
6+
_Remove this line after checking all the items here. If the item does not apply to the PR, both check it out and wrap it by `~`._
107

118
- [ ] Add/update test to cover these changes
129
- [ ] Update documentation
13-
- [ ] Update CHANGELOG file
14-
_Add the CHANGELOG entry at the top of the file._
10+
- [ ] Update CHANGELOG file
1511

1612
### Other Information
1713

18-
_Remove this parapraph and mention any other important and relevant information such as benchmarks._
14+
_Remove this paragraph and mention other important and relevant information, such as benchmarks._

.github/workflows/dummy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Dummy specs
22

3-
on: [pull_request]
3+
on: [push]
44

55
jobs:
66
test:

.github/workflows/jest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Jest specs
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
jest:
77
name: Jest specs
88
strategy:
99
matrix:
1010
os: [ubuntu-latest]
11-
node: [12.x, 14.x, 16.x]
11+
node: [14.x, 16.x, 18.x]
1212

1313
runs-on: ${{ matrix.os }}
1414

.github/workflows/js-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: JS lint
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
lint:
77
name: JS Lint
88
strategy:
99
matrix:
1010
os: [ubuntu-latest]
11-
node: [12.x, 14.x, 16.x]
11+
node: [14.x, 16.x, 18.x]
1212

1313
runs-on: ${{ matrix.os }}
1414

.github/workflows/rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Rubocop
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
rubocop:

.github/workflows/ruby-backward-compatibility.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Ruby specs - Backward compatibility
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
test:
@@ -11,7 +11,6 @@ jobs:
1111
os: [ubuntu-latest]
1212
ruby: ['2.6', '2.7', '3.0']
1313
gemfile:
14-
- gemfiles/Gemfile-rails.5.2.x
1514
- gemfiles/Gemfile-rails.6.0.x
1615
- gemfiles/Gemfile-rails.6.1.x
1716
- gemfiles/Gemfile-rails.7.0.x
@@ -25,9 +24,6 @@ jobs:
2524
- ruby: 2.6
2625
os: ubuntu-latest
2726
gemfile: gemfiles/Gemfile-rails-edge
28-
- ruby: 3.0
29-
os: ubuntu-latest
30-
gemfile: gemfiles/Gemfile-rails.5.2.x
3127

3228
env:
3329
BUNDLE_GEMFILE: ${{ matrix.gemfile }}

.github/workflows/ruby.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Ruby specs
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
test:
@@ -11,7 +11,6 @@ jobs:
1111
os: [ubuntu-latest]
1212
ruby: ['2.6', '2.7', '3.0']
1313
gemfile:
14-
- gemfiles/Gemfile-rails.5.2.x
1514
- gemfiles/Gemfile-rails.6.0.x
1615
- gemfiles/Gemfile-rails.6.1.x
1716
- gemfiles/Gemfile-rails.7.0.x
@@ -25,9 +24,6 @@ jobs:
2524
- ruby: 2.6
2625
os: ubuntu-latest
2726
gemfile: gemfiles/Gemfile-rails-edge
28-
- ruby: 3.0
29-
os: ubuntu-latest
30-
gemfile: gemfiles/Gemfile-rails.5.2.x
3127

3228
env:
3329
BUNDLE_GEMFILE: ${{ matrix.gemfile }}

CHANGELOG.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
Changes since last non-beta release.
99

1010
_Please add entries here for your pull requests that are not yet released._
11-
### Improved
12-
- Set CSS modules mode depending on file type. [PR 261](https://github.com/shakacode/shakapacker/pull/261) by [talyuk](https://github.com/talyuk).
1311

1412
### Breaking changes
1513
- Removes defaults passed to `@babel/preset-typescript`. [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
@@ -18,45 +16,42 @@ _Please add entries here for your pull requests that are not yet released._
1816

1917
- Export immutable webpackConfig function. [PR 293](https://github.com/shakacode/shakapacker/pull/293) by [tomdracz](https://github.com/tomdracz).
2018

21-
The `webpackConfig` property in the `shakapacker` module has been updated to be a function instead of a global mutable webpack configuration. This function now returns an immutable webpack configuration object, which ensures that any modifications made to it will not affect any other usage of the webpack configuration. If a project still requires the old mutable object, it can be accessed by replacing `webpackConfig` with `globalMutableWebpackConfig`.
19+
The `webpackConfig` property in the `shakapacker` module has been updated to be a function instead of a global mutable webpack configuration. This function now returns an immutable webpack configuration object, which ensures that any modifications made to it will not affect any other usage of the webpack configuration. If a project still requires the old mutable object, it can be accessed by replacing `webpackConfig` with `globalMutableWebpackConfig`. Check [v7-upgrade](https://github.com/shakacode/shakapacker/blob/master/docs/v7_upgrade.md) documentation for more detail.
2220

23-
### Improved
24-
- Move compilation lock file into the working directory. [PR 272](https://github.com/shakacode/shakapacker/pull/272) by [tomdracz](https://github.com/tomdracz).
21+
### Added
22+
- Set CSS modules mode depending on file type. [PR 261](https://github.com/shakacode/shakapacker/pull/261) by [talyuk](https://github.com/talyuk).
23+
- All standard webpack entries with the camelCase format are now supported in `shakapacker.yml` in snake_case format. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha).
24+
- The `shakapacker:install` rake task now has an option to force overriding files using `FORCE=true` environment variable [PR311](https://github.com/shakacode/shakapacker/pull/311) by [ahangarha](https://github.com/ahangarha).
2525

2626
### Changed
2727
- Rename Webpacker to Shakapacker in the entire project including config files, binstubs, environment variables, etc. with a high degree of backward compatibility.
2828

2929
This change might be breaking for certain setups and edge cases. More information: [v7 Upgrade Guide](./docs/v7_upgrade.md) [PR157](https://github.com/shakacode/shakapacker/pull/157) by [ahangarha](https://github.com/ahangarha)
30-
- Set `source_entry_path` to `packs` and `nested_entries` to `true` in`shakapacker.yml` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
31-
32-
### Fixed
33-
- Process `source_entry_path` with values starting with `/` as a relative path to `source_path` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
3430

31+
- Set `source_entry_path` to `packs` and `nested_entries` to `true` in`shakapacker.yml` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
3532
- Dev server configuration is modified to follow [webpack recommended configurations](https://webpack.js.org/configuration/dev-server/) for dev server. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha):
36-
- Deprecated `https` entry is removed from the default configuration file, allowing to set `server` or `https` as per the project requirements. For more detail, check Webpack documentation. The `https` entry can be effective only if there is no `server` entry in the config file.
33+
- Deprecated `https` entry is removed from the default configuration file, allowing to set `server` or `https` as per the project requirements. For more detail, check webpack documentation. The `https` entry can be effective only if there is no `server` entry in the config file.
3734
- `allowed_hosts` is now set to `auto` instead of `all` by default.
3835

39-
- Removes defaults passed to `@babel/preset-typescript`. [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
40-
41-
`@babel/preset-typescript` has been initialised in default configuration with `{ allExtensions: true, isTSX: true }` - meaning every file in the codebase was treated as TSX leading to potential issues. This has been removed and returns to sensible default of the preset which is to figure out the file type from the extensions. This change might affect generated output however so it is marked as breaking.
42-
4336
- Remove the arbitrary stripping of the top-level directory when generating static file paths. [PR 283](https://github.com/shakacode/shakapacker/pull/283) by [tomdracz](https://github.com/tomdracz).
4437

4538
Prior to this change, top level directory of static assets like images and fonts was stripped. This meant that file in `app/javascript/images/image.png` would be output to `static/image.png` directory and could be referenced through helpers as `image_pack_tag("image.jpg")` or `image_pack_tag("static/image.jpg")`.
4639

4740
Going forward, the top level directory of static files will be retained so this will necessitate the update of file name references in asset helpers. In the example above, the file sourced from `app/javascript/images/image.png` will be now output to `static/images/image.png` and needs to be referenced as `image_pack_tag("images/image.jpg")` or `image_pack_tag("static/images/image.jpg")`.
4841

42+
### Fixed
43+
- Move compilation lock file into the working directory. [PR 272](https://github.com/shakacode/shakapacker/pull/272) by [tomdracz](https://github.com/tomdracz).
44+
- Process `source_entry_path` with values starting with `/` as a relative path to `source_path` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
45+
- Removes defaults passed to `@babel/preset-typescript` to make it possible to have projects with mix of JS and TS code [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
46+
47+
`@babel/preset-typescript` has been initialised in default configuration with `{ allExtensions: true, isTSX: true }` - meaning every file in the codebase was treated as TSX leading to potential issues. This has been removed and returns to sensible default of the preset which is to figure out the file type from the extensions. This change might affect generated output however so it is marked as breaking.
48+
4949
- Fixed RC version detection during installation. [PR312](https://github.com/shakacode/shakapacker/pull/312) by [ahangarha](https://github.com/ahangarha)
5050
- Fix addition of webpack-dev-server to devDependencies during installation. [PR310](https://github.com/shakacode/shakapacker/pull/310) by [ahangarha](https://github.com/ahangarha)
51-
5251
### Removed
5352
- Remove redundant enhancement for precompile task to run `yarn install` [PR 270](https://github.com/shakacode/shakapacker/pull/270) by [ahangarha](https://github.com/ahangarha).
5453
- Remove deprecated `check_yarn_integrity` from `Shakapacker::Configuration` [PR SP288](https://github.com/shakacode/shakapacker/pull/288) by [ahangarha](https://github.com/ahangarha).
5554

56-
### Added
57-
- All standard Webpack entries with the camelCase format are now supported in `shakapacker.yml` in snake_case format. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha).
58-
- The `shakapacker:install` rake task now has an option to force overriding files using `FORCE=true` environment variable [PR311](https://github.com/shakacode/shakapacker/pull/311) by [ahangarha](https://github.com/ahangarha).
59-
6055
## [v6.6.0] - March 7, 2023
6156
### Improved
6257
- Allow configuration of webpacker.yml through env variable. [PR 254](https://github.com/shakacode/shakapacker/pull/254) by [alecslupu](https://github.com/alecslupu).

CONTRIBUTING.md

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,60 @@
1+
# Contributing Guidelines
2+
3+
Thank you for your interest in contributing to Shakapacker! We welcome all contributions that align with our project goals and values. To ensure a smooth and productive collaboration, please follow these guidelines.
4+
15
## Contents
6+
- [Reporting Issues](#reporting-issues)
7+
- [Submitting Pull Requests](#submitting-pull-requests)
28
- [Setting Up a Development Environment](#setting-up-a-development-environment)
39
- [Making sure your changes pass all tests](#making-sure-your-changes-pass-all-tests)
410
- [Testing the generator](#testing-the-generator)
5-
- [Find existing issues](#find-existing-issues)
611

7-
---
8-
## Setting Up a Development Environment
12+
## Reporting Issues
13+
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).
914

10-
1. Install [Yarn](https://yarnpkg.com/)
15+
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.
1116

12-
2. Run the following commands to set up the development environment.
17+
## Submitting Pull Requests
18+
We welcome pull requests that fix bugs, add new features, or improve existing ones. Before submitting a pull request, please make sure to:
1319

14-
```
15-
bundle install
16-
yarn
17-
```
20+
- Open an issue about what you want to propose before start working on.
21+
- Fork the repository and create a new branch for your changes.
22+
- Write clear and concise commit messages.
23+
- Follow our code style guidelines.
24+
- Write tests for your changes and [make sure all tests pass](#making-sure-your-changes-pass-all-tests).
25+
- Update the documentation as needed.
26+
- Update CHANGELOG.md if the changes affect public behavior of the project.
27+
28+
---
29+
## Setting Up a Development Environment
30+
31+
1. Install [Yarn](https://classic.yarnpkg.com/)
32+
2. To test your changes on a Rails test project do the following steps:
33+
- For Ruby gem, update `Gemfile` and point the `shakapacker` to the locally developing Shakapacker project:
34+
```ruby
35+
gem 'shakapacker', path: "relative_or_absolute_path_to_local_shakapacker"
36+
```
37+
- For npm package, use `yalc` with following steps:
38+
```bash
39+
# In Shakapacker root directory
40+
yalc publish
41+
# In Rails app for testing
42+
yalc link shakapacker
43+
44+
# After every chagnes in shakapacker, run the folloing in Shakapacker directory
45+
yalc push # or yalc publish --push
46+
```
47+
3. Run the following commands to set up the development environment.
48+
```
49+
bundle install
50+
yarn install
51+
```
1852
1953
## Making sure your changes pass all tests
2054
21-
There are a number of automated checks which run on GitHub Actions when a pull request is created.
55+
There are several specs, covering different aspects of Shakapacker gem. You may run them locally or rely on GitHub CI actions configured to test the gem functionality if different Ruby, Rails, and Node environment.
2256
23-
You can run those checks on your own locally to make sure that your changes would not break the CI build.
57+
We request running tests locally to ensure the new changes would not break the CI build.
2458
2559
### 1. Check the code for JavaScript style violations
2660
@@ -46,6 +80,8 @@ yarn test
4680
bundle exec rake test
4781
```
4882
83+
Note: For this, you need `yalc` to be installed on your local machine
84+
4985
#### 4.1 Run a single ruby test file
5086
5187
```
@@ -90,5 +126,3 @@ To ensure that your installer works as expected, either you can run `bundle exec
90126

91127
**Note:** Ensure that you use bundle exec otherwise the installed shakapacker gem will run and not the one you are working on.
92128

93-
## Find existing issues
94-
You may look at the issues list to find existing known issues to be addressed. In this, we recommend looking at closed issues, particularly with the "[help wanted](https://github.com/shakacode/shakapacker/issues?q=is%3Aissue+label%3A%22help+wanted%22+is%3Aclosed+)" label.

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace :run_spec do
1717
desc "Run backward compatibility specs"
1818
task :gem_bc do
1919
puts "Running Shakapacker gem specs for backward compatibility"
20-
sh("bundle exec rspec spec/backward_compatibility_specs/*_spec_bc.rb")
20+
sh("bundle exec rspec spec/backward_compatibility_specs/*_spec.rb")
2121
end
2222

2323
desc "Run specs in the dummy app"
File renamed without changes.

gemfiles/Gemfile-rails.5.2.x

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/shakapacker/deprecation_helper.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require "thor"
2+
13
module Shakapacker
24
DEPRECATION_GUIDE_URL = "https://github.com/shakacode/shakapacker/docs/v7_upgrade.md"
35
DEPRECATION_MESSAGE = <<~MSG
@@ -9,6 +11,7 @@ module Shakapacker
911
For more information about this process, check:
1012
#{DEPRECATION_GUIDE_URL}
1113
MSG
14+
SHELL = Thor::Shell::Color.new
1215

1316
def get_config_file_path_with_backward_compatibility(config_path)
1417
if config_path.to_s.end_with?("shakapacker.yml") && !File.exist?(config_path)
@@ -70,11 +73,7 @@ def short_deprecation_message(old_usage, new_usage)
7073
end
7174

7275
def puts_deprecation_message(message)
73-
puts <<~MSG
74-
\e[33m
75-
#{message}
76-
\e[0m
77-
MSG
76+
SHELL.say "\n#{message}\n", :yellow
7877
end
7978

8079
def puts_rake_deprecation_message(webpacker_task_name)

lib/tasks/shakapacker/compile.rake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ namespace :shakapacker do
55
task compile: ["shakapacker:verify_install", :environment] do
66
Shakapacker.with_node_env(ENV.fetch("NODE_ENV", "production")) do
77
Shakapacker.ensure_log_goes_to_stdout do
8-
if Shakapacker.compile
9-
# Successful compilation!
10-
else
11-
# Failed compilation
12-
exit!
13-
end
8+
exit! unless Shakapacker.compile
149
end
1510
end
1611
end

package/utils/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const isArray = (value) => Array.isArray(value)
22
const isBoolean = (str) => /^true/.test(str) || /^false/.test(str)
33
const chdirTestApp = () => {
44
try {
5-
return process.chdir('spec/test_app')
5+
return process.chdir('spec/shakapacker/test_app')
66
} catch (e) {
77
return null
88
}

0 commit comments

Comments
 (0)