shopify-cli 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +9 -0
- data/README.md +39 -7
- data/Rakefile +2 -0
- data/dev.yml +2 -2
- data/docs/_config.yml +1 -18
- data/docs/app/node/commands/index.md +2 -80
- data/docs/app/node/index.md +2 -33
- data/docs/app/rails/commands/index.md +2 -78
- data/docs/app/rails/index.md +2 -34
- data/docs/core/index.md +2 -84
- data/docs/getting-started/index.md +2 -25
- data/docs/getting-started/install/index.md +1 -118
- data/docs/getting-started/migrate/index.md +2 -94
- data/docs/getting-started/uninstall/index.md +2 -35
- data/docs/getting-started/upgrade/index.md +2 -39
- data/docs/help/start-app/index.md +2 -4
- data/docs/index.md +2 -24
- data/install.sh +1 -1
- data/lib/project_types/extension/cli.rb +19 -10
- data/lib/project_types/extension/commands/extension_command.rb +2 -2
- data/lib/project_types/extension/features/argo.rb +117 -0
- data/lib/project_types/extension/forms/create.rb +2 -2
- data/lib/project_types/extension/models/specification.rb +35 -0
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +19 -0
- data/lib/project_types/extension/models/specification_handlers/default.rb +67 -0
- data/lib/project_types/extension/models/specifications.rb +77 -0
- data/lib/project_types/extension/tasks/configure_features.rb +52 -0
- data/lib/project_types/extension/tasks/fetch_specifications.rb +38 -0
- data/lib/project_types/node/commands/create.rb +3 -1
- data/lib/project_types/node/commands/generate.rb +2 -11
- data/lib/project_types/node/messages/messages.rb +9 -44
- data/lib/project_types/rails/commands/create.rb +8 -9
- data/lib/project_types/rails/forms/create.rb +1 -1
- data/lib/project_types/rails/gem.rb +1 -1
- data/lib/project_types/rails/messages/messages.rb +1 -1
- data/lib/project_types/script/cli.rb +7 -4
- data/lib/project_types/script/commands/create.rb +6 -4
- data/lib/project_types/script/commands/push.rb +5 -13
- data/lib/project_types/script/config/extension_points.yml +9 -5
- data/lib/project_types/script/errors.rb +17 -0
- data/lib/project_types/script/forms/create.rb +26 -2
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +10 -1
- data/lib/project_types/script/layers/application/build_script.rb +9 -4
- data/lib/project_types/script/layers/application/create_script.rb +12 -10
- data/lib/project_types/script/layers/application/extension_points.rb +24 -0
- data/lib/project_types/script/layers/application/push_script.rb +18 -16
- data/lib/project_types/script/layers/domain/errors.rb +4 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +62 -6
- data/lib/project_types/script/layers/domain/metadata.rb +55 -0
- data/lib/project_types/script/layers/domain/push_package.rb +25 -6
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +6 -6
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +16 -6
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +10 -4
- data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +25 -13
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +72 -0
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +59 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +7 -1
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
- data/lib/project_types/script/messages/messages.rb +39 -8
- data/lib/project_types/script/script_project.rb +25 -16
- data/lib/project_types/script/ui/error_handler.rb +34 -1
- data/lib/project_types/theme/cli.rb +40 -0
- data/lib/project_types/theme/commands/connect.rb +54 -0
- data/lib/project_types/theme/commands/create.rb +48 -0
- data/lib/project_types/theme/commands/deploy.rb +38 -0
- data/lib/project_types/theme/commands/generate.rb +20 -0
- data/lib/project_types/theme/commands/generate/env.rb +79 -0
- data/lib/project_types/theme/commands/push.rb +55 -0
- data/lib/project_types/theme/commands/serve.rb +31 -0
- data/lib/project_types/theme/forms/connect.rb +34 -0
- data/lib/project_types/theme/forms/create.rb +22 -0
- data/lib/project_types/theme/messages/messages.rb +147 -0
- data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +78 -0
- data/lib/project_types/theme/themekit.rb +113 -0
- data/lib/shopify-cli/admin_api.rb +42 -2
- data/lib/shopify-cli/api.rb +27 -24
- data/lib/shopify-cli/commands/system.rb +1 -1
- data/lib/shopify-cli/context.rb +23 -2
- data/lib/shopify-cli/feature.rb +0 -2
- data/lib/shopify-cli/http_request.rb +20 -8
- data/lib/shopify-cli/messages/messages.rb +6 -3
- data/lib/shopify-cli/method_object.rb +104 -0
- data/lib/shopify-cli/partners_api.rb +8 -2
- data/lib/shopify-cli/project_type.rb +1 -1
- data/lib/shopify-cli/resolve_constant.rb +25 -0
- data/lib/shopify-cli/result.rb +432 -0
- data/lib/shopify-cli/shopifolk.rb +3 -2
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -5
- data/lib/shopify-cli/tunnel.rb +7 -1
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +4 -1
- data/shopify.fish +1 -1
- data/shopify.sh +1 -1
- data/vendor/deps/cli-kit/REVISION +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +2 -2
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +3 -3
- data/vendor/deps/cli-ui/REVISION +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui.rb +26 -22
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +4 -6
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -3
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +8 -9
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +15 -3
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +4 -11
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -5
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +10 -10
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +1 -1
- data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
- data/vendor/deps/webrick/.gitignore +9 -0
- data/vendor/deps/webrick/Gemfile +3 -0
- data/vendor/deps/webrick/LICENSE.txt +22 -0
- data/vendor/deps/webrick/README.md +61 -0
- data/vendor/deps/webrick/Rakefile +10 -0
- data/vendor/deps/webrick/lib/webrick.rb +232 -0
- data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
- data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
- data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
- data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
- data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
- data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
- data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
- data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
- data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
- data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
- data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
- data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
- data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
- data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
- data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
- data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
- data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
- data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
- data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
- data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
- data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
- data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
- data/vendor/deps/webrick/webrick.gemspec +74 -0
- metadata +70 -26
- data/docs/Gemfile +0 -5
- data/docs/Gemfile.lock +0 -258
- data/docs/_data/nav.yml +0 -35
- data/docs/_includes/footer.html +0 -15
- data/docs/_includes/head.html +0 -19
- data/docs/_includes/sidebar_nav.html +0 -22
- data/docs/_includes/toc.html +0 -112
- data/docs/_layouts/default.html +0 -79
- data/docs/css/docs.css +0 -157
- data/docs/images/header.png +0 -0
- data/docs/installing-ruby.md +0 -28
- data/lib/project_types/extension/features/argo/admin.rb +0 -20
- data/lib/project_types/extension/features/argo/base.rb +0 -129
- data/lib/project_types/extension/features/argo/checkout.rb +0 -20
- data/lib/project_types/extension/models/type.rb +0 -81
- data/lib/project_types/extension/models/types/checkout_post_purchase.rb +0 -23
- data/lib/project_types/extension/models/types/product_subscription.rb +0 -24
- data/lib/project_types/node/commands/generate/billing.rb +0 -39
- data/lib/project_types/node/commands/generate/page.rb +0 -59
- data/lib/project_types/node/commands/generate/webhook.rb +0 -37
- data/lib/project_types/script/layers/domain/script.rb +0 -18
- data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -47
- data/lib/project_types/script/templates/ts/as-pect.config.js +0 -27
- data/lib/project_types/script/templates/ts/as-pect.d.ts +0 -1
@@ -11,6 +11,30 @@ module Script
|
|
11
11
|
def self.types
|
12
12
|
Infrastructure::ExtensionPointRepository.new.extension_point_types
|
13
13
|
end
|
14
|
+
|
15
|
+
def self.non_deprecated_types
|
16
|
+
Infrastructure::ExtensionPointRepository.new.extension_points.select do |ep|
|
17
|
+
!ep.deprecated?
|
18
|
+
end.map(&:type)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.deprecated_types
|
22
|
+
Infrastructure::ExtensionPointRepository.new
|
23
|
+
.extension_points
|
24
|
+
.select(&:deprecated?)
|
25
|
+
.map(&:type)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.languages(type:)
|
29
|
+
get(type: type).sdks.all.map do |sdk|
|
30
|
+
next nil if sdk.beta? && !ShopifyCli::Feature.enabled?(:scripts_beta_languages)
|
31
|
+
sdk.class.language
|
32
|
+
end.compact
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.supported_language?(type:, language:)
|
36
|
+
languages(type: type).include?(language.downcase)
|
37
|
+
end
|
14
38
|
end
|
15
39
|
end
|
16
40
|
end
|
@@ -5,25 +5,27 @@ module Script
|
|
5
5
|
module Application
|
6
6
|
class PushScript
|
7
7
|
class << self
|
8
|
-
def call(ctx:,
|
9
|
-
|
10
|
-
|
11
|
-
extension_point_type,
|
12
|
-
script_name
|
13
|
-
)
|
14
|
-
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name, source_file)
|
8
|
+
def call(ctx:, force:)
|
9
|
+
script_project = ScriptProject.current
|
10
|
+
task_runner = Infrastructure::TaskRunner.for(ctx, script_project.language, script_project.script_name)
|
15
11
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
16
|
-
BuildScript.call(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
BuildScript.call(
|
13
|
+
ctx: ctx,
|
14
|
+
task_runner: task_runner,
|
15
|
+
extension_point_type: script_project.extension_point_type,
|
16
|
+
script_name: script_project.script_name,
|
17
|
+
description: script_project.description
|
18
|
+
)
|
21
19
|
|
22
|
-
def push_script(ctx, task_runner, script, api_key, force)
|
23
20
|
UI::PrintingSpinner.spin(ctx, ctx.message('script.application.pushing')) do |p_ctx, spinner|
|
24
|
-
Infrastructure::PushPackageRepository.new(ctx: p_ctx)
|
25
|
-
.
|
26
|
-
|
21
|
+
package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
|
22
|
+
extension_point_type: script_project.extension_point_type,
|
23
|
+
script_name: script_project.script_name,
|
24
|
+
description: script_project.description,
|
25
|
+
compiled_type: task_runner.compiled_type,
|
26
|
+
metadata: task_runner.metadata
|
27
|
+
)
|
28
|
+
package.push(Infrastructure::ScriptService.new(ctx: p_ctx), script_project.api_key, force)
|
27
29
|
spinner.update_title(p_ctx.message('script.application.pushed'))
|
28
30
|
end
|
29
31
|
end
|
@@ -4,24 +4,80 @@ module Script
|
|
4
4
|
module Layers
|
5
5
|
module Domain
|
6
6
|
class ExtensionPoint
|
7
|
-
attr_reader :type, :sdks
|
7
|
+
attr_reader :type, :deprecated, :sdks
|
8
8
|
|
9
9
|
def initialize(type, config)
|
10
10
|
@type = type
|
11
|
-
@
|
12
|
-
|
13
|
-
|
11
|
+
@deprecated = config["deprecated"] || false
|
12
|
+
@sdks = ExtensionPointSDKs.new(config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def deprecated?
|
16
|
+
@deprecated
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class ExtensionPointSDKs
|
21
|
+
def initialize(config)
|
22
|
+
@config = config
|
23
|
+
end
|
24
|
+
|
25
|
+
def all
|
26
|
+
[assemblyscript, rust].compact
|
27
|
+
end
|
28
|
+
|
29
|
+
def assemblyscript
|
30
|
+
@assemblyscript ||= new_sdk(ExtensionPointAssemblyScriptSDK)
|
31
|
+
end
|
32
|
+
|
33
|
+
def rust
|
34
|
+
@rust ||= new_sdk(ExtensionPointRustSDK)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def new_sdk(klass)
|
40
|
+
config = @config[klass.language]
|
41
|
+
return nil if config.nil?
|
42
|
+
klass.new(config)
|
14
43
|
end
|
15
44
|
end
|
16
45
|
|
17
|
-
class
|
18
|
-
attr_reader :
|
46
|
+
class ExtensionPointSDK
|
47
|
+
attr_reader :beta, :package
|
19
48
|
|
20
49
|
def initialize(config)
|
50
|
+
@beta = config["beta"] || false
|
21
51
|
@package = config["package"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def beta?
|
55
|
+
@beta
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.language
|
59
|
+
raise NotImplementedError
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class ExtensionPointAssemblyScriptSDK < ExtensionPointSDK
|
64
|
+
attr_reader :sdk_version, :toolchain_version
|
65
|
+
|
66
|
+
def initialize(config)
|
67
|
+
super
|
22
68
|
@sdk_version = config["sdk-version"]
|
23
69
|
@toolchain_version = config["toolchain-version"]
|
24
70
|
end
|
71
|
+
|
72
|
+
def self.language
|
73
|
+
"assemblyscript"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class ExtensionPointRustSDK < ExtensionPointSDK
|
78
|
+
def self.language
|
79
|
+
"rust"
|
80
|
+
end
|
25
81
|
end
|
26
82
|
end
|
27
83
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Script
|
4
|
+
module Layers
|
5
|
+
module Domain
|
6
|
+
class Metadata
|
7
|
+
attr_reader :schema_major_version, :schema_minor_version, :use_msgpack
|
8
|
+
|
9
|
+
def initialize(schema_major_version, schema_minor_version, use_msgpack)
|
10
|
+
@schema_major_version = schema_major_version
|
11
|
+
@schema_minor_version = schema_minor_version
|
12
|
+
@use_msgpack = use_msgpack
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def create_from_json(ctx, metadata_json)
|
17
|
+
metadata_hash = JSON.parse(metadata_json)
|
18
|
+
schema_versions = metadata_hash["schemaVersions"]
|
19
|
+
if schema_versions.nil?
|
20
|
+
err_msg = "script.error.metadata_schema_versions_missing"
|
21
|
+
raise ::Script::Layers::Domain::Errors::MetadataValidationError, ctx.message(err_msg)
|
22
|
+
end
|
23
|
+
# Scripts may be attached to more than one EP in the future but not right now
|
24
|
+
unless schema_versions.count == 1
|
25
|
+
err_msg = "script.error.metadata_schema_versions_single_key"
|
26
|
+
raise ::Script::Layers::Domain::Errors::MetadataValidationError, ctx.message(err_msg)
|
27
|
+
end
|
28
|
+
|
29
|
+
_, version = schema_versions.first
|
30
|
+
schema_major_version = version["major"]
|
31
|
+
schema_minor_version = version["minor"]
|
32
|
+
if schema_major_version.nil?
|
33
|
+
err_msg = "script.error.metadata_schema_versions_missing_major"
|
34
|
+
raise ::Script::Layers::Domain::Errors::MetadataValidationError, ctx.message(err_msg)
|
35
|
+
end
|
36
|
+
|
37
|
+
if schema_minor_version.nil?
|
38
|
+
err_msg = "script.error.metadata_schema_versions_missing_minor"
|
39
|
+
raise ::Script::Layers::Domain::Errors::MetadataValidationError, ctx.message(err_msg)
|
40
|
+
end
|
41
|
+
|
42
|
+
use_msgpack = !!metadata_hash.dig("flags", "use_msgpack")
|
43
|
+
|
44
|
+
Metadata.new(schema_major_version, schema_minor_version, use_msgpack)
|
45
|
+
rescue ::Script::Layers::Domain::Errors::MetadataValidationError
|
46
|
+
raise
|
47
|
+
rescue
|
48
|
+
err_msg = "script.error.metadata_validation_cause"
|
49
|
+
raise ::Script::Layers::Domain::Errors::MetadataValidationError, ctx.message(err_msg)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -4,23 +4,42 @@ module Script
|
|
4
4
|
module Layers
|
5
5
|
module Domain
|
6
6
|
class PushPackage
|
7
|
-
attr_reader :id,
|
7
|
+
attr_reader :id,
|
8
|
+
:extension_point_type,
|
9
|
+
:script_name,
|
10
|
+
:description,
|
11
|
+
:script_content,
|
12
|
+
:compiled_type,
|
13
|
+
:metadata
|
8
14
|
|
9
|
-
def initialize(
|
15
|
+
def initialize(
|
16
|
+
id:,
|
17
|
+
extension_point_type:,
|
18
|
+
script_name:,
|
19
|
+
description:,
|
20
|
+
script_content:,
|
21
|
+
compiled_type:,
|
22
|
+
metadata:
|
23
|
+
)
|
10
24
|
@id = id
|
11
|
-
@
|
25
|
+
@extension_point_type = extension_point_type
|
26
|
+
@script_name = script_name
|
27
|
+
@description = description
|
12
28
|
@script_content = script_content
|
13
29
|
@compiled_type = compiled_type
|
30
|
+
@metadata = metadata
|
14
31
|
end
|
15
32
|
|
16
33
|
def push(script_service, api_key, force)
|
17
34
|
script_service.push(
|
18
|
-
extension_point_type: @
|
19
|
-
script_name: @
|
35
|
+
extension_point_type: @extension_point_type,
|
36
|
+
script_name: @script_name,
|
37
|
+
description: @description,
|
20
38
|
script_content: @script_content,
|
21
39
|
compiled_type: @compiled_type,
|
22
40
|
api_key: api_key,
|
23
|
-
force: force
|
41
|
+
force: force,
|
42
|
+
metadata: @metadata,
|
24
43
|
)
|
25
44
|
end
|
26
45
|
end
|
@@ -36,7 +36,7 @@ module Script
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def extension_point_version
|
39
|
-
out, status = ctx.capture2e("npm show #{extension_point.sdks
|
39
|
+
out, status = ctx.capture2e("npm show #{extension_point.sdks.assemblyscript.package} version --json")
|
40
40
|
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
41
41
|
JSON.parse(out)
|
42
42
|
end
|
@@ -47,16 +47,16 @@ module Script
|
|
47
47
|
"name": "#{script_name}",
|
48
48
|
"version": "1.0.0",
|
49
49
|
"devDependencies": {
|
50
|
-
"@shopify/scripts-sdk-as": "#{extension_point.sdks
|
51
|
-
"@shopify/scripts-toolchain-as": "#{extension_point.sdks
|
52
|
-
"#{extension_point.sdks
|
50
|
+
"@shopify/scripts-sdk-as": "#{extension_point.sdks.assemblyscript.sdk_version}",
|
51
|
+
"@shopify/scripts-toolchain-as": "#{extension_point.sdks.assemblyscript.toolchain_version}",
|
52
|
+
"#{extension_point.sdks.assemblyscript.package}": "^#{extension_point_version}",
|
53
53
|
"@as-pect/cli": "4.0.0",
|
54
54
|
"as-wasi": "^0.2.1",
|
55
|
-
"assemblyscript": "^0.
|
55
|
+
"assemblyscript": "^0.16.1"
|
56
56
|
},
|
57
57
|
"scripts": {
|
58
58
|
"test": "asp --summary --verbose",
|
59
|
-
"build": "shopify-scripts-toolchain-as build --src src/script.ts --binary build/#{script_name}.wasm -- --lib node_modules --optimize --use Date="
|
59
|
+
"build": "shopify-scripts-toolchain-as build --src src/script.ts --binary build/#{script_name}.wasm --metadata build/metadata.json -- --lib node_modules --optimize --use Date="
|
60
60
|
},
|
61
61
|
"engines": {
|
62
62
|
"node": ">=#{MIN_NODE_VERSION}"
|
@@ -5,14 +5,14 @@ module Script
|
|
5
5
|
module Infrastructure
|
6
6
|
class AssemblyScriptTaskRunner
|
7
7
|
BYTECODE_FILE = "build/%{name}.wasm"
|
8
|
+
METADATA_FILE = "build/metadata.json"
|
8
9
|
SCRIPT_SDK_BUILD = "npm run build"
|
9
10
|
|
10
|
-
attr_reader :ctx, :script_name
|
11
|
+
attr_reader :ctx, :script_name
|
11
12
|
|
12
|
-
def initialize(ctx, script_name
|
13
|
+
def initialize(ctx, script_name)
|
13
14
|
@ctx = ctx
|
14
15
|
@script_name = script_name
|
15
|
-
@script_source_file = script_source_file
|
16
16
|
end
|
17
17
|
|
18
18
|
def build
|
@@ -27,7 +27,7 @@ module Script
|
|
27
27
|
def install_dependencies
|
28
28
|
check_node_version!
|
29
29
|
|
30
|
-
output, status = ctx.capture2e("npm
|
30
|
+
output, status = ctx.capture2e("npm install --no-audit --no-optional --legacy-peer-deps --loglevel error")
|
31
31
|
raise Errors::DependencyInstallError, output unless status.success?
|
32
32
|
end
|
33
33
|
|
@@ -38,6 +38,16 @@ module Script
|
|
38
38
|
true
|
39
39
|
end
|
40
40
|
|
41
|
+
def metadata
|
42
|
+
unless @ctx.file_exist?(METADATA_FILE)
|
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)
|
49
|
+
end
|
50
|
+
|
41
51
|
private
|
42
52
|
|
43
53
|
def check_node_version!
|
@@ -48,8 +58,8 @@ module Script
|
|
48
58
|
version = ::Semantic::Version.new(output[1..-1])
|
49
59
|
unless version >= ::Semantic::Version.new(AssemblyScriptProjectCreator::MIN_NODE_VERSION)
|
50
60
|
raise Errors::DependencyInstallError,
|
51
|
-
|
52
|
-
|
61
|
+
"Node version must be >= v#{AssemblyScriptProjectCreator::MIN_NODE_VERSION}. "\
|
62
|
+
"Current version: #{output.strip}."
|
53
63
|
end
|
54
64
|
end
|
55
65
|
|
@@ -8,18 +8,24 @@ module Script
|
|
8
8
|
Domain::ExtensionPoint.new(type, fetch_extension_point(type))
|
9
9
|
end
|
10
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
|
+
|
11
17
|
def extension_point_types
|
12
|
-
|
18
|
+
extension_point_configs.keys
|
13
19
|
end
|
14
20
|
|
15
21
|
private
|
16
22
|
|
17
23
|
def fetch_extension_point(type)
|
18
|
-
raise Domain::Errors::InvalidExtensionPointError, type unless
|
19
|
-
|
24
|
+
raise Domain::Errors::InvalidExtensionPointError, type unless extension_point_configs[type]
|
25
|
+
extension_point_configs[type]
|
20
26
|
end
|
21
27
|
|
22
|
-
def
|
28
|
+
def extension_point_configs
|
23
29
|
@extension_points ||= begin
|
24
30
|
require 'yaml'
|
25
31
|
YAML.load_file(Project.project_filepath('config/extension_points.yml'))
|
@@ -5,7 +5,8 @@ module Script
|
|
5
5
|
module Infrastructure
|
6
6
|
class ProjectCreator
|
7
7
|
PROJECT_CREATORS = {
|
8
|
-
"
|
8
|
+
"assemblyscript" => Infrastructure::AssemblyScriptProjectCreator,
|
9
|
+
"rust" => Infrastructure::RustProjectCreator,
|
9
10
|
}
|
10
11
|
|
11
12
|
def self.for(ctx, language, extension_point, script_name, path_to_project)
|
@@ -7,30 +7,42 @@ module Script
|
|
7
7
|
include SmartProperties
|
8
8
|
property! :ctx, accepts: ShopifyCli::Context
|
9
9
|
|
10
|
-
def create_push_package(
|
11
|
-
|
10
|
+
def create_push_package(
|
11
|
+
extension_point_type:,
|
12
|
+
script_name:,
|
13
|
+
description:,
|
14
|
+
script_content:,
|
15
|
+
compiled_type:,
|
16
|
+
metadata:
|
17
|
+
)
|
18
|
+
build_file_path = file_path(script_name, compiled_type)
|
12
19
|
write_to_path(build_file_path, script_content)
|
13
20
|
|
14
21
|
Domain::PushPackage.new(
|
15
|
-
build_file_path,
|
16
|
-
|
17
|
-
|
18
|
-
|
22
|
+
id: build_file_path,
|
23
|
+
extension_point_type: extension_point_type,
|
24
|
+
script_name: script_name,
|
25
|
+
description: description,
|
26
|
+
script_content: script_content,
|
27
|
+
compiled_type: compiled_type,
|
28
|
+
metadata: metadata,
|
19
29
|
)
|
20
30
|
end
|
21
31
|
|
22
|
-
def get_push_package(
|
23
|
-
build_file_path = file_path(
|
24
|
-
|
32
|
+
def get_push_package(extension_point_type:, script_name:, description:, compiled_type:, metadata:)
|
33
|
+
build_file_path = file_path(script_name, compiled_type)
|
25
34
|
raise Domain::PushPackageNotFoundError unless ctx.file_exist?(build_file_path)
|
26
35
|
|
27
36
|
script_content = File.read(build_file_path)
|
28
37
|
|
29
38
|
Domain::PushPackage.new(
|
30
|
-
build_file_path,
|
31
|
-
|
32
|
-
|
33
|
-
|
39
|
+
id: build_file_path,
|
40
|
+
extension_point_type: extension_point_type,
|
41
|
+
script_name: script_name,
|
42
|
+
description: description,
|
43
|
+
script_content: script_content,
|
44
|
+
compiled_type: compiled_type,
|
45
|
+
metadata: metadata,
|
34
46
|
)
|
35
47
|
end
|
36
48
|
|