shopify-cli 2.11.1 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/shopify.yml +2 -1
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -1
  5. data/CHANGELOG.md +32 -0
  6. data/Gemfile.lock +14 -14
  7. data/bin/shopify +17 -4
  8. data/dev.yml +1 -1
  9. data/docs/users/installation.md +1 -44
  10. data/ext/javy/hashes/javy-arm-macos-v0.2.0.gz.sha256 +1 -0
  11. data/ext/javy/hashes/javy-x86_64-linux-v0.2.0.gz.sha256 +1 -0
  12. data/ext/javy/hashes/javy-x86_64-macos-v0.2.0.gz.sha256 +1 -0
  13. data/ext/javy/hashes/javy-x86_64-windows-v0.2.0.gz.sha256 +1 -0
  14. data/ext/javy/version +1 -1
  15. data/lib/project_types/extension/commands/build.rb +0 -3
  16. data/lib/project_types/extension/commands/check.rb +0 -1
  17. data/lib/project_types/extension/commands/create.rb +0 -1
  18. data/lib/project_types/extension/commands/push.rb +0 -1
  19. data/lib/project_types/extension/commands/serve.rb +0 -1
  20. data/lib/project_types/extension/features/argo_setup_steps.rb +4 -6
  21. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +114 -0
  22. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +7 -1
  23. data/lib/project_types/extension/tasks/configure_features.rb +15 -2
  24. data/lib/project_types/extension/tasks/convert_server_config.rb +2 -1
  25. data/lib/project_types/script/cli.rb +2 -0
  26. data/lib/project_types/script/commands/create.rb +5 -5
  27. data/lib/project_types/script/commands/push.rb +4 -6
  28. data/lib/project_types/script/config/extension_points.yml +0 -4
  29. data/lib/project_types/script/errors.rb +1 -1
  30. data/lib/project_types/script/forms/create.rb +7 -20
  31. data/lib/project_types/script/layers/application/build_script.rb +22 -24
  32. data/lib/project_types/script/layers/application/connect_app.rb +3 -2
  33. data/lib/project_types/script/layers/application/create_script.rb +9 -10
  34. data/lib/project_types/script/layers/application/project_dependencies.rb +12 -14
  35. data/lib/project_types/script/layers/application/push_script.rb +2 -0
  36. data/lib/project_types/script/layers/domain/errors.rb +3 -3
  37. data/lib/project_types/script/layers/domain/push_package.rb +6 -0
  38. data/lib/project_types/script/layers/domain/script_config.rb +2 -4
  39. data/lib/project_types/script/layers/domain/script_project.rb +3 -2
  40. data/lib/project_types/script/layers/infrastructure/errors.rb +11 -0
  41. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +20 -9
  42. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +29 -18
  43. data/lib/project_types/script/layers/infrastructure/languages/project_creator.rb +0 -15
  44. data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +26 -0
  45. data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +22 -10
  46. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +30 -19
  47. data/lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb +0 -3
  48. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +4 -0
  49. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +13 -25
  50. data/lib/project_types/script/layers/infrastructure/script_service.rb +4 -2
  51. data/lib/project_types/script/loaders/project.rb +8 -7
  52. data/lib/project_types/script/messages/messages.rb +20 -19
  53. data/lib/project_types/script/ui/error_handler.rb +17 -4
  54. data/lib/project_types/script/ui/strict_spinner.rb +4 -6
  55. data/lib/project_types/theme/cli.rb +2 -0
  56. data/lib/project_types/theme/commands/common/root_helper.rb +71 -0
  57. data/lib/project_types/theme/commands/init.rb +2 -0
  58. data/lib/project_types/theme/commands/list.rb +34 -0
  59. data/lib/project_types/theme/commands/open.rb +65 -0
  60. data/lib/project_types/theme/commands/pull.rb +20 -10
  61. data/lib/project_types/theme/commands/push.rb +18 -12
  62. data/lib/project_types/theme/commands/serve.rb +6 -2
  63. data/lib/project_types/theme/conversions/base_glob.rb +50 -0
  64. data/lib/project_types/theme/conversions/ignore_glob.rb +15 -0
  65. data/lib/project_types/theme/conversions/include_glob.rb +15 -0
  66. data/lib/project_types/theme/forms/select.rb +11 -39
  67. data/lib/project_types/theme/messages/messages.rb +36 -7
  68. data/lib/project_types/theme/presenters/theme_presenter.rb +48 -0
  69. data/lib/project_types/theme/presenters/themes_presenter.rb +32 -0
  70. data/lib/shopify_cli/api.rb +1 -1
  71. data/lib/shopify_cli/command.rb +3 -1
  72. data/lib/shopify_cli/commands/app/create/node.rb +1 -0
  73. data/lib/shopify_cli/commands/app/create/php.rb +1 -0
  74. data/lib/shopify_cli/commands/app/create/rails.rb +1 -0
  75. data/lib/shopify_cli/commands/app/deploy.rb +1 -0
  76. data/lib/shopify_cli/constants.rb +3 -3
  77. data/lib/shopify_cli/context.rb +11 -13
  78. data/lib/shopify_cli/environment.rb +6 -0
  79. data/lib/shopify_cli/git.rb +9 -1
  80. data/lib/shopify_cli/messages/messages.rb +23 -3
  81. data/lib/shopify_cli/services/app/create/rails_service.rb +1 -1
  82. data/lib/shopify_cli/tasks/ensure_git_dependency.rb +14 -0
  83. data/lib/shopify_cli/tasks.rb +1 -0
  84. data/lib/shopify_cli/theme/dev_server/proxy.rb +14 -2
  85. data/lib/shopify_cli/theme/dev_server.rb +1 -3
  86. data/lib/shopify_cli/theme/development_theme.rb +11 -0
  87. data/lib/shopify_cli/theme/include_filter.rb +4 -2
  88. data/lib/shopify_cli/theme/syncer.rb +20 -11
  89. data/lib/shopify_cli/theme/theme.rb +0 -4
  90. data/lib/shopify_cli/version.rb +1 -1
  91. data/shopify-dev +9 -11
  92. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4c9bb44a8b7b750acbf3364201705d93dfb39ce9772976ba2af04183cfc5748
