shopify-cli 2.10.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.yaml +117 -0
- data/.github/ISSUE_TEMPLATE/enhancement.yaml +38 -0
- data/.github/ISSUE_TEMPLATE/feature.yaml +47 -0
- data/.github/ISSUE_TEMPLATE.md +18 -0
- data/CHANGELOG.md +35 -3
- data/Gemfile.lock +1 -1
- data/dev.yml +3 -0
- data/lib/project_types/extension/commands/build.rb +3 -0
- data/lib/project_types/extension/commands/check.rb +3 -0
- data/lib/project_types/extension/commands/create.rb +3 -0
- data/lib/project_types/extension/commands/push.rb +16 -0
- data/lib/project_types/extension/commands/serve.rb +3 -0
- data/lib/project_types/extension/loaders/project.rb +28 -8
- data/lib/project_types/extension/messages/messages.rb +10 -2
- data/lib/project_types/extension/models/specification_handlers/default.rb +1 -1
- data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
- data/lib/project_types/script/cli.rb +5 -0
- data/lib/project_types/script/commands/connect.rb +3 -1
- data/lib/project_types/script/commands/create.rb +2 -0
- data/lib/project_types/script/commands/push.rb +6 -0
- data/lib/project_types/script/config/extension_points.yml +12 -0
- data/lib/project_types/script/graphql/app_script_set.graphql +2 -0
- data/lib/project_types/script/graphql/module_upload_url_generate.graphql +5 -1
- data/lib/project_types/script/layers/application/build_script.rb +6 -3
- data/lib/project_types/script/layers/application/create_script.rb +1 -1
- data/lib/project_types/script/layers/application/project_dependencies.rb +1 -1
- data/lib/project_types/script/layers/application/push_script.rb +39 -31
- data/lib/project_types/script/layers/domain/errors.rb +7 -1
- data/lib/project_types/script/layers/domain/extension_point.rb +2 -2
- data/lib/project_types/script/layers/domain/push_package.rb +0 -3
- data/lib/project_types/script/layers/domain/script_project.rb +1 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +13 -3
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +3 -20
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +1 -0
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +35 -8
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +3 -20
- data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +15 -0
- data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +32 -0
- data/lib/project_types/script/layers/infrastructure/metadata_repository.rb +18 -0
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +7 -8
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +17 -26
- data/lib/project_types/script/layers/infrastructure/script_service.rb +15 -9
- data/lib/project_types/script/layers/infrastructure/script_uploader.rb +22 -9
- data/lib/project_types/script/loaders/project.rb +2 -1
- data/lib/project_types/script/messages/messages.rb +92 -84
- data/lib/project_types/script/ui/error_handler.rb +39 -14
- data/lib/project_types/theme/commands/check.rb +2 -0
- data/lib/project_types/theme/commands/delete.rb +2 -0
- data/lib/project_types/theme/commands/init.rb +2 -0
- data/lib/project_types/theme/commands/language_server.rb +2 -0
- data/lib/project_types/theme/commands/package.rb +2 -0
- data/lib/project_types/theme/commands/publish.rb +2 -0
- data/lib/project_types/theme/commands/pull.rb +6 -1
- data/lib/project_types/theme/commands/push.rb +6 -1
- data/lib/project_types/theme/commands/serve.rb +2 -0
- data/lib/shopify_cli/command/sub_command.rb +2 -0
- data/lib/shopify_cli/command.rb +72 -0
- data/lib/shopify_cli/commands/app/create/node.rb +3 -0
- data/lib/shopify_cli/commands/app/create/rails.rb +3 -0
- data/lib/shopify_cli/commands/app/deploy.rb +2 -0
- data/lib/shopify_cli/commands/app/serve.rb +2 -0
- data/lib/shopify_cli/constants.rb +13 -1
- data/lib/shopify_cli/environment.rb +55 -35
- data/lib/shopify_cli/exception_reporter.rb +9 -0
- data/lib/shopify_cli/github/issue_url_generator.rb +19 -8
- data/lib/shopify_cli/identity_auth/env_auth_token.rb +34 -0
- data/lib/shopify_cli/identity_auth.rb +33 -15
- data/lib/shopify_cli/messages/messages.rb +2 -1
- data/lib/shopify_cli/partners_api.rb +7 -2
- data/lib/shopify_cli/services/app/create/rails_service.rb +37 -13
- data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +28 -8
- data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +63 -0
- data/lib/shopify_cli/theme/dev_server/hot_reload.rb +22 -6
- data/lib/shopify_cli/theme/dev_server/local_assets.rb +0 -4
- data/lib/shopify_cli/theme/dev_server/proxy.rb +4 -5
- data/lib/shopify_cli/theme/dev_server.rb +0 -2
- data/lib/shopify_cli/theme/file.rb +4 -0
- data/lib/shopify_cli/theme/include_filter.rb +39 -17
- data/lib/shopify_cli/utilities.rb +7 -0
- data/lib/shopify_cli/version.rb +1 -1
- data/lib/shopify_cli.rb +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +11 -6
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +5 -1
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +6 -4
- data/vendor/lib/semantic/version.rb +0 -1
- metadata +11 -5
- data/lib/project_types/rails/commands/create.rb +0 -210
- data/lib/shopify_cli/theme/dev_server/cdn/cdn_helper.rb +0 -49
- data/lib/shopify_cli/theme/dev_server/cdn_assets.rb +0 -69
|
@@ -3,7 +3,7 @@ module Script
|
|
|
3
3
|
module Application
|
|
4
4
|
class ProjectDependencies
|
|
5
5
|
def self.install(ctx:, task_runner:)
|
|
6
|
-
CLI::UI::Frame.open(ctx.message("script.project_deps.
|
|
6
|
+
CLI::UI::Frame.open(ctx.message("script.project_deps.checking")) do
|
|
7
7
|
begin
|
|
8
8
|
if task_runner.dependencies_installed?
|
|
9
9
|
ctx.puts(ctx.message("script.project_deps.none_required"))
|
|
@@ -10,48 +10,56 @@ module Script
|
|
|
10
10
|
script_project = script_project_repo.get
|
|
11
11
|
script_project.env = project.env
|
|
12
12
|
task_runner = Infrastructure::Languages::TaskRunner
|
|
13
|
-
.for(ctx, script_project.language
|
|
13
|
+
.for(ctx, script_project.language)
|
|
14
14
|
|
|
15
15
|
extension_point = ExtensionPoints.get(type: script_project.extension_point_type)
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
library = extension_point.libraries.for(script_project.language)
|
|
18
|
+
|
|
17
19
|
raise Infrastructure::Errors::LanguageLibraryForAPINotFoundError.new(
|
|
18
20
|
language: script_project.language,
|
|
19
21
|
api: script_project.extension_point_type
|
|
20
|
-
)
|
|
22
|
+
) if library.nil? && (script_project.language != "wasm")
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
library_name = library&.package
|
|
25
|
+
library_data = {
|
|
23
26
|
language: script_project.language,
|
|
24
27
|
version: task_runner.library_version(library_name),
|
|
25
|
-
}
|
|
28
|
+
} if library_name
|
|
26
29
|
|
|
27
30
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
|
28
|
-
BuildScript.call(ctx: ctx, task_runner: task_runner, script_project: script_project, library:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
BuildScript.call(ctx: ctx, task_runner: task_runner, script_project: script_project, library: library_data)
|
|
32
|
+
|
|
33
|
+
metadata_file_location = task_runner.metadata_file_location
|
|
34
|
+
metadata = Infrastructure::MetadataRepository.new(ctx: ctx).get_metadata(metadata_file_location)
|
|
35
|
+
|
|
36
|
+
CLI::UI::Frame.open(ctx.message("script.application.pushing")) do
|
|
37
|
+
UI::PrintingSpinner.spin(ctx, ctx.message("script.application.pushing_script")) do |p_ctx, spinner|
|
|
38
|
+
package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
|
|
39
|
+
script_project: script_project,
|
|
40
|
+
metadata: metadata,
|
|
41
|
+
library: library_data,
|
|
42
|
+
)
|
|
43
|
+
script_service = Infrastructure::ServiceLocator.script_service(
|
|
44
|
+
ctx: p_ctx,
|
|
45
|
+
api_key: script_project.api_key
|
|
46
|
+
)
|
|
47
|
+
module_upload_url = Infrastructure::ScriptUploader.new(script_service).upload(package.script_content)
|
|
48
|
+
uuid = script_service.set_app_script(
|
|
49
|
+
uuid: package.uuid,
|
|
50
|
+
extension_point_type: package.extension_point_type,
|
|
51
|
+
force: force,
|
|
52
|
+
metadata: package.metadata,
|
|
53
|
+
script_config: package.script_config,
|
|
54
|
+
module_upload_url: module_upload_url,
|
|
55
|
+
library: package.library,
|
|
56
|
+
input_query: script_project.input_query,
|
|
57
|
+
)
|
|
58
|
+
if ShopifyCLI::Environment.interactive?
|
|
59
|
+
script_project_repo.update_env(uuid: uuid)
|
|
60
|
+
end
|
|
61
|
+
spinner.update_title(p_ctx.message("script.application.pushed"))
|
|
53
62
|
end
|
|
54
|
-
spinner.update_title(p_ctx.message("script.application.pushed"))
|
|
55
63
|
end
|
|
56
64
|
end
|
|
57
65
|
end
|
|
@@ -32,7 +32,13 @@ module Script
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
class MetadataNotFoundError < ScriptProjectError
|
|
35
|
+
class MetadataNotFoundError < ScriptProjectError
|
|
36
|
+
attr_reader :filename
|
|
37
|
+
def initialize(filename)
|
|
38
|
+
super()
|
|
39
|
+
@filename = filename
|
|
40
|
+
end
|
|
41
|
+
end
|
|
36
42
|
|
|
37
43
|
class MetadataValidationError < ScriptProjectError; end
|
|
38
44
|
end
|
|
@@ -42,8 +42,8 @@ module Script
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def all
|
|
45
|
-
@all ||= @config.map do |language,
|
|
46
|
-
ExtensionPointLibrary.new(language,
|
|
45
|
+
@all ||= @config.map do |language, library_config|
|
|
46
|
+
ExtensionPointLibrary.new(language, library_config)
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -9,7 +9,6 @@ module Script
|
|
|
9
9
|
:extension_point_type,
|
|
10
10
|
:script_config,
|
|
11
11
|
:script_content,
|
|
12
|
-
:compiled_type,
|
|
13
12
|
:metadata,
|
|
14
13
|
:library
|
|
15
14
|
|
|
@@ -18,7 +17,6 @@ module Script
|
|
|
18
17
|
uuid:,
|
|
19
18
|
extension_point_type:,
|
|
20
19
|
script_content:,
|
|
21
|
-
compiled_type: nil,
|
|
22
20
|
metadata:,
|
|
23
21
|
script_config:,
|
|
24
22
|
library:
|
|
@@ -27,7 +25,6 @@ module Script
|
|
|
27
25
|
@uuid = uuid
|
|
28
26
|
@extension_point_type = extension_point_type
|
|
29
27
|
@script_content = script_content
|
|
30
|
-
@compiled_type = compiled_type
|
|
31
28
|
@metadata = metadata
|
|
32
29
|
@script_config = script_config
|
|
33
30
|
@library = library
|
|
@@ -7,10 +7,11 @@ module Script
|
|
|
7
7
|
class BuildError < ScriptProjectError; end
|
|
8
8
|
|
|
9
9
|
class ScriptConfigurationDefinitionError < ScriptProjectError
|
|
10
|
-
attr_reader :filename
|
|
11
|
-
def initialize(
|
|
10
|
+
attr_reader :filename, :messages
|
|
11
|
+
def initialize(messages:, filename:)
|
|
12
|
+
super()
|
|
13
|
+
@messages = messages
|
|
12
14
|
@filename = filename
|
|
13
|
-
super(message)
|
|
14
15
|
end
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -159,6 +160,15 @@ module Script
|
|
|
159
160
|
class ScriptUploadError < ScriptProjectError; end
|
|
160
161
|
class ProjectConfigNotFoundError < ScriptProjectError; end
|
|
161
162
|
class InvalidProjectConfigError < ScriptProjectError; end
|
|
163
|
+
|
|
164
|
+
class ScriptTooLargeError < ScriptProjectError
|
|
165
|
+
attr_reader :max_size
|
|
166
|
+
|
|
167
|
+
def initialize(max_size)
|
|
168
|
+
super()
|
|
169
|
+
@max_size = max_size
|
|
170
|
+
end
|
|
171
|
+
end
|
|
162
172
|
end
|
|
163
173
|
end
|
|
164
174
|
end
|
|
@@ -4,27 +4,16 @@ module Script
|
|
|
4
4
|
module Layers
|
|
5
5
|
module Infrastructure
|
|
6
6
|
module Languages
|
|
7
|
-
class AssemblyScriptTaskRunner
|
|
7
|
+
class AssemblyScriptTaskRunner < TaskRunner
|
|
8
8
|
BYTECODE_FILE = "build/script.wasm"
|
|
9
9
|
METADATA_FILE = "build/metadata.json"
|
|
10
10
|
SCRIPT_SDK_BUILD = "npm run build"
|
|
11
11
|
|
|
12
|
-
attr_reader :ctx, :script_name
|
|
13
|
-
|
|
14
|
-
def initialize(ctx, script_name)
|
|
15
|
-
@ctx = ctx
|
|
16
|
-
@script_name = script_name
|
|
17
|
-
end
|
|
18
|
-
|
|
19
12
|
def build
|
|
20
13
|
compile
|
|
21
14
|
bytecode
|
|
22
15
|
end
|
|
23
16
|
|
|
24
|
-
def compiled_type
|
|
25
|
-
"wasm"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
17
|
def install_dependencies
|
|
29
18
|
check_node_version!
|
|
30
19
|
|
|
@@ -37,14 +26,8 @@ module Script
|
|
|
37
26
|
ctx.dir_exist?("node_modules")
|
|
38
27
|
end
|
|
39
28
|
|
|
40
|
-
def
|
|
41
|
-
|
|
42
|
-
msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
|
|
43
|
-
raise Domain::Errors::MetadataNotFoundError, msg
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
raw_contents = File.read(METADATA_FILE)
|
|
47
|
-
Domain::Metadata.create_from_json(@ctx, raw_contents)
|
|
29
|
+
def metadata_file_location
|
|
30
|
+
METADATA_FILE
|
|
48
31
|
end
|
|
49
32
|
|
|
50
33
|
def library_version(library_name)
|
|
@@ -5,14 +5,41 @@ module Script
|
|
|
5
5
|
module Infrastructure
|
|
6
6
|
module Languages
|
|
7
7
|
class TaskRunner
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
attr_reader :ctx
|
|
9
|
+
|
|
10
|
+
def self.for(ctx, language)
|
|
11
|
+
task_runners = {
|
|
12
|
+
"assemblyscript" => AssemblyScriptTaskRunner,
|
|
13
|
+
"typescript" => TypeScriptTaskRunner,
|
|
14
|
+
"wasm" => WasmTaskRunner,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
raise Errors::TaskRunnerNotFoundError unless task_runners[language]
|
|
18
|
+
task_runners[language].new(ctx)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def initialize(ctx)
|
|
22
|
+
@ctx = ctx
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def build
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def dependencies_installed?
|
|
30
|
+
raise NotImplementedError
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def install_dependencies
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def metadata_file_location
|
|
38
|
+
raise NotImplementedError
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def library_version(_library_name)
|
|
42
|
+
raise NotImplementedError
|
|
16
43
|
end
|
|
17
44
|
end
|
|
18
45
|
end
|
|
@@ -4,28 +4,17 @@ module Script
|
|
|
4
4
|
module Layers
|
|
5
5
|
module Infrastructure
|
|
6
6
|
module Languages
|
|
7
|
-
class TypeScriptTaskRunner
|
|
7
|
+
class TypeScriptTaskRunner < TaskRunner
|
|
8
8
|
BYTECODE_FILE = "build/index.wasm"
|
|
9
9
|
METADATA_FILE = "build/metadata.json"
|
|
10
10
|
SCRIPT_SDK_BUILD = "npm run build"
|
|
11
11
|
GEN_METADATA = "npm run gen-metadata"
|
|
12
12
|
|
|
13
|
-
attr_reader :ctx, :script_name
|
|
14
|
-
|
|
15
|
-
def initialize(ctx, script_name)
|
|
16
|
-
@ctx = ctx
|
|
17
|
-
@script_name = script_name
|
|
18
|
-
end
|
|
19
|
-
|
|
20
13
|
def build
|
|
21
14
|
compile
|
|
22
15
|
bytecode
|
|
23
16
|
end
|
|
24
17
|
|
|
25
|
-
def compiled_type
|
|
26
|
-
"wasm"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
18
|
def install_dependencies
|
|
30
19
|
check_node_version!
|
|
31
20
|
|
|
@@ -38,14 +27,8 @@ module Script
|
|
|
38
27
|
ctx.dir_exist?("node_modules")
|
|
39
28
|
end
|
|
40
29
|
|
|
41
|
-
def
|
|
42
|
-
|
|
43
|
-
msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
|
|
44
|
-
raise Domain::Errors::MetadataNotFoundError, msg
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
raw_contents = File.read(METADATA_FILE)
|
|
48
|
-
Domain::Metadata.create_from_json(@ctx, raw_contents)
|
|
30
|
+
def metadata_file_location
|
|
31
|
+
METADATA_FILE
|
|
49
32
|
end
|
|
50
33
|
|
|
51
34
|
def library_version(library_name)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Script
|
|
4
|
+
module Layers
|
|
5
|
+
module Infrastructure
|
|
6
|
+
module Languages
|
|
7
|
+
class WasmTaskRunner < TaskRunner
|
|
8
|
+
BYTECODE_FILE = "script.wasm"
|
|
9
|
+
|
|
10
|
+
def dependencies_installed?
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def install_dependencies; end
|
|
15
|
+
|
|
16
|
+
def library_version(_library_name)
|
|
17
|
+
nil
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def metadata_file_location
|
|
21
|
+
"metadata.json"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def build
|
|
25
|
+
raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(BYTECODE_FILE)
|
|
26
|
+
ctx.binread(BYTECODE_FILE)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
module Script
|
|
3
|
+
module Layers
|
|
4
|
+
module Infrastructure
|
|
5
|
+
class MetadataRepository
|
|
6
|
+
include SmartProperties
|
|
7
|
+
property! :ctx, accepts: ShopifyCLI::Context
|
|
8
|
+
|
|
9
|
+
def get_metadata(file_location)
|
|
10
|
+
raise Domain::Errors::MetadataNotFoundError, file_location unless ctx.file_exist?(file_location)
|
|
11
|
+
|
|
12
|
+
raw_contents = File.read(file_location)
|
|
13
|
+
Domain::Metadata.create_from_json(ctx, raw_contents)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -7,8 +7,8 @@ module Script
|
|
|
7
7
|
include SmartProperties
|
|
8
8
|
property! :ctx, accepts: ShopifyCLI::Context
|
|
9
9
|
|
|
10
|
-
def create_push_package(script_project:, script_content:,
|
|
11
|
-
build_file_path = file_path(script_project.id
|
|
10
|
+
def create_push_package(script_project:, script_content:, metadata:, library:)
|
|
11
|
+
build_file_path = file_path(script_project.id)
|
|
12
12
|
write_to_path(build_file_path, script_content)
|
|
13
13
|
|
|
14
14
|
Domain::PushPackage.new(
|
|
@@ -16,16 +16,15 @@ module Script
|
|
|
16
16
|
uuid: script_project.uuid,
|
|
17
17
|
extension_point_type: script_project.extension_point_type,
|
|
18
18
|
script_content: script_content,
|
|
19
|
-
compiled_type: compiled_type,
|
|
20
19
|
metadata: metadata,
|
|
21
20
|
script_config: script_project.script_config,
|
|
22
21
|
library: library
|
|
23
22
|
)
|
|
24
23
|
end
|
|
25
24
|
|
|
26
|
-
def get_push_package(script_project:,
|
|
27
|
-
build_file_path = file_path(script_project.id
|
|
28
|
-
raise Domain::PushPackageNotFoundError unless ctx.file_exist?(build_file_path)
|
|
25
|
+
def get_push_package(script_project:, metadata:, library:)
|
|
26
|
+
build_file_path = file_path(script_project.id)
|
|
27
|
+
raise Domain::Errors::PushPackageNotFoundError unless ctx.file_exist?(build_file_path)
|
|
29
28
|
|
|
30
29
|
script_content = ctx.binread(build_file_path)
|
|
31
30
|
Domain::PushPackage.new(
|
|
@@ -46,8 +45,8 @@ module Script
|
|
|
46
45
|
ctx.binwrite(path, content)
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
def file_path(path_to_script
|
|
50
|
-
"#{path_to_script}/build/script
|
|
48
|
+
def file_path(path_to_script)
|
|
49
|
+
"#{path_to_script}/build/script.wasm"
|
|
51
50
|
end
|
|
52
51
|
end
|
|
53
52
|
end
|
|
@@ -10,6 +10,7 @@ module Script
|
|
|
10
10
|
property :initial_directory, accepts: String
|
|
11
11
|
|
|
12
12
|
MUTABLE_ENV_VALUES = %i(uuid)
|
|
13
|
+
INPUT_QUERY_PATH = "input.graphql"
|
|
13
14
|
|
|
14
15
|
def create_project_directory
|
|
15
16
|
raise Infrastructure::Errors::ScriptProjectAlreadyExistsError, directory if ctx.dir_exist?(directory)
|
|
@@ -38,13 +39,7 @@ module Script
|
|
|
38
39
|
language: language
|
|
39
40
|
)
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
id: ctx.root,
|
|
43
|
-
env: project.env,
|
|
44
|
-
script_name: script_name,
|
|
45
|
-
extension_point_type: extension_point_type,
|
|
46
|
-
language: language
|
|
47
|
-
)
|
|
42
|
+
build_script_project(script_config: nil)
|
|
48
43
|
end
|
|
49
44
|
|
|
50
45
|
def get
|
|
@@ -56,7 +51,8 @@ module Script
|
|
|
56
51
|
script_name: script_name,
|
|
57
52
|
extension_point_type: extension_point_type,
|
|
58
53
|
language: language,
|
|
59
|
-
script_config: script_config_repository.get
|
|
54
|
+
script_config: script_config_repository.get!,
|
|
55
|
+
input_query: read_input_query,
|
|
60
56
|
)
|
|
61
57
|
end
|
|
62
58
|
|
|
@@ -68,14 +64,7 @@ module Script
|
|
|
68
64
|
end
|
|
69
65
|
end
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
id: ctx.root,
|
|
73
|
-
env: project.env,
|
|
74
|
-
script_name: script_name,
|
|
75
|
-
extension_point_type: extension_point_type,
|
|
76
|
-
language: language,
|
|
77
|
-
script_config: script_config_repository.get!,
|
|
78
|
-
)
|
|
67
|
+
build_script_project
|
|
79
68
|
end
|
|
80
69
|
|
|
81
70
|
def create_env(api_key:, secret:, uuid:)
|
|
@@ -87,19 +76,19 @@ module Script
|
|
|
87
76
|
}
|
|
88
77
|
).write(ctx)
|
|
89
78
|
|
|
90
|
-
|
|
91
|
-
id: ctx.root,
|
|
92
|
-
env: project.env,
|
|
93
|
-
script_name: script_name,
|
|
94
|
-
extension_point_type: extension_point_type,
|
|
95
|
-
language: language,
|
|
96
|
-
script_config: script_config_repository.get!,
|
|
97
|
-
)
|
|
79
|
+
build_script_project
|
|
98
80
|
end
|
|
99
81
|
|
|
100
82
|
def update_script_config(title:)
|
|
101
83
|
script_config = script_config_repository.update!(title: title)
|
|
84
|
+
build_script_project(script_config: script_config)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
102
88
|
|
|
89
|
+
def build_script_project(
|
|
90
|
+
script_config: script_config_repository.get!
|
|
91
|
+
)
|
|
103
92
|
Domain::ScriptProject.new(
|
|
104
93
|
id: ctx.root,
|
|
105
94
|
env: project.env,
|
|
@@ -110,8 +99,6 @@ module Script
|
|
|
110
99
|
)
|
|
111
100
|
end
|
|
112
101
|
|
|
113
|
-
private
|
|
114
|
-
|
|
115
102
|
def change_directory(directory:)
|
|
116
103
|
ctx.chdir(directory)
|
|
117
104
|
end
|
|
@@ -173,6 +160,10 @@ module Script
|
|
|
173
160
|
end
|
|
174
161
|
end
|
|
175
162
|
|
|
163
|
+
def read_input_query
|
|
164
|
+
ctx.read(INPUT_QUERY_PATH) if ctx.file_exist?(INPUT_QUERY_PATH)
|
|
165
|
+
end
|
|
166
|
+
|
|
176
167
|
class ScriptConfigRepository
|
|
177
168
|
include SmartProperties
|
|
178
169
|
property! :ctx, accepts: ShopifyCLI::Context
|
|
@@ -19,7 +19,8 @@ module Script
|
|
|
19
19
|
metadata:,
|
|
20
20
|
script_config:,
|
|
21
21
|
module_upload_url:,
|
|
22
|
-
library
|
|
22
|
+
library:,
|
|
23
|
+
input_query: nil
|
|
23
24
|
)
|
|
24
25
|
query_name = "app_script_set"
|
|
25
26
|
variables = {
|
|
@@ -34,11 +35,14 @@ module Script
|
|
|
34
35
|
configurationUi: script_config.configuration_ui,
|
|
35
36
|
configurationDefinition: script_config.configuration&.to_json,
|
|
36
37
|
moduleUploadUrl: module_upload_url,
|
|
37
|
-
|
|
38
|
-
language: library[:language],
|
|
39
|
-
version: library[:version],
|
|
40
|
-
},
|
|
38
|
+
inputQuery: input_query,
|
|
41
39
|
}
|
|
40
|
+
|
|
41
|
+
variables[:library] = {
|
|
42
|
+
language: library[:language],
|
|
43
|
+
version: library[:version],
|
|
44
|
+
} if library
|
|
45
|
+
|
|
42
46
|
resp_hash = make_request(query_name: query_name, variables: variables)
|
|
43
47
|
user_errors = resp_hash["data"]["appScriptSet"]["userErrors"]
|
|
44
48
|
|
|
@@ -46,9 +50,9 @@ module Script
|
|
|
46
50
|
|
|
47
51
|
if user_errors.any? { |e| e["tag"] == "already_exists_error" }
|
|
48
52
|
raise Errors::ScriptRepushError, uuid
|
|
49
|
-
elsif (
|
|
53
|
+
elsif (errors = user_errors.select { |err| err["tag"] == "configuration_definition_error" }).any?
|
|
50
54
|
raise Errors::ScriptConfigurationDefinitionError.new(
|
|
51
|
-
|
|
55
|
+
messages: errors.map { |e| e["message"] },
|
|
52
56
|
filename: script_config.filename,
|
|
53
57
|
)
|
|
54
58
|
elsif (e = user_errors.any? { |err| err["tag"] == "configuration_definition_syntax_error" })
|
|
@@ -91,14 +95,16 @@ module Script
|
|
|
91
95
|
response["data"]["appScripts"]
|
|
92
96
|
end
|
|
93
97
|
|
|
94
|
-
def
|
|
98
|
+
def generate_module_upload_details
|
|
95
99
|
query_name = "module_upload_url_generate"
|
|
96
100
|
variables = {}
|
|
97
101
|
response = make_request(query_name: query_name, variables: variables)
|
|
98
102
|
user_errors = response["data"]["moduleUploadUrlGenerate"]["userErrors"]
|
|
99
103
|
|
|
100
104
|
raise Errors::GraphqlError, user_errors if user_errors.any?
|
|
101
|
-
|
|
105
|
+
|
|
106
|
+
data = response["data"]["moduleUploadUrlGenerate"]["details"]
|
|
107
|
+
{ url: data["url"], headers: data["headers"], max_size: data["humanizedMaxSize"] }
|
|
102
108
|
end
|
|
103
109
|
|
|
104
110
|
private
|
|
@@ -7,19 +7,32 @@ module Script
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def upload(script_content)
|
|
10
|
-
@script_service.
|
|
11
|
-
|
|
10
|
+
upload_details = @script_service.generate_module_upload_details
|
|
11
|
+
url = URI(upload_details[:url])
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
https = Net::HTTP.new(url.host, url.port)
|
|
14
|
+
https.use_ssl = true
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
request.body = script_content
|
|
16
|
+
request = Net::HTTP::Put.new(url)
|
|
17
|
+
request["Content-Type"] = "application/wasm"
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
upload_details[:headers].each do |header, value|
|
|
20
|
+
request[header] = value
|
|
22
21
|
end
|
|
22
|
+
|
|
23
|
+
request.body = script_content
|
|
24
|
+
|
|
25
|
+
response = https.request(request)
|
|
26
|
+
raise Errors::ScriptTooLargeError, upload_details[:max_size] if script_too_large?(response)
|
|
27
|
+
raise Errors::ScriptUploadError unless response.code == "200"
|
|
28
|
+
|
|
29
|
+
upload_details[:url]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def script_too_large?(response)
|
|
35
|
+
response.code == "400" && response.body.include?("EntityTooLarge")
|
|
23
36
|
end
|
|
24
37
|
end
|
|
25
38
|
end
|
|
@@ -32,7 +32,8 @@ module Script
|
|
|
32
32
|
else
|
|
33
33
|
properties_hash = { api_key: "--api-key", secret: "--api-secret" }
|
|
34
34
|
missing_options = error.properties.map { |p| properties_hash[p.name] }.compact.join(", ")
|
|
35
|
-
raise ShopifyCLI::Abort, context.message("script.error.missing_push_options", missing_options
|
|
35
|
+
raise ShopifyCLI::Abort, context.message("script.error.missing_push_options", missing_options,
|
|
36
|
+
ShopifyCli::TOOL_NAME)
|
|
36
37
|
end
|
|
37
38
|
end
|
|
38
39
|
|