shopify-cli 1.3.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/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 +12 -11
- data/Gemfile.lock +39 -37
- data/README.md +39 -7
- data/RELEASING.md +19 -29
- 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 +11 -11
- data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
- data/lib/project_types/extension/cli.rb +64 -47
- data/lib/project_types/extension/commands/build.rb +3 -3
- data/lib/project_types/extension/commands/create.rb +16 -9
- data/lib/project_types/extension/commands/extension_command.rb +8 -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 +2 -2
- data/lib/project_types/extension/commands/tunnel.rb +12 -12
- data/lib/project_types/extension/extension_project.rb +4 -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 +36 -0
- data/lib/project_types/extension/messages/messages.rb +53 -52
- data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
- 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/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 +38 -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 +46 -38
- 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 +7 -7
- data/lib/project_types/node/messages/messages.rb +19 -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 +60 -54
- 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 +24 -24
- data/lib/project_types/rails/gem.rb +24 -24
- data/lib/project_types/rails/messages/messages.rb +12 -9
- data/lib/project_types/rails/ruby.rb +2 -2
- data/lib/project_types/script/cli.rb +42 -38
- data/lib/project_types/script/commands/create.rb +13 -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 +17 -12
- data/lib/project_types/script/errors.rb +38 -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 +18 -19
- data/lib/project_types/script/layers/application/create_script.rb +13 -11
- 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 +12 -18
- 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 +29 -6
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +19 -54
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +49 -18
- data/lib/project_types/script/layers/infrastructure/errors.rb +17 -1
- 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 +26 -16
- data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
- data/lib/project_types/script/messages/messages.rb +67 -10
- data/lib/project_types/script/script_project.rb +47 -16
- data/lib/project_types/script/ui/error_handler.rb +115 -45
- 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 +38 -37
- 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 +40 -31
- 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 +6 -6
- 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 +21 -19
- 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 +27 -0
- 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 +24 -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 +84 -0
- 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 +17 -6
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +11 -11
- 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 +29 -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 -51
- 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 +84 -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
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Script
|
|
4
|
+
module Layers
|
|
5
|
+
module Infrastructure
|
|
6
|
+
class RustProjectCreator
|
|
7
|
+
include SmartProperties
|
|
8
|
+
property! :ctx, accepts: ShopifyCli::Context
|
|
9
|
+
property! :extension_point, accepts: Domain::ExtensionPoint
|
|
10
|
+
property! :script_name, accepts: String
|
|
11
|
+
property! :path_to_project, accepts: String
|
|
12
|
+
|
|
13
|
+
ORIGIN_BRANCH = "main"
|
|
14
|
+
SAMPLE_PATH = "default"
|
|
15
|
+
|
|
16
|
+
def setup_dependencies
|
|
17
|
+
git_init
|
|
18
|
+
setup_remote
|
|
19
|
+
setup_sparse_checkout
|
|
20
|
+
pull
|
|
21
|
+
clean
|
|
22
|
+
set_script_name
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def bootstrap
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def git_init
|
|
31
|
+
out, status = ctx.capture2e("git init")
|
|
32
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def setup_remote
|
|
36
|
+
repo = extension_point.sdks.rust.package
|
|
37
|
+
out, status = ctx.capture2e("git remote add -f origin #{repo}")
|
|
38
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def setup_sparse_checkout
|
|
42
|
+
type = extension_point.type
|
|
43
|
+
out, status = ctx.capture2e("git config core.sparsecheckout true")
|
|
44
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
|
45
|
+
out, status = ctx.capture2e("echo #{type}/#{SAMPLE_PATH} >> .git/info/sparse-checkout")
|
|
46
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def pull
|
|
50
|
+
out, status = ctx.capture2e("git pull origin #{ORIGIN_BRANCH}")
|
|
51
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def clean
|
|
55
|
+
type = extension_point.type
|
|
56
|
+
ctx.rm_rf(".git")
|
|
57
|
+
source = File.join(path_to_project, File.join(type, SAMPLE_PATH))
|
|
58
|
+
FileUtils.copy_entry(source, path_to_project)
|
|
59
|
+
ctx.rm_rf(type)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def set_script_name
|
|
63
|
+
config_file = "Cargo.toml"
|
|
64
|
+
upstream_name = "#{extension_point.type.gsub("_", "-")}-default"
|
|
65
|
+
contents = File.read(config_file)
|
|
66
|
+
new_contents = contents.sub(upstream_name, script_name)
|
|
67
|
+
File.write(config_file, new_contents)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Script
|
|
3
|
+
module Layers
|
|
4
|
+
module Infrastructure
|
|
5
|
+
class RustTaskRunner
|
|
6
|
+
attr_reader :ctx, :script_name
|
|
7
|
+
|
|
8
|
+
BUILD_TARGET = "wasm32-unknown-unknown"
|
|
9
|
+
METADATA_FILE = "build/metadata.json"
|
|
10
|
+
|
|
11
|
+
def initialize(ctx, script_name)
|
|
12
|
+
@ctx = ctx
|
|
13
|
+
@script_name = script_name
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def dependencies_installed?
|
|
17
|
+
true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def install_dependencies
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def build
|
|
24
|
+
compile
|
|
25
|
+
bytecode
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def compiled_type
|
|
29
|
+
"wasm"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def metadata
|
|
33
|
+
unless @ctx.file_exist?(METADATA_FILE)
|
|
34
|
+
msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE)
|
|
35
|
+
raise Domain::Errors::MetadataNotFoundError, msg
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
raw_contents = File.read(METADATA_FILE)
|
|
39
|
+
Domain::Metadata.create_from_json(@ctx, raw_contents)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def compile
|
|
45
|
+
out, status = ctx.capture2e("cargo build --target=#{BUILD_TARGET} --release")
|
|
46
|
+
raise Domain::Errors::ServiceFailureError, out unless status.success?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def bytecode
|
|
50
|
+
binary_name = "#{script_name}.wasm"
|
|
51
|
+
binary_path = "target/#{BUILD_TARGET}/release/#{binary_name}"
|
|
52
|
+
raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(binary_path)
|
|
53
|
+
|
|
54
|
+
File.read(binary_path)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -15,23 +15,31 @@ module Script
|
|
|
15
15
|
script_name:,
|
|
16
16
|
script_content:,
|
|
17
17
|
compiled_type:,
|
|
18
|
+
description: nil,
|
|
18
19
|
api_key: nil,
|
|
19
|
-
force: false
|
|
20
|
+
force: false,
|
|
21
|
+
metadata:,
|
|
22
|
+
config_ui:
|
|
20
23
|
)
|
|
21
24
|
query_name = "app_script_update_or_create"
|
|
22
25
|
variables = {
|
|
23
26
|
extensionPointName: extension_point_type.upcase,
|
|
24
27
|
title: script_name,
|
|
28
|
+
description: description,
|
|
29
|
+
configUi: config_ui,
|
|
25
30
|
sourceCode: Base64.encode64(script_content),
|
|
26
31
|
language: compiled_type,
|
|
27
32
|
force: force,
|
|
33
|
+
schemaMajorVersion: metadata.schema_major_version.to_s, # API expects string value
|
|
34
|
+
schemaMinorVersion: metadata.schema_minor_version.to_s, # API expects string value
|
|
35
|
+
useMsgpack: metadata.use_msgpack,
|
|
28
36
|
}
|
|
29
37
|
resp_hash = script_service_request(query_name: query_name, api_key: api_key, variables: variables)
|
|
30
38
|
user_errors = resp_hash["data"]["appScriptUpdateOrCreate"]["userErrors"]
|
|
31
39
|
|
|
32
40
|
return resp_hash if user_errors.empty?
|
|
33
41
|
|
|
34
|
-
if user_errors.any? { |e| e[
|
|
42
|
+
if user_errors.any? { |e| e["tag"] == "already_exists_error" }
|
|
35
43
|
raise Errors::ScriptRepushError, api_key
|
|
36
44
|
else
|
|
37
45
|
raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
|
|
@@ -56,11 +64,11 @@ module Script
|
|
|
56
64
|
|
|
57
65
|
return resp_hash if user_errors.empty?
|
|
58
66
|
|
|
59
|
-
if user_errors.any? { |e| e[
|
|
67
|
+
if user_errors.any? { |e| e["tag"] == "app_script_not_found" }
|
|
60
68
|
raise Errors::AppScriptUndefinedError, api_key
|
|
61
|
-
elsif user_errors.any? { |e| e[
|
|
69
|
+
elsif user_errors.any? { |e| e["tag"] == "shop_script_conflict" }
|
|
62
70
|
raise Errors::ShopScriptConflictError
|
|
63
|
-
elsif user_errors.any? { |e| e[
|
|
71
|
+
elsif user_errors.any? { |e| e["tag"] == "app_script_not_pushed" }
|
|
64
72
|
raise Errors::AppScriptNotPushedError
|
|
65
73
|
else
|
|
66
74
|
raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
|
|
@@ -82,7 +90,7 @@ module Script
|
|
|
82
90
|
user_errors = resp_hash["data"]["shopScriptDelete"]["userErrors"]
|
|
83
91
|
return resp_hash if user_errors.empty?
|
|
84
92
|
|
|
85
|
-
if user_errors.any? { |e| e[
|
|
93
|
+
if user_errors.any? { |e| e["tag"] == "shop_script_not_found" }
|
|
86
94
|
raise Errors::ShopScriptUndefinedError, api_key
|
|
87
95
|
else
|
|
88
96
|
raise Errors::ScriptServiceUserError.new(query_name, user_errors.to_s)
|
|
@@ -106,8 +114,8 @@ module Script
|
|
|
106
114
|
def self.api_client(ctx, api_key, shop_domain)
|
|
107
115
|
new(
|
|
108
116
|
ctx: ctx,
|
|
109
|
-
url:
|
|
110
|
-
token:
|
|
117
|
+
url: "https://script-service.myshopify.io/graphql",
|
|
118
|
+
token: "",
|
|
111
119
|
api_key: api_key,
|
|
112
120
|
shop_id: shop_domain&.to_i
|
|
113
121
|
)
|
|
@@ -142,26 +150,28 @@ module Script
|
|
|
142
150
|
options[:variables] = variables.to_json if variables
|
|
143
151
|
resp = PartnersProxyAPI.query(ctx, query_name, **options)
|
|
144
152
|
raise_if_graphql_failed(resp)
|
|
145
|
-
JSON.parse(resp[
|
|
153
|
+
JSON.parse(resp["data"]["scriptServiceProxy"])
|
|
146
154
|
end
|
|
147
155
|
|
|
148
156
|
def raise_if_graphql_failed(response)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
raise Errors::EmptyResponseError if response.nil?
|
|
158
|
+
|
|
159
|
+
return unless response.key?("errors")
|
|
160
|
+
case error_code(response["errors"])
|
|
161
|
+
when "forbidden"
|
|
152
162
|
raise Errors::ForbiddenError
|
|
153
|
-
when
|
|
163
|
+
when "forbidden_on_shop"
|
|
154
164
|
raise Errors::ShopAuthenticationError
|
|
155
|
-
when
|
|
165
|
+
when "app_not_installed_on_shop"
|
|
156
166
|
raise Errors::AppNotInstalledError
|
|
157
167
|
else
|
|
158
|
-
raise Errors::GraphqlError, response[
|
|
168
|
+
raise Errors::GraphqlError, response["errors"].map { |e| e["message"] }
|
|
159
169
|
end
|
|
160
170
|
end
|
|
161
171
|
|
|
162
172
|
def error_code(errors)
|
|
163
173
|
errors.map do |e|
|
|
164
|
-
code = e.dig(
|
|
174
|
+
code = e.dig("extensions", "code")
|
|
165
175
|
return code if code
|
|
166
176
|
end
|
|
167
177
|
end
|
|
@@ -5,12 +5,13 @@ module Script
|
|
|
5
5
|
module Infrastructure
|
|
6
6
|
class TaskRunner
|
|
7
7
|
TASK_RUNNERS = {
|
|
8
|
-
"
|
|
8
|
+
"assemblyscript" => Infrastructure::AssemblyScriptTaskRunner,
|
|
9
|
+
"rust" => Infrastructure::RustTaskRunner,
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
def self.for(ctx, language, script_name
|
|
12
|
+
def self.for(ctx, language, script_name)
|
|
12
13
|
raise Errors::TaskRunnerNotFoundError unless TASK_RUNNERS[language]
|
|
13
|
-
TASK_RUNNERS[language].new(ctx, script_name
|
|
14
|
+
TASK_RUNNERS[language].new(ctx, script_name)
|
|
14
15
|
end
|
|
15
16
|
end
|
|
16
17
|
end
|
|
@@ -5,6 +5,9 @@ module Script
|
|
|
5
5
|
MESSAGES = {
|
|
6
6
|
script: {
|
|
7
7
|
error: {
|
|
8
|
+
deprecated_ep: "This project uses an extension point %s which has been deprecated. "\
|
|
9
|
+
"This Script will no longer function in production.",
|
|
10
|
+
deprecated_ep_cause: "Try using a different extension point.",
|
|
8
11
|
generic: "{{red:{{x}} Error}}",
|
|
9
12
|
eacces_cause: "You don't have permission to write to this directory.",
|
|
10
13
|
eacces_help: "Change your directory permissions and try again.",
|
|
@@ -18,16 +21,20 @@ module Script
|
|
|
18
21
|
invalid_context_cause: "Your .shopify-cli.yml file is not correct.",
|
|
19
22
|
invalid_context_help: "See https://help.shopify.com",
|
|
20
23
|
|
|
24
|
+
invalid_config_props_cause: "{{command:--config-props}} is formatted incorrectly.",
|
|
25
|
+
invalid_config_props_help: "Try again using this format: "\
|
|
26
|
+
"{{cyan:--config-props='name1:value1, name2:value2'}}",
|
|
27
|
+
|
|
21
28
|
invalid_script_name_cause: "Invalid script name.",
|
|
22
29
|
invalid_script_name_help: "Replace or remove unsupported characters. Valid characters "\
|
|
23
30
|
"are numbers, letters, hyphens, or underscores.",
|
|
24
31
|
|
|
25
32
|
no_existing_apps_cause: "You don't have any apps.",
|
|
26
|
-
no_existing_apps_help: "
|
|
33
|
+
no_existing_apps_help: "Create an app with {{command:shopify create}} or "\
|
|
27
34
|
"visit https://partners.shopify.com/.",
|
|
28
35
|
|
|
29
36
|
no_existing_orgs_cause: "You don't have any partner organizations.",
|
|
30
|
-
no_existing_orgs_help: "
|
|
37
|
+
no_existing_orgs_help: "Visit https://partners.shopify.com/ to create a partners account.",
|
|
31
38
|
|
|
32
39
|
no_existing_stores_cause: "You don't have any stores.",
|
|
33
40
|
no_existing_stores_help: "Visit https://partners.shopify.com/%{organization_id}/stores/ to create one.",
|
|
@@ -35,14 +42,45 @@ module Script
|
|
|
35
42
|
project_exists_cause: "Directory with the same name as the script already exists.",
|
|
36
43
|
project_exists_help: "Use different script name and try again.",
|
|
37
44
|
|
|
38
|
-
invalid_extension_cause: "Invalid extension point %s",
|
|
45
|
+
invalid_extension_cause: "Invalid extension point %s.",
|
|
39
46
|
invalid_extension_help: "Allowed values: %s.",
|
|
40
47
|
|
|
48
|
+
invalid_language_cause: "Invalid language %s.",
|
|
49
|
+
invalid_language_help: "Allowed values: %s.",
|
|
50
|
+
|
|
41
51
|
invalid_config: "Can't change the configuration values because %1$s is missing or "\
|
|
42
52
|
"it is not formatted properly.",
|
|
43
53
|
|
|
54
|
+
invalid_config_ui_definition_cause: "The UI configuration file %s contains invalid YAML.",
|
|
55
|
+
invalid_config_ui_definition_help: "Fix the errors and try again.",
|
|
56
|
+
|
|
57
|
+
missing_config_ui_definition_cause: "You are missing the UI configuration file %s.",
|
|
58
|
+
missing_config_ui_definition_help: "Create this file and try again.",
|
|
59
|
+
|
|
44
60
|
script_not_found_cause: "Couldn't find script %s for extension point %s",
|
|
45
61
|
|
|
62
|
+
service_failure_cause: "Internal service error.",
|
|
63
|
+
service_failure_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
|
|
64
|
+
|
|
65
|
+
user_error_cause: "Invalid script extension metadata.",
|
|
66
|
+
user_error_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
|
|
67
|
+
|
|
68
|
+
metadata_validation_cause: "Invalid script extension metadata.",
|
|
69
|
+
metadata_validation_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date.",
|
|
70
|
+
|
|
71
|
+
metadata_schema_versions_missing: "Invalid script metadata:" \
|
|
72
|
+
" 'schemaVersions' field is missing",
|
|
73
|
+
metadata_schema_versions_single_key: "Invalid script extension metadata:" \
|
|
74
|
+
" 'schemaVersions' can have only one extension point name.",
|
|
75
|
+
metadata_schema_versions_missing_major: "Invalid script extension metadata:" \
|
|
76
|
+
" 'schemaVersions' is missing the 'major' field",
|
|
77
|
+
metadata_schema_versions_missing_minor: "Invalid script extension metadata:" \
|
|
78
|
+
" 'schemaVersions' is missing the 'minor' field",
|
|
79
|
+
|
|
80
|
+
metadata_not_found_cause: "Script version file (%s) cannot be found.",
|
|
81
|
+
metadata_not_found_help: "Ensure the 'shopify/scripts-toolchain-as' package is up to date and " \
|
|
82
|
+
"'package.json' contains a 'scripts/build' entry with a " \
|
|
83
|
+
"'--metadata build/metadata.json' argument",
|
|
46
84
|
app_not_installed_cause: "App not installed on store.",
|
|
47
85
|
|
|
48
86
|
app_script_not_pushed_help: "Script isn't on the app. Run {{command:shopify push}}, and then try again.",
|
|
@@ -53,6 +91,9 @@ module Script
|
|
|
53
91
|
dependency_install_cause: "Something went wrong while installing the dependencies that are needed.",
|
|
54
92
|
dependency_install_help: "Correct the errors and try again.",
|
|
55
93
|
|
|
94
|
+
failed_api_request_cause: "Something went wrong while communicating with Shopify.",
|
|
95
|
+
failed_api_request_help: "Try again.",
|
|
96
|
+
|
|
56
97
|
forbidden_error_cause: "You do not have permission to do this action.",
|
|
57
98
|
|
|
58
99
|
graphql_error_cause: "An error was returned: %s.",
|
|
@@ -70,8 +111,21 @@ module Script
|
|
|
70
111
|
|
|
71
112
|
shop_script_undefined_cause: "Script is already turned off in store.",
|
|
72
113
|
|
|
73
|
-
packages_outdated_cause: "
|
|
74
|
-
packages_outdated_help: "
|
|
114
|
+
packages_outdated_cause: "These npm packages are out of date: %s.",
|
|
115
|
+
packages_outdated_help: "To update them, run {{cyan:npm install --save-dev %s}}.",
|
|
116
|
+
|
|
117
|
+
invalid_build_script: "The root package.json contains an invalid build command that " \
|
|
118
|
+
"is needed to compile your script to WebAssembly.",
|
|
119
|
+
build_script_not_found: "The root package.json is missing the build command that " \
|
|
120
|
+
"is needed to compile your script to WebAssembly.",
|
|
121
|
+
# rubocop:disable Layout/LineLength
|
|
122
|
+
build_script_suggestion: "\n\nFor example, your package.json needs the following command:" \
|
|
123
|
+
"\nbuild: npx shopify-scripts-toolchain-as build --src src/script.ts --binary build/<script_name>.wasm --metadata build/metadata.json -- --lib node_modules --optimize --use Date=",
|
|
124
|
+
|
|
125
|
+
web_assembly_binary_not_found: "WebAssembly binary not found.",
|
|
126
|
+
web_assembly_binary_not_found_suggestion: "No WebAssembly binary found." \
|
|
127
|
+
"Check that your build npm script outputs the generated binary to the root of the directory." \
|
|
128
|
+
"Generated binary should match the script name: <script_name>.wasm",
|
|
75
129
|
},
|
|
76
130
|
|
|
77
131
|
create: {
|
|
@@ -80,7 +134,8 @@ module Script
|
|
|
80
134
|
Usage: {{command:%1$s create script}}
|
|
81
135
|
Options:
|
|
82
136
|
{{command:--name=NAME}} Script project name. Use any string.
|
|
83
|
-
{{command:--
|
|
137
|
+
{{command:--description=DESCRIPTION}} Description of the project. Use any string.
|
|
138
|
+
{{command:--extension-point=TYPE}} Extension point name. Allowed values: %2$s.
|
|
84
139
|
HELP
|
|
85
140
|
|
|
86
141
|
error: {
|
|
@@ -89,7 +144,7 @@ module Script
|
|
|
89
144
|
|
|
90
145
|
change_directory_notice: "{{*}} Change directories to {{green:%s}} to run script commands",
|
|
91
146
|
creating: "Creating script",
|
|
92
|
-
created: "Created script
|
|
147
|
+
created: "Created script",
|
|
93
148
|
},
|
|
94
149
|
|
|
95
150
|
push: {
|
|
@@ -101,7 +156,7 @@ module Script
|
|
|
101
156
|
HELP
|
|
102
157
|
|
|
103
158
|
error: {
|
|
104
|
-
operation_failed: "Couldn't push script to app.",
|
|
159
|
+
operation_failed: "Couldn't push script to app (API key: %{api_key}).",
|
|
105
160
|
},
|
|
106
161
|
|
|
107
162
|
script_pushed: "{{v}} Script pushed to app (API key: %{api_key}).",
|
|
@@ -125,8 +180,8 @@ module Script
|
|
|
125
180
|
Turn on script in store.
|
|
126
181
|
Usage: {{command:%s enable}}
|
|
127
182
|
Options:
|
|
128
|
-
{{command:--
|
|
129
|
-
{{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --
|
|
183
|
+
{{command:--config-props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config-props will override those set in the file.
|
|
184
|
+
{{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --config-props values override properties in this file.
|
|
130
185
|
HELP
|
|
131
186
|
|
|
132
187
|
info: "{{*}} A script always remains enabled until you disable it - even after pushing "\
|
|
@@ -151,7 +206,9 @@ module Script
|
|
|
151
206
|
forms: {
|
|
152
207
|
create: {
|
|
153
208
|
select_extension_point: "Which extension point do you want to use?",
|
|
209
|
+
select_language: "Which language do you want to use?",
|
|
154
210
|
script_name: "Script Name",
|
|
211
|
+
description: "Description",
|
|
155
212
|
},
|
|
156
213
|
},
|
|
157
214
|
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
module Script
|
|
4
4
|
class ScriptProject < ShopifyCli::Project
|
|
5
|
-
|
|
6
|
-
SOURCE_DIR = "src"
|
|
7
|
-
|
|
8
|
-
attr_reader :extension_point_type, :script_name, :language
|
|
5
|
+
attr_reader :extension_point_type, :script_name, :language, :description, :config_ui
|
|
9
6
|
|
|
10
7
|
def initialize(*args)
|
|
11
8
|
super
|
|
12
|
-
@extension_point_type = lookup_config(
|
|
13
|
-
@
|
|
14
|
-
@
|
|
9
|
+
@extension_point_type = lookup_config!("extension_point_type")
|
|
10
|
+
raise Errors::DeprecatedEPError, @extension_point_type if deprecated?(@extension_point_type)
|
|
11
|
+
@script_name = lookup_config!("script_name")
|
|
12
|
+
@description = lookup_config("description")
|
|
13
|
+
@config_ui = lookup_config_ui
|
|
14
|
+
@language = lookup_language
|
|
15
15
|
ShopifyCli::Core::Monorail.metadata = {
|
|
16
16
|
"script_name" => @script_name,
|
|
17
17
|
"extension_point_type" => @extension_point_type,
|
|
@@ -19,25 +19,56 @@ module Script
|
|
|
19
19
|
}
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
|
|
22
|
+
def api_key
|
|
23
|
+
env[:api_key]
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
"#{SOURCE_DIR}/#{file_name}"
|
|
28
|
-
end
|
|
26
|
+
private
|
|
29
27
|
|
|
30
|
-
def
|
|
31
|
-
|
|
28
|
+
def deprecated?(ep)
|
|
29
|
+
Script::Layers::Application::ExtensionPoints.deprecated_types.include?(ep)
|
|
32
30
|
end
|
|
33
31
|
|
|
34
|
-
private
|
|
35
|
-
|
|
36
32
|
def lookup_config(key)
|
|
33
|
+
return nil unless config.key?(key)
|
|
34
|
+
config[key]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def lookup_config!(key)
|
|
37
38
|
raise Errors::InvalidContextError, key unless config.key?(key)
|
|
38
39
|
config[key]
|
|
39
40
|
end
|
|
40
41
|
|
|
42
|
+
def lookup_config_ui
|
|
43
|
+
filename = lookup_config("config_ui_file")
|
|
44
|
+
return nil unless filename
|
|
45
|
+
|
|
46
|
+
path = File.join(directory, filename)
|
|
47
|
+
raise Errors::MissingSpecifiedConfigUiDefinitionError, filename unless File.exist?(path)
|
|
48
|
+
|
|
49
|
+
contents = File.read(path)
|
|
50
|
+
raise Errors::InvalidConfigUiDefinitionError, filename unless valid_config_ui?(contents)
|
|
51
|
+
|
|
52
|
+
contents
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def lookup_language
|
|
56
|
+
lang = lookup_config("language")&.downcase || Layers::Domain::ExtensionPointAssemblyScriptSDK.language
|
|
57
|
+
if Layers::Application::ExtensionPoints.supported_language?(type: extension_point_type, language: lang)
|
|
58
|
+
lang
|
|
59
|
+
else
|
|
60
|
+
raise Errors::InvalidLanguageError.new(lang, extension_point_type)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def valid_config_ui?(raw_yaml)
|
|
65
|
+
require "yaml" # takes 20ms, so deferred as late as possible.
|
|
66
|
+
YAML.safe_load(raw_yaml)
|
|
67
|
+
true
|
|
68
|
+
rescue Psych::SyntaxError
|
|
69
|
+
false
|
|
70
|
+
end
|
|
71
|
+
|
|
41
72
|
class << self
|
|
42
73
|
def create(ctx, dir)
|
|
43
74
|
raise Errors::ScriptProjectAlreadyExistsError, dir if ctx.dir_exist?(dir)
|