shopify-cli 2.15.2 → 2.15.5

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.vscode/settings.json +1 -2
  3. data/CHANGELOG.md +69 -22
  4. data/Gemfile.lock +1 -1
  5. data/Rakefile +8 -0
  6. data/ext/javy/hashes/javy-arm-macos-v0.3.0.gz.sha256 +1 -0
  7. data/ext/javy/hashes/javy-x86_64-linux-v0.3.0.gz.sha256 +1 -0
  8. data/ext/javy/hashes/javy-x86_64-macos-v0.3.0.gz.sha256 +1 -0
  9. data/ext/javy/hashes/javy-x86_64-windows-v0.3.0.gz.sha256 +1 -0
  10. data/ext/javy/version +1 -1
  11. data/ext/shopify-extensions/version +1 -1
  12. data/lib/project_types/extension/cli.rb +4 -0
  13. data/lib/project_types/extension/commands/check.rb +6 -1
  14. data/lib/project_types/extension/forms/questions/ask_template.rb +1 -2
  15. data/lib/project_types/extension/messages/messages.rb +0 -2
  16. data/lib/project_types/extension/models/development_server_requirements.rb +1 -0
  17. data/lib/project_types/extension/models/specification_handlers/beacon_extension.rb +57 -0
  18. data/lib/project_types/extension/models/specification_handlers/beacon_extension_utils/script_config.rb +33 -0
  19. data/lib/project_types/extension/models/specification_handlers/beacon_extension_utils/script_config_repository.rb +75 -0
  20. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +16 -1
  21. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +4 -1
  22. data/lib/project_types/extension/tasks/configure_options.rb +2 -1
  23. data/lib/project_types/extension/tasks/convert_server_config.rb +13 -2
  24. data/lib/project_types/extension/tasks/merge_server_config.rb +5 -2
  25. data/lib/project_types/script/cli.rb +1 -0
  26. data/lib/project_types/script/layers/application/create_script.rb +14 -6
  27. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +6 -21
  28. data/lib/project_types/script/layers/infrastructure/sparse_checkout_details.rb +35 -0
  29. data/lib/project_types/theme/cli.rb +1 -0
  30. data/lib/project_types/theme/commands/check.rb +4 -1
  31. data/lib/project_types/theme/commands/open.rb +2 -2
  32. data/lib/project_types/theme/commands/push.rb +1 -3
  33. data/lib/project_types/theme/commands/share.rb +56 -0
  34. data/lib/project_types/theme/messages/messages.rb +24 -3
  35. data/lib/shopify_cli/changelog.rb +97 -25
  36. data/lib/shopify_cli/command_options/command_serve_options.rb +10 -0
  37. data/lib/shopify_cli/commands/app/serve.rb +7 -7
  38. data/lib/shopify_cli/commands/login.rb +5 -2
  39. data/lib/shopify_cli/context.rb +13 -0
  40. data/lib/shopify_cli/identity_auth.rb +24 -4
  41. data/lib/shopify_cli/messages/messages.rb +17 -7
  42. data/lib/shopify_cli/release.rb +1 -1
  43. data/lib/shopify_cli/services/app/create/rails_service.rb +9 -1
  44. data/lib/shopify_cli/services/app/serve/node_service.rb +2 -25
  45. data/lib/shopify_cli/services/app/serve/php_service.rb +2 -25
  46. data/lib/shopify_cli/services/app/serve/rails_service.rb +8 -28
  47. data/lib/shopify_cli/services/app/serve/serve_service.rb +57 -0
  48. data/lib/shopify_cli/services.rb +1 -0
  49. data/lib/shopify_cli/tasks/update_dashboard_urls.rb +7 -9
  50. data/lib/shopify_cli/theme/dev_server/remote_watcher/json_files_update_job.rb +1 -0
  51. data/lib/shopify_cli/theme/dev_server/watcher.rb +2 -8
  52. data/lib/shopify_cli/theme/dev_server.rb +3 -2
  53. data/lib/shopify_cli/theme/theme.rb +21 -7
  54. data/lib/shopify_cli/theme/theme_admin_api.rb +23 -8
  55. data/lib/shopify_cli/tunnel.rb +3 -13
  56. data/lib/shopify_cli/version.rb +1 -1
  57. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +8 -0
  58. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a06f3c09c3e5e000956befefcbb7b8108096236d9b03cd021959881324c7cfe5
