shopify-cli 1.3.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +2 -2
  3. data/.github/CONTRIBUTING.md +9 -1
  4. data/.github/PULL_REQUEST_TEMPLATE.md +10 -1
  5. data/.github/workflows/release.yml +61 -0
  6. data/.github/workflows/triage.yml +22 -0
  7. data/.gitignore +0 -1
  8. data/.rubocop.yml +61 -8
  9. data/.rubocop_todo.yml +11 -0
  10. data/.travis.yml +1 -0
  11. data/CHANGELOG.md +30 -0
  12. data/Gemfile +3 -2
  13. data/Gemfile.lock +39 -37
  14. data/README.md +39 -7
  15. data/RELEASING.md +19 -29
  16. data/Rakefile +2 -0
  17. data/dev.yml +2 -2
  18. data/docs/_config.yml +1 -18
  19. data/docs/app/node/commands/index.md +2 -80
  20. data/docs/app/node/index.md +2 -33
  21. data/docs/app/rails/commands/index.md +2 -78
  22. data/docs/app/rails/index.md +2 -34
  23. data/docs/core/index.md +2 -84
  24. data/docs/getting-started/index.md +2 -25
  25. data/docs/getting-started/install/index.md +1 -118
  26. data/docs/getting-started/migrate/index.md +2 -94
  27. data/docs/getting-started/uninstall/index.md +2 -35
  28. data/docs/getting-started/upgrade/index.md +2 -39
  29. data/docs/help/start-app/index.md +2 -4
  30. data/docs/index.md +2 -24
  31. data/install.sh +1 -1
  32. data/lib/project_types/extension/cli.rb +21 -11
  33. data/lib/project_types/extension/commands/extension_command.rb +2 -2
  34. data/lib/project_types/extension/features/argo.rb +117 -0
  35. data/lib/project_types/extension/forms/create.rb +2 -2
  36. data/lib/project_types/extension/models/specification.rb +35 -0
  37. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +19 -0
  38. data/lib/project_types/extension/models/specification_handlers/default.rb +67 -0
  39. data/lib/project_types/extension/models/specifications.rb +77 -0
  40. data/lib/project_types/extension/tasks/configure_features.rb +52 -0
  41. data/lib/project_types/extension/tasks/fetch_specifications.rb +38 -0
  42. data/lib/project_types/node/cli.rb +4 -1
  43. data/lib/project_types/node/commands/connect.rb +15 -0
  44. data/lib/project_types/node/commands/create.rb +10 -4
  45. data/lib/project_types/node/commands/generate.rb +2 -11
  46. data/lib/project_types/node/messages/messages.rb +16 -50
  47. data/lib/project_types/rails/cli.rb +4 -1
  48. data/lib/project_types/rails/commands/connect.rb +15 -0
  49. data/lib/project_types/rails/commands/create.rb +15 -12
  50. data/lib/project_types/rails/forms/create.rb +1 -1
  51. data/lib/project_types/rails/gem.rb +1 -1
  52. data/lib/project_types/rails/messages/messages.rb +8 -5
  53. data/lib/project_types/script/cli.rb +9 -5
  54. data/lib/project_types/script/commands/create.rb +6 -4
  55. data/lib/project_types/script/commands/enable.rb +12 -4
  56. data/lib/project_types/script/commands/push.rb +5 -13
  57. data/lib/project_types/script/config/extension_points.yml +17 -12
  58. data/lib/project_types/script/errors.rb +21 -0
  59. data/lib/project_types/script/forms/create.rb +26 -2
  60. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +10 -1
  61. data/lib/project_types/script/layers/application/build_script.rb +18 -17
  62. data/lib/project_types/script/layers/application/create_script.rb +12 -10
  63. data/lib/project_types/script/layers/application/extension_points.rb +24 -0
  64. data/lib/project_types/script/layers/application/push_script.rb +18 -16
  65. data/lib/project_types/script/layers/domain/errors.rb +7 -0
  66. data/lib/project_types/script/layers/domain/extension_point.rb +62 -7
  67. data/lib/project_types/script/layers/domain/metadata.rb +55 -0
  68. data/lib/project_types/script/layers/domain/push_package.rb +25 -6
  69. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +17 -52
  70. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +42 -11
  71. data/lib/project_types/script/layers/infrastructure/errors.rb +16 -0
  72. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +10 -4
  73. data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
  74. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +25 -13
  75. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +72 -0
  76. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +59 -0
  77. data/lib/project_types/script/layers/infrastructure/script_service.rb +9 -1
  78. data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
  79. data/lib/project_types/script/messages/messages.rb +55 -4
  80. data/lib/project_types/script/script_project.rb +25 -16
  81. data/lib/project_types/script/ui/error_handler.rb +59 -1
  82. data/lib/project_types/theme/cli.rb +40 -0
  83. data/lib/project_types/theme/commands/connect.rb +54 -0
  84. data/lib/project_types/theme/commands/create.rb +48 -0
  85. data/lib/project_types/theme/commands/deploy.rb +38 -0
  86. data/lib/project_types/theme/commands/generate.rb +20 -0
  87. data/lib/project_types/theme/commands/generate/env.rb +79 -0
  88. data/lib/project_types/theme/commands/push.rb +55 -0
  89. data/lib/project_types/theme/commands/serve.rb +31 -0
  90. data/lib/project_types/theme/forms/connect.rb +34 -0
  91. data/lib/project_types/theme/forms/create.rb +22 -0
  92. data/lib/project_types/theme/messages/messages.rb +147 -0
  93. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +78 -0
  94. data/lib/project_types/theme/themekit.rb +113 -0
  95. data/lib/shopify-cli/admin_api.rb +42 -2
  96. data/lib/shopify-cli/api.rb +34 -33
  97. data/lib/shopify-cli/commands/config.rb +24 -0
  98. data/lib/shopify-cli/commands/connect.rb +32 -15
  99. data/lib/shopify-cli/commands/system.rb +10 -1
  100. data/lib/shopify-cli/context.rb +23 -2
  101. data/lib/shopify-cli/core/entry_point.rb +1 -1
  102. data/lib/shopify-cli/core/monorail.rb +6 -4
  103. data/lib/shopify-cli/feature.rb +0 -2
  104. data/lib/shopify-cli/http_request.rb +27 -0
  105. data/lib/shopify-cli/js_deps.rb +1 -1
  106. data/lib/shopify-cli/messages/messages.rb +31 -7
  107. data/lib/shopify-cli/method_object.rb +104 -0
  108. data/lib/shopify-cli/partners_api.rb +25 -3
  109. data/lib/shopify-cli/process_supervision.rb +1 -1
  110. data/lib/shopify-cli/project.rb +12 -8
  111. data/lib/shopify-cli/project_type.rb +18 -2
  112. data/lib/shopify-cli/resolve_constant.rb +25 -0
  113. data/lib/shopify-cli/result.rb +432 -0
  114. data/lib/shopify-cli/shopifolk.rb +87 -0
  115. data/lib/shopify-cli/task.rb +8 -0
  116. data/lib/shopify-cli/tasks/create_api_client.rb +13 -2
  117. data/lib/shopify-cli/tasks/ensure_env.rb +3 -0
  118. data/lib/shopify-cli/tasks/select_org_and_shop.rb +10 -5
  119. data/lib/shopify-cli/tunnel.rb +8 -2
  120. data/lib/shopify-cli/version.rb +1 -1
  121. data/lib/shopify_cli.rb +5 -1
  122. data/shopify.fish +1 -1
  123. data/shopify.sh +1 -1
  124. data/vendor/deps/cli-kit/REVISION +1 -1
  125. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +2 -2
  126. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +3 -3
  127. data/vendor/deps/cli-ui/REVISION +1 -1
  128. data/vendor/deps/cli-ui/lib/cli/ui.rb +26 -22
  129. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +4 -6
  130. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -3
  131. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +8 -9
  132. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -1
  133. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +1 -0
  134. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +15 -3
  135. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +4 -11
  136. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -5
  137. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +10 -10
  138. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +1 -1
  139. data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
  140. data/vendor/deps/webrick/.gitignore +9 -0
  141. data/vendor/deps/webrick/Gemfile +3 -0
  142. data/vendor/deps/webrick/LICENSE.txt +22 -0
  143. data/vendor/deps/webrick/README.md +61 -0
  144. data/vendor/deps/webrick/Rakefile +10 -0
  145. data/vendor/deps/webrick/lib/webrick.rb +232 -0
  146. data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
  147. data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
  148. data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
  149. data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
  150. data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
  151. data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
  152. data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
  153. data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
  154. data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
  155. data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
  156. data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
  157. data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
  158. data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
  159. data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
  160. data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
  161. data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
  162. data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
  163. data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
  164. data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
  165. data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
  166. data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
  167. data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
  168. data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
  169. data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
  170. data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
  171. data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
  172. data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
  173. data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
  174. data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
  175. data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
  176. data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
  177. data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
  178. data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
  179. data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
  180. data/vendor/deps/webrick/webrick.gemspec +74 -0
  181. metadata +77 -27
  182. data/docs/Gemfile +0 -5
  183. data/docs/Gemfile.lock +0 -258
  184. data/docs/_data/nav.yml +0 -35
  185. data/docs/_includes/footer.html +0 -15
  186. data/docs/_includes/head.html +0 -19
  187. data/docs/_includes/sidebar_nav.html +0 -22
  188. data/docs/_includes/toc.html +0 -112
  189. data/docs/_layouts/default.html +0 -79
  190. data/docs/css/docs.css +0 -157
  191. data/docs/images/header.png +0 -0
  192. data/docs/installing-ruby.md +0 -28
  193. data/lib/project_types/extension/features/argo/admin.rb +0 -20
  194. data/lib/project_types/extension/features/argo/base.rb +0 -129
  195. data/lib/project_types/extension/features/argo/checkout.rb +0 -20
  196. data/lib/project_types/extension/models/type.rb +0 -81
  197. data/lib/project_types/extension/models/types/checkout_post_purchase.rb +0 -23
  198. data/lib/project_types/extension/models/types/product_subscription.rb +0 -24
  199. data/lib/project_types/node/commands/generate/billing.rb +0 -39
  200. data/lib/project_types/node/commands/generate/page.rb +0 -59
  201. data/lib/project_types/node/commands/generate/webhook.rb +0 -37
  202. data/lib/project_types/script/layers/domain/script.rb +0 -18
  203. data/lib/project_types/script/layers/infrastructure/assemblyscript_tsconfig.rb +0 -38
  204. data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -59
  205. data/lib/project_types/script/templates/ts/as-pect.config.js +0 -27
  206. data/lib/project_types/script/templates/ts/as-pect.d.ts +0 -1
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Node
3
+ module Commands
4
+ class Connect < ShopifyCli::SubCommand
5
+ def call(*)
6
+ if ShopifyCli::Project.has_current? && ShopifyCli::Project.current.env
7
+ @ctx.puts(@ctx.message('node.connect.production_warning'))
8
+ end
9
+
10
+ app = ShopifyCli::Commands::Connect.new.default_connect('node')
11
+ @ctx.done(@ctx.message('node.connect.connected', app))
12
+ end
13
+ end
14
+ end
15
+ end
@@ -40,11 +40,13 @@ module Node
40
40
  scopes: 'write_products,write_customers,write_draft_orders',
