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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module ShopifyCLI
|
|
2
|
+
module ExceptionReporter
|
|
3
|
+
autoload :PermissionController, "shopify_cli/exception_reporter/permission_controller"
|
|
4
|
+
|
|
5
|
+
def self.report(error, _logs = nil, _api_key = nil, custom_metadata = {})
|
|
6
|
+
context = ShopifyCLI::Context.new
|
|
7
|
+
context.puts("\n")
|
|
8
|
+
context.puts(context.message("core.error_reporting.unhandled_error.message"))
|
|
9
|
+
context.puts(context.message("core.error_reporting.unhandled_error.issue_message"))
|
|
10
|
+
unless ShopifyCLI::Environment.print_stacktrace?
|
|
11
|
+
context.puts(context.message("core.error_reporting.unhandled_error.stacktrace_message",
|
|
12
|
+
"#{ShopifyCLI::Constants::EnvironmentVariables::STACKTRACE}=1"))
|
|
13
|
+
end
|
|
14
|
+
context.puts("\n")
|
|
15
|
+
|
|
16
|
+
return unless reportable_error?(error)
|
|
17
|
+
return unless report?
|
|
18
|
+
|
|
19
|
+
ENV["BUGSNAG_DISABLE_AUTOCONFIGURE"] = "1"
|
|
20
|
+
require "bugsnag"
|
|
21
|
+
|
|
22
|
+
Bugsnag.configure do |config|
|
|
23
|
+
config.logger.level = ::Logger::ERROR
|
|
24
|
+
config.api_key = ShopifyCLI::Constants::Bugsnag::API_KEY
|
|
25
|
+
config.app_type = "shopify"
|
|
26
|
+
config.project_root = File.expand_path("../../..", __FILE__)
|
|
27
|
+
config.app_version = ShopifyCLI::VERSION
|
|
28
|
+
config.auto_capture_sessions = false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
metadata = {}
|
|
32
|
+
metadata.merge!(custom_metadata)
|
|
33
|
+
# Bugsnag.notify(error, metadata)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.report?
|
|
37
|
+
# return false if ShopifyCLI::Environment.development?
|
|
38
|
+
return true if ExceptionReporter::PermissionController.automatic_reporting_prompted? &&
|
|
39
|
+
ExceptionReporter::PermissionController.can_report_automatically?
|
|
40
|
+
|
|
41
|
+
report_error = ExceptionReporter::PermissionController.report_error?
|
|
42
|
+
|
|
43
|
+
unless ExceptionReporter::PermissionController.automatic_reporting_prompted?
|
|
44
|
+
ExceptionReporter::PermissionController.can_report_automatically?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
report_error
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.reportable_error?(error)
|
|
51
|
+
is_abort = error.is_a?(ShopifyCLI::Abort) || error.is_a?(ShopifyCLI::AbortSilent)
|
|
52
|
+
!is_abort
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module
|
|
1
|
+
module ShopifyCLI
|
|
2
2
|
##
|
|
3
|
-
#
|
|
3
|
+
# ShopifyCLI::Feature contains the logic to hide and show features across the CLI
|
|
4
4
|
# These features can be either commands or project types currently.
|
|
5
5
|
#
|
|
6
6
|
# Feature flags will persist between runs so if the flag is enabled or disabled,
|
|
@@ -9,7 +9,7 @@ module ShopifyCli
|
|
|
9
9
|
SECTION = "features"
|
|
10
10
|
|
|
11
11
|
##
|
|
12
|
-
#
|
|
12
|
+
# ShopifyCLI::Feature::Set is included on commands and projects to allow you to hide
|
|
13
13
|
# and enable projects and commands based on feature flags.
|
|
14
14
|
module Set
|
|
15
15
|
##
|
|
@@ -21,9 +21,9 @@ module ShopifyCli
|
|
|
21
21
|
#
|
|
22
22
|
# #### Example
|
|
23
23
|
#
|
|
24
|
-
# module
|
|
24
|
+
# module ShopifyCLI
|
|
25
25
|
# module Commands
|
|
26
|
-
# class Config <
|
|
26
|
+
# class Config < ShopifyCLI::Command
|
|
27
27
|
# hidden_feature(feature_set: :basic)
|
|
28
28
|
# ....
|
|
29
29
|
#
|
|
@@ -41,7 +41,7 @@ module ShopifyCli
|
|
|
41
41
|
#
|
|
42
42
|
# #### Example
|
|
43
43
|
#
|
|
44
|
-
#
|
|
44
|
+
# ShopifyCLI::Commands::Config.hidden?
|
|
45
45
|
#
|
|
46
46
|
def hidden?
|
|
47
47
|
enabled = (@hidden_feature_set || []).any? do |feature|
|
|
@@ -84,11 +84,11 @@ module ShopifyCli
|
|
|
84
84
|
# * `is_enabled` - will be true if the feature has been enabled.
|
|
85
85
|
def enabled?(feature)
|
|
86
86
|
return false if feature.nil?
|
|
87
|
-
|
|
87
|
+
ShopifyCLI::Config.get_bool(SECTION, feature.to_s)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def set(feature, value)
|
|
91
|
-
|
|
91
|
+
ShopifyCLI::Config.set(SECTION, feature.to_s, value)
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "shopify_cli"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
class Form
|
|
5
5
|
class << self
|
|
6
6
|
def ask(ctx, args, flags)
|
|
@@ -12,7 +12,7 @@ module ShopifyCli
|
|
|
12
12
|
begin
|
|
13
13
|
form.ask
|
|
14
14
|
form
|
|
15
|
-
rescue
|
|
15
|
+
rescue ShopifyCLI::Abort => err
|
|
16
16
|
ctx.puts(err.message)
|
|
17
17
|
nil
|
|
18
18
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
module
|
|
1
|
+
module ShopifyCLI
|
|
2
2
|
##
|
|
3
|
-
#
|
|
3
|
+
# ShopifyCLI::Git wraps git functionality to make it easier to integrate will
|
|
4
4
|
# git.
|
|
5
5
|
class Git
|
|
6
6
|
class << self
|
|
@@ -18,7 +18,7 @@ module ShopifyCli
|
|
|
18
18
|
#
|
|
19
19
|
# #### Example
|
|
20
20
|
#
|
|
21
|
-
#
|
|
21
|
+
# ShopifyCLI::Git.sha
|
|
22
22
|
#
|
|
23
23
|
def sha(dir: Dir.pwd, ctx: Context.new)
|
|
24
24
|
rev_parse("HEAD", dir: dir, ctx: ctx)
|
|
@@ -40,7 +40,7 @@ module ShopifyCli
|
|
|
40
40
|
#
|
|
41
41
|
# #### Example
|
|
42
42
|
#
|
|
43
|
-
#
|
|
43
|
+
# ShopifyCLI::Git.clone('git@github.com:shopify/test.git', 'test-app')
|
|
44
44
|
#
|
|
45
45
|
def clone(repository, dest, ctx: Context.new)
|
|
46
46
|
if Dir.exist?(dest)
|
|
@@ -66,7 +66,7 @@ module ShopifyCli
|
|
|
66
66
|
#
|
|
67
67
|
# #### Example
|
|
68
68
|
#
|
|
69
|
-
# branches =
|
|
69
|
+
# branches = ShopifyCLI::Git.branches(@ctx)
|
|
70
70
|
#
|
|
71
71
|
def branches(ctx)
|
|
72
72
|
output, status = ctx.capture2e("git", "branch", "--list", "--format=%(refname:short)")
|
|
@@ -91,7 +91,7 @@ module ShopifyCli
|
|
|
91
91
|
#
|
|
92
92
|
# #### Example
|
|
93
93
|
#
|
|
94
|
-
#
|
|
94
|
+
# ShopifyCLI::Git.init(@ctx)
|
|
95
95
|
#
|
|
96
96
|
def init(ctx)
|
|
97
97
|
output, status = ctx.capture2e("git", "status")
|
|
@@ -105,11 +105,41 @@ module ShopifyCli
|
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
def sparse_checkout(repo, set, branch, ctx)
|
|
109
|
+
_, status = ctx.capture2e("git init")
|
|
110
|
+
unless status.success?
|
|
111
|
+
ctx.abort(ctx.message("core.git.error.repo_not_initiated"))
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
_, status = ctx.capture2e("git remote add -f origin #{repo}")
|
|
115
|
+
unless status.success?
|
|
116
|
+
ctx.abort(ctx.message("core.git.error.remote_not_added"))
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
_, status = ctx.capture2e("git config core.sparsecheckout true")
|
|
120
|
+
unless status.success?
|
|
121
|
+
ctx.abort(ctx.message("core.git.error.sparse_checkout_not_enabled"))
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
_, status = ctx.capture2e("git sparse-checkout set #{set}")
|
|
125
|
+
unless status.success?
|
|
126
|
+
ctx.abort(ctx.message("core.git.error.sparse_checkout_not_set"))
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
resp, status = ctx.capture2e("git pull origin #{branch}")
|
|
130
|
+
unless status.success?
|
|
131
|
+
if resp.include?("fatal: couldn't find remote ref")
|
|
132
|
+
ctx.abort(ctx.message("core.git.error.pull_failed_bad_branch", branch))
|
|
133
|
+
end
|
|
134
|
+
ctx.abort(ctx.message("core.git.error.pull_failed"))
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
108
138
|
private
|
|
109
139
|
|
|
110
140
|
def exec(*args, dir: Dir.pwd, default: nil, ctx: Context.new)
|
|
111
|
-
args = %w(git) + args
|
|
112
|
-
out, _, stat = ctx.capture3(*args
|
|
141
|
+
args = %w(git) + ["--git-dir", File.join(dir, ".git")] + args
|
|
142
|
+
out, _, stat = ctx.capture3(*args)
|
|
113
143
|
return default unless stat.success?
|
|
114
144
|
out.chomp
|
|
115
145
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module ShopifyCLI
|
|
2
2
|
class Heroku
|
|
3
3
|
DOWNLOAD_URLS = {
|
|
4
4
|
linux: "https://cli-assets.heroku.com/heroku-linux-x64.tar.gz",
|
|
@@ -36,7 +36,7 @@ module ShopifyCli
|
|
|
36
36
|
def download
|
|
37
37
|
return if installed?
|
|
38
38
|
|
|
39
|
-
result = @ctx.system("curl", "-o", download_path, DOWNLOAD_URLS[@ctx.os], chdir:
|
|
39
|
+
result = @ctx.system("curl", "-o", download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCLI.cache_dir)
|
|
40
40
|
@ctx.abort(@ctx.message("core.heroku.error.download")) unless result.success?
|
|
41
41
|
@ctx.abort(@ctx.message("core.heroku.error.download")) unless File.exist?(download_path)
|
|
42
42
|
end
|
|
@@ -47,7 +47,7 @@ module ShopifyCli
|
|
|
47
47
|
result = if @ctx.windows?
|
|
48
48
|
@ctx.system("\"#{download_path}\"")
|
|
49
49
|
else
|
|
50
|
-
@ctx.system("tar", "-xf", download_path, chdir:
|
|
50
|
+
@ctx.system("tar", "-xf", download_path, chdir: ShopifyCLI.cache_dir)
|
|
51
51
|
end
|
|
52
52
|
@ctx.abort(@ctx.message("core.heroku.error.install")) unless result.success?
|
|
53
53
|
|
|
@@ -67,23 +67,33 @@ module ShopifyCli
|
|
|
67
67
|
nil
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
def get_config(config)
|
|
71
|
+
output, status = @ctx.capture2e(heroku_command, "config:get", config.to_s)
|
|
72
|
+
return output.strip if status.success?
|
|
73
|
+
nil
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
def
|
|
77
|
-
|
|
76
|
+
def set_config(config, value)
|
|
77
|
+
result = @ctx.system(heroku_command, "config:set", "#{config}=#{value}")
|
|
78
|
+
|
|
79
|
+
msg = @ctx.message("core.heroku.error.set_config", config, value)
|
|
80
|
+
@ctx.abort(msg) unless result.success?
|
|
78
81
|
end
|
|
79
82
|
|
|
80
|
-
def
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
def add_buildpacks(buildpacks)
|
|
84
|
+
result = @ctx.system(heroku_command, "buildpacks:clear")
|
|
85
|
+
msg = @ctx.message("core.heroku.error.add_buildpacks")
|
|
86
|
+
@ctx.abort(msg) unless result.success?
|
|
87
|
+
|
|
88
|
+
buildpacks.each do |buildpack|
|
|
89
|
+
result = @ctx.system(heroku_command, "buildpacks:add", buildpack)
|
|
90
|
+
msg = @ctx.message("core.heroku.error.add_buildpacks")
|
|
91
|
+
@ctx.abort(msg) unless result.success?
|
|
92
|
+
end
|
|
83
93
|
end
|
|
84
94
|
|
|
85
95
|
def heroku_command
|
|
86
|
-
local_path = File.join(
|
|
96
|
+
local_path = File.join(ShopifyCLI.cache_dir, "heroku", "bin", "heroku").to_s
|
|
87
97
|
if File.exist?(local_path)
|
|
88
98
|
local_path
|
|
89
99
|
elsif @ctx.windows?
|
|
@@ -103,6 +113,21 @@ module ShopifyCli
|
|
|
103
113
|
end
|
|
104
114
|
end
|
|
105
115
|
|
|
116
|
+
private
|
|
117
|
+
|
|
118
|
+
def download_filename
|
|
119
|
+
URI.parse(DOWNLOAD_URLS[@ctx.os]).path.split("/").last
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def download_path
|
|
123
|
+
File.join(ShopifyCLI.cache_dir, download_filename)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def git_remote
|
|
127
|
+
output, status = @ctx.capture2e("git", "remote", "get-url", "heroku")
|
|
128
|
+
status.success? ? output : nil
|
|
129
|
+
end
|
|
130
|
+
|
|
106
131
|
def installed?
|
|
107
132
|
_output, status = @ctx.capture2e(heroku_command, "--version")
|
|
108
133
|
status.success?
|
|
@@ -8,16 +8,15 @@ require "shopify_cli"
|
|
|
8
8
|
require "uri"
|
|
9
9
|
require "webrick"
|
|
10
10
|
|
|
11
|
-
module
|
|
11
|
+
module ShopifyCLI
|
|
12
12
|
class IdentityAuth
|
|
13
13
|
include SmartProperties
|
|
14
14
|
|
|
15
|
-
autoload :Servlet, "
|
|
15
|
+
autoload :Servlet, "shopify_cli/identity_auth/servlet"
|
|
16
16
|
|
|
17
17
|
class Error < StandardError; end
|
|
18
18
|
class Timeout < StandardError; end
|
|
19
19
|
LocalRequest = Struct.new(:method, :path, :query, :protocol)
|
|
20
|
-
LOCAL_DEBUG = "SHOPIFY_APP_CLI_LOCAL_PARTNERS"
|
|
21
20
|
|
|
22
21
|
DEFAULT_PORT = 3456
|
|
23
22
|
REDIRECT_HOST = "http://127.0.0.1:#{DEFAULT_PORT}"
|
|
@@ -50,7 +49,7 @@ module ShopifyCli
|
|
|
50
49
|
]
|
|
51
50
|
|
|
52
51
|
property! :ctx
|
|
53
|
-
property :store, default: -> {
|
|
52
|
+
property :store, default: -> { ShopifyCLI::DB.new }
|
|
54
53
|
property :state_token, accepts: String, default: SecureRandom.hex(30)
|
|
55
54
|
property :code_verifier, accepts: String, default: SecureRandom.hex(30)
|
|
56
55
|
|
|
@@ -71,7 +70,7 @@ module ShopifyCli
|
|
|
71
70
|
|
|
72
71
|
def reauthenticate
|
|
73
72
|
return if refresh_exchange_tokens || refresh_access_tokens
|
|
74
|
-
ctx.abort(ctx.message("core.identity_auth.error.reauthenticate",
|
|
73
|
+
ctx.abort(ctx.message("core.identity_auth.error.reauthenticate", ShopifyCLI::TOOL_NAME))
|
|
75
74
|
end
|
|
76
75
|
|
|
77
76
|
def code_challenge
|
|
@@ -94,8 +93,8 @@ module ShopifyCli
|
|
|
94
93
|
end
|
|
95
94
|
|
|
96
95
|
def self.delete_tokens_and_keys
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
ShopifyCLI::DB.del(*IDENTITY_ACCESS_TOKENS)
|
|
97
|
+
ShopifyCLI::DB.del(*EXCHANGE_TOKENS)
|
|
99
98
|
end
|
|
100
99
|
|
|
101
100
|
private
|
|
@@ -213,7 +212,7 @@ module ShopifyCli
|
|
|
213
212
|
https = Net::HTTP.new(uri.host, uri.port)
|
|
214
213
|
https.use_ssl = true
|
|
215
214
|
request = Net::HTTP::Post.new(uri.path)
|
|
216
|
-
request["User-Agent"] = "Shopify CLI #{::
|
|
215
|
+
request["User-Agent"] = "Shopify CLI #{::ShopifyCLI::VERSION}"
|
|
217
216
|
request.body = URI.encode_www_form(params)
|
|
218
217
|
res = https.request(request)
|
|
219
218
|
unless res.is_a?(Net::HTTPSuccess)
|
|
@@ -236,12 +235,17 @@ module ShopifyCli
|
|
|
236
235
|
end
|
|
237
236
|
|
|
238
237
|
def auth_url
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
if Environment.use_local_partners_instance?
|
|
239
|
+
"https://identity.myshopify.io/oauth"
|
|
240
|
+
elsif Environment.use_spin_partners_instance?
|
|
241
|
+
"https://identity.#{Environment.spin_url}/oauth"
|
|
242
|
+
else
|
|
243
|
+
"https://accounts.shopify.com/oauth"
|
|
244
|
+
end
|
|
241
245
|
end
|
|
242
246
|
|
|
243
247
|
def client_id_for_application(application_name)
|
|
244
|
-
client_ids = if
|
|
248
|
+
client_ids = if Environment.use_local_partners_instance? || Environment.use_spin_partners_instance?
|
|
245
249
|
DEV_APPLICATION_CLIENT_IDS
|
|
246
250
|
else
|
|
247
251
|
APPLICATION_CLIENT_IDS
|
|
@@ -252,31 +256,20 @@ module ShopifyCli
|
|
|
252
256
|
|
|
253
257
|
def scopes(additional_scopes = [])
|
|
254
258
|
(["openid"] + additional_scopes).tap do |result|
|
|
255
|
-
result << "employee" if
|
|
259
|
+
result << "employee" if ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
|
256
260
|
end.join(" ")
|
|
257
261
|
end
|
|
258
262
|
|
|
259
263
|
def client_id
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
})
|
|
269
|
-
|
|
270
|
-
response["client_id"]
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
def local_identity_running?
|
|
274
|
-
Net::HTTP.start("identity.myshopify.io", 443, use_ssl: true, open_timeout: 1, read_timeout: 10) do |http|
|
|
275
|
-
req = Net::HTTP::Get.new(URI.join("https://identity.myshopify.io", "/services/ping"))
|
|
276
|
-
http.request(req).is_a?(Net::HTTPSuccess)
|
|
264
|
+
if Environment.use_local_partners_instance? || Environment.use_spin_partners_instance?
|
|
265
|
+
Constants::Identity::CLIENT_ID_DEV
|
|
266
|
+
else
|
|
267
|
+
# In the future we might want to use Identity's dynamic
|
|
268
|
+
# registration. To migrate to a dynamic client ID we
|
|
269
|
+
# need to refactor some code that relies on a static
|
|
270
|
+
# value for the client
|
|
271
|
+
Constants::Identity::CLIENT_ID
|
|
277
272
|
end
|
|
278
|
-
rescue Timeout::Error, Errno::EHOSTUNREACH, Errno::EHOSTDOWN, Errno::EADDRNOTAVAIL, Errno::ECONNREFUSED
|
|
279
|
-
false
|
|
280
273
|
end
|
|
281
274
|
end
|
|
282
275
|
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
require "shopify_cli"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
##
|
|
5
|
-
#
|
|
5
|
+
# ShopifyCLI::JsDeps ensures that all JavaScript dependencies are installed for projects.
|
|
6
6
|
#
|
|
7
7
|
class JsDeps
|
|
8
8
|
include SmartProperties
|
|
9
9
|
|
|
10
|
-
property! :ctx, accepts:
|
|
10
|
+
property! :ctx, accepts: ShopifyCLI::Context
|
|
11
11
|
property! :system, accepts: JsSystem, default: -> { JsSystem.new(ctx: ctx) }
|
|
12
12
|
|
|
13
13
|
##
|
|
14
|
-
# Proxy to instance method
|
|
14
|
+
# Proxy to instance method ShopifyCLI::JsDeps.new.install.
|
|
15
15
|
#
|
|
16
16
|
# #### Parameters
|
|
17
17
|
# - `ctx`: running context from your command
|
|
@@ -19,7 +19,7 @@ module ShopifyCli
|
|
|
19
19
|
#
|
|
20
20
|
# #### Example
|
|
21
21
|
#
|
|
22
|
-
#
|
|
22
|
+
# ShopifyCLI::JsDeps.install(ctx)
|
|
23
23
|
#
|
|
24
24
|
def self.install(ctx, verbose = false)
|
|
25
25
|
new(ctx: ctx).install(verbose)
|
|
@@ -34,7 +34,7 @@ module ShopifyCli
|
|
|
34
34
|
# #### Example
|
|
35
35
|
#
|
|
36
36
|
# # context is the running context for the command
|
|
37
|
-
#
|
|
37
|
+
# ShopifyCLI::JsDeps.new(context).install(true)
|
|
38
38
|
#
|
|
39
39
|
def install(verbose = false)
|
|
40
40
|
title = ctx.message("core.js_deps.installing", @system.package_manager)
|
|
@@ -104,7 +104,7 @@ module ShopifyCli
|
|
|
104
104
|
ctx.message("core.js_deps.error.invalid_package", File.read(File.join(path, "package.json"))),
|
|
105
105
|
error: true
|
|
106
106
|
)
|
|
107
|
-
raise
|
|
107
|
+
raise ShopifyCLI::AbortSilent
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require "shopify_cli"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
##
|
|
5
|
-
#
|
|
5
|
+
# ShopifyCLI::JsSystem allows conditional system calls of npm or yarn commands.
|
|
6
6
|
#
|
|
7
7
|
class JsSystem
|
|
8
8
|
include SmartProperties
|
|
@@ -12,21 +12,21 @@ module ShopifyCli
|
|
|
12
12
|
|
|
13
13
|
class << self
|
|
14
14
|
##
|
|
15
|
-
# Proxy to instance method `
|
|
15
|
+
# Proxy to instance method `ShopifyCLI::JsSystem.new.yarn?`
|
|
16
16
|
#
|
|
17
17
|
# #### Parameters
|
|
18
18
|
# - `ctx`: running context from your command
|
|
19
19
|
#
|
|
20
20
|
# #### Example
|
|
21
21
|
#
|
|
22
|
-
#
|
|
22
|
+
# ShopifyCLI::JsSystem.yarn?(ctx)
|
|
23
23
|
#
|
|
24
24
|
def yarn?(ctx)
|
|
25
25
|
JsSystem.new(ctx: ctx).yarn?
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
##
|
|
29
|
-
# Proxy to instance method `
|
|
29
|
+
# Proxy to instance method `ShopifyCLI::JsSystem.new.call`
|
|
30
30
|
#
|
|
31
31
|
# #### Parameters
|
|
32
32
|
# - `ctx`: running context from your command
|
|
@@ -35,21 +35,21 @@ module ShopifyCli
|
|
|
35
35
|
#
|
|
36
36
|
# #### Example
|
|
37
37
|
#
|
|
38
|
-
#
|
|
38
|
+
# ShopifyCLI::JsSystem.call(ctx, yarn: ['install', '--silent'], npm: ['install', '--no-audit'])
|
|
39
39
|
#
|
|
40
40
|
def call(ctx, yarn:, npm:, capture_response: false)
|
|
41
41
|
JsSystem.new(ctx: ctx).call(yarn: yarn, npm: npm, capture_response: capture_response)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
property :ctx, accepts:
|
|
45
|
+
property :ctx, accepts: ShopifyCLI::Context
|
|
46
46
|
|
|
47
47
|
##
|
|
48
48
|
# Returns the name of the JS package manager being used
|
|
49
49
|
#
|
|
50
50
|
# #### Example
|
|
51
51
|
#
|
|
52
|
-
#
|
|
52
|
+
# ShopifyCLI::JsSystem.new(ctx: ctx).package_manager
|
|
53
53
|
#
|
|
54
54
|
def package_manager
|
|
55
55
|
yarn? ? YARN_CORE_COMMAND : NPM_CORE_COMMAND
|
|
@@ -60,7 +60,7 @@ module ShopifyCli
|
|
|
60
60
|
#
|
|
61
61
|
# #### Example
|
|
62
62
|
#
|
|
63
|
-
#
|
|
63
|
+
# ShopifyCLI::JsSystem.new(ctx: ctx).yarn?
|
|
64
64
|
#
|
|
65
65
|
def yarn?
|
|
66
66
|
@has_yarn ||= begin
|
|
@@ -80,7 +80,7 @@ module ShopifyCli
|
|
|
80
80
|
#
|
|
81
81
|
# #### Example
|
|
82
82
|
#
|
|
83
|
-
#
|
|
83
|
+
# ShopifyCLI::JsSystem.new(ctx: ctx).call(
|
|
84
84
|
# yarn: ['install', '--silent'],
|
|
85
85
|
# npm: ['install', '--no-audit'],
|
|
86
86
|
# capture_response: false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "delegate"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
##
|
|
5
5
|
# `LazyDelegator` defers initialization of its underlying delegatee until the
|
|
6
6
|
# latter is accessed for the first time due to a method call that the
|
|
@@ -16,7 +16,7 @@ module ShopifyCli
|
|
|
16
16
|
# LazyDelegator lends itself to being subclassed in scenarios where some
|
|
17
17
|
# facts are known and others are costly to compute:
|
|
18
18
|
#
|
|
19
|
-
# class LazySpecificationHandler <
|
|
19
|
+
# class LazySpecificationHandler < ShopifyCLI::LazyDelegator
|
|
20
20
|
# attr_reader :identifier
|
|
21
21
|
#
|
|
22
22
|
# def initialize(identifier, &initializer)
|