sewing_kit 0.129.0 → 0.130.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: 192f93794571de06b57d5125eec9da37d1331c3dbb47a2c530e29d6f4693cb47
4
- data.tar.gz: d06a650795388f99d0680e007e7402b8d964562be69610aa92032e9e24abdac1
3
+ metadata.gz: 1b4be7e61c2aec2c6298fb59b10911c320a3bdcc8f1d39ba1f20dacb24aa18d6
4
+ data.tar.gz: 01f90b60a90bd2b07aae4c2cca9c530f2bd4b563b4903de0ff4ff622db925782
5
5
  SHA512:
6
- metadata.gz: 773c4e613be0301501b9d8e31b12bce81027f7aaf39aabafa87c07a5a76430498b6c39d81801f4af44b1ea48e47cf127edddca88e7c2031dc22c44ffc202fe58
7
- data.tar.gz: 056bdc1ff814b70f35ffac31bcba3b7d95560002437272f8e615ae93d8e6a4bdcb49bb08b0d8db9961c99f88488ff3cd616cb991b044c125578ca41f660455de
6
+ metadata.gz: 53875153c6a31908a6c49d1f5b666166537bf58d020fac0b405f6b98e22aa044df7f28bf6ac61add74837324bb6910a1d36d33fd6f4fe557d3906328347b8a94
7
+ data.tar.gz: f1bf2019f9d98b2d6630466995c06f9c0229eb17c10dda1c499e52dc75527ad4aec04839a881e0c69667e4b0a5c0fbd16a2b3952676bb2f8b06b415233a4173d
data/README.md CHANGED
@@ -94,7 +94,13 @@ SewingKit.configure do |config|
94
94
  # Note: you *must* have a separate `yarn sewing-kit type-check` CI step for this to be viable.
95
95
  type_check: false,
96
96
  # Increase heap to accommodate webpack's space for source map generation
97
- heap: 2000
97
+ heap: 2000,
98
+ # Overrides ShopifyCloud's configuration for the assets directory.
99
+ # By default, when using the ShopifyCloud gem, assets are served from the CDN
100
+ # - when `asset_directory` is not specified, it defaults to: `ShopifyCloud::AssetUploader.asset_directory`
101
+ # - when specified, the asset path will be `https://cdn.shopify.com/shopifycloud/${assetDirectory}/bundles`
102
+ # - lastly, set it to `false` to disable serving assets from the CDN altogether
103
+ asset_directory: "foobar"
98
104
  }
99
105
  end
