shopify-cli 1.6.0 → 1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +15 -2
- data/CHANGELOG.md +21 -0
- data/Gemfile +12 -12
- data/Gemfile.lock +14 -14
- data/Rakefile +32 -30
- data/bin/load_shopify.rb +6 -6
- data/bin/shopify +2 -2
- data/dev.yml +3 -0
- data/ext/shopify-cli/extconf.rb +7 -7
- data/lib/docgen/markdown.rb +12 -12
- data/lib/graphql/extension_create.graphql +17 -2
- data/lib/graphql/fetch_specifications.graphql +14 -0
- data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
- data/lib/project_types/extension/cli.rb +56 -55
- data/lib/project_types/extension/commands/build.rb +3 -3
- data/lib/project_types/extension/commands/create.rb +17 -10
- data/lib/project_types/extension/commands/extension_command.rb +14 -7
- data/lib/project_types/extension/commands/push.rb +10 -10
- data/lib/project_types/extension/commands/register.rb +22 -32
- data/lib/project_types/extension/commands/serve.rb +1 -7
- data/lib/project_types/extension/commands/tunnel.rb +12 -12
- data/lib/project_types/extension/extension_project.rb +22 -7
- data/lib/project_types/extension/extension_project_keys.rb +5 -4
- data/lib/project_types/extension/features/argo.rb +26 -42
- data/lib/project_types/extension/features/argo_config.rb +5 -5
- data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
- data/lib/project_types/extension/features/argo_renderer_package.rb +47 -0
- data/lib/project_types/extension/features/argo_serve.rb +69 -0
- data/lib/project_types/extension/features/argo_setup.rb +3 -3
- data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
- data/lib/project_types/extension/forms/create.rb +28 -34
- data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
- data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
- data/lib/project_types/extension/forms/questions/ask_type.rb +47 -0
- data/lib/project_types/extension/messages/message_loading.rb +3 -1
- data/lib/project_types/extension/messages/messages.rb +55 -55
- data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
- data/lib/project_types/extension/models/registration.rb +1 -0
- data/lib/project_types/extension/models/specification.rb +6 -2
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +10 -2
- data/lib/project_types/extension/models/specifications.rb +14 -3
- data/lib/project_types/extension/models/version.rb +1 -1
- data/lib/project_types/extension/tasks/configure_features.rb +7 -5
- data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +8 -6
- data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
- data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
- data/lib/project_types/extension/tasks/create_extension.rb +4 -4
- data/lib/project_types/extension/tasks/fetch_specifications.rb +8 -28
- data/lib/project_types/extension/tasks/get_app.rb +4 -4
- data/lib/project_types/extension/tasks/get_apps.rb +3 -3
- data/lib/project_types/extension/tasks/update_draft.rb +4 -4
- data/lib/project_types/extension/tasks/user_errors.rb +4 -4
- data/lib/project_types/node/cli.rb +19 -19
- data/lib/project_types/node/commands/connect.rb +3 -3
- data/lib/project_types/node/commands/create.rb +40 -38
- data/lib/project_types/node/commands/deploy.rb +4 -4
- data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
- data/lib/project_types/node/commands/generate.rb +2 -24
- data/lib/project_types/node/commands/open.rb +2 -2
- data/lib/project_types/node/commands/populate.rb +6 -6
- data/lib/project_types/node/commands/populate/customer.rb +5 -5
- data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/node/commands/populate/product.rb +5 -5
- data/lib/project_types/node/commands/serve.rb +9 -9
- data/lib/project_types/node/commands/tunnel.rb +7 -7
- data/lib/project_types/node/forms/create.rb +17 -8
- data/lib/project_types/node/messages/messages.rb +8 -7
- data/lib/project_types/rails/cli.rb +21 -21
- data/lib/project_types/rails/commands/connect.rb +3 -3
- data/lib/project_types/rails/commands/create.rb +51 -48
- data/lib/project_types/rails/commands/deploy.rb +4 -4
- data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
- data/lib/project_types/rails/commands/generate.rb +7 -7
- data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
- data/lib/project_types/rails/commands/open.rb +2 -2
- data/lib/project_types/rails/commands/populate.rb +6 -6
- data/lib/project_types/rails/commands/populate/customer.rb +5 -5
- data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/rails/commands/populate/product.rb +5 -5
- data/lib/project_types/rails/commands/serve.rb +11 -11
- data/lib/project_types/rails/commands/tunnel.rb +7 -7
- data/lib/project_types/rails/forms/create.rb +34 -24
- data/lib/project_types/rails/gem.rb +23 -23
- data/lib/project_types/rails/messages/messages.rb +9 -8
- data/lib/project_types/rails/ruby.rb +2 -2
- data/lib/project_types/script/cli.rb +36 -40
- data/lib/project_types/script/commands/create.rb +9 -13
- data/lib/project_types/script/commands/push.rb +6 -5
- data/lib/project_types/script/config/extension_points.yml +25 -10
- data/lib/project_types/script/errors.rb +1 -19
- data/lib/project_types/script/forms/create.rb +7 -18
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +7 -5
- data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
- data/lib/project_types/script/layers/application/build_script.rb +6 -8
- data/lib/project_types/script/layers/application/create_script.rb +34 -24
- data/lib/project_types/script/layers/application/extension_points.rb +3 -2
- data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
- data/lib/project_types/script/layers/application/push_script.rb +10 -15
- data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
- data/lib/project_types/script/layers/domain/errors.rb +16 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +60 -45
- data/lib/project_types/script/layers/domain/metadata.rb +18 -25
- data/lib/project_types/script/layers/domain/push_package.rb +9 -5
- data/lib/project_types/script/layers/domain/script_project.rb +38 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +39 -10
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +9 -44
- data/lib/project_types/script/layers/infrastructure/errors.rb +50 -19
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +16 -21
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +4 -4
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +179 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +35 -78
- data/lib/project_types/script/messages/messages.rb +33 -57
- data/lib/project_types/script/ui/error_handler.rb +116 -88
- data/lib/project_types/script/ui/printing_spinner.rb +1 -1
- data/lib/project_types/script/ui/strict_spinner.rb +1 -1
- data/lib/project_types/theme/cli.rb +19 -19
- data/lib/project_types/theme/commands/connect.rb +12 -12
- data/lib/project_types/theme/commands/create.rb +11 -11
- data/lib/project_types/theme/commands/deploy.rb +8 -8
- data/lib/project_types/theme/commands/generate.rb +3 -3
- data/lib/project_types/theme/commands/generate/env.rb +15 -15
- data/lib/project_types/theme/commands/push.rb +15 -15
- data/lib/project_types/theme/commands/serve.rb +5 -5
- data/lib/project_types/theme/forms/connect.rb +4 -4
- data/lib/project_types/theme/forms/create.rb +5 -5
- data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +22 -22
- data/lib/project_types/theme/themekit.rb +15 -15
- data/lib/rubygems_plugin.rb +3 -3
- data/lib/shopify-cli/admin_api.rb +11 -11
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
- data/lib/shopify-cli/admin_api/schema.rb +3 -3
- data/lib/shopify-cli/api.rb +10 -10
- data/lib/shopify-cli/command.rb +1 -1
- data/lib/shopify-cli/commands.rb +9 -9
- data/lib/shopify-cli/commands/config.rb +28 -52
- data/lib/shopify-cli/commands/connect.rb +10 -10
- data/lib/shopify-cli/commands/create.rb +5 -5
- data/lib/shopify-cli/commands/help.rb +6 -6
- data/lib/shopify-cli/commands/logout.rb +3 -3
- data/lib/shopify-cli/commands/system.rb +32 -32
- data/lib/shopify-cli/commands/version.rb +2 -2
- data/lib/shopify-cli/context.rb +51 -23
- data/lib/shopify-cli/core.rb +4 -4
- data/lib/shopify-cli/core/entry_point.rb +5 -5
- data/lib/shopify-cli/core/executor.rb +1 -1
- data/lib/shopify-cli/core/help_resolver.rb +2 -2
- data/lib/shopify-cli/core/monorail.rb +16 -16
- data/lib/shopify-cli/db.rb +2 -2
- data/lib/shopify-cli/feature.rb +1 -1
- data/lib/shopify-cli/form.rb +1 -1
- data/lib/shopify-cli/git.rb +17 -17
- data/lib/shopify-cli/helpers.rb +1 -1
- data/lib/shopify-cli/helpers/haikunator.rb +1 -1
- data/lib/shopify-cli/heroku.rb +28 -28
- data/lib/shopify-cli/http_request.rb +2 -2
- data/lib/shopify-cli/js_deps.rb +12 -12
- data/lib/shopify-cli/js_system.rb +7 -7
- data/lib/shopify-cli/lazy_delegator.rb +55 -0
- data/lib/shopify-cli/messages/messages.rb +7 -16
- data/lib/shopify-cli/method_object.rb +1 -1
- data/lib/shopify-cli/oauth.rb +27 -27
- data/lib/shopify-cli/oauth/servlet.rb +9 -9
- data/lib/shopify-cli/options.rb +3 -3
- data/lib/shopify-cli/packager.rb +25 -25
- data/lib/shopify-cli/partners_api.rb +16 -16
- data/lib/shopify-cli/partners_api/organizations.rb +10 -10
- data/lib/shopify-cli/process_supervision.rb +7 -7
- data/lib/shopify-cli/project.rb +16 -16
- data/lib/shopify-cli/project_type.rb +3 -3
- data/lib/shopify-cli/resolve_constant.rb +1 -1
- data/lib/shopify-cli/resources.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +10 -10
- data/lib/shopify-cli/result.rb +11 -11
- data/lib/shopify-cli/shopifolk.rb +6 -9
- data/lib/shopify-cli/sub_command.rb +1 -1
- data/lib/shopify-cli/task.rb +3 -3
- data/lib/shopify-cli/tasks.rb +7 -7
- data/lib/shopify-cli/tasks/create_api_client.rb +5 -5
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +12 -12
- data/lib/shopify-cli/tasks/ensure_env.rb +15 -15
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +19 -19
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
- data/lib/shopify-cli/transform_data_structure.rb +86 -0
- data/lib/shopify-cli/tunnel.rb +30 -30
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +56 -54
- data/shopify-cli.gemspec +6 -6
- data/vendor/deps/smart_properties/REVISION +1 -1
- data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
- data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
- data/vendor/gen/template/bin/update-deps +9 -9
- metadata +15 -11
- data/lib/project_types/extension/forms/register.rb +0 -47
- data/lib/project_types/script/commands/disable.rb +0 -25
- data/lib/project_types/script/commands/enable.rb +0 -78
- data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
- data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
- data/lib/project_types/script/layers/application/disable_script.rb +0 -21
- data/lib/project_types/script/layers/application/enable_script.rb +0 -23
- data/lib/project_types/script/script_project.rb +0 -63
@@ -5,15 +5,15 @@ module Node
|
|
5
5
|
prerequisite_task :ensure_env, :ensure_dev_store
|
6
6
|
|
7
7
|
options do |parser, flags|
|
8
|
-
parser.on(
|
9
|
-
flags[:host] = h.gsub('"',
|
8
|
+
parser.on("--host=HOST") do |h|
|
9
|
+
flags[:host] = h.gsub('"', "")
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(*)
|
14
14
|
project = ShopifyCli::Project.current
|
15
15
|
url = options.flags[:host] || ShopifyCli::Tunnel.start(@ctx)
|
16
|
-
@ctx.abort(@ctx.message(
|
16
|
+
@ctx.abort(@ctx.message("node.serve.error.host_must_be_https")) if url.match(/^https/i).nil?
|
17
17
|
project.env.update(@ctx, :host, url)
|
18
18
|
ShopifyCli::Tasks::UpdateDashboardURLS.call(
|
19
19
|
@ctx,
|
@@ -23,22 +23,22 @@ module Node
|
|
23
23
|
|
24
24
|
if project.env.shop
|
25
25
|
project_url = "#{project.env.host}/auth?shop=#{project.env.shop}"
|
26
|
-
@ctx.puts("\n" + @ctx.message(
|
26
|
+
@ctx.puts("\n" + @ctx.message("node.serve.open_info", project_url) + "\n")
|
27
27
|
end
|
28
28
|
|
29
|
-
CLI::UI::Frame.open(@ctx.message(
|
29
|
+
CLI::UI::Frame.open(@ctx.message("node.serve.running_server")) do
|
30
30
|
env = project.env.to_h
|
31
|
-
env[
|
32
|
-
@ctx.system(
|
31
|
+
env["PORT"] = ShopifyCli::Tunnel::PORT.to_s
|
32
|
+
@ctx.system("npm run dev", env: env)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.help
|
37
|
-
ShopifyCli::Context.message(
|
37
|
+
ShopifyCli::Context.message("node.serve.help", ShopifyCli::TOOL_NAME)
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.extended_help
|
41
|
-
ShopifyCli::Context.message(
|
41
|
+
ShopifyCli::Context.message("node.serve.extended_help")
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "shopify_cli"
|
4
4
|
|
5
5
|
module Node
|
6
6
|
module Commands
|
@@ -10,17 +10,17 @@ module Node
|
|
10
10
|
def call(args, _name)
|
11
11
|
subcommand = args.shift
|
12
12
|
case subcommand
|
13
|
-
when
|
13
|
+
when "auth"
|
14
14
|
token = args.shift
|
15
15
|
if token.nil?
|
16
|
-
@ctx.puts(@ctx.message(
|
16
|
+
@ctx.puts(@ctx.message("node.tunnel.error.token_argument_missing"))
|
17
17
|
@ctx.puts("#{self.class.help}\n#{self.class.extended_help}")
|
18
18
|
else
|
19
19
|
ShopifyCli::Tunnel.auth(@ctx, token)
|
20
20
|
end
|
21
|
-
when
|
21
|
+
when "start"
|
22
22
|
ShopifyCli::Tunnel.start(@ctx)
|
23
|
-
when
|
23
|
+
when "stop"
|
24
24
|
ShopifyCli::Tunnel.stop(@ctx)
|
25
25
|
else
|
26
26
|
@ctx.puts(self.class.help)
|
@@ -28,11 +28,11 @@ module Node
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.help
|
31
|
-
ShopifyCli::Context.message(
|
31
|
+
ShopifyCli::Context.message("node.tunnel.help", ShopifyCli::TOOL_NAME)
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.extended_help
|
35
|
-
ShopifyCli::Context.message(
|
35
|
+
ShopifyCli::Context.message("node.tunnel.extended_help", ShopifyCli::TOOL_NAME)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "uri"
|
2
2
|
|
3
3
|
module Node
|
4
4
|
module Forms
|
@@ -7,9 +7,9 @@ module Node
|
|
7
7
|
flag_arguments :title, :organization_id, :shop_domain, :type
|
8
8
|
|
9
9
|
def ask
|
10
|
-
self.title ||= CLI::UI::Prompt.ask(ctx.message(
|
10
|
+
self.title ||= CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_name"))
|
11
|
+
self.name = format_name
|
11
12
|
self.type = ask_type
|
12
|
-
self.name = self.title.downcase.split(" ").join("_")
|
13
13
|
res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
|
14
14
|
self.organization_id = res[:organization_id]
|
15
15
|
self.shop_domain = res[:shop_domain]
|
@@ -17,18 +17,27 @@ module Node
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
def format_name
|
21
|
+
name = title.downcase.split(" ").join("_")
|
22
|
+
|
23
|
+
if name.include?("shopify")
|
24
|
+
ctx.abort(ctx.message("node.forms.create.error.invalid_app_name"))
|
25
|
+
end
|
26
|
+
name
|
27
|
+
end
|
28
|
+
|
20
29
|
def ask_type
|
21
30
|
if type.nil?
|
22
|
-
return CLI::UI::Prompt.ask(ctx.message(
|
23
|
-
handler.option(ctx.message(
|
24
|
-
handler.option(ctx.message(
|
31
|
+
return CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_type.select")) do |handler|
|
32
|
+
handler.option(ctx.message("node.forms.create.app_type.select_public")) { "public" }
|
33
|
+
handler.option(ctx.message("node.forms.create.app_type.select_custom")) { "custom" }
|
25
34
|
end
|
26
35
|
end
|
27
36
|
|
28
37
|
unless ShopifyCli::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type)
|
29
|
-
ctx.abort(ctx.message(
|
38
|
+
ctx.abort(ctx.message("node.forms.create.error.invalid_app_type", type))
|
30
39
|
end
|
31
|
-
ctx.puts(ctx.message(
|
40
|
+
ctx.puts(ctx.message("node.forms.create.app_type.selected", type))
|
32
41
|
type
|
33
42
|
end
|
34
43
|
end
|
@@ -21,9 +21,9 @@ module Node
|
|
21
21
|
Usage: {{command:%s create node}}
|
22
22
|
Options:
|
23
23
|
{{command:--name=NAME}} App name. Any string.
|
24
|
-
{{command:--
|
25
|
-
{{command:--
|
26
|
-
{{command:--
|
24
|
+
{{command:--app-url=APPURL}} App URL. Must be a valid URL.
|
25
|
+
{{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
|
26
|
+
{{command:--shop-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
|
27
27
|
HELP
|
28
28
|
error: {
|
29
29
|
node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.",
|
@@ -59,21 +59,21 @@ module Node
|
|
59
59
|
installed: "Installed Heroku CLI",
|
60
60
|
authenticating: "Authenticating with Heroku…",
|
61
61
|
authenticated: "{{v}} Authenticated with Heroku",
|
62
|
-
authenticated_with_account: "{{v}} Authenticated with Heroku as
|
62
|
+
authenticated_with_account: "{{v}} Authenticated with Heroku as {{green:%s}}",
|
63
63
|
deploying: "Deploying to Heroku…",
|
64
64
|
deployed: "{{v}} Deployed to Heroku",
|
65
65
|
git: {
|
66
66
|
checking: "Checking git repo…",
|
67
67
|
initialized: "Git repo initialized",
|
68
68
|
what_branch: "What branch would you like to deploy?",
|
69
|
-
branch_selected: "{{v}} Git branch
|
69
|
+
branch_selected: "{{v}} Git branch {{green:%s}} selected for deploy",
|
70
70
|
},
|
71
71
|
app: {
|
72
72
|
no_apps_found: "No existing Heroku app found. What would you like to do?",
|
73
73
|
name: "What is your Heroku app’s name?",
|
74
74
|
select: "Specify an existing Heroku app",
|
75
|
-
selecting: "Selecting Heroku app
|
76
|
-
selected: "{{v}} Heroku app
|
75
|
+
selecting: "Selecting Heroku app %s…",
|
76
|
+
selected: "{{v}} Heroku app {{green:%s}} selected",
|
77
77
|
create: "Create a new Heroku app",
|
78
78
|
creating: "Creating new Heroku app…",
|
79
79
|
created: "{{v}} New Heroku app created",
|
@@ -202,6 +202,7 @@ module Node
|
|
202
202
|
forms: {
|
203
203
|
create: {
|
204
204
|
error: {
|
205
|
+
invalid_app_name: "App name cannot contain 'Shopify'",
|
205
206
|
invalid_app_type: "Invalid app type %s",
|
206
207
|
},
|
207
208
|
app_name: "App name",
|
@@ -1,32 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Rails
|
3
3
|
class Project < ShopifyCli::ProjectType
|
4
|
-
title(
|
5
|
-
creator(
|
6
|
-
connector(
|
4
|
+
title("Ruby on Rails App")
|
5
|
+
creator("Rails::Commands::Create")
|
6
|
+
connector("Rails::Commands::Connect")
|
7
7
|
|
8
|
-
register_command(
|
9
|
-
register_command(
|
10
|
-
register_command(
|
11
|
-
register_command(
|
12
|
-
register_command(
|
13
|
-
register_command(
|
8
|
+
register_command("Rails::Commands::Deploy", "deploy")
|
9
|
+
register_command("Rails::Commands::Generate", "generate")
|
10
|
+
register_command("Rails::Commands::Open", "open")
|
11
|
+
register_command("Rails::Commands::Populate", "populate")
|
12
|
+
register_command("Rails::Commands::Serve", "serve")
|
13
|
+
register_command("Rails::Commands::Tunnel", "tunnel")
|
14
14
|
# register_task('Rails::Tasks::RailsTask', 'rails_task')
|
15
15
|
|
16
|
-
require Project.project_filepath(
|
16
|
+
require Project.project_filepath("messages/messages")
|
17
17
|
register_messages(Rails::Messages::MESSAGES)
|
18
18
|
end
|
19
19
|
|
20
20
|
# define/autoload project specific Commands
|
21
21
|
module Commands
|
22
|
-
autoload :Connect, Project.project_filepath(
|
23
|
-
autoload :Create, Project.project_filepath(
|
24
|
-
autoload :Deploy, Project.project_filepath(
|
25
|
-
autoload :Generate, Project.project_filepath(
|
26
|
-
autoload :Open, Project.project_filepath(
|
27
|
-
autoload :Populate, Project.project_filepath(
|
28
|
-
autoload :Serve, Project.project_filepath(
|
29
|
-
autoload :Tunnel, Project.project_filepath(
|
22
|
+
autoload :Connect, Project.project_filepath("commands/connect")
|
23
|
+
autoload :Create, Project.project_filepath("commands/create")
|
24
|
+
autoload :Deploy, Project.project_filepath("commands/deploy")
|
25
|
+
autoload :Generate, Project.project_filepath("commands/generate")
|
26
|
+
autoload :Open, Project.project_filepath("commands/open")
|
27
|
+
autoload :Populate, Project.project_filepath("commands/populate")
|
28
|
+
autoload :Serve, Project.project_filepath("commands/serve")
|
29
|
+
autoload :Tunnel, Project.project_filepath("commands/tunnel")
|
30
30
|
end
|
31
31
|
|
32
32
|
# define/autoload project specific Tasks
|
@@ -35,9 +35,9 @@ module Rails
|
|
35
35
|
|
36
36
|
# define/autoload project specific Forms
|
37
37
|
module Forms
|
38
|
-
autoload :Create, Project.project_filepath(
|
38
|
+
autoload :Create, Project.project_filepath("forms/create")
|
39
39
|
end
|
40
40
|
|
41
|
-
autoload :Ruby, Project.project_filepath(
|
42
|
-
autoload :Gem, Project.project_filepath(
|
41
|
+
autoload :Ruby, Project.project_filepath("ruby")
|
42
|
+
autoload :Gem, Project.project_filepath("gem")
|
43
43
|
end
|
@@ -4,11 +4,11 @@ module Rails
|
|
4
4
|
class Connect < ShopifyCli::SubCommand
|
5
5
|
def call(*)
|
6
6
|
if ShopifyCli::Project.has_current? && ShopifyCli::Project.current.env
|
7
|
-
@ctx.puts(@ctx.message(
|
7
|
+
@ctx.puts(@ctx.message("rails.connect.production_warning"))
|
8
8
|
end
|
9
9
|
|
10
|
-
app = ShopifyCli::Commands::Connect.new.default_connect(
|
11
|
-
@ctx.done(@ctx.message(
|
10
|
+
app = ShopifyCli::Commands::Connect.new.default_connect("rails")
|
11
|
+
@ctx.done(@ctx.message("rails.connect.connected", app))
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -14,13 +14,16 @@ module Rails
|
|
14
14
|
|
15
15
|
options do |parser, flags|
|
16
16
|
# backwards compatibility allow 'title' for now
|
17
|
-
parser.on(
|
18
|
-
parser.on(
|
19
|
-
parser.on(
|
20
|
-
parser.on(
|
21
|
-
parser.on(
|
22
|
-
parser.on(
|
23
|
-
parser.on(
|
17
|
+
parser.on("--title=TITLE") { |t| flags[:title] = t }
|
18
|
+
parser.on("--name=NAME") { |t| flags[:title] = t }
|
19
|
+
parser.on("--organization_id=ID") { |url| flags[:organization_id] = url }
|
20
|
+
parser.on("--organization-id=ID") { |url| flags[:organization_id] = url }
|
21
|
+
parser.on("--shop_domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
|
22
|
+
parser.on("--shop-domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
|
23
|
+
parser.on("--type=APPTYPE") { |url| flags[:type] = url }
|
24
|
+
parser.on("--db=DB") { |db| flags[:db] = db }
|
25
|
+
parser.on("--rails_opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts }
|
26
|
+
parser.on("--rails-opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts }
|
24
27
|
end
|
25
28
|
|
26
29
|
def call(args, _name)
|
@@ -28,8 +31,8 @@ module Rails
|
|
28
31
|
return @ctx.puts(self.class.help) if form.nil?
|
29
32
|
|
30
33
|
ruby_version = Ruby.version(@ctx)
|
31
|
-
@ctx.abort(@ctx.message(
|
32
|
-
ruby_version.satisfies?(
|
34
|
+
@ctx.abort(@ctx.message("rails.create.error.invalid_ruby_version")) unless
|
35
|
+
ruby_version.satisfies?("~>2.5") || ruby_version.satisfies?("~>3.0.0")
|
33
36
|
|
34
37
|
check_node
|
35
38
|
check_yarn
|
@@ -38,7 +41,7 @@ module Rails
|
|
38
41
|
set_custom_ua
|
39
42
|
ShopifyCli::Project.write(
|
40
43
|
@ctx,
|
41
|
-
project_type:
|
44
|
+
project_type: "rails",
|
42
45
|
organization_id: form.organization_id,
|
43
46
|
)
|
44
47
|
|
@@ -53,74 +56,74 @@ module Rails
|
|
53
56
|
api_key: api_client["apiKey"],
|
54
57
|
secret: api_client["apiSecretKeys"].first["secret"],
|
55
58
|
shop: form.shop_domain,
|
56
|
-
scopes:
|
59
|
+
scopes: "write_products,write_customers,write_draft_orders",
|
57
60
|
).write(@ctx)
|
58
61
|
|
59
|
-
partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client[
|
62
|
+
partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"], local_debug?)
|
60
63
|
|
61
|
-
@ctx.puts(@ctx.message(
|
62
|
-
@ctx.puts(@ctx.message(
|
64
|
+
@ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
|
65
|
+
@ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCli::TOOL_NAME))
|
63
66
|
unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
|
64
|
-
@ctx.puts(@ctx.message(
|
67
|
+
@ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
68
71
|
def self.help
|
69
|
-
ShopifyCli::Context.message(
|
72
|
+
ShopifyCli::Context.message("rails.create.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
|
70
73
|
end
|
71
74
|
|
72
75
|
private
|
73
76
|
|
74
77
|
def check_node
|
75
|
-
cmd_path = @ctx.which(
|
78
|
+
cmd_path = @ctx.which("node")
|
76
79
|
if cmd_path.nil?
|
77
|
-
@ctx.abort(@ctx.message(
|
78
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message(
|
79
|
-
@ctx.puts(@ctx.message(
|
80
|
+
@ctx.abort(@ctx.message("rails.create.error.node_required")) unless @ctx.windows?
|
81
|
+
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.node_required") + "}}")
|
82
|
+
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "node"))
|
80
83
|
raise ShopifyCli::AbortSilent
|
81
84
|
end
|
82
85
|
|
83
|
-
version, stat = @ctx.capture2e(
|
86
|
+
version, stat = @ctx.capture2e("node", "-v")
|
84
87
|
unless stat.success?
|
85
|
-
@ctx.abort(@ctx.message(
|
88
|
+
@ctx.abort(@ctx.message("rails.create.error.node_version_failure")) unless @ctx.windows?
|
86
89
|
# execution stops above if not Windows
|
87
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message(
|
88
|
-
@ctx.puts(@ctx.message(
|
90
|
+
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.node_version_failure") + "}}")
|
91
|
+
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "node"))
|
89
92
|
raise ShopifyCli::AbortSilent
|
90
93
|
end
|
91
94
|
|
92
|
-
@ctx.done(@ctx.message(
|
95
|
+
@ctx.done(@ctx.message("rails.create.node_version", version))
|
93
96
|
end
|
94
97
|
|
95
98
|
def check_yarn
|
96
|
-
cmd_path = @ctx.which(
|
99
|
+
cmd_path = @ctx.which("yarn")
|
97
100
|
if cmd_path.nil?
|
98
|
-
@ctx.abort(@ctx.message(
|
99
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message(
|
100
|
-
@ctx.puts(@ctx.message(
|
101
|
+
@ctx.abort(@ctx.message("rails.create.error.yarn_required")) unless @ctx.windows?
|
102
|
+
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.yarn_required") + "}}")
|
103
|
+
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "yarn"))
|
101
104
|
raise ShopifyCli::AbortSilent
|
102
105
|
end
|
103
106
|
|
104
|
-
version, stat = @ctx.capture2e(
|
107
|
+
version, stat = @ctx.capture2e("yarn", "-v")
|
105
108
|
unless stat.success?
|
106
|
-
@ctx.abort(@ctx.message(
|
107
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message(
|
108
|
-
@ctx.puts(@ctx.message(
|
109
|
+
@ctx.abort(@ctx.message("rails.create.error.yarn_version_failure")) unless @ctx.windows?
|
110
|
+
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.yarn_version_failure") + "}}")
|
111
|
+
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "yarn"))
|
109
112
|
raise ShopifyCli::AbortSilent
|
110
113
|
end
|
111
114
|
|
112
|
-
@ctx.done(@ctx.message(
|
115
|
+
@ctx.done(@ctx.message("rails.create.yarn_version", version))
|
113
116
|
end
|
114
117
|
|
115
118
|
def build(name, db)
|
116
|
-
@ctx.abort(@ctx.message(
|
117
|
-
@ctx.abort(@ctx.message(
|
118
|
-
install_gem(
|
119
|
+
@ctx.abort(@ctx.message("rails.create.error.install_failure", "rails")) unless install_gem("rails", "<6.1")
|
120
|
+
@ctx.abort(@ctx.message("rails.create.error.install_failure", "bundler ~>2.0")) unless
|
121
|
+
install_gem("bundler", "~>2.0")
|
119
122
|
|
120
123
|
full_path = File.join(@ctx.root, name)
|
121
|
-
@ctx.abort(@ctx.message(
|
124
|
+
@ctx.abort(@ctx.message("rails.create.error.dir_exists", name)) if Dir.exist?(full_path)
|
122
125
|
|
123
|
-
CLI::UI::Frame.open(@ctx.message(
|
126
|
+
CLI::UI::Frame.open(@ctx.message("rails.create.generating_app", name)) do
|
124
127
|
new_command = %w(rails new)
|
125
128
|
new_command += DEFAULT_RAILS_FLAGS
|
126
129
|
new_command << "--database=#{db}"
|
@@ -132,34 +135,34 @@ module Rails
|
|
132
135
|
|
133
136
|
@ctx.root = full_path
|
134
137
|
|
135
|
-
File.open(File.join(@ctx.root,
|
138
|
+
File.open(File.join(@ctx.root, ".gitignore"), "a") { |f| f.write(".env") }
|
136
139
|
|
137
|
-
@ctx.puts(@ctx.message(
|
138
|
-
File.open(File.join(@ctx.root,
|
140
|
+
@ctx.puts(@ctx.message("rails.create.adding_shopify_gem"))
|
141
|
+
File.open(File.join(@ctx.root, "Gemfile"), "a") do |f|
|
139
142
|
f.puts "\ngem 'shopify_app', '>=17.0.3'"
|
140
143
|
end
|
141
|
-
CLI::UI::Frame.open(@ctx.message(
|
144
|
+
CLI::UI::Frame.open(@ctx.message("rails.create.running_bundle_install")) do
|
142
145
|
syscall(%w(bundle install))
|
143
146
|
end
|
144
147
|
|
145
|
-
CLI::UI::Frame.open(@ctx.message(
|
148
|
+
CLI::UI::Frame.open(@ctx.message("rails.create.running_generator")) do
|
146
149
|
syscall(%w(rails generate shopify_app --new-shopify-cli-app))
|
147
150
|
end
|
148
151
|
|
149
|
-
CLI::UI::Frame.open(@ctx.message(
|
152
|
+
CLI::UI::Frame.open(@ctx.message("rails.create.running_migrations")) do
|
150
153
|
syscall(%w(rails db:create))
|
151
154
|
syscall(%w(rails db:migrate RAILS_ENV=development))
|
152
155
|
end
|
153
156
|
|
154
|
-
unless File.exist?(File.join(@ctx.root,
|
155
|
-
CLI::UI::Frame.open(@ctx.message(
|
157
|
+
unless File.exist?(File.join(@ctx.root, "config/webpacker.yml"))
|
158
|
+
CLI::UI::Frame.open(@ctx.message("rails.create.running_webpacker_install")) do
|
156
159
|
syscall(%w(rails webpacker:install))
|
157
160
|
end
|
158
161
|
end
|
159
162
|
end
|
160
163
|
|
161
164
|
def set_custom_ua
|
162
|
-
ua_path = File.join(
|
165
|
+
ua_path = File.join("config", "initializers", "user_agent.rb")
|
163
166
|
@ctx.write(ua_path, USER_AGENT_CODE)
|
164
167
|
end
|
165
168
|
|