shopify-cli 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. checksums.yaml +7 -0
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/CODE_OF_CONDUCT.md +73 -0
  4. data/.github/CONTRIBUTING.md +51 -0
  5. data/.github/DESIGN.md +153 -0
  6. data/.github/ISSUE_TEMPLATE.md +38 -0
  7. data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
  8. data/.github/probots.yml +3 -0
  9. data/.gitignore +19 -0
  10. data/.rubocop.yml +47 -0
  11. data/.ruby-version +1 -0
  12. data/.travis.yml +12 -0
  13. data/Gemfile +22 -0
  14. data/Gemfile.lock +77 -0
  15. data/LICENSE.md +7 -0
  16. data/README.md +13 -0
  17. data/Rakefile +101 -0
  18. data/SECURITY.md +59 -0
  19. data/Vagrantfile +17 -0
  20. data/bin/load_shopify.rb +20 -0
  21. data/bin/shopify +32 -0
  22. data/dev.yml +17 -0
  23. data/docs/Gemfile +5 -0
  24. data/docs/Gemfile.lock +248 -0
  25. data/docs/_config.yml +16 -0
  26. data/docs/_data/nav.yml +26 -0
  27. data/docs/_includes/footer.html +15 -0
  28. data/docs/_includes/head.html +19 -0
  29. data/docs/_includes/sidebar_nav.html +22 -0
  30. data/docs/_includes/toc.html +112 -0
  31. data/docs/_layouts/default.html +79 -0
  32. data/docs/app/node/commands/index.md +82 -0
  33. data/docs/app/node/index.md +35 -0
  34. data/docs/app/rails/commands/index.md +80 -0
  35. data/docs/app/rails/index.md +36 -0
  36. data/docs/core/index.md +70 -0
  37. data/docs/css/docs.css +157 -0
  38. data/docs/getting-started/index.md +61 -0
  39. data/docs/help/start-app/index.md +6 -0
  40. data/docs/images/header.png +0 -0
  41. data/docs/index.md +27 -0
  42. data/docs/installing-ruby.md +28 -0
  43. data/ext/shopify-cli/extconf.rb +27 -0
  44. data/install.sh +7 -0
  45. data/lib/docgen/class_template.md.erb +81 -0
  46. data/lib/docgen/index_template.md.erb +5 -0
  47. data/lib/docgen/markdown.rb +101 -0
  48. data/lib/graphql/admin_introspection.graphql +87 -0
  49. data/lib/graphql/all_organizations.graphql +19 -0
  50. data/lib/graphql/all_orgs_with_apps.graphql +30 -0
  51. data/lib/graphql/api_versions.graphql +6 -0
  52. data/lib/graphql/convert_dev_to_test_store.graphql +10 -0
  53. data/lib/graphql/create_app.graphql +20 -0
  54. data/lib/graphql/create_customer.graphql +9 -0
  55. data/lib/graphql/create_draft_order.graphql +8 -0
  56. data/lib/graphql/create_product.graphql +9 -0
  57. data/lib/graphql/extension_create.graphql +21 -0
  58. data/lib/graphql/extension_update_draft.graphql +18 -0
  59. data/lib/graphql/find_organization.graphql +17 -0
  60. data/lib/graphql/get_app_urls.graphql +6 -0
  61. data/lib/graphql/update_dashboard_urls.graphql +8 -0
  62. data/lib/project_types/extension/cli.rb +71 -0
  63. data/lib/project_types/extension/commands/build.rb +29 -0
  64. data/lib/project_types/extension/commands/create.rb +49 -0
  65. data/lib/project_types/extension/commands/extension_command.rb +22 -0
  66. data/lib/project_types/extension/commands/push.rb +69 -0
  67. data/lib/project_types/extension/commands/register.rb +78 -0
  68. data/lib/project_types/extension/commands/serve.rb +24 -0
  69. data/lib/project_types/extension/commands/tunnel.rb +69 -0
  70. data/lib/project_types/extension/extension_project.rb +85 -0
  71. data/lib/project_types/extension/extension_project_keys.rb +10 -0
  72. data/lib/project_types/extension/features/argo.rb +48 -0
  73. data/lib/project_types/extension/features/argo_dependencies.rb +28 -0
  74. data/lib/project_types/extension/features/argo_setup.rb +54 -0
  75. data/lib/project_types/extension/features/argo_setup_step.rb +31 -0
  76. data/lib/project_types/extension/features/argo_setup_steps.rb +53 -0
  77. data/lib/project_types/extension/features/tunnel_url.rb +20 -0
  78. data/lib/project_types/extension/forms/create.rb +52 -0
  79. data/lib/project_types/extension/forms/register.rb +48 -0
  80. data/lib/project_types/extension/messages/message_loading.rb +37 -0
  81. data/lib/project_types/extension/messages/messages.rb +126 -0
  82. data/lib/project_types/extension/models/app.rb +14 -0
  83. data/lib/project_types/extension/models/registration.rb +19 -0
  84. data/lib/project_types/extension/models/type.rb +76 -0
  85. data/lib/project_types/extension/models/types/checkout_post_purchase.rb +20 -0
  86. data/lib/project_types/extension/models/types/subscription_management.rb +20 -0
  87. data/lib/project_types/extension/models/validation_error.rb +17 -0
  88. data/lib/project_types/extension/models/version.rb +15 -0
  89. data/lib/project_types/extension/tasks/converters/registration_converter.rb +26 -0
  90. data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +25 -0
  91. data/lib/project_types/extension/tasks/converters/version_converter.rb +28 -0
  92. data/lib/project_types/extension/tasks/create_extension.rb +31 -0
  93. data/lib/project_types/extension/tasks/get_apps.rb +34 -0
  94. data/lib/project_types/extension/tasks/update_draft.rb +29 -0
  95. data/lib/project_types/extension/tasks/user_errors.rb +45 -0
  96. data/lib/project_types/node/cli.rb +37 -0
  97. data/lib/project_types/node/commands/create.rb +117 -0
  98. data/lib/project_types/node/commands/deploy.rb +22 -0
  99. data/lib/project_types/node/commands/deploy/heroku.rb +91 -0
  100. data/lib/project_types/node/commands/generate.rb +51 -0
  101. data/lib/project_types/node/commands/generate/billing.rb +37 -0
  102. data/lib/project_types/node/commands/generate/page.rb +55 -0
  103. data/lib/project_types/node/commands/generate/webhook.rb +33 -0
  104. data/lib/project_types/node/commands/open.rb +16 -0
  105. data/lib/project_types/node/commands/populate.rb +23 -0
  106. data/lib/project_types/node/commands/populate/customer.rb +31 -0
  107. data/lib/project_types/node/commands/populate/draft_order.rb +28 -0
  108. data/lib/project_types/node/commands/populate/product.rb +30 -0
  109. data/lib/project_types/node/commands/serve.rb +45 -0
  110. data/lib/project_types/node/commands/tunnel.rb +39 -0
  111. data/lib/project_types/node/forms/create.rb +87 -0
  112. data/lib/project_types/node/messages/messages.rb +260 -0
  113. data/lib/project_types/rails/cli.rb +41 -0
  114. data/lib/project_types/rails/commands/create.rb +126 -0
  115. data/lib/project_types/rails/commands/deploy.rb +22 -0
  116. data/lib/project_types/rails/commands/deploy/heroku.rb +113 -0
  117. data/lib/project_types/rails/commands/generate.rb +49 -0
  118. data/lib/project_types/rails/commands/generate/webhook.rb +39 -0
  119. data/lib/project_types/rails/commands/open.rb +16 -0
  120. data/lib/project_types/rails/commands/populate.rb +23 -0
  121. data/lib/project_types/rails/commands/populate/customer.rb +31 -0
  122. data/lib/project_types/rails/commands/populate/draft_order.rb +28 -0
  123. data/lib/project_types/rails/commands/populate/product.rb +30 -0
  124. data/lib/project_types/rails/commands/serve.rb +47 -0
  125. data/lib/project_types/rails/commands/tunnel.rb +39 -0
  126. data/lib/project_types/rails/forms/create.rb +116 -0
  127. data/lib/project_types/rails/gem.rb +56 -0
  128. data/lib/project_types/rails/messages/messages.rb +283 -0
  129. data/lib/project_types/rails/ruby.rb +17 -0
  130. data/lib/project_types/script/cli.rb +76 -0
  131. data/lib/project_types/script/commands/create.rb +45 -0
  132. data/lib/project_types/script/commands/disable.rb +36 -0
  133. data/lib/project_types/script/commands/enable.rb +46 -0
  134. data/lib/project_types/script/commands/push.rb +39 -0
  135. data/lib/project_types/script/config/extension_points.yml +18 -0
  136. data/lib/project_types/script/errors.rb +16 -0
  137. data/lib/project_types/script/forms/create.rb +29 -0
  138. data/lib/project_types/script/forms/enable.rb +24 -0
  139. data/lib/project_types/script/forms/push.rb +19 -0
  140. data/lib/project_types/script/forms/script_form.rb +66 -0
  141. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +27 -0
  142. data/lib/project_types/script/graphql/script_service_proxy.graphql +8 -0
  143. data/lib/project_types/script/graphql/shop_script_delete.graphql +14 -0
  144. data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +28 -0
  145. data/lib/project_types/script/layers/application/build_script.rb +43 -0
  146. data/lib/project_types/script/layers/application/create_script.rb +47 -0
  147. data/lib/project_types/script/layers/application/disable_script.rb +19 -0
  148. data/lib/project_types/script/layers/application/enable_script.rb +21 -0
  149. data/lib/project_types/script/layers/application/extension_points.rb +17 -0
  150. data/lib/project_types/script/layers/application/project_dependencies.rb +34 -0
  151. data/lib/project_types/script/layers/application/push_script.rb +30 -0
  152. data/lib/project_types/script/layers/domain/errors.rb +25 -0
  153. data/lib/project_types/script/layers/domain/extension_point.rb +29 -0
  154. data/lib/project_types/script/layers/domain/push_package.rb +29 -0
  155. data/lib/project_types/script/layers/domain/script.rb +18 -0
  156. data/lib/project_types/script/layers/infrastructure/assemblyscript_dependency_manager.rb +73 -0
  157. data/lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb +38 -0
  158. data/lib/project_types/script/layers/infrastructure/assemblyscript_wasm_builder.rb +39 -0
  159. data/lib/project_types/script/layers/infrastructure/dependency_manager.rb +36 -0
  160. data/lib/project_types/script/layers/infrastructure/errors.rb +38 -0
  161. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +31 -0
  162. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +47 -0
  163. data/lib/project_types/script/layers/infrastructure/script_builder.rb +34 -0
  164. data/lib/project_types/script/layers/infrastructure/script_repository.rb +89 -0
  165. data/lib/project_types/script/layers/infrastructure/script_service.rb +165 -0
  166. data/lib/project_types/script/layers/infrastructure/test_suite_repository.rb +59 -0
  167. data/lib/project_types/script/messages/messages.rb +204 -0
  168. data/lib/project_types/script/script_project.rb +37 -0
  169. data/lib/project_types/script/templates/ts/as-pect.config.js +21 -0
  170. data/lib/project_types/script/ui/error_handler.rb +136 -0
  171. data/lib/project_types/script/ui/strict_spinner.rb +22 -0
  172. data/lib/rubygems_plugin.rb +18 -0
  173. data/lib/shopify-cli/admin_api.rb +99 -0
  174. data/lib/shopify-cli/admin_api/populate_resource_command.rb +165 -0
  175. data/lib/shopify-cli/admin_api/schema.rb +32 -0
  176. data/lib/shopify-cli/api.rb +104 -0
  177. data/lib/shopify-cli/command.rb +67 -0
  178. data/lib/shopify-cli/commands.rb +28 -0
  179. data/lib/shopify-cli/commands/connect.rb +108 -0
  180. data/lib/shopify-cli/commands/create.rb +50 -0
  181. data/lib/shopify-cli/commands/help.rb +79 -0
  182. data/lib/shopify-cli/commands/logout.rb +23 -0
  183. data/lib/shopify-cli/commands/system.rb +135 -0
  184. data/lib/shopify-cli/commands/version.rb +15 -0
  185. data/lib/shopify-cli/context.rb +372 -0
  186. data/lib/shopify-cli/core.rb +9 -0
  187. data/lib/shopify-cli/core/entry_point.rb +40 -0
  188. data/lib/shopify-cli/core/executor.rb +21 -0
  189. data/lib/shopify-cli/core/help_resolver.rb +20 -0
  190. data/lib/shopify-cli/core/monorail.rb +118 -0
  191. data/lib/shopify-cli/db.rb +114 -0
  192. data/lib/shopify-cli/form.rb +40 -0
  193. data/lib/shopify-cli/git.rb +141 -0
  194. data/lib/shopify-cli/helpers.rb +5 -0
  195. data/lib/shopify-cli/helpers/haikunator.rb +92 -0
  196. data/lib/shopify-cli/heroku.rb +97 -0
  197. data/lib/shopify-cli/js_deps.rb +110 -0
  198. data/lib/shopify-cli/js_system.rb +98 -0
  199. data/lib/shopify-cli/messages/messages.rb +287 -0
  200. data/lib/shopify-cli/oauth.rb +192 -0
  201. data/lib/shopify-cli/oauth/servlet.rb +61 -0
  202. data/lib/shopify-cli/options.rb +40 -0
  203. data/lib/shopify-cli/packager.rb +116 -0
  204. data/lib/shopify-cli/partners_api.rb +114 -0
  205. data/lib/shopify-cli/partners_api/organizations.rb +32 -0
  206. data/lib/shopify-cli/process_supervision.rb +187 -0
  207. data/lib/shopify-cli/project.rb +191 -0
  208. data/lib/shopify-cli/project_type.rb +83 -0
  209. data/lib/shopify-cli/resources.rb +5 -0
  210. data/lib/shopify-cli/resources/env_file.rb +96 -0
  211. data/lib/shopify-cli/sub_command.rb +15 -0
  212. data/lib/shopify-cli/task.rb +10 -0
  213. data/lib/shopify-cli/tasks.rb +32 -0
  214. data/lib/shopify-cli/tasks/create_api_client.rb +29 -0
  215. data/lib/shopify-cli/tasks/ensure_dev_store.rb +41 -0
  216. data/lib/shopify-cli/tasks/ensure_env.rb +31 -0
  217. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +20 -0
  218. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +44 -0
  219. data/lib/shopify-cli/tunnel.rb +154 -0
  220. data/lib/shopify-cli/version.rb +3 -0
  221. data/lib/shopify_cli.rb +132 -0
  222. data/shopify-cli.gemspec +40 -0
  223. data/shopify.fish +12 -0
  224. data/shopify.sh +11 -0
  225. data/vendor/deps/cli-kit/REVISION +1 -0
  226. data/vendor/deps/cli-kit/lib/cli/kit.rb +60 -0
  227. data/vendor/deps/cli-kit/lib/cli/kit/autocall.rb +21 -0
  228. data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +49 -0
  229. data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +94 -0
  230. data/vendor/deps/cli-kit/lib/cli/kit/config.rb +133 -0
  231. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +115 -0
  232. data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +81 -0
  233. data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +102 -0
  234. data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +82 -0
  235. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +76 -0
  236. data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +60 -0
  237. data/vendor/deps/cli-kit/lib/cli/kit/ruby_backports/enumerable.rb +6 -0
  238. data/vendor/deps/cli-kit/lib/cli/kit/support.rb +9 -0
  239. data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +244 -0
  240. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +207 -0
  241. data/vendor/deps/cli-kit/lib/cli/kit/util.rb +189 -0
  242. data/vendor/deps/cli-kit/lib/cli/kit/version.rb +5 -0
  243. data/vendor/deps/cli-ui/REVISION +1 -0
  244. data/vendor/deps/cli-ui/lib/cli/ui.rb +187 -0
  245. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +153 -0
  246. data/vendor/deps/cli-ui/lib/cli/ui/box.rb +15 -0
  247. data/vendor/deps/cli-ui/lib/cli/ui/color.rb +79 -0
  248. data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +179 -0
  249. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +310 -0
  250. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +78 -0
  251. data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +88 -0
  252. data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +248 -0
  253. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +472 -0
  254. data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +24 -0
  255. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +48 -0
  256. data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +40 -0
  257. data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +241 -0
  258. data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +227 -0
  259. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +36 -0
  260. data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +102 -0
  261. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +5 -0
  262. data/vendor/deps/smart_properties/REVISION +1 -0
  263. data/vendor/deps/smart_properties/lib/smart_properties.rb +174 -0
  264. data/vendor/deps/smart_properties/lib/smart_properties/errors.rb +114 -0
  265. data/vendor/deps/smart_properties/lib/smart_properties/property.rb +162 -0
  266. data/vendor/deps/smart_properties/lib/smart_properties/property_collection.rb +83 -0
  267. data/vendor/deps/smart_properties/lib/smart_properties/validations.rb +8 -0
  268. data/vendor/deps/smart_properties/lib/smart_properties/validations/ancestor.rb +27 -0
  269. data/vendor/deps/smart_properties/lib/smart_properties/version.rb +3 -0
  270. data/vendor/lib/semantic/LICENSE +20 -0
  271. data/vendor/lib/semantic/semantic.rb +4 -0
  272. data/vendor/lib/semantic/version.rb +180 -0
  273. metadata +374 -0
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+ module Node
3
+ module Commands
4
+ class Create < ShopifyCli::SubCommand
5
+ options do |parser, flags|
6
+ # backwards compatibility allow 'title' for now
7
+ parser.on('--title=TITLE') { |t| flags[:title] = t }
8
+ parser.on('--name=NAME') { |t| flags[:title] = t }
9
+ parser.on('--organization_id=ID') { |url| flags[:organization_id] = url }
10
+ parser.on('--shop_domain=MYSHOPIFYDOMAIN') { |url| flags[:shop_domain] = url }
11
+ parser.on('--type=APPTYPE') { |url| flags[:type] = url }
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_node
20
+ check_npm
21
+ build(form.name)
22
+
23
+ ShopifyCli::Project.write(
24
+ @ctx,
25
+ project_type: 'node',
26
+ organization_id: form.organization_id,
27
+ )
28
+
29
+ api_client = ShopifyCli::Tasks::CreateApiClient.call(
30
+ @ctx,
31
+ org_id: form.organization_id,
32
+ title: form.title,
33
+ type: form.type,
34
+ )
35
+
36
+ ShopifyCli::Resources::EnvFile.new(
37
+ api_key: api_client["apiKey"],
38
+ secret: api_client["apiSecretKeys"].first["secret"],
39
+ shop: form.shop_domain,
40
+ scopes: 'write_products,write_customers,write_draft_orders',
41
+ ).write(@ctx)
42
+
43
+ partners_url = "https://partners.shopify.com/#{form.organization_id}/apps/#{api_client['id']}"
44
+
45
+ @ctx.puts(@ctx.message('node.create.info.created', form.title, partners_url))
46
+ @ctx.puts(@ctx.message('node.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
47
+ @ctx.puts(@ctx.message('node.create.info.install', partners_url, form.title))
48
+ end
49
+
50
+ def self.help
51
+ ShopifyCli::Context.message('node.create.help', ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
52
+ end
53
+
54
+ private
55
+
56
+ def check_node
57
+ _, stat = @ctx.capture2e('which', 'node')
58
+ @ctx.abort(@ctx.message('node.create.error.node_required')) unless stat.success?
59
+
60
+ version, stat = @ctx.capture2e('node', '-v')
61
+ @ctx.abort(@ctx.message('node.create.error.node_version_failure')) unless stat.success?
62
+
63
+ @ctx.done(@ctx.message('node.create.node_version', version))
64
+ end
65
+
66
+ def check_npm
67
+ _, stat = @ctx.capture2e('which', 'npm')
68
+ @ctx.abort(@ctx.message('node.create.error.npm_required')) unless stat.success?
69
+
70
+ version, stat = @ctx.capture2e('npm', '-v')
71
+ @ctx.abort(@ctx.message('node.create.error.npm_version_failure')) unless stat.success?
72
+
73
+ @ctx.done(@ctx.message('node.create.npm_version', version))
74
+ end
75
+
76
+ def set_npm_config
77
+ # check available npmrc (either user or system) for production registry
78
+ registry, _ = @ctx.capture2('npm config get @shopify:registry')
79
+ return if registry.include?('https://registry.yarnpkg.com')
80
+
81
+ # available npmrc doesn't have production registry =>
82
+ # set a project-based .npmrc
83
+ @ctx.system(
84
+ 'npm',
85
+ '--userconfig',
86
+ './.npmrc',
87
+ 'config',
88
+ 'set',
89
+ '@shopify:registry',
90
+ 'https://registry.yarnpkg.com',
91
+ chdir: @ctx.root
92
+ )
93
+ end
94
+
95
+ def build(name)
96
+ ShopifyCli::Git.clone('https://github.com/Shopify/shopify-app-node.git', name)
97
+
98
+ @ctx.root = File.join(@ctx.root, name)
99
+
100
+ set_npm_config
101
+ ShopifyCli::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
102
+
103
+ begin
104
+ @ctx.rm_r('.git')
105
+ @ctx.rm_r('.github')
106
+ @ctx.rm(File.join('server', 'handlers', 'client.js'))
107
+ @ctx.rename(
108
+ File.join('server', 'handlers', 'client.cli.js'),
109
+ File.join('server', 'handlers', 'client.js')
110
+ )
111
+ rescue Errno::ENOENT => e
112
+ @ctx.debug(e)
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'shopify_cli'
3
+
4
+ module Node
5
+ module Commands
6
+ class Deploy < ShopifyCli::Command
7
+ subcommand :Heroku, 'heroku', Project.project_filepath('commands/deploy/heroku')
8
+
9
+ def call(*)
10
+ @ctx.puts(self.class.help)
11
+ end
12
+
13
+ def self.help
14
+ ShopifyCli::Context.message('node.deploy.help', ShopifyCli::TOOL_NAME)
15
+ end
16
+
17
+ def self.extended_help
18
+ ShopifyCli::Context.message('node.deploy.extended_help', ShopifyCli::TOOL_NAME)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+ require 'shopify_cli'
3
+
4
+ module Node
5
+ module Commands
6
+ class Deploy
7
+ class Heroku < ShopifyCli::SubCommand
8
+ def self.help
9
+ ShopifyCli::Context.message('node.deploy.heroku.help', ShopifyCli::TOOL_NAME)
10
+ end
11
+
12
+ def call(*)
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
+ spin_group.add(@ctx.message('node.deploy.heroku.installing')) do |spinner|
23
+ heroku_service.install
24
+ spinner.update_title(@ctx.message('node.deploy.heroku.installed'))
25
+ end
26
+ spin_group.add(@ctx.message('node.deploy.heroku.git.checking')) do |spinner|
27
+ ShopifyCli::Git.init(@ctx)
28
+ spinner.update_title(@ctx.message('node.deploy.heroku.git.initialized'))
29
+ end
30
+ spin_group.wait
31
+
32
+ if (account = heroku_service.whoami)
33
+ @ctx.puts(@ctx.message('node.deploy.heroku.authenticated_with_account', account))
34
+ else
35
+ CLI::UI::Frame.open(
36
+ @ctx.message('node.deploy.heroku.authenticating'),
37
+ success_text: @ctx.message('node.deploy.heroku.authenticated')
38
+ ) do
39
+ heroku_service.authenticate
40
+ end
41
+ end
42
+
43
+ if (app_name = heroku_service.app)
44
+ @ctx.puts(@ctx.message('node.deploy.heroku.app.selected', app_name))
45
+ else
46
+ app_type = CLI::UI::Prompt.ask(@ctx.message('node.deploy.heroku.app.no_apps_found')) do |handler|
47
+ handler.option(@ctx.message('node.deploy.heroku.app.create')) { :new }
48
+ handler.option(@ctx.message('node.deploy.heroku.app.select')) { :existing }
49
+ end
50
+
51
+ if app_type == :existing
52
+ app_name = CLI::UI::Prompt.ask(@ctx.message('node.deploy.heroku.app.name'))
53
+ CLI::UI::Frame.open(
54
+ @ctx.message('node.deploy.heroku.app.selecting', app_name),
55
+ success_text: @ctx.message('node.deploy.heroku.app.selected', app_name)
56
+ ) do
57
+ heroku_service.select_existing_app(app_name)
58
+ end
59
+ elsif app_type == :new
60
+ CLI::UI::Frame.open(
61
+ @ctx.message('node.deploy.heroku.app.creating'),
62
+ success_text: @ctx.message('node.deploy.heroku.app.created')
63
+ ) do
64
+ heroku_service.create_new_app
65
+ end
66
+ end
67
+ end
68
+
69
+ branches = ShopifyCli::Git.branches(@ctx)
70
+ if branches.length == 1
71
+ branch_to_deploy = branches[0]
72
+ @ctx.puts(@ctx.message('node.deploy.heroku.git.branch_selected', branch_to_deploy))
73
+ else
74
+ branch_to_deploy = CLI::UI::Prompt.ask(@ctx.message('node.deploy.heroku.git.what_branch')) do |handler|
75
+ branches.each do |branch|
76
+ handler.option(branch) { branch }
77
+ end
78
+ end
79
+ end
80
+
81
+ CLI::UI::Frame.open(
82
+ @ctx.message('node.deploy.heroku.deploying'),
83
+ success_text: @ctx.message('node.deploy.heroku.deployed')
84
+ ) do
85
+ heroku_service.deploy(branch_to_deploy)
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ require 'shopify_cli'
3
+
4
+ module Node
5
+ module Commands
6
+ class Generate < ShopifyCli::Command
7
+ subcommand :Page, 'page', Project.project_filepath('commands/generate/page')
8
+ subcommand :Billing, 'billing', Project.project_filepath('commands/generate/billing')
9
+ subcommand :Webhook, 'webhook', Project.project_filepath('commands/generate/webhook')
10
+
11
+ def call(*)
12
+ @ctx.puts(self.class.help)
13
+ end
14
+
15
+ def self.help
16
+ ShopifyCli::Context.message('node.generate.help', ShopifyCli::TOOL_NAME)
17
+ end
18
+
19
+ def self.extended_help
20
+ extended_help = "{{bold:Subcommands:}}\n"
21
+ subcommand_registry.resolved_commands.sort.each do |name, klass|
22
+ extended_help += " {{cyan:#{name}}}: "
23
+
24
+ if (subcmd_help = klass.help)
25
+ extended_help += subcmd_help.gsub("\n ", "\n ")
26
+ end
27
+ extended_help += "\n"
28
+ end
29
+ extended_help += ShopifyCli::Context.message('node.generate.extended_help', ShopifyCli::TOOL_NAME)
30
+ end
31
+
32
+ def self.run_generate(script, name, ctx)
33
+ stat = ctx.system(script)
34
+ unless stat.success?
35
+ ctx.abort(response(stat.exitstatus, name, ctx))
36
+ end
37
+ end
38
+
39
+ def self.response(code, name, ctx)
40
+ case code
41
+ when 1
42
+ ctx.message('node.generate.error.generic', name)
43
+ when 2
44
+ ctx.message('node.generate.error.name_exists', name)
45
+ else
46
+ ctx.message('node.error.generic')
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,37 @@
1
+ require 'shopify_cli'
2
+
3
+ module Node
4
+ module Commands
5
+ class Generate
6
+ class Billing < ShopifyCli::SubCommand
7
+ BILLING_TYPES = {
8
+ 'recurring-billing' => './node_modules/.bin/generate-node-app recurring-billing',
9
+ 'one-time-billing' => './node_modules/.bin/generate-node-app one-time-billing',
10
+ }
11
+ def call(args, _name)
12
+ selected_type = BILLING_TYPES[args[1]]
13
+ unless selected_type
14
+ selected_type = CLI::UI::Prompt.ask(@ctx.message('node.generate.billing.type_select')) do |handler|
15
+ BILLING_TYPES.each do |key, value|
16
+ handler.option(key) { value }
17
+ end
18
+ end
19
+ end
20
+ billing_type_name = BILLING_TYPES.key(selected_type)
21
+ spin_group = CLI::UI::SpinGroup.new
22
+ spin_group.add(@ctx.message('node.generate.billing.generating', billing_type_name)) do |spinner|
23
+ Node::Commands::Generate.run_generate(
24
+ selected_type, billing_type_name, @ctx
25
+ )
26
+ spinner.update_title(@ctx.message('node.generate.billing.generated', billing_type_name))
27
+ end
28
+ spin_group.wait
29
+ end
30
+
31
+ def self.help
32
+ ShopifyCli::Context.message('node.generate.billing.help', ShopifyCli::TOOL_NAME)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,55 @@
1
+ require 'shopify_cli'
2
+
3
+ module Node
4
+ module Commands
5
+ class Generate
6
+ class Page < ShopifyCli::SubCommand
7
+ PAGE_TYPES = {
8
+ 'empty-state' => './node_modules/.bin/generate-node-app empty-state-page',
9
+ 'two-column' => './node_modules/.bin/generate-node-app two-column-page',
10
+ 'annotated' => './node_modules/.bin/generate-node-app settings-page',
11
+ 'list' => './node_modules/.bin/generate-node-app list-page',
12
+ }
13
+
14
+ options do |parser, flags|
15
+ parser.on('--type=TYPE') do |t|
16
+ flags[:type] = t.downcase
17
+ end
18
+ end
19
+
20
+ def call(args, _name)
21
+ name = args.first
22
+ flag = options.flags[:type]
23
+ unless name
24
+ @ctx.puts(self.class.help)
25
+ return
26
+ end
27
+
28
+ selected_type = if flag
29
+ unless PAGE_TYPES.key?(flag)
30
+ @ctx.abort(@ctx.message('node.generate.page.error.invalid_page_type'))
31
+ end
32
+ PAGE_TYPES[flag]
33
+ else
34
+ CLI::UI::Prompt.ask(@ctx.message('node.generate.page.type_select')) do |handler|
35
+ PAGE_TYPES.each do |key, value|
36
+ handler.option(key) { value }
37
+ end
38
+ end
39
+ end
40
+
41
+ spin_group = CLI::UI::SpinGroup.new
42
+ spin_group.add(@ctx.message('node.generate.page.generating', selected_type)) do |spinner|
43
+ Node::Commands::Generate.run_generate("#{selected_type} #{name}", name, @ctx)
44
+ spinner.update_title(@ctx.message('node.generate.page.generated', name, name))
45
+ end
46
+ spin_group.wait
47
+ end
48
+
49
+ def self.help
50
+ ShopifyCli::Context.message('node.generate.page.help', ShopifyCli::TOOL_NAME)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,33 @@
1
+ require 'shopify_cli'
2
+ require 'json'
3
+ module Node
4
+ module Commands
5
+ class Generate
6
+ class Webhook < ShopifyCli::SubCommand
7
+ def call(args, _name)
8
+ selected_type = args.first
9
+ schema = ShopifyCli::AdminAPI::Schema.get(@ctx)
10
+ webhooks = schema.get_names_from_type('WebhookSubscriptionTopic')
11
+ unless selected_type && webhooks.include?(selected_type)
12
+ selected_type = CLI::UI::Prompt.ask(@ctx.message('node.generate.webhook.type_select')) do |handler|
13
+ webhooks.each do |type|
14
+ handler.option(type) { type }
15
+ end
16
+ end
17
+ end
18
+ spin_group = CLI::UI::SpinGroup.new
19
+ spin_group.add(@ctx.message('node.generate.webhook.generating', selected_type)) do |spinner|
20
+ Node::Commands::Generate.run_generate("./node_modules/.bin/generate-node-app webhook #{selected_type}",
21
+ selected_type, @ctx)
22
+ spinner.update_title(@ctx.message('node.generate.webhook.generated', selected_type))
23
+ end
24
+ spin_group.wait
25
+ end
26
+
27
+ def self.help
28
+ ShopifyCli::Context.message('node.generate.webhook.help', ShopifyCli::TOOL_NAME)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ require 'shopify_cli'
2
+
3
+ module Node
4
+ module Commands
5
+ class Open < ShopifyCli::Command
6
+ def call(*)
7
+ project = ShopifyCli::Project.current
8
+ @ctx.open_url!("#{project.env.host}/auth?shop=#{project.env.shop}")
9
+ end
10
+
11
+ def self.help
12
+ ShopifyCli::Context.message('node.open.help', ShopifyCli::TOOL_NAME)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ require 'shopify_cli'
2
+
3
+ module Node
4
+ module Commands
5
+ class Populate < ShopifyCli::Command
6
+ subcommand :Customer, 'customers', Project.project_filepath('commands/populate/customer')
7
+ subcommand :DraftOrder, 'draftorders', Project.project_filepath('commands/populate/draft_order')
8
+ subcommand :Product, 'products', Project.project_filepath('commands/populate/product')
9
+
10
+ def call(_args, _name)
11
+ @ctx.puts(self.class.help)
12
+ end
13
+
14
+ def self.help
15
+ ShopifyCli::Context.message('node.populate.help', ShopifyCli::TOOL_NAME)
16
+ end
17
+
18
+ def self.extended_help
19
+ ShopifyCli::Context.message('node.populate.extended_help', ShopifyCli::TOOL_NAME)
20
+ end
21
+ end
22
+ end
23
+ end