shopify-cli 2.0.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/Gemfile.lock +4 -4
  4. data/README.md +3 -1
  5. data/THEMEKIT_MIGRATION.md +18 -0
  6. data/lib/graphql/api_versions.graphql +1 -1
  7. data/lib/graphql/get_variant_id.graphql +16 -0
  8. data/lib/project_types/extension/cli.rb +10 -1
  9. data/lib/project_types/extension/commands/check.rb +44 -0
  10. data/lib/project_types/extension/commands/push.rb +0 -1
  11. data/lib/project_types/extension/commands/serve.rb +8 -2
  12. data/lib/project_types/extension/extension_project.rb +39 -1
  13. data/lib/project_types/extension/extension_project_keys.rb +1 -0
  14. data/lib/project_types/extension/features/argo.rb +1 -11
  15. data/lib/project_types/extension/features/argo_runtime.rb +6 -38
  16. data/lib/project_types/extension/features/argo_serve.rb +30 -1
  17. data/lib/project_types/extension/features/runtimes/admin.rb +29 -0
  18. data/lib/project_types/extension/features/runtimes/base.rb +19 -0
  19. data/lib/project_types/extension/features/runtimes/checkout_post_purchase.rb +23 -0
  20. data/lib/project_types/extension/features/runtimes/checkout_ui_extension.rb +29 -0
  21. data/lib/project_types/extension/messages/messages.rb +19 -6
  22. data/lib/project_types/extension/models/product.rb +12 -0
  23. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +10 -0
  24. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +10 -2
  25. data/lib/project_types/extension/models/specification_handlers/default.rb +13 -4
  26. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +12 -0
  27. data/lib/project_types/extension/tasks/configure_features.rb +1 -0
  28. data/lib/project_types/extension/tasks/converters/product_converter.rb +21 -0
  29. data/lib/project_types/extension/tasks/get_product.rb +22 -0
  30. data/lib/project_types/node/messages/messages.rb +1 -1
  31. data/lib/project_types/rails/messages/messages.rb +18 -18
  32. data/lib/project_types/script/commands/create.rb +1 -1
  33. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +3 -3
  34. data/lib/project_types/theme/forms/select.rb +1 -1
  35. data/lib/project_types/theme/messages/messages.rb +3 -3
  36. data/lib/shopify-cli/admin_api.rb +6 -2
  37. data/lib/shopify-cli/api.rb +2 -2
  38. data/lib/shopify-cli/core/monorail.rb +8 -3
  39. data/lib/shopify-cli/messages/messages.rb +9 -8
  40. data/lib/shopify-cli/packager.rb +5 -5
  41. data/lib/shopify-cli/theme/dev_server.rb +1 -1
  42. data/lib/shopify-cli/theme/dev_server/local_assets.rb +1 -1
  43. data/lib/shopify-cli/theme/file.rb +2 -2
  44. data/lib/shopify-cli/theme/syncer.rb +9 -5
  45. data/lib/shopify-cli/theme/theme.rb +5 -5
  46. data/lib/shopify-cli/tunnel.rb +1 -1
  47. data/lib/shopify-cli/version.rb +1 -1
  48. data/shopify-cli.gemspec +1 -1
  49. metadata +14 -4
@@ -34,7 +34,7 @@ module Script
34
34
  end
35
35
 
36
36
  def self.help
37
- allowed_values = Script::Layers::Application::ExtensionPoints.types.map { |type| "{{cyan:#{type}}}" }
37
+ allowed_values = Script::Layers::Application::ExtensionPoints.available_types.map { |type| "{{cyan:#{type}}}" }
38
38
  ShopifyCli::Context.message("script.create.help", ShopifyCli::TOOL_NAME, allowed_values.join(", "))
39
39
  end
40
40
  end
