shopify-cli 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +9 -0
- data/README.md +39 -7
- data/Rakefile +2 -0
- data/dev.yml +2 -2
- data/docs/_config.yml +1 -18
- data/docs/app/node/commands/index.md +2 -80
- data/docs/app/node/index.md +2 -33
- data/docs/app/rails/commands/index.md +2 -78
- data/docs/app/rails/index.md +2 -34
- data/docs/core/index.md +2 -84
- data/docs/getting-started/index.md +2 -25
- data/docs/getting-started/install/index.md +1 -118
- data/docs/getting-started/migrate/index.md +2 -94
- data/docs/getting-started/uninstall/index.md +2 -35
- data/docs/getting-started/upgrade/index.md +2 -39
- data/docs/help/start-app/index.md +2 -4
- data/docs/index.md +2 -24
- data/install.sh +1 -1
- data/lib/project_types/extension/cli.rb +19 -10
- data/lib/project_types/extension/commands/extension_command.rb +2 -2
- data/lib/project_types/extension/features/argo.rb +117 -0
- data/lib/project_types/extension/forms/create.rb +2 -2
- data/lib/project_types/extension/models/specification.rb +35 -0
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +19 -0
- data/lib/project_types/extension/models/specification_handlers/default.rb +67 -0
- data/lib/project_types/extension/models/specifications.rb +77 -0
- data/lib/project_types/extension/tasks/configure_features.rb +52 -0
- data/lib/project_types/extension/tasks/fetch_specifications.rb +38 -0
- data/lib/project_types/node/commands/create.rb +3 -1
- data/lib/project_types/node/commands/generate.rb +2 -11
- data/lib/project_types/node/messages/messages.rb +9 -44
- data/lib/project_types/rails/commands/create.rb +8 -9
- data/lib/project_types/rails/forms/create.rb +1 -1
- data/lib/project_types/rails/gem.rb +1 -1
- data/lib/project_types/rails/messages/messages.rb +1 -1
- data/lib/project_types/script/cli.rb +7 -4
- data/lib/project_types/script/commands/create.rb +6 -4
- data/lib/project_types/script/commands/push.rb +5 -13
- data/lib/project_types/script/config/extension_points.yml +9 -5
- data/lib/project_types/script/errors.rb +17 -0
- data/lib/project_types/script/forms/create.rb +26 -2
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +10 -1
- data/lib/project_types/script/layers/application/build_script.rb +9 -4
- data/lib/project_types/script/layers/application/create_script.rb +12 -10
- data/lib/project_types/script/layers/application/extension_points.rb +24 -0
- data/lib/project_types/script/layers/application/push_script.rb +18 -16
- data/lib/project_types/script/layers/domain/errors.rb +4 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +62 -6
- data/lib/project_types/script/layers/domain/metadata.rb +55 -0
- data/lib/project_types/script/layers/domain/push_package.rb +25 -6
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +6 -6
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +16 -6
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +10 -4
- data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +25 -13
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +72 -0
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +59 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +7 -1
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
- data/lib/project_types/script/messages/messages.rb +39 -8
- data/lib/project_types/script/script_project.rb +25 -16
- data/lib/project_types/script/ui/error_handler.rb +34 -1
- data/lib/project_types/theme/cli.rb +40 -0
- data/lib/project_types/theme/commands/connect.rb +54 -0
- data/lib/project_types/theme/commands/create.rb +48 -0
- data/lib/project_types/theme/commands/deploy.rb +38 -0
- data/lib/project_types/theme/commands/generate.rb +20 -0
- data/lib/project_types/theme/commands/generate/env.rb +79 -0
- data/lib/project_types/theme/commands/push.rb +55 -0
- data/lib/project_types/theme/commands/serve.rb +31 -0
- data/lib/project_types/theme/forms/connect.rb +34 -0
- data/lib/project_types/theme/forms/create.rb +22 -0
- data/lib/project_types/theme/messages/messages.rb +147 -0
- data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +78 -0
- data/lib/project_types/theme/themekit.rb +113 -0
- data/lib/shopify-cli/admin_api.rb +42 -2
- data/lib/shopify-cli/api.rb +27 -24
- data/lib/shopify-cli/commands/system.rb +1 -1
- data/lib/shopify-cli/context.rb +23 -2
- data/lib/shopify-cli/feature.rb +0 -2
- data/lib/shopify-cli/http_request.rb +20 -8
- data/lib/shopify-cli/messages/messages.rb +6 -3
- data/lib/shopify-cli/method_object.rb +104 -0
- data/lib/shopify-cli/partners_api.rb +8 -2
- data/lib/shopify-cli/project_type.rb +1 -1
- data/lib/shopify-cli/resolve_constant.rb +25 -0
- data/lib/shopify-cli/result.rb +432 -0
- data/lib/shopify-cli/shopifolk.rb +3 -2
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -5
- data/lib/shopify-cli/tunnel.rb +7 -1
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +4 -1
- data/shopify.fish +1 -1
- data/shopify.sh +1 -1
- data/vendor/deps/cli-kit/REVISION +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +2 -2
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +3 -3
- data/vendor/deps/cli-ui/REVISION +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui.rb +26 -22
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +4 -6
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -3
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +8 -9
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +15 -3
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +4 -11
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -5
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +10 -10
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
- data/vendor/deps/webrick/.gitignore +9 -0
- data/vendor/deps/webrick/Gemfile +3 -0
- data/vendor/deps/webrick/LICENSE.txt +22 -0
- data/vendor/deps/webrick/README.md +61 -0
- data/vendor/deps/webrick/Rakefile +10 -0
- data/vendor/deps/webrick/lib/webrick.rb +232 -0
- data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
- data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
- data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
- data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
- data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
- data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
- data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
- data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
- data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
- data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
- data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
- data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
- data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
- data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
- data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
- data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
- data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
- data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
- data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
- data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
- data/vendor/deps/webrick/webrick.gemspec +74 -0
- metadata +70 -26
- data/docs/Gemfile +0 -5
- data/docs/Gemfile.lock +0 -258
- data/docs/_data/nav.yml +0 -35
- data/docs/_includes/footer.html +0 -15
- data/docs/_includes/head.html +0 -19
- data/docs/_includes/sidebar_nav.html +0 -22
- data/docs/_includes/toc.html +0 -112
- data/docs/_layouts/default.html +0 -79
- data/docs/css/docs.css +0 -157
- data/docs/images/header.png +0 -0
- data/docs/installing-ruby.md +0 -28
- data/lib/project_types/extension/features/argo/admin.rb +0 -20
- data/lib/project_types/extension/features/argo/base.rb +0 -129
- data/lib/project_types/extension/features/argo/checkout.rb +0 -20
- data/lib/project_types/extension/models/type.rb +0 -81
- data/lib/project_types/extension/models/types/checkout_post_purchase.rb +0 -23
- data/lib/project_types/extension/models/types/product_subscription.rb +0 -24
- data/lib/project_types/node/commands/generate/billing.rb +0 -39
- data/lib/project_types/node/commands/generate/page.rb +0 -59
- data/lib/project_types/node/commands/generate/webhook.rb +0 -37
- data/lib/project_types/script/layers/domain/script.rb +0 -18
- data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -47
- data/lib/project_types/script/templates/ts/as-pect.config.js +0 -27
- data/lib/project_types/script/templates/ts/as-pect.d.ts +0 -1
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'base64'
|
3
|
+
require 'shopify_cli'
|
4
|
+
require 'semantic/semantic'
|
5
|
+
|
6
|
+
module Extension
|
7
|
+
module Features
|
8
|
+
class Argo
|
9
|
+
include SmartProperties
|
10
|
+
|
11
|
+
property! :git_template, converts: :to_str
|
12
|
+
property! :renderer_package_name, converts: :to_str
|
13
|
+
|
14
|
+
SCRIPT_PATH = %w(build main.js).freeze
|
15
|
+
|
16
|
+
NPM_LIST_COMMAND = %w(list).freeze
|
17
|
+
YARN_LIST_COMMAND = %w(list --pattern).freeze
|
18
|
+
NPM_LIST_PARAMETERS = %w(--prod).freeze
|
19
|
+
YARN_LIST_PARAMETERS = %w(--production).freeze
|
20
|
+
private_constant :NPM_LIST_COMMAND, :YARN_LIST_COMMAND, :NPM_LIST_PARAMETERS, :YARN_LIST_PARAMETERS
|
21
|
+
|
22
|
+
YARN_INSTALL_COMMAND = %w(install).freeze
|
23
|
+
YARN_INSTALL_PARAMETERS = %w(--silent).freeze
|
24
|
+
YARN_RUN_COMMAND = %w(run).freeze
|
25
|
+
YARN_RUN_SCRIPT_NAME = %w(build).freeze
|
26
|
+
private_constant :YARN_INSTALL_COMMAND, :YARN_INSTALL_PARAMETERS, :YARN_RUN_COMMAND, :YARN_RUN_SCRIPT_NAME
|
27
|
+
|
28
|
+
def create(directory_name, identifier, context)
|
29
|
+
Features::ArgoSetup.new(git_template: git_template).call(directory_name, identifier, context)
|
30
|
+
end
|
31
|
+
|
32
|
+
def config(context)
|
33
|
+
js_system = ShopifyCli::JsSystem.new(ctx: context)
|
34
|
+
if js_system.package_manager == 'yarn'
|
35
|
+
run_yarn_install(context, js_system)
|
36
|
+
run_yarn_run_script(context, js_system)
|
37
|
+
end
|
38
|
+
filepath = File.join(context.root, SCRIPT_PATH)
|
39
|
+
context.abort(context.message('features.argo.missing_file_error')) unless File.exist?(filepath)
|
40
|
+
begin
|
41
|
+
{
|
42
|
+
renderer_version: extract_argo_renderer_version(context),
|
43
|
+
serialized_script: Base64.strict_encode64(File.read(filepath).chomp),
|
44
|
+
}
|
45
|
+
rescue StandardError
|
46
|
+
context.abort(context.message('features.argo.script_prepare_error'))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def extract_argo_renderer_version(context)
|
53
|
+
result = run_list_command(context)
|
54
|
+
found_version = find_version_number(context, result)
|
55
|
+
context.abort(
|
56
|
+
context.message('features.argo.dependencies.argo_renderer_package_invalid_version_error')
|
57
|
+
) if found_version.nil?
|
58
|
+
::Semantic::Version.new(found_version).to_s
|
59
|
+
rescue ArgumentError
|
60
|
+
context.abort(
|
61
|
+
context.message('features.argo.dependencies.argo_renderer_package_invalid_version_error')
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def find_version_number(context, result)
|
66
|
+
packages = result.to_json.split('\n')
|
67
|
+
found_package = packages.find do |package|
|
68
|
+
package.match(/#{renderer_package_name}@/)
|
69
|
+
end
|
70
|
+
if found_package.nil?
|
71
|
+
error = "'#{renderer_package_name}' not found."
|
72
|
+
context.abort(
|
73
|
+
context.message('features.argo.dependencies.argo_missing_renderer_package_error', error)
|
74
|
+
)
|
75
|
+
end
|
76
|
+
found_package.split('@')[2]&.strip
|
77
|
+
end
|
78
|
+
|
79
|
+
def run_list_command(context)
|
80
|
+
js_system = ShopifyCli::JsSystem.new(ctx: context)
|
81
|
+
result, error, status = js_system.call(
|
82
|
+
yarn: YARN_LIST_COMMAND + [renderer_package_name] + YARN_LIST_PARAMETERS,
|
83
|
+
npm: NPM_LIST_COMMAND + [renderer_package_name] + NPM_LIST_PARAMETERS,
|
84
|
+
capture_response: true
|
85
|
+
)
|
86
|
+
context.abort(
|
87
|
+
context.message('features.argo.dependencies.argo_missing_renderer_package_error', error)
|
88
|
+
) unless status.success?
|
89
|
+
result
|
90
|
+
end
|
91
|
+
|
92
|
+
def run_yarn_install(context, js_system)
|
93
|
+
_result, error, status = js_system.call(
|
94
|
+
yarn: YARN_INSTALL_COMMAND + YARN_INSTALL_PARAMETERS,
|
95
|
+
npm: [],
|
96
|
+
capture_response: true
|
97
|
+
)
|
98
|
+
|
99
|
+
context.abort(
|
100
|
+
context.message('features.argo.dependencies.yarn_install_error', error)
|
101
|
+
) unless status.success?
|
102
|
+
end
|
103
|
+
|
104
|
+
def run_yarn_run_script(context, js_system)
|
105
|
+
_result, error, status = js_system.call(
|
106
|
+
yarn: YARN_RUN_COMMAND + YARN_RUN_SCRIPT_NAME,
|
107
|
+
npm: [],
|
108
|
+
capture_response: true
|
109
|
+
)
|
110
|
+
|
111
|
+
context.abort(
|
112
|
+
context.message('features.argo.dependencies.yarn_run_script_error', error)
|
113
|
+
) unless status.success?
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -26,11 +26,11 @@ module Extension
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def ask_type
|
29
|
-
return
|
29
|
+
return Extension.specifications[type] if Extension.specifications.valid?(type)
|
30
30
|
ctx.puts(ctx.message('create.invalid_type')) unless type.nil?
|
31
31
|
|
32
32
|
CLI::UI::Prompt.ask(ctx.message('create.ask_type')) do |handler|
|
33
|
-
|
33
|
+
Extension.specifications.each do |type|
|
34
34
|
handler.option("#{type.name} #{type.tagline}") { type }
|
35
35
|
end
|
36
36
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Extension
|
2
|
+
module Models
|
3
|
+
class Specification
|
4
|
+
include SmartProperties
|
5
|
+
|
6
|
+
module Features
|
7
|
+
class Argo
|
8
|
+
include SmartProperties
|
9
|
+
|
10
|
+
property! :surface_area, converts: :to_str
|
11
|
+
property! :renderer_package_name, converts: :to_str
|
12
|
+
property! :git_template, converts: :to_str
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.build(feature_set_attributes)
|
16
|
+
feature_set_attributes.each_with_object(OpenStruct.new) do |(identifier, feature_attributes), feature_set|
|
17
|
+
feature_set[identifier] = ShopifyCli::ResolveConstant
|
18
|
+
.call(identifier, namespace: Features)
|
19
|
+
.rescue { OpenStruct }
|
20
|
+
.then { |c| c.new(**feature_attributes) }
|
21
|
+
.unwrap { |error| raise error }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
property! :identifier
|
27
|
+
property :graphql_identifier, converts: :to_str
|
28
|
+
property! :features, converts: Features.method(:build), default: -> { [] }
|
29
|
+
|
30
|
+
def graphql_identifier
|
31
|
+
super || identifier
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Models
|
6
|
+
module SpecificationHandlers
|
7
|
+
class CheckoutPostPurchase < Default
|
8
|
+
PERMITTED_CONFIG_KEYS = [:metafields]
|
9
|
+
|
10
|
+
def config(context)
|
11
|
+
{
|
12
|
+
**Features::ArgoConfig.parse_yaml(context, PERMITTED_CONFIG_KEYS),
|
13
|
+
**argo.config(context),
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
module SpecificationHandlers
|
6
|
+
class Default
|
7
|
+
attr_reader :specification
|
8
|
+
|
9
|
+
def initialize(specification)
|
10
|
+
@specification = specification
|
11
|
+
end
|
12
|
+
|
13
|
+
def identifier
|
14
|
+
specification.identifier.to_s.upcase
|
15
|
+
end
|
16
|
+
|
17
|
+
def graphql_identifier
|
18
|
+
specification.graphql_identifier.to_s.upcase
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
message('name')
|
23
|
+
end
|
24
|
+
|
25
|
+
def tagline
|
26
|
+
message('tagline') || ""
|
27
|
+
end
|
28
|
+
|
29
|
+
def config(context)
|
30
|
+
argo.config(context)
|
31
|
+
end
|
32
|
+
|
33
|
+
def create(directory_name, context)
|
34
|
+
argo.create(directory_name, identifier, context)
|
35
|
+
end
|
36
|
+
|
37
|
+
def extension_context(_context)
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def valid_extension_contexts
|
42
|
+
[]
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def argo
|
48
|
+
Features::Argo.new(
|
49
|
+
git_template: specification.features.argo.git_template,
|
50
|
+
renderer_package_name: specification.features.argo.renderer_package_name,
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def message(key, *params)
|
57
|
+
return unless messages.key?(key.to_sym)
|
58
|
+
messages[key.to_sym] % params
|
59
|
+
end
|
60
|
+
|
61
|
+
def messages
|
62
|
+
@messages ||= Messages::TYPES[identifier.downcase.to_sym] || {}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Extension
|
2
|
+
module Models
|
3
|
+
class Specifications
|
4
|
+
include SmartProperties
|
5
|
+
|
6
|
+
property! :custom_handler_root,
|
7
|
+
accepts: ->(d) { File.directory?(d) },
|
8
|
+
default: -> { File.expand_path('lib/project_types/extension/models/specification_handlers', ShopifyCli::ROOT) }
|
9
|
+
|
10
|
+
property! :custom_handler_namespace,
|
11
|
+
accepts: ->(m) { m.respond_to?(:const_get) },
|
12
|
+
default: -> { ::Extension::Models::SpecificationHandlers }
|
13
|
+
|
14
|
+
property! :fetch_specifications,
|
15
|
+
accepts: ->(p) { p.respond_to?(:to_proc) }
|
16
|
+
|
17
|
+
def [](identifier)
|
18
|
+
handlers[identifier]
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?(identifier)
|
22
|
+
handlers.key?(identifier)
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(&block)
|
26
|
+
handlers.values.each(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
|
31
|
+
def handlers
|
32
|
+
@handlers ||= fetch_specifications_and_build_handlers
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def fetch_specifications_and_build_handlers
|
38
|
+
ShopifyCli::Result
|
39
|
+
.call(&fetch_specifications)
|
40
|
+
.then(&Tasks::ConfigureFeatures)
|
41
|
+
.then(&method(:ensure_legacy_compatibility))
|
42
|
+
.then(&method(:build_specifications))
|
43
|
+
.then(&method(:require_handler_implementations))
|
44
|
+
.then(&method(:instantiate_specification_handlers))
|
45
|
+
.unwrap { |err| raise err }
|
46
|
+
end
|
47
|
+
|
48
|
+
def require_handler_implementations(specifications)
|
49
|
+
specifications.each do |s|
|
50
|
+
implementation_file = File.join(custom_handler_root, "#{s.identifier}.rb")
|
51
|
+
require(implementation_file) if File.file?(implementation_file)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def instantiate_specification_handlers(specifications)
|
56
|
+
specifications.each_with_object({}) do |specification, handlers|
|
57
|
+
ShopifyCli::ResolveConstant.call(specification.identifier, namespace: custom_handler_namespace)
|
58
|
+
.rescue { |error| error.is_a?(NameError) ? SpecificationHandlers::Default : raise(error) }
|
59
|
+
.then { |handler_class| handler_class.new(specification) }
|
60
|
+
.unwrap { |error| raise error }
|
61
|
+
.yield_self { |handler| handlers[handler.identifier] = handler }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def ensure_legacy_compatibility(specification_attribute_sets)
|
66
|
+
specification_attribute_sets.each do |attributes|
|
67
|
+
next unless attributes.fetch(:identifier) == 'product_subscription'
|
68
|
+
attributes[:graphql_identifier] = 'SUBSCRIPTION_MANAGEMENT'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def build_specifications(specification_attribute_sets)
|
73
|
+
specification_attribute_sets.map { |attributes| Models::Specification.new(**attributes) }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Extension
|
2
|
+
module Tasks
|
3
|
+
class ConfigureFeatures
|
4
|
+
include ShopifyCli::MethodObject
|
5
|
+
|
6
|
+
class Error < RuntimeError; end
|
7
|
+
class UnknownSurfaceArea < Error; end
|
8
|
+
class UnspecifiedSurfaceArea < Error; end
|
9
|
+
|
10
|
+
def call(specification_attribute_sets)
|
11
|
+
specification_attribute_sets.each do |attributes|
|
12
|
+
argo_configuration = extract_argo_configuration(attributes)
|
13
|
+
next if argo_configuration.nil?
|
14
|
+
surface_area = extract_surface_area(argo_configuration)
|
15
|
+
surface_area_configuration = fetch_surface_area_configuration(surface_area)
|
16
|
+
argo_configuration.merge!(surface_area_configuration)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def extract_argo_configuration(attributes)
|
23
|
+
attributes.dig(:features, :argo)
|
24
|
+
end
|
25
|
+
|
26
|
+
def extract_surface_area(argo_configuration)
|
27
|
+
argo_configuration.fetch(:surface_area) do
|
28
|
+
raise UnspecifiedSurfaceArea, "Argo configuration does not specify surface area"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def fetch_surface_area_configuration(surface_area)
|
33
|
+
surface_area_configurations.fetch(surface_area.to_sym) do
|
34
|
+
raise UnknownSurfaceArea, "Unknown surface area: #{surface_area}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def surface_area_configurations
|
39
|
+
{
|
40
|
+
admin: {
|
41
|
+
git_template: 'https://github.com/Shopify/argo-admin-template.git',
|
42
|
+
renderer_package_name: '@shopify/argo-admin',
|
43
|
+
},
|
44
|
+
checkout: {
|
45
|
+
git_template: 'https://github.com/Shopify/argo-checkout-template.git',
|
46
|
+
renderer_package_name: '@shopify/argo-checkout',
|
47
|
+
},
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Extension
|
2
|
+
module Tasks
|
3
|
+
class FetchSpecifications
|
4
|
+
include ShopifyCli::MethodObject
|
5
|
+
|
6
|
+
def call
|
7
|
+
[
|
8
|
+
product_subscription_specification,
|
9
|
+
checkout_post_purchase_specification,
|
10
|
+
]
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def product_subscription_specification
|
16
|
+
{
|
17
|
+
identifier: 'product_subscription',
|
18
|
+
features: {
|
19
|
+
argo: {
|
20
|
+
surface_area: 'admin',
|
21
|
+
},
|
22
|
+
},
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def checkout_post_purchase_specification
|
27
|
+
{
|
28
|
+
identifier: 'checkout_post_purchase',
|
29
|
+
features: {
|
30
|
+
argo: {
|
31
|
+
surface_area: 'checkout',
|
32
|
+
},
|
33
|
+
},
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -44,7 +44,9 @@ module Node
|
|
44
44
|
|
45
45
|
@ctx.puts(@ctx.message('apps.create.info.created', form.title, partners_url))
|
46
46
|
@ctx.puts(@ctx.message('apps.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
|
47
|
-
|
47
|
+
unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
|
48
|
+
@ctx.puts(@ctx.message('apps.create.info.install', partners_url, form.title))
|
49
|
+
end
|
48
50
|
end
|
49
51
|
|
50
52
|
def self.help
|
@@ -13,20 +13,11 @@ module Node
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.help
|
16
|
-
ShopifyCli::Context.message('node.generate.help'
|
16
|
+
ShopifyCli::Context.message('node.generate.help')
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.extended_help
|
20
|
-
|
21
|
-
subcommand_registry.resolved_commands.sort.each do |name, klass|
|
22
|
-
extended_help += " {{cyan:#{name}}}: "
|
23
|
-
|
24
|
-
if (subcmd_help = klass.help)
|
25
|
-
extended_help += subcmd_help.gsub("\n ", "\n ")
|
26
|
-
end
|
27
|
-
extended_help += "\n"
|
28
|
-
end
|
29
|
-
extended_help += ShopifyCli::Context.message('node.generate.extended_help', ShopifyCli::TOOL_NAME)
|
20
|
+
help
|
30
21
|
end
|
31
22
|
|
32
23
|
def self.run_generate(script, name, ctx)
|