4
- data.tar.gz: fa32248af15c17d01d80132b4caf42ea224edba35146098954f51b4453db50de
3
+ metadata.gz: e54fd77e2aa3b1721ea02cd7cad4a84afdae67a3c73510e6ee8b01e44bfc5949
4
+ data.tar.gz: a92380f94b7a33cea4eae04d2d528ef09a51d161a5b77a900a294e7176ee89e9
5
5
  SHA512:
6
- metadata.gz: 3446d1a595e343f6566b7ec087c187d31518398ad57be75ff519a394133c75e4f0a5f8670d78913271091632d8ef9fdeef4fb1bb3c1b4ac5cb99d0bc12aef765
7
- data.tar.gz: 48ad3c64a367e80facb7aecc393295fb8fa838949a51c7a71310c50a40e6bf2c648b57dbcaf53ade5e15af90ff911593e38865cbb8e2b8dce6b70a8918d83a03
6
+ metadata.gz: 3a55cc0e5a57ab4a842411667dfca871140ef324d17c537157e3913cce383c84ae70ebd26cbf8f14a020b94283c9d6264ab71af5f55c37255fbe7966ee8f46f5
7
+ data.tar.gz: 24328c051c6795d7c4778fdaea861cc77d3337a886126074bce4ae3073b635b6bcd878457e8cad4399c5982b0be5d168a3f6f3c86c5e3bbbe7b7b2ce192e4d58
@@ -17,6 +17,7 @@ jobs:
17
17
  strategy:
18
18
  matrix:
19
19
  version:
20
+ - 3.1.0
20
21
  - 3.0.2
21
22
  - 2.6.6
22
23
  - 2.7.5
@@ -82,7 +83,7 @@ jobs:
82
83
  strategy:
83
84
  matrix:
84
85
  version:
85
- - 3.0.2
86
+ - 3.1.0
86
87
  os:
87
88
  - macos-latest
88
89
  steps:
data/.rubocop.yml CHANGED
@@ -46,7 +46,7 @@ AllCops:
46
46
  - "vendor/**/*"
47
47
  - "docs/**/*"
48
48
  - "packaging/**/*"
49
- TargetRubyVersion: 2.4
49
+ TargetRubyVersion: 2.6
50
50
 
51
51
  Layout/EmptyLines:
52
52
  Exclude:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.5
