shopify-cli 2.7.2 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) 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 +52 -0
  7. data/Codespace.dockerfile +2 -2
  8. data/Gemfile.lock +4 -4
  9. data/RELEASING.md +4 -3
  10. data/Tests.dockerfile +2 -2
  11. data/dev.yml +3 -3
  12. data/ext/javy/hashes/javy-arm-macos-v0.1.0.gz.sha256 +1 -0
  13. data/ext/javy/hashes/javy-x86_64-linux-v0.1.0.gz.sha256 +1 -0
  14. data/ext/javy/hashes/javy-x86_64-macos-v0.1.0.gz.sha256 +1 -0
  15. data/ext/javy/hashes/javy-x86_64-windows-v0.1.0.gz.sha256 +1 -0
  16. data/ext/javy/javy.rb +31 -13
  17. data/lib/graphql/get_extension_registrations.graphql +27 -0
  18. data/lib/project_types/extension/cli.rb +27 -2
  19. data/lib/project_types/extension/commands/build.rb +10 -10
  20. data/lib/project_types/extension/commands/create.rb +2 -3
  21. data/lib/project_types/extension/commands/push.rb +36 -8
  22. data/lib/project_types/extension/extension_project.rb +1 -1
  23. data/lib/project_types/extension/features/argo_serve.rb +6 -5
  24. data/lib/project_types/extension/forms/questions/ask_registration.rb +6 -2
  25. data/lib/project_types/extension/loaders/project.rb +29 -0
  26. data/lib/project_types/extension/loaders/specification_handler.rb +22 -0
  27. data/lib/project_types/extension/messages/messages.rb +4 -0
  28. data/lib/project_types/extension/models/app.rb +1 -1
  29. data/lib/project_types/extension/models/development_server.rb +2 -4
  30. data/lib/project_types/extension/models/specification_handlers/default.rb +4 -0
  31. data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
  32. data/lib/project_types/extension/tasks/execute_commands/base.rb +13 -0
  33. data/lib/project_types/extension/tasks/execute_commands/build.rb +29 -0
  34. data/lib/project_types/extension/tasks/execute_commands/create.rb +33 -0
  35. data/lib/project_types/extension/tasks/execute_commands/serve.rb +35 -0
  36. data/lib/project_types/extension/tasks/merge_server_config.rb +33 -22
  37. data/lib/project_types/rails/commands/create.rb +1 -1
  38. data/lib/project_types/rails/gem.rb +1 -2
  39. data/lib/project_types/script/cli.rb +8 -1
  40. data/lib/project_types/script/commands/connect.rb +19 -0
  41. data/lib/project_types/script/commands/create.rb +8 -2
  42. data/lib/project_types/script/commands/push.rb +35 -12
  43. data/lib/project_types/script/config/extension_points.yml +10 -2
  44. data/lib/project_types/script/graphql/app_script_set.graphql +2 -2
  45. data/lib/project_types/script/layers/application/connect_app.rb +15 -3
  46. data/lib/project_types/script/layers/application/create_script.rb +17 -17
  47. data/lib/project_types/script/layers/application/extension_points.rb +50 -26
  48. data/lib/project_types/script/layers/application/push_script.rb +6 -3
  49. data/lib/project_types/script/layers/domain/errors.rb +1 -4
  50. data/lib/project_types/script/layers/domain/extension_point.rb +14 -0
  51. data/lib/project_types/script/layers/domain/push_package.rb +3 -3
  52. data/lib/project_types/script/layers/domain/{script_json.rb → script_config.rb} +2 -2
  53. data/lib/project_types/script/layers/domain/script_project.rb +1 -1
  54. data/lib/project_types/script/layers/infrastructure/errors.rb +30 -5
  55. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -2
  56. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +125 -27
  57. data/lib/project_types/script/layers/infrastructure/script_service.rb +11 -11
  58. data/lib/project_types/script/loaders/project.rb +44 -0
  59. data/lib/project_types/script/loaders/specification_handler.rb +22 -0
  60. data/lib/project_types/script/messages/messages.rb +34 -3
  61. data/lib/project_types/script/ui/error_handler.rb +35 -15
  62. data/lib/project_types/theme/commands/pull.rb +39 -16
  63. data/lib/project_types/theme/commands/push.rb +60 -29
  64. data/lib/project_types/theme/commands/serve.rb +5 -0
  65. data/lib/project_types/theme/messages/messages.rb +30 -18
  66. data/lib/shopify_cli/command.rb +6 -0
  67. data/lib/shopify_cli/commands/login.rb +11 -5
  68. data/lib/shopify_cli/commands/switch.rb +1 -1
  69. data/lib/shopify_cli/constants.rb +5 -0
  70. data/lib/shopify_cli/context.rb +66 -11
  71. data/lib/shopify_cli/environment.rb +15 -4
  72. data/lib/shopify_cli/form.rb +2 -0
  73. data/lib/shopify_cli/git.rb +2 -0
  74. data/lib/shopify_cli/identity_auth.rb +1 -0
  75. data/lib/shopify_cli/messages/messages.rb +10 -2
  76. data/lib/shopify_cli/partners_api/app_extensions/job.rb +36 -0
  77. data/lib/shopify_cli/partners_api/app_extensions.rb +46 -0
  78. data/lib/shopify_cli/partners_api/organizations.rb +2 -5
  79. data/lib/shopify_cli/partners_api.rb +1 -0
  80. data/lib/shopify_cli/project.rb +8 -7
  81. data/lib/shopify_cli/resources/env_file.rb +18 -6
  82. data/lib/shopify_cli/services/app/create/rails_service.rb +1 -1
  83. data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
  84. data/lib/shopify_cli/theme/dev_server/hot-reload.js +57 -10
  85. data/lib/shopify_cli/theme/dev_server/hot_reload.rb +18 -2
  86. data/lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb +84 -0
  87. data/lib/shopify_cli/theme/dev_server/proxy.rb +10 -15
  88. data/lib/shopify_cli/theme/dev_server/reload_mode.rb +34 -0
  89. data/lib/shopify_cli/theme/dev_server.rb +8 -21
  90. data/lib/shopify_cli/theme/theme.rb +26 -4
  91. data/lib/shopify_cli/thread_pool/job.rb +27 -0
  92. data/lib/shopify_cli/thread_pool.rb +37 -0
  93. data/lib/shopify_cli/tunnel.rb +1 -0
  94. data/lib/shopify_cli/version.rb +1 -1
  95. data/lib/shopify_cli.rb +4 -0
  96. data/shopify-cli.gemspec +1 -1
  97. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +3 -1
  98. metadata +26 -7
  99. data/lib/graphql/all_orgs_with_extensions.graphql +0 -37
  100. data/lib/project_types/extension/tasks/run_extension_command.rb +0 -82
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b15f9181fc2d774f3fcc0c7297881090097c32a873f5586a766a9f1af3ca4771
4
- data.tar.gz: b05883edae91e131bbe30ea0fcf78fc7b7c31d775299ee37e7ce4b14b14f875a
3
+ metadata.gz: 3126bd5c9f4667732d248380f29b84fcac3bab1e3c944748b18dd3b0a639301d
4
+ data.tar.gz: 8c6ffbcf72d7360e227178f970c63a6041ee6c7f61b0ea22a9d6747f163f5b6b
5
5
  SHA512:
