shopify-cli 2.28.0 → 2.29.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/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/project_types/theme/commands/common/shop_helper.rb +1 -1
- data/lib/shopify_cli/constants.rb +2 -1
- data/lib/shopify_cli/environment.rb +6 -0
- data/lib/shopify_cli/messages/messages.rb +3 -0
- data/lib/shopify_cli/theme/syncer.rb +5 -1
- data/lib/shopify_cli/theme/theme_access_api.rb +89 -0
- data/lib/shopify_cli/theme/theme_admin_api.rb +8 -2
- data/lib/shopify_cli/version.rb +1 -1
- data/lib/shopify_cli.rb +4 -4
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f07c45a6fc9d6b93d9f2826a7ad9eb139842d8b7f35717ca5fb17291285c330
|
|
4
|
+
data.tar.gz: 774e222e76f9a8d30b68e8b0756ed4cecbc8281d302d94c131d072c123b19f8c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eab29689be4de3a23b0b9dd14401a130d6f37cc1064c02f16bbce0656d378d487666bd964dfa673b8fcc48344b01acf8d10899e4fb3755c7f5f46c5dd8c46385
|
|
7
|
+
data.tar.gz: 01d9830606768a70de1de312527875d997dce26f1913c44fd6ffd82407afc7962931fe38dd7568e49c899438e33bf3f1b465b6b5d73bb0585d25643c0d26d5a2
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## Version 2.29.0 - 2022-10-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
* [#2664](https://github.com/Shopify/shopify-cli/pull/2664): Enable Theme Kit Access passwords
|
|
9
|
+
|
|
5
10
|
## Version 2.28.0 - 2022-10-17
|
|
6
11
|
|
|
7
12
|
### Fixed
|
data/Gemfile.lock
CHANGED
|
@@ -10,6 +10,8 @@ module ShopifyCLI
|
|
|
10
10
|
Constants::EnvironmentVariables::SPIN_NAMESPACE,
|
|
11
11
|
Constants::EnvironmentVariables::SPIN_HOST,
|
|
12
12
|
]
|
|
13
|
+
# https://github.com/Shopify/themekit-access/blob/4c3c917d78443160dcf24376a8b5ac6b9bef0bcd/app/models/password_token.rb#L8
|
|
14
|
+
THEME_ACCESS_PASSWORD_PREFIX = "shptka_"
|
|
13
15
|
|
|
14
16
|
def self.ruby_version(context: Context.new)
|
|
15
17
|
output, status = context.capture2e("ruby", "--version")
|
|
@@ -188,5 +190,9 @@ module ShopifyCLI
|
|
|
188
190
|
env_variables: env_variables
|
|
189
191
|
)
|
|
190
192
|
end
|
|
193
|
+
|
|
194
|
+
def self.theme_access_password?
|
|
195
|
+
admin_auth_token&.start_with?(THEME_ACCESS_PASSWORD_PREFIX)
|
|
196
|
+
end
|
|
191
197
|
end
|
|
192
198
|
end
|
|
@@ -541,6 +541,9 @@ module ShopifyCLI
|
|
|
541
541
|
forbidden: <<~FORBIDDEN,
|
|
542
542
|
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.
|
|
543
543
|
FORBIDDEN
|
|
544
|
+
theme_access_invalid_password: "Invalid password. Please check that it was generated from Theme Access app"\
|
|
545
|
+
" for the current store.",
|
|
546
|
+
theme_access_no_store: "No store found. Please pass it through the environment variable SHOPIFY_SHOP",
|
|
544
547
|
internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
|
|
545
548
|
internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
|
|
546
549
|
invalid_url: "Invalid URL: %s",
|
|
@@ -69,11 +69,15 @@ module ShopifyCLI
|
|
|
69
69
|
# Checksums of assets with errors.
|
|
70
70
|
@error_checksums = []
|
|
71
71
|
|
|
72
|
+
# Do not use the throttler when --stable is passed or a Theme Access password is set
|
|
73
|
+
# (Theme Access API is not compatible yet with bulks)
|
|
74
|
+
throttler_enabled = !stable && !Environment.theme_access_password?
|
|
75
|
+
|
|
72
76
|
# Initialize `api_client` on main thread
|
|
73
77
|
@api_client = ThemeAdminAPIThrottler.new(
|
|
74
78
|
@ctx,
|
|
75
79
|
ThemeAdminAPI.new(@ctx, @theme.shop),
|
|
76
|
-
|
|
80
|
+
throttler_enabled
|
|
77
81
|
)
|
|
78
82
|
end
|
|
79
83
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "shopify_cli"
|
|
4
|
+
|
|
5
|
+
module ShopifyCLI
|
|
6
|
+
module Theme
|
|
7
|
+
##
|
|
8
|
+
# ShopifyCLI::ThemeAccessAPI is a wrapper to use Shopify Theme Access API, which allows using passwords
|
|
9
|
+
# generated from Shopify Theme Access app to access the Shopify Admin API (for theme operations)
|
|
10
|
+
#
|
|
11
|
+
class ThemeAccessAPI < API
|
|
12
|
+
BASE_URL = "theme-kit-access.shopifyapps.com"
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
##
|
|
16
|
+
# #### Parameters
|
|
17
|
+
# - `ctx`: running context from your command
|
|
18
|
+
# - `shop`: shop domain string for shop whose admin you are calling
|
|
19
|
+
# - `path`: path string (excluding prefixes and API version) for specific JSON that you are requesting
|
|
20
|
+
# ex. "data.json" instead of "/admin/api/unstable/data.json"
|
|
21
|
+
# - `body`: data string for corresponding REST request types
|
|
22
|
+
# - `method`: REST request string for the type of request; if nil, will perform GET request
|
|
23
|
+
# - `api_version`: an api version string to specify version. Default value: unstable
|
|
24
|
+
#
|
|
25
|
+
# #### Raises
|
|
26
|
+
#
|
|
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
|
+
#
|
|
32
|
+
# #### Returns
|
|
33
|
+
#
|
|
34
|
+
# * `resp` - JSON response array
|
|
35
|
+
#
|
|
36
|
+
# #### Example
|
|
37
|
+
#
|
|
38
|
+
# ThemeAccessAPI.rest_request(@ctx, shop: 'shop.myshopify.com', path: 'data.json')
|
|
39
|
+
#
|
|
40
|
+
def rest_request(ctx, shop:, path:, query: nil, body: nil, method: "GET", api_version: "unstable")
|
|
41
|
+
client = api_client(ctx, api_version, shop, path: path)
|
|
42
|
+
url = build_url(api_version, path, query)
|
|
43
|
+
client.request(url: url, body: body, headers: headers(shop), method: method)
|
|
44
|
+
rescue ShopifyCLI::API::APIRequestForbiddenError,
|
|
45
|
+
ShopifyCLI::API::APIRequestUnauthorizedError
|
|
46
|
+
ctx.abort(ctx.message("core.api.error.theme_access_invalid_password"))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_shop_or_abort(ctx)
|
|
50
|
+
env_store = Environment.store
|
|
51
|
+
return env_store unless env_store.nil?
|
|
52
|
+
ctx.abort(
|
|
53
|
+
ctx.message("core.api.error.theme_access_no_store")
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def build_url(api_version, path, query = nil)
|
|
60
|
+
URI::HTTPS.build(
|
|
61
|
+
host: BASE_URL,
|
|
62
|
+
path: "/cli/admin/api/#{api_version}/#{path}",
|
|
63
|
+
query: query
|
|
64
|
+
).to_s
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def api_client(ctx, api_version, _shop, path: "graphql.json")
|
|
68
|
+
new(
|
|
69
|
+
ctx: ctx,
|
|
70
|
+
token: Environment.admin_auth_token,
|
|
71
|
+
url: build_url(api_version, path),
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def headers(shop)
|
|
76
|
+
{
|
|
77
|
+
"X-Shopify-Shop" => shop,
|
|
78
|
+
}
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def auth_headers(token)
|
|
83
|
+
{
|
|
84
|
+
"X-Shopify-Access-Token" => token,
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "theme_access_api"
|
|
4
|
+
|
|
3
5
|
module ShopifyCLI
|
|
4
6
|
module Theme
|
|
5
7
|
class ThemeAdminAPI
|
|
@@ -29,11 +31,11 @@ module ShopifyCLI
|
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
def get_shop_or_abort # rubocop:disable Naming/AccessorMethodName
|
|
32
|
-
|
|
34
|
+
api_client.get_shop_or_abort(@ctx)
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def rest_request(**args)
|
|
36
|
-
status, body, response =
|
|
38
|
+
status, body, response = api_client.rest_request(
|
|
37
39
|
@ctx,
|
|
38
40
|
shop: @shop,
|
|
39
41
|
api_version: API_VERSION,
|
|
@@ -67,6 +69,10 @@ module ShopifyCLI
|
|
|
67
69
|
|
|
68
70
|
private
|
|
69
71
|
|
|
72
|
+
def api_client
|
|
73
|
+
@api_client ||= Environment.theme_access_password? ? ThemeAccessAPI : ShopifyCLI::AdminAPI
|
|
74
|
+
end
|
|
75
|
+
|
|
70
76
|
def permission_error
|
|
71
77
|
ensure_user_error = @ctx.message("theme.ensure_user_error", shop)
|
|
72
78
|
ensure_user_try_this = @ctx.message("theme.ensure_user_try_this")
|
data/lib/shopify_cli/version.rb
CHANGED
data/lib/shopify_cli.rb
CHANGED
|
@@ -97,18 +97,18 @@ module ShopifyCLI
|
|
|
97
97
|
)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
autoload :AppTypeDetector, "shopify_cli/app_type_detector"
|
|
101
|
-
autoload :Constants, "shopify_cli/constants"
|
|
102
|
-
autoload :Environment, "shopify_cli/environment"
|
|
103
100
|
autoload :AdminAPI, "shopify_cli/admin_api"
|
|
104
101
|
autoload :API, "shopify_cli/api"
|
|
102
|
+
autoload :AppTypeDetector, "shopify_cli/app_type_detector"
|
|
105
103
|
autoload :Command, "shopify_cli/command"
|
|
106
104
|
autoload :CommandOptions, "shopify_cli/command_options"
|
|
107
105
|
autoload :Commands, "shopify_cli/commands"
|
|
108
106
|
autoload :Connect, "shopify_cli/connect"
|
|
107
|
+
autoload :Constants, "shopify_cli/constants"
|
|
109
108
|
autoload :Context, "shopify_cli/context"
|
|
110
109
|
autoload :Core, "shopify_cli/core"
|
|
111
110
|
autoload :DB, "shopify_cli/db"
|
|
111
|
+
autoload :Environment, "shopify_cli/environment"
|
|
112
112
|
autoload :Feature, "shopify_cli/feature"
|
|
113
113
|
autoload :Form, "shopify_cli/form"
|
|
114
114
|
autoload :Git, "shopify_cli/git"
|
|
@@ -118,11 +118,11 @@ module ShopifyCLI
|
|
|
118
118
|
autoload :IdentityAuth, "shopify_cli/identity_auth"
|
|
119
119
|
autoload :JsDeps, "shopify_cli/js_deps"
|
|
120
120
|
autoload :JsSystem, "shopify_cli/js_system"
|
|
121
|
-
autoload :PHPDeps, "shopify_cli/php_deps"
|
|
122
121
|
autoload :LazyDelegator, "shopify_cli/lazy_delegator"
|
|
123
122
|
autoload :MethodObject, "shopify_cli/method_object"
|
|
124
123
|
autoload :Options, "shopify_cli/options"
|
|
125
124
|
autoload :PartnersAPI, "shopify_cli/partners_api"
|
|
125
|
+
autoload :PHPDeps, "shopify_cli/php_deps"
|
|
126
126
|
autoload :ProcessSupervision, "shopify_cli/process_supervision"
|
|
127
127
|
autoload :Project, "shopify_cli/project"
|
|
128
128
|
autoload :ProjectType, "shopify_cli/project_type"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shopify-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.29.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shopify
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-10-
|
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -517,6 +517,7 @@ files:
|
|
|
517
517
|
- lib/shopify_cli/theme/syncer/standard_reporter.rb
|
|
518
518
|
- lib/shopify_cli/theme/syncer/unsupported_script_warning.rb
|
|
519
519
|
- lib/shopify_cli/theme/theme.rb
|
|
520
|
+
- lib/shopify_cli/theme/theme_access_api.rb
|
|
520
521
|
- lib/shopify_cli/theme/theme_admin_api.rb
|
|
521
522
|
- lib/shopify_cli/theme/theme_admin_api_throttler.rb
|
|
522
523
|
- lib/shopify_cli/theme/theme_admin_api_throttler/bulk.rb
|