sewing_kit 0.97.2 → 0.123.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: 8b06a7ac7ca6913c06fe04a78c864edfc777866c6c5091cd5c9e4498af7cf2f5
4
- data.tar.gz: cc6753141c017b19eb312fec44d023c747419bebe9879084b79c8b60a6dcc895
3
+ metadata.gz: ad8a311afdf9ea5efa60527866ac02247e3c91189a636aa78c9dde602f304e0f
4
+ data.tar.gz: 65e3897e31a73ae2ec5b3756672a35ccfda44df1d3cffa22a7473193aaf40b3a
5
5
  SHA512:
6
- metadata.gz: d76d48b71ded160f1f4033acb468a0f1b569499f91b228a144052b31fe1a137a61d77d725ffceb23052c25c2904ec6e088df1c1778ca80effb79d90991dc33be
7
- data.tar.gz: 249abd4930b338521f16e141e0a9405d7386919e0e641991fae90983aba9c54979ad960b62fba674556f0a569c991e7473fdb5d37a278ec2d7aa5b38815820ac
6
+ metadata.gz: 9c0706c23cb462eb4240def360fcfc0d2afd158f3b3db2846290ddcbea176ea94b00ec3a9cbf2471c372ea8cef7668a625bb55fca2f0e8429c8514ee59cc2d65
7
+ data.tar.gz: d255523fbb50e830708ac1dfaec86aede73ab3b815e0653627cf51488c16f25a234effceea37b177dd9cb28d46a30fa4bff5c7c4160820c7d610eff2796d1ea4
data/README.md CHANGED
@@ -19,6 +19,12 @@ yarn
19
19
  dev up
20
20
  ```
21
21
 
22
+ ### Run generator
23
+
24
+ `rails generate sewing_kit:install`
25
+
26
+ will generate a package.json file with common sewing-kit script tasks, default lint, format configuration; a sewing-kit configuration file, and other project default configurations.
27
+
22
28
  ### Add JavaScript
23
29
 
24
30
  sewing_kit looks for JavaScript in `app/ui/index.js`. The code in `index.js` (and any imported JS/CSS) will be built into a `main` bundle.
@@ -146,7 +152,7 @@ If sewing-kit makes a breaking change, this gem's minor version will be bumped t
146
152
 
147
153
  By moving everything into `package.json#dependencies`. This is necessary because Rails 5.2 prunes `devDependencies` during asset compilation.
148
154
 
149
- ### How can I test a production verison of my changes?
155
+ ### How can I test a production version of my changes?
150
156
 
151
157
  Ideally, by deploying to a `staging` environment. If that is not possible, a production-like local development experience is available via:
152
158
 
@@ -176,3 +182,15 @@ SewingKit.configure do |config|
176
182
  config.log_level = :warn # may be `:inherit`, `:debug`, `:info`, `:warn`, or `:error`
177
183
  end
