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
@@ -1,24 +1,29 @@
1
1
  discount:
2
+ deprecated: true
2
3
  assemblyscript:
3
4
  package: "@shopify/extension-point-as-discount"
4
- version: "^0.2.10"
5
- sdk-version: "^6.0.0"
6
- toolchain-version: "^1.1.0"
5
+ sdk-version: "^7.0.0"
6
+ toolchain-version: "^4.0.0"
7
7
  unit_limit_per_order:
8
8
  assemblyscript:
9
9
  package: "@shopify/extension-point-as-unit-limit-per-order"
10
- version: "^0.1.12"
11
- sdk-version: "^6.0.0"
12
- toolchain-version: "^1.1.0"
10
+ sdk-version: "^7.0.0"
11
+ toolchain-version: "^4.0.0"
13
12
  payment_filter:
14
13
  assemblyscript:
15
14
  package: "@shopify/extension-point-as-payment-filter"
16
- version: "^0.2.8"
17
- sdk-version: "^6.0.0"
18
- toolchain-version: "^1.1.0"
15
+ sdk-version: "^7.0.0"
16
+ toolchain-version: "^4.0.0"
17
+ rust:
18
+ beta: true
19
+ package: "https://github.com/Shopify/scripts-apis-rs"
19
20
  shipping_filter:
20
21
  assemblyscript:
21
22
  package: "@shopify/extension-point-as-shipping-filter"
22
- version: "^0.2.10"
23
- sdk-version: "^6.0.0"
24
- toolchain-version: "^1.1.0"
23
+ sdk-version: "^7.0.0"
24
+ toolchain-version: "^4.0.0"
25
+ tax_filter:
26
+ assemblyscript:
27
+ package: "@shopify/extension-point-as-tax-filter"
28
+ sdk-version: "^7.0.0"
29
+ toolchain-version: "^4.0.0"
@@ -6,6 +6,7 @@ module Script
6
6
  class InvalidScriptNameError < ScriptProjectError; end
7
7
  class NoExistingAppsError < ScriptProjectError; end
8
8
  class NoExistingOrganizationsError < ScriptProjectError; end
9
+
9
10
  class NoExistingStoresError < ScriptProjectError
10
11
  attr_reader :organization_id
11
12
  def initialize(organization_id)
@@ -13,7 +14,10 @@ module Script
13
14
  @organization_id = organization_id
14
15
  end
15
16
  end
17
+
16
18
  class ScriptProjectAlreadyExistsError < ScriptProjectError; end
19
+ class InvalidConfigProps < ScriptProjectError; end
20
+
17
21
  class InvalidConfigYAMLError < ScriptProjectError
18
22
  attr_reader :config_file
19
23
  def initialize(config_file)
@@ -21,5 +25,22 @@ module Script
21
25
  @config_file = config_file
22
26
  end
23
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
24
45
  end
25
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,33 +5,34 @@ module Script
5
5
  module Application
6
6
  class BuildScript
7
7
  class << self
8
- def call(ctx:, task_runner:, script:)
9
- return if CLI::UI::Frame.open(ctx.message('script.application.building')) do
8
+ def call(ctx:, task_runner:, script_name:, description:, extension_point_type:)
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
- build(ctx, task_runner, script)
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
+ )
13
20
  spinner.update_title(ctx.message('script.application.built'))
14
21
  end
15
- true
16
22
  rescue StandardError => e
17
23
  CLI::UI::Frame.with_frame_color_override(:red) do
18
24
  ctx.puts("\n{{red:#{e.message}}}")
19
25
  end
20
- false
21
- end
22
- end
23
- raise Infrastructure::Errors::BuildError
24
- end
26
+ errors = [
27
+ Infrastructure::Errors::InvalidBuildScriptError,
28
+ Infrastructure::Errors::BuildScriptNotFoundError,
29
+ Infrastructure::Errors::WebAssemblyBinaryNotFoundError,
30
+ ]
25
31
 
26
- private
27
-
28
- def build(ctx, task_runner, script)
29
- script_repo = Infrastructure::ScriptRepository.new(ctx: ctx)
30
- script_content = script_repo.with_temp_build_context do
31
- task_runner.build
32
+ raise Infrastructure::Errors::BuildError unless errors.any? { |err| e.is_a?(err) }
33
+ raise
34
+ end
32
35
  end
33
- Infrastructure::PushPackageRepository.new(ctx: ctx)
34
- .create_push_package(script, script_content, task_runner.compiled_type)
35
36
  end
36
37
  end
37
38
  end
@@ -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
@@ -11,6 +11,30 @@ module Script
11
11
  def self.types
12
12
  Infrastructure::ExtensionPointRepository.new.extension_point_types
13
13
  end
14
+
15
+ def self.non_deprecated_types
16
+ Infrastructure::ExtensionPointRepository.new.extension_points.select do |ep|
17
+ !ep.deprecated?
18
+ end.map(&:type)
19
+ end
20
+
21
+ def self.deprecated_types
22
+ Infrastructure::ExtensionPointRepository.new
23
+ .extension_points
24
+ .select(&:deprecated?)
25
+ .map(&:type)
26
+ end
27
+
28
+ def self.languages(type:)
29
+ get(type: type).sdks.all.map do |sdk|
30
+ next nil if sdk.beta? && !ShopifyCli::Feature.enabled?(:scripts_beta_languages)
31
+ sdk.class.language
32
+ end.compact
33
+ end
34
+
35
+ def self.supported_language?(type:, language:)
36
+ languages(type: type).include?(language.downcase)
37
+ end
14
38
  end
15
39
  end
16
40
  end
