shopify-cli 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +1 -0
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +9 -0
  5. data/README.md +39 -7
  6. data/Rakefile +2 -0
  7. data/dev.yml +2 -2
  8. data/docs/_config.yml +1 -18
  9. data/docs/app/node/commands/index.md +2 -80
  10. data/docs/app/node/index.md +2 -33
  11. data/docs/app/rails/commands/index.md +2 -78
  12. data/docs/app/rails/index.md +2 -34
  13. data/docs/core/index.md +2 -84
  14. data/docs/getting-started/index.md +2 -25
  15. data/docs/getting-started/install/index.md +1 -118
  16. data/docs/getting-started/migrate/index.md +2 -94
  17. data/docs/getting-started/uninstall/index.md +2 -35
  18. data/docs/getting-started/upgrade/index.md +2 -39
  19. data/docs/help/start-app/index.md +2 -4
  20. data/docs/index.md +2 -24
  21. data/install.sh +1 -1
  22. data/lib/project_types/extension/cli.rb +19 -10
  23. data/lib/project_types/extension/commands/extension_command.rb +2 -2
  24. data/lib/project_types/extension/features/argo.rb +117 -0
  25. data/lib/project_types/extension/forms/create.rb +2 -2
  26. data/lib/project_types/extension/models/specification.rb +35 -0
  27. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +19 -0
  28. data/lib/project_types/extension/models/specification_handlers/default.rb +67 -0
  29. data/lib/project_types/extension/models/specifications.rb +77 -0
  30. data/lib/project_types/extension/tasks/configure_features.rb +52 -0
  31. data/lib/project_types/extension/tasks/fetch_specifications.rb +38 -0
  32. data/lib/project_types/node/commands/create.rb +3 -1
  33. data/lib/project_types/node/commands/generate.rb +2 -11
  34. data/lib/project_types/node/messages/messages.rb +9 -44
  35. data/lib/project_types/rails/commands/create.rb +8 -9
  36. data/lib/project_types/rails/forms/create.rb +1 -1
  37. data/lib/project_types/rails/gem.rb +1 -1
  38. data/lib/project_types/rails/messages/messages.rb +1 -1
  39. data/lib/project_types/script/cli.rb +7 -4
  40. data/lib/project_types/script/commands/create.rb +6 -4
  41. data/lib/project_types/script/commands/push.rb +5 -13
  42. data/lib/project_types/script/config/extension_points.yml +9 -5
  43. data/lib/project_types/script/errors.rb +17 -0
  44. data/lib/project_types/script/forms/create.rb +26 -2
  45. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +10 -1
  46. data/lib/project_types/script/layers/application/build_script.rb +9 -4
  47. data/lib/project_types/script/layers/application/create_script.rb +12 -10
  48. data/lib/project_types/script/layers/application/extension_points.rb +24 -0
  49. data/lib/project_types/script/layers/application/push_script.rb +18 -16
  50. data/lib/project_types/script/layers/domain/errors.rb +4 -0
  51. data/lib/project_types/script/layers/domain/extension_point.rb +62 -6
  52. data/lib/project_types/script/layers/domain/metadata.rb +55 -0
  53. data/lib/project_types/script/layers/domain/push_package.rb +25 -6
  54. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +6 -6
  55. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +16 -6
  56. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +10 -4
  57. data/lib/project_types/script/layers/infrastructure/project_creator.rb +2 -1
  58. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +25 -13
  59. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +72 -0
  60. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +59 -0
  61. data/lib/project_types/script/layers/infrastructure/script_service.rb +7 -1
  62. data/lib/project_types/script/layers/infrastructure/task_runner.rb +4 -3
  63. data/lib/project_types/script/messages/messages.rb +39 -8
  64. data/lib/project_types/script/script_project.rb +25 -16
  65. data/lib/project_types/script/ui/error_handler.rb +34 -1
  66. data/lib/project_types/theme/cli.rb +40 -0
  67. data/lib/project_types/theme/commands/connect.rb +54 -0
  68. data/lib/project_types/theme/commands/create.rb +48 -0
  69. data/lib/project_types/theme/commands/deploy.rb +38 -0
  70. data/lib/project_types/theme/commands/generate.rb +20 -0
  71. data/lib/project_types/theme/commands/generate/env.rb +79 -0
  72. data/lib/project_types/theme/commands/push.rb +55 -0
  73. data/lib/project_types/theme/commands/serve.rb +31 -0
  74. data/lib/project_types/theme/forms/connect.rb +34 -0
  75. data/lib/project_types/theme/forms/create.rb +22 -0
  76. data/lib/project_types/theme/messages/messages.rb +147 -0
  77. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +78 -0
  78. data/lib/project_types/theme/themekit.rb +113 -0
  79. data/lib/shopify-cli/admin_api.rb +42 -2
  80. data/lib/shopify-cli/api.rb +27 -24
  81. data/lib/shopify-cli/commands/system.rb +1 -1
  82. data/lib/shopify-cli/context.rb +23 -2
  83. data/lib/shopify-cli/feature.rb +0 -2
  84. data/lib/shopify-cli/http_request.rb +20 -8
  85. data/lib/shopify-cli/messages/messages.rb +6 -3
  86. data/lib/shopify-cli/method_object.rb +104 -0
  87. data/lib/shopify-cli/partners_api.rb +8 -2
  88. data/lib/shopify-cli/project_type.rb +1 -1
  89. data/lib/shopify-cli/resolve_constant.rb +25 -0
  90. data/lib/shopify-cli/result.rb +432 -0
  91. data/lib/shopify-cli/shopifolk.rb +3 -2
  92. data/lib/shopify-cli/tasks/select_org_and_shop.rb +6 -5
  93. data/lib/shopify-cli/tunnel.rb +7 -1
  94. data/lib/shopify-cli/version.rb +1 -1
  95. data/lib/shopify_cli.rb +4 -1
  96. data/shopify.fish +1 -1
  97. data/shopify.sh +1 -1
  98. data/vendor/deps/cli-kit/REVISION +1 -1
  99. data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +2 -2
  100. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +3 -3
  101. data/vendor/deps/cli-ui/REVISION +1 -1
  102. data/vendor/deps/cli-ui/lib/cli/ui.rb +26 -22
  103. data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +4 -6
  104. data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +3 -3
  105. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +8 -9
  106. data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +1 -1
  107. data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +1 -0
  108. data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +15 -3
  109. data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +4 -11
  110. data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +3 -5
  111. data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +10 -10
  112. data/vendor/deps/cli-ui/lib/cli/ui/version.rb +1 -1
  113. data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +56 -0
  114. data/vendor/deps/webrick/.gitignore +9 -0
  115. data/vendor/deps/webrick/Gemfile +3 -0
  116. data/vendor/deps/webrick/LICENSE.txt +22 -0
  117. data/vendor/deps/webrick/README.md +61 -0
  118. data/vendor/deps/webrick/Rakefile +10 -0
  119. data/vendor/deps/webrick/lib/webrick.rb +232 -0
  120. data/vendor/deps/webrick/lib/webrick/accesslog.rb +157 -0
  121. data/vendor/deps/webrick/lib/webrick/cgi.rb +313 -0
  122. data/vendor/deps/webrick/lib/webrick/compat.rb +36 -0
  123. data/vendor/deps/webrick/lib/webrick/config.rb +158 -0
  124. data/vendor/deps/webrick/lib/webrick/cookie.rb +172 -0
  125. data/vendor/deps/webrick/lib/webrick/htmlutils.rb +30 -0
  126. data/vendor/deps/webrick/lib/webrick/httpauth.rb +96 -0
  127. data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +117 -0
  128. data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +116 -0
  129. data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +395 -0
  130. data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +132 -0
  131. data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +97 -0
  132. data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +158 -0
  133. data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +53 -0
  134. data/vendor/deps/webrick/lib/webrick/httpproxy.rb +354 -0
  135. data/vendor/deps/webrick/lib/webrick/httprequest.rb +636 -0
  136. data/vendor/deps/webrick/lib/webrick/httpresponse.rb +564 -0
  137. data/vendor/deps/webrick/lib/webrick/https.rb +152 -0
  138. data/vendor/deps/webrick/lib/webrick/httpserver.rb +294 -0
  139. data/vendor/deps/webrick/lib/webrick/httpservlet.rb +23 -0
  140. data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +152 -0
  141. data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +47 -0
  142. data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +126 -0
  143. data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +88 -0
  144. data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +552 -0
  145. data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +47 -0
  146. data/vendor/deps/webrick/lib/webrick/httpstatus.rb +194 -0
  147. data/vendor/deps/webrick/lib/webrick/httputils.rb +512 -0
  148. data/vendor/deps/webrick/lib/webrick/httpversion.rb +76 -0
  149. data/vendor/deps/webrick/lib/webrick/log.rb +156 -0
  150. data/vendor/deps/webrick/lib/webrick/server.rb +381 -0
  151. data/vendor/deps/webrick/lib/webrick/ssl.rb +215 -0
  152. data/vendor/deps/webrick/lib/webrick/utils.rb +265 -0
  153. data/vendor/deps/webrick/lib/webrick/version.rb +18 -0
  154. data/vendor/deps/webrick/webrick.gemspec +74 -0
  155. metadata +70 -26
  156. data/docs/Gemfile +0 -5
  157. data/docs/Gemfile.lock +0 -258
  158. data/docs/_data/nav.yml +0 -35
  159. data/docs/_includes/footer.html +0 -15
  160. data/docs/_includes/head.html +0 -19
  161. data/docs/_includes/sidebar_nav.html +0 -22
  162. data/docs/_includes/toc.html +0 -112
  163. data/docs/_layouts/default.html +0 -79
  164. data/docs/css/docs.css +0 -157
  165. data/docs/images/header.png +0 -0
  166. data/docs/installing-ruby.md +0 -28
  167. data/lib/project_types/extension/features/argo/admin.rb +0 -20
  168. data/lib/project_types/extension/features/argo/base.rb +0 -129
  169. data/lib/project_types/extension/features/argo/checkout.rb +0 -20
  170. data/lib/project_types/extension/models/type.rb +0 -81
  171. data/lib/project_types/extension/models/types/checkout_post_purchase.rb +0 -23
  172. data/lib/project_types/extension/models/types/product_subscription.rb +0 -24
  173. data/lib/project_types/node/commands/generate/billing.rb +0 -39
  174. data/lib/project_types/node/commands/generate/page.rb +0 -59
  175. data/lib/project_types/node/commands/generate/webhook.rb +0 -37
  176. data/lib/project_types/script/layers/domain/script.rb +0 -18
  177. data/lib/project_types/script/layers/infrastructure/script_repository.rb +0 -47
  178. data/lib/project_types/script/templates/ts/as-pect.config.js +0 -27
  179. data/lib/project_types/script/templates/ts/as-pect.d.ts +0 -1
