shopify-cli 2.7.0 → 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/.github/CODEOWNERS +2 -2
- data/.github/workflows/shopify.yml +1 -1
- data/.gitignore +2 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +46 -0
- data/Codespace.dockerfile +2 -2
- data/Gemfile.lock +4 -4
- data/Rakefile +27 -0
- data/Tests.dockerfile +2 -2
- data/dev.yml +3 -3
- data/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +1 -0
- data/ext/javy/javy.rb +204 -0
- data/ext/javy/version +1 -0
- 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 -14
- data/lib/project_types/extension/commands/create.rb +3 -6
- 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 -2
- data/lib/project_types/extension/models/app.rb +1 -1
- data/lib/project_types/extension/models/development_server.rb +2 -2
- 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/rails/commands/create.rb +2 -4
- data/lib/project_types/script/cli.rb +9 -1
- data/lib/project_types/script/commands/connect.rb +19 -0
- data/lib/project_types/script/commands/create.rb +1 -3
- data/lib/project_types/script/commands/javy.rb +29 -0
- data/lib/project_types/script/commands/push.rb +2 -1
- data/lib/project_types/script/config/extension_points.yml +12 -30
- data/lib/project_types/script/forms/ask_app.rb +32 -0
- data/lib/project_types/script/forms/ask_org.rb +30 -0
- data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
- data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
- data/lib/project_types/script/graphql/app_script_set.graphql +2 -2
- data/lib/project_types/script/layers/application/build_script.rb +0 -1
- data/lib/project_types/script/layers/application/connect_app.rb +79 -0
- data/lib/project_types/script/layers/application/create_script.rb +17 -17
- data/lib/project_types/script/layers/application/push_script.rb +1 -1
- data/lib/project_types/script/layers/domain/errors.rb +1 -4
- data/lib/project_types/script/layers/domain/push_package.rb +3 -3
- data/lib/project_types/script/layers/domain/{script_json.rb → script_config.rb} +2 -2
- data/lib/project_types/script/layers/domain/script_project.rb +5 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +36 -7
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -4
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -4
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +125 -27
- data/lib/project_types/script/layers/infrastructure/script_service.rb +11 -11
- data/lib/project_types/script/messages/messages.rb +32 -4
- data/lib/project_types/script/ui/error_handler.rb +31 -21
- data/lib/project_types/theme/commands/pull.rb +3 -0
- data/lib/project_types/theme/commands/push.rb +7 -1
- data/lib/project_types/theme/commands/serve.rb +1 -1
- data/lib/project_types/theme/messages/messages.rb +35 -1
- data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
- data/lib/shopify_cli/command/project_command.rb +20 -7
- data/lib/shopify_cli/command.rb +6 -0
- data/lib/shopify_cli/commands/app/create/node.rb +1 -3
- data/lib/shopify_cli/commands/app/create/rails.rb +1 -3
- data/lib/shopify_cli/constants.rb +7 -0
- data/lib/shopify_cli/context.rb +11 -1
- data/lib/shopify_cli/environment.rb +4 -0
- data/lib/shopify_cli/form.rb +2 -0
- data/lib/shopify_cli/git.rb +2 -0
- data/lib/shopify_cli/identity_auth.rb +18 -0
- data/lib/shopify_cli/messages/messages.rb +9 -2
- 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 +2 -8
- data/lib/shopify_cli/project.rb +8 -7
- data/lib/shopify_cli/resources/env_file.rb +13 -5
- data/lib/shopify_cli/services/app/create/node_service.rb +2 -0
- data/lib/shopify_cli/services/app/create/php_service.rb +1 -1
- data/lib/shopify_cli/services/app/create/rails_service.rb +3 -1
- data/lib/shopify_cli/services/app/serve/node_service.rb +1 -1
- data/lib/shopify_cli/services/app/serve/rails_service.rb +1 -1
- data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
- data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
- data/lib/shopify_cli/theme/dev_server/hot-reload.js +38 -9
- 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/theme/dev_server.rb +32 -19
- data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
- data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
- data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
- data/lib/shopify_cli/theme/syncer.rb +40 -39
- data/lib/shopify_cli/theme/theme.rb +31 -19
- data/lib/shopify_cli/thread_pool/job.rb +27 -0
- data/lib/shopify_cli/thread_pool.rb +37 -0
- data/lib/shopify_cli/tunnel.rb +26 -22
- data/lib/shopify_cli/version.rb +1 -1
- data/shopify-cli.gemspec +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +3 -1
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
- metadata +34 -8
- data/lib/graphql/all_orgs_with_extensions.graphql +0 -37
- data/lib/project_types/extension/tasks/run_extension_command.rb +0 -82
- data/lib/project_types/script/tasks/ensure_env.rb +0 -106
@@ -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
|
@@ -68,8 +68,6 @@ module Extension
|
|
68
68
|
HELP
|
69
69
|
frame_title: "Building extension with: %s…",
|
70
70
|
build_failure_message: "Failed to build extension code.",
|
71
|
-
build_success_message: "Build was successful!",
|
72
|
-
directory_not_found: "Build directory not found.",
|
73
71
|
},
|
74
72
|
register: {
|
75
73
|
help: <<~HELP,
|
@@ -91,6 +89,9 @@ module Extension
|
|
91
89
|
help: <<~HELP,
|
92
90
|
Push the current extension to Shopify.
|
93
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.
|
94
95
|
HELP
|
95
96
|
frame_title: "Pushing your extension to Shopify",
|
96
97
|
waiting_text: "Pushing code to Shopify…",
|
@@ -175,6 +176,7 @@ module Extension
|
|
175
176
|
errors: {
|
176
177
|
unknown_type: "Unknown extension type %s",
|
177
178
|
package_not_found: "`%s` package not found.",
|
179
|
+
missing_api_key: "Missing api_key.",
|
178
180
|
module_not_found: "Unable to find module %s. Ensure your dependencies are up-to-date and try again.",
|
179
181
|
},
|
180
182
|
warnings: {
|
@@ -33,8 +33,8 @@ module Extension
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def build(server_config)
|
36
|
-
|
37
|
-
return if status.success?
|
36
|
+
output, error, status = CLI::Kit::System.capture3(executable, "build", "-", stdin_data: server_config.to_yaml)
|
37
|
+
return output if status.success?
|
38
38
|
raise DevelopmentServerError, error
|
39
39
|
end
|
40
40
|
|
@@ -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
|
@@ -2,9 +2,7 @@
|
|
2
2
|
module Rails
|
3
3
|
class Command
|
4
4
|
class Create < ShopifyCLI::Command::AppSubCommand
|
5
|
-
|
6
|
-
prerequisite_task :ensure_authenticated
|
7
|
-
end
|
5
|
+
prerequisite_task :ensure_authenticated
|
8
6
|
|
9
7
|
USER_AGENT_CODE = <<~USERAGENT
|
10
8
|
module ShopifyAPI
|
@@ -158,10 +156,10 @@ module Rails
|
|
158
156
|
|
159
157
|
CLI::UI::Frame.open(@ctx.message("rails.create.generating_app", name)) do
|
160
158
|
new_command = %w(rails new)
|
159
|
+
new_command << name
|
161
160
|
new_command += DEFAULT_RAILS_FLAGS
|
162
161
|
new_command << "--database=#{db}"
|
163
162
|
new_command += options.flags[:rails_opts].split unless options.flags[:rails_opts].nil?
|
164
|
-
new_command << name
|
165
163
|
|
166
164
|
syscall(new_command)
|
167
165
|
end
|
@@ -13,12 +13,19 @@ module Script
|
|
13
13
|
hidden_feature(feature_set: :script_project)
|
14
14
|
subcommand :Create, "create", Project.project_filepath("commands/create")
|
15
15
|
subcommand :Push, "push", Project.project_filepath("commands/push")
|
16
|
+
subcommand :Connect, "connect", Project.project_filepath("commands/connect")
|
17
|
+
subcommand :Javy, "javy", Project.project_filepath("commands/javy")
|
16
18
|
end
|
17
19
|
ShopifyCLI::Commands.register("Script::Command", "script")
|
18
20
|
|
19
21
|
# define/autoload project specific Forms
|
20
22
|
module Forms
|
23
|
+
autoload :AskOrg, Project.project_filepath("forms/ask_org")
|
24
|
+
autoload :AskApp, Project.project_filepath("forms/ask_app")
|
25
|
+
autoload :AskScriptUuid, Project.project_filepath("forms/ask_script_uuid")
|
26
|
+
autoload :RunAgainstShopifyOrg, Project.project_filepath("forms/run_against_shopify_org")
|
21
27
|
autoload :Create, Project.project_filepath("forms/create")
|
28
|
+
autoload :Connect, Project.project_filepath("forms/connect")
|
22
29
|
autoload :ScriptForm, Project.project_filepath("forms/script_form")
|
23
30
|
end
|
24
31
|
|
@@ -29,6 +36,7 @@ module Script
|
|
29
36
|
module Layers
|
30
37
|
module Application
|
31
38
|
autoload :BuildScript, Project.project_filepath("layers/application/build_script")
|
39
|
+
autoload :ConnectApp, Project.project_filepath("layers/application/connect_app")
|
32
40
|
autoload :CreateScript, Project.project_filepath("layers/application/create_script")
|
33
41
|
autoload :PushScript, Project.project_filepath("layers/application/push_script")
|
34
42
|
autoload :ExtensionPoints, Project.project_filepath("layers/application/extension_points")
|
@@ -40,7 +48,7 @@ module Script
|
|
40
48
|
autoload :PushPackage, Project.project_filepath("layers/domain/push_package")
|
41
49
|
autoload :Metadata, Project.project_filepath("layers/domain/metadata")
|
42
50
|
autoload :ExtensionPoint, Project.project_filepath("layers/domain/extension_point")
|
43
|
-
autoload :
|
51
|
+
autoload :ScriptConfig, Project.project_filepath("layers/domain/script_config")
|
44
52
|
autoload :ScriptProject, Project.project_filepath("layers/domain/script_project")
|
45
53
|
end
|
46
54
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Script
|
3
|
+
class Command
|
4
|
+
class Connect < ShopifyCLI::Command::SubCommand
|
5
|
+
prerequisite_task :ensure_authenticated
|
6
|
+
prerequisite_task ensure_project_type: :script
|
7
|
+
|
8
|
+
def call(_args, _)
|
9
|
+
Layers::Application::ConnectApp.call(ctx: @ctx, force: true, strict: true)
|
10
|
+
rescue StandardError => e
|
11
|
+
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.connect.error.operation_failed"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.help
|
15
|
+
ShopifyCLI::Context.new.message("connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,9 +3,7 @@
|
|
3
3
|
module Script
|
4
4
|
class Command
|
5
5
|
class Create < ShopifyCLI::Command::SubCommand
|
6
|
-
|
7
|
-
prerequisite_task :ensure_authenticated
|
8
|
-
end
|
6
|
+
prerequisite_task :ensure_authenticated
|
9
7
|
|
10
8
|
options do |parser, flags|
|
11
9
|
parser.on("--name=NAME") { |name| flags[:name] = name }
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "shopify_cli"
|
3
|
+
require_relative "../../../../ext/javy/javy.rb"
|
4
|
+
|
5
|
+
module Script
|
6
|
+
class Command
|
7
|
+
class Javy < ShopifyCLI::Command::SubCommand
|
8
|
+
hidden_feature
|
9
|
+
|
10
|
+
options do |parser, flags|
|
11
|
+
parser.on("--in=IN") { |in_file| flags[:in_file] = in_file }
|
12
|
+
parser.on("--out=OUT") { |out_file| flags[:out_file] = out_file }
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(*)
|
16
|
+
source = options.flags[:in_file]
|
17
|
+
dest = options.flags[:out_file]
|
18
|
+
|
19
|
+
@ctx.abort(@ctx.message("script.javy.errors.invalid_arguments", ShopifyCLI::TOOL_NAME)) unless source
|
20
|
+
|
21
|
+
::Javy.build(source: source, dest: dest).unwrap { |e| @ctx.abort(e.message) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.help
|
25
|
+
ShopifyCLI::Context.message("script.javy.help", ShopifyCLI::TOOL_NAME)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -10,7 +10,8 @@ module Script
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(_args, _name)
|
13
|
-
fresh_env =
|
13
|
+
fresh_env = Layers::Application::ConnectApp.call(ctx: @ctx)
|
14
|
+
|
14
15
|
force = options.flags.key?(:force) || !!fresh_env
|
15
16
|
|
16
17
|
api_key = Layers::Infrastructure::ScriptProjectRepository.new(ctx: @ctx).get.api_key
|
@@ -1,29 +1,3 @@
|
|
1
|
-
discount:
|
2
|
-
deprecated: true
|
3
|
-
libraries:
|
4
|
-
assemblyscript:
|
5
|
-
package: "@shopify/extension-point-as-discount"
|
6
|
-
unit_limit_per_order:
|
7
|
-
beta: true
|
8
|
-
libraries:
|
9
|
-
assemblyscript:
|
10
|
-
package: "@shopify/extension-point-as-unit-limit-per-order"
|
11
|
-
payment_filter:
|
12
|
-
deprecated: true
|
13
|
-
libraries:
|
14
|
-
assemblyscript:
|
15
|
-
package: "@shopify/extension-point-as-payment-filter"
|
16
|
-
shipping_filter:
|
17
|
-
deprecated: true
|
18
|
-
libraries:
|
19
|
-
assemblyscript:
|
20
|
-
package: "@shopify/extension-point-as-shipping-filter"
|
21
|
-
tax_filter:
|
22
|
-
beta: true
|
23
|
-
libraries:
|
24
|
-
assemblyscript:
|
25
|
-
repo: "https://github.com/Shopify/extension-points.git"
|
26
|
-
package: "@shopify/extension-point-as-tax-filter"
|
27
1
|
payment_methods:
|
28
2
|
domain: 'checkout'
|
29
3
|
libraries:
|
@@ -32,7 +6,7 @@ payment_methods:
|
|
32
6
|
package: "@shopify/scripts-checkout-apis"
|
33
7
|
typescript:
|
34
8
|
beta: true
|
35
|
-
package: "@shopify/scripts-checkout-apis
|
9
|
+
package: "@shopify/scripts-checkout-apis"
|
36
10
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
37
11
|
shipping_methods:
|
38
12
|
domain: 'checkout'
|
@@ -42,13 +16,21 @@ shipping_methods:
|
|
42
16
|
package: "@shopify/scripts-checkout-apis"
|
43
17
|
typescript:
|
44
18
|
beta: true
|
45
|
-
package: "@shopify/scripts-checkout-apis
|
19
|
+
package: "@shopify/scripts-checkout-apis"
|
20
|
+
repo: "https://github.com/Shopify/scripts-apis-examples"
|
21
|
+
merchandise_discount_types:
|
22
|
+
beta: true
|
23
|
+
domain: 'discounts'
|
24
|
+
libraries:
|
25
|
+
typescript:
|
26
|
+
beta: true
|
27
|
+
package: "@shopify/scripts-discounts-apis"
|
46
28
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
47
|
-
|
29
|
+
delivery_discount_types:
|
48
30
|
beta: true
|
49
31
|
domain: 'discounts'
|
50
32
|
libraries:
|
51
33
|
typescript:
|
52
34
|
beta: true
|
53
|
-
package: "@shopify/scripts-
|
35
|
+
package: "@shopify/scripts-discounts-apis"
|
54
36
|
repo: "https://github.com/Shopify/scripts-apis-examples"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Forms
|
5
|
+
class AskApp < ShopifyCLI::Form
|
6
|
+
attr_reader :app
|
7
|
+
|
8
|
+
def ask
|
9
|
+
apps = @xargs.fetch(:apps)
|
10
|
+
|
11
|
+
unless @xargs[:acting_as_shopify_organization]
|
12
|
+
apps = apps.select { |app| app["appType"] == "custom" }
|
13
|
+
end
|
14
|
+
|
15
|
+
raise Errors::NoExistingAppsError if apps.empty?
|
16
|
+
|
17
|
+
@app =
|
18
|
+
if apps.count > 1
|
19
|
+
CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.app_select")) do |handler|
|
20
|
+
apps.each do |app|
|
21
|
+
handler.option(app["title"]) { app }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
apps.first.tap do |app|
|
26
|
+
ctx.puts(ctx.message("script.application.ensure_env.app", app["title"]))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Forms
|
5
|
+
class AskOrg < ShopifyCLI::Form
|
6
|
+
attr_reader :org
|
7
|
+
|
8
|
+
BUSINESS_NAME = "businessName"
|
9
|
+
ID = "id"
|
10
|
+
|
11
|
+
def ask
|
12
|
+
orgs = @xargs
|
13
|
+
@org =
|
14
|
+
if orgs.count == 1
|
15
|
+
orgs.first.tap do |org|
|
16
|
+
ctx.puts(ctx.message("script.application.ensure_env.organization", org[BUSINESS_NAME], org[ID]))
|
17
|
+
end
|
18
|
+
elsif orgs.count > 0
|
19
|
+
CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.organization_select")) do |handler|
|
20
|
+
orgs.each do |org|
|
21
|
+
handler.option("#{org[BUSINESS_NAME]} (#{org[ID]})") { org }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
raise Errors::NoExistingOrganizationsError
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Forms
|
5
|
+
class AskScriptUuid < ShopifyCLI::Form
|
6
|
+
attr_reader :uuid
|
7
|
+
def ask
|
8
|
+
scripts = @xargs
|
9
|
+
|
10
|
+
return if scripts.empty? ||
|
11
|
+
!CLI::UI::Prompt.confirm(ctx.message("script.application.ensure_env.ask_connect_to_existing_script"))
|
12
|
+
|
13
|
+
@uuid =
|
14
|
+
CLI::UI::Prompt.ask(ctx.message("script.application.ensure_env.ask_which_script_to_connect_to")) do |handler|
|
15
|
+
scripts.each do |script|
|
16
|
+
handler.option("#{script["title"]} (#{script["uuid"]})") { script["uuid"] }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Forms
|
5
|
+
class RunAgainstShopifyOrg < ShopifyCLI::Form
|
6
|
+
attr_reader :response
|
7
|
+
def ask
|
8
|
+
@ctx.puts(@ctx.message("core.tasks.select_org_and_shop.identified_as_shopify"))
|
9
|
+
message = @ctx.message("core.tasks.select_org_and_shop.first_party")
|
10
|
+
@response = CLI::UI::Prompt.confirm(message, default: false)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|