shakapacker 9.6.0.beta.0 â 9.6.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/claude-code-review.yml +21 -20
- data/.github/workflows/claude.yml +5 -0
- data/CHANGELOG.md +38 -3
- data/CLAUDE.md +8 -0
- data/README.md +1 -1
- data/docs/configuration.md +5 -3
- data/docs/precompile_hook.md +7 -7
- data/docs/releasing.md +100 -21
- data/eslint.config.js +1 -0
- data/lib/install/binstubs.rb +6 -2
- data/lib/install/config/shakapacker.yml +4 -2
- data/lib/install/template.rb +30 -22
- data/lib/shakapacker/env.rb +4 -2
- data/lib/shakapacker/install/env.rb +33 -0
- data/lib/shakapacker/manifest.rb +81 -20
- data/lib/shakapacker/runner.rb +42 -23
- data/lib/shakapacker/version.rb +1 -1
- data/package/environments/base.ts +4 -0
- data/package/index.d.ts +21 -0
- data/package/index.d.ts.template +21 -0
- data/package/index.ts +26 -0
- data/package/plugins/webpack.ts +5 -0
- data/package/rspack/index.ts +19 -1
- data/package/rules/file.ts +1 -1
- data/package/types/index.ts +8 -0
- data/package/utils/bundlerUtils.ts +232 -0
- data/package/utils/ensureManifestExists.ts +17 -0
- data/package.json +2 -2
- data/sig/shakapacker/manifest.rbs +15 -1
- data/test/package/bundlerUtils.rspack.test.js +102 -0
- data/test/package/bundlerUtils.test.js +97 -0
- data/test/package/environments/base.test.js +3 -0
- data/test/package/rspack/index.test.js +251 -0
- data/test/package/rspack/optimization.test.js +86 -0
- data/test/package/rspack/plugins.test.js +185 -0
- data/test/package/rspack/rules.test.js +229 -0
- data/test/package/rules/file.test.js +1 -1
- data/test/package/utils/ensureManifestExists.test.js +51 -0
- data/test/resolver.js +34 -3
- metadata +19 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68ba8fdde7f793bee53354a639cf21695963ff564e3478de1e19711f9e71704d
|
|
4
|
+
data.tar.gz: f5baa408e07f17e89cb0ba19abe652a4eeba151400b5014b4381156221e25811
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3845c0fd8e02339a077dd2a385bc2ed32905e62f56f786177c5761ddca3fab1b521bb92aeb1469458657cb139273137079a33e1ebbffba9574cf1e192e56fac2
|
|
7
|
+
data.tar.gz: 81d6113206160b9184bc1a0016cbe52d0c0ee565cd951da3b613ae99dd58ea83279d6ee60bfa6be8f14a2d524900941ed7568c8169ba2d855a9734c856260cc3
|
|
@@ -3,31 +3,20 @@ name: Claude Code Review
|
|
|
3
3
|
on:
|
|
4
4
|
pull_request:
|
|
5
5
|
types: [opened, synchronize, ready_for_review, reopened]
|
|
6
|
-
# Optional: Only run on specific file changes
|
|
7
|
-
# paths:
|
|
8
|
-
# - "src/**/*.ts"
|
|
9
|
-
# - "src/**/*.tsx"
|
|
10
|
-
# - "src/**/*.js"
|
|
11
|
-
# - "src/**/*.jsx"
|
|
12
6
|
|
|
13
7
|
jobs:
|
|
14
8
|
claude-review:
|
|
15
|
-
|
|
16
|
-
# if: |
|
|
17
|
-
# github.event.pull_request.user.login == 'external-contributor' ||
|
|
18
|
-
# github.event.pull_request.user.login == 'new-developer' ||
|
|
19
|
-
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
|
|
20
|
-
|
|
9
|
+
if: github.event.pull_request.head.repo.full_name == github.repository
|
|
21
10
|
runs-on: ubuntu-latest
|
|
22
11
|
permissions:
|
|
23
12
|
contents: read
|
|
24
|
-
pull-requests:
|
|
25
|
-
issues:
|
|
13
|
+
pull-requests: write
|
|
14
|
+
issues: write
|
|
26
15
|
id-token: write
|
|
27
16
|
|
|
28
17
|
steps:
|
|
29
18
|
- name: Checkout repository
|
|
30
|
-
uses: actions/checkout@
|
|
19
|
+
uses: actions/checkout@v6
|
|
31
20
|
with:
|
|
32
21
|
fetch-depth: 1
|
|
33
22
|
|
|
@@ -36,9 +25,21 @@ jobs:
|
|
|
36
25
|
uses: anthropics/claude-code-action@v1
|
|
37
26
|
with:
|
|
38
27
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
prompt: |
|
|
29
|
+
REPO: ${{ github.repository }}
|
|
30
|
+
PR NUMBER: ${{ github.event.pull_request.number }}
|
|
31
|
+
|
|
32
|
+
Please review this pull request with a focus on:
|
|
33
|
+
- Code quality and best practices
|
|
34
|
+
- Potential bugs or issues
|
|
35
|
+
- Security implications
|
|
36
|
+
- Performance considerations
|
|
37
|
+
|
|
38
|
+
Note: The PR branch is already checked out in the current working directory.
|
|
39
|
+
|
|
40
|
+
Use `gh pr comment` for top-level feedback.
|
|
41
|
+
Use `mcp__github_inline_comment__create_inline_comment` to highlight specific code issues.
|
|
42
|
+
Only post GitHub comments - don't submit review text as messages.
|
|
44
43
|
|
|
44
|
+
claude_args: |
|
|
45
|
+
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"
|
|
@@ -24,6 +24,8 @@ jobs:
|
|
|
24
24
|
issues: read
|
|
25
25
|
id-token: write
|
|
26
26
|
actions: read # Required for Claude to read CI results on PRs
|
|
27
|
+
checks: read
|
|
28
|
+
statuses: read
|
|
27
29
|
steps:
|
|
28
30
|
- name: Checkout repository
|
|
29
31
|
uses: actions/checkout@v4
|
|
@@ -34,11 +36,14 @@ jobs:
|
|
|
34
36
|
id: claude
|
|
35
37
|
uses: anthropics/claude-code-action@v1
|
|
36
38
|
with:
|
|
39
|
+
github_token: ${{ github.token }}
|
|
37
40
|
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
38
41
|
|
|
39
42
|
# This is an optional setting that allows Claude to read CI results on PRs
|
|
40
43
|
additional_permissions: |
|
|
41
44
|
actions: read
|
|
45
|
+
checks: read
|
|
46
|
+
statuses: read
|
|
42
47
|
|
|
43
48
|
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
|
|
44
49
|
# prompt: 'Update the pull request description to include a summary of changes.'
|
data/CHANGELOG.md
CHANGED
|
@@ -11,8 +11,34 @@
|
|
|
11
11
|
|
|
12
12
|
Changes since the last non-beta release.
|
|
13
13
|
|
|
14
|
+
## [v9.6.0-rc.0] - March 5, 2026
|
|
15
|
+
|
|
16
|
+
### Security
|
|
17
|
+
|
|
18
|
+
- Removed default `Access-Control-Allow-Origin: *` header from dev server configuration. This header allowed any website to access dev server resources. **If your setup runs webpack-dev-server on a different port from your Rails server, uncomment the `headers` section in `config/shakapacker.yml` to restore cross-origin asset loading.** [PR #936](https://github.com/shakacode/shakapacker/pull/936) by [justin808](https://github.com/justin808). Fixes [#935](https://github.com/shakacode/shakapacker/issues/935).
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- **Added `SKIP=true` installer mode to preserve existing files**. [PR #926](https://github.com/shakacode/shakapacker/pull/926) by [justin808](https://github.com/justin808). Running `rails shakapacker:install SKIP=true` now skips conflicting files instead of overwriting them. This is useful for CI/CD pipelines and automated setups where you want to install only missing files without touching existing configuration.
|
|
23
|
+
- **Export bundler utility functions for Webpack/Rspack compatibility**. [PR #922](https://github.com/shakacode/shakapacker/pull/922) by [justin808](https://github.com/justin808). New utility functions that make it easier to write bundler-agnostic configuration code: `isRspack`, `isWebpack`, `getBundler()`, `getCssExtractPlugin()`, `getCssExtractPluginLoader()`, `getDefinePlugin()`, `getEnvironmentPlugin()`, and `getProvidePlugin()`. Users no longer need to write conditional logic to handle differences between Webpack and Rspack.
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
// Before: manual conditional logic
|
|
27
|
+
const { config } = require("shakapacker")
|
|
28
|
+
const CssPlugin =
|
|
29
|
+
config.assets_bundler === "rspack"
|
|
30
|
+
? require("@rspack/core").CssExtractRspackPlugin
|
|
31
|
+
: require("mini-css-extract-plugin")
|
|
32
|
+
|
|
33
|
+
// After: use bundler utilities
|
|
34
|
+
const { getCssExtractPlugin } = require("shakapacker")
|
|
35
|
+
const CssPlugin = getCssExtractPlugin()
|
|
36
|
+
```
|
|
37
|
+
|
|
14
38
|
### Changed
|
|
15
39
|
|
|
40
|
+
- **Changed default file rule type from `asset/resource` to `asset`**. [PR #901](https://github.com/shakacode/shakapacker/pull/901) by [justin808](https://github.com/justin808). Static assets (images, fonts, SVGs) now use webpack/rspack's `asset` type instead of `asset/resource`, allowing the bundler to automatically inline small files as data URIs for better performance.
|
|
41
|
+
- Allow `compression-webpack-plugin` v12. [PR #937](https://github.com/shakacode/shakapacker/pull/937) by [G-Rath](https://github.com/G-Rath).
|
|
16
42
|
- **BREAKING: sass-loader now defaults to modern Sass API**. [PR #879](https://github.com/shakacode/shakapacker/pull/879) by [justin808](https://github.com/justin808). The sass-loader configuration now uses `api: "modern"` instead of the deprecated legacy API. This improves compatibility with plugins like sass-resources-loader that require the modern API. If you experience issues after upgrading, you can revert to the legacy API by customizing your webpack config:
|
|
17
43
|
|
|
18
44
|
```javascript
|
|
@@ -36,9 +62,17 @@ Changes since the last non-beta release.
|
|
|
36
62
|
|
|
37
63
|
### Fixed
|
|
38
64
|
|
|
65
|
+
- **Fixed hidden dotfiles and dot-directories being treated as entrypoints**. [PR #915](https://github.com/shakacode/shakapacker/pull/915) by [justin808](https://github.com/justin808). Entry discovery now ignores files and directories whose names start with `.` when traversing `source_entry_path`, preventing unintended bundles from being created. Closes [#853](https://github.com/shakacode/shakapacker/issues/853).
|
|
39
66
|
- **Fixed orphaned webpack/rspack processes when foreman receives SIGTERM**. [PR #888](https://github.com/shakacode/shakapacker/pull/888) by [jordan-brough](https://github.com/jordan-brough). When running under foreman, sending SIGTERM to foreman (e.g. `kill <pid>`) would kill the Ruby shakapacker process but leave the webpack/rspack child process running as an orphan. DevServerRunner now uses `exec` to replace the Ruby process entirely, and Runner uses `spawn` with SIGTERM forwarding to ensure the child process is properly terminated.
|
|
67
|
+
- **Fixed missing-environment fallback to use production instead of development**. [PR #894](https://github.com/shakacode/shakapacker/pull/894) by [justin808](https://github.com/justin808). When a Rails environment (e.g., staging) is not defined in `shakapacker.yml`, Shakapacker now falls back to the `production` configuration instead of `development`. This ensures unknown environments get production-optimized webpack/rspack builds by default.
|
|
40
68
|
- **Fixed installer writing wrong shakapacker version in package.json**. [PR #899](https://github.com/shakacode/shakapacker/pull/899) by [justin808](https://github.com/justin808). The `shakapacker:install` generator now keeps the `package.json` dependency value in sync with the exact version or path that was requested, instead of relying on the post-install value which could differ.
|
|
69
|
+
- **Fixed `privateOutputPath` not being computed in JavaScript config**. [PR #891](https://github.com/shakacode/shakapacker/pull/891) by [ihabadham](https://github.com/ihabadham). The `private_output_path` setting from `shakapacker.yml` is now properly resolved to an absolute path and exposed as `privateOutputPath` in the JavaScript configuration, matching the behavior already present in the Ruby configuration.
|
|
70
|
+
- **Fixed installer not updating `shakapacker.yml` when selecting a non-default transpiler**. [PR #895](https://github.com/shakacode/shakapacker/pull/895) by [codex-rs](https://github.com/apps/codex-rs). Installing with `JAVASCRIPT_TRANSPILER=babel` (or `esbuild`) now correctly updates `config/shakapacker.yml` to match the selected transpiler instead of leaving it set to `swc`. Previously, a quote mismatch in the `gsub_file` call meant the config was never actually updated, and the condition also excluded `JAVASCRIPT_TRANSPILER=babel` from the update entirely. Additionally, `JAVASCRIPT_TRANSPILER=babel` no longer installs SWC packages.
|
|
71
|
+
- **Fixed ENOENT crash on clean builds when using `webpack-assets-manifest` v6 with `merge: true`**. [PR #931](https://github.com/shakacode/shakapacker/pull/931) by [justin808](https://github.com/justin808). Seeds an empty `{}` manifest file before instantiating the plugin, so the merge read succeeds on first build rather than throwing an unhandled ENOENT.
|
|
72
|
+
- **Improved error message when manifest is empty or missing**. [PR #872](https://github.com/shakacode/shakapacker/pull/872) by [justin808](https://github.com/justin808). When the bundler is still compiling (empty manifest) or hasn't run yet (missing manifest file), users now see clear, actionable error messages instead of the generic 7-point checklist.
|
|
41
73
|
- **Fixed NODE_ENV=test causing DefinePlugin warnings**. [PR #870](https://github.com/shakacode/shakapacker/pull/870) by [justin808](https://github.com/justin808). When RAILS_ENV=test, Shakapacker now sets NODE_ENV=development instead of NODE_ENV=test. This prevents webpack/rspack DefinePlugin conflicts since these bundlers only recognize "development" and "production" as valid NODE_ENV values.
|
|
74
|
+
- **Fixed `--json` flag output being corrupted by log messages**. [PR #869](https://github.com/shakacode/shakapacker/pull/869) by [justin808](https://github.com/justin808). When `--json` is in the command arguments, `[Shakapacker]` log messages are now written to stderr instead of stdout, keeping stdout clean for valid JSON output. This allows `bin/shakapacker --profile --json` to be piped to tools like `webpack-bundle-analyzer`. Normal (non-JSON) usage is unchanged. Resolves [#868](https://github.com/shakacode/shakapacker/issues/868).
|
|
75
|
+
- **Require explicit truthy values for `SKIP` and `FORCE` installer env vars**. [PR #926](https://github.com/shakacode/shakapacker/pull/926) by [justin808](https://github.com/justin808). Previously, any set value (including `"false"` or `"0"`) would activate skip/force mode. Now only explicit truthy values (`true`, `1`, `yes`, case-insensitive) are recognized. This behavior change may require CI/scripts that relied on `FORCE=<any non-empty value>` to switch to `FORCE=true`.
|
|
42
76
|
|
|
43
77
|
### Documentation
|
|
44
78
|
|
|
@@ -86,7 +120,7 @@ Changes since the last non-beta release.
|
|
|
86
120
|
|
|
87
121
|
- **Added `SHAKAPACKER_SKIP_PRECOMPILE_HOOK` environment variable to skip precompile hook**. [PR #850](https://github.com/shakacode/shakapacker/pull/850) by [justin808](https://github.com/justin808). Set `SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true` to skip the precompile hook during compilation. This is useful when using process managers like Foreman or Overmind to run the hook once before starting multiple webpack processes, preventing duplicate hook execution. **Migration tip:** If you have a custom `bin/dev` script that starts multiple webpack processes, you can now run the precompile hook once in the script and set this environment variable to prevent each webpack process from running the hook again. See the [precompile hook documentation](./docs/precompile_hook.md#skipping-the-hook) for implementation examples.
|
|
88
122
|
|
|
89
|
-
## [v9.3.4
|
|
123
|
+
## [v9.3.4] - November 17, 2025
|
|
90
124
|
|
|
91
125
|
### Fixed
|
|
92
126
|
|
|
@@ -834,10 +868,11 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
834
868
|
|
|
835
869
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
|
836
870
|
|
|
837
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.
|
|
871
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.6.0-rc.0...main
|
|
872
|
+
[v9.6.0-rc.0]: https://github.com/shakacode/shakapacker/compare/v9.5.0...v9.6.0-rc.0
|
|
838
873
|
[v9.5.0]: https://github.com/shakacode/shakapacker/compare/v9.4.0...v9.5.0
|
|
839
874
|
[v9.4.0]: https://github.com/shakacode/shakapacker/compare/v9.3.4...v9.4.0
|
|
840
|
-
[v9.3.4
|
|
875
|
+
[v9.3.4]: https://github.com/shakacode/shakapacker/compare/v9.3.3...v9.3.4
|
|
841
876
|
[v9.3.3]: https://github.com/shakacode/shakapacker/compare/v9.3.2...v9.3.3
|
|
842
877
|
[v9.3.2]: https://github.com/shakacode/shakapacker/compare/v9.3.1...v9.3.2
|
|
843
878
|
[v9.3.1]: https://github.com/shakacode/shakapacker/compare/v9.3.0...v9.3.1
|
data/CLAUDE.md
CHANGED
|
@@ -40,6 +40,14 @@
|
|
|
40
40
|
- **Version management**: Run `bundle exec rake update_changelog` after releases to update version headers
|
|
41
41
|
- **Examples**: Run `grep -A 3 "^### " CHANGELOG.md | head -30` to see real formatting examples
|
|
42
42
|
|
|
43
|
+
## Open Source Maintainability
|
|
44
|
+
|
|
45
|
+
- **Prefer removing complexity over adding configuration.** If a default causes problems, consider removing the default rather than adding an option to disable it.
|
|
46
|
+
- **Every config option is maintenance surface.** Prefer convention over configuration. Don't add options for <10% of users â let them customize via existing extension points (e.g., custom webpack config).
|
|
47
|
+
- **"No is temporary, yes is forever."** Adding a feature creates a permanent maintenance obligation. Reject features that solve one user's niche problem but add complexity for everyone.
|
|
48
|
+
- **Security-safe defaults over convenient defaults.** Don't ship permissive defaults (e.g., `Access-Control-Allow-Origin: *`) just for convenience â make users opt in to less-secure configurations.
|
|
49
|
+
- **Don't refactor adjacent code in feature PRs.** Keep PRs focused. If you spot something to clean up, do it in a separate PR.
|
|
50
|
+
|
|
43
51
|
## Shakapacker-Specific
|
|
44
52
|
|
|
45
53
|
- This gem supports both webpack and rspack configurations
|
data/README.md
CHANGED
|
@@ -166,7 +166,7 @@ Then run the following to install Shakapacker:
|
|
|
166
166
|
bundle exec rake shakapacker:install
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
Before initiating the installation process, ensure you have committed all
|
|
169
|
+
Before initiating the installation process, ensure you have committed all changes. During install, Shakapacker may encounter conflicts with existing files. You can approve prompts interactively, use `FORCE=true` to overwrite without prompting, or use `SKIP=true` to preserve existing files and only create missing ones. Accepted truthy values are `true`, `1`, and `yes` (case-insensitive). If both are set, `FORCE` takes precedence.
|
|
170
170
|
|
|
171
171
|
Shakapacker uses the [`package_json`](https://github.com/shakacode/package_json) gem to handle updating the `package.json` and interacting with the underlying package manager of choice for managing dependencies and running commands; the package manager is managed using the [`packageManager`](https://nodejs.org/api/packages.html#packagemanager) property in the `package.json`, otherwise falling back to the value of `PACKAGE_JSON_FALLBACK_MANAGER` if set or otherwise `npm`.
|
|
172
172
|
|
data/docs/configuration.md
CHANGED
|
@@ -362,9 +362,11 @@ dev_server:
|
|
|
362
362
|
# pathname: '/ws'
|
|
363
363
|
# port: 8080
|
|
364
364
|
|
|
365
|
-
#
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
# Custom headers for dev server responses
|
|
366
|
+
# Uncomment to enable CORS (e.g., when webpack-dev-server runs on a different
|
|
367
|
+
# port than your Rails server and the browser blocks cross-origin asset requests):
|
|
368
|
+
# headers:
|
|
369
|
+
# "Access-Control-Allow-Origin": "*"
|
|
368
370
|
|
|
369
371
|
# Static file serving
|
|
370
372
|
static:
|
data/docs/precompile_hook.md
CHANGED
|
@@ -35,13 +35,13 @@ before launching long-running processes instead of using `precompile_hook`.
|
|
|
35
35
|
|
|
36
36
|
### Comparison
|
|
37
37
|
|
|
38
|
-
| Aspect
|
|
39
|
-
|
|
40
|
-
| Best for
|
|
41
|
-
| Runs when
|
|
42
|
-
| Production integration
|
|
43
|
-
| Process manager complexity | Lower
|
|
44
|
-
| Debugging
|
|
38
|
+
| Aspect | `precompile_hook` | Explicit setup in `bin/dev` |
|
|
39
|
+
| -------------------------- | ------------------------------------- | --------------------------------------- |
|
|
40
|
+
| Best for | Default/consistent pre-build tasks | Custom multi-step dev boot flows |
|
|
41
|
+
| Runs when | Immediately before compilation starts | Wherever you place it in startup script |
|
|
42
|
+
| Production integration | Automatic via `assets:precompile` | Requires explicit production wiring |
|
|
43
|
+
| Process manager complexity | Lower | Higher (you own orchestration) |
|
|
44
|
+
| Debugging | Centralized hook command | Fully explicit command-by-command flow |
|
|
45
45
|
|
|
46
46
|
### `shakapacker_precompile` Interaction
|
|
47
47
|
|
data/docs/releasing.md
CHANGED
|
@@ -9,6 +9,7 @@ This guide is for Shakapacker maintainers who need to publish a new release.
|
|
|
9
9
|
```bash
|
|
10
10
|
bundle install # Installs gem-release
|
|
11
11
|
yarn global add release-it # Installs release-it for npm publishing
|
|
12
|
+
gh --version # Required only if you plan to run sync_github_release
|
|
12
13
|
```
|
|
13
14
|
|
|
14
15
|
2. **Ensure you have publishing access:**
|
|
@@ -18,6 +19,8 @@ This guide is for Shakapacker maintainers who need to publish a new release.
|
|
|
18
19
|
3. **Enable 2FA on both platforms:**
|
|
19
20
|
- npm: 2FA is required for publishing
|
|
20
21
|
- RubyGems: 2FA is required for publishing
|
|
22
|
+
4. **If you plan to run `sync_github_release`, authenticate GitHub CLI:**
|
|
23
|
+
- Run `gh auth login` and ensure your account/token has write access to this repository
|
|
21
24
|
|
|
22
25
|
## Release Process
|
|
23
26
|
|
|
@@ -26,9 +29,7 @@ This guide is for Shakapacker maintainers who need to publish a new release.
|
|
|
26
29
|
Before running the release task:
|
|
27
30
|
|
|
28
31
|
1. Ensure all desired changes are merged to `main` branch
|
|
29
|
-
2.
|
|
30
|
-
3. Commit the CHANGELOG changes
|
|
31
|
-
4. Ensure your working directory is clean (`git status` shows no uncommitted changes)
|
|
32
|
+
2. Ensure your working directory is clean (`git status` shows no uncommitted changes)
|
|
32
33
|
|
|
33
34
|
### 2. Run the Release Task
|
|
34
35
|
|
|
@@ -36,38 +37,89 @@ The automated release task handles the entire release process:
|
|
|
36
37
|
|
|
37
38
|
```bash
|
|
38
39
|
# For a specific version (e.g., 9.1.0)
|
|
39
|
-
bundle exec rake create_release[9.1.0]
|
|
40
|
+
bundle exec rake "create_release[9.1.0]"
|
|
40
41
|
|
|
41
42
|
# For a beta release (note: use period, not dash)
|
|
42
|
-
bundle exec rake create_release[9.2.0.beta.1] # Creates npm package 9.2.0-beta.1
|
|
43
|
+
bundle exec rake "create_release[9.2.0.beta.1]" # Creates npm package 9.2.0-beta.1
|
|
44
|
+
|
|
45
|
+
# For a release candidate
|
|
46
|
+
bundle exec rake "create_release[9.6.0.rc.0]"
|
|
47
|
+
|
|
48
|
+
# Auto-calculate next prerelease and confirm before publishing
|
|
49
|
+
bundle exec rake "create_prerelease[9.6.0]" # defaults to rc -> 9.6.0.rc.0 or 9.6.0.rc.1, etc.
|
|
50
|
+
bundle exec rake "create_prerelease[9.6.0,rc]" # -> 9.6.0.rc.0 or 9.6.0.rc.1, etc.
|
|
51
|
+
bundle exec rake "create_prerelease[9.6.0,beta]" # -> 9.6.0.beta.0 or 9.6.0.beta.1, etc.
|
|
43
52
|
|
|
44
53
|
# For a patch version bump (auto-increments)
|
|
45
|
-
bundle exec rake create_release
|
|
54
|
+
bundle exec rake create_release # prompts to confirm computed patch version
|
|
46
55
|
|
|
47
56
|
# Dry run to test without publishing
|
|
48
|
-
bundle exec rake create_release[9.1.0,true]
|
|
57
|
+
bundle exec rake "create_release[9.1.0,true]"
|
|
58
|
+
|
|
59
|
+
# Override version policy checks (monotonic + changelog/bump consistency)
|
|
60
|
+
RELEASE_VERSION_POLICY_OVERRIDE=true bundle exec rake "create_release[9.1.0]"
|
|
61
|
+
bundle exec rake "create_release[9.1.0,false,true]"
|
|
49
62
|
```
|
|
50
63
|
|
|
64
|
+
Dry runs use a temporary git worktree so version bumps and installs do not modify your current checkout.
|
|
65
|
+
|
|
66
|
+
`create_release` and `create_prerelease` validate release-version policy before publishing:
|
|
67
|
+
- Target version must be greater than the latest tagged release.
|
|
68
|
+
- If the versioned target changelog section exists (`## [vX.Y.Z...]`; not `UNRELEASED`), it maps to expected bump type:
|
|
69
|
+
- Breaking changes => major bump
|
|
70
|
+
- Added/New Features/Features/Enhancements => minor bump
|
|
71
|
+
- Fixed/Fixes/Bug Fixes/Security/Improved/Deprecated => patch bump
|
|
72
|
+
- Other headings => no inferred bump level (consistency check is skipped)
|
|
73
|
+
|
|
74
|
+
Use override only when needed:
|
|
75
|
+
- `RELEASE_VERSION_POLICY_OVERRIDE=true`
|
|
76
|
+
- Or task arg override (`create_release[..., ..., true]`, `create_prerelease[..., ..., ..., true]`)
|
|
77
|
+
|
|
51
78
|
### 3. What the Release Task Does
|
|
52
79
|
|
|
53
80
|
The `create_release` task automatically:
|
|
54
81
|
|
|
55
|
-
1. **
|
|
56
|
-
|
|
82
|
+
1. **Validates release prerequisites**:
|
|
83
|
+
- Verifies npm authentication
|
|
84
|
+
2. **Pulls latest changes** from the repository
|
|
85
|
+
3. **Bumps version numbers** in:
|
|
57
86
|
- `lib/shakapacker/version.rb` (Ruby gem version)
|
|
58
87
|
- `package.json` (npm package version - converted from Ruby format)
|
|
59
|
-
|
|
88
|
+
4. **Publishes to npm:**
|
|
60
89
|
- Prompts for npm OTP (2FA code)
|
|
61
90
|
- Creates git tag
|
|
62
91
|
- Pushes to GitHub
|
|
63
|
-
|
|
92
|
+
5. **Publishes to RubyGems:**
|
|
64
93
|
- Prompts for RubyGems OTP (2FA code)
|
|
65
|
-
|
|
94
|
+
6. **Updates spec/dummy lockfiles:**
|
|
66
95
|
- Runs `bundle install` to update `Gemfile.lock`
|
|
67
96
|
- Runs `npm install` to update `package-lock.json` (yarn.lock may also be updated for multi-package-manager compatibility testing)
|
|
68
|
-
|
|
97
|
+
7. **Commits and pushes lockfile changes** automatically
|
|
98
|
+
|
|
99
|
+
### 4. Sync GitHub Release (Optional, After Publish)
|
|
100
|
+
|
|
101
|
+
If you want GitHub Releases, do that as a separate step after publishing.
|
|
102
|
+
Requires GitHub CLI (`gh`) with write access to this repository:
|
|
103
|
+
|
|
104
|
+
Legacy note: `SKIP_GITHUB_RELEASE=true` is no longer used by release tasks. GitHub release creation is now an explicit, separate step via `sync_github_release`.
|
|
105
|
+
|
|
106
|
+
1. Run `bundle exec rake update_changelog`
|
|
107
|
+
2. Update `CHANGELOG.md` with the published version section
|
|
108
|
+
- For prerelease entries, use npm semver header format with dashes, for example `## [v9.6.0-rc.1]`
|
|
109
|
+
3. Commit `CHANGELOG.md`
|
|
110
|
+
4. Run:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Stable
|
|
114
|
+
bundle exec rake "sync_github_release[9.6.0]"
|
|
115
|
+
|
|
116
|
+
# Prerelease
|
|
117
|
+
bundle exec rake "sync_github_release[9.6.0.rc.1]"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`sync_github_release` reads release notes from the matching `CHANGELOG.md` section and creates/updates the GitHub release for the corresponding tag.
|
|
69
121
|
|
|
70
|
-
###
|
|
122
|
+
### 5. Version Format
|
|
71
123
|
|
|
72
124
|
**Important:** Use Ruby gem version format (no dashes):
|
|
73
125
|
|
|
@@ -83,28 +135,35 @@ The task automatically converts Ruby gem format to npm semver format:
|
|
|
83
135
|
|
|
84
136
|
```bash
|
|
85
137
|
# Regular release
|
|
86
|
-
bundle exec rake create_release[9.1.0] # Gem: 9.1.0, npm: 9.1.0
|
|
138
|
+
bundle exec rake "create_release[9.1.0]" # Gem: 9.1.0, npm: 9.1.0
|
|
87
139
|
|
|
88
140
|
# Beta release
|
|
89
|
-
bundle exec rake create_release[9.2.0.beta.1] # Gem: 9.2.0.beta.1, npm: 9.2.0-beta.1
|
|
141
|
+
bundle exec rake "create_release[9.2.0.beta.1]" # Gem: 9.2.0.beta.1, npm: 9.2.0-beta.1
|
|
90
142
|
|
|
91
143
|
# Release candidate
|
|
92
|
-
bundle exec rake create_release[10.0.0.rc.1] # Gem: 10.0.0.rc.1, npm: 10.0.0-rc.1
|
|
144
|
+
bundle exec rake "create_release[10.0.0.rc.1]" # Gem: 10.0.0.rc.1, npm: 10.0.0-rc.1
|
|
145
|
+
|
|
146
|
+
# Auto-next prerelease (recommended)
|
|
147
|
+
bundle exec rake "create_prerelease[10.0.0,rc]" # picks rc.0 then rc.1, etc., with confirmation
|
|
93
148
|
```
|
|
94
149
|
|
|
95
|
-
|
|
150
|
+
The `create_prerelease` task defaults to `rc` if prerelease type is omitted. Use `beta` explicitly when needed.
|
|
151
|
+
|
|
152
|
+
### 6. During the Release
|
|
96
153
|
|
|
97
154
|
1. When prompted for **npm OTP**, enter your 2FA code from your authenticator app
|
|
98
155
|
2. Accept defaults for release-it options
|
|
99
156
|
3. When prompted for **RubyGems OTP**, enter your 2FA code
|
|
100
|
-
4.
|
|
157
|
+
4. If using patch auto-bump (`create_release` with no version), confirm the computed patch version when prompted
|
|
158
|
+
5. If using `create_prerelease`, confirm the computed next prerelease version when prompted
|
|
159
|
+
6. The script will automatically commit and push lockfile updates
|
|
101
160
|
|
|
102
|
-
###
|
|
161
|
+
### 7. After Release
|
|
103
162
|
|
|
104
163
|
1. Verify the release on:
|
|
105
164
|
- [npm](https://www.npmjs.com/package/shakapacker)
|
|
106
165
|
- [RubyGems](https://rubygems.org/gems/shakapacker)
|
|
107
|
-
- [GitHub releases](https://github.com/shakacode/shakapacker/releases)
|
|
166
|
+
- [GitHub releases](https://github.com/shakacode/shakapacker/releases) if you ran `sync_github_release`
|
|
108
167
|
|
|
109
168
|
2. Check that the lockfile commit was pushed:
|
|
110
169
|
|
|
@@ -141,6 +200,26 @@ If publishing fails partway through:
|
|
|
141
200
|
3. If RubyGems failed: Fix the issue and manually run `gem release`
|
|
142
201
|
4. Then manually update and commit spec/dummy lockfiles
|
|
143
202
|
|
|
203
|
+
### GitHub Release Sync Fails
|
|
204
|
+
|
|
205
|
+
If package publishing succeeds but `sync_github_release` fails:
|
|
206
|
+
|
|
207
|
+
1. Fix GitHub auth (`gh auth login`) or permissions
|
|
208
|
+
2. Ensure `CHANGELOG.md` has matching header `## [vX.Y.Z...]` (npm format for prereleases)
|
|
209
|
+
3. Rerun only:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
bundle exec rake "sync_github_release[<gem_version>]"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Legacy `SKIP_GITHUB_RELEASE` Usage
|
|
216
|
+
|
|
217
|
+
If your CI or local runbook still sets `SKIP_GITHUB_RELEASE=true`:
|
|
218
|
+
|
|
219
|
+
1. `create_release` and `create_prerelease` now always skip GitHub release creation by design
|
|
220
|
+
2. Remove `SKIP_GITHUB_RELEASE` from scripts to avoid confusion
|
|
221
|
+
3. Run `sync_github_release` explicitly when you want to create or update a GitHub release
|
|
222
|
+
|
|
144
223
|
### Wrong Version Format
|
|
145
224
|
|
|
146
225
|
If you accidentally use npm format (with dashes):
|
data/eslint.config.js
CHANGED
|
@@ -233,6 +233,7 @@ module.exports = [
|
|
|
233
233
|
// Remaining utils files that need type safety improvements
|
|
234
234
|
// These use dynamic requires and helper functions that return `any`
|
|
235
235
|
files: [
|
|
236
|
+
"package/utils/bundlerUtils.ts",
|
|
236
237
|
"package/utils/inliningCss.ts",
|
|
237
238
|
"package/utils/errorCodes.ts",
|
|
238
239
|
"package/utils/errorHelpers.ts",
|
data/lib/install/binstubs.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
require "shakapacker/install/env"
|
|
2
|
+
|
|
3
|
+
# template.rb sets @conflict_option first during normal install flow.
|
|
4
|
+
# ||= keeps binstubs runnable standalone (e.g., rake shakapacker:binstubs).
|
|
5
|
+
@conflict_option ||= Shakapacker::Install::Env.conflict_option
|
|
2
6
|
|
|
3
7
|
say "Copying binstubs"
|
|
4
|
-
directory "#{__dir__}/bin", "bin",
|
|
8
|
+
directory "#{__dir__}/bin", "bin", @conflict_option
|
|
5
9
|
|
|
6
10
|
chmod "bin", 0755 & ~File.umask, verbose: false
|
|
@@ -161,8 +161,10 @@ development:
|
|
|
161
161
|
allowed_hosts: "auto"
|
|
162
162
|
# Shows progress and colorizes output of bin/shakapacker[-dev-server]
|
|
163
163
|
pretty: true
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
# Uncomment to enable CORS (e.g., when webpack-dev-server runs on a different
|
|
165
|
+
# port than your Rails server and the browser blocks cross-origin asset requests):
|
|
166
|
+
# headers:
|
|
167
|
+
# "Access-Control-Allow-Origin": "*"
|
|
166
168
|
static:
|
|
167
169
|
watch:
|
|
168
170
|
ignored: "**/node_modules/**"
|
data/lib/install/template.rb
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
require "shakapacker/utils/misc"
|
|
2
2
|
require "shakapacker/utils/manager"
|
|
3
3
|
require "shakapacker/utils/version_syntax_converter"
|
|
4
|
+
require "shakapacker/install/env"
|
|
4
5
|
require "package_json"
|
|
5
6
|
require "yaml"
|
|
6
7
|
require "json"
|
|
7
8
|
|
|
8
9
|
# Install Shakapacker
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
@conflict_option = Shakapacker::Install::Env.conflict_option
|
|
11
12
|
|
|
12
13
|
# Initialize variables for use throughout the template
|
|
13
14
|
# Using instance variable to avoid method definition issues in Rails templates
|
|
@@ -17,33 +18,41 @@ install_dir = File.expand_path(File.dirname(__FILE__))
|
|
|
17
18
|
# Installation strategy:
|
|
18
19
|
# - USE_BABEL_PACKAGES installs both babel AND swc for compatibility
|
|
19
20
|
# - Otherwise install only the specified transpiler
|
|
20
|
-
if
|
|
21
|
+
if Shakapacker::Install::Env.truthy_env?("USE_BABEL_PACKAGES")
|
|
21
22
|
@transpiler_to_install = "babel"
|
|
23
|
+
@install_swc_compat_packages = true
|
|
22
24
|
say "đĻ Installing Babel packages (USE_BABEL_PACKAGES is set)", :yellow
|
|
23
25
|
say "⨠Also installing SWC packages for default config compatibility", :green
|
|
24
26
|
elsif ENV["JAVASCRIPT_TRANSPILER"]
|
|
25
27
|
@transpiler_to_install = ENV["JAVASCRIPT_TRANSPILER"]
|
|
28
|
+
@install_swc_compat_packages = false
|
|
26
29
|
say "đĻ Installing #{@transpiler_to_install} packages", :blue
|
|
27
30
|
else
|
|
28
31
|
# Default to swc (matches the default in shakapacker.yml)
|
|
29
32
|
@transpiler_to_install = "swc"
|
|
33
|
+
@install_swc_compat_packages = false
|
|
30
34
|
say "⨠Installing SWC packages (20x faster than Babel)", :green
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
# Copy config file
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
shakapacker_config_preexisting = Rails.root.join("config/shakapacker.yml").exist?
|
|
39
|
+
copy_file "#{install_dir}/config/shakapacker.yml", "config/shakapacker.yml", @conflict_option
|
|
40
|
+
|
|
41
|
+
# Update config to match the selected transpiler
|
|
42
|
+
# Skip modification only when SKIP mode preserved a pre-existing user file
|
|
43
|
+
if Shakapacker::Install::Env.update_transpiler_config?(
|
|
44
|
+
transpiler_to_install: @transpiler_to_install,
|
|
45
|
+
conflict_option: @conflict_option,
|
|
46
|
+
config_preexisting: shakapacker_config_preexisting
|
|
47
|
+
)
|
|
48
|
+
gsub_file "config/shakapacker.yml", 'javascript_transpiler: "swc"', "javascript_transpiler: \"#{@transpiler_to_install}\""
|
|
49
|
+
say " đ Updated config/shakapacker.yml to use #{@transpiler_to_install} transpiler", :green
|
|
41
50
|
end
|
|
42
51
|
|
|
43
52
|
# Detect TypeScript usage
|
|
44
53
|
# Auto-detect from tsconfig.json or explicit via SHAKAPACKER_USE_TYPESCRIPT env var
|
|
45
54
|
@use_typescript = File.exist?(Rails.root.join("tsconfig.json")) ||
|
|
46
|
-
|
|
55
|
+
Shakapacker::Install::Env.truthy_env?("SHAKAPACKER_USE_TYPESCRIPT")
|
|
47
56
|
assets_bundler = ENV["SHAKAPACKER_ASSETS_BUNDLER"] || "webpack"
|
|
48
57
|
config_extension = @use_typescript ? "ts" : "js"
|
|
49
58
|
|
|
@@ -53,7 +62,7 @@ source_config = "#{install_dir}/config/#{assets_bundler}/#{config_file}"
|
|
|
53
62
|
dest_config = "config/#{assets_bundler}/#{config_file}"
|
|
54
63
|
|
|
55
64
|
empty_directory "config/#{assets_bundler}"
|
|
56
|
-
copy_file source_config, dest_config,
|
|
65
|
+
copy_file source_config, dest_config, @conflict_option
|
|
57
66
|
|
|
58
67
|
if @use_typescript
|
|
59
68
|
say " ⨠Using TypeScript config for enhanced type safety", :green
|
|
@@ -216,29 +225,28 @@ Dir.chdir(Rails.root) do
|
|
|
216
225
|
|
|
217
226
|
# Inline fetch_peer_dependencies and fetch_common_dependencies
|
|
218
227
|
peers = PackageJson.read(install_dir).fetch(ENV["SHAKAPACKER_ASSETS_BUNDLER"] || "webpack")
|
|
219
|
-
common_deps =
|
|
228
|
+
common_deps = Shakapacker::Install::Env.truthy_env?("SKIP_COMMON_LOADERS") ? {} : PackageJson.read(install_dir).fetch("common")
|
|
220
229
|
peers = peers.merge(common_deps)
|
|
221
230
|
|
|
222
231
|
# Add transpiler-specific dependencies based on detected/configured transpiler
|
|
223
232
|
# Inline the logic here since methods can't be called before they're defined in Rails templates
|
|
224
233
|
|
|
225
234
|
# Install transpiler-specific dependencies
|
|
226
|
-
# When USE_BABEL_PACKAGES is set, install both babel AND swc
|
|
227
|
-
# This ensures backward compatibility while supporting the default config
|
|
228
235
|
if @transpiler_to_install == "babel"
|
|
229
236
|
# Install babel packages
|
|
230
237
|
babel_deps = PackageJson.read(install_dir).fetch("babel")
|
|
231
238
|
peers = peers.merge(babel_deps)
|
|
232
239
|
|
|
233
|
-
# Also install SWC
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
# Also install SWC only when USE_BABEL_PACKAGES requested compatibility mode.
|
|
241
|
+
if @install_swc_compat_packages
|
|
242
|
+
swc_deps = PackageJson.read(install_dir).fetch("swc")
|
|
243
|
+
peers = peers.merge(swc_deps)
|
|
237
244
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
245
|
+
say "âšī¸ Installing both Babel and SWC packages for compatibility:", :blue
|
|
246
|
+
say " - Babel packages are installed as requested via USE_BABEL_PACKAGES", :blue
|
|
247
|
+
say " - SWC packages are also installed to ensure the default config works", :blue
|
|
248
|
+
say " - Your actual transpiler will be determined by your shakapacker.yml configuration", :blue
|
|
249
|
+
end
|
|
242
250
|
elsif @transpiler_to_install == "swc"
|
|
243
251
|
swc_deps = PackageJson.read(install_dir).fetch("swc")
|
|
244
252
|
peers = peers.merge(swc_deps)
|
data/lib/shakapacker/env.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
class Shakapacker::Env
|
|
2
|
+
FALLBACK_ENV = "production".freeze
|
|
3
|
+
|
|
2
4
|
delegate :config_path, :logger, to: :@instance
|
|
3
5
|
|
|
4
6
|
def self.inquire(instance)
|
|
@@ -11,7 +13,7 @@ class Shakapacker::Env
|
|
|
11
13
|
|
|
12
14
|
def inquire
|
|
13
15
|
fallback_env_warning if config_path.exist? && !current
|
|
14
|
-
current ||
|
|
16
|
+
current || FALLBACK_ENV.inquiry
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
private
|
|
@@ -20,7 +22,7 @@ class Shakapacker::Env
|
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def fallback_env_warning
|
|
23
|
-
logger.info "RAILS_ENV=#{Rails.env} environment is not defined in #{config_path}, falling back to #{
|
|
25
|
+
logger.info "RAILS_ENV=#{Rails.env} environment is not defined in #{config_path}, falling back to #{FALLBACK_ENV} environment"
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
def available_environments
|