sewing_kit 0.31.0 → 0.31.1

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: 21441a0459fdd78c584adb2504b32f2ba964017be52285f807039dcd13597b98
4
- data.tar.gz: dccb4fa02846478b4034794ca7a3f5510ce75a1e57064a561ce589f205b8a828
3
+ metadata.gz: c2ff4aed0cbabd00ba3616fe4857319ebfa86aede64ff5e1786638397cdf81ba
4
+ data.tar.gz: bad9114b6759486b91aff61f4812382cbf198a3c1725bee8716be9febc8bd971
5
5
  SHA512:
6
- metadata.gz: afff024270869a6daa67dfda3d35f1568ff24427cfc0b388478266b5a1ec096c1412f399285da0ee2bdeb9a9998b493959eb7db4137c9d196ce71c729a1102e1
7
- data.tar.gz: a2e18ad68fd40637eb8fcf94700df6806dde7b9bfc55aa6f531bae32f0b0bd6bbe54828de4b6fb583ea819f5983d0e4fe4b5888cce8f70233cb82512ec9c5f5f
6
+ metadata.gz: 8568933258991662f2bc7b65d5e62ebb6e86070d97fe9d9967829332ef3de1c1952d705f0d762fcd6ff1c9ac442c5743b8d874ba4da744cad6e49f8c633c6205
7
+ data.tar.gz: ae9ae754502c4f991d79b48fe608968a724872c3d6536ec52c600719d235e900b66c50b0a806bde888b71c0f405f1d9b80cb0a98b212171796999439ab344372
@@ -16,10 +16,14 @@ require 'sewing_kit/webpack/dev'
16
16
 
17
17
  module SewingKit
18
18
  class Railtie < ::Rails::Railtie
19
+ initializer "sewing_kit.cache_production_manifest" do
20
+ unless SewingKit::Railtie.development_server?
21
+ SewingKit::CachedProductionManifest = SewingKit::Webpack::Manifest::Base.load_metadata_from_node
22
+ end
23
+ end
19
24
  # rubocop:disable Metrics/BlockLength
20
25
  config.after_initialize do
21
- is_development = Rails.env.development? && ENV['SK_SIMULATE_PRODUCTION'] != '1'
22
- if is_development && (Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
26
+ if SewingKit::Railtie.development_server?
23
27
  webpack_dev = SewingKit::Webpack::Dev.new
24
28
  webpack_dev.start
25
29
  end
@@ -28,10 +32,13 @@ module SewingKit
28
32
  include SewingKit::Webpack::Helper
29
33
  end
30
34
  end
31
- # rubocop:enable Metrics/BlockLength
32
-
33
35
  rake_tasks do
34
36
  load "tasks/sewing_kit.rake"
35
37
  end
38
+
39
+ def self.development_server?
40
+ Rails.env.development? && ENV['SK_SIMULATE_PRODUCTION'] != '1' &&
41
+ (Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
42
+ end
36
43
  end
37
44
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SewingKit
3
- VERSION = "0.31.0"
3
+ VERSION = "0.31.1"
4
4
  end
@@ -64,10 +64,9 @@ module SewingKit
64
64
  end
65
65
 
66
66
  def instance
67
- return @instance if @instance
68
-
69
67
  mode = ENV['NODE_ENV'] || Rails.env.to_s
70
- @instance = if mode == 'development' && ENV['SK_SIMULATE_PRODUCTION'] != '1'
68
+
69
+ @instance ||= if mode == 'development' && ENV['SK_SIMULATE_PRODUCTION'] != '1'
71
70
  Development.new
72
71
  else
73
72
  Production.new
@@ -27,7 +27,7 @@ module SewingKit
27
27
  metadata['assets']
28
28
  end
29
29
 
30
- def load_metadata_from_node
30
+ def self.load_metadata_from_node
31
31
  begin
32
32
  stdout, stderr, status = Open3.capture3('node_modules/.bin/sewing-kit', 'manifest', "--mode=#{mode}")
33
33
  rescue => e
@@ -43,9 +43,7 @@ module SewingKit
43
43
  end
44
44
  end
45
45
 
46
- protected
47
-
48
- def mode
46
+ def self.mode
49
47
  ENV['NODE_ENV'] || Rails.env.to_s || 'production'
50
48
  end
51
49
  end
@@ -27,7 +27,7 @@ module SewingKit
27
27
  @metadata_path = nil
28
28
  end
29
29
 
30
- result = load_metadata_from_node
30
+ result = SewingKit::Webpack::Manifest::Base.load_metadata_from_node
31
31
  raise LegacyManifestError, result unless result['entrypoints'] || result['development']
32
32
 
33
33
  @metadata_path = result && result['path']
@@ -14,14 +14,9 @@ module SewingKit
14
14
  end
15
15
 
16
16
  def metadata
17
- # Cache at class level, as JSON loading/parsing can be expensive.
18
- @metadata ||= load_metadata
19
- end
20
-
21
- def load_metadata
22
- result = load_metadata_from_node
23
- raise LegacyManifestError, result unless result['entrypoints']
24
- result
17
+ manifest = SewingKit::CachedProductionManifest
18
+ raise LegacyManifestError, manifest unless manifest['entrypoints']
19
+ manifest
25
20
  end
26
21
  end
27
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sewing_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Sauve