shopify-cli 2.6.4 → 2.7.1

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.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer.json +5 -0
  3. data/.github/DESIGN.md +1 -1
  4. data/.github/ISSUE_TEMPLATE.md +7 -0
  5. data/.gitignore +1 -0
  6. data/.vscode/extensions.json +5 -0
  7. data/.vscode/settings.json +9 -0
  8. data/CHANGELOG.md +35 -3
  9. data/CONTRIBUTING.md +1 -21
  10. data/{Dockerfile → Codespace.dockerfile} +11 -3
  11. data/Gemfile +1 -0
  12. data/Gemfile.lock +6 -4
  13. data/README.md +20 -99
  14. data/Rakefile +27 -0
  15. data/Tests.dockerfile +35 -0
  16. data/assets/logo.png +0 -0
  17. data/dev.yml +0 -3
  18. data/docs/README.md +13 -0
  19. data/docs/contributors/testing.md +27 -0
  20. data/docs/users/installation.md +46 -0
  21. data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
  22. data/ext/javy/javy.rb +186 -0
  23. data/ext/javy/version +1 -0
  24. data/lib/project_types/extension/cli.rb +7 -3
  25. data/lib/project_types/extension/commands/build.rb +1 -0
  26. data/lib/project_types/extension/commands/create.rb +6 -6
  27. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  28. data/lib/project_types/extension/features/argo.rb +1 -8
  29. data/lib/project_types/extension/features/argo_serve.rb +9 -23
  30. data/lib/project_types/extension/forms/create.rb +1 -1
  31. data/lib/project_types/extension/forms/questions/ask_template.rb +3 -6
  32. data/lib/project_types/extension/messages/messages.rb +1 -0
  33. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  34. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  35. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  36. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  37. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  38. data/lib/project_types/extension/models/server_config/extension.rb +4 -0
  39. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  40. data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
  41. data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  42. data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
  43. data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
  44. data/lib/project_types/extension/tasks/run_extension_command.rb +11 -10
  45. data/lib/project_types/node/cli.rb +0 -16
  46. data/lib/project_types/node/forms/create.rb +5 -5
  47. data/lib/project_types/node/messages/messages.rb +2 -144
  48. data/lib/project_types/php/cli.rb +0 -11
  49. data/lib/project_types/php/forms/create.rb +5 -6
  50. data/lib/project_types/php/messages/messages.rb +2 -161
  51. data/lib/project_types/rails/cli.rb +0 -16
  52. data/lib/project_types/rails/commands/create.rb +46 -17
  53. data/lib/project_types/rails/forms/create.rb +5 -7
  54. data/lib/project_types/rails/messages/messages.rb +6 -151
  55. data/lib/project_types/script/cli.rb +2 -1
  56. data/lib/project_types/script/commands/create.rb +2 -5
  57. data/lib/project_types/script/commands/javy.rb +31 -0
  58. data/lib/project_types/script/commands/push.rb +1 -1
  59. data/lib/project_types/script/config/extension_points.yml +3 -0
  60. data/lib/project_types/script/errors.rb +0 -18
  61. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  62. data/lib/project_types/script/layers/domain/script_json.rb +1 -1
  63. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
  64. data/lib/project_types/script/layers/infrastructure/errors.rb +8 -3
  65. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +22 -3
  66. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +25 -0
  67. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
  68. data/lib/project_types/script/layers/infrastructure/script_service.rb +1 -1
  69. data/lib/project_types/script/messages/messages.rb +16 -22
  70. data/lib/project_types/script/ui/error_handler.rb +1 -27
  71. data/lib/project_types/theme/cli.rb +1 -1
  72. data/lib/project_types/theme/commands/check.rb +1 -1
  73. data/lib/project_types/theme/commands/delete.rb +1 -1
  74. data/lib/project_types/theme/commands/init.rb +1 -1
  75. data/lib/project_types/theme/commands/language_server.rb +1 -1
  76. data/lib/project_types/theme/commands/package.rb +1 -1
  77. data/lib/project_types/theme/commands/publish.rb +1 -1
  78. data/lib/project_types/theme/commands/pull.rb +1 -1
  79. data/lib/project_types/theme/commands/push.rb +1 -1
  80. data/lib/project_types/theme/commands/serve.rb +9 -2
  81. data/lib/project_types/theme/messages/messages.rb +30 -1
  82. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  83. data/lib/shopify_cli/api.rb +7 -2
  84. data/lib/shopify_cli/app_type_detector.rb +24 -20
  85. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  86. data/lib/shopify_cli/command/project_command.rb +18 -0
  87. data/lib/shopify_cli/command/sub_command.rb +19 -0
  88. data/lib/shopify_cli/command.rb +7 -2
  89. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  90. data/lib/shopify_cli/commands/app/create/node.rb +38 -0
  91. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  92. data/lib/shopify_cli/commands/app/create/rails.rb +40 -0
  93. data/lib/shopify_cli/commands/app/create.rb +28 -0
  94. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  95. data/lib/shopify_cli/commands/app/open.rb +19 -0
  96. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  97. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  98. data/lib/shopify_cli/commands/app.rb +29 -0
  99. data/lib/shopify_cli/commands/config.rb +2 -2
  100. data/lib/shopify_cli/commands.rb +1 -0
  101. data/lib/shopify_cli/constants.rb +4 -0
  102. data/lib/shopify_cli/exception_reporter.rb +8 -6
  103. data/lib/shopify_cli/git.rb +12 -1
  104. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  105. data/lib/shopify_cli/github.rb +5 -0
  106. data/lib/shopify_cli/messages/messages.rb +253 -9
  107. data/lib/shopify_cli/migrator.rb +9 -11
  108. data/lib/shopify_cli/project.rb +5 -1
  109. data/lib/shopify_cli/project_commands.rb +1 -1
  110. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  111. data/lib/shopify_cli/services/app/create/node_service.rb +155 -0
  112. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  113. data/lib/shopify_cli/services/app/create/rails_service.rb +215 -0
  114. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  115. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  116. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  117. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  118. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  119. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  120. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  121. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  122. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  123. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  124. data/lib/shopify_cli/services.rb +31 -0
  125. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  126. data/lib/shopify_cli/theme/dev_server.rb +35 -17
  127. data/lib/shopify_cli/tunnel.rb +25 -20
  128. data/lib/shopify_cli/version.rb +1 -1
  129. data/lib/shopify_cli.rb +1 -2
  130. data/shopify-cli.gemspec +2 -6
  131. data/shopify-dev +18 -0
  132. data/utilities/constants.rb +7 -0
  133. data/utilities/docker/container.rb +30 -2
  134. data/utilities/docker.rb +3 -2
  135. data/utilities/utilities.rb +1 -0
  136. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
  137. metadata +56 -53
  138. data/docs/_config.yml +0 -2
  139. data/docs/app/node/commands/index.md +0 -4
  140. data/docs/app/node/index.md +0 -4
  141. data/docs/app/rails/commands/index.md +0 -4
  142. data/docs/app/rails/index.md +0 -4
  143. data/docs/core/index.md +0 -4
  144. data/docs/getting-started/index.md +0 -4
  145. data/docs/getting-started/install/index.md +0 -4
  146. data/docs/getting-started/migrate/index.md +0 -4
  147. data/docs/getting-started/uninstall/index.md +0 -4
  148. data/docs/getting-started/upgrade/index.md +0 -4
  149. data/docs/help/start-app/index.md +0 -4
  150. data/docs/index.md +0 -4
  151. data/ext/shopify-cli/extconf.rb +0 -60
  152. data/install.sh +0 -7
  153. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
  154. data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
  155. data/lib/project_types/node/commands/connect.rb +0 -21
  156. data/lib/project_types/node/commands/create.rb +0 -125
  157. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  158. data/lib/project_types/node/commands/deploy.rb +0 -32
  159. data/lib/project_types/node/commands/generate.rb +0 -22
  160. data/lib/project_types/node/commands/open.rb +0 -18
  161. data/lib/project_types/node/commands/serve.rb +0 -45
  162. data/lib/project_types/node/commands/tunnel.rb +0 -41
  163. data/lib/project_types/php/commands/connect.rb +0 -19
  164. data/lib/project_types/php/commands/create.rb +0 -143
  165. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  166. data/lib/project_types/php/commands/deploy.rb +0 -32
  167. data/lib/project_types/php/commands/open.rb +0 -16
  168. data/lib/project_types/php/commands/serve.rb +0 -48
  169. data/lib/project_types/php/commands/tunnel.rb +0 -37
  170. data/lib/project_types/rails/commands/connect.rb +0 -21
  171. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  172. data/lib/project_types/rails/commands/deploy.rb +0 -32
  173. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  174. data/lib/project_types/rails/commands/generate.rb +0 -60
  175. data/lib/project_types/rails/commands/open.rb +0 -18
  176. data/lib/project_types/rails/commands/serve.rb +0 -51
  177. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  178. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
  179. data/lib/shopify_cli/sub_command.rb +0 -17
  180. data/shopify.fish +0 -12
  181. data/shopify.sh +0 -11
