shopify-cli 2.6.5 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) 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 +42 -4
  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 +4 -8
  26. data/lib/project_types/extension/commands/create.rb +3 -5
  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 -2
  33. data/lib/project_types/extension/models/development_server.rb +2 -2
  34. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  35. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  36. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  37. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  38. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  39. data/lib/project_types/extension/models/server_config/extension.rb +4 -0
  40. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  41. data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
  42. data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  43. data/lib/project_types/extension/tasks/find_package_from_json.rb +37 -0
  44. data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
  45. data/lib/project_types/extension/tasks/run_extension_command.rb +11 -10
  46. data/lib/project_types/node/cli.rb +0 -16
  47. data/lib/project_types/node/forms/create.rb +5 -5
  48. data/lib/project_types/node/messages/messages.rb +2 -144
  49. data/lib/project_types/php/cli.rb +0 -11
  50. data/lib/project_types/php/forms/create.rb +5 -6
  51. data/lib/project_types/php/messages/messages.rb +2 -161
  52. data/lib/project_types/rails/cli.rb +0 -16
  53. data/lib/project_types/rails/commands/create.rb +43 -16
  54. data/lib/project_types/rails/forms/create.rb +5 -7
  55. data/lib/project_types/rails/messages/messages.rb +6 -151
  56. data/lib/project_types/script/cli.rb +7 -1
  57. data/lib/project_types/script/commands/create.rb +3 -8
  58. data/lib/project_types/script/commands/javy.rb +29 -0
  59. data/lib/project_types/script/commands/push.rb +3 -2
  60. data/lib/project_types/script/config/extension_points.yml +3 -26
  61. data/lib/project_types/script/errors.rb +0 -18
  62. data/lib/project_types/script/forms/ask_app.rb +32 -0
  63. data/lib/project_types/script/forms/ask_org.rb +30 -0
  64. data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
  65. data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
  66. data/lib/project_types/script/layers/application/build_script.rb +0 -1
  67. data/lib/project_types/script/layers/application/connect_app.rb +73 -0
  68. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  69. data/lib/project_types/script/layers/domain/script_json.rb +1 -1
  70. data/lib/project_types/script/layers/domain/script_project.rb +4 -0
  71. data/lib/project_types/script/layers/infrastructure/api_clients/partners_proxy_api_client.rb +0 -4
  72. data/lib/project_types/script/layers/infrastructure/errors.rb +8 -4
  73. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +1 -5
  74. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +25 -4
  75. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +3 -4
  76. data/lib/project_types/script/layers/infrastructure/script_service.rb +1 -1
  77. data/lib/project_types/script/messages/messages.rb +16 -20
  78. data/lib/project_types/script/ui/error_handler.rb +1 -32
  79. data/lib/project_types/theme/cli.rb +1 -1
  80. data/lib/project_types/theme/commands/check.rb +1 -1
  81. data/lib/project_types/theme/commands/delete.rb +1 -1
  82. data/lib/project_types/theme/commands/init.rb +1 -1
  83. data/lib/project_types/theme/commands/language_server.rb +1 -1
  84. data/lib/project_types/theme/commands/package.rb +1 -1
  85. data/lib/project_types/theme/commands/publish.rb +1 -1
  86. data/lib/project_types/theme/commands/pull.rb +4 -1
  87. data/lib/project_types/theme/commands/push.rb +7 -2
  88. data/lib/project_types/theme/commands/serve.rb +9 -2
  89. data/lib/project_types/theme/messages/messages.rb +39 -1
  90. data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
  91. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  92. data/lib/shopify_cli/api.rb +7 -2
  93. data/lib/shopify_cli/app_type_detector.rb +24 -20
  94. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  95. data/lib/shopify_cli/command/project_command.rb +31 -0
  96. data/lib/shopify_cli/command/sub_command.rb +19 -0
  97. data/lib/shopify_cli/command.rb +7 -2
  98. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  99. data/lib/shopify_cli/commands/app/create/node.rb +36 -0
  100. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  101. data/lib/shopify_cli/commands/app/create/rails.rb +38 -0
  102. data/lib/shopify_cli/commands/app/create.rb +28 -0
  103. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  104. data/lib/shopify_cli/commands/app/open.rb +19 -0
  105. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  106. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  107. data/lib/shopify_cli/commands/app.rb +29 -0
  108. data/lib/shopify_cli/commands/config.rb +2 -2
  109. data/lib/shopify_cli/commands.rb +1 -0
  110. data/lib/shopify_cli/constants.rb +7 -0
  111. data/lib/shopify_cli/context.rb +9 -0
  112. data/lib/shopify_cli/environment.rb +4 -0
  113. data/lib/shopify_cli/exception_reporter.rb +8 -6
  114. data/lib/shopify_cli/git.rb +12 -1
  115. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  116. data/lib/shopify_cli/github.rb +5 -0
  117. data/lib/shopify_cli/identity_auth.rb +18 -0
  118. data/lib/shopify_cli/messages/messages.rb +254 -9
  119. data/lib/shopify_cli/migrator.rb +9 -11
  120. data/lib/shopify_cli/partners_api.rb +1 -8
  121. data/lib/shopify_cli/project.rb +5 -1
  122. data/lib/shopify_cli/project_commands.rb +1 -1
  123. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  124. data/lib/shopify_cli/services/app/create/node_service.rb +155 -0
  125. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  126. data/lib/shopify_cli/services/app/create/rails_service.rb +215 -0
  127. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  128. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  129. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  130. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  131. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  132. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  133. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  134. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  135. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  136. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  137. data/lib/shopify_cli/services.rb +31 -0
  138. data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
  139. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  140. data/lib/shopify_cli/theme/dev_server.rb +35 -17
  141. data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  142. data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
  143. data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  144. data/lib/shopify_cli/theme/syncer.rb +40 -39
  145. data/lib/shopify_cli/theme/theme.rb +31 -19
  146. data/lib/shopify_cli/tunnel.rb +25 -22
  147. data/lib/shopify_cli/version.rb +1 -1
  148. data/lib/shopify_cli.rb +1 -2
  149. data/shopify-cli.gemspec +2 -6
  150. data/shopify-dev +18 -0
  151. data/utilities/constants.rb +7 -0
  152. data/utilities/docker/container.rb +30 -2
  153. data/utilities/docker.rb +3 -2
  154. data/utilities/utilities.rb +1 -0
  155. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
  156. metadata +64 -54
  157. data/docs/_config.yml +0 -2
  158. data/docs/app/node/commands/index.md +0 -4
  159. data/docs/app/node/index.md +0 -4
  160. data/docs/app/rails/commands/index.md +0 -4
  161. data/docs/app/rails/index.md +0 -4
  162. data/docs/core/index.md +0 -4
  163. data/docs/getting-started/index.md +0 -4
  164. data/docs/getting-started/install/index.md +0 -4
  165. data/docs/getting-started/migrate/index.md +0 -4
  166. data/docs/getting-started/uninstall/index.md +0 -4
  167. data/docs/getting-started/upgrade/index.md +0 -4
  168. data/docs/help/start-app/index.md +0 -4
  169. data/docs/index.md +0 -4
  170. data/ext/shopify-cli/extconf.rb +0 -60
  171. data/install.sh +0 -7
  172. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -31
  173. data/lib/project_types/extension/tasks/load_server_config.rb +0 -23
  174. data/lib/project_types/node/commands/connect.rb +0 -21
  175. data/lib/project_types/node/commands/create.rb +0 -125
  176. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  177. data/lib/project_types/node/commands/deploy.rb +0 -32
  178. data/lib/project_types/node/commands/generate.rb +0 -22
  179. data/lib/project_types/node/commands/open.rb +0 -18
  180. data/lib/project_types/node/commands/serve.rb +0 -45
  181. data/lib/project_types/node/commands/tunnel.rb +0 -41
  182. data/lib/project_types/php/commands/connect.rb +0 -19
  183. data/lib/project_types/php/commands/create.rb +0 -143
  184. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  185. data/lib/project_types/php/commands/deploy.rb +0 -32
  186. data/lib/project_types/php/commands/open.rb +0 -16
  187. data/lib/project_types/php/commands/serve.rb +0 -48
  188. data/lib/project_types/php/commands/tunnel.rb +0 -37
  189. data/lib/project_types/rails/commands/connect.rb +0 -21
  190. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  191. data/lib/project_types/rails/commands/deploy.rb +0 -32
  192. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  193. data/lib/project_types/rails/commands/generate.rb +0 -60
  194. data/lib/project_types/rails/commands/open.rb +0 -18
  195. data/lib/project_types/rails/commands/serve.rb +0 -51
  196. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  197. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -0
  198. data/lib/project_types/script/tasks/ensure_env.rb +0 -106
  199. data/lib/shopify_cli/sub_command.rb +0 -17
  200. data/shopify.fish +0 -12
  201. data/shopify.sh +0 -11
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+ require "json"
3
+
4
+ module Extension
5
+ module Tasks
6
+ class FindPackageFromJson < ShopifyCLI::Task
7
+ include SmartProperties
8
+
9
+ property! :context, accepts: ShopifyCLI::Context
10
+
11
+ def self.call(package_name, **config)
12
+ new(**config).call(package_name)
13
+ end
14
+
15
+ def call(package_name)
16
+ ShopifyCLI::Result.success(resolve_package_json(package_name))
17
+ .then { |file| File.read(file) }
18
+ .then { |file| JSON.parse(file) }
19
+ .then { |file| file.dig("version") }
20
+ .then { |version| return Models::NpmPackage.new(name: package_name, version: version) }
21
+ .unwrap do |error|
22
+ context.debug(error)
23
+ context.abort(context.message("errors.module_not_found", package_name))
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def resolve_package_json(package_name)
30
+ path = "path.join(require.resolve('#{package_name}'), '../package.json')"
31
+ package_json, error, _ = CLI::Kit::System.capture3("node", "-p", path)
32
+ return error unless !error.nil?
33
+ package_json.chomp
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+ require "shopify_cli"
3
+ require "yaml"
4
+
5
+ module Extension
6
+ module Tasks
7
+ class MergeServerConfig < ShopifyCLI::Task
8
+ class << self
9
+ def call(context:, file_name:, resource_url:, tunnel_url:, type:)
10
+ config = YAML.load_file(file_name)
11
+ project = ExtensionProject.current
12
+ Tasks::ConvertServerConfig.call(
13
+ api_key: project.env.api_key,
14
+ context: context,
15
+ hash: config,
16
+ registration_uuid: project.registration_uuid,
17
+ resource_url: resource_url || project.resource_url,
18
+ store: project.env.shop || "",
19
+ title: project.title,
20
+ tunnel_url: tunnel_url,
21
+ type: type
22
+ )
23
+ rescue Psych::SyntaxError => e
24
+ raise(
25
+ ShopifyCLI::Abort,
26
+ ShopifyCLI::Context.message("core.yaml.error.invalid", file_name, e.message)
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -7,10 +7,6 @@ module Extension
7
7
  class RunExtensionCommand < ShopifyCLI::Task
8
8
  include SmartProperties
9
9
 
10
- SUPPORTED_EXTENSION_TYPES = [
11
- "checkout_ui_extension",
12
- ]
13
-
14
10
  SUPPORTED_COMMANDS = [
15
11
  "create",
16
12
  "build",
@@ -18,12 +14,14 @@ module Extension
18
14
  ]
19
15
 
20
16
  property! :command, accepts: SUPPORTED_COMMANDS
21
- property! :type, accepts: SUPPORTED_EXTENSION_TYPES
22
- property :context, accepts: ShopifyCLI::Context
17
+ property! :type, accepts: Models::DevelopmentServerRequirements::SUPPORTED_EXTENSION_TYPES
18
+ property! :context, accepts: ShopifyCLI::Context
23
19
  property :config_file_name, accepts: String
24
20
  property :port, accepts: Integer, default: 39351
21
+ property :resource_url, accepts: String
25
22
  property :root_dir, accepts: String
26
23
  property :template, accepts: Models::ServerConfig::Development::VALID_TEMPLATES
24
+ property :tunnel_url, accepts: String
27
25
 
28
26
  def call
29
27
  ShopifyCLI::Result.success(config_file_exists?)
@@ -43,14 +41,17 @@ module Extension
43
41
  end
44
42
 
45
43
  def load_or_build_server_config(config_file_exists)
46
- return load_server_config if config_file_exists
44
+ return merge_server_config if config_file_exists
47
45
  build_server_config
48
46
  end
49
47
 
50
- def load_server_config
51
- Tasks::LoadServerConfig.call(
48
+ def merge_server_config
49
+ Tasks::MergeServerConfig.call(
50
+ context: context,
52
51
  file_name: config_file_name,
53
- type: type,
52
+ resource_url: resource_url,
53
+ tunnel_url: tunnel_url,
54
+ type: type
54
55
  )
55
56
  end
56
57
 
@@ -5,22 +5,6 @@ module Node
5
5
  register_messages(Node::Messages::MESSAGES)
6
6
  end
7
7
 
8
- # define/autoload project specific Commands
9
- class Command < ShopifyCLI::ProjectCommands
10
- subcommand :Connect, "connect", Project.project_filepath("commands/connect")
11
- subcommand :Create, "create", Project.project_filepath("commands/create")
12
- subcommand :Deploy, "deploy", Project.project_filepath("commands/deploy")
13
- subcommand :Generate, "generate", Project.project_filepath("commands/generate")
14
- subcommand :Open, "open", Project.project_filepath("commands/open")
15
- subcommand :Serve, "serve", Project.project_filepath("commands/serve")
16
- subcommand :Tunnel, "tunnel", Project.project_filepath("commands/tunnel")
17
- end
18
- ShopifyCLI::Commands.register("Node::Command", "node")
19
-
20
- # define/autoload project specific Tasks
21
- module Tasks
22
- end
23
-
24
8
  # define/autoload project specific Forms
25
9
  module Forms
26
10
  autoload :Create, Project.project_filepath("forms/create")
@@ -4,10 +4,10 @@ module Node
4
4
  module Forms
5
5
  class Create < ShopifyCLI::Form
6
6
  attr_accessor :name
7
- flag_arguments :title, :organization_id, :shop_domain, :type
7
+ flag_arguments :name, :organization_id, :shop_domain, :type
8
8
 
9
9
  def ask
10
- self.title ||= CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_name"))
10
+ self.name ||= CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_name"))
11
11
  self.name = format_name
12
12
  self.type = ask_type
13
13
  res = ShopifyCLI::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
@@ -18,12 +18,12 @@ module Node
18
18
  private
19
19
 
20
20
  def format_name
21
- name = title.downcase.split(" ").join("_")
21
+ formatted_name = name.downcase.split(" ").join("_")
22
22
 
23
- if name.include?("shopify")
23
+ if formatted_name.include?("shopify")
24
24
  ctx.abort(ctx.message("node.forms.create.error.invalid_app_name"))
25
25
  end
26
- name
26
+ formatted_name
27
27
  end
28
28
 
29
29
  def ask_type
@@ -5,155 +5,13 @@ module Node
5
5
  MESSAGES = {
6
6
  node: {
7
7
  help: <<~HELP,
8
- Suite of commands for developing Node.js apps. See {{command:%1$s node <command> --help}} for usage of each command.
9
- Usage: {{command:%1$s node [ %2$s ]}}
8
+ Suite of commands for developing Node.js apps. See {{command:%1$s app node <command> --help}} for usage of each command.
9
+ Usage: {{command:%1$s app node [ %2$s ]}}
10
10
  HELP
11
11
 
12
12
  error: {
13
13
  generic: "Error",
14
14
  },
15
-
16
- connect: {
17
- connected: "Project now connected to {{green:%s}}",
18
- help: <<~HELP,
19
- {{command:%s node connect}}: Connects an existing Node.js app to Shopify CLI. Creates a config file.
20
- Usage: {{command:%s node connect}}
21
- HELP
22
- production_warning: <<~MESSAGE,
23
- {{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
24
- MESSAGE
25
- },
26
-
27
- create: {
28
- help: <<~HELP,
29
- {{command:%s node create}}: Creates an embedded nodejs app.
30
- Usage: {{command:%s node create}}
31
- Options:
32
- {{command:--name=NAME}} App name. Any string.
33
- {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
34
- {{command:--store=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
35
- HELP
36
- error: {
37
- node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.",
38
- node_version_failure: "Failed to get the current node version. Please make sure it is installed as " \
39
- "per the instructions at https://nodejs.org/en.",
40
- npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
41
- npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
42
- "the instructions at https://www.npmjs.com/get-npm.",
43
- },
44
- node_version: "node %s",
45
- npm_version: "npm %s",
46
- },
47
-
48
- deploy: {
49
- help: <<~HELP,
50
- Deploy the current Node project to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future.
51
- Usage: {{command:%s node deploy [ heroku ]}}
52
- HELP
53
- extended_help: <<~HELP,
54
- {{bold:Subcommands:}}
55
- {{cyan:heroku}}: Deploys the current Node project to Heroku.
56
- Usage: {{command:%s node deploy heroku}}
57
- HELP
58
- heroku: {
59
- help: <<~HELP,
60
- Deploy the current Node project to Heroku
61
- Usage: {{command:%s node deploy heroku}}
62
- HELP
63
- downloading: "Downloading Heroku CLI…",
64
- downloaded: "Downloaded Heroku CLI",
65
- installing: "Installing Heroku CLI…",
66
- installing_windows: "Running Heroku CLI install wizard…",
67
- installed: "Installed Heroku CLI",
68
- authenticating: "Authenticating with Heroku…",
69
- authenticated: "{{v}} Authenticated with Heroku",
70
- authenticated_with_account: "{{v}} Authenticated with Heroku as {{green:%s}}",
71
- deploying: "Deploying to Heroku…",
72
- deployed: "{{v}} Deployed to Heroku",
73
- git: {
74
- checking: "Checking git repo…",
75
- initialized: "Git repo initialized",
76
- what_branch: "What branch would you like to deploy?",
77
- branch_selected: "{{v}} Git branch {{green:%s}} selected for deploy",
78
- },
79
- app: {
80
- no_apps_found: "No existing Heroku app found. What would you like to do?",
81
- name: "What is your Heroku app’s name?",
82
- select: "Specify an existing Heroku app",
83
- selecting: "Selecting Heroku app %s…",
84
- selected: "{{v}} Heroku app {{green:%s}} selected",
85
- create: "Create a new Heroku app",
86
- creating: "Creating new Heroku app…",
87
- created: "{{v}} New Heroku app created",
88
- },
89
- },
90
- },
91
-
92
- generate: {
93
- help: <<~HELP,
94
- {{red:The {{command:generate}} command is no longer supported.}}
95
- You can complete any tasks previously supported by {{command:generate}} with these guides:
96
- {{green:page}}
97
- Create a page with Polaris design components: {{green:https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/build-your-user-interface-with-polaris}}
98
-
99
- {{green:webhook}}
100
- Register and process webhooks: {{green:https://github.com/Shopify/shopify-node-api/blob/main/docs/usage/webhooks.md}}
101
-
102
- {{green:billing}}
103
- Create and manage app billing models: {{green:https://shopify.dev/tutorials/bill-for-your-app-using-graphql-admin-api}}
104
- HELP
105
- },
106
-
107
- open: {
108
- help: <<~HELP,
109
- Open your local development app in the default browser.
110
- Usage: {{command:%s node open}}
111
- HELP
112
- },
113
-
114
- serve: {
115
- help: <<~HELP,
116
- Start a local development node server for your project, as well as a public ngrok tunnel to your localhost.
117
- Usage: {{command:%s node serve}}
118
- HELP
119
- extended_help: <<~HELP,
120
- {{bold:Options:}}
121
- {{cyan:--host=HOST}}: Bypass running tunnel and use custom host. HOST must be HTTPS url.
122
- {{cyan:--port=PORT}}: Use custom port.
123
- HELP
124
-
125
- open_info: <<~MESSAGE,
126
- {{*}} To install and start using your app, open this URL in your browser:
127
- {{green:%s}}
128
- MESSAGE
129
- running_server: "Running server…",
130
- },
131
-
132
- tunnel: {
133
- help: <<~HELP,
134
- Start or stop an http tunnel to your local development app using ngrok.
135
- Usage: {{command:%s node tunnel [ auth | start | stop ]}}
136
- HELP
137
- extended_help: <<~HELP,
138
- {{bold:Subcommands:}}
139
-
140
- {{cyan:auth}}: Writes an ngrok auth token to ~/.ngrok2/ngrok.yml to connect with an ngrok account. Visit https://dashboard.ngrok.com/signup to sign up.
141
- Usage: {{command:%1$s node tunnel auth <token>}}
142
-
143
- {{cyan:start}}: Starts an ngrok tunnel, will print the URL for an existing tunnel if already running.
144
- Usage: {{command:%1$s node tunnel start}}
145
-
146
- {{cyan:stop}}: Stops the ngrok tunnel.
147
- Usage: {{command:%1$s node tunnel stop}}
148
-
149
- HELP
150
-
151
- error: {
152
- token_argument_missing: "{{x}} {{red:auth requires a token argument}}\n\n",
153
- },
154
-
155
- },
156
-
157
15
  forms: {
158
16
  create: {
159
17
  error: {
@@ -5,17 +5,6 @@ module PHP
5
5
  register_messages(PHP::Messages::MESSAGES)
6
6
  end
7
7
 
8
- # define/autoload project specific Commands
9
- class Command < ShopifyCLI::ProjectCommands
10
- subcommand :Connect, "connect", Project.project_filepath("commands/connect")
11
- subcommand :Create, "create", Project.project_filepath("commands/create")
12
- subcommand :Deploy, "deploy", Project.project_filepath("commands/deploy")
13
- subcommand :Open, "open", Project.project_filepath("commands/open")
14
- subcommand :Serve, "serve", Project.project_filepath("commands/serve")
15
- subcommand :Tunnel, "tunnel", Project.project_filepath("commands/tunnel")
16
- end
17
- ShopifyCLI::Commands.register("PHP::Command", "php")
18
-
19
8
  # define/autoload project specific Tasks
20
9
  module Tasks
21
10
  end
@@ -3,11 +3,10 @@ require "uri"
3
3
  module PHP
4
4
  module Forms
5
5
  class Create < ShopifyCLI::Form
6
- attr_accessor :name
7
- flag_arguments :title, :organization_id, :shop_domain, :type
6
+ flag_arguments :name, :organization_id, :shop_domain, :type
8
7
 
9
8
  def ask
10
- self.title ||= CLI::UI::Prompt.ask(ctx.message("php.forms.create.app_name"))
9
+ self.name ||= CLI::UI::Prompt.ask(ctx.message("php.forms.create.app_name"))
11
10
  self.name = format_name
12
11
  self.type = ask_type
13
12
  res = ShopifyCLI::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
@@ -18,12 +17,12 @@ module PHP
18
17
  private
19
18
 
20
19
  def format_name
21
- name = title.downcase.split(" ").join("_")
20
+ formatted_name = name.downcase.split(" ").join("_")
22
21
 
23
- if name.include?("shopify")
22
+ if formatted_name.include?("shopify")
24
23
  ctx.abort(ctx.message("php.forms.create.error.invalid_app_name"))
25
24
  end
26
- name
25
+ formatted_name
27
26
  end
28
27
 
29
28
  def ask_type
@@ -5,168 +5,9 @@ module PHP
5
5
  MESSAGES = {
6
6
  php: {
7
7
  help: <<~HELP,
8
- Suite of commands for developing PHP apps with Laravel. See {{command:%1$s php <command> --help}} for usage of each command.
9
- Usage: {{command:%1$s php [ %2$s ]}}
8
+ Suite of commands for developing PHP apps with Laravel. See {{command:%1$s app php <command> --help}} for usage of each command.
9
+ Usage: {{command:%1$s app php [ %2$s ]}}
10
10
  HELP
11
-
12
- connect: {
13
- connected: "Project now connected to {{green:%s}}",
14
- help: <<~HELP,
15
- {{command:%s php connect}}: Connects an existing PHP app to Shopify CLI. Creates a config file.
16
- Usage: {{command:%s php connect}}
17
- HELP
18
- production_warning: <<~MESSAGE,
19
- {{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
20
- MESSAGE
21
- },
22
-
23
- create: {
24
- help: <<~HELP,
25
- {{command:%s create php}}: Creates an embedded PHP app.
26
- Usage: {{command:%s create php}}
27
- Options:
28
- {{command:--name=NAME}} App name. Any string.
29
- {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
30
- {{command:--shop-domain=MYSHOPIFYDOMAIN}} Development store URL. Must be an existing development store.
31
- {{command:--type=APPTYPE}} Whether this app is public or custom.
32
- {{command:--verbose}} Output verbose information when installing dependencies.
33
- HELP
34
-
35
- error: {
36
- php_required: <<~VERSION,
37
- PHP is required to create an app project. For installation instructions, visit:
38
- {{underline:https://www.php.net/manual/en/install.php}}
39
- VERSION
40
- php_version_failure: <<~VERSION,
41
- Failed to get the current PHP version. Please make sure it is installed as per the instructions at:
42
- {{underline:https://www.php.net/manual/en/install.php.}}
43
- VERSION
44
- php_version_too_low: "Your PHP version is too low. Please use version %s or higher.",
45
- composer_required: <<~COMPOSER,
46
- Composer is required to create an app project. Download at:
47
- {{underline:https://getcomposer.org/download/}}
48
- COMPOSER
49
- npm_required: "npm is required to create an app project. Download at https://www.npmjs.com/get-npm.",
50
- npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
51
- "the instructions at https://www.npmjs.com/get-npm.",
52
- app_setup: "Failed to set up the app",
53
- },
54
-
55
- php_version: "PHP %s",
56
- npm_version: "npm %s",
57
- app_setting_up: "Setting up app…",
58
- app_set_up: "App is now set up",
59
- },
60
-
61
- open: {
62
- help: <<~HELP,
63
- Open your local development app in the default browser.
64
- Usage: {{command:%s open}}
65
- HELP
66
- },
67
-
68
- deploy: {
69
- help: <<~HELP,
70
- Deploy the current PHP project to a hosting service. Heroku ({{underline:https://www.heroku.com}}) is currently the only option, but more will be added in the future.
71
- Usage: {{command:%s deploy [ heroku ]}}
72
- HELP
73
-
74
- extended_help: <<~HELP,
75
- {{bold:Subcommands:}}
76
- {{cyan:heroku}}: Deploys the current PHP project to Heroku.
77
- Usage: {{command:%s deploy heroku}}
78
- HELP
79
-
80
- heroku: {
81
- help: <<~HELP,
82
- Deploy the current PHP project to Heroku
83
- Usage: {{command:%s deploy heroku}}
84
- HELP
85
-
86
- error: {
87
- generate_app_key: "Failed to generate Laravel APP_KEY",
88
- },
89
-
90
- downloading: "Downloading Heroku CLI…",
91
- downloaded: "Downloaded Heroku CLI",
92
- installing: "Installing Heroku CLI…",
93
- installing_windows: "Running Heroku CLI install wizard…",
94
- installed: "Installed Heroku CLI",
95
- authenticating: "Authenticating with Heroku…",
96
- authenticated: "{{v}} Authenticated with Heroku",
97
- authenticated_with_account: "{{v}} Authenticated with Heroku as `%s`",
98
- deploying: "Deploying to Heroku…",
99
- deployed: "Deployed to Heroku",
100
- post_deploy: <<~DEPLOYED,
101
- {{v}} Deployed to Heroku, you can access your app at {{green:%s}}
102
-
103
- If you're deploying this app for the first time, make sure to set up your database and your app's environment at {{bold:App dashboard -> Settings -> Config Vars}}.
104
-
105
- When setting your config vars, don't forget to set up your database and the appropriate Laravel values for it, particularly {{bold:DB_CONNECTION and DB_DATABASE}}.
106
- DEPLOYED
107
- git: {
108
- checking: "Checking git repo…",
109
- initialized: "Git repo initialized",
110
- what_branch: "What branch would you like to deploy?",
111
- branch_selected: "{{v}} Git branch `%s` selected for deploy",
112
- },
113
- app: {
114
- no_apps_found: "No existing Heroku app found. What would you like to do?",
115
- name: "What is your Heroku app’s name?",
116
- select: "Specify an existing Heroku app",
117
- selecting: "Selecting Heroku app `%s`…",
118
- selected: "{{v}} Heroku app `%s` selected",
119
- create: "Create a new Heroku app",
120
- creating: "Creating new Heroku app…",
121
- created: "{{v}} New Heroku app created",
122
- setting_configs: "Setting Shopify app configs…",
123
- configs_set: "{{v}} Shopify app configs set",
124
- },
125
- },
126
- },
127
-
128
- serve: {
129
- help: <<~HELP,
130
- Start a local development PHP server for your project, as well as a public ngrok tunnel to your localhost.
131
- Usage: {{command:%s serve}}
132
- HELP
133
- extended_help: <<~HELP,
134
- {{bold:Options:}}
135
- {{cyan:--host=HOST}}: Bypass running tunnel and use custom host. HOST must be HTTPS url.
136
- {{cyan:--port=PORT}}: Use custom port.
137
- HELP
138
-
139
- open_info: <<~MESSAGE,
140
- {{*}} To install and start using your app, open this URL in your browser:
141
- {{green:%s}}
142
- MESSAGE
143
- running_server: "Running server…",
144
- },
145
-
146
- tunnel: {
147
- help: <<~HELP,
148
- Start or stop an http tunnel to your local development app using ngrok.
149
- Usage: {{command:%s tunnel [ auth | start | stop ]}}
150
- HELP
151
- extended_help: <<~HELP,
152
- {{bold:Subcommands:}}
153
-
154
- {{cyan:auth}}: Writes an ngrok auth token to ~/.ngrok2/ngrok.yml to connect with an ngrok account. Visit https://dashboard.ngrok.com/signup to sign up.
155
- Usage: {{command:%1$s tunnel auth <token>}}
156
-
157
- {{cyan:start}}: Starts an ngrok tunnel, will print the URL for an existing tunnel if already running.
158
- Usage: {{command:%1$s tunnel start}}
159
-
160
- {{cyan:stop}}: Stops the ngrok tunnel.
161
- Usage: {{command:%1$s tunnel stop}}
162
-
163
- HELP
164
-
165
- error: {
166
- token_argument_missing: "{{x}} {{red:auth requires a token argument}}\n\n",
167
- },
168
- },
169
-
170
11
  forms: {
171
12
  create: {
172
13
  error: {
@@ -5,22 +5,6 @@ module Rails
5
5
  register_messages(Rails::Messages::MESSAGES)
6
6
  end
7
7
 
8
- # define/autoload project specific Commands
9
- class Command < ShopifyCLI::ProjectCommands
10
- subcommand :Connect, "connect", Project.project_filepath("commands/connect")
11
- subcommand :Create, "create", Project.project_filepath("commands/create")
12
- subcommand :Deploy, "deploy", Project.project_filepath("commands/deploy")
13
- subcommand :Generate, "generate", Project.project_filepath("commands/generate")
14
- subcommand :Open, "open", Project.project_filepath("commands/open")
15
- subcommand :Serve, "serve", Project.project_filepath("commands/serve")
16
- subcommand :Tunnel, "tunnel", Project.project_filepath("commands/tunnel")
17
- end
18
- ShopifyCLI::Commands.register("Rails::Command", "rails")
19
-
20
- # define/autoload project specific Tasks
21
- module Tasks
22
- end
23
-
24
8
  # define/autoload project specific Forms
25
9
  module Forms
26
10
  autoload :Create, Project.project_filepath("forms/create")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Rails
3
3
  class Command
4
- class Create < ShopifyCLI::SubCommand
4
+ class Create < ShopifyCLI::Command::AppSubCommand
5
5
  prerequisite_task :ensure_authenticated
6
6
 
7
7
  USER_AGENT_CODE = <<~USERAGENT
@@ -31,8 +31,8 @@ module Rails
31
31
  end
32
32
 
33
33
  def call(args, _name)
34
- form = Forms::Create.ask(@ctx, args, options.flags)
35
- return @ctx.puts(self.class.help) if form.nil?
34
+ form_data = self.form_data(args)
35
+ return @ctx.puts(self.class.help) if form_data.nil?
36
36
 
37
37
  ruby_version = Ruby.version(@ctx)
38
38
  @ctx.abort(@ctx.message("rails.create.error.invalid_ruby_version")) unless
@@ -41,34 +41,61 @@ module Rails
41
41
  check_node
42
42
  check_yarn
43
43
 
44
- build(form.name, form.db)
44
+ build(form_data.name, form_data.db)
45
+
45
46
  set_custom_ua
46
47
  ShopifyCLI::Project.write(
47
48
  @ctx,
48
49
  project_type: "rails",
49
- organization_id: form.organization_id,
50
+ organization_id: form_data.organization_id,
50
51
  )
51
52
 
52
- api_client = ShopifyCLI::Tasks::CreateApiClient.call(
53
- @ctx,
54
- org_id: form.organization_id,
55
- title: form.title,
56
- type: form.type,
57
- )
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
58
70
 
59
71
  ShopifyCLI::Resources::EnvFile.new(
60
72
  api_key: api_client["apiKey"],
61
73
  secret: api_client["apiSecretKeys"].first["secret"],
62
- shop: form.shop_domain,
74
+ shop: form_data.shop_domain,
63
75
  scopes: "write_products,write_customers,write_draft_orders",
64
76
  ).write(@ctx)
65
77
 
66
- partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
78
+ partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form_data.organization_id, api_client["id"])
67
79
 
68
- @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
69
- @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME, "rails"))
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"))
70
82
  unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
71
- @ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
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)
72
99
  end
73
100
  end
74
101