shopify-cli 1.9.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
  3. data/.github/workflows/build.yml +28 -0
  4. data/.github/workflows/release.yml +2 -4
  5. data/CHANGELOG.md +27 -0
  6. data/Gemfile.lock +1 -1
  7. data/README.md +2 -1
  8. data/lib/project_types/extension/cli.rb +7 -1
  9. data/lib/project_types/extension/commands/serve.rb +69 -1
  10. data/lib/project_types/extension/commands/tunnel.rb +3 -1
  11. data/lib/project_types/extension/extension_project.rb +1 -0
  12. data/lib/project_types/extension/features/argo.rb +18 -49
  13. data/lib/project_types/extension/features/argo_runtime.rb +81 -0
  14. data/lib/project_types/extension/features/argo_serve.rb +35 -27
  15. data/lib/project_types/extension/features/argo_serve_options.rb +41 -0
  16. data/lib/project_types/extension/features/argo_setup.rb +1 -1
  17. data/lib/project_types/extension/messages/messages.rb +5 -4
  18. data/lib/project_types/extension/models/npm_package.rb +14 -0
  19. data/lib/project_types/extension/models/specification.rb +3 -2
  20. data/lib/project_types/extension/models/specification_handlers/checkout_argo_extension.rb +18 -0
  21. data/lib/project_types/extension/models/specification_handlers/default.rb +33 -3
  22. data/lib/project_types/extension/models/version.rb +1 -1
  23. data/lib/project_types/extension/tasks/choose_next_available_port.rb +36 -0
  24. data/lib/project_types/extension/tasks/configure_features.rb +2 -0
  25. data/lib/project_types/extension/tasks/find_npm_packages.rb +106 -0
  26. data/lib/project_types/node/messages/messages.rb +4 -4
  27. data/lib/project_types/rails/messages/messages.rb +4 -4
  28. data/lib/project_types/script/cli.rb +17 -12
  29. data/lib/project_types/script/commands/push.rb +1 -1
  30. data/lib/project_types/script/config/extension_points.yml +2 -3
  31. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +5 -2
  32. data/lib/project_types/script/graphql/get_app_scripts.graphql +6 -0
  33. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  34. data/lib/project_types/script/layers/application/push_script.rb +6 -3
  35. data/lib/project_types/script/layers/domain/errors.rb +0 -2
  36. data/lib/project_types/script/layers/domain/push_package.rb +4 -0
  37. data/lib/project_types/script/layers/domain/script_project.rb +21 -1
  38. data/lib/project_types/script/layers/infrastructure/command_runner.rb +19 -0
  39. data/lib/project_types/script/layers/infrastructure/errors.rb +30 -3
  40. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +97 -0
  41. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +103 -0
  42. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +26 -0
  43. data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +73 -0
  44. data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +60 -0
  45. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +21 -0
  46. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +6 -5
  47. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +61 -34
  48. data/lib/project_types/script/layers/infrastructure/script_service.rb +14 -2
  49. data/lib/project_types/script/messages/messages.rb +20 -3
  50. data/lib/project_types/script/tasks/ensure_env.rb +85 -0
  51. data/lib/project_types/script/ui/error_handler.rb +25 -6
  52. data/lib/shopify-cli/admin_api.rb +7 -4
  53. data/lib/shopify-cli/js_system.rb +2 -2
  54. data/lib/shopify-cli/messages/messages.rb +51 -45
  55. data/lib/shopify-cli/method_object.rb +4 -4
  56. data/lib/shopify-cli/oauth.rb +9 -3
  57. data/lib/shopify-cli/packager.rb +1 -1
  58. data/lib/shopify-cli/partners_api.rb +7 -4
  59. data/lib/shopify-cli/partners_api/organizations.rb +3 -3
  60. data/lib/shopify-cli/resolve_constant.rb +1 -1
  61. data/lib/shopify-cli/resources/env_file.rb +2 -2
  62. data/lib/shopify-cli/shopifolk.rb +1 -1
  63. data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -4
  64. data/lib/shopify-cli/transform_data_structure.rb +1 -1
  65. data/lib/shopify-cli/tunnel.rb +22 -1
  66. data/lib/shopify-cli/version.rb +1 -1
  67. data/lib/shopify_cli.rb +0 -1
  68. data/vendor/deps/smart_properties/REVISION +1 -1
  69. data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
  70. data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
  71. metadata +19 -11
  72. data/.travis.yml +0 -14
  73. data/lib/project_types/extension/features/argo_renderer_package.rb +0 -32
  74. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +0 -100
  75. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +0 -95
  76. data/lib/project_types/script/layers/infrastructure/project_creator.rb +0 -24
  77. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +0 -72
  78. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +0 -59
  79. data/lib/project_types/script/layers/infrastructure/task_runner.rb +0 -19
