js-routes 2.2.5 → 2.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0fd81f6f8575bb26353c7e485f0551cc62420a266e22d5503739332b5762037
4
- data.tar.gz: b84d4ad0f70f8e1f454bdd2c6fb8b77a316376b3407a3fd0b6c681d87b87ada9
3
+ metadata.gz: 55d34a6a511e250d1fc59aa2e868a3148734bc6fafc6f156ff86eea1f0d6f81e
4
+ data.tar.gz: 94143965ae4a2a14db535dd484521c3348c18eee2ca6f61ee72186e908cdc786
5
5
  SHA512:
6
- metadata.gz: 23db2ecfc872d470727b60d7c63148aa15d9d5b76d6eaedbf7bbe5ee964ae5ca5abfb09f69199dd813fcd0b09b12d0920fcb0abf9b09a1bb2a6dbfbaf7884e75
7
- data.tar.gz: faf0d713243b705277604493bdf2f5d9f61c5cd953ef9bcfbcd1f2d88fdfd850d27ed48e0740f0fa4c0f4492a310bec13d6a76fc070113703ab7e7750e812b0c
6
+ metadata.gz: d727f254cec5e5269e92ef1180309aacb3362fc4aa8065c2fb604237d9096918c1e0ab534b7b443df656fb5218962e949522ce3338b4be9d99e17d0268f6efbb
7
+ data.tar.gz: 9ce12dc8aefab9a646aadc2318e541f6b422fc9340856e69488889374727c7de7f7e70fa8fbe510263b9d7f5edf2097657ae62fac0a90d0206b9b2be5481b48a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## master
2
2
 
3
+ ## v2.2.6
4
+
5
+ * Prefer to extend `javascript:build` instead of `assets:precompile`. [#305](https://github.com/railsware/js-routes/issues/305)
6
+ * Add stimulus framework application.js location to generators
3
7
 
4
8
  ## v2.2.5
5
9
 
data/Readme.md CHANGED
@@ -60,12 +60,13 @@ import {post_path} from '../routes';
60
60
  alert(post_path(1))
61
61
  ```
62
62
 
63
- Upgrade `rake assets:precompile` to update js-routes files in `Rakefile`:
63
+ Upgrade js building process to update js-routes files in `Rakefile`:
64
64
 
65
65
  ``` ruby
66
- namespace :assets do
67
- task :precompile => "js:routes:typescript"
68
- end
66
+ task "javascript:build" => "js:routes:typescript"
67
+ # For setups without jsbundling-rails
68
+ task "assets:precompile" => "js:routes:typescript"
69
+
69
70
  ```
70
71
 
71
72
  Add js-routes files to `.gitignore`:
@@ -0,0 +1,16 @@
1
+
2
+ require "rails/generators"
3
+
4
+ class JsRoutes::Generators::Base < Rails::Generators::Base
5
+
6
+ protected
7
+
8
+ def application_js_path
9
+ [
10
+ "app/javascript/packs/application.js",
11
+ "app/javascript/controllers/application.js",
12
+ ].find do |path|
13
+ File.exists?(Rails.root.join(path))
14
+ end
15
+ end
16
+ end
@@ -1,15 +1,17 @@
1
- require "rails/generators"
1
+ require "js_routes/generators/base"
2
2
 
3
- class JsRoutes::Generators::Middleware < Rails::Generators::Base
3
+ class JsRoutes::Generators::Middleware < JsRoutes::Generators::Base
4
4
 
5
5
  source_root File.expand_path(__FILE__ + "/../../../templates")
6
6
 
7
7
  def create_middleware
8
8
  copy_file "initializer.rb", "config/initializers/js_routes.rb"
9
- inject_into_file "app/javascript/packs/application.js", pack_content
10
9
  inject_into_file "config/environments/development.rb", middleware_content, before: /^end\n\z/
11
10
  inject_into_file "Rakefile", rakefile_content
12
11
  inject_into_file ".gitignore", gitignore_content
12
+ if path = application_js_path
13
+ inject_into_file path, pack_content
14
+ end
13
15
  JsRoutes.generate!
14
16
  JsRoutes.definitions!
15
17
  end
@@ -33,12 +35,11 @@ window.Routes = Routes;
33
35
  end
34
36
 
35
37
  def rakefile_content
38
+ enhanced_task = Bundler.load.gems.find {|g| g.name = 'jsbundling-rails'} ?
39
+ "javascript:build" : "assets:precompile"
36
40
  <<-RB
37
-
38
- # Update js-routes file before assets precompile
39
- namespace :assets do
40
- task :precompile => "js:routes:typescript"
41
- end
41
+ # Update js-routes file before javascript build
42
+ task "#{enhanced_task}" => "js:routes:typescript"
42
43
  RB
43
44
  end
44
45
 
@@ -9,7 +9,9 @@ class JsRoutes::Generators::Webpacker < Rails::Generators::Base
9
9
  copy_file "erb.js", "config/webpack/loaders/erb.js"
10
10
  copy_file "routes.js.erb", "app/javascript/routes.js.erb"
11
11
  inject_into_file "config/webpack/environment.js", loader_content
12
- inject_into_file "app/javascript/packs/application.js", pack_content
12
+ if path = application_js_path
13
+ inject_into_file path, pack_content
14
+ end
13
15
  command = Rails.root.join("./bin/yarn add rails-erb-loader")
14
16
  run command
15
17
  end
@@ -1,3 +1,3 @@
1
1
  module JsRoutes
2
- VERSION = "2.2.5"
2
+ VERSION = "2.2.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-08 00:00:00.000000000 Z
11
+ date: 2023-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -167,6 +167,7 @@ files:
167
167
  - lib/js_routes.rb
168
168
  - lib/js_routes/configuration.rb
169
169
  - lib/js_routes/engine.rb
170
+ - lib/js_routes/generators/base.rb
170
171
  - lib/js_routes/generators/middleware.rb
171
172
  - lib/js_routes/generators/webpacker.rb
172
173
  - lib/js_routes/instance.rb