sewing_kit 0.122.1 → 0.127.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: c35fc352107f7ecbb619a6009058eb25612d7d7efd4ed545799db01c7cc4f7c6
4
- data.tar.gz: 50185d9023bcca21c9a7786eb4ccbe8cda808869f70233feae7aeeca41444d26
3
+ metadata.gz: cf1b908d92ccc28fb41b4e5a2161631455adee178681ee79146a23e76fbf17dc
4
+ data.tar.gz: '08f476ab5358c90db8f509f9265c281eafc0816af96a0fe70b2c189a3324fd6c'
5
5
  SHA512:
6
- metadata.gz: 3da3fdace73c7260722287173e69c5c21efa9318503f02a6e56948a301e5bedb2747492003e262f6569d314ec63f4de6d07b65ac92a287c6a8aeae37c924afb4
7
- data.tar.gz: 7d360097fbc3f400e21d7147c1f60d6735c6a5939073b8e7bbb721cd6aee12ce142a2c8b5c2d904120768d2746aeae859c8d0e08963b29d8149cd66a8dc461bc
6
+ metadata.gz: 26335f7c93bc27b3e6625acdf1f2d492e4b0d396c8164c30d5d56c96164e938a7a5421f0b6a4b8686c510b35fc8cbd81809f34e572498ea622e4ae65108ebb9e
7
+ data.tar.gz: 5a648ac926b7b50326f087a561b6de9266eef13d7576b32c0593d5f86695d0b7b9e258ae9aa1e52385eb732cc0c140f12b9a7ec2047d41c4ac0b4906a5d05659
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
 
@@ -155,6 +161,9 @@ NODE_ENV=production SK_SIMULATE_PRODUCTION=1 bundle exec rake assets:precompile
155
161
  NODE_ENV=production SK_SIMULATE_PRODUCTION=1 dev run
156
162
  ```
157
163
 
164
+ If your application includes a node server (eg. uses `quilt_rails`), you can run the node server in a separate terminal window with:
165
+ `bin/rails sewing_kit:server:start`
166
+
158
167
  Note:
159
168
 
160
169
  - Code changes will not be automatically recompiled in this state
@@ -176,3 +185,15 @@ SewingKit.configure do |config|
176
185
  config.log_level = :warn # may be `:inherit`, `:debug`, `:info`, `:warn`, or `:error`
177
186
  end
178
187
  ```
188
+
189
+ ### How do I run sewing-kit in debug mode?
190
+
191
+ You can launch sewing-kit in debug mode by setting the `SK_DEBUG` environment flag.
192
+
193
+ ```bash
194
+ $ SK_DEBUG=1 dev run
195
+ ```
196
+
197
+ 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.
198
+
199
+ 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,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SewingKit
4
+ class InstallGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+ class_option :skip_yarn, type: :boolean, default: false
7
+
8
+ desc "This generator creates a sewing-kit config file."
9
+
10
+ def initialize(args, *options)
11
+ @application_name = Rails.application.class.module_parent.to_s.underscore
12
+ super(args, *options)
13
+ end
14
+
15
+ def create_package_json
16
+ package_json_path = "package.json"
17
+
18
+ copy_file(package_json_path)
19
+ gsub_file(package_json_path, "\${application_name}", @application_name)
20
+ end
21
+
22
+ def install_js_dependencies
23
+ return if options.skip_yarn?
24
+
25
+ say "Installing react and types dependencies"
26
+ system("yarn add @shopify/sewing-kit")
27
+ end
28
+
29
+ def create_sk_config
30
+ sk_config_path = "config/sewing-kit.config.ts"
31
+
32
+ copy_file("sewing-kit.config.ts", sk_config_path)
33
+ gsub_file(sk_config_path, "\${application_name}", @application_name)
34
+ end
35
+
36
+ def create_config_files
37
+ copy_file("editorconfig", ".editorconfig")
38
+ copy_file("eslintignore", ".eslintignore")
39
+ copy_file("prettierignore", ".prettierignore")
40
+ end
41
+ end
42
+ 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,4 @@
1
+ node_modules
2
+ build
3
+ **/schema.graphql
4
+ **/*.graphql.d.ts
@@ -0,0 +1,32 @@
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
+ "plugin:@shopify/graphql"
21
+ ]
22
+ },
23
+ "prettier": "@shopify/prettier-config",
24
+ "stylelint": {
25
+ "extends": [
26
+ "@shopify/stylelint-plugin/prettier"
27
+ ]
28
+ },
29
+ "resolutions": {
30
+ "babel-plugin-dynamic-import-node": "2.3.0"
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ package.json
2
+ .runix
3
+ .sewing-kit
4
+ .dev
5
+ node_modules
6
+ tmp
7
+ public
8
+ *.svg
9
+ *.graphql.d.ts
10
+ build
@@ -0,0 +1,11 @@
1
+ /* eslint-env node */
2
+
3
+ import {Plugins, Env} from '@shopify/sewing-kit';
4
+
5
+ export default function sewingKitConfig(plugins: Plugins, env: Env) {
6
+ return {
7
+ name: '${application_name}',
8
+ // remove cdn plugin when using dev
9
+ plugins: [plugins.cdn(env.isDevelopment ? 'http://localhost:8080/webpack/assets/' : undefined)],
10
+ };
11
+ }
@@ -1,18 +1,11 @@
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'
8
+ require 'sewing_kit/webpack/server'
16
9
 
