webpacker-routes 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45d682934f746c30fe5ff59bfb675749f634a3fe89e5ead1cb25db96e21cc988
4
- data.tar.gz: 4b579957ca80602172e1afbdafcd245afad774672679db4d88a1d814fbb77429
3
+ metadata.gz: bb945c3a04e8ac9462f27534db1827f05d197fb2b68f0e97adc154514151543d
4
+ data.tar.gz: 24e3ccbc0f592cbafd624dd11abe7bbce8c0e252f2cff2be90986cbaf25732a8
5
5
  SHA512:
6
- metadata.gz: 4718506c50f4998facbf7bcae58e2529d01ba25e77c38c9172ad8516b4c01a9233e728ff834f68bece906589cbfdbf4a6a309b112bd2fdfd2fd4ec784ef99996
7
- data.tar.gz: 2eeb6aaad2b8dd58d4f13ec6a00d7c7d790ac4ac89c3b8e769bef2e9c9dd927ebbfe771bd43cdd56f57f527849fdb2d67187e61ad669bdab529e1b5c6ad7af55
6
+ metadata.gz: 3c9977a5410055272581848d8fe57305cd88b8d9261100dc7892d212b89ae0411defa277b514f849a9c41c6682ad3ff98ae07306231407bcfaaeaae5af0583b5
7
+ data.tar.gz: 372e3e32cc92f432f449c41c43a035bbc9598dff9f6fc2926bd0f95607bcd7d3fcc627f46b53654619468afd8b0f80fa51ba3dc50d89947f574f1bedb4066c62
data/README.md CHANGED
@@ -14,13 +14,6 @@ $ bundle
14
14
  $ bundle exec rails webpacker:install:routes
15
15
  ```
16
16
 
17
- Finally, generate your routes file:
18
- ```bash
19
- $ bundle exec rails webpacker:routes:generate
20
- ```
21
-
22
- You will need to regenerate the routes file whenever you add a new Rails route.
23
-
24
17
  ## Usage
25
18
  Import individual routes from any Webpacker-compiled file:
26
19
 
@@ -30,12 +23,19 @@ import { root_path } from 'routes'
30
23
  console.log(root_path())
31
24
  ```
32
25
 
26
+ The routes file is generated when Rails starts, including during `webpacker:compile` (or `assets:precompile`).
27
+ In development, routes will be updated when a file changes and a request is processed.
28
+
29
+ To generate routes manually, run:
30
+ ```bash
31
+ $ bundle exec rails webpacker:routes:generate
32
+ ```
33
+
33
34
  ## License
34
35
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
35
36
 
36
37
  ## TODO
37
38
 
38
- - fix handle_positional_args in rails
39
39
  - somehow generate routes automatically in development
40
40
  - to_prepare?
41
41
  - support all valid route names
@@ -1,5 +1,5 @@
1
1
  say "Creating JavaScript app source directory"
2
- directory "#{__dir__}/javascript", Webpacker.config.source_path.join('routes')
2
+ file Webpacker.config.routes_path.join('.gitignore'), "/index.js\n"
3
3
 
4
4
  say "Installing all JavaScript dependencies"
5
- run "yarn add webpacker-routes@0.0.7 --exact"
5
+ run "yarn add webpacker-routes@#{Webpacker::Routes::VERSION} --exact"
@@ -3,11 +3,9 @@ namespace :webpacker do
3
3
  desc "Install everything needed for routes"
4
4
  task routes: ["webpacker:verify_install"] do
5
5
  template = File.expand_path("../../install/template.rb", __dir__)
6
- if Rails::VERSION::MAJOR >= 5
7
- exec "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{template}"
8
- else
9
- exec "#{RbConfig.ruby} ./bin/rake rails:template LOCATION=#{template}"
10
- end
6
+ command = Rails::VERSION::MAJOR >= 5 ? 'rails app' : 'rake rails'
7
+ arguments = "LOCATION=#{template} WEBPACKER_ROUTES_INSTALL=true"
8
+ exec "#{RbConfig.ruby} ./bin/#{command}:template #{arguments}"
11
9
  end
12
10
  end
13
11
 
@@ -16,7 +14,7 @@ namespace :webpacker do
16
14
  task verify_install: ["webpacker:verify_install"] do
17
15
  if Webpacker.config.routes_path.exist?
18
16
  $stdout.puts "Webpacker Routes is installed 🎉 🍰"
19
- $stdout.puts "Using #{Webpacker.config.routes_path} file for generating routes"
17
+ $stdout.puts "Using #{Webpacker.config.routes_path} directory for generating routes"
20
18
  else
21
19
  $stderr.puts "Webpacker Routes directory not found. \n"\
22
20
  "Make sure webpacker:install:routes is run successfully before " \
@@ -1,6 +1,11 @@
1
1
  module Webpacker
2
2
  module Routes
3
3
  class Engine < ::Rails::Engine
4
+ config.after_initialize do |app|
5
+ generate = -> { Webpacker::Routes.generate(app.tap(&:reload_routes!).routes) }
6
+ app.reloader.to_run(&generate)
7
+ generate.call unless ENV['WEBPACKER_ROUTES_INSTALL'] == 'true'
8
+ end
4
9
  end
5
10
  end
6
11
  end
@@ -1,5 +1,5 @@
1
1
  module Webpacker
2
2
  module Routes
3
- VERSION = '0.0.7'
3
+ VERSION = '0.0.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker-routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Harsha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-14 00:00:00.000000000 Z
11
+ date: 2019-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -76,7 +76,6 @@ files:
76
76
  - MIT-LICENSE
77
77
  - README.md
78
78
  - Rakefile
79
- - lib/install/javascript/index.js
80
79
  - lib/install/template.rb
81
80
  - lib/tasks/webpacker/routes_tasks.rake
82
81
  - lib/webpacker/routes.rb
@@ -1 +0,0 @@
1
- // run `webpacker:routes:generate`