shopify-cli 2.6.6 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) 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/.vscode/extensions.json +5 -0
  6. data/.vscode/settings.json +9 -0
  7. data/CHANGELOG.md +12 -3
  8. data/CONTRIBUTING.md +1 -29
  9. data/{Dockerfile → Codespace.dockerfile} +0 -0
  10. data/Gemfile.lock +4 -4
  11. data/README.md +20 -99
  12. data/Tests.dockerfile +35 -0
  13. data/assets/logo.png +0 -0
  14. data/dev.yml +0 -3
  15. data/docs/README.md +13 -0
  16. data/docs/contributors/testing.md +27 -0
  17. data/docs/users/installation.md +46 -0
  18. data/{THEMEKIT_MIGRATION.md → docs/users/migrate-from-themekit.md} +1 -1
  19. data/lib/project_types/extension/cli.rb +6 -3
  20. data/lib/project_types/extension/commands/create.rb +5 -6
  21. data/lib/project_types/extension/commands/extension_command.rb +1 -1
  22. data/lib/project_types/extension/features/argo_serve.rb +9 -23
  23. data/lib/project_types/extension/forms/questions/ask_template.rb +1 -5
  24. data/lib/project_types/extension/models/development_server_requirements.rb +2 -3
  25. data/lib/project_types/extension/models/server_config/app.rb +13 -0
  26. data/lib/project_types/extension/models/server_config/development.rb +5 -4
  27. data/lib/project_types/extension/models/server_config/development_renderer.rb +1 -1
  28. data/lib/project_types/extension/models/server_config/development_resource.rb +13 -0
  29. data/lib/project_types/extension/models/server_config/extension.rb +3 -1
  30. data/lib/project_types/extension/models/server_config/root.rb +4 -1
  31. data/lib/project_types/extension/tasks/convert_server_config.rb +65 -0
  32. data/lib/project_types/extension/tasks/ensure_resource_url.rb +39 -0
  33. data/lib/project_types/extension/tasks/merge_server_config.rb +32 -0
  34. data/lib/project_types/extension/tasks/run_extension_command.rb +10 -9
  35. data/lib/project_types/node/cli.rb +0 -16
  36. data/lib/project_types/node/forms/create.rb +5 -5
  37. data/lib/project_types/node/messages/messages.rb +2 -144
  38. data/lib/project_types/php/cli.rb +0 -11
  39. data/lib/project_types/php/forms/create.rb +5 -6
  40. data/lib/project_types/php/messages/messages.rb +2 -161
  41. data/lib/project_types/rails/cli.rb +0 -16
  42. data/lib/project_types/rails/commands/create.rb +1 -1
  43. data/lib/project_types/rails/forms/create.rb +5 -6
  44. data/lib/project_types/rails/messages/messages.rb +6 -151
  45. data/lib/project_types/script/cli.rb +1 -1
  46. data/lib/project_types/script/commands/create.rb +1 -1
  47. data/lib/project_types/script/commands/push.rb +1 -1
  48. data/lib/project_types/theme/cli.rb +1 -1
  49. data/lib/project_types/theme/commands/check.rb +1 -1
  50. data/lib/project_types/theme/commands/delete.rb +1 -1
  51. data/lib/project_types/theme/commands/init.rb +1 -1
  52. data/lib/project_types/theme/commands/language_server.rb +1 -1
  53. data/lib/project_types/theme/commands/package.rb +1 -1
  54. data/lib/project_types/theme/commands/publish.rb +1 -1
  55. data/lib/project_types/theme/commands/pull.rb +1 -1
  56. data/lib/project_types/theme/commands/push.rb +1 -1
  57. data/lib/project_types/theme/commands/serve.rb +9 -3
  58. data/lib/project_types/theme/messages/messages.rb +5 -1
  59. data/lib/shopify_cli/admin_api/populate_resource_command.rb +1 -1
  60. data/lib/shopify_cli/api.rb +7 -2
  61. data/lib/shopify_cli/app_type_detector.rb +24 -20
  62. data/lib/shopify_cli/command/app_sub_command.rb +10 -0
  63. data/lib/shopify_cli/command/project_command.rb +18 -0
  64. data/lib/shopify_cli/command/sub_command.rb +19 -0
  65. data/lib/shopify_cli/command.rb +7 -2
  66. data/lib/shopify_cli/commands/app/connect.rb +22 -0
  67. data/lib/shopify_cli/commands/app/create/node.rb +38 -0
  68. data/lib/shopify_cli/commands/app/create/php.rb +36 -0
  69. data/lib/shopify_cli/commands/app/create/rails.rb +40 -0
  70. data/lib/shopify_cli/commands/app/create.rb +28 -0
  71. data/lib/shopify_cli/commands/app/deploy.rb +49 -0
  72. data/lib/shopify_cli/commands/app/open.rb +19 -0
  73. data/lib/shopify_cli/commands/app/serve.rb +49 -0
  74. data/lib/shopify_cli/commands/app/tunnel.rb +43 -0
  75. data/lib/shopify_cli/commands/app.rb +29 -0
  76. data/lib/shopify_cli/commands/config.rb +2 -2
  77. data/lib/shopify_cli/commands.rb +1 -0
  78. data/lib/shopify_cli/constants.rb +4 -0
  79. data/lib/shopify_cli/exception_reporter.rb +3 -4
  80. data/lib/shopify_cli/git.rb +12 -1
  81. data/lib/shopify_cli/github/issue_url_generator.rb +19 -0
  82. data/lib/shopify_cli/github.rb +5 -0
  83. data/lib/shopify_cli/messages/messages.rb +252 -8
  84. data/lib/shopify_cli/project.rb +5 -1
  85. data/lib/shopify_cli/project_commands.rb +1 -1
  86. data/lib/shopify_cli/services/app/connect_service.rb +25 -0
  87. data/lib/shopify_cli/services/app/create/node_service.rb +153 -0
  88. data/lib/shopify_cli/services/app/create/php_service.rb +152 -0
  89. data/lib/shopify_cli/services/app/create/rails_service.rb +213 -0
  90. data/lib/shopify_cli/services/app/deploy/heroku/node_service.rb +101 -0
  91. data/lib/shopify_cli/services/app/deploy/heroku/php_service.rb +135 -0
  92. data/lib/shopify_cli/services/app/deploy/heroku/rails_service.rb +120 -0
  93. data/lib/shopify_cli/services/app/open_service.rb +19 -0
  94. data/lib/shopify_cli/services/app/serve/node_service.rb +42 -0
  95. data/lib/shopify_cli/services/app/serve/php_service.rb +46 -0
  96. data/lib/shopify_cli/services/app/serve/rails_service.rb +48 -0
  97. data/lib/shopify_cli/services/app/tunnel/auth_service.rb +21 -0
  98. data/lib/shopify_cli/services/app/tunnel/start_service.rb +20 -0
  99. data/lib/shopify_cli/services/app/tunnel/stop_service.rb +20 -0
  100. data/lib/shopify_cli/services.rb +31 -0
  101. data/lib/shopify_cli/theme/dev_server/local_assets.rb +1 -1
  102. data/lib/shopify_cli/theme/dev_server.rb +8 -2
  103. data/lib/shopify_cli/version.rb +1 -1
  104. data/lib/shopify_cli.rb +1 -2
  105. data/shopify-cli.gemspec +1 -1
  106. data/shopify-dev +18 -0
  107. data/utilities/constants.rb +7 -0
  108. data/utilities/docker/container.rb +10 -3
  109. data/utilities/docker.rb +2 -2
  110. data/utilities/utilities.rb +1 -0
  111. metadata +49 -48
  112. data/docs/_config.yml +0 -2
  113. data/docs/app/node/commands/index.md +0 -4
  114. data/docs/app/node/index.md +0 -4
  115. data/docs/app/rails/commands/index.md +0 -4
  116. data/docs/app/rails/index.md +0 -4
  117. data/docs/core/index.md +0 -4
  118. data/docs/getting-started/index.md +0 -4
  119. data/docs/getting-started/install/index.md +0 -4
  120. data/docs/getting-started/migrate/index.md +0 -4
  121. data/docs/getting-started/uninstall/index.md +0 -4
  122. data/docs/getting-started/upgrade/index.md +0 -4
  123. data/docs/help/start-app/index.md +0 -4
  124. data/docs/index.md +0 -4
  125. data/install.sh +0 -7
  126. data/lib/project_types/extension/tasks/converters/server_config_converter.rb +0 -30
  127. data/lib/project_types/extension/tasks/load_server_config.rb +0 -28
  128. data/lib/project_types/node/commands/connect.rb +0 -21
  129. data/lib/project_types/node/commands/create.rb +0 -125
  130. data/lib/project_types/node/commands/deploy/heroku.rb +0 -96
  131. data/lib/project_types/node/commands/deploy.rb +0 -32
  132. data/lib/project_types/node/commands/generate.rb +0 -22
  133. data/lib/project_types/node/commands/open.rb +0 -18
  134. data/lib/project_types/node/commands/serve.rb +0 -45
  135. data/lib/project_types/node/commands/tunnel.rb +0 -41
  136. data/lib/project_types/php/commands/connect.rb +0 -19
  137. data/lib/project_types/php/commands/create.rb +0 -143
  138. data/lib/project_types/php/commands/deploy/heroku.rb +0 -129
  139. data/lib/project_types/php/commands/deploy.rb +0 -32
  140. data/lib/project_types/php/commands/open.rb +0 -16
  141. data/lib/project_types/php/commands/serve.rb +0 -48
  142. data/lib/project_types/php/commands/tunnel.rb +0 -37
  143. data/lib/project_types/rails/commands/connect.rb +0 -21
  144. data/lib/project_types/rails/commands/deploy/heroku.rb +0 -115
  145. data/lib/project_types/rails/commands/deploy.rb +0 -32
  146. data/lib/project_types/rails/commands/generate/webhook.rb +0 -42
  147. data/lib/project_types/rails/commands/generate.rb +0 -60
  148. data/lib/project_types/rails/commands/open.rb +0 -18
  149. data/lib/project_types/rails/commands/serve.rb +0 -51
  150. data/lib/project_types/rails/commands/tunnel.rb +0 -41
  151. data/lib/shopify_cli/sub_command.rb +0 -17
  152. data/shopify.fish +0 -12
  153. data/shopify.sh +0 -11
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
- require "yaml"
4
-
5
- module Extension
6
- module Tasks
7
- class LoadServerConfig < ShopifyCLI::Task
8
- include SmartProperties
9
-
10
- class << self
11
- def call(file_name:, type:)
12
- config = YAML.load_file(file_name)
13
- project = ExtensionProject.current
14
- Tasks::Converters::ServerConfigConverter.from_hash(
15
- hash: config,
16
- type: type,
17
- registration_uuid: project.registration_uuid
18
- )
19
- rescue Psych::SyntaxError => e
20
- raise(
21
- ShopifyCLI::Abort,
22
- ShopifyCLI::Context.message("core.yaml.error.invalid", file_name, e.message)
23
- )
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
- module Node
3
- class Command
4
- class Connect < ShopifyCLI::SubCommand
5
- prerequisite_task ensure_project_type: :node
6
-
7
- def call(*)
8
- if ShopifyCLI::Project.has_current? && ShopifyCLI::Project.current.env
9
- @ctx.puts(@ctx.message("node.connect.production_warning"))
10
- end
11
-
12
- app = ShopifyCLI::Connect.new(@ctx).default_connect("node")
13
- @ctx.done(@ctx.message("node.connect.connected", app))
14
- end
15
-
16
- def self.help
17
- ShopifyCLI::Context.message("node.connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
18
- end
19
- end
20
- end
21
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
- module Node
3
- class Command
4
- class Create < ShopifyCLI::SubCommand
5
- prerequisite_task :ensure_authenticated
6
-
7
- options do |parser, flags|
8
- # backwards compatibility allow 'title' for now
9
- parser.on("--title=TITLE") { |t| flags[:title] = t }
10
- parser.on("--name=NAME") { |t| flags[:title] = t }
11
- parser.on("--organization_id=ID") { |id| flags[:organization_id] = id }
12
- parser.on("--organization-id=ID") { |id| flags[:organization_id] = id }
13
- parser.on("--store=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
14
- # backwards compatibility allow 'shop domain' for now
15
- parser.on("--shop_domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
16
- parser.on("--shop-domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
17
- parser.on("--type=APPTYPE") { |type| flags[:type] = type }
18
- parser.on("--verbose") { flags[:verbose] = true }
19
- end
20
-
21
- def call(args, _name)
22
- form = Forms::Create.ask(@ctx, args, options.flags)
23
- return @ctx.puts(self.class.help) if form.nil?
24
-
25
- check_node
26
- check_npm
27
- build(form.name)
28
-
29
- ShopifyCLI::Project.write(
30
- @ctx,
31
- project_type: "node",
32
- organization_id: form.organization_id,
33
- )
34
-
35
- api_client = ShopifyCLI::Tasks::CreateApiClient.call(
36
- @ctx,
37
- org_id: form.organization_id,
38
- title: form.title,
39
- type: form.type,
40
- )
41
-
42
- ShopifyCLI::Resources::EnvFile.new(
43
- api_key: api_client["apiKey"],
44
- secret: api_client["apiSecretKeys"].first["secret"],
45
- shop: form.shop_domain,
46
- scopes: "write_products,write_customers,write_draft_orders",
47
- ).write(@ctx)
48
-
49
- partners_url = ShopifyCLI::PartnersAPI.partners_url_for(form.organization_id, api_client["id"])
50
-
51
- @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
52
- @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCLI::TOOL_NAME, "node"))
53
- unless ShopifyCLI::Shopifolk.acting_as_shopify_organization?
54
- @ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
55
- end
56
- end
57
-
58
- def self.help
59
- ShopifyCLI::Context.message("node.create.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
60
- end
61
-
62
- private
63
-
64
- def check_node
65
- cmd_path = @ctx.which("node")
66
- @ctx.abort(@ctx.message("node.create.error.node_required")) if cmd_path.nil?
67
-
68
- version, stat = @ctx.capture2e("node", "-v")
69
- @ctx.abort(@ctx.message("node.create.error.node_version_failure")) unless stat.success?
70
-
71
- @ctx.done(@ctx.message("node.create.node_version", version))
72
- end
73
-
74
- def check_npm
75
- cmd_path = @ctx.which("npm")
76
- @ctx.abort(@ctx.message("node.create.error.npm_required")) if cmd_path.nil?
77
-
78
- version, stat = @ctx.capture2e("npm", "-v")
79
- @ctx.abort(@ctx.message("node.create.error.npm_version_failure")) unless stat.success?
80
-
81
- @ctx.done(@ctx.message("node.create.npm_version", version))
82
- end
83
-
84
- def set_npm_config
85
- # check available npmrc (either user or system) for production registry
86
- registry, _ = @ctx.capture2("npm config get @shopify:registry")
87
- return if registry.include?("https://registry.yarnpkg.com")
88
-
89
- # available npmrc doesn't have production registry =>
90
- # set a project-based .npmrc
91
- @ctx.system(
92
- "npm",
93
- "--userconfig",
94
- "./.npmrc",
95
- "config",
96
- "set",
97
- "@shopify:registry",
98
- "https://registry.yarnpkg.com",
99
- chdir: @ctx.root
100
- )
101
- end
102
-
103
- def build(name)
104
- ShopifyCLI::Git.clone("https://github.com/Shopify/shopify-app-node.git", name)
105
-
106
- @ctx.root = File.join(@ctx.root, name)
107
-
108
- set_npm_config
109
- ShopifyCLI::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
110
-
111
- begin
112
- @ctx.rm_r(".git")
113
- @ctx.rm_r(".github")
114
- @ctx.rm(File.join("server", "handlers", "client.js"))
115
- @ctx.rename(
116
- File.join("server", "handlers", "client.cli.js"),
117
- File.join("server", "handlers", "client.js")
118
- )
119
- rescue Errno::ENOENT => e
120
- @ctx.debug(e)
121
- end
122
- end
123
- end
124
- end
125
- end
@@ -1,96 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Node
5
- class Command
6
- class Deploy
7
- class Heroku
8
- def self.help
9
- ShopifyCLI::Context.message("node.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("node.deploy.heroku.downloading")) do |spinner|
17
- heroku_service.download
18
- spinner.update_title(ctx.message("node.deploy.heroku.downloaded"))
19
- end
20
- spin_group.wait
21
-
22
- install_message = ctx.message(
23
- ctx.windows? ? "node.deploy.heroku.installing_windows" : "node.deploy.heroku.installing"
24
- )
25
- spin_group.add(install_message) do |spinner|
26
- heroku_service.install
27
- spinner.update_title(ctx.message("node.deploy.heroku.installed"))
28
- end
29
- spin_group.wait
30
-
31
- spin_group.add(ctx.message("node.deploy.heroku.git.checking")) do |spinner|
32
- ShopifyCLI::Git.init(ctx)
33
- spinner.update_title(ctx.message("node.deploy.heroku.git.initialized"))
34
- end
35
- spin_group.wait
36
-
37
- if (account = heroku_service.whoami)
38
- ctx.puts(ctx.message("node.deploy.heroku.authenticated_with_account", account))
39
- else
40
- CLI::UI::Frame.open(
41
- ctx.message("node.deploy.heroku.authenticating"),
42
- success_text: ctx.message("node.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("node.deploy.heroku.app.selected", app_name))
50
- else
51
- app_type = CLI::UI::Prompt.ask(ctx.message("node.deploy.heroku.app.no_apps_found")) do |handler|
52
- handler.option(ctx.message("node.deploy.heroku.app.create")) { :new }
53
- handler.option(ctx.message("node.deploy.heroku.app.select")) { :existing }
54
- end
55
-
56
- if app_type == :existing
57
- app_name = CLI::UI::Prompt.ask(ctx.message("node.deploy.heroku.app.name"))
58
- CLI::UI::Frame.open(
59
- ctx.message("node.deploy.heroku.app.selecting", app_name),
60
- success_text: ctx.message("node.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("node.deploy.heroku.app.creating"),
67
- success_text: ctx.message("node.deploy.heroku.app.created")
68
- ) do
69
- heroku_service.create_new_app
70
- end
71
- end
72
- end
73
-
74
- branches = ShopifyCLI::Git.branches(ctx)
75
- if branches.length == 1
76
- branch_to_deploy = branches[0]
77
- ctx.puts(ctx.message("node.deploy.heroku.git.branch_selected", branch_to_deploy))
78
- else
79
- branch_to_deploy = CLI::UI::Prompt.ask(ctx.message("node.deploy.heroku.git.what_branch")) do |handler|
80
- branches.each do |branch|
81
- handler.option(branch) { branch }
82
- end
83
- end
84
- end
85
-
86
- CLI::UI::Frame.open(
87
- ctx.message("node.deploy.heroku.deploying"),
88
- success_text: ctx.message("node.deploy.heroku.deployed")
89
- ) do
90
- heroku_service.deploy(branch_to_deploy)
91
- end
92
- end
93
- end
94
- end
95
- end
96
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Node
5
- class Command
6
- class Deploy < ShopifyCLI::SubCommand
7
- prerequisite_task ensure_project_type: :node
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
- Node::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("node.deploy.help", ShopifyCLI::TOOL_NAME)
25
- end
26
-
27
- def self.extended_help
28
- ShopifyCLI::Context.message("node.deploy.extended_help", ShopifyCLI::TOOL_NAME)
29
- end
30
- end
31
- end
32
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
- require "shopify_cli"
3
-
4
- module Node
5
- class Command
6
- class Generate < ShopifyCLI::SubCommand
7
- prerequisite_task ensure_project_type: :node
8
-
9
- def call(*)
10
- @ctx.puts(self.class.help)
11
- end
12
-
13
- def self.help
14
- ShopifyCLI::Context.message("node.generate.help")
15
- end
16
-
17
- def self.extended_help
18
- help
19
- end
20
- end
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- require "shopify_cli"
2
-
3
- module Node
4
- class Command
5
- class Open < ShopifyCLI::SubCommand
6
- prerequisite_task ensure_project_type: :node
7
-
8
- def call(*)
9
- project = ShopifyCLI::Project.current
10
- @ctx.open_url!("#{project.env.host}/auth?shop=#{project.env.shop}")
11
- end
12
-
13
- def self.help
14
- ShopifyCLI::Context.message("node.open.help", ShopifyCLI::TOOL_NAME)
15
- end
16
- end
17
- end
18
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
- module Node
3
- class Command
4
- class Serve < ShopifyCLI::SubCommand
5
- include ShopifyCLI::CommandOptions::CommandServeOptions
6
-
7
- prerequisite_task ensure_project_type: :node
8
- prerequisite_task :ensure_env, :ensure_dev_store
9
-
10
- parse_host_option
11
- parse_port_option
12
-
13
- def call(*)
14
- project = ShopifyCLI::Project.current
15
- tunnel_port = port.to_s
16
- url = host || ShopifyCLI::Tunnel.start(@ctx, port: tunnel_port)
17
- project.env.update(@ctx, :host, url)
18
- ShopifyCLI::Tasks::UpdateDashboardURLS.call(
19
- @ctx,
20
- url: url,
21
- callback_url: "/auth/callback",
22
- )
23
-
24
- if project.env.shop
25
- project_url = "#{project.env.host}/auth?shop=#{project.env.shop}"
26
- @ctx.puts("\n" + @ctx.message("node.serve.open_info", project_url) + "\n")
27
- end
28
-
29
- CLI::UI::Frame.open(@ctx.message("node.serve.running_server")) do
30
- env = project.env.to_h
31
- env["PORT"] = tunnel_port
32
- @ctx.system("npm run dev", env: env)
33
- end
34
- end
35
-
36
- def self.help
37
- ShopifyCLI::Context.message("node.serve.help", ShopifyCLI::TOOL_NAME)
38
- end
39
-
40
- def self.extended_help
41
- ShopifyCLI::Context.message("node.serve.extended_help")
42
- end
43
- end
44
- end
45
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "shopify_cli"
4
-
5
- module Node
6
- class Command
7
- class Tunnel < ShopifyCLI::SubCommand
8
- # subcommands :auth, :start, :stop
9
-
10
- prerequisite_task ensure_project_type: :node
11
-
12
- def call(args, _name)
13
- subcommand = args.shift
14
- case subcommand
15
- when "auth"
16
- token = args.shift
17
- if token.nil?
18
- @ctx.puts(@ctx.message("node.tunnel.error.token_argument_missing"))
19
- @ctx.puts("#{self.class.help}\n#{self.class.extended_help}")
20
- else
21
- ShopifyCLI::Tunnel.auth(@ctx, token)
22
- end
23
- when "start"
24
- ShopifyCLI::Tunnel.start(@ctx)
25
- when "stop"
26
- ShopifyCLI::Tunnel.stop(@ctx)
27
- else
28
- @ctx.puts(self.class.help)
29
- end
30
- end
31
-
32
- def self.help
33
- ShopifyCLI::Context.message("node.tunnel.help", ShopifyCLI::TOOL_NAME)
34
- end
35
-
36
- def self.extended_help
37
- ShopifyCLI::Context.message("node.tunnel.extended_help", ShopifyCLI::TOOL_NAME)
38
- end
39
- end
40
- end
41
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
- module PHP
3
- class Command
4
- class Connect < ShopifyCLI::SubCommand
5
- def call(*)
6
- if ShopifyCLI::Project.has_current? && ShopifyCLI::Project.current.env
7
- @ctx.puts(@ctx.message("php.connect.production_warning"))
8
- end
9
-
10
- app = ShopifyCLI::Connect.new(@ctx).default_connect("php")
11
- @ctx.done(@ctx.message("php.connect.connected", app))
12
- end
13
-
14
- def self.help
15
- ShopifyCLI::Context.message("php.connect.help", ShopifyCLI::TOOL_NAME, ShopifyCLI::TOOL_NAME)
16
- end
17
- end
18
- end
19
- end
@@ -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