@@ -9,9 +9,9 @@ mutation AppScriptUpdateOrCreate(
9
9
  $schemaMinorVersion: String,
10
10
  $useMsgpack: Boolean,
11
11
  $uuid: String,
12
- $configurationUi: Boolean,
13
- $scriptJsonVersion: String,
14
- $configurationDefinition: String,
12
+ $configurationUi: Boolean!,
13
+ $scriptJsonVersion: String!,
14
+ $configurationDefinition: String!,
15
15
  ) {
16
16
  appScriptUpdateOrCreate(
17
17
  extensionPointName: $extensionPointName
@@ -43,7 +43,7 @@ module Theme
43
43
  when "development"
44
44
  "blue"
45
45
  else
46
- "grey"
46
+ "italic"
47
47
  end
48
48
 
49
49
  tags = ["{{#{color}:[#{theme.role}]}}"]
@@ -90,7 +90,7 @@ module Theme
90
90
  Uploads the current theme as a development theme to the connected store, then prints theme editor and preview URLs to your terminal. While running, changes will push to the store in real time.
91
91
  Usage: {{command:%s theme serve}}
92
92
  HELP
93
- serve: "Viewing theme...",
93
+ serve: "Viewing theme",
94
94
  open_fail: "Couldn't open the theme",
95
95
  },
96
96
  check: {
@@ -134,9 +134,9 @@ module Theme
134
134
  },
135
135
  language_server: {
136
136
  help: <<~HELP,
137
- {{command:%s theme language-server}}: Start a Language Server Protocol server.
137
+ {{command:%1$s theme language-server}}: Start a Language Server Protocol server.
138
138
 
139
- Usage: {{command:%s theme language-server}}
139
+ Usage: {{command:%1$s theme language-server}}
140
140
  HELP
141
141
  },
142
142
  pull: {
@@ -134,8 +134,12 @@ module ShopifyCli
134
134
  )
135
135
  CLI::Kit::Util.begin do
136
136
  versions = client.query("api_versions")["data"]["publicApiVersions"]
137
- latest = versions.find { |version| version["displayName"].include?("Latest") }
138
- latest["handle"]
137
+ # return the most recent supported version
138
+ versions
139
+ .select { |version| version["supported"] }
140
+ .map { |version| version["handle"] }
141
+ .sort
142
+ .reverse[0]
139
143
  end.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
140
144
  ShopifyCli::IdentityAuth.new(ctx: ctx).reauthenticate
141
145
  end
@@ -81,7 +81,7 @@ module ShopifyCli
81
81
  else
82
82
  raise APIRequestUnexpectedError.new("#{response.code}\n#{response.body}", response: response)
83
83
  end
84
- rescue Net::OpenTimeout, Net::ReadTimeout, Net::WriteTimeout, Errno::ETIMEDOUT, Timeout::Error
84
+ rescue Errno::ETIMEDOUT, Timeout::Error
85
85
  raise APIRequestTimeoutError.new("Timeout")
86
86
  end.retry_after(APIRequestRetriableError, retries: 3) do |e|
87
87
  sleep(1) if e.is_a?(APIRequestThrottledError)
@@ -108,7 +108,7 @@ module ShopifyCli
108
108
  {
109
109
  "User-Agent" => "Shopify CLI; v=#{ShopifyCli::VERSION}",
110
110
  "Sec-CH-UA" => "Shopify CLI; v=#{ShopifyCli::VERSION} sha=#{ShopifyCli.sha}",
111
- "Sec-CH-UA-PLATFORM" => ctx.os,
111
+ "Sec-CH-UA-PLATFORM" => ctx.os.to_s,
112
112
  }.tap do |headers|
113
113
  headers["X-Shopify-Cli-Employee"] = "1" if Shopifolk.acting_as_shopify_organization?
114
114
  end.merge(auth_headers(token))
@@ -46,7 +46,7 @@ module ShopifyCli
46
46
 
47
47
  # we only want to send Monorail events in production or when explicitly developing
48
48
  def enabled?
49
- Context.new.system? || ENV["MONORAIL_REAL_EVENTS"] == "1"
49
+ (Context.new.system? || ENV["MONORAIL_REAL_EVENTS"] == "1") && !Context.new.ci?
50
50
  end
51
51
 
52
52
  def consented?
@@ -54,6 +54,7 @@ module ShopifyCli
54
54
  end
55
55
 
56
56
  def prompt_for_consent
57
+ return if Context.new.ci?
57
58
  return unless enabled?
58
59
  return if ShopifyCli::Config.get_section("analytics").key?("enabled")
59
60
  msg = Context.message("core.monorail.consent_prompt")
@@ -90,7 +91,7 @@ module ShopifyCli
90
91
  {
91
92
  schema_id: INVOCATIONS_SCHEMA,
92
93
  payload: {
93
- project_type: Project.current_project_type.to_s,
94
+ project_type: project_type_from_dir_or_cmd(commands[0]).to_s,
94
95
  command: commands.join(" "),
95
96
  args: args.join(" "),
96
97
  time_start: start_time,
@@ -104,7 +105,7 @@ module ShopifyCli
104
105
  is_employee: ShopifyCli::Shopifolk.acting_as_shopify_organization?,
105
106
  }.tap do |payload|
106
107
  payload[:api_key] = metadata.delete(:api_key)
107
- payload[:partner_id] = metadata.delete(:organization_id)
108
+ payload[:partner_id] = metadata.delete(:organization_id) || ShopifyCli::DB.get(:organization_id)
108
109
  if Project.has_current?
109
110
  project = Project.current(force_reload: true)
110
111
  payload[:api_key] = project.env&.api_key
@@ -114,6 +115,10 @@ module ShopifyCli
114
115
  end,
115
116
  }
116
117
  end
118
+
119
+ def project_type_from_dir_or_cmd(command)
120
+ Project.current_project_type || (command unless ShopifyCli::Commands.core_command?(command)) || nil
121
+ end
117
122
  end
118
123
  end
119
124
  end
@@ -28,7 +28,7 @@ module ShopifyCli
28
28
  },