@@ -83,52 +83,17 @@ module Node
83
83
 
84
84
  generate: {
85
85
  help: <<~HELP,
86
- Generate code in your Node project. Supports generating new billing API calls, new pages, or new webhooks.
87
- Usage: {{command:%s generate [ billing | page | webhook ]}}
88
- HELP
89
- extended_help: <<~EXAMPLES,
90
- {{bold:Examples:}}
91
- {{cyan:%s generate webhook PRODUCTS_CREATE}}
92
- Generate and register a new webhook that will be called every time a new product is created on your store.
93
- EXAMPLES
94
-
95
- error: {
96
- name_exists: "%s already exists!",
97
- generic: "Error generating %s",
98
- },
99
-
100
- billing: {
101
- help: <<~HELP,
102
- Enable charging for your app. This command generates the necessary code to call Shopify’s billing API.
103
- Usage: {{command:%s generate billing [ one-time-billing | recurring-billing ]}}
104
- HELP
105
- type_select: "How would you like to charge for your app?",
106
- generating: "Generating %s code ...",
107
- generated: "{{green:%s}} generated in server/server.js",
108
- },
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}}
109
90
 
110
- page: {
111
- help: <<~HELP,
112
- Generate a new page in your app with the specified name. New files are generated inside the project’s “/pages” directory.
113
- Usage: {{command:%s generate page <pagename>}}
114
- HELP
115
- error: {
116
- invalid_page_type: "Invalid page type.",
117
- },
118
- type_select: "Which template would you like to use?",
119
- generating: "Generating %s page...",
120
- generated: "{{green: %s}} generated in pages/%s",
121
- },
91
+ {{green:webhook}}
92
+ Register and process webhooks: {{green:https://github.com/Shopify/shopify-node-api/blob/main/docs/usage/webhooks.md}}
122
93
 
123
- webhook: {
124
- help: <<~HELP,
125
- Generate and register a new webhook that listens for the specified Shopify store event.
126
- Usage: {{command:%s generate webhook <type>}}
127
- HELP
128
- type_select: "What type of webhook would you like to create?",
129
- generating: "Generating webhook: %s",
130
- generated: "{{green:%s}} generated in server/server.js",
131
- },
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
132
97
  },
133
98
 
134
99
  open: {
@@ -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
@@ -59,7 +60,9 @@ module Rails
59
60
 
60
61
  @ctx.puts(@ctx.message('apps.create.info.created', form.title, partners_url))
61
62
  @ctx.puts(@ctx.message('apps.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
62
- @ctx.puts(@ctx.message('apps.create.info.install', partners_url, form.title))
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
@@ -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,
@@ -39,7 +39,7 @@ module Rails
39
39
 
40
40
  error: {
41
41
  invalid_ruby_version: <<~MSG,
42
- This project requires a ruby version ~> 2.5.
42
+ This project requires a Ruby version ~> 2.5 or Ruby 3.0
43
43
  See {{underline:https://github.com/Shopify/shopify-app-cli/blob/master/docs/installing-ruby.md}}
44
44
  for our recommended method of installing ruby.
45
45
  MSG
@@ -42,22 +42,25 @@ module Script
42
42
  module Domain
43
43
  autoload :Errors, Project.project_filepath('layers/domain/errors')
44
44
  autoload :PushPackage, Project.project_filepath('layers/domain/push_package')
45
+ autoload :Metadata, Project.project_filepath('layers/domain/metadata')
45
46
  autoload :ExtensionPoint, Project.project_filepath('layers/domain/extension_point')
46
- autoload :Script, Project.project_filepath('layers/domain/script')
47
47
  end
48
48
 
49
49
  module Infrastructure
50
50
  autoload :Errors, Project.project_filepath('layers/infrastructure/errors')
51
51
  autoload :AssemblyScriptDependencyManager,
52
- Project.project_filepath('layers/infrastructure/assemblyscript_dependency_manager')
52
+ Project.project_filepath('layers/infrastructure/assemblyscript_dependency_manager')
53
53
  autoload :AssemblyScriptProjectCreator,
54
- Project.project_filepath('layers/infrastructure/assemblyscript_project_creator')
54
+ Project.project_filepath('layers/infrastructure/assemblyscript_project_creator')
55
55
  autoload :AssemblyScriptTaskRunner, Project.project_filepath('layers/infrastructure/assemblyscript_task_runner')
56
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
+
57
61
  autoload :PushPackageRepository, Project.project_filepath('layers/infrastructure/push_package_repository')
58
62
  autoload :ExtensionPointRepository, Project.project_filepath('layers/infrastructure/extension_point_repository')
59
63
  autoload :ProjectCreator, Project.project_filepath('layers/infrastructure/project_creator')
60
- autoload :ScriptRepository, Project.project_filepath('layers/infrastructure/script_repository')
61
64
  autoload :ScriptService, Project.project_filepath('layers/infrastructure/script_service')
62
65
  autoload :TaskRunner, Project.project_filepath('layers/infrastructure/task_runner')
63
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
@@ -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'))
@@ -1,25 +1,29 @@
1
1
  discount:
2
+ deprecated: true
2
3
  assemblyscript:
3
4
  package: "@shopify/extension-point-as-discount"
4
5
  sdk-version: "^7.0.0"
5
- toolchain-version: "^2.0.1"
6
+ toolchain-version: "^4.0.0"
6
7
  unit_limit_per_order:
7
8
  assemblyscript:
8
9
  package: "@shopify/extension-point-as-unit-limit-per-order"
9
10
  sdk-version: "^7.0.0"
10
- toolchain-version: "^2.0.1"
11
+ toolchain-version: "^4.0.0"
11
12
  payment_filter:
12
13
  assemblyscript:
13
14
  package: "@shopify/extension-point-as-payment-filter"
14
15
  sdk-version: "^7.0.0"
15
- toolchain-version: "^2.0.1"
16
+ toolchain-version: "^4.0.0"
17
+ rust:
18
+ beta: true
19
+ package: "https://github.com/Shopify/scripts-apis-rs"
16
20
  shipping_filter:
17
21
  assemblyscript:
18
22
  package: "@shopify/extension-point-as-shipping-filter"
19
23
  sdk-version: "^7.0.0"
20
- toolchain-version: "^2.0.1"
24
+ toolchain-version: "^4.0.0"
21
25
  tax_filter:
22
26
  assemblyscript:
23
27
  package: "@shopify/extension-point-as-tax-filter"
24
28
  sdk-version: "^7.0.0"
25
- toolchain-version: "^2.0.1"
29
+ toolchain-version: "^4.0.0"
@@ -25,5 +25,22 @@ module Script
25
25
  @config_file = config_file
26
26
  end
27
27
  end
28
+
29
+ class InvalidLanguageError < ScriptProjectError
30
+ attr_reader :language, :extension_point_type
31
+ def initialize(language, extension_point_type)
32
+ super()
33
+ @language = language
34
+ @extension_point_type = extension_point_type
35
+ end
36
+ end
37
+
38
+ class DeprecatedEPError < ScriptProjectError
39
+ attr_reader :ep
40
+ def initialize(ep)
41
+ super()
42
+ @ep = ep
43
+ end
44
+ end
28
45
  end
29
46
  end
@@ -3,11 +3,13 @@
3
3
  module Script
4
4
  module Forms
5
5
  class Create < ShopifyCli::Form
6
- flag_arguments :extension_point, :name
6
+ flag_arguments :extension_point, :name, :language, :description
7
7
 
8
8
  def ask
9
9
  self.name = valid_name
10
+ self.description ||= ask_description
10
11
  self.extension_point ||= ask_extension_point
12
+ self.language = ask_language
11
13
  end
12
14
 
13
15
  private
@@ -15,7 +17,7 @@ module Script
15
17
  def ask_extension_point
16
18
  CLI::UI::Prompt.ask(
17
19
  @ctx.message('script.forms.create.select_extension_point'),
18
- options: Script::Layers::Application::ExtensionPoints.types
20
+ options: Layers::Application::ExtensionPoints.non_deprecated_types
19
21
  )
20
22
  end
21
23
 
@@ -23,11 +25,33 @@ module Script
23
25
  CLI::UI::Prompt.ask(@ctx.message('script.forms.create.script_name'))
24
26
  end
25
27
 
28
+ def ask_description
29
+ CLI::UI::Prompt.ask(@ctx.message('script.forms.create.description'))
30
+ end
31
+
26
32
  def valid_name
27
33
  n = (name || ask_name).downcase.gsub(' ', '_')
28
34
  return n if n.match?(/^[0-9A-Za-z_-]*$/)
29
35
  raise Errors::InvalidScriptNameError
30
36
  end
37
+
38
+ def ask_language
39
+ if language
40
+ if Layers::Application::ExtensionPoints.supported_language?(type: extension_point, language: language)
41
+ return language.downcase
42
+ else
43
+ raise Errors::InvalidLanguageError.new(language, extension_point)
44
+ end
45
+ end
46
+
47
+ all_languages = Layers::Application::ExtensionPoints.languages(type: extension_point)
48
+ return all_languages.first if all_languages.count == 1
49
+
50
+ CLI::UI::Prompt.ask(
51
+ ctx.message('script.forms.create.select_language'),
52
+ options: all_languages
53
+ )
54
+ end
31
55
  end
32
56
  end
33
57
  end
@@ -1,16 +1,24 @@
1
1
  mutation AppScriptUpdateOrCreate(
2
2
  $extensionPointName: ExtensionPointName!,
3
3
  $title: String,
4
+ $description: String,
4
5
  $sourceCode: String,
5
6
  $language: String,
6
- $force: Boolean
7
+ $force: Boolean,
8
+ $schemaMajorVersion: String,
9
+ $schemaMinorVersion: String,
10
+ $useMsgpack: Boolean
7
11
  ) {
8
12
  appScriptUpdateOrCreate(
9
13
  extensionPointName: $extensionPointName
10
14
  title: $title
15
+ description: $description
11
16
  sourceCode: $sourceCode
12
17
  language: $language
13
18
  force: $force
19
+ schemaMajorVersion: $schemaMajorVersion
20
+ schemaMinorVersion: $schemaMinorVersion
21
+ useMsgpack: $useMsgpack
14
22
  ) {
15
23
  userErrors {
16
24
  field
@@ -22,6 +30,7 @@ mutation AppScriptUpdateOrCreate(
22
30
  configSchema
23
31
  extensionPointName
24
32
  title
33
+ description
25
34
  }
26
35
  }
27
36
  }
@@ -5,13 +5,18 @@ module Script
5
5
  module Application
6
6
  class BuildScript
7
7
  class << self
8
- def call(ctx:, task_runner:, script:)
8
+ def call(ctx:, task_runner:, script_name:, description:, extension_point_type:)
9
9
  CLI::UI::Frame.open(ctx.message('script.application.building')) do
10
10
  begin
11
11
  UI::StrictSpinner.spin(ctx.message('script.application.building_script')) do |spinner|
12
- Infrastructure::PushPackageRepository
13
- .new(ctx: ctx)
14
- .create_push_package(script, task_runner.build, task_runner.compiled_type)
12
+ Infrastructure::PushPackageRepository.new(ctx: ctx).create_push_package(
13
+ extension_point_type: extension_point_type,
14
+ script_name: script_name,
15
+ description: description,
16
+ script_content: task_runner.build,
17
+ compiled_type: task_runner.compiled_type,
18
+ metadata: task_runner.metadata
19
+ )
15
20
  spinner.update_title(ctx.message('script.application.built'))
16
21
  end
17
22
  rescue StandardError => e
@@ -7,40 +7,42 @@ module Script
7
7
  module Application
8
8
  class CreateScript
9
9
  class << self
10
- def call(ctx:, language:, script_name:, extension_point_type:)
10
+ def call(ctx:, language:, script_name:, extension_point_type:, description:)
11
11
  extension_point = ExtensionPoints.get(type: extension_point_type)
12
- project = setup_project(ctx, script_name, extension_point)
12
+ project = setup_project(ctx, language, script_name, extension_point, description)
13
13
  project_creator = Infrastructure::ProjectCreator
14
14
  .for(ctx, language, extension_point, script_name, project.directory)
15
- install_dependencies(ctx, language, script_name, project.source_file, project_creator)
16
- bootstrap(ctx, project.source_path, project_creator)
15
+ install_dependencies(ctx, language, script_name, project_creator)
16
+ bootstrap(ctx, project_creator)
17
17
  project
18
18
  end
19
19
 
20
20
  private
21
21
 
22
- def setup_project(ctx, script_name, extension_point)
22
+ def setup_project(ctx, language, script_name, extension_point, description)
23
23
  ScriptProject.create(ctx, script_name)
24
24
  ScriptProject.write(
25
25
  ctx,
26
26
  project_type: :script,
27
27
  organization_id: nil, # TODO: can you provide this at creation
28
28
  extension_point_type: extension_point.type,
29
- script_name: script_name
29
+ script_name: script_name,
30
+ language: language,
31
+ description: description
30
32
  )
31
33
  ScriptProject.current
32
34
  end
33
35
 
34
- def install_dependencies(ctx, language, script_name, source_file, project_creator)
35
- task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name, source_file)
36
+ def install_dependencies(ctx, language, script_name, project_creator)
37
+ task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name)
36
38
  project_creator.setup_dependencies
37
39
  ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
38
40
  end
39
41
 
40
- def bootstrap(ctx, source_path, project_creator)
42
+ def bootstrap(ctx, project_creator)
41
43
  UI::StrictSpinner.spin(ctx.message('script.create.creating')) do |spinner|
42
44
  project_creator.bootstrap
43
- spinner.update_title(ctx.message('script.create.created', source_path))
45
+ spinner.update_title(ctx.message('script.create.created'))
44
46
  end
45
47
  end
46
48
  end