sewing_kit 0.127.0 → 0.128.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: cf1b908d92ccc28fb41b4e5a2161631455adee178681ee79146a23e76fbf17dc
4
- data.tar.gz: '08f476ab5358c90db8f509f9265c281eafc0816af96a0fe70b2c189a3324fd6c'
3
+ metadata.gz: a461122bbd1f59afece53f1695188abeb57f7a70bf397c9871a1389a5c3dace0
4
+ data.tar.gz: 606ece89a71cf2748dd13bf2a1884e428d41365cbdabb9fe98dbbe2c7184e143
5
5
  SHA512:
6
- metadata.gz: 26335f7c93bc27b3e6625acdf1f2d492e4b0d396c8164c30d5d56c96164e938a7a5421f0b6a4b8686c510b35fc8cbd81809f34e572498ea622e4ae65108ebb9e
7
- data.tar.gz: 5a648ac926b7b50326f087a561b6de9266eef13d7576b32c0593d5f86695d0b7b9e258ae9aa1e52385eb732cc0c140f12b9a7ec2047d41c4ac0b4906a5d05659
6
+ metadata.gz: 9725a50c0872da10cb36d7882d446d9606177af40055bd309c7874f78de953768c201aacaf02853ce9b83f8ed6c80462e3df81552a225d5c1727e66a64e2df5a
7
+ data.tar.gz: 14f2b69ef3a1afc0b2cc99275933dd219767dcf9784026fd79d01d3b33c52f2a6adc36fcc2d3b88fc97dad481293f34cc9959e0400c59cf3ee71590721f468a4
@@ -3,40 +3,59 @@
3
3
  module SewingKit
4
4
  class InstallGenerator < Rails::Generators::Base
5
5
  source_root File.expand_path('templates', __dir__)
6
+
7
+ desc "Adds the configuration files for a sewing-kit powered front-end."
8
+
6
9
  class_option :skip_yarn, type: :boolean, default: false
10
+ class_option :javascript_path, type: :string, default: 'app/ui'
7
11
 
8
- desc "This generator creates a sewing-kit config file."
12
+ # We don't specify a default here because we want to fallback dynamically
13
+ class_option :uses_dev, type: :boolean
9
14
 
10
- def initialize(args, *options)
11
- @application_name = Rails.application.class.module_parent.to_s.underscore
12
- super(args, *options)
13
- end
15
+ def initialize(args, *opts)
16
+ super(args, *opts)
14
17
 
15
- def create_package_json
16
- package_json_path = "package.json"
18
+ @application_name = Project.app_name
19
+ @javascript_path = options[:javascript_path]
17
20
 
18
- copy_file(package_json_path)
19
- gsub_file(package_json_path, "\${application_name}", @application_name)
21
+ if Project.uses_webpacker?
22
+ warn "
23
+ WARNING: We've detected you currently have webpacker config at config/webpacker.yml.
24
+ You may experience conflicts between sewing-kit and webpacker's behaviour as build tools.
25
+ If your app was made with `rails new`, try rerunning it with `--skip-webpack-install --skip-javascript`
26
+ "
27
+ end
28
+ end
29
+
30
+ def create_config_files
31
+ say "Creating JS tooling config files"
32
+ copy_file("editorconfig", ".editorconfig")
33
+ copy_file("eslintignore", ".eslintignore")
34
+ copy_file("prettierignore", ".prettierignore")
35
+ template("package.json.erb", "package.json")
36
+ template("tsconfig.json.erb", "tsconfig.json")
37
+ template("sewing-kit.config.ts.erb", "config/sewing-kit.config.ts")
20
38
  end
21
39
 
22
40
  def install_js_dependencies
23
41
  return if options.skip_yarn?
24
-
25
- say "Installing react and types dependencies"
42
+ say "Installing javascript dependencies"
26
43
  system("yarn add @shopify/sewing-kit")
44
+ system("yarn add typescript")
27
45
  end
28
46
 
29
- def create_sk_config
30
- sk_config_path = "config/sewing-kit.config.ts"
47
+ class Project
48
+ def self.app_name
49
+ Rails.application.class.module_parent.to_s.underscore
50
+ end
31
51
 
32
- copy_file("sewing-kit.config.ts", sk_config_path)
33
- gsub_file(sk_config_path, "\${application_name}", @application_name)
34
- end
52
+ def self.uses_dev?
53
+ File.exist?('dev.yml')
54
+ end
35
55
 