4
- data.tar.gz: b1daa60127f1b93ceed1f00d151e67f9709bca8ae77a962913f6fd1edfaac0c9
3
+ metadata.gz: acc8ad7231574d322ab00d0f5223bbd270689a8251e4574329fc58ae001ddd76
4
+ data.tar.gz: 98ea2d3cb974a4cc33593bde1af7052807c1dcb31cb26246a3d65eec0a7fb074
5
5
  SHA512:
6
- metadata.gz: 31e29e63fd9f7e569f7d4834549645b1ca206489274709aa7577f57b6888b3bd28d06eb5bd5899721cf9478239fa524b7937c009575a93c0ac096cd56c911fa6
7
- data.tar.gz: '09f19940da497bf3fab8d8c78c801fc127c2a8cad8fe49887f86b05de373dc96acb805c8c282ce76c72d7ea89526d65f0ec0ef3732d6854110a50d02de2f240b'
6
+ metadata.gz: 33d4f4d824d79a8f5c2d6238e481985f4f9539b44c0a2d5666f55675fc320a0c30b0d1f058a3016a496a193151a296dd0351ea6d682aefba5394af90f5fb8ad9
7
+ data.tar.gz: a382ec37c557103b3d8ec5b939d90e9184355e184fdeaeee665c86d987c25fb695b8e7044c71f62f73620a4745119c7da84f3ad23c2bc1488dea78bed58b74f0
@@ -5,5 +5,4 @@
5
5
  "**/.DS_Store": true
6
6
  },
7
7
  "editor.formatOnSave": false,