1
+ 3.1.0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@ 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.13.0
6
+
7
+ ### Added
8
+ * [#2087](https://github.com/Shopify/shopify-cli/pull/2087): Add new Theme CLI commands: `theme list` and `theme open`
9
+ * [#2035](https://github.com/Shopify/shopify-cli/pull/2035): Support Ruby 3.1
10
+
11
+ ### Fixed
12
+ * [#2092](https://github.com/Shopify/shopify-cli/pull/2092): Fix `RootHelper` parse logic to support options with an equal (e.g.: `option=value`)
13
+ * [#2089](https://github.com/Shopify/shopify-cli/pull/2089): Use javy version 0.2.0
14
+
15
+ ## Version 2.12.0
16
+ ### Added
17
+ * [#1866](https://github.com/Shopify/shopify-cli/pull/1866): Enforce git dependency
18
+ * [#2009](https://github.com/Shopify/shopify-cli/pull/2009): Add localization support for Checkout Extensions
19
+ * [#2060](https://github.com/Shopify/shopify-cli/pull/2060): Improve CLI error messages for token-based auth (scripts)
20
+ * [#2076](https://github.com/Shopify/shopify-cli/pull/2076): Release Wasm Script Projects
21
+ * [#2051](https://github.com/Shopify/shopify-cli/pull/2051): Update `theme serve` to accept `root` argument
22
+ * [#2025](https://github.com/Shopify/shopify-cli/pull/2025): Improve `theme pull`/`push` help messages to indicate multiple `--only`/`--ignore` flags are allowed.
23
+
24
+ ### Fixed
25
+ * [#2030](https://github.com/Shopify/shopify-cli/pull/2030): Fix Theme::Syncer handling of file deletions in `download_file!`
26
+ * [#2071](https://github.com/Shopify/shopify-cli/pull/2071): Fix `theme pull` error message when dev theme doesn't exist
27
+ * [#2066](https://github.com/Shopify/shopify-cli/pull/2066): Improve `--only`/`--ignore` parameters on Theme `pull`/`push` commands to work without quotes
28
+ * [#2078](https://github.com/Shopify/shopify-cli/pull/2078): Fix errors on section rendering caused by CORS issues
29
+
30
+ ## Version 2.11.2
31
+ ### Fixed
32
+ * [#2047](https://github.com/Shopify/shopify-cli/pull/2047): Fix the Homebrew installation
33
+ * [#2019](https://github.com/Shopify/shopify-cli/pull/2019): Provide helpful link when nokogiri fails to load
34
+ * [#2055](https://github.com/Shopify/shopify-cli/pull/2055): Remove unneeded Node requirements
35
+ * [#2020](https://github.com/Shopify/shopify-cli/pull/2020): Fix `theme pull` so that correct dev theme is used with `-d` option
36
+
5
37
  ## Version 2.11.1
6
38
  ### Fixed
7
39
  * [#1973](https://github.com/Shopify/shopify-cli/pull/1973): Fix `theme serve` to preview generated files (`*.css.liquid`)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.11.1)
4
+ shopify-cli (2.13.0)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
7
  theme-check (~> 1.9.0)
@@ -66,7 +66,7 @@ GEM
66
66
  mime-types (3.3.1)
67
67
  mime-types-data (~> 3.2015)
68
68
  mime-types-data (3.2021.0901)
69
- mini_portile2 (2.6.1)
69
+ mini_portile2 (2.8.0)
70
70
  minitest (5.14.4)
71
71
  minitest-fail-fast (0.1.0)
72
72
  minitest (~> 5)
@@ -77,11 +77,11 @@ GEM
77
77
  ruby-progressbar
78
78
  mocha (1.13.0)
79
79
  multi_test (0.1.2)
80
- nokogiri (1.12.5)
81
- mini_portile2 (~> 2.6.1)
80
+ nokogiri (1.13.3)
81
+ mini_portile2 (~> 2.8.0)
82
82
  racc (~> 1.4)
83
83
  parallel (1.21.0)
84
- parser (3.0.3.1)
84
+ parser (3.1.0.0)
85
85
  ast (~> 2.4.1)
86
86
  pry (0.13.1)
87
87
  coderay (~> 1.1)
@@ -92,24 +92,24 @@ GEM
92
92
  public_suffix (4.0.6)
93
93
  racc (1.6.0)
94
94
  rack (2.2.3)
95
- rainbow (3.0.0)
95
+ rainbow (3.1.1)
96
96
  rake (13.0.6)
97
97
  rb-fsevent (0.11.0)
98
98
  rb-inotify (0.10.1)
99
99
  ffi (~> 1.0)
100
- regexp_parser (2.1.1)
100
+ regexp_parser (2.2.0)
101
101
  rexml (3.2.5)
102
- rubocop (1.12.1)
102
+ rubocop (1.25.1)
103
103
  parallel (~> 1.10)
104
- parser (>= 3.0.0.0)
104
+ parser (>= 3.1.0.0)
105
105
  rainbow (>= 2.2.2, < 4.0)
106
106
  regexp_parser (>= 1.8, < 3.0)
107
107
  rexml
108
- rubocop-ast (>= 1.2.0, < 2.0)
108
+ rubocop-ast (>= 1.15.1, < 2.0)
109
109
  ruby-progressbar (~> 1.7)
110
110
  unicode-display_width (>= 1.4.0, < 3.0)
111
- rubocop-ast (1.4.1)
112
- parser (>= 2.7.1.5)
111
+ rubocop-ast (1.15.1)
112
+ parser (>= 3.0.1.1)
113
113
  rubocop-minitest (0.10.1)
114
114
  rubocop (>= 0.87)
115
115
  rubocop-rake (0.5.1)
@@ -123,8 +123,8 @@ GEM
123
123
  liquid (>= 5.1.0)
124
124
  nokogiri (>= 1.12)
125
125
  parser (~> 3)
126
- timecop (0.9.2)
127
- unicode-display_width (2.0.0)
126
+ timecop (0.9.4)
127
+ unicode-display_width (2.1.0)
128
128
  webmock (3.9.3)
129
129
  addressable (>= 2.3.6)
130
130
  crack (>= 0.3.2)
data/bin/shopify CHANGED
@@ -14,6 +14,19 @@ module Kernel
14
14
  raise if name == "#{RUBY_VERSION[/\d+\.\d+/]}/psych.so"
15
15
  # Special case for ffi, which rescues this itself
16
16
  raise if name == "#{RUBY_VERSION.split(".")[0, 2].join(".")}/ffi_c"
17
+ # Special case for nokogiri, which might install the wrong architecture
18
+ if name == "nokogiri/nokogiri"
19
+ STDERR.puts(<<~MESSAGE)
20
+ The Nokogiri gem is failing to load, due to an installation or architecture issue.
21
+
22
+ To fix this, reinstall Nokogiri.
23
+
24
+ • Installation guide: https://nokogiri.org/tutorials/installing_nokogiri.html
25
+
26
+ MESSAGE
27
+ STDERR.puts e.full_message
28
+ exit(1)
29
+ end
17
30
  STDERR.puts "[Note] You cannot use gems with Shopify CLI."
18
31
  STDERR.puts "[LoadError] #{e.message}"
19
32
  if ENV["DEBUG"]
@@ -31,8 +44,8 @@ end
31
44
 
32
45
  require_relative "./load_shopify"
33
46
 
34
- exit(proc do
35
- begin
47
+ exit(
48
+ proc do
36
49
  ShopifyCLI::ErrorHandler.call do
37
50
  ShopifyCLI::Core::EntryPoint.call(ARGV.dup)
38
51
  end
@@ -43,5 +56,5 @@ exit(proc do
43
56
  else
44
57
  1
45
58
  end
46
- end
47
- end.call)
59
+ end.call
60
+ )
data/dev.yml CHANGED
@@ -6,7 +6,7 @@ env:
6
6
  SHOPIFY_CLI_DEVELOPMENT: "1"
7
7
 
8
8
  up:
9
- - ruby: 2.7.5
9
+ - ruby: 3.1.0
10
10
  - homebrew:
11
11
  - dpkg:
12
12
  version: 1.21.1
@@ -1,46 +1,3 @@
1
1
  # Installation
2
2
 
3
- ## Installation through RubyGems
4
-
5
- The easiest method to install the Shopify CLI is through RubyGems:
6
-
7
- ```shell
8
- $ gem install shopify-cli
9
- ```
10
-
11
- ## Installation for macOS Users
12
-
13
- - Make sure you have [Homebrew](https://brew.sh/) installed
14
- - Open your terminal app
15
- - Run `brew tap shopify/shopify`
16
- - Run `brew install shopify-cli`
17
- - After the installation is completed, run `shopify version`, if this outputs a version number you've successfully installed the CLI.
18
-
19
- ### To upgrade Shopify CLI
20
-
21
- #### Homebrew (Mac OS)
22
-
23
- ```shell
24
- $ brew update
25
- $ brew upgrade shopify-cli
26
- ```
27
-
28
- ## Installation for Debian and Ubuntu users through `apt`
29
-
30
- 1.- Download the latest `.deb` binary for Shopify CLI from the releases page.
31
-
32
- 2.- Install the downloaded file and make sure to replace /path/to/download/shopify-cli-x.y.z.deb with the path to your file's location:
33
-
34
- ```shell
35
- $ sudo apt install /path/to/downloaded/shopify-cli-x.y.z.deb
36
- ```
37
-
38
- ## Installation for CentOS 8+, Fedora, Red Hat, and SUSE users through `yum`
39
-
40
- 1.- Download the latest .rpm file for Shopify App CLI from the releases page.
41
-
42
- 2.- Install the downloaded file and make sure to replace /path/to/downloaded/shopify-cli-x.y.x.rpm with the path to your file's location:
43
-
44
- ```shell
45
- $ sudo yum install /path/to/downloaded/shopify-cli-x.y.x.rpm
46
- ```
3
+ The installation guide can be found here: https://shopify.dev/apps/tools/cli/installation
@@ -0,0 +1 @@
1
+ 69ac26fd99a41aa1839cdf8fc8a734874370947ef79e88b90f661c2e58485ae0
@@ -0,0 +1 @@
1
+ 9d2686f5caccc34e30baff614ccfc487e90c5d1220e515ca4e47337a0b6a2daf
@@ -0,0 +1 @@
1
+ a68b5cbfce2b4b6c1a7e89e50d41dfc63f083e73f846547232897e06345e9ca3
@@ -0,0 +1 @@
1
+ 786e417716969fcac4e97d9c0c701966c54a49152f9f57fa164f916cf14ae5f3
data/ext/javy/version CHANGED
@@ -1 +1 @@
1
- v0.1.0
1
+ v0.2.0
@@ -8,9 +8,6 @@ module Extension
8
8
 
9
9
  prerequisite_task ensure_project_type: :extension
10
10
 
11
- recommend_default_node_range
12
- recommend_default_ruby_range
13
-
14
11
  YARN_BUILD_COMMAND = %w(build)
15
12
  NPM_BUILD_COMMAND = %w(run-script build)
16
13
 
@@ -4,7 +4,6 @@ require "theme_check"
4
4
  module Extension
5
5
  class Command
6
6
  class Check < ExtensionCommand
7
- recommend_default_node_range
8
7
  recommend_default_ruby_range
9
8
 
10
9
  class CheckOptions < ShopifyCLI::Options
@@ -5,7 +5,6 @@ module Extension
5
5
  class Create < ShopifyCLI::Command::SubCommand
6
6
  prerequisite_task :ensure_authenticated
7
7
 
8
- recommend_default_node_range
9
8
  recommend_default_ruby_range
10
9
 
11
10
  options do |parser, flags|
@@ -6,7 +6,6 @@ module Extension
6
6
  class Push < ShopifyCLI::Command::SubCommand
7
7
  prerequisite_task ensure_project_type: :extension
8
8
 
9
- recommend_default_node_range
10
9
  recommend_default_ruby_range
11
10
 
12
11
  options do |parser, flags|
@@ -5,7 +5,6 @@ module Extension
5
5
  class Serve < ExtensionCommand
6
6
  prerequisite_task ensure_project_type: :extension
7
7
 
8
- recommend_default_node_range
9
8
  recommend_default_ruby_range
10
9
 
11
10
  DEFAULT_PORT = 39351
@@ -17,12 +17,10 @@ module Extension
17
17
 
18
18
  def self.clone_template(git_template)
19
19
  ArgoSetupStep.default do |context, _identifier, directory_name, _js_system|
20
- begin
21
- ShopifyCLI::Git.clone(git_template, directory_name, ctx: context)
22
- context.root = File.join(context.root, directory_name)
23
- rescue StandardError
24
- context.puts("{{x}} Unable to clone the repository.")
25
- end
20
+ ShopifyCLI::Git.clone(git_template, directory_name, ctx: context)
21
+ context.root = File.join(context.root, directory_name)
22
+ rescue StandardError
23
+ context.puts("{{x}} Unable to clone the repository.")
26
24
  end
27
25
  end
28
26
 
@@ -4,12 +4,24 @@ module Extension
4
4
  module Models
5
5
  module SpecificationHandlers
6
6
  class CheckoutUiExtension < Default
7
+ L10N_ERROR_PREFIX = "core.extension.push.checkout_ui_extension.localization.error"
8
+ L10N_FILE_SIZE_LIMIT = 16 * 1024 # 16kb
9
+ L10N_BUNDLE_SIZE_LIMIT = 256 * 1024 # 256kb
10
+ LOCALE_CODE_FORMAT = %r{
11
+ \A
12
+ (?<language>[a-zA-Z]{2,3}) # Language tag
13
+ (?:
14
+ -
15
+ (?<region>[a-zA-Z]{2}) # Optional region subtag
16
+ )?
17
+ \z}x
7
18
  PERMITTED_CONFIG_KEYS = [:extension_points, :metafields, :name]
8
19
 
9
20
  def config(context)
10
21
  {
11
22
  **Features::ArgoConfig.parse_yaml(context, PERMITTED_CONFIG_KEYS),
12
23
  **argo.config(context, include_renderer_version: false),
24
+ **localization(context),
13
25
  }
14
26
  end
15
27
 
@@ -22,6 +34,108 @@ module Extension
22
34
  return unless product
23
35
  format("/cart/%<variant_id>d:%<quantity>d", variant_id: product.variant_id, quantity: 1)
24
36
  end
37
+
38
+ private
39
+
40
+ def localization(context)
41
+ Dir.chdir(context.root) do
42
+ locale_filenames = Dir["locales/*"].select { |filename| valid_l10n_file?(filename) }
43
+ # Localization is optional
44
+ return {} if locale_filenames.empty?
45
+
46
+ validate_total_size(locale_filenames)
47
+ default_locale = single_default_locale(locale_filenames)
48
+
49
+ locale_filenames.map do |filename|
50
+ locale = basename_for_locale_filename(filename)
51
+ [locale.to_sym, Base64.strict_encode64(File.read(filename, mode: "rt", encoding: "UTF-8").strip)]
52
+ end
53
+ .yield_self do |encoded_files_by_locale|
54
+ {
55
+ localization: {
56
+ default_locale: default_locale,
57
+ translations: encoded_files_by_locale.to_h,
58
+ },
59
+ }
60
+ end
61
+ end
62
+ end
63
+
64
+ def validate_total_size(locale_filenames)
65
+ total_size = locale_filenames.sum { |filename| File.size(filename) }
66
+ if total_size > L10N_BUNDLE_SIZE_LIMIT
67
+ raise(
68
+ ShopifyCLI::Abort,
69
+ ShopifyCLI::Context.message(
70
+ "#{L10N_ERROR_PREFIX}.bundle_too_large",
71
+ CLI::Kit::Util.to_filesize(L10N_BUNDLE_SIZE_LIMIT)
72
+ )
73
+ )
74
+ end
75
+ end
76
+
77
+ def single_default_locale(locale_filenames)
78
+ default_locale_matches = locale_filenames.grep(/default/)
79
+ if default_locale_matches.size != 1
80
+ raise(ShopifyCLI::Abort, ShopifyCLI::Context.message("#{L10N_ERROR_PREFIX}.single_default_locale"))
81
+ end
82
+ basename_for_locale_filename(default_locale_matches.first)
83
+ end
84
+
85
+ def valid_l10n_file?(filename)
86
+ return false unless File.file?(filename)
87
+ return false unless File.dirname(filename) == "locales"
88
+
89
+ validate_file_extension(filename)
90
+ validate_file_locale_code(filename)
91
+ validate_file_size(filename)
92
+ validate_file_not_empty(filename)
93
+
94
+ true
95
+ end
96
+
97
+ def validate_file_extension(filename)
98
+ if File.extname(filename) != ".json"
99
+ raise(
100
+ ShopifyCLI::Abort, ShopifyCLI::Context.message("#{L10N_ERROR_PREFIX}.invalid_file_extension", filename)
101
+ )
102
+ end
103
+ end
104
+
105
+ def validate_file_locale_code(filename)
106
+ unless valid_locale_code?(basename_for_locale_filename(filename))
107
+ raise(
108
+ ShopifyCLI::Abort, ShopifyCLI::Context.message("#{L10N_ERROR_PREFIX}.invalid_locale_code", filename)
109
+ )
110
+ end
111
+ end
112
+
113
+ def validate_file_size(filename)
114
+ if File.size(filename) > L10N_FILE_SIZE_LIMIT
115
+ raise(
116
+ ShopifyCLI::Abort,
117
+ ShopifyCLI::Context.message(
118
+ "#{L10N_ERROR_PREFIX}.file_too_large",
119
+ filename,
120
+ CLI::Kit::Util.to_filesize(L10N_FILE_SIZE_LIMIT)
121
+ )
122
+ )
123
+ end
124
+ end
125
+
126
+ def validate_file_not_empty(filename)
127
+ if File.zero?(filename)
128
+ raise(ShopifyCLI::Abort, ShopifyCLI::Context.message("#{L10N_ERROR_PREFIX}.file_empty", filename))
129
+ end
130
+ end
131
+
132
+ def valid_locale_code?(locale_code)
133
+ LOCALE_CODE_FORMAT.match?(locale_code)
134
+ end
135
+
136
+ def basename_for_locale_filename(filename)
137
+ File.basename(File.basename(filename, ".json"), ".default")
138
+ end
25
139
  end
26
140
  end
27
141
  end
@@ -6,10 +6,11 @@ module Extension
6
6
  module Models
7
7
  module SpecificationHandlers
8
8
  class ThemeAppExtension < Default
9
- SUPPORTED_BUCKETS = %w(assets blocks snippets)
9
+ SUPPORTED_BUCKETS = %w(assets blocks snippets locales)
10
10
  BUNDLE_SIZE_LIMIT = 10 * 1024 * 1024 # 10MB
11
11
  LIQUID_SIZE_LIMIT = 100 * 1024 # 100kb
12
12
  SUPPORTED_ASSET_EXTS = %w(.jpg .js .css .png .svg)
13
+ SUPPORTED_LOCALE_EXTS = %w(.json)
13
14
 
14
15
  def create(directory_name, context, getting_started: false)
15
16
  context.root = File.join(context.root, directory_name)
@@ -89,6 +90,11 @@ module Extension
89
90
  raise Extension::Errors::InvalidFilenameError,
90
91
  "Invalid filename: #{filename}; #{ext} is not supported"
91
92
  end
93
+ elsif dirname == "locales"
94
+ unless SUPPORTED_LOCALE_EXTS.include?(ext)
95
+ raise Extension::Errors::InvalidFilenameError,
96
+ "Invalid filename: #{filename}; Only #{SUPPORTED_LOCALE_EXTS.join(", ")} allowed in #{dirname}"
97
+ end
92
98
  elsif ext != ".liquid"
93
99
  raise Extension::Errors::InvalidFilenameError,
94
100
  "Invalid filename: #{filename}; Only .liquid allowed in #{dirname}"
@@ -12,13 +12,21 @@ module Extension
12
12
  argo_configuration = extract_argo_configuration(attributes)
13
13
  next if argo_configuration.nil?
14
14
  surface_area = extract_surface_area(argo_configuration)
15
- surface_area_configuration = fetch_surface_area_configuration(surface_area)
16
- argo_configuration.merge!(surface_area_configuration)
15
+ if known_surface_area?(surface_area)
16
+ surface_area_configuration = fetch_surface_area_configuration(surface_area)
17
+ argo_configuration.merge!(surface_area_configuration)
18
+ else
19
+ clear_argo_configuration(attributes)
20
+ end
17
21
  end
18
22
  end
19
23
 
20
24
  private
21
25
 
26
+ def known_surface_area?(surface_area)
27
+ surface_area_configurations.keys.include?(surface_area.to_sym)
28
+ end
29
+
22
30
  def extract_argo_configuration(attributes)
23
31
  attributes.dig(:features, :argo)
24
32
  end
@@ -35,6 +43,11 @@ module Extension
35
43
  end
36
44
  end
37
45
 
46
+ def clear_argo_configuration(attributes)
47
+ attributes[:name] = "#{attributes[:name]} (Warning: surface area not configured properly)"
48
+ attributes[:features][:argo] = nil
49
+ end
50
+
38
51
  def surface_area_configurations
39
52
  {
40
53
  admin: {
@@ -18,6 +18,7 @@ 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
21
22
 
22
23
  def self.call(*args)
23
24
  new(*args).call
@@ -36,7 +37,7 @@ module Extension
36
37
  build_dir: hash.dig("development", "build_dir") || DEFAULT_BUILD_DIR,
37
38
  renderer: renderer,
38
39
  entries: Models::ServerConfig::DevelopmentEntries.new(
39
- main: hash.dig("development", "entries", "main")
40
+ main: hash.dig("development", "entries", "main") || DEFAULT_MAIN
40
41
  )
41
42
  ),
42
43
  extension_points: hash.dig("extension_points"),
@@ -78,6 +78,8 @@ module Script
78
78
  Project.project_filepath("layers/infrastructure/languages/wasm_project_creator.rb")
79
79
  autoload :WasmTaskRunner,
80
80
  Project.project_filepath("layers/infrastructure/languages/wasm_task_runner.rb")
81
+ autoload :ToolVersionChecker,
82
+ Project.project_filepath("layers/infrastructure/languages/tool_version_checker.rb")
81
83
  end
82
84
 
83
85
  module ApiClients
@@ -8,7 +8,7 @@ module Script
8
8
  recommend_default_ruby_range
9
9
 
10
10
  options do |parser, flags|
11
- parser.on("--name=NAME") { |name| flags[:name] = name }
11
+ parser.on("--title=TITLE") { |title| flags[:title] = title }
12
12
  parser.on("--api=API_NAME") { |ep_name| flags[:extension_point] = ep_name }
13
13
  parser.on("--language=LANGUAGE") { |language| flags[:language] = language }
14
14
  parser.on("--branch=BRANCH") { |branch| flags[:branch] = branch }
@@ -18,18 +18,18 @@ module Script
18
18
  form = Forms::Create.ask(@ctx, args, options.flags)
19
19
  return @ctx.puts(self.class.help) if form.nil?
20
20
 
21
- unless !form.name.empty? && form.extension_point && form.language
21
+ unless !form.title.empty? && form.extension_point
22
22
  return @ctx.puts(self.class.help)
23
23
  end
24
24
 
25
25
  project = Layers::Application::CreateScript.call(
26
26
  ctx: @ctx,
27
- language: form.language,
27
+ language: options.flags[:language]&.downcase || "wasm",
28
28
  sparse_checkout_branch: options.flags[:branch] || "master",
29
- script_name: form.name,
29
+ title: form.title,
30
30
  extension_point_type: form.extension_point,
31
31
  )
32
- @ctx.puts(@ctx.message("script.create.change_directory_notice", project.script_name))
32
+ @ctx.puts(@ctx.message("script.create.change_directory_notice", project.title))
33
33
  rescue StandardError => e
34
34
  UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message("script.create.error.operation_failed"))
35
35
  end
@@ -5,10 +5,6 @@ module Script
5
5
  class Push < ShopifyCLI::Command::SubCommand
6
6
  prerequisite_task ensure_project_type: :script
7
7
 
8
- recommend_node(
9
- from: ::Script::Layers::Infrastructure::Languages::TypeScriptProjectCreator::MIN_NODE_VERSION,
10
- to: ShopifyCLI::Constants::SupportedVersions::Node::TO
11
- )
12
8
  recommend_default_ruby_range
13
9
 
14
10
  options do |parser, flags|
@@ -26,7 +22,7 @@ module Script
26
22
  push(project: project)
27
23
  rescue StandardError => e
28
24
  UI::ErrorHandler.pretty_print_and_raise(e,
29
- failed_op: @ctx.message("script.push.error.operation_failed_no_api_key"))
25
+ failed_op: @ctx.message("script.push.error.operation_failed"))
30
26
  end
31
27
 
32
28
  def push(project:)
@@ -38,7 +34,9 @@ module Script
38
34
  Layers::Application::PushScript.call(ctx: @ctx, force: force, project: project)
39
35
  @ctx.puts(@ctx.message("script.push.script_pushed", api_key: api_key))
40
36
  else
41
- raise ShopifyCLI::Abort, @ctx.message("script.push.error.operation_failed_no_uuid")
37
+ message = @ctx.message("script.error.missing_push_options_ci", "--uuid")
38
+ message += @ctx.message("script.error.missing_push_options_ci_solution", ShopifyCLI::TOOL_NAME)
39
+ raise ShopifyCLI::Abort, message
42
40
  end
43
41
  end
44
42
 
@@ -9,7 +9,6 @@ payment_methods:
9
9
  package: "@shopify/scripts-checkout-apis"
10
10
  repo: "https://github.com/Shopify/scripts-apis-examples"
11
11
  wasm:
12
- beta: true
13
12
  repo: "https://github.com/Shopify/scripts-apis-examples"
14
13
  shipping_methods:
15
14
  domain: 'checkout'
@@ -22,7 +21,6 @@ shipping_methods:
22
21
  package: "@shopify/scripts-checkout-apis"
23
22
  repo: "https://github.com/Shopify/scripts-apis-examples"
24
23
  wasm:
25
- beta: true
26
24
  repo: "https://github.com/Shopify/scripts-apis-examples"
27
25
  merchandise_discount_types:
28
26
  beta: true
@@ -33,7 +31,6 @@ merchandise_discount_types:
33
31
  package: "@shopify/scripts-discounts-apis"
34
32
  repo: "https://github.com/Shopify/scripts-apis-examples"
35
33
  wasm:
36
- beta: true
37
34
  repo: "https://github.com/Shopify/scripts-apis-examples"
38
35
  delivery_discount_types:
39
36
  beta: true
@@ -44,5 +41,4 @@ delivery_discount_types:
44
41
  package: "@shopify/scripts-discounts-apis"
45
42
  repo: "https://github.com/Shopify/scripts-apis-examples"
46
43
  wasm:
47
- beta: true
48
44
  repo: "https://github.com/Shopify/scripts-apis-examples"
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Script
4
4
  module Errors
5
- class InvalidScriptNameError < ScriptProjectError; end
5
+ class InvalidScriptTitleError < ScriptProjectError; end
6
6
 
7
7
  class NoExistingAppsError < ScriptProjectError; end
8
8
  class NoExistingOrganizationsError < ScriptProjectError; end