shopify-cli 2.14.0 → 2.15.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: be8f00a6bb6d3e7059a63e77ff74327d9e11474cc34b156ec54da33080119e11
4
- data.tar.gz: ed986614e2b2c0b9b9ca70a175c2133a3130643f3678bbf17148556be4f39f86
3
+ metadata.gz: e5861ffd7a22ca4048791e4993469dff421162159c7dabbf06b413522297c4a8
4
+ data.tar.gz: b5593ee5d6cfbf5c9b616b050263eb825d2d7a9846f5bf71953b4d7f708ee06e
5
5
  SHA512:
6
- metadata.gz: cc1c384e33b5bc316e38ab1ab58b978ab56e811309c82746f9218fc8de2cd4d57b243414f324421baff1abdc69829d952840e2c2bd94049963858ca3700c5600
7
- data.tar.gz: d065d5a10be15c0f79c800798fb0302e9b2519b7b22fea5879ae321297e8bd0859d8b21756b40ae8abe78387e1e3e62b600d0e796a5848545b1c8e5c37af4cd2
6
+ metadata.gz: 8cf0ff62f5bf1687d5d98f4d808bf9f7d0bb921322483a5e446e34ef6638ff5a67a5ae15b3e34916a9c4fe627f4aee581f8630d4182925928eb67a762624c103
7
+ data.tar.gz: 161eba94f7e0fd3ca350a162eef9706c8f5a76da972eb4b3cbefdc2f9f3fdc8a37a72b7a48f47d81e1860dca4367eb8c2ceae6fe1bd57d4a9a61c7df3ecd0209
@@ -17,7 +17,7 @@ When contributing to the Shopify CLI, there are a set of [design guidelines](htt
17
17
 
18
18
  ### Where to find known issues
19
19
 
20
- We track all of our issues in GitHub and [bugs](https://github.com/Shopify/shopify-cli/labels/Bug) are labeled accordingly. If you are planning to work on an issue, avoid ones which already have an assignee, where someone has commented within the last two weeks they are working on it, or the issue is labeled with [fix in progress](https://github.com/Shopify/shopify-cli/labels/fix%20in%20progress). We will do our best to communicate when an issue is being worked on internally.
20
+ We track all of our issues in GitHub and [bugs](https://github.com/Shopify/shopify-cli/labels/type:bug) are labeled accordingly. If you are planning to work on an issue, avoid ones which already have an assignee, where someone has commented within the last two weeks they are working on it, or the issue is labeled with [fix in progress](https://github.com/Shopify/shopify-cli/labels/fix%20in%20progress). We will do our best to communicate when an issue is being worked on internally.
21
21
 
22
22
  ### Running against a local environment
23
23
 
@@ -0,0 +1,41 @@
1
+ # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2
+ #
3
+ # You can adjust the behavior by modifying this file.
4
+ # For more information, see:
5
+ # https://github.com/actions/stale
6
+ name: Mark stale issues and pull requests
7
+
8
+ on:
9
+ schedule:
10
+ - cron: '31 3 * * *' # randomly chosen time of day
11
+
12
+ jobs:
13
+ stale:
14
+
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ issues: write
18
+ pull-requests: write
19
+
20
+ steps:
21
+ - uses: actions/stale@v3
22
+ with:
23
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
24
+ days-before-issue-stale: 90
25
+ days-before-pr-stale: 30
26
+ days-before-close: 10
27
+ stale-issue-message: |-
28
+ This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
29
+
30
+ → If there's no activity within a week, then a bot will automatically close this.
31
+
32
+ Thanks for helping to improve Shopify's dev tooling and experience.
33
+ stale-pr-message: |-
34
+ This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
35
+
36
+ → If there's no activity within a week, then a bot will automatically close this.
37
+
38
+ Thanks for helping to improve Shopify's dev tooling and experience.
39
+ stale-issue-label: 'no-issue-activity'
40
+ stale-pr-label: 'no-pr-activity'
41
+ operations-per-run: 10 # temporary so we can ease into staling and see what happens
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## Version 2.15.0
6
+
7
+ ### Fixed
8
+ * [#2086](https://github.com/Shopify/shopify-cli/pull/2086): Improve check of dependency versions
9
+ * [#2149](https://github.com/Shopify/shopify-cli/pull/2149): Fix `ThemeAdminAPI` not to handle asset errors
10
+ * [#2122](https://github.com/Shopify/shopify-cli/pull/2122): Fix `--only`/`--ignore` flags parser to support multiple occurrences without quotes
11
+ * [#2146](https://github.com/Shopify/shopify-cli/pull/2146): Prevent duplicate locales for Checkout extension localization
12
+
5
13
  ## Version 2.14.0
6
14
 
7
15
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.14.0)
4
+ shopify-cli (2.15.0)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
7
  theme-check (~> 1.10.1)
@@ -43,6 +43,7 @@ module Extension
43
43
  # Localization is optional
44
44
  return {} if locale_filenames.empty?
45
45
 
46
+ validate_no_duplicate_locale(locale_filenames)
46
47
  validate_total_size(locale_filenames)
47
48
  default_locale = single_default_locale(locale_filenames)
48
49
 
@@ -61,6 +62,18 @@ module Extension
61
62
  end
62
63
  end
63
64
 
65
+ def validate_no_duplicate_locale(locale_filenames)
66
+ duplicate_locale = locale_filenames
67
+ .map { |filename| basename_for_locale_filename(filename.downcase) }
68
+ .group_by { |locale| locale }
69
+ .detect { |_k, v| v.size > 1 }
70
+ &.first
71
+ raise(
72
+ ShopifyCLI::Abort,
73
+ ShopifyCLI::Context.message("#{L10N_ERROR_PREFIX}.duplicate_locale_code", duplicate_locale)
74
+ ) unless duplicate_locale.nil?
75
+ end
76
+
64
77
  def validate_total_size(locale_filenames)
65
78
  total_size = locale_filenames.sum { |filename| File.size(filename) }
66
79
  if total_size > L10N_BUNDLE_SIZE_LIMIT
@@ -26,11 +26,11 @@ module Theme
26
26
  parser.on("-d", "--development") { flags[:development] = true }
27
27
  parser.on("-o", "--only=PATTERN", Conversions::IncludeGlob) do |pattern|
28
28
  flags[:includes] ||= []
29
- flags[:includes] += pattern
29
+ flags[:includes] |= pattern
30
30
  end
31
31
  parser.on("-x", "--ignore=PATTERN", Conversions::IgnoreGlob) do |pattern|
32
32
  flags[:ignores] ||= []
33
- flags[:ignores] += pattern
33
+ flags[:ignores] |= pattern
34
34
  end
35
35
  end
36
36
 
@@ -30,11 +30,11 @@ module Theme
30
30
  parser.on("-p", "--publish") { flags[:publish] = true }
31
31
  parser.on("-o", "--only=PATTERN", Conversions::IncludeGlob) do |pattern|
32
32
  flags[:includes] ||= []
33
- flags[:includes] += pattern
33
+ flags[:includes] |= pattern
34
34
  end
35
35
  parser.on("-x", "--ignore=PATTERN", Conversions::IgnoreGlob) do |pattern|
36
36
  flags[:ignores] ||= []
37
- flags[:ignores] += pattern
37
+ flags[:ignores] |= pattern
38
38
  end
39
39
  end
40
40
 
@@ -10,8 +10,22 @@ module Theme
10
10
 
11
11
  def convert(parser)
12
12
  argv = parser.default_argv
13
- option_index = argv.index { |v| options.include?(v) }
13
+ values = []
14
+
15
+ option_indexes(argv).each do |option_index|
16
+ values += option_values(argv, parser, option_index)
17
+ end
18
+
19
+ values
20
+ end
21
+
22
+ def options
23
+ raise "`#{self.class.name}#options` must be defined"
24
+ end
25
+
26
+ private
14
27
 
28
+ def option_values(argv, parser, option_index)
15
29
  return [] if option_index.nil?
16
30
 
17
31
  start_index = option_index + 1
@@ -26,12 +40,13 @@ module Theme
26
40
  values
27
41
  end
28
42
 
29
- def options
30
- raise "`#{self.class.name}#options` must be defined"
43
+ def option_indexes(argv)
44
+ argv
45
+ .each_with_index
46
+ .select { |item, _index| options.include?(item) }
47
+ .map(&:last)
31
48
  end
32
49
 
33
- private
34
-
35
50
  def options_map(parser)
36
51
  map = {}
37
52
  parser.top.list.each do |option|
@@ -102,16 +102,10 @@ module ShopifyCLI
102
102
  def check_node_version
103
103
  return unless @compatible_node_range
104
104
 
105
- context = Context.new
106
- if context.which("node").nil?
107
- raise ShopifyCLI::Abort, context.message("core.errors.missing_node")
108
- end
109
-
110
105
  check_version(
111
106
  Environment.node_version,
112
107
  range: @compatible_node_range,
113
- runtime: "Node",
114
- context: context
108
+ runtime: "Node"
115
109
  )
116
110
  end
117
111
 
@@ -12,23 +12,31 @@ module ShopifyCLI
12
12
  ]
13
13
 
14
14
  def self.ruby_version(context: Context.new)
15
- out, err, stat = context.capture3('ruby -e "puts RUBY_VERSION"')
16
- raise ShopifyCLI::Abort, err unless stat.success?
17
- out = out.gsub('"', "")
18
- ::Semantic::Version.new(out.chomp)
15
+ output, status = context.capture2e("ruby", "--version")
16
+ raise ShopifyCLI::Abort, context.message("core.errors.missing_ruby") unless status.success?
17
+ version = output.match(/ruby (\d+\.\d+\.\d+)/)[1]
18
+ ::Semantic::Version.new(version)
19
19
  end
20
20
 
21
21
  def self.node_version(context: Context.new)
22
- out, err, stat = context.capture3("node", "--version")
23
- raise ShopifyCLI::Abort, err unless stat.success?
24
- out = out.gsub("v", "")
25
- ::Semantic::Version.new(out.chomp)
22
+ output, status = context.capture2e("node", "--version")
23
+ raise ShopifyCLI::Abort, context.message("core.errors.missing_node") unless status.success?
24
+ version = output.match(/v(\d+\.\d+\.\d+)/)[1]
25
+ ::Semantic::Version.new(version)
26
26
  end
27
27
 
28
28
  def self.npm_version(context: Context.new)
29
- out, err, stat = context.capture3("npm", "--version")
30
- raise ShopifyCLI::Abort, err unless stat.success?
31
- ::Semantic::Version.new(out.chomp)
29
+ output, status = context.capture2e("npm", "--version")
30
+ raise ShopifyCLI::Abort, context.message("core.errors.missing_npm") unless status.success?
31
+ version = output.match(/(\d+\.\d+\.\d+)/)[1]
32
+ ::Semantic::Version.new(version)
33
+ end
34
+
35
+ def self.rails_version(context: Context.new)
36
+ output, status = context.capture2e("rails", "--version")
37
+ context.abort(context.message("core.app.create.rails.error.install_failure", "rails")) unless status.success?
38
+ version = output.match(/Rails (\d+\.\d+\.\d+)/)[1]
39
+ ::Semantic::Version.new(version)
32
40
  end
33
41
 
34
42
  def self.interactive=(interactive)
@@ -15,7 +15,9 @@ module ShopifyCLI
15
15
  },
16
16
  core: {
17
17
  errors: {
18
- missing_node: "Node is required to continue. Install node here: https://nodejs.org/en/download.",
18
+ missing_node: "Node.js is required to continue. Install Node.js here: https://nodejs.org/en/download.",
19
+ missing_npm: "npm is required to continue. Install npm here: https://www.npmjs.com/get-npm.",
20
+ missing_ruby: "Ruby is required to continue. Install Ruby here: https://www.ruby-lang.org/en/downloads.",
19
21
  option_parser: {
20
22
  invalid_option: "The option {{command:%s}} is not supported.",
21
23
  missing_argument: "The required argument {{command:%s}} is missing.",
@@ -95,8 +97,6 @@ module ShopifyCLI
95
97
  HELP
96
98
  error: {
97
99
  node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.",
98
- node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
99
- "per the instructions at https://nodejs.org/en.",
100
100
  npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
101
101
  npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
102
102
  "the instructions at https://www.npmjs.com/get-npm.",
@@ -131,8 +131,6 @@ module ShopifyCLI
131
131
  {{underline:https://getcomposer.org/download/}}
132
132
  COMPOSER
133
133
  npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
134
- npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
135
- "the instructions at https://www.npmjs.com/get-npm.",
136
134
  app_setup: "Failed to set up the app",
137
135
  },
138
136
 
@@ -283,6 +281,8 @@ module ShopifyCLI
283
281
  localization: {
284
282
  error: {
285
283
  bundle_too_large: "Total size of all locale files must be less than %s.",
284
+ duplicate_locale_code: "Duplicate locale found: `%s`; locale codes"\
285
+ " should be unique and are case insensitive.",
286
286
  file_empty: "Locale file `%s` is empty.",
287
287
  file_too_large: "Locale file `%s` too large; size must be less than %s.",
288
288
  invalid_file_extension: "Invalid locale filename: `%s`; only .json files are allowed.",
@@ -88,24 +88,12 @@ module ShopifyCLI
88
88
  end
89
89
 
90
90
  def check_node
91
- cmd_path = context.which("node")
92
- context.abort(context.message("core.app.create.node.error.node_required")) if cmd_path.nil?
93
-
94
- version, stat = context.capture2e("node", "-v")
95
- unless stat.success?
96
- context.abort(context.message("core.app.create.node.error.node_version_failure"))
97
- end
98
-
91
+ version = ShopifyCLI::Environment.node_version(context: context)
99
92
  context.done(context.message("core.app.create.node.node_version", version))
100
93
  end
101
94
 
102
95
  def check_npm
103
- cmd_path = context.which("npm")
104
- context.abort(context.message("core.app.create.node.error.npm_required")) if cmd_path.nil?
105
-
106
- version, stat = context.capture2e("npm", "-v")
107
- context.abort(context.message("core.app.create.node.error.npm_version_failure")) unless stat.success?
108
-
96
+ version = ShopifyCLI::Environment.npm_version(context: context)
109
97
  context.done(context.message("core.app.create.node.npm_version", version))
110
98
  end
111
99
 
@@ -69,12 +69,7 @@ module ShopifyCLI
69
69
  end
70
70
 
71
71
  def check_npm
72
- cmd_path = context.which("npm")
73
- context.abort(context.message("core.app.create.php.error.npm_required")) if cmd_path.nil?
74
-
75
- version, stat = context.capture2e("npm", "-v")
76
- context.abort(context.message("core.app.create.php.error.npm_version_failure")) unless stat.success?
77
-
72
+ version = ShopifyCLI::Environment.npm_version(context: context)
78
73
  context.done(context.message("core.app.create.php.npm_version", version))
79
74
  end
80
75
 
@@ -108,7 +108,7 @@ module ShopifyCLI
108
108
  end
109
109
 
110
110
  def check_ruby
111
- ruby_version = Rails::Ruby.version(context)
111
+ ruby_version = Environment.ruby_version(context)
112
112
  return if ruby_version.satisfies?("~>2.5") || ruby_version.satisfies?("~>3.1.0")
113
113
  context.abort(context.message("core.app.create.rails.error.invalid_ruby_version"))
114
114
  end
@@ -219,18 +219,10 @@ module ShopifyCLI
219
219
  end
220
220
 
221
221
  def install_webpacker?
222
- rails_version < ::Semantic::Version.new("7.0.0") &&
223
- !File.exist?(File.join(context.root, "config/webpacker.yml"))
224
- end
225
-
226
- def rails_version
227
- output, status = context.capture2e("rails", "--version")
228
- unless status.success?
229
- context.abort(context.message("core.app.create.rails.error.install_failure", "rails"))
230
- end
222
+ rails_version = Environment.rails_version(context: context)
223
+ webpacker_config = File.exist?(File.join(context.root, "config/webpacker.yml"))
231
224
 
232
- version = output.scan(/Rails \d+\.\d+\.\d+/).first.split(" ").last
233
- ::Semantic::Version.new(version)
225
+ rails_version < ::Semantic::Version.new("7.0.0") && !webpacker_config
234
226
  end
235
227
  end
236
228
  end
@@ -11,35 +11,19 @@ module ShopifyCLI
11
11
  end
12
12
 
13
13
  def get(path:, **args)
14
- rest_request(
15
- method: "GET",
16
- path: path,
17
- **args
18
- )
14
+ rest_request(method: "GET", path: path, **args)
19
15
  end
20
16
 
21
17
  def put(path:, **args)
22
- rest_request(
23
- method: "PUT",
24
- path: path,
25
- **args
26
- )
18
+ rest_request(method: "PUT", path: path, **args)
27
19
  end
28
20
 
29
21
  def post(path:, **args)
30
- rest_request(
31
- method: "POST",
32
- path: path,
33
- **args
34
- )
22
+ rest_request(method: "POST", path: path, **args)
35
23
  end
36
24
 
37
25
  def delete(path:, **args)
38
- rest_request(
39
- method: "DELETE",
40
- path: path,
41
- **args
42
- )
26
+ rest_request(method: "DELETE", path: path, **args)
43
27
  end
44
28
 
45
29
  def get_shop_or_abort # rubocop:disable Naming/AccessorMethodName
@@ -56,16 +40,33 @@ module ShopifyCLI
56
40
  **args.compact
57
41
  )
58
42
  rescue ShopifyCLI::API::APIRequestForbiddenError,
59
- ShopifyCLI::API::APIRequestUnauthorizedError
60
- handle_permissions_error
43
+ ShopifyCLI::API::APIRequestUnauthorizedError => error
44
+ # The Admin API returns 403 Forbidden responses on different
45
+ # scenarios:
46
+ #
47
+ # * when a user doesn't have permissions for a request:
48
+ # <APIRequestForbiddenError: 403 {}>
49
+ #
50
+ # * when an asset operation cannot be performed:
51
+ # <APIRequestForbiddenError: 403 {"message":"templates/gift_card.liquid could not be deleted"}>
52
+ if empty_response_error?(error)
53
+ return handle_permissions_error
54
+ end
55
+
56
+ raise error
61
57
  end
62
58
 
63
59
  def handle_permissions_error
64
- ensure_user_error = @ctx.message("theme.ensure_user_error", get_shop_or_abort)
60
+ ensure_user_error = @ctx.message("theme.ensure_user_error", shop)
65
61
  ensure_user_try_this = @ctx.message("theme.ensure_user_try_this")
66
62
 
67
63
  @ctx.abort(ensure_user_error, ensure_user_try_this)
68
64
  end
65
+
66
+ def empty_response_error?(error)
67
+ error_message = error&.response&.body.to_s
68
+ error_message.empty?
69
+ end
69
70
  end
70
71
  end
71
72
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyCLI
2
- VERSION = "2.14.0"
2
+ VERSION = "2.15.0"
3
3
  end
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: 2.14.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2022-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,6 +124,7 @@ files:
124
124
  - ".github/PULL_REQUEST_TEMPLATE.md"
125
125
  - ".github/probots.yml"
126
126
  - ".github/workflows/shopify.yml"
127
+ - ".github/workflows/stale.yml"
127
128
  - ".github/workflows/triage.yml"
128
129
  - ".gitignore"
129
130
  - ".rubocop.yml"
@@ -287,7 +288,6 @@ files:
287
288
  - lib/project_types/rails/forms/create.rb
288
289
  - lib/project_types/rails/gem.rb
289
290
  - lib/project_types/rails/messages/messages.rb
290
- - lib/project_types/rails/ruby.rb
291
291
  - lib/project_types/script/cli.rb
292
292
  - lib/project_types/script/commands/connect.rb
293
293
  - lib/project_types/script/commands/create.rb
@@ -1,17 +0,0 @@
1
- module Rails
2
- class Ruby
3
- include SmartProperties
4
-
5
- VERSION_STRING = /ruby ([\d\.]+)/
6
-
7
- property :ctx, accepts: ShopifyCLI::Context, required: true
8
-
9
- class << self
10
- def version(ctx)
11
- require "semantic/semantic"
12
- out, _ = ctx.capture2("ruby", "-v")
13
- Semantic::Version.new(VERSION_STRING.match(out)[1])
14
- end
15
- end
16
- end
17
- end