shopify-cli 2.15.2 → 2.15.3

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.vscode/settings.json +1 -2
  3. data/CHANGELOG.md +57 -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/lib/project_types/extension/commands/check.rb +6 -1
  12. data/lib/project_types/extension/messages/messages.rb +0 -2
  13. data/lib/project_types/extension/models/development_server_requirements.rb +1 -0
  14. data/lib/project_types/extension/models/specification_handlers/beacon_extension.rb +57 -0
  15. data/lib/project_types/extension/models/specification_handlers/beacon_extension_utils/script_config.rb +33 -0
  16. data/lib/project_types/extension/models/specification_handlers/beacon_extension_utils/script_config_repository.rb +75 -0
  17. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +16 -1
  18. data/lib/project_types/extension/tasks/configure_options.rb +2 -1
  19. data/lib/project_types/extension/tasks/convert_server_config.rb +13 -2
  20. data/lib/project_types/extension/tasks/merge_server_config.rb +5 -2
  21. data/lib/project_types/script/cli.rb +1 -0
  22. data/lib/project_types/script/layers/application/create_script.rb +14 -6
  23. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +6 -21
  24. data/lib/project_types/script/layers/infrastructure/sparse_checkout_details.rb +35 -0
  25. data/lib/project_types/theme/cli.rb +1 -0
  26. data/lib/project_types/theme/commands/check.rb +4 -1
  27. data/lib/project_types/theme/commands/open.rb +2 -2
  28. data/lib/project_types/theme/commands/push.rb +1 -3
  29. data/lib/project_types/theme/commands/share.rb +56 -0
  30. data/lib/project_types/theme/messages/messages.rb +24 -3
  31. data/lib/shopify_cli/changelog.rb +97 -25
  32. data/lib/shopify_cli/command_options/command_serve_options.rb +10 -0
  33. data/lib/shopify_cli/commands/app/serve.rb +7 -7
  34. data/lib/shopify_cli/commands/login.rb +5 -2
  35. data/lib/shopify_cli/context.rb +13 -0
  36. data/lib/shopify_cli/identity_auth.rb +24 -4
  37. data/lib/shopify_cli/messages/messages.rb +15 -1
  38. data/lib/shopify_cli/release.rb +1 -1
  39. data/lib/shopify_cli/services/app/create/rails_service.rb +9 -1
  40. data/lib/shopify_cli/services/app/serve/node_service.rb +2 -25
  41. data/lib/shopify_cli/services/app/serve/php_service.rb +2 -25
  42. data/lib/shopify_cli/services/app/serve/rails_service.rb +8 -28
  43. data/lib/shopify_cli/services/app/serve/serve_service.rb +57 -0
  44. data/lib/shopify_cli/services.rb +1 -0
  45. data/lib/shopify_cli/tasks/update_dashboard_urls.rb +7 -9
  46. data/lib/shopify_cli/theme/dev_server/remote_watcher/json_files_update_job.rb +1 -0
  47. data/lib/shopify_cli/theme/dev_server/watcher.rb +2 -8
  48. data/lib/shopify_cli/theme/dev_server.rb +3 -2
  49. data/lib/shopify_cli/theme/theme.rb +21 -7
  50. data/lib/shopify_cli/theme/theme_admin_api.rb +23 -8
  51. data/lib/shopify_cli/version.rb +1 -1
  52. data/vendor/deps/cli-ui/lib/cli/ui/os.rb +8 -0
  53. 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: 8f795330308fe8098043f9757452c62c5366eebcd724a90b3e81aafceb82a4f0
4
+ data.tar.gz: b5bac3e2def77bb94b993d39230a489d646bee5848cf4500e523da2b413e517f
5
5
  SHA512:
