shopify-cli 2.7.0 → 2.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +2 -2
  3. data/.github/workflows/shopify.yml +1 -1
  4. data/.gitignore +2 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +46 -0
  7. data/Codespace.dockerfile +2 -2
  8. data/Gemfile.lock +4 -4
  9. data/Rakefile +27 -0
  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 +204 -0
  17. data/ext/javy/version +1 -0
  18. data/lib/graphql/get_extension_registrations.graphql +27 -0
  19. data/lib/project_types/extension/cli.rb +27 -2
  20. data/lib/project_types/extension/commands/build.rb +10 -14
  21. data/lib/project_types/extension/commands/create.rb +3 -6
  22. data/lib/project_types/extension/commands/push.rb +36 -8
  23. data/lib/project_types/extension/extension_project.rb +1 -1
  24. data/lib/project_types/extension/features/argo_serve.rb +6 -5
  25. data/lib/project_types/extension/forms/questions/ask_registration.rb +6 -2
  26. data/lib/project_types/extension/loaders/project.rb +29 -0
  27. data/lib/project_types/extension/loaders/specification_handler.rb +22 -0
  28. data/lib/project_types/extension/messages/messages.rb +4 -2
  29. data/lib/project_types/extension/models/app.rb +1 -1
  30. data/lib/project_types/extension/models/development_server.rb +2 -2
  31. data/lib/project_types/extension/models/specification_handlers/default.rb +4 -0
  32. data/lib/project_types/extension/tasks/convert_server_config.rb +3 -1
  33. data/lib/project_types/extension/tasks/execute_commands/base.rb +13 -0
  34. data/lib/project_types/extension/tasks/execute_commands/build.rb +29 -0
  35. data/lib/project_types/extension/tasks/execute_commands/create.rb +33 -0
  36. data/lib/project_types/extension/tasks/execute_commands/serve.rb +35 -0
  37. data/lib/project_types/extension/tasks/merge_server_config.rb +33 -22
  38. data/lib/project_types/rails/commands/create.rb +2 -4
  39. data/lib/project_types/script/cli.rb +9 -1
  40. data/lib/project_types/script/commands/connect.rb +19 -0
  41. data/lib/project_types/script/commands/create.rb +1 -3
  42. data/lib/project_types/script/commands/javy.rb +29 -0
  43. data/lib/project_types/script/commands/push.rb +2 -1
  44. data/lib/project_types/script/config/extension_points.yml +12 -30
  45. data/lib/project_types/script/forms/ask_app.rb +32 -0
  46. data/lib/project_types/script/forms/ask_org.rb +30 -0
  47. data/lib/project_types/script/forms/ask_script_uuid.rb +22 -0
  48. data/lib/project_types/script/forms/run_against_shopify_org.rb +14 -0
  49. data/lib/project_types/script/graphql/app_script_set.graphql +2 -2
  50. data/lib/project_types/script/layers/application/build_script.rb +0 -1
  51. data/lib/project_types/script/layers/application/connect_app.rb +79 -0
  52. data/lib/project_types/script/layers/application/create_script.rb +17 -17
  53. data/lib/project_types/script/layers/application/push_script.rb +1 -1
  54. data/lib/project_types/script/layers/domain/errors.rb +1 -4
  55. data/lib/project_types/script/layers/domain/push_package.rb +3 -3
  56. data/lib/project_types/script/layers/domain/{script_json.rb → script_config.rb} +2 -2
  57. data/lib/project_types/script/layers/domain/script_project.rb +5 -1
  58. data/lib/project_types/script/layers/infrastructure/errors.rb +36 -7
  59. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +0 -4
  60. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +0 -4
  61. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +2 -2
  62. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +125 -27
  63. data/lib/project_types/script/layers/infrastructure/script_service.rb +11 -11
  64. data/lib/project_types/script/messages/messages.rb +32 -4
  65. data/lib/project_types/script/ui/error_handler.rb +31 -21
  66. data/lib/project_types/theme/commands/pull.rb +3 -0
  67. data/lib/project_types/theme/commands/push.rb +7 -1
  68. data/lib/project_types/theme/commands/serve.rb +1 -1
  69. data/lib/project_types/theme/messages/messages.rb +35 -1
  70. data/lib/project_types/theme/ui/sync_progress_bar.rb +2 -2
  71. data/lib/shopify_cli/command/project_command.rb +20 -7
  72. data/lib/shopify_cli/command.rb +6 -0
  73. data/lib/shopify_cli/commands/app/create/node.rb +1 -3
  74. data/lib/shopify_cli/commands/app/create/rails.rb +1 -3
  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 +9 -2
  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/node_service.rb +2 -0
  89. data/lib/shopify_cli/services/app/create/php_service.rb +1 -1
  90. data/lib/shopify_cli/services/app/create/rails_service.rb +3 -1
  91. data/lib/shopify_cli/services/app/serve/node_service.rb +1 -1
  92. data/lib/shopify_cli/services/app/serve/rails_service.rb +1 -1
  93. data/lib/shopify_cli/tasks/ensure_authenticated.rb +9 -3
  94. data/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +73 -0
  95. data/lib/shopify_cli/theme/dev_server/hot-reload.js +38 -9
  96. data/lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb +84 -0
  97. data/lib/shopify_cli/theme/dev_server/proxy.rb +9 -15
  98. data/lib/shopify_cli/theme/dev_server.rb +32 -19
  99. data/lib/shopify_cli/theme/syncer/error_reporter.rb +45 -0
  100. data/lib/shopify_cli/theme/syncer/operation.rb +56 -0
  101. data/lib/shopify_cli/theme/syncer/standard_reporter.rb +32 -0
  102. data/lib/shopify_cli/theme/syncer.rb +40 -39
  103. data/lib/shopify_cli/theme/theme.rb +31 -19
  104. data/lib/shopify_cli/thread_pool/job.rb +27 -0
  105. data/lib/shopify_cli/thread_pool.rb +37 -0
  106. data/lib/shopify_cli/tunnel.rb +26 -22
  107. data/lib/shopify_cli/version.rb +1 -1
  108. data/shopify-cli.gemspec +1 -1
  109. data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +3 -1
  110. data/vendor/deps/cli-kit/lib/cli/kit/system.rb +1 -1
  111. metadata +34 -8
  112. data/lib/graphql/all_orgs_with_extensions.graphql +0 -37
  113. data/lib/project_types/extension/tasks/run_extension_command.rb +0 -82
  114. 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: 4cce33ea79f749e3dc6e18d724ac5e584f887971224119f6e8ea61ade325798d