100
106
  ```
@@ -103,13 +109,13 @@ end
103
109
 
104
110
  For fast tests with consistent results, test front-end components using Jest instead of Rails integration tests.
105
111
 
106
- Use [`sewing-kit test`](https://github.com/Shopify/sewing-kit/blob/master/docs/commands/test.md#L3) to run all `.test.tsx` files in the `app/ui` directory. [Jest](https://jestjs.io) is used as a test runner, with customization available via [its sewing-kit plugin](https://github.com/Shopify/sewing-kit/blob/master/docs/plugins/jest.md).
112
+ Use [`sewing-kit test`](https://github.com/Shopify/sewing-kit/blob/main/docs/commands/test.md#L3) to run all `.test.tsx` files in the `app/ui` directory. [Jest](https://jestjs.io) is used as a test runner, with customization available via [its sewing-kit plugin](https://github.com/Shopify/sewing-kit/blob/main/docs/plugins/jest.md).
107
113
 
108
114
  ### Customizing the test environment
109
115
 
110
116
  Often you will want to hook up custom polyfills, global mocks, or other logic that needs to run either before the initialization of the test environment, or once for each test suite.
111
117
 
112
- By default, sewing-kit will look for such test setup files under `/app/ui/tests`. Check out the [documentation](https://github.com/Shopify/sewing-kit/blob/master/docs/plugins/jest.md#smart-defaults) for more details.
118
+ By default, sewing-kit will look for such test setup files under `/app/ui/tests`. Check out the [documentation](https://github.com/Shopify/sewing-kit/blob/main/docs/plugins/jest.md#smart-defaults) for more details.
113
119
 
114
120
  ### Rails tests
115
121
 
@@ -2,12 +2,12 @@
2
2
 
3
3
  module SewingKit
4
4
  class InstallGenerator < Rails::Generators::Base
5
- source_root File.expand_path('templates', __dir__)
5
+ source_root File.expand_path("templates", __dir__)
6
6
 
7
7
  desc "Adds the configuration files for a sewing-kit powered front-end."
8
8
 
9
9
  class_option :skip_yarn, type: :boolean, default: false
10
- class_option :javascript_path, type: :string, default: 'app/ui'
10
+ class_option :javascript_path, type: :string, default: "app/ui"
11
11
 
12
12
  # We don't specify a default here because we want to fallback dynamically
13
13
  class_option :uses_dev, type: :boolean
@@ -39,9 +39,11 @@ module SewingKit
39
39
 
40
40
  def install_js_dependencies
41
41
  return if options.skip_yarn?
42
+
42
43
  say("Installing javascript dependencies")
43
- system("yarn add @shopify/sewing-kit")
44
- system("yarn add typescript")
44
+ # rubocop:disable Layout/LineLength
45
+ system("yarn add @shopify/sewing-kit @shopify/eslint-plugin @shopify/stylelint-plugin @shopify/prettier-config @shopify/typescript-configs typescript")
46
+ # rubocop:enable Layout/LineLength
45
47
  end
46
48
 
47
49
  class Project
@@ -50,11 +52,11 @@ module SewingKit
50
52
  end
51
53
 
52
54
  def self.uses_dev?
53
- File.exist?('dev.yml')
55
+ File.exist?("dev.yml")
54
56
  end
55
57
 
56
58
  def self.uses_webpacker?
57
- File.exist?('config/webpacker.yml')
59
+ File.exist?("config/webpacker.yml")
58
60
  end
59
61
  end
60
62
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yaml'
3
+ require "yaml"
4
4
 
5
5
  # 🐵 patches eager-loading and cacheing of the default user_agent patterns
6
6
  # PR to add the functionality for reals: https://github.com/ua-parser/uap-ruby/pull/56
@@ -25,11 +25,11 @@ module UserAgentParser
25
25
  # Parse all the regexs
26
26
  yml.each_pair do |_type, patterns|
27
27
  patterns.each do |pattern|
28
- pattern[:regex] = Regexp.new(pattern['regex'], pattern['regex_flag'] == 'i')
28
+ pattern[:regex] = Regexp.new(pattern["regex"], pattern["regex_flag"] == "i")
29
29
  end
30
30
  end
31
31
 
32
- [yml['user_agent_parsers'], yml['os_parsers'], yml['device_parsers']]
32
+ [yml["user_agent_parsers"], yml["os_parsers"], yml["device_parsers"]]
33
33
  end
34
34
  end
35
35
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SewingKit
3
4
  class Configuration
4
5
  attr_accessor :development_options, :build_options, :dev_server_sewing_kit_bin, :manifest_name,
@@ -25,9 +26,9 @@ module SewingKit
25
26
  def initialize
26
27
  @build_options = nil
27
28
  @development_options = {}
28
- @manifest_name = 'sewing-kit-manifest.json'
29
+ @manifest_name = "sewing-kit-manifest.json"
29
30
  @manifest_path = nil
30
- @dev_server_sewing_kit_bin = 'node_modules/.bin/sewing-kit'
31
+ @dev_server_sewing_kit_bin = "node_modules/.bin/sewing-kit"
31
32
  @log_level = :inherit
32
33
  self.test_manifest_mode = :return_no_assets
33
34
  end
@@ -1,2 +1,3 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "sewing_kit/railtie" if defined? Rails
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
- require 'rails'
3
- require 'rails/railtie'
4
2
 
5
- require 'sewing_kit/webpack/compiler'
6
- require 'sewing_kit/webpack/helper'
7
- require 'sewing_kit/webpack/dev'
8
- require 'sewing_kit/webpack/server'
3
+ require "rails"
4
+ require "rails/railtie"
5
+
6
+ require "sewing_kit/webpack/compiler"
7
+ require "sewing_kit/webpack/helper"
8
+ require "sewing_kit/webpack/dev"
9
+ require "sewing_kit/webpack/server"
9
10
 
10
11
  module SewingKit
11
12
  class Railtie < ::Rails::Railtie
12
- # rubocop:disable Metrics/BlockLength
13
13
  config.after_initialize do
14
- is_development = Rails.env.development? && ENV['SK_SIMULATE_PRODUCTION'] != '1'
15
- if is_development && (Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
14
+ is_development = Rails.env.development? && ENV["SK_SIMULATE_PRODUCTION"] != "1"
15
+ if is_development && (Rails.const_defined?(:Server) || ENV["SK_FORCE_DEV_SERVER"])
16
16
  webpack_dev = SewingKit::Webpack::Dev.new
17
17
  webpack_dev.start
18
18
  end
@@ -25,8 +25,6 @@ module SewingKit
25
25
  include SewingKit::Webpack::Helper
26
26
  end
27
27
  end
28
- # rubocop:enable Metrics/BlockLength
29
-
30
28
  rake_tasks do
31
29
  load "tasks/sewing_kit.rake"
32
30
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SewingKit
3
- VERSION = "0.129.0"
4
+ VERSION = "0.130.1"
4
5
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'sewing_kit/webpack/webpack'
2
+
3
+ require "sewing_kit/webpack/webpack"
3
4
 
4
5
  module SewingKit
5
6
  module Webpack
@@ -19,7 +20,7 @@ module SewingKit
19
20
 
20
21
  def compile
21
22
  raise NodeNotInstalled unless node_installed?
22
- raise NodeSewingKitNotRunnable, node_env unless File.exist?('node_modules/.bin/sewing-kit')
23
+ raise NodeSewingKitNotRunnable, node_env unless File.exist?("node_modules/.bin/sewing-kit")
23
24
 
24
25
  result = Kernel.system(
25
26
  environment,
@@ -40,38 +41,42 @@ module SewingKit
40
41
 
41
42
  def command
42
43
  [
43
- 'node_modules/.bin/sewing-kit',
44
- 'build',
45
- '--mode',
44
+ "node_modules/.bin/sewing-kit",
45
+ "build",
46
+ "--mode",
46
47
  node_env,
47
48
  ].concat(options).reject(&:empty?)
48
49
  end
49
50
 
50
51
  def environment
51
- environment = {
52
- 'NODE_ENV' => node_env,
53
- }
54
-
55
- if defined?(ShopifyCloud)
56
- environment['SK_ASSET_DIR'] = ShopifyCloud::AssetUploader.asset_directory
57
- end
58
-
59
- environment
52
+ {
53
+ "NODE_ENV" => node_env,
54
+ "SK_ASSET_DIR" => asset_dir,
55
+ }.filter { |_, v| v }
60
56
  end
61
57
 
62
58
  def node_env
63
- ENV['NODE_ENV'] || Rails.env.to_s
59
+ ENV["NODE_ENV"] || Rails.env.to_s
60
+ end
61
+
62
+ def asset_dir
63
+ directory = SewingKit.configuration.build_options&.dig(:asset_directory)
64
+
65
+ return nil if directory == false
66
+ return ShopifyCloud::AssetUploader.asset_directory if directory.nil? && defined?(ShopifyCloud)
67
+
68
+ directory
64
69
  end
65
70
 
66
71
  def options
67
- build_options = SewingKit.configuration.build_options
72
+ build_options = SewingKit.configuration.build_options&.except(:asset_directory)
68
73
  return [] unless build_options
69
74
 
70
- build_options.map { |key, value| ["--#{key.to_s.tr('_', '-')}", value.to_s] }.flatten
75
+ build_options.map { |key, value| ["--#{key.to_s.tr("_", "-")}", value.to_s] }.flatten
71
76
  end
72
77
 
73
78
  def node_installed?
74
- Kernel.system('node --version')
79
+ Kernel.system("node --version")
75
80
  end
76
81
  end
77
82
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'English'
2
+
3
+ require "English"
3
4
 
4
5
  module SewingKit
5
6
  module Webpack
@@ -8,7 +9,7 @@ module SewingKit
8
9
  def initialize
9
10
  super(
10
11
  "sewing-kit is not installed. " \
11
- "Try `yarn add @shopify/sewing-kit`"
12
+ "Try `yarn add @shopify/sewing-kit`"
12
13
  )
13
14
  end
14
15
  end
@@ -26,9 +27,10 @@ module SewingKit
26
27
  def spawn
27
28
  Kernel.spawn(
28
29
  {
29
- 'NODE_ENV' => 'development',
30
- 'BLUEBIRD_DEBUG' => '0',
31
- 'BLUEBIRD_LONG_STACK_TRACES' => '0',
30
+ "NODE_ENV" => "development",
31
+ "BLUEBIRD_DEBUG" => "0",
32
+ "BLUEBIRD_LONG_STACK_TRACES" => "0",
33
+ "FORCE_COLOR" => "true",
32
34
  },
33
35
  command,
34
36
  chdir: Rails.root.to_s,
@@ -39,7 +41,8 @@ module SewingKit
39
41
 
40
42
  def handle_exit
41
43
  return if $ERROR_INFO.nil?
42
- Process.kill('SIGTERM', pid)
44
+
45
+ Process.kill("SIGTERM", pid)
43
46
  rescue Errno::ESRCH
44
47
  nil
45
48
  end
@@ -50,19 +53,19 @@ module SewingKit
50
53
 
51
54
  def command
52
55
  command_list = [
53
- 'node',
56
+ "node",
54
57
  heap_config,
55
58
  sewing_kit_bin,
56
- 'dev',
57
- '--log-level',
59
+ "dev",
60
+ "--log-level",
58
61
  log_level,
59
62
  ].compact.concat(options)
60
63
 
61
64
  if debug_mode?
62
- command_list.push(['--debug'])
65
+ command_list.push(["--debug"])
63
66
  end
64
67
 
65
- command_list.join(' ')
68
+ command_list.join(" ")
66
69
  end
67
70
 
68
71
  def heap_config
@@ -73,6 +76,7 @@ module SewingKit
73
76
  def sewing_kit_bin
74
77
  bin = SewingKit.configuration.dev_server_sewing_kit_bin
75
78
  raise NodeSewingKitNotInstalled unless File.exist?(bin)
79
+
76
80
  bin
77
81
  end
78
82
 
@@ -90,7 +94,7 @@ module SewingKit
90
94
 
91
95
  development_options
92
96
  .reject { |key| key == :heap }
93
- .map { |key, value| ["--#{key.to_s.tr('_', '-')}", value.to_s] }.flatten + focus.flatten
97
+ .map { |key, value| ["--#{key.to_s.tr("_", "-")}", value.to_s] }.flatten + focus.flatten
94
98
  end
95
99
 
96
100
  def log_level_from_rails
@@ -107,14 +111,14 @@ module SewingKit
107
111
  end
108
112
 
109
113
  def debug_mode?
110
- !ENV['SK_DEBUG'].nil?
114
+ !ENV["SK_DEBUG"].nil?
111
115
  end
112
116
 
113
117
  def focus_sections
114
- return [] if ENV['SK_FOCUS'].nil?
118
+ return [] if ENV["SK_FOCUS"].nil?
115
119
 
116
- ENV['SK_FOCUS']
117
- .split(',')
120
+ ENV["SK_FOCUS"]
121
+ .split(",")
118
122
  .map { |section| ["--focus", section] }
119
123
  end
120
124
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require 'base64'
3
- require 'sewing_kit/webpack/manifest'
2
+
3
+ require "base64"
4
+ require "sewing_kit/webpack/manifest"
4
5
 
5
6
  module SewingKit
6
7
  module Webpack
@@ -10,9 +11,8 @@ module SewingKit
10
11
 
11
12
  Asset = Struct.new(:path, :integrity)
12
13
 
13
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
14
- def sewing_kit_assets(entrypoint_name, extension: 'js')
15
- return '' unless entrypoint_name.present?
14
+ def sewing_kit_assets(entrypoint_name, extension: "js")
15
+ return "" unless entrypoint_name.present?
16
16
 
17
17
  assets = SewingKit::Webpack::Manifest.asset_dependencies(entrypoint_name, request.user_agent)
18
18
 
@@ -20,18 +20,17 @@ module SewingKit
20
20
  return [] unless assets && assets[extension]
21
21
 
22
22
  dependencies = assets[extension]
23
- dependencies.unshift(dll_asset) if serve_development_assets? && extension == 'js'
24
23
  dependencies.map do |raw_asset|
25
- Asset.new(raw_asset['path'], raw_asset['integrity'])
24
+ Asset.new(raw_asset["path"], raw_asset["integrity"])
26
25
  end
27
26
  end
28
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
29
27
 
30
28
  def sewing_kit_link_tag(*assets)
31
29
  options = assets.extract_options!
32
30
 
33
31
  tags = assets.uniq.map do |asset|
34
- next '' if asset.path == ''
32
+ next "" if asset.path == ""
33
+
35
34
  create_asset_tag(:link, asset, options)
36
35
  end
37
36
 
@@ -41,7 +40,7 @@ module SewingKit
41
40
  def sewing_kit_script_tag(*assets)
42
41
  options = assets.extract_options!
43
42
  tags = assets.map do |asset|
44
- next '' if asset.path == ''
43
+ next "" if asset.path == ""
45
44
 
46
45
  create_asset_tag(:script, asset, options)
47
46
  end
@@ -68,24 +67,21 @@ module SewingKit
68
67
 
69
68
  case tag_type
70
69
  when :script
71
- content_tag(:script, '', options.reverse_merge(src: asset.path))
70
+ content_tag(:script, "", options.reverse_merge(src: asset.path))
72
71
  when :link
73
- tag(:link, options.reverse_merge(href: asset.path, rel: 'stylesheet'))
72
+ tag(:link, options.reverse_merge(href: asset.path, rel: "stylesheet"))
74
73
  end
75
74
  end
76
75
 
77
76
  def serve_development_assets?
78
- return false if ENV['SK_SIMULATE_PRODUCTION'] == '1'
77
+ return false if ENV["SK_SIMULATE_PRODUCTION"] == "1"
78
+
79
79
  Rails.env.development?
80
80
  end
81
81
 
82
82
  def raise_unknown_error?(assets)
83
83
  assets.nil? && serve_development_assets?
84
84
  end
85
-
86
- def dll_asset
87
- Asset.new('/webpack/assets/dll/vendor.js')
88
- end
89
85
  end
90
86
  end
91
87
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'sewing_kit/webpack/webpack'
2
+
3
+ require "sewing_kit/webpack/webpack"
3
4
 
4
5
  module SewingKit
5
6
  module Webpack
@@ -18,7 +19,7 @@ module SewingKit
18
19
 
19
20
  if current_metadata.is_a?(Array)
20
21
  all_assets = current_metadata.flat_map do |data|
21
- data['assets']['all'].values
22
+ data["assets"]["all"].values
22
23
  end
23
24
 
24
25
  # sewing-kit asset manifests return a numerically indexed hash, not a true array,
@@ -31,7 +32,7 @@ module SewingKit
31
32
  "all" => asset_hash,
32
33
  }
33
34
  else
34
- current_metadata['assets']
35
+ current_metadata["assets"]
35
36
  end
36
37
  end
37
38
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'sewing_kit/webpack/manifest/base'
2
+
3
+ require "sewing_kit/webpack/manifest/base"
3
4
 
4
5
  module SewingKit
5
6
  module Webpack
@@ -11,15 +12,15 @@ module SewingKit
11
12
  end
12
13
 
13
14
  def asset_bundle_name(_user_agent)
14
- 'dev'
15
+ "dev"
15
16
  end
16
17
 
17
18
  def asset_dependencies(entrypoint_name, _user_agent)
18
19
  current_metadata = metadata
19
- if current_metadata.key?('development')
20
- current_metadata['development']['hangTight']
20
+ if current_metadata.key?("development")
21
+ current_metadata["development"]["hangTight"]
21
22
  else
22
- current_metadata['entrypoints'][entrypoint_name]
23
+ current_metadata["entrypoints"][entrypoint_name]
23
24
  end
24
25
  end
25
26
 
@@ -52,7 +53,7 @@ module SewingKit
52
53
  result = load_metadata_from_node
53
54
 
54
55
  metadata = normalize_metadata(result)
55
- @metadata_path = metadata && metadata['path']
56
+ @metadata_path = metadata && metadata["path"]
56
57
  metadata
57
58
  end
58
59
 
@@ -69,10 +70,10 @@ module SewingKit
69
70
  def load_metadata_from_node
70
71
  begin
71
72
  stdout, stderr, status = Open3.capture3(
72
- 'node_modules/.bin/sewing-kit', 'manifest', "--mode=development"
73
+ "node_modules/.bin/sewing-kit", "manifest", "--mode=development"
73
74
  )
74
75
  rescue => e
75
- raise NodeSewingKitNotRunnable.new('development', e)
76
+ raise NodeSewingKitNotRunnable.new("development", e)
76
77
  end
77
78
 
78
79
  raise NodeSewingKitManifestMissing, stderr unless status.success?
@@ -84,7 +85,7 @@ module SewingKit
84
85
  class OnlyUseInProductionError < StandardError
85
86
  def initialize
86
87
  super("The SewingKit::Webpack::Manifest#manifest is intended "\
87
- "for deploying assets to a CDN. Do not use it in development.")
88
+ "for deploying assets to a CDN. Do not use it in development.")
88
89
  end
89
90
  end
90
91
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
- require 'sewing_kit/webpack/manifest/base'
3
- require 'benchmark'
4
- require 'browserslist_useragent'
2
+
3
+ require "sewing_kit/webpack/manifest/base"
4
+ require "benchmark"
5
+ require "browserslist_useragent"
5
6
 
6
7
  module SewingKit
7
8
  module Webpack
@@ -15,12 +16,12 @@ module SewingKit
15
16
 
16
17
  def asset_bundle_name(user_agent)
17
18
  manifest = metadata_for(user_agent)
18
- manifest['identifier'] && manifest['identifier']['target'] || manifest['name']
19
+ manifest["identifier"] && manifest["identifier"]["target"] || manifest["name"]
19
20
  end
20
21
 
21
22
  # :nodoc:
22
23
  def asset_dependencies(entrypoint_name, user_agent)
23
- metadata_for(user_agent)['entrypoints'][entrypoint_name]
24
+ metadata_for(user_agent)["entrypoints"][entrypoint_name]
24
25
  end
25
26
 
26
27
  def metadata
@@ -75,7 +76,7 @@ module SewingKit
75
76
  def path
76
77
  return SewingKit.configuration.manifest_path unless SewingKit.configuration.manifest_path.nil?
77
78
 
78
- File.join(Rails.root, 'public', 'bundles', SewingKit.configuration.manifest_name)
79
+ File.join(Rails.root, "public", "bundles", SewingKit.configuration.manifest_name)
79
80
  end
80
81
  end
81
82
  end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
- require 'sewing_kit/webpack/manifest/base'
2
+
3
+ require "sewing_kit/webpack/manifest/base"
3
4
 
4
5
  module SewingKit
5
6
  module Webpack
6
7
  class Manifest
7
8
  class TestWithNoAssets < Base
8
9
  def asset_bundle_name(_user_agent)
9
- 'test'
10
+ "test"
10
11
  end
11
12
 
12
13
  def asset_dependencies(_entrypoint_name, _user_agent)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require 'open3'
3
- require 'uri'
2
+
3
+ require "open3"
4
+ require "uri"
4
5
 
5
6
  module SewingKit
6
7
  module Webpack
@@ -10,13 +11,13 @@ module SewingKit
10
11
  def initialize(node_error_message)
11
12
  super(
12
13
  "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" \
19
- "Original error #{node_error_message}"
14
+ "Possible next steps:\n" \
15
+ " - If the server is still starting up, wait for a " \
16
+ "'Compiled with latest changes' message then refresh your browser\n" \
17
+ " - Check the development console for compilation errors\n" \
18
+ " - Restart your development server\n" \
19
+ "\n" \
20
+ "Original error #{node_error_message}"
20
21
  )
21
22
  end
22
23
  end
@@ -56,7 +57,7 @@ module SewingKit
56
57
  def instance
57
58
  return Production.new if simulate_production?
58
59
 
59
- @instance ||= if mode == 'development'
60
+ @instance ||= if mode == "development"
60
61
  Development.new
61
62
  elsif skip_assets?
62
63
  TestWithNoAssets.new
@@ -68,21 +69,21 @@ module SewingKit
68
69
  private
69
70
 
70
71
  def mode
71
- ENV['NODE_ENV'] || Rails.env.to_s
72
+ ENV["NODE_ENV"] || Rails.env.to_s
72
73
  end
73
74
 
74
75
  def skip_assets?
75
- mode == 'test' && SewingKit.configuration.test_manifest_mode == :return_no_assets
76
+ mode == "test" && SewingKit.configuration.test_manifest_mode == :return_no_assets
76
77
  end
77
78
 
78
79
  def simulate_production?
79
- ENV['SK_SIMULATE_PRODUCTION'] == '1' || ENV['SK_SIMULATE_PRODUCTION'] == 'true'
80
+ ENV["SK_SIMULATE_PRODUCTION"] == "1" || ENV["SK_SIMULATE_PRODUCTION"] == "true"
80
81
  end
81
82
  end
82
83
  end
83
84
  end
84
85
  end
85
86
 
86
- require 'sewing_kit/webpack/manifest/development'
87
- require 'sewing_kit/webpack/manifest/production'
88
- require 'sewing_kit/webpack/manifest/test_with_no_assets'
87
+ require "sewing_kit/webpack/manifest/development"
88
+ require "sewing_kit/webpack/manifest/production"
89
+ require "sewing_kit/webpack/manifest/test_with_no_assets"
@@ -34,15 +34,15 @@ module SewingKit
34
34
 
35
35
  def command
36
36
  command_list = [
37
- 'node',
37
+ "node",
38
38
  default_entrypoint,
39
39
  ].compact
40
40
 
41
- command_list.join(' ')
41
+ command_list.join(" ")
42
42
  end
43
43
 
44
44
  def default_entrypoint
45
- 'build/server/main.js'
45
+ "build/server/main.js"
46
46
  end
47
47
  end
48
48
  end
@@ -5,19 +5,19 @@ module SewingKit
5
5
  # Raised if the node sewing-kit isn't installed/runnable.
6
6
  class NodeSewingKitNotRunnable < StandardError
7
7
  def initialize(mode, cause = nil)
8
- env_message = if 'development' == mode
8
+ env_message = if "development" == mode
9
9
  "Try `yarn add @shopify/sewing-kit`"
10
10
  else
11
11
  "\nIf this is a container build, try:\n" \
12
- " - Adding #{highlight('https://github.com/heroku/heroku-buildpack-nodejs')} to your " \
13
- "#{highlight('.buildpacks')} file\n" \
14
- " - Adding #{highlight('YARN_PRODUCTION=false')} to your pipeline's environment variables\n" \
12
+ " - Adding #{highlight("https://github.com/heroku/heroku-buildpack-nodejs")} to your " \
13
+ "#{highlight(".buildpacks")} file\n" \
14
+ " - Adding #{highlight("YARN_PRODUCTION=false")} to your pipeline's environment variables\n" \
15
15
  end
16
16
 
17
17
  super(
18
18
  "sewing-kit is not runnable.\n" \
19
- "#{env_message}\n" +
20
- (cause ? "Original error #{cause}" : '')
19
+ "#{env_message}\n" +
20
+ (cause ? "Original error #{cause}" : "")
21
21
  )
22
22
  end
23
23
 
data/lib/sewing_kit.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module SewingKit
3
4
  end
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  TEMPLATE_PATH = File.expand_path("../install/template.rb", File.dirname(__FILE__))
3
4
 
4
5
  namespace :sewing_kit do
@@ -24,13 +25,13 @@ end
24
25
 
25
26
  if Rake::Task.task_defined?("assets:precompile")
26
27
  Rake::Task["assets:precompile"].enhance do
27
- Rake::Task['sewing_kit:build'].invoke
28
+ Rake::Task["sewing_kit:build"].invoke
28
29
  end
29
30
  else
30
- Rake::Task.define_task("assets:precompile" => %w(sewing_kit:build))
31
+ Rake::Task.define_task("assets:precompile" => ["sewing_kit:build"])
31
32
  end
32
33
 
33
- unless Rake::Task.task_defined?('assets:clean')
34
+ unless Rake::Task.task_defined?("assets:clean")
34
35
  namespace :assets do
35
36
  task :clean do
36
37
  # This empty task is to offer the same interface than sprockets and webpacker
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.129.0
4
+ version: 0.130.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Sauve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-26 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.89.1
75
+ version: '1.28'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.89.1
82
+ version: '1.28'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop-git
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.5
103
+ version: '2.5'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.5
110
+ version: '2.5'
111
111
  description:
112
112
  email:
113
113
  - chris.sauve@shopify.com
@@ -141,11 +141,11 @@ files:
141
141
  - lib/sewing_kit/webpack/server.rb
142
142
  - lib/sewing_kit/webpack/webpack.rb
143
143
  - lib/tasks/sewing_kit.rake
144
- homepage: https://github.com/Shopify/sewing-kit/tree/master/gems/sewing_kit
144
+ homepage: https://github.com/Shopify/sewing-kit/tree/main/gems/sewing_kit
145
145
  licenses:
146
146
  - MIT
147
147
  metadata:
148
- changelog_uri: https://github.com/Shopify/sewing-kit/blob/master/gems/sewing_kit/CHANGELOG.md
148
+ changelog_uri: https://github.com/Shopify/sewing-kit/blob/main/gems/sewing_kit/CHANGELOG.md
149
149
  allowed_push_host: https://rubygems.org
150
150
  post_install_message:
151
151
  rdoc_options: []
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.0.3
165
+ rubygems_version: 3.4.10
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: Shopify's modern front-end tooling, nicely packaged for Rails