shopify-cli 2.4.0 → 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/workflows/shopify.yml +0 -2
- data/.rubocop.yml +14 -14
- data/.rubocop_todo.yml +3 -3
- data/CHANGELOG.md +5 -0
- data/Dockerfile +1 -1
- data/Gemfile.lock +1 -1
- data/RELEASING.md +1 -1
- data/Rakefile +18 -18
- data/bin/shopify +3 -3
- data/lib/project_types/extension/cli.rb +3 -3
- data/lib/project_types/extension/commands/build.rb +2 -2
- 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 +41 -23
- 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 +2 -2
- 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 +2 -2
- 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/models/development_server.rb +45 -6
- data/lib/project_types/extension/models/development_server_requirements.rb +22 -3
- data/lib/project_types/extension/models/lazy_specification_handler.rb +1 -1
- data/lib/project_types/extension/models/specification.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 +1 -1
- 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 +10 -3
- 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 -10
- 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 -12
- 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 +11 -4
- 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/layers/application/extension_points.rb +2 -2
- data/lib/project_types/script/layers/application/push_script.rb +4 -1
- 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/languages/assemblyscript_project_creator.rb +1 -1
- 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 -1
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +5 -5
- data/lib/project_types/script/layers/infrastructure/script_service.rb +4 -8
- data/lib/project_types/script/layers/infrastructure/service_locator.rb +20 -0
- data/lib/project_types/script/tasks/ensure_env.rb +6 -6
- data/lib/project_types/script/ui/error_handler.rb +75 -75
- 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 +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 → shopify_cli}/constants.rb +1 -1
- 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 → shopify_cli}/environment.rb +1 -1
- 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 +6 -6
- 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 +8 -8
- 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 +13 -13
- 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 +1 -1
- 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 → shopify_cli}/theme/development_theme.rb +9 -9
- 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 +50 -49
- data/shopify-cli.gemspec +2 -2
- metadata +104 -91
- data/lib/project_types/script/layers/infrastructure/api_clients.rb +0 -89
- 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/version.rb +0 -3
@@ -1,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require "
|
2
|
+
require "shopify_cli/theme/dev_server"
|
3
3
|
|
4
4
|
module Theme
|
5
5
|
class Command
|
6
|
-
class Serve <
|
6
|
+
class Serve < ShopifyCLI::SubCommand
|
7
7
|
options do |parser, flags|
|
8
8
|
parser.on("--port=PORT") { |port| flags[:port] = port.to_i }
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(*)
|
12
12
|
flags = options.flags.dup
|
13
|
-
|
13
|
+
ShopifyCLI::Theme::DevServer.start(@ctx, ".", **flags) do |syncer|
|
14
14
|
UI::SyncProgressBar.new(syncer).progress(:upload_theme!, delay_low_priority_files: true)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.help
|
19
|
-
|
19
|
+
ShopifyCLI::Context.message("theme.serve.help", ShopifyCLI::TOOL_NAME)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Theme
|
2
2
|
module Forms
|
3
|
-
class Select <
|
3
|
+
class Select < ShopifyCLI::Form
|
4
4
|
attr_accessor :theme
|
5
5
|
flag_arguments :root, :title, :exclude_roles, :include_foreign_developments
|
6
6
|
|
@@ -17,7 +17,7 @@ module Theme
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def themes
|
20
|
-
@themes ||=
|
20
|
+
@themes ||= ShopifyCLI::Theme::Theme.all(@ctx, root: root)
|
21
21
|
.sort_by { |theme| theme_sort_order(theme) }
|
22
22
|
end
|
23
23
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
require "optparse"
|
3
3
|
|
4
|
-
module
|
4
|
+
module ShopifyCLI
|
5
5
|
class AdminAPI
|
6
|
-
class PopulateResourceCommand <
|
6
|
+
class PopulateResourceCommand < ShopifyCLI::SubCommand
|
7
7
|
DEFAULT_COUNT = 5
|
8
8
|
|
9
9
|
attr_reader :input
|
@@ -40,7 +40,7 @@ module ShopifyCli
|
|
40
40
|
return @ctx.puts(output)
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
ShopifyCLI::Tasks::ConfirmStore.call(@ctx) unless @skip_shop_confirmation
|
44
44
|
@shop = AdminAPI.get_shop_or_abort(@ctx)
|
45
45
|
if @silent
|
46
46
|
spin_group = CLI::UI::SpinGroup.new
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
class AdminAPI
|
5
5
|
class Schema < Hash
|
6
6
|
class << self
|
7
7
|
def get(ctx)
|
8
|
-
unless
|
8
|
+
unless ShopifyCLI::DB.exists?(:shopify_admin_schema)
|
9
9
|
shop = AdminAPI.get_shop_or_abort(ctx)
|
10
10
|
schema = AdminAPI.query(ctx, "admin_introspection", shop: shop)
|
11
|
-
|
11
|
+
ShopifyCLI::DB.set(shopify_admin_schema: JSON.dump(schema))
|
12
12
|
end
|
13
13
|
# This is ruby magic for making a new hash with another hash.
|
14
14
|
# It wraps the JSON in our Schema Class to have the helper methods
|
15
15
|
# available
|
16
|
-
self[JSON.parse(
|
16
|
+
self[JSON.parse(ShopifyCLI::DB.get(:shopify_admin_schema))]
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
##
|
5
|
-
#
|
5
|
+
# ShopifyCLI::AdminAPI wraps our graphql functionality with authentication so that
|
6
6
|
# these concerns are taken care of.
|
7
7
|
#
|
8
8
|
class AdminAPI < API
|
9
|
-
autoload :PopulateResourceCommand, "
|
10
|
-
autoload :Schema, "
|
9
|
+
autoload :PopulateResourceCommand, "shopify_cli/admin_api/populate_resource_command"
|
10
|
+
autoload :Schema, "shopify_cli/admin_api/schema"
|
11
11
|
|
12
12
|
class << self
|
13
13
|
##
|
@@ -24,10 +24,10 @@ module ShopifyCli
|
|
24
24
|
#
|
25
25
|
# #### Raises
|
26
26
|
#
|
27
|
-
# * http 404 will raise a
|
28
|
-
# * http 400..499 will raise a
|
29
|
-
# * http 500..599 will raise a
|
30
|
-
# * All other codes will raise
|
27
|
+
# * http 404 will raise a ShopifyCLI::API::APIRequestNotFoundError
|
28
|
+
# * http 400..499 will raise a ShopifyCLI::API::APIRequestClientError
|
29
|
+
# * http 500..599 will raise a ShopifyCLI::API::APIRequestServerError
|
30
|
+
# * All other codes will raise ShopifyCLI::API::APIRequestUnexpectedError
|
31
31
|
#
|
32
32
|
# #### Returns
|
33
33
|
#
|
@@ -35,18 +35,18 @@ module ShopifyCli
|
|
35
35
|
#
|
36
36
|
# #### Example
|
37
37
|
#
|
38
|
-
#
|
38
|
+
# ShopifyCLI::AdminAPI.query(@ctx, 'all_organizations')
|
39
39
|
#
|
40
40
|
def query(ctx, query_name, shop:, api_version: nil, **variables)
|
41
41
|
CLI::Kit::Util.begin do
|
42
42
|
api_client(ctx, api_version, shop).query(query_name, variables: variables)
|
43
43
|
end.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
44
|
-
|
44
|
+
ShopifyCLI::IdentityAuth.new(ctx: ctx).reauthenticate
|
45
45
|
end
|
46
46
|
rescue API::APIRequestUnauthorizedError
|
47
47
|
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
48
48
|
rescue API::APIRequestForbiddenError
|
49
|
-
ctx.abort(ctx.message("core.api.error.forbidden",
|
49
|
+
ctx.abort(ctx.message("core.api.error.forbidden", ShopifyCLI::TOOL_NAME))
|
50
50
|
end
|
51
51
|
|
52
52
|
##
|
@@ -65,10 +65,10 @@ module ShopifyCli
|
|
65
65
|
#
|
66
66
|
# #### Raises
|
67
67
|
#
|
68
|
-
# * http 404 will raise a
|
69
|
-
# * http 400..499 will raise a
|
70
|
-
# * http 500..599 will raise a
|
71
|
-
# * All other codes will raise
|
68
|
+
# * http 404 will raise a ShopifyCLI::API::APIRequestNotFoundError
|
69
|
+
# * http 400..499 will raise a ShopifyCLI::API::APIRequestClientError
|
70
|
+
# * http 500..599 will raise a ShopifyCLI::API::APIRequestServerError
|
71
|
+
# * All other codes will raise ShopifyCLI::API::APIRequestUnexpectedError
|
72
72
|
#
|
73
73
|
# #### Returns
|
74
74
|
#
|
@@ -76,38 +76,38 @@ module ShopifyCli
|
|
76
76
|
#
|
77
77
|
# #### Example
|
78
78
|
#
|
79
|
-
#
|
79
|
+
# ShopifyCLI::AdminAPI.rest_request(@ctx,
|
80
80
|
# shop: 'shop.myshopify.com',
|
81
81
|
# path: 'data.json',
|
82
82
|
# token: 'password')
|
83
83
|
#
|
84
84
|
def rest_request(ctx, shop:, path:, query: nil, body: nil, method: "GET", api_version: nil, token: nil)
|
85
85
|
CLI::Kit::Util.begin do
|
86
|
-
|
86
|
+
ShopifyCLI::DB.set(shopify_exchange_token: token) unless token.nil?
|
87
87
|
url = URI::HTTPS.build(
|
88
88
|
host: shop,
|
89
89
|
path: "/admin/api/#{fetch_api_version(ctx, api_version, shop)}/#{path}",
|
90
90
|
query: query,
|
91
91
|
)
|
92
92
|
resp = api_client(ctx, api_version, shop, path: path).request(url: url.to_s, body: body, method: method)
|
93
|
-
|
93
|
+
ShopifyCLI::DB.set(shopify_exchange_token: nil) unless token.nil?
|
94
94
|
resp
|
95
95
|
end.retry_after(API::APIRequestUnauthorizedError) do
|
96
|
-
|
96
|
+
ShopifyCLI::IdentityAuth.new(ctx: ctx).reauthenticate
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
100
|
def get_shop_or_abort(ctx)
|
101
101
|
ctx.abort(
|
102
|
-
ctx.message("core.populate.error.no_shop",
|
103
|
-
) unless
|
104
|
-
|
102
|
+
ctx.message("core.populate.error.no_shop", ShopifyCLI::TOOL_NAME)
|
103
|
+
) unless ShopifyCLI::DB.exists?(:shop)
|
104
|
+
ShopifyCLI::DB.get(:shop)
|
105
105
|
end
|
106
106
|
|
107
107
|
private
|
108
108
|
|
109
109
|
def authenticate(ctx, _shop)
|
110
|
-
|
110
|
+
ShopifyCLI::IdentityAuth.new(ctx: ctx).authenticate
|
111
111
|
end
|
112
112
|
|
113
113
|
def api_client(ctx, api_version, shop, path: "graphql.json")
|
@@ -119,9 +119,9 @@ module ShopifyCli
|
|
119
119
|
end
|
120
120
|
|
121
121
|
def access_token(ctx, shop)
|
122
|
-
|
122
|
+
ShopifyCLI::DB.get(:shopify_exchange_token) do
|
123
123
|
authenticate(ctx, shop)
|
124
|
-
|
124
|
+
ShopifyCLI::DB.get(:shopify_exchange_token)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -141,12 +141,12 @@ module ShopifyCli
|
|
141
141
|
.sort
|
142
142
|
.reverse[0]
|
143
143
|
end.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
144
|
-
|
144
|
+
ShopifyCLI::IdentityAuth.new(ctx: ctx).reauthenticate
|
145
145
|
end
|
146
146
|
rescue API::APIRequestUnauthorizedError
|
147
147
|
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
148
148
|
rescue API::APIRequestForbiddenError
|
149
|
-
ctx.abort(ctx.message("core.api.error.forbidden",
|
149
|
+
ctx.abort(ctx.message("core.api.error.forbidden", ShopifyCLI::TOOL_NAME))
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
class API
|
5
5
|
include SmartProperties
|
6
6
|
|
7
|
-
property! :ctx, accepts:
|
7
|
+
property! :ctx, accepts: ShopifyCLI::Context
|
8
8
|
property! :token, accepts: String
|
9
9
|
property :auth_header, accepts: String
|
10
10
|
property! :url, accepts: String
|
@@ -52,7 +52,7 @@ module ShopifyCli
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# we delay this require so as to avoid a performance hit on starting the CLI
|
55
|
-
require "
|
55
|
+
require "shopify_cli/http_request"
|
56
56
|
headers = default_headers.merge(headers)
|
57
57
|
response = if method == "POST"
|
58
58
|
HttpRequest.post(uri, body, headers)
|
@@ -91,14 +91,14 @@ module ShopifyCli
|
|
91
91
|
protected
|
92
92
|
|
93
93
|
def load_query(name)
|
94
|
-
project_type =
|
94
|
+
project_type = ShopifyCLI::Project.current_project_type
|
95
95
|
project_file_path = File.join(
|
96
|
-
|
96
|
+
ShopifyCLI::ROOT, "lib", "project_types", project_type.to_s, "graphql", "#{name}.graphql"
|
97
97
|
)
|
98
98
|
if !project_type.nil? && File.exist?(project_file_path)
|
99
99
|
File.read(project_file_path)
|
100
100
|
else
|
101
|
-
File.read(File.join(
|
101
|
+
File.read(File.join(ShopifyCLI::ROOT, "lib", "graphql", "#{name}.graphql"))
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -106,8 +106,8 @@ module ShopifyCli
|
|
106
106
|
|
107
107
|
def default_headers
|
108
108
|
{
|
109
|
-
"User-Agent" => "Shopify CLI; v=#{
|
110
|
-
"Sec-CH-UA" => "Shopify CLI; v=#{
|
109
|
+
"User-Agent" => "Shopify CLI; v=#{ShopifyCLI::VERSION}",
|
110
|
+
"Sec-CH-UA" => "Shopify CLI; v=#{ShopifyCLI::VERSION} sha=#{ShopifyCLI.sha}",
|
111
111
|
"Sec-CH-UA-PLATFORM" => ctx.os.to_s,
|
112
112
|
}.tap do |headers|
|
113
113
|
headers["X-Shopify-Cli-Employee"] = "1" if Shopifolk.acting_as_shopify_organization?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "shopify_cli"
|
3
3
|
|
4
|
-
module
|
4
|
+
module ShopifyCLI
|
5
5
|
class Command < CLI::Kit::BaseCommand
|
6
6
|
extend Feature::Set
|
7
7
|
|
@@ -55,7 +55,7 @@ module ShopifyCli
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def task_registry
|
58
|
-
@task_registry ||
|
58
|
+
@task_registry || ShopifyCLI::Tasks::Registry
|
59
59
|
end
|
60
60
|
|
61
61
|
def call_help(*cmds)
|
@@ -75,7 +75,7 @@ module ShopifyCli
|
|
75
75
|
|
76
76
|
def initialize(ctx = nil)
|
77
77
|
super()
|
78
|
-
@ctx = ctx ||
|
78
|
+
@ctx = ctx || ShopifyCLI::Context.new
|
79
79
|
self.options = Options.new
|
80
80
|
end
|
81
81
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
|
-
class Config <
|
5
|
+
class Config < ShopifyCLI::Command
|
6
6
|
hidden_feature(feature_set: :debug)
|
7
7
|
|
8
8
|
subcommand :Feature, "feature"
|
@@ -13,12 +13,12 @@ module ShopifyCli
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.help
|
16
|
-
|
16
|
+
ShopifyCLI::Context.message("core.config.help", ShopifyCLI::TOOL_NAME)
|
17
17
|
end
|
18
18
|
|
19
|
-
class Feature <
|
19
|
+
class Feature < ShopifyCLI::SubCommand
|
20
20
|
def self.help
|
21
|
-
|
21
|
+
ShopifyCLI::Context.message("core.config.feature.help", ShopifyCLI::TOOL_NAME)
|
22
22
|
end
|
23
23
|
|
24
24
|
options do |parser, flags|
|
@@ -29,13 +29,13 @@ module ShopifyCli
|
|
29
29
|
|
30
30
|
def call(args, _name)
|
31
31
|
feature_name = args.shift
|
32
|
-
return @ctx.puts(@ctx.message("core.config.help",
|
33
|
-
is_enabled =
|
32
|
+
return @ctx.puts(@ctx.message("core.config.help", ShopifyCLI::TOOL_NAME)) if feature_name.nil?
|
33
|
+
is_enabled = ShopifyCLI::Feature.enabled?(feature_name)
|
34
34
|
if options.flags[:action] == "disable" && is_enabled
|
35
|
-
|
35
|
+
ShopifyCLI::Feature.disable(feature_name)
|
36
36
|
@ctx.puts(@ctx.message("core.config.feature.disabled", feature_name))
|
37
37
|
elsif options.flags[:action] == "enable" && !is_enabled
|
38
|
-
|
38
|
+
ShopifyCLI::Feature.enable(feature_name)
|
39
39
|
@ctx.puts(@ctx.message("core.config.feature.enabled", feature_name))
|
40
40
|
elsif is_enabled
|
41
41
|
@ctx.puts(@ctx.message("core.config.feature.is_enabled", feature_name))
|
@@ -45,9 +45,9 @@ module ShopifyCli
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
class Analytics <
|
48
|
+
class Analytics < ShopifyCLI::SubCommand
|
49
49
|
def self.help
|
50
|
-
|
50
|
+
ShopifyCLI::Context.message("core.config.analytics.help", ShopifyCLI::TOOL_NAME)
|
51
51
|
end
|
52
52
|
|
53
53
|
options do |parser, flags|
|
@@ -57,12 +57,12 @@ module ShopifyCli
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def call(_args, _name)
|
60
|
-
is_enabled =
|
60
|
+
is_enabled = ShopifyCLI::Config.get_bool("analytics", "enabled")
|
61
61
|
if options.flags[:action] == "disable" && is_enabled
|
62
|
-
|
62
|
+
ShopifyCLI::Config.set("analytics", "enabled", false)
|
63
63
|
@ctx.puts(@ctx.message("core.config.analytics.disabled"))
|
64
64
|
elsif options.flags[:action] == "enable" && !is_enabled
|
65
|
-
|
65
|
+
ShopifyCLI::Config.set("analytics", "enabled", true)
|
66
66
|
@ctx.puts(@ctx.message("core.config.analytics.enabled"))
|
67
67
|
elsif is_enabled
|
68
68
|
@ctx.puts(@ctx.message("core.config.analytics.is_enabled"))
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
|
-
class Help <
|
5
|
+
class Help < ShopifyCLI::Command
|
6
6
|
def call(args, _name)
|
7
7
|
command = args.shift
|
8
8
|
if command && command != "help"
|
@@ -20,7 +20,7 @@ module ShopifyCli
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
preamble = @ctx.message("core.help.preamble",
|
23
|
+
preamble = @ctx.message("core.help.preamble", ShopifyCLI::TOOL_NAME)
|
24
24
|
@ctx.puts(preamble)
|
25
25
|
|
26
26
|
available_commands = resolved_commands.select { |_name, c| !c.hidden? }
|
@@ -43,7 +43,7 @@ module ShopifyCli
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def resolved_commands
|
46
|
-
|
46
|
+
ShopifyCLI::Commands::Registry
|
47
47
|
.resolved_commands
|
48
48
|
.sort
|
49
49
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
|
-
class Login <
|
5
|
+
class Login < ShopifyCLI::Command
|
6
6
|
PROTOCOL_REGEX = /^https?\:\/\//
|
7
7
|
PERMANENT_DOMAIN_SUFFIX = /\.myshopify\.(com|io)$/
|
8
8
|
|
@@ -15,7 +15,7 @@ module ShopifyCli
|
|
15
15
|
|
16
16
|
def call(*)
|
17
17
|
shop = (options.flags[:shop] || @ctx.getenv("SHOPIFY_SHOP" || nil))
|
18
|
-
|
18
|
+
ShopifyCLI::DB.set(shop: self.class.validate_shop(shop)) unless shop.nil?
|
19
19
|
|
20
20
|
if shop.nil? && Shopifolk.check
|
21
21
|
Shopifolk.reset
|
@@ -28,17 +28,17 @@ module ShopifyCli
|
|
28
28
|
|
29
29
|
# As password auth will soon be deprecated, we enable only in CI
|
30
30
|
if @ctx.ci? && (password = options.flags[:password] || @ctx.getenv("SHOPIFY_PASSWORD"))
|
31
|
-
|
31
|
+
ShopifyCLI::DB.set(shopify_exchange_token: password)
|
32
32
|
else
|
33
33
|
IdentityAuth.new(ctx: @ctx).authenticate
|
34
34
|
org = select_organization
|
35
|
-
|
35
|
+
ShopifyCLI::DB.set(organization_id: org["id"].to_i) unless org.nil?
|
36
36
|
Whoami.call([], "whoami")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.help
|
41
|
-
|
41
|
+
ShopifyCLI::Context.message("core.login.help", ShopifyCLI::TOOL_NAME)
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.validate_shop(shop)
|
@@ -75,7 +75,7 @@ module ShopifyCli
|
|
75
75
|
private
|
76
76
|
|
77
77
|
def select_organization
|
78
|
-
organizations =
|
78
|
+
organizations = ShopifyCLI::PartnersAPI::Organizations.fetch_all(@ctx)
|
79
79
|
|
80
80
|
if organizations.count == 0
|
81
81
|
nil
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "shopify_cli"
|
2
|
+
require "shopify_cli/theme/development_theme"
|
3
|
+
|
4
|
+
module ShopifyCLI
|
5
|
+
module Commands
|
6
|
+
class Logout < ShopifyCLI::Command
|
7
|
+
def call(*)
|
8
|
+
try_delete_development_theme
|
9
|
+
ShopifyCLI::IdentityAuth.delete_tokens_and_keys
|
10
|
+
ShopifyCLI::DB.del(:shop) if has_shop?
|
11
|
+
ShopifyCLI::DB.del(:organization_id) if has_organization_id?
|
12
|
+
ShopifyCLI::Shopifolk.reset
|
13
|
+
@ctx.puts(@ctx.message("core.logout.success"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.help
|
17
|
+
ShopifyCLI::Context.message("core.logout.help", ShopifyCLI::TOOL_NAME)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def has_shop?
|
23
|
+
ShopifyCLI::DB.exists?(:shop)
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_organization_id?
|
27
|
+
ShopifyCLI::DB.exists?(:organization_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def try_delete_development_theme
|
31
|
+
return unless has_shop?
|
32
|
+
|
33
|
+
ShopifyCLI::Theme::DevelopmentTheme.delete(@ctx)
|
34
|
+
rescue ShopifyCLI::API::APIRequestError
|
35
|
+
# Ignore since we can't delete it
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
5
|
class Populate
|
6
|
-
class Customer <
|
6
|
+
class Customer < ShopifyCLI::AdminAPI::PopulateResourceCommand
|
7
7
|
@input_type = :CustomerInput
|
8
8
|
|
9
9
|
def defaults
|
10
|
-
first_name, last_name =
|
10
|
+
first_name, last_name = ShopifyCLI::Helpers::Haikunator.name
|
11
11
|
{
|
12
12
|
firstName: first_name,
|
13
13
|
lastName: last_name,
|
@@ -16,7 +16,7 @@ module ShopifyCli
|
|
16
16
|
|
17
17
|
def message(data)
|
18
18
|
ret = data["customerCreate"]["customer"]
|
19
|
-
id =
|
19
|
+
id = ShopifyCLI::API.gid_to_id(ret["id"])
|
20
20
|
@ctx.message("core.populate.customer.added", ret["displayName"], @shop, admin_url, id)
|
21
21
|
end
|
22
22
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require "shopify_cli"
|
2
2
|
|
3
|
-
module
|
3
|
+
module ShopifyCLI
|
4
4
|
module Commands
|
5
5
|
class Populate
|
6
|
-
class DraftOrder <
|
6
|
+
class DraftOrder < ShopifyCLI::AdminAPI::PopulateResourceCommand
|
7
7
|
@input_type = :DraftOrderInput
|
8
8
|
|
9
9
|
def defaults
|
@@ -12,14 +12,14 @@ module ShopifyCli
|
|
12
12
|
originalUnitPrice: price,
|
13
13
|
quantity: 1,
|
14
14
|
weight: { value: 10, unit: "GRAMS" },
|
15
|
-
title:
|
15
|
+
title: ShopifyCLI::Helpers::Haikunator.title,
|
16
16
|
}],
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
20
|
def message(data)
|
21
21
|
ret = data["draftOrderCreate"]["draftOrder"]
|
22
|
-
id =
|
22
|
+
id = ShopifyCLI::API.gid_to_id(ret["id"])
|
23
23
|
@ctx.message("core.populate.draft_order.added", @shop, admin_url, id)
|
24
24
|
end
|
25
25
|
end
|
@@ -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
|