29
29
 
30
30
  env_file: {
31
- saving_header: "writing %s file...",
31
+ saving_header: "writing %s file",
32
32
  saving: "writing %s file",
33
33
  saved: "%s saved to project root",
34
34
  },
@@ -69,7 +69,7 @@ module ShopifyCli
69
69
  no_commits_made: "No git commits have been made. Please make at least one commit.",
70
70
  },
71
71
 
72
- cloning: "Cloning %s into %s...",
72
+ cloning: "Cloning %s into %s",
73
73
  cloned: "{{v}} Cloned into %s",
74
74
  },
75
75
 
@@ -103,9 +103,9 @@ module ShopifyCli
103
103
  install_error: "An error occurred while installing dependencies",
104
104
  },
105
105
 
106
- installing: "Installing dependencies with %s...",
106
+ installing: "Installing dependencies with %s",
107
107
  installed: "Dependencies installed",
108
- npm_installing_deps: "Installing %d dependencies...",
108
+ npm_installing_deps: "Installing %d dependencies",
109
109
  npm_installed_deps: "%d npm dependencies installed",
110
110
  },
111
111
 
@@ -257,7 +257,7 @@ module ShopifyCli
257
257
  count_help: "Number of resources to generate",
258
258
  },
259
259
 
260
- populating: "Populating %d %ss...",
260
+ populating: "Populating %d %ss",
261
261
 
262
262
  completion_message: <<~COMPLETION_MESSAGE,
263
263
  Successfully added %d %s to {{green:%s}}
@@ -345,7 +345,7 @@ module ShopifyCli
345
345
  confirm_store: {
346
346
  prompt: "You are currently logged into {{green:%s}}. Do you want to proceed using this store?",
347
347
  confirmation: "Proceeding using {{green:%s}}",
348
- cancelling: "Cancelling ...",
348
+ cancelling: "Cancelling",
349
349
  },
350
350
  ensure_env: {
351
351
  organization_select: "To which partner organization does this project belong?",
@@ -414,7 +414,9 @@ module ShopifyCli
414
414
  "please make sure %s exists within %s before trying again",
415
415
  },
