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
@@ -1,24 +1,29 @@
|
|
1
1
|
discount:
|
2
|
+
deprecated: true
|
2
3
|
assemblyscript:
|
3
4
|
package: "@shopify/extension-point-as-discount"
|
4
|
-
version: "^0.
|
5
|
-
|
6
|
-
toolchain-version: "^1.1.0"
|
5
|
+
sdk-version: "^7.0.0"
|
6
|
+
toolchain-version: "^4.0.0"
|
7
7
|
unit_limit_per_order:
|
8
8
|
assemblyscript:
|
9
9
|
package: "@shopify/extension-point-as-unit-limit-per-order"
|
10
|
-
version: "^0.
|
11
|
-
|
12
|
-
toolchain-version: "^1.1.0"
|
10
|
+
sdk-version: "^7.0.0"
|
11
|
+
toolchain-version: "^4.0.0"
|
13
12
|
payment_filter:
|
14
13
|
assemblyscript:
|
15
14
|
package: "@shopify/extension-point-as-payment-filter"
|
16
|
-
version: "^0.
|
17
|
-
|
18
|
-
|
15
|
+
sdk-version: "^7.0.0"
|
16
|
+
toolchain-version: "^4.0.0"
|
17
|
+
rust:
|
18
|
+
beta: true
|
19
|
+
package: "https://github.com/Shopify/scripts-apis-rs"
|
19
20
|
shipping_filter:
|
20
21
|
assemblyscript:
|
21
22
|
package: "@shopify/extension-point-as-shipping-filter"
|
22
|
-
version: "^0.
|
23
|
-
|
24
|
-
|
23
|
+
sdk-version: "^7.0.0"
|
24
|
+
toolchain-version: "^4.0.0"
|
25
|
+
tax_filter:
|
26
|
+
assemblyscript:
|
27
|
+
package: "@shopify/extension-point-as-tax-filter"
|
28
|
+
sdk-version: "^7.0.0"
|
29
|
+
toolchain-version: "^4.0.0"
|
@@ -6,6 +6,7 @@ module Script
|
|
6
6
|
class InvalidScriptNameError < ScriptProjectError; end
|
7
7
|
class NoExistingAppsError < ScriptProjectError; end
|
8
8
|
class NoExistingOrganizationsError < ScriptProjectError; end
|
9
|
+
|
9
10
|
class NoExistingStoresError < ScriptProjectError
|
10
11
|
attr_reader :organization_id
|
11
12
|
def initialize(organization_id)
|
@@ -13,7 +14,10 @@ module Script
|
|
13
14
|
@organization_id = organization_id
|
14
15
|
end
|
15
16
|
end
|
17
|
+
|
16
18
|
class ScriptProjectAlreadyExistsError < ScriptProjectError; end
|
19
|
+
class InvalidConfigProps < ScriptProjectError; end
|
20
|
+
|
17
21
|
class InvalidConfigYAMLError < ScriptProjectError
|
18
22
|
attr_reader :config_file
|
19
23
|
def initialize(config_file)
|
@@ -21,5 +25,22 @@ module Script
|
|
21
25
|
@config_file = config_file
|
22
26
|
end
|
23
27
|
end
|
28
|
+
|
29
|
+
class InvalidLanguageError < ScriptProjectError
|
30
|
+
attr_reader :language, :extension_point_type
|
31
|
+
def initialize(language, extension_point_type)
|
32
|
+
super()
|
33
|
+
@language = language
|
34
|
+
@extension_point_type = extension_point_type
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class DeprecatedEPError < ScriptProjectError
|
39
|
+
attr_reader :ep
|
40
|
+
def initialize(ep)
|
41
|
+
super()
|
42
|
+
@ep = ep
|
43
|
+
end
|
44
|
+
end
|
24
45
|
end
|
25
46
|
end
|
@@ -3,11 +3,13 @@
|
|
3
3
|
module Script
|
4
4
|
module Forms
|
5
5
|
class Create < ShopifyCli::Form
|
6
|
-
flag_arguments :extension_point, :name
|
6
|
+
flag_arguments :extension_point, :name, :language, :description
|
7
7
|
|
8
8
|
def ask
|
9
9
|
self.name = valid_name
|
10
|
+
self.description ||= ask_description
|
10
11
|
self.extension_point ||= ask_extension_point
|
12
|
+
self.language = ask_language
|
11
13
|
end
|
12
14
|
|
13
15
|
private
|
@@ -15,7 +17,7 @@ module Script
|
|
15
17
|
def ask_extension_point
|
16
18
|
CLI::UI::Prompt.ask(
|
17
19
|
@ctx.message('script.forms.create.select_extension_point'),
|
18
|
-
options:
|
20
|
+
options: Layers::Application::ExtensionPoints.non_deprecated_types
|
19
21
|
)
|
20
22
|
end
|
21
23
|
|
@@ -23,11 +25,33 @@ module Script
|
|
23
25
|
CLI::UI::Prompt.ask(@ctx.message('script.forms.create.script_name'))
|
24
26
|
end
|
25
27
|
|
28
|
+
def ask_description
|
29
|
+
CLI::UI::Prompt.ask(@ctx.message('script.forms.create.description'))
|
30
|
+
end
|
31
|
+
|
26
32
|
def valid_name
|
27
33
|
n = (name || ask_name).downcase.gsub(' ', '_')
|
28
34
|
return n if n.match?(/^[0-9A-Za-z_-]*$/)
|
29
35
|
raise Errors::InvalidScriptNameError
|
30
36
|
end
|
37
|
+
|
38
|
+
def ask_language
|
39
|
+
if language
|
40
|
+
if Layers::Application::ExtensionPoints.supported_language?(type: extension_point, language: language)
|
41
|
+
return language.downcase
|
42
|
+
else
|
43
|
+
raise Errors::InvalidLanguageError.new(language, extension_point)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
all_languages = Layers::Application::ExtensionPoints.languages(type: extension_point)
|
48
|
+
return all_languages.first if all_languages.count == 1
|
49
|
+
|
50
|
+
CLI::UI::Prompt.ask(
|
51
|
+
ctx.message('script.forms.create.select_language'),
|
52
|
+
options: all_languages
|
53
|
+
)
|
54
|
+
end
|
31
55
|
end
|
32
56
|
end
|
33
57
|
end
|
@@ -1,16 +1,24 @@
|
|
1
1
|
mutation AppScriptUpdateOrCreate(
|
2
2
|
$extensionPointName: ExtensionPointName!,
|
3
3
|
$title: String,
|
4
|
+
$description: String,
|
4
5
|
$sourceCode: String,
|
5
6
|
$language: String,
|
6
|
-
$force: Boolean
|
7
|
+
$force: Boolean,
|
8
|
+
$schemaMajorVersion: String,
|
9
|
+
$schemaMinorVersion: String,
|
10
|
+
$useMsgpack: Boolean
|
7
11
|
) {
|
8
12
|
appScriptUpdateOrCreate(
|
9
13
|
extensionPointName: $extensionPointName
|
10
14
|
title: $title
|
15
|
+
description: $description
|
11
16
|
sourceCode: $sourceCode
|
12
17
|
language: $language
|
13
18
|
force: $force
|
19
|
+
schemaMajorVersion: $schemaMajorVersion
|
20
|
+
schemaMinorVersion: $schemaMinorVersion
|
21
|
+
useMsgpack: $useMsgpack
|
14
22
|
) {
|
15
23
|
userErrors {
|
16
24
|
field
|
@@ -22,6 +30,7 @@ mutation AppScriptUpdateOrCreate(
|
|
22
30
|
configSchema
|
23
31
|
extensionPointName
|
24
32
|
title
|
33
|
+
description
|
25
34
|
}
|
26
35
|
}
|
27
36
|
}
|
@@ -5,33 +5,34 @@ module Script
|
|
5
5
|
module Application
|
6
6
|
class BuildScript
|
7
7
|
class << self
|
8
|
-
def call(ctx:, task_runner:,
|
9
|
-
|
8
|
+
def call(ctx:, task_runner:, script_name:, description:, extension_point_type:)
|
9
|
+
CLI::UI::Frame.open(ctx.message('script.application.building')) do
|
10
10
|
begin
|
11
11
|
UI::StrictSpinner.spin(ctx.message('script.application.building_script')) do |spinner|
|
12
|
-
|
12
|
+
Infrastructure::PushPackageRepository.new(ctx: ctx).create_push_package(
|
13
|
+
extension_point_type: extension_point_type,
|
14
|
+
script_name: script_name,
|
15
|
+
description: description,
|
16
|
+
script_content: task_runner.build,
|
17
|
+
compiled_type: task_runner.compiled_type,
|
18
|
+
metadata: task_runner.metadata
|
19
|
+
)
|
13
20
|
spinner.update_title(ctx.message('script.application.built'))
|
14
21
|
end
|
15
|
-
true
|
16
22
|
rescue StandardError => e
|
17
23
|
CLI::UI::Frame.with_frame_color_override(:red) do
|
18
24
|
ctx.puts("\n{{red:#{e.message}}}")
|
19
25
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
errors = [
|
27
|
+
Infrastructure::Errors::InvalidBuildScriptError,
|
28
|
+
Infrastructure::Errors::BuildScriptNotFoundError,
|
29
|
+
Infrastructure::Errors::WebAssemblyBinaryNotFoundError,
|
30
|
+
]
|
25
31
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
script_repo = Infrastructure::ScriptRepository.new(ctx: ctx)
|
30
|
-
script_content = script_repo.with_temp_build_context do
|
31
|
-
task_runner.build
|
32
|
+
raise Infrastructure::Errors::BuildError unless errors.any? { |err| e.is_a?(err) }
|
33
|
+
raise
|
34
|
+
end
|
32
35
|
end
|
33
|
-
Infrastructure::PushPackageRepository.new(ctx: ctx)
|
34
|
-
.create_push_package(script, script_content, task_runner.compiled_type)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
@@ -7,40 +7,42 @@ module Script
|
|
7
7
|
module Application
|
8
8
|
class CreateScript
|
9
9
|
class << self
|
10
|
-
def call(ctx:, language:, script_name:, extension_point_type:)
|
10
|
+
def call(ctx:, language:, script_name:, extension_point_type:, description:)
|
11
11
|
extension_point = ExtensionPoints.get(type: extension_point_type)
|
12
|
-
project = setup_project(ctx, script_name, extension_point)
|
12
|
+
project = setup_project(ctx, language, script_name, extension_point, description)
|
13
13
|
project_creator = Infrastructure::ProjectCreator
|
14
14
|
.for(ctx, language, extension_point, script_name, project.directory)
|
15
|
-
install_dependencies(ctx, language, script_name,
|
16
|
-
bootstrap(ctx,
|
15
|
+
install_dependencies(ctx, language, script_name, project_creator)
|
16
|
+
bootstrap(ctx, project_creator)
|
17
17
|
project
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def setup_project(ctx, script_name, extension_point)
|
22
|
+
def setup_project(ctx, language, script_name, extension_point, description)
|
23
23
|
ScriptProject.create(ctx, script_name)
|
24
24
|
ScriptProject.write(
|
25
25
|
ctx,
|
26
26
|
project_type: :script,
|
27
27
|
organization_id: nil, # TODO: can you provide this at creation
|
28
28
|
extension_point_type: extension_point.type,
|
29
|
-
script_name: script_name
|
29
|
+
script_name: script_name,
|
30
|
+
language: language,
|
31
|
+
description: description
|
30
32
|
)
|
31
33
|
ScriptProject.current
|
32
34
|
end
|
33
35
|
|
34
|
-
def install_dependencies(ctx, language, script_name,
|
35
|
-
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name
|
36
|
+
def install_dependencies(ctx, language, script_name, project_creator)
|
37
|
+
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name)
|
36
38
|
project_creator.setup_dependencies
|
37
39
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
38
40
|
end
|
39
41
|
|
40
|
-
def bootstrap(ctx,
|
42
|
+
def bootstrap(ctx, project_creator)
|
41
43
|
UI::StrictSpinner.spin(ctx.message('script.create.creating')) do |spinner|
|
42
44
|
project_creator.bootstrap
|
43
|
-
spinner.update_title(ctx.message('script.create.created'
|
45
|
+
spinner.update_title(ctx.message('script.create.created'))
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -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
|
@@ -5,6 +5,7 @@ module Script
|
|
5
5
|
module Domain
|
6
6
|
module Errors
|
7
7
|
class PushPackageNotFoundError < ScriptProjectError; end
|
8
|
+
|
8
9
|
class InvalidExtensionPointError < ScriptProjectError
|
9
10
|
attr_reader :type
|
10
11
|
def initialize(type)
|
@@ -12,6 +13,7 @@ module Script
|
|
12
13
|
@type = type
|
13
14
|
end
|
14
15
|
end
|
16
|
+
|
15
17
|
class ScriptNotFoundError < ScriptProjectError
|
16
18
|
attr_reader :script_name, :extension_point_type
|
17
19
|
def initialize(extension_point_type, script_name)
|
@@ -20,7 +22,12 @@ module Script
|
|
20
22
|
@extension_point_type = extension_point_type
|
21
23
|
end
|
22
24
|
end
|
25
|
+
|
23
26
|
class ServiceFailureError < ScriptProjectError; end
|
27
|
+
|
28
|
+
class MetadataNotFoundError < ScriptProjectError; end
|
29
|
+
|
30
|
+
class MetadataValidationError < ScriptProjectError; end
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
@@ -4,25 +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"]
|
22
|
-
|
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
|
23
68
|
@sdk_version = config["sdk-version"]
|
24
69
|
@toolchain_version = config["toolchain-version"]
|
25
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
|
26
81
|
end
|
27
82
|
end
|
28
83
|
end
|