shopify-cli 2.3.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/workflows/shopify.yml +104 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +14 -14
- data/.rubocop_todo.yml +3 -3
- data/CHANGELOG.md +26 -0
- data/CONTRIBUTING.md +23 -0
- data/Dockerfile +17 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +67 -24
- data/README.md +1 -1
- data/RELEASING.md +1 -1
- data/Rakefile +75 -18
- data/bin/console +11 -0
- data/bin/shopify +17 -4
- data/dev.yml +14 -1
- data/ext/shopify-cli/extconf.rb +2 -0
- data/ext/shopify-extensions/extconf.rb +21 -0
- data/ext/shopify-extensions/shopify_extensions.rb +152 -0
- data/ext/shopify-extensions/version +1 -0
- data/lib/project_types/extension/cli.rb +19 -3
- data/lib/project_types/extension/commands/build.rb +32 -3
- data/lib/project_types/extension/commands/check.rb +2 -2
- data/lib/project_types/extension/commands/connect.rb +1 -1
- data/lib/project_types/extension/commands/create.rb +59 -16
- data/lib/project_types/extension/commands/extension_command.rb +1 -1
- data/lib/project_types/extension/commands/info.rb +1 -1
- data/lib/project_types/extension/commands/push.rb +1 -1
- data/lib/project_types/extension/commands/register.rb +2 -2
- data/lib/project_types/extension/commands/serve.rb +5 -5
- data/lib/project_types/extension/commands/tunnel.rb +6 -6
- data/lib/project_types/extension/extension_project.rb +4 -4
- data/lib/project_types/extension/features/argo.rb +3 -3
- data/lib/project_types/extension/features/argo_config.rb +5 -5
- data/lib/project_types/extension/features/argo_serve.rb +21 -6
- data/lib/project_types/extension/features/argo_setup.rb +1 -1
- data/lib/project_types/extension/features/argo_setup_step.rb +1 -1
- data/lib/project_types/extension/features/argo_setup_steps.rb +2 -2
- data/lib/project_types/extension/forms/connect.rb +2 -2
- data/lib/project_types/extension/forms/create.rb +6 -3
- data/lib/project_types/extension/forms/questions/ask_app.rb +2 -2
- data/lib/project_types/extension/forms/questions/ask_name.rb +1 -1
- data/lib/project_types/extension/forms/questions/ask_registration.rb +2 -2
- data/lib/project_types/extension/forms/questions/ask_template.rb +44 -0
- data/lib/project_types/extension/forms/questions/ask_type.rb +2 -2
- data/lib/project_types/extension/messages/message_loading.rb +2 -2
- data/lib/project_types/extension/messages/messages.rb +3 -0
- data/lib/project_types/extension/models/development_server.rb +78 -0
- data/lib/project_types/extension/models/development_server_requirements.rb +35 -0
- data/lib/project_types/extension/models/lazy_specification_handler.rb +1 -1
- data/lib/project_types/extension/models/server_config/base.rb +31 -0
- data/lib/project_types/extension/models/server_config/development.rb +23 -0
- data/lib/project_types/extension/models/server_config/development_entries.rb +38 -0
- data/lib/project_types/extension/models/server_config/development_renderer.rb +30 -0
- data/lib/project_types/extension/models/server_config/extension.rb +35 -0
- data/lib/project_types/extension/models/server_config/root.rb +18 -0
- data/lib/project_types/extension/models/server_config/user.rb +10 -0
- data/lib/project_types/extension/models/specification.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +14 -2
- data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
- data/lib/project_types/extension/models/specifications.rb +4 -4
- data/lib/project_types/extension/tasks/choose_next_available_port.rb +2 -2
- data/lib/project_types/extension/tasks/configure_features.rb +1 -1
- data/lib/project_types/extension/tasks/configure_options.rb +1 -1
- data/lib/project_types/extension/tasks/converters/product_converter.rb +1 -1
- data/lib/project_types/extension/tasks/converters/server_config_converter.rb +31 -0
- data/lib/project_types/extension/tasks/create_extension.rb +2 -2
- data/lib/project_types/extension/tasks/fetch_specifications.rb +2 -2
- data/lib/project_types/extension/tasks/find_npm_packages.rb +5 -5
- data/lib/project_types/extension/tasks/get_app.rb +2 -2
- data/lib/project_types/extension/tasks/get_apps.rb +2 -2
- data/lib/project_types/extension/tasks/get_extensions.rb +2 -2
- data/lib/project_types/extension/tasks/get_product.rb +2 -2
- data/lib/project_types/extension/tasks/load_server_config.rb +23 -0
- data/lib/project_types/extension/tasks/run_extension_command.rb +81 -0
- data/lib/project_types/extension/tasks/update_draft.rb +2 -2
- data/lib/project_types/node/cli.rb +3 -3
- data/lib/project_types/node/commands/connect.rb +4 -4
- data/lib/project_types/node/commands/create.rb +10 -14
- data/lib/project_types/node/commands/deploy/heroku.rb +4 -4
- data/lib/project_types/node/commands/deploy.rb +3 -3
- data/lib/project_types/node/commands/generate.rb +2 -2
- data/lib/project_types/node/commands/open.rb +3 -3
- data/lib/project_types/node/commands/serve.rb +15 -7
- data/lib/project_types/node/commands/tunnel.rb +6 -6
- data/lib/project_types/node/forms/create.rb +3 -3
- data/lib/project_types/node/messages/messages.rb +3 -0
- data/lib/project_types/php/cli.rb +27 -0
- data/lib/project_types/php/commands/connect.rb +19 -0
- data/lib/project_types/php/commands/create.rb +143 -0
- data/lib/project_types/php/commands/deploy/heroku.rb +129 -0
- data/lib/project_types/php/commands/deploy.rb +32 -0
- data/lib/project_types/php/commands/open.rb +16 -0
- data/lib/project_types/php/commands/serve.rb +51 -0
- data/lib/project_types/php/commands/tunnel.rb +37 -0
- data/lib/project_types/php/forms/create.rb +45 -0
- data/lib/project_types/php/messages/messages.rb +191 -0
- data/lib/project_types/rails/cli.rb +3 -3
- data/lib/project_types/rails/commands/connect.rb +4 -4
- data/lib/project_types/rails/commands/create.rb +12 -16
- data/lib/project_types/rails/commands/deploy/heroku.rb +4 -4
- data/lib/project_types/rails/commands/deploy.rb +3 -3
- data/lib/project_types/rails/commands/generate/webhook.rb +3 -3
- data/lib/project_types/rails/commands/generate.rb +3 -3
- data/lib/project_types/rails/commands/open.rb +3 -3
- data/lib/project_types/rails/commands/serve.rb +8 -8
- data/lib/project_types/rails/commands/tunnel.rb +6 -6
- data/lib/project_types/rails/forms/create.rb +3 -3
- data/lib/project_types/rails/gem.rb +1 -1
- data/lib/project_types/rails/ruby.rb +1 -1
- data/lib/project_types/script/cli.rb +16 -6
- data/lib/project_types/script/commands/create.rb +4 -2
- data/lib/project_types/script/commands/push.rb +2 -2
- data/lib/project_types/script/config/extension_points.yml +30 -29
- data/lib/project_types/script/forms/create.rb +1 -1
- data/lib/project_types/script/layers/application/create_script.rb +32 -12
- data/lib/project_types/script/layers/application/extension_points.rb +4 -4
- data/lib/project_types/script/layers/application/push_script.rb +13 -1
- data/lib/project_types/script/layers/domain/extension_point.rb +13 -45
- data/lib/project_types/script/layers/domain/push_package.rb +0 -12
- data/lib/project_types/script/layers/domain/script_project.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +57 -0
- data/lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb +35 -0
- data/lib/project_types/script/layers/infrastructure/command_runner.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +5 -0
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +10 -90
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +76 -11
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +33 -0
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +105 -0
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +6 -6
- data/lib/project_types/script/layers/infrastructure/script_service.rb +25 -144
- data/lib/project_types/script/layers/infrastructure/script_uploader.rb +27 -0
- data/lib/project_types/script/layers/infrastructure/service_locator.rb +20 -0
- data/lib/project_types/script/messages/messages.rb +4 -0
- data/lib/project_types/script/tasks/ensure_env.rb +7 -7
- data/lib/project_types/script/ui/error_handler.rb +84 -76
- data/lib/project_types/script/ui/printing_spinner.rb +1 -1
- data/lib/project_types/theme/cli.rb +3 -3
- data/lib/project_types/theme/commands/check.rb +3 -3
- data/lib/project_types/theme/commands/delete.rb +7 -7
- data/lib/project_types/theme/commands/init.rb +3 -3
- data/lib/project_types/theme/commands/language_server.rb +2 -2
- data/lib/project_types/theme/commands/package.rb +2 -2
- data/lib/project_types/theme/commands/publish.rb +5 -5
- data/lib/project_types/theme/commands/pull.rb +9 -9
- data/lib/project_types/theme/commands/push.rb +12 -12
- data/lib/project_types/theme/commands/serve.rb +4 -4
- data/lib/project_types/theme/forms/confirm_store.rb +1 -1
- data/lib/project_types/theme/forms/select.rb +2 -2
- data/lib/{shopify-cli → shopify_cli}/admin_api/populate_resource_command.rb +3 -3
- data/lib/{shopify-cli → shopify_cli}/admin_api/schema.rb +4 -4
- data/lib/{shopify-cli → shopify_cli}/admin_api.rb +27 -27
- data/lib/{shopify-cli → shopify_cli}/api.rb +12 -8
- data/lib/shopify_cli/command/app_sub_command.rb +16 -0
- data/lib/{shopify-cli → shopify_cli}/command.rb +3 -3
- data/lib/{shopify-cli → shopify_cli}/commands/config.rb +14 -14
- data/lib/{shopify-cli → shopify_cli}/commands/help.rb +4 -4
- data/lib/{shopify-cli → shopify_cli}/commands/login.rb +7 -7
- data/lib/shopify_cli/commands/logout.rb +39 -0
- data/lib/{shopify-cli → shopify_cli}/commands/populate/customer.rb +4 -4
- data/lib/{shopify-cli → shopify_cli}/commands/populate/draft_order.rb +4 -4
- data/lib/{shopify-cli → shopify_cli}/commands/populate/product.rb +4 -4
- data/lib/shopify_cli/commands/populate.rb +23 -0
- data/lib/shopify_cli/commands/store.rb +15 -0
- data/lib/{shopify-cli → shopify_cli}/commands/switch.rb +5 -5
- data/lib/{shopify-cli → shopify_cli}/commands/system.rb +10 -10
- data/lib/shopify_cli/commands/version.rb +15 -0
- data/lib/{shopify-cli → shopify_cli}/commands/whoami.rb +7 -7
- data/lib/shopify_cli/commands.rb +34 -0
- data/lib/{shopify-cli → shopify_cli}/connect.rb +3 -3
- data/lib/shopify_cli/constants.rb +54 -0
- data/lib/{shopify-cli → shopify_cli}/context.rb +6 -6
- data/lib/{shopify-cli → shopify_cli}/core/entry_point.rb +7 -7
- data/lib/{shopify-cli → shopify_cli}/core/executor.rb +8 -4
- data/lib/{shopify-cli → shopify_cli}/core/finalize.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/core/help_resolver.rb +2 -2
- data/lib/{shopify-cli → shopify_cli}/core/monorail.rb +8 -8
- data/lib/shopify_cli/core.rb +8 -0
- data/lib/{shopify-cli → shopify_cli}/db.rb +8 -8
- data/lib/shopify_cli/environment.rb +91 -0
- data/lib/shopify_cli/exception_reporter/permission_controller.rb +54 -0
- data/lib/shopify_cli/exception_reporter.rb +55 -0
- data/lib/{shopify-cli → shopify_cli}/feature.rb +8 -8
- data/lib/{shopify-cli → shopify_cli}/form.rb +2 -2
- data/lib/{shopify-cli → shopify_cli}/git.rb +38 -8
- data/lib/{shopify-cli → shopify_cli}/helpers/haikunator.rb +1 -1
- data/lib/shopify_cli/helpers.rb +5 -0
- data/lib/{shopify-cli → shopify_cli}/heroku.rb +38 -13
- data/lib/{shopify-cli → shopify_cli}/http_request.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/identity_auth/servlet.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/identity_auth.rb +24 -31
- data/lib/{shopify-cli → shopify_cli}/js_deps.rb +7 -7
- data/lib/{shopify-cli → shopify_cli}/js_system.rb +10 -10
- data/lib/{shopify-cli → shopify_cli}/lazy_delegator.rb +2 -2
- data/lib/{shopify-cli → shopify_cli}/messages/messages.rb +44 -2
- data/lib/{shopify-cli → shopify_cli}/method_object.rb +15 -8
- data/lib/shopify_cli/migrator/migration.rb +27 -0
- data/lib/shopify_cli/migrator/migrations/1631709766_noop.rb +13 -0
- data/lib/shopify_cli/migrator.rb +48 -0
- data/lib/{shopify-cli → shopify_cli}/options.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/packager.rb +8 -8
- data/lib/{shopify-cli → shopify_cli}/partners_api/organizations.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/partners_api.rb +16 -40
- data/lib/shopify_cli/php_deps.rb +102 -0
- data/lib/{shopify-cli → shopify_cli}/process_supervision.rb +10 -8
- data/lib/{shopify-cli → shopify_cli}/project.rb +15 -15
- data/lib/{shopify-cli → shopify_cli}/project_commands.rb +3 -3
- data/lib/{shopify-cli → shopify_cli}/project_type.rb +5 -5
- data/lib/{shopify-cli → shopify_cli}/resolve_constant.rb +5 -5
- data/lib/{shopify-cli → shopify_cli}/resources/env_file.rb +1 -1
- data/lib/shopify_cli/resources.rb +5 -0
- data/lib/{shopify-cli → shopify_cli}/result.rb +11 -11
- data/lib/{shopify-cli → shopify_cli}/shopifolk.rb +6 -6
- data/lib/{shopify-cli → shopify_cli}/sub_command.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/task.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/tasks/confirm_store.rb +3 -3
- data/lib/{shopify-cli → shopify_cli}/tasks/create_api_client.rb +4 -4
- data/lib/shopify_cli/tasks/ensure_authenticated.rb +13 -0
- data/lib/{shopify-cli → shopify_cli}/tasks/ensure_dev_store.rb +5 -5
- data/lib/{shopify-cli → shopify_cli}/tasks/ensure_env.rb +3 -3
- data/lib/{shopify-cli → shopify_cli}/tasks/ensure_loopback_url.rb +4 -4
- data/lib/{shopify-cli → shopify_cli}/tasks/ensure_project_type.rb +3 -3
- data/lib/{shopify-cli → shopify_cli}/tasks/select_org_and_shop.rb +8 -8
- data/lib/{shopify-cli → shopify_cli}/tasks/update_dashboard_urls.rb +6 -6
- data/lib/{shopify-cli → shopify_cli}/tasks.rb +10 -10
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/certificate_manager.rb +5 -5
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/header_hash.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot-reload.js +0 -0
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/hot_reload.rb +5 -6
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/local_assets.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/proxy.rb +2 -2
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/sse.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/watcher.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server/web_server.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/dev_server.rb +3 -3
- data/lib/shopify_cli/theme/development_theme.rb +83 -0
- data/lib/{shopify-cli → shopify_cli}/theme/file.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/ignore_filter.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/mime_type.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/syncer.rb +6 -6
- data/lib/{shopify-cli → shopify_cli}/theme/theme.rb +4 -4
- data/lib/{shopify-cli → shopify_cli}/transform_data_structure.rb +4 -4
- data/lib/{shopify-cli → shopify_cli}/tunnel.rb +14 -14
- data/lib/shopify_cli/version.rb +3 -0
- data/lib/shopify_cli.rb +61 -50
- data/shopify-cli.gemspec +13 -5
- data/utilities/docker.rb +47 -0
- data/utilities/utilities.rb +5 -0
- metadata +155 -97
- data/.github/workflows/build.yml +0 -28
- data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +0 -73
- data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +0 -60
- data/lib/shopify-cli/commands/logout.rb +0 -39
- data/lib/shopify-cli/commands/populate.rb +0 -23
- data/lib/shopify-cli/commands/store.rb +0 -15
- data/lib/shopify-cli/commands/version.rb +0 -15
- data/lib/shopify-cli/commands.rb +0 -34
- data/lib/shopify-cli/core.rb +0 -8
- data/lib/shopify-cli/helpers.rb +0 -5
- data/lib/shopify-cli/resources.rb +0 -5
- data/lib/shopify-cli/tasks/ensure_authenticated.rb +0 -13
- data/lib/shopify-cli/theme/development_theme.rb +0 -69
- data/lib/shopify-cli/version.rb +0 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
module Messages
|
|
5
5
|
MESSAGES = {
|
|
6
6
|
apps: {
|
|
@@ -14,6 +14,25 @@ module ShopifyCli
|
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
core: {
|
|
17
|
+
error_reporting: {
|
|
18
|
+
unhandled_error: {
|
|
19
|
+
message: "{{x}} {{red:An unexpected error occured.}}",
|
|
20
|
+
issue_message: "{{red:\tTo \e]8;;#{ShopifyCLI::Constants::Links::NEW_ISSUE}\e\\submit an issue\e]8;;\e\\"\
|
|
21
|
+
" include the stack trace.}}",
|
|
22
|
+
stacktrace_message: "{{red:\tTo print the stack trace, add the environment variable %s.}}",
|
|
23
|
+
},
|
|
24
|
+
enable_automatic_reporting_prompt: {
|
|
25
|
+
question: "Automatically send error reports moving forward?",
|
|
26
|
+
yes: "Automatically send error reports to the Shopify team",
|
|
27
|
+
no: "Don't send error reports",
|
|
28
|
+
enabled: "Anonymized error reports will be sent to Shopify.",
|
|
29
|
+
},
|
|
30
|
+
report_error: {
|
|
31
|
+
question: "Send an error report to Shopify?",
|
|
32
|
+
yes: "Send report",
|
|
33
|
+
no: "Don't send",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
17
36
|
connect: {
|
|
18
37
|
already_connected_warning: "{{yellow:! This app appears to be already connected}}",
|
|
19
38
|
project_type_select: "What type of project would you like to connect?",
|
|
@@ -67,10 +86,18 @@ module ShopifyCli
|
|
|
67
86
|
repo_not_initiated:
|
|
68
87
|
"Git repo is not initiated. Please run {{command:git init}} and make at least one commit.",
|
|
69
88
|
no_commits_made: "No git commits have been made. Please make at least one commit.",
|
|
89
|
+
remote_not_added: "Remote could not be added.",
|
|
90
|
+
sparse_checkout_not_enabled: "Sparse checkout could not be enabled.",
|
|
91
|
+
sparse_checkout_not_set: "Sparse checkout set command failed.",
|
|
92
|
+
pull_failed: "Pull failed.",
|
|
93
|
+
pull_failed_bad_branch: "Pull failed. Branch %s cannot be found. Check the branch name and try again.",
|
|
70
94
|
},
|
|
71
95
|
|
|
72
96
|
cloning: "Cloning %s into %s…",
|
|
73
97
|
cloned: "{{v}} Cloned into %s",
|
|
98
|
+
pulling_from_to: "Pulling %s into %s…",
|
|
99
|
+
pulling: "Pulling…",
|
|
100
|
+
pulled: "Pulled into %s",
|
|
74
101
|
},
|
|
75
102
|
|
|
76
103
|
help: {
|
|
@@ -92,6 +119,8 @@ module ShopifyCli
|
|
|
92
119
|
download: "Heroku CLI could not be downloaded",
|
|
93
120
|
install: "Could not install Heroku CLI",
|
|
94
121
|
could_not_select_app: "Heroku app {{green:%s}} could not be selected",
|
|
122
|
+
set_config: "Failed to set config %s to %s in Heroku app",
|
|
123
|
+
add_buildpacks: "Failed to add buildpacks in Heroku app",
|
|
95
124
|
},
|
|
96
125
|
},
|
|
97
126
|
|
|
@@ -188,6 +217,20 @@ module ShopifyCli
|
|
|
188
217
|
},
|
|
189
218
|
},
|
|
190
219
|
|
|
220
|
+
php_deps: {
|
|
221
|
+
error: {
|
|
222
|
+
missing_package: "Expected to have a file at: %s",
|
|
223
|
+
invalid_package: "{{info:%s}} was not valid JSON. Fix this then try again",
|
|
224
|
+
install: "Failed to install %s packages",
|
|
225
|
+
install_spinner_error: "Unable to install all %d dependencies",
|
|
226
|
+
install_error: "An error occurred while installing dependencies",
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
installing: "Installing Composer dependencies…",
|
|
230
|
+
installed: "Dependencies installed",
|
|
231
|
+
installed_count: "%d dependencies installed",
|
|
232
|
+
},
|
|
233
|
+
|
|
191
234
|
api: {
|
|
192
235
|
error: {
|
|
193
236
|
failed_auth: "Failed to authenticate with Shopify. Please try again later.",
|
|
@@ -413,7 +456,6 @@ module ShopifyCli
|
|
|
413
456
|
ngrok: "Something went wrong with ngrok installation,"\
|
|
414
457
|
"please make sure %s exists within %s before trying again",
|
|
415
458
|
},
|
|
416
|
-
|
|
417
459
|
installing: "Installing ngrok…",
|
|
418
460
|
not_running: "{{green:x}} ngrok tunnel not running",
|
|
419
461
|
prereq_command_location: "%s @ %s",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
module
|
|
1
|
+
module ShopifyCLI
|
|
2
2
|
##
|
|
3
3
|
# The `MethodObject` mixin can be included in any class that implements `call`
|
|
4
4
|
# to ensure that
|
|
5
5
|
#
|
|
6
|
-
# * `call` will always return a `
|
|
6
|
+
# * `call` will always return a `ShopifyCLI::Result` by prepending a module
|
|
7
7
|
# that takes care of the result wrapping and
|
|
8
8
|
# * a `to_proc` method that allows instances of this class to be passed as a
|
|
9
9
|
# block.
|
|
@@ -42,18 +42,20 @@ module ShopifyCli
|
|
|
42
42
|
# constructed using the `&` operator,
|
|
43
43
|
# * error handling is deferred until the result is unwrapped.
|
|
44
44
|
#
|
|
45
|
-
# Please see the section for `
|
|
46
|
-
# `
|
|
45
|
+
# Please see the section for `ShopifyCLI::Result`,
|
|
46
|
+
# `ShopifyCLI::Result::Success`, and `ShopifyCLI::Result::Failure` for more
|
|
47
47
|
# information on the API of result objects.
|
|
48
48
|
#
|
|
49
49
|
module MethodObject
|
|
50
50
|
module AutoCreateResultObject
|
|
51
|
+
def self.ruby2_keywords(*); end unless respond_to?(:ruby2_keywords, true)
|
|
52
|
+
|
|
51
53
|
##
|
|
52
54
|
# invokes the original `call` implementation and wraps its return value
|
|
53
55
|
# into a result object.
|
|
54
56
|
#
|
|
55
|
-
def call(*args,
|
|
56
|
-
Result.wrap {
|
|
57
|
+
ruby2_keywords def call(*args, &block)
|
|
58
|
+
Result.wrap { super(*args, &block) }.call
|
|
57
59
|
end
|
|
58
60
|
end
|
|
59
61
|
|
|
@@ -66,8 +68,13 @@ module ShopifyCli
|
|
|
66
68
|
#
|
|
67
69
|
def call(*args, **kwargs, &block)
|
|
68
70
|
properties.keys.yield_self do |properties|
|
|
69
|
-
new(**kwargs.slice(*properties))
|
|
70
|
-
|
|
71
|
+
instance = new(**kwargs.slice(*properties))
|
|
72
|
+
kwargs = kwargs.slice(*(kwargs.keys - properties))
|
|
73
|
+
if kwargs.any?
|
|
74
|
+
instance.call(*args, **kwargs, &block)
|
|
75
|
+
else
|
|
76
|
+
instance.call(*args, &block)
|
|
77
|
+
end
|
|
71
78
|
end
|
|
72
79
|
end
|
|
73
80
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "date"
|
|
3
|
+
|
|
4
|
+
module ShopifyCLI
|
|
5
|
+
module Migrator
|
|
6
|
+
class Migration
|
|
7
|
+
attr_reader :name, :path, :date
|
|
8
|
+
|
|
9
|
+
def initialize(name:, path:, date:)
|
|
10
|
+
@name = name
|
|
11
|
+
@path = path
|
|
12
|
+
@date = date
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run
|
|
16
|
+
require(path)
|
|
17
|
+
ShopifyCli::Migrator::Migrations.const_get(class_name).run
|
|
18
|
+
rescue StandardError
|
|
19
|
+
# Continue
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def class_name
|
|
23
|
+
name.split("_").collect(&:capitalize).join
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "date"
|
|
3
|
+
|
|
4
|
+
module ShopifyCLI
|
|
5
|
+
module Migrator
|
|
6
|
+
autoload :Migration, "shopify_cli/migrator/migration"
|
|
7
|
+
|
|
8
|
+
def self.migrate(
|
|
9
|
+
migrations_directory: File.expand_path("migrator/migrations", __dir__)
|
|
10
|
+
)
|
|
11
|
+
baseline_date = last_migration_date
|
|
12
|
+
unless baseline_date.nil?
|
|
13
|
+
migrations = migrations(migrations_directory: migrations_directory)
|
|
14
|
+
.select { |m|
|
|
15
|
+
m.date > baseline_date.to_i
|
|
16
|
+
}
|
|
17
|
+
.each { |m| m.run }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
store_last_migration_date
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def self.store_last_migration_date
|
|
26
|
+
ShopifyCLI::DB.set(ShopifyCLI::Constants::StoreKeys::LAST_MIGRATION_DATE => Time.now.to_i)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.last_migration_date
|
|
30
|
+
ShopifyCLI::DB.get(ShopifyCLI::Constants::StoreKeys::LAST_MIGRATION_DATE)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.migrations(migrations_directory:)
|
|
34
|
+
Dir.glob(File.join(migrations_directory, "*.rb")).map do |file_path|
|
|
35
|
+
file_name = File.basename(file_path).gsub(".rb", "")
|
|
36
|
+
file_name_components = file_name.split("_")
|
|
37
|
+
date_timestamp = file_name_components[0].to_i
|
|
38
|
+
migration_name = file_name_components[1...].join("_")
|
|
39
|
+
|
|
40
|
+
Migrator::Migration.new(
|
|
41
|
+
name: migration_name,
|
|
42
|
+
date: Time.at(date_timestamp).to_i,
|
|
43
|
+
path: file_path
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
module
|
|
1
|
+
module ShopifyCLI
|
|
2
2
|
class Packager
|
|
3
|
-
PACKAGING_DIR = File.join(
|
|
4
|
-
BUILDS_DIR = File.join(PACKAGING_DIR, "builds",
|
|
3
|
+
PACKAGING_DIR = File.join(ShopifyCLI::ROOT, "packaging")
|
|
4
|
+
BUILDS_DIR = File.join(PACKAGING_DIR, "builds", ShopifyCLI::VERSION)
|
|
5
5
|
|
|
6
6
|
def initialize
|
|
7
7
|
FileUtils.mkdir_p(BUILDS_DIR)
|
|
@@ -24,7 +24,7 @@ module ShopifyCli
|
|
|
24
24
|
file_path = File.join(debian_dir, file)
|
|
25
25
|
|
|
26
26
|
file_contents = File.read(File.join(root_dir, "#{file}.base"))
|
|
27
|
-
file_contents = file_contents.gsub("SHOPIFY_CLI_VERSION",
|
|
27
|
+
file_contents = file_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCLI::VERSION)
|
|
28
28
|
File.open(file_path, "w", 0775) { |f| f.write(file_contents) }
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ module ShopifyCli
|
|
|
33
33
|
raise "Failed to build package" unless system("dpkg-deb", "-b", "shopify-cli")
|
|
34
34
|
|
|
35
35
|
output_path = File.join(root_dir, "shopify-cli.deb")
|
|
36
|
-
final_path = File.join(BUILDS_DIR, "shopify-cli-#{
|
|
36
|
+
final_path = File.join(BUILDS_DIR, "shopify-cli-#{ShopifyCLI::VERSION}.deb")
|
|
37
37
|
|
|
38
38
|
puts "Moving generated package: \n From: #{output_path}\n To: #{final_path}\n\n"
|
|
39
39
|
FileUtils.mv(output_path, final_path)
|
|
@@ -53,7 +53,7 @@ module ShopifyCli
|
|
|
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
|
-
spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION",
|
|
56
|
+
spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCLI::VERSION)
|
|
57
57
|
File.write(spec_path, spec_contents)
|
|
58
58
|
|
|
59
59
|
puts "Building package…"
|
|
@@ -76,12 +76,12 @@ module ShopifyCli
|
|
|
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"))
|
|
79
|
-
spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION",
|
|
79
|
+
spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCLI::VERSION)
|
|
80
80
|
|
|
81
81
|
puts "Grabbing sha256 checksum from Rubygems.org"
|
|
82
82
|
require "digest/sha2"
|
|
83
83
|
require "open-uri"
|
|
84
|
-
gem_checksum = open("https://rubygems.org/downloads/shopify-cli-#{
|
|
84
|
+
gem_checksum = open("https://rubygems.org/downloads/shopify-cli-#{ShopifyCLI::VERSION}.gem") do |io|
|
|
85
85
|
Digest::SHA256.new.hexdigest(io.read)
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
require "shopify_cli"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
##
|
|
5
|
-
#
|
|
5
|
+
# ShopifyCLI::PartnersAPI provides easy access to the partners dashboard CLI
|
|
6
6
|
# schema.
|
|
7
7
|
#
|
|
8
8
|
class PartnersAPI < API
|
|
9
|
-
autoload :Organizations, "
|
|
10
|
-
|
|
11
|
-
# Defines the environment variable that this API looks for to operate on local
|
|
12
|
-
# services. If you set this environment variable in your shell then the partners
|
|
13
|
-
# API will operate on your local instance
|
|
14
|
-
#
|
|
15
|
-
# #### Example
|
|
16
|
-
#
|
|
17
|
-
# SHOPIFY_APP_CLI_LOCAL_PARTNERS=1 shopify create
|
|
18
|
-
#
|
|
19
|
-
LOCAL_DEBUG = "SHOPIFY_APP_CLI_LOCAL_PARTNERS"
|
|
9
|
+
autoload :Organizations, "shopify_cli/partners_api/organizations"
|
|
20
10
|
|
|
21
11
|
class << self
|
|
22
12
|
##
|
|
@@ -31,10 +21,10 @@ module ShopifyCli
|
|
|
31
21
|
#
|
|
32
22
|
# #### Raises
|
|
33
23
|
#
|
|
34
|
-
# * http 404 will raise a
|
|
35
|
-
# * http 400..499 will raise a
|
|
36
|
-
# * http 500..599 will raise a
|
|
37
|
-
# * All other codes will raise
|
|
24
|
+
# * http 404 will raise a ShopifyCLI::API::APIRequestNotFoundError
|
|
25
|
+
# * http 400..499 will raise a ShopifyCLI::API::APIRequestClientError
|
|
26
|
+
# * http 500..599 will raise a ShopifyCLI::API::APIRequestServerError
|
|
27
|
+
# * All other codes will raise ShopifyCLI::API::APIRequestUnexpectedError
|
|
38
28
|
#
|
|
39
29
|
# #### Returns
|
|
40
30
|
#
|
|
@@ -42,13 +32,13 @@ module ShopifyCli
|
|
|
42
32
|
#
|
|
43
33
|
# #### Example
|
|
44
34
|
#
|
|
45
|
-
#
|
|
35
|
+
# ShopifyCLI::PartnersAPI.query(@ctx, 'all_organizations')
|
|
46
36
|
#
|
|
47
37
|
def query(ctx, query_name, **variables)
|
|
48
38
|
CLI::Kit::Util.begin do
|
|
49
39
|
api_client(ctx).query(query_name, variables: variables)
|
|
50
40
|
end.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
|
51
|
-
|
|
41
|
+
ShopifyCLI::IdentityAuth.new(ctx: ctx).reauthenticate
|
|
52
42
|
end
|
|
53
43
|
rescue API::APIRequestUnauthorizedError => e
|
|
54
44
|
if (request_info = auth_failure_info(ctx, e))
|
|
@@ -56,14 +46,14 @@ module ShopifyCli
|
|
|
56
46
|
end
|
|
57
47
|
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
|
58
48
|
rescue API::APIRequestNotFoundError
|
|
59
|
-
ctx.puts(ctx.message("core.partners_api.error.account_not_found",
|
|
49
|
+
ctx.puts(ctx.message("core.partners_api.error.account_not_found", ShopifyCLI::TOOL_NAME))
|
|
60
50
|
end
|
|
61
51
|
|
|
62
|
-
def partners_url_for(organization_id, api_client_id
|
|
63
|
-
if
|
|
52
|
+
def partners_url_for(organization_id, api_client_id)
|
|
53
|
+
if ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
|
64
54
|
organization_id = "internal"
|
|
65
55
|
end
|
|
66
|
-
"
|
|
56
|
+
"https://#{Environment.partners_domain}/#{organization_id}/apps/#{api_client_id}"
|
|
67
57
|
end
|
|
68
58
|
|
|
69
59
|
private
|
|
@@ -72,29 +62,15 @@ module ShopifyCli
|
|
|
72
62
|
new(
|
|
73
63
|
ctx: ctx,
|
|
74
64
|
token: access_token(ctx),
|
|
75
|
-
url: "
|
|
65
|
+
url: "https://#{Environment.partners_domain}/api/cli/graphql",
|
|
76
66
|
)
|
|
77
67
|
end
|
|
78
68
|
|
|
79
69
|
def access_token(ctx)
|
|
80
|
-
|
|
70
|
+
ShopifyCLI::DB.get(:partners_exchange_token) do
|
|
81
71
|
IdentityAuth.new(ctx: ctx).authenticate
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def endpoint
|
|
87
|
-
return "https://partners.shopify.com" if ENV[LOCAL_DEBUG].nil?
|
|
88
|
-
"https://partners.myshopify.io/"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def partners_endpoint(local_debug)
|
|
92
|
-
domain = if local_debug
|
|
93
|
-
"partners.myshopify.io"
|
|
94
|
-
else
|
|
95
|
-
"partners.shopify.com"
|
|
72
|
+
ShopifyCLI::DB.get(:partners_exchange_token)
|
|
96
73
|
end
|
|
97
|
-
"https://#{domain}"
|
|
98
74
|
end
|
|
99
75
|
|
|
100
76
|
def auth_failure_info(ctx, error)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require "shopify_cli"
|
|
2
|
+
|
|
3
|
+
module ShopifyCLI
|
|
4
|
+
##
|
|
5
|
+
# ShopifyCLI::PHPDeps ensures that all PHP dependencies are installed for projects.
|
|
6
|
+
#
|
|
7
|
+
class PHPDeps
|
|
8
|
+
include SmartProperties
|
|
9
|
+
|
|
10
|
+
property! :ctx, accepts: ShopifyCLI::Context
|
|
11
|
+
|
|
12
|
+
##
|
|
13
|
+
# Proxy to instance method ShopifyCLI::PHPDeps.new.install.
|
|
14
|
+
#
|
|
15
|
+
# #### Parameters
|
|
16
|
+
# - `ctx`: running context from your command
|
|
17
|
+
# - `verbose`: whether to run the installation tools in verbose mode
|
|
18
|
+
#
|
|
19
|
+
# #### Example
|
|
20
|
+
#
|
|
21
|
+
# ShopifyCLI::PHPDeps.install(ctx)
|
|
22
|
+
#
|
|
23
|
+
def self.install(ctx, verbose = false)
|
|
24
|
+
new(ctx: ctx).install(verbose)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
##
|
|
28
|
+
# Installs all of a project's PHP dependencies using Composer.
|
|
29
|
+
#
|
|
30
|
+
# #### Parameters
|
|
31
|
+
# - `verbose`: whether to run the installation tools in verbose mode
|
|
32
|
+
#
|
|
33
|
+
# #### Example
|
|
34
|
+
#
|
|
35
|
+
# # context is the running context for the command
|
|
36
|
+
# ShopifyCLI::PHPDeps.new(context).install(true)
|
|
37
|
+
#
|
|
38
|
+
def install(verbose = false)
|
|
39
|
+
title = ctx.message("core.php_deps.installing")
|
|
40
|
+
success = ctx.message("core.php_deps.installed")
|
|
41
|
+
failure = ctx.message("core.php_deps.error.install_error")
|
|
42
|
+
|
|
43
|
+
CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
|
|
44
|
+
composer(verbose)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def composer(verbose = false)
|
|
51
|
+
cmd = %w(composer install)
|
|
52
|
+
cmd << "--quiet" unless verbose
|
|
53
|
+
|
|
54
|
+
run_install_command(cmd)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def run_install_command(cmd)
|
|
58
|
+
deps = parse_dependencies
|
|
59
|
+
errors = nil
|
|
60
|
+
|
|
61
|
+
spinner_title = ctx.message("core.php_deps.installing")
|
|
62
|
+
success = CLI::UI::Spinner.spin(spinner_title, auto_debrief: false) do |spinner|
|
|
63
|
+
_out, errors, status = CLI::Kit::System.capture3(*cmd, env: @ctx.env, chdir: ctx.root)
|
|
64
|
+
update_spinner_title_and_status(spinner, status, deps)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
errors.lines.each { |e| ctx.puts e } unless success || errors.nil?
|
|
68
|
+
|
|
69
|
+
ctx.abort(ctx.message("core.php_deps.error.install", "Composer")) unless success
|
|
70
|
+
success
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def update_spinner_title_and_status(spinner, status, deps)
|
|
74
|
+
if status.success?
|
|
75
|
+
spinner.update_title(ctx.message("core.php_deps.installed_count", deps.size))
|
|
76
|
+
else
|
|
77
|
+
spinner.update_title(ctx.message("core.php_deps.error.install_spinner_error", deps.size))
|
|
78
|
+
CLI::UI::Spinner::TASK_FAILED
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def parse_dependencies
|
|
83
|
+
composer_json = File.join(ctx.root, "composer.json")
|
|
84
|
+
pkg =
|
|
85
|
+
begin
|
|
86
|
+
JSON.parse(File.read(composer_json))
|
|
87
|
+
rescue Errno::ENOENT, Errno::ENOTDIR
|
|
88
|
+
ctx.abort(ctx.message("core.php_deps.error.missing_package", composer_json))
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
%w(require require-dev).map do |key|
|
|
92
|
+
pkg.fetch(key, []).keys
|
|
93
|
+
end.flatten
|
|
94
|
+
rescue JSON::ParserError
|
|
95
|
+
ctx.puts(
|
|
96
|
+
ctx.message("core.php_deps.error.invalid_package", File.read(File.join(path, "composer.json"))),
|
|
97
|
+
error: true
|
|
98
|
+
)
|
|
99
|
+
raise ShopifyCLI::AbortSilent
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "fileutils"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
##
|
|
5
5
|
# ProcessSupervision wraps a running process spawned by `exec` and keeps track
|
|
6
6
|
# if its `pid` and keeps a log file for it as well
|
|
@@ -19,7 +19,7 @@ module ShopifyCli
|
|
|
19
19
|
class << self
|
|
20
20
|
def run_dir
|
|
21
21
|
# is the directory where the pid and logfile are kept
|
|
22
|
-
File.join(
|
|
22
|
+
File.join(ShopifyCLI.cache_dir, "sv")
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
##
|
|
@@ -36,7 +36,7 @@ module ShopifyCli
|
|
|
36
36
|
# will be nil if the process is not running.
|
|
37
37
|
#
|
|
38
38
|
def for_ident(identifier)
|
|
39
|
-
pid, time = File.read(File.join(
|
|
39
|
+
pid, time = File.read(File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.pid")).split(":")
|
|
40
40
|
new(identifier, pid: Integer(pid), time: time)
|
|
41
41
|
rescue Errno::ENOENT
|
|
42
42
|
nil
|
|
@@ -50,19 +50,21 @@ module ShopifyCli
|
|
|
50
50
|
#
|
|
51
51
|
# * `identifier` - a string or symbol to identify the new process by.
|
|
52
52
|
# * `args` - a command to run, either a string or array of strings
|
|
53
|
+
# * `force_spawn` - whether we want the child process to be a spawn and not a fork, so it is terminated along with
|
|
54
|
+
# the parent
|
|
53
55
|
#
|
|
54
56
|
# #### Returns
|
|
55
57
|
#
|
|
56
58
|
# * `process` - ProcessSupervision instance if the process is running, this
|
|
57
59
|
# will be nil if the process did not start.
|
|
58
60
|
#
|
|
59
|
-
def start(identifier, args)
|
|
61
|
+
def start(identifier, args, force_spawn: false)
|
|
60
62
|
return for_ident(identifier) if running?(identifier)
|
|
61
63
|
|
|
62
64
|
# Some systems don't support forking process without extra gems, so we resort to spawning a new child process -
|
|
63
65
|
# that means that it dies along with the original process if it is interrupted. If possible, we fork the process
|
|
64
66
|
# so that it doesn't have to be restarted on every run.
|
|
65
|
-
if Process.respond_to?(:fork)
|
|
67
|
+
if Process.respond_to?(:fork) && !force_spawn
|
|
66
68
|
fork do
|
|
67
69
|
pid_file = new(identifier, pid: Process.pid)
|
|
68
70
|
pid_file.write
|
|
@@ -132,9 +134,9 @@ module ShopifyCli
|
|
|
132
134
|
@identifier = identifier
|
|
133
135
|
@pid = pid
|
|
134
136
|
@time = time
|
|
135
|
-
FileUtils.mkdir_p(
|
|
136
|
-
@pid_path = File.join(
|
|
137
|
-
@log_path = File.join(
|
|
137
|
+
FileUtils.mkdir_p(ShopifyCLI::ProcessSupervision.run_dir)
|
|
138
|
+
@pid_path = File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.pid")
|
|
139
|
+
@log_path = File.join(ShopifyCLI::ProcessSupervision.run_dir, "#{identifier}.log")
|
|
138
140
|
end
|
|
139
141
|
|
|
140
142
|
##
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
require "shopify_cli"
|
|
3
3
|
|
|
4
|
-
module
|
|
4
|
+
module ShopifyCLI
|
|
5
5
|
##
|
|
6
|
-
#
|
|
6
|
+
# ShopifyCLI::Project captures the current project that the user is working on.
|
|
7
7
|
# This class can be used to fetch and save project environment as well as the
|
|
8
8
|
# project config `.shopify-cli.yml`.
|
|
9
9
|
#
|
|
@@ -25,13 +25,13 @@ module ShopifyCli
|
|
|
25
25
|
#
|
|
26
26
|
# #### Raises
|
|
27
27
|
#
|
|
28
|
-
# * `
|
|
28
|
+
# * `ShopifyCLI::Abort` - If the cli is not currently in a project directory
|
|
29
29
|
# then this will be raised with a message implying that the user is not in
|
|
30
30
|
# a project directory.
|
|
31
31
|
#
|
|
32
32
|
# #### Example
|
|
33
33
|
#
|
|
34
|
-
# project =
|
|
34
|
+
# project = ShopifyCLI::Project.current
|
|
35
35
|
#
|
|
36
36
|
def current(force_reload: false)
|
|
37
37
|
clear if force_reload
|
|
@@ -60,7 +60,7 @@ module ShopifyCli
|
|
|
60
60
|
#
|
|
61
61
|
# #### Example
|
|
62
62
|
#
|
|
63
|
-
# type =
|
|
63
|
+
# type = ShopifyCLI::Project.current_project_type
|
|
64
64
|
#
|
|
65
65
|
def current_project_type
|
|
66
66
|
return unless has_current?
|
|
@@ -81,7 +81,7 @@ module ShopifyCli
|
|
|
81
81
|
#
|
|
82
82
|
# #### Example
|
|
83
83
|
#
|
|
84
|
-
# type =
|
|
84
|
+
# type = ShopifyCLI::Project.current_project_type
|
|
85
85
|
#
|
|
86
86
|
def write(ctx, project_type:, organization_id:, **identifiers)
|
|
87
87
|
require "yaml" # takes 20ms, so deferred as late as possible.
|
|
@@ -113,7 +113,7 @@ module ShopifyCli
|
|
|
113
113
|
def at(dir)
|
|
114
114
|
proj_dir = directory(dir)
|
|
115
115
|
unless proj_dir
|
|
116
|
-
raise(
|
|
116
|
+
raise(ShopifyCLI::Abort, Context.message("core.project.error.not_in_project"))
|
|
117
117
|
end
|
|
118
118
|
@at ||= Hash.new { |h, k| h[k] = new(directory: k) }
|
|
119
119
|
@at[proj_dir]
|
|
@@ -136,11 +136,11 @@ module ShopifyCli
|
|
|
136
136
|
#
|
|
137
137
|
# #### Returns
|
|
138
138
|
#
|
|
139
|
-
# * `env` - An instance of a
|
|
139
|
+
# * `env` - An instance of a ShopifyCLI::Resources::EnvFile
|
|
140
140
|
#
|
|
141
141
|
# #### Example
|
|
142
142
|
#
|
|
143
|
-
#
|
|
143
|
+
# ShopifyCLI::Project.current.env
|
|
144
144
|
#
|
|
145
145
|
def env
|
|
146
146
|
@env ||= begin
|
|
@@ -159,18 +159,18 @@ module ShopifyCli
|
|
|
159
159
|
#
|
|
160
160
|
# #### Raises
|
|
161
161
|
#
|
|
162
|
-
# * `
|
|
163
|
-
# * `
|
|
162
|
+
# * `ShopifyCLI::Abort` - If the yml is invalid or poorly formatted
|
|
163
|
+
# * `ShopifyCLI::Abort` - If the yml file does not exist
|
|
164
164
|
#
|
|
165
165
|
# #### Example
|
|
166
166
|
#
|
|
167
|
-
#
|
|
167
|
+
# ShopifyCLI::Project.current.config
|
|
168
168
|
#
|
|
169
169
|
def config
|
|
170
170
|
@config ||= begin
|
|
171
171
|
config = load_yaml_file(".shopify-cli.yml")
|
|
172
172
|
unless config.is_a?(Hash)
|
|
173
|
-
raise
|
|
173
|
+
raise ShopifyCLI::Abort, Context.message("core.yaml.error.not_hash", ".shopify-cli.yml")
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
# The app_type key was deprecated in favour of project_type, so replace it
|
|
@@ -191,12 +191,12 @@ module ShopifyCli
|
|
|
191
191
|
begin
|
|
192
192
|
YAML.load_file(f)
|
|
193
193
|
rescue Psych::SyntaxError => e
|
|
194
|
-
raise(
|
|
194
|
+
raise(ShopifyCLI::Abort, Context.message("core.yaml.error.invalid", relative_path, e.message))
|
|
195
195
|
# rescue Errno::EACCES => e
|
|
196
196
|
# TODO
|
|
197
197
|
# Dev::Helpers::EaccesHandler.diagnose_and_raise(f, e, mode: :read)
|
|
198
198
|
rescue Errno::ENOENT
|
|
199
|
-
raise
|
|
199
|
+
raise ShopifyCLI::Abort, Context.message("core.yaml.error.not_found", f)
|
|
200
200
|
end
|
|
201
201
|
end
|
|
202
202
|
end
|