41
41
  ).write(@ctx)
42
42
 
43
- partners_url = "https://partners.shopify.com/#{form.organization_id}/apps/#{api_client['id']}"
43
+ partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client['id'], local_debug?)
44
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))
45
+ @ctx.puts(@ctx.message('apps.create.info.created', form.title, partners_url))
46
+ @ctx.puts(@ctx.message('apps.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
47
+ unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
48
+ @ctx.puts(@ctx.message('apps.create.info.install', partners_url, form.title))
49
+ end
48
50
  end
49
51
 
50
52
  def self.help
@@ -112,6 +114,10 @@ module Node
112
114
  @ctx.debug(e)
113
115
  end
114
116
  end
117
+
118
+ def local_debug?
119
+ @ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
120
+ end
115
121
  end
116
122
  end
117
123
  end
@@ -13,20 +13,11 @@ module Node
13
13
  end
14
14
 
15
15
  def self.help
16
- ShopifyCli::Context.message('node.generate.help', ShopifyCli::TOOL_NAME)
16
+ ShopifyCli::Context.message('node.generate.help')
17
17
  end
18
18
 
19
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)
20
+ help
30
21
  end
31
22
 
32
23
  def self.run_generate(script, name, ctx)
@@ -8,6 +8,13 @@ module Node
8
8
  generic: "Error",
9
9
  },
