shopify-cli 2.8.0 → 2.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +18 -0
  3. data/CHANGELOG.md +34 -0
  4. data/Gemfile.lock +1 -1
  5. data/RELEASING.md +4 -3
  6. data/ext/javy/javy.rb +1 -1
  7. data/lib/project_types/extension/commands/push.rb +2 -2
  8. data/lib/project_types/extension/messages/messages.rb +1 -1
  9. data/lib/project_types/extension/models/development_server.rb +2 -4
  10. data/lib/project_types/rails/gem.rb +1 -2
  11. data/lib/project_types/script/cli.rb +10 -0
  12. data/lib/project_types/script/commands/connect.rb +1 -1
  13. data/lib/project_types/script/commands/create.rb +8 -2
  14. data/lib/project_types/script/commands/push.rb +35 -12
  15. data/lib/project_types/script/config/extension_points.yml +12 -0
  16. data/lib/project_types/script/graphql/app_script_set.graphql +2 -0
  17. data/lib/project_types/script/graphql/module_upload_url_generate.graphql +5 -1
  18. data/lib/project_types/script/layers/application/build_script.rb +6 -3
  19. data/lib/project_types/script/layers/application/connect_app.rb +11 -5
  20. data/lib/project_types/script/layers/application/extension_points.rb +50 -26
  21. data/lib/project_types/script/layers/application/project_dependencies.rb +1 -1
  22. data/lib/project_types/script/layers/application/push_script.rb +41 -30
  23. data/lib/project_types/script/layers/domain/errors.rb +10 -3
  24. data/lib/project_types/script/layers/domain/extension_point.rb +16 -2
  25. data/lib/project_types/script/layers/domain/push_package.rb +0 -3
  26. data/lib/project_types/script/layers/domain/script_config.rb +6 -4
  27. data/lib/project_types/script/layers/domain/script_project.rb +1 -0
  28. data/lib/project_types/script/layers/infrastructure/errors.rb +47 -23
  29. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +2 -12
  30. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +1 -0
  31. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +1 -0
  32. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +2 -12
  33. data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +15 -0
  34. data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +36 -0
  35. data/lib/project_types/script/layers/infrastructure/metadata_repository.rb +18 -0
  36. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +7 -8
  37. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +45 -54
  38. data/lib/project_types/script/layers/infrastructure/script_service.rb +35 -12
  39. data/lib/project_types/script/layers/infrastructure/script_uploader.rb +22 -9
  40. data/lib/project_types/script/loaders/project.rb +44 -0
  41. data/lib/project_types/script/loaders/specification_handler.rb +22 -0
  42. data/lib/project_types/script/messages/messages.rb +38 -19
  43. data/lib/project_types/script/ui/error_handler.rb +52 -30
  44. data/lib/project_types/theme/commands/pull.rb +45 -17
  45. data/lib/project_types/theme/commands/push.rb +62 -27
  46. data/lib/project_types/theme/commands/serve.rb +5 -0
  47. data/lib/project_types/theme/messages/messages.rb +33 -18
  48. data/lib/shopify_cli/constants.rb +7 -2
  49. data/lib/shopify_cli/context.rb +66 -12
  50. data/lib/shopify_cli/core/executor.rb +4 -4
  51. data/lib/shopify_cli/environment.rb +50 -20
  52. data/lib/shopify_cli/identity_auth.rb +4 -3
  53. data/lib/shopify_cli/messages/messages.rb +2 -0
  54. data/lib/shopify_cli/method_object.rb +21 -9
  55. data/lib/shopify_cli/resources/env_file.rb +5 -1
  56. data/lib/shopify_cli/result.rb +61 -59
  57. data/lib/shopify_cli/task.rb +5 -3
  58. data/lib/shopify_cli/theme/dev_server/hot-reload.js +19 -1
  59. data/lib/shopify_cli/theme/dev_server/hot_reload.rb +18 -2
  60. data/lib/shopify_cli/theme/dev_server/proxy.rb +1 -0
  61. data/lib/shopify_cli/theme/dev_server/reload_mode.rb +34 -0
  62. data/lib/shopify_cli/theme/dev_server.rb +6 -21
  63. data/lib/shopify_cli/theme/file.rb +2 -2
  64. data/lib/shopify_cli/theme/filter/path_matcher.rb +38 -0
  65. data/lib/shopify_cli/theme/ignore_filter.rb +14 -18
  66. data/lib/shopify_cli/theme/include_filter.rb +43 -0
  67. data/lib/shopify_cli/theme/syncer.rb +17 -2
  68. data/lib/shopify_cli/theme/theme.rb +26 -4
  69. data/lib/shopify_cli/version.rb +1 -1
  70. data/lib/shopify_cli.rb +6 -1
  71. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +10 -5
  72. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +6 -4
  73. data/vendor/deps/ruby2_keywords/LICENSE +22 -0
  74. data/vendor/deps/ruby2_keywords/README.md +67 -0
  75. data/vendor/deps/ruby2_keywords/Rakefile +54 -0
  76. data/vendor/deps/ruby2_keywords/lib/ruby2_keywords.rb +57 -0
  77. data/vendor/deps/ruby2_keywords/ruby2_keywords.gemspec +18 -0
  78. data/vendor/deps/ruby2_keywords/test/test_keyword.rb +41 -0
  79. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44313f65cde9217bac879066a57be593752c7d791d272d1ada078bc4a876f24c
