shopify-cli 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/CODEOWNERS +1 -0
- data/.github/CODE_OF_CONDUCT.md +73 -0
- data/.github/CONTRIBUTING.md +51 -0
- data/.github/DESIGN.md +153 -0
- data/.github/ISSUE_TEMPLATE.md +38 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
- data/.github/probots.yml +3 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +47 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +77 -0
- data/LICENSE.md +7 -0
- data/README.md +13 -0
- data/Rakefile +101 -0
- data/SECURITY.md +59 -0
- data/Vagrantfile +17 -0
- data/bin/load_shopify.rb +20 -0
- data/bin/shopify +32 -0
- data/dev.yml +17 -0
- data/docs/Gemfile +5 -0
- data/docs/Gemfile.lock +248 -0
- data/docs/_config.yml +16 -0
- data/docs/_data/nav.yml +26 -0
- data/docs/_includes/footer.html +15 -0
- data/docs/_includes/head.html +19 -0
- data/docs/_includes/sidebar_nav.html +22 -0
- data/docs/_includes/toc.html +112 -0
- data/docs/_layouts/default.html +79 -0
- data/docs/app/node/commands/index.md +82 -0
- data/docs/app/node/index.md +35 -0
- data/docs/app/rails/commands/index.md +80 -0
- data/docs/app/rails/index.md +36 -0
- data/docs/core/index.md +70 -0
- data/docs/css/docs.css +157 -0
- data/docs/getting-started/index.md +61 -0
- data/docs/help/start-app/index.md +6 -0
- data/docs/images/header.png +0 -0
- data/docs/index.md +27 -0
- data/docs/installing-ruby.md +28 -0
- data/ext/shopify-cli/extconf.rb +27 -0
- data/install.sh +7 -0
- data/lib/docgen/class_template.md.erb +81 -0
- data/lib/docgen/index_template.md.erb +5 -0
- data/lib/docgen/markdown.rb +101 -0
- data/lib/graphql/admin_introspection.graphql +87 -0
- data/lib/graphql/all_organizations.graphql +19 -0
- data/lib/graphql/all_orgs_with_apps.graphql +30 -0
- data/lib/graphql/api_versions.graphql +6 -0
- data/lib/graphql/convert_dev_to_test_store.graphql +10 -0
- data/lib/graphql/create_app.graphql +20 -0
- data/lib/graphql/create_customer.graphql +9 -0
- data/lib/graphql/create_draft_order.graphql +8 -0
- data/lib/graphql/create_product.graphql +9 -0
- data/lib/graphql/extension_create.graphql +21 -0
- data/lib/graphql/extension_update_draft.graphql +18 -0
- data/lib/graphql/find_organization.graphql +17 -0
- data/lib/graphql/get_app_urls.graphql +6 -0
- data/lib/graphql/update_dashboard_urls.graphql +8 -0
- data/lib/project_types/extension/cli.rb +71 -0
- data/lib/project_types/extension/commands/build.rb +29 -0
- data/lib/project_types/extension/commands/create.rb +49 -0
- data/lib/project_types/extension/commands/extension_command.rb +22 -0
- data/lib/project_types/extension/commands/push.rb +69 -0
- data/lib/project_types/extension/commands/register.rb +78 -0
- data/lib/project_types/extension/commands/serve.rb +24 -0
- data/lib/project_types/extension/commands/tunnel.rb +69 -0
- data/lib/project_types/extension/extension_project.rb +85 -0
- data/lib/project_types/extension/extension_project_keys.rb +10 -0
- data/lib/project_types/extension/features/argo.rb +48 -0
- data/lib/project_types/extension/features/argo_dependencies.rb +28 -0
- data/lib/project_types/extension/features/argo_setup.rb +54 -0
- data/lib/project_types/extension/features/argo_setup_step.rb +31 -0
- data/lib/project_types/extension/features/argo_setup_steps.rb +53 -0
- data/lib/project_types/extension/features/tunnel_url.rb +20 -0
- data/lib/project_types/extension/forms/create.rb +52 -0
- data/lib/project_types/extension/forms/register.rb +48 -0
- data/lib/project_types/extension/messages/message_loading.rb +37 -0
- data/lib/project_types/extension/messages/messages.rb +126 -0
- data/lib/project_types/extension/models/app.rb +14 -0
- data/lib/project_types/extension/models/registration.rb +19 -0
- data/lib/project_types/extension/models/type.rb +76 -0
- data/lib/project_types/extension/models/types/checkout_post_purchase.rb +20 -0
- data/lib/project_types/extension/models/types/subscription_management.rb +20 -0
- data/lib/project_types/extension/models/validation_error.rb +17 -0
- data/lib/project_types/extension/models/version.rb +15 -0
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +26 -0
- data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +25 -0
- data/lib/project_types/extension/tasks/converters/version_converter.rb +28 -0
- data/lib/project_types/extension/tasks/create_extension.rb +31 -0
- data/lib/project_types/extension/tasks/get_apps.rb +34 -0
- data/lib/project_types/extension/tasks/update_draft.rb +29 -0
- data/lib/project_types/extension/tasks/user_errors.rb +45 -0
- data/lib/project_types/node/cli.rb +37 -0
- data/lib/project_types/node/commands/create.rb +117 -0
- data/lib/project_types/node/commands/deploy.rb +22 -0
- data/lib/project_types/node/commands/deploy/heroku.rb +91 -0
- data/lib/project_types/node/commands/generate.rb +51 -0
- data/lib/project_types/node/commands/generate/billing.rb +37 -0
- data/lib/project_types/node/commands/generate/page.rb +55 -0
- data/lib/project_types/node/commands/generate/webhook.rb +33 -0
- data/lib/project_types/node/commands/open.rb +16 -0
- data/lib/project_types/node/commands/populate.rb +23 -0
- data/lib/project_types/node/commands/populate/customer.rb +31 -0
- data/lib/project_types/node/commands/populate/draft_order.rb +28 -0
- data/lib/project_types/node/commands/populate/product.rb +30 -0
- data/lib/project_types/node/commands/serve.rb +45 -0
- data/lib/project_types/node/commands/tunnel.rb +39 -0
- data/lib/project_types/node/forms/create.rb +87 -0
- data/lib/project_types/node/messages/messages.rb +260 -0
- data/lib/project_types/rails/cli.rb +41 -0
- data/lib/project_types/rails/commands/create.rb +126 -0
- data/lib/project_types/rails/commands/deploy.rb +22 -0
- data/lib/project_types/rails/commands/deploy/heroku.rb +113 -0
- data/lib/project_types/rails/commands/generate.rb +49 -0
- data/lib/project_types/rails/commands/generate/webhook.rb +39 -0
- data/lib/project_types/rails/commands/open.rb +16 -0
- data/lib/project_types/rails/commands/populate.rb +23 -0
- data/lib/project_types/rails/commands/populate/customer.rb +31 -0
- data/lib/project_types/rails/commands/populate/draft_order.rb +28 -0
- data/lib/project_types/rails/commands/populate/product.rb +30 -0
- data/lib/project_types/rails/commands/serve.rb +47 -0
- data/lib/project_types/rails/commands/tunnel.rb +39 -0
- data/lib/project_types/rails/forms/create.rb +116 -0
- data/lib/project_types/rails/gem.rb +56 -0
- data/lib/project_types/rails/messages/messages.rb +283 -0
- data/lib/project_types/rails/ruby.rb +17 -0
- data/lib/project_types/script/cli.rb +76 -0
- data/lib/project_types/script/commands/create.rb +45 -0
- data/lib/project_types/script/commands/disable.rb +36 -0
- data/lib/project_types/script/commands/enable.rb +46 -0
- data/lib/project_types/script/commands/push.rb +39 -0
- data/lib/project_types/script/config/extension_points.yml +18 -0
- data/lib/project_types/script/errors.rb +16 -0
- data/lib/project_types/script/forms/create.rb +29 -0
- data/lib/project_types/script/forms/enable.rb +24 -0
- data/lib/project_types/script/forms/push.rb +19 -0
- data/lib/project_types/script/forms/script_form.rb +66 -0
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +27 -0
- data/lib/project_types/script/graphql/script_service_proxy.graphql +8 -0
- data/lib/project_types/script/graphql/shop_script_delete.graphql +14 -0
- data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +28 -0
- data/lib/project_types/script/layers/application/build_script.rb +43 -0
- data/lib/project_types/script/layers/application/create_script.rb +47 -0
- data/lib/project_types/script/layers/application/disable_script.rb +19 -0
- data/lib/project_types/script/layers/application/enable_script.rb +21 -0
- data/lib/project_types/script/layers/application/extension_points.rb +17 -0
- data/lib/project_types/script/layers/application/project_dependencies.rb +34 -0
- data/lib/project_types/script/layers/application/push_script.rb +30 -0
- data/lib/project_types/script/layers/domain/errors.rb +25 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +29 -0
- data/lib/project_types/script/layers/domain/push_package.rb +29 -0
- data/lib/project_types/script/layers/domain/script.rb +18 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +73 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb +38 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_wasm_builder.rb +39 -0
- data/lib/project_types/script/layers/infrastructure/dependency_manager.rb +36 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +38 -0
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +31 -0
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +47 -0
- data/lib/project_types/script/layers/infrastructure/script_builder.rb +34 -0
- data/lib/project_types/script/layers/infrastructure/script_repository.rb +89 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +165 -0
- data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +59 -0
- data/lib/project_types/script/messages/messages.rb +204 -0
- data/lib/project_types/script/script_project.rb +37 -0
- data/lib/project_types/script/templates/ts/as-pect.config.js +21 -0
- data/lib/project_types/script/ui/error_handler.rb +136 -0
- data/lib/project_types/script/ui/strict_spinner.rb +22 -0
- data/lib/rubygems_plugin.rb +18 -0
- data/lib/shopify-cli/admin_api.rb +99 -0
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +165 -0
- data/lib/shopify-cli/admin_api/schema.rb +32 -0
- data/lib/shopify-cli/api.rb +104 -0
- data/lib/shopify-cli/command.rb +67 -0
- data/lib/shopify-cli/commands.rb +28 -0
- data/lib/shopify-cli/commands/connect.rb +108 -0
- data/lib/shopify-cli/commands/create.rb +50 -0
- data/lib/shopify-cli/commands/help.rb +79 -0
- data/lib/shopify-cli/commands/logout.rb +23 -0
- data/lib/shopify-cli/commands/system.rb +135 -0
- data/lib/shopify-cli/commands/version.rb +15 -0
- data/lib/shopify-cli/context.rb +372 -0
- data/lib/shopify-cli/core.rb +9 -0
- data/lib/shopify-cli/core/entry_point.rb +40 -0
- data/lib/shopify-cli/core/executor.rb +21 -0
- data/lib/shopify-cli/core/help_resolver.rb +20 -0
- data/lib/shopify-cli/core/monorail.rb +118 -0
- data/lib/shopify-cli/db.rb +114 -0
- data/lib/shopify-cli/form.rb +40 -0
- data/lib/shopify-cli/git.rb +141 -0
- data/lib/shopify-cli/helpers.rb +5 -0
- data/lib/shopify-cli/helpers/haikunator.rb +92 -0
- data/lib/shopify-cli/heroku.rb +97 -0
- data/lib/shopify-cli/js_deps.rb +110 -0
- data/lib/shopify-cli/js_system.rb +98 -0
- data/lib/shopify-cli/messages/messages.rb +287 -0
- data/lib/shopify-cli/oauth.rb +192 -0
- data/lib/shopify-cli/oauth/servlet.rb +61 -0
- data/lib/shopify-cli/options.rb +40 -0
- data/lib/shopify-cli/packager.rb +116 -0
- data/lib/shopify-cli/partners_api.rb +114 -0
- data/lib/shopify-cli/partners_api/organizations.rb +32 -0
- data/lib/shopify-cli/process_supervision.rb +187 -0
- data/lib/shopify-cli/project.rb +191 -0
- data/lib/shopify-cli/project_type.rb +83 -0
- data/lib/shopify-cli/resources.rb +5 -0
- data/lib/shopify-cli/resources/env_file.rb +96 -0
- data/lib/shopify-cli/sub_command.rb +15 -0
- data/lib/shopify-cli/task.rb +10 -0
- data/lib/shopify-cli/tasks.rb +32 -0
- data/lib/shopify-cli/tasks/create_api_client.rb +29 -0
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +41 -0
- data/lib/shopify-cli/tasks/ensure_env.rb +31 -0
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +20 -0
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +44 -0
- data/lib/shopify-cli/tunnel.rb +154 -0
- data/lib/shopify-cli/version.rb +3 -0
- data/lib/shopify_cli.rb +132 -0
- data/shopify-cli.gemspec +40 -0
- data/shopify.fish +12 -0
- data/shopify.sh +11 -0
- data/vendor/deps/cli-kit/REVISION +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit.rb +60 -0
- data/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +21 -0
- data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +49 -0
- data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +94 -0
- data/vendor/deps/cli-kit/lib/cli/kit/config.rb +133 -0
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +115 -0
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +81 -0
- data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +102 -0
- data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +82 -0
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +76 -0
- data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +60 -0
- data/vendor/deps/cli-kit/lib/cli/kit/ruby_backports/enumerable.rb +6 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support.rb +9 -0
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +244 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +207 -0
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +189 -0
- data/vendor/deps/cli-kit/lib/cli/kit/version.rb +5 -0
- data/vendor/deps/cli-ui/REVISION +1 -0
- data/vendor/deps/cli-ui/lib/cli/ui.rb +187 -0
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +153 -0
- data/vendor/deps/cli-ui/lib/cli/ui/box.rb +15 -0
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +79 -0
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +179 -0
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +310 -0
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +78 -0
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +88 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +248 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +472 -0
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +24 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +48 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +40 -0
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +241 -0
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +227 -0
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +36 -0
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +102 -0
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +5 -0
- data/vendor/deps/smart_properties/REVISION +1 -0
- data/vendor/deps/smart_properties/lib/smart_properties.rb +174 -0
- data/vendor/deps/smart_properties/lib/smart_properties/errors.rb +114 -0
- data/vendor/deps/smart_properties/lib/smart_properties/property.rb +162 -0
- data/vendor/deps/smart_properties/lib/smart_properties/property_collection.rb +83 -0
- data/vendor/deps/smart_properties/lib/smart_properties/validations.rb +8 -0
- data/vendor/deps/smart_properties/lib/smart_properties/validations/ancestor.rb +27 -0
- data/vendor/deps/smart_properties/lib/smart_properties/version.rb +3 -0
- data/vendor/lib/semantic/LICENSE +20 -0
- data/vendor/lib/semantic/semantic.rb +4 -0
- data/vendor/lib/semantic/version.rb +180 -0
- metadata +374 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Node
|
3
|
+
module Commands
|
4
|
+
class Create < ShopifyCli::SubCommand
|
5
|
+
options do |parser, flags|
|
6
|
+
# backwards compatibility allow 'title' for now
|
7
|
+
parser.on('--title=TITLE') { |t| flags[:title] = t }
|
8
|
+
parser.on('--name=NAME') { |t| flags[:title] = t }
|
9
|
+
parser.on('--organization_id=ID') { |url| flags[:organization_id] = url }
|
10
|
+
parser.on('--shop_domain=MYSHOPIFYDOMAIN') { |url| flags[:shop_domain] = url }
|
11
|
+
parser.on('--type=APPTYPE') { |url| flags[:type] = url }
|
12
|
+
parser.on('--verbose') { flags[:verbose] = true }
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(args, _name)
|
16
|
+
form = Forms::Create.ask(@ctx, args, options.flags)
|
17
|
+
return @ctx.puts(self.class.help) if form.nil?
|
18
|
+
|
19
|
+
check_node
|
20
|
+
check_npm
|
21
|
+
build(form.name)
|
22
|
+
|
23
|
+
ShopifyCli::Project.write(
|
24
|
+
@ctx,
|
25
|
+
project_type: 'node',
|
26
|
+
organization_id: form.organization_id,
|
27
|
+
)
|
28
|
+
|
29
|
+
api_client = ShopifyCli::Tasks::CreateApiClient.call(
|
30
|
+
@ctx,
|
31
|
+
org_id: form.organization_id,
|
32
|
+
title: form.title,
|
33
|
+
type: form.type,
|
34
|
+
)
|
35
|
+
|
36
|
+
ShopifyCli::Resources::EnvFile.new(
|
37
|
+
api_key: api_client["apiKey"],
|
38
|
+
secret: api_client["apiSecretKeys"].first["secret"],
|
39
|
+
shop: form.shop_domain,
|
40
|
+
scopes: 'write_products,write_customers,write_draft_orders',
|
41
|
+
).write(@ctx)
|
42
|
+
|
43
|
+
partners_url = "https://partners.shopify.com/#{form.organization_id}/apps/#{api_client['id']}"
|
44
|
+
|
45
|
+
@ctx.puts(@ctx.message('node.create.info.created', form.title, partners_url))
|
46
|
+
@ctx.puts(@ctx.message('node.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
|
47
|
+
@ctx.puts(@ctx.message('node.create.info.install', partners_url, form.title))
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.help
|
51
|
+
ShopifyCli::Context.message('node.create.help', ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def check_node
|
57
|
+
_, stat = @ctx.capture2e('which', 'node')
|
58
|
+
@ctx.abort(@ctx.message('node.create.error.node_required')) unless stat.success?
|
59
|
+
|
60
|
+
version, stat = @ctx.capture2e('node', '-v')
|
61
|
+
@ctx.abort(@ctx.message('node.create.error.node_version_failure')) unless stat.success?
|
62
|
+
|
63
|
+
@ctx.done(@ctx.message('node.create.node_version', version))
|
64
|
+
end
|
65
|
+
|
66
|
+
def check_npm
|
67
|
+
_, stat = @ctx.capture2e('which', 'npm')
|
68
|
+
@ctx.abort(@ctx.message('node.create.error.npm_required')) unless stat.success?
|
69
|
+
|
70
|
+
version, stat = @ctx.capture2e('npm', '-v')
|
71
|
+
@ctx.abort(@ctx.message('node.create.error.npm_version_failure')) unless stat.success?
|
72
|
+
|
73
|
+
@ctx.done(@ctx.message('node.create.npm_version', version))
|
74
|
+
end
|
75
|
+
|
76
|
+
def set_npm_config
|
77
|
+
# check available npmrc (either user or system) for production registry
|
78
|
+
registry, _ = @ctx.capture2('npm config get @shopify:registry')
|
79
|
+
return if registry.include?('https://registry.yarnpkg.com')
|
80
|
+
|
81
|
+
# available npmrc doesn't have production registry =>
|
82
|
+
# set a project-based .npmrc
|
83
|
+
@ctx.system(
|
84
|
+
'npm',
|
85
|
+
'--userconfig',
|
86
|
+
'./.npmrc',
|
87
|
+
'config',
|
88
|
+
'set',
|
89
|
+
'@shopify:registry',
|
90
|
+
'https://registry.yarnpkg.com',
|
91
|
+
chdir: @ctx.root
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def build(name)
|
96
|
+
ShopifyCli::Git.clone('https://github.com/Shopify/shopify-app-node.git', name)
|
97
|
+
|
98
|
+
@ctx.root = File.join(@ctx.root, name)
|
99
|
+
|
100
|
+
set_npm_config
|
101
|
+
ShopifyCli::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
|
102
|
+
|
103
|
+
begin
|
104
|
+
@ctx.rm_r('.git')
|
105
|
+
@ctx.rm_r('.github')
|
106
|
+
@ctx.rm(File.join('server', 'handlers', 'client.js'))
|
107
|
+
@ctx.rename(
|
108
|
+
File.join('server', 'handlers', 'client.cli.js'),
|
109
|
+
File.join('server', 'handlers', 'client.js')
|
110
|
+
)
|
111
|
+
rescue Errno::ENOENT => e
|
112
|
+
@ctx.debug(e)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Node
|
5
|
+
module Commands
|
6
|
+
class Deploy < ShopifyCli::Command
|
7
|
+
subcommand :Heroku, 'heroku', Project.project_filepath('commands/deploy/heroku')
|
8
|
+
|
9
|
+
def call(*)
|
10
|
+
@ctx.puts(self.class.help)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.help
|
14
|
+
ShopifyCli::Context.message('node.deploy.help', ShopifyCli::TOOL_NAME)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.extended_help
|
18
|
+
ShopifyCli::Context.message('node.deploy.extended_help', ShopifyCli::TOOL_NAME)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Node
|
5
|
+
module Commands
|
6
|
+
class Deploy
|
7
|
+
class Heroku < ShopifyCli::SubCommand
|
8
|
+
def self.help
|
9
|
+
ShopifyCli::Context.message('node.deploy.heroku.help', ShopifyCli::TOOL_NAME)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(*)
|
13
|
+
spin_group = CLI::UI::SpinGroup.new
|
14
|
+
heroku_service = ShopifyCli::Heroku.new(@ctx)
|
15
|
+
|
16
|
+
spin_group.add(@ctx.message('node.deploy.heroku.downloading')) do |spinner|
|
17
|
+
heroku_service.download
|
18
|
+
spinner.update_title(@ctx.message('node.deploy.heroku.downloaded'))
|
19
|
+
end
|
20
|
+
spin_group.wait
|
21
|
+
|
22
|
+
spin_group.add(@ctx.message('node.deploy.heroku.installing')) do |spinner|
|
23
|
+
heroku_service.install
|
24
|
+
spinner.update_title(@ctx.message('node.deploy.heroku.installed'))
|
25
|
+
end
|
26
|
+
spin_group.add(@ctx.message('node.deploy.heroku.git.checking')) do |spinner|
|
27
|
+
ShopifyCli::Git.init(@ctx)
|
28
|
+
spinner.update_title(@ctx.message('node.deploy.heroku.git.initialized'))
|
29
|
+
end
|
30
|
+
spin_group.wait
|
31
|
+
|
32
|
+
if (account = heroku_service.whoami)
|
33
|
+
@ctx.puts(@ctx.message('node.deploy.heroku.authenticated_with_account', account))
|
34
|
+
else
|
35
|
+
CLI::UI::Frame.open(
|
36
|
+
@ctx.message('node.deploy.heroku.authenticating'),
|
37
|
+
success_text: @ctx.message('node.deploy.heroku.authenticated')
|
38
|
+
) do
|
39
|
+
heroku_service.authenticate
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if (app_name = heroku_service.app)
|
44
|
+
@ctx.puts(@ctx.message('node.deploy.heroku.app.selected', app_name))
|
45
|
+
else
|
46
|
+
app_type = CLI::UI::Prompt.ask(@ctx.message('node.deploy.heroku.app.no_apps_found')) do |handler|
|
47
|
+
handler.option(@ctx.message('node.deploy.heroku.app.create')) { :new }
|
48
|
+
handler.option(@ctx.message('node.deploy.heroku.app.select')) { :existing }
|
49
|
+
end
|
50
|
+
|
51
|
+
if app_type == :existing
|
52
|
+
app_name = CLI::UI::Prompt.ask(@ctx.message('node.deploy.heroku.app.name'))
|
53
|
+
CLI::UI::Frame.open(
|
54
|
+
@ctx.message('node.deploy.heroku.app.selecting', app_name),
|
55
|
+
success_text: @ctx.message('node.deploy.heroku.app.selected', app_name)
|
56
|
+
) do
|
57
|
+
heroku_service.select_existing_app(app_name)
|
58
|
+
end
|
59
|
+
elsif app_type == :new
|
60
|
+
CLI::UI::Frame.open(
|
61
|
+
@ctx.message('node.deploy.heroku.app.creating'),
|
62
|
+
success_text: @ctx.message('node.deploy.heroku.app.created')
|
63
|
+
) do
|
64
|
+
heroku_service.create_new_app
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
branches = ShopifyCli::Git.branches(@ctx)
|
70
|
+
if branches.length == 1
|
71
|
+
branch_to_deploy = branches[0]
|
72
|
+
@ctx.puts(@ctx.message('node.deploy.heroku.git.branch_selected', branch_to_deploy))
|
73
|
+
else
|
74
|
+
branch_to_deploy = CLI::UI::Prompt.ask(@ctx.message('node.deploy.heroku.git.what_branch')) do |handler|
|
75
|
+
branches.each do |branch|
|
76
|
+
handler.option(branch) { branch }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
CLI::UI::Frame.open(
|
82
|
+
@ctx.message('node.deploy.heroku.deploying'),
|
83
|
+
success_text: @ctx.message('node.deploy.heroku.deployed')
|
84
|
+
) do
|
85
|
+
heroku_service.deploy(branch_to_deploy)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Node
|
5
|
+
module Commands
|
6
|
+
class Generate < ShopifyCli::Command
|
7
|
+
subcommand :Page, 'page', Project.project_filepath('commands/generate/page')
|
8
|
+
subcommand :Billing, 'billing', Project.project_filepath('commands/generate/billing')
|
9
|
+
subcommand :Webhook, 'webhook', Project.project_filepath('commands/generate/webhook')
|
10
|
+
|
11
|
+
def call(*)
|
12
|
+
@ctx.puts(self.class.help)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.help
|
16
|
+
ShopifyCli::Context.message('node.generate.help', ShopifyCli::TOOL_NAME)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.extended_help
|
20
|
+
extended_help = "{{bold:Subcommands:}}\n"
|
21
|
+
subcommand_registry.resolved_commands.sort.each do |name, klass|
|
22
|
+
extended_help += " {{cyan:#{name}}}: "
|
23
|
+
|
24
|
+
if (subcmd_help = klass.help)
|
25
|
+
extended_help += subcmd_help.gsub("\n ", "\n ")
|
26
|
+
end
|
27
|
+
extended_help += "\n"
|
28
|
+
end
|
29
|
+
extended_help += ShopifyCli::Context.message('node.generate.extended_help', ShopifyCli::TOOL_NAME)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.run_generate(script, name, ctx)
|
33
|
+
stat = ctx.system(script)
|
34
|
+
unless stat.success?
|
35
|
+
ctx.abort(response(stat.exitstatus, name, ctx))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.response(code, name, ctx)
|
40
|
+
case code
|
41
|
+
when 1
|
42
|
+
ctx.message('node.generate.error.generic', name)
|
43
|
+
when 2
|
44
|
+
ctx.message('node.generate.error.name_exists', name)
|
45
|
+
else
|
46
|
+
ctx.message('node.error.generic')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
|
3
|
+
module Node
|
4
|
+
module Commands
|
5
|
+
class Generate
|
6
|
+
class Billing < ShopifyCli::SubCommand
|
7
|
+
BILLING_TYPES = {
|
8
|
+
'recurring-billing' => './node_modules/.bin/generate-node-app recurring-billing',
|
9
|
+
'one-time-billing' => './node_modules/.bin/generate-node-app one-time-billing',
|
10
|
+
}
|
11
|
+
def call(args, _name)
|
12
|
+
selected_type = BILLING_TYPES[args[1]]
|
13
|
+
unless selected_type
|
14
|
+
selected_type = CLI::UI::Prompt.ask(@ctx.message('node.generate.billing.type_select')) do |handler|
|
15
|
+
BILLING_TYPES.each do |key, value|
|
16
|
+
handler.option(key) { value }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
billing_type_name = BILLING_TYPES.key(selected_type)
|
21
|
+
spin_group = CLI::UI::SpinGroup.new
|
22
|
+
spin_group.add(@ctx.message('node.generate.billing.generating', billing_type_name)) do |spinner|
|
23
|
+
Node::Commands::Generate.run_generate(
|
24
|
+
selected_type, billing_type_name, @ctx
|
25
|
+
)
|
26
|
+
spinner.update_title(@ctx.message('node.generate.billing.generated', billing_type_name))
|
27
|
+
end
|
28
|
+
spin_group.wait
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.help
|
32
|
+
ShopifyCli::Context.message('node.generate.billing.help', ShopifyCli::TOOL_NAME)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
|
3
|
+
module Node
|
4
|
+
module Commands
|
5
|
+
class Generate
|
6
|
+
class Page < ShopifyCli::SubCommand
|
7
|
+
PAGE_TYPES = {
|
8
|
+
'empty-state' => './node_modules/.bin/generate-node-app empty-state-page',
|
9
|
+
'two-column' => './node_modules/.bin/generate-node-app two-column-page',
|
10
|
+
'annotated' => './node_modules/.bin/generate-node-app settings-page',
|
11
|
+
'list' => './node_modules/.bin/generate-node-app list-page',
|
12
|
+
}
|
13
|
+
|
14
|
+
options do |parser, flags|
|
15
|
+
parser.on('--type=TYPE') do |t|
|
16
|
+
flags[:type] = t.downcase
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(args, _name)
|
21
|
+
name = args.first
|
22
|
+
flag = options.flags[:type]
|
23
|
+
unless name
|
24
|
+
@ctx.puts(self.class.help)
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
selected_type = if flag
|
29
|
+
unless PAGE_TYPES.key?(flag)
|
30
|
+
@ctx.abort(@ctx.message('node.generate.page.error.invalid_page_type'))
|
31
|
+
end
|
32
|
+
PAGE_TYPES[flag]
|
33
|
+
else
|
34
|
+
CLI::UI::Prompt.ask(@ctx.message('node.generate.page.type_select')) do |handler|
|
35
|
+
PAGE_TYPES.each do |key, value|
|
36
|
+
handler.option(key) { value }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
spin_group = CLI::UI::SpinGroup.new
|
42
|
+
spin_group.add(@ctx.message('node.generate.page.generating', selected_type)) do |spinner|
|
43
|
+
Node::Commands::Generate.run_generate("#{selected_type} #{name}", name, @ctx)
|
44
|
+
spinner.update_title(@ctx.message('node.generate.page.generated', name, name))
|
45
|
+
end
|
46
|
+
spin_group.wait
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.help
|
50
|
+
ShopifyCli::Context.message('node.generate.page.help', ShopifyCli::TOOL_NAME)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
require 'json'
|
3
|
+
module Node
|
4
|
+
module Commands
|
5
|
+
class Generate
|
6
|
+
class Webhook < ShopifyCli::SubCommand
|
7
|
+
def call(args, _name)
|
8
|
+
selected_type = args.first
|
9
|
+
schema = ShopifyCli::AdminAPI::Schema.get(@ctx)
|
10
|
+
webhooks = schema.get_names_from_type('WebhookSubscriptionTopic')
|
11
|
+
unless selected_type && webhooks.include?(selected_type)
|
12
|
+
selected_type = CLI::UI::Prompt.ask(@ctx.message('node.generate.webhook.type_select')) do |handler|
|
13
|
+
webhooks.each do |type|
|
14
|
+
handler.option(type) { type }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
spin_group = CLI::UI::SpinGroup.new
|
19
|
+
spin_group.add(@ctx.message('node.generate.webhook.generating', selected_type)) do |spinner|
|
20
|
+
Node::Commands::Generate.run_generate("./node_modules/.bin/generate-node-app webhook #{selected_type}",
|
21
|
+
selected_type, @ctx)
|
22
|
+
spinner.update_title(@ctx.message('node.generate.webhook.generated', selected_type))
|
23
|
+
end
|
24
|
+
spin_group.wait
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.help
|
28
|
+
ShopifyCli::Context.message('node.generate.webhook.help', ShopifyCli::TOOL_NAME)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
|
3
|
+
module Node
|
4
|
+
module Commands
|
5
|
+
class Open < ShopifyCli::Command
|
6
|
+
def call(*)
|
7
|
+
project = ShopifyCli::Project.current
|
8
|
+
@ctx.open_url!("#{project.env.host}/auth?shop=#{project.env.shop}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.help
|
12
|
+
ShopifyCli::Context.message('node.open.help', ShopifyCli::TOOL_NAME)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
|
3
|
+
module Node
|
4
|
+
module Commands
|
5
|
+
class Populate < ShopifyCli::Command
|
6
|
+
subcommand :Customer, 'customers', Project.project_filepath('commands/populate/customer')
|
7
|
+
subcommand :DraftOrder, 'draftorders', Project.project_filepath('commands/populate/draft_order')
|
8
|
+
subcommand :Product, 'products', Project.project_filepath('commands/populate/product')
|
9
|
+
|
10
|
+
def call(_args, _name)
|
11
|
+
@ctx.puts(self.class.help)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.help
|
15
|
+
ShopifyCli::Context.message('node.populate.help', ShopifyCli::TOOL_NAME)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.extended_help
|
19
|
+
ShopifyCli::Context.message('node.populate.extended_help', ShopifyCli::TOOL_NAME)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|