@@ -0,0 +1,85 @@
1
+ require "shopify_cli"
2
+
3
+ module Script
4
+ module Tasks
5
+ class EnsureEnv < ShopifyCli::Task
6
+ attr_accessor :ctx
7
+
8
+ def call(ctx)
9
+ self.ctx = ctx
10
+
11
+ script_project_repo = Layers::Infrastructure::ScriptProjectRepository.new(ctx: ctx)
12
+ script_project = script_project_repo.get
13
+
14
+ return if script_project.api_key && script_project.api_secret && script_project.uuid_defined?
15
+
16
+ org = ask_org
17
+ app = ask_app(org["apps"])
18
+ uuid = ask_script_uuid(app, script_project.extension_point_type)
19
+
20
+ script_project_repo.create_env(
21
+ api_key: app["apiKey"],
22
+ secret: app["apiSecretKeys"].first["secret"],
23
+ uuid: uuid
24
+ )
25
+ end
26
+
27
+ private
28
+
29
+ def ask_org
30
+ if ShopifyCli::Shopifolk.check && wants_to_run_against_shopify_org?
31
+ ShopifyCli::Shopifolk.act_as_shopify_organization
32
+ end
33
+
34
+ orgs = ShopifyCli::PartnersAPI::Organizations.fetch_with_app(ctx)
35
+ if orgs.count == 1
36
+ default = orgs.first
37
+ ctx.puts(ctx.message("script.application.ensure_env.organization", default["businessName"], default["id"]))
38
+ default
39
+ elsif orgs.count > 0
40
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.organization_select")) do |handler|
41
+ orgs.each do |org|
42
+ handler.option("#{org["businessName"]} (#{org["id"]})") { org }
43
+ end
44
+ end
45
+ else
46
+ raise Errors::NoExistingOrganizationsError
47
+ end
48
+ end
49
+
50
+ def ask_app(apps)
51
+ unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
52
+ apps = apps.select { |app| app["appType"] == "custom" }
53
+ end
54
+
55
+ if apps.count == 1
56
+ default = apps.first
57
+ ctx.puts(ctx.message("script.application.ensure_env.app", default["title"]))
58
+ default
59
+ elsif apps.count > 0
60
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.app_select")) do |handler|
61
+ apps.each do |app|
62
+ handler.option(app["title"]) { app }
63
+ end
64
+ end
65
+ else
66
+ raise Errors::NoExistingAppsError
67
+ end
68
+ end
69
+
70
+ def ask_script_uuid(app, extension_point_type)
71
+ script_service = Layers::Infrastructure::ScriptService.new(ctx: ctx)
72
+ scripts = script_service.get_app_scripts(api_key: app["apiKey"], extension_point_type: extension_point_type)
73
+
74
+ return nil unless scripts.count > 0 &&
75
+ CLI::UI::Prompt.confirm(ctx.message("script.application.ensure_env.ask_connect_to_existing_script"))
76
+
77
+ CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.ask_which_script_to_connect_to")) do |handler|
78
+ scripts.each do |script|
79
+ handler.option("#{script["title"]} (#{script["uuid"]})") { script["uuid"] }
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -110,11 +110,6 @@ module Script
110
110
  e.extension_point_type