6
- metadata.gz: 31e29e63fd9f7e569f7d4834549645b1ca206489274709aa7577f57b6888b3bd28d06eb5bd5899721cf9478239fa524b7937c009575a93c0ac096cd56c911fa6
7
- data.tar.gz: '09f19940da497bf3fab8d8c78c801fc127c2a8cad8fe49887f86b05de373dc96acb805c8c282ce76c72d7ea89526d65f0ec0ef3732d6854110a50d02de2f240b'
6
+ metadata.gz: 05ffb12d03f75fd4bd1f5f8e0709445b51364cd8d8576407473c2f7ccc8ae1fa6d202181005041dd258ede96a1cd4a2382d9572cc427f936d62a9071229ce997
7
+ data.tar.gz: 2afbac5fe6fc03aa52858b00118661faac907cb23bb9c37368e46e4eb79feb3a309482d7ac59828b964c7a43d6de3c2446e750b6412344729e115f422b42bb84
@@ -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,44 @@ 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.3 - 2022-04-07
6
+
7
+ ### Changed
8
+ * [#2188](https://github.com/Shopify/shopify-cli/pull/2188): Update URLs by default on serve and add --no-update flag to skip it
9
+ * [#2203](https://github.com/Shopify/shopify-cli/pull/2203): Use javy version 0.3.0
10
+
11
+ ### Fixed
12
+ * [#2162](https://github.com/Shopify/shopify-cli/pull/2162): Improve encoding error handling for Checkout Extension localization
13
+ * [#2187](https://github.com/Shopify/shopify-cli/pull/2187): Fix app serve after rails update
14
+ * [#2191](https://github.com/Shopify/shopify-cli/pull/2191): Directories with the `.json` extension should not be handled as JSON files
15
+ * [#2018](https://github.com/Shopify/shopify-cli/pull/2018): Run theme-check as a code dependency, not a pseudo-CLI invocation
16
+ * [#2211](https://github.com/Shopify/shopify-cli/pull/2211): Fix the `theme open` command to open the theme in the browser
17
+ * [#2183](https://github.com/Shopify/shopify-cli/pull/2183): Improve error message when suspended users run `theme serve`
18
+ * [#2219](https://github.com/Shopify/shopify-cli/pull/2219): Fix issues when creating Rails apps after the release of `shopify_app` v19
19
+
20
+ ### Added
21
+ * [#2190](https://github.com/Shopify/shopify-cli/pull/2190): Better login experience with spinner
22
+ * [#2200](https://github.com/Shopify/shopify-cli/pull/2200): Add `theme share` command
23
+
24
+ ## Version 2.15.2 - 2022-03-28
6
25
 
7
26
  ### Fixed
8
27
  * [#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
28
 
10
- ## Version 2.15.1
29
+ ### Added
30
+ * [#2174](https://github.com/Shopify/shopify-cli/pull/2174): Add optional 2-way sync between the CLI (`theme serve`) and the Theme Editor
31
+
32
+ ## Version 2.15.1 - 2022-03-24
11
33
 
12
34
  ### Added
13
35
  * [#1934](https://github.com/Shopify/shopify-cli/pull/1934): Block directories in theme assets
14
36
  * [#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
37
 
17
38
  ### Fixed
18
39
  * [#1874](https://github.com/Shopify/shopify-cli/pull/1874): Make ngrok errors more robust and helpful
19
40
  * [#2172](https://github.com/Shopify/shopify-cli/pull/2172): Fix Ruby check for Rails app creation
20
41
 
21
- ## Version 2.15.0
42
+ ## Version 2.15.0 - 2022-03-21
22
43
 
23
44
  ### Fixed
24
45
  * [#2086](https://github.com/Shopify/shopify-cli/pull/2086): Improve check of dependency versions
@@ -26,7 +47,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
26
47
  * [#2122](https://github.com/Shopify/shopify-cli/pull/2122): Fix `--only`/`--ignore` flags parser to support multiple occurrences without quotes
27
48
  * [#2146](https://github.com/Shopify/shopify-cli/pull/2146): Prevent duplicate locales for Checkout extension localization
28
49
 
29
- ## Version 2.14.0
50
+ ## Version 2.14.0 - 2022-03-15
30
51
 
31
52
  ### Changed
32
53
  * [#2126](https://github.com/Shopify/shopify-cli/pull/2126): Use javy version 0.2.1
@@ -40,7 +61,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
40
61
  * [#2130](https://github.com/Shopify/shopify-cli/pull/2130): Fix Homebrew installation.
41
62
  * [#2133](https://github.com/Shopify/shopify-cli/pull/2133): Fix ignore file handling in DevServer::Watcher.
42
63
 
43
- ## Version 2.13.0
64
+ ## Version 2.13.0 - 2022-03-02
44
65
 
45
66
  ### Added
46
67
  * [#2087](https://github.com/Shopify/shopify-cli/pull/2087): Add new Theme CLI commands: `theme list` and `theme open`
@@ -54,7 +75,8 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
54
75
  ### Removed
55
76
  * [#2102](https://github.com/Shopify/shopify-cli/pull/2102): Remove AssemblyScript as a supported script language.
56
77
 
57
- ## Version 2.12.0
78
+ ## Version 2.12.0 - 2022-02-23
79
+
58
80
  ### Added
59
81
  * [#1866](https://github.com/Shopify/shopify-cli/pull/1866): Enforce git dependency
60
82
  * [#2009](https://github.com/Shopify/shopify-cli/pull/2009): Add localization support for Checkout Extensions
@@ -69,21 +91,24 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
69
91
  * [#2066](https://github.com/Shopify/shopify-cli/pull/2066): Improve `--only`/`--ignore` parameters on Theme `pull`/`push` commands to work without quotes
70
92
  * [#2078](https://github.com/Shopify/shopify-cli/pull/2078): Fix errors on section rendering caused by CORS issues
71
93
 
72
- ## Version 2.11.2
94
+ ## Version 2.11.2 - 2022-02-14
95
+
73
96
  ### Fixed
74
97
  * [#2047](https://github.com/Shopify/shopify-cli/pull/2047): Fix the Homebrew installation
75
98
  * [#2019](https://github.com/Shopify/shopify-cli/pull/2019): Provide helpful link when nokogiri fails to load
76
99
  * [#2055](https://github.com/Shopify/shopify-cli/pull/2055): Remove unneeded Node requirements
77
100
  * [#2020](https://github.com/Shopify/shopify-cli/pull/2020): Fix `theme pull` so that correct dev theme is used with `-d` option
78
101
 
79
- ## Version 2.11.1
102
+ ## Version 2.11.1 - 2022-02-09
103
+
80
104
  ### Fixed
81
105
  * [#1973](https://github.com/Shopify/shopify-cli/pull/1973): Fix `theme serve` to preview generated files (`*.css.liquid`)
82
106
  * [#2034](https://github.com/Shopify/shopify-cli/pull/2034): Fix `theme serve` to accept parameters with multiple values
83
107
  * [#2033](https://github.com/Shopify/shopify-cli/pull/2033): Pin Homebrew Ruby to 3.0
84
108
  * [#2032](https://github.com/Shopify/shopify-cli/pull/2032): Runtime error checking the Node version if Node is not present in the environment.
85
109
 
86
- ## Version 2.11.0
110
+ ## Version 2.11.0 - 2022-02-07
111
+
87
112
  ### Fixed
88
113
  * [#2005](https://github.com/Shopify/shopify-cli/pull/2005): Fix PHP app serve on Windows environments
89
114
 
@@ -98,17 +123,20 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
98
123
  * [#2002](https://github.com/Shopify/shopify-cli/pull/2002): Update `-o`/`--only` parameter to allow multiple patterns on `theme push`/`theme pull` commands
99
124
  * [#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
125
 
101
- ## Version 2.10.2
126
+ ## Version 2.10.2 - 2022-01-31
127
+
102
128
  ### Fixed
103
129
  * [#1983](https://github.com/Shopify/shopify-cli/pull/1983): Improve Windows compatibility
104
130
  * [#1928](https://github.com/Shopify/shopify-cli/pull/1928): Ensure script Wasm file sizes don't exceed the limit
105
131
  * [#2006](https://github.com/Shopify/shopify-cli/pull/2006): Fix: More defensive URL generation
106
132
 
107
- ## Version 2.10.1
133
+ ## Version 2.10.1 - 2022-01-28
134
+
108
135
  ### Fixed
109
136
  * [#1985](https://github.com/Shopify/shopify-cli/pull/1985): Revert "Fix CORS (Cross-origin resource sharing) errors (#1952)"
110
137
 
111
- ## Version 2.10.0
138
+ ## Version 2.10.0 - 2022-01-25
139
+
112
140
  ### Fixed
113
141
  * [#1937](https://github.com/Shopify/shopify-cli/pull/1937): Fix `theme pull` to no longer add empty lines on Windows
114
142
  * [#1952](https://github.com/Shopify/shopify-cli/pull/1952): Fix CORS (cross-origin resource sharing) errors
@@ -117,7 +145,8 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
117
145
  ### Added
118
146
  * [#1892](https://github.com/Shopify/shopify-cli/pull/1892): Add `-o`/`--only` parameter to filter files on `theme push`/`theme pull` commands
119
147
 
120
- ## Version 2.9.0
148
+ ## Version 2.9.0 - 2022-01-17
149
+
121
150
  ### Fixed
122
151
  * [#1922](https://github.com/Shopify/shopify-cli/pull/1922): Respect RUBY_BINDIR from Homebrew for installing gem
123
152
  * [#1906](https://github.com/Shopify/shopify-cli/pull/1906): Fix Ngrok incompatibility with some Apple ARM environments
@@ -131,13 +160,15 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
131
160
  * [#1871](https://github.com/Shopify/shopify-cli/pull/1871): Add a new `--live-reload` parameter to the `theme serve` command
132
161
 
133
162
  ### Changed
134
- - [#1929](https://github.com/Shopify/shopify-cli/pull/1929): Rename `--registration-id` to `--extension-id` in `shopify extension push`.
163
+ * [#1929](https://github.com/Shopify/shopify-cli/pull/1929): Rename `--registration-id` to `--extension-id` in `shopify extension push`.
164
+
165
+ ## Version 2.8.0 - 2022-01-06
135
166
 
136
- ## Version 2.8.0
137
167
  ### Fixed
138
168
  * [#1879](https://github.com/Shopify/shopify-cli/pull/1879): Disambiguate -s as store option
139
169
 
140
- ## Version 2.7.4
170
+ ## Version 2.7.4 - 2021-12-22
171
+
141
172
  ### Added
142
173
  * [#1825](https://github.com/Shopify/shopify-cli/pull/1825): Support passing the connection information through arguments
143
174
 
@@ -148,10 +179,11 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
148
179
  * [#1850](https://github.com/Shopify/shopify-cli/pull/1850): Fix `shopify extension` commands timeout when organization has too many apps
149
180
  * [#1860](https://github.com/Shopify/shopify-cli/pull/1860): Fix `theme serve` hot reload when there are many tabs active
150
181
 
151
- ## Version 2.7.3
182
+ ## Version 2.7.3 - 2021-12-13
183
+
152
184
  ### Added
153
185
  * [#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
186
+ * [#1843](https://github.com/Shopify/shopify-cli/pull/1843): Support using javy on Apple ARM processors
155
187
  * [#1847](https://github.com/Shopify/shopify-cli/pull/1847): `shopify script connect` command.
156
188
 
157
189
  ### Fixed
@@ -164,7 +196,8 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
164
196
  * [#1830](https://github.com/Shopify/shopify-cli/pull/1830): Fix hot reload when users update many files "simultaneously"
165
197
  * [#1837](https://github.com/Shopify/shopify-cli/pull/1837): Fix `ShopifyCLI::Theme::DevServer::CdnFonts` class to support any font
166
198
 
167
- ## Version 2.7.2
199
+ ## Version 2.7.2 - 2021-11-30
200
+
168
201
  ### Fixed
169
202
  * [#1763](https://github.com/Shopify/shopify-cli/pull/1763): Fix: Tunnel --PORT parameter not working in Node.js app.
170
203
  * [#1769](https://github.com/Shopify/shopify-cli/pull/1769): Fix `theme push --development --json` to output the proper exit code
@@ -175,14 +208,16 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
175
208
  * [#1788](https://github.com/Shopify/shopify-cli/pull/1788): Improve `theme serve` errors and add logs for successful operations
176
209
  * [#1794](https://github.com/Shopify/shopify-cli/pull/1794): Fix bug where hidden subcommands appear in the help menu.
177
210
 
178
- ## Version 2.7.1
211
+ ## Version 2.7.1 - 2021-11-17
212
+
179
213
  ### Fixed
180
214
  * [#1722](https://github.com/Shopify/shopify-cli/pull/1722): Fix `theme serve` failing when the port is already being used
181
215
  * [#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
216
  * [#1750](https://github.com/Shopify/shopify-cli/pull/1750): Runtime errors in Windows' environments when the `PATHEXT` environment variable is not defined.
183
217
  * [#1758](https://github.com/Shopify/shopify-cli/pull/1758): Fix tunnel creation for expired anonymous tunnels
184
218
 
185
- ## Version 2.7.0
219
+ ## Version 2.7.0 - 2021-11-15
220
+
186
221
  ### Changed
187
222
  * [#1650](https://github.com/Shopify/shopify-cli/pull/1650): **Breaking** Move app commands under `shopify app`.
188
223
 
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.3)
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
@@ -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
@@ -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
@@ -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")
@@ -23,19 +23,23 @@ module Script
23
23
  )
24
24
 
25
25
  # remove the need to pass the whole extension-point object to the infra layer
26
- sparse_checkout_repo = extension_point.libraries.for(language).repo
27
26
  type = extension_point.dasherize_type
28
27
  domain = extension_point.domain
29
28
 
29
+ sparse_checkout_details = Infrastructure::SparseCheckoutDetails.new(
30
+ repo: extension_point.libraries.for(language).repo,
31
+ branch: sparse_checkout_branch,
32
+ path: "#{domain}/#{language}/#{type}/default",
33
+ input_queries_enabled: input_queries_enabled?,
34
+ )
35
+
30
36
  project_creator = Infrastructure::Languages::ProjectCreator.for(
31
37
  ctx: ctx,
32
38
  language: language,
33
39
  type: type,
34
40
  project_name: title,
35
41
  path_to_project: project.id,
36
- sparse_checkout_repo: sparse_checkout_repo,
37
- sparse_checkout_branch: sparse_checkout_branch,
38
- sparse_checkout_set_path: "#{domain}/#{language}/#{type}/default"
42
+ sparse_checkout_details: sparse_checkout_details,
39
43
  )
40
44
 
41
45
  install_dependencies(ctx, language, title, project_creator)
@@ -49,12 +53,12 @@ module Script
49
53
  task_runner = Infrastructure::Languages::TaskRunner.for(ctx, language)
50
54
  CLI::UI::Frame.open(ctx.message(
51
55
  "core.git.pulling_from_to",
52
- project_creator.sparse_checkout_repo,
56
+ project_creator.sparse_checkout_details.repo,
53
57
  title,
54
58
  )) do
55
59
  UI::StrictSpinner.spin(ctx.message(
56
60
  "core.git.pulling",
57
- project_creator.sparse_checkout_repo,
61
+ project_creator.sparse_checkout_details.repo,
58
62
  title,
59
63
  )) do |spinner|
60
64
  project_creator.setup_dependencies
@@ -75,6 +79,10 @@ module Script
75
79
  ensure
76
80
  script_project_repo.change_to_initial_directory
77
81
  end
82
+
83
+ def input_queries_enabled?
84
+ ShopifyCLI::Feature.enabled?(:scripts_beta_input_queries)
85
+ end
78
86
  end
79
87
  end
80
88
  end