shopify-cli 0.9.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -3
- data/docs/_config.yml +3 -0
- data/docs/_data/nav.yml +9 -0
- data/docs/getting-started/index.md +5 -40
- data/docs/getting-started/install/index.md +75 -0
- data/docs/getting-started/migrate/index.md +96 -0
- data/docs/getting-started/uninstall/index.md +37 -0
- data/docs/getting-started/upgrade/index.md +37 -0
- data/docs/index.md +5 -6
- data/lib/project_types/extension/cli.rb +3 -2
- data/lib/project_types/extension/commands/build.rb +1 -1
- data/lib/project_types/extension/commands/tunnel.rb +1 -1
- data/lib/project_types/extension/forms/register.rb +2 -3
- data/lib/project_types/extension/graphql/get_app_by_api_key.graphql +9 -0
- data/lib/project_types/extension/tasks/converters/app_converter.rb +27 -0
- data/lib/project_types/extension/tasks/get_app.rb +22 -0
- data/lib/project_types/extension/tasks/get_apps.rb +1 -6
- data/lib/project_types/node/forms/create.rb +3 -54
- data/lib/project_types/node/messages/messages.rb +3 -14
- data/lib/project_types/rails/cli.rb +0 -1
- data/lib/project_types/rails/forms/create.rb +3 -52
- data/lib/project_types/rails/messages/messages.rb +2 -13
- data/lib/project_types/script/cli.rb +5 -5
- data/lib/project_types/script/commands/create.rb +5 -4
- data/lib/project_types/script/commands/disable.rb +4 -14
- data/lib/project_types/script/commands/enable.rb +35 -11
- data/lib/project_types/script/commands/push.rb +9 -9
- data/lib/project_types/script/config/extension_points.yml +9 -3
- data/lib/project_types/script/errors.rb +1 -0
- data/lib/project_types/script/forms/create.rb +8 -4
- data/lib/project_types/script/forms/script_form.rb +5 -2
- data/lib/project_types/script/layers/application/create_script.rb +14 -20
- data/lib/project_types/script/layers/application/disable_script.rb +9 -7
- data/lib/project_types/script/layers/application/enable_script.rb +11 -9
- data/lib/project_types/script/layers/application/project_dependencies.rb +0 -5
- data/lib/project_types/script/layers/application/push_script.rb +6 -4
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +106 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/errors.rb +2 -1
- data/lib/project_types/script/layers/infrastructure/project_creator.rb +23 -0
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/script_repository.rb +1 -34
- data/lib/project_types/script/layers/infrastructure/script_service.rb +2 -0
- data/lib/project_types/script/messages/messages.rb +21 -25
- data/lib/project_types/script/script_project.rb +8 -4
- data/lib/project_types/script/templates/ts/as-pect.config.js +6 -0
- data/lib/project_types/script/templates/ts/as-pect.d.ts +1 -0
- data/lib/project_types/script/ui/error_handler.rb +9 -0
- data/lib/project_types/script/ui/printing_spinner.rb +75 -0
- data/lib/shopify-cli/admin_api.rb +1 -2
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +10 -1
- data/lib/shopify-cli/admin_api/schema.rb +20 -8
- data/lib/shopify-cli/command.rb +2 -5
- data/lib/shopify-cli/commands.rb +1 -0
- data/lib/shopify-cli/commands/config.rb +44 -0
- data/lib/shopify-cli/commands/connect.rb +17 -10
- data/lib/shopify-cli/commands/create.rb +1 -1
- data/lib/shopify-cli/commands/help.rb +1 -1
- data/lib/shopify-cli/commands/system.rb +1 -1
- data/lib/shopify-cli/context.rb +10 -1
- data/lib/shopify-cli/core.rb +0 -1
- data/lib/shopify-cli/core/entry_point.rb +6 -0
- data/lib/shopify-cli/core/finalize.rb +13 -0
- data/lib/shopify-cli/feature.rb +97 -0
- data/lib/shopify-cli/messages/messages.rb +45 -2
- data/lib/shopify-cli/partners_api/organizations.rb +7 -7
- data/lib/shopify-cli/project_type.rb +2 -5
- data/lib/shopify-cli/tasks.rb +1 -0
- data/lib/shopify-cli/tasks/ensure_env.rb +0 -1
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +77 -0
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +4 -3
- data/lib/shopify-cli/tunnel.rb +66 -10
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +1 -0
- data/vendor/deps/cli-ui/REVISION +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui.rb +52 -11
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +11 -7
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +34 -21
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +107 -149
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +99 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +119 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +158 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +112 -0
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +9 -15
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +47 -0
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +9 -7
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +39 -14
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +62 -44
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +7 -2
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +23 -3
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +34 -10
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +12 -7
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +26 -16
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +3 -3
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +75 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +27 -0
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +61 -0
- metadata +25 -9
- data/lib/project_types/extension/features/tunnel_url.rb +0 -20
- data/lib/project_types/script/forms/enable.rb +0 -24
- data/lib/project_types/script/forms/push.rb +0 -19
- data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +0 -51
- data/lib/project_types/script/layers/infrastructure/dependency_manager.rb +0 -36
- data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +0 -62
- data/vendor/deps/cli-ui/lib/cli/ui/box.rb +0 -15
@@ -60,6 +60,8 @@ module Script
|
|
60
60
|
raise Errors::AppScriptUndefinedError, api_key
|
61
61
|
elsif user_errors.any? { |e| e['tag'] == 'shop_script_conflict' }
|
62
62
|
raise Errors::ShopScriptConflictError
|
63
|
+
elsif user_errors.any? { |e| e['tag'] == 'app_script_not_pushed' }
|
64
|
+
raise Errors::AppScriptNotPushedError
|
63
65
|
else
|
64
66
|
raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
|
65
67
|
end
|
@@ -18,8 +18,12 @@ module Script
|
|
18
18
|
invalid_context_cause: "Your .shopify-cli.yml file is not correct.",
|
19
19
|
invalid_context_help: "See https://help.shopify.com",
|
20
20
|
|
21
|
+
invalid_script_name_cause: "Invalid script name.",
|
22
|
+
invalid_script_name_help: "Replace or remove unsupported characters. Valid characters "\
|
23
|
+
"are numbers, letters, hyphens, or underscores.",
|
24
|
+
|
21
25
|
no_existing_apps_cause: "You don't have any apps.",
|
22
|
-
no_existing_apps_help: "Please create an app with {{command:shopify create}} or"\
|
26
|
+
no_existing_apps_help: "Please create an app with {{command:shopify create}} or "\
|
23
27
|
"visit https://partners.shopify.com/.",
|
24
28
|
|
25
29
|
no_existing_orgs_cause: "You don't have any partner organizations.",
|
@@ -38,6 +42,8 @@ module Script
|
|
38
42
|
|
39
43
|
app_not_installed_cause: "App not installed on development store.",
|
40
44
|
|
45
|
+
app_script_not_pushed_help: "Push the script and then try this command again.",
|
46
|
+
|
41
47
|
app_script_undefined_help: "Push script to app.",
|
42
48
|
|
43
49
|
build_error_cause: "Something went wrong while building the script.",
|
@@ -79,10 +85,9 @@ module Script
|
|
79
85
|
operation_failed: "Script not created.",
|
80
86
|
},
|
81
87
|
|
82
|
-
|
83
|
-
script_created: "{{v}} Script created: {{green:%{script_id}}}",
|
88
|
+
change_directory_notice: "{{*}} Change directories to {{green:%s}} to run script commands",
|
84
89
|
creating: "Creating script",
|
85
|
-
created: "Created script",
|
90
|
+
created: "Created script: {{green:%s}}",
|
86
91
|
},
|
87
92
|
|
88
93
|
push: {
|
@@ -92,7 +97,6 @@ module Script
|
|
92
97
|
HELP
|
93
98
|
extended_help: <<~HELP,
|
94
99
|
\s\sOptions:
|
95
|
-
\s\s{{command:--API_key=<API_key>}} API key. Must be a valid API key, otherwise store access fails.
|
96
100
|
\s\s{{command:[--force]}} Forces the script to be overwritten if an instance of it already exists.
|
97
101
|
HELP
|
98
102
|
|
@@ -108,14 +112,10 @@ module Script
|
|
108
112
|
Turn off script in development store.
|
109
113
|
Usage: {{command:%s disable}}
|
110
114
|
HELP
|
111
|
-
extended_help: <<~HELP,
|
112
|
-
\s\sOptions:
|
113
|
-
\s\s{{command:--API_key=<API_key>}} API key. Must be a valid API key, otherwise store access fails.
|
114
|
-
\s\s{{command:--shop_domain=<my_store.myshopify.com>}} Test store URL. Must be an existing test store.
|
115
|
-
HELP
|
116
115
|
|
117
116
|
error: {
|
118
117
|
operation_failed: "Can't disable script.",
|
118
|
+
not_pushed_to_app: "Can't disable the script because it hasn't been pushed to the app.",
|
119
119
|
},
|
120
120
|
|
121
121
|
script_disabled: "{{v}} Script disabled. Script is turned off in development store.",
|
@@ -128,8 +128,8 @@ module Script
|
|
128
128
|
HELP
|
129
129
|
extended_help: <<~HELP,
|
130
130
|
\s\sOptions:
|
131
|
-
\s\s{{command:--
|
132
|
-
\s\s{{command:--
|
131
|
+
\s\s{{command:--config_props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config_props will override those set in the file.
|
132
|
+
\s\s{{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --config_props values override properties in this file.
|
133
133
|
HELP
|
134
134
|
|
135
135
|
info: "{{*}} A script always remains enabled until you disable it - even after pushing "\
|
@@ -138,6 +138,7 @@ module Script
|
|
138
138
|
|
139
139
|
error: {
|
140
140
|
operation_failed: "Can't enable script.",
|
141
|
+
not_pushed_to_app: "Can't enable the script because it hasn't been pushed to the app.",
|
141
142
|
},
|
142
143
|
|
143
144
|
script_enabled: "{{v}} Script enabled. %{type} script %{title} in app (API key: %{api_key}) "\
|
@@ -169,34 +170,29 @@ module Script
|
|
169
170
|
create: {
|
170
171
|
select_extension_point: "Which extension point do you want to use?",
|
171
172
|
script_name: "Script Name",
|
172
|
-
|
173
|
-
error: {
|
174
|
-
invalid_name: "Invalid script name: replace or remove unsupported characters. Valid "\
|
175
|
-
"characters are numbers, letters, spaces, hyphens, or underscores.",
|
176
|
-
},
|
177
173
|
},
|
178
174
|
script_form: {
|
179
175
|
ask_app_api_key_default: "Which app do you want this script to belong to?",
|
180
176
|
ask_shop_domain_default: "Select a development store",
|
181
|
-
fetching_organizations: "
|
177
|
+
fetching_organizations: "Fetching partner organizations",
|
178
|
+
fetched_organizations: "Fetched partner organizations",
|
182
179
|
select_organization: "Select partner organization.",
|
183
180
|
using_app: "Using app {{green:%{title} (%{api_key})}}.",
|
184
181
|
using_development_store: "Using development store {{green:%{domain}}}",
|
185
182
|
using_organization: "Partner organization {{green:%s}}.",
|
186
183
|
},
|
187
|
-
enable: {
|
188
|
-
ask_app_api_key: "Which app is the script pushed to?",
|
189
|
-
ask_shop_domain: "Which development store is the app installed on?",
|
190
|
-
},
|
191
184
|
},
|
192
185
|
|
193
186
|
application: {
|
194
187
|
building: "Building",
|
195
188
|
building_script: "Building script",
|
196
189
|
built: "Built",
|
197
|
-
|
198
|
-
|
199
|
-
|
190
|
+
pushing: "Pushing",
|
191
|
+
pushed: "Pushed",
|
192
|
+
disabling: "Disabling",
|
193
|
+
disabled: "Disabled",
|
194
|
+
enabling: "Enabling",
|
195
|
+
enabled: "Enabled",
|
200
196
|
},
|
201
197
|
},
|
202
198
|
}.freeze
|
@@ -19,12 +19,16 @@ module Script
|
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
22
|
+
def file_name
|
23
|
+
"script.#{language}"
|
24
|
+
end
|
25
|
+
|
22
26
|
def source_file
|
23
27
|
"#{SOURCE_DIR}/#{file_name}"
|
24
28
|
end
|
25
29
|
|
26
|
-
def
|
27
|
-
"
|
30
|
+
def source_path
|
31
|
+
"#{script_name}/#{source_file}"
|
28
32
|
end
|
29
33
|
|
30
34
|
private
|
@@ -36,14 +40,14 @@ module Script
|
|
36
40
|
|
37
41
|
class << self
|
38
42
|
def create(ctx, dir)
|
39
|
-
raise Errors::ScriptProjectAlreadyExistsError, dir if ctx.
|
43
|
+
raise Errors::ScriptProjectAlreadyExistsError, dir if ctx.dir_exist?(dir)
|
40
44
|
ctx.mkdir_p(dir)
|
41
45
|
ctx.chdir(dir)
|
42
46
|
end
|
43
47
|
|
44
48
|
def cleanup(ctx:, script_name:, root_dir:)
|
45
49
|
ctx.chdir(root_dir)
|
46
|
-
ctx.rm_r("#{root_dir}/#{script_name}") if ctx.
|
50
|
+
ctx.rm_r("#{root_dir}/#{script_name}") if ctx.dir_exist?("#{root_dir}/#{script_name}")
|
47
51
|
end
|
48
52
|
end
|
49
53
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
/// <reference types="@as-pect/assembly/types/as-pect" />
|
@@ -44,6 +44,11 @@ module Script
|
|
44
44
|
cause_of_error: ShopifyCli::Context.message('script.error.invalid_context_cause'),
|
45
45
|
help_suggestion: ShopifyCli::Context.message('script.error.invalid_context_help'),
|
46
46
|
}
|
47
|
+
when Errors::InvalidScriptNameError
|
48
|
+
{
|
49
|
+
cause_of_error: ShopifyCli::Context.message('script.error.invalid_script_name_cause'),
|
50
|
+
help_suggestion: ShopifyCli::Context.message('script.error.invalid_script_name_help'),
|
51
|
+
}
|
47
52
|
when Errors::NoExistingAppsError
|
48
53
|
{
|
49
54
|
cause_of_error: ShopifyCli::Context.message('script.error.no_existing_apps_cause'),
|
@@ -87,6 +92,10 @@ module Script
|
|
87
92
|
{
|
88
93
|
cause_of_error: ShopifyCli::Context.message('script.error.app_not_installed_cause'),
|
89
94
|
}
|
95
|
+
when Layers::Infrastructure::Errors::AppScriptNotPushedError
|
96
|
+
{
|
97
|
+
cause_of_error: ShopifyCli::Context.message('script.error.app_script_not_pushed_help'),
|
98
|
+
}
|
90
99
|
when Layers::Infrastructure::Errors::AppScriptUndefinedError
|
91
100
|
{
|
92
101
|
help_suggestion: ShopifyCli::Context.message('script.error.app_script_undefined_help'),
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Script
|
5
|
+
module UI
|
6
|
+
module PrintingSpinner
|
7
|
+
##
|
8
|
+
# Creates a single spinner that runs the provided block.
|
9
|
+
# The block can take in a ctx argument that formats printed output to support
|
10
|
+
# printing from within the spin block.
|
11
|
+
#
|
12
|
+
# ==== Attributes
|
13
|
+
#
|
14
|
+
# * +ctx+ - The current context.
|
15
|
+
# * +title+ - Title of the spinner to use
|
16
|
+
#
|
17
|
+
# ==== Options
|
18
|
+
#
|
19
|
+
# * +:auto_debrief+ - Automatically debrief exceptions? Default to true
|
20
|
+
#
|
21
|
+
# ==== Block
|
22
|
+
#
|
23
|
+
# * +ctx+ - Instance of the PrintingSpinnerContext built from the ctx attribute.
|
24
|
+
# - +ctx.puts(...)+ formats output to enable support for printing within spinners
|
25
|
+
# * +spinner+ - Instance of the spinner. Can call +update_title+ to update the user of changes
|
26
|
+
#
|
27
|
+
def self.spin(ctx, title, auto_debrief: false)
|
28
|
+
StrictSpinner.spin(title, auto_debrief: auto_debrief) do |spinner, *args|
|
29
|
+
Thread.current[:cliui_output_hook] = nil
|
30
|
+
yield(PrintingSpinnerContext.from(ctx, spinner), spinner, *args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Printing within spinners requires the manipulation of ANSI escape
|
36
|
+
# sequences in order to make sure the CLI::UI::Spinner does not overwrite
|
37
|
+
# previously printed content.
|
38
|
+
class PrintingSpinnerContext < ShopifyCli::Context
|
39
|
+
include SmartProperties
|
40
|
+
property :spinner, required: true
|
41
|
+
|
42
|
+
def self.from(ctx, spinner)
|
43
|
+
new_ctx = new(spinner: spinner)
|
44
|
+
ctx.instance_variables.each do |var|
|
45
|
+
new_ctx.instance_variable_set(var, ctx.instance_variable_get(var))
|
46
|
+
end
|
47
|
+
new_ctx
|
48
|
+
end
|
49
|
+
|
50
|
+
def puts(*input)
|
51
|
+
super(encoded_lines(*input) + "\n" + spinner_text)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def encoded_lines(*lines)
|
57
|
+
lines
|
58
|
+
.join("\n")
|
59
|
+
.split("\n")
|
60
|
+
.map { |line| encode_ansi(line) unless line.nil? }
|
61
|
+
.join(CLI::UI::ANSI.next_line + "\n")
|
62
|
+
end
|
63
|
+
|
64
|
+
def encode_ansi(line)
|
65
|
+
CLI::UI::ANSI.previous_line + line + CLI::UI::ANSI.clear_to_end_of_line
|
66
|
+
end
|
67
|
+
|
68
|
+
def spinner_text
|
69
|
+
spinner.render(0, true)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
private_constant(:PrintingSpinnerContext)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -37,8 +37,7 @@ module ShopifyCli
|
|
37
37
|
#
|
38
38
|
# ShopifyCli::AdminAPI.query(@ctx, 'all_organizations')
|
39
39
|
#
|
40
|
-
def query(ctx, query_name, api_version: nil,
|
41
|
-
shop ||= Project.current.env.shop
|
40
|
+
def query(ctx, query_name, shop:, api_version: nil, **variables)
|
42
41
|
authenticated_req(ctx, shop) do
|
43
42
|
api_client(ctx, api_version, shop).query(query_name, variables: variables)
|
44
43
|
end
|
@@ -41,6 +41,8 @@ module ShopifyCli
|
|
41
41
|
return @ctx.puts(output)
|
42
42
|
end
|
43
43
|
|
44
|
+
@shop ||= Project.current.env.shop || get_shop(@ctx)
|
45
|
+
|
44
46
|
if @silent
|
45
47
|
spin_group = CLI::UI::SpinGroup.new
|
46
48
|
spin_group.add(@ctx.message('core.populate.populating', @count, camel_case_resource_type)) do |spinner|
|
@@ -114,7 +116,7 @@ module ShopifyCli
|
|
114
116
|
|
115
117
|
def run_mutation(data)
|
116
118
|
kwargs = { input: data }
|
117
|
-
kwargs[:shop] = @shop
|
119
|
+
kwargs[:shop] = @shop
|
118
120
|
resp = AdminAPI.query(
|
119
121
|
@ctx, "create_#{snake_case_resource_type}", kwargs
|
120
122
|
)
|
@@ -145,6 +147,13 @@ module ShopifyCli
|
|
145
147
|
|
146
148
|
private
|
147
149
|
|
150
|
+
def get_shop(ctx)
|
151
|
+
res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx)
|
152
|
+
domain = res[:shop_domain]
|
153
|
+
Project.current.env.update(ctx, :shop, domain)
|
154
|
+
domain
|
155
|
+
end
|
156
|
+
|
148
157
|
def camel_case_resource_type
|
149
158
|
@camel_case_resource_type ||= self.class.to_s.split('::').last
|
150
159
|
end
|
@@ -3,15 +3,27 @@ require 'shopify_cli'
|
|
3
3
|
module ShopifyCli
|
4
4
|
class AdminAPI
|
5
5
|
class Schema < Hash
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
class << self
|
7
|
+
def get(ctx)
|
8
|
+
unless ShopifyCli::DB.exists?(:shopify_admin_schema)
|
9
|
+
shop = Project.current.env.shop || get_shop(ctx)
|
10
|
+
schema = AdminAPI.query(ctx, 'admin_introspection', shop: shop)
|
11
|
+
ShopifyCli::DB.set(shopify_admin_schema: JSON.dump(schema))
|
12
|
+
end
|
13
|
+
# This is ruby magic for making a new hash with another hash.
|
14
|
+
# It wraps the JSON in our Schema Class to have the helper methods
|
15
|
+
# available
|
16
|
+
self[JSON.parse(ShopifyCli::DB.get(:shopify_admin_schema))]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def get_shop(ctx)
|
22
|
+
res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx)
|
23
|
+
domain = res[:shop_domain]
|
24
|
+
Project.current.env.update(ctx, :shop, domain)
|
25
|
+
domain
|
10
26
|
end
|
11
|
-
# This is ruby magic for making a new hash with another hash.
|
12
|
-
# It wraps the JSON in our Schema Class to have the helper methods
|
13
|
-
# available
|
14
|
-
self[JSON.parse(ShopifyCli::DB.get(:shopify_admin_schema))]
|
15
27
|
end
|
16
28
|
|
17
29
|
def type(name)
|
data/lib/shopify-cli/command.rb
CHANGED
@@ -3,12 +3,13 @@ require 'shopify_cli'
|
|
3
3
|
|
4
4
|
module ShopifyCli
|
5
5
|
class Command < CLI::Kit::BaseCommand
|
6
|
+
extend Feature::Set
|
7
|
+
|
6
8
|
attr_writer :ctx
|
7
9
|
attr_accessor :options
|
8
10
|
|
9
11
|
class << self
|
10
12
|
attr_writer :ctx
|
11
|
-
attr_reader :hidden
|
12
13
|
|
13
14
|
def call(args, command_name)
|
14
15
|
subcommand, resolved_name = subcommand_registry.lookup_command(args.first)
|
@@ -23,10 +24,6 @@ module ShopifyCli
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
def hidden_command
|
27
|
-
@hidden = true
|
28
|
-
end
|
29
|
-
|
30
27
|
def options(&block)
|
31
28
|
@_options = block
|
32
29
|
end
|
data/lib/shopify-cli/commands.rb
CHANGED
@@ -18,6 +18,7 @@ module ShopifyCli
|
|
18
18
|
@core_commands.include?(cmd)
|
19
19
|
end
|
20
20
|
|
21
|
+
register :Config, 'config', 'shopify-cli/commands/config', true
|
21
22
|
register :Connect, 'connect', 'shopify-cli/commands/connect', true
|
22
23
|
register :Create, 'create', 'shopify-cli/commands/create', true
|
23
24
|
register :Help, 'help', 'shopify-cli/commands/help', true
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
|
3
|
+
module ShopifyCli
|
4
|
+
module Commands
|
5
|
+
class Config < ShopifyCli::Command
|
6
|
+
hidden_feature(feature_set: :debug)
|
7
|
+
|
8
|
+
subcommand :Feature, 'feature'
|
9
|
+
|
10
|
+
def call(*)
|
11
|
+
@ctx.puts(self.class.help)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.help
|
15
|
+
ShopifyCli::Context.message('core.config.help', ShopifyCli::TOOL_NAME)
|
16
|
+
end
|
17
|
+
|
18
|
+
class Feature < ShopifyCli::SubCommand
|
19
|
+
options do |parser, flags|
|
20
|
+
parser.on('--enable') { flags[:action] = 'enable' }
|
21
|
+
parser.on('--disable') { flags[:action] = 'disable' }
|
22
|
+
parser.on('--status') { flags[:action] = 'status' }
|
23
|
+
end
|
24
|
+
|
25
|
+
def call(args, _name)
|
26
|
+
feature_name = args.shift
|
27
|
+
return @ctx.puts(@ctx.message('core.config.help', ShopifyCli::TOOL_NAME)) if feature_name.nil?
|
28
|
+
is_enabled = ShopifyCli::Feature.enabled?(feature_name)
|
29
|
+
if options.flags[:action] == 'disable' && is_enabled
|
30
|
+
ShopifyCli::Feature.disable(feature_name)
|
31
|
+
@ctx.puts(@ctx.message('core.config.feature.disabled', is_enabled))
|
32
|
+
elsif options.flags[:action] == 'enable' && !is_enabled
|
33
|
+
ShopifyCli::Feature.enable(feature_name)
|
34
|
+
@ctx.puts(@ctx.message('core.config.feature.enabled', feature_name))
|
35
|
+
elsif is_enabled
|
36
|
+
@ctx.puts(@ctx.message('core.config.feature.is_enabled', feature_name))
|
37
|
+
else
|
38
|
+
@ctx.puts(@ctx.message('core.config.feature.is_disabled', feature_name))
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -6,7 +6,7 @@ module ShopifyCli
|
|
6
6
|
def call(*)
|
7
7
|
project_type = ask_project_type unless Project.has_current?
|
8
8
|
|
9
|
-
if Project.has_current? && Project.current
|
9
|
+
if Project.has_current? && Project.current && Project.current.env
|
10
10
|
@ctx.puts @ctx.message('core.connect.already_connected_warning')
|
11
11
|
prod_warning = @ctx.message('core.connect.production_warning')
|
12
12
|
@ctx.puts prod_warning if [:rails, :node].include?(Project.current_project_type)
|
@@ -20,13 +20,13 @@ module ShopifyCli
|
|
20
20
|
|
21
21
|
org = fetch_org
|
22
22
|
id = org['id']
|
23
|
-
app = get_app(org['apps'])
|
23
|
+
app = get_app(id, org['apps'])
|
24
24
|
shop = get_shop(org['stores'], id)
|
25
25
|
|
26
26
|
write_env(app, shop, env_data[:scopes], env_data[:extra])
|
27
27
|
write_cli_yml(project_type, id) unless Project.has_current?
|
28
28
|
|
29
|
-
@ctx.puts(@ctx.message('core.connect.connected', app
|
29
|
+
@ctx.puts(@ctx.message('core.connect.connected', app['title']))
|
30
30
|
end
|
31
31
|
|
32
32
|
def ask_project_type
|
@@ -54,15 +54,22 @@ module ShopifyCli
|
|
54
54
|
org
|
55
55
|
end
|
56
56
|
|
57
|
-
def get_app(apps)
|
58
|
-
|
59
|
-
apps.first
|
57
|
+
def get_app(org_id, apps)
|
58
|
+
if apps.count == 1
|
59
|
+
apps.first
|
60
|
+
elsif apps.count == 0
|
61
|
+
@ctx.puts(@ctx.message('core.connect.no_apps'))
|
62
|
+
title = CLI::UI::Prompt.ask(@ctx.message('core.connect.app_name'))
|
63
|
+
type = CLI::UI::Prompt.ask(@ctx.message('core.connect.app_type.select')) do |handler|
|
64
|
+
handler.option(@ctx.message('core.connect.app_type.select_public')) { 'public' }
|
65
|
+
handler.option(@ctx.message('core.connect.app_type.select_custom')) { 'custom' }
|
66
|
+
end
|
67
|
+
ShopifyCli::Tasks::CreateApiClient.call(@ctx, org_id: org_id, title: title, type: type)
|
60
68
|
else
|
61
69
|
CLI::UI::Prompt.ask(@ctx.message('core.connect.app_select')) do |handler|
|
62
|
-
apps.each { |app| handler.option(app["title"]) { app
|
70
|
+
apps.each { |app| handler.option(app["title"]) { app } }
|
63
71
|
end
|
64
72
|
end
|
65
|
-
apps.select { |app| app["id"] == app_id }
|
66
73
|
end
|
67
74
|
|
68
75
|
def get_shop(shops, id)
|
@@ -83,8 +90,8 @@ module ShopifyCli
|
|
83
90
|
extra = {} if extra.nil?
|
84
91
|
|
85
92
|
Resources::EnvFile.new(
|
86
|
-
api_key: app
|
87
|
-
secret: app
|
93
|
+
api_key: app["apiKey"],
|
94
|
+
secret: app["apiSecretKeys"].first["secret"],
|
88
95
|
shop: shop,
|
89
96
|
scopes: scopes,
|
90
97
|
extra: extra,
|