shakapacker 8.4.0 → 9.7.0

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.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/commands/address-review.md +206 -0
  3. data/.claude/commands/update-changelog.md +354 -0
  4. data/.github/ISSUE_TEMPLATE/bug_report.md +6 -9
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +6 -8
  6. data/.github/STATUS.md +1 -0
  7. data/.github/actionlint-matcher.json +17 -0
  8. data/.github/workflows/claude-code-review.yml +45 -0
  9. data/.github/workflows/claude.yml +55 -0
  10. data/.github/workflows/dummy.yml +18 -5
  11. data/.github/workflows/eslint-validation.yml +46 -0
  12. data/.github/workflows/generator.yml +38 -22
  13. data/.github/workflows/node.yml +116 -2
  14. data/.github/workflows/ruby.yml +57 -15
  15. data/.github/workflows/test-bundlers.yml +180 -0
  16. data/.gitignore +27 -0
  17. data/.husky/pre-commit +2 -0
  18. data/.npmignore +56 -0
  19. data/.prettierignore +7 -0
  20. data/.rubocop.yml +2 -0
  21. data/.yalcignore +26 -0
  22. data/CHANGELOG.md +487 -19
  23. data/CLAUDE.md +63 -0
  24. data/CONTRIBUTING.md +268 -21
  25. data/ESLINT_TECHNICAL_DEBT.md +165 -0
  26. data/README.md +497 -137
  27. data/Rakefile +44 -4
  28. data/TODO.md +58 -0
  29. data/TODO_v9.md +97 -0
  30. data/bin/conductor-exec +24 -0
  31. data/bin/shakapacker-config +11 -0
  32. data/conductor-setup.sh +147 -0
  33. data/conductor.json +9 -0
  34. data/docs/api-reference.md +519 -0
  35. data/docs/cdn_setup.md +384 -0
  36. data/docs/common-upgrades.md +695 -0
  37. data/docs/configuration.md +845 -0
  38. data/docs/css-modules-export-mode.md +566 -0
  39. data/docs/customizing_babel_config.md +16 -16
  40. data/docs/deployment.md +78 -7
  41. data/docs/developing_shakapacker.md +6 -0
  42. data/docs/early_hints.md +433 -0
  43. data/docs/early_hints_manual_api.md +454 -0
  44. data/docs/feature_testing.md +492 -0
  45. data/docs/node_package_api.md +70 -0
  46. data/docs/optional-peer-dependencies.md +203 -0
  47. data/docs/peer-dependencies.md +71 -0
  48. data/docs/precompile_hook.md +486 -0
  49. data/docs/preventing_fouc.md +132 -0
  50. data/docs/react.md +58 -48
  51. data/docs/releasing.md +288 -0
  52. data/docs/rspack.md +218 -0
  53. data/docs/rspack_migration_guide.md +862 -0
  54. data/docs/sprockets.md +1 -0
  55. data/docs/style_loader_vs_mini_css.md +12 -12
  56. data/docs/subresource_integrity.md +13 -7
  57. data/docs/transpiler-migration.md +212 -0
  58. data/docs/transpiler-performance.md +200 -0
  59. data/docs/troubleshooting.md +272 -24
  60. data/docs/typescript-migration.md +388 -0
  61. data/docs/typescript.md +103 -0
  62. data/docs/using_esbuild_loader.md +12 -12
  63. data/docs/using_swc_loader.md +121 -16
  64. data/docs/v6_upgrade.md +42 -19
  65. data/docs/v7_upgrade.md +8 -6
  66. data/docs/v8_upgrade.md +13 -12
  67. data/docs/v9_upgrade.md +616 -0
  68. data/eslint.config.fast.js +254 -0
  69. data/eslint.config.js +309 -0
  70. data/jest.config.js +8 -1
  71. data/knip.ts +61 -0
  72. data/lib/install/bin/shakapacker +4 -6
  73. data/lib/install/bin/shakapacker-config +11 -0
  74. data/lib/install/bin/shakapacker-dev-server +1 -1
  75. data/lib/install/binstubs.rb +6 -2
  76. data/lib/install/config/rspack/rspack.config.js +6 -0
  77. data/lib/install/config/rspack/rspack.config.ts +7 -0
  78. data/lib/install/config/shakapacker.yml +75 -12
  79. data/lib/install/config/webpack/webpack.config.ts +7 -0
  80. data/lib/install/package.json +38 -0
  81. data/lib/install/template.rb +207 -45
  82. data/lib/shakapacker/build_config_loader.rb +147 -0
  83. data/lib/shakapacker/bundler_switcher.rb +415 -0
  84. data/lib/shakapacker/compiler.rb +87 -0
  85. data/lib/shakapacker/configuration.rb +475 -6
  86. data/lib/shakapacker/dev_server.rb +88 -1
  87. data/lib/shakapacker/dev_server_runner.rb +240 -6
  88. data/lib/shakapacker/doctor.rb +1191 -0
  89. data/lib/shakapacker/env.rb +19 -3
  90. data/lib/shakapacker/helper.rb +411 -14
  91. data/lib/shakapacker/install/env.rb +33 -0
  92. data/lib/shakapacker/instance.rb +93 -4
  93. data/lib/shakapacker/manifest.rb +167 -30
  94. data/lib/shakapacker/railtie.rb +4 -0
  95. data/lib/shakapacker/rspack_runner.rb +19 -0
  96. data/lib/shakapacker/runner.rb +668 -9
  97. data/lib/shakapacker/swc_migrator.rb +384 -0
  98. data/lib/shakapacker/utils/manager.rb +2 -0
  99. data/lib/shakapacker/utils/version_syntax_converter.rb +1 -1
  100. data/lib/shakapacker/version.rb +1 -1
  101. data/lib/shakapacker/version_checker.rb +1 -1
  102. data/lib/shakapacker/webpack_runner.rb +4 -42
  103. data/lib/shakapacker.rb +159 -1
  104. data/lib/tasks/shakapacker/binstubs.rake +4 -2
  105. data/lib/tasks/shakapacker/check_binstubs.rake +2 -2
  106. data/lib/tasks/shakapacker/doctor.rake +48 -0
  107. data/lib/tasks/shakapacker/export_bundler_config.rake +68 -0
  108. data/lib/tasks/shakapacker/install.rake +16 -4
  109. data/lib/tasks/shakapacker/migrate_to_swc.rake +13 -0
  110. data/lib/tasks/shakapacker/switch_bundler.rake +72 -0
  111. data/lib/tasks/shakapacker.rake +2 -0
  112. data/package/.npmignore +4 -0
  113. data/package/babel/preset.ts +59 -0
  114. data/package/config.ts +189 -0
  115. data/package/configExporter/buildValidator.ts +906 -0
  116. data/package/configExporter/cli.ts +1748 -0
  117. data/package/configExporter/configDocs.ts +102 -0
  118. data/package/configExporter/configFile.ts +663 -0
  119. data/package/configExporter/fileWriter.ts +112 -0
  120. data/package/configExporter/index.ts +15 -0
  121. data/package/configExporter/types.ts +159 -0
  122. data/package/configExporter/yamlSerializer.ts +391 -0
  123. data/package/dev_server.ts +27 -0
  124. data/package/env.ts +92 -0
  125. data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +36 -0
  126. data/package/environments/base.ts +147 -0
  127. data/package/environments/development.ts +88 -0
  128. data/package/environments/production.ts +82 -0
  129. data/package/environments/test.ts +55 -0
  130. data/package/environments/types.ts +98 -0
  131. data/package/esbuild/index.ts +40 -0
  132. data/package/index.d.ts +68 -93
  133. data/package/index.d.ts.template +72 -0
  134. data/package/index.ts +104 -0
  135. data/package/loaders.d.ts +28 -0
  136. data/package/optimization/rspack.ts +36 -0
  137. data/package/optimization/webpack.ts +55 -0
  138. data/package/plugins/envFilter.ts +82 -0
  139. data/package/plugins/rspack.ts +119 -0
  140. data/package/plugins/webpack.ts +82 -0
  141. data/package/rspack/index.ts +91 -0
  142. data/package/rules/{babel.js → babel.ts} +2 -2
  143. data/package/rules/{coffee.js → coffee.ts} +1 -1
  144. data/package/rules/css.ts +3 -0
  145. data/package/rules/{erb.js → erb.ts} +1 -1
  146. data/package/rules/esbuild.ts +10 -0
  147. data/package/rules/file.ts +41 -0
  148. data/package/rules/{jscommon.js → jscommon.ts} +5 -4
  149. data/package/rules/{less.js → less.ts} +4 -4
  150. data/package/rules/raw.ts +28 -0
  151. data/package/rules/rspack.ts +174 -0
  152. data/package/rules/sass.ts +21 -0
  153. data/package/rules/{stylus.js → stylus.ts} +4 -8
  154. data/package/rules/swc.ts +10 -0
  155. data/package/rules/{index.js → webpack.ts} +1 -2
  156. data/package/swc/index.ts +54 -0
  157. data/package/types/README.md +90 -0
  158. data/package/types/index.ts +69 -0
  159. data/package/types.ts +105 -0
  160. data/package/utils/bundlerUtils.ts +232 -0
  161. data/package/utils/configPath.ts +6 -0
  162. data/package/utils/debug.ts +45 -0
  163. data/package/utils/defaultConfigPath.ts +7 -0
  164. data/package/utils/ensureManifestExists.ts +17 -0
  165. data/package/utils/errorCodes.ts +249 -0
  166. data/package/utils/errorHelpers.ts +152 -0
  167. data/package/utils/getStyleRule.ts +75 -0
  168. data/package/utils/helpers.ts +99 -0
  169. data/package/utils/{inliningCss.js → inliningCss.ts} +3 -3
  170. data/package/utils/pathValidation.ts +207 -0
  171. data/package/utils/requireOrError.ts +24 -0
  172. data/package/utils/snakeToCamelCase.ts +5 -0
  173. data/package/utils/typeGuards.ts +388 -0
  174. data/package/utils/validateDependencies.ts +61 -0
  175. data/package/webpack-types.d.ts +33 -0
  176. data/package/webpackDevServerConfig.ts +130 -0
  177. data/package.json +157 -18
  178. data/scripts/remove-use-strict.js +44 -0
  179. data/scripts/type-check-no-emit.js +27 -0
  180. data/shakapacker.gemspec +4 -2
  181. data/sig/shakapacker/commands.rbs +35 -0
  182. data/sig/shakapacker/compiler.rbs +65 -0
  183. data/sig/shakapacker/compiler_strategy.rbs +41 -0
  184. data/sig/shakapacker/configuration.rbs +140 -0
  185. data/sig/shakapacker/dev_server.rbs +56 -0
  186. data/sig/shakapacker/env.rbs +25 -0
  187. data/sig/shakapacker/helper.rbs +98 -0
  188. data/sig/shakapacker/instance.rbs +46 -0
  189. data/sig/shakapacker/manifest.rbs +69 -0
  190. data/sig/shakapacker/version.rbs +4 -0
  191. data/sig/shakapacker.rbs +66 -0
  192. data/test/configExporter/buildValidator.test.js +1295 -0
  193. data/test/configExporter/configFile.test.js +393 -0
  194. data/test/configExporter/integration.test.js +262 -0
  195. data/test/helpers.js +1 -1
  196. data/test/package/bundlerUtils.rspack.test.js +145 -0
  197. data/test/package/bundlerUtils.test.js +97 -0
  198. data/test/package/config.test.js +14 -0
  199. data/test/package/configExporter/cli.test.js +440 -0
  200. data/test/package/configExporter/types.test.js +163 -0
  201. data/test/package/configExporter.test.js +491 -0
  202. data/test/package/env.test.js +42 -7
  203. data/test/package/environments/base.test.js +14 -4
  204. data/test/package/helpers.test.js +2 -2
  205. data/test/package/plugins/envFiltering.test.js +453 -0
  206. data/test/package/plugins/webpackSubresourceIntegrity.test.js +89 -0
  207. data/test/package/rspack/index.test.js +293 -0
  208. data/test/package/rspack/optimization.test.js +86 -0
  209. data/test/package/rspack/plugins.test.js +185 -0
  210. data/test/package/rspack/rules.test.js +229 -0
  211. data/test/package/rules/babel.test.js +65 -38
  212. data/test/package/rules/esbuild.test.js +13 -4
  213. data/test/package/rules/file.test.js +7 -1
  214. data/test/package/rules/raw.test.js +40 -7
  215. data/test/package/rules/sass-version-parsing.test.js +71 -0
  216. data/test/package/rules/sass.test.js +11 -6
  217. data/test/package/rules/sass1.test.js +8 -5
  218. data/test/package/rules/sass16.test.js +24 -0
  219. data/test/package/rules/swc.test.js +50 -39
  220. data/test/package/rules/webpack.test.js +35 -0
  221. data/test/package/staging.test.js +4 -3
  222. data/test/package/transpiler-defaults.test.js +169 -0
  223. data/test/package/utils/ensureManifestExists.test.js +51 -0
  224. data/test/package/yamlSerializer.test.js +204 -0
  225. data/test/peer-dependencies.sh +85 -0
  226. data/test/resolver.js +34 -3
  227. data/test/scripts/remove-use-strict.test.js +125 -0
  228. data/test/typescript/build.test.js +118 -0
  229. data/test/typescript/environments.test.js +107 -0
  230. data/test/typescript/pathValidation.test.js +186 -0
  231. data/test/typescript/requireOrError.test.js +49 -0
  232. data/test/typescript/securityValidation.test.js +182 -0
  233. data/tools/README.md +134 -0
  234. data/tools/css-modules-v9-codemod.js +179 -0
  235. data/tsconfig.eslint.json +9 -0
  236. data/tsconfig.json +38 -0
  237. data/yarn.lock +3202 -1097
  238. metadata +212 -44
  239. data/.eslintignore +0 -4
  240. data/.eslintrc.js +0 -36
  241. data/Gemfile.lock +0 -251
  242. data/package/babel/preset.js +0 -48
  243. data/package/config.js +0 -56
  244. data/package/dev_server.js +0 -23
  245. data/package/env.js +0 -48
  246. data/package/environments/base.js +0 -171
  247. data/package/environments/development.js +0 -13
  248. data/package/environments/production.js +0 -88
  249. data/package/environments/test.js +0 -3
  250. data/package/esbuild/index.js +0 -40
  251. data/package/index.js +0 -40
  252. data/package/rules/css.js +0 -3
  253. data/package/rules/esbuild.js +0 -10
  254. data/package/rules/file.js +0 -29
  255. data/package/rules/raw.js +0 -5
  256. data/package/rules/sass.js +0 -18
  257. data/package/rules/swc.js +0 -10
  258. data/package/swc/index.js +0 -50
  259. data/package/utils/configPath.js +0 -4
  260. data/package/utils/defaultConfigPath.js +0 -2
  261. data/package/utils/getStyleRule.js +0 -40
  262. data/package/utils/helpers.js +0 -62
  263. data/package/utils/snakeToCamelCase.js +0 -5
  264. data/package/webpackDevServerConfig.js +0 -71
  265. data/test/package/rules/index.test.js +0 -16