36
- def create_config_files
37
- copy_file("editorconfig", ".editorconfig")
38
- copy_file("eslintignore", ".eslintignore")
39
- copy_file("prettierignore", ".prettierignore")
56
+ def self.uses_webpacker?
57
+ File.exist?('config/webpacker.yml')
58
+ end
40
59
  end
41
60
  end
42
61
  end
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "${application_name}",
2
+ "name": "<%= @application_name %>",
3
3
  "private": true,
4
4
  "sideEffects": false,
5
5
  "scripts": {
@@ -0,0 +1,47 @@
1
+ /* eslint-env node */
2
+ import {resolve} from 'path';
3
+
4
+ import {Plugins, Env} from '@shopify/sewing-kit';
5
+
6
+ const ROOT_PATH = resolve(__dirname, '..');
7
+
8
+ export default function sewingKitConfig(plugins: Plugins, env: Env) {
9
+ return {
10
+ name: '<%= @application_name %>',
11
+ plugins: [
12
+ plugins.paths({
13
+ // Determines where the root directory for front-end code is
14
+ app: resolve(ROOT_PATH, '<%= @javascript_path %>'),
15
+ // Determines where test setup should go for front-end code
16
+ tests: resolve(ROOT_PATH, '<%= @javascript_path %>', 'tests'),
17
+ }),
18
+
19
+ <% unless @uses_dev %>
20
+ // Sets up the app to get its assets from the default webpack endpoint in development.
21
+ // You will need to change this to use your actual production cdn to get it working in production.
22
+ // NOTE: If you are using dev and shopify-cloud gem you can delete this.
23
+ plugins.cdn(
24
+ env.isDevelopment ? 'http://localhost:8080/webpack/assets/' : undefined,
25
+ ),
26
+ <% end %>
27
+ // Sets up sewing-kit to generate type definitions for GraphQL using the given schema(s)
28
+ // Uncomment the following if you are using GraphQL and make sure the path points to your generated schema
29
+ // plugins.graphql({
30
+ // schema: resolve(__dirname, '..', 'app', 'graphql', 'schema.graphql'),
31
+ // }),
32
+
33
+ // Sets up sass mixins to be automatically imported.
34
+ // Uncomment if you are using Polaris and want access to the sass mixins in your custom SCSS
35
+ // plugins.sass({
36
+ // autoInclude: [
37
+ // path.join(
38
+ // __dirname,
39
+ // 'node_modules/@shopify/polaris/dist/styles/_public-api.scss',
40
+ // ),
41
+ // ],
42
+ // }),
43
+
44
+ // configure additional sewing-kit plugins here
45
+ ],
46
+ };
47
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "@shopify/typescript-configs/application.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "rootDir": ".",
6
+ "paths": {
7
+ "*": ["<%= @javascript_path %>*"]
8
+ }
9
+ },
10
+ "include": ["./config/*.ts", "./<%= @javascript_path %>**/*"]
11
+ }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SewingKit
3
- VERSION = "0.127.0"
3
+ VERSION = "0.128.0"
4
4
  end
@@ -4,7 +4,7 @@ TEMPLATE_PATH = File.expand_path("../install/template.rb", File.dirname(__FILE__
4
4
  namespace :sewing_kit do
5
5
  desc "Install all of Shopify’s modern FED tooling"
6
6
  task :install do
7
- exec "./bin/rails app:template LOCATION=#{TEMPLATE_PATH}"
7
+ exec "bundle exec rails generate sewing_kit:install"
8
8
  end
9
9
 
10
10
  desc "Build webpack asset bundles"
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.127.0
4
+ version: 0.128.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-07-15 00:00:00.000000000 Z
11
+ date: 2020-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -106,9 +106,10 @@ files:
106
106
  - lib/generators/sewing_kit/install_generator.rb
107
107
  - lib/generators/sewing_kit/templates/editorconfig
108
108
  - lib/generators/sewing_kit/templates/eslintignore
109
- - lib/generators/sewing_kit/templates/package.json
109
+ - lib/generators/sewing_kit/templates/package.json.erb
110
110
  - lib/generators/sewing_kit/templates/prettierignore
111
- - lib/generators/sewing_kit/templates/sewing-kit.config.ts
111
+ - lib/generators/sewing_kit/templates/sewing-kit.config.ts.erb
112
+ - lib/generators/sewing_kit/templates/tsconfig.json.erb
112
113
  - lib/hacks/user_agent_parser.rb
113
114
  - lib/sewing_kit.rb
114
115
  - lib/sewing_kit/configuration.rb
@@ -1,11 +0,0 @@
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
- }