js-routes 2.2.9 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -3
  3. data/Readme.md +16 -15
  4. data/lib/js_routes/configuration.rb +7 -5
  5. data/lib/js_routes/generators/base.rb +6 -1
  6. data/lib/js_routes/generators/middleware.rb +2 -3
  7. data/lib/js_routes/generators/webpacker.rb +2 -1
  8. data/lib/js_routes/instance.rb +21 -6
  9. data/lib/js_routes/middleware.rb +5 -4
  10. data/lib/js_routes/route.rb +7 -3
  11. data/lib/js_routes/types.rb +10 -0
  12. data/lib/js_routes/utils.rb +18 -0
  13. data/lib/js_routes/version.rb +1 -1
  14. data/lib/js_routes.rb +12 -4
  15. data/lib/routes.d.ts +7 -6
  16. data/lib/routes.js +19 -18
  17. data/lib/routes.ts +33 -27
  18. data/lib/tasks/js_routes.rake +4 -2
  19. metadata +12 -145
  20. data/.document +0 -5
  21. data/.eslintrc.js +0 -15
  22. data/.github/workflows/ci.yml +0 -36
  23. data/.gitignore +0 -65
  24. data/.nvmrc +0 -1
  25. data/.rspec +0 -1
  26. data/Appraisals +0 -17
  27. data/Gemfile +0 -9
  28. data/Rakefile +0 -37
  29. data/VERSION_2_UPGRADE.md +0 -66
  30. data/bin/tapioca +0 -27
  31. data/gemfiles/rails50_sprockets_3.gemfile +0 -8
  32. data/gemfiles/rails51_sprockets_3.gemfile +0 -8
  33. data/gemfiles/rails52_sprockets_3.gemfile +0 -8
  34. data/gemfiles/rails70_sprockets_4.gemfile +0 -8
  35. data/js-routes.gemspec +0 -42
  36. data/package.json +0 -38
  37. data/sorbet/config +0 -4
  38. data/sorbet/rbi/annotations/.gitattributes +0 -1
  39. data/sorbet/rbi/annotations/actionpack.rbi +0 -428
  40. data/sorbet/rbi/annotations/actionview.rbi +0 -75
  41. data/sorbet/rbi/annotations/activesupport.rbi +0 -421
  42. data/sorbet/rbi/annotations/railties.rbi +0 -61
  43. data/sorbet/rbi/gems/.gitattributes +0 -1
  44. data/sorbet/rbi/gems/actionpack@7.0.4.1.rbi +0 -303
  45. data/sorbet/rbi/gems/actionview@7.0.4.1.rbi +0 -8
  46. data/sorbet/rbi/gems/activesupport@7.0.4.1.rbi +0 -16424
  47. data/sorbet/rbi/gems/appraisal@2.4.1.rbi +0 -584
  48. data/sorbet/rbi/gems/builder@3.2.4.rbi +0 -8
  49. data/sorbet/rbi/gems/bump@0.10.0.rbi +0 -168
  50. data/sorbet/rbi/gems/byebug@11.1.3.rbi +0 -3606
  51. data/sorbet/rbi/gems/coderay@1.1.3.rbi +0 -3426
  52. data/sorbet/rbi/gems/concurrent-ruby@1.2.0.rbi +0 -11570
  53. data/sorbet/rbi/gems/crass@1.0.6.rbi +0 -8
  54. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +0 -1083
  55. data/sorbet/rbi/gems/erubi@1.12.0.rbi +0 -145
  56. data/sorbet/rbi/gems/i18n@1.12.0.rbi +0 -2296
  57. data/sorbet/rbi/gems/libv8-node@16.10.0.0.rbi +0 -8
  58. data/sorbet/rbi/gems/loofah@2.19.1.rbi +0 -8
  59. data/sorbet/rbi/gems/method_source@1.0.0.rbi +0 -272
  60. data/sorbet/rbi/gems/mini_racer@0.6.3.rbi +0 -224
  61. data/sorbet/rbi/gems/minitest@5.17.0.rbi +0 -1457
  62. data/sorbet/rbi/gems/netrc@0.11.0.rbi +0 -158
  63. data/sorbet/rbi/gems/nokogiri@1.14.0.rbi +0 -8
  64. data/sorbet/rbi/gems/parallel@1.24.0.rbi +0 -280
  65. data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +0 -951
  66. data/sorbet/rbi/gems/prism@0.24.0.rbi +0 -29744
  67. data/sorbet/rbi/gems/pry-byebug@3.10.1.rbi +0 -1150
  68. data/sorbet/rbi/gems/pry@0.14.2.rbi +0 -10075
  69. data/sorbet/rbi/gems/racc@1.6.2.rbi +0 -150
  70. data/sorbet/rbi/gems/rack-test@2.0.2.rbi +0 -8
  71. data/sorbet/rbi/gems/rack@2.2.6.2.rbi +0 -5585
  72. data/sorbet/rbi/gems/rails-dom-testing@2.0.3.rbi +0 -8
  73. data/sorbet/rbi/gems/rails-html-sanitizer@1.5.0.rbi +0 -8
  74. data/sorbet/rbi/gems/railties@7.0.4.1.rbi +0 -1959
  75. data/sorbet/rbi/gems/rake@13.0.6.rbi +0 -3072
  76. data/sorbet/rbi/gems/rbi@0.1.9.rbi +0 -3006
  77. data/sorbet/rbi/gems/rspec-core@3.12.0.rbi +0 -10868
  78. data/sorbet/rbi/gems/rspec-expectations@3.12.2.rbi +0 -8100
  79. data/sorbet/rbi/gems/rspec-mocks@3.12.3.rbi +0 -5299
  80. data/sorbet/rbi/gems/rspec-support@3.12.0.rbi +0 -1611
  81. data/sorbet/rbi/gems/rspec@3.12.0.rbi +0 -82
  82. data/sorbet/rbi/gems/spoom@1.2.4.rbi +0 -3777
  83. data/sorbet/rbi/gems/sprockets-rails@3.4.2.rbi +0 -14
  84. data/sorbet/rbi/gems/sprockets@4.2.0.rbi +0 -8
  85. data/sorbet/rbi/gems/syntax_tree@6.2.0.rbi +0 -23136
  86. data/sorbet/rbi/gems/tapioca@0.12.0.rbi +0 -3510
  87. data/sorbet/rbi/gems/thor@1.2.1.rbi +0 -3956
  88. data/sorbet/rbi/gems/tzinfo@2.0.5.rbi +0 -5914
  89. data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +0 -428
  90. data/sorbet/rbi/gems/yard@0.9.34.rbi +0 -18332
  91. data/sorbet/rbi/gems/zeitwerk@2.6.8.rbi +0 -8
  92. data/sorbet/rbi/todo.rbi +0 -31
  93. data/sorbet/tapioca/config.yml +0 -13
  94. data/sorbet/tapioca/require.rb +0 -4
  95. data/spec/dummy/app/assets/config/manifest.js +0 -2
  96. data/spec/dummy/app/assets/javascripts/.gitkeep +0 -0
  97. data/spec/dummy/config/routes.rb +0 -55
  98. data/spec/js_routes/default_serializer_spec.rb +0 -31
  99. data/spec/js_routes/module_types/amd_spec.rb +0 -35
  100. data/spec/js_routes/module_types/cjs_spec.rb +0 -15
  101. data/spec/js_routes/module_types/dts/routes.spec.d.ts +0 -115
  102. data/spec/js_routes/module_types/dts/test.spec.ts +0 -56
  103. data/spec/js_routes/module_types/dts_spec.rb +0 -126
  104. data/spec/js_routes/module_types/esm_spec.rb +0 -45
  105. data/spec/js_routes/module_types/nil_spec.rb +0 -87
  106. data/spec/js_routes/module_types/umd_spec.rb +0 -85
  107. data/spec/js_routes/options_spec.rb +0 -508
  108. data/spec/js_routes/rails_routes_compatibility_spec.rb +0 -473
  109. data/spec/js_routes/route_specification_spec.rb +0 -37
  110. data/spec/js_routes/zzz_sprockets_spec.rb +0 -152
  111. data/spec/spec_helper.rb +0 -135
  112. data/spec/support/routes.rb +0 -81
  113. data/spec/tsconfig.json +0 -4
  114. data/tsconfig.json +0 -28
  115. data/yarn.lock +0 -2457