6
- metadata.gz: fd64941e6aee6553c078d9cb52c9ff97d04f2975d396943cb94b009e862ea14e2be44632534786288fdc71075bea47337d474a63a87d889393ecb159848c5958
7
- data.tar.gz: 24086b852a37609e95cc6a3f3c639b4d7b32c90b3b8b3db8154dd840f86f72b13b9c09b060e3f6da3dfeaa905e5a0c93c31c607c7ba7d7ea4d0029b80a90025e
6
+ metadata.gz: 2a21a55b5b258fa6c5037fff6652c43ba09a207e7f2b313b52a950b7a1d221e41d7edf719ce66c089200c1f2fba577e412fb985420c872ee83a4d40ef0cd05be
7
+ data.tar.gz: 338348f5e2220ef8b307e619981cc16985f012ecafc09c2d2eb232c2639ca65a11df12249f0d64fea5839b9015e1e31f0617eae84b82b4e530df587969b5fcc8
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,4 +1,56 @@
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
+
3
+ ## [Unreleased]
4
+
5
+ ## 2.9.0
6
+
7
+ ### Fixed
8
+ * [#1922](https://github.com/Shopify/shopify-cli/pull/1922): Respect RUBY_BINDIR from Homebrew for installing gem
9
+ * [#1906](https://github.com/Shopify/shopify-cli/pull/1906): Fix Ngrok incompatibility with some Apple ARM environments
10
+ * [#1873](https://github.com/Shopify/shopify-cli/pull/1873): Fix partners ability to login to external shops.
11
+ * [#1909](https://github.com/Shopify/shopify-cli/pull/1909): Fix `theme serve` on Safari
12
+
13
+ ### Added
14
+ * [#1900](https://github.com/Shopify/shopify-cli/pull/1900): Add `-d`/`--development` flag to Shopify theme pull command
15
+ * [#1896](https://github.com/Shopify/shopify-cli/pull/1896): Release Typescript options for payment_methods and shipping_methods scripts
16
+ * [#1891](https://github.com/Shopify/shopify-cli/pull/1891): Allow for additional arguments in `shopify push script` on CI.
17
+ * [#1877](https://github.com/Shopify/shopify-cli/pull/1877): Add theme (`-t`/`--theme=NAME_OR_ID`) parameter to `theme push`/`theme pull` commands
18
+ * [#1871](https://github.com/Shopify/shopify-cli/pull/1871): Add a new `--live-reload` parameter to the `theme serve` command
19
+
20
+ ### Changed
21
+ - [#1929](https://github.com/Shopify/shopify-cli/pull/1929): Rename `--registration-id` to `--extension-id` in `shopify extension push`.
22
+
23
+ ## Version 2.8.0
24
+ ### Fixed
25
+ * [#1879](https://github.com/Shopify/shopify-cli/pull/1879): Disambiguate -s as store option
26
+
27
+ ## Version 2.7.4
28
+ ### Added
29
+ * [#1825](https://github.com/Shopify/shopify-cli/pull/1825): Support passing the connection information through arguments
30
+
31
+ ### Fixed
32
+ * [#1852](https://github.com/Shopify/shopify-cli/pull/1852): Fix `shopify --help` to include `extension` commands
33
+ * [#1853](https://github.com/Shopify/shopify-cli/pull/1853): Fix javy installation failures from MacOS universal ruby installations
34
+ * [#1851](https://github.com/Shopify/shopify-cli/pull/1851): Improve `shopify theme push --live` confirmation message to show current live theme
35
+ * [#1850](https://github.com/Shopify/shopify-cli/pull/1850): Fix `shopify extension` commands timeout when organization has too many apps
36
+ * [#1860](https://github.com/Shopify/shopify-cli/pull/1860): Fix `theme serve` hot reload when there are many tabs active
37
+
38
+ ## Version 2.7.3
39
+ ### Added
40
+ * [#1826](https://github.com/Shopify/shopify-cli/pull/1826): Support using `script.config.yml` file for script configuration
41
+ * [#1843](https://github.com/Shopify/shopify-cli/pull/1826): Support using javy on Apple ARM processors
42
+ * [#1847](https://github.com/Shopify/shopify-cli/pull/1847): `shopify script connect` command.
43
+
44
+ ### Fixed
45
+ * [#1811](https://github.com/Shopify/shopify-cli/pull/1811): Update theme-check to 1.9.0
46
+ * [#1831](https://github.com/Shopify/shopify-cli/pull/1831): Ensure correct `ngrok` version is downloaded for Apple M1
47
+ * [#1823](https://github.com/Shopify/shopify-cli/pull/1823): Indicate git is unavailable; don't error out
48
+ * [#1807](https://github.com/Shopify/shopify-cli/pull/1807): Fix `--live` parameter, it should not imply `--allow-live` in the `theme push` command
49
+ * [#1812](https://github.com/Shopify/shopify-cli/pull/1812): App creation with Rails 7
50
+ * [#1821](https://github.com/Shopify/shopify-cli/pull/1821): Fix Shopify hosted fonts to load via the local preview URL
51
+ * [#1830](https://github.com/Shopify/shopify-cli/pull/1830): Fix hot reload when users update many files "simultaneously"
52
+ * [#1837](https://github.com/Shopify/shopify-cli/pull/1837): Fix `ShopifyCLI::Theme::DevServer::CdnFonts` class to support any font
53
+
2
54
  ## Version 2.7.2
3
55
  ### Fixed
4
56
  * [#1763](https://github.com/Shopify/shopify-cli/pull/1763): Fix: Tunnel --PORT parameter not working in Node.js app.
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.2)
4
+ shopify-cli (2.9.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/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/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
- BIN_FOLDER = File.join(ROOT, "bin")
8
+ BIN_FOLDER = File.join(ShopifyCLI.cache_dir, "javy", "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,16 +24,16 @@ module Extension
24
24
  private
25
25
 
26
26
  def run_new_flow(project)
27
- output = 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(output)
35
- rescue => error
36
- raise ShopifyCLI::Abort, error.message
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
37
37
  end
38
38
 
39
39
  def run_legacy_flow
@@ -53,12 +53,11 @@ module Extension
53
53
  end
54
54
 
55
55
  def use_new_create_flow(form)
56
- Tasks::RunExtensionCommand.new(
56
+ Tasks::ExecuteCommands.create(
57
57
  root_dir: form.directory_name,
58
58
  template: form.template,
59
59
  type: form.type.identifier.downcase,
60
- command: "create"
61
- ).call
60
+ )
62
61
  @ctx.chdir(form.directory_name)
63
62
  write_env_file(form)
64
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("--extension-id=EXTENSION_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 ShopifyCLI::Environment.interactive? && !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