shopify-cli 2.2.2 → 2.6.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 +3 -0
- data/.rubocop.yml +14 -14
- data/.rubocop_todo.yml +3 -3
- data/CHANGELOG.md +30 -0
- data/CONTRIBUTING.md +23 -0
- data/Dockerfile +17 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +67 -24
- data/RELEASING.md +1 -1
- data/Rakefile +75 -18
- data/bin/console +11 -0
- data/bin/shopify +16 -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/checkout_ui_extension.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 +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/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 +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 +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,21 +1,21 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
5
|
class Populate
|
6
|
-
class Product <
|
6
|
+
class Product < ShopifyCLI::AdminAPI::PopulateResourceCommand
|
7
7
|
@input_type = :ProductInput
|
8
8
|
|
9
9
|
def defaults
|
10
10
|
{
|
11
|
-
title:
|
11
|
+
title: ShopifyCLI::Helpers::Haikunator.title,
|
12
12
|
variants: [{ price: price }],
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
16
|
def message(data)
|
17
17
|
ret = data["productCreate"]["product"]
|
18
|
-
id =
|
18
|
+
id = ShopifyCLI::API.gid_to_id(ret["id"])
|
19
19
|
@ctx.message("core.populate.product.added", ret["title"], @shop, admin_url, id)
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "shopify_cli"
|
2
|
+
|
3
|
+
module ShopifyCLI
|
4
|
+
module Commands
|
5
|
+
class Populate < ShopifyCLI::Command
|
6
|
+
subcommand :Customer, "customers", "shopify_cli/commands/populate/customer"
|
7
|
+
subcommand :DraftOrder, "draftorders", "shopify_cli/commands/populate/draft_order"
|
8
|
+
subcommand :Product, "products", "shopify_cli/commands/populate/product"
|
9
|
+
|
10
|
+
def call(_args, _name)
|
11
|
+
@ctx.puts(self.class.help)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.help
|
15
|
+
ShopifyCLI::Context.message("core.populate.help", ShopifyCLI::TOOL_NAME)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.extended_help
|
19
|
+
ShopifyCLI::Context.message("core.populate.extended_help", ShopifyCLI::TOOL_NAME)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "shopify_cli"
|
2
|
+
|
3
|
+
module ShopifyCLI
|
4
|
+
module Commands
|
5
|
+
class Store < ShopifyCLI::Command
|
6
|
+
def call(_args, _name)
|
7
|
+
@ctx.puts(@ctx.message("core.store.shop", ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.help
|
11
|
+
ShopifyCLI::Context.message("core.store.help", ShopifyCLI::TOOL_NAME)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
|
-
class Switch <
|
5
|
+
class Switch < ShopifyCLI::Command
|
6
6
|
options do |parser, flags|
|
7
7
|
parser.on("--store=STORE") { |url| flags[:shop] = url }
|
8
8
|
# backwards compatibility allow 'shop' for now
|
@@ -18,11 +18,11 @@ module ShopifyCli
|
|
18
18
|
shop = if options.flags[:shop]
|
19
19
|
Login.validate_shop(options.flags[:shop])
|
20
20
|
elsif (org_id = DB.get(:organization_id))
|
21
|
-
res =
|
21
|
+
res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx, organization_id: org_id)
|
22
22
|
res[:shop_domain]
|
23
23
|
else
|
24
24
|
AdminAPI.get_shop_or_abort(@ctx)
|
25
|
-
res =
|
25
|
+
res = ShopifyCLI::Tasks::SelectOrgAndShop.call(@ctx)
|
26
26
|
res[:shop_domain]
|
27
27
|
end
|
28
28
|
DB.set(shop: shop)
|
@@ -32,7 +32,7 @@ module ShopifyCli
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.help
|
35
|
-
|
35
|
+
ShopifyCLI::Context.message("core.switch.help", ShopifyCLI::TOOL_NAME)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
require "rbconfig"
|
3
3
|
|
4
|
-
module
|
4
|
+
module ShopifyCLI
|
5
5
|
module Commands
|
6
|
-
class System <
|
6
|
+
class System < ShopifyCLI::Command
|
7
7
|
hidden_feature(feature_set: :debug)
|
8
8
|
|
9
9
|
def call(args, _name)
|
@@ -28,7 +28,7 @@ module ShopifyCli
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.help
|
31
|
-
|
31
|
+
ShopifyCLI::Context.message("core.system.help", ShopifyCLI::TOOL_NAME)
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
@@ -50,21 +50,21 @@ module ShopifyCli
|
|
50
50
|
|
51
51
|
@ctx.puts(@ctx.message("core.system.header"))
|
52
52
|
cli_constants.each do |s|
|
53
|
-
@ctx.puts(" " + @ctx.message("core.system.const", s,
|
53
|
+
@ctx.puts(" " + @ctx.message("core.system.const", s, ShopifyCLI.const_get(s.to_sym)) + "\n")
|
54
54
|
end
|
55
55
|
|
56
56
|
if show_all_details
|
57
57
|
cli_path_methods.each do |m|
|
58
|
-
@ctx.puts(" " + @ctx.message("core.system.const", m.upcase,
|
58
|
+
@ctx.puts(" " + @ctx.message("core.system.const", m.upcase, ShopifyCLI.send(m)) + "\n")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
def display_shopify_store(_show_all_details)
|
64
|
-
shop = if
|
65
|
-
|
64
|
+
shop = if ShopifyCLI::DB.exists?(:shop)
|
65
|
+
ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)
|
66
66
|
else
|
67
|
-
@ctx.message("core.populate.error.no_shop",
|
67
|
+
@ctx.message("core.populate.error.no_shop", ShopifyCLI::TOOL_NAME)
|
68
68
|
end
|
69
69
|
|
70
70
|
@ctx.puts("\n" + @ctx.message("core.system.shop_header"))
|
@@ -96,7 +96,7 @@ module ShopifyCli
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def display_ngrok
|
99
|
-
ngrok_location = File.join(
|
99
|
+
ngrok_location = File.join(ShopifyCLI.cache_dir, "ngrok#{@ctx.executable_file_extension}")
|
100
100
|
if File.exist?(ngrok_location)
|
101
101
|
@ctx.puts(" " + @ctx.message("core.system.ngrok_available", ngrok_location))
|
102
102
|
else
|
@@ -154,7 +154,7 @@ module ShopifyCli
|
|
154
154
|
end
|
155
155
|
|
156
156
|
def display_shopify_staff_identity
|
157
|
-
is_shopifolk =
|
157
|
+
is_shopifolk = ShopifyCLI::Shopifolk.check
|
158
158
|
if is_shopifolk
|
159
159
|
@ctx.puts("\n" + @ctx.message("core.system.identity_header"))
|
160
160
|
@ctx.puts(" " + @ctx.message("core.system.identity_is_shopifolk"))
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "shopify_cli"
|
2
|
+
|
3
|
+
module ShopifyCLI
|
4
|
+
module Commands
|
5
|
+
class Version < ShopifyCLI::Command
|
6
|
+
def self.help
|
7
|
+
ShopifyCLI::Context.message("core.version.help", ShopifyCLI::TOOL_NAME)
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(_args, _name)
|
11
|
+
@ctx.puts(ShopifyCLI::VERSION.to_s)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
|
-
class Whoami <
|
5
|
+
class Whoami < ShopifyCLI::Command
|
6
6
|
def call(_args, _name)
|
7
|
-
shop =
|
8
|
-
org_id =
|
9
|
-
org =
|
7
|
+
shop = ShopifyCLI::DB.get(:shop)
|
8
|
+
org_id = ShopifyCLI::DB.get(:organization_id)
|
9
|
+
org = ShopifyCLI::PartnersAPI::Organizations.fetch(@ctx, id: org_id) unless org_id.nil?
|
10
10
|
|
11
11
|
output = if shop.nil? && org.nil?
|
12
|
-
@ctx.message("core.whoami.not_logged_in",
|
12
|
+
@ctx.message("core.whoami.not_logged_in", ShopifyCLI::TOOL_NAME)
|
13
13
|
elsif !shop.nil? && org.nil?
|
14
14
|
@ctx.message("core.whoami.logged_in_shop_only", shop)
|
15
15
|
elsif shop.nil? && !org.nil?
|
@@ -21,7 +21,7 @@ module ShopifyCli
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.help
|
24
|
-
|
24
|
+
ShopifyCLI::Context.message("core.whoami.help", ShopifyCLI::TOOL_NAME)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "shopify_cli"
|
2
|
+
|
3
|
+
module ShopifyCLI
|
4
|
+
module Commands
|
5
|
+
Registry = CLI::Kit::CommandRegistry.new(
|
6
|
+
default: "help",
|
7
|
+
contextual_resolver: nil,
|
8
|
+
)
|
9
|
+
@core_commands = []
|
10
|
+
|
11
|
+
def self.register(const, cmd, path = nil, is_core = false)
|
12
|
+
autoload(const, path) if path
|
13
|
+
Registry.add(->() { const_get(const) }, cmd)
|
14
|
+
@core_commands.push(cmd) if is_core
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.core_command?(cmd)
|
18
|
+
@core_commands.include?(cmd)
|
19
|
+
end
|
20
|
+
|
21
|
+
register :Config, "config", "shopify_cli/commands/config", true
|
22
|
+
register :Help, "help", "shopify_cli/commands/help", true
|
23
|
+
register :Login, "login", "shopify_cli/commands/login", true
|
24
|
+
register :Logout, "logout", "shopify_cli/commands/logout", true
|
25
|
+
register :Populate, "populate", "shopify_cli/commands/populate", true
|
26
|
+
register :Store, "store", "shopify_cli/commands/store", true
|
27
|
+
register :Switch, "switch", "shopify_cli/commands/switch", true
|
28
|
+
register :System, "system", "shopify_cli/commands/system", true
|
29
|
+
register :Version, "version", "shopify_cli/commands/version", true
|
30
|
+
register :Whoami, "whoami", "shopify_cli/commands/whoami", true
|
31
|
+
|
32
|
+
autoload :Connect, "shopify_cli/commands/connect"
|
33
|
+
end
|
34
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
class Connect
|
5
5
|
def initialize(ctx)
|
6
6
|
@ctx = ctx
|
@@ -10,14 +10,14 @@ module ShopifyCli
|
|
10
10
|
if Project.current&.env
|
11
11
|
@ctx.puts(@ctx.message("core.connect.already_connected_warning"))
|
12
12
|
end
|
13
|
-
org =
|
13
|
+
org = ShopifyCLI::Tasks::EnsureEnv.call(@ctx, regenerate: true)
|
14
14
|
write_cli_yml(project_type, org["id"]) unless Project.has_current?
|
15
15
|
api_key = Project.current(force_reload: true).env["api_key"]
|
16
16
|
get_app(org["apps"], api_key).first["title"]
|
17
17
|
end
|
18
18
|
|
19
19
|
def write_cli_yml(project_type, org_id)
|
20
|
-
|
20
|
+
ShopifyCLI::Project.write(
|
21
21
|
@ctx,
|
22
22
|
project_type: project_type,
|
23
23
|
organization_id: org_id,
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module ShopifyCLI
|
2
|
+
module Constants
|
3
|
+
module Paths
|
4
|
+
ROOT = File.expand_path("../..", __dir__)
|
5
|
+
end
|
6
|
+
|
7
|
+
module StoreKeys
|
8
|
+
LAST_MIGRATION_DATE = :last_migration_date
|
9
|
+
ANALYTICS_ENABLED = :analytics_enabled
|
10
|
+
end
|
11
|
+
|
12
|
+
module Bugsnag
|
13
|
+
API_KEY = "773b0c801eb40c20d8928be5b7c739bd"
|
14
|
+
end
|
15
|
+
|
16
|
+
module Config
|
17
|
+
module Sections
|
18
|
+
module ErrorTracking
|
19
|
+
NAME = "error-tracking"
|
20
|
+
module Fields
|
21
|
+
AUTOMATIC_REPORTING = "automatic-reporting"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module EnvironmentVariables
|
28
|
+
STACKTRACE = "SHOPIFY_CLI_STACKTRACE"
|
29
|
+
|
30
|
+
# When true the CLI points to a local instance of
|
31
|
+
# the partners dashboard and identity.
|
32
|
+
LOCAL_PARTNERS = "SHOPIFY_APP_CLI_LOCAL_PARTNERS"
|
33
|
+
|
34
|
+
# When true the CLI points to a spin instance of spin
|
35
|
+
SPIN_PARTNERS = "SHOPIFY_APP_CLI_SPIN_PARTNERS"
|
36
|
+
SPIN_WORKSPACE = "SPIN_WORKSPACE"
|
37
|
+
SPIN_NAMESPACE = "SPIN_NAMESPACE"
|
38
|
+
SPIN_HOST = "SPIN_HOST"
|
39
|
+
|
40
|
+
# Environments
|
41
|
+
TEST = "SHOPIFY_CLI_TEST"
|
42
|
+
DEVELOPMENT = "SHOPIFY_CLI_DEVELOPMENT"
|
43
|
+
end
|
44
|
+
|
45
|
+
module Identity
|
46
|
+
CLIENT_ID_DEV = "e5380e02-312a-7408-5718-e07017e9cf52"
|
47
|
+
CLIENT_ID = "fbdb2649-e327-4907-8f67-908d24cfd7e3"
|
48
|
+
end
|
49
|
+
|
50
|
+
module Links
|
51
|
+
NEW_ISSUE = "https://github.com/Shopify/shopify-cli/issues/new"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -5,7 +5,7 @@ require "rbconfig"
|
|
5
5
|
require "net/http"
|
6
6
|
require "json"
|
7
7
|
|
8
|
-
module
|
8
|
+
module ShopifyCLI
|
9
9
|
##
|
10
10
|
# Context captures a lot about the current running command. It captures the
|
11
11
|
# environment, output, system and file operations. It is useful to have the
|
@@ -97,7 +97,7 @@ module ShopifyCli
|
|
97
97
|
# See `#development?` for checking for development environment.
|
98
98
|
#
|
99
99
|
def system?
|
100
|
-
!Dir.exist?(File.join(
|
100
|
+
!Dir.exist?(File.join(ShopifyCLI::ROOT, "test"))
|
101
101
|
end
|
102
102
|
|
103
103
|
# will return true if the cli is running on your development instance.
|
@@ -382,7 +382,7 @@ module ShopifyCli
|
|
382
382
|
# * `text` - a string message to output
|
383
383
|
#
|
384
384
|
def abort(text)
|
385
|
-
raise
|
385
|
+
raise ShopifyCLI::Abort, "{{x}} #{text}"
|
386
386
|
end
|
387
387
|
|
388
388
|
# outputs a message, prefixed by a red `DEBUG` tag. This will only output to
|
@@ -559,7 +559,7 @@ module ShopifyCli
|
|
559
559
|
if (time_of_last_check + VERSION_CHECK_INTERVAL) < (now = Time.now.to_i)
|
560
560
|
update_time_of_last_check(now)
|
561
561
|
latest_version = retrieve_latest_gem_version
|
562
|
-
latest_version unless latest_version ==
|
562
|
+
latest_version unless latest_version == ShopifyCLI::VERSION
|
563
563
|
end
|
564
564
|
end
|
565
565
|
|
@@ -600,11 +600,11 @@ module ShopifyCli
|
|
600
600
|
end
|
601
601
|
|
602
602
|
def time_of_last_check
|
603
|
-
(val =
|
603
|
+
(val = ShopifyCLI::Config.get(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD)) ? val.to_i : 0
|
604
604
|
end
|
605
605
|
|
606
606
|
def update_time_of_last_check(time)
|
607
|
-
|
607
|
+
ShopifyCLI::Config.set(VERSION_CHECK_SECTION, LAST_CHECKED_AT_FIELD, time)
|
608
608
|
end
|
609
609
|
end
|
610
610
|
end
|
@@ -1,26 +1,26 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Core
|
5
5
|
module EntryPoint
|
6
6
|
class << self
|
7
7
|
def call(args, ctx = Context.new)
|
8
8
|
if ctx.development?
|
9
9
|
ctx.warn(
|
10
|
-
ctx.message("core.warning.development_version", File.join(
|
10
|
+
ctx.message("core.warning.development_version", File.join(ShopifyCLI::ROOT, "bin", ShopifyCLI::TOOL_NAME))
|
11
11
|
)
|
12
12
|
elsif !ctx.testing?
|
13
13
|
new_version = ctx.new_version
|
14
|
-
ctx.warn(ctx.message("core.warning.new_version",
|
14
|
+
ctx.warn(ctx.message("core.warning.new_version", ShopifyCLI::VERSION, new_version)) unless new_version.nil?
|
15
15
|
end
|
16
16
|
|
17
17
|
ProjectType.load_all
|
18
18
|
|
19
|
-
task_registry =
|
19
|
+
task_registry = ShopifyCLI::Tasks::Registry
|
20
20
|
|
21
|
-
command, command_name, args =
|
22
|
-
executor =
|
23
|
-
|
21
|
+
command, command_name, args = ShopifyCLI::Resolver.call(args)
|
22
|
+
executor = ShopifyCLI::Core::Executor.new(ctx, task_registry, log_file: ShopifyCLI.log_file)
|
23
|
+
ShopifyCLI::Core::Monorail.log(command_name, args) do
|
24
24
|
executor.call(command, command_name, args)
|
25
25
|
end
|
26
26
|
end
|
@@ -1,18 +1,22 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Core
|
5
5
|
class Executor < CLI::Kit::Executor
|
6
6
|
def initialize(ctx, task_registry, *args, **kwargs)
|
7
|
-
@ctx = ctx ||
|
8
|
-
@task_registry = task_registry ||
|
7
|
+
@ctx = ctx || ShopifyCLI::Context.new
|
8
|
+
@task_registry = task_registry || ShopifyCLI::Tasks::TaskRegistry.new
|
9
9
|
super(*args, **kwargs)
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(command, command_name, args)
|
13
13
|
command.task_registry = @task_registry
|
14
14
|
command.ctx = @ctx
|
15
|
-
|
15
|
+
with_traps do
|
16
|
+
with_logging do |_id|
|
17
|
+
command.call(args, command_name)
|
18
|
+
end
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ShopifyCLI
|
2
2
|
module Core
|
3
3
|
# This class is just a dummy to make sure that we don't trigger warnings on the first time the updated code runs.
|
4
4
|
# The old code would try to call the Finalizer after it is done updating, which would then trigger an autoload of
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "cli/kit"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Core
|
5
5
|
class HelpResolver < CLI::Kit::Resolver
|
6
6
|
def call(args)
|
@@ -10,7 +10,7 @@ module ShopifyCli
|
|
10
10
|
help = Commands::Help
|
11
11
|
help.ctx = Context.new
|
12
12
|
help.call([], nil)
|
13
|
-
raise
|
13
|
+
raise ShopifyCLI::AbortSilent
|
14
14
|
else
|
15
15
|
super(args)
|
16
16
|
end
|
@@ -3,7 +3,7 @@ require "net/http"
|
|
3
3
|
require "time"
|
4
4
|
require "rbconfig"
|
5
5
|
|
6
|
-
module
|
6
|
+
module ShopifyCLI
|
7
7
|
module Core
|
8
8
|
module Monorail
|
9
9
|
ENDPOINT_URI = URI.parse("https://monorail-edge.shopifycloud.com/v1/produce")
|
@@ -50,16 +50,16 @@ module ShopifyCli
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def consented?
|
53
|
-
|
53
|
+
ShopifyCLI::Config.get_bool("analytics", "enabled")
|
54
54
|
end
|
55
55
|
|
56
56
|
def prompt_for_consent
|
57
57
|
return if Context.new.ci?
|
58
58
|
return unless enabled?
|
59
|
-
return if
|
59
|
+
return if ShopifyCLI::Config.get_section("analytics").key?("enabled")
|
60
60
|
msg = Context.message("core.monorail.consent_prompt")
|
61
61
|
opt = CLI::UI::Prompt.confirm(msg)
|
62
|
-
|
62
|
+
ShopifyCLI::Config.set("analytics", "enabled", opt)
|
63
63
|
end
|
64
64
|
|
65
65
|
def send_event(start_time, commands, args, err = nil)
|
@@ -100,12 +100,12 @@ module ShopifyCli
|
|
100
100
|
success: err.nil?,
|
101
101
|
error_message: err,
|
102
102
|
uname: RbConfig::CONFIG["host"],
|
103
|
-
cli_version:
|
103
|
+
cli_version: ShopifyCLI::VERSION,
|
104
104
|
ruby_version: RUBY_VERSION,
|
105
|
-
is_employee:
|
105
|
+
is_employee: ShopifyCLI::Shopifolk.acting_as_shopify_organization?,
|
106
106
|
}.tap do |payload|
|
107
107
|
payload[:api_key] = metadata.delete(:api_key)
|
108
|
-
payload[:partner_id] = metadata.delete(:organization_id) ||
|
108
|
+
payload[:partner_id] = metadata.delete(:organization_id) || ShopifyCLI::DB.get(:organization_id)
|
109
109
|
if Project.has_current?
|
110
110
|
project = Project.current(force_reload: true)
|
111
111
|
payload[:api_key] = project.env&.api_key
|
@@ -117,7 +117,7 @@ module ShopifyCli
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def project_type_from_dir_or_cmd(command)
|
120
|
-
Project.current_project_type || (command unless
|
120
|
+
Project.current_project_type || (command unless ShopifyCLI::Commands.core_command?(command)) || nil
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "pstore"
|
2
2
|
require "forwardable"
|
3
3
|
|
4
|
-
module
|
4
|
+
module ShopifyCLI
|
5
5
|
# Persists transient data like access tokens that may be cleared
|
6
6
|
# when user clears their session
|
7
7
|
#
|
@@ -14,7 +14,7 @@ module ShopifyCli
|
|
14
14
|
|
15
15
|
attr_reader :db # :nodoc:
|
16
16
|
|
17
|
-
def initialize(path: File.join(
|
17
|
+
def initialize(path: File.join(ShopifyCLI.cache_dir, ".db.pstore")) # :nodoc:
|
18
18
|
@db = PStore.new(path)
|
19
19
|
end
|
20
20
|
|
@@ -25,7 +25,7 @@ module ShopifyCli
|
|
25
25
|
#
|
26
26
|
# #### Usage
|
27
27
|
#
|
28
|
-
#
|
28
|
+
# ShopifyCLI::DB.keys
|
29
29
|
#
|
30
30
|
def keys
|
31
31
|
db.transaction(true) { db.roots }
|
@@ -42,7 +42,7 @@ module ShopifyCli
|
|
42
42
|
#
|
43
43
|
# #### Usage
|
44
44
|
#
|
45
|
-
# exists =
|
45
|
+
# exists = ShopifyCLI::DB.exists?('shopify_exchange_token')
|
46
46
|
#
|
47
47
|
def exists?(key)
|
48
48
|
db.transaction(true) { db.root?(key) }
|
@@ -55,7 +55,7 @@ module ShopifyCli
|
|
55
55
|
#
|
56
56
|
# #### Usage
|
57
57
|
#
|
58
|
-
#
|
58
|
+
# ShopifyCLI::DB.set(shopify_exchange_token: 'token', metric_consent: true)
|
59
59
|
#
|
60
60
|
def set(**args)
|
61
61
|
db.transaction do
|
@@ -80,7 +80,7 @@ module ShopifyCli
|
|
80
80
|
#
|
81
81
|
# #### Usage
|
82
82
|
#
|
83
|
-
#
|
83
|
+
# ShopifyCLI::DB.get(:shopify_exchange_token)
|
84
84
|
#
|
85
85
|
def get(key)
|
86
86
|
val = db.transaction(true) { db[key] }
|
@@ -95,7 +95,7 @@ module ShopifyCli
|
|
95
95
|
#
|
96
96
|
# #### Usage
|
97
97
|
#
|
98
|
-
#
|
98
|
+
# ShopifyCLI::DB.del(:shopify_exchange_token)
|
99
99
|
#
|
100
100
|
def del(*args)
|
101
101
|
db.transaction { args.each { |key| db.delete(key) } }
|
@@ -105,7 +105,7 @@ module ShopifyCli
|
|
105
105
|
#
|
106
106
|
# #### Usage
|
107
107
|
#
|
108
|
-
#
|
108
|
+
# ShopifyCLI::DB.clear
|
109
109
|
#
|
110
110
|
def clear
|
111
111
|
del(*keys)
|