4
- data.tar.gz: 3ae9563de4ea7eb1eaf3e51a03e71fba509ca9249c35e9be8d1311e952ddf577
3
+ metadata.gz: '068a38773a84e132b2b1dd435d4e369a2100d2fca4cccb539699e6033f816fb7'
4
+ data.tar.gz: d4f356f9f4bf9f0e43733da4f223f7e02917d8c29e4193c90eb276ac80a73c5b
5
5
  SHA512:
6
- metadata.gz: f5e46c8fa4c9eeb026d7e7b451a53886338a32ea084153f541eda085a6a3bb6cf5247831498b0dcc960c9079e7eaf3906662965c32e17f2dfd31a47113343674
7
- data.tar.gz: 46df1b135b1d37618560a00fb8121291ddf9d63f0e35c2c33abfdcf3decb2b9d0fb3380c99726cedab37bd4b01627ac4a3df51869312f82bbfd5ebeb43d9b6a3
6
+ metadata.gz: a163a0878650fbf8c846fa9d510240c3b4f938a621e14558a63788ce56e63a8fe39e6254ef4cc83107cd6b241d2d66e2fe935cd207d47a88c20182ceb7d59d5c
7
+ data.tar.gz: db35b09603e3ccb0c7a526da096a76663b4ab5f952cb37e1bde4b71fba3509d87c3e8626929e8d20e316a4c04097d3430da98e252b9634d5a0e53586b06ec2a9
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
@@ -21,4 +21,6 @@ packaging/rpm/build
21
21
  packaging/rpm/shopify-cli.spec
22
22
  .byebug_history
