shopify-cli 1.3.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/CODEOWNERS +2 -2
- data/.github/CONTRIBUTING.md +9 -1
- data/.github/PULL_REQUEST_TEMPLATE.md +10 -1
- data/.github/workflows/release.yml +61 -0
- data/.github/workflows/triage.yml +22 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +61 -8
- data/.rubocop_todo.yml +11 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +30 -0
- data/Gemfile +3 -2
- data/Gemfile.lock +39 -37
- data/README.md +39 -7
- data/RELEASING.md +19 -29
- 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 +21 -11
- 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/cli.rb +4 -1
- data/lib/project_types/node/commands/connect.rb +15 -0
- data/lib/project_types/node/commands/create.rb +10 -4
- data/lib/project_types/node/commands/generate.rb +2 -11
- data/lib/project_types/node/messages/messages.rb +16 -50
- data/lib/project_types/rails/cli.rb +4 -1
- data/lib/project_types/rails/commands/connect.rb +15 -0
- data/lib/project_types/rails/commands/create.rb +15 -12
- 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 +8 -5
- data/lib/project_types/script/cli.rb +9 -5
- data/lib/project_types/script/commands/create.rb +6 -4
- data/lib/project_types/script/commands/enable.rb +12 -4
- data/lib/project_types/script/commands/push.rb +5 -13
- data/lib/project_types/script/config/extension_points.yml +17 -12
- data/lib/project_types/script/errors.rb +21 -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 +18 -17
- 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 +7 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +62 -7
- 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 +17 -52
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +42 -11
- data/lib/project_types/script/layers/infrastructure/errors.rb +16 -0
- 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 +9 -1
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
- data/lib/project_types/script/messages/messages.rb +55 -4
- data/lib/project_types/script/script_project.rb +25 -16
- data/lib/project_types/script/ui/error_handler.rb +59 -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 +34 -33
- data/lib/shopify-cli/commands/config.rb +24 -0
- data/lib/shopify-cli/commands/connect.rb +32 -15
- data/lib/shopify-cli/commands/system.rb +10 -1
- data/lib/shopify-cli/context.rb +23 -2
- data/lib/shopify-cli/core/entry_point.rb +1 -1
- data/lib/shopify-cli/core/monorail.rb +6 -4
- data/lib/shopify-cli/feature.rb +0 -2
- data/lib/shopify-cli/http_request.rb +27 -0
- data/lib/shopify-cli/js_deps.rb +1 -1
- data/lib/shopify-cli/messages/messages.rb +31 -7
- data/lib/shopify-cli/method_object.rb +104 -0
- data/lib/shopify-cli/partners_api.rb +25 -3
- data/lib/shopify-cli/process_supervision.rb +1 -1
- data/lib/shopify-cli/project.rb +12 -8
- data/lib/shopify-cli/project_type.rb +18 -2
- data/lib/shopify-cli/resolve_constant.rb +25 -0
- data/lib/shopify-cli/result.rb +432 -0
- data/lib/shopify-cli/shopifolk.rb +87 -0
- data/lib/shopify-cli/task.rb +8 -0
- data/lib/shopify-cli/tasks/create_api_client.rb +13 -2
- data/lib/shopify-cli/tasks/ensure_env.rb +3 -0
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +10 -5
- data/lib/shopify-cli/tunnel.rb +8 -2
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +5 -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 +77 -27
- 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/assemblyscript_tsconfig.rb +0 -38
- data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -59
- 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
@@ -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
|
@@ -10,11 +10,8 @@ module Script
|
|
10
10
|
property! :script_name, accepts: String
|
11
11
|
property! :path_to_project, accepts: String
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
SOURCE_DIR = "src"
|
16
|
-
TEST_DIR = "test"
|
17
|
-
LANGUAGE = "ts"
|
13
|
+
BOOTSTRAP = "npx --no-install shopify-scripts-toolchain-as bootstrap --from %{extension_point} --dest %{base}"
|
14
|
+
MIN_NODE_VERSION = "14.5.0"
|
18
15
|
|
19
16
|
def setup_dependencies
|
20
17
|
write_npmrc
|
@@ -22,42 +19,12 @@ module Script
|
|
22
19
|
end
|
23
20
|
|
24
21
|
def bootstrap
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def create_src_folder
|
32
|
-
ctx.mkdir_p(src_base)
|
33
|
-
out, status = ctx.capture2e(format(BOOTSTRAP_SRC, src_base: src_base))
|
22
|
+
type = extension_point.type.gsub('_', '-')
|
23
|
+
out, status = ctx.capture2e(format(BOOTSTRAP, extension_point: type, base: path_to_project))
|
34
24
|
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
35
|
-
|
36
|
-
write_tsconfig_file(SOURCE_DIR, ".")
|
37
|
-
end
|
38
|
-
|
39
|
-
def create_test_folder
|
40
|
-
ctx.mkdir_p(test_base)
|
41
|
-
out, status = ctx.capture2e(format(BOOTSTRAP_TEST, test_base: test_base))
|
42
|
-
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
43
|
-
|
44
|
-
copy_template_file(test_base, 'as-pect.config.js')
|
45
|
-
copy_template_file(test_base, 'as-pect.d.ts')
|
46
|
-
write_tsconfig_file(TEST_DIR, "../#{SOURCE_DIR}")
|
47
25
|
end
|
48
26
|
|
49
|
-
|
50
|
-
"#{path_to_project}/#{TEST_DIR}"
|
51
|
-
end
|
52
|
-
|
53
|
-
def src_base
|
54
|
-
"#{path_to_project}/#{SOURCE_DIR}"
|
55
|
-
end
|
56
|
-
|
57
|
-
def copy_template_file(destination, name)
|
58
|
-
template_file = Project.project_filepath("templates/#{LANGUAGE}/#{name}")
|
59
|
-
ctx.cp(template_file, "#{destination}/#{name}")
|
60
|
-
end
|
27
|
+
private
|
61
28
|
|
62
29
|
def write_npmrc
|
63
30
|
ctx.system(
|
@@ -68,12 +35,10 @@ module Script
|
|
68
35
|
)
|
69
36
|
end
|
70
37
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
.with_module_resolution_paths(paths: { "*": ["#{path_to_source}/*.ts"] })
|
76
|
-
.write
|
38
|
+
def extension_point_version
|
39
|
+
out, status = ctx.capture2e("npm show #{extension_point.sdks.assemblyscript.package} version --json")
|
40
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
41
|
+
JSON.parse(out)
|
77
42
|
end
|
78
43
|
|
79
44
|
def write_package_json
|
@@ -82,22 +47,22 @@ module Script
|
|
82
47
|
"name": "#{script_name}",
|
83
48
|
"version": "1.0.0",
|
84
49
|
"devDependencies": {
|
85
|
-
"@shopify/scripts-sdk-as": "#{extension_point.sdks
|
86
|
-
"@shopify/scripts-toolchain-as": "#{extension_point.sdks
|
87
|
-
"#{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}",
|
88
53
|
"@as-pect/cli": "4.0.0",
|
89
|
-
"as-wasi": "^0.2.
|
90
|
-
"assemblyscript": "^0.
|
54
|
+
"as-wasi": "^0.2.1",
|
55
|
+
"assemblyscript": "^0.16.1"
|
91
56
|
},
|
92
57
|
"scripts": {
|
93
|
-
"test": "asp --
|
58
|
+
"test": "asp --summary --verbose",
|
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="
|
94
60
|
},
|
95
61
|
"engines": {
|
96
|
-
"node": "
|
62
|
+
"node": ">=#{MIN_NODE_VERSION}"
|
97
63
|
}
|
98
64
|
}
|
99
65
|
HERE
|
100
|
-
|
101
66
|
ctx.write("package.json", package_json)
|
102
67
|
end
|
103
68
|
end
|
@@ -4,16 +4,15 @@ module Script
|
|
4
4
|
module Layers
|
5
5
|
module Infrastructure
|
6
6
|
class AssemblyScriptTaskRunner
|
7
|
-
BYTECODE_FILE = "
|
8
|
-
|
9
|
-
|
7
|
+
BYTECODE_FILE = "build/%{name}.wasm"
|
8
|
+
METADATA_FILE = "build/metadata.json"
|
9
|
+
SCRIPT_SDK_BUILD = "npm run build"
|
10
10
|
|
11
|
-
attr_reader :ctx, :script_name
|
11
|
+
attr_reader :ctx, :script_name
|
12
12
|
|
13
|
-
def initialize(ctx, script_name
|
13
|
+
def initialize(ctx, script_name)
|
14
14
|
@ctx = ctx
|
15
15
|
@script_name = script_name
|
16
|
-
@script_source_file = script_source_file
|
17
16
|
end
|
18
17
|
|
19
18
|
def build
|
@@ -28,7 +27,7 @@ module Script
|
|
28
27
|
def install_dependencies
|
29
28
|
check_node_version!
|
30
29
|
|
31
|
-
output, status = ctx.capture2e("npm
|
30
|
+
output, status = ctx.capture2e("npm install --no-audit --no-optional --legacy-peer-deps --loglevel error")
|
32
31
|
raise Errors::DependencyInstallError, output unless status.success?
|
33
32
|
end
|
34
33
|
|
@@ -39,6 +38,16 @@ module Script
|
|
39
38
|
true
|
40
39
|
end
|
41
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
|
+
|
42
51
|
private
|
43
52
|
|
44
53
|
def check_node_version!
|
@@ -47,18 +56,40 @@ module Script
|
|
47
56
|
|
48
57
|
require 'semantic/semantic'
|
49
58
|
version = ::Semantic::Version.new(output[1..-1])
|
50
|
-
unless version >= ::Semantic::Version.new(
|
51
|
-
raise Errors::DependencyInstallError,
|
59
|
+
unless version >= ::Semantic::Version.new(AssemblyScriptProjectCreator::MIN_NODE_VERSION)
|
60
|
+
raise Errors::DependencyInstallError,
|
61
|
+
"Node version must be >= v#{AssemblyScriptProjectCreator::MIN_NODE_VERSION}. "\
|
62
|
+
"Current version: #{output.strip}."
|
52
63
|
end
|
53
64
|
end
|
54
65
|
|
55
66
|
def compile
|
56
|
-
|
67
|
+
check_compilation_dependencies!
|
68
|
+
|
69
|
+
out, status = ctx.capture2e(SCRIPT_SDK_BUILD)
|
57
70
|
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
58
71
|
end
|
59
72
|
|
73
|
+
def check_compilation_dependencies!
|
74
|
+
pkg = JSON.parse(File.read('package.json'))
|
75
|
+
build_script = pkg.dig('scripts', 'build')
|
76
|
+
|
77
|
+
raise Errors::BuildScriptNotFoundError,
|
78
|
+
"Build script not found" if build_script.nil?
|
79
|
+
|
80
|
+
unless build_script.start_with?("shopify-scripts")
|
81
|
+
raise Errors::InvalidBuildScriptError, "Invalid build script"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
60
85
|
def bytecode
|
61
|
-
|
86
|
+
blob = format(BYTECODE_FILE, name: script_name)
|
87
|
+
raise Errors::WebAssemblyBinaryNotFoundError unless @ctx.file_exist?(blob)
|
88
|
+
|
89
|
+
contents = File.read(blob)
|
90
|
+
@ctx.rm(blob)
|
91
|
+
|
92
|
+
contents
|
62
93
|
end
|
63
94
|
|
64
95
|
def check_if_ep_dependencies_up_to_date!
|
@@ -9,7 +9,9 @@ module Script
|
|
9
9
|
class AppScriptUndefinedError < ScriptProjectError; end
|
10
10
|
class BuildError < ScriptProjectError; end
|
11
11
|
class DependencyInstallError < ScriptProjectError; end
|
12
|
+
class EmptyResponseError < ScriptProjectError; end
|
12
13
|
class ForbiddenError < ScriptProjectError; end
|
14
|
+
|
13
15
|
class GraphqlError < ScriptProjectError
|
14
16
|
attr_reader :errors
|
15
17
|
def initialize(errors)
|
@@ -17,7 +19,9 @@ module Script
|
|
17
19
|
super("GraphQL failed with errors: #{errors}")
|
18
20
|
end
|
19
21
|
end
|
22
|
+
|
20
23
|
class ProjectCreatorNotFoundError < ScriptProjectError; end
|
24
|
+
|
21
25
|
class ScriptRepushError < ScriptProjectError
|
22
26
|
attr_reader :api_key
|
23
27
|
def initialize(api_key)
|
@@ -25,15 +29,18 @@ module Script
|
|
25
29
|
@api_key = api_key
|
26
30
|
end
|
27
31
|
end
|
32
|
+
|
28
33
|
class ScriptServiceUserError < ScriptProjectError
|
29
34
|
def initialize(query_name, errors)
|
30
35
|
super("Failed performing #{query_name}. Errors: #{errors}.")
|
31
36
|
end
|
32
37
|
end
|
38
|
+
|
33
39
|
class ShopAuthenticationError < ScriptProjectError; end
|
34
40
|
class ShopScriptConflictError < ScriptProjectError; end
|
35
41
|
class ShopScriptUndefinedError < ScriptProjectError; end
|
36
42
|
class TaskRunnerNotFoundError < ScriptProjectError; end
|
43
|
+
|
37
44
|
class PackagesOutdatedError < ScriptProjectError
|
38
45
|
attr_reader :outdated_packages
|
39
46
|
def initialize(outdated_packages)
|
@@ -41,6 +48,15 @@ module Script
|
|
41
48
|
@outdated_packages = outdated_packages
|
42
49
|
end
|
43
50
|
end
|
51
|
+
|
52
|
+
class BuildScriptNotFoundError < ScriptProjectError; end
|
53
|
+
class InvalidBuildScriptError < ScriptProjectError; end
|
54
|
+
|
55
|
+
class WebAssemblyBinaryNotFoundError < ScriptProjectError
|
56
|
+
def initialize
|
57
|
+
super("WebAssembly binary not found")
|
58
|
+
end
|
59
|
+
end
|
44
60
|
end
|
45
61
|
end
|
46
62
|
end
|
@@ -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
|
|