shopify-cli 1.0.2 → 1.1.1
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/.travis.yml +3 -2
- data/CHANGELOG.md +20 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -13
- data/bin/load_shopify.rb +3 -1
- data/bin/shopify +2 -0
- data/docs/Gemfile.lock +23 -13
- data/docs/getting-started/index.md +3 -2
- data/docs/getting-started/install/index.md +55 -9
- data/docs/getting-started/uninstall/index.md +1 -1
- data/docs/getting-started/upgrade/index.md +8 -4
- data/ext/shopify-cli/extconf.rb +40 -20
- data/lib/project_types/extension/cli.rb +1 -1
- data/lib/project_types/extension/commands/build.rb +1 -1
- data/lib/project_types/extension/models/type.rb +1 -0
- data/lib/project_types/extension/tasks/create_extension.rb +1 -1
- data/lib/project_types/extension/tasks/get_app.rb +1 -1
- data/lib/project_types/extension/tasks/update_draft.rb +1 -1
- data/lib/project_types/node/commands/create.rb +4 -4
- data/lib/project_types/node/commands/deploy/heroku.rb +6 -1
- data/lib/project_types/node/commands/generate/billing.rb +7 -5
- data/lib/project_types/node/commands/generate/page.rb +9 -5
- data/lib/project_types/node/commands/generate/webhook.rb +5 -1
- data/lib/project_types/node/messages/messages.rb +1 -0
- data/lib/project_types/rails/cli.rb +0 -1
- data/lib/project_types/rails/commands/create.rb +52 -4
- data/lib/project_types/rails/commands/generate.rb +1 -0
- data/lib/project_types/rails/commands/generate/webhook.rb +3 -2
- data/lib/project_types/rails/commands/serve.rb +6 -2
- data/lib/project_types/rails/gem.rb +61 -6
- data/lib/project_types/rails/messages/messages.rb +27 -11
- data/lib/project_types/script/cli.rb +2 -3
- data/lib/project_types/script/commands/create.rb +5 -9
- data/lib/project_types/script/commands/disable.rb +4 -15
- data/lib/project_types/script/commands/enable.rb +37 -13
- data/lib/project_types/script/commands/push.rb +8 -13
- data/lib/project_types/script/config/extension_points.yml +9 -3
- data/lib/project_types/script/errors.rb +8 -0
- data/lib/project_types/script/forms/create.rb +1 -1
- data/lib/project_types/script/layers/application/create_script.rb +7 -6
- 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/push_script.rb +6 -4
- data/lib/project_types/script/layers/domain/errors.rb +2 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +2 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +8 -2
- data/lib/project_types/script/messages/messages.rb +25 -31
- data/lib/project_types/script/script_project.rb +6 -2
- data/lib/project_types/script/templates/ts/as-pect.config.js +6 -0
- data/lib/project_types/script/ui/error_handler.rb +8 -0
- data/lib/project_types/script/ui/printing_spinner.rb +75 -0
- data/lib/rubygems_plugin.rb +18 -10
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +1 -1
- data/lib/shopify-cli/admin_api/schema.rb +20 -18
- data/lib/shopify-cli/command.rb +14 -11
- data/lib/shopify-cli/commands.rb +1 -0
- data/lib/shopify-cli/commands/config.rb +44 -0
- data/lib/shopify-cli/commands/connect.rb +8 -69
- data/lib/shopify-cli/commands/create.rb +2 -2
- data/lib/shopify-cli/commands/help.rb +1 -1
- data/lib/shopify-cli/commands/system.rb +22 -13
- data/lib/shopify-cli/context.rb +28 -0
- data/lib/shopify-cli/core.rb +0 -1
- data/lib/shopify-cli/core/entry_point.rb +1 -1
- data/lib/shopify-cli/core/executor.rb +3 -5
- data/lib/shopify-cli/core/monorail.rb +1 -1
- data/lib/shopify-cli/db.rb +1 -1
- data/lib/shopify-cli/feature.rb +97 -0
- data/lib/shopify-cli/heroku.rb +21 -5
- data/lib/shopify-cli/js_deps.rb +2 -2
- data/lib/shopify-cli/js_system.rb +2 -2
- data/lib/shopify-cli/messages/messages.rb +40 -12
- data/lib/shopify-cli/partners_api/organizations.rb +7 -7
- data/lib/shopify-cli/process_supervision.rb +60 -21
- data/lib/shopify-cli/project.rb +14 -6
- data/lib/shopify-cli/project_type.rb +5 -7
- data/lib/shopify-cli/sub_command.rb +1 -0
- data/lib/shopify-cli/task.rb +2 -2
- data/lib/shopify-cli/tasks.rb +11 -4
- data/lib/shopify-cli/tasks/ensure_env.rb +72 -16
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +4 -3
- data/lib/shopify-cli/tunnel.rb +53 -14
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +36 -9
- data/shopify-cli.gemspec +4 -1
- data/vendor/deps/cli-kit/REVISION +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit.rb +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +2 -2
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +12 -6
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +9 -11
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +8 -2
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +7 -7
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +48 -17
- data/vendor/deps/cli-ui/REVISION +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui.rb +5 -4
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +9 -3
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -2
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +13 -5
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +29 -2
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +21 -10
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +63 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +11 -2
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -3
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +6 -8
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +2 -0
- data/vendor/gen/lib/gen.rb +39 -0
- data/vendor/gen/lib/gen/commands.rb +18 -0
- data/vendor/gen/lib/gen/commands/help.rb +20 -0
- data/vendor/gen/lib/gen/commands/new.rb +21 -0
- data/vendor/gen/lib/gen/entry_point.rb +10 -0
- data/vendor/gen/lib/gen/generator.rb +165 -0
- data/vendor/gen/template/.gitignore +2 -0
- data/vendor/gen/template/Gemfile +10 -0
- data/vendor/gen/template/README.md +1 -0
- data/vendor/gen/template/bin/testunit +23 -0
- data/vendor/gen/template/bin/update-deps +97 -0
- data/vendor/gen/template/dev-gems.yml +3 -0
- data/vendor/gen/template/dev-vendor.yml +4 -0
- data/vendor/gen/template/exe/__app__-gems +17 -0
- data/vendor/gen/template/exe/__app__-vendor +18 -0
- data/vendor/gen/template/lib/__app__.rb +33 -0
- data/vendor/gen/template/lib/__app__/commands.rb +18 -0
- data/vendor/gen/template/lib/__app__/commands/example.rb +19 -0
- data/vendor/gen/template/lib/__app__/commands/help.rb +21 -0
- data/vendor/gen/template/lib/__app__/entry_point.rb +10 -0
- data/vendor/gen/template/test/example_test.rb +17 -0
- data/vendor/gen/template/test/test_helper.rb +22 -0
- metadata +28 -6
- data/Vagrantfile +0 -17
- 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/forms/script_form.rb +0 -66
|
@@ -38,10 +38,15 @@ module Script
|
|
|
38
38
|
invalid_extension_cause: "Invalid extension point %s",
|
|
39
39
|
invalid_extension_help: "Allowed values: %s.",
|
|
40
40
|
|
|
41
|
+
invalid_config: "Can't change the configuration values because %1$s is missing or "\
|
|
42
|
+
"it is not formatted properly.",
|
|
43
|
+
|
|
41
44
|
script_not_found_cause: "Couldn't find script %s for extension point %s",
|
|
42
45
|
|
|
43
46
|
app_not_installed_cause: "App not installed on development store.",
|
|
44
47
|
|
|
48
|
+
app_script_not_pushed_help: "Push the script and then try this command again.",
|
|
49
|
+
|
|
45
50
|
app_script_undefined_help: "Push script to app.",
|
|
46
51
|
|
|
47
52
|
build_error_cause: "Something went wrong while building the script.",
|
|
@@ -72,32 +77,26 @@ module Script
|
|
|
72
77
|
help: <<~HELP,
|
|
73
78
|
{{command:%1$s create script}}: Creates a script project.
|
|
74
79
|
Usage: {{command:%1$s create script}}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
\s\s{{command:--name=NAME}} Script project name. Use any string.
|
|
79
|
-
\s\s{{command:--extension_point=TYPE}} Extension point name. Allowed values: %2$s.
|
|
80
|
+
Options:
|
|
81
|
+
{{command:--name=NAME}} Script project name. Use any string.
|
|
82
|
+
{{command:--extension_point=TYPE}} Extension point name. Allowed values: %2$s.
|
|
80
83
|
HELP
|
|
81
84
|
|
|
82
85
|
error: {
|
|
83
86
|
operation_failed: "Script not created.",
|
|
84
87
|
},
|
|
85
88
|
|
|
86
|
-
|
|
87
|
-
script_created: "{{v}} Script created: {{green:%{script_id}}}",
|
|
89
|
+
change_directory_notice: "{{*}} Change directories to {{green:%s}} to run script commands",
|
|
88
90
|
creating: "Creating script",
|
|
89
|
-
created: "Created script",
|
|
91
|
+
created: "Created script: {{green:%s}}",
|
|
90
92
|
},
|
|
91
93
|
|
|
92
94
|
push: {
|
|
93
95
|
help: <<~HELP,
|
|
94
96
|
Build the script and put it into production. If you've already pushed a script with the same extension point, use --force to replace the current script with the newest one.
|
|
95
97
|
Usage: {{command:%s push}}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
\s\sOptions:
|
|
99
|
-
\s\s{{command:--API_key=<API_key>}} API key. Must be a valid API key, otherwise store access fails.
|
|
100
|
-
\s\s{{command:[--force]}} Forces the script to be overwritten if an instance of it already exists.
|
|
98
|
+
Options:
|
|
99
|
+
{{command:[--force]}} Forces the script to be overwritten if an instance of it already exists.
|
|
101
100
|
HELP
|
|
102
101
|
|
|
103
102
|
error: {
|
|
@@ -112,14 +111,10 @@ module Script
|
|
|
112
111
|
Turn off script in development store.
|
|
113
112
|
Usage: {{command:%s disable}}
|
|
114
113
|
HELP
|
|
115
|
-
extended_help: <<~HELP,
|
|
116
|
-
\s\sOptions:
|
|
117
|
-
\s\s{{command:--API_key=<API_key>}} API key. Must be a valid API key, otherwise store access fails.
|
|
118
|
-
\s\s{{command:--shop_domain=<my_store.myshopify.com>}} Test store URL. Must be an existing test store.
|
|
119
|
-
HELP
|
|
120
114
|
|
|
121
115
|
error: {
|
|
122
116
|
operation_failed: "Can't disable script.",
|
|
117
|
+
not_pushed_to_app: "Can't disable the script because it hasn't been pushed to the app.",
|
|
123
118
|
},
|
|
124
119
|
|
|
125
120
|
script_disabled: "{{v}} Script disabled. Script is turned off in development store.",
|
|
@@ -129,11 +124,9 @@ module Script
|
|
|
129
124
|
help: <<~HELP,
|
|
130
125
|
Turn on script in development store.
|
|
131
126
|
Usage: {{command:%s enable}}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
\s\s{{command:--API_key=<API_key>}} API key. Must be a valid API key, otherwise store access fails.
|
|
136
|
-
\s\s{{command:--shop_domain=<my_store.myshopify.com>}} Test store URL. Must be an existing test store.
|
|
127
|
+
Options:
|
|
128
|
+
{{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.
|
|
129
|
+
{{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.
|
|
137
130
|
HELP
|
|
138
131
|
|
|
139
132
|
info: "{{*}} A script always remains enabled until you disable it - even after pushing "\
|
|
@@ -142,6 +135,7 @@ module Script
|
|
|
142
135
|
|
|
143
136
|
error: {
|
|
144
137
|
operation_failed: "Can't enable script.",
|
|
138
|
+
not_pushed_to_app: "Can't enable the script because it hasn't been pushed to the app.",
|
|
145
139
|
},
|
|
146
140
|
|
|
147
141
|
script_enabled: "{{v}} Script enabled. %{type} script %{title} in app (API key: %{api_key}) "\
|
|
@@ -177,25 +171,25 @@ module Script
|
|
|
177
171
|
script_form: {
|
|
178
172
|
ask_app_api_key_default: "Which app do you want this script to belong to?",
|
|
179
173
|
ask_shop_domain_default: "Select a development store",
|
|
180
|
-
fetching_organizations: "
|
|
174
|
+
fetching_organizations: "Fetching partner organizations",
|
|
175
|
+
fetched_organizations: "Fetched partner organizations",
|
|
181
176
|
select_organization: "Select partner organization.",
|
|
182
177
|
using_app: "Using app {{green:%{title} (%{api_key})}}.",
|
|
183
178
|
using_development_store: "Using development store {{green:%{domain}}}",
|
|
184
179
|
using_organization: "Partner organization {{green:%s}}.",
|
|
185
180
|
},
|
|
186
|
-
enable: {
|
|
187
|
-
ask_app_api_key: "Which app is the script pushed to?",
|
|
188
|
-
ask_shop_domain: "Which development store is the app installed on?",
|
|
189
|
-
},
|
|
190
181
|
},
|
|
191
182
|
|
|
192
183
|
application: {
|
|
193
184
|
building: "Building",
|
|
194
185
|
building_script: "Building script",
|
|
195
186
|
built: "Built",
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
187
|
+
pushing: "Pushing",
|
|
188
|
+
pushed: "Pushed",
|
|
189
|
+
disabling: "Disabling",
|
|
190
|
+
disabled: "Disabled",
|
|
191
|
+
enabling: "Enabling",
|
|
192
|
+
enabled: "Enabled",
|
|
199
193
|
},
|
|
200
194
|
},
|
|
201
195
|
}.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
|
|
@@ -44,6 +44,10 @@ 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::InvalidConfigYAMLError
|
|
48
|
+
{
|
|
49
|
+
cause_of_error: ShopifyCli::Context.message('script.error.invalid_config', e.config_file),
|
|
50
|
+
}
|
|
47
51
|
when Errors::InvalidScriptNameError
|
|
48
52
|
{
|
|
49
53
|
cause_of_error: ShopifyCli::Context.message('script.error.invalid_script_name_cause'),
|
|
@@ -92,6 +96,10 @@ module Script
|
|
|
92
96
|
{
|
|
93
97
|
cause_of_error: ShopifyCli::Context.message('script.error.app_not_installed_cause'),
|
|
94
98
|
}
|
|
99
|
+
when Layers::Infrastructure::Errors::AppScriptNotPushedError
|
|
100
|
+
{
|
|
101
|
+
cause_of_error: ShopifyCli::Context.message('script.error.app_script_not_pushed_help'),
|
|
102
|
+
}
|
|
95
103
|
when Layers::Infrastructure::Errors::AppScriptUndefinedError
|
|
96
104
|
{
|
|
97
105
|
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
|
data/lib/rubygems_plugin.rb
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
Gem.post_uninstall do |uninstaller|
|
|
2
2
|
if uninstaller.spec.name == 'shopify-cli'
|
|
3
|
-
|
|
3
|
+
if RUBY_PLATFORM.match(/mingw32/)
|
|
4
|
+
bat_path = File.dirname(RbConfig.ruby)
|
|
5
|
+
bat = "#{bat_path}\\shopify.bat"
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
# delete the auto-generated batch script
|
|
8
|
+
File.unlink(bat)
|
|
9
|
+
else
|
|
10
|
+
require 'fileutils'
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
symlink = '/usr/local/bin/shopify'
|
|
13
|
+
|
|
14
|
+
# delete the symbolic link IFF it exists AND it does not point to a file
|
|
15
|
+
# (i.e., it's been left hanging as a result of the uninstall, as expected)
|
|
16
|
+
#
|
|
17
|
+
# if the file still exists, either the uninstall failed (possible but
|
|
18
|
+
# unlikely) OR
|
|
19
|
+
# there's another installation of the gem in another ruby folder that has
|
|
20
|
+
# overwritten it, so leave the symbolic link alone
|
|
21
|
+
system("sudo rm -f #{symlink}") if File.symlink?(symlink) && !File.exist?(symlink)
|
|
22
|
+
end
|
|
15
23
|
end
|
|
16
24
|
|
|
17
25
|
true
|
|
@@ -118,7 +118,7 @@ module ShopifyCli
|
|
|
118
118
|
kwargs = { input: data }
|
|
119
119
|
kwargs[:shop] = @shop
|
|
120
120
|
resp = AdminAPI.query(
|
|
121
|
-
@ctx, "create_#{snake_case_resource_type}", kwargs
|
|
121
|
+
@ctx, "create_#{snake_case_resource_type}", **kwargs
|
|
122
122
|
)
|
|
123
123
|
@ctx.abort(resp['errors']) if resp['errors']
|
|
124
124
|
@ctx.done(message(resp['data'])) unless @silent
|
|
@@ -3,16 +3,27 @@ require 'shopify_cli'
|
|
|
3
3
|
module ShopifyCli
|
|
4
4
|
class AdminAPI
|
|
5
5
|
class Schema < Hash
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
11
26
|
end
|
|
12
|
-
# This is ruby magic for making a new hash with another hash.
|
|
13
|
-
# It wraps the JSON in our Schema Class to have the helper methods
|
|
14
|
-
# available
|
|
15
|
-
self[JSON.parse(ShopifyCli::DB.get(:shopify_admin_schema))]
|
|
16
27
|
end
|
|
17
28
|
|
|
18
29
|
def type(name)
|
|
@@ -28,15 +39,6 @@ module ShopifyCli
|
|
|
28
39
|
object["name"]
|
|
29
40
|
end
|
|
30
41
|
end
|
|
31
|
-
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
def get_shop(ctx)
|
|
35
|
-
res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx)
|
|
36
|
-
domain = res[:shop_domain]
|
|
37
|
-
Project.current.env.update(ctx, :shop, domain)
|
|
38
|
-
domain
|
|
39
|
-
end
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
end
|
data/lib/shopify-cli/command.rb
CHANGED
|
@@ -3,30 +3,29 @@ 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
|
-
attr_writer :ctx
|
|
11
|
-
attr_reader :hidden
|
|
12
|
+
attr_writer :ctx, :task_registry
|
|
12
13
|
|
|
13
14
|
def call(args, command_name)
|
|
14
15
|
subcommand, resolved_name = subcommand_registry.lookup_command(args.first)
|
|
15
16
|
if subcommand
|
|
16
17
|
subcommand.ctx = @ctx
|
|
18
|
+
subcommand.task_registry = @task_registry
|
|
17
19
|
subcommand.call(args, resolved_name, command_name)
|
|
18
20
|
else
|
|
19
21
|
cmd = new(@ctx)
|
|
20
22
|
cmd.options.parse(@_options, args)
|
|
21
23
|
return call_help(command_name) if cmd.options.help
|
|
24
|
+
run_prerequisites
|
|
22
25
|
cmd.call(args, command_name)
|
|
23
26
|
end
|
|
24
27
|
end
|
|
25
28
|
|
|
26
|
-
def hidden_command
|
|
27
|
-
@hidden = true
|
|
28
|
-
end
|
|
29
|
-
|
|
30
29
|
def options(&block)
|
|
31
30
|
@_options = block
|
|
32
31
|
end
|
|
@@ -44,13 +43,16 @@ module ShopifyCli
|
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
def prerequisite_task(*tasks)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
@prerequisite_tasks ||= []
|
|
47
|
+
@prerequisite_tasks += tasks
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def run_prerequisites
|
|
51
|
+
(@prerequisite_tasks || []).each { |task| task_registry[task]&.call(@ctx) }
|
|
50
52
|
end
|
|
51
53
|
|
|
52
|
-
def
|
|
53
|
-
@
|
|
54
|
+
def task_registry
|
|
55
|
+
@task_registry || ShopifyCli::Tasks::Registry
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
def call_help(*cmds)
|
|
@@ -60,6 +62,7 @@ module ShopifyCli
|
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
def initialize(ctx = nil)
|
|
65
|
+
super()
|
|
63
66
|
@ctx = ctx || ShopifyCli::Context.new
|
|
64
67
|
self.options = Options.new
|
|
65
68
|
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
|