shopify-cli 1.3.1 → 1.7.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 +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
data/lib/shopify-cli/helpers.rb
CHANGED
data/lib/shopify-cli/heroku.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module ShopifyCli
|
2
2
|
class Heroku
|
3
3
|
DOWNLOAD_URLS = {
|
4
|
-
linux:
|
5
|
-
mac:
|
6
|
-
windows:
|
4
|
+
linux: "https://cli-assets.heroku.com/heroku-linux-x64.tar.gz",
|
5
|
+
mac: "https://cli-assets.heroku.com/heroku-darwin-x64.tar.gz",
|
6
|
+
windows: "https://cli-assets.heroku.com/heroku-x64.exe",
|
7
7
|
}
|
8
8
|
|
9
9
|
def initialize(ctx)
|
@@ -12,33 +12,33 @@ module ShopifyCli
|
|
12
12
|
|
13
13
|
def app
|
14
14
|
return nil unless (app = git_remote)
|
15
|
-
app = app.split(
|
16
|
-
app = app.split(
|
15
|
+
app = app.split("/").last
|
16
|
+
app = app.split(".").first
|
17
17
|
app
|
18
18
|
end
|
19
19
|
|
20
20
|
def authenticate
|
21
|
-
result = @ctx.system(heroku_command,
|
22
|
-
@ctx.abort(@ctx.message(
|
21
|
+
result = @ctx.system(heroku_command, "login")
|
22
|
+
@ctx.abort(@ctx.message("core.heroku.error.authentication")) unless result.success?
|
23
23
|
end
|
24
24
|
|
25
25
|
def create_new_app
|
26
|
-
output, status = @ctx.capture2e(heroku_command,
|
27
|
-
@ctx.abort(@ctx.message(
|
26
|
+
output, status = @ctx.capture2e(heroku_command, "create")
|
27
|
+
@ctx.abort(@ctx.message("core.heroku.error.creation")) unless status.success?
|
28
28
|
@ctx.puts(output)
|
29
29
|
end
|
30
30
|
|
31
31
|
def deploy(branch_to_deploy)
|
32
|
-
result = @ctx.system(
|
33
|
-
@ctx.abort(@ctx.message(
|
32
|
+
result = @ctx.system("git", "push", "-u", "heroku", "#{branch_to_deploy}:master")
|
33
|
+
@ctx.abort(@ctx.message("core.heroku.error.deploy")) unless result.success?
|
34
34
|
end
|
35
35
|
|
36
36
|
def download
|
37
37
|
return if installed?
|
38
38
|
|
39
|
-
result = @ctx.system(
|
40
|
-
@ctx.abort(@ctx.message(
|
41
|
-
@ctx.abort(@ctx.message(
|
39
|
+
result = @ctx.system("curl", "-o", download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli.cache_dir)
|
40
|
+
@ctx.abort(@ctx.message("core.heroku.error.download")) unless result.success?
|
41
|
+
@ctx.abort(@ctx.message("core.heroku.error.download")) unless File.exist?(download_path)
|
42
42
|
end
|
43
43
|
|
44
44
|
def install
|
@@ -47,22 +47,22 @@ module ShopifyCli
|
|
47
47
|
result = if @ctx.windows?
|
48
48
|
@ctx.system("\"#{download_path}\"")
|
49
49
|
else
|
50
|
-
@ctx.system(
|
50
|
+
@ctx.system("tar", "-xf", download_path, chdir: ShopifyCli.cache_dir)
|
51
51
|
end
|
52
|
-
@ctx.abort(@ctx.message(
|
52
|
+
@ctx.abort(@ctx.message("core.heroku.error.install")) unless result.success?
|
53
53
|
|
54
54
|
@ctx.rm(download_path)
|
55
55
|
end
|
56
56
|
|
57
57
|
def select_existing_app(app_name)
|
58
|
-
result = @ctx.system(heroku_command,
|
58
|
+
result = @ctx.system(heroku_command, "git:remote", "-a", app_name)
|
59
59
|
|
60
|
-
msg = @ctx.message(
|
60
|
+
msg = @ctx.message("core.heroku.error.could_not_select_app", app_name)
|
61
61
|
@ctx.abort(msg) unless result.success?
|
62
62
|
end
|
63
63
|
|
64
64
|
def whoami
|
65
|
-
output, status = @ctx.capture2e(heroku_command,
|
65
|
+
output, status = @ctx.capture2e(heroku_command, "whoami")
|
66
66
|
return output.strip if status.success?
|
67
67
|
nil
|
68
68
|
end
|
@@ -70,7 +70,7 @@ module ShopifyCli
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def download_filename
|
73
|
-
URI.parse(DOWNLOAD_URLS[@ctx.os]).path.split(
|
73
|
+
URI.parse(DOWNLOAD_URLS[@ctx.os]).path.split("/").last
|
74
74
|
end
|
75
75
|
|
76
76
|
def download_path
|
@@ -78,33 +78,33 @@ module ShopifyCli
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def git_remote
|
81
|
-
output, status = @ctx.capture2e(
|
81
|
+
output, status = @ctx.capture2e("git", "remote", "get-url", "heroku")
|
82
82
|
status.success? ? output : nil
|
83
83
|
end
|
84
84
|
|
85
85
|
def heroku_command
|
86
|
-
local_path = File.join(ShopifyCli.cache_dir,
|
86
|
+
local_path = File.join(ShopifyCli.cache_dir, "heroku", "bin", "heroku").to_s
|
87
87
|
if File.exist?(local_path)
|
88
88
|
local_path
|
89
89
|
elsif @ctx.windows?
|
90
90
|
# Check if Heroku exists in the Windows registry and run it from there
|
91
|
-
require
|
91
|
+
require "win32/registry"
|
92
92
|
begin
|
93
93
|
windows_path = Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\heroku') do |reg|
|
94
|
-
reg[
|
94
|
+
reg[""] # This reads the 'Default' registry key
|
95
95
|
end
|
96
96
|
|
97
|
-
File.join(windows_path,
|
97
|
+
File.join(windows_path, "bin", "heroku").to_s
|
98
98
|
rescue
|
99
|
-
|
99
|
+
"heroku"
|
100
100
|
end
|
101
101
|
else
|
102
|
-
|
102
|
+
"heroku"
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
def installed?
|
107
|
-
_output, status = @ctx.capture2e(heroku_command,
|
107
|
+
_output, status = @ctx.capture2e(heroku_command, "--version")
|
108
108
|
status.success?
|
109
109
|
rescue
|
110
110
|
false
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
module ShopifyCli
|
4
|
+
class HttpRequest
|
5
|
+
class << self
|
6
|
+
def post(uri, body, headers)
|
7
|
+
req = ::Net::HTTP::Post.new(uri.request_uri)
|
8
|
+
request(uri, body, headers, req)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(uri, body, headers)
|
12
|
+
req = ::Net::HTTP::Get.new(uri.request_uri)
|
13
|
+
request(uri, body, headers, req)
|
14
|
+
end
|
15
|
+
|
16
|
+
def request(uri, body, headers, req)
|
17
|
+
http = ::Net::HTTP.new(uri.host, uri.port)
|
18
|
+
http.use_ssl = true
|
19
|
+
|
20
|
+
req.body = body unless body.nil?
|
21
|
+
req["Content-Type"] = "application/json"
|
22
|
+
headers.each { |header, value| req[header] = value }
|
23
|
+
http.request(req)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/shopify-cli/js_deps.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "shopify_cli"
|
2
2
|
|
3
3
|
module ShopifyCli
|
4
4
|
##
|
@@ -37,9 +37,9 @@ module ShopifyCli
|
|
37
37
|
# ShopifyCli::JsDeps.new(context).install(true)
|
38
38
|
#
|
39
39
|
def install(verbose = false)
|
40
|
-
title = ctx.message(
|
41
|
-
success = ctx.message(
|
42
|
-
failure = ctx.message(
|
40
|
+
title = ctx.message("core.js_deps.installing", @system.package_manager)
|
41
|
+
success = ctx.message("core.js_deps.installed")
|
42
|
+
failure = ctx.message("core.js_deps.error.install_error", @system.package_manager)
|
43
43
|
|
44
44
|
CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
|
45
45
|
@system.call(
|
@@ -53,14 +53,14 @@ module ShopifyCli
|
|
53
53
|
|
54
54
|
def yarn(verbose = false)
|
55
55
|
cmd = %w(yarn install)
|
56
|
-
cmd <<
|
56
|
+
cmd << "--silent" unless verbose
|
57
57
|
|
58
58
|
run_install_command(cmd)
|
59
59
|
end
|
60
60
|
|
61
61
|
def npm(verbose = false)
|
62
|
-
cmd = %w(npm install --no-audit
|
63
|
-
cmd <<
|
62
|
+
cmd = %w(npm install --no-audit)
|
63
|
+
cmd << "--quiet" unless verbose
|
64
64
|
|
65
65
|
run_install_command(cmd)
|
66
66
|
end
|
@@ -69,7 +69,7 @@ module ShopifyCli
|
|
69
69
|
deps = parse_dependencies
|
70
70
|
errors = nil
|
71
71
|
|
72
|
-
spinner_title = ctx.message(
|
72
|
+
spinner_title = ctx.message("core.js_deps.installing", @system.package_manager)
|
73
73
|
success = CLI::UI::Spinner.spin(spinner_title, auto_debrief: false) do |spinner|
|
74
74
|
_, errors, status = CLI::Kit::System.capture3(*cmd, env: @ctx.env, chdir: ctx.root)
|
75
75
|
update_spinner_title_and_status(spinner, status, deps)
|
@@ -81,19 +81,19 @@ module ShopifyCli
|
|
81
81
|
|
82
82
|
def update_spinner_title_and_status(spinner, status, deps)
|
83
83
|
if status.success?
|
84
|
-
spinner.update_title(ctx.message(
|
84
|
+
spinner.update_title(ctx.message("core.js_deps.installed", deps.size))
|
85
85
|
else
|
86
|
-
spinner.update_title(ctx.message(
|
86
|
+
spinner.update_title(ctx.message("core.js_deps.error.install_spinner_error", deps.size))
|
87
87
|
CLI::UI::Spinner::TASK_FAILED
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
def parse_dependencies
|
92
|
-
package_json = File.join(ctx.root,
|
92
|
+
package_json = File.join(ctx.root, "package.json")
|
93
93
|
pkg = begin
|
94
94
|
JSON.parse(File.read(package_json))
|
95
95
|
rescue Errno::ENOENT, Errno::ENOTDIR
|
96
|
-
ctx.abort(ctx.message(
|
96
|
+
ctx.abort(ctx.message("core.js_deps.error.missing_package", package_json))
|
97
97
|
end
|
98
98
|
|
99
99
|
%w(dependencies devDependencies).map do |key|
|
@@ -101,7 +101,7 @@ module ShopifyCli
|
|
101
101
|
end.flatten
|
102
102
|
rescue JSON::ParserError
|
103
103
|
ctx.puts(
|
104
|
-
ctx.message(
|
104
|
+
ctx.message("core.js_deps.error.invalid_package", File.read(File.join(path, "package.json"))),
|
105
105
|
error: true
|
106
106
|
)
|
107
107
|
raise ShopifyCli::AbortSilent
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "shopify_cli"
|
2
2
|
|
3
3
|
module ShopifyCli
|
4
4
|
##
|
@@ -7,8 +7,8 @@ module ShopifyCli
|
|
7
7
|
class JsSystem
|
8
8
|
include SmartProperties
|
9
9
|
|
10
|
-
YARN_CORE_COMMAND =
|
11
|
-
NPM_CORE_COMMAND =
|
10
|
+
YARN_CORE_COMMAND = "yarn"
|
11
|
+
NPM_CORE_COMMAND = "npm"
|
12
12
|
|
13
13
|
class << self
|
14
14
|
##
|
@@ -64,8 +64,8 @@ module ShopifyCli
|
|
64
64
|
#
|
65
65
|
def yarn?
|
66
66
|
@has_yarn ||= begin
|
67
|
-
cmd_path = @ctx.which(
|
68
|
-
File.exist?(File.join(ctx.root,
|
67
|
+
cmd_path = @ctx.which("yarn")
|
68
|
+
File.exist?(File.join(ctx.root, "yarn.lock")) && !cmd_path.nil?
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "delegate"
|
2
|
+
|
3
|
+
module ShopifyCli
|
4
|
+
##
|
5
|
+
# `LazyDelegator` defers initialization of its underlying delegatee until the
|
6
|
+
# latter is accessed for the first time due to a method call that the
|
7
|
+
# delegator cannot handle itself:
|
8
|
+
#
|
9
|
+
# result = LazyDelegator.new do
|
10
|
+
# # carry out costly operation ...
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# result # referencing the object itself does not result in Proc evaluation
|
14
|
+
# result.to_h # however, calling a method on it will result in Proc evaluation
|
15
|
+
#
|
16
|
+
# LazyDelegator lends itself to being subclassed in scenarios where some
|
17
|
+
# facts are known and others are costly to compute:
|
18
|
+
#
|
19
|
+
# class LazySpecificationHandler < ShopifyCli::LazyDelegator
|
20
|
+
# attr_reader :identifier
|
21
|
+
#
|
22
|
+
# def initialize(identifier, &initializer)
|
23
|
+
# super(&initializer)
|
24
|
+
# @identifier = identifier
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# handler = LazySpecificationHandler.new(:product_subscription) do
|
29
|
+
# # fetch specification from the Partners Dashboard API ...
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # Accessing identifier will not result in Proc evaluation as it is
|
33
|
+
# # available as an attribute of the delegator itself
|
34
|
+
# handler.identifier # => :product_subscription
|
35
|
+
#
|
36
|
+
# # Accessing the specification will result in evaluation of the Proc
|
37
|
+
# # and in our example in a subsequent network call
|
38
|
+
# handler.specification # => <Extension::Models::Specifcation:...>
|
39
|
+
#
|
40
|
+
class LazyDelegator < SimpleDelegator
|
41
|
+
def initialize(&delegatee_initializer)
|
42
|
+
super([false, delegatee_initializer])
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def __getobj__(*)
|
48
|
+
initialized, value_or_initializer = super
|
49
|
+
return value_or_initializer if initialized
|
50
|
+
value_or_initializer.call.tap do |value|
|
51
|
+
__setobj__([true, value])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -3,6 +3,16 @@
|
|
3
3
|
module ShopifyCli
|
4
4
|
module Messages
|
5
5
|
MESSAGES = {
|
6
|
+
apps: {
|
7
|
+
create: {
|
8
|
+
info: {
|
9
|
+
created: "{{v}} {{green:%s}} was created in the organization's Partner Dashboard {{underline:%s}}",
|
10
|
+
serve: "{{*}} Change directories to your new project folder {{green:%s}} and run {{command:%s serve}} " \
|
11
|
+
"to start a local server",
|
12
|
+
install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
|
13
|
+
},
|
14
|
+
},
|
15
|
+
},
|
6
16
|
core: {
|
7
17
|
connect: {
|
8
18
|
help: <<~HELP,
|
@@ -10,11 +20,7 @@ module ShopifyCli
|
|
10
20
|
Usage: {{command:%s connect}}
|
11
21
|
HELP
|
12
22
|
|
13
|
-
production_warning: <<~MESSAGE,
|
14
|
-
{{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
|
15
|
-
MESSAGE
|
16
23
|
already_connected_warning: "{{yellow:! This app appears to be already connected}}",
|
17
|
-
connected: "{{v}} Project now connected to {{green:%s}}",
|
18
24
|
project_type_select: "What type of project would you like to connect?",
|
19
25
|
cli_yml_saved: ".shopify-cli.yml saved to project root",
|
20
26
|
},
|
@@ -113,7 +119,7 @@ module ShopifyCli
|
|
113
119
|
missing_package: "expected to have a file at: %s",
|
114
120
|
invalid_package: "{{info:%s}} was not valid JSON. Fix this then try again",
|
115
121
|
install_spinner_error: "Unable to install all %d dependencies",
|
116
|
-
install_error:
|
122
|
+
install_error: "An error occurred while installing dependencies",
|
117
123
|
},
|
118
124
|
|
119
125
|
installing: "Installing dependencies with %s...",
|
@@ -176,7 +182,9 @@ module ShopifyCli
|
|
176
182
|
|
177
183
|
api: {
|
178
184
|
error: {
|
179
|
-
internal_server_error:
|
185
|
+
internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
|
186
|
+
internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
|
187
|
+
invalid_url: "Invalid URL: %s",
|
180
188
|
},
|
181
189
|
},
|
182
190
|
|
@@ -251,6 +259,8 @@ module ShopifyCli
|
|
251
259
|
},
|
252
260
|
environment_header: "{{bold:Environment}}",
|
253
261
|
env: "%-17s = %s",
|
262
|
+
identity_header: "{{bold:Identity}}",
|
263
|
+
identity_is_shopifolk: "{{v}} Checked user settings: you’re Shopify staff!",
|
254
264
|
},
|
255
265
|
|
256
266
|
tasks: {
|
@@ -262,7 +272,7 @@ module ShopifyCli
|
|
262
272
|
MESSAGE
|
263
273
|
development_store_select: "Which development store would you like to use?",
|
264
274
|
app_select: "To which app does this project belong?",
|
265
|
-
no_apps:
|
275
|
+
no_apps: "You have no apps to connect to, creating a new app.",
|
266
276
|
app_name: "App name",
|
267
277
|
app_type: {
|
268
278
|
select: "What type of app are you building?",
|
@@ -297,6 +307,8 @@ module ShopifyCli
|
|
297
307
|
organization_not_found: "Cannot find a partner organization with that ID",
|
298
308
|
partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
|
299
309
|
},
|
310
|
+
first_party: "Are you working on a 1P (1st Party) app?",
|
311
|
+
identified_as_shopify: "We've identified you as a {{green:Shopify}} employee.",
|
300
312
|
organization: "Partner organization {{green:%s (%s)}}",
|
301
313
|
organization_select: "Select partner organization",
|
302
314
|
},
|
@@ -308,6 +320,8 @@ module ShopifyCli
|
|
308
320
|
url_fetch_failure: "Unable to fetch external url",
|
309
321
|
prereq_command_required: "%1$s is required for installing ngrok. Please install %1$s using the appropriate"\
|
310
322
|
" package manager for your system.",
|
323
|
+
ngrok: "Something went wrong with ngrok installation,"\
|
324
|
+
"please make sure %s exists within %s before trying again",
|
311
325
|
},
|
312
326
|
|
313
327
|
not_running: "{{green:x}} ngrok tunnel not running",
|
@@ -342,15 +356,15 @@ module ShopifyCli
|
|
342
356
|
{{x}} This version of Shopify App CLI is no longer supported. You’ll need to migrate to the new CLI version to continue.
|
343
357
|
|
344
358
|
Please visit this page for complete instructions:
|
345
|
-
{{underline:https://shopify.
|
359
|
+
{{underline:https://shopify.dev/tools/cli/troubleshooting#migrate-from-a-legacy-version}}
|
346
360
|
|
347
361
|
MESSAGE
|
348
362
|
|
349
363
|
new_version: <<~MESSAGE,
|
350
|
-
{{*}} {{yellow:A new version of
|
364
|
+
{{*}} {{yellow:A new version of Shopify App CLI is available! You have version %s and the latest version is %s.
|
351
365
|
|
352
366
|
To upgrade, follow the instructions for the package manager you’re using:
|
353
|
-
{{underline:https://shopify.
|
367
|
+
{{underline:https://shopify.dev/tools/cli/troubleshooting#upgrade-shopify-app-cli}}}}
|
354
368
|
|
355
369
|
MESSAGE
|
356
370
|
},
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module ShopifyCli
|
2
|
+
##
|
3
|
+
# The `MethodObject` mixin can be included in any class that implements `call`
|
4
|
+
# to ensure that
|
5
|
+
#
|
6
|
+
# * `call` will always return a `ShopifyCli::Result` by prepending a module
|
7
|
+
# that takes care of the result wrapping and
|
8
|
+
# * a `to_proc` method that allows instances of this class to be passed as a
|
9
|
+
# block.
|
10
|
+
#
|
11
|
+
# For convenience, this mixin also adds the corresponding class methods:
|
12
|
+
# `call` and `to_proc`. Method and result objects pair nicely as they greatly
|
13
|
+
# simplify the creation of complex processing chains:
|
14
|
+
#
|
15
|
+
# class Serialize
|
16
|
+
# include MethodObject
|
17
|
+
#
|
18
|
+
# def call(attrs)
|
19
|
+
# attrs.to_json
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# class Deserialize
|
24
|
+
# include MethodObject
|
25
|
+
#
|
26
|
+
# def call(json)
|
27
|
+
# JSON.parse(json)
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# Serialize
|
32
|
+
# .call(firstname: "John", lastname: "Doe")
|
33
|
+
# .then(&Deserialize)
|
34
|
+
# .map { |attrs| OpenStruct.new(attrs) }
|
35
|
+
# .unwrap(nil)
|
36
|
+
#
|
37
|
+
# While this example is contrived, it still illustrates some key advantages of
|
38
|
+
# this programming paradigm:
|
39
|
+
#
|
40
|
+
# * chaining operations is as simple as repeatedly calling `then` or `map`,
|
41
|
+
# * method objects don't have to be manually instantiated but can be
|
42
|
+
# constructed using the `&` operator,
|
43
|
+
# * error handling is deferred until the result is unwrapped.
|
44
|
+
#
|
45
|
+
# Please see the section for `ShopifyCli::Result`,
|
46
|
+
# `ShopifyCli::Result::Success`, and `ShopifyCli::Result::Failure` for more
|
47
|
+
# information on the API of result objects.
|
48
|
+
#
|
49
|
+
module MethodObject
|
50
|
+
module AutoCreateResultObject
|
51
|
+
##
|
52
|
+
# invokes the original `call` implementation and wraps its return value
|
53
|
+
# into a result object.
|
54
|
+
#
|
55
|
+
def call(*args, **kwargs)
|
56
|
+
Result.wrap { super(*args, **kwargs) }.call
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
module ClassMethods
|
61
|
+
##
|
62
|
+
# creates a new instance and invokes `call`. Any positional argument
|
63
|
+
# is forward to `call`. Keyword arguments are either forwarded to the
|
64
|
+
# inializer or to `call`. If the keyword argument matches the name of
|
65
|
+
# property, it is forwarded to the initializer, otherwise to call.
|
66
|
+
#
|
67
|
+
def call(*args, **kwargs)
|
68
|
+
properties.keys.yield_self do |properties|
|
69
|
+
new(**kwargs.slice(*properties))
|
70
|
+
.call(*args, **kwargs.slice(*(kwargs.keys - properties)))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# returns a proc that invokes `call` with all arguments it receives when
|
76
|
+
# called itself.
|
77
|
+
#
|
78
|
+
def to_proc
|
79
|
+
method(:call).to_proc
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# is invoked when this mixin is included into a class. This results in
|
85
|
+
#
|
86
|
+
# * including `SmartProperties`,
|
87
|
+
# * prepending the result wrapping mechanism, and
|
88
|
+
# * adding the class methods `.call` and `.to_proc`.
|
89
|
+
#
|
90
|
+
def self.included(method_object_implementation)
|
91
|
+
method_object_implementation.prepend(AutoCreateResultObject)
|
92
|
+
method_object_implementation.include(SmartProperties)
|
93
|
+
method_object_implementation.extend(ClassMethods)
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# returns a proc that invokes `call` with all arguments it receives when
|
98
|
+
# called itself.
|
99
|
+
#
|
100
|
+
def to_proc
|
101
|
+
method(:call).to_proc
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|