shopify-cli 2.25.0 → 2.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/dev.yml +0 -3
- data/lib/project_types/extension/models/specification_handlers/default.rb +6 -1
- data/lib/project_types/script/cli.rb +0 -79
- data/lib/project_types/script/commands/connect.rb +3 -8
- data/lib/project_types/script/commands/create.rb +4 -29
- data/lib/project_types/script/commands/javy.rb +3 -8
- data/lib/project_types/script/commands/push.rb +4 -41
- data/lib/project_types/script/messages/messages.rb +1 -258
- data/lib/project_types/theme/commands/common/shop_helper.rb +13 -0
- data/lib/project_types/theme/commands/delete.rb +4 -1
- data/lib/project_types/theme/commands/list.rb +3 -4
- data/lib/project_types/theme/commands/open.rb +4 -1
- data/lib/project_types/theme/commands/publish.rb +4 -1
- data/lib/project_types/theme/commands/pull.rb +3 -1
- data/lib/project_types/theme/commands/push.rb +3 -1
- data/lib/project_types/theme/commands/serve.rb +2 -1
- data/lib/project_types/theme/messages/messages.rb +5 -5
- data/lib/shopify_cli/messages/messages.rb +1 -1
- data/lib/shopify_cli/packager.rb +12 -3
- data/lib/shopify_cli/release.rb +4 -2
- data/lib/shopify_cli/version.rb +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +1 -1
- metadata +3 -48
- data/lib/project_types/script/config/extension_points.yml +0 -45
- data/lib/project_types/script/errors.rb +0 -10
- data/lib/project_types/script/forms/ask_app.rb +0 -27
- data/lib/project_types/script/forms/ask_org.rb +0 -30
- data/lib/project_types/script/forms/ask_script_uuid.rb +0 -22
- data/lib/project_types/script/forms/create.rb +0 -33
- data/lib/project_types/script/forms/run_against_shopify_org.rb +0 -14
- data/lib/project_types/script/graphql/app_script_set.graphql +0 -46
- data/lib/project_types/script/graphql/get_app_scripts.graphql +0 -6
- data/lib/project_types/script/graphql/module_upload_url_generate.graphql +0 -13
- data/lib/project_types/script/graphql/script_service_proxy.graphql +0 -7
- data/lib/project_types/script/layers/application/build_script.rb +0 -25
- data/lib/project_types/script/layers/application/connect_app.rb +0 -86
- data/lib/project_types/script/layers/application/create_script.rb +0 -90
- data/lib/project_types/script/layers/application/extension_points.rb +0 -66
- data/lib/project_types/script/layers/application/project_dependencies.rb +0 -26
- data/lib/project_types/script/layers/application/push_script.rb +0 -74
- data/lib/project_types/script/layers/domain/app_bridge.rb +0 -16
- data/lib/project_types/script/layers/domain/errors.rb +0 -47
- data/lib/project_types/script/layers/domain/extension_point.rb +0 -81
- data/lib/project_types/script/layers/domain/metadata.rb +0 -46
- data/lib/project_types/script/layers/domain/push_package.rb +0 -41
- data/lib/project_types/script/layers/domain/script_config.rb +0 -32
- data/lib/project_types/script/layers/domain/script_project.rb +0 -61
- data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -53
- data/lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb +0 -35
- data/lib/project_types/script/layers/infrastructure/command_runner.rb +0 -19
- data/lib/project_types/script/layers/infrastructure/errors.rb +0 -211
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +0 -37
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +0 -62
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +0 -47
- data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +0 -26
- data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +0 -45
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -103
- data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +0 -12
- data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +0 -32
- data/lib/project_types/script/layers/infrastructure/metadata_repository.rb +0 -18
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +0 -36
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +0 -273
- data/lib/project_types/script/layers/infrastructure/script_service.rb +0 -135
- data/lib/project_types/script/layers/infrastructure/script_uploader.rb +0 -40
- data/lib/project_types/script/layers/infrastructure/service_locator.rb +0 -20
- data/lib/project_types/script/layers/infrastructure/sparse_checkout_details.rb +0 -35
- data/lib/project_types/script/ui/error_handler.rb +0 -331
- data/lib/project_types/script/ui/printing_spinner.rb +0 -75
- data/lib/project_types/script/ui/strict_spinner.rb +0 -20
@@ -1,211 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
module Errors
|
7
|
-
class BuildError < ScriptProjectError; end
|
8
|
-
|
9
|
-
class ScriptConfigurationDefinitionError < ScriptProjectError
|
10
|
-
attr_reader :filename, :messages
|
11
|
-
def initialize(messages:, filename:)
|
12
|
-
super()
|
13
|
-
@messages = messages
|
14
|
-
@filename = filename
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class ScriptConfigSyntaxError < ScriptProjectError
|
19
|
-
attr_reader :filename
|
20
|
-
def initialize(filename)
|
21
|
-
@filename = filename
|
22
|
-
super()
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class ScriptConfigMissingKeysError < ScriptProjectError
|
27
|
-
attr_reader :missing_keys, :filename
|
28
|
-
def initialize(missing_keys:, filename:)
|
29
|
-
super()
|
30
|
-
@missing_keys = missing_keys
|
31
|
-
@filename = filename
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class ScriptConfigInvalidValueError < ScriptProjectError
|
36
|
-
attr_reader :valid_input_modes, :filename
|
37
|
-
def initialize(valid_input_modes:, filename:)
|
38
|
-
super()
|
39
|
-
@valid_input_modes = valid_input_modes
|
40
|
-
@filename = filename
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class ScriptConfigFieldsMissingKeysError < ScriptProjectError
|
45
|
-
attr_reader :missing_keys, :filename
|
46
|
-
def initialize(missing_keys:, filename:)
|
47
|
-
super()
|
48
|
-
@missing_keys = missing_keys
|
49
|
-
@filename = filename
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class ScriptConfigFieldsInvalidValueError < ScriptProjectError
|
54
|
-
attr_reader :valid_types, :filename
|
55
|
-
def initialize(valid_types:, filename:)
|
56
|
-
super()
|
57
|
-
@valid_types = valid_types
|
58
|
-
@filename = filename
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class ScriptEnvAppNotConnectedError < ScriptProjectError; end
|
63
|
-
|
64
|
-
class ScriptConfigParseError < ScriptProjectError
|
65
|
-
attr_reader :filename, :serialization_format
|
66
|
-
def initialize(filename:, serialization_format:)
|
67
|
-
super()
|
68
|
-
@filename = filename
|
69
|
-
@serialization_format = serialization_format
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class NoScriptConfigFileError < ScriptProjectError
|
74
|
-
attr_reader :filename
|
75
|
-
def initialize(filename)
|
76
|
-
super()
|
77
|
-
@filename = filename
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
class APILibraryNotFoundError < ScriptProjectError
|
82
|
-
attr_reader :library_name
|
83
|
-
def initialize(library_name)
|
84
|
-
super()
|
85
|
-
@library_name = library_name
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class LanguageLibraryForAPINotFoundError < ScriptProjectError
|
90
|
-
attr_reader :language, :api
|
91
|
-
def initialize(language:, api:)
|
92
|
-
super()
|
93
|
-
@language = language
|
94
|
-
@api = api
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
class DeprecatedEPError < ScriptProjectError
|
99
|
-
attr_reader(:extension_point)
|
100
|
-
def initialize(extension_point)
|
101
|
-
super()
|
102
|
-
@extension_point = extension_point
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class DependencyInstallError < ScriptProjectError; end
|
107
|
-
class EmptyResponseError < ScriptProjectError; end
|
108
|
-
|
109
|
-
class InvalidEnvironmentError < ScriptProjectError
|
110
|
-
attr_reader :tool, :env_version, :minimum_version
|
111
|
-
def initialize(tool, env_version, minimum_version)
|
112
|
-
super()
|
113
|
-
@tool = tool
|
114
|
-
@env_version = env_version
|
115
|
-
@minimum_version = minimum_version
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
class InvalidResponseError < ScriptProjectError; end
|
120
|
-
class ForbiddenError < ScriptProjectError; end
|
121
|
-
class InvalidContextError < ScriptProjectError; end
|
122
|
-
|
123
|
-
class InvalidLanguageError < ScriptProjectError
|
124
|
-
attr_reader :language, :extension_point_type
|
125
|
-
def initialize(language, extension_point_type)
|
126
|
-
super()
|
127
|
-
@language = language
|
128
|
-
@extension_point_type = extension_point_type
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
class GraphqlError < ScriptProjectError
|
133
|
-
attr_reader :errors
|
134
|
-
def initialize(errors)
|
135
|
-
@errors = errors
|
136
|
-
super("GraphQL failed with errors: #{errors}")
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
class SystemCallFailureError < ScriptProjectError
|
141
|
-
attr_reader :out, :cmd
|
142
|
-
def initialize(out:, cmd:)
|
143
|
-
super(out)
|
144
|
-
@out = out
|
145
|
-
@cmd = cmd
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
class ScriptRepushError < ScriptProjectError
|
150
|
-
attr_reader :uuid
|
151
|
-
def initialize(uuid)
|
152
|
-
super()
|
153
|
-
@uuid = uuid
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
class ScriptProjectAlreadyExistsError < ScriptProjectError; end
|
158
|
-
class BuildScriptNotFoundError < ScriptProjectError; end
|
159
|
-
|
160
|
-
class WebAssemblyBinaryNotFoundError < ScriptProjectError
|
161
|
-
def initialize
|
162
|
-
super("WebAssembly binary not found")
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
class InvalidProjectError < ScriptProjectError; end
|
167
|
-
|
168
|
-
class ScriptUploadError < ScriptProjectError; end
|
169
|
-
class ProjectConfigNotFoundError < ScriptProjectError; end
|
170
|
-
class InvalidProjectConfigError < ScriptProjectError; end
|
171
|
-
|
172
|
-
class ScriptTooLargeError < ScriptProjectError
|
173
|
-
attr_reader :max_size
|
174
|
-
|
175
|
-
def initialize(max_size)
|
176
|
-
super()
|
177
|
-
@max_size = max_size
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
class InvalidInputQueryErrors < ScriptProjectError
|
182
|
-
attr_reader :messages
|
183
|
-
|
184
|
-
def initialize(messages)
|
185
|
-
@messages = messages
|
186
|
-
super()
|
187
|
-
end
|
188
|
-
|
189
|
-
def input_query_path
|
190
|
-
ScriptProjectRepository::INPUT_QUERY_PATH
|
191
|
-
end
|
192
|
-
|
193
|
-
def message
|
194
|
-
messages.join("\n")
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
class InvalidAppBridgePathError < ScriptProjectError
|
199
|
-
def initialize(path_type)
|
200
|
-
@path_type = path_type
|
201
|
-
super()
|
202
|
-
end
|
203
|
-
|
204
|
-
def path_key
|
205
|
-
"app_bridge_#{@path_type}_path"
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class ExtensionPointRepository
|
7
|
-
def get_extension_point(type)
|
8
|
-
Domain::ExtensionPoint.new(type, fetch_extension_point(type))
|
9
|
-
end
|
10
|
-
|
11
|
-
def extension_points
|
12
|
-
extension_point_configs.map do |type, extension_point_config|
|
13
|
-
Domain::ExtensionPoint.new(type, extension_point_config)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def extension_point_types
|
18
|
-
extension_point_configs.keys
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def fetch_extension_point(type)
|
24
|
-
raise Domain::Errors::InvalidExtensionPointError, type unless extension_point_configs[type]
|
25
|
-
extension_point_configs[type]
|
26
|
-
end
|
27
|
-
|
28
|
-
def extension_point_configs
|
29
|
-
@extension_points ||= begin
|
30
|
-
require "yaml"
|
31
|
-
YAML.load_file(Project.project_filepath("config/extension_points.yml"))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
module Languages
|
7
|
-
class ProjectCreator
|
8
|
-
include SmartProperties
|
9
|
-
property! :ctx, accepts: ShopifyCLI::Context
|
10
|
-
property! :type, accepts: String
|
11
|
-
property! :project_name, accepts: String
|
12
|
-
property! :path_to_project, accepts: String
|
13
|
-
property! :sparse_checkout_details, accepts: SparseCheckoutDetails
|
14
|
-
|
15
|
-
def self.for(
|
16
|
-
ctx:,
|
17
|
-
language:,
|
18
|
-
type:,
|
19
|
-
project_name:,
|
20
|
-
path_to_project:,
|
21
|
-
sparse_checkout_details:
|
22
|
-
)
|
23
|
-
|
24
|
-
project_creators = {
|
25
|
-
"typescript" => TypeScriptProjectCreator,
|
26
|
-
"wasm" => WasmProjectCreator,
|
27
|
-
}
|
28
|
-
|
29
|
-
project_creator = project_creators[language] || WasmProjectCreator
|
30
|
-
|
31
|
-
project_creator.new(
|
32
|
-
ctx: ctx,
|
33
|
-
type: type,
|
34
|
-
project_name: project_name,
|
35
|
-
path_to_project: path_to_project,
|
36
|
-
sparse_checkout_details: sparse_checkout_details,
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
# the sparse checkout process is common to all script types
|
41
|
-
def setup_dependencies
|
42
|
-
sparse_checkout_details.setup(ctx)
|
43
|
-
clean
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def clean
|
49
|
-
source = File.join(path_to_project, sparse_checkout_details.path, ".")
|
50
|
-
FileUtils.cp_r(source, path_to_project)
|
51
|
-
ctx.rm_rf(sparse_checkout_details.path.split("/")[0])
|
52
|
-
ctx.rm_rf(".git")
|
53
|
-
end
|
54
|
-
|
55
|
-
def command_runner
|
56
|
-
@command_runner ||= CommandRunner.new(ctx: ctx)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
module Languages
|
7
|
-
class TaskRunner
|
8
|
-
attr_reader :ctx
|
9
|
-
|
10
|
-
def self.for(ctx, language)
|
11
|
-
task_runners = {
|
12
|
-
"typescript" => TypeScriptTaskRunner,
|
13
|
-
"wasm" => WasmTaskRunner,
|
14
|
-
}
|
15
|
-
|
16
|
-
task_runner = task_runners[language] || WasmTaskRunner
|
17
|
-
task_runner.new(ctx)
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(ctx)
|
21
|
-
@ctx = ctx
|
22
|
-
end
|
23
|
-
|
24
|
-
def build
|
25
|
-
raise NotImplementedError
|
26
|
-
end
|
27
|
-
|
28
|
-
def dependencies_installed?
|
29
|
-
raise NotImplementedError
|
30
|
-
end
|
31
|
-
|
32
|
-
def install_dependencies
|
33
|
-
raise NotImplementedError
|
34
|
-
end
|
35
|
-
|
36
|
-
def metadata_file_location
|
37
|
-
raise NotImplementedError
|
38
|
-
end
|
39
|
-
|
40
|
-
def library_version(_library_name)
|
41
|
-
raise NotImplementedError
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Script
|
2
|
-
module Layers
|
3
|
-
module Infrastructure
|
4
|
-
module Languages
|
5
|
-
class ToolVersionChecker
|
6
|
-
class << self
|
7
|
-
def check_node(minimum_version:)
|
8
|
-
check_version("node", ShopifyCLI::Environment.node_version, minimum_version)
|
9
|
-
end
|
10
|
-
|
11
|
-
def check_npm(minimum_version:)
|
12
|
-
check_version("npm", ShopifyCLI::Environment.npm_version, minimum_version)
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def check_version(tool, env_version, minimum_version)
|
18
|
-
return if env_version >= ::Semantic::Version.new(minimum_version)
|
19
|
-
raise Errors::InvalidEnvironmentError.new(tool, env_version, minimum_version)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
module Languages
|
7
|
-
class TypeScriptProjectCreator < ProjectCreator
|
8
|
-
def setup_dependencies
|
9
|
-
task_runner = Infrastructure::Languages::TypeScriptTaskRunner.new(ctx)
|
10
|
-
task_runner.set_npm_config
|
11
|
-
|
12
|
-
super
|
13
|
-
|
14
|
-
if ctx.file_exist?("yarn.lock")
|
15
|
-
ctx.rm("yarn.lock")
|
16
|
-
end
|
17
|
-
|
18
|
-
if ctx.file_exist?("package-lock.json")
|
19
|
-
ctx.rm("package-lock.json")
|
20
|
-
end
|
21
|
-
|
22
|
-
update_package_json_name
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def update_package_json_name
|
28
|
-
file_content = ctx.read("package.json")
|
29
|
-
hash = file_content_to_hash(file_content)
|
30
|
-
hash["name"] = project_name
|
31
|
-
ctx.write("package.json", hash_to_file_content(hash))
|
32
|
-
end
|
33
|
-
|
34
|
-
def file_content_to_hash(content)
|
35
|
-
JSON.parse(content)
|
36
|
-
end
|
37
|
-
|
38
|
-
def hash_to_file_content(hash)
|
39
|
-
JSON.pretty_generate(hash)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
module Languages
|
7
|
-
class TypeScriptTaskRunner < TaskRunner
|
8
|
-
NODE_MIN_VERSION = "14.15.0"
|
9
|
-
NPM_MIN_VERSION = "5.2.0"
|
10
|
-
|
11
|
-
BYTECODE_FILE = "build/index.wasm"
|
12
|
-
METADATA_FILE = "build/metadata.json"
|
13
|
-
SCRIPT_SDK_BUILD = "npm run build"
|
14
|
-
GEN_METADATA = "npm run gen-metadata"
|
15
|
-
NPM_SET_REGISTRY_COMMAND = "npm --userconfig ./.npmrc config set @shopify:registry https://registry.npmjs.com"
|
16
|
-
NPM_SET_ENGINE_STRICT_COMMAND = "npm --userconfig ./.npmrc config set engine-strict true"
|
17
|
-
NPM_INSTALL_COMMAND = "npm install --no-audit --no-optional --legacy-peer-deps --loglevel error"
|
18
|
-
|
19
|
-
def build
|
20
|
-
compile
|
21
|
-
rescue Errors::SystemCallFailureError => e
|
22
|
-
raise Errors::BuildError, e.out
|
23
|
-
end
|
24
|
-
|
25
|
-
def install_dependencies
|
26
|
-
run_cmd_with_env_check(NPM_INSTALL_COMMAND)
|
27
|
-
|
28
|
-
rescue Errors::SystemCallFailureError => e
|
29
|
-
raise Errors::DependencyInstallError, e.out
|
30
|
-
end
|
31
|
-
|
32
|
-
def dependencies_installed?
|
33
|
-
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
34
|
-
ctx.dir_exist?("node_modules")
|
35
|
-
end
|
36
|
-
|
37
|
-
def metadata_file_location
|
38
|
-
METADATA_FILE
|
39
|
-
end
|
40
|
-
|
41
|
-
def library_version(library_name)
|
42
|
-
output = JSON.parse(run_cmd_with_env_check("npm -s list --json"))
|
43
|
-
library_version_from_npm_list(output, library_name)
|
44
|
-
rescue Errors::SystemCallFailureError => error
|
45
|
-
library_version_from_npm_list_error_output(error, library_name)
|
46
|
-
end
|
47
|
-
|
48
|
-
def set_npm_config
|
49
|
-
run_cmd_with_env_check(NPM_SET_REGISTRY_COMMAND)
|
50
|
-
run_cmd_with_env_check(NPM_SET_ENGINE_STRICT_COMMAND)
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def ensure_environment
|
56
|
-
return if defined?(@environment_checked)
|
57
|
-
@environment_checked = true
|
58
|
-
|
59
|
-
ToolVersionChecker.check_node(minimum_version: NODE_MIN_VERSION)
|
60
|
-
ToolVersionChecker.check_npm(minimum_version: NPM_MIN_VERSION)
|
61
|
-
end
|
62
|
-
|
63
|
-
def run_cmd_with_env_check(cmd)
|
64
|
-
ensure_environment
|
65
|
-
CommandRunner.new(ctx: ctx).call(cmd)
|
66
|
-
end
|
67
|
-
|
68
|
-
def library_version_from_npm_list_error_output(error, library_name)
|
69
|
-
# npm list can return a failure status code, even when returning the correct data.
|
70
|
-
# This causes the CommandRunner to throw a SystemCallFailure error that contains the data.
|
71
|
-
# In here, we check that the output contains `npm list`'s structure and extract the version.
|
72
|
-
output = JSON.parse(error.out)
|
73
|
-
raise error unless output.key?("dependencies")
|
74
|
-
|
75
|
-
library_version_from_npm_list(output, library_name)
|
76
|
-
rescue JSON::ParserError
|
77
|
-
raise error
|
78
|
-
end
|
79
|
-
|
80
|
-
def library_version_from_npm_list(output, library_name)
|
81
|
-
output.dig("dependencies", library_name, "version").tap do |version|
|
82
|
-
raise Errors::APILibraryNotFoundError, library_name unless version
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def compile
|
87
|
-
check_compilation_dependencies!
|
88
|
-
run_cmd_with_env_check(SCRIPT_SDK_BUILD)
|
89
|
-
run_cmd_with_env_check(GEN_METADATA)
|
90
|
-
end
|
91
|
-
|
92
|
-
def check_compilation_dependencies!
|
93
|
-
pkg = JSON.parse(File.read("package.json"))
|
94
|
-
build_script = pkg.dig("scripts", "build")
|
95
|
-
|
96
|
-
raise Errors::BuildScriptNotFoundError,
|
97
|
-
"Build script not found" if build_script.nil?
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,32 +0,0 @@
|
|
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 = "build/index.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
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class PushPackageRepository
|
7
|
-
include SmartProperties
|
8
|
-
property! :ctx, accepts: ShopifyCLI::Context
|
9
|
-
|
10
|
-
def get_push_package(script_project:, metadata:, library:)
|
11
|
-
build_file_path = file_path(script_project.id)
|
12
|
-
raise Domain::Errors::PushPackageNotFoundError unless ctx.file_exist?(build_file_path)
|
13
|
-
|
14
|
-
script_content = ctx.binread(build_file_path)
|
15
|
-
Domain::PushPackage.new(
|
16
|
-
id: build_file_path,
|
17
|
-
uuid: script_project.uuid,
|
18
|
-
extension_point_type: script_project.extension_point_type,
|
19
|
-
title: script_project.title,
|
20
|
-
description: script_project.description,
|
21
|
-
script_content: script_content,
|
22
|
-
metadata: metadata,
|
23
|
-
script_config: script_project.script_config,
|
24
|
-
library: library
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def file_path(path_to_script)
|
31
|
-
"#{path_to_script}/build/index.wasm"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|