shopify-cli 1.3.1 → 1.4.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: b46dd31f52ee5649fcf42ca444e124fb2bf91e65c8cf2450a3e0a296da669e13
4
- data.tar.gz: 1712d16f7849ec0fa33c898fb425e5543dc792549bf1925311b5cb52b6dbc7d2
3
+ metadata.gz: 5832060f2695566da5c38ce98ccd1c67d522e8bb8306a5b2a16d95f92b3e56f1
4
+ data.tar.gz: e223c587130318b500d5cd12b494c50aef424957aef5da797dafea4b233e9933
5
5
  SHA512:
6
- metadata.gz: 20fa92e7de4e785804a620c612ca40317c341d69ef636e0d611d9dda081decb57bca95ca478cef2ed4f151fb7613fe749000f1f4d85c17d211c4367cfbd8f676
7
- data.tar.gz: af418cf9c0d05c82e4f29776111286760865d54e7b99774a8d63d70537de69073152a8a643c33965870d85e3209af1f21e27daea6f77826ff096bfbc2aa50ceb
6
+ metadata.gz: b85a1e420f5d8b80a46f93ca4d16ebc1198fd31899bc7fbb8c9e0fbfa485c5f38fe9eca820782b0c4743b53e10266ce73bb0010fa90cd5b08fff199bb6a99585
7
+ data.tar.gz: 0dfd783ede5fcad7b04d648ec0f4d7084bea778d1fe7c73c0d2a86e683181cce73e8706a53462b7e285c04095dcebcc0c7cc489587f35ceb34716be4ec71efa2
data/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
- .rubocop-*
2
1
  .tmp/*
3
2
  .bundle/*
4
3
  .DS_Store
@@ -1,5 +1,8 @@
1
- inherit_from:
2
- - https://shopify.github.io/ruby-style-guide/rubocop-cli.yml
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ inherit_gem:
4
+ rubocop-shopify:
5
+ - rubocop-cli.yml
3
6
 
4
7
  AllCops:
5
8
  Exclude:
@@ -45,3 +48,4 @@ Style/MethodCallWithArgsParentheses:
45
48
  - assert_equal
46
49
  - assert
47
50
  - refute
51
+ - assert_requested # from Webmock
@@ -0,0 +1,20 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-10-17 00:53:36 UTC using RuboCop version 0.93.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 66
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: IgnoreMacros, IgnoredMethods, IgnoredPatterns, IncludedMacros, AllowParenthesesInMultilineCall, AllowParenthesesInChaining, AllowParenthesesInCamelCaseMethod, EnforcedStyle.
12
+ # SupportedStyles: require_parentheses, omit_parentheses
13
+ Style/MethodCallWithArgsParentheses:
14
+ Enabled: false
15
+
16
+ # Offense count: 1
17
+ # Cop supports --auto-correct.
18
+ Style/RedundantBegin:
19
+ Exclude:
20
+ - 'test/test_helper.rb'
@@ -1,3 +1,11 @@
1
+ Unreleased
2
+ ------
3
+
4
+ Version 1.4.0
5
+ ------
6
+ * Updates to tests, dependencies and internal tooling
7
+ * #924: Improve debugging messages on Partner API errors
8
+
1
9
  Version 1.3.1
2
10
  ------
3
11
  * Allow any characters in ngrok account names
data/Gemfile CHANGED
@@ -8,11 +8,10 @@ group :development, :test do
8
8
  gem 'rake'
9
9
  gem 'pry-byebug'
10
10
  gem 'byebug'
11
- gem 'rubocop'
11
+ gem 'rubocop-shopify', require: false
12
12
  end
13
13
 
14
14
  group :test do
15
- gem 'session'
16
15
  gem 'mocha', require: false
17
16
  gem 'minitest', '>= 5.0.0', require: false
18
17
  gem 'minitest-reporters', require: false
@@ -23,7 +23,7 @@ GEM
23
23
  mocha (1.7.0)
24
24
  metaclass (~> 0.0.1)
25
25
  parallel (1.19.2)
26
- parser (2.7.1.4)
26
+ parser (2.7.2.0)
27
27
  ast (~> 2.4.1)
28
28
  pry (0.12.2)
29
29
  coderay (~> 1.1.0)
@@ -34,22 +34,23 @@ GEM
34
34
  public_suffix (3.0.3)
35
35
  rainbow (3.0.0)
36
36
  rake (13.0.1)
37
- regexp_parser (1.7.1)
37
+ regexp_parser (1.8.2)
38
38
  rexml (3.2.4)
39
- rubocop (0.89.1)
39
+ rubocop (0.93.1)
40
40
  parallel (~> 1.10)
41
- parser (>= 2.7.1.1)
41
+ parser (>= 2.7.1.5)
42
42
  rainbow (>= 2.2.2, < 4.0)
43
- regexp_parser (>= 1.7)
43
+ regexp_parser (>= 1.8)
44
44
  rexml
45
- rubocop-ast (>= 0.3.0, < 1.0)
45
+ rubocop-ast (>= 0.6.0)
46
46
  ruby-progressbar (~> 1.7)
47
47
  unicode-display_width (>= 1.4.0, < 2.0)
48
- rubocop-ast (0.3.0)
49
- parser (>= 2.7.1.4)
48
+ rubocop-ast (0.8.0)
49
+ parser (>= 2.7.1.5)
50
+ rubocop-shopify (1.0.6)
51
+ rubocop (>= 0.92, < 0.94)
50
52
  ruby-progressbar (1.10.1)
51
53
  safe_yaml (1.0.4)
52
- session (3.2.0)
53
54
  timecop (0.9.1)
54
55
  unicode-display_width (1.7.0)
55
56
  webmock (2.3.2)
@@ -68,8 +69,7 @@ DEPENDENCIES
68
69
  mocha
69
70
  pry-byebug
70
71
  rake
71
- rubocop
72
- session
72
+ rubocop-shopify
73
73
  timecop
74
74
  webmock
75
75
 
@@ -2,42 +2,54 @@
2
2
 
3
3
  1. Check the Semantic Versioning page for info on how to version the new release: http://semver.org
4
4
 
5
- 2. Create a branch named `release_X_Y_Z` (replacing `X_Y_Z` with the intended release version)
5
+ 1. Make sure you're on the most recent `master`
6
+ ```
7
+ $ git checkout master
8
+ $ git pull
9
+ ```
10
+
11
+ 1. Create a branch named `release_X_Y_Z` (replacing `X_Y_Z` with the intended release version)
6
12
  ```
7
13
  $ git checkout -b release_X_Y_Z
8
14
  ```
9
15
 
10
- 3. Update the version of Shopify CLI in `lib/shopify-cli/version.rb`
16
+ 1. Update the version of Shopify CLI in `lib/shopify-cli/version.rb`
11
17
 
12
- 4. Add an entry for the new release to `CHANGELOG.md`
18
+ 1. Add an entry for the new release to `CHANGELOG.md`
13
19
 
14
- 5. Commit the changes with a commit message like "Packaging for release X.Y.Z"
20
+ 1. Commit the changes with a commit message like "Packaging for release X.Y.Z"
15
21
  ```
16
22
  $ git commit -am "Packaging for release vX.Y.Z"
17
23
  ```
18
24
 
19
- 6. Push out the changes
25
+ 1. Push out the changes
20
26
  ```
21
27
  $ git push -u origin release_X_Y_Z
22
28
  ```
23
29
 
24
- 7. Open a PR for the branch, get necessary approvals from code owners and merge into main branch. Note that the PR title will be the release note in Shipit, so make sure it mentions the release
30
+ 1. Open a PR for the branch, get necessary approvals from code owners and merge into main branch. Note that the PR title will be the release note in Shipit, so make sure it mentions the release
25
31
 
26
- 8. Deploy using Shipit
32
+ 1. Deploy using Shipit
33
+
34
+ 1. Update your `master` branch to the latest version
35
+ ```
36
+ $ git checkout master
37
+ $ git pull
38
+ ```
27
39
 
28
- 9. On local machine and _AFTER_ gem has been published to https://rubygems.org, run
40
+ 1. On local machine and _AFTER_ gem has been published to https://rubygems.org, run
29
41
  ```
30
42
  $ rake package
31
43
  ```
32
44
  This will generate the `.deb`, `.rpm` and brew formula files, which will be located in `packaging/builds/X.Y.Z/`.
33
45
 
34
- 10. Clone the `Shopify/homebrew-shopify` repository (if not already cloned), and then
46
+ 1. Clone the `Shopify/homebrew-shopify` repository (if not already cloned), and then
35
47
  * create a branch named `release_X_Y_Z_of_shopify-cli`
36
48
  * update the brew formula in `shopify-cli.rb` with the generated formula in `packaging/builds/X.Y.Z/` in the `Shopify/shopify-app-cli` repo (from step 9)
37
49
  * commit the change and create a PR on the [Shopify Homebrew repository](https://github.com/Shopify/homebrew-shopify)
38
50
  * when PR is approved, merge into main branch
39
51
 
40
- 11. Go to [releases](https://github.com/Shopify/shopify-app-cli/releases) page of `Shopify/shopify-app-cli` repo and create a new release:
52
+ 1. Go to [releases](https://github.com/Shopify/shopify-app-cli/releases) page of `Shopify/shopify-app-cli` repo and create a new release:
41
53
  * use the tag created in step 8 by Shipit (should be "vX.Y.Z")
42
54
  * release title = "Version X.Y.Z"
43
55
  * description should be
@@ -40,7 +40,7 @@ module Node
40
40
  scopes: 'write_products,write_customers,write_draft_orders',
41
41
  ).write(@ctx)
42
42
 
43
- partners_url = "https://partners.shopify.com/#{form.organization_id}/apps/#{api_client['id']}"
43
+ partners_url = "#{partners_endpoint}/#{form.organization_id}/apps/#{api_client['id']}"
44
44
 
45
45
  @ctx.puts(@ctx.message('node.create.info.created', form.title, partners_url))
46
46
  @ctx.puts(@ctx.message('node.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
@@ -112,6 +112,11 @@ module Node
112
112
  @ctx.debug(e)
113
113
  end
114
114
  end
115
+
116
+ def partners_endpoint
117
+ return 'https://partners.myshopify.io' if @ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
118
+ 'https://partners.shopify.com'
119
+ end
115
120
  end
116
121
  end
117
122
  end
@@ -55,7 +55,7 @@ module Rails
55
55
  scopes: 'write_products,write_customers,write_draft_orders',
56
56
  ).write(@ctx)
57
57
 
58
- partners_url = "https://partners.shopify.com/#{form.organization_id}/apps/#{api_client['id']}"
58
+ partners_url = "#{partners_endpoint}/#{form.organization_id}/apps/#{api_client['id']}"
59
59
 
60
60
  @ctx.puts(@ctx.message('rails.create.info.created', form.title, partners_url))
61
61
  @ctx.puts(@ctx.message('rails.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
@@ -172,6 +172,11 @@ module Rails
172
172
  def install_gem(name, version = nil)
173
173
  Gem.install(@ctx, name, version)
174
174
  end
175
+
176
+ def partners_endpoint
177
+ return 'https://partners.myshopify.io' if @ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
178
+ 'https://partners.shopify.com'
179
+ end
175
180
  end
176
181
  end
177
182
  end
@@ -1,24 +1,24 @@
1
1
  discount:
2
2
  assemblyscript:
3
3
  package: "@shopify/extension-point-as-discount"
4
- version: "^0.2.10"
5
- sdk-version: "^6.0.0"
4
+ version: "^0.3.0"
5
+ sdk-version: "^7.0.0"
6
6
  toolchain-version: "^1.1.0"
7
7
  unit_limit_per_order:
8
8
  assemblyscript:
9
9
  package: "@shopify/extension-point-as-unit-limit-per-order"
10
- version: "^0.1.12"
11
- sdk-version: "^6.0.0"
10
+ version: "^0.2.0"
11
+ sdk-version: "^7.0.0"
12
12
  toolchain-version: "^1.1.0"
13
13
  payment_filter:
14
14
  assemblyscript:
15
15
  package: "@shopify/extension-point-as-payment-filter"
16
- version: "^0.2.8"
17
- sdk-version: "^6.0.0"
16
+ version: "^0.5.0"
17
+ sdk-version: "^7.0.0"
18
18
  toolchain-version: "^1.1.0"
19
19
  shipping_filter:
20
20
  assemblyscript:
21
21
  package: "@shopify/extension-point-as-shipping-filter"
22
- version: "^0.2.10"
23
- sdk-version: "^6.0.0"
22
+ version: "^0.3.0"
23
+ sdk-version: "^7.0.0"
24
24
  toolchain-version: "^1.1.0"
@@ -86,8 +86,8 @@ module Script
86
86
  "@shopify/scripts-toolchain-as": "#{extension_point.sdks[:ts].toolchain_version}",
87
87
  "#{extension_point.sdks[:ts].package}": "#{extension_point.sdks[:ts].version}",
88
88
  "@as-pect/cli": "4.0.0",
89
- "as-wasi": "^0.2.0",
90
- "assemblyscript": "^0.12.0"
89
+ "as-wasi": "^0.2.1",
90
+ "assemblyscript": "^0.14.0"
91
91
  },
92
92
  "scripts": {
93
93
  "test": "asp --config test/as-pect.config.js --summary --verbose"
@@ -1,5 +1,4 @@
1
1
  require 'shopify_cli'
2
- require 'net/http'
3
2
 
4
3
  module ShopifyCli
5
4
  class API
@@ -32,8 +31,9 @@ module ShopifyCli
32
31
  )
33
32
  ctx.debug(resp)
34
33
  resp
35
- rescue API::APIRequestServerError, API::APIRequestUnexpectedError
34
+ rescue API::APIRequestServerError, API::APIRequestUnexpectedError => e
36
35
  ctx.puts(ctx.message('core.api.error.internal_server_error'))
36
+ ctx.debug(ctx.message('core.api.error.internal_server_error_debug', e.message))
37
37
  end
38
38
 
39
39
  protected
@@ -58,14 +58,10 @@ module ShopifyCli
58
58
  unless uri.is_a?(URI::HTTP)
59
59
  ctx.abort("Invalid URL: #{graphql_url}")
60
60
  end
61
- http = ::Net::HTTP.new(uri.host, uri.port)
62
- http.use_ssl = true
63
61
 
64
- req = ::Net::HTTP::Post.new(uri.request_uri)
65
- req.body = JSON.dump(query: body.tr("\n", ""), variables: variables)
66
- req['Content-Type'] = 'application/json'
67
- headers.each { |header, value| req[header] = value }
68
- response = http.request(req)
62
+ # we delay this require so as to avoid a performance hit on starting the CLI
63
+ require 'shopify-cli/http_request'
64
+ response = HttpRequest.call(uri, body, variables, headers)
69
65
 
70
66
  case response.code.to_i
71
67
  when 200..399
@@ -23,6 +23,7 @@ module ShopifyCli
23
23
  display_cli_ruby(show_all_details)
24
24
  display_utility_commands(show_all_details)
25
25
  display_project_commands(show_all_details)
26
+ display_shopify_staff_identity if show_all_details
26
27
  end
27
28
 
28
29
  def self.help
@@ -139,6 +140,14 @@ module ShopifyCli
139
140
  end
140
141
  @ctx.puts("")
141
142
  end
143
+
144
+ def display_shopify_staff_identity
145
+ is_shopifolk = ShopifyCli::Shopifolk.check
146
+ if is_shopifolk
147
+ @ctx.puts("\n" + @ctx.message('core.system.identity_header'))
148
+ @ctx.puts(" " + @ctx.message('core.system.identity_is_shopifolk'))
149
+ end
150
+ end
142
151
  end
143
152
  end
144
153
  end
@@ -28,7 +28,7 @@ module ShopifyCli
28
28
  ctx.puts(
29
29
  ctx.message('core.warning.development_version', File.join(ShopifyCli::ROOT, 'bin', ShopifyCli::TOOL_NAME))
30
30
  )
31
- else
31
+ elsif !ctx.testing?
32
32
  new_version = ctx.new_version
33
33
  ctx.puts(ctx.message('core.warning.new_version', ShopifyCli::VERSION, new_version)) unless new_version.nil?
34
34
  end
@@ -0,0 +1,15 @@
1
+ require 'net/http'
2
+
3
+ module ShopifyCli
4
+ class HttpRequest
5
+ def self.call(uri, body, variables, headers)
6
+ http = ::Net::HTTP.new(uri.host, uri.port)
7
+ http.use_ssl = true
8
+ req = ::Net::HTTP::Post.new(uri.request_uri)
9
+ req.body = JSON.dump(query: body.tr("\n", ""), variables: variables)
10
+ req['Content-Type'] = 'application/json'
11
+ headers.each { |header, value| req[header] = value }
12
+ http.request(req)
13
+ end
14
+ end
15
+ end
@@ -177,6 +177,7 @@ module ShopifyCli
177
177
  api: {
178
178
  error: {
179
179
  internal_server_error: '{{red:{{x}} An unexpected error occurred on Shopify.}}',
180
+ internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
180
181
  },
181
182
  },
182
183
 
@@ -251,6 +252,8 @@ module ShopifyCli
251
252
  },
252
253
  environment_header: "{{bold:Environment}}",
253
254
  env: "%-17s = %s",
255
+ identity_header: "{{bold:Identity}}",
256
+ identity_is_shopifolk: "{{v}} Checked user settings: you’re Shopify staff!",
254
257
  },
255
258
 
256
259
  tasks: {
@@ -0,0 +1,67 @@
1
+ module ShopifyCli
2
+ ##
3
+ # ShopifyCli::Shopifolk contains the logic to determine if the user appears to be a Shopify staff
4
+ #
5
+ # The Shopifolk Feature flag will persist between runs so if the flag is enabled or disabled,
6
+ # it will still be in that same state until the next class invocation.
7
+ class Shopifolk
8
+ GCLOUD_CONFIG_FILE = File.expand_path('~/.config/gcloud/configurations/config_default')
9
+ DEV_PATH = '/opt/dev'
10
+ SECTION = 'core'
11
+ FEATURE_NAME = 'shopifolk'
12
+
13
+ ##
14
+ # will return if the user appears to be a Shopify employee, based on several heuristics
15
+ #
16
+ # #### Returns
17
+ #
18
+ # * `is_shopifolk` - returns true if the user is a Shopify Employee
19
+ #
20
+ # #### Example
21
+ #
22
+ # ShopifyCli::Shopifolk.check
23
+ #
24
+ def self.check
25
+ ShopifyCli::Shopifolk.new.shopifolk?
26
+ end
27
+
28
+ ##
29
+ # will return if the user is a Shopify employee
30
+ #
31
+ # #### Returns
32
+ #
33
+ # * `is_shopifolk` - returns true if the user has `dev` installed and
34
+ # a valid google cloud config file with email ending in "@shopify.com"
35
+ #
36
+ def shopifolk?
37
+ return true if Feature.enabled?(FEATURE_NAME)
38
+ if shopifolk_by_gcloud? && shopifolk_by_dev?
39
+ ShopifyCli::Feature.enable(FEATURE_NAME)
40
+ true
41
+ else
42
+ ShopifyCli::Feature.disable(FEATURE_NAME)
43
+ false
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def shopifolk_by_gcloud?
50
+ ini&.dig("[#{SECTION}]", 'account')&.match?(/@shopify.com\z/)
51
+ end
52
+
53
+ def shopifolk_by_dev?
54
+ File.exist?("#{DEV_PATH}/bin/dev") && File.exist?("#{DEV_PATH}/.shopify-build")
55
+ end
56
+
57
+ def ini
58
+ @ini ||= begin
59
+ if File.exist?(GCLOUD_CONFIG_FILE)
60
+ CLI::Kit::Ini
61
+ .new(GCLOUD_CONFIG_FILE, default_section: "[#{SECTION}]", convert_types: false)
62
+ .tap(&:parse).ini
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module ShopifyCli
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -116,6 +116,7 @@ module ShopifyCli
116
116
  autoload :Project, 'shopify-cli/project'
117
117
  autoload :ProjectType, 'shopify-cli/project_type'
118
118
  autoload :Resources, 'shopify-cli/resources'
119
+ autoload :Shopifolk, 'shopify-cli/shopifolk'
119
120
  autoload :SubCommand, 'shopify-cli/sub_command'
120
121
  autoload :Task, 'shopify-cli/task'
121
122
  autoload :Tasks, 'shopify-cli/tasks'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-08 00:00:00.000000000 Z
11
+ date: 2020-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ files:
79
79
  - ".github/probots.yml"
80
80
  - ".gitignore"
81
81
  - ".rubocop.yml"
82
+ - ".rubocop_todo.yml"
82
83
  - ".ruby-version"
83
84
  - ".tmp/.gitkeep"
84
85
  - ".tmp/sv/.gitkeep"
@@ -278,6 +279,7 @@ files:
278
279
  - lib/shopify-cli/helpers.rb
279
280
  - lib/shopify-cli/helpers/haikunator.rb
280
281
  - lib/shopify-cli/heroku.rb
282
+ - lib/shopify-cli/http_request.rb
281
283
  - lib/shopify-cli/js_deps.rb
282
284
  - lib/shopify-cli/js_system.rb
283
285
  - lib/shopify-cli/messages/messages.rb
@@ -292,6 +294,7 @@ files:
292
294
  - lib/shopify-cli/project_type.rb
293
295
  - lib/shopify-cli/resources.rb
294
296
  - lib/shopify-cli/resources/env_file.rb
297
+ - lib/shopify-cli/shopifolk.rb
295
298
  - lib/shopify-cli/sub_command.rb
296
299
  - lib/shopify-cli/task.rb
297
300
  - lib/shopify-cli/tasks.rb