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
@@ -16,13 +16,12 @@ module Extension
|
|
16
16
|
attr_writer :app
|
17
17
|
|
18
18
|
def ask_app
|
19
|
-
apps = load_apps
|
20
|
-
|
21
19
|
if !api_key.nil?
|
22
|
-
found_app =
|
20
|
+
found_app = Tasks::GetApp.call(context: ctx, api_key: api_key)
|
23
21
|
ctx.abort(ctx.message('register.invalid_api_key', api_key)) if found_app.nil?
|
24
22
|
found_app
|
25
23
|
else
|
24
|
+
apps = load_apps
|
26
25
|
CLI::UI::Prompt.ask(ctx.message('register.ask_app')) do |handler|
|
27
26
|
apps.each do |app|
|
28
27
|
handler.option("#{app.title} by #{app.business_name}") { app }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module Converters
|
7
|
+
module AppConverter
|
8
|
+
API_KEY_FIELD = 'apiKey'
|
9
|
+
API_SECRET_KEYS_FIELD = 'apiSecretKeys'
|
10
|
+
API_SECRET_FIELD = 'secret'
|
11
|
+
TITLE_FIELD = 'title'
|
12
|
+
ORGANIZATION_NAME_FIELD = 'businessName'
|
13
|
+
|
14
|
+
def self.from_hash(hash, organization = {})
|
15
|
+
return nil if hash.nil?
|
16
|
+
|
17
|
+
Models::App.new(
|
18
|
+
api_key: hash[API_KEY_FIELD],
|
19
|
+
secret: hash[API_SECRET_KEYS_FIELD].first[API_SECRET_FIELD],
|
20
|
+
title: hash[TITLE_FIELD],
|
21
|
+
business_name: organization[ORGANIZATION_NAME_FIELD]
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
class GetApp < ShopifyCli::Task
|
7
|
+
GRAPHQL_FILE = 'get_app_by_api_key'
|
8
|
+
|
9
|
+
RESPONSE_FIELD = %w(data)
|
10
|
+
APP_FIELD = 'app'
|
11
|
+
|
12
|
+
def call(context:, api_key:)
|
13
|
+
input = { api_key: api_key }
|
14
|
+
|
15
|
+
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, input).dig(*RESPONSE_FIELD)
|
16
|
+
context.abort(context.message('tasks.errors.parse_error')) if response.nil?
|
17
|
+
|
18
|
+
Converters::AppConverter.from_hash(response.dig(APP_FIELD))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -21,12 +21,7 @@ module Extension
|
|
21
21
|
return [] unless organization.key?('apps') && organization['apps'].any?
|
22
22
|
|
23
23
|
organization['apps'].map do |app|
|
24
|
-
|
25
|
-
api_key: app['apiKey'],
|
26
|
-
secret: app["apiSecretKeys"].first["secret"],
|
27
|
-
title: app['title'],
|
28
|
-
business_name: organization['businessName']
|
29
|
-
)
|
24
|
+
Converters::AppConverter.from_hash(app, organization)
|
30
25
|
end
|
31
26
|
end
|
32
27
|
end
|
@@ -10,8 +10,9 @@ module Node
|
|
10
10
|
self.title ||= CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_name'))
|
11
11
|
self.type = ask_type
|
12
12
|
self.name = self.title.downcase.split(" ").join("_")
|
13
|
-
|
14
|
-
self.
|
13
|
+
res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
|
14
|
+
self.organization_id = res[:organization_id]
|
15
|
+
self.shop_domain = res[:shop_domain]
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
@@ -30,58 +31,6 @@ module Node
|
|
30
31
|
ctx.puts(ctx.message('node.forms.create.app_type.selected', type))
|
31
32
|
type
|
32
33
|
end
|
33
|
-
|
34
|
-
def organizations
|
35
|
-
@organizations ||= ShopifyCli::PartnersAPI::Organizations.fetch_all(ctx)
|
36
|
-
end
|
37
|
-
|
38
|
-
def organization
|
39
|
-
@organization ||= if !organization_id.nil?
|
40
|
-
org = ShopifyCli::PartnersAPI::Organizations.fetch(ctx, id: organization_id)
|
41
|
-
if org.nil?
|
42
|
-
ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
43
|
-
ctx.abort(ctx.message('node.forms.create.error.organization_not_found'))
|
44
|
-
end
|
45
|
-
org
|
46
|
-
elsif organizations.count == 0
|
47
|
-
ctx.puts(ctx.message('node.forms.create.partners_notice'))
|
48
|
-
ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
49
|
-
ctx.abort(ctx.message('node.forms.create.error.no_organizations'))
|
50
|
-
elsif organizations.count == 1
|
51
|
-
org = organizations.first
|
52
|
-
ctx.puts(ctx.message('node.forms.create.organization',
|
53
|
-
ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])))
|
54
|
-
org
|
55
|
-
else
|
56
|
-
org_id = CLI::UI::Prompt.ask(ctx.message('node.forms.create.organization_select')) do |handler|
|
57
|
-
organizations.each do |o|
|
58
|
-
handler.option(ctx.message('core.partners_api.org_name_and_id', o['businessName'], o['id'])) { o['id'] }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
organizations.find { |o| o['id'] == org_id }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def ask_shop_domain
|
66
|
-
valid_stores = organization['stores'].select do |store|
|
67
|
-
store['transferDisabled'] == true || store['convertableToPartnerTest'] == true
|
68
|
-
end
|
69
|
-
|
70
|
-
if valid_stores.count == 0
|
71
|
-
ctx.puts(ctx.message('node.forms.create.no_development_stores'))
|
72
|
-
ctx.puts(ctx.message('node.forms.create.create_store', organization['id']))
|
73
|
-
ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
74
|
-
elsif valid_stores.count == 1
|
75
|
-
domain = valid_stores.first['shopDomain']
|
76
|
-
ctx.puts(ctx.message('node.forms.create.development_store', domain))
|
77
|
-
domain
|
78
|
-
else
|
79
|
-
CLI::UI::Prompt.ask(
|
80
|
-
ctx.message('node.forms.create.development_store_select'),
|
81
|
-
options: valid_stores.map { |s| s['shopDomain'] }
|
82
|
-
)
|
83
|
-
end
|
84
|
-
end
|
85
34
|
end
|
86
35
|
end
|
87
36
|
end
|
@@ -28,8 +28,8 @@ module Node
|
|
28
28
|
},
|
29
29
|
info: {
|
30
30
|
created: "{{v}} {{green:%s}} was created in your Partner Dashboard {{underline:%s}}",
|
31
|
-
serve: "{{*}} Change
|
32
|
-
"local server",
|
31
|
+
serve: "{{*}} Change directories to your new project folder {{green:%s}} and run {{command:%s serve}} " \
|
32
|
+
"to start a local server",
|
33
33
|
install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
|
34
34
|
},
|
35
35
|
node_version: "node %s",
|
@@ -233,25 +233,14 @@ module Node
|
|
233
233
|
create: {
|
234
234
|
error: {
|
235
235
|
invalid_app_type: "Invalid app type %s",
|
236
|
-
organization_not_found: "Cannot find a partner organization with that ID",
|
237
|
-
no_organizations: "No partner organizations available.",
|
238
236
|
},
|
239
|
-
|
240
|
-
authentication_issue: "For authentication issues, run {{command:%s logout}} to clear invalid credentials",
|
241
|
-
partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
|
242
|
-
no_development_stores: "{{x}} No Development Stores available.",
|
243
|
-
create_store: "Visit {{underline:https://partners.shopify.com/%s/stores}} to create one",
|
244
|
-
app_name: "App Name",
|
237
|
+
app_name: "App name",
|
245
238
|
app_type: {
|
246
239
|
select: "What type of app are you building?",
|
247
240
|
select_public: "Public: An app built for a wide merchant audience.",
|
248
241
|
select_custom: "Custom: An app custom built for a single client.",
|
249
242
|
selected: "App type {{green:%s}}",
|
250
243
|
},
|
251
|
-
organization_select: "Select partner organization",
|
252
|
-
organization: "Partner organization {{green:%s}}",
|
253
|
-
development_store_select: "Select a development store",
|
254
|
-
development_store: "Using development store {{green:%s}}",
|
255
244
|
},
|
256
245
|
},
|
257
246
|
},
|
@@ -22,8 +22,9 @@ module Rails
|
|
22
22
|
self.title ||= CLI::UI::Prompt.ask(ctx.message('rails.forms.create.app_name'))
|
23
23
|
self.type = ask_type
|
24
24
|
self.name = self.title.downcase.split(" ").join("_")
|
25
|
-
|
26
|
-
self.
|
25
|
+
res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
|
26
|
+
self.organization_id = res[:organization_id]
|
27
|
+
self.shop_domain = res[:shop_domain]
|
27
28
|
self.db = ask_db
|
28
29
|
end
|
29
30
|
|
@@ -44,56 +45,6 @@ module Rails
|
|
44
45
|
type
|
45
46
|
end
|
46
47
|
|
47
|
-
def organizations
|
48
|
-
@organizations ||= ShopifyCli::PartnersAPI::Organizations.fetch_all(ctx)
|
49
|
-
end
|
50
|
-
|
51
|
-
def organization
|
52
|
-
@organization ||= if !organization_id.nil?
|
53
|
-
org = ShopifyCli::PartnersAPI::Organizations.fetch(ctx, id: organization_id)
|
54
|
-
if org.nil?
|
55
|
-
ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
56
|
-
ctx.abort(ctx.message('rails.forms.create.error.organization_not_found'))
|
57
|
-
end
|
58
|
-
org
|
59
|
-
elsif organizations.count == 0
|
60
|
-
ctx.puts(ctx.message('rails.forms.create.partners_notice'))
|
61
|
-
ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
62
|
-
ctx.abort(ctx.message('rails.forms.create.error.no_organizations'))
|
63
|
-
elsif organizations.count == 1
|
64
|
-
org = organizations.first
|
65
|
-
ctx.puts(ctx.message('rails.forms.create.organization',
|
66
|
-
ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])))
|
67
|
-
org
|
68
|
-
else
|
69
|
-
org_id = CLI::UI::Prompt.ask(ctx.message('rails.forms.create.organization_select')) do |handler|
|
70
|
-
organizations.each { |o| handler.option(o['businessName']) { o['id'] } }
|
71
|
-
end
|
72
|
-
organizations.find { |o| o['id'] == org_id }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def ask_shop_domain
|
77
|
-
valid_stores = organization['stores'].select do |store|
|
78
|
-
store['transferDisabled'] == true || store['convertableToPartnerTest'] == true
|
79
|
-
end
|
80
|
-
|
81
|
-
if valid_stores.count == 0
|
82
|
-
ctx.puts(ctx.message('rails.forms.create.no_development_stores'))
|
83
|
-
ctx.puts(ctx.message('rails.forms.create.create_store', organization['id']))
|
84
|
-
ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
85
|
-
elsif valid_stores.count == 1
|
86
|
-
domain = valid_stores.first['shopDomain']
|
87
|
-
ctx.puts(ctx.message('rails.forms.create.development_store', domain))
|
88
|
-
domain
|
89
|
-
else
|
90
|
-
CLI::UI::Prompt.ask(
|
91
|
-
ctx.message('rails.forms.create.development_store_select'),
|
92
|
-
options: valid_stores.map { |s| s['shopDomain'] }
|
93
|
-
)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
48
|
def ask_db
|
98
49
|
if db.nil?
|
99
50
|
return 'sqlite3' unless CLI::UI::Prompt.confirm(ctx.message('rails.forms.create.db.want_select'),
|
@@ -37,8 +37,8 @@ module Rails
|
|
37
37
|
|
38
38
|
info: {
|
39
39
|
created: "{{v}} {{green:%s}} was created in your Partner Dashboard {{underline:%s}}",
|
40
|
-
serve: "{{*}} Change
|
41
|
-
"local server",
|
40
|
+
serve: "{{*}} Change directories to your new project folder {{green:%s}} and run {{command:%s serve}} " \
|
41
|
+
"to start a local server",
|
42
42
|
install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
|
43
43
|
},
|
44
44
|
installing_bundler: "Installing bundler…",
|
@@ -236,14 +236,7 @@ module Rails
|
|
236
236
|
error: {
|
237
237
|
invalid_app_type: "Invalid app type %s",
|
238
238
|
invalid_db_type: "Invalid database type %s",
|
239
|
-
organization_not_found: "Cannot find a partner organization with that ID",
|
240
|
-
no_organizations: "No partner organizations available.",
|
241
239
|
},
|
242
|
-
|
243
|
-
authentication_issue: "For authentication issues, run {{command:%s logout}} to clear invalid credentials",
|
244
|
-
partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
|
245
|
-
no_development_stores: "{{x}} No development stores available.",
|
246
|
-
create_store: "Visit {{underline:https://partners.shopify.com/%s/stores}} to create one",
|
247
240
|
app_name: "App name",
|
248
241
|
app_type: {
|
249
242
|
select: "What type of app are you building?",
|
@@ -271,10 +264,6 @@ module Rails
|
|
271
264
|
select_jdbc: "JDBC",
|
272
265
|
selected: "Database Type {{green:%s}}",
|
273
266
|
},
|
274
|
-
organization_select: "Select partner organization",
|
275
|
-
organization: "Partner organization {{green:%s}}",
|
276
|
-
development_store_select: "Select a development store",
|
277
|
-
development_store: "Using development store {{green:%s}}",
|
278
267
|
},
|
279
268
|
},
|
280
269
|
},
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Script
|
4
4
|
class Project < ShopifyCli::ProjectType
|
5
|
-
|
5
|
+
hidden_feature(feature_set: :script_project)
|
6
6
|
creator 'Script', 'Script::Commands::Create'
|
7
7
|
|
8
8
|
register_command('Script::Commands::Push', 'push')
|
@@ -24,8 +24,6 @@ module Script
|
|
24
24
|
# define/autoload project specific Forms
|
25
25
|
module Forms
|
26
26
|
autoload :Create, Project.project_filepath('forms/create')
|
27
|
-
autoload :Push, Project.project_filepath('forms/push')
|
28
|
-
autoload :Enable, Project.project_filepath('forms/enable')
|
29
27
|
autoload :ScriptForm, Project.project_filepath('forms/script_form')
|
30
28
|
end
|
31
29
|
|
@@ -51,20 +49,22 @@ module Script
|
|
51
49
|
autoload :Errors, Project.project_filepath('layers/infrastructure/errors')
|
52
50
|
autoload :AssemblyScriptDependencyManager,
|
53
51
|
Project.project_filepath('layers/infrastructure/assemblyscript_dependency_manager')
|
52
|
+
autoload :AssemblyScriptProjectCreator,
|
53
|
+
Project.project_filepath('layers/infrastructure/assemblyscript_project_creator')
|
54
54
|
autoload :AssemblyScriptTaskRunner, Project.project_filepath('layers/infrastructure/assemblyscript_task_runner')
|
55
55
|
autoload :AssemblyScriptTsConfig, Project.project_filepath('layers/infrastructure/assemblyscript_tsconfig')
|
56
|
-
autoload :DependencyManager, Project.project_filepath('layers/infrastructure/dependency_manager')
|
57
56
|
autoload :PushPackageRepository, Project.project_filepath('layers/infrastructure/push_package_repository')
|
58
57
|
autoload :ExtensionPointRepository, Project.project_filepath('layers/infrastructure/extension_point_repository')
|
58
|
+
autoload :ProjectCreator, Project.project_filepath('layers/infrastructure/project_creator')
|
59
59
|
autoload :ScriptRepository, Project.project_filepath('layers/infrastructure/script_repository')
|
60
60
|
autoload :ScriptService, Project.project_filepath('layers/infrastructure/script_service')
|
61
61
|
autoload :TaskRunner, Project.project_filepath('layers/infrastructure/task_runner')
|
62
|
-
autoload :TestSuiteRepository, Project.project_filepath('layers/infrastructure/test_suite_repository')
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
65
|
module UI
|
67
66
|
autoload :ErrorHandler, Project.project_filepath('ui/error_handler')
|
67
|
+
autoload :PrintingSpinner, Project.project_filepath('ui/printing_spinner')
|
68
68
|
autoload :StrictSpinner, Project.project_filepath('ui/strict_spinner')
|
69
69
|
end
|
70
70
|
|
@@ -19,16 +19,17 @@ module Script
|
|
19
19
|
return @ctx.puts(self.class.help)
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
project = Layers::Application::CreateScript.call(
|
23
23
|
ctx: @ctx,
|
24
24
|
language: language,
|
25
25
|
script_name: form.name,
|
26
26
|
extension_point_type: form.extension_point
|
27
27
|
)
|
28
|
-
@ctx.puts(@ctx.message('script.create.
|
29
|
-
|
28
|
+
@ctx.puts(@ctx.message('script.create.change_directory_notice', project.script_name))
|
29
|
+
rescue Script::Errors::ScriptProjectAlreadyExistsError => e
|
30
|
+
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.create.error.operation_failed'))
|
30
31
|
rescue StandardError => e
|
31
|
-
ScriptProject.cleanup(ctx: @ctx, script_name: form.name, root_dir: cur_dir)
|
32
|
+
ScriptProject.cleanup(ctx: @ctx, script_name: form.name, root_dir: cur_dir) if form
|
32
33
|
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.create.error.operation_failed'))
|
33
34
|
end
|
34
35
|
|
@@ -3,20 +3,14 @@
|
|
3
3
|
module Script
|
4
4
|
module Commands
|
5
5
|
class Disable < ShopifyCli::Command
|
6
|
-
|
7
|
-
parser.on('--api_key=APIKEY') { |t| flags[:api_key] = t }
|
8
|
-
parser.on('--shop_domain=MYSHOPIFYDOMAIN') { |t| flags[:shop_domain] = t }
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(args, _name)
|
12
|
-
form = Forms::Enable.ask(@ctx, args, options.flags)
|
13
|
-
return @ctx.puts(self.class.help) unless form
|
6
|
+
prerequisite_task :ensure_env
|
14
7
|
|
8
|
+
def call(_args, _name)
|
15
9
|
project = ScriptProject.current
|
16
10
|
Layers::Application::DisableScript.call(
|
17
11
|
ctx: @ctx,
|
18
|
-
api_key:
|
19
|
-
shop_domain:
|
12
|
+
api_key: project.env[:api_key],
|
13
|
+
shop_domain: project.env[:shop],
|
20
14
|
extension_point_type: project.extension_point_type
|
21
15
|
)
|
22
16
|
@ctx.puts(@ctx.message('script.disable.script_disabled'))
|
@@ -27,10 +21,6 @@ module Script
|
|
27
21
|
def self.help
|
28
22
|
ShopifyCli::Context.message('script.disable.help', ShopifyCli::TOOL_NAME)
|
29
23
|
end
|
30
|
-
|
31
|
-
def self.extended_help
|
32
|
-
ShopifyCli::Context.message('script.disable.extended_help', ShopifyCli::TOOL_NAME)
|
33
|
-
end
|
34
24
|
end
|
35
25
|
end
|
36
26
|
end
|
@@ -3,29 +3,31 @@
|
|
3
3
|
module Script
|
4
4
|
module Commands
|
5
5
|
class Enable < ShopifyCli::Command
|
6
|
+
prerequisite_task :ensure_env
|
6
7
|
options do |parser, flags|
|
7
|
-
parser.on('--
|
8
|
-
|
8
|
+
parser.on('--config_props=KEYVALUEPAIRS', Array) do |t|
|
9
|
+
flags[:config_props] = Hash[t.map { |s| s.split(':') }]
|
10
|
+
end
|
11
|
+
parser.on('--config_file=CONFIGFILEPATH') { |t| flags[:config_file] = t }
|
9
12
|
end
|
10
13
|
|
11
|
-
def call(
|
12
|
-
form = Forms::Enable.ask(@ctx, args, options.flags)
|
13
|
-
return @ctx.puts(self.class.help) unless form
|
14
|
-
|
14
|
+
def call(_args, _name)
|
15
15
|
project = ScriptProject.current
|
16
|
+
api_key = project.env[:api_key]
|
17
|
+
shop_domain = project.env[:shop]
|
16
18
|
|
17
19
|
Layers::Application::EnableScript.call(
|
18
20
|
ctx: @ctx,
|
19
|
-
api_key:
|
20
|
-
shop_domain:
|
21
|
-
configuration:
|
21
|
+
api_key: api_key,
|
22
|
+
shop_domain: shop_domain,
|
23
|
+
configuration: acquire_configuration(**slice(options.flags, :config_file, :config_props)),
|
22
24
|
extension_point_type: project.extension_point_type,
|
23
25
|
title: project.script_name
|
24
26
|
)
|
25
27
|
@ctx.puts(@ctx.message(
|
26
28
|
'script.enable.script_enabled',
|
27
|
-
api_key:
|
28
|
-
shop_domain:
|
29
|
+
api_key: api_key,
|
30
|
+
shop_domain: shop_domain,
|
29
31
|
type: project.extension_point_type.capitalize,
|
30
32
|
title: project.script_name
|
31
33
|
))
|
@@ -41,6 +43,28 @@ module Script
|
|
41
43
|
def self.extended_help
|
42
44
|
ShopifyCli::Context.message('script.enable.extended_help', ShopifyCli::TOOL_NAME)
|
43
45
|
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def acquire_configuration(config_file: nil, config_props: nil)
|
50
|
+
properties = {}
|
51
|
+
properties = YAML.load(File.read(config_file)) unless config_file.nil?
|
52
|
+
properties = properties.merge(config_props) unless config_props.nil?
|
53
|
+
|
54
|
+
configuration = { entries: [] }
|
55
|
+
properties.each do |key, value|
|
56
|
+
configuration[:entries].push({
|
57
|
+
key: key,
|
58
|
+
value: value,
|
59
|
+
})
|
60
|
+
end
|
61
|
+
configuration
|
62
|
+
end
|
63
|
+
|
64
|
+
# No slice pre Ruby 2.5 so roll our own
|
65
|
+
def slice(hash, *keys)
|
66
|
+
Hash[hash.to_a - hash.select { |key, _value| !keys.include?(key) }.to_a]
|
67
|
+
end
|
44
68
|
end
|
45
69
|
end
|
46
70
|
end
|