111
111
  ),
112
112
  }
113
- when Layers::Domain::Errors::ServiceFailureError
114
- {
115
- cause_of_error: ShopifyCli::Context.message("script.error.service_failure_cause"),
116
- help_suggestion: ShopifyCli::Context.message("script.error.service_failure_help"),
117
- }
118
113
  when Layers::Domain::Errors::MetadataValidationError
119
114
  {
120
115
  cause_of_error: ShopifyCli::Context.message("script.error.metadata_validation_cause"),
@@ -163,6 +158,15 @@ module Script
163
158
  ),
164
159
  help_suggestion: ShopifyCli::Context.message("script.error.config_ui_missing_keys_error_help"),
165
160
  }
161
+ when Layers::Infrastructure::Errors::ConfigUiInvalidInputModeError
162
+ {
163
+ cause_of_error: ShopifyCli::Context.message(
164
+ "script.error.config_ui_invalid_input_mode_error_cause",
165
+ filename: e.filename,
166
+ valid_input_modes: e.valid_input_modes
167
+ ),
168
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_invalid_input_mode_error_help"),
169
+ }
166
170
  when Layers::Infrastructure::Errors::ConfigUiFieldsMissingKeysError
167
171
  {
168
172
  cause_of_error: ShopifyCli::Context.message(
@@ -172,6 +176,15 @@ module Script
172
176
  ),
173
177
  help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_missing_keys_error_help"),
174
178
  }
179
+ when Layers::Infrastructure::Errors::ConfigUiFieldsInvalidTypeError
180
+ {
181
+ cause_of_error: ShopifyCli::Context.message(
182
+ "script.error.config_ui_fields_invalid_type_error_cause",
183
+ filename: e.filename,
184
+ valid_types: e.valid_types
185
+ ),
186
+ help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_invalid_type_error_help"),
187
+ }
175
188
  when Layers::Infrastructure::Errors::DependencyInstallError
176
189
  {
177
190
  cause_of_error: ShopifyCli::Context.message("script.error.dependency_install_cause"),
@@ -193,9 +206,15 @@ module Script
193
206
  ),
194
207
  help_suggestion: ShopifyCli::Context.message("script.error.graphql_error_help"),
195
208
  }
209
+ when Layers::Infrastructure::Errors::SystemCallFailureError
210
+ {
211
+ cause_of_error: ShopifyCli::Context
212
+ .message("script.error.system_call_failure_cause", cmd: e.cmd),
213
+ help_suggestion: ShopifyCli::Context.message("script.error.system_call_failure_help", out: e.out),
214
+ }
196
215
  when Layers::Infrastructure::Errors::ScriptRepushError
197
216
  {
198
- cause_of_error: ShopifyCli::Context.message("script.error.script_repush_cause", e.api_key),
217
+ cause_of_error: ShopifyCli::Context.message("script.error.script_repush_cause", e.uuid),
199
218
  help_suggestion: ShopifyCli::Context.message("script.error.script_repush_help"),
200
219
  }
201
220
  when Layers::Infrastructure::Errors::ShopAuthenticationError
@@ -85,11 +85,14 @@ module ShopifyCli
85
85
 
86
86
  private
87
87
 
88
- def authenticated_req(ctx, shop)
89
- yield
88
+ def authenticated_req(ctx, shop, &block)
89
+ CLI::Kit::Util
90
+ .begin(&block)
91
+ .retry_after(API::APIRequestUnauthorizedError, retries: 1) do
92
+ authenticate(ctx, shop)
93
+ end
90
94
  rescue API::APIRequestUnauthorizedError
91
- authenticate(ctx, shop)
92
- retry
95
+ ctx.abort(ctx.message("core.api.error.failed_auth"))
93
96
  end
94
97
 
95
98
  def authenticate(ctx, shop)
