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,28 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Commands
|
5
|
+
class Populate
|
6
|
+
class DraftOrder < ShopifyCli::AdminAPI::PopulateResourceCommand
|
7
|
+
@input_type = :DraftOrderInput
|
8
|
+
|
9
|
+
def defaults
|
10
|
+
{
|
11
|
+
lineItems: [{
|
12
|
+
originalUnitPrice: price,
|
13
|
+
quantity: 1,
|
14
|
+
weight: { value: 10, unit: 'GRAMS' },
|
15
|
+
title: ShopifyCli::Helpers::Haikunator.title,
|
16
|
+
}],
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def message(data)
|
21
|
+
ret = data['draftOrderCreate']['draftOrder']
|
22
|
+
id = ShopifyCli::API.gid_to_id(ret['id'])
|
23
|
+
@ctx.message('rails.populate.draft_order.added', ShopifyCli::Project.current.env.shop, admin_url, id)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'shopify_cli'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Commands
|
5
|
+
class Populate
|
6
|
+
class Product < ShopifyCli::AdminAPI::PopulateResourceCommand
|
7
|
+
@input_type = :ProductInput
|
8
|
+
|
9
|
+
def defaults
|
10
|
+
{
|
11
|
+
title: ShopifyCli::Helpers::Haikunator.title,
|
12
|
+
variants: [{ price: price }],
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def message(data)
|
17
|
+
ret = data['productCreate']['product']
|
18
|
+
id = ShopifyCli::API.gid_to_id(ret['id'])
|
19
|
+
@ctx.message(
|
20
|
+
'rails.populate.product.added',
|
21
|
+
ret['title'],
|
22
|
+
ShopifyCli::Project.current.env.shop,
|
23
|
+
admin_url,
|
24
|
+
id
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Rails
|
3
|
+
module Commands
|
4
|
+
class Serve < ShopifyCli::Command
|
5
|
+
prerequisite_task :ensure_env, :ensure_dev_store
|
6
|
+
|
7
|
+
options do |parser, flags|
|
8
|
+
parser.on('--host=HOST') do |h|
|
9
|
+
flags[:host] = h.gsub('"', '')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(*)
|
14
|
+
project = ShopifyCli::Project.current
|
15
|
+
url = options.flags[:host] || ShopifyCli::Tunnel.start(@ctx)
|
16
|
+
@ctx.abort(@ctx.message('rails.serve.error.host_must_be_https')) if url.match(/^https/i).nil?
|
17
|
+
project.env.update(@ctx, :host, url)
|
18
|
+
ShopifyCli::Tasks::UpdateDashboardURLS.call(
|
19
|
+
@ctx,
|
20
|
+
url: url,
|
21
|
+
callback_url: "/auth/shopify/callback",
|
22
|
+
)
|
23
|
+
if @ctx.mac? && project.env.shop
|
24
|
+
@ctx.puts(@ctx.message('rails.serve.open_info', project.env.shop))
|
25
|
+
@ctx.on_siginfo do
|
26
|
+
@ctx.open_url!("#{project.env.host}/login?shop=#{project.env.shop}")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
Gem.gem_home(@ctx)
|
30
|
+
CLI::UI::Frame.open(@ctx.message('rails.serve.running_server')) do
|
31
|
+
env = ShopifyCli::Project.current.env.to_h
|
32
|
+
env.delete('HOST')
|
33
|
+
env['PORT'] = ShopifyCli::Tunnel::PORT.to_s
|
34
|
+
@ctx.system('bin/rails server', env: env)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.help
|
39
|
+
ShopifyCli::Context.message('rails.serve.help', ShopifyCli::TOOL_NAME)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.extended_help
|
43
|
+
ShopifyCli::Context.message('rails.serve.extended_help', ShopifyCli::TOOL_NAME)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'shopify_cli'
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Commands
|
7
|
+
class Tunnel < ShopifyCli::Command
|
8
|
+
# subcommands :auth, :start, :stop
|
9
|
+
|
10
|
+
def call(args, _name)
|
11
|
+
subcommand = args.shift
|
12
|
+
case subcommand
|
13
|
+
when 'auth'
|
14
|
+
token = args.shift
|
15
|
+
if token.nil?
|
16
|
+
@ctx.puts(@ctx.message('rails.tunnel.error.token_argument_missing'))
|
17
|
+
@ctx.puts("#{self.class.help}\n#{self.class.extended_help}")
|
18
|
+
else
|
19
|
+
ShopifyCli::Tunnel.auth(@ctx, token)
|
20
|
+
end
|
21
|
+
when 'start'
|
22
|
+
ShopifyCli::Tunnel.start(@ctx)
|
23
|
+
when 'stop'
|
24
|
+
ShopifyCli::Tunnel.stop(@ctx)
|
25
|
+
else
|
26
|
+
@ctx.puts(self.class.help)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.help
|
31
|
+
ShopifyCli::Context.message('rails.tunnel.help', ShopifyCli::TOOL_NAME)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.extended_help
|
35
|
+
ShopifyCli::Context.message('rails.tunnel.extended_help', ShopifyCli::TOOL_NAME)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Forms
|
5
|
+
class Create < ShopifyCli::Form
|
6
|
+
attr_accessor :name
|
7
|
+
flag_arguments :title, :organization_id, :shop_domain, :type, :db
|
8
|
+
VALID_DB_TYPES = ['sqlite3',
|
9
|
+
'mysql',
|
10
|
+
'postgresql',
|
11
|
+
'sqlite3',
|
12
|
+
'oracle',
|
13
|
+
'frontbase',
|
14
|
+
'ibm_db',
|
15
|
+
'sqlserver',
|
16
|
+
'jdbcmysql',
|
17
|
+
'jdbcsqlite3',
|
18
|
+
'jdbcpostgresql',
|
19
|
+
'jdbc']
|
20
|
+
|
21
|
+
def ask
|
22
|
+
self.title ||= CLI::UI::Prompt.ask(ctx.message('rails.forms.create.app_name'))
|
23
|
+
self.type = ask_type
|
24
|
+
self.name = self.title.downcase.split(" ").join("_")
|
25
|
+
self.organization_id ||= organization["id"].to_i
|
26
|
+
self.shop_domain ||= ask_shop_domain
|
27
|
+
self.db = ask_db
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def ask_type
|
33
|
+
if type.nil?
|
34
|
+
return CLI::UI::Prompt.ask(ctx.message('rails.forms.create.app_type.select')) do |handler|
|
35
|
+
handler.option(ctx.message('rails.forms.create.app_type.select_public')) { 'public' }
|
36
|
+
handler.option(ctx.message('rails.forms.create.app_type.select_custom')) { 'custom' }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
unless ShopifyCli::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type)
|
41
|
+
ctx.abort(ctx.message('rails.forms.create.error.invalid_app_type', type))
|
42
|
+
end
|
43
|
+
ctx.puts(ctx.message('rails.forms.create.app_type.selected', type))
|
44
|
+
type
|
45
|
+
end
|
46
|
+
|
47
|
+
def organizations
|
48
|
+
@organizations ||= ShopifyCli::PartnersAPI::Organizations.fetch_all(ctx)
|
49
|
+
end
|
50
|
+
|
51
|
+
def organization
|
52
|
+
@organization ||= if !organization_id.nil?
|
53
|
+
org = ShopifyCli::PartnersAPI::Organizations.fetch(ctx, id: organization_id)
|
54
|
+
if org.nil?
|
55
|
+
ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
56
|
+
ctx.abort(ctx.message('rails.forms.create.error.organization_not_found'))
|
57
|
+
end
|
58
|
+
org
|
59
|
+
elsif organizations.count == 0
|
60
|
+
ctx.puts(ctx.message('rails.forms.create.partners_notice'))
|
61
|
+
ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
62
|
+
ctx.abort(ctx.message('rails.forms.create.error.no_organizations'))
|
63
|
+
elsif organizations.count == 1
|
64
|
+
org = organizations.first
|
65
|
+
ctx.puts(ctx.message('rails.forms.create.organization',
|
66
|
+
ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])))
|
67
|
+
org
|
68
|
+
else
|
69
|
+
org_id = CLI::UI::Prompt.ask(ctx.message('rails.forms.create.organization_select')) do |handler|
|
70
|
+
organizations.each { |o| handler.option(o['businessName']) { o['id'] } }
|
71
|
+
end
|
72
|
+
organizations.find { |o| o['id'] == org_id }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def ask_shop_domain
|
77
|
+
valid_stores = organization['stores'].select do |store|
|
78
|
+
store['transferDisabled'] == true || store['convertableToPartnerTest'] == true
|
79
|
+
end
|
80
|
+
|
81
|
+
if valid_stores.count == 0
|
82
|
+
ctx.puts(ctx.message('rails.forms.create.no_development_stores'))
|
83
|
+
ctx.puts(ctx.message('rails.forms.create.create_store', organization['id']))
|
84
|
+
ctx.puts(ctx.message('rails.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
85
|
+
elsif valid_stores.count == 1
|
86
|
+
domain = valid_stores.first['shopDomain']
|
87
|
+
ctx.puts(ctx.message('rails.forms.create.development_store', domain))
|
88
|
+
domain
|
89
|
+
else
|
90
|
+
CLI::UI::Prompt.ask(
|
91
|
+
ctx.message('rails.forms.create.development_store_select'),
|
92
|
+
options: valid_stores.map { |s| s['shopDomain'] }
|
93
|
+
)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def ask_db
|
98
|
+
if db.nil?
|
99
|
+
return 'sqlite3' unless CLI::UI::Prompt.confirm(ctx.message('rails.forms.create.db.want_select'),
|
100
|
+
default: false)
|
101
|
+
@db = CLI::UI::Prompt.ask(ctx.message('rails.forms.create.db.select')) do |handler|
|
102
|
+
VALID_DB_TYPES.each do |db_type|
|
103
|
+
handler.option(ctx.message("rails.forms.create.db.select_#{db_type}")) { db_type }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
unless VALID_DB_TYPES.include?(db)
|
109
|
+
ctx.abort(ctx.message('rails.forms.create.error.invalid_db_type', db))
|
110
|
+
end
|
111
|
+
ctx.puts(ctx.message('rails.forms.create.db.selected', db))
|
112
|
+
db
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'shopify_cli'
|
3
|
+
|
4
|
+
module Rails
|
5
|
+
class Gem
|
6
|
+
include SmartProperties
|
7
|
+
|
8
|
+
property :ctx, accepts: ShopifyCli::Context, required: true
|
9
|
+
property :name, converts: :to_s, required: true
|
10
|
+
property :version, converts: :to_s
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def install(ctx, *args)
|
14
|
+
name = args.shift
|
15
|
+
version = args.shift
|
16
|
+
gem = new(ctx: ctx, name: name, version: version)
|
17
|
+
ctx.debug(ctx.message('rails.gem.installed_debug', name, gem.installed?))
|
18
|
+
gem.install! unless gem.installed?
|
19
|
+
end
|
20
|
+
|
21
|
+
def binary_path_for(ctx, binary)
|
22
|
+
File.join(gem_home(ctx), 'bin', binary)
|
23
|
+
end
|
24
|
+
|
25
|
+
def gem_home(ctx)
|
26
|
+
ctx.getenv('GEM_HOME') || apply_gem_home(ctx)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def apply_gem_home(ctx)
|
32
|
+
path = File.join(ctx.getenv('HOME'), '.gem', 'ruby', RUBY_VERSION)
|
33
|
+
ctx.mkdir_p(path) unless Dir.exist?(path)
|
34
|
+
ctx.setenv('GEM_HOME', path)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def installed?
|
39
|
+
!!Dir.glob("#{self.class.gem_home(ctx)}/gems/#{name}-*").detect do |f|
|
40
|
+
f =~ %r{/#{Regexp.quote(name)}-\d}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def install!
|
45
|
+
spin = CLI::UI::SpinGroup.new
|
46
|
+
spin.add(ctx.message('rails.gem.installing', name)) do |spinner|
|
47
|
+
args = %w(gem install)
|
48
|
+
args.push(name)
|
49
|
+
args.push('-v', version) unless version.nil?
|
50
|
+
ctx.system(*args)
|
51
|
+
spinner.update_title(ctx.message('rails.gem.installed', name))
|
52
|
+
end
|
53
|
+
spin.wait
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,283 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Messages
|
5
|
+
MESSAGES = {
|
6
|
+
rails: {
|
7
|
+
error: {
|
8
|
+
generic: "Error",
|
9
|
+
},
|
10
|
+
|
11
|
+
gem: {
|
12
|
+
installed_debug: "%s installed: %s",
|
13
|
+
installing: "Installing %s gem...",
|
14
|
+
installed: "Installed %s gem",
|
15
|
+
},
|
16
|
+
|
17
|
+
create: {
|
18
|
+
help: <<~HELP,
|
19
|
+
{{command:%s create rails}}: Creates a ruby on rails app.
|
20
|
+
Usage: {{command:%s create rails}}
|
21
|
+
Options:
|
22
|
+
{{command:--name=NAME}} App name. Any string.
|
23
|
+
{{command:--app_url=APPURL}} App URL. Must be a valid URL.
|
24
|
+
{{command:--organization_id=ID}} Partner organization ID. Must be an existing organization.
|
25
|
+
{{command:--shop_domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
|
26
|
+
{{command:--db=DB}} Database type. Must be one of: mysql, postgresql, sqlite3, oracle, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.
|
27
|
+
{{command:--rails_opts=RAILSOPTS}} Additional options. Must be string containing one or more valid Rails options, separated by spaces.
|
28
|
+
HELP
|
29
|
+
|
30
|
+
error: {
|
31
|
+
invalid_ruby_version: <<~MSG,
|
32
|
+
This project requires a ruby version ~> 2.5.
|
33
|
+
See {{underline:https://github.com/Shopify/shopify-app-cli/blob/master/docs/installing-ruby.md}}
|
34
|
+
for our recommended method of installing ruby.
|
35
|
+
MSG
|
36
|
+
},
|
37
|
+
|
38
|
+
info: {
|
39
|
+
created: "{{v}} {{green:%s}} was created in your Partner Dashboard {{underline:%s}}",
|
40
|
+
serve: "{{*}} Change into your new project folder {{green:%s}} and run {{command:%s serve}} to start a " \
|
41
|
+
"local server",
|
42
|
+
install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
|
43
|
+
},
|
44
|
+
installing_bundler: "Installing bundler…",
|
45
|
+
generating_app: "Generating new rails app project in %s...",
|
46
|
+
adding_shopify_gem: "{{v}} Adding shopify_app gem…",
|
47
|
+
running_bundle_install: "Running bundle install...",
|
48
|
+
running_generator: "Running shopify_app generator...",
|
49
|
+
running_migrations: "Running migrations…",
|
50
|
+
},
|
51
|
+
|
52
|
+
deploy: {
|
53
|
+
help: <<~HELP,
|
54
|
+
Deploy the current Rails project to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future.
|
55
|
+
Usage: {{command:%s deploy [ heroku ]}}
|
56
|
+
HELP
|
57
|
+
extended_help: <<~HELP,
|
58
|
+
{{bold:Subcommands:}}
|
59
|
+
{{cyan:heroku}}: Deploys the current Rails project to Heroku.
|
60
|
+
Usage: {{command:%s deploy heroku}}
|
61
|
+
HELP
|
62
|
+
|
63
|
+
heroku: {
|
64
|
+
help: <<~HELP,
|
65
|
+
Deploy the current Rails project to Heroku
|
66
|
+
Usage: {{command:%s deploy heroku}}
|
67
|
+
HELP
|
68
|
+
downloading: "Downloading Heroku CLI…",
|
69
|
+
downloaded: "Downloaded Heroku CLI",
|
70
|
+
installing: "Installing Heroku CLI…",
|
71
|
+
installed: "Installed Heroku CLI",
|
72
|
+
authenticated_with_account: "{{v}} Authenticated with Heroku as `%s`",
|
73
|
+
authenticating: "Authenticating with Heroku…",
|
74
|
+
authenticated: "{{v}} Authenticated with Heroku",
|
75
|
+
deploying: "Deploying to Heroku…",
|
76
|
+
deployed: "{{v}} Deployed to Heroku",
|
77
|
+
db_check: {
|
78
|
+
validating: "Validating application...",
|
79
|
+
checking: "Checking database type...",
|
80
|
+
validated: "Database type \"%s\" validated for platform \"Heroku\"",
|
81
|
+
problem: "A problem was encountered while checking your database type.",
|
82
|
+
sqlite: <<~SQLITE,
|
83
|
+
Heroku does not support deployment using the SQLite database system.
|
84
|
+
Change the database type using {{command:rails db:system:change --to=[new_db_type]}}. For more info:
|
85
|
+
{{underline:https://gorails.com/episodes/rails-6-db-system-change-command}}
|
86
|
+
SQLITE
|
87
|
+
},
|
88
|
+
git: {
|
89
|
+
checking: "Checking git repo…",
|
90
|
+
initialized: "Git repo initialized",
|
91
|
+
what_branch: "What branch would you like to deploy?",
|
92
|
+
branch_selected: "{{v}} Git branch `%s` selected for deploy",
|
93
|
+
},
|
94
|
+
app: {
|
95
|
+
no_apps_found: "No existing Heroku app found. What would you like to do?",
|
96
|
+
name: "What is your Heroku app’s name?",
|
97
|
+
select: "Specify an existing Heroku app",
|
98
|
+
selecting: "Selecting Heroku app `%s`…",
|
99
|
+
selected: "{{v}} Heroku app `%s` selected",
|
100
|
+
create: "Create a new Heroku app",
|
101
|
+
creating: "Creating new Heroku app…",
|
102
|
+
created: "{{v}} New Heroku app created",
|
103
|
+
},
|
104
|
+
},
|
105
|
+
},
|
106
|
+
|
107
|
+
generate: {
|
108
|
+
help: <<~HELP,
|
109
|
+
Generate code in your Rails project. Currently supports generating new webhooks.
|
110
|
+
Usage: {{command:%s generate [ webhook ]}}
|
111
|
+
HELP
|
112
|
+
extended_help: <<~EXAMPLES,
|
113
|
+
{{bold:Examples:}}
|
114
|
+
{{cyan:%s generate webhook PRODUCTS_CREATE}}
|
115
|
+
Generate and register a new webhook that will be called every time a new product is created on your store.
|
116
|
+
EXAMPLES
|
117
|
+
|
118
|
+
error: {
|
119
|
+
name_exists: "%s already exists!",
|
120
|
+
generic: "Error generating %s",
|
121
|
+
},
|
122
|
+
|
123
|
+
webhook: {
|
124
|
+
help: <<~HELP,
|
125
|
+
Generate and register a new webhook that listens for the specified Shopify store event.
|
126
|
+
Usage: {{command:%s generate webhook <type>}}
|
127
|
+
HELP
|
128
|
+
|
129
|
+
select: "What type of webhook would you like to create?",
|
130
|
+
selected: "Generating webhook: %s",
|
131
|
+
},
|
132
|
+
},
|
133
|
+
|
134
|
+
open: {
|
135
|
+
help: <<~HELP,
|
136
|
+
Open your local development app in the default browser.
|
137
|
+
Usage: {{command:%s open}}
|
138
|
+
HELP
|
139
|
+
},
|
140
|
+
|
141
|
+
populate: {
|
142
|
+
help: <<~HELP,
|
143
|
+
Populate your Shopify development store with example customers, orders, or products.
|
144
|
+
Usage: {{command:%s populate [ customers | draftorders | products ]}}
|
145
|
+
HELP
|
146
|
+
extended_help: <<~HELP,
|
147
|
+
{{bold:Subcommands:}}
|
148
|
+
|
149
|
+
{{cyan:customers [options]}}: Add dummy customers to the specified development store.
|
150
|
+
Usage: {{command:%1$s populate customers}}
|
151
|
+
|
152
|
+
{{cyan:draftorders [options]}}: Add dummy orders to the specified development store.
|
153
|
+
Usage: {{command:%1$s populate draftorders}}
|
154
|
+
|
155
|
+
{{cyan:products [options]}}: Add dummy products to the specified development store.
|
156
|
+
Usage: {{command:%1$s populate products}}
|
157
|
+
|
158
|
+
{{bold:Options:}}
|
159
|
+
|
160
|
+
{{cyan:--count [integer]}}: The number of dummy items to populate. Defaults to 5.
|
161
|
+
{{cyan:--silent}}: Silence the populate output.
|
162
|
+
{{cyan:--help}}: Display more options specific to each subcommand.
|
163
|
+
|
164
|
+
{{bold:Examples:}}
|
165
|
+
|
166
|
+
{{command:%1$s populate products}}
|
167
|
+
Populate your development store with 5 additional products.
|
168
|
+
|
169
|
+
{{command:%1$s populate customers --count 30}}
|
170
|
+
Populate your development store with 30 additional customers.
|
171
|
+
|
172
|
+
{{command:%1$s populate draftorders}}
|
173
|
+
Populate your development store with 5 additional orders.
|
174
|
+
|
175
|
+
{{command:%1$s populate products --help}}
|
176
|
+
Display the list of options available to customize the {{command:%1$s populate products}} command.
|
177
|
+
HELP
|
178
|
+
|
179
|
+
customer: {
|
180
|
+
added: "%s added to {{green:%s}} at {{underline:%scustomers/%d}}",
|
181
|
+
},
|
182
|
+
|
183
|
+
draft_order: {
|
184
|
+
added: "DraftOrder added to {{green:%s}} at {{underline:%sdraft_orders/%d}}",
|
185
|
+
},
|
186
|
+
|
187
|
+
product: {
|
188
|
+
added: "%s added to {{green:%s}} at {{underline:%sproducts/%d}}",
|
189
|
+
},
|
190
|
+
},
|
191
|
+
|
192
|
+
serve: {
|
193
|
+
help: <<~HELP,
|
194
|
+
Start a local development rails server for your project, as well as a public ngrok tunnel to your localhost.
|
195
|
+
Usage: {{command:%s serve}}
|
196
|
+
HELP
|
197
|
+
extended_help: <<~HELP,
|
198
|
+
{{bold:Options:}}
|
199
|
+
{{cyan:--host=HOST}}: Bypass running tunnel and use custom host. HOST must be HTTPS url.
|
200
|
+
HELP
|
201
|
+
|
202
|
+
error: {
|
203
|
+
host_must_be_https: "{{red:HOST must be a HTTPS url.}}",
|
204
|
+
},
|
205
|
+
|
206
|
+
open_info: "{{*}} Press {{yellow: Control-T}} to open this project in {{green:%s}} ",
|
207
|
+
running_server: "Running server...",
|
208
|
+
},
|
209
|
+
|
210
|
+
tunnel: {
|
211
|
+
help: <<~HELP,
|
212
|
+
Start or stop an http tunnel to your local development app using ngrok.
|
213
|
+
Usage: {{command:%s tunnel [ auth | start | stop ]}}
|
214
|
+
HELP
|
215
|
+
extended_help: <<~HELP,
|
216
|
+
{{bold:Subcommands:}}
|
217
|
+
|
218
|
+
{{cyan:auth}}: Writes an ngrok auth token to ~/.ngrok2/ngrok.yml to connect with an ngrok account. Visit https://dashboard.ngrok.com/signup to sign up.
|
219
|
+
Usage: {{command:%1$s tunnel auth <token>}}
|
220
|
+
|
221
|
+
{{cyan:start}}: Starts an ngrok tunnel, will print the URL for an existing tunnel if already running.
|
222
|
+
Usage: {{command:%1$s tunnel start}}
|
223
|
+
|
224
|
+
{{cyan:stop}}: Stops the ngrok tunnel.
|
225
|
+
Usage: {{command:%1$s tunnel stop}}
|
226
|
+
|
227
|
+
HELP
|
228
|
+
|
229
|
+
error: {
|
230
|
+
token_argument_missing: "{{x}} {{red:auth requires a token argument}}\n\n",
|
231
|
+
},
|
232
|
+
},
|
233
|
+
|
234
|
+
forms: {
|
235
|
+
create: {
|
236
|
+
error: {
|
237
|
+
invalid_app_type: "Invalid app type %s",
|
238
|
+
invalid_db_type: "Invalid database type %s",
|
239
|
+
organization_not_found: "Cannot find a partner organization with that ID",
|
240
|
+
no_organizations: "No partner organizations available.",
|
241
|
+
},
|
242
|
+
|
243
|
+
authentication_issue: "For authentication issues, run {{command:%s logout}} to clear invalid credentials",
|
244
|
+
partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
|
245
|
+
no_development_stores: "{{x}} No development stores available.",
|
246
|
+
create_store: "Visit {{underline:https://partners.shopify.com/%s/stores}} to create one",
|
247
|
+
app_name: "App name",
|
248
|
+
app_type: {
|
249
|
+
select: "What type of app are you building?",
|
250
|
+
select_public: "Public: An app built for a wide merchant audience.",
|
251
|
+
select_custom: "Custom: An app custom built for a single client.",
|
252
|
+
selected: "App type {{green:%s}}",
|
253
|
+
},
|
254
|
+
db: {
|
255
|
+
want_select: <<~WANT_SELECT,
|
256
|
+
Would you like to select what database type to use now? (SQLite is the default)
|
257
|
+
If you want to change this in the future, run {{command:rails db:system:change --to=[new_db_type]}}. For more info:
|
258
|
+
{{underline:https://gorails.com/episodes/rails-6-db-system-change-command}}
|
259
|
+
WANT_SELECT
|
260
|
+
select: "What database type would you like to use? Please ensure the database is installed.",
|
261
|
+
select_sqlite3: "SQLite (default)",
|
262
|
+
select_mysql: "MySQL",
|
263
|
+
select_postgresql: "PostgreSQL",
|
264
|
+
select_oracle: "Oracle",
|
265
|
+
select_frontbase: "FrontBase",
|
266
|
+
select_ibm_db: "IBM_DB",
|
267
|
+
select_sqlserver: "SQL Server",
|
268
|
+
select_jdbcmysql: "JDBC MySQL",
|
269
|
+
select_jdbcsqlite3: "JDBC SQlite",
|
270
|
+
select_jdbcpostgresql: "JDBC PostgreSQL",
|
271
|
+
select_jdbc: "JDBC",
|
272
|
+
selected: "Database Type {{green:%s}}",
|
273
|
+
},
|
274
|
+
organization_select: "Select partner organization",
|
275
|
+
organization: "Partner organization {{green:%s}}",
|
276
|
+
development_store_select: "Select a development store",
|
277
|
+
development_store: "Using development store {{green:%s}}",
|
278
|
+
},
|
279
|
+
},
|
280
|
+
},
|
281
|
+
}.freeze
|
282
|
+
end
|
283
|
+
end
|