js-routes 2.3.2 → 2.3.3

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: 771e5ddecccbde6b5b78778d456fe9602a4ae4b2aaa89e821cd6bda24be95565
4
- data.tar.gz: b0ac96fe4273cc21fa616614429e270a393c7bcd11f15b5b79e1b14e56ec579f
3
+ metadata.gz: 1acb75b6e26ae17c5b028fb97d400d0fb061ec582298598e91b05f27a5a9a32c
4
+ data.tar.gz: 2bc54da6a67463569ad6b239f90392394d666f0b89cde662a09cf35f19b07f85
5
5
  SHA512:
6
- metadata.gz: 150bccfe350126ca0db67d03a8a7bbc22884edd63ef2e86c1cecd4ac2d0d72b941d7f1133cadbe64d19f99332be22db9891ca42f2f4ccfbec7e77447b741fb71
7
- data.tar.gz: 2a51b7337560e055a21ff96be1b6f89d40d88bc6b541c56129a5f99823436a7c31027cc6e029f6b33b00a42805cd7986d805a30fc8a8ce5cc4e9bd5be20e2757
6
+ metadata.gz: d4a84398697f1bfb41f9c0dace8d50a805b5aae36de24382bd5b43214e237a776471267046ec01487cb52ab542f0b61cc46f62a32037476af8aa2510d5b87c77
7
+ data.tar.gz: db690e312707ad1951b9b9905c62400eb1f70eafbeab95aab94920eab5df57c18d6d18cec1e3bc3bbe133d0a2a98308469fe934b955a43f401357284cf29f9c3
data/CHANGELOG.md CHANGED
@@ -1,21 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.3.3
4
+
5
+ * Rework default banner to use `routes.rb` digest instead of timestamp to ensure
6
+ consistent routes.js version accross environments.
7
+ * Use [JSDoc Tags](https://jsdoc.app/) in banner by default.
8
+
9
+
10
+ The new default banner:
11
+
12
+ ``` js
13
+ /**
14
+ * @file Generated by js-routes 2.3.3. Based on Rails 7.2.0 routes of App.
15
+ * @see https://github.com/railsware/js-routes
16
+ * @version e289929fc3fbe69b77aa24c5c3a58fcb1246ad1ea3f4e883f7eafa915ca929f3
17
+ */
18
+ ```
19
+
3
20
  ## v2.3.2
4
21
 
5
22
  * Add `banner` option that allow to control JSDoc on top of generated file. [#324](https://github.com/bogdan/repo/issues/324).
6
23
 
7
24
  ``` ruby
8
- JsRoutes.configure do |c|
9
- c.banner = -> {
10
- commit_hash = `git rev-parse --short HEAD`.strip
11
-
12
- <<~DOC
13
- @file Javascript Route helpers of my magic pony app.
14
- @author Bogdan Gusiev
15
- @license MIT
16
- @version #{commit_hash}
17
- DOC
18
- }
25
+ JsRoutes.setup do |c|
26
+ c.banner = -> {
27
+ <<~DOC
28
+ @file Javascript Route helpers of my magic pony app.
29
+ @author Bogdan Gusiev
30
+ @license MIT
31
+ @version #{JsRoutes.digest}
32
+ DOC
33
+ }
19
34
  end
20
35
  ```
21
36
 
data/Readme.md CHANGED
@@ -483,7 +483,7 @@ While all of these methods are supported by JsRoutes, it is impossible to suppor
483
483
  If you are using routes like this, use the following configuration that will prevent required parameters presence to be validated by definition:
484
484
 
485
485
  ``` ruby
486
- JsRoutes.configure do |c|
486
+ JsRoutes.setup do |c|
487
487
  c.optional_definition_params = true
488
488
  end
489
489
  ```
@@ -168,8 +168,9 @@ module JsRoutes
168
168
  -> () {
169
169
  app = application.is_a?(Proc) ? T.unsafe(application).call : application
170
170
  <<~TXT
171
- File generated by js-routes #{JsRoutes::VERSION} on #{Time.now}
172
- Based on Rails #{Rails.version} routes of #{app.class}
171
+ @file Generated by js-routes #{JsRoutes::VERSION}. Based on Rails #{Rails.version} routes of #{app.class}.
172
+ @version #{JsRoutes.digest}
173
+ @see https://github.com/railsware/js-routes
173
174
  TXT
174
175
 
175
176
  }
@@ -16,8 +16,7 @@ module JsRoutes
16
16
  sig { params(app: T.untyped).void }
17
17
  def initialize(app)
18
18
  @app = app
19
- @routes_file = T.let(Rails.root.join("config/routes.rb"), Pathname)
20
- @mtime = T.let(nil, T.nilable(Time))
19
+ @digest = T.let(nil, T.nilable(String))
21
20
  end
22
21
 
23
22
  sig { override.params(env: StringHash).returns(UntypedArray) }
@@ -30,10 +29,10 @@ module JsRoutes
30
29
 
31
30
  sig { void }
32
31
  def update_js_routes
33
- new_mtime = routes_mtime
34
- unless new_mtime == @mtime
32
+ new_digest = fetch_digest
33
+ unless new_digest == @digest
35
34
  regenerate
36
- @mtime = new_mtime
35
+ @digest = new_digest
37
36
  end
38
37
  end
39
38
 
@@ -42,9 +41,9 @@ module JsRoutes
42
41
  JsRoutes.generate!(typed: true)
43
42
  end
44
43
 
45
- sig { returns(T.nilable(Time)) }
46
- def routes_mtime
47
- File.mtime(@routes_file)
44
+ sig { returns(T.nilable(String)) }
45
+ def fetch_digest
46
+ JsRoutes.digest
48
47
  rescue Errno::ENOENT
49
48
  nil
50
49
  end
@@ -1,4 +1,4 @@
1
1
  # typed: strict
2
2
  module JsRoutes
3
- VERSION = "2.3.2"
3
+ VERSION = "2.3.3"
4
4
  end
data/lib/js_routes.rb CHANGED
@@ -7,6 +7,7 @@ require "js_routes/configuration"
7
7
  require "js_routes/instance"
8
8
  require "js_routes/types"
9
9
  require 'active_support/core_ext/string/indent'
10
+ require "digest/sha2"
10
11
 
11
12
  module JsRoutes
12
13
  extend T::Sig
@@ -62,6 +63,13 @@ module JsRoutes
62
63
  def json(value)
63
64
  ActiveSupport::JSON.encode(value)
64
65
  end
66
+
67
+ sig { returns(String) }
68
+ def digest
69
+ Digest::SHA256.file(
70
+ Rails.root.join("config/routes.rb")
71
+ ).hexdigest
72
+ end
65
73
  end
66
74
  module Generators
67
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
@@ -144,9 +144,9 @@ licenses:
144
144
  - MIT
145
145
  metadata:
146
146
  bug_tracker_uri: https://github.com/railsware/js-routes/issues
147
- changelog_uri: https://github.com/railsware/js-routes/blob/v2.3.2/CHANGELOG.md
147
+ changelog_uri: https://github.com/railsware/js-routes/blob/v2.3.3/CHANGELOG.md
148
148
  documentation_uri: https://github.com/railsware/js-routes
149
- source_code_uri: https://github.com/railsware/js-routes/tree/v2.3.2/activerecord
149
+ source_code_uri: https://github.com/railsware/js-routes/tree/v2.3.3/activerecord
150
150
  rubygems_mfa_required: 'true'
151
151
  github_repo: ssh://github.com/railsware/js-routes
152
152
  post_install_message: