shopify-cli 2.7.1 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +2 -2
- data/.github/workflows/shopify.yml +1 -1
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +43 -0
- data/Codespace.dockerfile +2 -2
- data/Gemfile.lock +4 -4
- data/Tests.dockerfile +2 -2
- data/dev.yml +3 -3
- data/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/javy.rb +30 -12
- data/lib/graphql/get_extension_registrations.graphql +27 -0
- data/lib/project_types/extension/cli.rb +27 -2
- data/lib/project_types/extension/commands/build.rb +10 -15
- data/lib/project_types/extension/commands/create.rb +3 -6
- data/lib/project_types/extension/commands/push.rb +36 -8
- data/lib/project_types/extension/extension_project.rb +1 -1
- data/lib/project_types/extension/features/argo_serve.rb +6 -5
- data/lib/project_types/extension/forms/questions/ask_registration.rb +6 -2
- data/lib/project_types/extension/loaders/project.rb +29 -0
- data/lib/project_types/extension/loaders/specification_handler.rb +22 -0
- data/lib/project_types/extension/messages/messages.rb +4 -2
- data/lib/project_types/extension/models/app.rb +1 -1
- data/lib/project_types/extension/models/development_server.rb +2 -2
- data/lib/project_types/extension/models/specification_handlers/default.rb +4 -0
- data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
- data/lib/project_types/extension/tasks/execute_commands/base.rb +13 -0
- data/lib/project_types/extension/tasks/execute_commands/build.rb +29 -0
- data/lib/project_types/extension/tasks/execute_commands/create.rb +33 -0
- data/lib/project_types/extension/tasks/execute_commands/serve.rb +35 -0
- data/lib/project_types/extension/tasks/merge_server_config.rb +33 -22
- data/lib/project_types/rails/commands/create.rb +2 -4
- data/lib/project_types/script/cli.rb +8 -1
- data/lib/project_types/script/commands/connect.rb +19 -0
- data/lib/project_types/script/commands/create.rb +1 -3
- data/lib/project_types/script/commands/javy.rb +0 -2
- data/lib/project_types/script/commands/push.rb +2 -1
- data/lib/project_types/script/config/extension_points.yml +10 -28
- data/lib/project_types/script/forms/ask_app.rb +32 -0
- data/lib/project_types/script/forms/ask_org.rb +30 -0
- data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
- data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
- data/lib/project_types/script/graphql/app_script_set.graphql +2 -2
- data/lib/project_types/script/layers/application/build_script.rb +0 -1
- data/lib/project_types/script/layers/application/connect_app.rb +79 -0
- data/lib/project_types/script/layers/application/create_script.rb +17 -17
- data/lib/project_types/script/layers/application/push_script.rb +1 -1
- data/lib/project_types/script/layers/domain/errors.rb +1 -4
- data/lib/project_types/script/layers/domain/push_package.rb +3 -3
- data/lib/project_types/script/layers/domain/{script_json.rb → script_config.rb} +2 -2
- data/lib/project_types/script/layers/domain/script_project.rb +5 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +28 -6
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -4
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -4
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +125 -27
- data/lib/project_types/script/layers/infrastructure/script_service.rb +11 -11
- data/lib/project_types/script/messages/messages.rb +20 -5
- data/lib/project_types/script/ui/error_handler.rb +30 -20
- data/lib/project_types/theme/commands/pull.rb +3 -0
- data/lib/project_types/theme/commands/push.rb +7 -1
- data/lib/project_types/theme/commands/serve.rb +1 -1
- data/lib/project_types/theme/messages/messages.rb +10 -0
- data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
- data/lib/shopify_cli/command/project_command.rb +20 -7
- data/lib/shopify_cli/command.rb +6 -0
- data/lib/shopify_cli/commands/app/create/node.rb +1 -3
- data/lib/shopify_cli/commands/app/create/rails.rb +1 -3
- data/lib/shopify_cli/commands/login.rb +1 -1
- data/lib/shopify_cli/commands/switch.rb +1 -1
- data/lib/shopify_cli/constants.rb +7 -0
- data/lib/shopify_cli/context.rb +11 -1
- data/lib/shopify_cli/environment.rb +4 -0
- data/lib/shopify_cli/form.rb +2 -0
- data/lib/shopify_cli/git.rb +2 -0
- data/lib/shopify_cli/identity_auth.rb +18 -0
- data/lib/shopify_cli/messages/messages.rb +8 -1
- data/lib/shopify_cli/partners_api/app_extensions/job.rb +36 -0
- data/lib/shopify_cli/partners_api/app_extensions.rb +46 -0
- data/lib/shopify_cli/partners_api/organizations.rb +2 -5
- data/lib/shopify_cli/partners_api.rb +2 -8
- data/lib/shopify_cli/project.rb +8 -7
- data/lib/shopify_cli/resources/env_file.rb +13 -5
- data/lib/shopify_cli/services/app/create/rails_service.rb +1 -1
- data/lib/shopify_cli/services/app/serve/node_service.rb +1 -1
- data/lib/shopify_cli/services/app/serve/rails_service.rb +1 -1
- data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
- data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
- data/lib/shopify_cli/theme/dev_server/hot-reload.js +38 -9
- data/lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb +84 -0
- data/lib/shopify_cli/theme/dev_server/proxy.rb +9 -15
- data/lib/shopify_cli/theme/dev_server.rb +6 -4
- data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
- data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
- data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
- data/lib/shopify_cli/theme/syncer.rb +40 -39
- data/lib/shopify_cli/theme/theme.rb +31 -19
- data/lib/shopify_cli/thread_pool/job.rb +27 -0
- data/lib/shopify_cli/thread_pool.rb +37 -0
- data/lib/shopify_cli/tunnel.rb +9 -10
- data/lib/shopify_cli/version.rb +1 -1
- data/shopify-cli.gemspec +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +3 -1
- metadata +31 -8
- data/lib/graphql/all_orgs_with_extensions.graphql +0 -37
- data/lib/project_types/extension/tasks/run_extension_command.rb +0 -82
- data/lib/project_types/script/tasks/ensure_env.rb +0 -106
data/lib/shopify_cli/tunnel.rb
CHANGED
@@ -21,6 +21,7 @@ module ShopifyCLI
|
|
21
21
|
# mapping for supported operating systems for where to download ngrok from.
|
22
22
|
DOWNLOAD_URLS = {
|
23
23
|
mac: "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-amd64.zip",
|
24
|
+
mac_m1: "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-darwin-arm64.zip",
|
24
25
|
linux: "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip",
|
25
26
|
windows: "https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-windows-amd64.zip",
|
26
27
|
}
|
@@ -87,7 +88,7 @@ module ShopifyCLI
|
|
87
88
|
#
|
88
89
|
def auth(ctx, token)
|
89
90
|
install(ctx)
|
90
|
-
ctx.system(ngrok_path, "authtoken", token)
|
91
|
+
ctx.system(ngrok_path(ctx), "authtoken", token)
|
91
92
|
end
|
92
93
|
|
93
94
|
##
|
@@ -150,7 +151,7 @@ module ShopifyCLI
|
|
150
151
|
|
151
152
|
def install(ctx)
|
152
153
|
ngrok = "ngrok#{ctx.executable_file_extension}"
|
153
|
-
return if File.exist?(ngrok_path)
|
154
|
+
return if File.exist?(ngrok_path(ctx))
|
154
155
|
check_prereq_command(ctx, "curl")
|
155
156
|
check_prereq_command(ctx, ctx.linux? ? "unzip" : "tar")
|
156
157
|
spinner = CLI::UI::SpinGroup.new
|
@@ -170,7 +171,7 @@ module ShopifyCLI
|
|
170
171
|
spinner.wait
|
171
172
|
|
172
173
|
# final check to see if ngrok is accessible
|
173
|
-
unless File.exist?(ngrok_path)
|
174
|
+
unless File.exist?(ngrok_path(ctx))
|
174
175
|
ctx.abort(ctx.message("core.tunnel.error.ngrok", ngrok, ShopifyCLI.cache_dir))
|
175
176
|
end
|
176
177
|
end
|
@@ -182,12 +183,9 @@ module ShopifyCLI
|
|
182
183
|
raise e.class, e.message
|
183
184
|
end
|
184
185
|
|
185
|
-
def ngrok_path
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
def ngrok_command(port)
|
190
|
-
"\"#{ngrok_path}\" http -inspect=false -log=stdout -log-level=debug #{port}"
|
186
|
+
def ngrok_path(ctx)
|
187
|
+
ngrok = "ngrok#{ctx.executable_file_extension}"
|
188
|
+
File.join(ShopifyCLI.cache_dir, ngrok)
|
191
189
|
end
|
192
190
|
|
193
191
|
def seconds_to_hm(seconds)
|
@@ -195,7 +193,8 @@ module ShopifyCLI
|
|
195
193
|
end
|
196
194
|
|
197
195
|
def start_ngrok(ctx, port)
|
198
|
-
|
196
|
+
ngrok_command = "\"#{ngrok_path(ctx)}\" http -inspect=false -log=stdout -log-level=debug #{port}"
|
197
|
+
process = ShopifyCLI::ProcessSupervision.start(:ngrok, ngrok_command)
|
199
198
|
log = fetch_url(ctx, process.log_path)
|
200
199
|
[log.url, log.account]
|
201
200
|
end
|
data/lib/shopify_cli/version.rb
CHANGED
data/shopify-cli.gemspec
CHANGED
@@ -114,7 +114,9 @@ module CLI
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def print_error_message(e)
|
117
|
-
|
117
|
+
CLI::UI::Frame.open("Error", color: :red, timing: false) do
|
118
|
+
$stderr.puts(format_error_message(e.message))
|
119
|
+
end
|
118
120
|
end
|
119
121
|
end
|
120
122
|
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.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 1.
|
95
|
+
version: 1.9.0
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 1.
|
102
|
+
version: 1.9.0
|
103
103
|
description: |
|
104
104
|
Shopify CLI helps you build Shopify apps faster. It quickly scaffolds Node.js
|
105
105
|
and Ruby on Rails embedded apps. It also automates many common tasks in the
|
@@ -150,6 +150,10 @@ files:
|
|
150
150
|
- docs/contributors/testing.md
|
151
151
|
- docs/users/installation.md
|
152
152
|
- docs/users/migrate-from-themekit.md
|
153
|
+
- ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256
|
154
|
+
- ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256
|
155
|
+
- ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256
|
156
|
+
- ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256
|
153
157
|
- ext/javy/javy.rb
|
154
158
|
- ext/javy/version
|
155
159
|
- ext/shopify-extensions/extconf.rb
|
@@ -161,7 +165,6 @@ files:
|
|
161
165
|
- lib/graphql/admin_introspection.graphql
|
162
166
|
- lib/graphql/all_organizations.graphql
|
163
167
|
- lib/graphql/all_orgs_with_apps.graphql
|
164
|
-
- lib/graphql/all_orgs_with_extensions.graphql
|
165
168
|
- lib/graphql/api_versions.graphql
|
166
169
|
- lib/graphql/convert_dev_to_test_store.graphql
|
167
170
|
- lib/graphql/create_app.graphql
|
@@ -174,6 +177,7 @@ files:
|
|
174
177
|
- lib/graphql/find_organization.graphql
|
175
178
|
- lib/graphql/get_app_by_api_key.graphql
|
176
179
|
- lib/graphql/get_app_urls.graphql
|
180
|
+
- lib/graphql/get_extension_registrations.graphql
|
177
181
|
- lib/graphql/get_variant_id.graphql
|
178
182
|
- lib/graphql/update_dashboard_urls.graphql
|
179
183
|
- lib/project_types/extension/cli.rb
|
@@ -209,6 +213,8 @@ files:
|
|
209
213
|
- lib/project_types/extension/forms/questions/ask_registration.rb
|
210
214
|
- lib/project_types/extension/forms/questions/ask_template.rb
|
211
215
|
- lib/project_types/extension/forms/questions/ask_type.rb
|
216
|
+
- lib/project_types/extension/loaders/project.rb
|
217
|
+
- lib/project_types/extension/loaders/specification_handler.rb
|
212
218
|
- lib/project_types/extension/messages/message_loading.rb
|
213
219
|
- lib/project_types/extension/messages/messages.rb
|
214
220
|
- lib/project_types/extension/models/app.rb
|
@@ -246,6 +252,10 @@ files:
|
|
246
252
|
- lib/project_types/extension/tasks/converters/version_converter.rb
|
247
253
|
- lib/project_types/extension/tasks/create_extension.rb
|
248
254
|
- lib/project_types/extension/tasks/ensure_resource_url.rb
|
255
|
+
- lib/project_types/extension/tasks/execute_commands/base.rb
|
256
|
+
- lib/project_types/extension/tasks/execute_commands/build.rb
|
257
|
+
- lib/project_types/extension/tasks/execute_commands/create.rb
|
258
|
+
- lib/project_types/extension/tasks/execute_commands/serve.rb
|
249
259
|
- lib/project_types/extension/tasks/fetch_specifications.rb
|
250
260
|
- lib/project_types/extension/tasks/find_npm_packages.rb
|
251
261
|
- lib/project_types/extension/tasks/find_package_from_json.rb
|
@@ -254,7 +264,6 @@ files:
|
|
254
264
|
- lib/project_types/extension/tasks/get_extensions.rb
|
255
265
|
- lib/project_types/extension/tasks/get_product.rb
|
256
266
|
- lib/project_types/extension/tasks/merge_server_config.rb
|
257
|
-
- lib/project_types/extension/tasks/run_extension_command.rb
|
258
267
|
- lib/project_types/extension/tasks/update_draft.rb
|
259
268
|
- lib/project_types/extension/tasks/user_errors.rb
|
260
269
|
- lib/project_types/node/cli.rb
|
@@ -270,17 +279,23 @@ files:
|
|
270
279
|
- lib/project_types/rails/messages/messages.rb
|
271
280
|
- lib/project_types/rails/ruby.rb
|
272
281
|
- lib/project_types/script/cli.rb
|
282
|
+
- lib/project_types/script/commands/connect.rb
|
273
283
|
- lib/project_types/script/commands/create.rb
|
274
284
|
- lib/project_types/script/commands/javy.rb
|
275
285
|
- lib/project_types/script/commands/push.rb
|
276
286
|
- lib/project_types/script/config/extension_points.yml
|
277
287
|
- lib/project_types/script/errors.rb
|
288
|
+
- lib/project_types/script/forms/ask_app.rb
|
289
|
+
- lib/project_types/script/forms/ask_org.rb
|
290
|
+
- lib/project_types/script/forms/ask_script_uuid.rb
|
278
291
|
- lib/project_types/script/forms/create.rb
|
292
|
+
- lib/project_types/script/forms/run_against_shopify_org.rb
|
279
293
|
- lib/project_types/script/graphql/app_script_set.graphql
|
280
294
|
- lib/project_types/script/graphql/get_app_scripts.graphql
|
281
295
|
- lib/project_types/script/graphql/module_upload_url_generate.graphql
|
282
296
|
- lib/project_types/script/graphql/script_service_proxy.graphql
|
283
297
|
- lib/project_types/script/layers/application/build_script.rb
|
298
|
+
- lib/project_types/script/layers/application/connect_app.rb
|
284
299
|
- lib/project_types/script/layers/application/create_script.rb
|
285
300
|
- lib/project_types/script/layers/application/extension_points.rb
|
286
301
|
- lib/project_types/script/layers/application/project_dependencies.rb
|
@@ -289,7 +304,7 @@ files:
|
|
289
304
|
- lib/project_types/script/layers/domain/extension_point.rb
|
290
305
|
- lib/project_types/script/layers/domain/metadata.rb
|
291
306
|
- lib/project_types/script/layers/domain/push_package.rb
|
292
|
-
- lib/project_types/script/layers/domain/
|
307
|
+
- lib/project_types/script/layers/domain/script_config.rb
|
293
308
|
- lib/project_types/script/layers/domain/script_project.rb
|
294
309
|
- lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb
|
295
310
|
- lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
|
@@ -308,7 +323,6 @@ files:
|
|
308
323
|
- lib/project_types/script/layers/infrastructure/script_uploader.rb
|
309
324
|
- lib/project_types/script/layers/infrastructure/service_locator.rb
|
310
325
|
- lib/project_types/script/messages/messages.rb
|
311
|
-
- lib/project_types/script/tasks/ensure_env.rb
|
312
326
|
- lib/project_types/script/ui/error_handler.rb
|
313
327
|
- lib/project_types/script/ui/printing_spinner.rb
|
314
328
|
- lib/project_types/script/ui/strict_spinner.rb
|
@@ -399,6 +413,8 @@ files:
|
|
399
413
|
- lib/shopify_cli/options.rb
|
400
414
|
- lib/shopify_cli/packager.rb
|
401
415
|
- lib/shopify_cli/partners_api.rb
|
416
|
+
- lib/shopify_cli/partners_api/app_extensions.rb
|
417
|
+
- lib/shopify_cli/partners_api/app_extensions/job.rb
|
402
418
|
- lib/shopify_cli/partners_api/organizations.rb
|
403
419
|
- lib/shopify_cli/php_deps.rb
|
404
420
|
- lib/shopify_cli/process_supervision.rb
|
@@ -440,12 +456,14 @@ files:
|
|
440
456
|
- lib/shopify_cli/tasks/select_org_and_shop.rb
|
441
457
|
- lib/shopify_cli/tasks/update_dashboard_urls.rb
|
442
458
|
- lib/shopify_cli/theme/dev_server.rb
|
459
|
+
- lib/shopify_cli/theme/dev_server/cdn_fonts.rb
|
443
460
|
- lib/shopify_cli/theme/dev_server/certificate_manager.rb
|
444
461
|
- lib/shopify_cli/theme/dev_server/header_hash.rb
|
445
462
|
- lib/shopify_cli/theme/dev_server/hot-reload.js
|
446
463
|
- lib/shopify_cli/theme/dev_server/hot_reload.rb
|
447
464
|
- lib/shopify_cli/theme/dev_server/local_assets.rb
|
448
465
|
- lib/shopify_cli/theme/dev_server/proxy.rb
|
466
|
+
- lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb
|
449
467
|
- lib/shopify_cli/theme/dev_server/sse.rb
|
450
468
|
- lib/shopify_cli/theme/dev_server/watcher.rb
|
451
469
|
- lib/shopify_cli/theme/dev_server/web_server.rb
|
@@ -454,7 +472,12 @@ files:
|
|
454
472
|
- lib/shopify_cli/theme/ignore_filter.rb
|
455
473
|
- lib/shopify_cli/theme/mime_type.rb
|
456
474
|
- lib/shopify_cli/theme/syncer.rb
|
475
|
+
- lib/shopify_cli/theme/syncer/error_reporter.rb
|
476
|
+
- lib/shopify_cli/theme/syncer/operation.rb
|
477
|
+
- lib/shopify_cli/theme/syncer/standard_reporter.rb
|
457
478
|
- lib/shopify_cli/theme/theme.rb
|
479
|
+
- lib/shopify_cli/thread_pool.rb
|
480
|
+
- lib/shopify_cli/thread_pool/job.rb
|
458
481
|
- lib/shopify_cli/transform_data_structure.rb
|
459
482
|
- lib/shopify_cli/tunnel.rb
|
460
483
|
- lib/shopify_cli/version.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
query AllOrgs ($type: String) {
|
2
|
-
organizations {
|
3
|
-
nodes {
|
4
|
-
id
|
5
|
-
businessName
|
6
|
-
website
|
7
|
-
apps(first: 500) {
|
8
|
-
nodes {
|
9
|
-
id
|
10
|
-
title
|
11
|
-
apiKey
|
12
|
-
apiSecretKeys{
|
13
|
-
secret
|
14
|
-
}
|
15
|
-
appType
|
16
|
-
extensionRegistrations(specificationIdentifier: $type) {
|
17
|
-
id
|
18
|
-
type
|
19
|
-
uuid
|
20
|
-
title
|
21
|
-
draftVersion {
|
22
|
-
registrationId
|
23
|
-
context
|
24
|
-
lastUserInteractionAt
|
25
|
-
location
|
26
|
-
validationErrors { field message }
|
27
|
-
|
28
|
-
id
|
29
|
-
uuid
|
30
|
-
versionTag
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
}
|
@@ -1,82 +0,0 @@
|
|
1
|
-
|
2
|
-
# frozen_string_literal: true
|
3
|
-
require "shopify_cli"
|
4
|
-
|
5
|
-
module Extension
|
6
|
-
module Tasks
|
7
|
-
class RunExtensionCommand < ShopifyCLI::Task
|
8
|
-
include SmartProperties
|
9
|
-
|
10
|
-
SUPPORTED_COMMANDS = [
|
11
|
-
"create",
|
12
|
-
"build",
|
13
|
-
"serve",
|
14
|
-
]
|
15
|
-
|
16
|
-
property! :command, accepts: SUPPORTED_COMMANDS
|
17
|
-
property! :type, accepts: Models::DevelopmentServerRequirements::SUPPORTED_EXTENSION_TYPES
|
18
|
-
property! :context, accepts: ShopifyCLI::Context
|
19
|
-
property :config_file_name, accepts: String
|
20
|
-
property :port, accepts: Integer, default: 39351
|
21
|
-
property :resource_url, accepts: String
|
22
|
-
property :root_dir, accepts: String
|
23
|
-
property :template, accepts: Models::ServerConfig::Development::VALID_TEMPLATES
|
24
|
-
property :tunnel_url, accepts: String
|
25
|
-
|
26
|
-
def call
|
27
|
-
ShopifyCLI::Result.success(config_file_exists?)
|
28
|
-
.then(&method(:load_or_build_server_config))
|
29
|
-
.then(&method(:run_command))
|
30
|
-
.unwrap do |error|
|
31
|
-
raise error unless error.nil?
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def config_file_exists?
|
38
|
-
return false if config_file_name.nil?
|
39
|
-
project = ExtensionProject.current
|
40
|
-
File.exist?(File.join(project.directory, config_file_name))
|
41
|
-
end
|
42
|
-
|
43
|
-
def load_or_build_server_config(config_file_exists)
|
44
|
-
return merge_server_config if config_file_exists
|
45
|
-
build_server_config
|
46
|
-
end
|
47
|
-
|
48
|
-
def merge_server_config
|
49
|
-
Tasks::MergeServerConfig.call(
|
50
|
-
context: context,
|
51
|
-
file_name: config_file_name,
|
52
|
-
resource_url: resource_url,
|
53
|
-
tunnel_url: tunnel_url,
|
54
|
-
type: type
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
def build_server_config
|
59
|
-
extension = Models::ServerConfig::Extension.build(
|
60
|
-
template: template,
|
61
|
-
type: type,
|
62
|
-
root_dir: root_dir,
|
63
|
-
)
|
64
|
-
|
65
|
-
Models::ServerConfig::Root.new(port: port, extensions: [extension])
|
66
|
-
end
|
67
|
-
|
68
|
-
def run_command(server_config)
|
69
|
-
case command
|
70
|
-
when "create"
|
71
|
-
Models::DevelopmentServer.new.create(server_config)
|
72
|
-
when "build"
|
73
|
-
Models::DevelopmentServer.new.build(server_config)
|
74
|
-
when "serve"
|
75
|
-
Models::DevelopmentServer.new.serve(context, server_config)
|
76
|
-
else
|
77
|
-
raise NotImplementedError
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,106 +0,0 @@
|
|
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 false 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
|
-
|
26
|
-
true
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def ask_org
|
32
|
-
return stubbed_org if partner_proxy_bypass
|
33
|
-
|
34
|
-
if ShopifyCLI::Shopifolk.check && wants_to_run_against_shopify_org?
|
35
|
-
ShopifyCLI::Shopifolk.act_as_shopify_organization
|
36
|
-
end
|
37
|
-
|
38
|
-
orgs = ShopifyCLI::PartnersAPI::Organizations.fetch_with_app(ctx)
|
39
|
-
if orgs.count == 1
|
40
|
-
default = orgs.first
|
41
|
-
ctx.puts(ctx.message("script.application.ensure_env.organization", default["businessName"], default["id"]))
|
42
|
-
default
|
43
|
-
elsif orgs.count > 0
|
44
|
-
CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.organization_select")) do |handler|
|
45
|
-
orgs.each do |org|
|
46
|
-
handler.option("#{org["businessName"]} (#{org["id"]})") { org }
|
47
|
-
end
|
48
|
-
end
|
49
|
-
else
|
50
|
-
raise Errors::NoExistingOrganizationsError
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def stubbed_org
|
55
|
-
{
|
56
|
-
"apps" => [
|
57
|
-
{
|
58
|
-
"appType" => "custom",
|
59
|
-
"apiKey" => "stubbed-api-key",
|
60
|
-
"apiSecretKeys" => [{ "secret" => "stubbed-api-secret" }],
|
61
|
-
"title" => "Fake App (Not connected to Partners)",
|
62
|
-
},
|
63
|
-
],
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
def partner_proxy_bypass
|
68
|
-
!ENV["BYPASS_PARTNERS_PROXY"].nil?
|
69
|
-
end
|
70
|
-
|
71
|
-
def ask_app(apps)
|
72
|
-
unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
73
|
-
apps = apps.select { |app| app["appType"] == "custom" }
|
74
|
-
end
|
75
|
-
|
76
|
-
if apps.count == 1
|
77
|
-
default = apps.first
|
78
|
-
ctx.puts(ctx.message("script.application.ensure_env.app", default["title"]))
|
79
|
-
default
|
80
|
-
elsif apps.count > 0
|
81
|
-
CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.app_select")) do |handler|
|
82
|
-
apps.each do |app|
|
83
|
-
handler.option(app["title"]) { app }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
else
|
87
|
-
raise Errors::NoExistingAppsError
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def ask_script_uuid(app, extension_point_type)
|
92
|
-
script_service = Layers::Infrastructure::ServiceLocator.script_service(ctx: ctx, api_key: app["apiKey"])
|
93
|
-
scripts = script_service.get_app_scripts(extension_point_type: extension_point_type)
|
94
|
-
|
95
|
-
return nil unless scripts.count > 0 &&
|
96
|
-
CLI::UI::Prompt.confirm(ctx.message("script.application.ensure_env.ask_connect_to_existing_script"))
|
97
|
-
|
98
|
-
CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.ask_which_script_to_connect_to")) do |handler|
|
99
|
-
scripts.each do |script|
|
100
|
-
handler.option("#{script["title"]} (#{script["uuid"]})") { script["uuid"] }
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|