@@ -1,143 +0,0 @@
1
- # frozen_string_literal: true
2
- require "semantic/semantic"
3
-
4
- module PHP
5
- class Command
6
- class Create < ShopifyCLI::SubCommand
7
- options do |parser, flags|
8
- parser.on("--name=NAME") { |name| flags[:title] = name }
9
- parser.on("--organization-id=ID") { |organization_id| flags[:organization_id] = organization_id }
10
- parser.on("--store=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
11
- parser.on("--type=APPTYPE") { |type| flags[:type] = type }
12
- parser.on("--verbose") { flags[:verbose] = true }
13
- end
14
-
15
- def call(args, _name)
16
- form = Forms::Create.ask(@ctx, args, options.flags)
17
- return @ctx.puts(self.class.help) if form.nil?
18
-
19
- check_php
20
- check_composer
21
- check_npm
22
- app_id = build(form)
23
-
24
- ShopifyCLI::Project.write(
25
- @ctx,
26
- project_type: "php",
27
- organization_id: form.organization_id,
28
- )
29
-
30
- partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, app_id)
31
-
32
- @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
33
- @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME, "php"))
34
- unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
35
- @ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
36
- end
37
- end
38
-
39
- def self.help
40
- ShopifyCLI::Context.message("php.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
41
- end
42
-
43
- private
44
-
45
- def check_php
46
- cmd_path = @ctx.which("php")
47
- @ctx.abort(@ctx.message("php.create.error.php_required")) if cmd_path.nil?
48
-
49
- version, stat = @ctx.capture2e("php", "-r", "echo phpversion();")
50
- @ctx.abort(@ctx.message("php.create.error.php_version_failure")) unless stat.success?
51
-
52
- if ::Semantic::Version.new(version) < ::Semantic::Version.new("7.3.0")
53
- @ctx.abort(@ctx.message("php.create.error.php_version_too_low", "7.3"))
54
- end
55
-
56
- @ctx.done(@ctx.message("php.create.php_version", version))
57
- end
58
-
59
- def check_composer
60
- cmd_path = @ctx.which("composer")
61
- @ctx.abort(@ctx.message("php.create.error.composer_required")) if cmd_path.nil?
62
- end
63
-
64
- def check_npm
65
- cmd_path = @ctx.which("npm")
66
- @ctx.abort(@ctx.message("php.create.error.npm_required")) if cmd_path.nil?
67
-
68
- version, stat = @ctx.capture2e("npm", "-v")
69
- @ctx.abort(@ctx.message("php.create.error.npm_version_failure")) unless stat.success?
70
-
71
- @ctx.done(@ctx.message("php.create.npm_version", version))
72
- end
73
-
74
- def build(form)
75
- ShopifyCLI::Git.clone("https://github.com/Shopify/shopify-app-php.git", form.name)
76
-
77
- @ctx.root = File.join(@ctx.root, form.name)
78
- @ctx.chdir(@ctx.root)
79
-
80
- api_client = ShopifyCLI::Tasks::CreateApiClient.call(
81
- @ctx,
82
- org_id: form.organization_id,
83
- title: form.title,
84
- type: form.type,
85
- )
86
-
87
- # Override the example settings with our own
88
- @ctx.cp(".env.example", ".env")
89
-
90
- env_file = ShopifyCLI::Resources::EnvFile.read
91
- env_file.api_key = api_client["apiKey"]
92
- env_file.secret = api_client["apiSecretKeys"].first["secret"]
93
- env_file.shop = form.shop_domain
94
- env_file.host = "localhost"
95
- env_file.scopes = "write_products,write_draft_orders,write_customers"
96
- env_file.extra["DB_DATABASE"] = File.join(@ctx.root, env_file.extra["DB_DATABASE"])
97
- env_file.write(@ctx)
98
-
99
- ShopifyCLI::PHPDeps.install(@ctx, !options.flags[:verbose].nil?)
100
-
101
- set_npm_config
102
- ShopifyCLI::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
103
-
104
- title = @ctx.message("php.create.app_setting_up")
105
- success = @ctx.message("php.create.app_set_up")
106
- failure = @ctx.message("php.create.error.app_setup")
107
- CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
108
- FileUtils.touch(env_file.extra["DB_DATABASE"])
109
- @ctx.system("php", "artisan", "key:generate")
110
- @ctx.system("php", "artisan", "migrate")
111
- end
112
-
113
- begin
114
- @ctx.rm_r(".git")
115
- @ctx.rm_r(".github")
116
- rescue Errno::ENOENT => e
117
- @ctx.debug(e)
118
- end
119
-
120
- api_client["id"]
121
- end
122
-
123
- def set_npm_config
124
- # check available npmrc (either user or system) for production registry
125
- registry, _ = @ctx.capture2("npm config get @shopify:registry")
126
- return if registry.include?("https://registry.yarnpkg.com")
127
-
128
- # available npmrc doesn't have production registry =>
129
- # set a project-based .npmrc
130
- @ctx.system(
131
- "npm",
132
- "--userconfig",
133
- "./.npmrc",
134
- "config",
135
- "set",
136
- "@shopify:registry",
137
- "https://registry.yarnpkg.com",
138
- chdir: @ctx.root
139
- )
140
- end
141
- end
142
- end
143
- end
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module PHP
5
- class Command
6
- class Deploy
7
- class Heroku
8
- def self.help
9
- ShopifyCLI::Context.message("php.deploy.heroku.help", ShopifyCLI::TOOL_NAME)
10
- end
11
-
12
- def self.start(ctx)
13
- spin_group = CLI::UI::SpinGroup.new
14
- heroku_service = ShopifyCLI::Heroku.new(ctx)
15
-
16
- spin_group.add(ctx.message("php.deploy.heroku.downloading")) do |spinner|
17
- heroku_service.download
18
- spinner.update_title(ctx.message("php.deploy.heroku.downloaded"))
19
- end
20
- spin_group.wait
21
-
22
- install_message = ctx.message(
23
- ctx.windows? ? "php.deploy.heroku.installing_windows" : "php.deploy.heroku.installing"
24
- )
25
- spin_group.add(install_message) do |spinner|
26
- heroku_service.install
27
- spinner.update_title(ctx.message("php.deploy.heroku.installed"))
28
- end
29
- spin_group.wait
30
-
31
- spin_group.add(ctx.message("php.deploy.heroku.git.checking")) do |spinner|
32
- ShopifyCLI::Git.init(ctx)
33
- spinner.update_title(ctx.message("php.deploy.heroku.git.initialized"))
34
- end
35
- spin_group.wait
36
-
37
- if (account = heroku_service.whoami)
38
- ctx.puts(ctx.message("php.deploy.heroku.authenticated_with_account", account))
39
- else
40
- CLI::UI::Frame.open(
41
- ctx.message("php.deploy.heroku.authenticating"),
42
- success_text: ctx.message("php.deploy.heroku.authenticated")
43
- ) do
44
- heroku_service.authenticate
45
- end
46
- end
47
-
48
- if (app_name = heroku_service.app)
49
- ctx.puts(ctx.message("php.deploy.heroku.app.selected", app_name))
50
- else
51
- app_type = CLI::UI::Prompt.ask(ctx.message("php.deploy.heroku.app.no_apps_found")) do |handler|
52
- handler.option(ctx.message("php.deploy.heroku.app.create")) { :new }
53
- handler.option(ctx.message("php.deploy.heroku.app.select")) { :existing }
54
- end
55
-
56
- if app_type == :existing
57
- app_name = CLI::UI::Prompt.ask(ctx.message("php.deploy.heroku.app.name"))
58
- CLI::UI::Frame.open(
59
- ctx.message("php.deploy.heroku.app.selecting", app_name),
60
- success_text: ctx.message("php.deploy.heroku.app.selected", app_name)
61
- ) do
62
- heroku_service.select_existing_app(app_name)
63
- end
64
- elsif app_type == :new
65
- CLI::UI::Frame.open(
66
- ctx.message("php.deploy.heroku.app.creating"),
67
- success_text: ctx.message("php.deploy.heroku.app.created")
68
- ) do
69
- heroku_service.create_new_app
70
- app_name = heroku_service.app
71
- end
72
- end
73
- end
74
-
75
- branches = ShopifyCLI::Git.branches(ctx)
76
- if branches.length == 1
77
- branch_to_deploy = branches[0]
78
- ctx.puts(ctx.message("php.deploy.heroku.git.branch_selected", branch_to_deploy))
79
- else
80
- branch_to_deploy = CLI::UI::Prompt.ask(ctx.message("php.deploy.heroku.git.what_branch")) do |handler|
81
- branches.each do |branch|
82
- handler.option(branch) { branch }
83
- end
84
- end
85
- end
86
-
87
- app_url = "https://#{app_name}.herokuapp.com"
88
-
89
- CLI::UI::Frame.open(
90
- ctx.message("php.deploy.heroku.app.setting_configs"),
91
- success_text: ctx.message("php.deploy.heroku.app.configs_set")
92
- ) do
93
- allowed_configs = [/SHOPIFY_API_KEY/, /SHOPIFY_API_SECRET/, /SCOPES/, /HOST/]
94
-
95
- ShopifyCLI::Project.current.env.to_h.each do |config, value|
96
- next unless allowed_configs.any? { |pattern| pattern.match?(config) }
97
-
98
- value = app_url if config == "HOST"
99
-
100
- current = heroku_service.get_config(config)
101
- heroku_service.set_config(config, value) if current.nil? || current != value
102
- end
103
-
104
- current_key = heroku_service.get_config("APP_KEY")
105
- if current_key.nil? || current_key.empty?
106
- output, status = ctx.capture2e("php", "artisan", "key:generate", "--show")
107
-
108
- ctx.abort(ctx.message("php.deploy.heroku.error.generate_app_key")) unless status.success?
109
-
110
- heroku_service.set_config("APP_KEY", output.strip) if status.success?
111
- end
112
-
113
- heroku_service.add_buildpacks(["heroku/php", "heroku/nodejs"])
114
- end
115
-
116
- CLI::UI::Frame.open(
117
- ctx.message("php.deploy.heroku.deploying"),
118
- success_text: ctx.message("php.deploy.heroku.deployed")
119
- ) do
120
- heroku_service.deploy(branch_to_deploy)
121
- end
122
-
123
- heroku_command = heroku_service.heroku_command
124
- ctx.puts(ctx.message("php.deploy.heroku.post_deploy", app_url, heroku_command))
125
- end
126
- end
127
- end
128
- end
129
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module PHP
5
- class Command
6
- class Deploy < ShopifyCLI::SubCommand
7
- prerequisite_task ensure_project_type: :php
8
-
9
- autoload :Heroku, Project.project_filepath("commands/deploy/heroku")
10
-
11
- HEROKU = "heroku"
12
-
13
- def call(args, _name)
14
- subcommand = args.shift
15
- case subcommand
16
- when HEROKU
17
- PHP::Command::Deploy::Heroku.start(@ctx)
18
- else
19
- @ctx.puts(self.class.help)
20
- end
21
- end
22
-
23
- def self.help
24
- ShopifyCLI::Context.message("php.deploy.help", ShopifyCLI::TOOL_NAME)
25
- end
26
-
27
- def self.extended_help
28
- ShopifyCLI::Context.message("php.deploy.extended_help", ShopifyCLI::TOOL_NAME)
29
- end
30
- end
31
- end
32
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PHP
4
- class Command
5
- class Open < ShopifyCLI::SubCommand
6
- def call(*)
7
- project = ShopifyCLI::Project.current
8
- @ctx.open_url!("#{project.env.host}/login?shop=#{project.env.shop}")
9
- end
10
-
11
- def self.help
12
- ShopifyCLI::Context.message("php.open.help", ShopifyCLI::TOOL_NAME)
13
- end
14
- end
15
- end
16
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
- module PHP
3
- class Command
4
- class Serve < ShopifyCLI::SubCommand
5
- include ShopifyCLI::CommandOptions::CommandServeOptions
6
-
7
- prerequisite_task :ensure_env, :ensure_dev_store
8
-
9
- parse_host_option
10
- parse_port_option
11
-
12
- def call(*)
13
- project = ShopifyCLI::Project.current
14
- tunnel_port = port.to_s
15
- url = host || ShopifyCLI::Tunnel.start(@ctx, port: tunnel_port)
16
- project.env.update(@ctx, :host, url)
17
- ShopifyCLI::Tasks::UpdateDashboardURLS.call(
18
- @ctx,
19
- url: url,
20
- callback_url: "/auth/callback",
21
- )
22
-
23
- if project.env.shop
24
- project_url = "#{project.env.host}/login?shop=#{project.env.shop}"
25
- @ctx.puts("\n" + @ctx.message("php.serve.open_info", project_url) + "\n")
26
- end
27
-
28
- CLI::UI::Frame.open(@ctx.message("php.serve.running_server")) do
29
- if ShopifyCLI::ProcessSupervision.running?(:npm_watch)
30
- ShopifyCLI::ProcessSupervision.stop(:npm_watch)
31
- end
32
- ShopifyCLI::ProcessSupervision.start(:npm_watch, "npm run watch", force_spawn: true)
33
-
34
- env = project.env.to_h
35
- @ctx.system("php", "artisan", "serve", "--port", tunnel_port, env: env)
36
- end
37
- end
38
-
39
- def self.help
40
- ShopifyCLI::Context.message("php.serve.help", ShopifyCLI::TOOL_NAME)
41
- end
42
-
43
- def self.extended_help
44
- ShopifyCLI::Context.message("php.serve.extended_help")
45
- end
46
- end
47
- end
48
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "shopify_cli"
4
-
5
- module PHP
6
- class Command
7
- class Tunnel < ShopifyCLI::SubCommand
8
- def call(args, _name)
9
- subcommand = args.shift
10
- case subcommand
11
- when "auth"
12
- token = args.shift
13
- if token.nil?
14
- @ctx.puts(@ctx.message("php.tunnel.error.token_argument_missing"))
15
- @ctx.puts("#{self.class.help}\n#{self.class.extended_help}")
16
- else
17
- ShopifyCLI::Tunnel.auth(@ctx, token)
18
- end
19
- when "start"
20
- ShopifyCLI::Tunnel.start(@ctx)
21
- when "stop"
22
- ShopifyCLI::Tunnel.stop(@ctx)
23
- else
24
- @ctx.puts(self.class.help)
25
- end
26
- end
27
-
28
- def self.help
29
- ShopifyCLI::Context.message("php.tunnel.help", ShopifyCLI::TOOL_NAME)
30
- end
31
-
32
- def self.extended_help
33
- ShopifyCLI::Context.message("php.tunnel.extended_help", ShopifyCLI::TOOL_NAME)
34
- end
35
- end
36
- end
37
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
- module Rails
3
- class Command
4
- class Connect < ShopifyCLI::SubCommand
5
- prerequisite_task ensure_project_type: :rails
6
-
7
- def call(*)
8
- if ShopifyCLI::Project.has_current? && ShopifyCLI::Project.current.env
9
- @ctx.puts(@ctx.message("rails.connect.production_warning"))
10
- end
11
-
12
- app = ShopifyCLI::Connect.new(@ctx).default_connect("rails")
13
- @ctx.done(@ctx.message("rails.connect.connected", app))
14
- end
15
-
16
- def self.help
17
- ShopifyCLI::Context.message("rails.connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
18
- end
19
- end
20
- end
21
- end
@@ -1,115 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Rails
5
- class Command
6
- class Deploy
7
- class Heroku
8
- class << self
9
- DB_CHECK_CMD = 'bundle exec rails runner "puts ActiveRecord::Base.connection.adapter_name.downcase"'
10
-
11
- def help
12
- ShopifyCLI::Context.message("rails.deploy.heroku.help", ShopifyCLI::TOOL_NAME)
13
- end
14
-
15
- def start(ctx)
16
- CLI::UI::Frame.open(ctx.message("rails.deploy.heroku.db_check.validating")) do
17
- CLI::UI::Spinner.spin(ctx.message("rails.deploy.heroku.db_check.checking")) do |spinner|
18
- db_type, err = check_db(ctx)
19
- ctx.abort(ctx.message(err)) unless err.nil?
20
- spinner.update_title(ctx.message("rails.deploy.heroku.db_check.validated", db_type))
21
- end
22
- true
23
- end
24
-
25
- spin_group = CLI::UI::SpinGroup.new
26
- heroku_service = ShopifyCLI::Heroku.new(ctx)
27
-
28
- spin_group.add(ctx.message("rails.deploy.heroku.downloading")) do |spinner|
29
- heroku_service.download
30
- spinner.update_title(ctx.message("rails.deploy.heroku.downloaded"))
31
- end
32
- spin_group.wait
33
-
34
- spin_group.add(ctx.message("rails.deploy.heroku.installing")) do |spinner|
35
- heroku_service.install
36
- spinner.update_title(ctx.message("rails.deploy.heroku.installed"))
37
- end
38
- spin_group.add(ctx.message("rails.deploy.heroku.git.checking")) do |spinner|
39
- ShopifyCLI::Git.init(ctx)
40
- spinner.update_title(ctx.message("rails.deploy.heroku.git.initialized"))
41
- end
42
- spin_group.wait
43
-
44
- if (account = heroku_service.whoami)
45
- ctx.puts(ctx.message("rails.deploy.heroku.authenticated_with_account", account))
46
- else
47
- CLI::UI::Frame.open(
48
- ctx.message("rails.deploy.heroku.authenticating"),
49
- success_text: ctx.message("rails.deploy.heroku.authenticated")
50
- ) do
51
- heroku_service.authenticate
52
- end
53
- end
54
-
55
- if (app_name = heroku_service.app)
56
- ctx.puts(ctx.message("rails.deploy.heroku.app.selected", app_name))
57
- else
58
- app_type = CLI::UI::Prompt.ask(ctx.message("rails.deploy.heroku.app.no_apps_found")) do |handler|
59
- handler.option(ctx.message("rails.deploy.heroku.app.create")) { :new }
60
- handler.option(ctx.message("rails.deploy.heroku.app.select")) { :existing }
61
- end
62
-
63
- if app_type == :existing
64
- app_name = CLI::UI::Prompt.ask(ctx.message("rails.deploy.heroku.app.name"))
65
- CLI::UI::Frame.open(
66
- ctx.message("rails.deploy.heroku.app.selecting", app_name),
67
- success_text: ctx.message("rails.deploy.heroku.app.selected", app_name)
68
- ) do
69
- heroku_service.select_existing_app(app_name)
70
- end
71
- elsif app_type == :new
72
- CLI::UI::Frame.open(
73
- ctx.message("rails.deploy.heroku.app.creating"),
74
- success_text: ctx.message("rails.deploy.heroku.app.created")
75
- ) do
76
- heroku_service.create_new_app
77
- end
78
- end
79
- end
80
-
81
- branches = ShopifyCLI::Git.branches(ctx)
82
- if branches.length == 1
83
- branch_to_deploy = branches[0]
84
- ctx.puts(ctx.message("rails.deploy.heroku.git.branch_selected", branch_to_deploy))
85
- else
86
- branch_to_deploy = CLI::UI::Prompt.ask(ctx.message("rails.deploy.heroku.git.what_branch")) do |handler|
87
- branches.each do |branch|
88
- handler.option(branch) { branch }
89
- end
90
- end
91
- end
92
-
93
- CLI::UI::Frame.open(
94
- ctx.message("rails.deploy.heroku.deploying"),
95
- success_text: ctx.message("rails.deploy.heroku.deployed")
96
- ) do
97
- heroku_service.deploy(branch_to_deploy)
98
- end
99
- end
100
-
101
- def check_db(ctx)
102
- out, stat = ctx.capture2e(DB_CHECK_CMD)
103
- if stat.success? && out.strip == "sqlite"
104
- ["sqlite", "rails.deploy.heroku.db_check.sqlite"]
105
- elsif !stat.success?
106
- [nil, "rails.deploy.heroku.db_check.problem"]
107
- else
108
- [out.strip, nil]
109
- end
110
- end
111
- end
112
- end
113
- end
114
- end
115
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Rails
5
- class Command
6
- class Deploy < ShopifyCLI::SubCommand
7
- prerequisite_task ensure_project_type: :rails
8
-
9
- autoload :Heroku, Project.project_filepath("commands/deploy/heroku")
10
-
11
- HEROKU = "heroku"
12
-
13
- def call(args, _name)
14
- subcommand = args.shift
15
- case subcommand
16
- when HEROKU
17
- Rails::Command::Deploy::Heroku.start(@ctx)
18
- else
19
- @ctx.puts(self.class.help)
20
- end
21
- end
22
-
23
- def self.help
24
- ShopifyCLI::Context.message("rails.deploy.help", ShopifyCLI::TOOL_NAME)
25
- end
26
-
27
- def self.extended_help
28
- ShopifyCLI::Context.message("rails.deploy.extended_help", ShopifyCLI::TOOL_NAME)
29
- end
30
- end
31
- end
32
- end
@@ -1,42 +0,0 @@
1
- require "shopify_cli"
2
- require "json"
3
- module Rails
4
- class Command
5
- class Generate
6
- class Webhook
7
- class << self
8
- def start(ctx, args)
9
- selected_type = args.first
10
- schema = ShopifyCLI::AdminAPI::Schema.get(ctx)
11
- webhooks = schema.get_names_from_type("WebhookSubscriptionTopic")
12
- unless selected_type && webhooks.include?(selected_type)
13
- selected_type = CLI::UI::Prompt.ask(ctx.message("rails.generate.webhook.select")) do |handler|
14
- webhooks.each do |type|
15
- handler.option(type) { type }
16
- end
17
- end
18
- end
19
- spin_group = CLI::UI::SpinGroup.new
20
- spin_group.add(ctx.message("rails.generate.webhook.selected", selected_type)) do |spinner|
21
- Rails::Command::Generate.run_generate(generate_command(selected_type, ctx), selected_type, ctx)
22
- spinner.update_title("{{green:#{selected_type}}} config/initializers/shopify_app.rb")
23
- end
24
- spin_group.wait
25
- end
26
-
27
- def help
28
- ShopifyCLI::Context.message("rails.generate.webhook.help", ShopifyCLI::TOOL_NAME)
29
- end
30
-
31
- def generate_command(selected_type, ctx)
32
- parts = selected_type.downcase.split("_")
33
- host = ShopifyCLI::Project.current.env.host
34
- selected_type = parts[0..-2].join("_") + "/" + parts[-1]
35
- command = ctx.windows? ? "ruby bin\\rails" : "bin/rails"
36
- "#{command} g shopify_app:add_webhook -t #{selected_type} -a #{host}/webhooks/#{selected_type.downcase}"
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Rails
5
- class Command
6
- class Generate < ShopifyCLI::SubCommand
7
- prerequisite_task ensure_project_type: :rails
8
-
9
- autoload :Webhook, Project.project_filepath("commands/generate/webhook")
10
-
11
- WEBHOOK = "webhook"
12
-
13
- def call(args, _name)
14
- subcommand = args.shift
15
- case subcommand
16
- when WEBHOOK
17
- Rails::Command::Generate::Webhook.start(@ctx, args)
18
- else
19
- @ctx.puts(self.class.help)
20
- end
21
- end
22
-
23
- def self.help
24
- ShopifyCLI::Context.message("rails.generate.help", ShopifyCLI::TOOL_NAME)
25
- end
26
-
27
- def self.extended_help
28
- extended_help = "{{bold:Subcommands:}}\n"
29
- subcommand_registry.resolved_commands.sort.each do |name, klass|
30
- extended_help += " {{cyan:#{name}}}: "
31
-
32
- if (subcmd_help = klass.help)
33
- extended_help += subcmd_help.gsub("\n ", "\n ")
34
- end
35
- extended_help += "\n"
36
- end
37
- extended_help += ShopifyCLI::Context.message("rails.generate.extended_help", ShopifyCLI::TOOL_NAME)
38
- end
39
-
40
- def self.run_generate(script, name, ctx)
41
- Gem.gem_path(ctx)
42
- stat = ctx.system(script)
43
- unless stat.success?
44
- ctx.abort(response(stat.exitstatus, name, ctx))
45
- end
46
- end
47
-
48
- def self.response(code, name, ctx)
49
- case code
50
- when 1
51
- ctx.message("rails.generate.error.generic", name)
52
- when 2
53
- ctx.message("rails.generate.error.name_exists", name)
54
- else
55
- ctx.message("rails.error.generic")
56
- end
57
- end
58
- end
59
- end
60
- end