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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3b2b21c04f2ce3043bc5ff0c27dc61b301ab3585e4f84347d1edfeef0f92121
4
- data.tar.gz: d378424249b09da4747a81281d2ba3f703790f23ac8fa2732e0a39ef655224a7
3
+ metadata.gz: 6b602141d9384dbe196746242130707db37ed8cc877f50b36364b3c8e15a018f
4
+ data.tar.gz: b9669c5e2666ae28ae2f3ad6228cff9b6e969e73da05855224ba8acc837cf437
5
5
  SHA512:
6
- metadata.gz: f5beb6976e7812ebef7adc31040a1c5c08178af88118d3952d7aaaea5c740172a6e381b89cf1a388c1ed7e4e6d026e21effdc321e196587613fc0a56233b7be3
7
- data.tar.gz: 2b2a62b6e61004d24571e4b5b14319100e5bfc3a60c392a2fcec30912e1e71c4ca3e2142de49d25d14d64d438384e2d3c51385ad7b413d0a5f60a898b195d852
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-commenoner`, can I use sewing_kit too?
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SewingKit
3
- VERSION = "0.94.0"
3
+ VERSION = "0.95.0"
4
4
  end
@@ -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
- sewing_kit_bin,
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
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.94.0
4
+ version: 0.95.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Sauve