@@ -37,8 +37,8 @@ module ShopifyCli
37
37
  #
38
38
  # ShopifyCli::JsSystem.call(ctx, yarn: ['install', '--silent'], npm: ['install', '--no-audit'])
39
39
  #
40
- def call(ctx, yarn:, npm:)
41
- JsSystem.new(ctx: ctx).call(yarn: yarn, npm: npm)
40
+ def call(ctx, yarn:, npm:, capture_response: false)
41
+ JsSystem.new(ctx: ctx).call(yarn: yarn, npm: npm, capture_response: capture_response)
42
42
  end
43
43
  end
44
44
 
@@ -16,8 +16,8 @@ module ShopifyCli
16
16
  core: {
17
17
  connect: {
18
18
  help: <<~HELP,
19
- Connect (or re-connect) an existing project to a Shopify partner organization and/or a store. Creates or updates the {{green:.env}} file, and creates the {{green:.shopify-cli.yml}} file.
20
- Usage: {{command:%s connect}}
19
+ Connect (or re-connect) an existing project to a Shopify partner organization and/or a store. Creates or updates the {{green:.env}} file, and creates the {{green:.shopify-cli.yml}} file.
20
+ Usage: {{command:%s connect}}
21
21
  HELP
22
22
 
23
23
  already_connected_warning: "{{yellow:! This app appears to be already connected}}",
@@ -27,15 +27,15 @@ module ShopifyCli
27
27
 
28
28
  context: {
29
29
  open_url: <<~OPEN,
30
- Please open this URL in your browser:
31
- {{green:%s}}
30
+ Please open this URL in your browser:
31
+ {{green:%s}}
32
32
  OPEN
33
33
  },
34
34
 
35
35
  create: {
36
36
  help: <<~HELP,
37
- Create a new project.
38
- Usage: {{command:%s create [ %s ]}}
37
+ Create a new project.
38
+ Usage: {{command:%s create [ %s ]}}
39
39
  HELP
40
40
 
41
41
  error: {
@@ -53,13 +53,13 @@ module ShopifyCli
53
53
 
54
54
  config: {
55
55
  help: <<~HELP,
56
- Change configuration of how the CLI operates
57
- Usage: {{command:%s config [ feature | analytics ] }}
56
+ Change configuration of how the CLI operates
57
+ Usage: {{command:%s config [ feature | analytics ] }}
58
58
  HELP
59
59
  feature: {
60
60
  help: <<~HELP,
61
- Change configuration of various features
62
- Usage: {{command:%s config [ feature ] [ feature_name ] }}
61
+ Change configuration of various features
62
+ Usage: {{command:%s config [ feature ] [ feature_name ] }}
63
63
  HELP
64
64
  enabled: "{{v}} feature {{green:%s}} has been enabled",
65
65
  disabled: "{{v}} feature {{green:%s}} has been disabled",
@@ -68,8 +68,8 @@ module ShopifyCli
68
68
  },
69
69
  analytics: {
70
70
  help: <<~HELP,
71
- Opt in/out of anonymous usage reporting
72
- Usage: {{command:%s config [ analytics ] }}
71
+ Opt in/out of anonymous usage reporting
72
+ Usage: {{command:%s config [ analytics ] }}
73
73
  HELP
74
74
  enabled: "{{v}} analytics have been enabled",
75
75
  disabled: "{{v}} analytics have been disabled",
@@ -82,7 +82,8 @@ module ShopifyCli
82
82
  error: {
83
83
  directory_exists: "Project directory already exists. Please create a project with a new name.",
84
84
  no_branches_found: "Could not find any git branches",
85
- repo_not_initiated: "Git repo is not initiated. Please run `git init` and make at least one commit.",
85
+ repo_not_initiated:
86
+ "Git repo is not initiated. Please run {{command:git init}} and make at least one commit.",
86
87
  no_commits_made: "No git commits have been made. Please make at least one commit.",
87
88
  },
88
89
 
@@ -96,9 +97,9 @@ module ShopifyCli
96
97
  },
97
98
 
98
99
  preamble: <<~MESSAGE,
99
- Use {{command:%s help <command>}} to display detailed information about a specific command.
100
+ Use {{command:%s help <command>}} to display detailed information about a specific command.
100
101
 
101
- {{bold:Available core commands:}}
102
+ {{bold:Available core commands:}}
102
103
 
103
104
  MESSAGE
104
105
  },
@@ -110,7 +111,7 @@ module ShopifyCli
110
111
  deploy: "Could not deploy to Heroku",
111
112
  download: "Heroku CLI could not be downloaded",
112
113
  install: "Could not install Heroku CLI",
113
- could_not_select_app: "Heroku app `%s` could not be selected",
114
+ could_not_select_app: "Heroku app {{green:%s}} could not be selected",
114
115
  },
115
116
  },
116
117
 
@@ -130,8 +131,8 @@ module ShopifyCli
130
131
 
131
132
  logout: {
132
133
  help: <<~HELP,
133
- Log out of a currently authenticated partner organization and store, or clear invalid credentials
134
- Usage: {{command:%s logout}}
134
+ Log out of a currently authenticated partner organization and store, or clear invalid credentials
135
+ Usage: {{command:%s logout}}
135
136
  HELP
136
137
 
137
138
  success: "Logged out of partner organization and store",
@@ -153,6 +154,7 @@ module ShopifyCli
153
154
  location: {
154
155
  admin: "development store",
155
156
  partner: "Shopify Partners account",
157
+ shopifolk: "{{green:Shopify Employee account}}",
156
158
  },
157
159
  authentication_required:
158
160
  "{{i}} Authentication required. Login to the URL below with your %s credentials to continue.",
@@ -174,14 +176,15 @@ module ShopifyCli
174
176
  org_name_and_id: "%s (%s)",
175
177
  error: {
176
178
  account_not_found: <<~MESSAGE,
177
- {{x}} error: Your account was not found. Please sign up at https://partners.shopify.com/signup
178
- For authentication issues, run {{command:%s logout}} to clear invalid credentials
179
+ {{x}} error: Your account was not found. Please sign up at https://partners.shopify.com/signup
180
+ For authentication issues, run {{command:%s logout}} to clear invalid credentials
179
181
  MESSAGE
180
182
  },
181
183
  },
182
184
 
183
185
  api: {
184
186
  error: {
187
+ failed_auth: "Failed to authenticate with Shopify. Please try again later.",
185
188
  internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
186
189
  internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
187
190
  invalid_url: "Invalid URL: %s",
@@ -195,16 +198,16 @@ module ShopifyCli
195
198
  },
196
199
  populating: "Populating %d %ss...",
197
200
  completion_message: <<~COMPLETION_MESSAGE,
198
- Successfully added %d %s to {{green:%s}}
199
- {{*}} View all %ss at {{underline:%s%ss}}
201
+ Successfully added %d %s to {{green:%s}}
202
+ {{*}} View all %ss at {{underline:%s%ss}}
200
203
  COMPLETION_MESSAGE
201
204
  },
202
205
 
203
206
  project: {
204
207
  error: {
205
208
  not_in_project: <<~MESSAGE,
206
- {{x}} You are not in a Shopify app project
207
- {{yellow:{{*}}}}{{reset: Run}}{{cyan: shopify create}}{{reset: to create your app}}
209
+ {{x}} You are not in a Shopify app project
210
+ {{yellow:{{*}}}}{{reset: Run}}{{cyan: shopify create}}{{reset: to create your app}}
208
211
  MESSAGE
209
212
  },
210
213
  },
@@ -225,10 +228,10 @@ module ShopifyCli
225
228
 
226
229
  system: {
227
230
  help: <<~HELP,
228
- Print details about the development system.
229
- Usage: {{command:%s system [all]}}
231
+ Print details about the development system.
232
+ Usage: {{command:%s system [all]}}
230
233
 
231
- {{cyan:all}}: displays more details about development system and environment
234
+ {{cyan:all}}: displays more details about development system and environment
232
235
 
233
236
  HELP
234
237
 
@@ -239,8 +242,8 @@ module ShopifyCli
239
242
  header: "{{bold:Shopify App CLI}}",
240
243
  const: "%17s = %s",
241
244
  ruby_header: <<~RUBY_MESSAGE,
242
- {{bold:Ruby (via RbConfig)}}
243
- %s
245
+ {{bold:Ruby (via RbConfig)}}
246
+ %s
244
247
  RUBY_MESSAGE
245
248
  rb_config: "%-25s - RbConfig[\"%s\"]",
246
249
  command_header: "{{bold:Commands}}",
@@ -267,8 +270,8 @@ module ShopifyCli
267
270
  ensure_env: {
268
271
  organization_select: "To which partner organization does this project belong?",
269
272
  no_development_stores: <<~MESSAGE,
270
- No development stores available.
271
- Visit {{underline:https://partners.shopify.com/%d/stores}} to create one
273
+ No development stores available.
274
+ Visit {{underline:https://partners.shopify.com/%d/stores}} to create one
272
275
  MESSAGE
273
276
  development_store_select: "Which development store would you like to use?",
274
277
  app_select: "To which app does this project belong?",
@@ -305,7 +308,10 @@ module ShopifyCli
305
308
  no_development_stores: "{{x}} No Development Stores available.",
306
309
  no_organizations: "No partner organizations available.",
307
310
  organization_not_found: "Cannot find a partner organization with that ID",
308
- partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
311
+ shopifolk_notice: <<~MESSAGE,
312
+ {{i}} As a {{green:Shopify}} employee, the authentication should take you to the Shopify Okta login,
313
+ NOT the Partner account login. Please run {{command:%s logout}} and try again.
314
+ MESSAGE
309
315
  },
310
316
  first_party: "Are you working on a 1P (1st Party) app?",
311
317
  identified_as_shopify: "We've identified you as a {{green:Shopify}} employee.",
@@ -326,9 +332,9 @@ module ShopifyCli
326
332
 
327
333
  not_running: "{{green:x}} ngrok tunnel not running",
328
334
  signup_suggestion: <<~MESSAGE,
329
- {{*}} To avoid tunnels that timeout, it is recommended to signup for a free ngrok
330
- account at {{underline:https://ngrok.com/signup}}. After you signup, install your
331
- personalized authorization token using {{command:%s tunnel auth <token>}}.
335
+ {{*}} To avoid tunnels that timeout, it is recommended to signup for a free ngrok
336
+ account at {{underline:https://ngrok.com/signup}}. After you signup, install your
337
+ personalized authorization token using {{command:%s tunnel auth <token>}}.
332
338
  MESSAGE
333
339
  start: "{{v}} ngrok tunnel running at {{underline:%s}}",
334
340
  start_with_account: "{{v}} ngrok tunnel running at {{underline:%s}}, with account %s",
@@ -340,31 +346,31 @@ module ShopifyCli
340
346
 
341
347
  version: {
342
348
  help: <<~HELP,
343
- Prints version number.
344
- Usage: {{command:%s version}}
349
+ Prints version number.
350
+ Usage: {{command:%s version}}
345
351
  HELP
346
352
  },
347
353
 
348
354
  warning: {
349
355
  development_version: <<~DEVELOPMENT,
350
- {{*}} {{yellow:You are running a development version of the CLI at:}}
351
- {{yellow:%s}}
356
+ {{*}} {{yellow:You are running a development version of the CLI at:}}
357
+ {{yellow:%s}}
352
358
 
353
359
  DEVELOPMENT
354
360
 
355
361
  shell_shim: <<~MESSAGE,
356
- {{x}} This version of Shopify App CLI is no longer supported. You’ll need to migrate to the new CLI version to continue.
362
+ {{x}} This version of Shopify App CLI is no longer supported. You’ll need to migrate to the new CLI version to continue.
357
363
 
358
- Please visit this page for complete instructions:
359
- {{underline:https://shopify.dev/tools/cli/troubleshooting#migrate-from-a-legacy-version}}
364
+ Please visit this page for complete instructions:
365
+ {{underline:https://shopify.dev/tools/cli/troubleshooting#migrate-from-a-legacy-version}}
360
366
 
361
367
  MESSAGE
362
368
 
363
369
  new_version: <<~MESSAGE,
364
- {{*}} {{yellow:A new version of Shopify App CLI is available! You have version %s and the latest version is %s.
370
+ {{*}} {{yellow:A new version of Shopify App CLI is available! You have version %s and the latest version is %s.
365
371
 
366
- To upgrade, follow the instructions for the package manager you’re using:
367
- {{underline:https://shopify.dev/tools/cli/troubleshooting#upgrade-shopify-app-cli}}}}
372
+ To upgrade, follow the instructions for the package manager you’re using:
373
+ {{underline:https://shopify.dev/tools/cli/troubleshooting#upgrade-shopify-app-cli}}}}
368
374
 
369
375
  MESSAGE
370
376
  },
@@ -52,8 +52,8 @@ module ShopifyCli
52
52
  # invokes the original `call` implementation and wraps its return value
53
53
  # into a result object.
54
54
  #
55
- def call(*args, **kwargs)
56
- Result.wrap { super(*args, **kwargs) }.call
55
+ def call(*args, **kwargs, &block)
56
+ Result.wrap { kwargs.any? ? super(*args, **kwargs, &block) : super(*args, &block) }.call
57
57
  end
58
58
  end
59
59
 
@@ -64,10 +64,10 @@ module ShopifyCli
64
64
  # initializer or to `call`. If the keyword argument matches the name of
65
65
  # property, it is forwarded to the initializer, otherwise to call.
66
66
  #
67
- def call(*args, **kwargs)
67
+ def call(*args, **kwargs, &block)
68
68
  properties.keys.yield_self do |properties|
69
69
  new(**kwargs.slice(*properties))
70
- .call(*args, **kwargs.slice(*(kwargs.keys - properties)))
70
+ .call(*args, **kwargs.slice(*(kwargs.keys - properties)), &block)
71
71
  end
72
72
  end
73
73
 
@@ -24,10 +24,10 @@ module ShopifyCli
24
24
  property! :service, accepts: String
25
25
  property! :client_id, accepts: String
26
26
  property! :scopes
27
- property :store, default: ShopifyCli::DB.new
27
+ property :store, default: -> { ShopifyCli::DB.new }
28
28
  property :secret, accepts: String
29
29
  property :request_exchange, accepts: String
30
- property :options, default: {}, accepts: Hash
30
+ property :options, default: -> { {} }, accepts: Hash
31
31
  property :auth_path, default: "/authorize", accepts: ->(path) { path.is_a?(String) && path.start_with?("/") }
32
32
  property :token_path, default: "/token", accepts: ->(path) { path.is_a?(String) && path.start_with?("/") }
33
33
  property :state_token, accepts: String, default: SecureRandom.hex(30)
@@ -80,7 +80,13 @@ module ShopifyCli
80
80
  end
81
81
 
82
82
  def output_authentication_info(uri)
83
- login_location = ctx.message(service == "admin" ? "core.oauth.location.admin" : "core.oauth.location.partner")
83
+ login_location = if service == "admin"
84
+ ctx.message("core.oauth.location.admin")
85
+ elsif Shopifolk.acting_as_shopify_organization?
86
+ ctx.message("core.oauth.location.shopifolk")
87
+ else
88
+ ctx.message("core.oauth.location.partner")
89
+ end
84
90
  ctx.puts(ctx.message("core.oauth.authentication_required", login_location))
85
91
  ctx.open_url!(uri)
86
92
  end