23
23
  ext/shopify-extensions/shopify-extensions
24
+ ext/javy/bin
24
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,52 @@
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.7.4
6
+ ### Added
7
+ * [#1825](https://github.com/Shopify/shopify-cli/pull/1825): Support passing the connection information through arguments
8
+
9
+ ### Fixed
10
+ * [#1852](https://github.com/Shopify/shopify-cli/pull/1852): Fix `shopify --help` to include `extension` commands
11
+ * [#1853](https://github.com/Shopify/shopify-cli/pull/1853): Fix javy installation failures from MacOS universal ruby installations
12
+ * [#1851](https://github.com/Shopify/shopify-cli/pull/1851): Improve `shopify theme push --live` confirmation message to show current live theme
13
+ * [#1850](https://github.com/Shopify/shopify-cli/pull/1850): Fix `shopify extension` commands timeout when organization has too many apps
14
+ * [#1860](https://github.com/Shopify/shopify-cli/pull/1860): Fix `theme serve` hot reload when there are many tabs active
15
+
16
+ ## Version 2.7.3
17
+ ### Added
18
+ * [#1826](https://github.com/Shopify/shopify-cli/pull/1826): Support using `script.config.yml` file for script configuration
19
+ * [#1843](https://github.com/Shopify/shopify-cli/pull/1826): Support using javy on Apple ARM processors
20
+ * [#1847](https://github.com/Shopify/shopify-cli/pull/1847): `shopify script connect` command.
21
+
22
+ ### Fixed
23
+ * [#1811](https://github.com/Shopify/shopify-cli/pull/1811): Update theme-check to 1.9.0
24
+ * [#1831](https://github.com/Shopify/shopify-cli/pull/1831): Ensure correct `ngrok` version is downloaded for Apple M1
25
+ * [#1823](https://github.com/Shopify/shopify-cli/pull/1823): Indicate git is unavailable; don't error out
26
+ * [#1807](https://github.com/Shopify/shopify-cli/pull/1807): Fix `--live` parameter, it should not imply `--allow-live` in the `theme push` command
27
+ * [#1812](https://github.com/Shopify/shopify-cli/pull/1812): App creation with Rails 7
28
+ * [#1821](https://github.com/Shopify/shopify-cli/pull/1821): Fix Shopify hosted fonts to load via the local preview URL
29
+ * [#1830](https://github.com/Shopify/shopify-cli/pull/1830): Fix hot reload when users update many files "simultaneously"
30
+ * [#1837](https://github.com/Shopify/shopify-cli/pull/1837): Fix `ShopifyCLI::Theme::DevServer::CdnFonts` class to support any font
31
+
32
+ ## Version 2.7.2
33
+ ### Fixed
34
+ * [#1763](https://github.com/Shopify/shopify-cli/pull/1763): Fix: Tunnel --PORT parameter not working in Node.js app.
35
+ * [#1769](https://github.com/Shopify/shopify-cli/pull/1769): Fix `theme push --development --json` to output the proper exit code
36
+ * [#1766](https://github.com/Shopify/shopify-cli/pull/1766): Fix `theme serve` failing with the `--host` property
37
+ * [#1771](https://github.com/Shopify/shopify-cli/pull/1771): Fix `theme push --development --json` to output errors in the STDERR
38
+ * [#1778](https://github.com/Shopify/shopify-cli/pull/1778): Fix ngrok installation check on Windows
39
+ * [#1798](https://github.com/Shopify/shopify-cli/pull/1798): Add `--live` option to the `theme pull` and the `theme push` commands
40
+ * [#1788](https://github.com/Shopify/shopify-cli/pull/1788): Improve `theme serve` errors and add logs for successful operations
41
+ * [#1794](https://github.com/Shopify/shopify-cli/pull/1794): Fix bug where hidden subcommands appear in the help menu.
42
+
43
+ ## Version 2.7.1
44
+ ### Fixed
45
+ * [#1722](https://github.com/Shopify/shopify-cli/pull/1722): Fix `theme serve` failing when the port is already being used
46
+ * [#1751](https://github.com/Shopify/shopify-cli/pull/1751): A bug in the app creation flow that caused the CLI to abort when the form validation failed.
47
+ * [#1750](https://github.com/Shopify/shopify-cli/pull/1750): Runtime errors in Windows' environments when the `PATHEXT` environment variable is not defined.
48
+ * [#1758](https://github.com/Shopify/shopify-cli/pull/1758): Fix tunnel creation for expired anonymous tunnels
49
+
4
50
  ## Version 2.7.0
5
51
  ### Changed
6
52
  * [#1650](https://github.com/Shopify/shopify-cli/pull/1650): **Breaking** Move app commands under `shopify 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.0)
4
+ shopify-cli (2.7.4)
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/Rakefile CHANGED
@@ -146,6 +146,33 @@ namespace :extensions do
146
146
  end
147
147
  end
148
148
 
149
+ namespace :scripts do
150
+ namespace :javy do
151
+ task :symlink do
152
+ source = Paths.root("..", "javy", "target", "release", "javy")
153
+ error("Unable to find javy executable: #{executable}") unless File.executable?(source)
154
+ target = Paths.javy("javy")
155
+ File.delete(target) if File.exist?(target)
156
+ File.symlink(source, target)
157
+ end
158
+
159
+ task :install do
160
+ require_relative Paths.javy("javy.rb")
161
+ Javy.install
162
+ end
163
+
164
+ module Paths
165
+ def self.javy(*args)
166
+ root("ext", "javy", *args)
167
+ end
168
+
169
+ def self.root(*args)
170
+ Pathname(File.dirname(__FILE__)).join(*args).to_s
171
+ end
172
+ end
173
+ end
174
+ end
175
+
149
176
  def error(message, output: STDERR, code: 1)
150
177
  output.puts(message)
151
178
  exit(code)
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 ADDED
@@ -0,0 +1,204 @@
1
+ require "open-uri"
2
+ require "zlib"
3
+ require "open3"
4
+ require "digest/sha2"
5
+
6
+ module Javy
7
+ ROOT = __dir__
8
+ BIN_FOLDER = File.join(ROOT, "bin")
9
+ HASH_FOLDER = File.join(ROOT, "hashes")
10
+ VERSION = File.read(File.join(ROOT, "version")).strip
11
+ TARGET = File.join(BIN_FOLDER, "javy-#{VERSION}")
12
+
13
+ class << self
14
+ def install
15
+ ShopifyCLI::Result
16
+ .wrap { Installer.call(target: target, platform: platform, version: VERSION) }
17
+ .call
18
+ end
19
+
20
+ def build(source:, dest: nil)
21
+ optional_args = []
22
+ optional_args += ["-o", dest] unless dest.nil?
23
+
24
+ ShopifyCLI::Result
25
+ .wrap { ensure_installed }
26
+ .call
27
+ .then { exec(source, *optional_args) }
28
+ end
29
+
30
+ private
31
+
32
+ def exec(*args, **kwargs)
33
+ out_and_err, stat = CLI::Kit::System.capture2e(target, *args, **kwargs)
34
+ raise ExecutionError, out_and_err unless stat.success?
35
+ true
36
+ end
37
+
38
+ def platform
39
+ Platform.new
40
+ end
41
+
42
+ def target
43
+ platform.format_executable_path(TARGET)
44
+ end
45
+
46
+ def ensure_installed
47
+ delete_outdated_installations
48
+ install.unwrap { |e| raise e } unless Installer.installed?(target: target)
49
+ true
50
+ end
51
+
52
+ def delete_outdated_installations
53
+ installed_binaries
54
+ .reject { |v| v == target }
55
+ .each { |file| File.delete(file) }
56
+ end
57
+
58
+ def installed_binaries
59
+ Dir[File.join(BIN_FOLDER, "javy-*")]
60
+ end
61
+
62
+ module Installer
63
+ def self.call(target:, platform:, version:)
64
+ asset = Asset.new(
65
+ platform: platform,
66
+ version: version,
67
+ owner: "Shopify",
68
+ repository: "javy",
69
+ basename: "javy"
70
+ )
71
+
72
+ downloaded = asset.download(target: target)
73
+ raise InstallationError.asset_not_found(platform: platform, version: version, url: asset.url) unless downloaded
74
+
75
+ true
76
+ end
77
+
78
+ def self.installed?(target:)
79
+ File.executable?(target)
80
+ end
81
+ end
82
+ end
83
+
84
+ class Error < RuntimeError; end
85
+ class ExecutionError < Error; end
86
+
87
+ class InstallationError < Error
88
+ def self.cpu_unsupported
89
+ new("Javy is not supported on this CPU")
90
+ end
91
+
92
+ def self.asset_not_found(platform:, version:, url:)
93
+ new(format(
94
+ "Unable to download javy %{version} for %{os} (%{cpu}) at %{url}",
95
+ version: version,
96
+ os: platform.os,
97
+ cpu: platform.cpu,
98
+ url: url
99
+ ))
100
+ end
101
+
102
+ def self.invalid_binary
103
+ new("Invalid Javy binary downloaded.")
104
+ end
105
+ end
106
+
107
+ Asset = Struct.new(:platform, :version, :owner, :repository, :basename, keyword_init: true) do
108
+ def download(target:)
109
+ FileUtils.mkdir_p(BIN_FOLDER)
110
+
111
+ source_file = url.open
112
+ validate_sha!(source_file)
113
+ source_file.seek(0)
114
+
115
+ Dir.chdir(File.dirname(target)) do
116
+ File.open(File.basename(target), "wb") do |target_file|
117
+ decompress(source_file, target_file)
118
+ end
119
+
120
+ File.chmod(0755, target)
121
+ end
122
+
123
+ true
124
+ rescue OpenURI::HTTPError
125
+ false
126
+ end
127
+
128
+ def url
129
+ URI.parse(format(
130
+ "https://github.com/%{owner}/%{repository}/releases/download/%{version}/%{filename}",
131
+ owner: owner,
132
+ repository: repository,
133
+ version: version,
134
+ filename: filename
135
+ ))
136
+ end
137
+
138
+ def filename
139
+ format(
140
+ "%{basename}-%{cpu}-%{os}-%{version}.gz",
141
+ basename: basename,
142
+ cpu: platform.cpu,
143
+ os: platform.os,
144
+ version: version
145
+ )
146
+ end
147
+
148
+ private
149
+
150
+ def decompress(source, target)
151
+ zlib = Zlib::GzipReader.new(source)
152
+ target << zlib.read
153
+ ensure
154
+ zlib.close
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
162
+ end
163
+
164
+ Platform = Struct.new(:ruby_platform) do
165
+ def initialize(ruby_platform = RUBY_PLATFORM)
166
+ super(ruby_platform)
167
+ end
168
+
169
+ def to_s
170
+ format("%{cpu}-%{os}", cpu: cpu, os: os)
171
+ end
172
+
173
+ def os
174
+ case ruby_platform
175
+ when /linux/
176
+ "linux"
177
+ when /darwin/
178
+ "macos"
179
+ else
180
+ "windows"
181
+ end
182
+ end
183
+
184
+ def cpu
185
+ case ruby_platform
186
+ when /x64/, /x86_64/
187
+ "x86_64"
188
+ when /arm/
189
+ "arm"
190
+ else
191
+ raise InstallationError.cpu_unsupported
192
+ end
193
+ end
194
+
195
+ def format_executable_path(path)
196
+ case os
197
+ when "windows"
198
+ File.extname(path) != ".exe" ? path + ".exe" : path
199
+ else
200
+ path
201
+ end
202
+ end
203
+ end
204
+ end
data/ext/javy/version ADDED
@@ -0,0 +1 @@
1
+ v0.1.0
@@ -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,20 +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
- ).call
32
-
33
- @ctx.puts(@ctx.message("build.build_success_message"))
34
- rescue => error
35
- if error.message.include?("no such file or directory")
36
- @ctx.abort(@ctx.message("build.directory_not_found"))
37
- else
38
- @ctx.debug(error)
39
- @ctx.abort(@ctx.message("build.build_failure_message"))
40
- 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
41
37
  end
42
38
 
43
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