Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
### Added
* [#2520](https://github.com/Shopify/shopify-cli/pull/2520): Add the option to ignore new version warnings by passing the `SHOPIFY_CLI_RUN_AS_SUBPROCESS` environment variable
* [#2440](https://github.com/Shopify/shopify-cli/pull/2440): Warn when using CLI 2.0 in a CLI 3.0 project
* [#2558](https://github.com/Shopify/shopify-cli/pull/2558): Enable Theme Kit Access passwords

## Version 2.22.0 - 2022-08-08

Expand Down
2 changes: 1 addition & 1 deletion lib/project_types/theme/commands/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def themes_presenter
end

def shop
ShopifyCLI::Theme::ThemeAdminAPI.new(@ctx).get_shop_or_abort
ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)
end
end
end
Expand Down
9 changes: 4 additions & 5 deletions lib/shopify_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ module ShopifyCLI
)
end

autoload :AppTypeDetector, "shopify_cli/app_type_detector"
autoload :Constants, "shopify_cli/constants"
autoload :Environment, "shopify_cli/environment"
autoload :AdminAPI, "shopify_cli/admin_api"
autoload :API, "shopify_cli/api"
autoload :AppTypeDetector, "shopify_cli/app_type_detector"
autoload :Command, "shopify_cli/command"
autoload :CommandOptions, "shopify_cli/command_options"
autoload :Commands, "shopify_cli/commands"
autoload :Connect, "shopify_cli/connect"
autoload :Constants, "shopify_cli/constants"
autoload :Context, "shopify_cli/context"
autoload :Core, "shopify_cli/core"
autoload :DB, "shopify_cli/db"
autoload :Environment, "shopify_cli/environment"
autoload :Feature, "shopify_cli/feature"
autoload :Form, "shopify_cli/form"
autoload :Git, "shopify_cli/git"
Expand All @@ -118,11 +118,11 @@ module ShopifyCLI
autoload :IdentityAuth, "shopify_cli/identity_auth"
autoload :JsDeps, "shopify_cli/js_deps"
autoload :JsSystem, "shopify_cli/js_system"
autoload :PHPDeps, "shopify_cli/php_deps"
autoload :LazyDelegator, "shopify_cli/lazy_delegator"
autoload :MethodObject, "shopify_cli/method_object"
autoload :Options, "shopify_cli/options"
autoload :PartnersAPI, "shopify_cli/partners_api"
autoload :PHPDeps, "shopify_cli/php_deps"
autoload :ProcessSupervision, "shopify_cli/process_supervision"
autoload :Project, "shopify_cli/project"
autoload :ProjectType, "shopify_cli/project_type"
Expand All @@ -134,7 +134,6 @@ module ShopifyCLI
autoload :Shopifolk, "shopify_cli/shopifolk"
autoload :Task, "shopify_cli/task"
autoload :Tasks, "shopify_cli/tasks"
autoload :ThemeAccessAPI, "shopify_cli/theme_access_api"
autoload :TransformDataStructure, "shopify_cli/transform_data_structure"
autoload :Tunnel, "shopify_cli/tunnel"
autoload :Utilities, "shopify_cli/utilities"
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_cli/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module EnvironmentVariables

# Monorail
MONORAIL_REAL_EVENTS = "MONORAIL_REAL_EVENTS"
STORE = "SHOPIFY_SHOP"
STORE = "SHOPIFY_CLI_STORE"
end

module SupportedVersions
Expand Down
6 changes: 0 additions & 6 deletions lib/shopify_cli/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ module Environment
Constants::EnvironmentVariables::SPIN_NAMESPACE,
Constants::EnvironmentVariables::SPIN_HOST,
]
# https://github.com/Shopify/themekit-access/blob/ecda007604279ce485e6c80c677cc6e7b4e464be/app/models/password_token.rb#L8
THEME_ACCESS_PASSWORD_PREFIX = "shptka_"

def self.ruby_version(context: Context.new)
output, status = context.capture2e("ruby", "--version")
Expand Down Expand Up @@ -190,9 +188,5 @@ def self.run_as_subprocess?(env_variables: ENV)
env_variables: env_variables
)
end