10
10
 
11
+ connect: {
12
+ connected: "Project now connected to {{green:%s}}",
13
+ production_warning: <<~MESSAGE,
14
+ {{yellow:! Warning: if you have connected to an {{bold:app in production}}, running {{command:serve}} may update the app URL and cause an outage.
15
+ MESSAGE
16
+ },
17
+
11
18
  create: {
12
19
  help: <<~HELP,
13
20
  {{command:%s create node}}: Creates an embedded nodejs app.
@@ -26,12 +33,6 @@ module Node
26
33
  npm_version_failure: "Failed to get the current npm version. Please make sure it is installed as per " \
27
34
  "the instructions at https://www.npmjs.com/get-npm.",
28
35
  },
29
- info: {
30
- created: "{{v}} {{green:%s}} was created in your Partner Dashboard {{underline:%s}}",
31
- serve: "{{*}} Change directories to your new project folder {{green:%s}} and run {{command:%s serve}} " \
32
- "to start a local server",
33
- install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
34
- },
35
36
  node_version: "node %s",
36
37
  npm_version: "npm %s",
37
38
  },
@@ -82,52 +83,17 @@ module Node
82
83
 
83
84
  generate: {
84
85
  help: <<~HELP,
85
- Generate code in your Node project. Supports generating new billing API calls, new pages, or new webhooks.
86
- Usage: {{command:%s generate [ billing | page | webhook ]}}
87
- HELP
88
- extended_help: <<~EXAMPLES,
89
- {{bold:Examples:}}
90
- {{cyan:%s generate webhook PRODUCTS_CREATE}}
91
- Generate and register a new webhook that will be called every time a new product is created on your store.
92
- EXAMPLES
93
-
94
- error: {
95
- name_exists: "%s already exists!",
96
- generic: "Error generating %s",
97
- },
98
-
99
- billing: {
100
- help: <<~HELP,
101
- Enable charging for your app. This command generates the necessary code to call Shopify’s billing API.
102
- Usage: {{command:%s generate billing [ one-time-billing | recurring-billing ]}}
103
- HELP
104
- type_select: "How would you like to charge for your app?",
105
- generating: "Generating %s code ...",
106
- generated: "{{green:%s}} generated in server/server.js",
107
- },
86
+ {{red:The {{command:generate}} command is no longer supported.}}
87
+ You can complete any tasks previously supported by {{command:generate}} with these guides:
88
+ {{green:page}}
89
+ 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}}
108
90
 
