shakapacker 8.0.0 → 8.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dummy.yml +1 -1
  3. data/.github/workflows/generator.yml +5 -1
  4. data/.github/workflows/node.yml +1 -1
  5. data/.github/workflows/ruby.yml +8 -2
  6. data/.gitignore +0 -1
  7. data/.node-version +1 -1
  8. data/CHANGELOG.md +27 -11
  9. data/Gemfile.lock +257 -0
  10. data/README.md +11 -12
  11. data/__mocks__/nonexistent/package.json +4 -0
  12. data/__mocks__/sass-loader/package.json +4 -0
  13. data/docs/customizing_babel_config.md +32 -4
  14. data/docs/react.md +3 -2
  15. data/docs/troubleshooting.md +1 -1
  16. data/docs/using_esbuild_loader.md +1 -1
  17. data/docs/v8_upgrade.md +2 -2
  18. data/jest.config.js +2 -1
  19. data/lib/shakapacker/version.rb +1 -1
  20. data/package/rules/sass.js +8 -6
  21. data/package/utils/helpers.js +9 -1
  22. data/package.json +2 -2
  23. data/shakapacker.gemspec +5 -2
  24. data/test/package/development.test.js +9 -0
  25. data/test/package/environments/base.test.js +9 -0
  26. data/test/package/environments/development.test.js +9 -0
  27. data/test/package/environments/production.test.js +9 -0
  28. data/test/package/helpers.test.js +11 -0
  29. data/test/package/index.test.js +9 -0
  30. data/test/package/production.test.js +9 -0
  31. data/test/package/rules/index.test.js +9 -0
  32. data/test/package/rules/sass.test.js +23 -0
  33. data/test/package/rules/sass1.test.js +23 -0
  34. data/test/package/staging.test.js +9 -0
  35. data/test/package/test.test.js +9 -0
  36. data/test/resolver.js +13 -0
  37. metadata +15 -235
  38. data/lib/install/bin/yarn +0 -18
  39. data/rakelib/release.rake +0 -65
  40. data/spec/dummy/.browserslistrc +0 -1
  41. data/spec/dummy/.gitignore +0 -20
  42. data/spec/dummy/.prettierrc.yaml +0 -4
  43. data/spec/dummy/Gemfile +0 -61
  44. data/spec/dummy/Procfile.dev +0 -5
  45. data/spec/dummy/Procfile.dev-static +0 -9
  46. data/spec/dummy/README.md +0 -1
  47. data/spec/dummy/Rakefile +0 -6
  48. data/spec/dummy/app/assets/config/manifest.js +0 -2
  49. data/spec/dummy/app/assets/images/.keep +0 -0
  50. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  51. data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
  52. data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
  53. data/spec/dummy/app/controllers/application_controller.rb +0 -2
  54. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  55. data/spec/dummy/app/controllers/hello_world_controller.rb +0 -9
  56. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  57. data/spec/dummy/app/javascript/Globals.d.ts +0 -3
  58. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +0 -25
  59. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +0 -47
  60. data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx +0 -5
  61. data/spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg +0 -7
  62. data/spec/dummy/app/javascript/packs/application.js +0 -17
  63. data/spec/dummy/app/javascript/packs/hello-world-bundle.ts +0 -8
  64. data/spec/dummy/app/javascript/packs/server-bundle.ts +0 -8
  65. data/spec/dummy/app/jobs/application_job.rb +0 -7
  66. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  67. data/spec/dummy/app/models/application_record.rb +0 -3
  68. data/spec/dummy/app/models/concerns/.keep +0 -0
  69. data/spec/dummy/app/views/hello_world/index.html.erb +0 -2
  70. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  71. data/spec/dummy/app/views/layouts/hello_world.html.erb +0 -13
  72. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  73. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  74. data/spec/dummy/babel.config.js +0 -30
  75. data/spec/dummy/bin/bundle +0 -114
  76. data/spec/dummy/bin/dev +0 -30
  77. data/spec/dummy/bin/dev-static +0 -30
  78. data/spec/dummy/bin/rails +0 -9
  79. data/spec/dummy/bin/rake +0 -9
  80. data/spec/dummy/bin/setup +0 -33
  81. data/spec/dummy/bin/shakapacker +0 -13
  82. data/spec/dummy/bin/shakapacker-dev-server +0 -13
  83. data/spec/dummy/bin/spring +0 -17
  84. data/spec/dummy/bin/yarn +0 -18
  85. data/spec/dummy/config/application.rb +0 -35
  86. data/spec/dummy/config/boot.rb +0 -4
  87. data/spec/dummy/config/cable.yml +0 -10
  88. data/spec/dummy/config/credentials.yml.enc +0 -1
  89. data/spec/dummy/config/database.yml +0 -25
  90. data/spec/dummy/config/environment.rb +0 -5
  91. data/spec/dummy/config/environments/development.rb +0 -54
  92. data/spec/dummy/config/environments/production.rb +0 -106
  93. data/spec/dummy/config/environments/test.rb +0 -49
  94. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
  95. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  96. data/spec/dummy/config/initializers/content_security_policy.rb +0 -28
  97. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
  98. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  99. data/spec/dummy/config/initializers/inflections.rb +0 -16
  100. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  101. data/spec/dummy/config/initializers/react_on_rails.rb +0 -58
  102. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  103. data/spec/dummy/config/locales/en.yml +0 -33
  104. data/spec/dummy/config/puma.rb +0 -38
  105. data/spec/dummy/config/routes.rb +0 -6
  106. data/spec/dummy/config/shakapacker.yml +0 -61
  107. data/spec/dummy/config/spring.rb +0 -6
  108. data/spec/dummy/config/storage.yml +0 -34
  109. data/spec/dummy/config/webpack/ServerClientOrBoth.js +0 -34
  110. data/spec/dummy/config/webpack/clientWebpackConfig.js +0 -15
  111. data/spec/dummy/config/webpack/commonWebpackConfig.js +0 -17
  112. data/spec/dummy/config/webpack/development.js +0 -32
  113. data/spec/dummy/config/webpack/production.js +0 -9
  114. data/spec/dummy/config/webpack/serverWebpackConfig.js +0 -116
  115. data/spec/dummy/config/webpack/test.js +0 -7
  116. data/spec/dummy/config/webpack/webpack.config.js +0 -24
  117. data/spec/dummy/config.ru +0 -5
  118. data/spec/dummy/db/seeds.rb +0 -7
  119. data/spec/dummy/lib/assets/.keep +0 -0
  120. data/spec/dummy/lib/tasks/.keep +0 -0
  121. data/spec/dummy/package.json +0 -44
  122. data/spec/dummy/postcss.config.js +0 -12
  123. data/spec/dummy/public/404.html +0 -67
  124. data/spec/dummy/public/422.html +0 -67
  125. data/spec/dummy/public/500.html +0 -66
  126. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  127. data/spec/dummy/public/apple-touch-icon.png +0 -0
  128. data/spec/dummy/public/favicon.ico +0 -0
  129. data/spec/dummy/public/robots.txt +0 -1
  130. data/spec/dummy/spec/rails_helper.rb +0 -118
  131. data/spec/dummy/spec/spec_helper.rb +0 -96
  132. data/spec/dummy/spec/system/hello_world_spec.rb +0 -19
  133. data/spec/dummy/tsconfig.json +0 -21
  134. data/spec/dummy/vendor/.keep +0 -0
  135. data/spec/dummy/yarn.lock +0 -4696
  136. data/spec/fixtures/beta_package-lock.v1.json +0 -119
  137. data/spec/fixtures/beta_package-lock.v2.json +0 -6777
  138. data/spec/fixtures/beta_package.json +0 -13
  139. data/spec/fixtures/beta_pnpm-lock.v7.yaml +0 -116
  140. data/spec/fixtures/beta_pnpm-lock.v8.yaml +0 -2537
  141. data/spec/fixtures/beta_pnpm-lock.v9.yaml +0 -2885
  142. data/spec/fixtures/beta_yarn.v1.lock +0 -106
  143. data/spec/fixtures/beta_yarn.v2.lock +0 -164
  144. data/spec/fixtures/git_url_package-lock.v1.json +0 -118
  145. data/spec/fixtures/git_url_package-lock.v2.json +0 -10263
  146. data/spec/fixtures/git_url_package.json +0 -13
  147. data/spec/fixtures/git_url_pnpm-lock.v7.yaml +0 -126
  148. data/spec/fixtures/git_url_pnpm-lock.v8.yaml +0 -3728
  149. data/spec/fixtures/git_url_pnpm-lock.v9.yaml +0 -4544
  150. data/spec/fixtures/git_url_yarn.v1.lock +0 -106
  151. data/spec/fixtures/git_url_yarn.v2.lock +0 -165
  152. data/spec/fixtures/github_url_package-lock.v1.json +0 -118
  153. data/spec/fixtures/github_url_package-lock.v2.json +0 -10263
  154. data/spec/fixtures/github_url_package.json +0 -13
  155. data/spec/fixtures/github_url_pnpm-lock.v7.yaml +0 -126
  156. data/spec/fixtures/github_url_pnpm-lock.v8.yaml +0 -3728
  157. data/spec/fixtures/github_url_pnpm-lock.v9.yaml +0 -4544
  158. data/spec/fixtures/github_url_yarn.v1.lock +0 -105
  159. data/spec/fixtures/github_url_yarn.v2.lock +0 -165
  160. data/spec/fixtures/relative_path_package-lock.v1.json +0 -3468
  161. data/spec/fixtures/relative_path_package-lock.v2.json +0 -105
  162. data/spec/fixtures/relative_path_package.json +0 -13
  163. data/spec/fixtures/relative_path_pnpm-lock.v7.yaml +0 -18
  164. data/spec/fixtures/relative_path_pnpm-lock.v8.yaml +0 -22
  165. data/spec/fixtures/relative_path_pnpm-lock.v9.yaml +0 -28
  166. data/spec/fixtures/relative_path_yarn.v1.lock +0 -104
  167. data/spec/fixtures/relative_path_yarn.v2.lock +0 -165
  168. data/spec/fixtures/semver_caret_package-lock.v1.json +0 -119
  169. data/spec/fixtures/semver_caret_package-lock.v2.json +0 -10264
  170. data/spec/fixtures/semver_caret_package.json +0 -13
  171. data/spec/fixtures/semver_caret_pnpm-lock.v7.yaml +0 -117
  172. data/spec/fixtures/semver_caret_pnpm-lock.v8.yaml +0 -2558
  173. data/spec/fixtures/semver_caret_pnpm-lock.v9.yaml +0 -4285
  174. data/spec/fixtures/semver_caret_yarn.v1.lock +0 -106
  175. data/spec/fixtures/semver_caret_yarn.v2.lock +0 -165
  176. data/spec/fixtures/semver_exact_package-lock.v1.json +0 -119
  177. data/spec/fixtures/semver_exact_package-lock.v2.json +0 -6819
  178. data/spec/fixtures/semver_exact_package.json +0 -13
  179. data/spec/fixtures/semver_exact_pnpm-lock.v7.yaml +0 -117
  180. data/spec/fixtures/semver_exact_pnpm-lock.v8.yaml +0 -2558
  181. data/spec/fixtures/semver_exact_pnpm-lock.v9.yaml +0 -2908
  182. data/spec/fixtures/semver_exact_yarn.v1.lock +0 -106
  183. data/spec/fixtures/semver_exact_yarn.v2.lock +0 -165
  184. data/spec/fixtures/semver_tilde_package-lock.v1.json +0 -119
  185. data/spec/fixtures/semver_tilde_package-lock.v2.json +0 -6777
  186. data/spec/fixtures/semver_tilde_package.json +0 -13
  187. data/spec/fixtures/semver_tilde_pnpm-lock.v7.yaml +0 -116
  188. data/spec/fixtures/semver_tilde_pnpm-lock.v8.yaml +0 -2558
  189. data/spec/fixtures/semver_tilde_pnpm-lock.v9.yaml +0 -2885
  190. data/spec/fixtures/semver_tilde_yarn.v1.lock +0 -106
  191. data/spec/fixtures/semver_tilde_yarn.v2.lock +0 -164
  192. data/spec/fixtures/without_package-lock.v1.json +0 -19
  193. data/spec/fixtures/without_package-lock.v2.json +0 -47
  194. data/spec/fixtures/without_package.json +0 -13
  195. data/spec/fixtures/without_pnpm-lock.v7.yaml +0 -23
  196. data/spec/fixtures/without_pnpm-lock.v8.yaml +0 -27
  197. data/spec/fixtures/without_pnpm-lock.v9.yaml +0 -34
  198. data/spec/fixtures/without_yarn.v1.lock +0 -13
  199. data/spec/fixtures/without_yarn.v2.lock +0 -29
  200. data/spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb +0 -4
  201. data/spec/generator_specs/e2e_template/files/app/javascript/components/App.js +0 -12
  202. data/spec/generator_specs/e2e_template/files/app/javascript/packs/application.js +0 -10
  203. data/spec/generator_specs/e2e_template/files/app/views/home/index.html.erb +0 -2
  204. data/spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb +0 -17
  205. data/spec/generator_specs/e2e_template/files/config/routes.rb +0 -3
  206. data/spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb +0 -13
  207. data/spec/generator_specs/e2e_template/template.rb +0 -29
  208. data/spec/generator_specs/fake-bin/bun +0 -10
  209. data/spec/generator_specs/fake-bin/npm +0 -10
  210. data/spec/generator_specs/fake-bin/pnpm +0 -10
  211. data/spec/generator_specs/fake-bin/yarn +0 -10
  212. data/spec/generator_specs/generator_spec.rb +0 -193
  213. data/spec/mounted_app/Rakefile +0 -4
  214. data/spec/mounted_app/package.json +0 -1
  215. data/spec/mounted_app/test/dummy/Rakefile +0 -3
  216. data/spec/mounted_app/test/dummy/bin/rails +0 -3
  217. data/spec/mounted_app/test/dummy/bin/rake +0 -3
  218. data/spec/mounted_app/test/dummy/config/application.rb +0 -10
  219. data/spec/mounted_app/test/dummy/config/environment.rb +0 -3
  220. data/spec/mounted_app/test/dummy/config/webpacker.yml +0 -81
  221. data/spec/mounted_app/test/dummy/config.ru +0 -5
  222. data/spec/mounted_app/test/dummy/package.json +0 -7
  223. data/spec/shakapacker/command_spec.rb +0 -134
  224. data/spec/shakapacker/compiler_spec.rb +0 -57
  225. data/spec/shakapacker/compiler_strategy_spec.rb +0 -24
  226. data/spec/shakapacker/configuration_spec.rb +0 -377
  227. data/spec/shakapacker/dev_server_runner_spec.rb +0 -136
  228. data/spec/shakapacker/dev_server_spec.rb +0 -118
  229. data/spec/shakapacker/digest_strategy_spec.rb +0 -59
  230. data/spec/shakapacker/engine_rake_tasks_spec.rb +0 -50
  231. data/spec/shakapacker/env_spec.rb +0 -23
  232. data/spec/shakapacker/helper_spec.rb +0 -243
  233. data/spec/shakapacker/instance_spec.rb +0 -29
  234. data/spec/shakapacker/manifest_spec.rb +0 -100
  235. data/spec/shakapacker/mtime_strategy_spec.rb +0 -55
  236. data/spec/shakapacker/rake_tasks_spec.rb +0 -85
  237. data/spec/shakapacker/shakapacker_spec.rb +0 -40
  238. data/spec/shakapacker/spec_helper_initializer.rb +0 -24
  239. data/spec/shakapacker/test_app/.gitignore +0 -2
  240. data/spec/shakapacker/test_app/Rakefile +0 -3
  241. data/spec/shakapacker/test_app/app/javascript/entrypoints/application.js +0 -10
  242. data/spec/shakapacker/test_app/app/javascript/entrypoints/generated/something.js +0 -2
  243. data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.css +0 -4
  244. data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.js +0 -4
  245. data/spec/shakapacker/test_app/bin/shakapacker +0 -14
  246. data/spec/shakapacker/test_app/bin/shakapacker-dev-server +0 -14
  247. data/spec/shakapacker/test_app/config/application.rb +0 -11
  248. data/spec/shakapacker/test_app/config/environment.rb +0 -4
  249. data/spec/shakapacker/test_app/config/initializers/inspect_autoload_paths.rb +0 -1
  250. data/spec/shakapacker/test_app/config/shakapacker.yml +0 -82
  251. data/spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +0 -83
  252. data/spec/shakapacker/test_app/config/shakapacker_defaults_fallback.yml +0 -11
  253. data/spec/shakapacker/test_app/config/shakapacker_manifest_path.yml +0 -79
  254. data/spec/shakapacker/test_app/config/shakapacker_nested_entries.yml +0 -82
  255. data/spec/shakapacker/test_app/config/shakapacker_no_precompile.yml +0 -7
  256. data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +0 -84
  257. data/spec/shakapacker/test_app/config/shakapacker_public_root.yml +0 -18
  258. data/spec/shakapacker/test_app/config/webpack/webpack.config.js +0 -0
  259. data/spec/shakapacker/test_app/config.ru +0 -5
  260. data/spec/shakapacker/test_app/package.json +0 -14
  261. data/spec/shakapacker/test_app/public/packs/manifest.json +0 -58
  262. data/spec/shakapacker/test_app/some.config.js +0 -0
  263. data/spec/shakapacker/test_app/yarn.lock +0 -11
  264. data/spec/shakapacker/utils_manager_spec.rb +0 -125
  265. data/spec/shakapacker/version_checker_spec.rb +0 -1469
  266. data/spec/shakapacker/webpack_runner_spec.rb +0 -76
  267. data/spec/spec_helper.rb +0 -100
  268. data/spec/support/package_json_helpers.rb +0 -19
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shakapacker",
3
- "version": "8.0.0",
3
+ "version": "8.0.2",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "homepage": "https://github.com/shakacode/shakapacker",
6
6
  "bugs": {
@@ -62,7 +62,7 @@
62
62
  "webpack-assets-manifest": "^5.0.6",
63
63
  "webpack-cli": "^4.9.2 || ^5.0.0",
64
64
  "webpack-dev-server": "^4.9.0 || ^5.0.0",
65
- "webpack-merge": "^5.8.0"
65
+ "webpack-merge": "^5.8.0 || ^6.0.0"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "@types/babel__core": {
data/shakapacker.gemspec CHANGED
@@ -27,6 +27,9 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency "rubocop"
28
28
  s.add_development_dependency "rubocop-performance"
29
29
 
30
- s.files = `git ls-files`.split("\n")
31
- s.test_files = `git ls-files -- test/*`.split("\n")
30
+ s.files = `git ls-files -z`.split("\x0").reject { |f|
31
+ f.match(%r{^(test|spec|features|tmp|node_modules|packages|coverage|Gemfile.lock|rakelib)/})
32
+ }
33
+
34
+ s.test_files = `git ls-files -- test/*`.split("\n")
32
35
  end
@@ -4,6 +4,15 @@ const { chdirTestApp, resetEnv } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Development environment", () => {
8
17
  beforeEach(() => jest.resetModules() && resetEnv())
9
18
  afterAll(() => process.chdir(rootPath))
@@ -10,6 +10,15 @@ chdirTestApp()
10
10
  const baseConfig = require("../../../package/environments/base")
11
11
  const config = require("../../../package/config")
12
12
 
13
+ jest.mock("../../../package/utils/helpers", () => {
14
+ const original = jest.requireActual("../../../package/utils/helpers")
15
+ const moduleExists = () => false
16
+ return {
17
+ ...original,
18
+ moduleExists
19
+ }
20
+ })
21
+
13
22
  describe("Base config", () => {
14
23
  beforeEach(() => jest.resetModules() && resetEnv())
15
24
  afterAll(() => process.chdir(rootPath))
@@ -3,6 +3,15 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
3
3
  const rootPath = process.cwd()
4
4
  chdirTestApp()
5
5
 
6
+ jest.mock("../../../package/utils/helpers", () => {
7
+ const original = jest.requireActual("../../../package/utils/helpers")
8
+ const moduleExists = () => false
9
+ return {
10
+ ...original,
11
+ moduleExists
12
+ }
13
+ })
14
+
6
15
  describe("Development specific config", () => {
7
16
  beforeEach(() => {
8
17
  jest.resetModules()
@@ -3,6 +3,15 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
3
3
  const rootPath = process.cwd()
4
4
  chdirTestApp()
5
5
 
6
+ jest.mock("../../../package/utils/helpers", () => {
7
+ const original = jest.requireActual("../../../package/utils/helpers")
8
+ const moduleExists = () => false
9
+ return {
10
+ ...original,
11
+ moduleExists
12
+ }
13
+ })
14
+
6
15
  describe("Production specific config", () => {
7
16
  beforeEach(() => {
8
17
  jest.resetModules()
@@ -0,0 +1,11 @@
1
+ const { packageMajorVersion } = require("../../package/utils/helpers")
2
+
3
+ describe("packageMajorVersion", () => {
4
+ test("should find that sass-loader is v16", () => {
5
+ expect(packageMajorVersion("sass-loader")).toBe("16")
6
+ })
7
+
8
+ test("should find that nonexistent is v12", () => {
9
+ expect(packageMajorVersion("nonexistent")).toBe("12")
10
+ })
11
+ })
@@ -1,5 +1,14 @@
1
1
  const index = require("../../package/index")
2
2
 
3
+ jest.mock("../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../package/utils/helpers")
5
+ const moduleExists = () => false
6
+ return {
7
+ ...original,
8
+ moduleExists
9
+ }
10
+ })
11
+
3
12
  describe("index", () => {
4
13
  test("exports webpack-merge v5 functions", () => {
5
14
  expect(index.merge).toBeInstanceOf(Function)
@@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Production environment", () => {
8
17
  afterAll(() => process.chdir(rootPath))
9
18
 
@@ -1,5 +1,14 @@
1
1
  const rules = require("../../../package/rules/index")
2
2
 
3
+ jest.mock("../../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../../package/utils/helpers")
5
+ const moduleExists = () => false
6
+ return {
7
+ ...original,
8
+ moduleExists
9
+ }
10
+ })
11
+
3
12
  describe("index", () => {
4
13
  test("rule tests are regexes", () => {
5
14
  rules.forEach((rule) => expect(rule.test instanceof RegExp).toBe(true))
@@ -0,0 +1,23 @@
1
+ const sass = require("../../../package/rules/sass")
2
+
3
+ jest.mock("../../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../../package/utils/helpers")
5
+ const canProcess = (rule, fn) => {
6
+ return fn("This path was mocked")
7
+ }
8
+ const packageMajorVersion = () => "15"
9
+ return {
10
+ ...original,
11
+ canProcess,
12
+ packageMajorVersion
13
+ }
14
+ })
15
+
16
+ jest.mock("../../../package/utils/inliningCss", () => true)
17
+
18
+ describe("sass rule", () => {
19
+ test("contains loadPaths as the sassOptions key if sass-loader is v15 or earlier", () => {
20
+ expect(typeof sass.use[3].options.sassOptions.includePaths).toBe("object")
21
+ expect(typeof sass.use[3].options.sassOptions.loadPaths).toBe("undefined")
22
+ })
23
+ })
@@ -0,0 +1,23 @@
1
+ const sass = require("../../../package/rules/sass")
2
+
3
+ jest.mock("../../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../../package/utils/helpers")
5
+ const canProcess = (rule, fn) => {
6
+ return fn("This path was mocked")
7
+ }
8
+ return {
9
+ ...original,
10
+ canProcess
11
+ }
12
+ })
13
+
14
+ jest.mock("../../../package/utils/inliningCss", () => true)
15
+
16
+ describe("sass rule", () => {
17
+ test("contains loadPaths as the sassOptions key if sass-loader is v15 or earlier", () => {
18
+ expect(typeof sass.use[3].options.sassOptions.includePaths).toBe(
19
+ "undefined"
20
+ )
21
+ expect(typeof sass.use[3].options.sassOptions.loadPaths).toBe("object")
22
+ })
23
+ })
@@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Custom environment", () => {
8
17
  afterAll(() => process.chdir(rootPath))
9
18
 
@@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Test environment", () => {
8
17
  afterAll(() => process.chdir(rootPath))
9
18
 
data/test/resolver.js ADDED
@@ -0,0 +1,13 @@
1
+ const mapping = {
2
+ "css-loader": "this path was mocked",
3
+ "sass-loader/package.json": "../../__mocks__/sass-loader/package.json",
4
+ "nonexistent/package.json": "../../__mocks__/nonexistent/package.json"
5
+ }
6
+
7
+ function resolver(module, options) {
8
+ // If the path corresponds to a key in the mapping object, returns the fakely resolved path
9
+ // otherwise it calls the Jest's default resolver
10
+ return mapping[module] || options.defaultResolver(module, options)
11
+ }
12
+
13
+ module.exports = resolver
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shakapacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0
4
+ version: 8.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-05-18 00:00:00.000000000 Z
13
+ date: 2024-08-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -151,9 +151,12 @@ files:
151
151
  - CONTRIBUTING.md
152
152
  - Gemfile
153
153
  - Gemfile.development_dependencies
154
+ - Gemfile.lock
154
155
  - MIT-LICENSE
155
156
  - README.md
156
157
  - Rakefile
158
+ - __mocks__/nonexistent/package.json
159
+ - __mocks__/sass-loader/package.json
157
160
  - config/README.md
158
161
  - config/shakapacker.yml
159
162
  - docs/customizing_babel_config.md
@@ -177,7 +180,6 @@ files:
177
180
  - lib/install/application.js
178
181
  - lib/install/bin/shakapacker
179
182
  - lib/install/bin/shakapacker-dev-server
180
- - lib/install/bin/yarn
181
183
  - lib/install/binstubs.rb
182
184
  - lib/install/config/shakapacker.yml
183
185
  - lib/install/config/webpack/webpack.config.js
@@ -252,237 +254,7 @@ files:
252
254
  - package/utils/snakeToCamelCase.js
253
255
  - package/webpackDevServerConfig.js
254
256
  - prettier.config.js
255
- - rakelib/release.rake
256
257
  - shakapacker.gemspec
257
- - spec/dummy/.browserslistrc
258
- - spec/dummy/.gitignore
259
- - spec/dummy/.prettierrc.yaml
260
- - spec/dummy/Gemfile
261
- - spec/dummy/Procfile.dev
262
- - spec/dummy/Procfile.dev-static
263
- - spec/dummy/README.md
264
- - spec/dummy/Rakefile
265
- - spec/dummy/app/assets/config/manifest.js
266
- - spec/dummy/app/assets/images/.keep
267
- - spec/dummy/app/assets/stylesheets/application.css
268
- - spec/dummy/app/channels/application_cable/channel.rb
269
- - spec/dummy/app/channels/application_cable/connection.rb
270
- - spec/dummy/app/controllers/application_controller.rb
271
- - spec/dummy/app/controllers/concerns/.keep
272
- - spec/dummy/app/controllers/hello_world_controller.rb
273
- - spec/dummy/app/helpers/application_helper.rb
274
- - spec/dummy/app/javascript/Globals.d.ts
275
- - spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css
276
- - spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx
277
- - spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx
278
- - spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg
279
- - spec/dummy/app/javascript/packs/application.js
280
- - spec/dummy/app/javascript/packs/hello-world-bundle.ts
281
- - spec/dummy/app/javascript/packs/server-bundle.ts
282
- - spec/dummy/app/jobs/application_job.rb
283
- - spec/dummy/app/mailers/application_mailer.rb
284
- - spec/dummy/app/models/application_record.rb
285
- - spec/dummy/app/models/concerns/.keep
286
- - spec/dummy/app/views/hello_world/index.html.erb
287
- - spec/dummy/app/views/layouts/application.html.erb
288
- - spec/dummy/app/views/layouts/hello_world.html.erb
289
- - spec/dummy/app/views/layouts/mailer.html.erb
290
- - spec/dummy/app/views/layouts/mailer.text.erb
291
- - spec/dummy/babel.config.js
292
- - spec/dummy/bin/bundle
293
- - spec/dummy/bin/dev
294
- - spec/dummy/bin/dev-static
295
- - spec/dummy/bin/rails
296
- - spec/dummy/bin/rake
297
- - spec/dummy/bin/setup
298
- - spec/dummy/bin/shakapacker
299
- - spec/dummy/bin/shakapacker-dev-server
300
- - spec/dummy/bin/spring
301
- - spec/dummy/bin/yarn
302
- - spec/dummy/config.ru
303
- - spec/dummy/config/application.rb
304
- - spec/dummy/config/boot.rb
305
- - spec/dummy/config/cable.yml
306
- - spec/dummy/config/credentials.yml.enc
307
- - spec/dummy/config/database.yml
308
- - spec/dummy/config/environment.rb
309
- - spec/dummy/config/environments/development.rb
310
- - spec/dummy/config/environments/production.rb
311
- - spec/dummy/config/environments/test.rb
312
- - spec/dummy/config/initializers/application_controller_renderer.rb
313
- - spec/dummy/config/initializers/backtrace_silencers.rb
314
- - spec/dummy/config/initializers/content_security_policy.rb
315
- - spec/dummy/config/initializers/cookies_serializer.rb
316
- - spec/dummy/config/initializers/filter_parameter_logging.rb
317
- - spec/dummy/config/initializers/inflections.rb
318
- - spec/dummy/config/initializers/mime_types.rb
319
- - spec/dummy/config/initializers/react_on_rails.rb
320
- - spec/dummy/config/initializers/wrap_parameters.rb
321
- - spec/dummy/config/locales/en.yml
322
- - spec/dummy/config/puma.rb
323
- - spec/dummy/config/routes.rb
324
- - spec/dummy/config/shakapacker.yml
325
- - spec/dummy/config/spring.rb
326
- - spec/dummy/config/storage.yml
327
- - spec/dummy/config/webpack/ServerClientOrBoth.js
328
- - spec/dummy/config/webpack/clientWebpackConfig.js
329
- - spec/dummy/config/webpack/commonWebpackConfig.js
330
- - spec/dummy/config/webpack/development.js
331
- - spec/dummy/config/webpack/production.js
332
- - spec/dummy/config/webpack/serverWebpackConfig.js
333
- - spec/dummy/config/webpack/test.js
334
- - spec/dummy/config/webpack/webpack.config.js
335
- - spec/dummy/db/seeds.rb
336
- - spec/dummy/lib/assets/.keep
337
- - spec/dummy/lib/tasks/.keep
338
- - spec/dummy/package.json
339
- - spec/dummy/postcss.config.js
340
- - spec/dummy/public/404.html
341
- - spec/dummy/public/422.html
342
- - spec/dummy/public/500.html
343
- - spec/dummy/public/apple-touch-icon-precomposed.png
344
- - spec/dummy/public/apple-touch-icon.png
345
- - spec/dummy/public/favicon.ico
346
- - spec/dummy/public/robots.txt
347
- - spec/dummy/spec/rails_helper.rb
348
- - spec/dummy/spec/spec_helper.rb
349
- - spec/dummy/spec/system/hello_world_spec.rb
350
- - spec/dummy/tsconfig.json
351
- - spec/dummy/vendor/.keep
352
- - spec/dummy/yarn.lock
353
- - spec/fixtures/beta_package-lock.v1.json
354
- - spec/fixtures/beta_package-lock.v2.json
355
- - spec/fixtures/beta_package.json
356
- - spec/fixtures/beta_pnpm-lock.v7.yaml
357
- - spec/fixtures/beta_pnpm-lock.v8.yaml
358
- - spec/fixtures/beta_pnpm-lock.v9.yaml
359
- - spec/fixtures/beta_yarn.v1.lock
360
- - spec/fixtures/beta_yarn.v2.lock
361
- - spec/fixtures/git_url_package-lock.v1.json
362
- - spec/fixtures/git_url_package-lock.v2.json
363
- - spec/fixtures/git_url_package.json
364
- - spec/fixtures/git_url_pnpm-lock.v7.yaml
365
- - spec/fixtures/git_url_pnpm-lock.v8.yaml
366
- - spec/fixtures/git_url_pnpm-lock.v9.yaml
367
- - spec/fixtures/git_url_yarn.v1.lock
368
- - spec/fixtures/git_url_yarn.v2.lock
369
- - spec/fixtures/github_url_package-lock.v1.json
370
- - spec/fixtures/github_url_package-lock.v2.json
371
- - spec/fixtures/github_url_package.json
372
- - spec/fixtures/github_url_pnpm-lock.v7.yaml
373
- - spec/fixtures/github_url_pnpm-lock.v8.yaml
374
- - spec/fixtures/github_url_pnpm-lock.v9.yaml
375
- - spec/fixtures/github_url_yarn.v1.lock
376
- - spec/fixtures/github_url_yarn.v2.lock
377
- - spec/fixtures/relative_path_package-lock.v1.json
378
- - spec/fixtures/relative_path_package-lock.v2.json
379
- - spec/fixtures/relative_path_package.json
380
- - spec/fixtures/relative_path_pnpm-lock.v7.yaml
381
- - spec/fixtures/relative_path_pnpm-lock.v8.yaml
382
- - spec/fixtures/relative_path_pnpm-lock.v9.yaml
383
- - spec/fixtures/relative_path_yarn.v1.lock
384
- - spec/fixtures/relative_path_yarn.v2.lock
385
- - spec/fixtures/semver_caret_package-lock.v1.json
386
- - spec/fixtures/semver_caret_package-lock.v2.json
387
- - spec/fixtures/semver_caret_package.json
388
- - spec/fixtures/semver_caret_pnpm-lock.v7.yaml
389
- - spec/fixtures/semver_caret_pnpm-lock.v8.yaml
390
- - spec/fixtures/semver_caret_pnpm-lock.v9.yaml
391
- - spec/fixtures/semver_caret_yarn.v1.lock
392
- - spec/fixtures/semver_caret_yarn.v2.lock
393
- - spec/fixtures/semver_exact_package-lock.v1.json
394
- - spec/fixtures/semver_exact_package-lock.v2.json
395
- - spec/fixtures/semver_exact_package.json
396
- - spec/fixtures/semver_exact_pnpm-lock.v7.yaml
397
- - spec/fixtures/semver_exact_pnpm-lock.v8.yaml
398
- - spec/fixtures/semver_exact_pnpm-lock.v9.yaml
399
- - spec/fixtures/semver_exact_yarn.v1.lock
400
- - spec/fixtures/semver_exact_yarn.v2.lock
401
- - spec/fixtures/semver_tilde_package-lock.v1.json
402
- - spec/fixtures/semver_tilde_package-lock.v2.json
403
- - spec/fixtures/semver_tilde_package.json
404
- - spec/fixtures/semver_tilde_pnpm-lock.v7.yaml
405
- - spec/fixtures/semver_tilde_pnpm-lock.v8.yaml
406
- - spec/fixtures/semver_tilde_pnpm-lock.v9.yaml
407
- - spec/fixtures/semver_tilde_yarn.v1.lock
408
- - spec/fixtures/semver_tilde_yarn.v2.lock
409
- - spec/fixtures/without_package-lock.v1.json
410
- - spec/fixtures/without_package-lock.v2.json
411
- - spec/fixtures/without_package.json
412
- - spec/fixtures/without_pnpm-lock.v7.yaml
413
- - spec/fixtures/without_pnpm-lock.v8.yaml
414
- - spec/fixtures/without_pnpm-lock.v9.yaml
415
- - spec/fixtures/without_yarn.v1.lock
416
- - spec/fixtures/without_yarn.v2.lock
417
- - spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb
418
- - spec/generator_specs/e2e_template/files/app/javascript/components/App.js
419
- - spec/generator_specs/e2e_template/files/app/javascript/packs/application.js
420
- - spec/generator_specs/e2e_template/files/app/views/home/index.html.erb
421
- - spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb
422
- - spec/generator_specs/e2e_template/files/config/routes.rb
423
- - spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb
424
- - spec/generator_specs/e2e_template/template.rb
425
- - spec/generator_specs/fake-bin/bun
426
- - spec/generator_specs/fake-bin/npm
427
- - spec/generator_specs/fake-bin/pnpm
428
- - spec/generator_specs/fake-bin/yarn
429
- - spec/generator_specs/generator_spec.rb
430
- - spec/mounted_app/Rakefile
431
- - spec/mounted_app/package.json
432
- - spec/mounted_app/test/dummy/Rakefile
433
- - spec/mounted_app/test/dummy/bin/rails
434
- - spec/mounted_app/test/dummy/bin/rake
435
- - spec/mounted_app/test/dummy/config.ru
436
- - spec/mounted_app/test/dummy/config/application.rb
437
- - spec/mounted_app/test/dummy/config/environment.rb
438
- - spec/mounted_app/test/dummy/config/webpacker.yml
439
- - spec/mounted_app/test/dummy/package.json
440
- - spec/shakapacker/command_spec.rb
441
- - spec/shakapacker/compiler_spec.rb
442
- - spec/shakapacker/compiler_strategy_spec.rb
443
- - spec/shakapacker/configuration_spec.rb
444
- - spec/shakapacker/dev_server_runner_spec.rb
445
- - spec/shakapacker/dev_server_spec.rb
446
- - spec/shakapacker/digest_strategy_spec.rb
447
- - spec/shakapacker/engine_rake_tasks_spec.rb
448
- - spec/shakapacker/env_spec.rb
449
- - spec/shakapacker/helper_spec.rb
450
- - spec/shakapacker/instance_spec.rb
451
- - spec/shakapacker/manifest_spec.rb
452
- - spec/shakapacker/mtime_strategy_spec.rb
453
- - spec/shakapacker/rake_tasks_spec.rb
454
- - spec/shakapacker/shakapacker_spec.rb
455
- - spec/shakapacker/spec_helper_initializer.rb
456
- - spec/shakapacker/test_app/.gitignore
457
- - spec/shakapacker/test_app/Rakefile
458
- - spec/shakapacker/test_app/app/javascript/entrypoints/application.js
459
- - spec/shakapacker/test_app/app/javascript/entrypoints/generated/something.js
460
- - spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.css
461
- - spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.js
462
- - spec/shakapacker/test_app/bin/shakapacker
463
- - spec/shakapacker/test_app/bin/shakapacker-dev-server
464
- - spec/shakapacker/test_app/config.ru
465
- - spec/shakapacker/test_app/config/application.rb
466
- - spec/shakapacker/test_app/config/environment.rb
467
- - spec/shakapacker/test_app/config/initializers/inspect_autoload_paths.rb
468
- - spec/shakapacker/test_app/config/shakapacker.yml
469
- - spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml
470
- - spec/shakapacker/test_app/config/shakapacker_defaults_fallback.yml
471
- - spec/shakapacker/test_app/config/shakapacker_manifest_path.yml
472
- - spec/shakapacker/test_app/config/shakapacker_nested_entries.yml
473
- - spec/shakapacker/test_app/config/shakapacker_no_precompile.yml
474
- - spec/shakapacker/test_app/config/shakapacker_other_location.yml
475
- - spec/shakapacker/test_app/config/shakapacker_public_root.yml
476
- - spec/shakapacker/test_app/config/webpack/webpack.config.js
477
- - spec/shakapacker/test_app/package.json
478
- - spec/shakapacker/test_app/public/packs/manifest.json
479
- - spec/shakapacker/test_app/some.config.js
480
- - spec/shakapacker/test_app/yarn.lock
481
- - spec/shakapacker/utils_manager_spec.rb
482
- - spec/shakapacker/version_checker_spec.rb
483
- - spec/shakapacker/webpack_runner_spec.rb
484
- - spec/spec_helper.rb
485
- - spec/support/package_json_helpers.rb
486
258
  - test/helpers.js
487
259
  - test/package/config.test.js
488
260
  - test/package/dev_server.test.js
@@ -491,6 +263,7 @@ files:
491
263
  - test/package/environments/base.test.js
492
264
  - test/package/environments/development.test.js
493
265
  - test/package/environments/production.test.js
266
+ - test/package/helpers.test.js
494
267
  - test/package/index.test.js
495
268
  - test/package/production.test.js
496
269
  - test/package/rules/babel.test.js
@@ -498,15 +271,18 @@ files:
498
271
  - test/package/rules/file.test.js
499
272
  - test/package/rules/index.test.js
500
273
  - test/package/rules/raw.test.js
274
+ - test/package/rules/sass.test.js
275
+ - test/package/rules/sass1.test.js
501
276
  - test/package/rules/swc.test.js
502
277
  - test/package/staging.test.js
503
278
  - test/package/test.test.js
279
+ - test/resolver.js
504
280
  - yarn.lock
505
281
  homepage: https://github.com/shakacode/shakapacker
506
282
  licenses:
507
283
  - MIT
508
284
  metadata:
509
- source_code_uri: https://github.com/shakacode/shakapacker/tree/v8.0.0
285
+ source_code_uri: https://github.com/shakacode/shakapacker/tree/v8.0.2
510
286
  post_install_message:
511
287
  rdoc_options: []
512
288
  require_paths:
@@ -522,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
522
298
  - !ruby/object:Gem::Version
523
299
  version: '0'
524
300
  requirements: []
525
- rubygems_version: 3.4.12
301
+ rubygems_version: 3.5.3
526
302
  signing_key:
527
303
  specification_version: 4
528
304
  summary: Use webpack to manage app-like JavaScript modules in Rails
@@ -535,6 +311,7 @@ test_files:
535
311
  - test/package/environments/base.test.js
536
312
  - test/package/environments/development.test.js
537
313
  - test/package/environments/production.test.js
314
+ - test/package/helpers.test.js
538
315
  - test/package/index.test.js
539
316
  - test/package/production.test.js
540
317
  - test/package/rules/babel.test.js
@@ -542,6 +319,9 @@ test_files:
542
319
  - test/package/rules/file.test.js
543
320
  - test/package/rules/index.test.js
544
321
  - test/package/rules/raw.test.js
322
+ - test/package/rules/sass.test.js
323
+ - test/package/rules/sass1.test.js
545
324
  - test/package/rules/swc.test.js
546
325
  - test/package/staging.test.js
547
326
  - test/package/test.test.js
327
+ - test/resolver.js
data/lib/install/bin/yarn DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- APP_ROOT = File.expand_path("..", __dir__)
4
- Dir.chdir(APP_ROOT) do
5
- yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
6
- select { |dir| File.expand_path(dir) != __dir__ }.
7
- product(["yarn", "yarnpkg", "yarn.cmd", "yarn.ps1"]).
8
- map { |dir, file| File.expand_path(file, dir) }.
9
- find { |file| File.executable?(file) }
10
-
11
- if yarn
12
- exec yarn, *ARGV
13
- else
14
- $stderr.puts "Yarn executable was not detected in the system."
15
- $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
16
- exit 1
17
- end
18
- end
data/rakelib/release.rake DELETED
@@ -1,65 +0,0 @@
1
- require_relative File.join("..", "lib", "shakapacker", "utils", "version_syntax_converter")
2
- require_relative File.join("..", "lib", "shakapacker", "utils", "misc")
3
-
4
- class RaisingMessageHandler
5
- def add_error(error)
6
- raise error
7
- end
8
- end
9
-
10
- desc("Releases both the gem and node package using the given version.
11
-
12
- IMPORTANT: the gem version must be in valid rubygem format (no dashes).
13
- It will be automatically converted to a valid yarn semver by the rake task
14
- for the node package version. This only makes a difference for pre-release
15
- versions such as `3.0.0.beta.1` (yarn version would be `3.0.0-beta.1`).
16
-
17
- This task depends on the gem-release (ruby gem) and release-it (node package)
18
- which are installed via `bundle install` and `yarn global add release-it`
19
-
20
- 1st argument: The new version in rubygem format (no dashes). Pass no argument to
21
- automatically perform a patch version bump.
22
- 2nd argument: Perform a dry run by passing 'true' as a second argument.
23
-
24
- Note, accept defaults for npmjs options. Script will pause to get 2FA tokens.
25
-
26
- Example: `rake release[2.1.0,false]`")
27
- task :create_release, %i[gem_version dry_run] do |_t, args|
28
- # Check if there are uncommitted changes
29
- Shakapacker::Utils::Misc.uncommitted_changes?(RaisingMessageHandler.new)
30
- args_hash = args.to_hash
31
-
32
- is_dry_run = Shakapacker::Utils::Misc.object_to_boolean(args_hash[:dry_run])
33
-
34
- gem_version = args_hash.fetch(:gem_version, "")
35
-
36
- gem_root = File.expand_path("..", __dir__)
37
-
38
- npm_version = if gem_version.strip.empty?
39
- ""
40
- else
41
- Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(gem_version)
42
- end
43
-
44
- # See https://github.com/svenfuchs/gem-release
45
- Shakapacker::Utils::Misc.sh_in_dir(gem_root, "git pull --rebase")
46
- Shakapacker::Utils::Misc.sh_in_dir(gem_root, "gem bump --no-commit #{gem_version.strip.empty? ? '' : %(--version #{gem_version})}")
47
- Shakapacker::Utils::Misc.sh_in_dir(gem_root, "bundle install")
48
-
49
- # Will bump the yarn version, commit, tag the commit, push to repo, and release on yarn
50
- release_it_command = +"release-it"
51
- release_it_command << " #{npm_version}" unless npm_version.strip.empty?
52
- release_it_command << " --npm.publish --no-git.requireCleanWorkingDir"
53
- release_it_command << " --dry-run --verbose" if is_dry_run
54
- puts "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
55
- puts "Use the OTP for NPM!"
56
- puts "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
57
- Shakapacker::Utils::Misc.sh_in_dir(gem_root, release_it_command)
58
-
59
- # Release the new gem version
60
- puts "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
61
- puts "Use the OTP for RubyGems!"
62
- puts "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
63
-
64
- Shakapacker::Utils::Misc.sh_in_dir(gem_root, "gem release") unless is_dry_run
65
- end