@@ -0,0 +1,45 @@
1
+ name: Claude Code Review
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, ready_for_review, reopened]
6
+
7
+ jobs:
8
+ claude-review:
9
+ if: github.event.pull_request.head.repo.full_name == github.repository
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ pull-requests: write
14
+ issues: write
15
+ id-token: write
16
+
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 1
22
+
23
+ - name: Run Claude Code Review
24
+ id: claude-review
25
+ uses: anthropics/claude-code-action@v1
26
+ with:
27
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
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.
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:*)"
@@ -0,0 +1,55 @@
1
+ name: Claude Code
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+ pull_request_review_comment:
7
+ types: [created]
8
+ issues:
9
+ types: [opened, assigned]
10
+ pull_request_review:
11
+ types: [submitted]
12
+
13
+ jobs:
14
+ claude:
15
+ if: |
16
+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17
+ (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18
+ (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19
+ (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20
+ runs-on: ubuntu-latest
21
+ permissions:
22
+ contents: read
23
+ pull-requests: read
24
+ issues: read
25
+ id-token: write
26
+ actions: read # Required for Claude to read CI results on PRs
27
+ checks: read
28
+ statuses: read
29
+ steps:
30
+ - name: Checkout repository
31
+ uses: actions/checkout@v4
32
+ with:
33
+ fetch-depth: 1
34
+
35
+ - name: Run Claude Code
36
+ id: claude
37
+ uses: anthropics/claude-code-action@v1
38
+ with:
39
+ github_token: ${{ github.token }}
40
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
41
+
42
+ # This is an optional setting that allows Claude to read CI results on PRs
43
+ additional_permissions: |
44
+ actions: read
45
+ checks: read
46
+ statuses: read
47
+
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.
49
+ # prompt: 'Update the pull request description to include a summary of changes.'
50
+
51
+ # Optional: Add claude_args to customize behavior and configuration
52
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
53
+ # or https://code.claude.com/docs/en/cli-reference for available options
54
+ # claude_args: '--allowed-tools Bash(gh pr:*)'
55
+
@@ -3,8 +3,17 @@ name: Dummy specs
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
+ paths:
9
+ - "spec/dummy/**"
10
+ - "lib/**"
11
+ - "**.rb"
12
+ - "**.js"
13
+ - "**.ts"
14
+ - "package.json"
15
+ - ".github/workflows/dummy.yml"
16
+ workflow_dispatch:
8
17
 
9
18
  concurrency:
10
19
  # Pushing new changes to a branch will cancel any in-progress CI runs
@@ -21,16 +30,20 @@ jobs:
21
30
  persist-credentials: false
22
31
  - uses: actions/setup-node@v4
23
32
  with:
24
- node-version: '16'
33
+ node-version: "20"
25
34
  - uses: ruby/setup-ruby@v1
26
35
  with:
27
- ruby-version: '3.1.2'
36
+ ruby-version: "3.2"
28
37
  rubygems: latest
29
38
  - name: Install dependencies
30
39
  run: |
31
40
  bundle install
32
- yarn install
33
- sudo yarn global add yalc
41
+ yarn install --frozen-lockfile --production=false
42
+ npm install -g yalc
43
+ cd spec/dummy && npm install
44
+
45
+ - name: Build TypeScript
46
+ run: yarn build
34
47
 
35
48
  - name: Run tests
36
49
  run: bundle exec rake run_spec:dummy
@@ -0,0 +1,46 @@
1
+ name: ESLint Validation
2
+
3
+ on:
4
+ pull_request:
5
+ paths:
6
+ - "eslint.config.js"
7
+ - "package.json"
8
+ - "package/**/*.js"
9
+ - "test/**/*.js"
10
+ - ".github/workflows/eslint-validation.yml"
11
+
12
+ jobs:
13
+ validate:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Setup Node
19
+ uses: actions/setup-node@v4
20
+ with:
21
+ node-version: "20"
22
+ cache: "yarn"
23
+
24
+ - name: Install dependencies
25
+ run: yarn install --frozen-lockfile
26
+
27
+ - name: Validate ESLint config
28
+ run: |
29
+ echo "Validating ESLint configuration..."
30
+ node -e "const config = require('./eslint.config.js'); console.log('✓ Config is valid with', config.length, 'rule sets')"
31
+
32
+ - name: Run ESLint
33
+ run: |
34
+ echo "Running ESLint on allowed files..."
35
+ yarn eslint . --max-warnings 5
36
+
37
+ - name: Check warning count
38
+ run: |
39
+ echo "Checking warning count..."
40
+ WARNING_COUNT=$(yarn eslint . 2>&1 | grep -E "^✖.*warning" | grep -oE "[0-9]+ warning" | cut -d' ' -f1)
41
+ echo "Current warning count: $WARNING_COUNT"
42
+ if [ "$WARNING_COUNT" -gt "5" ]; then
43
+ echo "❌ Too many warnings: $WARNING_COUNT (max allowed: 5)"
44
+ exit 1
45
+ fi
46
+ echo "✓ Warning count is acceptable"
@@ -3,8 +3,21 @@ name: Generator specs
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
+ paths:
9
+ - "lib/install/**"
10
+ - "lib/generators/**"
11
+ - "spec/generator_specs/**"
12
+ - "**.rb"
13
+ - "**.gemspec"
14
+ - "Gemfile"
15
+ - "gemfiles/**"
16
+ - "package.json"
17
+ - "**.js"
18
+ - "**.ts"
19
+ - ".github/workflows/generator.yml"
20
+ workflow_dispatch:
8
21
 
9
22
  concurrency:
10
23
  # Pushing new changes to a branch will cancel any in-progress CI runs
@@ -18,10 +31,8 @@ jobs:
18
31
  strategy:
19
32
  matrix:
20
33
  os: [ubuntu-latest]
21
- ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
34
+ ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4"]
22
35
  gemfile:
23
- - gemfiles/Gemfile-rails.6.0.x
24
- - gemfiles/Gemfile-rails.6.1.x
25
36
  - gemfiles/Gemfile-rails.7.0.x
26
37
  - gemfiles/Gemfile-rails.7.1.x
27
38
  - gemfiles/Gemfile-rails.7.2.x
@@ -30,29 +41,17 @@ jobs:
30
41
  # upcomming Rails versions, maybe before a release.
31
42
  #- gemfiles/Gemfile-rails-edge
32
43
  exclude:
33
- - ruby: '2.7'
44
+ - ruby: "2.7"
34
45
  gemfile: gemfiles/Gemfile-rails.7.2.x
35
- - ruby: '2.7'
46
+ - ruby: "2.7"
36
47
  gemfile: gemfiles/Gemfile-rails.8.0.x
37
- - ruby: '3.0'
48
+ - ruby: "3.0"
38
49
  gemfile: gemfiles/Gemfile-rails.7.2.x
39
- - ruby: '3.0'
50
+ - ruby: "3.0"
40
51
  gemfile: gemfiles/Gemfile-rails.8.0.x
41
- - ruby: '3.1'
42
- gemfile: gemfiles/Gemfile-rails.6.0.x
43
- - ruby: '3.1'
52
+ - ruby: "3.1"
44
53
  gemfile: gemfiles/Gemfile-rails.8.0.x
45
- - ruby: '3.2'
46
- gemfile: gemfiles/Gemfile-rails.6.0.x
47
- - ruby: '3.3'
48
- gemfile: gemfiles/Gemfile-rails.6.0.x
49
- - ruby: '3.3'
50
- gemfile: gemfiles/Gemfile-rails.6.1.x
51
- - ruby: '3.4'
52
- gemfile: gemfiles/Gemfile-rails.6.0.x
53
- - ruby: '3.4'
54
- gemfile: gemfiles/Gemfile-rails.6.1.x
55
- - ruby: '3.4'
54
+ - ruby: "3.4"
56
55
  gemfile: gemfiles/Gemfile-rails.7.0.x
57
56
 
58
57
  env:
@@ -67,4 +66,21 @@ jobs:
67
66
  ruby-version: ${{ matrix.ruby }}
68
67
  rubygems: latest
69
68
  bundler-cache: true
69
+ - uses: actions/setup-node@v4
70
+ with:
71
+ node-version: 20.x
72
+ cache: yarn
73
+
74
+ - name: Install Node dependencies
75
+ run: yarn install --frozen-lockfile --production=false
76
+
77
+ - name: Build TypeScript
78
+ run: yarn build
79
+
80
+ - name: Pack npm package for testing
81
+ run: |
82
+ TARBALL=$(npm pack)
83
+ echo "SHAKAPACKER_NPM_PACKAGE=$(pwd)/$TARBALL" >> $GITHUB_ENV
84
+ echo "Created package: $TARBALL"
85
+
70
86
  - run: bundle exec rake run_spec:generator
@@ -3,8 +3,21 @@ name: Node based checks
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
+ paths:
9
+ - "**.js"
10
+ - "**.ts"
11
+ - "package.json"
12
+ - "yarn.lock"
13
+ - "eslint.config.js"
14
+ - ".prettierrc"
15
+ - ".prettierignore"
16
+ - "knip.json"
17
+ - "tsconfig.json"
18
+ - "jest.config.js"
19
+ - ".github/workflows/node.yml"
20
+ workflow_dispatch:
8
21
 
9
22
  concurrency:
10
23
  # Pushing new changes to a branch will cancel any in-progress CI runs
@@ -30,12 +43,110 @@ jobs:
30
43
 
31
44
  - name: Node eslint
32
45
  run: yarn lint
46
+
47
+ - name: Prettier format check
48
+ run: yarn prettier --check .
49
+
50
+ - name: Detect dead code
51
+ run: yarn knip
52
+
53
+ - name: Detect dead code in production
54
+ run: yarn knip:production
55
+
56
+ type-check:
57
+ name: TypeScript Type Checking
58
+ runs-on: ubuntu-latest
59
+
60
+ steps:
61
+ - uses: actions/checkout@v4
62
+ with:
63
+ persist-credentials: false
64
+ - uses: actions/setup-node@v4
65
+ with:
66
+ node-version: 20.x
67
+ cache: yarn
68
+
69
+ - name: Install dependencies
70
+ run: yarn --frozen-lockfile --non-interactive --prefer-offline
71
+
72
+ - name: TypeScript type check
73
+ run: yarn type-check
74
+
75
+ # We only download and run Actionlint if there is any difference in GitHub Action workflows
76
+ # https://github.com/rhysd/actionlint/blob/main/docs/usage.md#on-github-actions
77
+ # Note: Only runs on pull_request events, not push events (where github.event.pull_request is null)
78
+ - name: Check GitHub Action changes
79
+ if: github.event_name == 'pull_request'
80
+ id: check-workflows
81
+ run: |
82
+ git fetch origin ${{ github.event.pull_request.base.sha }}
83
+ if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q '^.github/workflows'; then
84
+ echo "changed=true" >> "$GITHUB_OUTPUT"
85
+ response=$(curl -sf https://api.github.com/repos/rhysd/actionlint/releases/latest)
86
+ if [ $? -eq 0 ]; then
87
+ actionlint_version=$(echo "$response" | jq -r .tag_name)
88
+ if [ -z "$actionlint_version" ]; then
89
+ echo "Failed to parse Actionlint version"
90
+ exit 1
91
+ fi
92
+ echo "actionlint_version=\"$actionlint_version\"" >> "$GITHUB_OUTPUT"
93
+ fi
94
+ fi
95
+ - name: Setup Actionlint
96
+ if: github.event_name == 'pull_request' && steps.check-workflows.outputs.changed == 'true'
97
+ uses: actions/cache@v4
98
+ id: cache-actionlint
99
+ with:
100
+ path: ./actionlint
101
+ key: ${{ runner.os }}-actionlint-${{ steps.check-workflows.outputs.actionlint_version }}
102
+ - name: Download Actionlint
103
+ if: github.event_name == 'pull_request' && steps.check-workflows.outputs.changed == 'true' && steps.cache-actionlint.outputs.cache-hit != 'true'
104
+ run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
105
+ - name: Lint GitHub Actions
106
+ if: github.event_name == 'pull_request' && steps.check-workflows.outputs.changed == 'true'
107
+ run: |
108
+ echo "::add-matcher::.github/actionlint-matcher.json"
109
+ SHELLCHECK_OPTS="-S warning" ./actionlint -color
110
+ shell: bash
111
+
112
+ type-check-dts-without-webpack:
113
+ name: Verify .d.ts files work without webpack
114
+ runs-on: ubuntu-latest
115
+
116
+ steps:
117
+ - uses: actions/checkout@v4
118
+ with:
119
+ persist-credentials: false
120
+ - uses: actions/setup-node@v4
121
+ with:
122
+ node-version: 20.x
123
+
124
+ - name: Create test directory and copy .d.ts files
125
+ run: |
126
+ mkdir -p /tmp/test-types
127
+ cp package/*.d.ts /tmp/test-types/
128
+ # types.ts is imported by index.d.ts; copy if it exists
129
+ cp package/types.ts /tmp/test-types/ 2>/dev/null || true
130
+
131
+ - name: Install TypeScript in test directory
132
+ run: |
133
+ cd /tmp/test-types
134
+ npm init -y
135
+ npm install typescript @types/node
136
+
137
+ - name: Verify hand-written .d.ts files type-check without webpack
138
+ run: |
139
+ cd /tmp/test-types
140
+ npx tsc --noEmit \
141
+ --skipLibCheck \
142
+ --moduleResolution node \
143
+ *.d.ts
33
144
  test:
34
145
  name: Testing
35
146
  strategy:
36
147
  matrix:
37
148
  os: [ubuntu-latest]
38
- node: [14.x, 16.x, 18.x, 20.x]
149
+ node: [20.x, 22.x]
39
150
 
40
151
  runs-on: ${{ matrix.os }}
41
152
 
@@ -52,5 +163,8 @@ jobs:
52
163
  - name: Install dependencies
53
164
  run: yarn --frozen-lockfile --non-interactive --prefer-offline
54
165
 
166
+ - name: Build TypeScript
167
+ run: yarn build
168
+
55
169
  - name: Jest Specs
56
170
  run: yarn test
@@ -3,8 +3,20 @@ name: Ruby based checks
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - 'main'
6
+ - "main"
7
7
  pull_request:
8
+ paths:
9
+ - "**.rb"
10
+ - "**.rbs"
11
+ - "**.gemspec"
12
+ - "Gemfile"
13
+ - "Rakefile"
14
+ - "gemfiles/**"
15
+ - ".rubocop.yml"
16
+ - "package.json"
17
+ - "**.ts"
18
+ - ".github/workflows/ruby.yml"
19
+ workflow_dispatch:
8
20
 
9
21
  concurrency:
10
22
  # Pushing new changes to a branch will cancel any in-progress CI runs
@@ -23,20 +35,39 @@ jobs:
23
35
  run: rm -f Gemfile.lock
24
36
  - uses: ruby/setup-ruby@v1
25
37
  with:
26
- ruby-version: '3.4'
38
+ ruby-version: "3.4"
27
39
  rubygems: latest
28
40
  bundler-cache: true
29
41
 
30
42
  - name: Ruby rubocop
31
43
  run: bundle exec rubocop
32
44
 
45
+ rbs-validate:
46
+ name: RBS Type Validation
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+ with:
51
+ persist-credentials: false
52
+ - name: Remove Gemfile.lock
53
+ # Remove lock to test compatibility with latest gem versions
54
+ run: rm -f Gemfile.lock
55
+ - uses: ruby/setup-ruby@v1
56
+ with:
57
+ ruby-version: "3.4"
58
+ rubygems: latest
59
+ bundler-cache: true
60
+
61
+ - name: Validate RBS signatures
62
+ run: bundle exec rbs validate
63
+
33
64
  test:
34
65
  name: Testing
35
66
  runs-on: ${{ matrix.os }}
36
67
  strategy:
37
68
  matrix:
38
69
  os: [ubuntu-latest]
39
- ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
70
+ ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4"]
40
71
  gemfile:
41
72
  - gemfiles/Gemfile-rails.6.0.x
42
73
  - gemfiles/Gemfile-rails.6.1.x
@@ -48,29 +79,29 @@ jobs:
48
79
  # upcomming Rails versions, maybe before a release.
49
80
  #- gemfiles/Gemfile-rails-edge
50
81
  exclude:
51
- - ruby: '2.7'
82
+ - ruby: "2.7"
52
83
  gemfile: gemfiles/Gemfile-rails.7.2.x
53
- - ruby: '2.7'
84
+ - ruby: "2.7"
54
85
  gemfile: gemfiles/Gemfile-rails.8.0.x
55
- - ruby: '3.0'
86
+ - ruby: "3.0"
56
87
  gemfile: gemfiles/Gemfile-rails.7.2.x
57
- - ruby: '3.0'
88
+ - ruby: "3.0"
58
89
  gemfile: gemfiles/Gemfile-rails.8.0.x
59
- - ruby: '3.1'
90
+ - ruby: "3.1"
60
91
  gemfile: gemfiles/Gemfile-rails.6.0.x
61
- - ruby: '3.1'
92
+ - ruby: "3.1"
62
93
  gemfile: gemfiles/Gemfile-rails.8.0.x
63
- - ruby: '3.2'
94
+ - ruby: "3.2"
64
95
  gemfile: gemfiles/Gemfile-rails.6.0.x
65
- - ruby: '3.3'
96
+ - ruby: "3.3"
66
97
  gemfile: gemfiles/Gemfile-rails.6.0.x
67
- - ruby: '3.3'
98
+ - ruby: "3.3"
68
99
  gemfile: gemfiles/Gemfile-rails.6.1.x
69
- - ruby: '3.4'
100
+ - ruby: "3.4"
70
101
  gemfile: gemfiles/Gemfile-rails.6.0.x
71
- - ruby: '3.4'
102
+ - ruby: "3.4"
72
103
  gemfile: gemfiles/Gemfile-rails.6.1.x
73
- - ruby: '3.4'
104
+ - ruby: "3.4"
74
105
  gemfile: gemfiles/Gemfile-rails.7.0.x
75
106
 
76
107
  env:
@@ -86,5 +117,16 @@ jobs:
86
117
  rubygems: latest
87
118
  bundler-cache: true
88
119
 
120
+ - uses: actions/setup-node@v4
121
+ with:
122
+ node-version: 20.x
123
+ cache: yarn
124
+
125
+ - name: Install Node dependencies
126
+ run: yarn install --frozen-lockfile --production=false
127
+
128
+ - name: Build TypeScript
129
+ run: yarn build
130
+
89
131
  - name: Ruby specs
90
132
  run: bundle exec rake run_spec:gem