416
416
 
417
+ installing: "Installing ngrok…",
417
418
  not_running: "{{green:x}} ngrok tunnel not running",
419
+ prereq_command_location: "%s @ %s",
418
420
  signup_suggestion: <<~MESSAGE,
419
421
  {{*}} To avoid tunnels that timeout, it is recommended to signup for a free ngrok
420
422
  account at {{underline:https://ngrok.com/signup}}. After you signup, install your
@@ -423,9 +425,8 @@ module ShopifyCli
423
425
  start: "{{v}} ngrok tunnel running at {{underline:%s}}",
424
426
  start_with_account: "{{v}} ngrok tunnel running at {{underline:%s}}, with account %s",
425
427
  stopped: "{{green:x}} ngrok tunnel stopped",
426
- timed_out: "{{x}} ngrok tunnel has timed out, restarting ...",
428
+ timed_out: "{{x}} ngrok tunnel has timed out, restarting",
427
429
  will_timeout: "{{*}} This tunnel will timeout in {{red:%s}}",
428
- prereq_command_location: "%s @ %s",
429
430
  },
430
431
 
431
432
  version: {
@@ -16,7 +16,7 @@ module ShopifyCli
16
16
 
17
17
  puts "\nBuilding Debian package"
18
18
 
19
- puts "Generating metadata files..."
19
+ puts "Generating metadata files"
20
20
  Dir.glob("#{debian_dir}/*").each { |file| File.delete(file) }
21
21
 
22
22
  metadata_files = %w(control preinst prerm)
@@ -28,7 +28,7 @@ module ShopifyCli
28
28
  File.open(file_path, "w", 0775) { |f| f.write(file_contents) }
29
29
  end
30
30
 
31
- puts "Building package..."
31
+ puts "Building package"
32
32
  Dir.chdir(root_dir)
33
33
  raise "Failed to build package" unless system("dpkg-deb", "-b", "shopify-cli")
34
34
 
@@ -49,14 +49,14 @@ module ShopifyCli
49
49
  spec_path = File.join(root_dir, "shopify-cli.spec")
50
50
  puts "\nBuilding RPM package"
51
51
 
52
- puts "Generating spec file..."
52
+ puts "Generating spec file"
53
53
  File.delete(spec_path) if File.exist?(spec_path)
54
54
 
55
55
  spec_contents = File.read(File.join(root_dir, "shopify-cli.spec.base"))
56
56
  spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCli::VERSION)
57
57
  File.write(spec_path, spec_contents)
58
58
 
59
- puts "Building package..."
59
+ puts "Building package"
60
60
  Dir.chdir(root_dir)
61
61
  system("rpmbuild", "-bb", File.basename(spec_path))
62
62
 
@@ -72,7 +72,7 @@ module ShopifyCli
72
72
  build_path = File.join(BUILDS_DIR, "shopify-cli.rb")
73
73
  puts "\nBuilding Homebrew package"
74
74
 
75
- puts "Generating formula..."
75
+ puts "Generating formula"
76
76
  File.delete(build_path) if File.exist?(build_path)
77
77
 
78
78
  spec_contents = File.read(File.join(root_dir, "shopify-cli.base.rb"))
@@ -87,7 +87,7 @@ module ShopifyCli
87
87
  end
88
88
 
89
89
  def stop
90
- @ctx.puts("Stopping ...")
90
+ @ctx.puts("Stopping")
91
91
  @app.close
92
92
  @syncer.shutdown
93
93
  WebServer.shutdown
@@ -72,7 +72,7 @@ module ShopifyCli
72
72
  def replace_asset_urls(body)
73
73
  replaced_body = body.join.gsub(ASSET_REGEX) do |match|
74
74
  path = Pathname.new(Regexp.last_match[1])
75
- if @theme.asset_paths.include?(path)
75
+ if @theme.static_asset_paths.include?(path)
76
76
  "/#{path}"
77
77
  else
78
78
  match
@@ -20,9 +20,9 @@ module ShopifyCli
20
20
  path.read
21
21
  end
22
22
 
23
- def write(content)
23
+ def write(*args)
24
24
  path.parent.mkpath unless path.parent.directory?
25
- path.write(content)
25
+ path.write(*args)
26
26
  end
27
27
 
28
28
  def delete
@@ -149,7 +149,7 @@ module ShopifyCli
149
149
  # Process lower-priority files in the background
150
150
 
151
151
  # Assets are served locally, so can be uploaded in the background
152
- enqueue_updates(@theme.asset_files)
152
+ enqueue_updates(@theme.static_asset_files)
153
153
 
154
154
  unless delay_low_priority_files
155
155
  wait!(&block)
@@ -254,8 +254,12 @@ module ShopifyCli
254
254
 
255
255
  update_checksums(body)
256
256
 
257
- value = body.dig("asset", "value") || Base64.decode64(body.dig("asset", "attachment"))
258
- file.write(value)
257
+ attachment = body.dig("asset", "attachment")
258
+ value = if attachment
259
+ file.write(Base64.decode64(attachment), 0, mode: "wb")
260
+ else
261
+ file.write(body.dig("asset", "value"))
262
+ end
259
263
 
260
264
  response
261
265
  end
@@ -277,7 +281,7 @@ module ShopifyCli
277
281
 
278
282
  def update_checksums(api_response)
279
283
  api_response.values.flatten.each do |asset|
280
- if asset["key"] && asset["checksum"]
284
+ if asset["key"]
281
285
  @checksums[asset["key"]] = asset["checksum"]
282
286
  end
283
287
  end
@@ -310,7 +314,7 @@ module ShopifyCli
310
314
 
311
315
  def backoff_if_near_limit!(used, limit)
312
316
  if used > limit - @threads.size
313
- @ctx.debug("Near API call limit, waiting 2 sec ...")
317
+ @ctx.debug("Near API call limit, waiting 2 sec")
314
318
  @backoff_mutex.synchronize { sleep 2 }
315
319
  end
316
320
  end
@@ -20,11 +20,11 @@ module ShopifyCli
20
20
  end
21
21
 
22
22
  def theme_files
23
- glob(["**/*.liquid", "**/*.json", "assets/*"])
23
+ glob(["**/*.liquid", "**/*.json", "assets/*"]).uniq
24
24
  end
25
25
 
26
- def asset_files
27
- glob("assets/*")
26
+ def static_asset_files
27
+ glob("assets/*").reject(&:liquid?)
28
28
  end
29
29
 
30
30
  def liquid_files
@@ -43,8 +43,8 @@ module ShopifyCli
43
43
  theme_files.include?(self[file])
44
44
  end
45
45
 
46
- def asset_paths
47
- asset_files.map(&:relative_path)
46
+ def static_asset_paths
47
+ static_asset_files.map(&:relative_path)
48
48
  end
49
49
 
50
50
  def [](file)
@@ -149,7 +149,7 @@ module ShopifyCli
149
149
  check_prereq_command(ctx, "curl")
150
150
  check_prereq_command(ctx, ctx.linux? ? "unzip" : "tar")
151
151
  spinner = CLI::UI::SpinGroup.new
152
- spinner.add("Installing ngrok...") do
152
+ spinner.add(ctx.message("core.tunnel.installing")) do
153
153
  zip_dest = File.join(ShopifyCli.cache_dir, "ngrok.zip")
154
154
  unless File.exist?(zip_dest)
155
155
  ctx.system("curl", "-o", zip_dest, DOWNLOAD_URLS[ctx.os], chdir: ShopifyCli.cache_dir)
@@ -1,3 +1,3 @@
1
1
  module ShopifyCli
2
- VERSION = "2.0.1"
2
+ VERSION = "2.2.1"
3
3
  end
data/shopify-cli.gemspec CHANGED
@@ -44,5 +44,5 @@ Gem::Specification.new do |spec|
44
44
  spec.add_development_dependency("minitest", "~> 5.0")
45
45
 
46
46
  spec.add_dependency("listen", "~> 3.5")
47
- spec.add_dependency("theme-check", "~> 1.0")
47
+ spec.add_dependency("theme-check", "~> 1.1")
48
48
  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.0.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-29 00:00:00.000000000 Z
11
+ date: 2021-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '1.0'
81
+ version: '1.1'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '1.0'
88
+ version: '1.1'
89
89
  description: |
90
90
  Shopify CLI helps you build Shopify apps faster. It quickly scaffolds Node.js
91
91
  and Ruby on Rails embedded apps. It also automates many common tasks in the
@@ -121,6 +121,7 @@ files:
121
121
  - RELEASING.md
122
122
  - Rakefile
123
123
  - SECURITY.md
124
+ - THEMEKIT_MIGRATION.md
124
125
  - bin/load_shopify.rb
125
126
  - bin/shopify
126
127
  - dev.yml
@@ -158,9 +159,11 @@ files:
158
159
  - lib/graphql/find_organization.graphql
159
160
  - lib/graphql/get_app_by_api_key.graphql
160
161
  - lib/graphql/get_app_urls.graphql
162
+ - lib/graphql/get_variant_id.graphql
161
163
  - lib/graphql/update_dashboard_urls.graphql
162
164
  - lib/project_types/extension/cli.rb
163
165
  - lib/project_types/extension/commands/build.rb
166
+ - lib/project_types/extension/commands/check.rb
164
167
  - lib/project_types/extension/commands/connect.rb
165
168
  - lib/project_types/extension/commands/create.rb
166
169
  - lib/project_types/extension/commands/extension_command.rb
@@ -180,6 +183,10 @@ files:
180
183
  - lib/project_types/extension/features/argo_setup.rb
181
184
  - lib/project_types/extension/features/argo_setup_step.rb
182
185
  - lib/project_types/extension/features/argo_setup_steps.rb
186
+ - lib/project_types/extension/features/runtimes/admin.rb
187
+ - lib/project_types/extension/features/runtimes/base.rb
188
+ - lib/project_types/extension/features/runtimes/checkout_post_purchase.rb
189
+ - lib/project_types/extension/features/runtimes/checkout_ui_extension.rb
183
190
  - lib/project_types/extension/forms/connect.rb
184
191
  - lib/project_types/extension/forms/create.rb
185
192
  - lib/project_types/extension/forms/questions/ask_app.rb
@@ -191,6 +198,7 @@ files:
191
198
  - lib/project_types/extension/models/app.rb
192
199
  - lib/project_types/extension/models/lazy_specification_handler.rb
193
200
  - lib/project_types/extension/models/npm_package.rb
201
+ - lib/project_types/extension/models/product.rb
194
202
  - lib/project_types/extension/models/registration.rb
195
203
  - lib/project_types/extension/models/specification.rb
196
204
  - lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb
@@ -204,6 +212,7 @@ files:
204
212
  - lib/project_types/extension/tasks/configure_features.rb
205
213
  - lib/project_types/extension/tasks/configure_options.rb
206
214
  - lib/project_types/extension/tasks/converters/app_converter.rb
215
+ - lib/project_types/extension/tasks/converters/product_converter.rb
207
216
  - lib/project_types/extension/tasks/converters/registration_converter.rb
208
217
  - lib/project_types/extension/tasks/converters/validation_error_converter.rb
209
218
  - lib/project_types/extension/tasks/converters/version_converter.rb
@@ -213,6 +222,7 @@ files:
213
222
  - lib/project_types/extension/tasks/get_app.rb
214
223
  - lib/project_types/extension/tasks/get_apps.rb
215
224
  - lib/project_types/extension/tasks/get_extensions.rb
225
+ - lib/project_types/extension/tasks/get_product.rb
216
226
  - lib/project_types/extension/tasks/update_draft.rb
217
227
  - lib/project_types/extension/tasks/user_errors.rb
218
228
  - lib/project_types/node/cli.rb