shopify-cli 2.7.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +2 -2
  3. data/.github/workflows/shopify.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +43 -0
  7. data/Codespace.dockerfile +2 -2
  8. data/Gemfile.lock +4 -4
  9. data/Tests.dockerfile +2 -2
  10. data/dev.yml +3 -3
  11. data/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +1 -0
  12. data/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +1 -0
  13. data/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +1 -0
  14. data/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +1 -0
  15. data/ext/javy/javy.rb +30 -12
  16. data/lib/graphql/get_extension_registrations.graphql +27 -0
  17. data/lib/project_types/extension/cli.rb +27 -2
  18. data/lib/project_types/extension/commands/build.rb +10 -15
  19. data/lib/project_types/extension/commands/create.rb +3 -6
  20. data/lib/project_types/extension/commands/push.rb +36 -8
  21. data/lib/project_types/extension/extension_project.rb +1 -1
  22. data/lib/project_types/extension/features/argo_serve.rb +6 -5
  23. data/lib/project_types/extension/forms/questions/ask_registration.rb +6 -2
  24. data/lib/project_types/extension/loaders/project.rb +29 -0
  25. data/lib/project_types/extension/loaders/specification_handler.rb +22 -0
  26. data/lib/project_types/extension/messages/messages.rb +4 -2
  27. data/lib/project_types/extension/models/app.rb +1 -1
  28. data/lib/project_types/extension/models/development_server.rb +2 -2
  29. data/lib/project_types/extension/models/specification_handlers/default.rb +4 -0
  30. data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
  31. data/lib/project_types/extension/tasks/execute_commands/base.rb +13 -0
  32. data/lib/project_types/extension/tasks/execute_commands/build.rb +29 -0
  33. data/lib/project_types/extension/tasks/execute_commands/create.rb +33 -0
  34. data/lib/project_types/extension/tasks/execute_commands/serve.rb +35 -0
  35. data/lib/project_types/extension/tasks/merge_server_config.rb +33 -22
  36. data/lib/project_types/rails/commands/create.rb +2 -4
  37. data/lib/project_types/script/cli.rb +8 -1
  38. data/lib/project_types/script/commands/connect.rb +19 -0
  39. data/lib/project_types/script/commands/create.rb +1 -3
  40. data/lib/project_types/script/commands/javy.rb +0 -2
  41. data/lib/project_types/script/commands/push.rb +2 -1
  42. data/lib/project_types/script/config/extension_points.yml +10 -28
  43. data/lib/project_types/script/forms/ask_app.rb +32 -0
  44. data/lib/project_types/script/forms/ask_org.rb +30 -0
  45. data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
  46. data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
  47. data/lib/project_types/script/graphql/app_script_set.graphql +2 -2
  48. data/lib/project_types/script/layers/application/build_script.rb +0 -1
  49. data/lib/project_types/script/layers/application/connect_app.rb +79 -0
  50. data/lib/project_types/script/layers/application/create_script.rb +17 -17
  51. data/lib/project_types/script/layers/application/push_script.rb +1 -1
  52. data/lib/project_types/script/layers/domain/errors.rb +1 -4
  53. data/lib/project_types/script/layers/domain/push_package.rb +3 -3
  54. data/lib/project_types/script/layers/domain/{script_json.rb → script_config.rb} +2 -2
  55. data/lib/project_types/script/layers/domain/script_project.rb +5 -1
  56. data/lib/project_types/script/layers/infrastructure/errors.rb +28 -6
  57. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -4
  58. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -4
  59. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -2
  60. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +125 -27
  61. data/lib/project_types/script/layers/infrastructure/script_service.rb +11 -11
  62. data/lib/project_types/script/messages/messages.rb +20 -5
  63. data/lib/project_types/script/ui/error_handler.rb +30 -20
  64. data/lib/project_types/theme/commands/pull.rb +3 -0
  65. data/lib/project_types/theme/commands/push.rb +7 -1
  66. data/lib/project_types/theme/commands/serve.rb +1 -1
  67. data/lib/project_types/theme/messages/messages.rb +10 -0
  68. data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
  69. data/lib/shopify_cli/command/project_command.rb +20 -7
  70. data/lib/shopify_cli/command.rb +6 -0
  71. data/lib/shopify_cli/commands/app/create/node.rb +1 -3
  72. data/lib/shopify_cli/commands/app/create/rails.rb +1 -3
  73. data/lib/shopify_cli/commands/login.rb +1 -1
  74. data/lib/shopify_cli/commands/switch.rb +1 -1
  75. data/lib/shopify_cli/constants.rb +7 -0
  76. data/lib/shopify_cli/context.rb +11 -1
  77. data/lib/shopify_cli/environment.rb +4 -0
  78. data/lib/shopify_cli/form.rb +2 -0
  79. data/lib/shopify_cli/git.rb +2 -0
  80. data/lib/shopify_cli/identity_auth.rb +18 -0
  81. data/lib/shopify_cli/messages/messages.rb +8 -1
  82. data/lib/shopify_cli/partners_api/app_extensions/job.rb +36 -0
  83. data/lib/shopify_cli/partners_api/app_extensions.rb +46 -0
  84. data/lib/shopify_cli/partners_api/organizations.rb +2 -5
  85. data/lib/shopify_cli/partners_api.rb +2 -8
  86. data/lib/shopify_cli/project.rb +8 -7
  87. data/lib/shopify_cli/resources/env_file.rb +13 -5
  88. data/lib/shopify_cli/services/app/create/rails_service.rb +1 -1
  89. data/lib/shopify_cli/services/app/serve/node_service.rb +1 -1
  90. data/lib/shopify_cli/services/app/serve/rails_service.rb +1 -1
  91. data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
  92. data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
  93. data/lib/shopify_cli/theme/dev_server/hot-reload.js +38 -9
  94. data/lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb +84 -0
  95. data/lib/shopify_cli/theme/dev_server/proxy.rb +9 -15
  96. data/lib/shopify_cli/theme/dev_server.rb +6 -4
  97. data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  98. data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
  99. data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  100. data/lib/shopify_cli/theme/syncer.rb +40 -39
  101. data/lib/shopify_cli/theme/theme.rb +31 -19
  102. data/lib/shopify_cli/thread_pool/job.rb +27 -0
  103. data/lib/shopify_cli/thread_pool.rb +37 -0
  104. data/lib/shopify_cli/tunnel.rb +9 -10
  105. data/lib/shopify_cli/version.rb +1 -1
  106. data/shopify-cli.gemspec +1 -1
  107. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +3 -1
  108. metadata +31 -8
  109. data/lib/graphql/all_orgs_with_extensions.graphql +0 -37
  110. data/lib/project_types/extension/tasks/run_extension_command.rb +0 -82
  111. data/lib/project_types/script/tasks/ensure_env.rb +0 -106
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6009a6f735f27532db922768483b5563cc1a89417742616d0712837f7a4c3f8a
4
- data.tar.gz: 501ee710f57e5ffc27f7f9abfbb23e155a55da8f67127bfe32031c46fa2df08e
3
+ metadata.gz: 44313f65cde9217bac879066a57be593752c7d791d272d1ada078bc4a876f24c
4
+ data.tar.gz: bcb6ac1b939ee13ccec83eb74814ceddb1cb2d11661f516327ca2f0d294795a3
5
5
  SHA512:
6
- metadata.gz: 783329de6e2b6481c6ebcd747284dcd5e3c81c4303bf82f1d9a22e2e5f9a81aeda51a211c0344636ec03ff17fa1e5aae492fd750540387c85de4204bab8f4327
7
- data.tar.gz: 6af49d1fff422d17362c2e05f68341fc530cd7849f7d375a39ea8cb5abcb5d825ed8a4f04d8f25cc9265c9b2660c57b028be280db23882d58506e7c184b0d4cc
6
+ metadata.gz: 77f0ea5bef5ce778e87c9414c4ec1712795ef144e603bf22f88975d5f86dab2f4d43052522f18302be1ac836b3b2b98cb2f66ea9d413d93214da365895d3a2b5
7
+ data.tar.gz: 7cc5de0ba35117ae63a6cbb9e6d761695a75166cb15a996fd6545ba981e1809f60e9e42ad2d13e59a837310b11328b693744eb9547e90a0a8f537fd6640ba206
data/.github/CODEOWNERS CHANGED
@@ -1,5 +1,5 @@
1
1
  * @shopify/core-build-learn
2
2
  * @shopify/development-lifecycle
3
3
 
4
- /lib/project_types/script/ @shopify/scripts-experience
5
- /test/project_types/script/ @shopify/scripts-experience
4
+ /lib/project_types/script/ @shopify/scripts-platform
5
+ /test/project_types/script/ @shopify/scripts-platform
@@ -19,7 +19,7 @@ jobs:
19
19
  version:
