@shopify/cli-kit 3.45.0 → 3.46.0-pre.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.
- package/assets/cli-ruby/Gemfile +0 -1
- package/assets/cli-ruby/Rakefile +0 -76
- package/assets/cli-ruby/lib/project_types/extension/cli.rb +5 -86
- package/assets/cli-ruby/lib/shopify_cli/admin_api.rb +0 -3
- package/assets/cli-ruby/lib/shopify_cli/command/sub_command.rb +1 -2
- package/assets/cli-ruby/lib/shopify_cli/command.rb +0 -7
- package/assets/cli-ruby/lib/shopify_cli/commands.rb +0 -15
- package/assets/cli-ruby/lib/shopify_cli/core.rb +0 -1
- package/assets/cli-ruby/lib/shopify_cli/identity_auth.rb +0 -1
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +9 -1
- package/assets/cli-ruby/lib/shopify_cli.rb +1 -10
- package/assets/cli-ruby/test/test_helpers.rb +0 -2
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/assets/cli-ruby/lib/project_types/extension/commands/build.rb +0 -51
- package/assets/cli-ruby/lib/project_types/extension/commands/check.rb +0 -51
- package/assets/cli-ruby/lib/project_types/extension/commands/connect.rb +0 -35
- package/assets/cli-ruby/lib/project_types/extension/commands/create.rb +0 -100
- package/assets/cli-ruby/lib/project_types/extension/commands/info.rb +0 -86
- package/assets/cli-ruby/lib/project_types/extension/commands/push.rb +0 -112
- package/assets/cli-ruby/lib/project_types/extension/commands/register.rb +0 -67
- package/assets/cli-ruby/lib/project_types/extension/commands/tunnel.rb +0 -73
- package/assets/cli-ruby/lib/project_types/extension/forms/connect.rb +0 -42
- package/assets/cli-ruby/lib/project_types/extension/forms/create.rb +0 -49
- package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_app.rb +0 -53
- package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_name.rb +0 -48
- package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_registration.rb +0 -55
- package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_template.rb +0 -37
- package/assets/cli-ruby/lib/project_types/extension/forms/questions/ask_type.rb +0 -47
- package/assets/cli-ruby/lib/project_types/extension/models/development_server.rb +0 -77
- package/assets/cli-ruby/lib/project_types/extension/models/development_server_requirements.rb +0 -56
- package/assets/cli-ruby/lib/project_types/extension/models/npm_package.rb +0 -44
- package/assets/cli-ruby/lib/project_types/extension/models/product.rb +0 -12
- package/assets/cli-ruby/lib/project_types/extension/models/registration.rb +0 -20
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/app.rb +0 -13
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/base.rb +0 -31
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/capabilities.rb +0 -11
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/development.rb +0 -33
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_entries.rb +0 -38
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_renderer.rb +0 -38
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/development_resource.rb +0 -13
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/extension.rb +0 -46
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/root.rb +0 -21
- package/assets/cli-ruby/lib/project_types/extension/models/server_config/user.rb +0 -10
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +0 -29
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +0 -170
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension.rb +0 -58
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension_utils/script_config.rb +0 -33
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/web_pixel_extension_utils/script_config_repository.rb +0 -75
- package/assets/cli-ruby/lib/project_types/extension/tasks/choose_next_available_port.rb +0 -36
- package/assets/cli-ruby/lib/project_types/extension/tasks/convert_server_config.rb +0 -85
- package/assets/cli-ruby/lib/project_types/extension/tasks/converters/app_converter.rb +0 -27
- package/assets/cli-ruby/lib/project_types/extension/tasks/converters/product_converter.rb +0 -21
- package/assets/cli-ruby/lib/project_types/extension/tasks/converters/registration_converter.rb +0 -28
- package/assets/cli-ruby/lib/project_types/extension/tasks/create_extension.rb +0 -31
- package/assets/cli-ruby/lib/project_types/extension/tasks/ensure_resource_url.rb +0 -39
- package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/base.rb +0 -15
- package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/build.rb +0 -30
- package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/create.rb +0 -30
- package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/outdated_extension_detection.rb +0 -57
- package/assets/cli-ruby/lib/project_types/extension/tasks/execute_commands/serve.rb +0 -36
- package/assets/cli-ruby/lib/project_types/extension/tasks/find_npm_packages.rb +0 -106
- package/assets/cli-ruby/lib/project_types/extension/tasks/find_package_from_json.rb +0 -37
- package/assets/cli-ruby/lib/project_types/extension/tasks/get_app.rb +0 -22
- package/assets/cli-ruby/lib/project_types/extension/tasks/get_apps.rb +0 -26
- package/assets/cli-ruby/lib/project_types/extension/tasks/get_extensions.rb +0 -33
- package/assets/cli-ruby/lib/project_types/extension/tasks/get_product.rb +0 -22
- package/assets/cli-ruby/lib/project_types/extension/tasks/merge_server_config.rb +0 -47
- package/assets/cli-ruby/lib/project_types/extension/tasks/update_draft.rb +0 -29
- package/assets/cli-ruby/lib/project_types/extension/tasks/user_errors.rb +0 -45
- package/assets/cli-ruby/lib/shopify_cli/admin_api/populate_resource_command.rb +0 -166
- package/assets/cli-ruby/lib/shopify_cli/admin_api/schema.rb +0 -35
- package/assets/cli-ruby/lib/shopify_cli/app_type_detector.rb +0 -36
- package/assets/cli-ruby/lib/shopify_cli/assets/post_auth_page/index.html.erb +0 -34
- package/assets/cli-ruby/lib/shopify_cli/assets/post_auth_page/style.css +0 -58
- package/assets/cli-ruby/lib/shopify_cli/changelog.rb +0 -148
- package/assets/cli-ruby/lib/shopify_cli/command/app_sub_command.rb +0 -26
- package/assets/cli-ruby/lib/shopify_cli/command_options/command_serve_options.rb +0 -53
- package/assets/cli-ruby/lib/shopify_cli/command_options.rb +0 -7
- package/assets/cli-ruby/lib/shopify_cli/commands/app/connect.rb +0 -22
- package/assets/cli-ruby/lib/shopify_cli/commands/app/create/node.rb +0 -40
- package/assets/cli-ruby/lib/shopify_cli/commands/app/create/php.rb +0 -37
- package/assets/cli-ruby/lib/shopify_cli/commands/app/create/rails.rb +0 -42
- package/assets/cli-ruby/lib/shopify_cli/commands/app/create.rb +0 -28
- package/assets/cli-ruby/lib/shopify_cli/commands/app/deploy.rb +0 -51
- package/assets/cli-ruby/lib/shopify_cli/commands/app/open.rb +0 -19
- package/assets/cli-ruby/lib/shopify_cli/commands/app/serve.rb +0 -51
- package/assets/cli-ruby/lib/shopify_cli/commands/app/tunnel.rb +0 -43
- package/assets/cli-ruby/lib/shopify_cli/commands/app.rb +0 -29
- package/assets/cli-ruby/lib/shopify_cli/commands/config.rb +0 -76
- package/assets/cli-ruby/lib/shopify_cli/commands/help.rb +0 -52
- package/assets/cli-ruby/lib/shopify_cli/commands/login.rb +0 -98
- package/assets/cli-ruby/lib/shopify_cli/commands/logout.rb +0 -50
- package/assets/cli-ruby/lib/shopify_cli/commands/populate/customer.rb +0 -25
- package/assets/cli-ruby/lib/shopify_cli/commands/populate/draft_order.rb +0 -28
- package/assets/cli-ruby/lib/shopify_cli/commands/populate/product.rb +0 -24
- package/assets/cli-ruby/lib/shopify_cli/commands/populate.rb +0 -23
- package/assets/cli-ruby/lib/shopify_cli/commands/reporting.rb +0 -38
- package/assets/cli-ruby/lib/shopify_cli/commands/store.rb +0 -15
- package/assets/cli-ruby/lib/shopify_cli/commands/switch.rb +0 -39
- package/assets/cli-ruby/lib/shopify_cli/commands/system.rb +0 -165
- package/assets/cli-ruby/lib/shopify_cli/commands/version.rb +0 -15
- package/assets/cli-ruby/lib/shopify_cli/commands/whoami.rb +0 -28
- package/assets/cli-ruby/lib/shopify_cli/connect.rb +0 -32
- package/assets/cli-ruby/lib/shopify_cli/core/help_resolver.rb +0 -20
- package/assets/cli-ruby/lib/shopify_cli/heroku.rb +0 -140
- package/assets/cli-ruby/lib/shopify_cli/identity_auth/servlet.rb +0 -44
- package/assets/cli-ruby/lib/shopify_cli/js_deps.rb +0 -110
- package/assets/cli-ruby/lib/shopify_cli/packager.rb +0 -108
- package/assets/cli-ruby/lib/shopify_cli/php_deps.rb +0 -102
- package/assets/cli-ruby/lib/shopify_cli/process_supervision.rb +0 -228
- package/assets/cli-ruby/lib/shopify_cli/project_commands.rb +0 -16
- package/assets/cli-ruby/lib/shopify_cli/release.rb +0 -197
- package/assets/cli-ruby/lib/shopify_cli/sed.rb +0 -19
- package/assets/cli-ruby/lib/shopify_cli/services/app/connect_service.rb +0 -25
- package/assets/cli-ruby/lib/shopify_cli/services/app/create/node_service.rb +0 -143
- package/assets/cli-ruby/lib/shopify_cli/services/app/create/php_service.rb +0 -147
- package/assets/cli-ruby/lib/shopify_cli/services/app/create/rails_service.rb +0 -239
- package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +0 -101
- package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +0 -135
- package/assets/cli-ruby/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +0 -120
- package/assets/cli-ruby/lib/shopify_cli/services/app/open_service.rb +0 -19
- package/assets/cli-ruby/lib/shopify_cli/services/app/serve/node_service.rb +0 -19
- package/assets/cli-ruby/lib/shopify_cli/services/app/serve/php_service.rb +0 -23
- package/assets/cli-ruby/lib/shopify_cli/services/app/serve/rails_service.rb +0 -28
- package/assets/cli-ruby/lib/shopify_cli/services/app/serve/serve_service.rb +0 -57
- package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/auth_service.rb +0 -21
- package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/start_service.rb +0 -20
- package/assets/cli-ruby/lib/shopify_cli/services/app/tunnel/stop_service.rb +0 -20
- package/assets/cli-ruby/lib/shopify_cli/services/base_service.rb +0 -13
- package/assets/cli-ruby/lib/shopify_cli/services/reporting_service.rb +0 -16
- package/assets/cli-ruby/lib/shopify_cli/services.rb +0 -38
- package/assets/cli-ruby/lib/shopify_cli/tunnel.rb +0 -255
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
require "semantic/semantic"
|
|
2
|
-
|
|
3
|
-
module ShopifyCLI
|
|
4
|
-
module Services
|
|
5
|
-
module App
|
|
6
|
-
module Create
|
|
7
|
-
class NodeService < BaseService
|
|
8
|
-
attr_reader :context, :name, :organization_id, :store_domain, :type, :verbose
|
|
9
|
-
|
|
10
|
-
def initialize(name:, organization_id:, store_domain:, type:, verbose:, context:)
|
|
11
|
-
@name = name
|
|
12
|
-
@organization_id = organization_id
|
|
13
|
-
@store_domain = store_domain
|
|
14
|
-
@type = type
|
|
15
|
-
@verbose = verbose
|
|
16
|
-
@context = context
|
|
17
|
-
super()
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def call
|
|
21
|
-
form = form_data({
|
|
22
|
-
name: name,
|
|
23
|
-
organization_id: organization_id,
|
|
24
|
-
shop_domain: store_domain,
|
|
25
|
-
type: type,
|
|
26
|
-
verbose: verbose,
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
raise ShopifyCLI::AbortSilent if form.nil?
|
|
30
|
-
|
|
31
|
-
check_node
|
|
32
|
-
check_npm
|
|
33
|
-
build(form.name)
|
|
34
|
-
|
|
35
|
-
ShopifyCLI::Project.write(
|
|
36
|
-
context,
|
|
37
|
-
project_type: "node",
|
|
38
|
-
organization_id: form.organization_id,
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
api_client = if ShopifyCLI::Environment.acceptance_test?
|
|
42
|
-
{
|
|
43
|
-
"apiKey" => "public_api_key",
|
|
44
|
-
"apiSecretKeys" => [
|
|
45
|
-
{
|
|
46
|
-
"secret" => "api_secret_key",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
}
|
|
50
|
-
else
|
|
51
|
-
ShopifyCLI::Tasks::CreateApiClient.call(
|
|
52
|
-
context,
|
|
53
|
-
org_id: form.organization_id,
|
|
54
|
-
title: form.name,
|
|
55
|
-
type: form.type,
|
|
56
|
-
)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
ShopifyCLI::Resources::EnvFile.new(
|
|
60
|
-
api_key: api_client["apiKey"],
|
|
61
|
-
secret: api_client["apiSecretKeys"].first["secret"],
|
|
62
|
-
shop: form.shop_domain,
|
|
63
|
-
scopes: "write_products,write_customers,write_draft_orders",
|
|
64
|
-
).write(context)
|
|
65
|
-
|
|
66
|
-
partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
|
|
67
|
-
|
|
68
|
-
context.puts(context.message("apps.create.info.created", form.name, partners_url))
|
|
69
|
-
context.puts(context.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME))
|
|
70
|
-
unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
|
71
|
-
context.puts(context.message("apps.create.info.install", partners_url, form.name))
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
private
|
|
76
|
-
|
|
77
|
-
def form_data(form_options)
|
|
78
|
-
if ShopifyCLI::Environment.acceptance_test?
|
|
79
|
-
Struct.new(:name, :organization_id, :type, :shop_domain, keyword_init: true).new(
|
|
80
|
-
name: form_options[:name],
|
|
81
|
-
organization_id: form_options[:organization_id] || "123",
|
|
82
|
-
shop_domain: form_options[:shop_domain] || "test.shopify.io",
|
|
83
|
-
type: form_options[:type] || "public",
|
|
84
|
-
)
|
|
85
|
-
else
|
|
86
|
-
Node::Forms::Create.ask(context, [], form_options)
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def check_node
|
|
91
|
-
version = ShopifyCLI::Environment.node_version(context: context)
|
|
92
|
-
context.done(context.message("core.app.create.node.node_version", version))
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def check_npm
|
|
96
|
-
version = ShopifyCLI::Environment.npm_version(context: context)
|
|
97
|
-
context.done(context.message("core.app.create.node.npm_version", version))
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def set_npm_config
|
|
101
|
-
# check available npmrc (either user or system) for production registry
|
|
102
|
-
registry, _ = context.capture2("npm config get @shopify:registry")
|
|
103
|
-
return if registry.include?("https://registry.yarnpkg.com")
|
|
104
|
-
|
|
105
|
-
# available npmrc doesn't have production registry =>
|
|
106
|
-
# set a project-based .npmrc
|
|
107
|
-
context.system(
|
|
108
|
-
"npm",
|
|
109
|
-
"--userconfig",
|
|
110
|
-
"./.npmrc",
|
|
111
|
-
"config",
|
|
112
|
-
"set",
|
|
113
|
-
"@shopify:registry",
|
|
114
|
-
"https://registry.yarnpkg.com",
|
|
115
|
-
chdir: context.root
|
|
116
|
-
)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def build(name)
|
|
120
|
-
ShopifyCLI::Git.clone("https://github.com/Shopify/shopify-app-template-node.git#cli_two", name)
|
|
121
|
-
|
|
122
|
-
context.root = File.join(context.root, name)
|
|
123
|
-
|
|
124
|
-
set_npm_config
|
|
125
|
-
ShopifyCLI::JsDeps.install(context, verbose)
|
|
126
|
-
|
|
127
|
-
begin
|
|
128
|
-
context.rm_r(".git")
|
|
129
|
-
context.rm_r(".github")
|
|
130
|
-
context.rm(File.join("server", "handlers", "client.js"))
|
|
131
|
-
context.rename(
|
|
132
|
-
File.join("server", "handlers", "client.cli.js"),
|
|
133
|
-
File.join("server", "handlers", "client.js")
|
|
134
|
-
)
|
|
135
|
-
rescue Errno::ENOENT => e
|
|
136
|
-
context.debug(e)
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
require "semantic/semantic"
|
|
2
|
-
|
|
3
|
-
module ShopifyCLI
|
|
4
|
-
module Services
|
|
5
|
-
module App
|
|
6
|
-
module Create
|
|
7
|
-
class PHPService < BaseService
|
|
8
|
-
attr_reader :name, :organization_id, :store_domain, :type, :verbose, :context
|
|
9
|
-
|
|
10
|
-
def initialize(name:, organization_id:, store_domain:, type:, verbose:, context:)
|
|
11
|
-
@name = name
|
|
12
|
-
@organization_id = organization_id
|
|
13
|
-
@store_domain = store_domain
|
|
14
|
-
@type = type
|
|
15
|
-
@verbose = verbose
|
|
16
|
-
@context = context
|
|
17
|
-
super()
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def call
|
|
21
|
-
form = PHP::Forms::Create.ask(context, [], {
|
|
22
|
-
name: name,
|
|
23
|
-
organization_id: organization_id,
|
|
24
|
-
shop_domain: store_domain,
|
|
25
|
-
type: type,
|
|
26
|
-
verbose: verbose,
|
|
27
|
-
})
|
|
28
|
-
raise ShopifyCLI::AbortSilent if form.nil?
|
|
29
|
-
|
|
30
|
-
check_php
|
|
31
|
-
check_composer
|
|
32
|
-
check_npm
|
|
33
|
-
app_id = build(form)
|
|
34
|
-
|
|
35
|
-
ShopifyCLI::Project.write(
|
|
36
|
-
context,
|
|
37
|
-
project_type: "php",
|
|
38
|
-
organization_id: form.organization_id,
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, app_id)
|
|
42
|
-
|
|
43
|
-
context.puts(context.message("apps.create.info.created", form.name, partners_url))
|
|
44
|
-
context.puts(context.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME))
|
|
45
|
-
unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
|
46
|
-
context.puts(context.message("apps.create.info.install", partners_url, form.name))
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def check_php
|
|
53
|
-
cmd_path = context.which("php")
|
|
54
|
-
context.abort(context.message("core.app.create.php.error.php_required")) if cmd_path.nil?
|
|
55
|
-
|
|
56
|
-
version, stat = context.capture2e("php", "-r", "echo phpversion();")
|
|
57
|
-
context.abort(context.message("core.app.create.php.error.php_version_failure")) unless stat.success?
|
|
58
|
-
|
|
59
|
-
if ::Semantic::Version.new(version) < ::Semantic::Version.new("7.3.0")
|
|
60
|
-
context.abort(context.message("core.app.create.php.error.php_version_too_low", "7.3"))
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context.done(context.message("core.app.create.php.php_version", version))
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def check_composer
|
|
67
|
-
cmd_path = context.which("composer")
|
|
68
|
-
context.abort(context.message("core.app.create.php.error.composer_required")) if cmd_path.nil?
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def check_npm
|
|
72
|
-
version = ShopifyCLI::Environment.npm_version(context: context)
|
|
73
|
-
context.done(context.message("core.app.create.php.npm_version", version))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def build(form)
|
|
77
|
-
ShopifyCLI::Git.clone("https://github.com/Shopify/shopify-app-template-php.git#cli_two", form.name)
|
|
78
|
-
|
|
79
|
-
context.root = File.join(context.root, form.name)
|
|
80
|
-
context.chdir(context.root)
|
|
81
|
-
|
|
82
|
-
api_client = ShopifyCLI::Tasks::CreateApiClient.call(
|
|
83
|
-
context,
|
|
84
|
-
org_id: form.organization_id,
|
|
85
|
-
title: form.name,
|
|
86
|
-
type: form.type,
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
# Override the example settings with our own
|
|
90
|
-
context.cp(".env.example", ".env")
|
|
91
|
-
|
|
92
|
-
env_file = ShopifyCLI::Resources::EnvFile.read
|
|
93
|
-
env_file.api_key = api_client["apiKey"]
|
|
94
|
-
env_file.secret = api_client["apiSecretKeys"].first["secret"]
|
|
95
|
-
env_file.shop = form.shop_domain
|
|
96
|
-
env_file.host = "localhost"
|
|
97
|
-
env_file.scopes = "write_products,write_draft_orders,write_customers"
|
|
98
|
-
env_file.extra["DB_DATABASE"] = File.join(context.root, env_file.extra["DB_DATABASE"])
|
|
99
|
-
env_file.write(context)
|
|
100
|
-
|
|
101
|
-
ShopifyCLI::PHPDeps.install(context, verbose)
|
|
102
|
-
|
|
103
|
-
set_npm_config
|
|
104
|
-
ShopifyCLI::JsDeps.install(context, verbose)
|
|
105
|
-
|
|
106
|
-
title = context.message("core.app.create.php.app_setting_up")
|
|
107
|
-
success = context.message("core.app.create.php.app_set_up")
|
|
108
|
-
failure = context.message("core.app.create.php.error.app_setup")
|
|
109
|
-
CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
|
|
110
|
-
FileUtils.touch(env_file.extra["DB_DATABASE"])
|
|
111
|
-
context.system("php", "artisan", "key:generate")
|
|
112
|
-
context.system("php", "artisan", "migrate")
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
begin
|
|
116
|
-
context.rm_r(".git")
|
|
117
|
-
context.rm_r(".github")
|
|
118
|
-
rescue Errno::ENOENT => e
|
|
119
|
-
context.debug(e)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
api_client["id"]
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def set_npm_config
|
|
126
|
-
# check available npmrc (either user or system) for production registry
|
|
127
|
-
registry, _ = context.capture2("npm config get @shopify:registry")
|
|
128
|
-
return if registry.include?("https://registry.yarnpkg.com")
|
|
129
|
-
|
|
130
|
-
# available npmrc doesn't have production registry =>
|
|
131
|
-
# set a project-based .npmrc
|
|
132
|
-
context.system(
|
|
133
|
-
"npm",
|
|
134
|
-
"--userconfig",
|
|
135
|
-
"./.npmrc",
|
|
136
|
-
"config",
|
|
137
|
-
"set",
|
|
138
|
-
"@shopify:registry",
|
|
139
|
-
"https://registry.yarnpkg.com",
|
|
140
|
-
chdir: context.root
|
|
141
|
-
)
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
require "semantic/semantic"
|
|
2
|
-
|
|
3
|
-
module ShopifyCLI
|
|
4
|
-
module Services
|
|
5
|
-
module App
|
|
6
|
-
module Create
|
|
7
|
-
class RailsService < BaseService
|
|
8
|
-
USER_AGENT_CODE = <<~USERAGENT
|
|
9
|
-
module ShopifyAPI
|
|
10
|
-
class Base < ActiveResource::Base
|
|
11
|
-
self.headers['User-Agent'] << " | ShopifyApp/\#{ShopifyApp::VERSION} | Shopify CLI"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
USERAGENT
|
|
15
|
-
|
|
16
|
-
DEFAULT_RAILS_FLAGS = %w(--skip-spring)
|
|
17
|
-
|
|
18
|
-
attr_reader :name, :organization_id, :store_domain, :type, :db, :rails_opts, :context
|
|
19
|
-
|
|
20
|
-
def initialize(name:, organization_id:, store_domain:, type:, db:, rails_opts:, context:)
|
|
21
|
-
@name = name
|
|
22
|
-
@organization_id = organization_id
|
|
23
|
-
@store_domain = store_domain
|
|
24
|
-
@type = type
|
|
25
|
-
@db = db
|
|
26
|
-
@rails_opts = rails_opts
|
|
27
|
-
@context = context
|
|
28
|
-
super()
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def call
|
|
32
|
-
form_options = {
|
|
33
|
-
name: name,
|
|
34
|
-
organization_id: organization_id,
|
|
35
|
-
shop_domain: store_domain,
|
|
36
|
-
type: type,
|
|
37
|
-
}
|
|
38
|
-
form_options[:db] = db unless db.nil?
|
|
39
|
-
form_options[:rails_opts] = rails_opts unless rails_opts.nil?
|
|
40
|
-
form = form_data(form_options)
|
|
41
|
-
|
|
42
|
-
raise ShopifyCLI::AbortSilent if form.nil?
|
|
43
|
-
|
|
44
|
-
check_dependencies
|
|
45
|
-
|
|
46
|
-
build(form.name, form.db)
|
|
47
|
-
set_custom_ua
|
|
48
|
-
ShopifyCLI::Project.write(
|
|
49
|
-
context,
|
|
50
|
-
project_type: "rails",
|
|
51
|
-
organization_id: form.organization_id,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
api_client = if ShopifyCLI::Environment.acceptance_test?
|
|
55
|
-
{
|
|
56
|
-
"apiKey" => "public_api_key",
|
|
57
|
-
"apiSecretKeys" => [
|
|
58
|
-
{
|
|
59
|
-
"secret" => "api_secret_key",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
}
|
|
63
|
-
else
|
|
64
|
-
ShopifyCLI::Tasks::CreateApiClient.call(
|
|
65
|
-
context,
|
|
66
|
-
org_id: form.organization_id,
|
|
67
|
-
title: form.name,
|
|
68
|
-
type: form.type,
|
|
69
|
-
)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
ShopifyCLI::Resources::EnvFile.new(
|
|
73
|
-
api_key: api_client["apiKey"],
|
|
74
|
-
secret: api_client["apiSecretKeys"].first["secret"],
|
|
75
|
-
shop: form.shop_domain,
|
|
76
|
-
scopes: "write_products,write_customers,write_draft_orders",
|
|
77
|
-
).write(context)
|
|
78
|
-
|
|
79
|
-
partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
|
|
80
|
-
|
|
81
|
-
context.puts(context.message("apps.create.info.created", form.name, partners_url))
|
|
82
|
-
context.puts(context.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME))
|
|
83
|
-
unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
|
|
84
|
-
context.puts(context.message("apps.create.info.install", partners_url, form.name))
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
private
|
|
89
|
-
|
|
90
|
-
def form_data(form_options)
|
|
91
|
-
if ShopifyCLI::Environment.acceptance_test?
|
|
92
|
-
Struct.new(:name, :organization_id, :type, :shop_domain, :db, keyword_init: true).new(
|
|
93
|
-
name: form_options[:name],
|
|
94
|
-
organization_id: "123",
|
|
95
|
-
shop_domain: "test.shopify.io",
|
|
96
|
-
type: "public",
|
|
97
|
-
db: form_options[:db]
|
|
98
|
-
)
|
|
99
|
-
else
|
|
100
|
-
Rails::Forms::Create.ask(context, [], form_options)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def check_dependencies
|
|
105
|
-
check_ruby
|
|
106
|
-
check_node
|
|
107
|
-
check_yarn
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def check_ruby
|
|
111
|
-
ruby_version = Environment.ruby_version(context: context)
|
|
112
|
-
return if ruby_version.satisfies?("~>2.5") ||
|
|
113
|
-
ruby_version.satisfies?("~>3.0.0") ||
|
|
114
|
-
ruby_version.satisfies?("~>3.1.0")
|
|
115
|
-
context.abort(context.message("core.app.create.rails.error.invalid_ruby_version"))
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def check_node
|
|
119
|
-
cmd_path = context.which("node")
|
|
120
|
-
if cmd_path.nil?
|
|
121
|
-
context.abort(context.message("core.app.create.rails.error.node_required")) unless context.windows?
|
|
122
|
-
context.puts("{{x}} {{red:" + context.message("core.app.create.rails.error.node_required") + "}}")
|
|
123
|
-
context.puts(context.message("core.app.create.rails.info.open_new_shell", "node"))
|
|
124
|
-
raise ShopifyCLI::AbortSilent
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
version, stat = context.capture2e("node", "-v")
|
|
128
|
-
unless stat.success?
|
|
129
|
-
context.abort(context.message("core.app.create.rails.error.node_version_failure")) unless context.windows?
|
|
130
|
-
# execution stops above if not Windows
|
|
131
|
-
context.puts("{{x}} {{red:" + context.message("core.app.create.rails.error.node_version_failure") + "}}")
|
|
132
|
-
context.puts(context.message("core.app.create.rails.info.open_new_shell", "node"))
|
|
133
|
-
raise ShopifyCLI::AbortSilent
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
context.done(context.message("core.app.create.rails.node_version", version))
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def check_yarn
|
|
140
|
-
cmd_path = context.which("yarn")
|
|
141
|
-
if cmd_path.nil?
|
|
142
|
-
context.abort(context.message("core.app.create.rails.error.yarn_required")) unless context.windows?
|
|
143
|
-
context.puts("{{x}} {{red:" + context.message("core.app.create.rails.error.yarn_required") + "}}")
|
|
144
|
-
context.puts(context.message("core.app.create.rails.info.open_new_shell", "yarn"))
|
|
145
|
-
raise ShopifyCLI::AbortSilent
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
version, stat = context.capture2e("yarn", "-v")
|
|
149
|
-
unless stat.success?
|
|
150
|
-
context.abort(context.message("core.app.create.rails.error.yarn_version_failure")) unless context.windows?
|
|
151
|
-
context.puts("{{x}} {{red:" + context.message("core.app.create.rails.error.yarn_version_failure") + "}}")
|
|
152
|
-
context.puts(context.message("core.app.create.rails.info.open_new_shell", "yarn"))
|
|
153
|
-
raise ShopifyCLI::AbortSilent
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
context.done(context.message("core.app.create.rails.yarn_version", version))
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def build(name, db)
|
|
160
|
-
unless install_gem("rails")
|
|
161
|
-
context.abort(context.message("core.app.create.rails.error.install_failure", "rails"))
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
unless install_gem("bundler", "~>2.0")
|
|
165
|
-
context.abort(context.message("core.app.create.rails.error.install_failure", "bundler ~>2.0"))
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
full_path = File.join(context.root, name)
|
|
169
|
-
context.abort(context.message("core.app.create.rails.error.dir_exists", name)) if Dir.exist?(full_path)
|
|
170
|
-
|
|
171
|
-
CLI::UI::Frame.open(context.message("core.app.create.rails.generating_app", name)) do
|
|
172
|
-
new_command = %w(rails new)
|
|
173
|
-
new_command << name
|
|
174
|
-
new_command += DEFAULT_RAILS_FLAGS
|
|
175
|
-
new_command << "--database=#{db}"
|
|
176
|
-
new_command += rails_opts.split unless rails_opts.nil?
|
|
177
|
-
|
|
178
|
-
syscall(new_command)
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
context.root = full_path
|
|
182
|
-
|
|
183
|
-
File.open(File.join(context.root, ".gitignore"), "a") { |f| f.write(".env") }
|
|
184
|
-
|
|
185
|
-
context.puts(context.message("core.app.create.rails.adding_shopify_gem"))
|
|
186
|
-
File.open(File.join(context.root, "Gemfile"), "a") do |f|
|
|
187
|
-
f.puts "\ngem 'shopify_app', '~>19.0.1'"
|
|
188
|
-
end
|
|
189
|
-
CLI::UI::Frame.open(context.message("core.app.create.rails.running_bundle_install")) do
|
|
190
|
-
syscall(%w(bundle install))
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
CLI::UI::Frame.open(context.message("core.app.create.rails.running_generator")) do
|
|
194
|
-
syscall(%w(rails generate shopify_app --new-shopify-cli-app))
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
CLI::UI::Frame.open(context.message("core.app.create.rails.running_migrations")) do
|
|
198
|
-
syscall(%w(rails db:create))
|
|
199
|
-
syscall(%w(rails db:migrate RAILS_ENV=development))
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
if install_webpacker?
|
|
203
|
-
CLI::UI::Frame.open(context.message("core.app.create.rails.running_webpacker_install")) do
|
|
204
|
-
syscall(%w(rails webpacker:install))
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
def set_custom_ua
|
|
210
|
-
requires_ua_file = Dir.chdir(context.root) do
|
|
211
|
-
context.ruby_gem_version("shopify_app") < ::Semantic::Version.new("19.0.0")
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
return unless requires_ua_file
|
|
215
|
-
|
|
216
|
-
ua_path = File.join("config", "initializers", "user_agent.rb")
|
|
217
|
-
context.write(ua_path, USER_AGENT_CODE)
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def syscall(args)
|
|
221
|
-
args[0] = Rails::Gem.binary_path_for(context, args[0])
|
|
222
|
-
context.system(*args, chdir: context.root)
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
def install_gem(name, version = nil)
|
|
226
|
-
Rails::Gem.install(context, name, version)
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
def install_webpacker?
|
|
230
|
-
rails_version = Environment.rails_version(context: context)
|
|
231
|
-
webpacker_config = File.exist?(File.join(context.root, "config/webpacker.yml"))
|
|
232
|
-
|
|
233
|
-
rails_version < ::Semantic::Version.new("7.0.0") && !webpacker_config
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
end
|
|
239
|
-
end
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
module ShopifyCLI
|
|
2
|
-
module Services
|
|
3
|
-
module App
|
|
4
|
-
module Deploy
|
|
5
|
-
module Heroku
|
|
6
|
-
class NodeService < BaseService
|
|
7
|
-
attr_reader :context
|
|
8
|
-
|
|
9
|
-
def initialize(context:)
|
|
10
|
-
@context = context
|
|
11
|
-
super()
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def call
|
|
15
|
-
spin_group = CLI::UI::SpinGroup.new
|
|
16
|
-
heroku_service = ShopifyCLI::Heroku.new(context)
|
|
17
|
-
|
|
18
|
-
spin_group.add(context.message("core.app.deploy.heroku.downloading")) do |spinner|
|
|
19
|
-
heroku_service.download
|
|
20
|
-
spinner.update_title(context.message("core.app.deploy.heroku.downloaded"))
|
|
21
|
-
end
|
|
22
|
-
spin_group.wait
|
|
23
|
-
|
|
24
|
-
install_message = context.message(
|
|
25
|
-
context.windows? ? "core.app.deploy.heroku.installing_windows" : "core.app.deploy.heroku.installing"
|
|
26
|
-
)
|
|
27
|
-
spin_group.add(install_message) do |spinner|
|
|
28
|
-
heroku_service.install
|
|
29
|
-
spinner.update_title(context.message("core.app.deploy.heroku.installed"))
|
|
30
|
-
end
|
|
31
|
-
spin_group.wait
|
|
32
|
-
|
|
33
|
-
spin_group.add(context.message("core.app.deploy.heroku.git.checking")) do |spinner|
|
|
34
|
-
ShopifyCLI::Git.init(context)
|
|
35
|
-
spinner.update_title(context.message("core.app.deploy.heroku.git.initialized"))
|
|
36
|
-
end
|
|
37
|
-
spin_group.wait
|
|
38
|
-
|
|
39
|
-
if (account = heroku_service.whoami)
|
|
40
|
-
context.puts(context.message("core.app.deploy.heroku.authenticated_with_account", account))
|
|
41
|
-
else
|
|
42
|
-
CLI::UI::Frame.open(
|
|
43
|
-
context.message("core.app.deploy.heroku.authenticating"),
|
|
44
|
-
success_text: context.message("core.app.deploy.heroku.authenticated")
|
|
45
|
-
) do
|
|
46
|
-
heroku_service.authenticate
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
if (app_name = heroku_service.app)
|
|
51
|
-
context.puts(context.message("core.app.deploy.heroku.app.selected", app_name))
|
|
52
|
-
else
|
|
53
|
-
app_type = CLI::UI::Prompt.ask(context.message("core.app.deploy.heroku.app.no_apps_found")) do |handler|
|
|
54
|
-
handler.option(context.message("core.app.deploy.heroku.app.create")) { :new }
|
|
55
|
-
handler.option(context.message("core.app.deploy.heroku.app.select")) { :existing }
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
if app_type == :existing
|
|
59
|
-
app_name = CLI::UI::Prompt.ask(context.message("core.app.deploy.heroku.app.name"))
|
|
60
|
-
CLI::UI::Frame.open(
|
|
61
|
-
context.message("core.app.deploy.heroku.app.selecting", app_name),
|
|
62
|
-
success_text: context.message("core.app.deploy.heroku.app.selected", app_name)
|
|
63
|
-
) do
|
|
64
|
-
heroku_service.select_existing_app(app_name)
|
|
65
|
-
end
|
|
66
|
-
elsif app_type == :new
|
|
67
|
-
CLI::UI::Frame.open(
|
|
68
|
-
context.message("core.app.deploy.heroku.app.creating"),
|
|
69
|
-
success_text: context.message("core.app.deploy.heroku.app.created")
|
|
70
|
-
) do
|
|
71
|
-
heroku_service.create_new_app
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
branches = ShopifyCLI::Git.branches(context)
|
|
77
|
-
if branches.length == 1
|
|
78
|
-
branch_to_deploy = branches[0]
|
|
79
|
-
context.puts(context.message("core.app.deploy.heroku.git.branch_selected", branch_to_deploy))
|
|
80
|
-
else
|
|
81
|
-
prompt_question = context.message("core.app.deploy.heroku.git.what_branch")
|
|
82
|
-
branch_to_deploy = CLI::UI::Prompt.ask(prompt_question) do |handler|
|
|
83
|
-
branches.each do |branch|
|
|
84
|
-
handler.option(branch) { branch }
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
CLI::UI::Frame.open(
|
|
90
|
-
context.message("core.app.deploy.heroku.deploying"),
|
|
91
|
-
success_text: context.message("core.app.deploy.heroku.deployed")
|
|
92
|
-
) do
|
|
93
|
-
heroku_service.deploy(branch_to_deploy)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|