4
- data.tar.gz: bcb6ac1b939ee13ccec83eb74814ceddb1cb2d11661f516327ca2f0d294795a3
3
+ metadata.gz: 0cd807b7755484c50b506a5b4af90072b08ac0f9fc2aaff6c684f0fe5e6b63cc
4
+ data.tar.gz: 76aaf43ba5f6af3a6c9ed5f2f73b0d79cb03261d544602996b9563cd45f4b572
5
5
  SHA512:
6
- metadata.gz: 77f0ea5bef5ce778e87c9414c4ec1712795ef144e603bf22f88975d5f86dab2f4d43052522f18302be1ac836b3b2b98cb2f66ea9d413d93214da365895d3a2b5
7
- data.tar.gz: 7cc5de0ba35117ae63a6cbb9e6d761695a75166cb15a996fd6545ba981e1809f60e9e42ad2d13e59a837310b11328b693744eb9547e90a0a8f537fd6640ba206
6
+ metadata.gz: 407ad8f61eebbfcfbf4c6099eef78a41544ed95002cf7f91fbd9cd56aa473cc1ab6ea323812032c3f21d09760bdcd824908ce9ba1f069ed492997b0cdf3d5853
7
+ data.tar.gz: 91ae64882ee0e7969bf93697dda900fb812009df58eeff176833e3e609e51f37fa67f418c1b80be670f852a6594308fc0e89e43a477105b316943827f80ad780
@@ -1,3 +1,21 @@
1
+ <!--
2
+
3
+ Hi! 👋 Thanks for taking the time to open an issue.
4
+
5
+ BEFORE SUBMITTING YOUR ISSUE, please ensure that:
6
+
7
+ 1. You've searched the existing issues to see if someone else has already submitted the same thing. You can access the list at: https://github.com/Shopify/shopify-cli/issues (and feel free to add any additional information in a comment!)
8
+ 2. You've given as much detail as reasonably possible
9
+ 3. You're working with the latest CLI version (check the badge at https://github.com/Shopify/shopify-cli)
10
+
11
+ This is important because:
12
+
13
+ 1. We will notice and prioritize 1 popular issue more quickly than many small duplicates
14
+ 2. More details = faster, higher-quality response
15
+ 3. We might have fixed your issue already!
16
+
17
+ -->
18
+
1
19
  # Issue summary
2
20
 
3
21
  Write a short description of the issue here ↓