178
184
  ```
185
+
186
+ ### How do I run sewing-kit in debug mode?
187
+
188
+ You can launch sewing-kit in debug mode by setting the `SK_DEBUG` environment flag.
189
+
190
+ ```bash
191
+ $ SK_DEBUG=1 dev run
192
+ ```
193
+
194
+ This runs your rails app with the sewing-kit development server in debug mode. This is useful for when you want to debug sewing-kit from a rails app.
195
+
196
+ Tip: Install the [Node.js V8 --inspector Manager (NiM)](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj?hl=en) Chrome extension. This will launch a chrome debugger automatically for you.
@@ -0,0 +1,5 @@
1
+ Description:
2
+ This generator creates a sewing-kit config file.
3
+
4
+ Example:
5
+ rails generate sewing_kit:install
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SewingKit
4
+ class InstallGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ desc "This generator creates a sewing-kit config file."
8
+
9
+ def initialize(args, *options)
10
+ @application_name = Rails.application.class.module_parent.to_s.underscore
11
+ super(args, *options)
12
+ end
13
+
14
+ def create_package_json
15
+ package_json_path = "package.json"
16
+
17
+ copy_file(package_json_path)
18
+ gsub_file(package_json_path, "\${application_name}", @application_name)
19
+ end
20
+
21
+ def create_sk_config
22
+ sk_config_path = "config/sewing-kit.config.ts"
23
+
24
+ copy_file("sewing-kit.config.ts", sk_config_path)
25
+ gsub_file(sk_config_path, "\${application_name}", @application_name)
26
+ end
27
+
28
+ def create_config_files
29
+ copy_file("editorconfig", ".editorconfig")
30
+ copy_file("eslintignore", ".eslintignore")
31
+ copy_file("prettierignore", ".prettierignore")
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,15 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_size = 2
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ # Markdown syntax specifies that trailing whitespaces can be meaningful,
12
+ # so let’s not trim those. e.g. 2 trailing spaces = linebreak (<br />)
13
+ # See https://daringfireball.net/projects/markdown/syntax#p
14
+ [*.md]
15
+ trim_trailing_whitespace = false
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ build
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "${application_name}",
3
+ "private": true,
4
+ "sideEffects": false,
5
+ "scripts": {
6
+ "dev": "sewing-kit dev",
7
+ "check": "sewing-kit check",
8
+ "lint": "sewing-kit lint",
9
+ "type-check": "sewing-kit type-check",
10
+ "nuke": "sewing-kit nuke",
11
+ "test": "sewing-kit test"
12
+ },
13
+ "eslintConfig": {
14
+ "extends": [
15
+ "plugin:@shopify/typescript",
16
+ "plugin:@shopify/react",
17
+ "plugin:@shopify/prettier",
18
+ "plugin:@shopify/jest",
19
+ "plugin:@shopify/polaris"
20
+ ]
21
+ },
22
+ "prettier": "@shopify/prettier-config",
23
+ "stylelint": {
24
+ "extends": [
25
+ "@shopify/stylelint-plugin/prettier"
26
+ ]
27
+ },
28
+ "resolutions": {
29
+ "babel-plugin-dynamic-import-node": "2.3.0"
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ package.json
2
+ .sewing-kit
3
+ .dev
4
+ node_modules
5
+ tmp
6
+ public
7
+ *.svg
@@ -0,0 +1,11 @@
1
+ /* eslint-env node */
2
+
3
+ import {Plugins} from '@shopify/sewing-kit';
4
+
5
+ export default function sewingKitConfig(plugins: Plugins) {
6
+ return {
7
+ name: "${application_name}",
8
+ plugins: [
9
+ ],
10
+ };
11
+ }
@@ -1,15 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'rails'
3
3
  require 'rails/railtie'
4
- begin
5
- # Force assets:precompile to be defined before sewing_kit's railtie tries to
6
- # extend it.
7
- require "sprockets/railtie" if defined? Rails
8
- # rubocop:disable Lint/HandleExceptions
9
- rescue
10
- #
11
- end
12
- # rubocop:enable Lint/HandleExceptions
4
+
13
5
  require 'sewing_kit/webpack/compiler'
14
6
  require 'sewing_kit/webpack/helper'
15
7
  require 'sewing_kit/webpack/dev'
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SewingKit
3
- VERSION = "0.97.2"
3
+ VERSION = "0.123.0"
4
4
  end
@@ -22,7 +22,7 @@ module SewingKit
22
22
  raise NodeSewingKitNotRunnable, node_env unless File.exist?('node_modules/.bin/sewing-kit')
23
23
 
24
24
  result = Kernel.system(
25
- { 'NODE_ENV' => node_env },
25
+ environment,
26
26
  *command,
27
27
  chdir: Rails.root.to_s,
28
28
  out: $stdout,
@@ -47,6 +47,18 @@ module SewingKit
47
47
  ].concat(options).reject(&:empty?)
48
48
  end
49
49
 
50
+ 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
60
+ end
61
+
50
62
  def node_env
51
63
  ENV['NODE_ENV'] || Rails.env.to_s
52
64
  end
@@ -14,7 +14,8 @@ module SewingKit
14
14
  end
15
15
 
16
16
  def asset_bundle_name(user_agent)
17
- metadata_for(user_agent)['name']
17
+ manifest = metadata_for(user_agent)
18
+ manifest['identifier'] && manifest['identifier']['target'] || manifest['name']
18
19
  end
19
20
 
20
21
  # :nodoc:
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- def highlight(message)
4
- "\u001b[1m\u001b[37m#{message}\u001b[39m\u001b[22m"
5
- end
6
-
7
3
  module SewingKit
8
4
  module Webpack
9
5
  # Raised if the node sewing-kit isn't installed/runnable.
@@ -24,6 +20,10 @@ module SewingKit
24
20
  (cause ? "Original error #{cause}" : '')
25
21
  )
26
22
  end
23
+
24
+ def highlight(message)
25
+ "\u001b[1m\u001b[37m#{message}\u001b[39m\u001b[22m"
26
+ end
27
27
  end
28
28
  end
29
29
  end
@@ -14,8 +14,10 @@ namespace :sewing_kit do
14
14
  end
15
15
  end
16
16
 
17
- if Rake::Task.task_defined?('assets:precompile')
18
- Rake::Task['assets:precompile'].enhance do
17
+ if Rake::Task.task_defined?("assets:precompile")
18
+ Rake::Task["assets:precompile"].enhance do
19
19
  Rake::Task['sewing_kit:build'].invoke
20
20
  end
21
+ else
22
+ Rake::Task.define_task("assets:precompile" => %w(sewing_kit:build))
21
23
  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.97.2
4
+ version: 0.123.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-12-19 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -102,6 +102,13 @@ extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
104
  - README.md
105
+ - lib/generators/sewing_kit/USAGE
106
+ - lib/generators/sewing_kit/install_generator.rb
107
+ - lib/generators/sewing_kit/templates/editorconfig
108
+ - lib/generators/sewing_kit/templates/eslintignore
109
+ - lib/generators/sewing_kit/templates/package.json
110
+ - lib/generators/sewing_kit/templates/prettierignore
111
+ - lib/generators/sewing_kit/templates/sewing-kit.config.ts
105
112
  - lib/hacks/user_agent_parser.rb
106
113
  - lib/sewing_kit.rb
107
114
  - lib/sewing_kit/configuration.rb
@@ -123,6 +130,7 @@ licenses:
123
130
  - MIT
124
131
  metadata:
125
132
  changelog_uri: https://github.com/Shopify/sewing-kit/blob/master/gems/sewing_kit/CHANGELOG.md
133
+ allowed_push_host: https://rubygems.org
126
134
  post_install_message:
127
135
  rdoc_options: []
128
136
  require_paths: