shopify-cli 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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,31 @@
|
|
|
1
|
+
require 'shopify_cli'
|
|
2
|
+
|
|
3
|
+
module Node
|
|
4
|
+
module Commands
|
|
5
|
+
class Populate
|
|
6
|
+
class Customer < ShopifyCli::AdminAPI::PopulateResourceCommand
|
|
7
|
+
@input_type = :CustomerInput
|
|
8
|
+
|
|
9
|
+
def defaults
|
|
10
|
+
first_name, last_name = ShopifyCli::Helpers::Haikunator.name
|
|
11
|
+
{
|
|
12
|
+
firstName: first_name,
|
|
13
|
+
lastName: last_name,
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def message(data)
|
|
18
|
+
ret = data['customerCreate']['customer']
|
|
19
|
+
id = ShopifyCli::API.gid_to_id(ret['id'])
|
|
20
|
+
@ctx.message(
|
|
21
|
+
'node.populate.customer.added',
|
|
22
|
+
ret['displayName'],
|
|
23
|
+
ShopifyCli::Project.current.env.shop,
|
|
24
|
+
admin_url,
|
|
25
|
+
id
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'shopify_cli'
|
|
2
|
+
|
|
3
|
+
module Node
|
|
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('node.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 Node
|
|
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
|
+
'node.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,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Node
|
|
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('node.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/callback",
|
|
22
|
+
)
|
|
23
|
+
if @ctx.mac? && project.env.shop
|
|
24
|
+
@ctx.puts(@ctx.message('node.serve.open_info', project.env.shop))
|
|
25
|
+
@ctx.on_siginfo do
|
|
26
|
+
@ctx.open_url!("#{project.env.host}/auth?shop=#{project.env.shop}")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
CLI::UI::Frame.open(@ctx.message('node.serve.running_server')) do
|
|
30
|
+
env = project.env.to_h
|
|
31
|
+
env['PORT'] = ShopifyCli::Tunnel::PORT.to_s
|
|
32
|
+
@ctx.system('npm run dev', env: env)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.help
|
|
37
|
+
ShopifyCli::Context.message('node.serve.help', ShopifyCli::TOOL_NAME)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.extended_help
|
|
41
|
+
ShopifyCli::Context.message('node.serve.extended_help')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'shopify_cli'
|
|
4
|
+
|
|
5
|
+
module Node
|
|
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('node.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('node.tunnel.help', ShopifyCli::TOOL_NAME)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.extended_help
|
|
35
|
+
ShopifyCli::Context.message('node.tunnel.extended_help', ShopifyCli::TOOL_NAME)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
|
|
3
|
+
module Node
|
|
4
|
+
module Forms
|
|
5
|
+
class Create < ShopifyCli::Form
|
|
6
|
+
attr_accessor :name
|
|
7
|
+
flag_arguments :title, :organization_id, :shop_domain, :type
|
|
8
|
+
|
|
9
|
+
def ask
|
|
10
|
+
self.title ||= CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_name'))
|
|
11
|
+
self.type = ask_type
|
|
12
|
+
self.name = self.title.downcase.split(" ").join("_")
|
|
13
|
+
self.organization_id ||= organization["id"].to_i
|
|
14
|
+
self.shop_domain ||= ask_shop_domain
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def ask_type
|
|
20
|
+
if type.nil?
|
|
21
|
+
return CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_type.select')) do |handler|
|
|
22
|
+
handler.option(ctx.message('node.forms.create.app_type.select_public')) { 'public' }
|
|
23
|
+
handler.option(ctx.message('node.forms.create.app_type.select_custom')) { 'custom' }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
unless ShopifyCli::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type)
|
|
28
|
+
ctx.abort(ctx.message('node.forms.create.error.invalid_app_type', type))
|
|
29
|
+
end
|
|
30
|
+
ctx.puts(ctx.message('node.forms.create.app_type.selected', type))
|
|
31
|
+
type
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def organizations
|
|
35
|
+
@organizations ||= ShopifyCli::PartnersAPI::Organizations.fetch_all(ctx)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def organization
|
|
39
|
+
@organization ||= if !organization_id.nil?
|
|
40
|
+
org = ShopifyCli::PartnersAPI::Organizations.fetch(ctx, id: organization_id)
|
|
41
|
+
if org.nil?
|
|
42
|
+
ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
|
43
|
+
ctx.abort(ctx.message('node.forms.create.error.organization_not_found'))
|
|
44
|
+
end
|
|
45
|
+
org
|
|
46
|
+
elsif organizations.count == 0
|
|
47
|
+
ctx.puts(ctx.message('node.forms.create.partners_notice'))
|
|
48
|
+
ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
|
49
|
+
ctx.abort(ctx.message('node.forms.create.error.no_organizations'))
|
|
50
|
+
elsif organizations.count == 1
|
|
51
|
+
org = organizations.first
|
|
52
|
+
ctx.puts(ctx.message('node.forms.create.organization',
|
|
53
|
+
ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])))
|
|
54
|
+
org
|
|
55
|
+
else
|
|
56
|
+
org_id = CLI::UI::Prompt.ask(ctx.message('node.forms.create.organization_select')) do |handler|
|
|
57
|
+
organizations.each do |o|
|
|
58
|
+
handler.option(ctx.message('core.partners_api.org_name_and_id', o['businessName'], o['id'])) { o['id'] }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
organizations.find { |o| o['id'] == org_id }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def ask_shop_domain
|
|
66
|
+
valid_stores = organization['stores'].select do |store|
|
|
67
|
+
store['transferDisabled'] == true || store['convertableToPartnerTest'] == true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if valid_stores.count == 0
|
|
71
|
+
ctx.puts(ctx.message('node.forms.create.no_development_stores'))
|
|
72
|
+
ctx.puts(ctx.message('node.forms.create.create_store', organization['id']))
|
|
73
|
+
ctx.puts(ctx.message('node.forms.create.authentication_issue', ShopifyCli::TOOL_NAME))
|
|
74
|
+
elsif valid_stores.count == 1
|
|
75
|
+
domain = valid_stores.first['shopDomain']
|
|
76
|
+
ctx.puts(ctx.message('node.forms.create.development_store', domain))
|
|
77
|
+
domain
|
|
78
|
+
else
|
|
79
|
+
CLI::UI::Prompt.ask(
|
|
80
|
+
ctx.message('node.forms.create.development_store_select'),
|
|
81
|
+
options: valid_stores.map { |s| s['shopDomain'] }
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Node
|
|
4
|
+
module Messages
|
|
5
|
+
MESSAGES = {
|
|
6
|
+
node: {
|
|
7
|
+
error: {
|
|
8
|
+
generic: "Error",
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
create: {
|
|
12
|
+
help: <<~HELP,
|
|
13
|
+
{{command:%s create node}}: Creates an embedded nodejs app.
|
|
14
|
+
Usage: {{command:%s create node}}
|
|
15
|
+
Options:
|
|
16
|
+
{{command:--name=NAME}} App name. Any string.
|
|
17
|
+
{{command:--app_url=APPURL}} App URL. Must be a valid URL.
|
|
18
|
+
{{command:--organization_id=ID}} Partner organization ID. Must be an existing organization.
|
|
19
|
+
{{command:--shop_domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
|
|
20
|
+
HELP
|
|
21
|
+
error: {
|
|
22
|
+
node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.",
|
|
23
|
+
node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
|
|
24
|
+
"per the instructions at https://nodejs.org/en.",
|
|
25
|
+
npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
|
|
26
|
+
npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
|
|
27
|
+
"the instructions at https://www.npmjs.com/get-npm.",
|
|
28
|
+
},
|
|
29
|
+
info: {
|
|
30
|
+
created: "{{v}} {{green:%s}} was created in your Partner Dashboard {{underline:%s}}",
|
|
31
|
+
serve: "{{*}} Change into your new project folder {{green:%s}} and run {{command:%s serve}} to start a " \
|
|
32
|
+
"local server",
|
|
33
|
+
install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
|
|
34
|
+
},
|
|
35
|
+
node_version: "node %s",
|
|
36
|
+
npm_version: "npm %s",
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
deploy: {
|
|
40
|
+
help: <<~HELP,
|
|
41
|
+
Deploy the current Node project to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future.
|
|
42
|
+
Usage: {{command:%s deploy [ heroku ]}}
|
|
43
|
+
HELP
|
|
44
|
+
extended_help: <<~HELP,
|
|
45
|
+
{{bold:Subcommands:}}
|
|
46
|
+
{{cyan:heroku}}: Deploys the current Node project to Heroku.
|
|
47
|
+
Usage: {{command:%s deploy heroku}}
|
|
48
|
+
HELP
|
|
49
|
+
heroku: {
|
|
50
|
+
help: <<~HELP,
|
|
51
|
+
Deploy the current Node project to Heroku
|
|
52
|
+
Usage: {{command:%s deploy heroku}}
|
|
53
|
+
HELP
|
|
54
|
+
downloading: "Downloading Heroku CLI…",
|
|
55
|
+
downloaded: "Downloaded Heroku CLI",
|
|
56
|
+
installing: "Installing Heroku CLI…",
|
|
57
|
+
installed: "Installed Heroku CLI",
|
|
58
|
+
authenticating: "Authenticating with Heroku…",
|
|
59
|
+
authenticated: "{{v}} Authenticated with Heroku",
|
|
60
|
+
authenticated_with_account: "{{v}} Authenticated with Heroku as `%s`",
|
|
61
|
+
deploying: "Deploying to Heroku…",
|
|
62
|
+
deployed: "{{v}} Deployed to Heroku",
|
|
63
|
+
git: {
|
|
64
|
+
checking: "Checking git repo…",
|
|
65
|
+
initialized: "Git repo initialized",
|
|
66
|
+
what_branch: "What branch would you like to deploy?",
|
|
67
|
+
branch_selected: "{{v}} Git branch `%s` selected for deploy",
|
|
68
|
+
},
|
|
69
|
+
app: {
|
|
70
|
+
no_apps_found: "No existing Heroku app found. What would you like to do?",
|
|
71
|
+
name: "What is your Heroku app’s name?",
|
|
72
|
+
select: "Specify an existing Heroku app",
|
|
73
|
+
selecting: "Selecting Heroku app `%s`…",
|
|
74
|
+
selected: "{{v}} Heroku app `%s` selected",
|
|
75
|
+
create: "Create a new Heroku app",
|
|
76
|
+
creating: "Creating new Heroku app…",
|
|
77
|
+
created: "{{v}} New Heroku app created",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
generate: {
|
|
83
|
+
help: <<~HELP,
|
|
84
|
+
Generate code in your Node project. Supports generating new billing API calls, new pages, or new webhooks.
|
|
85
|
+
Usage: {{command:%s generate [ billing | page | webhook ]}}
|
|
86
|
+
HELP
|
|
87
|
+
extended_help: <<~EXAMPLES,
|
|
88
|
+
{{bold:Examples:}}
|
|
89
|
+
{{cyan:%s generate webhook PRODUCTS_CREATE}}
|
|
90
|
+
Generate and register a new webhook that will be called every time a new product is created on your store.
|
|
91
|
+
EXAMPLES
|
|
92
|
+
|
|
93
|
+
error: {
|
|
94
|
+
name_exists: "%s already exists!",
|
|
95
|
+
generic: "Error generating %s",
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
billing: {
|
|
99
|
+
help: <<~HELP,
|
|
100
|
+
Enable charging for your app. This command generates the necessary code to call Shopify’s billing API.
|
|
101
|
+
Usage: {{command:%s generate billing [ one-time-billing | recurring-billing ]}}
|
|
102
|
+
HELP
|
|
103
|
+
type_select: "How would you like to charge for your app?",
|
|
104
|
+
generating: "Generating %s code ...",
|
|
105
|
+
generated: "{{green:%s}} generated in server/server.js",
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
page: {
|
|
109
|
+
help: <<~HELP,
|
|
110
|
+
Generate a new page in your app with the specified name. New files are generated inside the project’s “/pages” directory.
|
|
111
|
+
Usage: {{command:%s generate page <pagename>}}
|
|
112
|
+
HELP
|
|
113
|
+
error: {
|
|
114
|
+
invalid_page_type: "Invalid page type.",
|
|
115
|
+
},
|
|
116
|
+
type_select: "Which template would you like to use?",
|
|
117
|
+
generating: "Generating %s page...",
|
|
118
|
+
generated: "{{green: %s}} generated in pages/%s",
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
webhook: {
|
|
122
|
+
help: <<~HELP,
|
|
123
|
+
Generate and register a new webhook that listens for the specified Shopify store event.
|
|
124
|
+
Usage: {{command:%s generate webhook <type>}}
|
|
125
|
+
HELP
|
|
126
|
+
type_select: "What type of webhook would you like to create?",
|
|
127
|
+
generating: "Generating webhook: %s",
|
|
128
|
+
generated: "{{green:%s}} generated in server/server.js",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
open: {
|
|
133
|
+
help: <<~HELP,
|
|
134
|
+
Open your local development app in the default browser.
|
|
135
|
+
Usage: {{command:%s open}}
|
|
136
|
+
HELP
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
populate: {
|
|
140
|
+
help: <<~HELP,
|
|
141
|
+
Populate your Shopify development store with example customers, orders, or products.
|
|
142
|
+
Usage: {{command:%s populate [ customers | draftorders | products ]}}
|
|
143
|
+
HELP
|
|
144
|
+
extended_help: <<~HELP,
|
|
145
|
+
{{bold:Subcommands:}}
|
|
146
|
+
|
|
147
|
+
{{cyan:customers [options]}}: Add dummy customers to the specified development store.
|
|
148
|
+
Usage: {{command:%1$s populate customers}}
|
|
149
|
+
|
|
150
|
+
{{cyan:draftorders [options]}}: Add dummy orders to the specified development store.
|
|
151
|
+
Usage: {{command:%1$s populate draftorders}}
|
|
152
|
+
|
|
153
|
+
{{cyan:products [options]}}: Add dummy products to the specified development store.
|
|
154
|
+
Usage: {{command:%1$s populate products}}
|
|
155
|
+
|
|
156
|
+
{{bold:Options:}}
|
|
157
|
+
|
|
158
|
+
{{cyan:--count [integer]}}: The number of dummy items to populate. Defaults to 5.
|
|
159
|
+
{{cyan:--silent}}: Silence the populate output.
|
|
160
|
+
{{cyan:--help}}: Display more options specific to each subcommand.
|
|
161
|
+
|
|
162
|
+
{{bold:Examples:}}
|
|
163
|
+
|
|
164
|
+
{{command:%1$s populate products}}
|
|
165
|
+
Populate your development store with 5 additional products.
|
|
166
|
+
|
|
167
|
+
{{command:%1$s populate customers --count 30}}
|
|
168
|
+
Populate your development store with 30 additional customers.
|
|
169
|
+
|
|
170
|
+
{{command:%1$s populate draftorders}}
|
|
171
|
+
Populate your development store with 5 additional orders.
|
|
172
|
+
|
|
173
|
+
{{command:%1$s populate products --help}}
|
|
174
|
+
Display the list of options available to customize the {{command:%1$s populate products}} command.
|
|
175
|
+
HELP
|
|
176
|
+
|
|
177
|
+
customer: {
|
|
178
|
+
added: "%s added to {{green:%s}} at {{underline:%scustomers/%d}}",
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
draft_order: {
|
|
182
|
+
added: "DraftOrder added to {{green:%s}} at {{underline:%sdraft_orders/%d}}",
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
product: {
|
|
186
|
+
added: "%s added to {{green:%s}} at {{underline:%sproducts/%d}}",
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
serve: {
|
|
191
|
+
help: <<~HELP,
|
|
192
|
+
Start a local development node server for your project, as well as a public ngrok tunnel to your localhost.
|
|
193
|
+
Usage: {{command:%s serve}}
|
|
194
|
+
HELP
|
|
195
|
+
extended_help: <<~HELP,
|
|
196
|
+
{{bold:Options:}}
|
|
197
|
+
{{cyan:--host=HOST}}: Bypass running tunnel and use custom host. HOST must be HTTPS url.
|
|
198
|
+
HELP
|
|
199
|
+
|
|
200
|
+
error: {
|
|
201
|
+
host_must_be_https: "HOST must be a HTTPS url.",
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
open_info: "{{*}} Press {{yellow: Control-T}} to open this project in {{green:%s}} ",
|
|
205
|
+
running_server: "Running server...",
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
tunnel: {
|
|
209
|
+
help: <<~HELP,
|
|
210
|
+
Start or stop an http tunnel to your local development app using ngrok.
|
|
211
|
+
Usage: {{command:%s tunnel [ auth | start | stop ]}}
|
|
212
|
+
HELP
|
|
213
|
+
extended_help: <<~HELP,
|
|
214
|
+
{{bold:Subcommands:}}
|
|
215
|
+
|
|
216
|
+
{{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.
|
|
217
|
+
Usage: {{command:%1$s tunnel auth <token>}}
|
|
218
|
+
|
|
219
|
+
{{cyan:start}}: Starts an ngrok tunnel, will print the URL for an existing tunnel if already running.
|
|
220
|
+
Usage: {{command:%1$s tunnel start}}
|
|
221
|
+
|
|
222
|
+
{{cyan:stop}}: Stops the ngrok tunnel.
|
|
223
|
+
Usage: {{command:%1$s tunnel stop}}
|
|
224
|
+
|
|
225
|
+
HELP
|
|
226
|
+
|
|
227
|
+
error: {
|
|
228
|
+
token_argument_missing: "{{x}} {{red:auth requires a token argument}}\n\n",
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
forms: {
|
|
233
|
+
create: {
|
|
234
|
+
error: {
|
|
235
|
+
invalid_app_type: "Invalid app type %s",
|
|
236
|
+
organization_not_found: "Cannot find a partner organization with that ID",
|
|
237
|
+
no_organizations: "No partner organizations available.",
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
authentication_issue: "For authentication issues, run {{command:%s logout}} to clear invalid credentials",
|
|
241
|
+
partners_notice: "Please visit https://partners.shopify.com/ to create a partners account",
|
|
242
|
+
no_development_stores: "{{x}} No Development Stores available.",
|
|
243
|
+
create_store: "Visit {{underline:https://partners.shopify.com/%s/stores}} to create one",
|
|
244
|
+
app_name: "App Name",
|
|
245
|
+
app_type: {
|
|
246
|
+
select: "What type of app are you building?",
|
|
247
|
+
select_public: "Public: An app built for a wide merchant audience.",
|
|
248
|
+
select_custom: "Custom: An app custom built for a single client.",
|
|
249
|
+
selected: "App type {{green:%s}}",
|
|
250
|
+
},
|
|
251
|
+
organization_select: "Select partner organization",
|
|
252
|
+
organization: "Partner organization {{green:%s}}",
|
|
253
|
+
development_store_select: "Select a development store",
|
|
254
|
+
development_store: "Using development store {{green:%s}}",
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
}.freeze
|
|
259
|
+
end
|
|
260
|
+
end
|