data/CHANGELOG.md CHANGED
@@ -2,6 +2,40 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## Version 2.10.2
6
+ ### Fixed
7
+ * [#1983](https://github.com/Shopify/shopify-cli/pull/1983): Improve Windows compatibility
8
+ * [#1928](https://github.com/Shopify/shopify-cli/pull/1928): Ensure script Wasm file sizes don't exceed the limit
9
+
10
+ ## Version 2.10.1
11
+ ### Fixed
12
+ * [#1985](https://github.com/Shopify/shopify-cli/pull/1985): Revert "Fix CORS (Cross-origin resource sharing) errors (#1952)"
13
+
14
+ ## Version 2.10.0
15
+ ### Fixed
16
+ * [#1937](https://github.com/Shopify/shopify-cli/pull/1937): Fix `theme pull` to no longer add empty lines on Windows
17
+ * [#1952](https://github.com/Shopify/shopify-cli/pull/1952): Fix CORS (cross-origin resource sharing) errors
18
+ * [#1965](https://github.com/Shopify/shopify-cli/pull/1965): Revert: Fix partners ability to login to external shops. (#1873)
19
+
20
+ ### Added
21
+ * [#1892](https://github.com/Shopify/shopify-cli/pull/1892): Add `-o`/`--only` parameter to filter files on `theme push`/`theme pull` commands
22
+
23
+ ## Version 2.9.0
24
+ ### Fixed
25
+ * [#1922](https://github.com/Shopify/shopify-cli/pull/1922): Respect RUBY_BINDIR from Homebrew for installing gem
26
+ * [#1906](https://github.com/Shopify/shopify-cli/pull/1906): Fix Ngrok incompatibility with some Apple ARM environments
27
+ * [#1873](https://github.com/Shopify/shopify-cli/pull/1873): Fix partners ability to login to external shops.
28
+ * [#1909](https://github.com/Shopify/shopify-cli/pull/1909): Fix `theme serve` on Safari
29
+
30
+ ### Added
31
+ * [#1900](https://github.com/Shopify/shopify-cli/pull/1900): Add `-d`/`--development` flag to Shopify theme pull command
32
+ * [#1891](https://github.com/Shopify/shopify-cli/pull/1891): Allow for additional arguments in `shopify push script` on CI.
33
+ * [#1877](https://github.com/Shopify/shopify-cli/pull/1877): Add theme (`-t`/`--theme=NAME_OR_ID`) parameter to `theme push`/`theme pull` commands
34
+ * [#1871](https://github.com/Shopify/shopify-cli/pull/1871): Add a new `--live-reload` parameter to the `theme serve` command
35
+
36
+ ### Changed
37
+ - [#1929](https://github.com/Shopify/shopify-cli/pull/1929): Rename `--registration-id` to `--extension-id` in `shopify extension push`.
38
+
5
39
  ## Version 2.8.0
6
40
  ### Fixed
7
41
  * [#1879](https://github.com/Shopify/shopify-cli/pull/1879): Disambiguate -s as store option
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.8.0)
4
+ shopify-cli (2.10.2)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
7
  theme-check (~> 1.9.0)
data/RELEASING.md CHANGED
@@ -23,21 +23,22 @@
23
23
  ```
24
24
 
25
25
  9. Open a PR for the branch, get necessary approvals from code owners and merge into main branch. Note that the PR title will be the release note in Shipit, so make sure it mentions the release
26
- 10. Deploy using Shipit
26
+ 10. Deploy to RubyGems using [Shipit](https://shipit.shopify.io/shopify/shopify-cli/rubygems)
27
27
  11. Update your `main` branch to the latest version
28
28
  ```
29
29
  $ git checkout main
30
30
  $ git pull
31
31
  ```
32
32
 
33
- 12. On local machine and _AFTER_ gem has been published to https://rubygems.org, run
33
+ 12. On local machine and _AFTER_ gem has been published to https://rubygems.org/gems/shopify-cli, run
34
34
  ```
35
35
  $ rake package
36
36
  ```
37
37
  This will generate the `.deb`, `.rpm` and brew formula files, which will be located in `packaging/builds/X.Y.Z/`.
38
38
 
39
39
  13. Clone the `Shopify/homebrew-shopify` repository (if not already cloned), and then
40
- * create a branch named `release_X_Y_Z_of_shopify-cli`
40
+ * update your `master` branch to the latest version: `git checkout master && git pull`
41
+ * create a new branch: `git checkout -b release_X_Y_Z_of_shopify-cli`
41
42
  * update the brew formula in `shopify-cli.rb` with the generated formula in `packaging/builds/X.Y.Z/` in the `Shopify/shopify-cli` repo (from the `rake package` step above)
42
43
  * commit the change and create a PR on the [Shopify Homebrew repository](https://github.com/Shopify/homebrew-shopify)
43
44
  * when PR is approved, merge into main branch
data/ext/javy/javy.rb CHANGED
@@ -5,7 +5,7 @@ require "digest/sha2"
5
5
 
6
6
  module Javy
7
7
  ROOT = __dir__
8
- BIN_FOLDER = File.join(ROOT, "bin")
8
+ BIN_FOLDER = File.join(ShopifyCLI.cache_dir, "javy", "bin")
9
9
  HASH_FOLDER = File.join(ROOT, "hashes")
10
10
  VERSION = File.read(File.join(ROOT, "version")).strip
11
11
  TARGET = File.join(BIN_FOLDER, "javy-#{VERSION}")
@@ -9,7 +9,7 @@ module Extension
9
9
  options do |parser, flags|
10
10
  parser.on("--api-key=API_KEY") { |api_key| flags[:api_key] = api_key.gsub('"', "") }
11
11
  parser.on("--api-secret=API_SECRET") { |api_secret| flags[:api_secret] = api_secret.gsub('"', "") }
12
- parser.on("--registration-id=REGISTRATION_ID") do |registration_id|
12
+ parser.on("--extension-id=EXTENSION_ID") do |registration_id|
13
13
  flags[:registration_id] = registration_id.gsub('"', "")
14
14
  end
15
15
  end
@@ -35,7 +35,7 @@ module Extension
35
35
  end
36
36
 
37
37
  def register_if_necessary(project:, args:, name:)
38
- if @ctx.tty? && !project.registered?
38
+ if ShopifyCLI::Environment.interactive? && !project.registered?
39
39
  Command::Register.new(@ctx).call(args, name)
40
40
  end
41
41
  end
@@ -91,7 +91,7 @@ module Extension
91
91
  Usage: {{command:%s extension push}}
92
92
  Options:
93
93
  {{command:--api-key=API_KEY}} Connect your extension and app by inserting your app's API key (which you can get from your app setup page on shopify.dev).
94
- {{command:--registration-id=REGISTRATION_ID}} The id of the extension's registration.
94
+ {{command:--extension-id=EXTENSION_ID}} The id of the extension's registration.
95
95
  HELP
96
96
  frame_title: "Pushing your extension to Shopify",
97
97
  waiting_text: "Pushing code to Shopify…",
@@ -40,7 +40,7 @@ module Extension
40
40
 
41
41
  def serve(context, server_config)
42
42
  CLI::Kit::System.popen3(executable, "serve", "-") do |input, out, err, status|
43
- context.puts("Sending configuration data …")
43
+ context.debug("Sending configuration data to extension development server …")
44
44
  input << server_config.to_yaml
45
45
  input.close
46
46
 
@@ -57,17 +57,15 @@ module Extension
57
57
  private
58
58
 
59
59
  def forward_output_to_user(out, err, ctx)
60
- ctx.puts("Starting monitoring threads …")
60
+ ctx.debug("Starting message processing threads to relay output produced by the extension development server …")
61
61
 
62
62
  Thread.new do
63
- ctx.puts("Ready to process standard output")
64
63
  while (line = out.gets)
65
64
  ctx.puts(line)
66
65
  end
67
66
  end
68
67
 
69
68
  Thread.new do
70
- ctx.puts("Ready to process standard error")
71
69
  while (error = err.gets)
72
70
  ctx.puts(error)
73
71
  end
@@ -79,8 +79,7 @@ module Rails
79
79
  def install!
80
80
  spin = CLI::UI::SpinGroup.new
81
81
  spin.add(ctx.message("rails.gem.installing", name)) do |spinner|
82
- args = %w(gem install)
83
- args.push(name)
82
+ args = ["#{ENV["RUBY_BINDIR"]}gem", "install", name]
84
83
  unless version.nil?
85
84
  if ctx.windows? && version.include?("~")
86
85
  args.push("-v", "\"#{version}\"")
@@ -57,6 +57,7 @@ module Script
57
57
  autoload :CommandRunner, Project.project_filepath("layers/infrastructure/command_runner")
58
58
  autoload :PushPackageRepository, Project.project_filepath("layers/infrastructure/push_package_repository")
59
59
  autoload :ExtensionPointRepository, Project.project_filepath("layers/infrastructure/extension_point_repository")
60
+ autoload :MetadataRepository, Project.project_filepath("layers/infrastructure/metadata_repository")
60
61
  autoload :ScriptProjectRepository, Project.project_filepath("layers/infrastructure/script_project_repository")
61
62
  autoload :ScriptService, Project.project_filepath("layers/infrastructure/script_service")
62
63
  autoload :ScriptUploader, Project.project_filepath("layers/infrastructure/script_uploader")
@@ -73,6 +74,10 @@ module Script
73
74
  Project.project_filepath("layers/infrastructure/languages/typescript_project_creator.rb")
74
75
  autoload :TypeScriptTaskRunner,
75
76
  Project.project_filepath("layers/infrastructure/languages/typescript_task_runner.rb")
77
+ autoload :WasmProjectCreator,
78
+ Project.project_filepath("layers/infrastructure/languages/wasm_project_creator.rb")
79
+ autoload :WasmTaskRunner,
80
+ Project.project_filepath("layers/infrastructure/languages/wasm_task_runner.rb")
76
81
  end
77
82
 
78
83
  module ApiClients
@@ -92,5 +97,10 @@ module Script
92
97
 
93
98
  autoload :Errors, Project.project_filepath("errors")
94
99
 
100
+ module Loaders
101
+ autoload :Project, Script::Project.project_filepath("loaders/project")
102
+ autoload :SpecificationHandler, Script::Project.project_filepath("loaders/specification_handler")
103
+ end
104
+
95
105
  class ScriptProjectError < StandardError; end
96
106
  end
@@ -6,7 +6,7 @@ module Script
6
6
  prerequisite_task ensure_project_type: :script
7
7
 
8
8
  def call(_args, _)
9
- Layers::Application::ConnectApp.call(ctx: @ctx, force: true, strict: true)
9
+ Layers::Application::ConnectApp.call(ctx: @ctx, force: true)
10
10
  rescue StandardError => e
11
11
  UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.connect.error.operation_failed"))
12
12
  end
@@ -33,8 +33,14 @@ module Script
33
33
  end
34
34
 
35
35
  def self.help
36
- allowed_values = Script::Layers::Application::ExtensionPoints.available_types.map { |type| "{{cyan:#{type}}}" }
37
- ShopifyCLI::Context.message("script.create.help", ShopifyCLI::TOOL_NAME, allowed_values.join(", "))
36
+ allowed_apis = Layers::Application::ExtensionPoints.available_types.map { |type| "{{cyan:#{type}}}" }
37
+ allowed_languages = Layers::Application::ExtensionPoints.all_languages.map { |lang| "{{cyan:#{lang}}}" }
38
+ ShopifyCLI::Context.message(
39
+ "script.create.help",
40
+ ShopifyCLI::TOOL_NAME,
41
+ allowed_apis.join(", "),
42
+ allowed_languages.join(", ")
43
+ )
38
44
  end
39
45
  end
40
46
  end
@@ -7,25 +7,48 @@ module Script
7
7
 
8
8
  options do |parser, flags|
9
9
  parser.on("--force") { |t| flags[:force] = t }
10
+ parser.on("--api-key=API_KEY") { |api_key| flags[:api_key] = api_key.gsub('"', "") }
11
+ parser.on("--api-secret=API_SECRET") { |api_secret| flags[:api_secret] = api_secret.gsub('"', "") }
12
+ parser.on("--uuid=UUID") do |uuid|
13
+ flags[:uuid] = uuid.gsub('""', "")
14
+ end
10
15
  end
11
16
 
12
17
  def call(_args, _name)
13
- fresh_env = Layers::Application::ConnectApp.call(ctx: @ctx)
14
-
15
- force = options.flags.key?(:force) || !!fresh_env
18
+ connect_to_app
19
+ project = load_project
20
+ push(project: project)
21
+ rescue StandardError => e
22
+ UI::ErrorHandler.pretty_print_and_raise(e,
23
+ failed_op: @ctx.message("script.push.error.operation_failed_no_api_key"))
24
+ end
16
25
 
17
- api_key = Layers::Infrastructure::ScriptProjectRepository.new(ctx: @ctx).get.api_key
18
- return @ctx.puts(self.class.help) unless api_key
26
+ def push(project:)
27
+ force = options.flags.key?(:force)
28
+ api_key = project.env[:api_key]
29
+ uuid = project.env[:extra]["UUID"]
19
30
 
20
- Layers::Application::PushScript.call(ctx: @ctx, force: force)
21
- @ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
22
- rescue StandardError => e
23
- msg = if api_key
24
- @ctx.message("script.push.error.operation_failed_with_api_key", api_key: api_key)
31
+ if ShopifyCLI::Environment.interactive? || (uuid && !uuid.empty?)
32
+ Layers::Application::PushScript.call(ctx: @ctx, force: force, project: project)
33
+ @ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
25
34
  else
26
- @ctx.message("script.push.error.operation_failed_no_api_key")
35
+ raise ShopifyCLI::Abort, @ctx.message("script.push.error.operation_failed_no_uuid")
36
+ end
37
+ end
38
+
39
+ def load_project
40
+ Script::Loaders::Project.load(
41
+ directory: Dir.pwd,
42
+ api_key: options.flags[:api_key],
43
+ api_secret: options.flags[:api_secret],
44
+ uuid: options.flags[:uuid]
45
+ )
46
+ end
47
+
48
+ def connect_to_app
49
+ if ShopifyCLI::Environment.interactive?
50
+ Layers::Application::ConnectApp.call(ctx: @ctx)
27
51
  end
28
- UI::ErrorHandler.pretty_print_and_raise(e, failed_op: msg)
29
52
  end
30
53
 
31
54
  def self.help
@@ -8,6 +8,9 @@ payment_methods:
8
8
  beta: true
9
9
  package: "@shopify/scripts-checkout-apis"
10
10
  repo: "https://github.com/Shopify/scripts-apis-examples"
11
+ wasm:
12
+ beta: true
13
+ repo: "https://github.com/Shopify/scripts-apis-examples"
11
14
  shipping_methods:
12
15
  domain: 'checkout'
13
16
  libraries:
@@ -18,6 +21,9 @@ shipping_methods:
18
21
  beta: true
19
22
  package: "@shopify/scripts-checkout-apis"
20
23
  repo: "https://github.com/Shopify/scripts-apis-examples"
24
+ wasm:
25
+ beta: true
26
+ repo: "https://github.com/Shopify/scripts-apis-examples"
21
27
  merchandise_discount_types:
22
28
  beta: true
23
29
  domain: 'discounts'
@@ -26,6 +32,9 @@ merchandise_discount_types:
26
32
  beta: true
27
33
  package: "@shopify/scripts-discounts-apis"
28
34
  repo: "https://github.com/Shopify/scripts-apis-examples"
35
+ wasm:
36
+ beta: true
37
+ repo: "https://github.com/Shopify/scripts-apis-examples"
29
38
  delivery_discount_types:
30
39
  beta: true
31
40
  domain: 'discounts'
@@ -34,3 +43,6 @@ delivery_discount_types:
34
43
  beta: true
35
44
  package: "@shopify/scripts-discounts-apis"
36
45
  repo: "https://github.com/Shopify/scripts-apis-examples"
46
+ wasm:
47
+ beta: true
48
+ repo: "https://github.com/Shopify/scripts-apis-examples"
@@ -11,6 +11,7 @@ mutation AppScriptSet(
11
11
  $configurationDefinition: String!,
12
12
  $moduleUploadUrl: String!,
13
13
  $library: LibraryInput,
14
+ $inputQuery: String,
14
15
  ) {
15
16
  appScriptSet(
16
17
  uuid: $uuid
@@ -25,6 +26,7 @@ mutation AppScriptSet(
25
26
  configurationDefinition: $configurationDefinition,
26
27
  moduleUploadUrl: $moduleUploadUrl,
27
28
  library: $library,
29
+ inputQuery: $inputQuery,
28
30
  ) {
29
31
  userErrors {
30
32
  field
@@ -1,6 +1,10 @@
1
1
  mutation moduleUploadUrlGenerate {
2
2
  moduleUploadUrlGenerate {
3
- url
3
+ details {
4
+ url
5
+ headers
6
+ humanizedMaxSize
7
+ }
4
8
  userErrors {
5
9
  field
6
10
  message
@@ -9,11 +9,14 @@ module Script
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
+ script_content = task_runner.build
13
+ metadata_file_location = task_runner.metadata_file_location
14
+ metadata = Infrastructure::MetadataRepository.new(ctx: ctx).get_metadata(metadata_file_location)
15
+
12
16
  Infrastructure::PushPackageRepository.new(ctx: ctx).create_push_package(
13
17
  script_project: script_project,
14
- script_content: task_runner.build,
15
- compiled_type: task_runner.compiled_type,
16
- metadata: task_runner.metadata,
18
+ script_content: script_content,
19
+ metadata: metadata,
17
20
  library: library,
18
21
  )
19
22
  spinner.update_title(ctx.message("script.application.built"))
@@ -7,7 +7,7 @@ module Script
7
7
  module Application
8
8
  class ConnectApp
9
9
  class << self
10
- def call(ctx:, force: false, strict: false)
10
+ def call(ctx:, force: false)
11
11
  script_project_repo = Layers::Infrastructure::ScriptProjectRepository.new(ctx: ctx)
12
12
  script_project = script_project_repo.get
13
13
 
@@ -40,10 +40,6 @@ module Script
40
40
 
41
41
  uuid = Forms::AskScriptUuid.ask(ctx, scripts, nil)&.uuid
42
42
 
43
- if strict && uuid.nil?
44
- ctx.abort(ctx.message("script.connect.missing_script"))
45
- end
46
-
47
43
  script_project_repo.create_env(
48
44
  api_key: app["apiKey"],
49
45
  secret: app["apiSecretKeys"].first["secret"],
@@ -52,6 +48,16 @@ module Script
52
48
  ctx.done(ctx.message("script.connect.connected", app["title"]))
53
49
 
54
50
  true
51
+ rescue SmartProperties::InitializationError, SmartProperties::InvalidValueError => error
52
+ handle_error(error, context: ctx)
53
+ end
54
+
55
+ def handle_error(error, context:)
56
+ properties_hash = { api_key: "SHOPIFY_API_KEY", secret: "SHOPIFY_API_SECRET" }
57
+ missing_env_variables = error.properties.map { |p| properties_hash[p.name] }.compact.join(", ")
58
+ raise ShopifyCLI::Abort,
59
+ context.message("script.connect.error.missing_env_file_variables", missing_env_variables,
60
+ ShopifyCLI::TOOL_NAME)
55
61
  end
56
62
 
57
63
  private
@@ -4,37 +4,61 @@ module Script
4
4
  module Layers
5
5
  module Application
6
6
  class ExtensionPoints
7
- def self.get(type:)
8
- Infrastructure::ExtensionPointRepository.new.get_extension_point(type)
9
- end
7
+ class << self
8
+ def get(type:)
9
+ extension_point_repository.get_extension_point(type)
10
+ end
10
11
 
11
- def self.types
12
- Infrastructure::ExtensionPointRepository.new.extension_point_types
13
- end
12
+ def types
13
+ extension_point_repository.extension_point_types
14
+ end
14
15
 
15
- def self.available_types
16
- Infrastructure::ExtensionPointRepository.new.extension_points.select do |ep|
17
- next false if ep.deprecated?
18
- !ep.beta? || ShopifyCLI::Feature.enabled?(:scripts_beta_extension_points)
19
- end.map(&:type)
20
- end
16
+ def available_types
17
+ available_extension_points.map(&:type)
18
+ end
21
19
 
22
- def self.deprecated_types
23
- Infrastructure::ExtensionPointRepository.new
24
- .extension_points
25
- .select(&:deprecated?)
26
- .map(&:type)
27
- end
20
+ def deprecated_types
21
+ extension_point_repository
22
+ .extension_points
23
+ .select(&:deprecated?)
24
+ .map(&:type)
25
+ end
28
26
 
29
- def self.languages(type:)
30
- get(type: type).libraries.all.map do |library|
31
- next nil if library.beta? && !ShopifyCLI::Feature.enabled?(:scripts_beta_languages)
32
- library.language
33
- end.compact
34
- end
27
+ def all_languages
28
+ available_extension_points
29
+ .map { |ep| ep.library_languages(include_betas: include_beta_languages?) }
30
+ .flatten
31
+ .uniq
32
+ end
33
+
34
+ def languages(type:)
35
+ get(type: type).library_languages(include_betas: include_beta_languages?)
36
+ end
37
+
38
+ def supported_language?(type:, language:)
39
+ languages(type: type).include?(language.downcase)
40
+ end
41
+
42
+ private
43
+
44
+ def available_extension_points
45
+ extension_point_repository.extension_points.select do |ep|
46
+ next false if ep.deprecated?
47
+ ep.stable? || include_beta_extension_points?
48
+ end
49
+ end
50
+
51
+ def extension_point_repository
52
+ Infrastructure::ExtensionPointRepository.new
53
+ end
54
+
55
+ def include_beta_languages?
56
+ ShopifyCLI::Feature.enabled?(:scripts_beta_languages)
57
+ end
35
58
 
36
- def self.supported_language?(type:, language:)
37
- languages(type: type).include?(language.downcase)
59
+ def include_beta_extension_points?
60
+ ShopifyCLI::Feature.enabled?(:scripts_beta_extension_points)
61
+ end
38
62
  end
39
63
  end
40
64
  end
@@ -3,7 +3,7 @@ module Script
3
3
  module Application
4
4
  class ProjectDependencies
5
5
  def self.install(ctx:, task_runner:)
6
- CLI::UI::Frame.open(ctx.message("script.project_deps.checking_with_npm")) do
6
+ CLI::UI::Frame.open(ctx.message("script.project_deps.checking")) do
7
7
  begin
8
8
  if task_runner.dependencies_installed?
9
9
  ctx.puts(ctx.message("script.project_deps.none_required"))
@@ -5,50 +5,61 @@ module Script
5
5
  module Application
6
6
  class PushScript
7
7
  class << self
8
- def call(ctx:, force:)
8
+ def call(ctx:, force:, project:)
9
9
  script_project_repo = Infrastructure::ScriptProjectRepository.new(ctx: ctx)
10
10
  script_project = script_project_repo.get
11
+ script_project.env = project.env
11
12
  task_runner = Infrastructure::Languages::TaskRunner
12
13
  .for(ctx, script_project.language, script_project.script_name)
13
14
 
14
15
  extension_point = ExtensionPoints.get(type: script_project.extension_point_type)
15
- library_name = extension_point.libraries.for(script_project.language)&.package
16
+
17
+ library = extension_point.libraries.for(script_project.language)
18
+
16
19
  raise Infrastructure::Errors::LanguageLibraryForAPINotFoundError.new(
17
20
  language: script_project.language,
18
21
  api: script_project.extension_point_type
19
- ) unless library_name
22
+ ) if library.nil? && (script_project.language != "wasm")
20
23
 
21
- library = {
24
+ library_name = library&.package
25
+ library_data = {
22
26
  language: script_project.language,
23
27
  version: task_runner.library_version(library_name),
24
- }
28
+ } if library_name
25
29
 
26
30
  ProjectDependencies.install(ctx: ctx, task_runner: task_runner)
27
- BuildScript.call(ctx: ctx, task_runner: task_runner, script_project: script_project, library: library)
28
-
29
- UI::PrintingSpinner.spin(ctx, ctx.message("script.application.pushing")) do |p_ctx, spinner|
30
- package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
31
- script_project: script_project,
32
- compiled_type: task_runner.compiled_type,
33
- metadata: task_runner.metadata,
34
- library: library,
35
- )
36
- script_service = Infrastructure::ServiceLocator.script_service(
37
- ctx: p_ctx,
38
- api_key: script_project.api_key
39
- )
40
- module_upload_url = Infrastructure::ScriptUploader.new(script_service).upload(package.script_content)
41
- uuid = script_service.set_app_script(
42
- uuid: package.uuid,
43
- extension_point_type: package.extension_point_type,
44
- force: force,
45
- metadata: package.metadata,
46
- script_config: package.script_config,
47
- module_upload_url: module_upload_url,
48
- library: package.library,
49
- )
50
- script_project_repo.update_env(uuid: uuid)
51
- spinner.update_title(p_ctx.message("script.application.pushed"))
31
+ BuildScript.call(ctx: ctx, task_runner: task_runner, script_project: script_project, library: library_data)
32
+
33
+ metadata_file_location = task_runner.metadata_file_location
34
+ metadata = Infrastructure::MetadataRepository.new(ctx: ctx).get_metadata(metadata_file_location)
35
+
36
+ CLI::UI::Frame.open(ctx.message("script.application.pushing")) do
37
+ UI::PrintingSpinner.spin(ctx, ctx.message("script.application.pushing_script")) do |p_ctx, spinner|
38
+ package = Infrastructure::PushPackageRepository.new(ctx: p_ctx).get_push_package(
39
+ script_project: script_project,
40
+ metadata: metadata,
41
+ library: library_data,
42
+ )
43
+ script_service = Infrastructure::ServiceLocator.script_service(
44
+ ctx: p_ctx,
45
+ api_key: script_project.api_key
46
+ )
47
+ module_upload_url = Infrastructure::ScriptUploader.new(script_service).upload(package.script_content)
48
+ uuid = script_service.set_app_script(
49
+ uuid: package.uuid,
50
+ extension_point_type: package.extension_point_type,
51
+ force: force,
52
+ metadata: package.metadata,
53
+ script_config: package.script_config,
54
+ module_upload_url: module_upload_url,
55
+ library: package.library,
56
+ input_query: script_project.input_query,
57
+ )
58
+ if ShopifyCLI::Environment.interactive?
59
+ script_project_repo.update_env(uuid: uuid)
60
+ end
61
+ spinner.update_title(p_ctx.message("script.application.pushed"))
62
+ end
52
63
  end
53
64
  end
54
65
  end