shopify-cli 1.8.0 → 1.12.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/.github/workflows/build.yml +28 -0
- data/.rubocop_todo.yml +15 -2
- data/CHANGELOG.md +24 -1
- data/Gemfile.lock +4 -4
- data/README.md +2 -1
- data/dev.yml +3 -0
- data/lib/graphql/extension_create.graphql +17 -2
- data/lib/project_types/extension/cli.rb +8 -0
- data/lib/project_types/extension/commands/extension_command.rb +4 -4
- data/lib/project_types/extension/commands/push.rb +2 -2
- data/lib/project_types/extension/commands/register.rb +4 -3
- data/lib/project_types/extension/commands/serve.rb +62 -28
- data/lib/project_types/extension/commands/tunnel.rb +3 -1
- data/lib/project_types/extension/extension_project.rb +16 -4
- data/lib/project_types/extension/extension_project_keys.rb +2 -1
- data/lib/project_types/extension/features/argo.rb +19 -44
- data/lib/project_types/extension/features/argo_runtime.rb +84 -0
- data/lib/project_types/extension/features/argo_serve.rb +80 -0
- data/lib/project_types/extension/features/argo_serve_options.rb +41 -0
- data/lib/project_types/extension/features/argo_setup.rb +1 -1
- data/lib/project_types/extension/messages/message_loading.rb +3 -1
- data/lib/project_types/extension/messages/messages.rb +5 -4
- data/lib/project_types/extension/models/npm_package.rb +14 -0
- data/lib/project_types/extension/models/registration.rb +1 -0
- data/lib/project_types/extension/models/specification.rb +3 -0
- data/lib/project_types/extension/models/specification_handlers/checkout_argo_extension.rb +18 -0
- data/lib/project_types/extension/models/specification_handlers/default.rb +49 -1
- data/lib/project_types/extension/models/version.rb +1 -1
- data/lib/project_types/extension/tasks/choose_next_available_port.rb +36 -0
- data/lib/project_types/extension/tasks/configure_features.rb +4 -0
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +2 -0
- data/lib/project_types/extension/tasks/find_npm_packages.rb +106 -0
- data/lib/project_types/node/commands/generate.rb +0 -22
- data/lib/project_types/node/messages/messages.rb +4 -4
- data/lib/project_types/rails/messages/messages.rb +4 -4
- data/lib/project_types/script/cli.rb +7 -8
- data/lib/project_types/script/commands/create.rb +0 -7
- data/lib/project_types/script/commands/push.rb +3 -3
- data/lib/project_types/script/config/extension_points.yml +4 -0
- data/lib/project_types/script/errors.rb +0 -19
- data/lib/project_types/script/forms/create.rb +3 -14
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +5 -5
- data/lib/project_types/script/graphql/get_app_scripts.graphql +6 -0
- data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
- data/lib/project_types/script/layers/application/build_script.rb +1 -2
- data/lib/project_types/script/layers/application/create_script.rb +30 -51
- data/lib/project_types/script/layers/application/extension_points.rb +3 -2
- data/lib/project_types/script/layers/application/push_script.rb +5 -5
- data/lib/project_types/script/layers/domain/errors.rb +0 -2
- data/lib/project_types/script/layers/domain/extension_point.rb +56 -46
- data/lib/project_types/script/layers/domain/metadata.rb +18 -25
- data/lib/project_types/script/layers/domain/push_package.rb +4 -4
- data/lib/project_types/script/layers/domain/script_project.rb +54 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +15 -16
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +13 -7
- data/lib/project_types/script/layers/infrastructure/command_runner.rb +19 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +40 -11
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +12 -13
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +9 -10
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +6 -7
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +172 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +21 -72
- data/lib/project_types/script/messages/messages.rb +20 -50
- data/lib/project_types/script/tasks/ensure_env.rb +85 -0
- data/lib/project_types/script/ui/error_handler.rb +32 -30
- data/lib/shopify-cli/context.rb +28 -0
- data/lib/shopify-cli/js_system.rb +2 -2
- data/lib/shopify-cli/messages/messages.rb +50 -45
- data/lib/shopify-cli/method_object.rb +4 -4
- data/lib/shopify-cli/oauth.rb +9 -3
- data/lib/shopify-cli/packager.rb +1 -1
- data/lib/shopify-cli/partners_api/organizations.rb +3 -3
- data/lib/shopify-cli/resolve_constant.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +1 -1
- data/lib/shopify-cli/shopifolk.rb +1 -1
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -4
- data/lib/shopify-cli/transform_data_structure.rb +1 -1
- data/lib/shopify-cli/tunnel.rb +22 -1
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +0 -1
- data/vendor/deps/smart_properties/REVISION +1 -1
- data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
- data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
- metadata +16 -12
- data/.travis.yml +0 -14
- data/lib/project_types/script/commands/disable.rb +0 -25
- data/lib/project_types/script/commands/enable.rb +0 -80
- data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
- data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
- data/lib/project_types/script/layers/application/disable_script.rb +0 -21
- data/lib/project_types/script/layers/application/enable_script.rb +0 -23
- data/lib/project_types/script/layers/infrastructure/config_ui_repository.rb +0 -46
- data/lib/project_types/script/script_project.rb +0 -64
@@ -4,7 +4,8 @@ require "shopify_cli"
|
|
4
4
|
module Extension
|
5
5
|
module ExtensionProjectKeys
|
6
6
|
REGISTRATION_ID_KEY = "EXTENSION_ID"
|
7
|
-
|
7
|
+
REGISTRATION_UUID_KEY = "EXTENSION_UUID"
|
8
|
+
SPECIFICATION_IDENTIFIER_KEY = "EXTENSION_TYPE"
|
8
9
|
TITLE_KEY = "EXTENSION_TITLE"
|
9
10
|
end
|
10
11
|
end
|
@@ -13,18 +13,22 @@ module Extension
|
|
13
13
|
|
14
14
|
SCRIPT_PATH = %w(build main.js).freeze
|
15
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
16
|
YARN_INSTALL_COMMAND = %w(install).freeze
|
23
17
|
YARN_INSTALL_PARAMETERS = %w(--silent).freeze
|
24
18
|
YARN_RUN_COMMAND = %w(run).freeze
|
25
19
|
YARN_RUN_SCRIPT_NAME = %w(build).freeze
|
26
20
|
private_constant :YARN_INSTALL_COMMAND, :YARN_INSTALL_PARAMETERS, :YARN_RUN_COMMAND, :YARN_RUN_SCRIPT_NAME
|
27
21
|
|
22
|
+
ARGO_CHECKOUT = "@shopify/argo-checkout"
|
23
|
+
ARGO_ADMIN = "@shopify/argo-admin"
|
24
|
+
ARGO_POST_PURCHASE = "@shopify/argo-post-purchase"
|
25
|
+
|
26
|
+
PACKAGE_NAMES = [
|
27
|
+
ARGO_CHECKOUT,
|
28
|
+
ARGO_ADMIN,
|
29
|
+
ARGO_POST_PURCHASE,
|
30
|
+
].freeze
|
31
|
+
|
28
32
|
def create(directory_name, identifier, context)
|
29
33
|
Features::ArgoSetup.new(git_template: git_template).call(directory_name, identifier, context)
|
30
34
|
end
|
@@ -39,7 +43,7 @@ module Extension
|
|
39
43
|
context.abort(context.message("features.argo.missing_file_error")) unless File.exist?(filepath)
|
40
44
|
begin
|
41
45
|
{
|
42
|
-
renderer_version:
|
46
|
+
renderer_version: renderer_package(context).version,
|
43
47
|
serialized_script: Base64.strict_encode64(File.read(filepath).chomp),
|
44
48
|
}
|
45
49
|
rescue StandardError
|
@@ -47,47 +51,18 @@ module Extension
|
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
54
|
+
def renderer_package(context)
|
55
|
+
js_system = ShopifyCli::JsSystem.new(ctx: context)
|
56
|
+
Tasks::FindNpmPackages
|
57
|
+
.exactly_one_of(*PACKAGE_NAMES, js_system: js_system)
|
58
|
+
.unwrap { |err| raise err }
|
59
|
+
rescue Extension::PackageResolutionFailed
|
60
60
|
context.abort(
|
61
|
-
context.message("features.argo.dependencies.
|
61
|
+
context.message("features.argo.dependencies.argo_missing_renderer_package_error")
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
65
|
-
|
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
|
65
|
+
private
|
91
66
|
|
92
67
|
def run_yarn_install(context, js_system)
|
93
68
|
_result, error, status = js_system.call(
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Extension
|
2
|
+
module Features
|
3
|
+
class ArgoRuntime
|
4
|
+
include SmartProperties
|
5
|
+
|
6
|
+
ARGO_RUN_PACKAGE_NAME = "@shopify/argo-run"
|
7
|
+
ARGO_ADMIN_CLI_PACKAGE_NAME = "@shopify/argo-admin-cli"
|
8
|
+
|
9
|
+
ARGO_RUN_0_4_0 = Models::NpmPackage.new(name: "@shopify/argo-run", version: "0.4.0")
|
10
|
+
ARGO_ADMIN_CLI_0_9_3 = Models::NpmPackage.new(name: "@shopify/argo-admin-cli", version: "0.9.3")
|
11
|
+
ARGO_ADMIN_CLI_0_11_0 = Models::NpmPackage.new(name: "@shopify/argo-admin-cli", version: "0.11.0")
|
12
|
+
|
13
|
+
property! :renderer, accepts: Models::NpmPackage
|
14
|
+
property! :cli, accepts: Models::NpmPackage
|
15
|
+
property :beta_access, accepts: Array, default: -> { [] }
|
16
|
+
|
17
|
+
def accepts_port?
|
18
|
+
case cli
|
19
|
+
when admin?
|
20
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
21
|
+
when checkout?
|
22
|
+
cli >= ARGO_RUN_0_4_0
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def accepts_tunnel_url?
|
27
|
+
case cli
|
28
|
+
when admin?
|
29
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
30
|
+
when checkout?
|
31
|
+
cli >= ARGO_RUN_0_4_0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def accepts_uuid?
|
36
|
+
case cli
|
37
|
+
when admin?
|
38
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
39
|
+
else
|
40
|
+
false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def accepts_argo_version?
|
45
|
+
case cli
|
46
|
+
when admin?
|
47
|
+
cli >= ARGO_ADMIN_CLI_0_9_3
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def accepts_shop?
|
54
|
+
return false unless beta_access.include?(:argo_admin_beta)
|
55
|
+
case cli
|
56
|
+
when admin?
|
57
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
58
|
+
else
|
59
|
+
false
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def accepts_api_key?
|
64
|
+
return false unless beta_access.include?(:argo_admin_beta)
|
65
|
+
case cli
|
66
|
+
when admin?
|
67
|
+
cli >= ARGO_ADMIN_CLI_0_11_0
|
68
|
+
else
|
69
|
+
false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def admin?
|
76
|
+
->(cli) { cli.name == ARGO_ADMIN_CLI_PACKAGE_NAME }
|
77
|
+
end
|
78
|
+
|
79
|
+
def checkout?
|
80
|
+
->(cli) { cli.name == ARGO_RUN_PACKAGE_NAME }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Extension
|
2
|
+
module Features
|
3
|
+
class ArgoServe
|
4
|
+
include SmartProperties
|
5
|
+
|
6
|
+
property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
|
7
|
+
property! :argo_runtime, accepts: Features::ArgoRuntime
|
8
|
+
property! :context, accepts: ShopifyCli::Context
|
9
|
+
property! :port, accepts: Integer, default: 39351
|
10
|
+
property :tunnel_url, accepts: String, default: ""
|
11
|
+
property :beta_access, accepts: Array, default: -> { [] }
|
12
|
+
|
13
|
+
def call
|
14
|
+
validate_env!
|
15
|
+
|
16
|
+
CLI::UI::Frame.open(context.message("serve.frame_title")) do
|
17
|
+
success = call_js_system(yarn_command: yarn_serve_command, npm_command: npm_serve_command)
|
18
|
+
context.abort(context.message("serve.serve_failure_message")) unless success
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def call_js_system(yarn_command:, npm_command:)
|
25
|
+
ShopifyCli::JsSystem.call(context, yarn: yarn_command, npm: npm_command)
|
26
|
+
end
|
27
|
+
|
28
|
+
def specification
|
29
|
+
specification_handler.specification
|
30
|
+
end
|
31
|
+
|
32
|
+
def renderer_package
|
33
|
+
specification_handler.renderer_package(context)
|
34
|
+
end
|
35
|
+
|
36
|
+
def required_fields
|
37
|
+
specification.features.argo.required_fields
|
38
|
+
end
|
39
|
+
|
40
|
+
def serve_options
|
41
|
+
@options ||= Features::ArgoServeOptions.new(
|
42
|
+
argo_runtime: argo_runtime,
|
43
|
+
port: port,
|
44
|
+
context: context,
|
45
|
+
required_fields: required_fields,
|
46
|
+
renderer_package: renderer_package,
|
47
|
+
public_url: tunnel_url
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def yarn_serve_command
|
52
|
+
serve_options.yarn_serve_command
|
53
|
+
end
|
54
|
+
|
55
|
+
def npm_serve_command
|
56
|
+
serve_options.npm_serve_command
|
57
|
+
end
|
58
|
+
|
59
|
+
def validate_env!
|
60
|
+
ExtensionProject.reload
|
61
|
+
|
62
|
+
return if required_fields.none?
|
63
|
+
|
64
|
+
return unless beta_access.include?(:argo_admin_beta)
|
65
|
+
|
66
|
+
ShopifyCli::Tasks::EnsureEnv.call(context, required: required_fields)
|
67
|
+
ShopifyCli::Tasks::EnsureDevStore.call(context) if required_fields.include?(:shop)
|
68
|
+
|
69
|
+
project = ExtensionProject.current
|
70
|
+
|
71
|
+
return if required_fields.all? do |field|
|
72
|
+
value = project.env.public_send(field)
|
73
|
+
value && !value.strip.empty?
|
74
|
+
end
|
75
|
+
|
76
|
+
context.abort(context.message("serve.serve_missing_information"))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Extension
|
2
|
+
module Features
|
3
|
+
class ArgoServeOptions
|
4
|
+
include SmartProperties
|
5
|
+
|
6
|
+
property! :argo_runtime, accepts: Features::ArgoRuntime
|
7
|
+
property! :context, accepts: ShopifyCli::Context
|
8
|
+
property :port, accepts: Integer, default: 39351
|
9
|
+
property :public_url, accepts: String, default: ""
|
10
|
+
property! :required_fields, accepts: Array, default: -> { [] }
|
11
|
+
property! :renderer_package, accepts: Models::NpmPackage
|
12
|
+
|
13
|
+
YARN_SERVE_COMMAND = %w(server)
|
14
|
+
NPM_SERVE_COMMAND = %w(run-script server)
|
15
|
+
|
16
|
+
def yarn_serve_command
|
17
|
+
YARN_SERVE_COMMAND + options
|
18
|
+
end
|
19
|
+
|
20
|
+
def npm_serve_command
|
21
|
+
NPM_SERVE_COMMAND + ["--"] + options
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def options
|
27
|
+
project = ExtensionProject.current
|
28
|
+
api_key = project.env.api_key
|
29
|
+
|
30
|
+
@serve_options ||= [].tap do |options|
|
31
|
+
options << "--port=#{port}" if argo_runtime.accepts_port?
|
32
|
+
options << "--shop=#{project.env.shop}" if required_fields.include?(:shop) && argo_runtime.accepts_shop?
|
33
|
+
options << "--apiKey=#{api_key}" if required_fields.include?(:api_key) && argo_runtime.accepts_api_key?
|
34
|
+
options << "--argoVersion=#{renderer_package.version}" if argo_runtime.accepts_argo_version?
|
35
|
+
options << "--uuid=#{project.registration_uuid}" if argo_runtime.accepts_uuid?
|
36
|
+
options << "--publicUrl=#{public_url}" if argo_runtime.accepts_tunnel_url?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -16,7 +16,9 @@ module Extension
|
|
16
16
|
|
17
17
|
def self.load_current_type_messages
|
18
18
|
return unless ShopifyCli::Project.has_current?
|
19
|
-
messages_for_type(
|
19
|
+
messages_for_type(
|
20
|
+
ShopifyCli::Project.current.config[Extension::ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY]
|
21
|
+
)
|
20
22
|
end
|
21
23
|
|
22
24
|
def self.messages_for_type(type_identifier)
|
@@ -56,8 +56,10 @@ module Extension
|
|
56
56
|
},
|
57
57
|
serve: {
|
58
58
|
frame_title: "Serving extension...",
|
59
|
+
no_available_ports_found: "No available ports found to run extension.",
|
59
60
|
serve_failure_message: "Failed to run extension code.",
|
60
61
|
serve_missing_information: "Missing shop or api_key.",
|
62
|
+
tunnel_already_running: "A tunnel running on another port has been detected. Close the tunnel and try again.",
|
61
63
|
},
|
62
64
|
tunnel: {
|
63
65
|
missing_token: "{{x}} {{red:auth requires a token argument}}. "\
|
@@ -98,10 +100,8 @@ module Extension
|
|
98
100
|
node_not_installed: "Node must be installed to create this extension.",
|
99
101
|
version_too_low: "Your node version %s does not meet the minimum required version %s",
|
100
102
|
},
|
101
|
-
argo_missing_renderer_package_error: "
|
102
|
-
|
103
|
-
The renderer package version is not a valid SemVer Version (http://semver.org)
|
104
|
-
MESSAGE
|
103
|
+
argo_missing_renderer_package_error: "Extension template references invalid renderer package "\
|
104
|
+
"please contact Shopify for help.",
|
105
105
|
yarn_install_error: "Something went wrong while running 'yarn install'. %s.",
|
106
106
|
yarn_run_script_error: "Something went wrong while running script. %s.",
|
107
107
|
},
|
@@ -117,6 +117,7 @@ module Extension
|
|
117
117
|
},
|
118
118
|
errors: {
|
119
119
|
unknown_type: "Unknown extension type %s",
|
120
|
+
package_not_found: "`%s` package not found.",
|
120
121
|
},
|
121
122
|
}
|
122
123
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "semantic/semantic"
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
NpmPackage = Struct.new(:name, :version, keyword_init: true) do
|
6
|
+
include Comparable
|
7
|
+
|
8
|
+
def <=>(other)
|
9
|
+
return nil unless name == other.name
|
10
|
+
Semantic::Version.new(version) <=> Semantic::Version.new(other.version)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -10,6 +10,9 @@ module Extension
|
|
10
10
|
property! :surface, converts: :to_str
|
11
11
|
property! :renderer_package_name, converts: :to_str
|
12
12
|
property! :git_template, converts: :to_str
|
13
|
+
property! :required_fields, accepts: Array, default: -> { [] }
|
14
|
+
property! :required_shop_beta_flags, accepts: Array, default: -> { [] }
|
15
|
+
property! :cli_package_name, accepts: String, converts: :to_str, default: ""
|
13
16
|
end
|
14
17
|
|
15
18
|
def self.build(feature_set_attributes)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Models
|
5
|
+
module SpecificationHandlers
|
6
|
+
class CheckoutArgoExtension < Default
|
7
|
+
PERMITTED_CONFIG_KEYS = [:metafields, :extension_points]
|
8
|
+
|
9
|
+
def config(context)
|
10
|
+
{
|
11
|
+
**Features::ArgoConfig.parse_yaml(context, PERMITTED_CONFIG_KEYS),
|
12
|
+
**argo.config(context),
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -42,12 +42,60 @@ module Extension
|
|
42
42
|
[]
|
43
43
|
end
|
44
44
|
|
45
|
+
def choose_port?(context)
|
46
|
+
argo_runtime(context).accepts_port?
|
47
|
+
end
|
48
|
+
|
49
|
+
def establish_tunnel?(context)
|
50
|
+
argo_runtime(context).accepts_tunnel_url?
|
51
|
+
end
|
52
|
+
|
53
|
+
def serve(context:, port:, tunnel_url:)
|
54
|
+
Features::ArgoServe.new(
|
55
|
+
specification_handler: self,
|
56
|
+
argo_runtime: argo_runtime(context),
|
57
|
+
context: context,
|
58
|
+
port: port,
|
59
|
+
tunnel_url: tunnel_url,
|
60
|
+
beta_access: beta_access
|
61
|
+
).call
|
62
|
+
end
|
63
|
+
|
64
|
+
def renderer_package(context)
|
65
|
+
argo.renderer_package(context)
|
66
|
+
end
|
67
|
+
|
68
|
+
def argo_runtime(context)
|
69
|
+
@argo_runtime ||= Features::ArgoRuntime.new(
|
70
|
+
renderer: renderer_package(context),
|
71
|
+
cli: cli_package(context),
|
72
|
+
beta_access: beta_access
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def beta_access
|
77
|
+
argo_admin_beta? ? [:argo_admin_beta] : []
|
78
|
+
end
|
79
|
+
|
80
|
+
def argo_admin_beta?
|
81
|
+
ShopifyCli::Shopifolk.check && ShopifyCli::Feature.enabled?(:argo_admin_beta)
|
82
|
+
end
|
83
|
+
|
84
|
+
def cli_package(context)
|
85
|
+
cli_package_name = specification.features.argo&.cli_package_name
|
86
|
+
return unless cli_package_name
|
87
|
+
|
88
|
+
js_system = ShopifyCli::JsSystem.new(ctx: context)
|
89
|
+
Tasks::FindNpmPackages.exactly_one_of(cli_package_name, js_system: js_system)
|
90
|
+
.unwrap { |_e| context.abort(context.message("errors.package_not_found", cli_package_name)) }
|
91
|
+
end
|
92
|
+
|
45
93
|
protected
|
46
94
|
|
47
95
|
def argo
|
48
96
|
Features::Argo.new(
|
49
97
|
git_template: specification.features.argo.git_template,
|
50
|
-
renderer_package_name: specification.features.argo.renderer_package_name
|
98
|
+
renderer_package_name: specification.features.argo.renderer_package_name
|
51
99
|
)
|
52
100
|
end
|
53
101
|
|