shopify-cli 2.2.1 → 2.5.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 +1 -0
- data/.github/ISSUE_TEMPLATE.md +0 -4
- data/.github/workflows/shopify.yml +104 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +14 -14
- data/.rubocop_todo.yml +3 -3
- data/CHANGELOG.md +23 -0
- data/CONTRIBUTING.md +23 -0
- data/Dockerfile +19 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +50 -13
- data/RELEASING.md +1 -1
- data/Rakefile +84 -18
- data/bin/shopify +3 -3
- data/dev.yml +11 -1
- 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 +17 -3
- data/lib/project_types/extension/commands/build.rb +31 -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 +2 -2
- data/lib/project_types/extension/features/argo_config.rb +5 -5
- data/lib/project_types/extension/features/argo_serve.rb +20 -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 +74 -0
- data/lib/project_types/extension/models/development_server_requirements.rb +36 -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/checkout_ui_extension.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +10 -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/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 +3 -3
- 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/run_extension_command.rb +65 -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 +7 -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/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 +12 -3
- data/lib/project_types/script/commands/create.rb +2 -2
- data/lib/project_types/script/commands/push.rb +2 -2
- data/lib/project_types/script/forms/create.rb +1 -1
- data/lib/project_types/script/graphql/app_script_set.graphql +40 -0
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -44
- data/lib/project_types/script/graphql/module_upload_url_generate.graphql +9 -0
- data/lib/project_types/script/layers/application/extension_points.rb +2 -2
- data/lib/project_types/script/layers/application/push_script.rb +13 -1
- data/lib/project_types/script/layers/domain/push_package.rb +1 -14
- 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 +55 -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 +2 -0
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +1 -2
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +5 -5
- data/lib/project_types/script/layers/infrastructure/script_service.rb +28 -97
- 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 +3 -0
- data/lib/project_types/script/tasks/ensure_env.rb +7 -7
- data/lib/project_types/script/ui/error_handler.rb +79 -74
- 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 +15 -9
- data/lib/project_types/theme/commands/push.rb +18 -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 +8 -8
- 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 +26 -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 +3 -3
- 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 +60 -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 +8 -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 +17 -1
- data/lib/{shopify-cli → shopify_cli}/method_object.rb +4 -4
- 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 +23 -21
- 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 +5 -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 +15 -3
- 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 +12 -4
- data/lib/{shopify-cli → shopify_cli}/theme/ignore_filter.rb +8 -1
- data/lib/{shopify-cli → shopify_cli}/theme/mime_type.rb +1 -1
- data/lib/{shopify-cli → shopify_cli}/theme/syncer.rb +7 -7
- 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 +52 -49
- data/shopify-cli.gemspec +5 -5
- metadata +130 -95
- data/.github/workflows/build.yml +0 -28
- 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
@@ -3,7 +3,7 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
|
-
class CreateExtension <
|
6
|
+
class CreateExtension < ShopifyCLI::Task
|
7
7
|
include UserErrors
|
8
8
|
|
9
9
|
GRAPHQL_FILE = "extension_create"
|
@@ -20,7 +20,7 @@ module Extension
|
|
20
20
|
extension_context: extension_context,
|
21
21
|
}
|
22
22
|
|
23
|
-
response =
|
23
|
+
response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
24
24
|
context.abort(context.message("tasks.errors.parse_error")) if response.nil?
|
25
25
|
|
26
26
|
abort_if_user_errors(context, response)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Extension
|
2
2
|
module Tasks
|
3
3
|
class FetchSpecifications
|
4
|
-
include
|
4
|
+
include ShopifyCLI::MethodObject
|
5
5
|
|
6
6
|
property :context
|
7
7
|
property :api_key
|
8
8
|
|
9
9
|
def call
|
10
|
-
response =
|
10
|
+
response = ShopifyCLI::PartnersAPI
|
11
11
|
.query(context, "fetch_specifications", api_key: api_key)
|
12
12
|
.dig("data", "extensionSpecifications")
|
13
13
|
context.abort(context.message("tasks.errors.parse_error")) if response.nil?
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Extension
|
2
2
|
module Tasks
|
3
3
|
class FindNpmPackages
|
4
|
-
include
|
4
|
+
include ShopifyCLI::MethodObject
|
5
5
|
|
6
|
-
property! :js_system, accepts:
|
6
|
+
property! :js_system, accepts: ShopifyCLI::JsSystem
|
7
7
|
property! :production_only, accepts: [true, false], default: false, reader: :production_only?
|
8
8
|
|
9
9
|
def self.at_least_one_of(*package_names, **config)
|
@@ -69,7 +69,7 @@ module Extension
|
|
69
69
|
raise ArgumentError, "Expected a list of package names"
|
70
70
|
end
|
71
71
|
|
72
|
-
|
72
|
+
ShopifyCLI::Result
|
73
73
|
.call(&method(:list_packages))
|
74
74
|
.then(&method(:search_packages).curry[package_names])
|
75
75
|
.then(&method(:filter_duplicates))
|
@@ -3,7 +3,7 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
|
-
class GetApp <
|
6
|
+
class GetApp < ShopifyCLI::Task
|
7
7
|
GRAPHQL_FILE = "get_app_by_api_key"
|
8
8
|
|
9
9
|
RESPONSE_FIELD = %w(data)
|
@@ -12,7 +12,7 @@ module Extension
|
|
12
12
|
def call(context:, api_key:)
|
13
13
|
input = { api_key: api_key }
|
14
14
|
|
15
|
-
response =
|
15
|
+
response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
16
16
|
context.abort(context.message("tasks.errors.parse_error")) if response.nil?
|
17
17
|
|
18
18
|
Converters::AppConverter.from_hash(response.dig(APP_FIELD))
|
@@ -3,9 +3,9 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
|
-
class GetApps <
|
6
|
+
class GetApps < ShopifyCLI::Task
|
7
7
|
def call(context:)
|
8
|
-
organizations =
|
8
|
+
organizations = ShopifyCLI::PartnersAPI::Organizations.fetch_with_app(context)
|
9
9
|
apps_from_organizations(organizations)
|
10
10
|
end
|
11
11
|
|
@@ -3,9 +3,9 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
|
-
class GetExtensions <
|
6
|
+
class GetExtensions < ShopifyCLI::Task
|
7
7
|
def call(context:, type:)
|
8
|
-
organizations =
|
8
|
+
organizations = ShopifyCLI::PartnersAPI::Organizations.fetch_with_extensions(context, type)
|
9
9
|
extensions_from_organizations(organizations, context: context)
|
10
10
|
end
|
11
11
|
|
@@ -3,12 +3,12 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
|
-
class GetProduct <
|
6
|
+
class GetProduct < ShopifyCLI::Task
|
7
7
|
API_VERSION = "2021-07"
|
8
8
|
GRAPHQL_FILE = "get_variant_id"
|
9
9
|
|
10
10
|
def call(context, shop)
|
11
|
-
response =
|
11
|
+
response = ShopifyCLI::AdminAPI.query(
|
12
12
|
context,
|
13
13
|
GRAPHQL_FILE,
|
14
14
|
shop: shop,
|
@@ -0,0 +1,65 @@
|
|
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_EXTENSION_TYPES = [
|
11
|
+
"checkout_ui_extension",
|
12
|
+
]
|
13
|
+
|
14
|
+
SUPPORTED_COMMANDS = [
|
15
|
+
"create",
|
16
|
+
"build",
|
17
|
+
"serve",
|
18
|
+
]
|
19
|
+
|
20
|
+
property :root_dir, accepts: String
|
21
|
+
property :template, accepts: Models::ServerConfig::Development::VALID_TEMPLATES
|
22
|
+
property! :type, accepts: SUPPORTED_EXTENSION_TYPES
|
23
|
+
property! :command, accepts: SUPPORTED_COMMANDS
|
24
|
+
property :context, accepts: ShopifyCLI::Context
|
25
|
+
property :port, accepts: Integer, default: 39351
|
26
|
+
|
27
|
+
def call
|
28
|
+
ShopifyCLI::Result
|
29
|
+
.call(&method(:build_extension))
|
30
|
+
.then(&method(:build_server_config))
|
31
|
+
.then(&method(:run_command))
|
32
|
+
.unwrap do |error|
|
33
|
+
raise error unless error.nil?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def build_extension
|
40
|
+
Models::ServerConfig::Extension.build(
|
41
|
+
template: template,
|
42
|
+
type: type,
|
43
|
+
root_dir: root_dir,
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_server_config(extension)
|
48
|
+
Models::ServerConfig::Root.new(port: port, extensions: [extension])
|
49
|
+
end
|
50
|
+
|
51
|
+
def run_command(server_config)
|
52
|
+
case command
|
53
|
+
when "create"
|
54
|
+
Models::DevelopmentServer.new.create(server_config)
|
55
|
+
when "build"
|
56
|
+
Models::DevelopmentServer.new.build(server_config)
|
57
|
+
when "serve"
|
58
|
+
Models::DevelopmentServer.new.serve(context, server_config)
|
59
|
+
else
|
60
|
+
raise NotImplementedError
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -3,7 +3,7 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
module Tasks
|
6
|
-
class UpdateDraft <
|
6
|
+
class UpdateDraft < ShopifyCLI::Task
|
7
7
|
include UserErrors
|
8
8
|
|
9
9
|
GRAPHQL_FILE = "extension_update_draft"
|
@@ -18,7 +18,7 @@ module Extension
|
|
18
18
|
config: JSON.generate(config),
|
19
19
|
extension_context: extension_context,
|
20
20
|
}
|
21
|
-
response =
|
21
|
+
response = ShopifyCLI::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
22
22
|
context.abort(context.message("tasks.errors.parse_error")) if response.nil?
|
23
23
|
|
24
24
|
abort_if_user_errors(context, response)
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Node
|
3
|
-
class Project <
|
3
|
+
class Project < ShopifyCLI::ProjectType
|
4
4
|
require Project.project_filepath("messages/messages")
|
5
5
|
register_messages(Node::Messages::MESSAGES)
|
6
6
|
end
|
7
7
|
|
8
8
|
# define/autoload project specific Commands
|
9
|
-
class Command <
|
9
|
+
class Command < ShopifyCLI::ProjectCommands
|
10
10
|
subcommand :Connect, "connect", Project.project_filepath("commands/connect")
|
11
11
|
subcommand :Create, "create", Project.project_filepath("commands/create")
|
12
12
|
subcommand :Deploy, "deploy", Project.project_filepath("commands/deploy")
|
@@ -15,7 +15,7 @@ module Node
|
|
15
15
|
subcommand :Serve, "serve", Project.project_filepath("commands/serve")
|
16
16
|
subcommand :Tunnel, "tunnel", Project.project_filepath("commands/tunnel")
|
17
17
|
end
|
18
|
-
|
18
|
+
ShopifyCLI::Commands.register("Node::Command", "node")
|
19
19
|
|
20
20
|
# define/autoload project specific Tasks
|
21
21
|
module Tasks
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Node
|
3
3
|
class Command
|
4
|
-
class Connect <
|
4
|
+
class Connect < ShopifyCLI::SubCommand
|
5
5
|
prerequisite_task ensure_project_type: :node
|
6
6
|
|
7
7
|
def call(*)
|
8
|
-
if
|
8
|
+
if ShopifyCLI::Project.has_current? && ShopifyCLI::Project.current.env
|
9
9
|
@ctx.puts(@ctx.message("node.connect.production_warning"))
|
10
10
|
end
|
11
11
|
|
12
|
-
app =
|
12
|
+
app = ShopifyCLI::Connect.new(@ctx).default_connect("node")
|
13
13
|
@ctx.done(@ctx.message("node.connect.connected", app))
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.help
|
17
|
-
|
17
|
+
ShopifyCLI::Context.message("node.connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Node
|
3
3
|
class Command
|
4
|
-
class Create <
|
4
|
+
class Create < ShopifyCLI::SubCommand
|
5
5
|
prerequisite_task :ensure_authenticated
|
6
6
|
|
7
7
|
options do |parser, flags|
|
@@ -26,37 +26,37 @@ module Node
|
|
26
26
|
check_npm
|
27
27
|
build(form.name)
|
28
28
|
|
29
|
-
|
29
|
+
ShopifyCLI::Project.write(
|
30
30
|
@ctx,
|
31
31
|
project_type: "node",
|
32
32
|
organization_id: form.organization_id,
|
33
33
|
)
|
34
34
|
|
35
|
-
api_client =
|
35
|
+
api_client = ShopifyCLI::Tasks::CreateApiClient.call(
|
36
36
|
@ctx,
|
37
37
|
org_id: form.organization_id,
|
38
38
|
title: form.title,
|
39
39
|
type: form.type,
|
40
40
|
)
|
41
41
|
|
42
|
-
|
42
|
+
ShopifyCLI::Resources::EnvFile.new(
|
43
43
|
api_key: api_client["apiKey"],
|
44
44
|
secret: api_client["apiSecretKeys"].first["secret"],
|
45
45
|
shop: form.shop_domain,
|
46
46
|
scopes: "write_products,write_customers,write_draft_orders",
|
47
47
|
).write(@ctx)
|
48
48
|
|
49
|
-
partners_url =
|
49
|
+
partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
|
50
50
|
|
51
51
|
@ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
|
52
|
-
@ctx.puts(@ctx.message("apps.create.info.serve", form.name,
|
53
|
-
unless
|
52
|
+
@ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME, "node"))
|
53
|
+
unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
54
54
|
@ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.help
|
59
|
-
|
59
|
+
ShopifyCLI::Context.message("node.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
|
60
60
|
end
|
61
61
|
|
62
62
|
private
|
@@ -101,12 +101,12 @@ module Node
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def build(name)
|
104
|
-
|
104
|
+
ShopifyCLI::Git.clone("https://github.com/Shopify/shopify-app-node.git", name)
|
105
105
|
|
106
106
|
@ctx.root = File.join(@ctx.root, name)
|
107
107
|
|
108
108
|
set_npm_config
|
109
|
-
|
109
|
+
ShopifyCLI::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
|
110
110
|
|
111
111
|
begin
|
112
112
|
@ctx.rm_r(".git")
|
@@ -120,10 +120,6 @@ module Node
|
|
120
120
|
@ctx.debug(e)
|
121
121
|
end
|
122
122
|
end
|
123
|
-
|
124
|
-
def local_debug?
|
125
|
-
@ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
|
126
|
-
end
|
127
123
|
end
|
128
124
|
end
|
129
125
|
end
|
@@ -6,12 +6,12 @@ module Node
|
|
6
6
|
class Deploy
|
7
7
|
class Heroku
|
8
8
|
def self.help
|
9
|
-
|
9
|
+
ShopifyCLI::Context.message("node.deploy.heroku.help", ShopifyCLI::TOOL_NAME)
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.start(ctx)
|
13
13
|
spin_group = CLI::UI::SpinGroup.new
|
14
|
-
heroku_service =
|
14
|
+
heroku_service = ShopifyCLI::Heroku.new(ctx)
|
15
15
|
|
16
16
|
spin_group.add(ctx.message("node.deploy.heroku.downloading")) do |spinner|
|
17
17
|
heroku_service.download
|
@@ -29,7 +29,7 @@ module Node
|
|
29
29
|
spin_group.wait
|
30
30
|
|
31
31
|
spin_group.add(ctx.message("node.deploy.heroku.git.checking")) do |spinner|
|
32
|
-
|
32
|
+
ShopifyCLI::Git.init(ctx)
|
33
33
|
spinner.update_title(ctx.message("node.deploy.heroku.git.initialized"))
|
34
34
|
end
|
35
35
|
spin_group.wait
|
@@ -71,7 +71,7 @@ module Node
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
branches =
|
74
|
+
branches = ShopifyCLI::Git.branches(ctx)
|
75
75
|
if branches.length == 1
|
76
76
|
branch_to_deploy = branches[0]
|
77
77
|
ctx.puts(ctx.message("node.deploy.heroku.git.branch_selected", branch_to_deploy))
|
@@ -3,7 +3,7 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Node
|
5
5
|
class Command
|
6
|
-
class Deploy <
|
6
|
+
class Deploy < ShopifyCLI::SubCommand
|
7
7
|
prerequisite_task ensure_project_type: :node
|
8
8
|
|
9
9
|
autoload :Heroku, Project.project_filepath("commands/deploy/heroku")
|
@@ -21,11 +21,11 @@ module Node
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.help
|
24
|
-
|
24
|
+
ShopifyCLI::Context.message("node.deploy.help", ShopifyCLI::TOOL_NAME)
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.extended_help
|
28
|
-
|
28
|
+
ShopifyCLI::Context.message("node.deploy.extended_help", ShopifyCLI::TOOL_NAME)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -3,7 +3,7 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Node
|
5
5
|
class Command
|
6
|
-
class Generate <
|
6
|
+
class Generate < ShopifyCLI::SubCommand
|
7
7
|
prerequisite_task ensure_project_type: :node
|
8
8
|
|
9
9
|
def call(*)
|
@@ -11,7 +11,7 @@ module Node
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.help
|
14
|
-
|
14
|
+
ShopifyCLI::Context.message("node.generate.help")
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.extended_help
|
@@ -2,16 +2,16 @@ require "shopify_cli"
|
|
2
2
|
|
3
3
|
module Node
|
4
4
|
class Command
|
5
|
-
class Open <
|
5
|
+
class Open < ShopifyCLI::SubCommand
|
6
6
|
prerequisite_task ensure_project_type: :node
|
7
7
|
|
8
8
|
def call(*)
|
9
|
-
project =
|
9
|
+
project = ShopifyCLI::Project.current
|
10
10
|
@ctx.open_url!("#{project.env.host}/auth?shop=#{project.env.shop}")
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.help
|
14
|
-
|
14
|
+
ShopifyCLI::Context.message("node.open.help", ShopifyCLI::TOOL_NAME)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Node
|
3
3
|
class Command
|
4
|
-
class Serve <
|
4
|
+
class Serve < ShopifyCLI::SubCommand
|
5
5
|
prerequisite_task ensure_project_type: :node
|
6
6
|
prerequisite_task :ensure_env, :ensure_dev_store
|
7
7
|
|
@@ -12,11 +12,11 @@ module Node
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call(*)
|
15
|
-
project =
|
16
|
-
url = options.flags[:host] ||
|
15
|
+
project = ShopifyCLI::Project.current
|
16
|
+
url = options.flags[:host] || ShopifyCLI::Tunnel.start(@ctx)
|
17
17
|
@ctx.abort(@ctx.message("node.serve.error.host_must_be_https")) if url.match(/^https/i).nil?
|
18
18
|
project.env.update(@ctx, :host, url)
|
19
|
-
|
19
|
+
ShopifyCLI::Tasks::UpdateDashboardURLS.call(
|
20
20
|
@ctx,
|
21
21
|
url: url,
|
22
22
|
callback_url: "/auth/callback",
|
@@ -29,17 +29,17 @@ module Node
|
|
29
29
|
|
30
30
|
CLI::UI::Frame.open(@ctx.message("node.serve.running_server")) do
|
31
31
|
env = project.env.to_h
|
32
|
-
env["PORT"] =
|
32
|
+
env["PORT"] = ShopifyCLI::Tunnel::PORT.to_s
|
33
33
|
@ctx.system("npm run dev", env: env)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.help
|
38
|
-
|
38
|
+
ShopifyCLI::Context.message("node.serve.help", ShopifyCLI::TOOL_NAME)
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.extended_help
|
42
|
-
|
42
|
+
ShopifyCLI::Context.message("node.serve.extended_help")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -4,7 +4,7 @@ require "shopify_cli"
|
|
4
4
|
|
5
5
|
module Node
|
6
6
|
class Command
|
7
|
-
class Tunnel <
|
7
|
+
class Tunnel < ShopifyCLI::SubCommand
|
8
8
|
# subcommands :auth, :start, :stop
|
9
9
|
|
10
10
|
prerequisite_task ensure_project_type: :node
|
@@ -18,23 +18,23 @@ module Node
|
|
18
18
|
@ctx.puts(@ctx.message("node.tunnel.error.token_argument_missing"))
|
19
19
|
@ctx.puts("#{self.class.help}\n#{self.class.extended_help}")
|
20
20
|
else
|
21
|
-
|
21
|
+
ShopifyCLI::Tunnel.auth(@ctx, token)
|
22
22
|
end
|
23
23
|
when "start"
|
24
|
-
|
24
|
+
ShopifyCLI::Tunnel.start(@ctx)
|
25
25
|
when "stop"
|
26
|
-
|
26
|
+
ShopifyCLI::Tunnel.stop(@ctx)
|
27
27
|
else
|
28
28
|
@ctx.puts(self.class.help)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.help
|
33
|
-
|
33
|
+
ShopifyCLI::Context.message("node.tunnel.help", ShopifyCLI::TOOL_NAME)
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.extended_help
|
37
|
-
|
37
|
+
ShopifyCLI::Context.message("node.tunnel.extended_help", ShopifyCLI::TOOL_NAME)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -2,7 +2,7 @@ require "uri"
|
|
2
2
|
|
3
3
|
module Node
|
4
4
|
module Forms
|
5
|
-
class Create <
|
5
|
+
class Create < ShopifyCLI::Form
|
6
6
|
attr_accessor :name
|
7
7
|
flag_arguments :title, :organization_id, :shop_domain, :type
|
8
8
|
|
@@ -10,7 +10,7 @@ module Node
|
|
10
10
|
self.title ||= CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_name"))
|
11
11
|
self.name = format_name
|
12
12
|
self.type = ask_type
|
13
|
-
res =
|
13
|
+
res = ShopifyCLI::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
|
14
14
|
self.organization_id = res[:organization_id]
|
15
15
|
self.shop_domain = res[:shop_domain]
|
16
16
|
end
|
@@ -34,7 +34,7 @@ module Node
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
unless
|
37
|
+
unless ShopifyCLI::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type)
|
38
38
|
ctx.abort(ctx.message("node.forms.create.error.invalid_app_type", type))
|
39
39
|
end
|
40
40
|
ctx.puts(ctx.message("node.forms.create.app_type.selected", type))
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module PHP
|
3
|
+
class Project < ShopifyCLI::ProjectType
|
4
|
+
require Project.project_filepath("messages/messages")
|
5
|
+
register_messages(PHP::Messages::MESSAGES)
|
6
|
+
end
|
7
|
+
|
8
|
+
# define/autoload project specific Commands
|
9
|
+
class Command < ShopifyCLI::ProjectCommands
|
10
|
+
subcommand :Connect, "connect", Project.project_filepath("commands/connect")
|
11
|
+
subcommand :Create, "create", Project.project_filepath("commands/create")
|
12
|
+
subcommand :Deploy, "deploy", Project.project_filepath("commands/deploy")
|
13
|
+
subcommand :Open, "open", Project.project_filepath("commands/open")
|
14
|
+
subcommand :Serve, "serve", Project.project_filepath("commands/serve")
|
15
|
+
subcommand :Tunnel, "tunnel", Project.project_filepath("commands/tunnel")
|
16
|
+
end
|
17
|
+
ShopifyCLI::Commands.register("PHP::Command", "php")
|
18
|
+
|
19
|
+
# define/autoload project specific Tasks
|
20
|
+
module Tasks
|
21
|
+
end
|
22
|
+
|
23
|
+
# define/autoload project specific Forms
|
24
|
+
module Forms
|
25
|
+
autoload :Create, Project.project_filepath("forms/create")
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module PHP
|
3
|
+
class Command
|
4
|
+
class Connect < ShopifyCLI::SubCommand
|
5
|
+
def call(*)
|
6
|
+
if ShopifyCLI::Project.has_current? && ShopifyCLI::Project.current.env
|
7
|
+
@ctx.puts(@ctx.message("php.connect.production_warning"))
|
8
|
+
end
|
9
|
+
|
10
|
+
app = ShopifyCLI::Connect.new(@ctx).default_connect("php")
|
11
|
+
@ctx.done(@ctx.message("php.connect.connected", app))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.help
|
15
|
+
ShopifyCLI::Context.message("php.connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|