sewing_kit 0.94.0 → 0.95.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/lib/sewing_kit/configuration.rb +12 -1
- data/lib/sewing_kit/version.rb +1 -1
- data/lib/sewing_kit/webpack/dev.rb +47 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b602141d9384dbe196746242130707db37ed8cc877f50b36364b3c8e15a018f
|
4
|
+
data.tar.gz: b9669c5e2666ae28ae2f3ad6228cff9b6e969e73da05855224ba8acc837cf437
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e05bd301abc39d37c44b660cc56d35874de2a4d527012e872a6bf76f46b88079d8e683a8dd983ea3eadd267a3a7f054f4ad65685f823dac5784d2f655e39672c
|
7
|
+
data.tar.gz: 53129c412805f4a5cc602566d0add516693a1e5f723045def7826498884dbaa314f8338b9ae887ae095b6b3182586c117a68af68d3c1f8d4214e3cc573399e9a
|
data/README.md
CHANGED
@@ -235,6 +235,24 @@ NODE_ENV=production SK_SIMULATE_PRODUCTION=1 dev run
|
|
235
235
|
|
236
236
|
Note that code changes will not be automatically recompiled in this state. After verifying production behaviour, run `bundle exec rake assets:clobber` to get back to development mode.
|
237
237
|
|
238
|
-
### My project is using `sprockets-
|
238
|
+
### My project is using `sprockets-commoner`, can I use sewing_kit too?
|
239
239
|
|
240
240
|
No. sprockets-commoner uses an outdated Babel version, and is no longer compatible with sewing-kit.
|
241
|
+
|
242
|
+
## sewing-kit's logs are too noisy. How can I see less of them?
|
243
|
+
|
244
|
+
sewing-kit defaults to using the same `log_level` as Rails' built in logger. It can be customized this using a configuration block:
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
SewingKit.configure do |config|
|
248
|
+
config.log_level = :warn # may be `:inherit`, `:debug`, `:info`, `:warn`, or `:error`
|
249
|
+
end
|
250
|
+
```
|
251
|
+
|
252
|
+
### How can I set breakpoints for server rendered apps?
|
253
|
+
|
254
|
+
Start your Rails server with `SK_DEBUG` set as an environment variable, and configure your Node debugger to listen on port `5858`.
|
255
|
+
|
256
|
+
```bash
|
257
|
+
SK_DEBUG=1 bundle exec rails start
|
258
|
+
```
|
@@ -3,7 +3,7 @@ module SewingKit
|
|
3
3
|
class Configuration
|
4
4
|
attr_accessor :build_options, :dev_server_sewing_kit_bin, :manifest_name,
|
5
5
|
:manifest_path
|
6
|
-
attr_reader :test_manifest_mode
|
6
|
+
attr_reader :test_manifest_mode, :log_level
|
7
7
|
|
8
8
|
def test_manifest_mode=(mode)
|
9
9
|
valid_modes = [:return_no_assets, :use_precompiled_assets]
|
@@ -12,11 +12,22 @@ module SewingKit
|
|
12
12
|
@test_manifest_mode = mode
|
13
13
|
end
|
14
14
|
|
15
|
+
def log_level=(level)
|
16
|
+
valid_log_levels = [:inherit, :info, :debug, :warn, :error]
|
17
|
+
|
18
|
+
if valid_log_levels.include?(level)
|
19
|
+
@log_level = level
|
20
|
+
else
|
21
|
+
raise "Unknown log_level '#{level}' (valid log_levels are: #{valid_log_levels})"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
15
25
|
def initialize
|
16
26
|
@build_options = nil
|
17
27
|
@manifest_name = 'sewing-kit-manifest.json'
|
18
28
|
@manifest_path = nil
|
19
29
|
@dev_server_sewing_kit_bin = 'node_modules/.bin/sewing-kit'
|
30
|
+
@log_level = :inherit
|
20
31
|
self.test_manifest_mode = :return_no_assets
|
21
32
|
end
|
22
33
|
end
|
data/lib/sewing_kit/version.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
require 'English'
|
4
3
|
|
5
4
|
module SewingKit
|
@@ -25,17 +24,13 @@ module SewingKit
|
|
25
24
|
private
|
26
25
|
|
27
26
|
def spawn
|
28
|
-
sewing_kit_bin = SewingKit.configuration.dev_server_sewing_kit_bin
|
29
|
-
raise NodeSewingKitNotInstalled unless File.exist?(sewing_kit_bin)
|
30
|
-
|
31
27
|
Kernel.spawn(
|
32
28
|
{
|
33
29
|
'NODE_ENV' => 'development',
|
34
30
|
'BLUEBIRD_DEBUG' => '0',
|
35
31
|
'BLUEBIRD_LONG_STACK_TRACES' => '0',
|
36
32
|
},
|
37
|
-
|
38
|
-
'dev',
|
33
|
+
command,
|
39
34
|
chdir: Rails.root.to_s,
|
40
35
|
out: $stdout,
|
41
36
|
err: $stderr,
|
@@ -52,6 +47,52 @@ module SewingKit
|
|
52
47
|
def detach
|
53
48
|
Process.detach pid
|
54
49
|
end
|
50
|
+
|
51
|
+
def command
|
52
|
+
command_list = [
|
53
|
+
sewing_kit_bin,
|
54
|
+
'dev',
|
55
|
+
'--logLevel',
|
56
|
+
log_level,
|
57
|
+
]
|
58
|
+
|
59
|
+
if debug_mode?
|
60
|
+
command_list.push(['--debug'])
|
61
|
+
end
|
62
|
+
|
63
|
+
command_list.join(' ')
|
64
|
+
end
|
65
|
+
|
66
|
+
def sewing_kit_bin
|
67
|
+
bin = SewingKit.configuration.dev_server_sewing_kit_bin
|
68
|
+
raise NodeSewingKitNotInstalled unless File.exist?(bin)
|
69
|
+
bin
|
70
|
+
end
|
71
|
+
|
72
|
+
def log_level
|
73
|
+
if SewingKit.configuration.log_level == :inherit
|
74
|
+
log_level_from_rails
|
75
|
+
else
|
76
|
+
SewingKit.configuration.log_level.to_s
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def log_level_from_rails
|
81
|
+
case Rails.logger.level
|
82
|
+
when 0
|
83
|
+
:debug
|
84
|
+
when 1
|
85
|
+
:info
|
86
|
+
when 2
|
87
|
+
:warn
|
88
|
+
else
|
89
|
+
:error
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def debug_mode?
|
94
|
+
!ENV['SK_DEBUG'].nil?
|
95
|
+
end
|
55
96
|
end
|
56
97
|
end
|
57
98
|
end
|