shopify-cli 1.12.0 → 1.13.0
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/PULL_REQUEST_TEMPLATE.md +1 -1
- data/.github/workflows/release.yml +2 -4
- data/CHANGELOG.md +7 -0
- data/lib/project_types/extension/features/argo_runtime.rb +0 -3
- data/lib/project_types/extension/features/argo_serve.rb +0 -3
- data/lib/project_types/extension/models/specification_handlers/default.rb +0 -10
- data/lib/project_types/script/cli.rb +12 -12
- data/lib/project_types/script/config/extension_points.yml +0 -3
- data/lib/project_types/script/layers/application/create_script.rb +2 -2
- data/lib/project_types/script/layers/application/push_script.rb +2 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +97 -0
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +103 -0
- data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +26 -0
- data/lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb +73 -0
- data/lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb +60 -0
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +21 -0
- data/lib/shopify-cli/admin_api.rb +7 -4
- data/lib/shopify-cli/messages/messages.rb +1 -0
- data/lib/shopify-cli/partners_api.rb +7 -4
- data/lib/shopify-cli/resources/env_file.rb +1 -1
- data/lib/shopify-cli/version.rb +1 -1
- metadata +8 -8
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +0 -95
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +0 -101
- data/lib/project_types/script/layers/infrastructure/project_creator.rb +0 -24
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +0 -71
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +0 -58
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efb6500804d976bce67276002bd2e95343cc080c7278fc7c510017676abb24a0
|
4
|
+
data.tar.gz: 3f0ab9095319fb4743fb37d19db43195c4fd4c737122ceada5958c00bad01b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27cf1b9e1256bb8732fbc291eb423a26ec1570e79cd960c9cc508e387ca58edeb5559680183f5a94009255b17f970e78ed4e1aee591f2782a29be2b9ab9b79b2
|
7
|
+
data.tar.gz: d6e489fc945ce4f27f3800238ff62b24b23073debfe29e48a196c972f7c7ebb34cea7f0affe7d7d326e48573e6df61c7ff68d062e261e83844fbd72cb0ce29ab
|
@@ -29,4 +29,4 @@ Fixes #0000 <!-- link to issue if one exists -->
|
|
29
29
|
-->
|
30
30
|
- [ ] I've added a CHANGELOG entry for this PR (if the change is public-facing)
|
31
31
|
- [ ] I've considered possible cross-platform impacts (Mac, Linux, Windows).
|
32
|
-
- [ ] I've left the version number as is (we'll handle
|
32
|
+
- [ ] I've left the version number as is (we'll handle incrementing this when releasing).
|
@@ -15,12 +15,10 @@ jobs:
|
|
15
15
|
- uses: actions/checkout@v2
|
16
16
|
|
17
17
|
- name: Set up Ruby
|
18
|
-
uses:
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
19
|
with:
|
20
20
|
ruby-version: 2.6
|
21
|
-
|
22
|
-
- name: Install dependencies
|
23
|
-
run: bundle install
|
21
|
+
bundler-cache: true
|
24
22
|
|
25
23
|
- name: Create package
|
26
24
|
run: bundle exec rake package
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
Unreleased
|
2
2
|
------
|
3
3
|
|
4
|
+
Version 1.13.0
|
5
|
+
--------------
|
6
|
+
|
7
|
+
* [1266](https://github.com/Shopify/shopify-app-cli/pull/1266): Developer Console release
|
8
|
+
* [1265](https://github.com/Shopify/shopify-app-cli/pull/1265): Fix bug where commands hang after an unsuccessful authentication
|
9
|
+
|
4
10
|
Version 1.12.0
|
5
11
|
--------------
|
6
12
|
* [1255](https://github.com/Shopify/shopify-app-cli/pull/1255): Fix beta flag checks when running `shopify serve`
|
@@ -12,6 +18,7 @@ Version 1.11.0
|
|
12
18
|
* [#1225](https://github.com/Shopify/shopify-app-cli/pull/1225): Improved handling of "account not found" scenario, plus improvements to related tests and UX messaging
|
13
19
|
* [#1229](https://github.com/Shopify/shopify-app-cli/pull/1229): Allows Checkout Extensions to specify configuration attributes in their extension.config.yml file.
|
14
20
|
* [#1238](https://github.com/Shopify/shopify-app-cli/pull/1238): Auto Tunnel Support for Checkout Extension
|
21
|
+
* [#1256](https://github.com/Shopify/shopify-app-cli/pull/1256): Allow using spaces around the equal sign on .env file.
|
15
22
|
|
16
23
|
Version 1.10.0
|
17
24
|
--------------
|
@@ -12,7 +12,6 @@ module Extension
|
|
12
12
|
|
13
13
|
property! :renderer, accepts: Models::NpmPackage
|
14
14
|
property! :cli, accepts: Models::NpmPackage
|
15
|
-
property :beta_access, accepts: Array, default: -> { [] }
|
16
15
|
|
17
16
|
def accepts_port?
|
18
17
|
case cli
|
@@ -51,7 +50,6 @@ module Extension
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def accepts_shop?
|
54
|
-
return false unless beta_access.include?(:argo_admin_beta)
|
55
53
|
case cli
|
56
54
|
when admin?
|
57
55
|
cli >= ARGO_ADMIN_CLI_0_11_0
|
@@ -61,7 +59,6 @@ module Extension
|
|
61
59
|
end
|
62
60
|
|
63
61
|
def accepts_api_key?
|
64
|
-
return false unless beta_access.include?(:argo_admin_beta)
|
65
62
|
case cli
|
66
63
|
when admin?
|
67
64
|
cli >= ARGO_ADMIN_CLI_0_11_0
|
@@ -8,7 +8,6 @@ module Extension
|
|
8
8
|
property! :context, accepts: ShopifyCli::Context
|
9
9
|
property! :port, accepts: Integer, default: 39351
|
10
10
|
property :tunnel_url, accepts: String, default: ""
|
11
|
-
property :beta_access, accepts: Array, default: -> { [] }
|
12
11
|
|
13
12
|
def call
|
14
13
|
validate_env!
|
@@ -61,8 +60,6 @@ module Extension
|
|
61
60
|
|
62
61
|
return if required_fields.none?
|
63
62
|
|
64
|
-
return unless beta_access.include?(:argo_admin_beta)
|
65
|
-
|
66
63
|
ShopifyCli::Tasks::EnsureEnv.call(context, required: required_fields)
|
67
64
|
ShopifyCli::Tasks::EnsureDevStore.call(context) if required_fields.include?(:shop)
|
68
65
|
|
@@ -57,7 +57,6 @@ module Extension
|
|
57
57
|
context: context,
|
58
58
|
port: port,
|
59
59
|
tunnel_url: tunnel_url,
|
60
|
-
beta_access: beta_access
|
61
60
|
).call
|
62
61
|
end
|
63
62
|
|
@@ -69,18 +68,9 @@ module Extension
|
|
69
68
|
@argo_runtime ||= Features::ArgoRuntime.new(
|
70
69
|
renderer: renderer_package(context),
|
71
70
|
cli: cli_package(context),
|
72
|
-
beta_access: beta_access
|
73
71
|
)
|
74
72
|
end
|
75
73
|
|
76
|
-
def beta_access
|
77
|
-
argo_admin_beta? ? [:argo_admin_beta] : []
|
78
|
-
end
|
79
|
-
|
80
|
-
def argo_admin_beta?
|
81
|
-
ShopifyCli::Shopifolk.check && ShopifyCli::Feature.enabled?(:argo_admin_beta)
|
82
|
-
end
|
83
|
-
|
84
74
|
def cli_package(context)
|
85
75
|
cli_package_name = specification.features.argo&.cli_package_name
|
86
76
|
return unless cli_package_name
|
@@ -48,23 +48,23 @@ module Script
|
|
48
48
|
|
49
49
|
module Infrastructure
|
50
50
|
autoload :Errors, Project.project_filepath("layers/infrastructure/errors")
|
51
|
-
autoload :AssemblyScriptDependencyManager,
|
52
|
-
Project.project_filepath("layers/infrastructure/assemblyscript_dependency_manager")
|
53
|
-
autoload :AssemblyScriptProjectCreator,
|
54
|
-
Project.project_filepath("layers/infrastructure/assemblyscript_project_creator")
|
55
|
-
autoload :AssemblyScriptTaskRunner, Project.project_filepath("layers/infrastructure/assemblyscript_task_runner")
|
56
|
-
autoload :AssemblyScriptTsConfig, Project.project_filepath("layers/infrastructure/assemblyscript_tsconfig")
|
57
51
|
autoload :CommandRunner, Project.project_filepath("layers/infrastructure/command_runner")
|
58
|
-
autoload :RustProjectCreator,
|
59
|
-
Project.project_filepath("layers/infrastructure/rust_project_creator.rb")
|
60
|
-
autoload :RustTaskRunner, Project.project_filepath("layers/infrastructure/rust_task_runner")
|
61
|
-
|
62
52
|
autoload :PushPackageRepository, Project.project_filepath("layers/infrastructure/push_package_repository")
|
63
53
|
autoload :ExtensionPointRepository, Project.project_filepath("layers/infrastructure/extension_point_repository")
|
64
|
-
autoload :ProjectCreator, Project.project_filepath("layers/infrastructure/project_creator")
|
65
54
|
autoload :ScriptProjectRepository, Project.project_filepath("layers/infrastructure/script_project_repository")
|
66
55
|
autoload :ScriptService, Project.project_filepath("layers/infrastructure/script_service")
|
67
|
-
|
56
|
+
|
57
|
+
module Languages
|
58
|
+
autoload :AssemblyScriptProjectCreator,
|
59
|
+
Project.project_filepath("layers/infrastructure/languages/assemblyscript_project_creator")
|
60
|
+
autoload :AssemblyScriptTaskRunner,
|
61
|
+
Project.project_filepath("layers/infrastructure/languages/assemblyscript_task_runner")
|
62
|
+
autoload :ProjectCreator, Project.project_filepath("layers/infrastructure/languages/project_creator")
|
63
|
+
autoload :RustProjectCreator,
|
64
|
+
Project.project_filepath("layers/infrastructure/languages/rust_project_creator.rb")
|
65
|
+
autoload :RustTaskRunner, Project.project_filepath("layers/infrastructure/languages/rust_task_runner")
|
66
|
+
autoload :TaskRunner, Project.project_filepath("layers/infrastructure/languages/task_runner")
|
67
|
+
end
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -36,11 +36,8 @@ payment_methods:
|
|
36
36
|
assemblyscript:
|
37
37
|
package: "@shopify/scripts-checkout-apis"
|
38
38
|
toolchain-version: "^5.0.0"
|
39
|
-
sdk-version: "^9.0.0"
|
40
39
|
shipping_methods:
|
41
40
|
domain: 'checkout'
|
42
41
|
assemblyscript:
|
43
42
|
package: "@shopify/scripts-checkout-apis"
|
44
|
-
sdk-version: "^9.0.0"
|
45
43
|
toolchain-version: "^5.0.0"
|
46
|
-
|
@@ -18,7 +18,7 @@ module Script
|
|
18
18
|
language: language,
|
19
19
|
no_config_ui: no_config_ui
|
20
20
|
)
|
21
|
-
project_creator = Infrastructure::ProjectCreator
|
21
|
+
project_creator = Infrastructure::Languages::ProjectCreator
|
22
22
|
.for(ctx, language, extension_point, script_name, project.id)
|
23
23
|
install_dependencies(ctx, language, script_name, project_creator)
|
24
24
|
bootstrap(ctx, project_creator)
|
@@ -29,7 +29,7 @@ module Script
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def install_dependencies(ctx, language, script_name, project_creator)
|
32
|
-
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name)
|
32
|
+
task_runner = Infrastructure::Languages::TaskRunner.for(ctx, language, script_name)
|
33
33
|
project_creator.setup_dependencies
|
34
34
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
35
35
|
end
|
@@ -8,7 +8,8 @@ module Script
|
|
8
8
|
def call(ctx:, force:)
|
9
9
|
script_project_repo = Infrastructure::ScriptProjectRepository.new(ctx: ctx)
|
10
10
|
script_project = script_project_repo.get
|
11
|
-
task_runner = Infrastructure::TaskRunner
|
11
|
+
task_runner = Infrastructure::Languages::TaskRunner
|
12
|
+
.for(ctx, script_project.language, script_project.script_name)
|
12
13
|
|
13
14
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
14
15
|
BuildScript.call(ctx: ctx, task_runner: task_runner, script_project: script_project)
|
data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
module Languages
|
7
|
+
class AssemblyScriptProjectCreator
|
8
|
+
include SmartProperties
|
9
|
+
property! :ctx, accepts: ShopifyCli::Context
|
10
|
+
property! :extension_point, accepts: Domain::ExtensionPoint
|
11
|
+
property! :script_name, accepts: String
|
12
|
+
property! :path_to_project, accepts: String
|
13
|
+
|
14
|
+
BOOTSTRAP = "npx --no-install shopify-scripts-toolchain-as bootstrap --from %{extension_point} --dest %{base}"
|
15
|
+
BUILD = "shopify-scripts-toolchain-as build --src src/shopify_main.ts " \
|
16
|
+
"--binary build/script.wasm --metadata build/metadata.json"
|
17
|
+
MIN_NODE_VERSION = "14.5.0"
|
18
|
+
ASC_ARGS = "-- --lib node_modules --optimize --use Date="
|
19
|
+
|
20
|
+
def setup_dependencies
|
21
|
+
write_npmrc
|
22
|
+
write_package_json
|
23
|
+
end
|
24
|
+
|
25
|
+
def bootstrap
|
26
|
+
command_runner.call(bootstap_command)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def command_runner
|
32
|
+
@command_runner ||= CommandRunner.new(ctx: ctx)
|
33
|
+
end
|
34
|
+
|
35
|
+
def write_npmrc
|
36
|
+
command_runner.call("npm --userconfig ./.npmrc config set @shopify:registry https://registry.npmjs.com")
|
37
|
+
command_runner.call("npm --userconfig ./.npmrc config set engine-strict true")
|
38
|
+
end
|
39
|
+
|
40
|
+
def extension_point_version
|
41
|
+
return extension_point.sdks.assemblyscript.version if extension_point.sdks.assemblyscript.versioned?
|
42
|
+
|
43
|
+
out = command_runner.call("npm show #{extension_point.sdks.assemblyscript.package} version --json")
|
44
|
+
"^#{JSON.parse(out)}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def write_package_json
|
48
|
+
package_json = <<~HERE
|
49
|
+
{
|
50
|
+
"name": "#{script_name}",
|
51
|
+
"version": "1.0.0",
|
52
|
+
"devDependencies": {
|
53
|
+
"@shopify/scripts-sdk-as": "#{extension_point.sdks.assemblyscript.sdk_version}",
|
54
|
+
"@shopify/scripts-toolchain-as": "#{extension_point.sdks.assemblyscript.toolchain_version}",
|
55
|
+
"#{extension_point.sdks.assemblyscript.package}": "#{extension_point_version}",
|
56
|
+
"@as-pect/cli": "^6.0.0",
|
57
|
+
"assemblyscript": "^0.18.13"
|
58
|
+
},
|
59
|
+
"scripts": {
|
60
|
+
"test": "asp --summary --verbose",
|
61
|
+
"build": "#{build_command}"
|
62
|
+
},
|
63
|
+
"engines": {
|
64
|
+
"node": ">=#{MIN_NODE_VERSION}"
|
65
|
+
}
|
66
|
+
}
|
67
|
+
HERE
|
68
|
+
ctx.write("package.json", package_json)
|
69
|
+
end
|
70
|
+
|
71
|
+
def bootstap_command
|
72
|
+
type = extension_point.dasherize_type
|
73
|
+
base_command = format(BOOTSTRAP, extension_point: type, base: path_to_project)
|
74
|
+
domain = extension_point.domain
|
75
|
+
|
76
|
+
if domain.nil?
|
77
|
+
base_command
|
78
|
+
else
|
79
|
+
"#{base_command} --domain #{domain}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def build_command
|
84
|
+
type = extension_point.dasherize_type
|
85
|
+
domain = extension_point.domain
|
86
|
+
|
87
|
+
if domain.nil?
|
88
|
+
"#{BUILD} #{ASC_ARGS}"
|
89
|
+
else
|
90
|
+
"#{BUILD} --domain #{domain} --ep #{type} #{ASC_ARGS}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
module Languages
|
7
|
+
class AssemblyScriptTaskRunner
|
8
|
+
BYTECODE_FILE = "build/%{name}.wasm"
|
9
|
+
METADATA_FILE = "build/metadata.json"
|
10
|
+
SCRIPT_SDK_BUILD = "npm run build"
|
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
|
+
def build
|
20
|
+
compile
|
21
|
+
bytecode
|
22
|
+
end
|
23
|
+
|
24
|
+
def compiled_type
|
25
|
+
"wasm"
|
26
|
+
end
|
27
|
+
|
28
|
+
def install_dependencies
|
29
|
+
check_node_version!
|
30
|
+
|
31
|
+
output, status = ctx.capture2e("npm install --no-audit --no-optional --legacy-peer-deps --loglevel error")
|
32
|
+
raise Errors::DependencyInstallError, output unless status.success?
|
33
|
+
end
|
34
|
+
|
35
|
+
def dependencies_installed?
|
36
|
+
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
37
|
+
ctx.dir_exist?("node_modules")
|
38
|
+
end
|
39
|
+
|
40
|
+
def metadata
|
41
|
+
unless @ctx.file_exist?(METADATA_FILE)
|
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)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def check_node_version!
|
53
|
+
output, status = @ctx.capture2e("node", "--version")
|
54
|
+
raise Errors::DependencyInstallError, output unless status.success?
|
55
|
+
|
56
|
+
require "semantic/semantic"
|
57
|
+
version = ::Semantic::Version.new(output[1..-1])
|
58
|
+
unless version >= ::Semantic::Version.new(AssemblyScriptProjectCreator::MIN_NODE_VERSION)
|
59
|
+
raise Errors::DependencyInstallError,
|
60
|
+
"Node version must be >= v#{AssemblyScriptProjectCreator::MIN_NODE_VERSION}. "\
|
61
|
+
"Current version: #{output.strip}."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def compile
|
66
|
+
check_compilation_dependencies!
|
67
|
+
CommandRunner.new(ctx: ctx).call(SCRIPT_SDK_BUILD)
|
68
|
+
end
|
69
|
+
|
70
|
+
def check_compilation_dependencies!
|
71
|
+
pkg = JSON.parse(File.read("package.json"))
|
72
|
+
build_script = pkg.dig("scripts", "build")
|
73
|
+
|
74
|
+
raise Errors::BuildScriptNotFoundError,
|
75
|
+
"Build script not found" if build_script.nil?
|
76
|
+
|
77
|
+
unless build_script.start_with?("shopify-scripts")
|
78
|
+
raise Errors::InvalidBuildScriptError, "Invalid build script"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def bytecode
|
83
|
+
legacy_filename = format(BYTECODE_FILE, name: script_name)
|
84
|
+
filename = format(BYTECODE_FILE, name: "script")
|
85
|
+
|
86
|
+
bytecode_file = if ctx.file_exist?(filename)
|
87
|
+
filename
|
88
|
+
elsif ctx.file_exist?(legacy_filename)
|
89
|
+
legacy_filename
|
90
|
+
else
|
91
|
+
raise Errors::WebAssemblyBinaryNotFoundError
|
92
|
+
end
|
93
|
+
|
94
|
+
contents = ctx.binread(bytecode_file)
|
95
|
+
ctx.rm(bytecode_file)
|
96
|
+
|
97
|
+
contents
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
module Languages
|
7
|
+
class ProjectCreator
|
8
|
+
PROJECT_CREATORS = {
|
9
|
+
"assemblyscript" => AssemblyScriptProjectCreator,
|
10
|
+
"rust" => RustProjectCreator,
|
11
|
+
}
|
12
|
+
|
13
|
+
def self.for(ctx, language, extension_point, script_name, path_to_project)
|
14
|
+
raise Errors::ProjectCreatorNotFoundError unless PROJECT_CREATORS[language]
|
15
|
+
PROJECT_CREATORS[language].new(
|
16
|
+
ctx: ctx,
|
17
|
+
extension_point: extension_point,
|
18
|
+
script_name: script_name,
|
19
|
+
path_to_project: path_to_project
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
module Languages
|
7
|
+
class RustProjectCreator
|
8
|
+
include SmartProperties
|
9
|
+
property! :ctx, accepts: ShopifyCli::Context
|
10
|
+
property! :extension_point, accepts: Domain::ExtensionPoint
|
11
|
+
property! :script_name, accepts: String
|
12
|
+
property! :path_to_project, accepts: String
|
13
|
+
|
14
|
+
ORIGIN_BRANCH = "main"
|
15
|
+
SAMPLE_PATH = "default"
|
16
|
+
|
17
|
+
def setup_dependencies
|
18
|
+
git_init
|
19
|
+
setup_remote
|
20
|
+
setup_sparse_checkout
|
21
|
+
pull
|
22
|
+
clean
|
23
|
+
set_script_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def bootstrap
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def command_runner
|
32
|
+
@command_runner ||= CommandRunner.new(ctx: ctx)
|
33
|
+
end
|
34
|
+
|
35
|
+
def git_init
|
36
|
+
command_runner.call("git init")
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup_remote
|
40
|
+
repo = extension_point.sdks.rust.package
|
41
|
+
command_runner.call("git remote add -f origin #{repo}")
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_sparse_checkout
|
45
|
+
type = extension_point.type
|
46
|
+
command_runner.call("git config core.sparsecheckout true")
|
47
|
+
command_runner.call("echo #{type}/#{SAMPLE_PATH} >> .git/info/sparse-checkout")
|
48
|
+
end
|
49
|
+
|
50
|
+
def pull
|
51
|
+
command_runner.call("git pull origin #{ORIGIN_BRANCH}")
|
52
|
+
end
|
53
|
+
|
54
|
+
def clean
|
55
|
+
type = extension_point.type
|
56
|
+
ctx.rm_rf(".git")
|
57
|
+
source = File.join(path_to_project, File.join(type, SAMPLE_PATH))
|
58
|
+
FileUtils.copy_entry(source, path_to_project)
|
59
|
+
ctx.rm_rf(type)
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_script_name
|
63
|
+
config_file = "Cargo.toml"
|
64
|
+
upstream_name = "#{extension_point.type.gsub("_", "-")}-default"
|
65
|
+
contents = File.read(config_file)
|
66
|
+
new_contents = contents.sub(upstream_name, script_name)
|
67
|
+
File.write(config_file, new_contents)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Script
|
3
|
+
module Layers
|
4
|
+
module Infrastructure
|
5
|
+
module Languages
|
6
|
+
class RustTaskRunner
|
7
|
+
attr_reader :ctx
|
8
|
+
|
9
|
+
BUILD_TARGET = "wasm32-unknown-unknown"
|
10
|
+
METADATA_FILE = "build/metadata.json"
|
11
|
+
CARGO_BUILD_CMD = "cargo build --target=#{BUILD_TARGET} --release"
|
12
|
+
|
13
|
+
def initialize(ctx, _)
|
14
|
+
@ctx = ctx
|
15
|
+
end
|
16
|
+
|
17
|
+
def dependencies_installed?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def install_dependencies
|
22
|
+
end
|
23
|
+
|
24
|
+
def build
|
25
|
+
compile
|
26
|
+
bytecode
|
27
|
+
end
|
28
|
+
|
29
|
+
def compiled_type
|
30
|
+
"wasm"
|
31
|
+
end
|
32
|
+
|
33
|
+
def metadata
|
34
|
+
unless @ctx.file_exist?(METADATA_FILE)
|
35
|
+
msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
|
36
|
+
raise Domain::Errors::MetadataNotFoundError, msg
|
37
|
+
end
|
38
|
+
|
39
|
+
raw_contents = File.read(METADATA_FILE)
|
40
|
+
Domain::Metadata.create_from_json(@ctx, raw_contents)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def compile
|
46
|
+
CommandRunner.new(ctx: ctx).call(CARGO_BUILD_CMD)
|
47
|
+
end
|
48
|
+
|
49
|
+
def bytecode
|
50
|
+
binary_name = "script.wasm"
|
51
|
+
binary_path = "target/#{BUILD_TARGET}/release/#{binary_name}"
|
52
|
+
raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(binary_path)
|
53
|
+
|
54
|
+
ctx.binread(binary_path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Infrastructure
|
6
|
+
module Languages
|
7
|
+
class TaskRunner
|
8
|
+
TASK_RUNNERS = {
|
9
|
+
"assemblyscript" => AssemblyScriptTaskRunner,
|
10
|
+
"rust" => RustTaskRunner,
|
11
|
+
}
|
12
|
+
|
13
|
+
def self.for(ctx, language, script_name)
|
14
|
+
raise Errors::TaskRunnerNotFoundError unless TASK_RUNNERS[language]
|
15
|
+
TASK_RUNNERS[language].new(ctx, script_name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -85,11 +85,14 @@ module ShopifyCli
|
|
85
85
|
|
86
86
|
private
|
87
87
|
|
88
|
-
def authenticated_req(ctx, shop)
|
89
|
-
|
88
|
+
def authenticated_req(ctx, shop, &block)
|
89
|
+
CLI::Kit::Util
|
90
|
+
.begin(&block)
|
91
|
+
.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
92
|
+
authenticate(ctx, shop)
|
93
|
+
end
|
90
94
|
rescue API::APIRequestUnauthorizedError
|
91
|
-
|
92
|
-
retry
|
95
|
+
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
93
96
|
end
|
94
97
|
|
95
98
|
def authenticate(ctx, shop)
|
@@ -184,6 +184,7 @@ module ShopifyCli
|
|
184
184
|
|
185
185
|
api: {
|
186
186
|
error: {
|
187
|
+
failed_auth: "Failed to authenticate with Shopify. Please try again later.",
|
187
188
|
internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
|
188
189
|
internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
|
189
190
|
invalid_url: "Invalid URL: %s",
|
@@ -59,11 +59,14 @@ module ShopifyCli
|
|
59
59
|
|
60
60
|
private
|
61
61
|
|
62
|
-
def authenticated_req(ctx)
|
63
|
-
|
62
|
+
def authenticated_req(ctx, &block)
|
63
|
+
CLI::Kit::Util
|
64
|
+
.begin(&block)
|
65
|
+
.retry_after(API::APIRequestUnauthorizedError, retries: 1) do
|
66
|
+
authenticate(ctx)
|
67
|
+
end
|
64
68
|
rescue API::APIRequestUnauthorizedError
|
65
|
-
|
66
|
-
retry
|
69
|
+
ctx.abort(ctx.message("core.api.error.failed_auth"))
|
67
70
|
rescue API::APIRequestNotFoundError
|
68
71
|
ctx.puts(ctx.message("core.partners_api.error.account_not_found", ShopifyCli::TOOL_NAME))
|
69
72
|
end
|
@@ -22,7 +22,7 @@ module ShopifyCli
|
|
22
22
|
def parse(directory)
|
23
23
|
File.read(File.join(directory, FILENAME))
|
24
24
|
.gsub("\r\n", "\n").split("\n").each_with_object({}) do |line, output|
|
25
|
-
match = /\A([A-Za-z_0-9]+)
|
25
|
+
match = /\A([A-Za-z_0-9]+)\s*=\s*(.*)\z/.match(line)
|
26
26
|
if match
|
27
27
|
key = match[1]
|
28
28
|
output[key] = case match[2]
|
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.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -233,18 +233,18 @@ files:
|
|
233
233
|
- lib/project_types/script/layers/domain/metadata.rb
|
234
234
|
- lib/project_types/script/layers/domain/push_package.rb
|
235
235
|
- lib/project_types/script/layers/domain/script_project.rb
|
236
|
-
- lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb
|
237
|
-
- lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb
|
238
236
|
- lib/project_types/script/layers/infrastructure/command_runner.rb
|
239
237
|
- lib/project_types/script/layers/infrastructure/errors.rb
|
240
238
|
- lib/project_types/script/layers/infrastructure/extension_point_repository.rb
|
241
|
-
- lib/project_types/script/layers/infrastructure/
|
239
|
+
- lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb
|
240
|
+
- lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb
|
241
|
+
- lib/project_types/script/layers/infrastructure/languages/project_creator.rb
|
242
|
+
- lib/project_types/script/layers/infrastructure/languages/rust_project_creator.rb
|
243
|
+
- lib/project_types/script/layers/infrastructure/languages/rust_task_runner.rb
|
244
|
+
- lib/project_types/script/layers/infrastructure/languages/task_runner.rb
|
242
245
|
- lib/project_types/script/layers/infrastructure/push_package_repository.rb
|
243
|
-
- lib/project_types/script/layers/infrastructure/rust_project_creator.rb
|
244
|
-
- lib/project_types/script/layers/infrastructure/rust_task_runner.rb
|
245
246
|
- lib/project_types/script/layers/infrastructure/script_project_repository.rb
|
246
247
|
- lib/project_types/script/layers/infrastructure/script_service.rb
|
247
|
-
- lib/project_types/script/layers/infrastructure/task_runner.rb
|
248
248
|
- lib/project_types/script/messages/messages.rb
|
249
249
|
- lib/project_types/script/tasks/ensure_env.rb
|
250
250
|
- lib/project_types/script/ui/error_handler.rb
|
@@ -1,95 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class AssemblyScriptProjectCreator
|
7
|
-
include SmartProperties
|
8
|
-
property! :ctx, accepts: ShopifyCli::Context
|
9
|
-
property! :extension_point, accepts: Domain::ExtensionPoint
|
10
|
-
property! :script_name, accepts: String
|
11
|
-
property! :path_to_project, accepts: String
|
12
|
-
|
13
|
-
BOOTSTRAP = "npx --no-install shopify-scripts-toolchain-as bootstrap --from %{extension_point} --dest %{base}"
|
14
|
-
BUILD = "shopify-scripts-toolchain-as build --src src/shopify_main.ts " \
|
15
|
-
"--binary build/script.wasm --metadata build/metadata.json"
|
16
|
-
MIN_NODE_VERSION = "14.5.0"
|
17
|
-
ASC_ARGS = "-- --lib node_modules --optimize --use Date="
|
18
|
-
|
19
|
-
def setup_dependencies
|
20
|
-
write_npmrc
|
21
|
-
write_package_json
|
22
|
-
end
|
23
|
-
|
24
|
-
def bootstrap
|
25
|
-
command_runner.call(bootstap_command)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def command_runner
|
31
|
-
@command_runner ||= CommandRunner.new(ctx: ctx)
|
32
|
-
end
|
33
|
-
|
34
|
-
def write_npmrc
|
35
|
-
command_runner.call("npm --userconfig ./.npmrc config set @shopify:registry https://registry.npmjs.com")
|
36
|
-
command_runner.call("npm --userconfig ./.npmrc config set engine-strict true")
|
37
|
-
end
|
38
|
-
|
39
|
-
def extension_point_version
|
40
|
-
return extension_point.sdks.assemblyscript.version if extension_point.sdks.assemblyscript.versioned?
|
41
|
-
|
42
|
-
out = command_runner.call("npm show #{extension_point.sdks.assemblyscript.package} version --json")
|
43
|
-
"^#{JSON.parse(out)}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def write_package_json
|
47
|
-
package_json = <<~HERE
|
48
|
-
{
|
49
|
-
"name": "#{script_name}",
|
50
|
-
"version": "1.0.0",
|
51
|
-
"devDependencies": {
|
52
|
-
"@shopify/scripts-sdk-as": "#{extension_point.sdks.assemblyscript.sdk_version}",
|
53
|
-
"@shopify/scripts-toolchain-as": "#{extension_point.sdks.assemblyscript.toolchain_version}",
|
54
|
-
"#{extension_point.sdks.assemblyscript.package}": "#{extension_point_version}",
|
55
|
-
"@as-pect/cli": "^6.0.0",
|
56
|
-
"assemblyscript": "^0.18.13"
|
57
|
-
},
|
58
|
-
"scripts": {
|
59
|
-
"test": "asp --summary --verbose",
|
60
|
-
"build": "#{build_command}"
|
61
|
-
},
|
62
|
-
"engines": {
|
63
|
-
"node": ">=#{MIN_NODE_VERSION}"
|
64
|
-
}
|
65
|
-
}
|
66
|
-
HERE
|
67
|
-
ctx.write("package.json", package_json)
|
68
|
-
end
|
69
|
-
|
70
|
-
def bootstap_command
|
71
|
-
type = extension_point.dasherize_type
|
72
|
-
base_command = format(BOOTSTRAP, extension_point: type, base: path_to_project)
|
73
|
-
domain = extension_point.domain
|
74
|
-
|
75
|
-
if domain.nil?
|
76
|
-
base_command
|
77
|
-
else
|
78
|
-
"#{base_command} --domain #{domain}"
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def build_command
|
83
|
-
type = extension_point.dasherize_type
|
84
|
-
domain = extension_point.domain
|
85
|
-
|
86
|
-
if domain.nil?
|
87
|
-
"#{BUILD} #{ASC_ARGS}"
|
88
|
-
else
|
89
|
-
"#{BUILD} --domain #{domain} --ep #{type} #{ASC_ARGS}"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class AssemblyScriptTaskRunner
|
7
|
-
BYTECODE_FILE = "build/%{name}.wasm"
|
8
|
-
METADATA_FILE = "build/metadata.json"
|
9
|
-
SCRIPT_SDK_BUILD = "npm run build"
|
10
|
-
|
11
|
-
attr_reader :ctx, :script_name
|
12
|
-
|
13
|
-
def initialize(ctx, script_name)
|
14
|
-
@ctx = ctx
|
15
|
-
@script_name = script_name
|
16
|
-
end
|
17
|
-
|
18
|
-
def build
|
19
|
-
compile
|
20
|
-
bytecode
|
21
|
-
end
|
22
|
-
|
23
|
-
def compiled_type
|
24
|
-
"wasm"
|
25
|
-
end
|
26
|
-
|
27
|
-
def install_dependencies
|
28
|
-
check_node_version!
|
29
|
-
|
30
|
-
output, status = ctx.capture2e("npm install --no-audit --no-optional --legacy-peer-deps --loglevel error")
|
31
|
-
raise Errors::DependencyInstallError, output unless status.success?
|
32
|
-
end
|
33
|
-
|
34
|
-
def dependencies_installed?
|
35
|
-
# Assuming if node_modules folder exist at root of script folder, all deps are installed
|
36
|
-
ctx.dir_exist?("node_modules")
|
37
|
-
end
|
38
|
-
|
39
|
-
def metadata
|
40
|
-
unless @ctx.file_exist?(METADATA_FILE)
|
41
|
-
msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
|
42
|
-
raise Domain::Errors::MetadataNotFoundError, msg
|
43
|
-
end
|
44
|
-
|
45
|
-
raw_contents = File.read(METADATA_FILE)
|
46
|
-
Domain::Metadata.create_from_json(@ctx, raw_contents)
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def check_node_version!
|
52
|
-
output, status = @ctx.capture2e("node", "--version")
|
53
|
-
raise Errors::DependencyInstallError, output unless status.success?
|
54
|
-
|
55
|
-
require "semantic/semantic"
|
56
|
-
version = ::Semantic::Version.new(output[1..-1])
|
57
|
-
unless version >= ::Semantic::Version.new(AssemblyScriptProjectCreator::MIN_NODE_VERSION)
|
58
|
-
raise Errors::DependencyInstallError,
|
59
|
-
"Node version must be >= v#{AssemblyScriptProjectCreator::MIN_NODE_VERSION}. "\
|
60
|
-
"Current version: #{output.strip}."
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def compile
|
65
|
-
check_compilation_dependencies!
|
66
|
-
CommandRunner.new(ctx: ctx).call(SCRIPT_SDK_BUILD)
|
67
|
-
end
|
68
|
-
|
69
|
-
def check_compilation_dependencies!
|
70
|
-
pkg = JSON.parse(File.read("package.json"))
|
71
|
-
build_script = pkg.dig("scripts", "build")
|
72
|
-
|
73
|
-
raise Errors::BuildScriptNotFoundError,
|
74
|
-
"Build script not found" if build_script.nil?
|
75
|
-
|
76
|
-
unless build_script.start_with?("shopify-scripts")
|
77
|
-
raise Errors::InvalidBuildScriptError, "Invalid build script"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def bytecode
|
82
|
-
legacy_filename = format(BYTECODE_FILE, name: script_name)
|
83
|
-
filename = format(BYTECODE_FILE, name: "script")
|
84
|
-
|
85
|
-
bytecode_file = if ctx.file_exist?(filename)
|
86
|
-
filename
|
87
|
-
elsif ctx.file_exist?(legacy_filename)
|
88
|
-
legacy_filename
|
89
|
-
else
|
90
|
-
raise Errors::WebAssemblyBinaryNotFoundError
|
91
|
-
end
|
92
|
-
|
93
|
-
contents = ctx.binread(bytecode_file)
|
94
|
-
ctx.rm(bytecode_file)
|
95
|
-
|
96
|
-
contents
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class ProjectCreator
|
7
|
-
PROJECT_CREATORS = {
|
8
|
-
"assemblyscript" => Infrastructure::AssemblyScriptProjectCreator,
|
9
|
-
"rust" => Infrastructure::RustProjectCreator,
|
10
|
-
}
|
11
|
-
|
12
|
-
def self.for(ctx, language, extension_point, script_name, path_to_project)
|
13
|
-
raise Errors::ProjectCreatorNotFoundError unless PROJECT_CREATORS[language]
|
14
|
-
PROJECT_CREATORS[language].new(
|
15
|
-
ctx: ctx,
|
16
|
-
extension_point: extension_point,
|
17
|
-
script_name: script_name,
|
18
|
-
path_to_project: path_to_project
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class RustProjectCreator
|
7
|
-
include SmartProperties
|
8
|
-
property! :ctx, accepts: ShopifyCli::Context
|
9
|
-
property! :extension_point, accepts: Domain::ExtensionPoint
|
10
|
-
property! :script_name, accepts: String
|
11
|
-
property! :path_to_project, accepts: String
|
12
|
-
|
13
|
-
ORIGIN_BRANCH = "main"
|
14
|
-
SAMPLE_PATH = "default"
|
15
|
-
|
16
|
-
def setup_dependencies
|
17
|
-
git_init
|
18
|
-
setup_remote
|
19
|
-
setup_sparse_checkout
|
20
|
-
pull
|
21
|
-
clean
|
22
|
-
set_script_name
|
23
|
-
end
|
24
|
-
|
25
|
-
def bootstrap
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def command_runner
|
31
|
-
@command_runner ||= CommandRunner.new(ctx: ctx)
|
32
|
-
end
|
33
|
-
|
34
|
-
def git_init
|
35
|
-
command_runner.call("git init")
|
36
|
-
end
|
37
|
-
|
38
|
-
def setup_remote
|
39
|
-
repo = extension_point.sdks.rust.package
|
40
|
-
command_runner.call("git remote add -f origin #{repo}")
|
41
|
-
end
|
42
|
-
|
43
|
-
def setup_sparse_checkout
|
44
|
-
type = extension_point.type
|
45
|
-
command_runner.call("git config core.sparsecheckout true")
|
46
|
-
command_runner.call("echo #{type}/#{SAMPLE_PATH} >> .git/info/sparse-checkout")
|
47
|
-
end
|
48
|
-
|
49
|
-
def pull
|
50
|
-
command_runner.call("git pull origin #{ORIGIN_BRANCH}")
|
51
|
-
end
|
52
|
-
|
53
|
-
def clean
|
54
|
-
type = extension_point.type
|
55
|
-
ctx.rm_rf(".git")
|
56
|
-
source = File.join(path_to_project, File.join(type, SAMPLE_PATH))
|
57
|
-
FileUtils.copy_entry(source, path_to_project)
|
58
|
-
ctx.rm_rf(type)
|
59
|
-
end
|
60
|
-
|
61
|
-
def set_script_name
|
62
|
-
config_file = "Cargo.toml"
|
63
|
-
upstream_name = "#{extension_point.type.gsub("_", "-")}-default"
|
64
|
-
contents = File.read(config_file)
|
65
|
-
new_contents = contents.sub(upstream_name, script_name)
|
66
|
-
File.write(config_file, new_contents)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Script
|
3
|
-
module Layers
|
4
|
-
module Infrastructure
|
5
|
-
class RustTaskRunner
|
6
|
-
attr_reader :ctx
|
7
|
-
|
8
|
-
BUILD_TARGET = "wasm32-unknown-unknown"
|
9
|
-
METADATA_FILE = "build/metadata.json"
|
10
|
-
CARGO_BUILD_CMD = "cargo build --target=#{BUILD_TARGET} --release"
|
11
|
-
|
12
|
-
def initialize(ctx, _)
|
13
|
-
@ctx = ctx
|
14
|
-
end
|
15
|
-
|
16
|
-
def dependencies_installed?
|
17
|
-
true
|
18
|
-
end
|
19
|
-
|
20
|
-
def install_dependencies
|
21
|
-
end
|
22
|
-
|
23
|
-
def build
|
24
|
-
compile
|
25
|
-
bytecode
|
26
|
-
end
|
27
|
-
|
28
|
-
def compiled_type
|
29
|
-
"wasm"
|
30
|
-
end
|
31
|
-
|
32
|
-
def metadata
|
33
|
-
unless @ctx.file_exist?(METADATA_FILE)
|
34
|
-
msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
|
35
|
-
raise Domain::Errors::MetadataNotFoundError, msg
|
36
|
-
end
|
37
|
-
|
38
|
-
raw_contents = File.read(METADATA_FILE)
|
39
|
-
Domain::Metadata.create_from_json(@ctx, raw_contents)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def compile
|
45
|
-
CommandRunner.new(ctx: ctx).call(CARGO_BUILD_CMD)
|
46
|
-
end
|
47
|
-
|
48
|
-
def bytecode
|
49
|
-
binary_name = "script.wasm"
|
50
|
-
binary_path = "target/#{BUILD_TARGET}/release/#{binary_name}"
|
51
|
-
raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(binary_path)
|
52
|
-
|
53
|
-
ctx.binread(binary_path)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Script
|
4
|
-
module Layers
|
5
|
-
module Infrastructure
|
6
|
-
class TaskRunner
|
7
|
-
TASK_RUNNERS = {
|
8
|
-
"assemblyscript" => Infrastructure::AssemblyScriptTaskRunner,
|
9
|
-
"rust" => Infrastructure::RustTaskRunner,
|
10
|
-
}
|
11
|
-
|
12
|
-
def self.for(ctx, language, script_name)
|
13
|
-
raise Errors::TaskRunnerNotFoundError unless TASK_RUNNERS[language]
|
14
|
-
TASK_RUNNERS[language].new(ctx, script_name)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|