shopify-cli 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/project_types/extension/commands/serve.rb +21 -1
- data/lib/project_types/script/cli.rb +2 -0
- data/lib/project_types/script/commands/create.rb +3 -1
- data/lib/project_types/script/config/extension_points.yml +10 -10
- data/lib/project_types/script/errors.rb +0 -16
- data/lib/project_types/script/layers/application/build_script.rb +2 -1
- data/lib/project_types/script/layers/application/create_script.rb +34 -7
- data/lib/project_types/script/layers/application/push_script.rb +5 -2
- data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
- data/lib/project_types/script/layers/domain/errors.rb +16 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +3 -4
- data/lib/project_types/script/layers/infrastructure/config_ui_repository.rb +46 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +20 -0
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +4 -4
- data/lib/project_types/script/layers/infrastructure/script_service.rb +14 -2
- data/lib/project_types/script/messages/messages.rb +13 -1
- data/lib/project_types/script/script_project.rb +2 -23
- data/lib/project_types/script/ui/error_handler.rb +38 -12
- data/lib/shopify-cli/method_object.rb +1 -1
- data/lib/shopify-cli/result.rb +3 -3
- data/lib/shopify-cli/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 810ed674eed1f0938f1e4fdb55703fe8bcbcf10d13293a27f7e59f28cc39d384
|
4
|
+
data.tar.gz: 0f7572e8d715e589bbe3cc23d6835e6256063a54b99504f3f6975b5008a0ed24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7681161d8502e8e728bac04b339b06d84334b1ec0edfc8a58c3f8eb5d4a85ba873c79810c63d30e784508cb9b155c3f39d672e88689b53fc0dd5cff32be865ff
|
7
|
+
data.tar.gz: ac283b1b16d617b27c2f61dc948e77adead2910f218c0649783884ee6debc6c4135c18dccf35bf73931ded907dadab0ba9c70598238874d941107fa471970041
|
data/CHANGELOG.md
CHANGED
@@ -7,8 +7,20 @@ module Extension
|
|
7
7
|
NPM_SERVE_COMMAND = %w(run-script server)
|
8
8
|
|
9
9
|
def call(_args, _command_name)
|
10
|
+
if argo_admin?
|
11
|
+
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
12
|
+
ShopifyCli::Tasks::EnsureDevStore.call(@ctx)
|
13
|
+
end
|
14
|
+
|
10
15
|
CLI::UI::Frame.open(@ctx.message("serve.frame_title")) do
|
11
|
-
|
16
|
+
yarn_serve_command = YARN_SERVE_COMMAND
|
17
|
+
npm_serve_command = NPM_SERVE_COMMAND
|
18
|
+
if argo_admin?
|
19
|
+
serve_args = %W(--shop=#{project.env.shop} --apiKey=#{project.env.api_key})
|
20
|
+
yarn_serve_command += serve_args
|
21
|
+
npm_serve_command += %w(--) + serve_args
|
22
|
+
end
|
23
|
+
success = ShopifyCli::JsSystem.call(@ctx, yarn: yarn_serve_command, npm: npm_serve_command)
|
12
24
|
@ctx.abort(@ctx.message("serve.serve_failure_message")) unless success
|
13
25
|
end
|
14
26
|
end
|
@@ -19,6 +31,14 @@ module Extension
|
|
19
31
|
Usage: {{command:#{ShopifyCli::TOOL_NAME} serve}}
|
20
32
|
HELP
|
21
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def argo_admin?
|
38
|
+
ShopifyCli::Shopifolk.check &&
|
39
|
+
ShopifyCli::Feature.enabled?(:argo_admin_beta) &&
|
40
|
+
extension_type.specification.features&.argo&.surface_area == "admin"
|
41
|
+
end
|
22
42
|
end
|
23
43
|
end
|
24
44
|
end
|
@@ -41,6 +41,7 @@ module Script
|
|
41
41
|
|
42
42
|
module Domain
|
43
43
|
autoload :Errors, Project.project_filepath("layers/domain/errors")
|
44
|
+
autoload :ConfigUi, Project.project_filepath("layers/domain/config_ui")
|
44
45
|
autoload :PushPackage, Project.project_filepath("layers/domain/push_package")
|
45
46
|
autoload :Metadata, Project.project_filepath("layers/domain/metadata")
|
46
47
|
autoload :ExtensionPoint, Project.project_filepath("layers/domain/extension_point")
|
@@ -58,6 +59,7 @@ module Script
|
|
58
59
|
Project.project_filepath("layers/infrastructure/rust_project_creator.rb")
|
59
60
|
autoload :RustTaskRunner, Project.project_filepath("layers/infrastructure/rust_task_runner")
|
60
61
|
|
62
|
+
autoload :ConfigUiRepository, Project.project_filepath("layers/infrastructure/config_ui_repository")
|
61
63
|
autoload :PushPackageRepository, Project.project_filepath("layers/infrastructure/push_package_repository")
|
62
64
|
autoload :ExtensionPointRepository, Project.project_filepath("layers/infrastructure/extension_point_repository")
|
63
65
|
autoload :ProjectCreator, Project.project_filepath("layers/infrastructure/project_creator")
|
@@ -9,6 +9,7 @@ module Script
|
|
9
9
|
parser.on("--extension_point=EP_NAME") { |ep_name| flags[:extension_point] = ep_name }
|
10
10
|
parser.on("--extension-point=EP_NAME") { |ep_name| flags[:extension_point] = ep_name }
|
11
11
|
parser.on("--language=LANGUAGE") { |language| flags[:language] = language }
|
12
|
+
parser.on("--no-config-ui") { |no_config_ui| flags[:no_config_ui] = no_config_ui }
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(args, _name)
|
@@ -26,7 +27,8 @@ module Script
|
|
26
27
|
language: form.language,
|
27
28
|
script_name: form.name,
|
28
29
|
extension_point_type: form.extension_point,
|
29
|
-
description: form.description
|
30
|
+
description: form.description,
|
31
|
+
no_config_ui: options.flags.key?(:no_config_ui)
|
30
32
|
)
|
31
33
|
@ctx.puts(@ctx.message("script.create.change_directory_notice", project.script_name))
|
32
34
|
rescue Script::Errors::ScriptProjectAlreadyExistsError => e
|
@@ -2,28 +2,28 @@ discount:
|
|
2
2
|
deprecated: true
|
3
3
|
assemblyscript:
|
4
4
|
package: "@shopify/extension-point-as-discount"
|
5
|
-
sdk-version: "^
|
6
|
-
toolchain-version: "^
|
5
|
+
sdk-version: "^9.0.0"
|
6
|
+
toolchain-version: "^5.0.0"
|
7
7
|
unit_limit_per_order:
|
8
8
|
assemblyscript:
|
9
9
|
package: "@shopify/extension-point-as-unit-limit-per-order"
|
10
|
-
sdk-version: "^
|
11
|
-
toolchain-version: "^
|
10
|
+
sdk-version: "^9.0.0"
|
11
|
+
toolchain-version: "^5.0.0"
|
12
12
|
payment_filter:
|
13
13
|
assemblyscript:
|
14
14
|
package: "@shopify/extension-point-as-payment-filter"
|
15
|
-
sdk-version: "^
|
16
|
-
toolchain-version: "^
|
15
|
+
sdk-version: "^9.0.0"
|
16
|
+
toolchain-version: "^5.0.0"
|
17
17
|
rust:
|
18
18
|
beta: true
|
19
19
|
package: "https://github.com/Shopify/scripts-apis-rs"
|
20
20
|
shipping_filter:
|
21
21
|
assemblyscript:
|
22
22
|
package: "@shopify/extension-point-as-shipping-filter"
|
23
|
-
sdk-version: "^
|
24
|
-
toolchain-version: "^
|
23
|
+
sdk-version: "^9.0.0"
|
24
|
+
toolchain-version: "^5.0.0"
|
25
25
|
tax_filter:
|
26
26
|
assemblyscript:
|
27
27
|
package: "@shopify/extension-point-as-tax-filter"
|
28
|
-
sdk-version: "^
|
29
|
-
toolchain-version: "^
|
28
|
+
sdk-version: "^9.0.0"
|
29
|
+
toolchain-version: "^5.0.0"
|
@@ -5,22 +5,6 @@ module Script
|
|
5
5
|
class InvalidContextError < ScriptProjectError; end
|
6
6
|
class InvalidScriptNameError < ScriptProjectError; end
|
7
7
|
|
8
|
-
class InvalidConfigUiDefinitionError < ScriptProjectError
|
9
|
-
attr_reader :filename
|
10
|
-
def initialize(filename)
|
11
|
-
super()
|
12
|
-
@filename = filename
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class MissingSpecifiedConfigUiDefinitionError < ScriptProjectError
|
17
|
-
attr_reader :filename
|
18
|
-
def initialize(filename)
|
19
|
-
super()
|
20
|
-
@filename = filename
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
8
|
class NoExistingAppsError < ScriptProjectError; end
|
25
9
|
class NoExistingOrganizationsError < ScriptProjectError; end
|
26
10
|
|
@@ -5,7 +5,7 @@ module Script
|
|
5
5
|
module Application
|
6
6
|
class BuildScript
|
7
7
|
class << self
|
8
|
-
def call(ctx:, task_runner:, script_project:)
|
8
|
+
def call(ctx:, task_runner:, script_project:, config_ui:)
|
9
9
|
CLI::UI::Frame.open(ctx.message("script.application.building")) do
|
10
10
|
begin
|
11
11
|
UI::StrictSpinner.spin(ctx.message("script.application.building_script")) do |spinner|
|
@@ -14,6 +14,7 @@ module Script
|
|
14
14
|
script_content: task_runner.build,
|
15
15
|
compiled_type: task_runner.compiled_type,
|
16
16
|
metadata: task_runner.metadata,
|
17
|
+
config_ui: config_ui,
|
17
18
|
)
|
18
19
|
spinner.update_title(ctx.message("script.application.built"))
|
19
20
|
end
|
@@ -7,9 +7,16 @@ module Script
|
|
7
7
|
module Application
|
8
8
|
class CreateScript
|
9
9
|
class << self
|
10
|
-
def call(ctx:, language:, script_name:, extension_point_type:, description:)
|
10
|
+
def call(ctx:, language:, script_name:, extension_point_type:, description:, no_config_ui:)
|
11
11
|
extension_point = ExtensionPoints.get(type: extension_point_type)
|
12
|
-
project = setup_project(
|
12
|
+
project = setup_project(
|
13
|
+
ctx: ctx,
|
14
|
+
language: language,
|
15
|
+
script_name: script_name,
|
16
|
+
extension_point: extension_point,
|
17
|
+
description: description,
|
18
|
+
no_config_ui: no_config_ui
|
19
|
+
)
|
13
20
|
project_creator = Infrastructure::ProjectCreator
|
14
21
|
.for(ctx, language, extension_point, script_name, project.directory)
|
15
22
|
install_dependencies(ctx, language, script_name, project_creator)
|
@@ -19,16 +26,36 @@ module Script
|
|
19
26
|
|
20
27
|
private
|
21
28
|
|
22
|
-
|
29
|
+
DEFAULT_CONFIG_UI_FILENAME = "config-ui.yml"
|
30
|
+
DEFAULT_CONFIG = {
|
31
|
+
"version" => 1,
|
32
|
+
"type" => "single",
|
33
|
+
"fields" => [],
|
34
|
+
}
|
35
|
+
|
36
|
+
def setup_project(ctx:, language:, script_name:, extension_point:, description:, no_config_ui:)
|
23
37
|
ScriptProject.create(ctx, script_name)
|
38
|
+
|
39
|
+
identifiers = {
|
40
|
+
extension_point_type: extension_point.type,
|
41
|
+
script_name: script_name,
|
42
|
+
language: language,
|
43
|
+
description: description,
|
44
|
+
}
|
45
|
+
|
46
|
+
unless no_config_ui
|
47
|
+
require "yaml" # takes 20ms, so deferred as late as possible.
|
48
|
+
identifiers.merge!(config_ui_file: DEFAULT_CONFIG_UI_FILENAME)
|
49
|
+
Infrastructure::ConfigUiRepository
|
50
|
+
.new(ctx: ctx)
|
51
|
+
.create_config_ui(DEFAULT_CONFIG_UI_FILENAME, YAML.dump(DEFAULT_CONFIG))
|
52
|
+
end
|
53
|
+
|
24
54
|
ScriptProject.write(
|
25
55
|
ctx,
|
26
56
|
project_type: :script,
|
27
57
|
organization_id: nil, # TODO: can you provide this at creation
|
28
|
-
|
29
|
-
script_name: script_name,
|
30
|
-
language: language,
|
31
|
-
description: description
|
58
|
+
**identifiers
|
32
59
|
)
|
33
60
|
ScriptProject.current
|
34
61
|
end
|
@@ -8,14 +8,17 @@ module Script
|
|
8
8
|
def call(ctx:, force:)
|
9
9
|
script_project = ScriptProject.current
|
10
10
|
task_runner = Infrastructure::TaskRunner.for(ctx, script_project.language, script_project.script_name)
|
11
|
+
config_ui = Infrastructure::ConfigUiRepository.new(ctx: ctx).get_config_ui(script_project.config_ui_file)
|
12
|
+
|
11
13
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
12
|
-
BuildScript.call(ctx: ctx, task_runner: task_runner, script_project: script_project)
|
14
|
+
BuildScript.call(ctx: ctx, task_runner: task_runner, script_project: script_project, config_ui: config_ui)
|
13
15
|
|
14
16
|
UI::PrintingSpinner.spin(ctx, ctx.message("script.application.pushing")) do |p_ctx, spinner|
|
15
17
|
package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
|
16
18
|
script_project: script_project,
|
17
19
|
compiled_type: task_runner.compiled_type,
|
18
|
-
metadata: task_runner.metadata
|
20
|
+
metadata: task_runner.metadata,
|
21
|
+
config_ui: config_ui,
|
19
22
|
)
|
20
23
|
package.push(Infrastructure::ScriptService.new(ctx: p_ctx), script_project.api_key, force)
|
21
24
|
spinner.update_title(p_ctx.message("script.application.pushed"))
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Domain
|
6
|
+
class ConfigUi
|
7
|
+
attr_reader :filename, :content
|
8
|
+
|
9
|
+
def initialize(filename:, content:)
|
10
|
+
@filename = filename
|
11
|
+
@content = content
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -14,6 +14,22 @@ module Script
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
class InvalidConfigUiDefinitionError < ScriptProjectError
|
18
|
+
attr_reader :filename
|
19
|
+
def initialize(filename)
|
20
|
+
super()
|
21
|
+
@filename = filename
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class MissingSpecifiedConfigUiDefinitionError < ScriptProjectError
|
26
|
+
attr_reader :filename
|
27
|
+
def initialize(filename)
|
28
|
+
super()
|
29
|
+
@filename = filename
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
17
33
|
class ScriptNotFoundError < ScriptProjectError
|
18
34
|
attr_reader :script_name, :extension_point_type
|
19
35
|
def initialize(extension_point_type, script_name)
|
@@ -50,13 +50,12 @@ module Script
|
|
50
50
|
"@shopify/scripts-sdk-as": "#{extension_point.sdks.assemblyscript.sdk_version}",
|
51
51
|
"@shopify/scripts-toolchain-as": "#{extension_point.sdks.assemblyscript.toolchain_version}",
|
52
52
|
"#{extension_point.sdks.assemblyscript.package}": "^#{extension_point_version}",
|
53
|
-
"@as-pect/cli": "
|
54
|
-
"
|
55
|
-
"assemblyscript": "^0.16.1"
|
53
|
+
"@as-pect/cli": "^6.0.0",
|
54
|
+
"assemblyscript": "^0.18.13"
|
56
55
|
},
|
57
56
|
"scripts": {
|
58
57
|
"test": "asp --summary --verbose",
|
59
|
-
"build": "shopify-scripts-toolchain-as build --src src/
|
58
|
+
"build": "shopify-scripts-toolchain-as build --src src/shopify_main.ts --binary build/#{script_name}.wasm --metadata build/metadata.json -- --lib node_modules --optimize --use Date="
|
60
59
|
},
|
61
60
|
"engines": {
|
62
61
|
"node": ">=#{MIN_NODE_VERSION}"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
class ConfigUiRepository
|
7
|
+
include SmartProperties
|
8
|
+
property! :ctx, accepts: ShopifyCli::Context
|
9
|
+
|
10
|
+
def create_config_ui(filename, content)
|
11
|
+
File.write(filename, content)
|
12
|
+
|
13
|
+
Domain::ConfigUi.new(
|
14
|
+
filename: filename,
|
15
|
+
content: content,
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_config_ui(filename)
|
20
|
+
return nil unless filename
|
21
|
+
|
22
|
+
path = File.join(ctx.root, filename)
|
23
|
+
raise Domain::Errors::MissingSpecifiedConfigUiDefinitionError, filename unless File.exist?(path)
|
24
|
+
|
25
|
+
content = File.read(path)
|
26
|
+
raise Domain::Errors::InvalidConfigUiDefinitionError, filename unless valid_config_ui?(content)
|
27
|
+
|
28
|
+
Domain::ConfigUi.new(
|
29
|
+
filename: filename,
|
30
|
+
content: content,
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def valid_config_ui?(raw_yaml)
|
37
|
+
require "yaml" # takes 20ms, so deferred as late as possible.
|
38
|
+
YAML.safe_load(raw_yaml)
|
39
|
+
true
|
40
|
+
rescue Psych::SyntaxError
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -8,6 +8,26 @@ module Script
|
|
8
8
|
class AppScriptNotPushedError < ScriptProjectError; end
|
9
9
|
class AppScriptUndefinedError < ScriptProjectError; end
|
10
10
|
class BuildError < ScriptProjectError; end
|
11
|
+
class ConfigUiSyntaxError < ScriptProjectError; end
|
12
|
+
|
13
|
+
class ConfigUiMissingKeysError < ScriptProjectError
|
14
|
+
attr_reader :filename, :missing_keys
|
15
|
+
def initialize(filename, missing_keys)
|
16
|
+
super()
|
17
|
+
@filename = filename
|
18
|
+
@missing_keys = missing_keys
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ConfigUiFieldsMissingKeysError < ScriptProjectError
|
23
|
+
attr_reader :filename, :missing_keys
|
24
|
+
def initialize(filename, missing_keys)
|
25
|
+
super()
|
26
|
+
@filename = filename
|
27
|
+
@missing_keys = missing_keys
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
11
31
|
class DependencyInstallError < ScriptProjectError; end
|
12
32
|
class EmptyResponseError < ScriptProjectError; end
|
13
33
|
class ForbiddenError < ScriptProjectError; end
|
@@ -7,7 +7,7 @@ module Script
|
|
7
7
|
include SmartProperties
|
8
8
|
property! :ctx, accepts: ShopifyCli::Context
|
9
9
|
|
10
|
-
def create_push_package(script_project:, script_content:, compiled_type:, metadata:)
|
10
|
+
def create_push_package(script_project:, script_content:, compiled_type:, metadata:, config_ui:)
|
11
11
|
build_file_path = file_path(script_project.script_name, compiled_type)
|
12
12
|
write_to_path(build_file_path, script_content)
|
13
13
|
|
@@ -19,11 +19,11 @@ module Script
|
|
19
19
|
script_content: script_content,
|
20
20
|
compiled_type: compiled_type,
|
21
21
|
metadata: metadata,
|
22
|
-
config_ui:
|
22
|
+
config_ui: config_ui,
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
-
def get_push_package(script_project:, compiled_type:, metadata:)
|
26
|
+
def get_push_package(script_project:, compiled_type:, metadata:, config_ui:)
|
27
27
|
build_file_path = file_path(script_project.script_name, compiled_type)
|
28
28
|
raise Domain::PushPackageNotFoundError unless ctx.file_exist?(build_file_path)
|
29
29
|
|
@@ -37,7 +37,7 @@ module Script
|
|
37
37
|
script_content: script_content,
|
38
38
|
compiled_type: compiled_type,
|
39
39
|
metadata: metadata,
|
40
|
-
config_ui:
|
40
|
+
config_ui: config_ui,
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|
@@ -26,7 +26,7 @@ module Script
|
|
26
26
|
extensionPointName: extension_point_type.upcase,
|
27
27
|
title: script_name,
|
28
28
|
description: description,
|
29
|
-
configUi: config_ui,
|
29
|
+
configUi: config_ui.content,
|
30
30
|
sourceCode: Base64.encode64(script_content),
|
31
31
|
language: compiled_type,
|
32
32
|
force: force,
|
@@ -41,6 +41,12 @@ module Script
|
|
41
41
|
|
42
42
|
if user_errors.any? { |e| e["tag"] == "already_exists_error" }
|
43
43
|
raise Errors::ScriptRepushError, api_key
|
44
|
+
elsif (e = user_errors.any? { |err| err["tag"] == "config_ui_syntax_error" })
|
45
|
+
raise Errors::ConfigUiSyntaxError, config_ui.filename
|
46
|
+
elsif (e = user_errors.find { |err| err["tag"] == "config_ui_missing_keys_error" })
|
47
|
+
raise Errors::ConfigUiMissingKeysError.new(config_ui.filename, e["message"])
|
48
|
+
elsif (e = user_errors.find { |err| err["tag"] == "config_ui_fields_missing_keys_error" })
|
49
|
+
raise Errors::ConfigUiFieldsMissingKeysError.new(config_ui.filename, e["message"])
|
44
50
|
else
|
45
51
|
raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
|
46
52
|
end
|
@@ -117,10 +123,16 @@ module Script
|
|
117
123
|
url: "https://script-service.myshopify.io/graphql",
|
118
124
|
token: "",
|
119
125
|
api_key: api_key,
|
120
|
-
shop_id: shop_domain
|
126
|
+
shop_id: infer_shop_id(shop_domain)
|
121
127
|
)
|
122
128
|
end
|
123
129
|
|
130
|
+
def self.infer_shop_id(shop_domain)
|
131
|
+
return unless shop_domain
|
132
|
+
|
133
|
+
[shop_domain.to_i, 1].max
|
134
|
+
end
|
135
|
+
|
124
136
|
def auth_headers(*)
|
125
137
|
tokens = { "APP_KEY" => api_key, "SHOP_ID" => shop_id }.compact.to_json
|
126
138
|
{ "X-Shopify-Authenticated-Tokens" => tokens }
|
@@ -57,6 +57,17 @@ module Script
|
|
57
57
|
missing_config_ui_definition_cause: "You are missing the UI configuration file %s.",
|
58
58
|
missing_config_ui_definition_help: "Create this file and try again.",
|
59
59
|
|
60
|
+
config_ui_syntax_error_cause: "The UI configuration file %{filename} is not formatted properly.",
|
61
|
+
config_ui_syntax_error_help: "Fix the errors and try again.",
|
62
|
+
|
63
|
+
config_ui_missing_keys_error_cause: "The UI configuration file %{filename} is missing required keys: "\
|
64
|
+
"%{missing_keys}.",
|
65
|
+
config_ui_missing_keys_error_help: "Add the keys and try again.",
|
66
|
+
|
67
|
+
config_ui_fields_missing_keys_error_cause: "A field entry in the UI configuration file %{filename} is "\
|
68
|
+
"missing required keys: %{missing_keys}.",
|
69
|
+
config_ui_fields_missing_keys_error_help: "Add the keys and try again.",
|
70
|
+
|
60
71
|
script_not_found_cause: "Couldn't find script %s for extension point %s",
|
61
72
|
|
62
73
|
service_failure_cause: "Internal service error.",
|
@@ -120,7 +131,7 @@ module Script
|
|
120
131
|
"is needed to compile your script to WebAssembly.",
|
121
132
|
# rubocop:disable Layout/LineLength
|
122
133
|
build_script_suggestion: "\n\nFor example, your package.json needs the following command:" \
|
123
|
-
"\nbuild: npx shopify-scripts-toolchain-as build --src src/
|
134
|
+
"\nbuild: npx shopify-scripts-toolchain-as build --src src/shopify_main.ts --binary build/<script_name>.wasm --metadata build/metadata.json -- --lib node_modules --optimize --use Date=",
|
124
135
|
|
125
136
|
web_assembly_binary_not_found: "WebAssembly binary not found.",
|
126
137
|
web_assembly_binary_not_found_suggestion: "No WebAssembly binary found." \
|
@@ -136,6 +147,7 @@ module Script
|
|
136
147
|
{{command:--name=NAME}} Script project name. Use any string.
|
137
148
|
{{command:--description=DESCRIPTION}} Description of the project. Use any string.
|
138
149
|
{{command:--extension-point=TYPE}} Extension point name. Allowed values: %2$s.
|
150
|
+
{{command:--no-config-ui}} Specify this option if you don’t want Scripts to render an interface in the Shopify admin.
|
139
151
|
HELP
|
140
152
|
|
141
153
|
error: {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Script
|
4
4
|
class ScriptProject < ShopifyCli::Project
|
5
|
-
attr_reader :extension_point_type, :script_name, :language, :description, :
|
5
|
+
attr_reader :extension_point_type, :script_name, :language, :description, :config_ui_file
|
6
6
|
|
7
7
|
def initialize(*args)
|
8
8
|
super
|
@@ -10,7 +10,7 @@ module Script
|
|
10
10
|
raise Errors::DeprecatedEPError, @extension_point_type if deprecated?(@extension_point_type)
|
11
11
|
@script_name = lookup_config!("script_name")
|
12
12
|
@description = lookup_config("description")
|
13
|
-
@
|
13
|
+
@config_ui_file = lookup_config("config_ui_file")
|
14
14
|
@language = lookup_language
|
15
15
|
ShopifyCli::Core::Monorail.metadata = {
|
16
16
|
"script_name" => @script_name,
|
@@ -39,19 +39,6 @@ module Script
|
|
39
39
|
config[key]
|
40
40
|
end
|
41
41
|
|
42
|
-
def lookup_config_ui
|
43
|
-
filename = lookup_config("config_ui_file")
|
44
|
-
return nil unless filename
|
45
|
-
|
46
|
-
path = File.join(directory, filename)
|
47
|
-
raise Errors::MissingSpecifiedConfigUiDefinitionError, filename unless File.exist?(path)
|
48
|
-
|
49
|
-
contents = File.read(path)
|
50
|
-
raise Errors::InvalidConfigUiDefinitionError, filename unless valid_config_ui?(contents)
|
51
|
-
|
52
|
-
contents
|
53
|
-
end
|
54
|
-
|
55
42
|
def lookup_language
|
56
43
|
lang = lookup_config("language")&.downcase || Layers::Domain::ExtensionPointAssemblyScriptSDK.language
|
57
44
|
if Layers::Application::ExtensionPoints.supported_language?(type: extension_point_type, language: lang)
|
@@ -61,14 +48,6 @@ module Script
|
|
61
48
|
end
|
62
49
|
end
|
63
50
|
|
64
|
-
def valid_config_ui?(raw_yaml)
|
65
|
-
require "yaml" # takes 20ms, so deferred as late as possible.
|
66
|
-
YAML.safe_load(raw_yaml)
|
67
|
-
true
|
68
|
-
rescue Psych::SyntaxError
|
69
|
-
false
|
70
|
-
end
|
71
|
-
|
72
51
|
class << self
|
73
52
|
def create(ctx, dir)
|
74
53
|
raise Errors::ScriptProjectAlreadyExistsError, dir if ctx.dir_exist?(dir)
|
@@ -61,18 +61,6 @@ module Script
|
|
61
61
|
Script::Layers::Application::ExtensionPoints.languages(type: e.extension_point_type).join(", ")
|
62
62
|
),
|
63
63
|
}
|
64
|
-
when Errors::InvalidConfigUiDefinitionError
|
65
|
-
{
|
66
|
-
cause_of_error: ShopifyCli::Context
|
67
|
-
.message("script.error.invalid_config_ui_definition_cause", e.filename),
|
68
|
-
help_suggestion: ShopifyCli::Context.message("script.error.invalid_config_ui_definition_help"),
|
69
|
-
}
|
70
|
-
when Errors::MissingSpecifiedConfigUiDefinitionError
|
71
|
-
{
|
72
|
-
cause_of_error: ShopifyCli::Context
|
73
|
-
.message("script.error.missing_config_ui_definition_cause", e.filename),
|
74
|
-
help_suggestion: ShopifyCli::Context.message("script.error.missing_config_ui_definition_help"),
|
75
|
-
}
|
76
64
|
when Errors::InvalidScriptNameError
|
77
65
|
{
|
78
66
|
cause_of_error: ShopifyCli::Context.message("script.error.invalid_script_name_cause"),
|
@@ -137,6 +125,18 @@ module Script
|
|
137
125
|
cause_of_error: ShopifyCli::Context.message("script.error.metadata_not_found_cause"),
|
138
126
|
help_suggestion: ShopifyCli::Context.message("script.error.metadata_not_found_help"),
|
139
127
|
}
|
128
|
+
when Layers::Domain::Errors::InvalidConfigUiDefinitionError
|
129
|
+
{
|
130
|
+
cause_of_error: ShopifyCli::Context
|
131
|
+
.message("script.error.invalid_config_ui_definition_cause", e.filename),
|
132
|
+
help_suggestion: ShopifyCli::Context.message("script.error.invalid_config_ui_definition_help"),
|
133
|
+
}
|
134
|
+
when Layers::Domain::Errors::MissingSpecifiedConfigUiDefinitionError
|
135
|
+
{
|
136
|
+
cause_of_error: ShopifyCli::Context
|
137
|
+
.message("script.error.missing_config_ui_definition_cause", e.filename),
|
138
|
+
help_suggestion: ShopifyCli::Context.message("script.error.missing_config_ui_definition_help"),
|
139
|
+
}
|
140
140
|
when Layers::Infrastructure::Errors::AppNotInstalledError
|
141
141
|
{
|
142
142
|
cause_of_error: ShopifyCli::Context.message("script.error.app_not_installed_cause"),
|
@@ -151,6 +151,32 @@ module Script
|
|
151
151
|
cause_of_error: ShopifyCli::Context.message("script.error.build_error_cause"),
|
152
152
|
help_suggestion: ShopifyCli::Context.message("script.error.build_error_help"),
|
153
153
|
}
|
154
|
+
when Layers::Infrastructure::Errors::ConfigUiSyntaxError
|
155
|
+
{
|
156
|
+
cause_of_error: ShopifyCli::Context.message(
|
157
|
+
"script.error.config_ui_syntax_error_cause",
|
158
|
+
filename: e.message
|
159
|
+
),
|
160
|
+
help_suggestion: ShopifyCli::Context.message("script.error.config_ui_syntax_error_help"),
|
161
|
+
}
|
162
|
+
when Layers::Infrastructure::Errors::ConfigUiMissingKeysError
|
163
|
+
{
|
164
|
+
cause_of_error: ShopifyCli::Context.message(
|
165
|
+
"script.error.config_ui_missing_keys_error_cause",
|
166
|
+
filename: e.filename,
|
167
|
+
missing_keys: e.missing_keys
|
168
|
+
),
|
169
|
+
help_suggestion: ShopifyCli::Context.message("script.error.config_ui_missing_keys_error_help"),
|
170
|
+
}
|
171
|
+
when Layers::Infrastructure::Errors::ConfigUiFieldsMissingKeysError
|
172
|
+
{
|
173
|
+
cause_of_error: ShopifyCli::Context.message(
|
174
|
+
"script.error.config_ui_fields_missing_keys_error_cause",
|
175
|
+
filename: e.filename,
|
176
|
+
missing_keys: e.missing_keys
|
177
|
+
),
|
178
|
+
help_suggestion: ShopifyCli::Context.message("script.error.config_ui_fields_missing_keys_error_help"),
|
179
|
+
}
|
154
180
|
when Layers::Infrastructure::Errors::DependencyInstallError
|
155
181
|
{
|
156
182
|
cause_of_error: ShopifyCli::Context.message("script.error.dependency_install_cause"),
|
@@ -61,7 +61,7 @@ module ShopifyCli
|
|
61
61
|
##
|
62
62
|
# creates a new instance and invokes `call`. Any positional argument
|
63
63
|
# is forward to `call`. Keyword arguments are either forwarded to the
|
64
|
-
#
|
64
|
+
# initializer or to `call`. If the keyword argument matches the name of
|
65
65
|
# property, it is forwarded to the initializer, otherwise to call.
|
66
66
|
#
|
67
67
|
def call(*args, **kwargs)
|
data/lib/shopify-cli/result.rb
CHANGED
@@ -104,7 +104,7 @@ module ShopifyCli
|
|
104
104
|
end
|
105
105
|
|
106
106
|
##
|
107
|
-
# raises an `UnexpectedSuccess` as a `
|
107
|
+
# raises an `UnexpectedSuccess` as a `Success` does not carry an error
|
108
108
|
# value.
|
109
109
|
#
|
110
110
|
def error
|
@@ -221,8 +221,8 @@ module ShopifyCli
|
|
221
221
|
# .then { |data| data.values_at(:firstname, :lastname) } # Ignored
|
222
222
|
# .unwrap(Person.new("John", "Doe")) # => Person
|
223
223
|
#
|
224
|
-
# Alternatively, we could
|
225
|
-
#
|
224
|
+
# Alternatively, we could rescue from the error and then proceed with the
|
225
|
+
# remaining transformations:
|
226
226
|
#
|
227
227
|
# Person = Struct.new(:firstname, :lastname)
|
228
228
|
# Failure
|
data/lib/shopify-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -224,12 +224,14 @@ files:
|
|
224
224
|
- lib/project_types/script/layers/application/extension_points.rb
|
225
225
|
- lib/project_types/script/layers/application/project_dependencies.rb
|
226
226
|
- lib/project_types/script/layers/application/push_script.rb
|
227
|
+
- lib/project_types/script/layers/domain/config_ui.rb
|
227
228
|
- lib/project_types/script/layers/domain/errors.rb
|
228
229
|
- lib/project_types/script/layers/domain/extension_point.rb
|
229
230
|
- lib/project_types/script/layers/domain/metadata.rb
|
230
231
|
- lib/project_types/script/layers/domain/push_package.rb
|
231
232
|
- lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb
|
232
233
|
- lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb
|
234
|
+
- lib/project_types/script/layers/infrastructure/config_ui_repository.rb
|
233
235
|
- lib/project_types/script/layers/infrastructure/errors.rb
|
234
236
|
- lib/project_types/script/layers/infrastructure/extension_point_repository.rb
|
235
237
|
- lib/project_types/script/layers/infrastructure/project_creator.rb
|