@@ -5,25 +5,27 @@ module Script
5
5
  module Application
6
6
  class PushScript
7
7
  class << self
8
- def call(ctx:, language:, extension_point_type:, script_name:, source_file:, api_key:, force:)
9
- script = Infrastructure::ScriptRepository.new(ctx: ctx).get_script(
10
- language,
11
- extension_point_type,
12
- script_name
13
- )
14
- task_runner = Infrastructure::TaskRunner.for(ctx, language, script_name, source_file)
8
+ def call(ctx:, force:)
9
+ script_project = ScriptProject.current
10
+ task_runner = Infrastructure::TaskRunner.for(ctx, script_project.language, script_project.script_name)
15
11
  ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
16
- BuildScript.call(ctx: ctx, task_runner: task_runner, script: script)
17
- push_script(ctx, task_runner, script, api_key, force)
18
- end
19
-
20
- private
12
+ BuildScript.call(
13
+ ctx: ctx,
14
+ task_runner: task_runner,
15
+ extension_point_type: script_project.extension_point_type,
16
+ script_name: script_project.script_name,
17
+ description: script_project.description
18
+ )
21
19
 
22
- def push_script(ctx, task_runner, script, api_key, force)
23
20
  UI::PrintingSpinner.spin(ctx, ctx.message('script.application.pushing')) do |p_ctx, spinner|
24
- Infrastructure::PushPackageRepository.new(ctx: p_ctx)
25
- .get_push_package(script, task_runner.compiled_type)
26
- .push(Infrastructure::ScriptService.new(ctx: p_ctx), api_key, force)
21
+ package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
22
+ extension_point_type: script_project.extension_point_type,
23
+ script_name: script_project.script_name,
24
+ description: script_project.description,
25
+ compiled_type: task_runner.compiled_type,
26
+ metadata: task_runner.metadata
27
+ )
28
+ package.push(Infrastructure::ScriptService.new(ctx: p_ctx), script_project.api_key, force)
27
29
  spinner.update_title(p_ctx.message('script.application.pushed'))
28
30
  end
29
31
  end
@@ -5,6 +5,7 @@ module Script
5
5
  module Domain
6
6
  module Errors
7
7
  class PushPackageNotFoundError < ScriptProjectError; end
8
+
8
9
  class InvalidExtensionPointError < ScriptProjectError
9
10
  attr_reader :type
10
11
  def initialize(type)
@@ -12,6 +13,7 @@ module Script
12
13
  @type = type
13
14
  end
14
15
  end
16
+
15
17
  class ScriptNotFoundError < ScriptProjectError
16
18
  attr_reader :script_name, :extension_point_type
17
19
  def initialize(extension_point_type, script_name)
@@ -20,7 +22,12 @@ module Script
20
22
  @extension_point_type = extension_point_type
21
23
  end
22
24
  end
25
+
23
26
  class ServiceFailureError < ScriptProjectError; end
27
+
28
+ class MetadataNotFoundError < ScriptProjectError; end
29
+
30
+ class MetadataValidationError < ScriptProjectError; end
24
31
  end
25
32
  end
26
33
  end
@@ -4,25 +4,80 @@ module Script
4
4
  module Layers
5
5
  module Domain
6
6
  class ExtensionPoint
7
- attr_reader :type, :sdks
7
+ attr_reader :type, :deprecated, :sdks
8
8
 
9
9
  def initialize(type, config)
10
10
  @type = type
11
- @sdks = {
12
- ts: ExtensionPointAssemblyScriptSDK.new(config["assemblyscript"]),
13
- }
11
+ @deprecated = config["deprecated"] || false
12
+ @sdks = ExtensionPointSDKs.new(config)
13
+ end
14
+
15
+ def deprecated?
16
+ @deprecated
17
+ end
18
+ end
19
+
20
+ class ExtensionPointSDKs
21
+ def initialize(config)
22
+ @config = config
23
+ end
24
+
25
+ def all
26
+ [assemblyscript, rust].compact
27
+ end
28
+
29
+ def assemblyscript
30
+ @assemblyscript ||= new_sdk(ExtensionPointAssemblyScriptSDK)
31
+ end
32
+
33
+ def rust
34
+ @rust ||= new_sdk(ExtensionPointRustSDK)
35
+ end
36
+
37
+ private
38
+
39
+ def new_sdk(klass)
40
+ config = @config[klass.language]
41
+ return nil if config.nil?
42
+ klass.new(config)
14
43
  end
15
44
  end
16
45
 
17
- class ExtensionPointAssemblyScriptSDK
18
- attr_reader :package, :version, :sdk_version, :toolchain_version
46
+ class ExtensionPointSDK
47
+ attr_reader :beta, :package
19
48
 
20
49
  def initialize(config)
50
+ @beta = config["beta"] || false
21
51
  @package = config["package"]
22
- @version = config["version"]
52
+ end
53
+
54
+ def beta?
55
+ @beta
56
+ end
57
+
58
+ def self.language
59
+ raise NotImplementedError
60
+ end
61
+ end
62
+
63
+ class ExtensionPointAssemblyScriptSDK < ExtensionPointSDK
64
+ attr_reader :sdk_version, :toolchain_version
65
+
66
+ def initialize(config)
67
+ super
23
68
  @sdk_version = config["sdk-version"]
24
69
  @toolchain_version = config["toolchain-version"]
25
70
  end
71
+
72
+ def self.language
73
+ "assemblyscript"
74
+ end
75
+ end
76
+
77
+ class ExtensionPointRustSDK < ExtensionPointSDK
78
+ def self.language
79
+ "rust"
80
+ end
26
81
  end
27
82
  end
28
83
  end