shopify-cli 2.10.2 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.yaml +117 -0
- data/.github/ISSUE_TEMPLATE/enhancement.yaml +38 -0
- data/.github/ISSUE_TEMPLATE/feature.yaml +47 -0
- data/CHANGELOG.md +20 -3
- data/Gemfile.lock +1 -1
- data/dev.yml +3 -0
- data/lib/project_types/extension/commands/build.rb +3 -0
- data/lib/project_types/extension/commands/check.rb +3 -0
- data/lib/project_types/extension/commands/create.rb +3 -0
- data/lib/project_types/extension/commands/push.rb +3 -0
- data/lib/project_types/extension/commands/serve.rb +3 -0
- data/lib/project_types/extension/models/specification_handlers/default.rb +1 -1
- data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
- data/lib/project_types/script/commands/connect.rb +3 -1
- data/lib/project_types/script/commands/create.rb +2 -0
- data/lib/project_types/script/commands/push.rb +6 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +4 -3
- data/lib/project_types/script/layers/infrastructure/script_service.rb +2 -2
- data/lib/project_types/script/loaders/project.rb +2 -1
- data/lib/project_types/script/messages/messages.rb +87 -86
- data/lib/project_types/script/ui/error_handler.rb +34 -14
- data/lib/project_types/theme/commands/check.rb +3 -0
- data/lib/project_types/theme/commands/delete.rb +3 -0
- data/lib/project_types/theme/commands/init.rb +3 -0
- data/lib/project_types/theme/commands/language_server.rb +3 -0
- data/lib/project_types/theme/commands/package.rb +3 -0
- data/lib/project_types/theme/commands/publish.rb +3 -0
- data/lib/project_types/theme/commands/pull.rb +7 -1
- data/lib/project_types/theme/commands/push.rb +7 -1
- data/lib/project_types/theme/commands/serve.rb +3 -0
- data/lib/shopify_cli/command/sub_command.rb +2 -0
- data/lib/shopify_cli/command.rb +66 -0
- data/lib/shopify_cli/commands/app/create/node.rb +3 -0
- data/lib/shopify_cli/commands/app/create/rails.rb +3 -0
- data/lib/shopify_cli/commands/app/create.rb +3 -0
- data/lib/shopify_cli/commands/app/deploy.rb +3 -0
- data/lib/shopify_cli/commands/app/serve.rb +3 -0
- data/lib/shopify_cli/constants.rb +12 -0
- data/lib/shopify_cli/environment.rb +27 -1
- data/lib/shopify_cli/exception_reporter.rb +9 -0
- data/lib/shopify_cli/github/issue_url_generator.rb +19 -8
- data/lib/shopify_cli/identity_auth/env_auth_token.rb +34 -0
- data/lib/shopify_cli/identity_auth.rb +33 -15
- data/lib/shopify_cli/messages/messages.rb +1 -1
- data/lib/shopify_cli/partners_api.rb +7 -2
- data/lib/shopify_cli/services/app/create/rails_service.rb +37 -13
- data/lib/shopify_cli/theme/include_filter.rb +39 -17
- data/lib/shopify_cli/utilities.rb +7 -0
- data/lib/shopify_cli/version.rb +1 -1
- data/lib/shopify_cli.rb +1 -0
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +5 -1
- data/vendor/lib/semantic/version.rb +0 -1
- metadata +7 -3
- data/lib/project_types/rails/commands/create.rb +0 -210
@@ -1,210 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Rails
|
3
|
-
class Command
|
4
|
-
class Create < ShopifyCLI::Command::AppSubCommand
|
5
|
-
prerequisite_task :ensure_authenticated
|
6
|
-
|
7
|
-
USER_AGENT_CODE = <<~USERAGENT
|
8
|
-
module ShopifyAPI
|
9
|
-
class Base < ActiveResource::Base
|
10
|
-
self.headers['User-Agent'] << " | ShopifyApp/\#{ShopifyApp::VERSION} | Shopify CLI"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
USERAGENT
|
14
|
-
|
15
|
-
DEFAULT_RAILS_FLAGS = %w(--skip-spring)
|
16
|
-
|
17
|
-
options do |parser, flags|
|
18
|
-
# backwards compatibility allow 'title' for now
|
19
|
-
parser.on("--title=TITLE") { |t| flags[:title] = t }
|
20
|
-
parser.on("--name=NAME") { |t| flags[:title] = t }
|
21
|
-
parser.on("--organization_id=ID") { |id| flags[:organization_id] = id }
|
22
|
-
parser.on("--organization-id=ID") { |id| flags[:organization_id] = id }
|
23
|
-
parser.on("--store=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
|
24
|
-
# backwards compatibility allow 'shop domain' for now
|
25
|
-
parser.on("--shop_domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
|
26
|
-
parser.on("--shop-domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
|
27
|
-
parser.on("--type=APPTYPE") { |type| flags[:type] = type }
|
28
|
-
parser.on("--db=DB") { |db| flags[:db] = db }
|
29
|
-
parser.on("--rails_opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts }
|
30
|
-
parser.on("--rails-opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts }
|
31
|
-
end
|
32
|
-
|
33
|
-
def call(args, _name)
|
34
|
-
form_data = self.form_data(args)
|
35
|
-
return @ctx.puts(self.class.help) if form_data.nil?
|
36
|
-
|
37
|
-
ruby_version = Ruby.version(@ctx)
|
38
|
-
@ctx.abort(@ctx.message("rails.create.error.invalid_ruby_version")) unless
|
39
|
-
ruby_version.satisfies?("~>2.5") || ruby_version.satisfies?("~>3.0.0")
|
40
|
-
|
41
|
-
check_node
|
42
|
-
check_yarn
|
43
|
-
|
44
|
-
build(form_data.name, form_data.db)
|
45
|
-
|
46
|
-
set_custom_ua
|
47
|
-
ShopifyCLI::Project.write(
|
48
|
-
@ctx,
|
49
|
-
project_type: "rails",
|
50
|
-
organization_id: form_data.organization_id,
|
51
|
-
)
|
52
|
-
|
53
|
-
api_client = if ShopifyCLI::Environment.acceptance_test?
|
54
|
-
{
|
55
|
-
"apiKey" => "public_api_key",
|
56
|
-
"apiSecretKeys" => [
|
57
|
-
{
|
58
|
-
"secret" => "api_secret_key",
|
59
|
-
},
|
60
|
-
],
|
61
|
-
}
|
62
|
-
else
|
63
|
-
ShopifyCLI::Tasks::CreateApiClient.call(
|
64
|
-
@ctx,
|
65
|
-
org_id: form_data.organization_id,
|
66
|
-
title: form_data.title,
|
67
|
-
type: form_data.type,
|
68
|
-
)
|
69
|
-
end
|
70
|
-
|
71
|
-
ShopifyCLI::Resources::EnvFile.new(
|
72
|
-
api_key: api_client["apiKey"],
|
73
|
-
secret: api_client["apiSecretKeys"].first["secret"],
|
74
|
-
shop: form_data.shop_domain,
|
75
|
-
scopes: "write_products,write_customers,write_draft_orders",
|
76
|
-
).write(@ctx)
|
77
|
-
|
78
|
-
partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form_data.organization_id, api_client["id"])
|
79
|
-
|
80
|
-
@ctx.puts(@ctx.message("apps.create.info.created", form_data.title, partners_url))
|
81
|
-
@ctx.puts(@ctx.message("apps.create.info.serve", form_data.name, ShopifyCLI::TOOL_NAME, "rails"))
|
82
|
-
unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
83
|
-
@ctx.puts(@ctx.message("apps.create.info.install", partners_url, form_data.title))
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def form_data(args)
|
88
|
-
if ShopifyCLI::Environment.acceptance_test?
|
89
|
-
Struct.new(:title, :name, :organization_id, :type, :shop_domain, :db, keyword_init: true).new(
|
90
|
-
title: options.flags[:title],
|
91
|
-
name: options.flags[:title],
|
92
|
-
organization_id: "123",
|
93
|
-
shop_domain: "test.shopify.io",
|
94
|
-
type: "public",
|
95
|
-
db: options.flags[:db]
|
96
|
-
)
|
97
|
-
else
|
98
|
-
Forms::Create.ask(@ctx, args, options.flags)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def self.help
|
103
|
-
ShopifyCLI::Context.message("rails.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
def check_node
|
109
|
-
cmd_path = @ctx.which("node")
|
110
|
-
if cmd_path.nil?
|
111
|
-
@ctx.abort(@ctx.message("rails.create.error.node_required")) unless @ctx.windows?
|
112
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.node_required") + "}}")
|
113
|
-
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "node"))
|
114
|
-
raise ShopifyCLI::AbortSilent
|
115
|
-
end
|
116
|
-
|
117
|
-
version, stat = @ctx.capture2e("node", "-v")
|
118
|
-
unless stat.success?
|
119
|
-
@ctx.abort(@ctx.message("rails.create.error.node_version_failure")) unless @ctx.windows?
|
120
|
-
# execution stops above if not Windows
|
121
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.node_version_failure") + "}}")
|
122
|
-
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "node"))
|
123
|
-
raise ShopifyCLI::AbortSilent
|
124
|
-
end
|
125
|
-
|
126
|
-
@ctx.done(@ctx.message("rails.create.node_version", version))
|
127
|
-
end
|
128
|
-
|
129
|
-
def check_yarn
|
130
|
-
cmd_path = @ctx.which("yarn")
|
131
|
-
if cmd_path.nil?
|
132
|
-
@ctx.abort(@ctx.message("rails.create.error.yarn_required")) unless @ctx.windows?
|
133
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.yarn_required") + "}}")
|
134
|
-
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "yarn"))
|
135
|
-
raise ShopifyCLI::AbortSilent
|
136
|
-
end
|
137
|
-
|
138
|
-
version, stat = @ctx.capture2e("yarn", "-v")
|
139
|
-
unless stat.success?
|
140
|
-
@ctx.abort(@ctx.message("rails.create.error.yarn_version_failure")) unless @ctx.windows?
|
141
|
-
@ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.yarn_version_failure") + "}}")
|
142
|
-
@ctx.puts(@ctx.message("rails.create.info.open_new_shell", "yarn"))
|
143
|
-
raise ShopifyCLI::AbortSilent
|
144
|
-
end
|
145
|
-
|
146
|
-
@ctx.done(@ctx.message("rails.create.yarn_version", version))
|
147
|
-
end
|
148
|
-
|
149
|
-
def build(name, db)
|
150
|
-
@ctx.abort(@ctx.message("rails.create.error.install_failure", "rails")) unless install_gem("rails", "<6.1")
|
151
|
-
@ctx.abort(@ctx.message("rails.create.error.install_failure", "bundler ~>2.0")) unless
|
152
|
-
install_gem("bundler", "~>2.0")
|
153
|
-
|
154
|
-
full_path = File.join(@ctx.root, name)
|
155
|
-
@ctx.abort(@ctx.message("rails.create.error.dir_exists", name)) if Dir.exist?(full_path)
|
156
|
-
|
157
|
-
CLI::UI::Frame.open(@ctx.message("rails.create.generating_app", name)) do
|
158
|
-
new_command = %w(rails new)
|
159
|
-
new_command << name
|
160
|
-
new_command += DEFAULT_RAILS_FLAGS
|
161
|
-
new_command << "--database=#{db}"
|
162
|
-
new_command += options.flags[:rails_opts].split unless options.flags[:rails_opts].nil?
|
163
|
-
|
164
|
-
syscall(new_command)
|
165
|
-
end
|
166
|
-
|
167
|
-
@ctx.root = full_path
|
168
|
-
|
169
|
-
File.open(File.join(@ctx.root, ".gitignore"), "a") { |f| f.write(".env") }
|
170
|
-
|
171
|
-
@ctx.puts(@ctx.message("rails.create.adding_shopify_gem"))
|
172
|
-
File.open(File.join(@ctx.root, "Gemfile"), "a") do |f|
|
173
|
-
f.puts "\ngem 'shopify_app', '>=17.0.3'"
|
174
|
-
end
|
175
|
-
CLI::UI::Frame.open(@ctx.message("rails.create.running_bundle_install")) do
|
176
|
-
syscall(%w(bundle install))
|
177
|
-
end
|
178
|
-
|
179
|
-
CLI::UI::Frame.open(@ctx.message("rails.create.running_generator")) do
|
180
|
-
syscall(%w(rails generate shopify_app --new-shopify-cli-app))
|
181
|
-
end
|
182
|
-
|
183
|
-
CLI::UI::Frame.open(@ctx.message("rails.create.running_migrations")) do
|
184
|
-
syscall(%w(rails db:create))
|
185
|
-
syscall(%w(rails db:migrate RAILS_ENV=development))
|
186
|
-
end
|
187
|
-
|
188
|
-
unless File.exist?(File.join(@ctx.root, "config/webpacker.yml"))
|
189
|
-
CLI::UI::Frame.open(@ctx.message("rails.create.running_webpacker_install")) do
|
190
|
-
syscall(%w(rails webpacker:install))
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def set_custom_ua
|
196
|
-
ua_path = File.join("config", "initializers", "user_agent.rb")
|
197
|
-
@ctx.write(ua_path, USER_AGENT_CODE)
|
198
|
-
end
|
199
|
-
|
200
|
-
def syscall(args)
|
201
|
-
args[0] = Gem.binary_path_for(@ctx, args[0])
|
202
|
-
@ctx.system(*args, chdir: @ctx.root)
|
203
|
-
end
|
204
|
-
|
205
|
-
def install_gem(name, version = nil)
|
206
|
-
Gem.install(@ctx, name, version)
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|