8
- "workbench.colorTheme": "Dracula Soft",
9
- }
8
+ }
data/CHANGELOG.md CHANGED
@@ -2,23 +2,56 @@ 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.15.2
5
+ ## Version 2.15.5 - 2022-04-08
6
+
7
+ ### Fixed
8
+ * [#2237](https://github.com/Shopify/shopify-cli/pull/2237): Fix Homebrew Wrapper
9
+
10
+ ## Version 2.15.4 - 2022-04-08
11
+
12
+ ### Fixed
13
+ * [#2230](https://github.com/Shopify/shopify-cli/pull/2230): Show an error without ngrok account
14
+ * [#2235](https://github.com/Shopify/shopify-cli/pull/2235): Update shopify-extensions to v0.3.0 and fix issues with template choosing and missing dependencies
15
+ * [#2226](https://github.com/Shopify/shopify-cli/pull/2226): Fix liquid file size validation to disclude locales directory
16
+
17
+ ## Version 2.15.3 - 2022-04-07
18
+
19
+ ### Changed
20
+ * [#2188](https://github.com/Shopify/shopify-cli/pull/2188): Update URLs by default on serve and add --no-update flag to skip it
21
+ * [#2203](https://github.com/Shopify/shopify-cli/pull/2203): Use javy version 0.3.0
22
+
23
+ ### Fixed
24
+ * [#2162](https://github.com/Shopify/shopify-cli/pull/2162): Improve encoding error handling for Checkout Extension localization
25
+ * [#2187](https://github.com/Shopify/shopify-cli/pull/2187): Fix app serve after rails update
26
+ * [#2191](https://github.com/Shopify/shopify-cli/pull/2191): Directories with the `.json` extension should not be handled as JSON files
27
+ * [#2018](https://github.com/Shopify/shopify-cli/pull/2018): Run theme-check as a code dependency, not a pseudo-CLI invocation
28
+ * [#2211](https://github.com/Shopify/shopify-cli/pull/2211): Fix the `theme open` command to open the theme in the browser
29
+ * [#2183](https://github.com/Shopify/shopify-cli/pull/2183): Improve error message when suspended users run `theme serve`
30
+ * [#2219](https://github.com/Shopify/shopify-cli/pull/2219): Fix issues when creating Rails apps after the release of `shopify_app` v19
31
+
32
+ ### Added
33
+ * [#2190](https://github.com/Shopify/shopify-cli/pull/2190): Better login experience with spinner
34
+ * [#2200](https://github.com/Shopify/shopify-cli/pull/2200): Add `theme share` command
35
+
36
+ ## Version 2.15.2 - 2022-03-28
6
37
 
7
38
  ### Fixed
8
39
  * [#2121](https://github.com/Shopify/shopify-cli/pull/2121): Fix the hot-reload to work when the section name is not equal to the type
9
40
 
10
- ## Version 2.15.1
41
+ ### Added
42
+ * [#2174](https://github.com/Shopify/shopify-cli/pull/2174): Add optional 2-way sync between the CLI (`theme serve`) and the Theme Editor
43
+
44
+ ## Version 2.15.1 - 2022-03-24
11
45
 
12
46
  ### Added
13
47
  * [#1934](https://github.com/Shopify/shopify-cli/pull/1934): Block directories in theme assets
14
48
  * [#1880](https://github.com/Shopify/shopify-cli/pull/1880): Recognize attempts to pass a store name and suggest correction
15
- * [#2174](https://github.com/Shopify/shopify-cli/pull/2174): Add optional 2-way sync between the CLI (`theme serve`) and the Theme Editor
16
49
 
17
50
  ### Fixed
18
51
  * [#1874](https://github.com/Shopify/shopify-cli/pull/1874): Make ngrok errors more robust and helpful
19
52
  * [#2172](https://github.com/Shopify/shopify-cli/pull/2172): Fix Ruby check for Rails app creation
20
53
 
21
- ## Version 2.15.0
54
+ ## Version 2.15.0 - 2022-03-21
22
55
 
23
56
  ### Fixed
24
57
  * [#2086](https://github.com/Shopify/shopify-cli/pull/2086): Improve check of dependency versions
@@ -26,7 +59,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
26
59
  * [#2122](https://github.com/Shopify/shopify-cli/pull/2122): Fix `--only`/`--ignore` flags parser to support multiple occurrences without quotes
27
60
  * [#2146](https://github.com/Shopify/shopify-cli/pull/2146): Prevent duplicate locales for Checkout extension localization
28
61
 
29
- ## Version 2.14.0
62
+ ## Version 2.14.0 - 2022-03-15
30
63
 
31
64
  ### Changed
32
65
  * [#2126](https://github.com/Shopify/shopify-cli/pull/2126): Use javy version 0.2.1
@@ -40,7 +73,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
40
73
  * [#2130](https://github.com/Shopify/shopify-cli/pull/2130): Fix Homebrew installation.
41
74
  * [#2133](https://github.com/Shopify/shopify-cli/pull/2133): Fix ignore file handling in DevServer::Watcher.
42
75
 
43
- ## Version 2.13.0
76
+ ## Version 2.13.0 - 2022-03-02
44
77
 
45
78
  ### Added
46
79
  * [#2087](https://github.com/Shopify/shopify-cli/pull/2087): Add new Theme CLI commands: `theme list` and `theme open`
@@ -54,7 +87,8 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
54
87
  ### Removed
55
88
  * [#2102](https://github.com/Shopify/shopify-cli/pull/2102): Remove AssemblyScript as a supported script language.
56
89
 
57
- ## Version 2.12.0
90
+ ## Version 2.12.0 - 2022-02-23
91
+
58
92
  ### Added
59
93
  * [#1866](https://github.com/Shopify/shopify-cli/pull/1866): Enforce git dependency
60
94
  * [#2009](https://github.com/Shopify/shopify-cli/pull/2009): Add localization support for Checkout Extensions
@@ -69,21 +103,24 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
69
103
  * [#2066](https://github.com/Shopify/shopify-cli/pull/2066): Improve `--only`/`--ignore` parameters on Theme `pull`/`push` commands to work without quotes
70
104
  * [#2078](https://github.com/Shopify/shopify-cli/pull/2078): Fix errors on section rendering caused by CORS issues
71
105
 
72
- ## Version 2.11.2
106
+ ## Version 2.11.2 - 2022-02-14
107
+
73
108
  ### Fixed
74
109
  * [#2047](https://github.com/Shopify/shopify-cli/pull/2047): Fix the Homebrew installation
75
110
  * [#2019](https://github.com/Shopify/shopify-cli/pull/2019): Provide helpful link when nokogiri fails to load
76
111
  * [#2055](https://github.com/Shopify/shopify-cli/pull/2055): Remove unneeded Node requirements
77
112
  * [#2020](https://github.com/Shopify/shopify-cli/pull/2020): Fix `theme pull` so that correct dev theme is used with `-d` option
78
113
 
79
- ## Version 2.11.1
114
+ ## Version 2.11.1 - 2022-02-09
115
+
80
116
  ### Fixed
81
117
  * [#1973](https://github.com/Shopify/shopify-cli/pull/1973): Fix `theme serve` to preview generated files (`*.css.liquid`)
82
118
  * [#2034](https://github.com/Shopify/shopify-cli/pull/2034): Fix `theme serve` to accept parameters with multiple values
83
119
  * [#2033](https://github.com/Shopify/shopify-cli/pull/2033): Pin Homebrew Ruby to 3.0
84
120
  * [#2032](https://github.com/Shopify/shopify-cli/pull/2032): Runtime error checking the Node version if Node is not present in the environment.
85
121
 
86
- ## Version 2.11.0
122
+ ## Version 2.11.0 - 2022-02-07
123
+
87
124
  ### Fixed
88
125
  * [#2005](https://github.com/Shopify/shopify-cli/pull/2005): Fix PHP app serve on Windows environments
89
126
 
@@ -98,17 +135,20 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
98
135
  * [#2002](https://github.com/Shopify/shopify-cli/pull/2002): Update `-o`/`--only` parameter to allow multiple patterns on `theme push`/`theme pull` commands
99
136
  * [#2022](https://github.com/Shopify/shopify-cli/pull/2022): Don't warn the user if the Ruby version is in the range 3.0.x.
100
137
 
101
- ## Version 2.10.2
138
+ ## Version 2.10.2 - 2022-01-31
139
+
102
140
  ### Fixed
103
141
  * [#1983](https://github.com/Shopify/shopify-cli/pull/1983): Improve Windows compatibility
104
142
  * [#1928](https://github.com/Shopify/shopify-cli/pull/1928): Ensure script Wasm file sizes don't exceed the limit
105
143
  * [#2006](https://github.com/Shopify/shopify-cli/pull/2006): Fix: More defensive URL generation
106
144
 
107
- ## Version 2.10.1
145
+ ## Version 2.10.1 - 2022-01-28
146
+
108
147
  ### Fixed
109
148
  * [#1985](https://github.com/Shopify/shopify-cli/pull/1985): Revert "Fix CORS (Cross-origin resource sharing) errors (#1952)"
110
149
 
111
- ## Version 2.10.0
150
+ ## Version 2.10.0 - 2022-01-25
151
+
112
152
  ### Fixed
113
153
  * [#1937](https://github.com/Shopify/shopify-cli/pull/1937): Fix `theme pull` to no longer add empty lines on Windows
114
154
  * [#1952](https://github.com/Shopify/shopify-cli/pull/1952): Fix CORS (cross-origin resource sharing) errors
@@ -117,7 +157,8 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
117
157
  ### Added
118
158
  * [#1892](https://github.com/Shopify/shopify-cli/pull/1892): Add `-o`/`--only` parameter to filter files on `theme push`/`theme pull` commands
119
159
 
120
- ## Version 2.9.0
160
+ ## Version 2.9.0 - 2022-01-17
161
+
121
162
  ### Fixed
122
163
  * [#1922](https://github.com/Shopify/shopify-cli/pull/1922): Respect RUBY_BINDIR from Homebrew for installing gem
123
164
  * [#1906](https://github.com/Shopify/shopify-cli/pull/1906): Fix Ngrok incompatibility with some Apple ARM environments
@@ -131,13 +172,15 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
131
172
  * [#1871](https://github.com/Shopify/shopify-cli/pull/1871): Add a new `--live-reload` parameter to the `theme serve` command
132
173
 
133
174
  ### Changed
134
- - [#1929](https://github.com/Shopify/shopify-cli/pull/1929): Rename `--registration-id` to `--extension-id` in `shopify extension push`.
175
+ * [#1929](https://github.com/Shopify/shopify-cli/pull/1929): Rename `--registration-id` to `--extension-id` in `shopify extension push`.
176
+
177
+ ## Version 2.8.0 - 2022-01-06
135
178
 
136
- ## Version 2.8.0
137
179
  ### Fixed
138
180
  * [#1879](https://github.com/Shopify/shopify-cli/pull/1879): Disambiguate -s as store option
139
181
 
140
- ## Version 2.7.4
182
+ ## Version 2.7.4 - 2021-12-22
183
+
141
184
  ### Added
142
185
  * [#1825](https://github.com/Shopify/shopify-cli/pull/1825): Support passing the connection information through arguments
143
186
 
@@ -148,10 +191,11 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
148
191
  * [#1850](https://github.com/Shopify/shopify-cli/pull/1850): Fix `shopify extension` commands timeout when organization has too many apps
149
192
  * [#1860](https://github.com/Shopify/shopify-cli/pull/1860): Fix `theme serve` hot reload when there are many tabs active
150
193
 
151
- ## Version 2.7.3
194
+ ## Version 2.7.3 - 2021-12-13
195
+
152
196
  ### Added
153
197
  * [#1826](https://github.com/Shopify/shopify-cli/pull/1826): Support using `script.config.yml` file for script configuration
154
- * [#1843](https://github.com/Shopify/shopify-cli/pull/1826): Support using javy on Apple ARM processors
198
+ * [#1843](https://github.com/Shopify/shopify-cli/pull/1843): Support using javy on Apple ARM processors
155
199
  * [#1847](https://github.com/Shopify/shopify-cli/pull/1847): `shopify script connect` command.
156
200
 
157
201
  ### Fixed
@@ -164,7 +208,8 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
164
208
  * [#1830](https://github.com/Shopify/shopify-cli/pull/1830): Fix hot reload when users update many files "simultaneously"
165
209
  * [#1837](https://github.com/Shopify/shopify-cli/pull/1837): Fix `ShopifyCLI::Theme::DevServer::CdnFonts` class to support any font
166
210
 
167
- ## Version 2.7.2
211
+ ## Version 2.7.2 - 2021-11-30
212
+
168
213
  ### Fixed
169
214
  * [#1763](https://github.com/Shopify/shopify-cli/pull/1763): Fix: Tunnel --PORT parameter not working in Node.js app.
170
215
  * [#1769](https://github.com/Shopify/shopify-cli/pull/1769): Fix `theme push --development --json` to output the proper exit code
@@ -175,14 +220,16 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
175
220
  * [#1788](https://github.com/Shopify/shopify-cli/pull/1788): Improve `theme serve` errors and add logs for successful operations
176
221
  * [#1794](https://github.com/Shopify/shopify-cli/pull/1794): Fix bug where hidden subcommands appear in the help menu.
177
222
 
178
- ## Version 2.7.1
223
+ ## Version 2.7.1 - 2021-11-17
224
+
179
225
  ### Fixed
180
226
  * [#1722](https://github.com/Shopify/shopify-cli/pull/1722): Fix `theme serve` failing when the port is already being used
181
227
  * [#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.
182
228
  * [#1750](https://github.com/Shopify/shopify-cli/pull/1750): Runtime errors in Windows' environments when the `PATHEXT` environment variable is not defined.
183
229
  * [#1758](https://github.com/Shopify/shopify-cli/pull/1758): Fix tunnel creation for expired anonymous tunnels
184
230
 
185
- ## Version 2.7.0
231
+ ## Version 2.7.0 - 2021-11-15
232
+
186
233
  ### Changed
187
234
  * [#1650](https://github.com/Shopify/shopify-cli/pull/1650): **Breaking** Move app commands under `shopify app`.
188
235
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.15.2)
4
+ shopify-cli (2.15.5)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
7
  theme-check (~> 1.10.1)
data/Rakefile CHANGED
@@ -129,6 +129,14 @@ end
129
129
  desc("Builds all distribution packages of the CLI")
130
130
  task(package: "package:all")
131
131
 
132
+ namespace :changelog do
133
+ require "shopify_cli/changelog"
134
+
135
+ task :update do
136
+ ShopifyCLI::Changelog.new.update!
137
+ end
138
+ end
139
+
132
140
  namespace :release do
133
141
  require "shopify_cli/release"
134
142
 
@@ -0,0 +1 @@
1
+ c7e97d166e46d96fa43a70046c80607035101b4a96e40edcf4643a6c92913692
@@ -0,0 +1 @@
1
+ 877e6383b921de2b93ecaf5d1d902c7305d65bdab52758b9d5c02d9c5cea45ab
@@ -0,0 +1 @@
1
+ c8a40adf83cacae33f819fa78501355eee9077dce3818ab4a483b2473952941e
@@ -0,0 +1 @@
1
+ 9ca1e65b0f7a2645f408cb65e683d243069f03828d4b3eeaf59f3012e5d41e73
data/ext/javy/version CHANGED
@@ -1 +1 @@
1
- v0.2.1
1
+ v0.3.0
@@ -1 +1 @@
1
- v0.2.0
1
+ v0.3.0
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "pathname"
4
+ require "json"
5
+ require "yaml"
6
+
3
7
  module Extension
4
8
  class PackageResolutionFailed < RuntimeError; end
5
9
 
@@ -32,7 +32,12 @@ module Extension
32
32
 
33
33
  def call(*)
34
34
  if project.specification_identifier == "THEME_APP_EXTENSION"
35
- @theme_check.run
35
+ begin
36
+ @theme_check.run!
37
+ rescue ThemeCheck::Cli::Abort, ThemeCheck::ThemeCheckError => e
38
+ raise ShopifyCLI::Abort,
39
+ ShopifyCLI::Context.message("theme.check.error", e.full_message)
40
+ end
36
41
  else
37
42
  @ctx.abort(@ctx.message("check.unsupported", project.specification_identifier))
38
43
  end
@@ -21,8 +21,7 @@ module Extension
21
21
 
22
22
  def template_required?(project_details)
23
23
  type = project_details&.type&.identifier
24
- (Models::DevelopmentServerRequirements.beta_enabled? &&
25
- Models::DevelopmentServerRequirements.type_supported?(type.downcase))
24
+ Models::DevelopmentServerRequirements.supported?(type)
26
25
  end
27
26
 
28
27
  def choose_interactively
@@ -73,8 +73,6 @@ module Extension
73
73
  help: <<~HELP,
74
74
  Register your local extension to a Shopify app
75
75
  Usage: {{command:%s extension register}}
76
- Options:
77
- {{command:--api-key=API_KEY}} The API key used to register an app with the extension. This can be found on the app page on Partners Dashboard.
78
76
  HELP
79
77
  frame_title: "Registering Extension",
80
78
  waiting_text: "Registering with Shopify…",
@@ -9,6 +9,7 @@ module Extension
9
9
  "checkout_ui_extension",
10
10
  "checkout_post_purchase",
11
11
  "product_subscription",
12
+ "beacon_extension",
12
13
  ]
13
14
 
14
15
  class << self
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+ require "base64"
3
+ require "fileutils"
4
+ require "json"
5
+ require_relative "beacon_extension_utils/script_config"
6
+ require_relative "beacon_extension_utils/script_config_repository"
7
+
8
+ module Extension
9
+ module Models
10
+ module SpecificationHandlers
11
+ class BeaconExtension < Default
12
+ SCRIPT_FILE = "build/main.js"
13
+
14
+ def name
15
+ "Beacon Extension"
16
+ end
17
+
18
+ def read_configuration
19
+ end
20
+
21
+ def access_config_property(context, ext_config, key, &process_value)
22
+ context.abort(context.message("core.extension.push.beacon_extension.error.missing_config_key_error",
23
+ key)) unless ext_config.key?(key)
24
+
25
+ begin
26
+ process_value.nil? ? ext_config[key] : process_value.call(ext_config[key])
27
+ rescue StandardError
28
+ context.abort(context.message("core.extension.push.beacon_extension.error.invalid_config_value_error", key))
29
+ end
30
+ end
31
+
32
+ def config(context)
33
+ begin
34
+ ext_config = BeaconExtensionUtils::ScriptConfigYmlRepository.new(ctx: context).get!.content
35
+ rescue StandardError
36
+ context.abort(context.message("core.extension.push.beacon_extension.error.file_read_error",
37
+ BeaconExtensionUtils::ScriptConfigYmlRepository.filename))
38
+ end
39
+
40
+ begin
41
+ script_contents = File.read(File.join(context.root, SCRIPT_FILE)).chomp
42
+ rescue
43
+ context.abort(context.message("core.extension.push.beacon_extension.error.file_read_error", SCRIPT_FILE))
44
+ end
45
+ {
46
+ runtime_context: access_config_property(context, ext_config, "runtime_context"),
47
+ serialized_script: Base64.strict_encode64(script_contents),
48
+ runtime_configuration_definition: access_config_property(context, ext_config,
49
+ "configuration", &:to_json),
50
+ config_version: access_config_property(context, ext_config,
51
+ "version", &:to_s),
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extension
4
+ module Models
5
+ module SpecificationHandlers
6
+ module BeaconExtensionUtils
7
+ class ScriptConfig
8
+ attr_reader :content, :version, :configuration, :filename
9
+
10
+ REQUIRED_FIELDS = %w(version)
11
+
12
+ def initialize(content:, filename:)
13
+ @filename = filename
14
+ validate_content!(content)
15
+ @content = content
16
+ @version = @content["version"].to_s
17
+ @configuration = @content["configuration"]
18
+ end
19
+
20
+ private
21
+
22
+ def validate_content!(content)
23
+ REQUIRED_FIELDS.each do |field|
24
+ if content[field].nil?
25
+ raise "invalid field:#{field}, filename:#{filename}"
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,75 @@
1
+ require_relative "script_config"
2
+ module Extension
3
+ module Models
4
+ module SpecificationHandlers
5
+ module BeaconExtensionUtils
6
+ class ScriptConfigRepository
7
+ include SmartProperties
8
+ property! :ctx, accepts: ShopifyCLI::Context
9
+
10
+ def active?
11
+ ctx.file_exist?(filename)
12
+ end
13
+
14
+ def get!
15
+ raise RuntimeError.new("NoScriptConfigFile"), filename unless active?
16
+
17
+ content = ctx.read(filename)
18
+ hash = file_content_to_hash(content)
19
+
20
+ from_h(hash)
21
+ end
22
+
23
+ def filename
24
+ raise NotImplementedError
25
+ end
26
+
27
+ private
28
+
29
+ def from_h(hash)
30
+ Extension::Models::SpecificationHandlers::BeaconExtensionUtils::ScriptConfig.new(content: hash,
31
+ filename: filename)
32
+ end
33
+
34
+ def file_content_to_hash(file_content)
35
+ raise NotImplementedError
36
+ end
37
+
38
+ def hash_to_file_content(hash)
39
+ raise NotImplementedError
40
+ end
41
+ end
42
+
43
+ class ScriptConfigYmlRepository < ScriptConfigRepository
44
+ def self.filename
45
+ "extension.config.yml"
46
+ end
47
+
48
+ def filename
49
+ ScriptConfigYmlRepository.filename
50
+ end
51
+
52
+ private
53
+
54
+ def file_content_to_hash(file_content)
55
+ begin
56
+ hash = YAML.load(file_content)
57
+ rescue Psych::SyntaxError
58
+ raise parse_error
59
+ end
60
+ raise parse_error unless hash.is_a?(Hash)
61
+ hash
62
+ end
63
+
64
+ def hash_to_file_content(hash)
65
+ YAML.dump(hash)
66
+ end
67
+
68
+ def parse_error
69
+ RuntimeError.new("ScriptConfigParseError #{filename}, serialization_format: \"YAML\" ")
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -49,7 +49,7 @@ module Extension
49
49
 
50
50
  locale_filenames.map do |filename|
51
51
  locale = basename_for_locale_filename(filename)
52
- [locale.to_sym, Base64.strict_encode64(File.read(filename, mode: "rt", encoding: "UTF-8").strip)]
52
+ [locale.to_sym, read_locale_file(filename)]
53
53
  end
54
54
  .yield_self do |encoded_files_by_locale|
55
55
  {
@@ -62,6 +62,14 @@ module Extension
62
62
  end
63
63
  end
64
64
 
65
+ def read_locale_file(filename)
66
+ content = File.read(filename, mode: "rt", encoding: "bom|utf-8").strip
67
+ raise_invalid_encoding_error(filename) unless content.valid_encoding?
68
+ Base64.strict_encode64(content)
69
+ rescue ArgumentError
70
+ raise_invalid_encoding_error(filename)
71
+ end
72
+
65
73
  def validate_no_duplicate_locale(locale_filenames)
66
74
  duplicate_locale = locale_filenames
67
75
  .map { |filename| basename_for_locale_filename(filename.downcase) }
@@ -149,6 +157,13 @@ module Extension
149
157
  def basename_for_locale_filename(filename)
150
158
  File.basename(File.basename(filename, ".json"), ".default")
151
159
  end
160
+
161
+ def raise_invalid_encoding_error(filename)
162
+ raise(
163
+ ShopifyCLI::Abort,
164
+ ShopifyCLI::Context.message("#{L10N_ERROR_PREFIX}.invalid_file_encoding", filename)
165
+ )
166
+ end
152
167
  end
153
168
  end
154
169
  end
@@ -38,7 +38,10 @@ module Extension
38
38
  # Other assets should be treated as UTF-8 encoded text
39
39
  mode = "rt"
40
40
  encoding = "UTF-8"
41
- current_liquid_size += File.size(filename)
41
+
42
+ if dirname == "snippets" || dirname == "blocks"
43
+ current_liquid_size += File.size(filename)
44
+ end
42
45
  end
43
46
  current_size += File.size(filename)
44
47
  if current_size > BUNDLE_SIZE_LIMIT
@@ -13,7 +13,8 @@ module Extension
13
13
  private
14
14
 
15
15
  def configure_skip_build(attributes)
16
- attributes[:options].merge!(skip_build: attributes[:identifier] == "theme_app_extension")
16
+ attributes[:options].merge!(skip_build: attributes[:identifier] == "theme_app_extension" ||
17
+ attributes[:identifier] == "beacon_extension")
17
18
  end
18
19
  end
19
20
  end
@@ -18,7 +18,6 @@ module Extension
18
18
  property! :type, accepts: String
19
19
 
20
20
  DEFAULT_BUILD_DIR = "build"
21
- DEFAULT_MAIN = Dir["src/*"].lazy.grep(/index.[jt]sx?/).first
22
21
 
23
22
  def self.call(*args)
24
23
  new(*args).call
@@ -37,7 +36,7 @@ module Extension
37
36
  build_dir: hash.dig("development", "build_dir") || DEFAULT_BUILD_DIR,
38
37
  renderer: renderer,
39
38
  entries: Models::ServerConfig::DevelopmentEntries.new(
40
- main: hash.dig("development", "entries", "main") || DEFAULT_MAIN
39
+ main: hash.dig("development", "entries", "main") || determine_default_entry_main(project_directory),
41
40
  )
42
41
  ),
43
42
  extension_points: hash.dig("extension_points"),
@@ -65,6 +64,18 @@ module Extension
65
64
  def version(renderer, context)
66
65
  Tasks::FindPackageFromJson.call(renderer, context: context).version
67
66
  end
67
+
68
+ private
69
+
70
+ def determine_default_entry_main(project_directory)
71
+ Dir.chdir(project_directory) do
72
+ Dir["src/*"].lazy.grep(/index.[jt]sx?/).first
73
+ end
74
+ end
75
+
76
+ def project_directory
77
+ ExtensionProject.current.directory
78
+ end
68
79
  end
69
80
  end
70
81
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require "shopify_cli"
3
3
  require "yaml"
4
+ require "pathname"
4
5
 
5
6
  module Extension
6
7
  module Tasks
@@ -8,7 +9,7 @@ module Extension
8
9
  include SmartProperties
9
10
 
10
11
  property! :context, accepts: ShopifyCLI::Context
11
- property! :file_path, accepts: ->(path) { Pathname(path).yield_self { |pn| pn.absolute? && pn.file? } }
12
+ property! :file_path, accepts: ->(path) { Pathname(path).yield_self(&:absolute?) }
12
13
  property :port, accepts: Integer, default: ShopifyCLI::Constants::Extension::DEFAULT_PORT
13
14
  property :resource_url, accepts: String
14
15
  property :tunnel_url, accepts: String
@@ -19,7 +20,9 @@ module Extension
19
20
  end
20
21
 
21
22
  def call
22
- config = YAML.load_file(file_path)
23
+ config = YAML.load_file(file_path) if File.file?(file_path)
24
+ config ||= {}
25
+
23
26
  project = ExtensionProject.current
24
27
  Tasks::ConvertServerConfig.call(
25
28
  api_key: project.env.api_key,
@@ -62,6 +62,7 @@ module Script
62
62
  autoload :ScriptService, Project.project_filepath("layers/infrastructure/script_service")
63
63
  autoload :ScriptUploader, Project.project_filepath("layers/infrastructure/script_uploader")
64
64
  autoload :ServiceLocator, Project.project_filepath("layers/infrastructure/service_locator")
65
+ autoload :SparseCheckoutDetails, Project.project_filepath("layers/infrastructure/sparse_checkout_details")
65
66
 
66
67
  module Languages
67
68
  autoload :ProjectCreator, Project.project_filepath("layers/infrastructure/languages/project_creator")