shopify-cli 2.7.3 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/dev.yml +2 -2
- data/ext/javy/javy.rb +7 -8
- data/lib/graphql/get_extension_registrations.graphql +27 -0
- data/lib/project_types/extension/cli.rb +27 -2
- data/lib/project_types/extension/commands/build.rb +10 -10
- data/lib/project_types/extension/commands/create.rb +2 -3
- data/lib/project_types/extension/commands/push.rb +36 -8
- data/lib/project_types/extension/extension_project.rb +1 -1
- data/lib/project_types/extension/features/argo_serve.rb +6 -5
- data/lib/project_types/extension/forms/questions/ask_registration.rb +6 -2
- data/lib/project_types/extension/loaders/project.rb +29 -0
- data/lib/project_types/extension/loaders/specification_handler.rb +22 -0
- data/lib/project_types/extension/messages/messages.rb +4 -0
- data/lib/project_types/extension/models/app.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +4 -0
- data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
- data/lib/project_types/extension/tasks/execute_commands/base.rb +13 -0
- data/lib/project_types/extension/tasks/execute_commands/build.rb +29 -0
- data/lib/project_types/extension/tasks/execute_commands/create.rb +33 -0
- data/lib/project_types/extension/tasks/execute_commands/serve.rb +35 -0
- data/lib/project_types/extension/tasks/merge_server_config.rb +33 -22
- data/lib/project_types/script/cli.rb +2 -0
- data/lib/project_types/script/commands/connect.rb +19 -0
- data/lib/project_types/script/layers/application/connect_app.rb +9 -3
- data/lib/project_types/script/layers/application/create_script.rb +16 -16
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +21 -0
- data/lib/project_types/script/messages/messages.rb +12 -1
- data/lib/project_types/theme/commands/push.rb +3 -1
- data/lib/project_types/theme/messages/messages.rb +1 -0
- data/lib/shopify_cli/command.rb +6 -0
- data/lib/shopify_cli/constants.rb +4 -0
- data/lib/shopify_cli/context.rb +1 -1
- data/lib/shopify_cli/form.rb +2 -0
- data/lib/shopify_cli/messages/messages.rb +7 -1
- data/lib/shopify_cli/partners_api/app_extensions/job.rb +36 -0
- data/lib/shopify_cli/partners_api/app_extensions.rb +46 -0
- data/lib/shopify_cli/partners_api/organizations.rb +2 -5
- data/lib/shopify_cli/partners_api.rb +1 -0
- data/lib/shopify_cli/project.rb +8 -7
- data/lib/shopify_cli/resources/env_file.rb +13 -5
- data/lib/shopify_cli/theme/dev_server/hot-reload.js +15 -2
- data/lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb +84 -0
- data/lib/shopify_cli/theme/dev_server/proxy.rb +9 -15
- data/lib/shopify_cli/thread_pool/job.rb +27 -0
- data/lib/shopify_cli/thread_pool.rb +37 -0
- data/lib/shopify_cli/version.rb +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +3 -1
- metadata +15 -4
- data/lib/graphql/all_orgs_with_extensions.graphql +0 -37
- data/lib/project_types/extension/tasks/run_extension_command.rb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '068a38773a84e132b2b1dd435d4e369a2100d2fca4cccb539699e6033f816fb7'
|
4
|
+
data.tar.gz: d4f356f9f4bf9f0e43733da4f223f7e02917d8c29e4193c90eb276ac80a73c5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a163a0878650fbf8c846fa9d510240c3b4f938a621e14558a63788ce56e63a8fe39e6254ef4cc83107cd6b241d2d66e2fe935cd207d47a88c20182ceb7d59d5c
|
7
|
+
data.tar.gz: db35b09603e3ccb0c7a526da096a76663b4ab5f952cb37e1bde4b71fba3509d87c3e8626929e8d20e316a4c04097d3430da98e252b9634d5a0e53586b06ec2a9
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
From version 2.6.0, the sections in this file adhere to the [keep a changelog](https://keepachangelog.com/en/1.0.0/) specification.
|
2
|
+
|
3
|
+
## [Unreleased]
|
4
|
+
|
5
|
+
## Version 2.7.4
|
6
|
+
### Added
|
7
|
+
* [#1825](https://github.com/Shopify/shopify-cli/pull/1825): Support passing the connection information through arguments
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
* [#1852](https://github.com/Shopify/shopify-cli/pull/1852): Fix `shopify --help` to include `extension` commands
|
11
|
+
* [#1853](https://github.com/Shopify/shopify-cli/pull/1853): Fix javy installation failures from MacOS universal ruby installations
|
12
|
+
* [#1851](https://github.com/Shopify/shopify-cli/pull/1851): Improve `shopify theme push --live` confirmation message to show current live theme
|
13
|
+
* [#1850](https://github.com/Shopify/shopify-cli/pull/1850): Fix `shopify extension` commands timeout when organization has too many apps
|
14
|
+
* [#1860](https://github.com/Shopify/shopify-cli/pull/1860): Fix `theme serve` hot reload when there are many tabs active
|
15
|
+
|
2
16
|
## Version 2.7.3
|
3
17
|
### Added
|
4
18
|
* [#1826](https://github.com/Shopify/shopify-cli/pull/1826): Support using `script.config.yml` file for script configuration
|
5
19
|
* [#1843](https://github.com/Shopify/shopify-cli/pull/1826): Support using javy on Apple ARM processors
|
20
|
+
* [#1847](https://github.com/Shopify/shopify-cli/pull/1847): `shopify script connect` command.
|
6
21
|
|
7
22
|
### Fixed
|
8
23
|
* [#1811](https://github.com/Shopify/shopify-cli/pull/1811): Update theme-check to 1.9.0
|
data/Gemfile.lock
CHANGED
data/dev.yml
CHANGED
data/ext/javy/javy.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "rbconfig"
|
2
1
|
require "open-uri"
|
3
2
|
require "zlib"
|
4
3
|
require "open3"
|
@@ -162,9 +161,9 @@ module Javy
|
|
162
161
|
end
|
163
162
|
end
|
164
163
|
|
165
|
-
Platform = Struct.new(:
|
166
|
-
def initialize(
|
167
|
-
super(
|
164
|
+
Platform = Struct.new(:ruby_platform) do
|
165
|
+
def initialize(ruby_platform = RUBY_PLATFORM)
|
166
|
+
super(ruby_platform)
|
168
167
|
end
|
169
168
|
|
170
169
|
def to_s
|
@@ -172,7 +171,7 @@ module Javy
|
|
172
171
|
end
|
173
172
|
|
174
173
|
def os
|
175
|
-
case
|
174
|
+
case ruby_platform
|
176
175
|
when /linux/
|
177
176
|
"linux"
|
178
177
|
when /darwin/
|
@@ -183,10 +182,10 @@ module Javy
|
|
183
182
|
end
|
184
183
|
|
185
184
|
def cpu
|
186
|
-
case
|
187
|
-
when
|
185
|
+
case ruby_platform
|
186
|
+
when /x64/, /x86_64/
|
188
187
|
"x86_64"
|
189
|
-
when
|
188
|
+
when /arm/
|
190
189
|
"arm"
|
191
190
|
else
|
192
191
|
raise InstallationError.cpu_unsupported
|
@@ -0,0 +1,27 @@
|
|
1
|
+
query GetExtensionRegistrations($api_key: String!, $type: String) {
|
2
|
+
app(apiKey: $api_key) {
|
3
|
+
id
|
4
|
+
title
|
5
|
+
apiKey
|
6
|
+
apiSecretKeys{
|
7
|
+
secret
|
8
|
+
}
|
9
|
+
appType
|
10
|
+
extensionRegistrations(specificationIdentifier: $type) {
|
11
|
+
id
|
12
|
+
type
|
13
|
+
uuid
|
14
|
+
title
|
15
|
+
draftVersion {
|
16
|
+
registrationId
|
17
|
+
context
|
18
|
+
lastUserInteractionAt
|
19
|
+
location
|
20
|
+
validationErrors { field message }
|
21
|
+
id
|
22
|
+
uuid
|
23
|
+
versionTag
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
@@ -13,7 +13,6 @@ module Extension
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class Command < ShopifyCLI::Command::ProjectCommand
|
16
|
-
hidden_feature
|
17
16
|
autoload :ExtensionCommand, Project.project_filepath("commands/extension_command")
|
18
17
|
|
19
18
|
subcommand :Create, "create", Project.project_filepath("commands/create")
|
@@ -41,7 +40,6 @@ module Extension
|
|
41
40
|
autoload :FindNpmPackages, Project.project_filepath("tasks/find_npm_packages")
|
42
41
|
autoload :GetExtensions, Project.project_filepath("tasks/get_extensions")
|
43
42
|
autoload :GetProduct, Project.project_filepath("tasks/get_product")
|
44
|
-
autoload :RunExtensionCommand, Project.project_filepath("tasks/run_extension_command")
|
45
43
|
autoload :MergeServerConfig, Project.project_filepath("tasks/merge_server_config")
|
46
44
|
autoload :FindPackageFromJson, Project.project_filepath("tasks/find_package_from_json.rb")
|
47
45
|
autoload :EnsureResourceUrl, Project.project_filepath("tasks/ensure_resource_url.rb")
|
@@ -53,6 +51,28 @@ module Extension
|
|
53
51
|
autoload :ValidationErrorConverter, Project.project_filepath("tasks/converters/validation_error_converter")
|
54
52
|
autoload :AppConverter, Project.project_filepath("tasks/converters/app_converter")
|
55
53
|
autoload :ProductConverter, Project.project_filepath("tasks/converters/product_converter")
|
54
|
+
autoload :ExecuteCommands, Project.project_filepath("cli/execute_commands")
|
55
|
+
end
|
56
|
+
|
57
|
+
module ExecuteCommands
|
58
|
+
autoload :Base, Project.project_filepath("tasks/execute_commands/base")
|
59
|
+
autoload :Build, Project.project_filepath("tasks/execute_commands/build")
|
60
|
+
autoload :Create, Project.project_filepath("tasks/execute_commands/create")
|
61
|
+
autoload :Serve, Project.project_filepath("tasks/execute_commands/serve")
|
62
|
+
|
63
|
+
class << self
|
64
|
+
def build(*args)
|
65
|
+
Build.new(*args).call
|
66
|
+
end
|
67
|
+
|
68
|
+
def create(*args)
|
69
|
+
Create.new(*args).call
|
70
|
+
end
|
71
|
+
|
72
|
+
def serve(*args)
|
73
|
+
Serve.new(*args).call
|
74
|
+
end
|
75
|
+
end
|
56
76
|
end
|
57
77
|
end
|
58
78
|
|
@@ -121,4 +141,9 @@ module Extension
|
|
121
141
|
autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
|
122
142
|
autoload :ExtensionProject, Project.project_filepath("extension_project")
|
123
143
|
autoload :Errors, Project.project_filepath("errors")
|
144
|
+
|
145
|
+
module Loaders
|
146
|
+
autoload :Project, Extension::Project.project_filepath("loaders/project")
|
147
|
+
autoload :SpecificationHandler, Extension::Project.project_filepath("loaders/specification_handler")
|
148
|
+
end
|
124
149
|
end
|
@@ -24,16 +24,16 @@ module Extension
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def run_new_flow(project)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
Tasks::ExecuteCommands
|
28
|
+
.build(
|
29
|
+
context: @ctx,
|
30
|
+
config_file_path: specification_handler.server_config_path,
|
31
|
+
type: project.specification_identifier.downcase
|
32
|
+
)
|
33
|
+
.then { |output| @ctx.puts(output) }
|
34
|
+
.unwrap do |error|
|
35
|
+
raise ShopifyCLI::Abort, error.message unless error.nil?
|
36
|
+
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def run_legacy_flow
|
@@ -53,12 +53,11 @@ module Extension
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def use_new_create_flow(form)
|
56
|
-
Tasks::
|
56
|
+
Tasks::ExecuteCommands.create(
|
57
57
|
root_dir: form.directory_name,
|
58
58
|
template: form.template,
|
59
59
|
type: form.type.identifier.downcase,
|
60
|
-
|
61
|
-
).call
|
60
|
+
)
|
62
61
|
@ctx.chdir(form.directory_name)
|
63
62
|
write_env_file(form)
|
64
63
|
rescue => error
|
@@ -3,17 +3,40 @@ require "shopify_cli"
|
|
3
3
|
|
4
4
|
module Extension
|
5
5
|
class Command
|
6
|
-
class Push <
|
6
|
+
class Push < ShopifyCLI::Command::SubCommand
|
7
7
|
prerequisite_task ensure_project_type: :extension
|
8
8
|
|
9
|
+
options do |parser, flags|
|
10
|
+
parser.on("--api-key=API_KEY") { |api_key| flags[:api_key] = api_key.gsub('"', "") }
|
11
|
+
parser.on("--api-secret=API_SECRET") { |api_secret| flags[:api_secret] = api_secret.gsub('"', "") }
|
12
|
+
parser.on("--registration-id=REGISTRATION_ID") do |registration_id|
|
13
|
+
flags[:registration_id] = registration_id.gsub('"', "")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
TIME_DISPLAY_FORMAT = "%B %d, %Y %H:%M:%S %Z"
|
10
18
|
|
11
19
|
def call(args, name)
|
12
|
-
|
20
|
+
project = Extension::Loaders::Project.load(
|
21
|
+
context: @ctx,
|
22
|
+
directory: Dir.pwd,
|
23
|
+
api_key: options.flags[:api_key],
|
24
|
+
api_secret: options.flags[:api_secret],
|
25
|
+
registration_id: options.flags[:registration_id]
|
26
|
+
)
|
27
|
+
specification_handler = Extension::Loaders::SpecificationHandler.load(project: project, context: @ctx)
|
28
|
+
register_if_necessary(project: project, args: args, name: name)
|
29
|
+
|
13
30
|
Command::Build.new(@ctx).call(args, name) unless specification_handler.specification.options[:skip_build]
|
14
31
|
CLI::UI::Frame.open(@ctx.message("push.frame_title")) do
|
15
|
-
updated_draft_version = update_draft
|
16
|
-
show_message(updated_draft_version)
|
32
|
+
updated_draft_version = update_draft(project: project, specification_handler: specification_handler)
|
33
|
+
show_message(updated_draft_version, project: project)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def register_if_necessary(project:, args:, name:)
|
38
|
+
if @ctx.tty? && !project.registered?
|
39
|
+
Command::Register.new(@ctx).call(args, name)
|
17
40
|
end
|
18
41
|
end
|
19
42
|
|
@@ -23,11 +46,16 @@ module Extension
|
|
23
46
|
|
24
47
|
private
|
25
48
|
|
26
|
-
def show_message(draft)
|
27
|
-
draft.validation_errors.empty?
|
49
|
+
def show_message(draft, project:)
|
50
|
+
if draft.validation_errors.empty?
|
51
|
+
output_success_messages(draft,
|
52
|
+
project: project)
|
53
|
+
else
|
54
|
+
output_validation_errors(draft)
|
55
|
+
end
|
28
56
|
end
|
29
57
|
|
30
|
-
def output_success_messages(draft)
|
58
|
+
def output_success_messages(draft, project:)
|
31
59
|
@ctx.puts(@ctx.message("push.success_confirmation", project.title, format_time(draft.last_user_interaction_at)))
|
32
60
|
@ctx.puts(@ctx.message("push.success_info", draft.location))
|
33
61
|
end
|
@@ -51,7 +79,7 @@ module Extension
|
|
51
79
|
yield
|
52
80
|
end
|
53
81
|
|
54
|
-
def update_draft
|
82
|
+
def update_draft(project:, specification_handler:)
|
55
83
|
with_waiting_text do
|
56
84
|
Tasks::UpdateDraft.call(
|
57
85
|
context: @ctx,
|
@@ -9,7 +9,7 @@ module Extension
|
|
9
9
|
property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
|
10
10
|
property :argo_runtime, accepts: -> (runtime) { runtime.class < Features::Runtimes::Base }
|
11
11
|
property! :context, accepts: ShopifyCLI::Context
|
12
|
-
property! :port, accepts: Integer, default:
|
12
|
+
property! :port, accepts: Integer, default: ShopifyCLI::Constants::Extension::DEFAULT_PORT
|
13
13
|
property :tunnel_url, accepts: String, default: nil
|
14
14
|
property! :js_system, accepts: ->(jss) { jss.respond_to?(:call) }, default: ShopifyCLI::JsSystem
|
15
15
|
property :resource_url, accepts: String, default: nil
|
@@ -95,15 +95,16 @@ module Extension
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def new_serve_flow
|
98
|
-
Tasks::
|
98
|
+
Tasks::ExecuteCommands.serve(
|
99
99
|
type: specification_handler.specification.identifier,
|
100
|
-
command: "serve",
|
101
100
|
context: context,
|
101
|
+
config_file_path: specification_handler.server_config_path,
|
102
102
|
port: port,
|
103
|
-
config_file_name: specification_handler.server_config_file,
|
104
103
|
resource_url: resource_url,
|
105
104
|
tunnel_url: tunnel_url
|
106
|
-
).
|
105
|
+
).unwrap do |error|
|
106
|
+
raise error unless error.nil?
|
107
|
+
end
|
107
108
|
end
|
108
109
|
|
109
110
|
def supports_development_server?
|
@@ -34,8 +34,12 @@ module Extension
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_registrations(type)
|
37
|
-
|
38
|
-
|
37
|
+
registrations = []
|
38
|
+
loading_extensions = @ctx.message("connect.loading_extensions")
|
39
|
+
|
40
|
+
CLI::UI::Spinner.spin(loading_extensions) do |_spinner|
|
41
|
+
registrations += Tasks::GetExtensions.call(context: ctx, type: type)
|
42
|
+
end
|
39
43
|
|
40
44
|
registrations.empty? ? abort_no_registrations : registrations
|
41
45
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Loaders
|
5
|
+
module Project
|
6
|
+
def self.load(context:, directory:, api_key:, registration_id:, api_secret:)
|
7
|
+
env_overrides = {
|
8
|
+
"SHOPIFY_API_KEY" => api_key,
|
9
|
+
"SHOPIFY_API_SECRET" => api_secret,
|
10
|
+
"EXTENSION_ID" => registration_id,
|
11
|
+
}.compact
|
12
|
+
env =
|
13
|
+
begin
|
14
|
+
ShopifyCLI::Resources::EnvFile.read(directory, overrides: env_overrides)
|
15
|
+
rescue Errno::ENOENT
|
16
|
+
ShopifyCLI::Resources::EnvFile.from_hash(env_overrides)
|
17
|
+
end
|
18
|
+
# This is a somewhat uncomfortable hack we use because `Project::at` is
|
19
|
+
# a global cache and we can't rely on this class loading the project
|
20
|
+
# first. Long-term we should move away from that global cache.
|
21
|
+
project = ExtensionProject.at(directory)
|
22
|
+
project.env = env
|
23
|
+
project
|
24
|
+
rescue SmartProperties::InitializationError, SmartProperties::MissingValueError
|
25
|
+
context.abort(context.message("errors.missing_api_key"))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Extension
|
4
|
+
module Loaders
|
5
|
+
module SpecificationHandler
|
6
|
+
def self.load(project:, context:)
|
7
|
+
identifier = project.specification_identifier
|
8
|
+
Models::LazySpecificationHandler.new(identifier) do
|
9
|
+
specifications = Models::Specifications.new(
|
10
|
+
fetch_specifications: Tasks::FetchSpecifications.new(api_key: project.app.api_key, context: context)
|
11
|
+
)
|
12
|
+
|
13
|
+
unless specifications.valid?(identifier)
|
14
|
+
raise ShopifyCLI::Abort, context.message("errors.unknown_type", project.specification_identifier)
|
15
|
+
end
|
16
|
+
|
17
|
+
specifications[identifier]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -89,6 +89,9 @@ module Extension
|
|
89
89
|
help: <<~HELP,
|
90
90
|
Push the current extension to Shopify.
|
91
91
|
Usage: {{command:%s extension push}}
|
92
|
+
Options:
|
93
|
+
{{command:--api-key=API_KEY}} Connect your extension and app by inserting your app's API key (which you can get from your app setup page on shopify.dev).
|
94
|
+
{{command:--registration-id=REGISTRATION_ID}} The id of the extension's registration.
|
92
95
|
HELP
|
93
96
|
frame_title: "Pushing your extension to Shopify",
|
94
97
|
waiting_text: "Pushing code to Shopify…",
|
@@ -173,6 +176,7 @@ module Extension
|
|
173
176
|
errors: {
|
174
177
|
unknown_type: "Unknown extension type %s",
|
175
178
|
package_not_found: "`%s` package not found.",
|
179
|
+
missing_api_key: "Missing api_key.",
|
176
180
|
module_not_found: "Unable to find module %s. Ensure your dependencies are up-to-date and try again.",
|
177
181
|
},
|
178
182
|
warnings: {
|
@@ -9,11 +9,12 @@ module Extension
|
|
9
9
|
property! :api_key, accepts: String
|
10
10
|
property! :context, accepts: ShopifyCLI::Context
|
11
11
|
property! :hash, accepts: Hash
|
12
|
+
property :port, accepts: Integer, default: ShopifyCLI::Constants::Extension::DEFAULT_PORT
|
12
13
|
property! :registration_uuid, accepts: String
|
13
14
|
property :resource_url, accepts: String
|
14
15
|
property! :store, accepts: String
|
15
16
|
property! :title, accepts: String
|
16
|
-
property
|
17
|
+
property :tunnel_url, accepts: String
|
17
18
|
property! :type, accepts: String
|
18
19
|
|
19
20
|
def self.call(*args)
|
@@ -46,6 +47,7 @@ module Extension
|
|
46
47
|
end
|
47
48
|
server_config = Models::ServerConfig::Root.new(
|
48
49
|
extensions: [extension],
|
50
|
+
port: port,
|
49
51
|
public_url: tunnel_url,
|
50
52
|
store: store
|
51
53
|
)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "shopify_cli"
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module ExecuteCommands
|
7
|
+
class Base
|
8
|
+
include SmartProperties
|
9
|
+
property! :type, accepts: Models::DevelopmentServerRequirements::SUPPORTED_EXTENSION_TYPES
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "shopify_cli"
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module ExecuteCommands
|
7
|
+
class Build < Base
|
8
|
+
property! :context, accepts: ShopifyCLI::Context
|
9
|
+
property! :config_file_path, accepts: String
|
10
|
+
|
11
|
+
def call
|
12
|
+
ShopifyCLI::Result
|
13
|
+
.call(&method(:merge_server_config))
|
14
|
+
.then { |server_config| Models::DevelopmentServer.new.build(server_config) }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def merge_server_config
|
20
|
+
Tasks::MergeServerConfig.call(
|
21
|
+
context: context,
|
22
|
+
file_path: config_file_path,
|
23
|
+
type: type
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "shopify_cli"
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module ExecuteCommands
|
7
|
+
class Create < Base
|
8
|
+
property! :template, accepts: Models::ServerConfig::Development::VALID_TEMPLATES
|
9
|
+
property! :root_dir, accepts: String
|
10
|
+
|
11
|
+
def call
|
12
|
+
ShopifyCLI::Result.success(generate_config)
|
13
|
+
.then { |server_config| Models::DevelopmentServer.new.create(server_config) }
|
14
|
+
.unwrap do |error|
|
15
|
+
raise error unless error.nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def generate_config
|
22
|
+
extension = Models::ServerConfig::Extension.build(
|
23
|
+
template: template,
|
24
|
+
type: type,
|
25
|
+
root_dir: root_dir,
|
26
|
+
)
|
27
|
+
|
28
|
+
Models::ServerConfig::Root.new(extensions: [extension])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "shopify_cli"
|
3
|
+
|
4
|
+
module Extension
|
5
|
+
module Tasks
|
6
|
+
module ExecuteCommands
|
7
|
+
class Serve < Base
|
8
|
+
property! :context, accepts: ShopifyCLI::Context
|
9
|
+
property! :config_file_path, accepts: String
|
10
|
+
property :port, accepts: Integer, default: ShopifyCLI::Constants::Extension::DEFAULT_PORT
|
11
|
+
property :resource_url, accepts: String
|
12
|
+
property! :tunnel_url, accepts: String
|
13
|
+
|
14
|
+
def call
|
15
|
+
ShopifyCLI::Result
|
16
|
+
.call(&method(:merge_server_config))
|
17
|
+
.then { |server_config| Models::DevelopmentServer.new.serve(context, server_config) }
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def merge_server_config
|
23
|
+
Tasks::MergeServerConfig.call(
|
24
|
+
context: context,
|
25
|
+
file_path: config_file_path,
|
26
|
+
port: port,
|
27
|
+
resource_url: resource_url,
|
28
|
+
tunnel_url: tunnel_url,
|
29
|
+
type: type
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -4,28 +4,39 @@ require "yaml"
|
|
4
4
|
|
5
5
|
module Extension
|
6
6
|
module Tasks
|
7
|
-
class MergeServerConfig
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
7
|
+
class MergeServerConfig
|
8
|
+
include SmartProperties
|
9
|
+
|
10
|
+
property! :context, accepts: ShopifyCLI::Context
|
11
|
+
property! :file_path, accepts: ->(path) { Pathname(path).yield_self { |pn| pn.absolute? && pn.file? } }
|
12
|
+
property :port, accepts: Integer, default: ShopifyCLI::Constants::Extension::DEFAULT_PORT
|
13
|
+
property :resource_url, accepts: String
|
14
|
+
property :tunnel_url, accepts: String
|
15
|
+
property! :type, accepts: Models::DevelopmentServerRequirements::SUPPORTED_EXTENSION_TYPES
|
16
|
+
|
17
|
+
def self.call(*args)
|
18
|
+
new(*args).call
|
19
|
+
end
|
20
|
+
|
21
|
+
def call
|
22
|
+
config = YAML.load_file(file_path)
|
23
|
+
project = ExtensionProject.current
|
24
|
+
Tasks::ConvertServerConfig.call(
|
25
|
+
api_key: project.env.api_key,
|
26
|
+
context: context,
|
27
|
+
hash: config,
|
28
|
+
registration_uuid: project.registration_uuid,
|
29
|
+
resource_url: resource_url || project.resource_url,
|
30
|
+
store: project.env.shop || "",
|
31
|
+
title: project.title,
|
32
|
+
tunnel_url: tunnel_url,
|
33
|
+
type: type
|
34
|
+
)
|
35
|
+
rescue Psych::SyntaxError => e
|
36
|
+
raise(
|
37
|
+
ShopifyCLI::Abort,
|
38
|
+
ShopifyCLI::Context.message("core.yaml.error.invalid", file_name, e.message)
|
39
|
+
)
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|