17
10
  module SewingKit
18
11
  class Railtie < ::Rails::Railtie
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SewingKit
3
- VERSION = "0.122.1"
3
+ VERSION = "0.127.0"
4
4
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SewingKit
4
+ module Webpack
5
+ class Server
6
+ class DefaultEntrypointMissing < StandardError
7
+ def initialize
8
+ super(
9
+ "Default entrypoint build/server/main.js is missing."
10
+ )
11
+ end
12
+ end
13
+
14
+ def start
15
+ raise DefaultEntrypointMissing unless File.exist?(default_entrypoint)
16
+
17
+ result = Kernel.system(
18
+ {},
19
+ *command,
20
+ chdir: Rails.root.to_s,
21
+ out: $stdout,
22
+ err: $stderr
23
+ )
24
+
25
+ unless result
26
+ puts "sewing_kit:server:start failed"
27
+ exit(1)
28
+ end
29
+
30
+ result
31
+ end
32
+
33
+ private
34
+
35
+ def command
36
+ command_list = [
37
+ 'node',
38
+ default_entrypoint,
39
+ ].compact
40
+
41
+ command_list.join(' ')
42
+ end
43
+
44
+ def default_entrypoint
45
+ 'build/server/main.js'
46
+ end
47
+ end
48
+ end
49
+ end
@@ -12,10 +12,20 @@ namespace :sewing_kit do
12
12
  compiler = SewingKit::Webpack::Compiler.new
13
13
  compiler.compile
14
14
  end
15
+
16
+ namespace :server do
17
+ desc "Starts the production server"
18
+ task start: :environment do
19
+ server = SewingKit::Webpack::Server.new
20
+ server.start
21
+ end
22
+ end
15
23
  end
16
24
 
17
- if Rake::Task.task_defined?('assets:precompile')
18
- Rake::Task['assets:precompile'].enhance do
25
+ if Rake::Task.task_defined?("assets:precompile")
26
+ Rake::Task["assets:precompile"].enhance do
19
27
  Rake::Task['sewing_kit:build'].invoke
20
28
  end
29
+ else
30
+ Rake::Task.define_task("assets:precompile" => %w(sewing_kit:build))
21
31
  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.122.1
4
+ version: 0.127.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: 2020-04-17 00:00:00.000000000 Z
11
+ date: 2020-07-15 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
@@ -116,6 +123,7 @@ files:
116
123
  - lib/sewing_kit/webpack/manifest/development.rb
117
124
  - lib/sewing_kit/webpack/manifest/production.rb
118
125
  - lib/sewing_kit/webpack/manifest/test_with_no_assets.rb
126
+ - lib/sewing_kit/webpack/server.rb
119
127
  - lib/sewing_kit/webpack/webpack.rb
120
128
  - lib/tasks/sewing_kit.rake
121
129
  homepage: https://github.com/Shopify/sewing-kit/tree/master/gems/sewing_kit