shopify-cli 1.6.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +15 -2
- data/CHANGELOG.md +21 -0
- data/Gemfile +12 -12
- data/Gemfile.lock +14 -14
- data/Rakefile +32 -30
- data/bin/load_shopify.rb +6 -6
- data/bin/shopify +2 -2
- data/dev.yml +3 -0
- data/ext/shopify-cli/extconf.rb +7 -7
- data/lib/docgen/markdown.rb +12 -12
- data/lib/graphql/extension_create.graphql +17 -2
- data/lib/graphql/fetch_specifications.graphql +14 -0
- data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
- data/lib/project_types/extension/cli.rb +56 -55
- data/lib/project_types/extension/commands/build.rb +3 -3
- data/lib/project_types/extension/commands/create.rb +17 -10
- data/lib/project_types/extension/commands/extension_command.rb +14 -7
- data/lib/project_types/extension/commands/push.rb +10 -10
- data/lib/project_types/extension/commands/register.rb +22 -32
- data/lib/project_types/extension/commands/serve.rb +1 -7
- data/lib/project_types/extension/commands/tunnel.rb +12 -12
- data/lib/project_types/extension/extension_project.rb +22 -7
- data/lib/project_types/extension/extension_project_keys.rb +5 -4
- data/lib/project_types/extension/features/argo.rb +26 -42
- data/lib/project_types/extension/features/argo_config.rb +5 -5
- data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
- data/lib/project_types/extension/features/argo_renderer_package.rb +47 -0
- data/lib/project_types/extension/features/argo_serve.rb +69 -0
- data/lib/project_types/extension/features/argo_setup.rb +3 -3
- data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
- data/lib/project_types/extension/forms/create.rb +28 -34
- data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
- data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
- data/lib/project_types/extension/forms/questions/ask_type.rb +47 -0
- data/lib/project_types/extension/messages/message_loading.rb +3 -1
- data/lib/project_types/extension/messages/messages.rb +55 -55
- data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
- data/lib/project_types/extension/models/registration.rb +1 -0
- data/lib/project_types/extension/models/specification.rb +6 -2
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +10 -2
- data/lib/project_types/extension/models/specifications.rb +14 -3
- data/lib/project_types/extension/models/version.rb +1 -1
- data/lib/project_types/extension/tasks/configure_features.rb +7 -5
- data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +8 -6
- data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
- data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
- data/lib/project_types/extension/tasks/create_extension.rb +4 -4
- data/lib/project_types/extension/tasks/fetch_specifications.rb +8 -28
- data/lib/project_types/extension/tasks/get_app.rb +4 -4
- data/lib/project_types/extension/tasks/get_apps.rb +3 -3
- data/lib/project_types/extension/tasks/update_draft.rb +4 -4
- data/lib/project_types/extension/tasks/user_errors.rb +4 -4
- data/lib/project_types/node/cli.rb +19 -19
- data/lib/project_types/node/commands/connect.rb +3 -3
- data/lib/project_types/node/commands/create.rb +40 -38
- data/lib/project_types/node/commands/deploy.rb +4 -4
- data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
- data/lib/project_types/node/commands/generate.rb +2 -24
- data/lib/project_types/node/commands/open.rb +2 -2
- data/lib/project_types/node/commands/populate.rb +6 -6
- data/lib/project_types/node/commands/populate/customer.rb +5 -5
- data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/node/commands/populate/product.rb +5 -5
- data/lib/project_types/node/commands/serve.rb +9 -9
- data/lib/project_types/node/commands/tunnel.rb +7 -7
- data/lib/project_types/node/forms/create.rb +17 -8
- data/lib/project_types/node/messages/messages.rb +8 -7
- data/lib/project_types/rails/cli.rb +21 -21
- data/lib/project_types/rails/commands/connect.rb +3 -3
- data/lib/project_types/rails/commands/create.rb +51 -48
- data/lib/project_types/rails/commands/deploy.rb +4 -4
- data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
- data/lib/project_types/rails/commands/generate.rb +7 -7
- data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
- data/lib/project_types/rails/commands/open.rb +2 -2
- data/lib/project_types/rails/commands/populate.rb +6 -6
- data/lib/project_types/rails/commands/populate/customer.rb +5 -5
- data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/rails/commands/populate/product.rb +5 -5
- data/lib/project_types/rails/commands/serve.rb +11 -11
- data/lib/project_types/rails/commands/tunnel.rb +7 -7
- data/lib/project_types/rails/forms/create.rb +34 -24
- data/lib/project_types/rails/gem.rb +23 -23
- data/lib/project_types/rails/messages/messages.rb +9 -8
- data/lib/project_types/rails/ruby.rb +2 -2
- data/lib/project_types/script/cli.rb +36 -40
- data/lib/project_types/script/commands/create.rb +9 -13
- data/lib/project_types/script/commands/push.rb +6 -5
- data/lib/project_types/script/config/extension_points.yml +25 -10
- data/lib/project_types/script/errors.rb +1 -19
- data/lib/project_types/script/forms/create.rb +7 -18
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +7 -5
- data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
- data/lib/project_types/script/layers/application/build_script.rb +6 -8
- data/lib/project_types/script/layers/application/create_script.rb +34 -24
- data/lib/project_types/script/layers/application/extension_points.rb +3 -2
- data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
- data/lib/project_types/script/layers/application/push_script.rb +10 -15
- data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
- data/lib/project_types/script/layers/domain/errors.rb +16 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +60 -45
- data/lib/project_types/script/layers/domain/metadata.rb +18 -25
- data/lib/project_types/script/layers/domain/push_package.rb +9 -5
- data/lib/project_types/script/layers/domain/script_project.rb +38 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +39 -10
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +9 -44
- data/lib/project_types/script/layers/infrastructure/errors.rb +50 -19
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +16 -21
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +4 -4
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +179 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +35 -78
- data/lib/project_types/script/messages/messages.rb +33 -57
- data/lib/project_types/script/ui/error_handler.rb +116 -88
- data/lib/project_types/script/ui/printing_spinner.rb +1 -1
- data/lib/project_types/script/ui/strict_spinner.rb +1 -1
- data/lib/project_types/theme/cli.rb +19 -19
- data/lib/project_types/theme/commands/connect.rb +12 -12
- data/lib/project_types/theme/commands/create.rb +11 -11
- data/lib/project_types/theme/commands/deploy.rb +8 -8
- data/lib/project_types/theme/commands/generate.rb +3 -3
- data/lib/project_types/theme/commands/generate/env.rb +15 -15
- data/lib/project_types/theme/commands/push.rb +15 -15
- data/lib/project_types/theme/commands/serve.rb +5 -5
- data/lib/project_types/theme/forms/connect.rb +4 -4
- data/lib/project_types/theme/forms/create.rb +5 -5
- data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +22 -22
- data/lib/project_types/theme/themekit.rb +15 -15
- data/lib/rubygems_plugin.rb +3 -3
- data/lib/shopify-cli/admin_api.rb +11 -11
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
- data/lib/shopify-cli/admin_api/schema.rb +3 -3
- data/lib/shopify-cli/api.rb +10 -10
- data/lib/shopify-cli/command.rb +1 -1
- data/lib/shopify-cli/commands.rb +9 -9
- data/lib/shopify-cli/commands/config.rb +28 -52
- data/lib/shopify-cli/commands/connect.rb +10 -10
- data/lib/shopify-cli/commands/create.rb +5 -5
- data/lib/shopify-cli/commands/help.rb +6 -6
- data/lib/shopify-cli/commands/logout.rb +3 -3
- data/lib/shopify-cli/commands/system.rb +32 -32
- data/lib/shopify-cli/commands/version.rb +2 -2
- data/lib/shopify-cli/context.rb +51 -23
- data/lib/shopify-cli/core.rb +4 -4
- data/lib/shopify-cli/core/entry_point.rb +5 -5
- data/lib/shopify-cli/core/executor.rb +1 -1
- data/lib/shopify-cli/core/help_resolver.rb +2 -2
- data/lib/shopify-cli/core/monorail.rb +16 -16
- data/lib/shopify-cli/db.rb +2 -2
- data/lib/shopify-cli/feature.rb +1 -1
- data/lib/shopify-cli/form.rb +1 -1
- data/lib/shopify-cli/git.rb +17 -17
- data/lib/shopify-cli/helpers.rb +1 -1
- data/lib/shopify-cli/helpers/haikunator.rb +1 -1
- data/lib/shopify-cli/heroku.rb +28 -28
- data/lib/shopify-cli/http_request.rb +2 -2
- data/lib/shopify-cli/js_deps.rb +12 -12
- data/lib/shopify-cli/js_system.rb +7 -7
- data/lib/shopify-cli/lazy_delegator.rb +55 -0
- data/lib/shopify-cli/messages/messages.rb +7 -16
- data/lib/shopify-cli/method_object.rb +1 -1
- data/lib/shopify-cli/oauth.rb +27 -27
- data/lib/shopify-cli/oauth/servlet.rb +9 -9
- data/lib/shopify-cli/options.rb +3 -3
- data/lib/shopify-cli/packager.rb +25 -25
- data/lib/shopify-cli/partners_api.rb +16 -16
- data/lib/shopify-cli/partners_api/organizations.rb +10 -10
- data/lib/shopify-cli/process_supervision.rb +7 -7
- data/lib/shopify-cli/project.rb +16 -16
- data/lib/shopify-cli/project_type.rb +3 -3
- data/lib/shopify-cli/resolve_constant.rb +1 -1
- data/lib/shopify-cli/resources.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +10 -10
- data/lib/shopify-cli/result.rb +11 -11
- data/lib/shopify-cli/shopifolk.rb +6 -9
- data/lib/shopify-cli/sub_command.rb +1 -1
- data/lib/shopify-cli/task.rb +3 -3
- data/lib/shopify-cli/tasks.rb +7 -7
- data/lib/shopify-cli/tasks/create_api_client.rb +5 -5
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +12 -12
- data/lib/shopify-cli/tasks/ensure_env.rb +15 -15
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +19 -19
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
- data/lib/shopify-cli/transform_data_structure.rb +86 -0
- data/lib/shopify-cli/tunnel.rb +30 -30
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +56 -54
- data/shopify-cli.gemspec +6 -6
- data/vendor/deps/smart_properties/REVISION +1 -1
- data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
- data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
- data/vendor/gen/template/bin/update-deps +9 -9
- metadata +15 -11
- data/lib/project_types/extension/forms/register.rb +0 -47
- data/lib/project_types/script/commands/disable.rb +0 -25
- data/lib/project_types/script/commands/enable.rb +0 -78
- data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
- data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
- data/lib/project_types/script/layers/application/disable_script.rb +0 -21
- data/lib/project_types/script/layers/application/enable_script.rb +0 -23
- data/lib/project_types/script/script_project.rb +0 -63
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "shopify_cli"
|
2
2
|
|
3
3
|
module ShopifyCli
|
4
4
|
##
|
@@ -6,7 +6,7 @@ module ShopifyCli
|
|
6
6
|
# schema.
|
7
7
|
#
|
8
8
|
class PartnersAPI < API
|
9
|
-
autoload :Organizations,
|
9
|
+
autoload :Organizations, "shopify-cli/partners_api/organizations"
|
10
10
|
|
11
11
|
# Defines the environment variable that this API looks for to operate on local
|
12
12
|
# services. If you set this environment variable in your shell then the partners
|
@@ -16,7 +16,7 @@ module ShopifyCli
|
|
16
16
|
#
|
17
17
|
# SHOPIFY_APP_CLI_LOCAL_PARTNERS=1 shopify create
|
18
18
|
#
|
19
|
-
LOCAL_DEBUG =
|
19
|
+
LOCAL_DEBUG = "SHOPIFY_APP_CLI_LOCAL_PARTNERS"
|
20
20
|
|
21
21
|
class << self
|
22
22
|
##
|
@@ -52,7 +52,7 @@ module ShopifyCli
|
|
52
52
|
|
53
53
|
def partners_url_for(organization_id, api_client_id, local_debug)
|
54
54
|
if ShopifyCli::Shopifolk.acting_as_shopify_organization?
|
55
|
-
organization_id =
|
55
|
+
organization_id = "internal"
|
56
56
|
end
|
57
57
|
"#{partners_endpoint(local_debug)}/#{organization_id}/apps/#{api_client_id}"
|
58
58
|
end
|
@@ -65,7 +65,7 @@ module ShopifyCli
|
|
65
65
|
authenticate(ctx)
|
66
66
|
retry
|
67
67
|
rescue API::APIRequestNotFoundError
|
68
|
-
ctx.puts(ctx.message(
|
68
|
+
ctx.puts(ctx.message("core.partners_api.error.account_not_found", ShopifyCli::TOOL_NAME))
|
69
69
|
end
|
70
70
|
|
71
71
|
def api_client(ctx)
|
@@ -86,7 +86,7 @@ module ShopifyCli
|
|
86
86
|
def authenticate(ctx)
|
87
87
|
OAuth.new(
|
88
88
|
ctx: ctx,
|
89
|
-
service:
|
89
|
+
service: "identity",
|
90
90
|
client_id: cli_id,
|
91
91
|
scopes: scopes.join(" "),
|
92
92
|
request_exchange: partners_id,
|
@@ -94,30 +94,30 @@ module ShopifyCli
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def partners_id
|
97
|
-
return
|
98
|
-
|
97
|
+
return "271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6" if ENV[LOCAL_DEBUG].nil?
|
98
|
+
"df89d73339ac3c6c5f0a98d9ca93260763e384d51d6038da129889c308973978"
|
99
99
|
end
|
100
100
|
|
101
101
|
def cli_id
|
102
|
-
return
|
103
|
-
|
102
|
+
return "fbdb2649-e327-4907-8f67-908d24cfd7e3" if ENV[LOCAL_DEBUG].nil?
|
103
|
+
"e5380e02-312a-7408-5718-e07017e9cf52"
|
104
104
|
end
|
105
105
|
|
106
106
|
def auth_endpoint
|
107
|
-
return
|
108
|
-
|
107
|
+
return "https://accounts.shopify.com" if ENV[LOCAL_DEBUG].nil?
|
108
|
+
"https://identity.myshopify.io"
|
109
109
|
end
|
110
110
|
|
111
111
|
def endpoint
|
112
|
-
return
|
113
|
-
|
112
|
+
return "https://partners.shopify.com" if ENV[LOCAL_DEBUG].nil?
|
113
|
+
"https://partners.myshopify.io/"
|
114
114
|
end
|
115
115
|
|
116
116
|
def partners_endpoint(local_debug)
|
117
117
|
domain = if local_debug
|
118
|
-
|
118
|
+
"partners.myshopify.io"
|
119
119
|
else
|
120
|
-
|
120
|
+
"partners.shopify.com"
|
121
121
|
end
|
122
122
|
"https://#{domain}"
|
123
123
|
end
|
@@ -3,26 +3,26 @@ module ShopifyCli
|
|
3
3
|
class Organizations
|
4
4
|
class << self
|
5
5
|
def fetch_all(ctx)
|
6
|
-
resp = PartnersAPI.query(ctx,
|
7
|
-
(resp.dig(
|
8
|
-
org[
|
6
|
+
resp = PartnersAPI.query(ctx, "all_organizations")
|
7
|
+
(resp.dig("data", "organizations", "nodes") || []).map do |org|
|
8
|
+
org["stores"] = (org.dig("stores", "nodes") || [])
|
9
9
|
org
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def fetch(ctx, id:)
|
14
|
-
resp = PartnersAPI.query(ctx,
|
15
|
-
org = resp.dig(
|
14
|
+
resp = PartnersAPI.query(ctx, "find_organization", id: id)
|
15
|
+
org = resp.dig("data", "organizations", "nodes").first
|
16
16
|
return nil if org.nil?
|
17
|
-
org[
|
17
|
+
org["stores"] = (org.dig("stores", "nodes") || [])
|
18
18
|
org
|
19
19
|
end
|
20
20
|
|
21
21
|
def fetch_with_app(ctx)
|
22
|
-
resp = PartnersAPI.query(ctx,
|
23
|
-
(resp.dig(
|
24
|
-
org[
|
25
|
-
org[
|
22
|
+
resp = PartnersAPI.query(ctx, "all_orgs_with_apps")
|
23
|
+
(resp.dig("data", "organizations", "nodes") || []).map do |org|
|
24
|
+
org["stores"] = (org.dig("stores", "nodes") || [])
|
25
|
+
org["apps"] = (org.dig("apps", "nodes") || [])
|
26
26
|
org
|
27
27
|
end
|
28
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "fileutils"
|
2
2
|
|
3
3
|
module ShopifyCli
|
4
4
|
##
|
@@ -19,7 +19,7 @@ module ShopifyCli
|
|
19
19
|
class << self
|
20
20
|
def run_dir
|
21
21
|
# is the directory where the pid and logfile are kept
|
22
|
-
File.join(ShopifyCli.cache_dir,
|
22
|
+
File.join(ShopifyCli.cache_dir, "sv")
|
23
23
|
end
|
24
24
|
|
25
25
|
##
|
@@ -36,7 +36,7 @@ module ShopifyCli
|
|
36
36
|
# will be nil if the process is not running.
|
37
37
|
#
|
38
38
|
def for_ident(identifier)
|
39
|
-
pid, time = File.read(File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.pid")).split(
|
39
|
+
pid, time = File.read(File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.pid")).split(":")
|
40
40
|
new(identifier, pid: Integer(pid), time: time)
|
41
41
|
rescue Errno::ENOENT
|
42
42
|
nil
|
@@ -66,7 +66,7 @@ module ShopifyCli
|
|
66
66
|
pid_file = new(identifier)
|
67
67
|
|
68
68
|
# Make sure the file exists and is empty, otherwise Windows fails
|
69
|
-
File.open(pid_file.log_path,
|
69
|
+
File.open(pid_file.log_path, "w") {}
|
70
70
|
pid = Process.spawn(
|
71
71
|
*args,
|
72
72
|
out: pid_file.log_path,
|
@@ -128,7 +128,7 @@ module ShopifyCli
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
def initialize(identifier, pid: nil, time: Time.now.strftime(
|
131
|
+
def initialize(identifier, pid: nil, time: Time.now.strftime("%s")) # :nodoc:
|
132
132
|
@identifier = identifier
|
133
133
|
@pid = pid
|
134
134
|
@time = time
|
@@ -204,13 +204,13 @@ module ShopifyCli
|
|
204
204
|
|
205
205
|
# Windows does not handle SIGTERM, go straight to SIGKILL
|
206
206
|
unless ctx.windows?
|
207
|
-
Process.kill(
|
207
|
+
Process.kill("TERM", id)
|
208
208
|
50.times do
|
209
209
|
sleep(0.1)
|
210
210
|
break unless stat(id)
|
211
211
|
end
|
212
212
|
end
|
213
|
-
Process.kill(
|
213
|
+
Process.kill("KILL", id) if stat(id)
|
214
214
|
sleep(0.1) if ctx.windows? # Give Windows a second to actually close the process
|
215
215
|
end
|
216
216
|
|
data/lib/shopify-cli/project.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "shopify_cli"
|
3
3
|
|
4
4
|
module ShopifyCli
|
5
5
|
##
|
@@ -64,7 +64,7 @@ module ShopifyCli
|
|
64
64
|
#
|
65
65
|
def current_project_type
|
66
66
|
return unless has_current?
|
67
|
-
current.config[
|
67
|
+
current.config["project_type"].to_sym
|
68
68
|
end
|
69
69
|
|
70
70
|
##
|
@@ -84,13 +84,13 @@ module ShopifyCli
|
|
84
84
|
# type = ShopifyCli::Project.current_project_type
|
85
85
|
#
|
86
86
|
def write(ctx, project_type:, organization_id:, **identifiers)
|
87
|
-
require
|
87
|
+
require "yaml" # takes 20ms, so deferred as late as possible.
|
88
88
|
content = Hash[{ project_type: project_type, organization_id: organization_id.to_i }
|
89
89
|
.merge(identifiers)
|
90
90
|
.collect { |k, v| [k.to_s, v] }]
|
91
|
-
content[
|
91
|
+
content["shopify_organization"] = true if Shopifolk.acting_as_shopify_organization?
|
92
92
|
|
93
|
-
ctx.write(
|
93
|
+
ctx.write(".shopify-cli.yml", YAML.dump(content))
|
94
94
|
clear
|
95
95
|
end
|
96
96
|
|
@@ -113,7 +113,7 @@ module ShopifyCli
|
|
113
113
|
def at(dir)
|
114
114
|
proj_dir = directory(dir)
|
115
115
|
unless proj_dir
|
116
|
-
raise(ShopifyCli::Abort, Context.message(
|
116
|
+
raise(ShopifyCli::Abort, Context.message("core.project.error.not_in_project"))
|
117
117
|
end
|
118
118
|
@at ||= Hash.new { |h, k| h[k] = new(directory: k) }
|
119
119
|
@at[proj_dir]
|
@@ -121,8 +121,8 @@ module ShopifyCli
|
|
121
121
|
|
122
122
|
def __directory(curr)
|
123
123
|
loop do
|
124
|
-
return nil if curr ==
|
125
|
-
file = File.join(curr,
|
124
|
+
return nil if curr == "/" || /^[A-Z]:\/$/.match?(curr)
|
125
|
+
file = File.join(curr, ".shopify-cli.yml")
|
126
126
|
return curr if File.exist?(file)
|
127
127
|
curr = File.dirname(curr)
|
128
128
|
end
|
@@ -168,15 +168,15 @@ module ShopifyCli
|
|
168
168
|
#
|
169
169
|
def config
|
170
170
|
@config ||= begin
|
171
|
-
config = load_yaml_file(
|
171
|
+
config = load_yaml_file(".shopify-cli.yml")
|
172
172
|
unless config.is_a?(Hash)
|
173
|
-
raise ShopifyCli::Abort, Context.message(
|
173
|
+
raise ShopifyCli::Abort, Context.message("core.yaml.error.not_hash", ".shopify-cli.yml")
|
174
174
|
end
|
175
175
|
|
176
176
|
# The app_type key was deprecated in favour of project_type, so replace it
|
177
|
-
if config.key?(
|
178
|
-
config[
|
179
|
-
config.delete(
|
177
|
+
if config.key?("app_type")
|
178
|
+
config["project_type"] = config["app_type"]
|
179
|
+
config.delete("app_type")
|
180
180
|
end
|
181
181
|
|
182
182
|
config
|
@@ -187,16 +187,16 @@ module ShopifyCli
|
|
187
187
|
|
188
188
|
def load_yaml_file(relative_path)
|
189
189
|
f = File.join(directory, relative_path)
|
190
|
-
require
|
190
|
+
require "yaml" # takes 20ms, so deferred as late as possible.
|
191
191
|
begin
|
192
192
|
YAML.load_file(f)
|
193
193
|
rescue Psych::SyntaxError => e
|
194
|
-
raise(ShopifyCli::Abort, Context.message(
|
194
|
+
raise(ShopifyCli::Abort, Context.message("core.yaml.error.invalid", relative_path, e.message))
|
195
195
|
# rescue Errno::EACCES => e
|
196
196
|
# TODO
|
197
197
|
# Dev::Helpers::EaccesHandler.diagnose_and_raise(f, e, mode: :read)
|
198
198
|
rescue Errno::ENOENT
|
199
|
-
raise ShopifyCli::Abort, Context.message(
|
199
|
+
raise ShopifyCli::Abort, Context.message("core.yaml.error.not_found", f)
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end
|
@@ -21,7 +21,7 @@ module ShopifyCli
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def load_type(current_type, shallow = false)
|
24
|
-
filepath = File.join(ShopifyCli::ROOT,
|
24
|
+
filepath = File.join(ShopifyCli::ROOT, "lib", "project_types", current_type.to_s, "cli.rb")
|
25
25
|
return unless File.exist?(filepath)
|
26
26
|
@shallow_load = shallow
|
27
27
|
@current_type = current_type
|
@@ -32,7 +32,7 @@ module ShopifyCli
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def load_all
|
35
|
-
Dir.glob(File.join(ShopifyCli::ROOT,
|
35
|
+
Dir.glob(File.join(ShopifyCli::ROOT, "lib", "project_types", "*", "cli.rb")).map do |filepath|
|
36
36
|
load_type(filepath.split(File::Separator)[-2].to_sym, true)
|
37
37
|
end
|
38
38
|
end
|
@@ -74,7 +74,7 @@ module ShopifyCli
|
|
74
74
|
def register_command(const, cmd)
|
75
75
|
return if project_load_shallow
|
76
76
|
Context.new.abort(
|
77
|
-
Context.message(
|
77
|
+
Context.message("core.project_type.error.cannot_override_core", cmd, const)
|
78
78
|
) if Commands.core_command?(cmd)
|
79
79
|
Commands.register(const, cmd)
|
80
80
|
end
|
@@ -11,7 +11,7 @@
|
|
11
11
|
module ShopifyCli
|
12
12
|
class ResolveConstant
|
13
13
|
include ShopifyCli::MethodObject
|
14
|
-
property! :namespace, accepts: ->(ns) { ns.respond_to?(:const_get) }, default: Kernel
|
14
|
+
property! :namespace, accepts: ->(ns) { ns.respond_to?(:const_get) }, default: -> { Kernel }
|
15
15
|
|
16
16
|
def call(name)
|
17
17
|
name
|
@@ -4,13 +4,13 @@ module ShopifyCli
|
|
4
4
|
module Resources
|
5
5
|
class EnvFile
|
6
6
|
include SmartProperties
|
7
|
-
FILENAME =
|
7
|
+
FILENAME = ".env"
|
8
8
|
KEY_MAP = {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
"SHOPIFY_API_KEY" => :api_key,
|
10
|
+
"SHOPIFY_API_SECRET" => :secret,
|
11
|
+
"SHOP" => :shop,
|
12
|
+
"SCOPES" => :scopes,
|
13
|
+
"HOST" => :host,
|
14
14
|
}
|
15
15
|
|
16
16
|
class << self
|
@@ -57,7 +57,7 @@ module ShopifyCli
|
|
57
57
|
property :shop
|
58
58
|
property :scopes
|
59
59
|
property :host
|
60
|
-
property :extra, default: {}
|
60
|
+
property :extra, default: -> { {} }
|
61
61
|
|
62
62
|
def to_h
|
63
63
|
out = {}
|
@@ -72,7 +72,7 @@ module ShopifyCli
|
|
72
72
|
|
73
73
|
def write(ctx)
|
74
74
|
spin_group = CLI::UI::SpinGroup.new
|
75
|
-
spin_group.add(ctx.message(
|
75
|
+
spin_group.add(ctx.message("core.env_file.saving_header", FILENAME)) do |spinner|
|
76
76
|
output = []
|
77
77
|
KEY_MAP.each do |key, value|
|
78
78
|
output << "#{key}=#{send(value)}" if send(value)
|
@@ -80,9 +80,9 @@ module ShopifyCli
|
|
80
80
|
extra.each do |key, value|
|
81
81
|
output << "#{key}=#{value}"
|
82
82
|
end
|
83
|
-
ctx.print_task(ctx.message(
|
83
|
+
ctx.print_task(ctx.message("core.env_file.saving", FILENAME))
|
84
84
|
ctx.write(FILENAME, output.join("\n") + "\n")
|
85
|
-
spinner.update_title(ctx.message(
|
85
|
+
spinner.update_title(ctx.message("core.env_file.saved", FILENAME))
|
86
86
|
end
|
87
87
|
spin_group.wait
|
88
88
|
end
|
data/lib/shopify-cli/result.rb
CHANGED
@@ -104,7 +104,7 @@ module ShopifyCli
|
|
104
104
|
end
|
105
105
|
|
106
106
|
##
|
107
|
-
# raises an `UnexpectedSuccess` as a `
|
107
|
+
# raises an `UnexpectedSuccess` as a `Success` does not carry an error
|
108
108
|
# value.
|
109
109
|
#
|
110
110
|
def error
|
@@ -191,7 +191,7 @@ module ShopifyCli
|
|
191
191
|
# Success.new(1).unwrap(0) => 1
|
192
192
|
#
|
193
193
|
def unwrap(*args, &block)
|
194
|
-
raise ArgumentError, "expected either a fallback value or a block" unless args.
|
194
|
+
raise ArgumentError, "expected either a fallback value or a block" unless (args.length == 1) ^ block
|
195
195
|
@value
|
196
196
|
end
|
197
197
|
end
|
@@ -221,8 +221,8 @@ module ShopifyCli
|
|
221
221
|
# .then { |data| data.values_at(:firstname, :lastname) } # Ignored
|
222
222
|
# .unwrap(Person.new("John", "Doe")) # => Person
|
223
223
|
#
|
224
|
-
# Alternatively, we could
|
225
|
-
#
|
224
|
+
# Alternatively, we could rescue from the error and then proceed with the
|
225
|
+
# remaining transformations:
|
226
226
|
#
|
227
227
|
# Person = Struct.new(:firstname, :lastname)
|
228
228
|
# Failure
|
@@ -304,12 +304,12 @@ module ShopifyCli
|
|
304
304
|
#
|
305
305
|
# Failure
|
306
306
|
# .new(RuntimeError.new)
|
307
|
-
# .
|
307
|
+
# .rescue { "All good! "}
|
308
308
|
# .success? # => true
|
309
309
|
#
|
310
310
|
# Failure
|
311
311
|
# .new(RuntimeError.new)
|
312
|
-
# .
|
312
|
+
# .rescue { Failure.new("Still broken!") }
|
313
313
|
# .success? # => false
|
314
314
|
#
|
315
315
|
def rescue(&block)
|
@@ -336,7 +336,7 @@ module ShopifyCli
|
|
336
336
|
# * `ArgumentError` if both a fallback argument and a block is provided
|
337
337
|
#
|
338
338
|
def unwrap(*args, &block)
|
339
|
-
raise ArgumentError, "expected either a fallback value or a block" unless args.
|
339
|
+
raise ArgumentError, "expected either a fallback value or a block" unless (args.length == 1) ^ block
|
340
340
|
block ? block.call(@error) : args.pop
|
341
341
|
end
|
342
342
|
end
|
@@ -397,14 +397,14 @@ module ShopifyCli
|
|
397
397
|
# end
|
398
398
|
#
|
399
399
|
def self.wrap(*values, &block)
|
400
|
-
raise ArgumentError, "expected either a value or a block" unless values.
|
400
|
+
raise ArgumentError, "expected either a value or a block" unless (values.length == 1) ^ block
|
401
401
|
|
402
|
-
if values.
|
402
|
+
if values.length == 1
|
403
403
|
values.pop.yield_self do |value|
|
404
404
|
case value
|
405
405
|
when Result::Success, Result::Failure
|
406
406
|
value
|
407
|
-
when Exception
|
407
|
+
when NilClass, Exception
|
408
408
|
Result.failure(value)
|
409
409
|
else
|
410
410
|
Result.success(value)
|
@@ -414,7 +414,7 @@ module ShopifyCli
|
|
414
414
|
->(*args) do
|
415
415
|
begin
|
416
416
|
wrap(block.call(*args))
|
417
|
-
rescue => error
|
417
|
+
rescue Exception => error # rubocop:disable Lint/RescueException
|
418
418
|
wrap(error)
|
419
419
|
end
|
420
420
|
end
|
@@ -5,10 +5,10 @@ module ShopifyCli
|
|
5
5
|
# The Shopifolk Feature flag will persist between runs so if the flag is enabled or disabled,
|
6
6
|
# it will still be in that same state until the next class invocation.
|
7
7
|
class Shopifolk
|
8
|
-
GCLOUD_CONFIG_FILE = File.expand_path(
|
9
|
-
DEV_PATH =
|
10
|
-
SECTION =
|
11
|
-
FEATURE_NAME =
|
8
|
+
GCLOUD_CONFIG_FILE = File.expand_path("~/.config/gcloud/configurations/config_default")
|
9
|
+
DEV_PATH = "/opt/dev"
|
10
|
+
SECTION = "core"
|
11
|
+
FEATURE_NAME = "shopifolk"
|
12
12
|
|
13
13
|
class << self
|
14
14
|
attr_writer :acting_as_shopify_organization
|
@@ -25,8 +25,6 @@ module ShopifyCli
|
|
25
25
|
# ShopifyCli::Shopifolk.check
|
26
26
|
#
|
27
27
|
def check
|
28
|
-
return false unless ShopifyCli::Config.get_bool('shopifolk-beta', 'enabled')
|
29
|
-
|
30
28
|
ShopifyCli::Shopifolk.new.shopifolk?
|
31
29
|
end
|
32
30
|
|
@@ -35,7 +33,7 @@ module ShopifyCli
|
|
35
33
|
end
|
36
34
|
|
37
35
|
def acting_as_shopify_organization?
|
38
|
-
!!@acting_as_shopify_organization || (Project.has_current? && Project.current.config[
|
36
|
+
!!@acting_as_shopify_organization || (Project.has_current? && Project.current.config["shopify_organization"])
|
39
37
|
end
|
40
38
|
|
41
39
|
def reset
|
@@ -52,7 +50,6 @@ module ShopifyCli
|
|
52
50
|
# a valid google cloud config file with email ending in "@shopify.com"
|
53
51
|
#
|
54
52
|
def shopifolk?
|
55
|
-
return false unless ShopifyCli::Config.get_bool('shopifolk-beta', 'enabled')
|
56
53
|
return true if Feature.enabled?(FEATURE_NAME)
|
57
54
|
|
58
55
|
if shopifolk_by_gcloud? && shopifolk_by_dev?
|
@@ -67,7 +64,7 @@ module ShopifyCli
|
|
67
64
|
private
|
68
65
|
|
69
66
|
def shopifolk_by_gcloud?
|
70
|
-
ini&.dig("[#{SECTION}]",
|
67
|
+
ini&.dig("[#{SECTION}]", "account")&.match?(/@shopify.com\z/)
|
71
68
|
end
|
72
69
|
|
73
70
|
def shopifolk_by_dev?
|