sewing_kit 0.122.0 → 0.126.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 +22 -1
- data/lib/generators/sewing_kit/USAGE +5 -0
- data/lib/generators/sewing_kit/install_generator.rb +39 -0
- data/lib/generators/sewing_kit/templates/editorconfig +15 -0
- data/lib/generators/sewing_kit/templates/eslintignore +4 -0
- data/lib/generators/sewing_kit/templates/package.json +32 -0
- data/lib/generators/sewing_kit/templates/prettierignore +10 -0
- data/lib/generators/sewing_kit/templates/sewing-kit.config.ts +11 -0
- data/lib/sewing_kit/railtie.rb +2 -9
- data/lib/sewing_kit/version.rb +1 -1
- data/lib/sewing_kit/webpack/server.rb +49 -0
- data/lib/sewing_kit/webpack/webpack.rb +4 -4
- data/lib/tasks/sewing_kit.rake +12 -2
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f7676a191cae2f1a88ca7e9ad7da940446cbd5ec766198676848c39b8ffe78f
|
4
|
+
data.tar.gz: cf8d8fdbe0214201f91657f8a820659e1f90483d682060d929fbc34278bcb878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e4ced8405cd2af14a1cfa7748ac6725310d04df823097c90a415ac243aabe0cbb956474defbfc2ad4cf8a0e581d2f53f5410b40960470c80f3dbef97d68cd70
|
7
|
+
data.tar.gz: 1aac700c5d8b31e8310cdfefe541f44b4c193af3a8ad2e6fd474479d0d7873a45818b99321619ce57c0b4d1c6bc59ebd025ad1a41c832663343a0b6a724c3771
|
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
|
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,39 @@
|
|
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 install_js_dependencies
|
22
|
+
say "Installing react and types dependencies"
|
23
|
+
system("yarn add @shopify/sewing-kit") unless Rails.env.test?
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_sk_config
|
27
|
+
sk_config_path = "config/sewing-kit.config.ts"
|
28
|
+
|
29
|
+
copy_file("sewing-kit.config.ts", sk_config_path)
|
30
|
+
gsub_file(sk_config_path, "\${application_name}", @application_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_config_files
|
34
|
+
copy_file("editorconfig", ".editorconfig")
|
35
|
+
copy_file("eslintignore", ".eslintignore")
|
36
|
+
copy_file("prettierignore", ".prettierignore")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
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,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,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
|
+
}
|
data/lib/sewing_kit/railtie.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'rails'
|
3
3
|
require 'rails/railtie'
|
4
|
-
|
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
|
data/lib/sewing_kit/version.rb
CHANGED
@@ -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
|
@@ -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
|
data/lib/tasks/sewing_kit.rake
CHANGED
@@ -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?(
|
18
|
-
Rake::Task[
|
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.
|
4
|
+
version: 0.126.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-
|
11
|
+
date: 2020-07-02 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
|