shopify-cli 2.2.2 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/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,6 +1,6 @@
|
|
|
1
1
|
require "shopify_cli"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
module Tasks
|
|
5
5
|
class TaskRegistry
|
|
6
6
|
def initialize
|
|
@@ -30,14 +30,14 @@ module ShopifyCli
|
|
|
30
30
|
Registry.add(-> () { const_get(task) }, name)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
register :ConfirmStore, :confirm_store, "
|
|
34
|
-
register :CreateApiClient, :create_api_client, "
|
|
35
|
-
register :EnsureAuthenticated, :ensure_authenticated, "
|
|
36
|
-
register :EnsureEnv, :ensure_env, "
|
|
37
|
-
register :EnsureLoopbackURL, :ensure_loopback_url, "
|
|
38
|
-
register :EnsureProjectType, :ensure_project_type, "
|
|
39
|
-
register :EnsureDevStore, :ensure_dev_store, "
|
|
40
|
-
register :SelectOrgAndShop, :select_org_and_shop, "
|
|
41
|
-
register :UpdateDashboardURLS, :update_dashboard_urls, "
|
|
33
|
+
register :ConfirmStore, :confirm_store, "shopify_cli/tasks/confirm_store"
|
|
34
|
+
register :CreateApiClient, :create_api_client, "shopify_cli/tasks/create_api_client"
|
|
35
|
+
register :EnsureAuthenticated, :ensure_authenticated, "shopify_cli/tasks/ensure_authenticated"
|
|
36
|
+
register :EnsureEnv, :ensure_env, "shopify_cli/tasks/ensure_env"
|
|
37
|
+
register :EnsureLoopbackURL, :ensure_loopback_url, "shopify_cli/tasks/ensure_loopback_url"
|
|
38
|
+
register :EnsureProjectType, :ensure_project_type, "shopify_cli/tasks/ensure_project_type"
|
|
39
|
+
register :EnsureDevStore, :ensure_dev_store, "shopify_cli/tasks/ensure_dev_store"
|
|
40
|
+
register :SelectOrgAndShop, :select_org_and_shop, "shopify_cli/tasks/select_org_and_shop"
|
|
41
|
+
register :UpdateDashboardURLS, :update_dashboard_urls, "shopify_cli/tasks/update_dashboard_urls"
|
|
42
42
|
end
|
|
43
43
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "openssl"
|
|
4
4
|
|
|
5
|
-
module
|
|
5
|
+
module ShopifyCLI
|
|
6
6
|
module Theme
|
|
7
7
|
module DevServer
|
|
8
8
|
class CertificateManager
|
|
@@ -19,13 +19,13 @@ module ShopifyCli
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def find_or_create_certificates!
|
|
22
|
-
@private_key = if (private_key_pem =
|
|
22
|
+
@private_key = if (private_key_pem = ShopifyCLI::DB.get(:ssl_private_key))
|
|
23
23
|
OpenSSL::PKey::RSA.new(private_key_pem)
|
|
24
24
|
else
|
|
25
25
|
OpenSSL::PKey::RSA.new(2048)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
@certificate = if (certificate_pem =
|
|
28
|
+
@certificate = if (certificate_pem = ShopifyCLI::DB.get(:ssl_certificate))
|
|
29
29
|
OpenSSL::X509::Certificate.new(certificate_pem)
|
|
30
30
|
else
|
|
31
31
|
x509_certificate = build_x509_certificate
|
|
@@ -35,8 +35,8 @@ module ShopifyCli
|
|
|
35
35
|
x509_certificate
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
ShopifyCLI::DB.set(ssl_certificate: certificate.to_pem)
|
|
39
|
+
ShopifyCLI::DB.set(ssl_private_key: private_key.to_pem)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
private
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
module Theme
|
|
5
5
|
module DevServer
|
|
6
6
|
# Based on Rack::HeaderHash
|
|
@@ -47,6 +47,10 @@ module ShopifyCli
|
|
|
47
47
|
super(k) || super(@names[k.downcase])
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
def fetch(k, default = nil)
|
|
51
|
+
self[k] || super(@names[k.downcase], default)
|
|
52
|
+
end
|
|
53
|
+
|
|
50
54
|
def []=(k, v)
|
|
51
55
|
canonical = k.downcase.freeze
|
|
52
56
|
# .delete is expensive, don't invoke it unless necessary
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
module Theme
|
|
5
5
|
module DevServer
|
|
6
6
|
class HotReload
|
|
@@ -34,11 +34,10 @@ module ShopifyCli
|
|
|
34
34
|
files = (modified + added).reject { |file| @ignore_filter&.ignore?(file) }
|
|
35
35
|
.map { |file| @theme[file].relative_path }
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
modified: files
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
@ctx.debug("[HotReload] Modified #{files.join(", ")}")
|
|
37
|
+
unless files.empty?
|
|
38
|
+
@streams.broadcast(JSON.generate(modified: files))
|
|
39
|
+
@ctx.debug("[HotReload] Modified #{files.join(", ")}")
|
|
40
|
+
end
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
private
|
|
@@ -3,7 +3,7 @@ require "net/http"
|
|
|
3
3
|
require "stringio"
|
|
4
4
|
require "time"
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module ShopifyCLI
|
|
7
7
|
module Theme
|
|
8
8
|
module DevServer
|
|
9
9
|
HOP_BY_HOP_HEADERS = [
|
|
@@ -79,7 +79,7 @@ module ShopifyCli
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def bearer_token
|
|
82
|
-
|
|
82
|
+
ShopifyCLI::DB.get(:storefront_renderer_production_exchange_token) ||
|
|
83
83
|
raise(KeyError, "storefront_renderer_production_exchange_token missing")
|
|
84
84
|
end
|
|
85
85
|
|
|
@@ -155,11 +155,16 @@ module ShopifyCli
|
|
|
155
155
|
Time.now - @last_session_cookie_refresh >= SESSION_COOKIE_MAX_AGE
|
|
156
156
|
end
|
|
157
157
|
|
|
158
|
+
def extract_secure_session_id_from_response_headers(headers)
|
|
159
|
+
return unless headers["set-cookie"]
|
|
160
|
+
headers["set-cookie"][SESSION_COOKIE_REGEXP, 1]
|
|
161
|
+
end
|
|
162
|
+
|
|
158
163
|
def secure_session_id
|
|
159
164
|
if secure_session_id_expired?
|
|
160
165
|
@ctx.debug("Refreshing preview _secure_session_id cookie")
|
|
161
166
|
response = request("HEAD", "/", query: { preview_theme_id: @theme.id })
|
|
162
|
-
@secure_session_id = response
|
|
167
|
+
@secure_session_id = extract_secure_session_id_from_response_headers(response)
|
|
163
168
|
@last_session_cookie_refresh = Time.now
|
|
164
169
|
end
|
|
165
170
|
|
|
@@ -179,6 +184,13 @@ module ShopifyCli
|
|
|
179
184
|
response_headers["location"].gsub!(%r{(https://#{@theme.shop})}, "http://127.0.0.1:9292")
|
|
180
185
|
end
|
|
181
186
|
|
|
187
|
+
new_session_id = extract_secure_session_id_from_response_headers(response_headers)
|
|
188
|
+
if new_session_id
|
|
189
|
+
@ctx.debug("New _secure_session_id cookie from response")
|
|
190
|
+
@secure_session_id = new_session_id
|
|
191
|
+
@last_session_cookie_refresh = Time.now
|
|
192
|
+
end
|
|
193
|
+
|
|
182
194
|
response_headers
|
|
183
195
|
end
|
|
184
196
|
|
|
@@ -14,7 +14,7 @@ require_relative "dev_server/certificate_manager"
|
|
|
14
14
|
|
|
15
15
|
require "pathname"
|
|
16
16
|
|
|
17
|
-
module
|
|
17
|
+
module ShopifyCLI
|
|
18
18
|
module Theme
|
|
19
19
|
module DevServer
|
|
20
20
|
class << self
|
|
@@ -80,8 +80,8 @@ module ShopifyCli
|
|
|
80
80
|
)
|
|
81
81
|
watcher.stop
|
|
82
82
|
|
|
83
|
-
rescue
|
|
84
|
-
|
|
83
|
+
rescue ShopifyCLI::API::APIRequestForbiddenError,
|
|
84
|
+
ShopifyCLI::API::APIRequestUnauthorizedError
|
|
85
85
|
@ctx.abort("You are not authorized to edit themes on #{theme.shop}.\n" \
|
|
86
86
|
"Make sure you are a user of that store, and allowed to edit themes.")
|
|
87
87
|
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require_relative "theme"
|
|
3
|
+
|
|
4
|
+
require "socket"
|
|
5
|
+
require "securerandom"
|
|
6
|
+
|
|
7
|
+
module ShopifyCLI
|
|
8
|
+
module Theme
|
|
9
|
+
API_NAME_LIMIT = 50
|
|
10
|
+
|
|
11
|
+
class DevelopmentTheme < Theme
|
|
12
|
+
def id
|
|
13
|
+
ShopifyCLI::DB.get(:development_theme_id)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def name
|
|
17
|
+
existing_name = ShopifyCLI::DB.get(:development_theme_name)
|
|
18
|
+
# Up to version 2.3.0 (included) generated names stored locally
|
|
19
|
+
# could have more than 50 characters and the API rejected them.
|
|
20
|
+
# This code ensures we update the name for those users to ensure
|
|
21
|
+
# the name stays under the limit.
|
|
22
|
+
if existing_name.nil? || existing_name.length > API_NAME_LIMIT
|
|
23
|
+
generate_theme_name
|
|
24
|
+
else
|
|
25
|
+
existing_name
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def role
|
|
30
|
+
"development"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def ensure_exists!
|
|
34
|
+
if exists?
|
|
35
|
+
@ctx.debug("Using temporary development theme: ##{id} #{name}")
|
|
36
|
+
else
|
|
37
|
+
create
|
|
38
|
+
@ctx.debug("Created temporary development theme: #{@id}")
|
|
39
|
+
ShopifyCLI::DB.set(development_theme_id: @id)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def exists?
|
|
44
|
+
return false unless id
|
|
45
|
+
|
|
46
|
+
ShopifyCLI::AdminAPI.rest_request(
|
|
47
|
+
@ctx,
|
|
48
|
+
shop: shop,
|
|
49
|
+
path: "themes/#{id}.json",
|
|
50
|
+
api_version: "unstable",
|
|
51
|
+
)
|
|
52
|
+
rescue ShopifyCLI::API::APIRequestNotFoundError
|
|
53
|
+
false
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def delete
|
|
57
|
+
super if exists?
|
|
58
|
+
ShopifyCLI::DB.del(:development_theme_id) if ShopifyCLI::DB.exists?(:development_theme_id)
|
|
59
|
+
ShopifyCLI::DB.del(:development_theme_name) if ShopifyCLI::DB.exists?(:development_theme_name)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.delete(ctx)
|
|
63
|
+
new(ctx).delete
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def generate_theme_name
|
|
69
|
+
hostname = Socket.gethostname.split(".").shift
|
|
70
|
+
hash = SecureRandom.hex(3)
|
|
71
|
+
|
|
72
|
+
theme_name = "Development ()"
|
|
73
|
+
hostname_character_limit = API_NAME_LIMIT - theme_name.length - hash.length - 1
|
|
74
|
+
identifier = "#{hash}-#{hostname[0, hostname_character_limit]}"
|
|
75
|
+
theme_name = "Development (#{identifier})"
|
|
76
|
+
|
|
77
|
+
ShopifyCLI::DB.set(development_theme_name: theme_name)
|
|
78
|
+
|
|
79
|
+
theme_name
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
require_relative "mime_type"
|
|
3
3
|
|
|
4
|
-
module
|
|
4
|
+
module ShopifyCLI
|
|
5
5
|
module Theme
|
|
6
6
|
class File < Struct.new(:path)
|
|
7
7
|
attr_reader :relative_path
|
|
@@ -17,12 +17,20 @@ module ShopifyCli
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def read
|
|
20
|
-
|
|
20
|
+
if text?
|
|
21
|
+
path.read
|
|
22
|
+
else
|
|
23
|
+
path.read(mode: "rb")
|
|
24
|
+
end
|
|
21
25
|
end
|
|
22
26
|
|
|
23
|
-
def write(
|
|
27
|
+
def write(content)
|
|
24
28
|
path.parent.mkpath unless path.parent.directory?
|
|
25
|
-
|
|
29
|
+
if text?
|
|
30
|
+
path.write(content)
|
|
31
|
+
else
|
|
32
|
+
path.write(content, 0, mode: "wb")
|
|
33
|
+
end
|
|
26
34
|
end
|
|
27
35
|
|
|
28
36
|
def delete
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module ShopifyCLI
|
|
4
4
|
module Theme
|
|
5
5
|
class IgnoreFilter
|
|
6
6
|
FILE = ".shopifyignore"
|
|
@@ -59,6 +59,13 @@ module ShopifyCli
|
|
|
59
59
|
@globs = globs
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
def add_patterns(patterns)
|
|
63
|
+
regexes, globs = patterns_to_regexes_and_globs(patterns)
|
|
64
|
+
|
|
65
|
+
@regexes += regexes
|
|
66
|
+
@globs += globs
|
|
67
|
+
end
|
|
68
|
+
|
|
62
69
|
def match?(path)
|
|
63
70
|
path = path.to_s
|
|
64
71
|
|
|
@@ -3,7 +3,7 @@ require "thread"
|
|
|
3
3
|
require "json"
|
|
4
4
|
require "base64"
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module ShopifyCLI
|
|
7
7
|
module Theme
|
|
8
8
|
class Syncer
|
|
9
9
|
class Operation < Struct.new(:method, :file)
|
|
@@ -80,7 +80,7 @@ module ShopifyCli
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def fetch_checksums!
|
|
83
|
-
_status, response =
|
|
83
|
+
_status, response = ShopifyCLI::AdminAPI.rest_request(
|
|
84
84
|
@ctx,
|
|
85
85
|
shop: @theme.shop,
|
|
86
86
|
path: "themes/#{@theme.id}/assets.json",
|
|
@@ -211,7 +211,7 @@ module ShopifyCli
|
|
|
211
211
|
used, total = limit.split("/").map(&:to_i)
|
|
212
212
|
backoff_if_near_limit!(used, total)
|
|
213
213
|
end
|
|
214
|
-
rescue
|
|
214
|
+
rescue ShopifyCLI::API::APIRequestError => e
|
|
215
215
|
report_error(
|
|
216
216
|
"{{red:ERROR}} {{blue:#{operation}}}:\n " +
|
|
217
217
|
parse_api_errors(e).join("\n ")
|
|
@@ -228,7 +228,7 @@ module ShopifyCli
|
|
|
228
228
|
asset[:attachment] = Base64.encode64(file.read)
|
|
229
229
|
end
|
|
230
230
|
|
|
231
|
-
_status, body, response =
|
|
231
|
+
_status, body, response = ShopifyCLI::AdminAPI.rest_request(
|
|
232
232
|
@ctx,
|
|
233
233
|
shop: @theme.shop,
|
|
234
234
|
path: "themes/#{@theme.id}/assets.json",
|
|
@@ -243,7 +243,7 @@ module ShopifyCli
|
|
|
243
243
|
end
|
|
244
244
|
|
|
245
245
|
def get(file)
|
|
246
|
-
_status, body, response =
|
|
246
|
+
_status, body, response = ShopifyCLI::AdminAPI.rest_request(
|
|
247
247
|
@ctx,
|
|
248
248
|
shop: @theme.shop,
|
|
249
249
|
path: "themes/#{@theme.id}/assets.json",
|
|
@@ -256,7 +256,7 @@ module ShopifyCli
|
|
|
256
256
|
|
|
257
257
|
attachment = body.dig("asset", "attachment")
|
|
258
258
|
value = if attachment
|
|
259
|
-
file.write(Base64.decode64(attachment)
|
|
259
|
+
file.write(Base64.decode64(attachment))
|
|
260
260
|
else
|
|
261
261
|
file.write(body.dig("asset", "value"))
|
|
262
262
|
end
|
|
@@ -265,7 +265,7 @@ module ShopifyCli
|
|
|
265
265
|
end
|
|
266
266
|
|
|
267
267
|
def delete(file)
|
|
268
|
-
_status, _body, response =
|
|
268
|
+
_status, _body, response = ShopifyCLI::AdminAPI.rest_request(
|
|
269
269
|
@ctx,
|
|
270
270
|
shop: @theme.shop,
|
|
271
271
|
path: "themes/#{@theme.id}/assets.json",
|
|
@@ -4,7 +4,7 @@ require_relative "file"
|
|
|
4
4
|
require "pathname"
|
|
5
5
|
require "time"
|
|
6
6
|
|
|
7
|
-
module
|
|
7
|
+
module ShopifyCLI
|
|
8
8
|
module Theme
|
|
9
9
|
class InvalidThemeRole < StandardError; end
|
|
10
10
|
|
|
@@ -101,7 +101,7 @@ module ShopifyCli
|
|
|
101
101
|
def create
|
|
102
102
|
raise InvalidThemeRole, "Can't create live theme. Use publish." if live?
|
|
103
103
|
|
|
104
|
-
_status, body =
|
|
104
|
+
_status, body = ShopifyCLI::AdminAPI.rest_request(
|
|
105
105
|
@ctx,
|
|
106
106
|
shop: shop,
|
|
107
107
|
path: "themes.json",
|
|
@@ -144,11 +144,11 @@ module ShopifyCli
|
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
def current_development?
|
|
147
|
-
development? && id ==
|
|
147
|
+
development? && id == ShopifyCLI::DB.get(:development_theme_id)
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
def foreign_development?
|
|
151
|
-
development? && id !=
|
|
151
|
+
development? && id != ShopifyCLI::DB.get(:development_theme_id)
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
def to_h
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
module
|
|
2
|
+
module ShopifyCLI
|
|
3
3
|
##
|
|
4
4
|
# `TransformDataStructure` helps to standardize data structure access. It
|
|
5
5
|
# traverses nested data structures and can convert
|
|
@@ -22,13 +22,13 @@ module ShopifyCli
|
|
|
22
22
|
# Since `TransformDataStructure` is a method object, it can easily be chained:
|
|
23
23
|
#
|
|
24
24
|
# require 'open-uri'
|
|
25
|
-
#
|
|
25
|
+
# ShopifyCLI::Result
|
|
26
26
|
# .call { open("https://jsonplaceholder.typicode.com/todos/1") }
|
|
27
27
|
# .map(&TransformDataStructure.new(symbolize_keys: true, underscore_keys: true))
|
|
28
28
|
# .value # => { id: 1, user_id: 1, ... }
|
|
29
29
|
#
|
|
30
30
|
class TransformDataStructure
|
|
31
|
-
include
|
|
31
|
+
include ShopifyCLI::MethodObject
|
|
32
32
|
|
|
33
33
|
class << self
|
|
34
34
|
private
|
|
@@ -53,7 +53,7 @@ module ShopifyCli
|
|
|
53
53
|
result[transform_key(key)] = call(value).value
|
|
54
54
|
end
|
|
55
55
|
else
|
|
56
|
-
|
|
56
|
+
ShopifyCLI::Result.success(object)
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -4,7 +4,7 @@ require "shopify_cli"
|
|
|
4
4
|
require "forwardable"
|
|
5
5
|
require "uri"
|
|
6
6
|
|
|
7
|
-
module
|
|
7
|
+
module ShopifyCLI
|
|
8
8
|
##
|
|
9
9
|
# Wraps around ngrok functionality to allow you to spawn a ngrok proccess in the
|
|
10
10
|
# background and stop the process when you need to. It also allows control over
|
|
@@ -39,8 +39,8 @@ module ShopifyCli
|
|
|
39
39
|
# * `ctx` - running context from your command
|
|
40
40
|
#
|
|
41
41
|
def stop(ctx)
|
|
42
|
-
if
|
|
43
|
-
if
|
|
42
|
+
if ShopifyCLI::ProcessSupervision.running?(:ngrok)
|
|
43
|
+
if ShopifyCLI::ProcessSupervision.stop(:ngrok)
|
|
44
44
|
ctx.puts(ctx.message("core.tunnel.stopped"))
|
|
45
45
|
else
|
|
46
46
|
ctx.abort(ctx.message("core.tunnel.error.stop"))
|
|
@@ -75,7 +75,7 @@ module ShopifyCli
|
|
|
75
75
|
end
|
|
76
76
|
ctx.puts(ctx.message("core.tunnel.start", url))
|
|
77
77
|
ctx.puts(ctx.message("core.tunnel.will_timeout", seconds_to_hm(seconds_remaining)))
|
|
78
|
-
ctx.puts(ctx.message("core.tunnel.signup_suggestion",
|
|
78
|
+
ctx.puts(ctx.message("core.tunnel.signup_suggestion", ShopifyCLI::TOOL_NAME))
|
|
79
79
|
end
|
|
80
80
|
url
|
|
81
81
|
end
|
|
@@ -91,7 +91,7 @@ module ShopifyCli
|
|
|
91
91
|
#
|
|
92
92
|
def auth(ctx, token)
|
|
93
93
|
install(ctx)
|
|
94
|
-
ctx.system(File.join(
|
|
94
|
+
ctx.system(File.join(ShopifyCLI.cache_dir, "ngrok"), "authtoken", token)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
##
|
|
@@ -145,28 +145,28 @@ module ShopifyCli
|
|
|
145
145
|
|
|
146
146
|
def install(ctx)
|
|
147
147
|
ngrok = "ngrok#{ctx.executable_file_extension}"
|
|
148
|
-
return if File.exist?(File.join(
|
|
148
|
+
return if File.exist?(File.join(ShopifyCLI.cache_dir, ngrok))
|
|
149
149
|
check_prereq_command(ctx, "curl")
|
|
150
150
|
check_prereq_command(ctx, ctx.linux? ? "unzip" : "tar")
|
|
151
151
|
spinner = CLI::UI::SpinGroup.new
|
|
152
152
|
spinner.add(ctx.message("core.tunnel.installing")) do
|
|
153
|
-
zip_dest = File.join(
|
|
153
|
+
zip_dest = File.join(ShopifyCLI.cache_dir, "ngrok.zip")
|
|
154
154
|
unless File.exist?(zip_dest)
|
|
155
|
-
ctx.system("curl", "-o", zip_dest, DOWNLOAD_URLS[ctx.os], chdir:
|
|
155
|
+
ctx.system("curl", "-o", zip_dest, DOWNLOAD_URLS[ctx.os], chdir: ShopifyCLI.cache_dir)
|
|
156
156
|
end
|
|
157
157
|
args = if ctx.linux?
|
|
158
158
|
%W(unzip -u #{zip_dest})
|
|
159
159
|
else
|
|
160
160
|
%W(tar -xf #{zip_dest})
|
|
161
161
|
end
|
|
162
|
-
ctx.system(*args, chdir:
|
|
162
|
+
ctx.system(*args, chdir: ShopifyCLI.cache_dir)
|
|
163
163
|
ctx.rm(zip_dest)
|
|
164
164
|
end
|
|
165
165
|
spinner.wait
|
|
166
166
|
|
|
167
167
|
# final check to see if ngrok is accessible
|
|
168
|
-
unless File.exist?(File.join(
|
|
169
|
-
ctx.abort(ctx.message("core.tunnel.error.ngrok", ngrok,
|
|
168
|
+
unless File.exist?(File.join(ShopifyCLI.cache_dir, ngrok))
|
|
169
|
+
ctx.abort(ctx.message("core.tunnel.error.ngrok", ngrok, ShopifyCLI.cache_dir))
|
|
170
170
|
end
|
|
171
171
|
end
|
|
172
172
|
|
|
@@ -178,7 +178,7 @@ module ShopifyCli
|
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
def ngrok_command(port)
|
|
181
|
-
"\"#{File.join(
|
|
181
|
+
"\"#{File.join(ShopifyCLI.cache_dir, "ngrok")}\" http -inspect=false -log=stdout -log-level=debug #{port}"
|
|
182
182
|
end
|
|
183
183
|
|
|
184
184
|
def seconds_to_hm(seconds)
|
|
@@ -186,14 +186,14 @@ module ShopifyCli
|
|
|
186
186
|
end
|
|
187
187
|
|
|
188
188
|
def start_ngrok(ctx, port)
|
|
189
|
-
process =
|
|
189
|
+
process = ShopifyCLI::ProcessSupervision.start(:ngrok, ngrok_command(port))
|
|
190
190
|
log = fetch_url(ctx, process.log_path)
|
|
191
191
|
seconds_remaining = (process.time.to_i + log.timeout) - Time.now.to_i
|
|
192
192
|
[log.url, log.account, seconds_remaining]
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
def restart_ngrok(ctx, port)
|
|
196
|
-
unless
|
|
196
|
+
unless ShopifyCLI::ProcessSupervision.stop(:ngrok)
|
|
197
197
|
ctx.abort(ctx.message("core.tunnel.error.stop"))
|
|
198
198
|
end
|
|
199
199
|
start_ngrok(ctx, port)
|