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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Readme.md +5 -4
- data/lib/js_routes/generators/base.rb +16 -0
- data/lib/js_routes/generators/middleware.rb +9 -8
- data/lib/js_routes/generators/webpacker.rb +3 -1
- data/lib/js_routes/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55d34a6a511e250d1fc59aa2e868a3148734bc6fafc6f156ff86eea1f0d6f81e
|
4
|
+
data.tar.gz: 94143965ae4a2a14db535dd484521c3348c18eee2ca6f61ee72186e908cdc786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d727f254cec5e5269e92ef1180309aacb3362fc4aa8065c2fb604237d9096918c1e0ab534b7b443df656fb5218962e949522ce3338b4be9d99e17d0268f6efbb
|
7
|
+
data.tar.gz: 9ce12dc8aefab9a646aadc2318e541f6b422fc9340856e69488889374727c7de7f7e70fa8fbe510263b9d7f5edf2097657ae62fac0a90d0206b9b2be5481b48a
|
data/CHANGELOG.md
CHANGED
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
|
63
|
+
Upgrade js building process to update js-routes files in `Rakefile`:
|
64
64
|
|
65
65
|
``` ruby
|
66
|
-
|
67
|
-
|
68
|
-
|
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 "
|
1
|
+
require "js_routes/generators/base"
|
2
2
|
|
3
|
-
class JsRoutes::Generators::Middleware <
|
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
|
-
#
|
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
|
-
|
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
|
data/lib/js_routes/version.rb
CHANGED
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.
|
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-
|
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
|