js-routes 1.4.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.eslintrc.js +15 -0
- data/.gitignore +5 -0
- data/.nvmrc +1 -0
- data/.travis.yml +37 -30
- data/Appraisals +16 -13
- data/CHANGELOG.md +95 -0
- data/Rakefile +6 -2
- data/Readme.md +220 -88
- data/VERSION_2_UPGRADE.md +66 -0
- data/app/assets/javascripts/js-routes.js.erb +1 -1
- data/gemfiles/{rails40.gemfile → rails40_sprockets_2.gemfile} +1 -1
- data/gemfiles/{rails40_sprockets3.gemfile → rails40_sprockets_3.gemfile} +0 -0
- data/gemfiles/{rails41.gemfile → rails41_sprockets_2.gemfile} +1 -1
- data/gemfiles/{rails41_sprockets3.gemfile → rails41_sprockets_3.gemfile} +0 -0
- data/gemfiles/{rails32.gemfile → rails42_sprockets_2.gemfile} +2 -2
- data/gemfiles/{rails42_sprockets3.gemfile → rails42_sprockets_3.gemfile} +1 -1
- data/gemfiles/{rails50_sprockets3.gemfile → rails50_sprockets_3.gemfile} +1 -1
- data/gemfiles/rails51_sprockets_3.gemfile +8 -0
- data/gemfiles/rails52_sprockets_3.gemfile +8 -0
- data/js-routes.gemspec +9 -6
- data/lib/js_routes/engine.rb +6 -18
- data/lib/js_routes/version.rb +1 -1
- data/lib/js_routes.rb +329 -171
- data/lib/routes.d.ts +79 -0
- data/lib/routes.js +499 -485
- data/lib/routes.ts +732 -0
- data/lib/tasks/js_routes.rake +8 -2
- data/package.json +37 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/js_routes/default_serializer_spec.rb +19 -3
- data/spec/js_routes/{amd_compatibility_spec.rb → module_types/amd_spec.rb} +1 -9
- data/spec/js_routes/module_types/cjs_spec.rb +15 -0
- data/spec/js_routes/module_types/dts/routes.spec.d.ts +114 -0
- data/spec/js_routes/module_types/dts/test.spec.ts +56 -0
- data/spec/js_routes/module_types/dts_spec.rb +111 -0
- data/spec/js_routes/module_types/esm_spec.rb +45 -0
- data/spec/js_routes/{generated_javascript_spec.rb → module_types/umd_spec.rb} +33 -27
- data/spec/js_routes/options_spec.rb +92 -50
- data/spec/js_routes/rails_routes_compatibility_spec.rb +107 -45
- data/spec/js_routes/zzz_last_post_rails_init_spec.rb +19 -8
- data/spec/spec_helper.rb +45 -42
- data/spec/support/routes.rb +19 -14
- data/spec/tsconfig.json +4 -0
- data/tsconfig.json +28 -0
- data/yarn.lock +2145 -0
- metadata +47 -34
- data/gemfiles/rails42.gemfile +0 -8
- data/gemfiles/rails50.gemfile +0 -8
- data/lib/routes.js.coffee +0 -386
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 242f329ab92abe8be4a2fa3790f72a3f161a6c2355b2392eae484a36a91d3a24
|
4
|
+
data.tar.gz: 120e5191eccfe3a8978c89ecb690a4f93a62279b249c58bc84b9273fe3e900c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1998fd3c98dff227905bfcd8a09be8bb6901d3da7293b60d1a6f11c3a2627c623372324a13010cbe425eb7b93781fa64db042c08e7b4123d4a50ec8bd8814b2
|
7
|
+
data.tar.gz: 5395c808f148bd39a99de0ce748cbb3a57c27620f048764bfcf6a455ac6ce2bbc43e282f4c660ba019f8d4b5df39a316728bb673d56b2667aecb667dde82d91b
|
data/.eslintrc.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module.exports = {
|
2
|
+
root: true,
|
3
|
+
extends: [
|
4
|
+
'eslint:recommended',
|
5
|
+
'plugin:@typescript-eslint/eslint-recommended',
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
7
|
+
'prettier/@typescript-eslint',
|
8
|
+
],
|
9
|
+
parser: '@typescript-eslint/parser',
|
10
|
+
plugins: ['@typescript-eslint'],
|
11
|
+
rules: {
|
12
|
+
'@typescript-eslint/ban-types': 'off',
|
13
|
+
'@typescript-eslint/no-explicit-any': 'off'
|
14
|
+
},
|
15
|
+
};
|
data/.gitignore
CHANGED
@@ -14,6 +14,9 @@ log
|
|
14
14
|
|
15
15
|
# jeweler generated
|
16
16
|
pkg
|
17
|
+
tmp
|
18
|
+
|
19
|
+
node_modules
|
17
20
|
|
18
21
|
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
22
|
#
|
@@ -58,3 +61,5 @@ gemfiles/*.lock
|
|
58
61
|
/spec/dummy/app/assets/javascripts/routes.js
|
59
62
|
/spec/dummy/logs
|
60
63
|
/spec/dummy/tmp
|
64
|
+
node_modules
|
65
|
+
|
data/.nvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
14
|
data/.travis.yml
CHANGED
@@ -5,27 +5,27 @@ before_install:
|
|
5
5
|
- gem install bundler # need for jruby and ruby-head
|
6
6
|
|
7
7
|
rvm:
|
8
|
-
- 2.0
|
9
|
-
- 2.1
|
10
|
-
- 2.2.5
|
11
|
-
- 2.3.1
|
12
8
|
- 2.4.1
|
13
|
-
-
|
9
|
+
- 2.5.3
|
10
|
+
- 2.6.0
|
14
11
|
- ruby-head
|
15
|
-
- jruby
|
12
|
+
- jruby
|
16
13
|
|
17
14
|
gemfile:
|
18
|
-
- gemfiles/
|
19
|
-
- gemfiles/
|
20
|
-
- gemfiles/
|
21
|
-
- gemfiles/
|
22
|
-
- gemfiles/
|
23
|
-
- gemfiles/
|
24
|
-
- gemfiles/
|
25
|
-
- gemfiles/
|
26
|
-
- gemfiles/
|
15
|
+
- gemfiles/rails40_sprockets_2.gemfile
|
16
|
+
- gemfiles/rails40_sprockets_3.gemfile
|
17
|
+
- gemfiles/rails41_sprockets_2.gemfile
|
18
|
+
- gemfiles/rails41_sprockets_3.gemfile
|
19
|
+
- gemfiles/rails42_sprockets_2.gemfile
|
20
|
+
- gemfiles/rails42_sprockets_3.gemfile
|
21
|
+
- gemfiles/rails50_sprockets_3.gemfile
|
22
|
+
- gemfiles/rails51_sprockets_3.gemfile
|
23
|
+
- gemfiles/rails52_sprockets_3.gemfile
|
24
|
+
env:
|
25
|
+
TRAVIS_CI: true
|
27
26
|
|
28
27
|
sudo: false
|
28
|
+
dist: xenial
|
29
29
|
|
30
30
|
notifications:
|
31
31
|
email:
|
@@ -36,25 +36,32 @@ branches:
|
|
36
36
|
- master
|
37
37
|
|
38
38
|
matrix:
|
39
|
+
fast_finish: true
|
39
40
|
allow_failures:
|
40
|
-
- rvm: jruby-19mode
|
41
41
|
- rvm: ruby-head
|
42
|
-
- rvm: jruby
|
43
|
-
- gemfile: gemfiles/rails50.gemfile
|
42
|
+
- rvm: jruby
|
44
43
|
exclude:
|
45
|
-
- rvm: 2.0
|
46
|
-
gemfile: gemfiles/
|
47
|
-
- rvm: 2.0
|
48
|
-
gemfile: gemfiles/
|
49
|
-
- rvm: 2.
|
50
|
-
gemfile: gemfiles/
|
51
|
-
- rvm: 2.
|
52
|
-
gemfile: gemfiles/
|
44
|
+
- rvm: 2.6.0
|
45
|
+
gemfile: gemfiles/rails40_sprockets_2.gemfile # Segmentation fault
|
46
|
+
- rvm: 2.6.0
|
47
|
+
gemfile: gemfiles/rails40_sprockets_3.gemfile # Segmentation fault
|
48
|
+
- rvm: 2.6.0
|
49
|
+
gemfile: gemfiles/rails41_sprockets_2.gemfile # Segmentation fault
|
50
|
+
- rvm: 2.6.0
|
51
|
+
gemfile: gemfiles/rails41_sprockets_3.gemfile # Segmentation fault
|
52
|
+
- rvm: 2.5.3
|
53
|
+
gemfile: gemfiles/rails40_sprockets_2.gemfile # Segmentation fault
|
54
|
+
- rvm: 2.5.3
|
55
|
+
gemfile: gemfiles/rails40_sprockets_3.gemfile # Segmentation fault
|
56
|
+
- rvm: 2.5.3
|
57
|
+
gemfile: gemfiles/rails41_sprockets_2.gemfile # Segmentation fault
|
58
|
+
- rvm: 2.5.3
|
59
|
+
gemfile: gemfiles/rails41_sprockets_3.gemfile # Segmentation fault
|
53
60
|
- rvm: 2.4.1
|
54
|
-
gemfile: gemfiles/
|
61
|
+
gemfile: gemfiles/rails40_sprockets_2.gemfile # Segmentation fault
|
55
62
|
- rvm: 2.4.1
|
56
|
-
gemfile: gemfiles/
|
63
|
+
gemfile: gemfiles/rails40_sprockets_3.gemfile # Segmentation fault
|
57
64
|
- rvm: 2.4.1
|
58
|
-
gemfile: gemfiles/
|
65
|
+
gemfile: gemfiles/rails41_sprockets_2.gemfile # Segmentation fault
|
59
66
|
- rvm: 2.4.1
|
60
|
-
gemfile: gemfiles/
|
67
|
+
gemfile: gemfiles/rails41_sprockets_3.gemfile # Segmentation fault
|
data/Appraisals
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
appraise "#{rails}" do
|
8
|
-
gem "railties", "~> #{version}"
|
9
|
-
gem "sprockets", "< 3"
|
1
|
+
def define_appraisal(rails, version, sprockets)
|
2
|
+
sprockets.each do |sprocket|
|
3
|
+
appraise "#{rails}-sprockets-#{sprocket}" do
|
4
|
+
gem "railties", "~> #{version}"
|
5
|
+
gem "sprockets", "~> #{sprocket}.0"
|
6
|
+
end
|
10
7
|
end
|
8
|
+
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
[
|
11
|
+
[:rails40, '4.0.13', [2, 3]],
|
12
|
+
[:rails41, '4.1.16', [2, 3]],
|
13
|
+
[:rails42, '4.2.9', [2, 3]],
|
14
|
+
[:rails50, '5.0.5', [3]],
|
15
|
+
[:rails51, '5.1.3', [3]],
|
16
|
+
[:rails52, '5.2.3', [3]]
|
17
|
+
].each do |name, version, sprockets|
|
18
|
+
define_appraisal(name, version, sprockets)
|
16
19
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,100 @@
|
|
1
1
|
## master
|
2
2
|
|
3
|
+
## v2.1.0
|
4
|
+
|
5
|
+
* Support typescript defintions file aka `routes.d.ts`. See [Readme.md](./Readme.md#definitions) for more information.
|
6
|
+
|
7
|
+
## v2.0.8
|
8
|
+
|
9
|
+
* Forbid usage of `namespace` option if `module_type` is not `nil`. [#281](https://github.com/railsware/js-routes/issues/281).
|
10
|
+
|
11
|
+
## v2.0.7
|
12
|
+
|
13
|
+
* Remove source map annotation from JS file. Fixes [#277](https://github.com/railsware/js-routes/issues/277)
|
14
|
+
* Generated file is not minified, so it is better to use app side bundler/compressor for source maps
|
15
|
+
|
16
|
+
|
17
|
+
## v2.0.6
|
18
|
+
|
19
|
+
* Disable `namespace` option default for all envs [#278](https://github.com/railsware/js-routes/issues/278)
|
20
|
+
|
21
|
+
## v2.0.5
|
22
|
+
|
23
|
+
* Fixed backward compatibility issue [#276](https://github.com/railsware/js-routes/issues/276)
|
24
|
+
|
25
|
+
## v2.0.4
|
26
|
+
|
27
|
+
* Fixed backward compatibility issue [#275](https://github.com/railsware/js-routes/issues/275)
|
28
|
+
|
29
|
+
## v2.0.3
|
30
|
+
|
31
|
+
* Fixed backward compatibility issue [#275](https://github.com/railsware/js-routes/issues/275)
|
32
|
+
|
33
|
+
## v2.0.2
|
34
|
+
|
35
|
+
* Fixed backward compatibility issue [#274](https://github.com/railsware/js-routes/issues/274)
|
36
|
+
|
37
|
+
## v2.0.1
|
38
|
+
|
39
|
+
* Fixed backward compatibility issue [#272](https://github.com/railsware/js-routes/issues/272)
|
40
|
+
|
41
|
+
## v2.0.0
|
42
|
+
|
43
|
+
Version 2.0 has some breaking changes.
|
44
|
+
See [UPGRADE TO 2.0](./VERSION_2_UPGRADE.md) for guidance.
|
45
|
+
|
46
|
+
* `module_type` option support
|
47
|
+
* `documentation` option spport
|
48
|
+
* Migrated implementation to typescript
|
49
|
+
* ESM tree shaking support
|
50
|
+
* Support camel case `toParam` version of `to_param` property
|
51
|
+
|
52
|
+
## v1.4.14
|
53
|
+
|
54
|
+
* Fix compatibility with UMD modules #237 [Comment](https://github.com/railsware/js-routes/issues/237#issuecomment-752754679)
|
55
|
+
|
56
|
+
## v1.4.13
|
57
|
+
|
58
|
+
* Improve compatibility with node environment #269.
|
59
|
+
* Change default file location configuration to Webpacker if both Webpacker and Sprockets are loaded
|
60
|
+
|
61
|
+
## v1.4.11
|
62
|
+
|
63
|
+
* Use app/javascript/routes.js as a default file location if app/javascript directory exists
|
64
|
+
* Add `default` export for better experience when used as es6 module
|
65
|
+
|
66
|
+
## v1.4.10
|
67
|
+
|
68
|
+
* Require engine only when sprockets is loaded #257.
|
69
|
+
|
70
|
+
## v1.4.9
|
71
|
+
|
72
|
+
* Allow to specify null namespace and receive routes as an object without assigning it anywhere #247
|
73
|
+
|
74
|
+
## v1.4.7
|
75
|
+
|
76
|
+
* Fix a LocalJumpError on secondary initialization of the app #248
|
77
|
+
|
78
|
+
## v1.4.6
|
79
|
+
|
80
|
+
* Fix regression of #244 in #243
|
81
|
+
|
82
|
+
## v1.4.5
|
83
|
+
|
84
|
+
* Fix escaping inside route parameters and globbing #244
|
85
|
+
|
86
|
+
## v1.4.4
|
87
|
+
|
88
|
+
* More informative stack trace for ParameterMissing error #235
|
89
|
+
|
90
|
+
## v1.4.3
|
91
|
+
|
92
|
+
* Proper implementation of the :subdomain option in routes generation
|
93
|
+
|
94
|
+
## v1.4.2
|
95
|
+
|
96
|
+
* Added JsRoutes namespace to Engine #230
|
97
|
+
|
3
98
|
## v1.4.1
|
4
99
|
|
5
100
|
* Fixed bug when js-routes is used in envs without window.location #224
|
data/Rakefile
CHANGED
@@ -12,7 +12,10 @@ require 'bundler/gem_tasks'
|
|
12
12
|
require 'rspec/core'
|
13
13
|
require 'rspec/core/rake_task'
|
14
14
|
require 'appraisal'
|
15
|
-
|
15
|
+
require 'rails/version'
|
16
|
+
if Rails.version < "6.1"
|
17
|
+
load "rails/tasks/routes.rake"
|
18
|
+
end
|
16
19
|
|
17
20
|
RSpec::Core::RakeTask.new(:spec)
|
18
21
|
|
@@ -22,12 +25,13 @@ task :default => :spec
|
|
22
25
|
|
23
26
|
|
24
27
|
namespace :spec do
|
28
|
+
desc "Print all routes defined in test env"
|
25
29
|
task :routes do
|
26
30
|
require './spec/spec_helper'
|
27
31
|
require 'action_dispatch/routing/inspector'
|
28
32
|
draw_routes
|
29
33
|
all_routes = Rails.application.routes.routes
|
30
34
|
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
31
|
-
puts inspector.format(ActionDispatch::Routing::ConsoleFormatter.new
|
35
|
+
puts inspector.format(ActionDispatch::Routing::ConsoleFormatter::Sheet.new)
|
32
36
|
end
|
33
37
|
end
|