20
20
  - 3.0.2
21
21
  - 2.6.6
22
- - 2.7.1
22
+ - 2.7.5
23
23
  os:
24
24
  - macos-10.15
25
25
  - macos-11
data/.gitignore CHANGED
@@ -23,3 +23,4 @@ packaging/rpm/shopify-cli.spec
23
23
  ext/shopify-extensions/shopify-extensions
24
24
  ext/javy/bin
25
25
  .console_history
26
+ TODO.md
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.5
data/CHANGELOG.md CHANGED
@@ -1,6 +1,49 @@
1
1
  From version 2.6.0, the sections in this file adhere to the [keep a changelog](https://keepachangelog.com/en/1.0.0/) specification.
2
+
2
3
  ## [Unreleased]
3
4
 
5
+ ## Version 2.8.0
6
+ ### Fixed
7
+ * [#1879](https://github.com/Shopify/shopify-cli/pull/1879): Disambiguate -s as store option
8
+
9
+ ## Version 2.7.4
10
+ ### Added
11
+ * [#1825](https://github.com/Shopify/shopify-cli/pull/1825): Support passing the connection information through arguments
12
+
13
+ ### Fixed
14
+ * [#1852](https://github.com/Shopify/shopify-cli/pull/1852): Fix `shopify --help` to include `extension` commands
15
+ * [#1853](https://github.com/Shopify/shopify-cli/pull/1853): Fix javy installation failures from MacOS universal ruby installations
16
+ * [#1851](https://github.com/Shopify/shopify-cli/pull/1851): Improve `shopify theme push --live` confirmation message to show current live theme
17
+ * [#1850](https://github.com/Shopify/shopify-cli/pull/1850): Fix `shopify extension` commands timeout when organization has too many apps
18
+ * [#1860](https://github.com/Shopify/shopify-cli/pull/1860): Fix `theme serve` hot reload when there are many tabs active
19
+
20
+ ## Version 2.7.3
21
+ ### Added
22
+ * [#1826](https://github.com/Shopify/shopify-cli/pull/1826): Support using `script.config.yml` file for script configuration
23
+ * [#1843](https://github.com/Shopify/shopify-cli/pull/1826): Support using javy on Apple ARM processors
24
+ * [#1847](https://github.com/Shopify/shopify-cli/pull/1847): `shopify script connect` command.
25
+
26
+ ### Fixed
27
+ * [#1811](https://github.com/Shopify/shopify-cli/pull/1811): Update theme-check to 1.9.0
28
+ * [#1831](https://github.com/Shopify/shopify-cli/pull/1831): Ensure correct `ngrok` version is downloaded for Apple M1
29
+ * [#1823](https://github.com/Shopify/shopify-cli/pull/1823): Indicate git is unavailable; don't error out
30
+ * [#1807](https://github.com/Shopify/shopify-cli/pull/1807): Fix `--live` parameter, it should not imply `--allow-live` in the `theme push` command
31
+ * [#1812](https://github.com/Shopify/shopify-cli/pull/1812): App creation with Rails 7
32
+ * [#1821](https://github.com/Shopify/shopify-cli/pull/1821): Fix Shopify hosted fonts to load via the local preview URL
33
+ * [#1830](https://github.com/Shopify/shopify-cli/pull/1830): Fix hot reload when users update many files "simultaneously"
34
+ * [#1837](https://github.com/Shopify/shopify-cli/pull/1837): Fix `ShopifyCLI::Theme::DevServer::CdnFonts` class to support any font
35
+
36
+ ## Version 2.7.2
37
+ ### Fixed
38
+ * [#1763](https://github.com/Shopify/shopify-cli/pull/1763): Fix: Tunnel --PORT parameter not working in Node.js app.
39
+ * [#1769](https://github.com/Shopify/shopify-cli/pull/1769): Fix `theme push --development --json` to output the proper exit code
40
+ * [#1766](https://github.com/Shopify/shopify-cli/pull/1766): Fix `theme serve` failing with the `--host` property
41
+ * [#1771](https://github.com/Shopify/shopify-cli/pull/1771): Fix `theme push --development --json` to output errors in the STDERR
42
+ * [#1778](https://github.com/Shopify/shopify-cli/pull/1778): Fix ngrok installation check on Windows
43
+ * [#1798](https://github.com/Shopify/shopify-cli/pull/1798): Add `--live` option to the `theme pull` and the `theme push` commands
44
+ * [#1788](https://github.com/Shopify/shopify-cli/pull/1788): Improve `theme serve` errors and add logs for successful operations
45
+ * [#1794](https://github.com/Shopify/shopify-cli/pull/1794): Fix bug where hidden subcommands appear in the help menu.
46
+
4
47
  ## Version 2.7.1
5
48
  ### Fixed
6
49
  * [#1722](https://github.com/Shopify/shopify-cli/pull/1722): Fix `theme serve` failing when the port is already being used
data/Codespace.dockerfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # This is a Docker image to test the CLI in UNIX environments other than macOS
2
2
  # Build the image: docker build . -t shopify-cli
3
3
  # Run tests: docker run -t --rm --volume "$(pwd):/usr/src/app" shopify-cli bundle exec rake test
4
- FROM cimg/ruby:2.7.1
4
+ FROM cimg/ruby:2.7.5
5
5
 
6
6
  RUN git config --global user.email "development-lifecycle@shopify.com"
7
7
  RUN git config --global user.name "Development Lifecycle"
@@ -29,7 +29,7 @@ RUN sudo apt-get install -y nodejs
29
29
  RUN sudo npm install --global yarn
30
30
 
31
31
  # Python is necessary to compile NPM packages with native extensions through node-gyp
32
- RUN sudo apt install python-minimal -y
32
+ RUN sudo apt install python2-minimal -y
33
33
 
34
34
  # Install sqlite3
35
35
  RUN sudo apt-get install libsqlite3-dev -y
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.7.1)
4
+ shopify-cli (2.8.0)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
- theme-check (~> 1.8.0)
7
+ theme-check (~> 1.9.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -81,7 +81,7 @@ GEM
81
81
  mini_portile2 (~> 2.6.1)
82
82
  racc (~> 1.4)
83
83
  parallel (1.21.0)
84
- parser (3.0.2.0)
84
+ parser (3.0.3.1)
85
85
  ast (~> 2.4.1)
86
86
  pry (0.13.1)
87
87
  coderay (~> 1.1)
@@ -119,7 +119,7 @@ GEM
119
119
  ruby-progressbar (1.11.0)
120
120
  sys-uname (1.2.2)
121
121
  ffi (~> 1.1)
122
- theme-check (1.8.0)
122
+ theme-check (1.9.0)
123
123
  liquid (>= 5.1.0)
124
124
  nokogiri (>= 1.12)
125
125
  parser (~> 3)
data/Tests.dockerfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # This is a Docker image to test the CLI in UNIX environments other than macOS
2
2
  # Build the image: docker build . -t shopify-cli
3
3
  # Run tests: docker run -t --rm --volume "$(pwd):/usr/src/app" shopify-cli bundle exec rake test
4
- FROM cimg/ruby:2.7.1
4
+ FROM cimg/ruby:2.7.5
5
5
 
6
6
  RUN git config --global user.email "development-lifecycle@shopify.com"
7
7
  RUN git config --global user.name "Development Lifecycle"
@@ -29,7 +29,7 @@ RUN sudo apt-get install -y nodejs
29
29
  RUN sudo npm install --global yarn
30
30
 
31
31
  # Python is necessary to compile NPM packages with native extensions through node-gyp
32
- RUN sudo apt install python-minimal -y
32
+ RUN sudo apt install python2-minimal -y
33
33
 
34
34
  # Install sqlite3
35
35
  RUN sudo apt-get install libsqlite3-dev -y
data/dev.yml CHANGED
@@ -6,12 +6,12 @@ env:
6
6
  SHOPIFY_CLI_DEVELOPMENT: "1"
7
7
 
8
8
  up:
9
- - ruby: 2.7.1
9
+ - ruby: 2.7.5
10
10
  - homebrew:
11
11
  - dpkg:
12
- version: 1.20.9
12
+ version: 1.21.1
13
13
  - rpm:
14
- version: 4.16.1.3
14
+ version: 4.17.0
15
15
  - bundler
16
16
  - docker
17
17
 
@@ -0,0 +1 @@
1
+ 16e1a74c06eff6e5be79253a8ee96a08a404e95be3479a6e384c8926bb736e43
@@ -0,0 +1 @@
1
+ 53cb9d0e8a345d68f91512a28a7d2eab93463dc8650c7a044f03cbee1f7cac05
@@ -0,0 +1 @@
1
+ 5e1ca88385206a653980139ab969efd80de11fd9b298dafe450d3ac27d6d0173
@@ -0,0 +1 @@
1
+ 37f9b3f75b4ffca68b06656d6f90abfbac57597ee45fffb59b3a559b6b5de44e
data/ext/javy/javy.rb CHANGED
@@ -1,11 +1,12 @@
1
- require "rbconfig"
2
1
  require "open-uri"
3
2
  require "zlib"
4
3
  require "open3"
4
+ require "digest/sha2"
5
5
 
6
6
  module Javy
7
7
  ROOT = __dir__
8
8
  BIN_FOLDER = File.join(ROOT, "bin")
9
+ HASH_FOLDER = File.join(ROOT, "hashes")
9
10
  VERSION = File.read(File.join(ROOT, "version")).strip
10
11
  TARGET = File.join(BIN_FOLDER, "javy-#{VERSION}")
11
12
 
@@ -17,14 +18,13 @@ module Javy
17
18
  end
18
19
 
19
20
  def build(source:, dest: nil)
20
- ensure_installed
21
-
22
21
  optional_args = []
23
22
  optional_args += ["-o", dest] unless dest.nil?
24
23
 
25
24
  ShopifyCLI::Result
26
- .wrap { exec(source, *optional_args) }
25
+ .wrap { ensure_installed }
27
26
  .call
27
+ .then { exec(source, *optional_args) }
28
28
  end
29
29
 
30
30
  private
@@ -45,7 +45,8 @@ module Javy
45
45
 
46
46
  def ensure_installed
47
47
  delete_outdated_installations
48
- install unless Installer.installed?(target: target)
48
+ install.unwrap { |e| raise e } unless Installer.installed?(target: target)
49
+ true
49
50
  end
50
51
 
51
52
  def delete_outdated_installations
@@ -97,16 +98,25 @@ module Javy
97
98
  url: url
98
99
  ))
99
100
  end
101
+
102
+ def self.invalid_binary
103
+ new("Invalid Javy binary downloaded.")
104
+ end
100
105
  end
101
106
 
102
107
  Asset = Struct.new(:platform, :version, :owner, :repository, :basename, keyword_init: true) do
103
108
  def download(target:)
104
109
  FileUtils.mkdir_p(BIN_FOLDER)
105
110
 
111
+ source_file = url.open
112
+ validate_sha!(source_file)
113
+ source_file.seek(0)
114
+
106
115
  Dir.chdir(File.dirname(target)) do
107
116
  File.open(File.basename(target), "wb") do |target_file|
108
- decompress(url.open, target_file)
117
+ decompress(source_file, target_file)
109
118
  end
119
+
110
120
  File.chmod(0755, target)
111
121
  end
112
122
 
@@ -143,11 +153,17 @@ module Javy
143
153
  ensure
144
154
  zlib.close
145
155
  end
156
+
157
+ def validate_sha!(source)
158
+ generated_hash = Digest::SHA256.hexdigest(source.read).strip
159
+ expected_hash = File.read(File.join(HASH_FOLDER, "#{filename}.sha256")).strip
160
+ raise InstallationError.invalid_binary unless generated_hash == expected_hash
161
+ end
146
162
  end
147
163
 
148
- Platform = Struct.new(:ruby_config) do
149
- def initialize(ruby_config = RbConfig::CONFIG)
150
- super(ruby_config)
164
+ Platform = Struct.new(:ruby_platform) do
165
+ def initialize(ruby_platform = RUBY_PLATFORM)
166
+ super(ruby_platform)
151
167
  end
152
168
 
153
169
  def to_s
@@ -155,7 +171,7 @@ module Javy
155
171
  end
156
172
 
157
173
  def os
158
- case ruby_config.fetch("host_os")
174
+ case ruby_platform
159
175
  when /linux/
160
176
  "linux"
161
177
  when /darwin/
@@ -166,9 +182,11 @@ module Javy
166
182
  end
167
183
 
168
184
  def cpu
169
- case ruby_config.fetch("host_cpu")
170
- when "x64", "x86_64"
185
+ case ruby_platform
186
+ when /x64/, /x86_64/
171
187
  "x86_64"
188
+ when /arm/
189
+ "arm"
172
190
  else
173
191
  raise InstallationError.cpu_unsupported
174
192
  end
@@ -0,0 +1,27 @@
1
+ query GetExtensionRegistrations($api_key: String!, $type: String) {
2
+ app(apiKey: $api_key) {
3
+ id
4
+ title
5
+ apiKey
6
+ apiSecretKeys{
7
+ secret
8
+ }
9
+ appType
10
+ extensionRegistrations(specificationIdentifier: $type) {
11
+ id
12
+ type
13
+ uuid
14
+ title
15
+ draftVersion {
16
+ registrationId
17
+ context
18
+ lastUserInteractionAt
19
+ location
20
+ validationErrors { field message }
21
+ id
22
+ uuid
23
+ versionTag
24
+ }
25
+ }
26
+ }
27
+ }
@@ -13,7 +13,6 @@ module Extension
13
13
  end
14
14
 
15
15
  class Command < ShopifyCLI::Command::ProjectCommand
16
- hidden_feature
17
16
  autoload :ExtensionCommand, Project.project_filepath("commands/extension_command")
18
17
 
19
18
  subcommand :Create, "create", Project.project_filepath("commands/create")
@@ -41,7 +40,6 @@ module Extension
41
40
  autoload :FindNpmPackages, Project.project_filepath("tasks/find_npm_packages")
42
41
  autoload :GetExtensions, Project.project_filepath("tasks/get_extensions")
43
42
  autoload :GetProduct, Project.project_filepath("tasks/get_product")
44
- autoload :RunExtensionCommand, Project.project_filepath("tasks/run_extension_command")
45
43
  autoload :MergeServerConfig, Project.project_filepath("tasks/merge_server_config")
46
44
  autoload :FindPackageFromJson, Project.project_filepath("tasks/find_package_from_json.rb")
47
45
  autoload :EnsureResourceUrl, Project.project_filepath("tasks/ensure_resource_url.rb")
@@ -53,6 +51,28 @@ module Extension
53
51
  autoload :ValidationErrorConverter, Project.project_filepath("tasks/converters/validation_error_converter")
54
52
  autoload :AppConverter, Project.project_filepath("tasks/converters/app_converter")
55
53
  autoload :ProductConverter, Project.project_filepath("tasks/converters/product_converter")
54
+ autoload :ExecuteCommands, Project.project_filepath("cli/execute_commands")
55
+ end
56
+
57
+ module ExecuteCommands
58
+ autoload :Base, Project.project_filepath("tasks/execute_commands/base")
59
+ autoload :Build, Project.project_filepath("tasks/execute_commands/build")
60
+ autoload :Create, Project.project_filepath("tasks/execute_commands/create")
61
+ autoload :Serve, Project.project_filepath("tasks/execute_commands/serve")
62
+
63
+ class << self
64
+ def build(*args)
65
+ Build.new(*args).call
66
+ end
67
+
68
+ def create(*args)
69
+ Create.new(*args).call
70
+ end
71
+
72
+ def serve(*args)
73
+ Serve.new(*args).call
74
+ end
75
+ end
56
76
  end
57
77
  end
58
78
 
@@ -121,4 +141,9 @@ module Extension
121
141
  autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
122
142
  autoload :ExtensionProject, Project.project_filepath("extension_project")
123
143
  autoload :Errors, Project.project_filepath("errors")
144
+
145
+ module Loaders
146
+ autoload :Project, Extension::Project.project_filepath("loaders/project")
147
+ autoload :SpecificationHandler, Extension::Project.project_filepath("loaders/specification_handler")
148
+ end
124
149
  end
@@ -24,21 +24,16 @@ module Extension
24
24
  private
25
25
 
26
26
  def run_new_flow(project)
27
- Tasks::RunExtensionCommand.new(
28
- type: project.specification_identifier.downcase,
29
- command: "build",
30
- config_file_name: specification_handler.server_config_file,
31
- context: @ctx,
32
- ).call
33
-
34
- @ctx.puts(@ctx.message("build.build_success_message"))
35
- rescue => error
36
- if error.message.include?("no such file or directory")
37
- @ctx.abort(@ctx.message("build.directory_not_found"))
38
- else
39
- @ctx.debug(error)
40
- @ctx.abort(@ctx.message("build.build_failure_message"))
41
- end
27
+ Tasks::ExecuteCommands
28
+ .build(
29
+ context: @ctx,
30
+ config_file_path: specification_handler.server_config_path,
31
+ type: project.specification_identifier.downcase
32
+ )
33
+ .then { |output| @ctx.puts(output) }
34
+ .unwrap do |error|
35
+ raise ShopifyCLI::Abort, error.message unless error.nil?
36
+ end
42
37
  end
43
38
 
44
39
  def run_legacy_flow
@@ -3,9 +3,7 @@
3
3
  module Extension
4
4
  class Command
5
5
  class Create < ShopifyCLI::Command::SubCommand
6
- unless ShopifyCLI::Environment.acceptance_test?
7
- prerequisite_task :ensure_authenticated
8
- end
6
+ prerequisite_task :ensure_authenticated
9
7
 
10
8
  options do |parser, flags|
11
9
  parser.on("--name=NAME") { |name| flags[:name] = name }
@@ -55,12 +53,11 @@ module Extension
55
53
  end
56
54
 
57
55
  def use_new_create_flow(form)
58
- Tasks::RunExtensionCommand.new(
56
+ Tasks::ExecuteCommands.create(
59
57
  root_dir: form.directory_name,
60
58
  template: form.template,
61
59
  type: form.type.identifier.downcase,
62
- command: "create"
63
- ).call
60
+ )
64
61
  @ctx.chdir(form.directory_name)
65
62
  write_env_file(form)
66
63
  rescue => error
@@ -3,17 +3,40 @@ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  class Command
6
- class Push < ExtensionCommand
6
+ class Push < ShopifyCLI::Command::SubCommand
7
7
  prerequisite_task ensure_project_type: :extension
8
8
 
9
+ options do |parser, flags|
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("--registration-id=REGISTRATION_ID") do |registration_id|
13
+ flags[:registration_id] = registration_id.gsub('"', "")
14
+ end
15
+ end
16
+
9
17
  TIME_DISPLAY_FORMAT = "%B %d, %Y %H:%M:%S %Z"
10
18
 
11
19
  def call(args, name)
12
- Command::Register.new(@ctx).call(args, name) unless project.registered?
20
+ project = Extension::Loaders::Project.load(
21
+ context: @ctx,
22
+ directory: Dir.pwd,
23
+ api_key: options.flags[:api_key],
24
+ api_secret: options.flags[:api_secret],
25
+ registration_id: options.flags[:registration_id]
26
+ )
27
+ specification_handler = Extension::Loaders::SpecificationHandler.load(project: project, context: @ctx)
28
+ register_if_necessary(project: project, args: args, name: name)
29
+
13
30
  Command::Build.new(@ctx).call(args, name) unless specification_handler.specification.options[:skip_build]
14
31
  CLI::UI::Frame.open(@ctx.message("push.frame_title")) do
15
- updated_draft_version = update_draft
16
- show_message(updated_draft_version)
32
+ updated_draft_version = update_draft(project: project, specification_handler: specification_handler)
33
+ show_message(updated_draft_version, project: project)
34
+ end
35
+ end
36
+
37
+ def register_if_necessary(project:, args:, name:)
38
+ if @ctx.tty? && !project.registered?
39
+ Command::Register.new(@ctx).call(args, name)
17
40
  end
18
41
  end
19
42
 
@@ -23,11 +46,16 @@ module Extension
23
46
 
24
47
  private
25
48
 
26
- def show_message(draft)
27
- draft.validation_errors.empty? ? output_success_messages(draft) : output_validation_errors(draft)
49
+ def show_message(draft, project:)
50
+ if draft.validation_errors.empty?
51
+ output_success_messages(draft,
52
+ project: project)
53
+ else
54
+ output_validation_errors(draft)
55
+ end
28
56
  end
29
57
 
30
- def output_success_messages(draft)
58
+ def output_success_messages(draft, project:)
31
59
  @ctx.puts(@ctx.message("push.success_confirmation", project.title, format_time(draft.last_user_interaction_at)))
32
60
  @ctx.puts(@ctx.message("push.success_info", draft.location))
33
61
  end
@@ -51,7 +79,7 @@ module Extension
51
79
  yield
52
80
  end
53
81
 
54
- def update_draft
82
+ def update_draft(project:, specification_handler:)
55
83
  with_waiting_text do
56
84
  Tasks::UpdateDraft.call(
57
85
  context: @ctx,
@@ -74,7 +74,7 @@ module Extension
74
74
  end
75
75
 
76
76
  def registered?
77
- property_present?("api_key") && property_present?("secret") && registration_id?
77
+ registration_id?
78
78
  end
79
79
 
80
80
  def title
@@ -9,7 +9,7 @@ module Extension
9
9
  property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
10
10
  property :argo_runtime, accepts: -> (runtime) { runtime.class < Features::Runtimes::Base }
11
11
  property! :context, accepts: ShopifyCLI::Context
12
- property! :port, accepts: Integer, default: 39351
12
+ property! :port, accepts: Integer, default: ShopifyCLI::Constants::Extension::DEFAULT_PORT
13
13
  property :tunnel_url, accepts: String, default: nil
14
14
  property! :js_system, accepts: ->(jss) { jss.respond_to?(:call) }, default: ShopifyCLI::JsSystem
15
15
  property :resource_url, accepts: String, default: nil
@@ -95,15 +95,16 @@ module Extension
95
95
  end
96
96
 
97
97
  def new_serve_flow
98
- Tasks::RunExtensionCommand.new(
98
+ Tasks::ExecuteCommands.serve(
99
99
  type: specification_handler.specification.identifier,
100
- command: "serve",
101
100
  context: context,
101
+ config_file_path: specification_handler.server_config_path,
102
102
  port: port,
103
- config_file_name: specification_handler.server_config_file,
104
103
  resource_url: resource_url,
105
104
  tunnel_url: tunnel_url
106
- ).call
105
+ ).unwrap do |error|
106
+ raise error unless error.nil?
107
+ end
107
108
  end
108
109
 
109
110
  def supports_development_server?
@@ -34,8 +34,12 @@ module Extension
34
34
  end
35
35
 
36
36
  def load_registrations(type)
37
- ctx.puts(@ctx.message("connect.loading_extensions"))
38
- registrations = Tasks::GetExtensions.call(context: ctx, type: type)
37
+ registrations = []
38
+ loading_extensions = @ctx.message("connect.loading_extensions")
39
+
40
+ CLI::UI::Spinner.spin(loading_extensions) do |_spinner|
41
+ registrations += Tasks::GetExtensions.call(context: ctx, type: type)
42
+ end
39
43
 
40
44
  registrations.empty? ? abort_no_registrations : registrations
41
45
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Loaders
5
+ module Project
6
+ def self.load(context:, directory:, api_key:, registration_id:, api_secret:)
7
+ env_overrides = {
8
+ "SHOPIFY_API_KEY" => api_key,
9
+ "SHOPIFY_API_SECRET" => api_secret,
10
+ "EXTENSION_ID" => registration_id,
11
+ }.compact
12
+ env =
13
+ begin
14
+ ShopifyCLI::Resources::EnvFile.read(directory, overrides: env_overrides)
15
+ rescue Errno::ENOENT
16
+ ShopifyCLI::Resources::EnvFile.from_hash(env_overrides)
17
+ end
18
+ # This is a somewhat uncomfortable hack we use because `Project::at` is
19
+ # a global cache and we can't rely on this class loading the project
20
+ # first. Long-term we should move away from that global cache.
21
+ project = ExtensionProject.at(directory)
22
+ project.env = env
23
+ project
24
+ rescue SmartProperties::InitializationError, SmartProperties::MissingValueError
25
+ context.abort(context.message("errors.missing_api_key"))
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Loaders
5
+ module SpecificationHandler
6
+ def self.load(project:, context:)
7
+ identifier = project.specification_identifier
8
+ Models::LazySpecificationHandler.new(identifier) do
9
+ specifications = Models::Specifications.new(
10
+ fetch_specifications: Tasks::FetchSpecifications.new(api_key: project.app.api_key, context: context)
11
+ )
12
+
13
+ unless specifications.valid?(identifier)
14
+ raise ShopifyCLI::Abort, context.message("errors.unknown_type", project.specification_identifier)
15
+ end
16
+
17
+ specifications[identifier]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -68,8 +68,6 @@ module Extension
68
68
  HELP
69
69
  frame_title: "Building extension with: %s…",
70
70
  build_failure_message: "Failed to build extension code.",
71
- build_success_message: "Build was successful!",
72
- directory_not_found: "Build directory not found.",
73
71
  },
74
72
  register: {
75
73
  help: <<~HELP,
@@ -91,6 +89,9 @@ module Extension
91
89
  help: <<~HELP,
92
90
  Push the current extension to Shopify.
93
91
  Usage: {{command:%s extension push}}
92
+ Options:
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
95
  HELP
95
96
  frame_title: "Pushing your extension to Shopify",
96
97
  waiting_text: "Pushing code to Shopify…",
@@ -175,6 +176,7 @@ module Extension
175
176
  errors: {
176
177
  unknown_type: "Unknown extension type %s",
177
178
  package_not_found: "`%s` package not found.",
179
+ missing_api_key: "Missing api_key.",
178
180
  module_not_found: "Unable to find module %s. Ensure your dependencies are up-to-date and try again.",
179
181
  },
180
182
  warnings: {