data/spec/spec_helper.rb DELETED
@@ -1,135 +0,0 @@
1
- # encoding: utf-8
2
-
3
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- $:.unshift(File.dirname(__FILE__))
5
- require 'rspec'
6
- require 'rails/all'
7
- require 'js-routes'
8
- require 'active_support/core_ext/hash/slice'
9
-
10
- unless ENV['CI']
11
- code = system("yarn build")
12
- unless code
13
- exit(1)
14
- end
15
- end
16
-
17
-
18
- if defined?(JRUBY_VERSION)
19
- require 'rhino'
20
- JS_LIB_CLASS = Rhino
21
- else
22
- require 'mini_racer'
23
- JS_LIB_CLASS = MiniRacer
24
- end
25
-
26
- def jscontext(force = false)
27
- if force
28
- @jscontext = JS_LIB_CLASS::Context.new
29
- else
30
- @jscontext ||= JS_LIB_CLASS::Context.new
31
- end
32
- end
33
-
34
- def js_error_class
35
- if defined?(JRUBY_VERSION)
36
- JS_LIB_CLASS::JSError
37
- else
38
- JS_LIB_CLASS::Error
39
- end
40
- end
41
-
42
- def evaljs(string, force: false, filename: 'context.js')
43
- jscontext(force).eval(string, filename: filename)
44
- rescue MiniRacer::ParseError => e
45
- trace = e.message
46
- _, _, line, _ = trace.split(':')
47
- if line
48
- code = string.split("\n")[line.to_i-1]
49
- raise "#{trace}. Code: #{code.strip}";
50
- else
51
- raise e
52
- end
53
- rescue MiniRacer::RuntimeError => e
54
- raise e
55
- end
56
-
57
- def evallib(**options)
58
- evaljs(JsRoutes.generate(**options), filename: 'lib/routes.js')
59
- end
60
-
61
- def test_routes
62
- ::App.routes.url_helpers
63
- end
64
-
65
- def blog_routes
66
- BlogEngine::Engine.routes.url_helpers
67
- end
68
-
69
- def planner_routes
70
- Planner::Engine.routes.url_helpers
71
- end
72
-
73
- def log(string)
74
- evaljs("console.log(#{string})")
75
- end
76
-
77
- def expectjs(string)
78
- expect(evaljs(string))
79
- end
80
-
81
- ActiveSupport::Inflector.inflections do |inflect|
82
- inflect.irregular "budgie", "budgies"
83
- end
84
-
85
-
86
- module Planner
87
- class Engine < Rails::Engine
88
- isolate_namespace Planner
89
- end
90
- end
91
-
92
- module BlogEngine
93
- class Engine < Rails::Engine
94
- isolate_namespace BlogEngine
95
- end
96
-
97
- end
98
-
99
-
100
- class ::App < Rails::Application
101
- config.paths['config/routes.rb'] << 'spec/config/routes.rb'
102
- config.root = File.expand_path('../dummy', __FILE__)
103
- end
104
-
105
-
106
- # prevent warning
107
- Rails.configuration.active_support.deprecation = :log
108
-
109
- # Requires supporting files with custom matchers and macros, etc,
110
- # in ./support/ and its subdirectories.
111
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
112
-
113
- RSpec.configure do |config|
114
- config.expect_with :rspec do |c|
115
- c.syntax = :expect
116
- end
117
-
118
- config.before(:suite) do
119
- draw_routes
120
- end
121
-
122
- config.before :each do
123
- log = proc do |*values|
124
- puts values.map(&:inspect).join(", ")
125
- end
126
-
127
- if defined?(JRUBY_VERSION)
128
- jscontext[:"console.log"] = lambda do |context, *values|
129
- log(*values)
130
- end
131
- else
132
- jscontext.attach("console.log", log)
133
- end
134
- end
135
- end
@@ -1,81 +0,0 @@
1
- def draw_routes
2
- Planner::Engine.routes.draw do
3
- get "/manage" => 'foo#foo', as: :manage
4
- end
5
-
6
- BlogEngine::Engine.routes.draw do
7
- root to: "application#index"
8
- resources :posts, only: [:show, :index]
9
- end
10
- App.routes.draw do
11
-
12
- mount Planner::Engine, at: "/(locale/:locale)", as: :planner
13
-
14
- mount BlogEngine::Engine => "/blog", as: :blog_app
15
- get 'support(/page/:page)', to: BlogEngine::Engine, as: 'support'
16
-
17
- resources :inboxes, only: [:index, :show] do
18
- resources :messages, only: [:index, :show] do
19
- resources :attachments, only: [:new, :show]
20
- end
21
- end
22
-
23
- get "(/:space)/campaigns" => "foo#foo", as: :campaigns, defaults: {space: nil}
24
-
25
- root :to => "inboxes#index"
26
-
27
- namespace :admin do
28
- resources :users, only: [:index]
29
- end
30
-
31
- scope "/returns/:return" do
32
- resources :objects, only: [:show]
33
- end
34
-
35
- scope "(/optional/:optional_id)" do
36
- resources :things, only: [:show, :index]
37
- end
38
-
39
- get "(/sep1/:first_optional)/sep2/:second_required/sep3/:third_required(/:forth_optional)",
40
- as: :thing_deep, controller: :things, action: :show
41
-
42
- if Rails.version < "5.0.0"
43
- get "/:controller(/:action(/:id))" => "classic#classic", :as => :classic
44
- end
45
-
46
- get "/other_optional/(:optional_id)" => "foo#foo", :as => :foo
47
- get '/other_optional(/*optional_id)' => 'foo#foo', :as => :foo_all
48
-
49
- get 'books/*section/:title' => 'books#show', :as => :book
50
- get 'books/:title/*section' => 'books#show', :as => :book_title
51
-
52
- get '/no_format' => "foo#foo", :format => false, :as => :no_format
53
-
54
- get '/json_only' => "foo#foo", :format => true, :constraints => {:format => /json/}, :as => :json_only
55
-
56
- get '/привет' => "foo#foo", :as => :hello
57
- get '(/o/:organization)/search/:q' => "foo#foo", as: :search
58
-
59
- resources :sessions, :only => [:new, :create], :protocol => 'https'
60
- get '/' => 'sso#login', host: 'sso.example.com', as: :sso
61
- get "/" => "a#b", subdomain: 'www', host: 'example.com', port: 88, as: :secret_root
62
-
63
- resources :portals, :port => 8080, only: [:index]
64
-
65
- get '/with_defaults' => 'foo#foo', defaults: { bar: 'tested', format: :json }, format: true
66
-
67
- namespace :api, format: true, defaults: {format: 'json'} do
68
- get "/purchases" => "purchases#index"
69
- end
70
-
71
- resources :budgies, only: [:show, :index] do
72
- get "descendents"
73
- end
74
-
75
- namespace :backend, path: '', constraints: {subdomain: 'backend'} do
76
- root to: 'backend#index'
77
- end
78
-
79
- end
80
-
81
- end
data/spec/tsconfig.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "include": ["./**/*.spec.ts"]
4
- }
data/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2019",
4
- "lib": ["es2020", "dom"],
5
- "module": "commonjs",
6
- "sourceMap": false,
7
- "declaration": true,
8
- "allowSyntheticDefaultImports": true,
9
- "resolveJsonModule": false,
10
- "strictNullChecks": true,
11
- "noImplicitAny": true,
12
- "noImplicitThis": true,
13
- "strictBindCallApply": true,
14
- "strictFunctionTypes": true,
15
- "alwaysStrict": false,
16
-
17
- "esModuleInterop": true,
18
- "forceConsistentCasingInFileNames": true,
19
- "emitDecoratorMetadata": true,
20
- "experimentalDecorators": true
21
-
22
- },
23
- "ts-node": {
24
- "files": true,
25
- "transpileOnly": false
26
- },
27
- "include": ["lib/*.ts"]
28
- }