shopify-cli 1.4.1 → 1.8.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 +3 -2
- data/.github/workflows/release.yml +0 -1
- data/.github/workflows/triage.yml +22 -0
- data/.rubocop.yml +21 -7
- data/.rubocop_todo.yml +2 -15
- data/.travis.yml +1 -1
- data/CHANGELOG.md +28 -0
- data/Gemfile +12 -11
- data/Gemfile.lock +17 -14
- data/README.md +39 -7
- data/RELEASING.md +5 -13
- data/Rakefile +32 -28
- data/bin/load_shopify.rb +6 -6
- data/bin/shopify +2 -2
- 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/ext/shopify-cli/extconf.rb +7 -7
- data/install.sh +1 -1
- data/lib/docgen/markdown.rb +12 -12
- data/lib/graphql/fetch_specifications.graphql +14 -0
- data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
- data/lib/project_types/extension/cli.rb +54 -47
- data/lib/project_types/extension/commands/build.rb +3 -3
- data/lib/project_types/extension/commands/create.rb +17 -10
- data/lib/project_types/extension/commands/extension_command.rb +12 -5
- data/lib/project_types/extension/commands/push.rb +8 -8
- data/lib/project_types/extension/commands/register.rb +19 -30
- data/lib/project_types/extension/commands/serve.rb +31 -3
- data/lib/project_types/extension/commands/tunnel.rb +12 -12
- data/lib/project_types/extension/extension_project.rb +8 -4
- data/lib/project_types/extension/extension_project_keys.rb +4 -4
- data/lib/project_types/extension/features/argo.rb +117 -0
- data/lib/project_types/extension/features/argo_config.rb +5 -5
- data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
- data/lib/project_types/extension/features/argo_setup.rb +2 -2
- data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
- data/lib/project_types/extension/forms/create.rb +28 -34
- data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
- data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
- data/lib/project_types/extension/forms/questions/ask_type.rb +47 -0
- data/lib/project_types/extension/messages/messages.rb +55 -52
- data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
- data/lib/project_types/extension/models/specification.rb +37 -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 +88 -0
- data/lib/project_types/extension/tasks/configure_features.rb +52 -0
- data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
- data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
- data/lib/project_types/extension/tasks/create_extension.rb +4 -4
- data/lib/project_types/extension/tasks/fetch_specifications.rb +18 -0
- data/lib/project_types/extension/tasks/get_app.rb +4 -4
- data/lib/project_types/extension/tasks/get_apps.rb +3 -3
- data/lib/project_types/extension/tasks/update_draft.rb +4 -4
- data/lib/project_types/extension/tasks/user_errors.rb +4 -4
- data/lib/project_types/node/cli.rb +19 -16
- data/lib/project_types/node/commands/connect.rb +15 -0
- data/lib/project_types/node/commands/create.rb +44 -41
- data/lib/project_types/node/commands/deploy.rb +4 -4
- data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
- data/lib/project_types/node/commands/generate.rb +9 -18
- data/lib/project_types/node/commands/open.rb +2 -2
- data/lib/project_types/node/commands/populate.rb +6 -6
- data/lib/project_types/node/commands/populate/customer.rb +5 -5
- data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/node/commands/populate/product.rb +5 -5
- data/lib/project_types/node/commands/serve.rb +9 -9
- data/lib/project_types/node/commands/tunnel.rb +7 -7
- data/lib/project_types/node/forms/create.rb +17 -8
- data/lib/project_types/node/messages/messages.rb +20 -53
- data/lib/project_types/rails/cli.rb +21 -18
- data/lib/project_types/rails/commands/connect.rb +15 -0
- data/lib/project_types/rails/commands/create.rb +58 -57
- data/lib/project_types/rails/commands/deploy.rb +4 -4
- data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
- data/lib/project_types/rails/commands/generate.rb +7 -7
- data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
- data/lib/project_types/rails/commands/open.rb +2 -2
- data/lib/project_types/rails/commands/populate.rb +6 -6
- data/lib/project_types/rails/commands/populate/customer.rb +5 -5
- data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/rails/commands/populate/product.rb +5 -5
- data/lib/project_types/rails/commands/serve.rb +11 -11
- data/lib/project_types/rails/commands/tunnel.rb +7 -7
- data/lib/project_types/rails/forms/create.rb +35 -25
- data/lib/project_types/rails/gem.rb +24 -24
- data/lib/project_types/rails/messages/messages.rb +13 -9
- data/lib/project_types/rails/ruby.rb +2 -2
- data/lib/project_types/script/cli.rb +44 -38
- data/lib/project_types/script/commands/create.rb +15 -10
- data/lib/project_types/script/commands/disable.rb +3 -3
- data/lib/project_types/script/commands/enable.rb +19 -9
- data/lib/project_types/script/commands/push.rb +10 -17
- data/lib/project_types/script/config/extension_points.yml +30 -12
- data/lib/project_types/script/errors.rb +22 -0
- data/lib/project_types/script/forms/create.rb +29 -5
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +12 -1
- data/lib/project_types/script/layers/application/build_script.rb +19 -19
- data/lib/project_types/script/layers/application/create_script.rb +45 -12
- data/lib/project_types/script/layers/application/disable_script.rb +2 -2
- data/lib/project_types/script/layers/application/enable_script.rb +2 -2
- data/lib/project_types/script/layers/application/extension_points.rb +24 -0
- data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
- data/lib/project_types/script/layers/application/push_script.rb +15 -18
- data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
- data/lib/project_types/script/layers/domain/errors.rb +23 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +67 -7
- data/lib/project_types/script/layers/domain/metadata.rb +55 -0
- data/lib/project_types/script/layers/domain/push_package.rb +29 -6
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +45 -55
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +41 -45
- data/lib/project_types/script/layers/infrastructure/config_ui_repository.rb +46 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +32 -5
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +12 -6
- data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +20 -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 +39 -17
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
- data/lib/project_types/script/messages/messages.rb +76 -10
- data/lib/project_types/script/script_project.rb +26 -16
- data/lib/project_types/script/ui/error_handler.rb +135 -50
- data/lib/project_types/script/ui/printing_spinner.rb +1 -1
- data/lib/project_types/script/ui/strict_spinner.rb +1 -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/rubygems_plugin.rb +3 -3
- data/lib/shopify-cli/admin_api.rb +52 -12
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
- data/lib/shopify-cli/admin_api/schema.rb +3 -3
- data/lib/shopify-cli/api.rb +36 -31
- data/lib/shopify-cli/command.rb +1 -1
- data/lib/shopify-cli/commands.rb +9 -9
- data/lib/shopify-cli/commands/config.rb +28 -28
- data/lib/shopify-cli/commands/connect.rb +35 -18
- data/lib/shopify-cli/commands/create.rb +5 -5
- data/lib/shopify-cli/commands/help.rb +6 -6
- data/lib/shopify-cli/commands/logout.rb +3 -3
- data/lib/shopify-cli/commands/system.rb +33 -33
- data/lib/shopify-cli/commands/version.rb +2 -2
- data/lib/shopify-cli/context.rb +43 -22
- data/lib/shopify-cli/core.rb +4 -4
- data/lib/shopify-cli/core/entry_point.rb +5 -5
- data/lib/shopify-cli/core/executor.rb +1 -1
- data/lib/shopify-cli/core/help_resolver.rb +2 -2
- data/lib/shopify-cli/core/monorail.rb +17 -16
- data/lib/shopify-cli/db.rb +2 -2
- data/lib/shopify-cli/feature.rb +1 -3
- data/lib/shopify-cli/form.rb +1 -1
- data/lib/shopify-cli/git.rb +17 -17
- data/lib/shopify-cli/helpers.rb +1 -1
- data/lib/shopify-cli/helpers/haikunator.rb +1 -1
- data/lib/shopify-cli/heroku.rb +28 -28
- data/lib/shopify-cli/http_request.rb +21 -9
- data/lib/shopify-cli/js_deps.rb +13 -13
- data/lib/shopify-cli/js_system.rb +5 -5
- data/lib/shopify-cli/lazy_delegator.rb +55 -0
- data/lib/shopify-cli/messages/messages.rb +21 -10
- data/lib/shopify-cli/method_object.rb +104 -0
- data/lib/shopify-cli/oauth.rb +25 -25
- data/lib/shopify-cli/oauth/servlet.rb +9 -9
- data/lib/shopify-cli/options.rb +3 -3
- data/lib/shopify-cli/packager.rb +24 -24
- data/lib/shopify-cli/partners_api.rb +38 -16
- data/lib/shopify-cli/partners_api/organizations.rb +10 -10
- data/lib/shopify-cli/process_supervision.rb +8 -8
- data/lib/shopify-cli/project.rb +27 -23
- data/lib/shopify-cli/project_type.rb +21 -5
- data/lib/shopify-cli/resolve_constant.rb +25 -0
- data/lib/shopify-cli/resources.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +9 -9
- data/lib/shopify-cli/result.rb +432 -0
- data/lib/shopify-cli/shopifolk.rb +35 -18
- data/lib/shopify-cli/sub_command.rb +1 -1
- data/lib/shopify-cli/task.rb +9 -1
- data/lib/shopify-cli/tasks.rb +7 -7
- data/lib/shopify-cli/tasks/create_api_client.rb +13 -4
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +12 -12
- data/lib/shopify-cli/tasks/ensure_env.rb +18 -15
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +28 -24
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
- data/lib/shopify-cli/transform_data_structure.rb +86 -0
- data/lib/shopify-cli/tunnel.rb +36 -30
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +57 -52
- data/shopify-cli.gemspec +6 -6
- 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
- data/vendor/gen/template/bin/update-deps +9 -9
- metadata +83 -29
- 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/forms/register.rb +0 -47
- 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
@@ -12,13 +12,13 @@ module Script
|
|
12
12
|
shop_domain: project.env[:shop],
|
13
13
|
extension_point_type: project.extension_point_type
|
14
14
|
)
|
15
|
-
@ctx.puts(@ctx.message(
|
15
|
+
@ctx.puts(@ctx.message("script.disable.script_disabled"))
|
16
16
|
rescue StandardError => e
|
17
|
-
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message(
|
17
|
+
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.disable.error.operation_failed"))
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.help
|
21
|
-
ShopifyCli::Context.message(
|
21
|
+
ShopifyCli::Context.message("script.disable.help", ShopifyCli::TOOL_NAME)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -4,10 +4,10 @@ module Script
|
|
4
4
|
module Commands
|
5
5
|
class Enable < ShopifyCli::Command
|
6
6
|
options do |parser, flags|
|
7
|
-
parser.on(
|
8
|
-
|
9
|
-
|
10
|
-
parser.on(
|
7
|
+
parser.on("--config_props=KEYVALUEPAIRS", Array) { |t| flags[:config_props] = t }
|
8
|
+
parser.on("--config-props=KEYVALUEPAIRS", Array) { |t| flags[:config_props] = t }
|
9
|
+
parser.on("--config_file=CONFIGFILEPATH") { |t| flags[:config_file] = t }
|
10
|
+
parser.on("--config-file=CONFIGFILEPATH") { |t| flags[:config_file] = t }
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(_args, _name)
|
@@ -25,21 +25,21 @@ module Script
|
|
25
25
|
title: project.script_name
|
26
26
|
)
|
27
27
|
@ctx.puts(@ctx.message(
|
28
|
-
|
28
|
+
"script.enable.script_enabled",
|
29
29
|
api_key: api_key,
|
30
30
|
shop_domain: shop_domain,
|
31
31
|
type: project.extension_point_type.capitalize,
|
32
32
|
title: project.script_name
|
33
33
|
))
|
34
|
-
@ctx.puts(@ctx.message(
|
34
|
+
@ctx.puts(@ctx.message("script.enable.info"))
|
35
35
|
rescue Errors::InvalidConfigYAMLError => e
|
36
36
|
UI::ErrorHandler.pretty_print_and_raise(e)
|
37
37
|
rescue StandardError => e
|
38
|
-
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message(
|
38
|
+
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.enable.error.operation_failed"))
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.help
|
42
|
-
ShopifyCli::Context.message(
|
42
|
+
ShopifyCli::Context.message("script.enable.help", ShopifyCli::TOOL_NAME)
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
@@ -47,7 +47,7 @@ module Script
|
|
47
47
|
def acquire_configuration(config_file: nil, config_props: nil)
|
48
48
|
properties = {}
|
49
49
|
properties = YAML.load(File.read(config_file)) unless config_file.nil?
|
50
|
-
properties = properties.merge(config_props) unless config_props.nil?
|
50
|
+
properties = properties.merge(parse_config_props(config_props)) unless config_props.nil?
|
51
51
|
|
52
52
|
configuration = { entries: [] }
|
53
53
|
properties.each do |key, value|
|
@@ -61,6 +61,16 @@ module Script
|
|
61
61
|
raise Errors::InvalidConfigYAMLError, options.flags[:config_file]
|
62
62
|
end
|
63
63
|
|
64
|
+
def parse_config_props(config_props)
|
65
|
+
Hash[
|
66
|
+
config_props.map do |s|
|
67
|
+
args = s.split(":").map(&:strip)
|
68
|
+
raise Errors::InvalidConfigProps unless args.size == 2
|
69
|
+
args
|
70
|
+
end
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
64
74
|
# No slice pre Ruby 2.5 so roll our own
|
65
75
|
def slice(hash, *keys)
|
66
76
|
Hash[hash.to_a - hash.select { |key, _value| !keys.include?(key) }.to_a]
|
@@ -4,31 +4,24 @@ module Script
|
|
4
4
|
module Commands
|
5
5
|
class Push < ShopifyCli::Command
|
6
6
|
options do |parser, flags|
|
7
|
-
parser.on(
|
7
|
+
parser.on("--force") { |t| flags[:force] = t }
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(_args, _name)
|
11
11
|
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
12
|
-
|
13
|
-
api_key =
|
14
|
-
return @ctx.puts(self.class.help) unless api_key
|
15
|
-
|
16
|
-
Layers::Application::PushScript.call(
|
17
|
-
|
18
|
-
language: project.language,
|
19
|
-
extension_point_type: project.extension_point_type,
|
20
|
-
script_name: project.script_name,
|
21
|
-
source_file: project.source_file,
|
22
|
-
api_key: api_key,
|
23
|
-
force: options.flags.key?(:force)
|
24
|
-
)
|
25
|
-
@ctx.puts(@ctx.message('script.push.script_pushed', api_key: api_key))
|
12
|
+
|
13
|
+
api_key = ScriptProject.current.api_key
|
14
|
+
return @ctx.puts(self.class.help) unless api_key
|
15
|
+
|
16
|
+
Layers::Application::PushScript.call(ctx: @ctx, force: options.flags.key?(:force))
|
17
|
+
@ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
|
26
18
|
rescue StandardError => e
|
27
|
-
|
19
|
+
msg = @ctx.message("script.push.error.operation_failed", api_key: ShopifyCli::Project.current.env.api_key)
|
20
|
+
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: msg)
|
28
21
|
end
|
29
22
|
|
30
23
|
def self.help
|
31
|
-
ShopifyCli::Context.message(
|
24
|
+
ShopifyCli::Context.message("script.push.help", ShopifyCli::TOOL_NAME)
|
32
25
|
end
|
33
26
|
end
|
34
27
|
end
|
@@ -1,24 +1,42 @@
|
|
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: "^9.0.0"
|
6
|
+
toolchain-version: "^5.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: "^9.0.0"
|
11
|
+
toolchain-version: "^5.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: "^9.0.0"
|
16
|
+
toolchain-version: "^5.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: "^9.0.0"
|
24
|
+
toolchain-version: "^5.0.0"
|
25
|
+
tax_filter:
|
26
|
+
assemblyscript:
|
27
|
+
package: "@shopify/extension-point-as-tax-filter"
|
28
|
+
sdk-version: "^9.0.0"
|
29
|
+
toolchain-version: "^5.0.0"
|
30
|
+
payment_methods:
|
31
|
+
domain: 'checkout'
|
32
|
+
assemblyscript:
|
33
|
+
package: "@shopify/scripts-checkout-apis"
|
34
|
+
toolchain-version: "^5.0.0"
|
35
|
+
sdk-version: "^9.0.0"
|
36
|
+
shipping_methods:
|
37
|
+
domain: 'checkout'
|
38
|
+
assemblyscript:
|
39
|
+
package: "@shopify/scripts-checkout-apis"
|
40
|
+
sdk-version: "^9.0.0"
|
41
|
+
toolchain-version: "^5.0.0"
|
42
|
+
|
@@ -4,8 +4,10 @@ module Script
|
|
4
4
|
module Errors
|
5
5
|
class InvalidContextError < ScriptProjectError; end
|
6
6
|
class InvalidScriptNameError < ScriptProjectError; end
|
7
|
+
|
7
8
|
class NoExistingAppsError < ScriptProjectError; end
|
8
9
|
class NoExistingOrganizationsError < ScriptProjectError; end
|
10
|
+
|
9
11
|
class NoExistingStoresError < ScriptProjectError
|
10
12
|
attr_reader :organization_id
|
11
13
|
def initialize(organization_id)
|
@@ -13,7 +15,10 @@ module Script
|
|
13
15
|
@organization_id = organization_id
|
14
16
|
end
|
15
17
|
end
|
18
|
+
|
16
19
|
class ScriptProjectAlreadyExistsError < ScriptProjectError; end
|
20
|
+
class InvalidConfigProps < ScriptProjectError; end
|
21
|
+
|
17
22
|
class InvalidConfigYAMLError < ScriptProjectError
|
18
23
|
attr_reader :config_file
|
19
24
|
def initialize(config_file)
|
@@ -21,5 +26,22 @@ module Script
|
|
21
26
|
@config_file = config_file
|
22
27
|
end
|
23
28
|
end
|
29
|
+
|
30
|
+
class InvalidLanguageError < ScriptProjectError
|
31
|
+
attr_reader :language, :extension_point_type
|
32
|
+
def initialize(language, extension_point_type)
|
33
|
+
super()
|
34
|
+
@language = language
|
35
|
+
@extension_point_type = extension_point_type
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class DeprecatedEPError < ScriptProjectError
|
40
|
+
attr_reader :ep
|
41
|
+
def initialize(ep)
|
42
|
+
super()
|
43
|
+
@ep = ep
|
44
|
+
end
|
45
|
+
end
|
24
46
|
end
|
25
47
|
end
|
@@ -3,31 +3,55 @@
|
|
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
|
14
16
|
|
15
17
|
def ask_extension_point
|
16
18
|
CLI::UI::Prompt.ask(
|
17
|
-
@ctx.message(
|
18
|
-
options:
|
19
|
+
@ctx.message("script.forms.create.select_extension_point"),
|
20
|
+
options: Layers::Application::ExtensionPoints.non_deprecated_types
|
19
21
|
)
|
20
22
|
end
|
21
23
|
|
22
24
|
def ask_name
|
23
|
-
CLI::UI::Prompt.ask(@ctx.message(
|
25
|
+
CLI::UI::Prompt.ask(@ctx.message("script.forms.create.script_name"))
|
26
|
+
end
|
27
|
+
|
28
|
+
def ask_description
|
29
|
+
CLI::UI::Prompt.ask(@ctx.message("script.forms.create.description"))
|
24
30
|
end
|
25
31
|
|
26
32
|
def valid_name
|
27
|
-
n = (name || ask_name).downcase.gsub(
|
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,26 @@
|
|
1
1
|
mutation AppScriptUpdateOrCreate(
|
2
2
|
$extensionPointName: ExtensionPointName!,
|
3
3
|
$title: String,
|
4
|
+
$description: String,
|
5
|
+
$configUi: String,
|
4
6
|
$sourceCode: String,
|
5
7
|
$language: String,
|
6
|
-
$force: Boolean
|
8
|
+
$force: Boolean,
|
9
|
+
$schemaMajorVersion: String,
|
10
|
+
$schemaMinorVersion: String,
|
11
|
+
$useMsgpack: Boolean
|
7
12
|
) {
|
8
13
|
appScriptUpdateOrCreate(
|
9
14
|
extensionPointName: $extensionPointName
|
10
15
|
title: $title
|
16
|
+
description: $description
|
17
|
+
configUi: $configUi
|
11
18
|
sourceCode: $sourceCode
|
12
19
|
language: $language
|
13
20
|
force: $force
|
21
|
+
schemaMajorVersion: $schemaMajorVersion
|
22
|
+
schemaMinorVersion: $schemaMinorVersion
|
23
|
+
useMsgpack: $useMsgpack
|
14
24
|
) {
|
15
25
|
userErrors {
|
16
26
|
field
|
@@ -22,6 +32,7 @@ mutation AppScriptUpdateOrCreate(
|
|
22
32
|
configSchema
|
23
33
|
extensionPointName
|
24
34
|
title
|
35
|
+
description
|
25
36
|
}
|
26
37
|
}
|
27
38
|
}
|
@@ -5,33 +5,33 @@ 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_project:, config_ui:)
|
9
|
+
CLI::UI::Frame.open(ctx.message("script.application.building")) do
|
10
10
|
begin
|
11
|
-
UI::StrictSpinner.spin(ctx.message(
|
12
|
-
|
13
|
-
|
11
|
+
UI::StrictSpinner.spin(ctx.message("script.application.building_script")) do |spinner|
|
12
|
+
Infrastructure::PushPackageRepository.new(ctx: ctx).create_push_package(
|
13
|
+
script_project: script_project,
|
14
|
+
script_content: task_runner.build,
|
15
|
+
compiled_type: task_runner.compiled_type,
|
16
|
+
metadata: task_runner.metadata,
|
17
|
+
config_ui: config_ui,
|
18
|
+
)
|
19
|
+
spinner.update_title(ctx.message("script.application.built"))
|
14
20
|
end
|
15
|
-
true
|
16
21
|
rescue StandardError => e
|
17
22
|
CLI::UI::Frame.with_frame_color_override(:red) do
|
18
23
|
ctx.puts("\n{{red:#{e.message}}}")
|
19
24
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
errors = [
|
26
|
+
Infrastructure::Errors::InvalidBuildScriptError,
|
27
|
+
Infrastructure::Errors::BuildScriptNotFoundError,
|
28
|
+
Infrastructure::Errors::WebAssemblyBinaryNotFoundError,
|
29
|
+
]
|
25
30
|
|
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
|
31
|
+
raise Infrastructure::Errors::BuildError unless errors.any? { |err| e.is_a?(err) }
|
32
|
+
raise
|
33
|
+
end
|
32
34
|
end
|
33
|
-
Infrastructure::PushPackageRepository.new(ctx: ctx)
|
34
|
-
.create_push_package(script, script_content, task_runner.compiled_type)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -7,42 +7,75 @@ 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:, no_config_ui:)
|
11
11
|
extension_point = ExtensionPoints.get(type: extension_point_type)
|
12
|
-
project = setup_project(
|
12
|
+
project = setup_project(
|
13
|
+
ctx: ctx,
|
14
|
+
language: language,
|
15
|
+
script_name: script_name,
|
16
|
+
extension_point: extension_point,
|
17
|
+
description: description,
|
18
|
+
no_config_ui: no_config_ui
|
19
|
+
)
|
13
20
|
project_creator = Infrastructure::ProjectCreator
|
14
21
|
.for(ctx, language, extension_point, script_name, project.directory)
|
15
|
-
install_dependencies(ctx, language, script_name,
|
16
|
-
bootstrap(ctx,
|
22
|
+
install_dependencies(ctx, language, script_name, project_creator)
|
23
|
+
bootstrap(ctx, project_creator)
|
17
24
|
project
|
18
25
|
end
|
19
26
|
|
20
27
|
private
|
21
28
|
|
22
|
-
|
29
|
+
DEFAULT_CONFIG_UI_FILENAME = "config-ui.yml"
|
30
|
+
|
31
|
+
def setup_project(ctx:, language:, script_name:, extension_point:, description:, no_config_ui:)
|
23
32
|
ScriptProject.create(ctx, script_name)
|
33
|
+
|
34
|
+
identifiers = {
|
35
|
+
extension_point_type: extension_point.type,
|
36
|
+
script_name: script_name,
|
37
|
+
language: language,
|
38
|
+
description: description,
|
39
|
+
}
|
40
|
+
|
41
|
+
unless no_config_ui
|
42
|
+
require "yaml" # takes 20ms, so deferred as late as possible.
|
43
|
+
identifiers.merge!(config_ui_file: DEFAULT_CONFIG_UI_FILENAME)
|
44
|
+
Infrastructure::ConfigUiRepository
|
45
|
+
.new(ctx: ctx)
|
46
|
+
.create_config_ui(DEFAULT_CONFIG_UI_FILENAME, default_config_ui_content(script_name))
|
47
|
+
end
|
48
|
+
|
24
49
|
ScriptProject.write(
|
25
50
|
ctx,
|
26
51
|
project_type: :script,
|
27
52
|
organization_id: nil, # TODO: can you provide this at creation
|
28
|
-
|
29
|
-
script_name: script_name
|
53
|
+
**identifiers
|
30
54
|
)
|
31
55
|
ScriptProject.current
|
32
56
|
end
|
33
57
|
|
34
|
-
def install_dependencies(ctx, language, script_name,
|
35
|
-
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name
|
58
|
+
def install_dependencies(ctx, language, script_name, project_creator)
|
59
|
+
task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name)
|
36
60
|
project_creator.setup_dependencies
|
37
61
|
ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
|
38
62
|
end
|
39
63
|
|
40
|
-
def bootstrap(ctx,
|
41
|
-
UI::StrictSpinner.spin(ctx.message(
|
64
|
+
def bootstrap(ctx, project_creator)
|
65
|
+
UI::StrictSpinner.spin(ctx.message("script.create.creating")) do |spinner|
|
42
66
|
project_creator.bootstrap
|
43
|
-
spinner.update_title(ctx.message(
|
67
|
+
spinner.update_title(ctx.message("script.create.created"))
|
44
68
|
end
|
45
69
|
end
|
70
|
+
|
71
|
+
def default_config_ui_content(title)
|
72
|
+
YAML.dump({
|
73
|
+
"version" => 1,
|
74
|
+
"type" => "single",
|
75
|
+
"title" => title,
|
76
|
+
"fields" => [],
|
77
|
+
})
|
78
|
+
end
|
46
79
|
end
|
47
80
|
end
|
48
81
|
end
|