109
- page: {
110
- help: <<~HELP,
111
- Generate a new page in your app with the specified name. New files are generated inside the project’s “/pages” directory.
112
- Usage: {{command:%s generate page <pagename>}}
113
- HELP
114
- error: {
115
- invalid_page_type: "Invalid page type.",
116
- },
117
- type_select: "Which template would you like to use?",
118
- generating: "Generating %s page...",
119
- generated: "{{green: %s}} generated in pages/%s",
120
- },
91
+ {{green:webhook}}
92
+ Register and process webhooks: {{green:https://github.com/Shopify/shopify-node-api/blob/main/docs/usage/webhooks.md}}
121
93
 
122
- webhook: {
123
- help: <<~HELP,
124
- Generate and register a new webhook that listens for the specified Shopify store event.
125
- Usage: {{command:%s generate webhook <type>}}
126
- HELP
127
- type_select: "What type of webhook would you like to create?",
128
- generating: "Generating webhook: %s",
129
- generated: "{{green:%s}} generated in server/server.js",
130
- },
94
+ {{green:billing}}
95
+ Create and manage app billing models: {{green:https://shopify.dev/tutorials/bill-for-your-app-using-graphql-admin-api}}
96
+ HELP
131
97
  },
132
98
 
133
99
  open: {
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
  module Rails
3
3
  class Project < ShopifyCli::ProjectType
4
- creator 'Ruby on Rails App', 'Rails::Commands::Create'
4
+ title('Ruby on Rails App')
5
+ creator('Rails::Commands::Create')
6
+ connector('Rails::Commands::Connect')
5
7
 
6
8
  register_command('Rails::Commands::Deploy', "deploy")
7
9
  register_command('Rails::Commands::Generate', "generate")
@@ -17,6 +19,7 @@ module Rails
17
19
 
18
20
  # define/autoload project specific Commands
19
21
  module Commands
22
+ autoload :Connect, Project.project_filepath('commands/connect')
20
23
  autoload :Create, Project.project_filepath('commands/create')
21
24
  autoload :Deploy, Project.project_filepath('commands/deploy')
22
25
  autoload :Generate, Project.project_filepath('commands/generate')
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+ module Rails
3
+ module Commands
4
+ class Connect < ShopifyCli::SubCommand
5
+ def call(*)
6
+ if ShopifyCli::Project.has_current? && ShopifyCli::Project.current.env
7
+ @ctx.puts(@ctx.message('rails.connect.production_warning'))
8
+ end
9
+
10
+ app = ShopifyCli::Commands::Connect.new.default_connect('rails')
11
+ @ctx.done(@ctx.message('rails.connect.connected', app))
12
+ end
13
+ end
14
+ end
15
+ end
@@ -27,8 +27,9 @@ module Rails
27
27
  form = Forms::Create.ask(@ctx, args, options.flags)
28
28
  return @ctx.puts(self.class.help) if form.nil?
29
29
 
30
+ ruby_version = Ruby.version(@ctx)
30
31
  @ctx.abort(@ctx.message('rails.create.error.invalid_ruby_version')) unless
31
- Ruby.version(@ctx).satisfies?('~>2.5')
32
+ ruby_version.satisfies?('~>2.5') || ruby_version.satisfies?('~>3.0.0')
32
33
 
33
34
  check_node
34
35
  check_yarn
@@ -55,11 +56,13 @@ module Rails
55
56
  scopes: 'write_products,write_customers,write_draft_orders',
56
57
  ).write(@ctx)
57
58
 
58
- partners_url = "https://partners.shopify.com/#{form.organization_id}/apps/#{api_client['id']}"
59
+ partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client['id'], local_debug?)
59
60
 
60
- @ctx.puts(@ctx.message('rails.create.info.created', form.title, partners_url))
61
- @ctx.puts(@ctx.message('rails.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
62
- @ctx.puts(@ctx.message('rails.create.info.install', partners_url, form.title))
61
+ @ctx.puts(@ctx.message('apps.create.info.created', form.title, partners_url))
62
+ @ctx.puts(@ctx.message('apps.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
63
+ unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
64
+ @ctx.puts(@ctx.message('apps.create.info.install', partners_url, form.title))
65
+ end
63
66
  end
64
67
 
65
68
  def self.help
@@ -110,7 +113,7 @@ module Rails
110
113
  end
111
114
 
112
115
  def build(name, db)
113
- @ctx.abort(@ctx.message('rails.create.error.install_failure', 'rails')) unless install_gem('rails')
116
+ @ctx.abort(@ctx.message('rails.create.error.install_failure', 'rails')) unless install_gem('rails', '<6.1')
114
117
  @ctx.abort(@ctx.message('rails.create.error.install_failure', 'bundler ~>2.0')) unless
115
118
  install_gem('bundler', '~>2.0')
116
119
 
@@ -133,18 +136,14 @@ module Rails
133
136
 
134
137
  @ctx.puts(@ctx.message('rails.create.adding_shopify_gem'))
135
138
  File.open(File.join(@ctx.root, 'Gemfile'), 'a') do |f|
136
- f.puts "\ngem 'shopify_app', '>=11.3.0'"
139
+ f.puts "\ngem 'shopify_app', '>=17.0.3'"
137
140
  end
138
141
  CLI::UI::Frame.open(@ctx.message('rails.create.running_bundle_install')) do
139
142
  syscall(%w(bundle install))
140
143
  end
141
144
 
142
145
  CLI::UI::Frame.open(@ctx.message('rails.create.running_generator')) do
143
- begin
144
- syscall(%w(spring stop))
145
- rescue
146
- end
147
- syscall(%w(rails generate shopify_app))
146
+ syscall(%w(rails generate shopify_app --new-shopify-cli-app))
148
147
  end
149
148
 
150
149
  CLI::UI::Frame.open(@ctx.message('rails.create.running_migrations')) do
@@ -172,6 +171,10 @@ module Rails
172
171
  def install_gem(name, version = nil)
173
172
  Gem.install(@ctx, name, version)
174
173
  end
174
+
175
+ def local_debug?
176
+ @ctx.getenv(ShopifyCli::PartnersAPI::LOCAL_DEBUG)
177
+ end
175
178
  end
176
179
  end
177
180
  end
@@ -48,7 +48,7 @@ module Rails
48
48
  def ask_db
49
49
  if db.nil?
50
50
  return 'sqlite3' unless CLI::UI::Prompt.confirm(ctx.message('rails.forms.create.db.want_select'),
51
- default: false)
51
+ default: false)
52
52
  @db = CLI::UI::Prompt.ask(ctx.message('rails.forms.create.db.select')) do |handler|
53
53
  VALID_DB_TYPES.each do |db_type|
54
54
  handler.option(ctx.message("rails.forms.create.db.select_#{db_type}")) { db_type }
@@ -99,7 +99,7 @@ module Rails
99
99
  # there was a specific version given during new(), so
100
100
  # check version of gem found to determine match
101
101
  require 'semantic/semantic'
102
- found_version, _ = path.match(%r{/#{Regexp.quote(name)}-([\d\.]+)})&.captures
102
+ found_version, _ = path.match(%r{/#{Regexp.quote(name)}-(\d\.\d\.\d)})&.captures
103
103
  found_version.nil? ? false : Semantic::Version.new(found_version).satisfies?(version)
104
104
  else
105
105
  # otherwise ignore the actual version number,
@@ -17,6 +17,13 @@ module Rails
17
17
  setting_gem_path: "GEM_PATH being set to %s",
18
18
  },
19
19
 
20
+ connect: {
21
+ connected: "Project now connected to {{green:%s}}",
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
+
20
27
  create: {
21
28
  help: <<~HELP,
22
29
  {{command:%s create rails}}: Creates a ruby on rails app.
@@ -32,7 +39,7 @@ module Rails
32
39
 
33
40
  error: {
34
41
  invalid_ruby_version: <<~MSG,
35
- This project requires a ruby version ~> 2.5.
42
+ This project requires a Ruby version ~> 2.5 or Ruby 3.0
36
43
  See {{underline:https://github.com/Shopify/shopify-app-cli/blob/master/docs/installing-ruby.md}}
37
44
  for our recommended method of installing ruby.
38
45
  MSG
@@ -48,10 +55,6 @@ module Rails
48
55
  },
49
56
 
50
57
  info: {
51
- created: "{{v}} {{green:%s}} was created in your Partner Dashboard {{underline:%s}}",
52
- serve: "{{*}} Change directories to your new project folder {{green:%s}} and run {{command:%s serve}} " \
53
- "to start a local server",
54
- install: "{{*}} Then, visit {{underline:%s/test}} to install {{green:%s}} on your Dev Store",
55
58
  open_new_shell: "{{*}} {{yellow:After installing %s, please open a new Command Prompt or PowerShell " \
56
59
  "window to continue.}}",
57
60
  },
@@ -3,7 +3,8 @@
3
3
  module Script
4
4
  class Project < ShopifyCli::ProjectType
5
5
  hidden_feature(feature_set: :script_project)
6
- creator 'Script', 'Script::Commands::Create'
6
+ title('Script')
7
+ creator('Script::Commands::Create')
7
8
 
8
9
  register_command('Script::Commands::Push', 'push')
9
10
  register_command('Script::Commands::Disable', 'disable')
@@ -41,22 +42,25 @@ module Script
41
42
  module Domain
42
43
  autoload :Errors, Project.project_filepath('layers/domain/errors')
43
44
  autoload :PushPackage, Project.project_filepath('layers/domain/push_package')
45
+ autoload :Metadata, Project.project_filepath('layers/domain/metadata')
44
46
  autoload :ExtensionPoint, Project.project_filepath('layers/domain/extension_point')
45
- autoload :Script, Project.project_filepath('layers/domain/script')
46
47
  end
47
48
 
48
49
  module Infrastructure
49
50
  autoload :Errors, Project.project_filepath('layers/infrastructure/errors')
50
51
  autoload :AssemblyScriptDependencyManager,
51
- Project.project_filepath('layers/infrastructure/assemblyscript_dependency_manager')
52
+ Project.project_filepath('layers/infrastructure/assemblyscript_dependency_manager')
52
53
  autoload :AssemblyScriptProjectCreator,
53
- Project.project_filepath('layers/infrastructure/assemblyscript_project_creator')
54
+ Project.project_filepath('layers/infrastructure/assemblyscript_project_creator')
54
55
  autoload :AssemblyScriptTaskRunner, Project.project_filepath('layers/infrastructure/assemblyscript_task_runner')
55
56
  autoload :AssemblyScriptTsConfig, Project.project_filepath('layers/infrastructure/assemblyscript_tsconfig')
57
+ autoload :RustProjectCreator,
58
+ Project.project_filepath('layers/infrastructure/rust_project_creator.rb')
59
+ autoload :RustTaskRunner, Project.project_filepath('layers/infrastructure/rust_task_runner')
60
+
56
61
  autoload :PushPackageRepository, Project.project_filepath('layers/infrastructure/push_package_repository')
57
62
  autoload :ExtensionPointRepository, Project.project_filepath('layers/infrastructure/extension_point_repository')
58
63
  autoload :ProjectCreator, Project.project_filepath('layers/infrastructure/project_creator')
59
- autoload :ScriptRepository, Project.project_filepath('layers/infrastructure/script_repository')
60
64
  autoload :ScriptService, Project.project_filepath('layers/infrastructure/script_service')
61
65
  autoload :TaskRunner, Project.project_filepath('layers/infrastructure/task_runner')
62
66
  end
@@ -5,25 +5,27 @@ module Script
5
5
  class Create < ShopifyCli::SubCommand
6
6
  options do |parser, flags|
7
7
  parser.on('--name=NAME') { |name| flags[:name] = name }
8
+ parser.on('--description=DESCRIPTION') { |description| flags[:description] = description }
8
9
  parser.on('--extension_point=EP_NAME') { |ep_name| flags[:extension_point] = ep_name }
10
+ parser.on('--language=LANGUAGE') { |language| flags[:language] = language }
9
11
  end
10
12
 
11
13
  def call(args, _name)
12
- language = 'ts'
13
14
  cur_dir = @ctx.root
14
15
 
15
16
  form = Forms::Create.ask(@ctx, args, options.flags)
16
17
  return @ctx.puts(self.class.help) if form.nil?
17
18
 
18
- unless !form.name.empty? && form.extension_point && ScriptProject::SUPPORTED_LANGUAGES.include?(language)
19
+ unless !form.name.empty? && form.extension_point && form.language
19
20
  return @ctx.puts(self.class.help)
20
21
  end
21
22
 
22
23
  project = Layers::Application::CreateScript.call(
23
24
  ctx: @ctx,
24
- language: language,
25
+ language: form.language,
25
26
  script_name: form.name,
26
- extension_point_type: form.extension_point
27
+ extension_point_type: form.extension_point,
28
+ description: form.description
27
29
  )
28
30
  @ctx.puts(@ctx.message('script.create.change_directory_notice', project.script_name))
29
31
  rescue Script::Errors::ScriptProjectAlreadyExistsError => e
@@ -4,9 +4,7 @@ module Script
4
4
  module Commands
5
5
  class Enable < ShopifyCli::Command
6
6
  options do |parser, flags|
7
- parser.on('--config_props=KEYVALUEPAIRS', Array) do |t|
8
- flags[:config_props] = Hash[t.map { |s| s.split(':') }]
9
- end
7
+ parser.on('--config_props=KEYVALUEPAIRS', Array) { |t| flags[:config_props] = t }
10
8
  parser.on('--config_file=CONFIGFILEPATH') { |t| flags[:config_file] = t }
11
9
  end
12
10
 
@@ -47,7 +45,7 @@ module Script
47
45
  def acquire_configuration(config_file: nil, config_props: nil)
48
46
  properties = {}
49
47
  properties = YAML.load(File.read(config_file)) unless config_file.nil?
50
- properties = properties.merge(config_props) unless config_props.nil?
48
+ properties = properties.merge(parse_config_props(config_props)) unless config_props.nil?
51
49
 
52
50
  configuration = { entries: [] }
53
51
  properties.each do |key, value|
@@ -61,6 +59,16 @@ module Script
61
59
  raise Errors::InvalidConfigYAMLError, options.flags[:config_file]
62
60
  end
63
61
 
62
+ def parse_config_props(config_props)
63
+ Hash[
64
+ config_props.map do |s|
65
+ args = s.split(':').map(&:strip)
66
+ raise Errors::InvalidConfigProps unless args.size == 2
67
+ args
68
+ end
69
+ ]
70
+ end
71
+
64
72
  # No slice pre Ruby 2.5 so roll our own
65
73
  def slice(hash, *keys)
66
74
  Hash[hash.to_a - hash.select { |key, _value| !keys.include?(key) }.to_a]
@@ -9,19 +9,11 @@ module Script
9
9
 
10
10
  def call(_args, _name)
11
11
  ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
12
- project = ScriptProject.current
13
- api_key = project.env[:api_key]
14
- return @ctx.puts(self.class.help) unless api_key &&
15
- ScriptProject::SUPPORTED_LANGUAGES.include?(project.language)
16
- Layers::Application::PushScript.call(
17
- ctx: @ctx,
18
- language: project.language,
19
- extension_point_type: project.extension_point_type,
20
- script_name: project.script_name,
21
- source_file: project.source_file,
22
- api_key: api_key,
23
- force: options.flags.key?(:force)
24
- )
12
+
13
+ api_key = ScriptProject.current.api_key
14
+ return @ctx.puts(self.class.help) unless api_key
15
+
16
+ Layers::Application::PushScript.call(ctx: @ctx, force: options.flags.key?(:force))
25
17
  @ctx.puts(@ctx.message('script.push.script_pushed', api_key: api_key))
26
18
  rescue StandardError => e
27
19
  UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.push.error.operation_failed'))