sewing_kit 0.91.0 → 0.92.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sewing_kit/configuration.rb +2 -1
- data/lib/sewing_kit/railtie.rb +4 -12
- data/lib/sewing_kit/version.rb +1 -1
- data/lib/sewing_kit/webpack/manifest.rb +8 -17
- data/lib/sewing_kit/webpack/manifest/base.rb +12 -12
- data/lib/sewing_kit/webpack/manifest/development.rb +14 -18
- data/lib/sewing_kit/webpack/manifest/production.rb +9 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b5d379f248e1cb49dbdc63d5c6a1ae02a8b2368f3101f00d55f38e6d3dbfecc
|
4
|
+
data.tar.gz: b118d063e8d4075d9f545a9bd62d5448298880a482f2093ff8601df12791a108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 386f8b2cdecd5b9dc7c5cdfb40bedc9577492a5d96dcd6038ea936f4d47ddf0ade31c8e9422d7f153f96731a1a551f175f292dcc339980d5f401f7bb9b60e1a5
|
7
|
+
data.tar.gz: 413a472e7349f6a21d1a3532c2a511b5c36474ee7b442f0aa6f030ee298ec0d005643ca804cd8872062e91e2558ffc752d65ac9d440b4aa5d2742b22f026e0b2
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module SewingKit
|
3
3
|
class Configuration
|
4
|
-
attr_accessor :build_options, :dev_server_sewing_kit_bin
|
4
|
+
attr_accessor :build_options, :dev_server_sewing_kit_bin, :manifest_name
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@build_options = nil
|
8
|
+
@manifest_name = 'sewing-kit-manifest.json'
|
8
9
|
@dev_server_sewing_kit_bin = 'node_modules/.bin/sewing-kit'
|
9
10
|
end
|
10
11
|
end
|
data/lib/sewing_kit/railtie.rb
CHANGED
@@ -16,14 +16,10 @@ 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? || Rails.env.test?
|
21
|
-
SewingKit::CachedProductionManifest = SewingKit::Webpack::Manifest::Base.load_metadata_from_node
|
22
|
-
end
|
23
|
-
end
|
24
19
|
# rubocop:disable Metrics/BlockLength
|
25
20
|
config.after_initialize do
|
26
|
-
|
21
|
+
is_development = Rails.env.development? && ENV['SK_SIMULATE_PRODUCTION'] != '1'
|
22
|
+
if is_development && (Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
|
27
23
|
webpack_dev = SewingKit::Webpack::Dev.new
|
28
24
|
webpack_dev.start
|
29
25
|
end
|
@@ -32,14 +28,10 @@ module SewingKit
|
|
32
28
|
include SewingKit::Webpack::Helper
|
33
29
|
end
|
34
30
|
end
|
31
|
+
# rubocop:enable Metrics/BlockLength
|
32
|
+
|
35
33
|
rake_tasks do
|
36
34
|
load "tasks/sewing_kit.rake"
|
37
35
|
end
|
38
|
-
|
39
|
-
def self.development_server?
|
40
|
-
Rails.env.development? &&
|
41
|
-
ENV['SK_SIMULATE_PRODUCTION'] != '1' &&
|
42
|
-
(Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
|
43
|
-
end
|
44
36
|
end
|
45
37
|
end
|
data/lib/sewing_kit/version.rb
CHANGED
@@ -7,23 +7,15 @@ module SewingKit
|
|
7
7
|
# Webpack manifest loading, caching & entry point retrieval
|
8
8
|
class Manifest
|
9
9
|
class NodeSewingKitManifestMissing < StandardError
|
10
|
-
def initialize(
|
11
|
-
env_message = if 'production' == mode
|
12
|
-
"\nIf this is a container build:\n" \
|
13
|
-
" - Verify that sewing_kit compilation succeeded before deployment\n" \
|
14
|
-
" - Verify that public/bundles/sewing-kit.manifest.json was uploaded\n" \
|
15
|
-
" - Verify that public/bundles/sewing-kit.manifest.json exists in the container\n" \
|
16
|
-
else
|
17
|
-
"\nPossible next steps:\n" \
|
18
|
-
" - If the server is still starting up, wait for a 'Compiled with latest changes' message" \
|
19
|
-
" then refresh your browser\n" \
|
20
|
-
" - Check the development console for compilation errors\n" \
|
21
|
-
" - Restart your development server\n"
|
22
|
-
end
|
23
|
-
|
10
|
+
def initialize(node_error_message)
|
24
11
|
super(
|
25
|
-
"Could not fetch the sewing-kit manifest 🙀 " \
|
26
|
-
"
|
12
|
+
"Could not fetch the sewing-kit manifest 🙀 \n" \
|
13
|
+
"Possible next steps:\n" \
|
14
|
+
" - If the server is still starting up, wait for a " \
|
15
|
+
"'Compiled with latest changes' message then refresh your browser\n" \
|
16
|
+
" - Check the development console for compilation errors\n" \
|
17
|
+
" - Restart your development server\n" \
|
18
|
+
"\n" \
|
27
19
|
"Original error #{node_error_message}"
|
28
20
|
)
|
29
21
|
end
|
@@ -59,7 +51,6 @@ module SewingKit
|
|
59
51
|
|
60
52
|
def instance
|
61
53
|
mode = ENV['NODE_ENV'] || Rails.env.to_s
|
62
|
-
|
63
54
|
@instance ||= if (mode == 'development' && ENV['SK_SIMULATE_PRODUCTION'] != '1') || Rails.env.test?
|
64
55
|
Development.new
|
65
56
|
else
|
@@ -35,24 +35,24 @@ module SewingKit
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
begin
|
40
|
-
stdout, stderr, status = Open3.capture3('node_modules/.bin/sewing-kit', 'manifest', "--mode=#{mode}")
|
41
|
-
rescue => e
|
42
|
-
raise NodeSewingKitNotRunnable.new(mode, e)
|
43
|
-
end
|
44
|
-
|
45
|
-
raise NodeSewingKitManifestMissing.new(mode, stderr) unless status.success?
|
38
|
+
protected
|
46
39
|
|
40
|
+
def load_metadata_from_fs(path)
|
47
41
|
begin
|
48
|
-
|
42
|
+
content = File.read(path)
|
49
43
|
rescue => e
|
50
|
-
raise
|
44
|
+
raise ManifestLoadError.new(path, e)
|
51
45
|
end
|
46
|
+
|
47
|
+
parse_metadata(content)
|
52
48
|
end
|
53
49
|
|
54
|
-
|
55
|
-
|
50
|
+
private
|
51
|
+
|
52
|
+
def parse_metadata(json)
|
53
|
+
JSON.parse(json)
|
54
|
+
rescue => e
|
55
|
+
raise ManifestParseError, e
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -43,28 +43,14 @@ module SewingKit
|
|
43
43
|
@metadata_path = nil
|
44
44
|
end
|
45
45
|
|
46
|
-
result =
|
46
|
+
result = load_metadata_from_node
|
47
47
|
|
48
48
|
metadata = normalize_metadata(result)
|
49
49
|
@metadata_path = metadata && metadata['path']
|
50
50
|
metadata
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
begin
|
55
|
-
json_str = File.read(path)
|
56
|
-
rescue => e
|
57
|
-
raise ManifestLoadError.new(path, e)
|
58
|
-
end
|
59
|
-
|
60
|
-
begin
|
61
|
-
JSON.parse(json_str)
|
62
|
-
rescue => e
|
63
|
-
raise ManifestParseError, e
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
protected
|
53
|
+
private
|
68
54
|
|
69
55
|
def normalize_metadata(maybe_array_metadata)
|
70
56
|
if maybe_array_metadata.is_a?(Array)
|
@@ -74,8 +60,18 @@ module SewingKit
|
|
74
60
|
end
|
75
61
|
end
|
76
62
|
|
77
|
-
def
|
78
|
-
|
63
|
+
def load_metadata_from_node
|
64
|
+
begin
|
65
|
+
stdout, stderr, status = Open3.capture3(
|
66
|
+
'node_modules/.bin/sewing-kit', 'manifest', "--mode=development"
|
67
|
+
)
|
68
|
+
rescue => e
|
69
|
+
raise NodeSewingKitNotRunnable.new('development', e)
|
70
|
+
end
|
71
|
+
|
72
|
+
raise NodeSewingKitManifestMissing, stderr unless status.success?
|
73
|
+
|
74
|
+
parse_metadata(stdout)
|
79
75
|
end
|
80
76
|
end
|
81
77
|
|
@@ -15,7 +15,7 @@ module SewingKit
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def metadata
|
18
|
-
|
18
|
+
@metadata ||= load_metadata
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -38,6 +38,14 @@ module SewingKit
|
|
38
38
|
|
39
39
|
found || consolidated_metadata.last
|
40
40
|
end
|
41
|
+
|
42
|
+
def load_metadata
|
43
|
+
load_metadata_from_fs(path)
|
44
|
+
end
|
45
|
+
|
46
|
+
def path
|
47
|
+
File.join(Rails.root, 'public', 'bundles', SewingKit.configuration.manifest_name)
|
48
|
+
end
|
41
49
|
end
|
42
50
|
end
|
43
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sewing_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.92.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Sauve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|