def self.theme_access_password?
admin_auth_token&.start_with?(THEME_ACCESS_PASSWORD_PREFIX)
end
end
end
1 change: 0 additions & 1 deletion lib/shopify_cli/messages/messages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ module Messages
forbidden: <<~FORBIDDEN,
Command not allowed with current login. Please check your login details with {{command:%s whoami}}. You may need to request additional permissions for this action.
FORBIDDEN
theme_access_no_store: "No store found. Please pass it through the environment variable SHOPIFY_SHOP",
internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
invalid_url: "Invalid URL: %s",
Expand Down
6 changes: 1 addition & 5 deletions lib/shopify_cli/theme/syncer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ def initialize(ctx, theme:, include_filter: nil, ignore_filter: nil, overwrite_j
# Checksums of assets with errors.
@error_checksums = []

# Do not use the throttler when --stable is passed or a Theme Access password is set
# (Theme Access API is not compatible yet with bulks)
active_throttler = !stable && !Environment.theme_access_password?

# Initialize `api_client` on main thread
@api_client = ThemeAdminAPIThrottler.new(
@ctx,
ThemeAdminAPI.new(@ctx, @theme.shop),
active_throttler
!stable
)
end

Expand Down
8 changes: 2 additions & 6 deletions lib/shopify_cli/theme/theme_admin_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def delete(path:, **args, &block)
end

def get_shop_or_abort # rubocop:disable Naming/AccessorMethodName
api_client.get_shop_or_abort(@ctx)
ShopifyCLI::AdminAPI.get_shop_or_abort(@ctx)
end

def rest_request(**args)
status, body, response = api_client.rest_request(
status, body, response = ShopifyCLI::AdminAPI.rest_request(
@ctx,
shop: @shop,
api_version: API_VERSION,
Expand Down Expand Up @@ -67,10 +67,6 @@ def rest_request(**args)

private

def api_client
@api_client ||= Environment.theme_access_password? ? ShopifyCLI::ThemeAccessAPI : ShopifyCLI::AdminAPI
end

def permission_error
ensure_user_error = @ctx.message("theme.ensure_user_error", shop)
ensure_user_try_this = @ctx.message("theme.ensure_user_try_this")
Expand Down
87 changes: 0 additions & 87 deletions lib/shopify_cli/theme_access_api.rb

This file was deleted.

32 changes: 6 additions & 26 deletions test/shopify-cli/theme/theme_admin_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_get
path: path,
}

expect_admin_api_request_with_params(request_params)
expect_correct_request_arguments(request_params)

@api_client.get(
path: path
Expand All @@ -50,7 +50,7 @@ def test_put
body: body,
}

expect_admin_api_request_with_params(request_params)
expect_correct_request_arguments(request_params)

@api_client.put(
path: path,
Expand All @@ -70,7 +70,7 @@ def test_post
body: body,
}

expect_admin_api_request_with_params(request_params)
expect_correct_request_arguments(request_params)

@api_client.post(
path: path,
Expand All @@ -85,7 +85,7 @@ def test_delete
path: path,
}

expect_admin_api_request_with_params(request_params)
expect_correct_request_arguments(request_params)

@api_client.delete(
path: path
Expand Down Expand Up @@ -124,7 +124,7 @@ def test_does_not_pass_nil_arguments
path: path,
}

expect_admin_api_request_with_params(request_params)
expect_correct_request_arguments(request_params)

@api_client.post(
path: path,
Expand Down Expand Up @@ -229,29 +229,9 @@ def test_unauthorized_response_with_other_error
refute(@api_client.send(:unauthorized_response?, error))
end

def test_theme_access_api_is_used_with_theme_access_password
shop = "testshop.myshopify.io"
password = "shptka_XXX"
Environment.expects(:store).returns(shop)
Environment.expects(:admin_auth_token).returns(password)
api_client = ThemeAdminAPI.new(@ctx)
request_params = {
method: "POST",
path: "themes.json",
query: "query",
body: JSON.generate({ theme: {} }),
token: password,
}

ShopifyCLI::ThemeAccessAPI.expects(:rest_request)
.with(@ctx, shop: shop, api_version: @api_version, **request_params)

api_client.send(:rest_request, **request_params)
end

private

def expect_admin_api_request_with_params(request_params)
def expect_correct_request_arguments(request_params)
ShopifyCLI::AdminAPI.expects(:rest_request)
.with(@ctx, shop: @shop, api_version: @api_version, **request_params)
end
Expand Down
54 changes: 0 additions & 54 deletions test/shopify-cli/theme_access_api_test.rb

This file was deleted.