Class: Script::Layers::Infrastructure::AssemblyScriptTaskRunner
- Inherits:
-
Object
- Object
- Script::Layers::Infrastructure::AssemblyScriptTaskRunner
- Defined in:
- lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb
Constant Summary collapse
- BYTECODE_FILE =
"%{name}.wasm"- SCRIPT_SDK_BUILD =
"npx --no-install shopify-scripts-build --src=../%{source} --binary=#{BYTECODE_FILE} "\ "-- --lib=../node_modules --optimize --use Date="
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#script_name ⇒ Object
readonly
Returns the value of attribute script_name.
-
#script_source_file ⇒ Object
readonly
Returns the value of attribute script_source_file.
Instance Method Summary collapse
- #build ⇒ Object
- #compiled_type ⇒ Object
- #dependencies_installed? ⇒ Boolean
-
#initialize(ctx, script_name, script_source_file) ⇒ AssemblyScriptTaskRunner
constructor
A new instance of AssemblyScriptTaskRunner.
- #install_dependencies ⇒ Object
Constructor Details
#initialize(ctx, script_name, script_source_file) ⇒ AssemblyScriptTaskRunner
Returns a new instance of AssemblyScriptTaskRunner.
13 14 15 16 17 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 13 def initialize(ctx, script_name, script_source_file) @ctx = ctx @script_name = script_name @script_source_file = script_source_file end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
11 12 13 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 11 def ctx @ctx end |
#script_name ⇒ Object (readonly)
Returns the value of attribute script_name.
11 12 13 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 11 def script_name @script_name end |
#script_source_file ⇒ Object (readonly)
Returns the value of attribute script_source_file.
11 12 13 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 11 def script_source_file @script_source_file end |
Instance Method Details
#build ⇒ Object
19 20 21 22 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 19 def build compile bytecode end |
#compiled_type ⇒ Object
24 25 26 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 24 def compiled_type "wasm" end |
#dependencies_installed? ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 35 def dependencies_installed? # Assuming if node_modules folder exist at root of script folder, all deps are installed return false unless ctx.dir_exist?("node_modules") check_if_ep_dependencies_up_to_date! true end |
#install_dependencies ⇒ Object
28 29 30 31 32 33 |
# File 'lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb', line 28 def install_dependencies check_node_version! output, status = ctx.capture2e("npm", "install", "--no-audit", "--no-optional", "--loglevel error") raise Errors::DependencyInstallError, output unless status.success? end |