shopify-cli 2.11.0 → 2.12.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -1
- data/Gemfile.lock +1 -1
- data/bin/shopify +13 -0
- data/docs/users/installation.md +1 -44
- data/lib/project_types/extension/commands/build.rb +0 -3
- data/lib/project_types/extension/commands/check.rb +0 -1
- data/lib/project_types/extension/commands/create.rb +0 -1
- data/lib/project_types/extension/commands/push.rb +13 -1
- data/lib/project_types/extension/commands/serve.rb +0 -1
- data/lib/project_types/extension/loaders/project.rb +28 -8
- data/lib/project_types/extension/messages/messages.rb +10 -2
- data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +114 -0
- data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +7 -1
- data/lib/project_types/script/cli.rb +2 -0
- data/lib/project_types/script/commands/create.rb +2 -2
- data/lib/project_types/script/commands/push.rb +4 -6
- data/lib/project_types/script/config/extension_points.yml +0 -4
- data/lib/project_types/script/forms/create.rb +1 -14
- data/lib/project_types/script/layers/application/connect_app.rb +3 -2
- data/lib/project_types/script/layers/application/create_script.rb +1 -1
- data/lib/project_types/script/layers/application/push_script.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/errors.rb +11 -0
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +2 -6
- data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +30 -26
- data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +35 -9
- data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +26 -0
- data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +3 -6
- data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +31 -27
- data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +3 -7
- data/lib/project_types/script/loaders/project.rb +8 -7
- data/lib/project_types/script/messages/messages.rb +14 -13
- data/lib/project_types/script/ui/error_handler.rb +13 -0
- data/lib/project_types/theme/commands/check.rb +0 -1
- data/lib/project_types/theme/commands/common/root_helper.rb +65 -0
- data/lib/project_types/theme/commands/delete.rb +0 -1
- data/lib/project_types/theme/commands/init.rb +2 -1
- data/lib/project_types/theme/commands/language_server.rb +0 -1
- data/lib/project_types/theme/commands/package.rb +0 -1
- data/lib/project_types/theme/commands/publish.rb +0 -1
- data/lib/project_types/theme/commands/pull.rb +18 -9
- data/lib/project_types/theme/commands/push.rb +16 -11
- data/lib/project_types/theme/commands/serve.rb +6 -3
- data/lib/project_types/theme/conversions/base_glob.rb +50 -0
- data/lib/project_types/theme/conversions/ignore_glob.rb +15 -0
- data/lib/project_types/theme/conversions/include_glob.rb +15 -0
- data/lib/project_types/theme/messages/messages.rb +5 -5
- data/lib/shopify_cli/command.rb +11 -3
- data/lib/shopify_cli/commands/app/create/node.rb +1 -0
- data/lib/shopify_cli/commands/app/create/php.rb +1 -0
- data/lib/shopify_cli/commands/app/create/rails.rb +2 -1
- data/lib/shopify_cli/commands/app/create.rb +0 -3
- data/lib/shopify_cli/commands/app/deploy.rb +1 -1
- data/lib/shopify_cli/commands/app/serve.rb +0 -1
- data/lib/shopify_cli/constants.rb +2 -2
- data/lib/shopify_cli/environment.rb +45 -45
- data/lib/shopify_cli/git.rb +9 -1
- data/lib/shopify_cli/messages/messages.rb +23 -2
- data/lib/shopify_cli/tasks/ensure_git_dependency.rb +14 -0
- data/lib/shopify_cli/tasks.rb +1 -0
- data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +63 -0
- data/lib/shopify_cli/theme/dev_server/hot_reload.rb +22 -6
- data/lib/shopify_cli/theme/dev_server/proxy.rb +18 -7
- data/lib/shopify_cli/theme/dev_server.rb +1 -3
- data/lib/shopify_cli/theme/development_theme.rb +11 -0
- data/lib/shopify_cli/theme/file.rb +4 -0
- data/lib/shopify_cli/theme/include_filter.rb +4 -2
- data/lib/shopify_cli/theme/syncer.rb +13 -4
- data/lib/shopify_cli/theme/theme.rb +0 -4
- data/lib/shopify_cli/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee0786bedc79f0e7fb3646adc5161faeb0fb2f4f15c6147394782db33236f425
|
4
|
+
data.tar.gz: 13d805804c7764151bfdd80747e879bd480ffcf85ba91fa280b776b93f784855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8347252541e765517a6bc485cc7bc1b811771a55610543549d676d5321944185e9a446bed4c8a3909f21f336fd56ae76b91ede2e3731f30ea66c0916d1a3e591
|
7
|
+
data.tar.gz: 930367d81adf351b66aa7365daaf9f4406067db80a4959409e68ddd5ab7041ed10db4f983f81d1af3d8f2457b8d79543cbf33c927e69bfbde027a31da4b166a8
|
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,36 @@ 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.
|
5
|
+
## Version 2.12.0
|
6
|
+
### Added
|
7
|
+
* [#1866](https://github.com/Shopify/shopify-cli/pull/1866): Enforce git dependency
|
8
|
+
* [#2009](https://github.com/Shopify/shopify-cli/pull/2009): Add localization support for Checkout Extensions
|
9
|
+
* [#2060](https://github.com/Shopify/shopify-cli/pull/2060): Improve CLI error messages for token-based auth (scripts)
|
10
|
+
* [#2076](https://github.com/Shopify/shopify-cli/pull/2076): Release Wasm Script Projects
|
11
|
+
* [#2051](https://github.com/Shopify/shopify-cli/pull/2051): Update `theme serve` to accept `root` argument
|
12
|
+
* [#2025](https://github.com/Shopify/shopify-cli/pull/2025): Improve `theme pull`/`push` help messages to indicate multiple `--only`/`--ignore` flags are allowed.
|
6
13
|
|
14
|
+
### Fixed
|
15
|
+
* [#2030](https://github.com/Shopify/shopify-cli/pull/2030): Fix Theme::Syncer handling of file deletions in `download_file!`
|
16
|
+
* [#2071](https://github.com/Shopify/shopify-cli/pull/2071): Fix `theme pull` error message when dev theme doesn't exist
|
17
|
+
* [#2066](https://github.com/Shopify/shopify-cli/pull/2066): Improve `--only`/`--ignore` parameters on Theme `pull`/`push` commands to work without quotes
|
18
|
+
* [#2078](https://github.com/Shopify/shopify-cli/pull/2078): Fix errors on section rendering caused by CORS issues
|
19
|
+
|
20
|
+
## Version 2.11.2
|
21
|
+
### Fixed
|
22
|
+
* [#2047](https://github.com/Shopify/shopify-cli/pull/2047): Fix the Homebrew installation
|
23
|
+
* [#2019](https://github.com/Shopify/shopify-cli/pull/2019): Provide helpful link when nokogiri fails to load
|
24
|
+
* [#2055](https://github.com/Shopify/shopify-cli/pull/2055): Remove unneeded Node requirements
|
25
|
+
* [#2020](https://github.com/Shopify/shopify-cli/pull/2020): Fix `theme pull` so that correct dev theme is used with `-d` option
|
26
|
+
|
27
|
+
## Version 2.11.1
|
28
|
+
### Fixed
|
29
|
+
* [#1973](https://github.com/Shopify/shopify-cli/pull/1973): Fix `theme serve` to preview generated files (`*.css.liquid`)
|
30
|
+
* [#2034](https://github.com/Shopify/shopify-cli/pull/2034): Fix `theme serve` to accept parameters with multiple values
|
31
|
+
* [#2033](https://github.com/Shopify/shopify-cli/pull/2033): Pin Homebrew Ruby to 3.0
|
32
|
+
* [#2032](https://github.com/Shopify/shopify-cli/pull/2032): Runtime error checking the Node version if Node is not present in the environment.
|
33
|
+
|
34
|
+
## Version 2.11.0
|
7
35
|
### Fixed
|
8
36
|
* [#2005](https://github.com/Shopify/shopify-cli/pull/2005): Fix PHP app serve on Windows environments
|
9
37
|
|
data/Gemfile.lock
CHANGED
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"]
|
data/docs/users/installation.md
CHANGED
@@ -1,46 +1,3 @@
|
|
1
1
|
# Installation
|
2
2
|
|
3
|
-
|
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
|
@@ -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|
|
@@ -27,6 +26,10 @@ module Extension
|
|
27
26
|
api_secret: options.flags[:api_secret],
|
28
27
|
registration_id: options.flags[:registration_id]
|
29
28
|
)
|
29
|
+
# on ci, registration id must be present
|
30
|
+
registration_id = options.flags[:registration_id]
|
31
|
+
check_registration(registration_id: registration_id, context: @ctx)
|
32
|
+
|
30
33
|
specification_handler = Extension::Loaders::SpecificationHandler.load(project: project, context: @ctx)
|
31
34
|
register_if_necessary(project: project, args: args, name: name)
|
32
35
|
|
@@ -43,6 +46,15 @@ module Extension
|
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
49
|
+
def check_registration(registration_id:, context:)
|
50
|
+
if !ShopifyCLI::Environment.interactive? && (!registration_id || registration_id.empty?)
|
51
|
+
message = context.message("errors.missing_push_options_ci", "--registration-id")
|
52
|
+
message += context.message("errors.missing_push_options_ci_solution", ShopifyCLI::TOOL_NAME)
|
53
|
+
raise ShopifyCLI::Abort,
|
54
|
+
message
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
46
58
|
def self.help
|
47
59
|
ShopifyCLI::Context.new.message("push.help", ShopifyCLI::TOOL_NAME)
|
48
60
|
end
|
@@ -9,20 +9,40 @@ module Extension
|
|
9
9
|
"SHOPIFY_API_SECRET" => api_secret,
|
10
10
|
"EXTENSION_ID" => registration_id,
|
11
11
|
}.compact
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
env_file_present = env_file_exists?(directory)
|
13
|
+
env = if env_file_present
|
14
|
+
ShopifyCLI::Resources::EnvFile.read(directory, overrides: env_overrides)
|
15
|
+
else
|
16
|
+
ShopifyCLI::Resources::EnvFile.from_hash(env_overrides)
|
17
|
+
end
|
18
18
|
# This is a somewhat uncomfortable hack we use because `Project::at` is
|
19
19
|
# a global cache and we can't rely on this class loading the project
|
20
20
|
# first. Long-term we should move away from that global cache.
|
21
21
|
project = ExtensionProject.at(directory)
|
22
22
|
project.env = env
|
23
23
|
project
|
24
|
-
rescue SmartProperties::InitializationError, SmartProperties::MissingValueError
|
25
|
-
|
24
|
+
rescue SmartProperties::InitializationError, SmartProperties::MissingValueError => error
|
25
|
+
handle_error(error, context: context)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.handle_error(error, context:)
|
29
|
+
if ShopifyCLI::Environment.interactive?
|
30
|
+
properties_hash = { api_key: "SHOPIFY_API_KEY", secret: "SHOPIFY_API_SECRET" }
|
31
|
+
missing_env_variables = error.properties.map { |p| properties_hash[p.name] }.compact.join(", ")
|
32
|
+
message = context.message("errors.missing_env_file_variables", missing_env_variables)
|
33
|
+
message += context.message("errors.missing_env_file_variables_solution", ShopifyCLI::TOOL_NAME)
|
34
|
+
else
|
35
|
+
properties_hash = { api_key: "--api-key", secret: "--api-secret" }
|
36
|
+
missing_options = error.properties.map { |p| properties_hash[p.name] }.compact.join(", ")
|
37
|
+
message = context.message("errors.missing_push_options_ci", missing_options)
|
38
|
+
message += context.message("errors.missing_push_options_ci_solution", ShopifyCLI::TOOL_NAME)
|
39
|
+
end
|
40
|
+
raise ShopifyCLI::Abort,
|
41
|
+
message
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.env_file_exists?(directory)
|
45
|
+
File.exist?(ShopifyCLI::Resources::EnvFile.path(directory))
|
26
46
|
end
|
27
47
|
end
|
28
48
|
end
|
@@ -174,9 +174,17 @@ module Extension
|
|
174
174
|
},
|
175
175
|
},
|
176
176
|
errors: {
|
177
|
-
unknown_type: "Unknown extension type %s"
|
177
|
+
unknown_type: "Unknown extension type %s. Valid extension types include: CHECKOUT_POST_PURCHASE, " \
|
178
|
+
"CHECKOUT_UI_EXTENSION, THEME_APP_EXTENSION, and PRODUCT_SUBSCRIPTION.",
|
178
179
|
package_not_found: "`%s` package not found.",
|
179
|
-
|
180
|
+
missing_push_options_ci: "The following are missing: %s. ",
|
181
|
+
missing_push_options_ci_solution: "To add them to a CI environment:\n\t1. Run a connect command " \
|
182
|
+
"({{command:%1$s extension connect}})\n\t2. Navigate to the .env file at the root of your project\n\t" \
|
183
|
+
"3. Copy the missing values and pass them through as arguments in {{command:%1$s extension push}}",
|
184
|
+
missing_env_file_variables: "The following are missing in the .env file: %s. ",
|
185
|
+
missing_env_file_variables_solution: "To add it, connect your extension with " \
|
186
|
+
"{{command:%1$s extension connect}} " \
|
187
|
+
"or run {{command:%1$s extension register}} to register a new extension.",
|
180
188
|
module_not_found: "Unable to find module %s. Ensure your dependencies are up-to-date and try again.",
|
181
189
|
},
|
182
190
|
warnings: {
|
@@ -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}"
|
@@ -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
|
@@ -18,13 +18,13 @@ 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
|
21
|
+
unless !form.name.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:
|
27
|
+
language: options.flags[:language]&.downcase || "wasm",
|
28
28
|
sparse_checkout_branch: options.flags[:branch] || "master",
|
29
29
|
script_name: form.name,
|
30
30
|
extension_point_type: form.extension_point,
|
@@ -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.
|
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
|
-
|
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"
|
@@ -3,12 +3,11 @@
|
|
3
3
|
module Script
|
4
4
|
module Forms
|
5
5
|
class Create < ShopifyCLI::Form
|
6
|
-
flag_arguments :extension_point, :name
|
6
|
+
flag_arguments :extension_point, :name
|
7
7
|
|
8
8
|
def ask
|
9
9
|
self.name = valid_name
|
10
10
|
self.extension_point ||= ask_extension_point
|
11
|
-
self.language = ask_language
|
12
11
|
end
|
13
12
|
|
14
13
|
private
|
@@ -29,18 +28,6 @@ module Script
|
|
29
28
|
return n if n.match?(/^[0-9A-Za-z_-]*$/)
|
30
29
|
raise Errors::InvalidScriptNameError
|
31
30
|
end
|
32
|
-
|
33
|
-
def ask_language
|
34
|
-
return language.downcase if language
|
35
|
-
|
36
|
-
all_languages = Layers::Application::ExtensionPoints.languages(type: extension_point)
|
37
|
-
return all_languages.first if all_languages.count == 1
|
38
|
-
|
39
|
-
CLI::UI::Prompt.ask(
|
40
|
-
ctx.message("script.forms.create.select_language"),
|
41
|
-
options: all_languages
|
42
|
-
)
|
43
|
-
end
|
44
31
|
end
|
45
32
|
end
|
46
33
|
end
|
@@ -55,9 +55,10 @@ module Script
|
|
55
55
|
def handle_error(error, context:)
|
56
56
|
properties_hash = { api_key: "SHOPIFY_API_KEY", secret: "SHOPIFY_API_SECRET" }
|
57
57
|
missing_env_variables = error.properties.map { |p| properties_hash[p.name] }.compact.join(", ")
|
58
|
+
message = context.message("script.error.missing_env_file_variables", missing_env_variables)
|
59
|
+
message += context.message("script.error.missing_env_file_variables_solution", ShopifyCLI::TOOL_NAME)
|
58
60
|
raise ShopifyCLI::Abort,
|
59
|
-
|
60
|
-
ShopifyCLI::TOOL_NAME)
|
61
|
+
message
|
61
62
|
end
|
62
63
|
|
63
64
|
private
|
@@ -47,7 +47,7 @@ module Script
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def install_dependencies(ctx, language, script_name, project_creator)
|
50
|
-
task_runner = Infrastructure::Languages::TaskRunner.for(ctx, language
|
50
|
+
task_runner = Infrastructure::Languages::TaskRunner.for(ctx, language)
|
51
51
|
CLI::UI::Frame.open(ctx.message(
|
52
52
|
"core.git.pulling_from_to",
|
53
53
|
project_creator.sparse_checkout_repo,
|
@@ -10,7 +10,7 @@ module Script
|
|
10
10
|
script_project = script_project_repo.get
|
11
11
|
script_project.env = project.env
|
12
12
|
task_runner = Infrastructure::Languages::TaskRunner
|
13
|
-
.for(ctx, script_project.language
|
13
|
+
.for(ctx, script_project.language)
|
14
14
|
|
15
15
|
extension_point = ExtensionPoints.get(type: script_project.extension_point_type)
|
16
16
|
|
@@ -105,6 +105,17 @@ module Script
|
|
105
105
|
|
106
106
|
class DependencyInstallError < ScriptProjectError; end
|
107
107
|
class EmptyResponseError < ScriptProjectError; end
|
108
|
+
|
109
|
+
class InvalidEnvironmentError < ScriptProjectError
|
110
|
+
attr_reader :tool, :env_version, :minimum_version
|
111
|
+
def initialize(tool, env_version, minimum_version)
|
112
|
+
super()
|
113
|
+
@tool = tool
|
114
|
+
@env_version = env_version
|
115
|
+
@minimum_version = minimum_version
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
108
119
|
class InvalidResponseError < ScriptProjectError; end
|
109
120
|
class ForbiddenError < ScriptProjectError; end
|
110
121
|
class InvalidContextError < ScriptProjectError; end
|
data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb
CHANGED
@@ -5,18 +5,14 @@ module Script
|
|
5
5
|
module Infrastructure
|
6
6
|
module Languages
|
7
7
|
class AssemblyScriptProjectCreator < ProjectCreator
|
8
|
-
MIN_NODE_VERSION = "14.5.0" # kept because task_runner uses this
|
9
|
-
NPM_SET_REGISTRY_COMMAND = "npm --userconfig ./.npmrc config set @shopify:registry https://registry.npmjs.com"
|
10
|
-
NPM_SET_ENGINE_STRICT_COMMAND = "npm --userconfig ./.npmrc config set engine-strict true"
|
11
|
-
|
12
8
|
def self.config_file
|
13
9
|
"package.json"
|
14
10
|
end
|
15
11
|
|
16
12
|
def setup_dependencies
|
13
|
+
task_runner = Infrastructure::Languages::AssemblyScriptTaskRunner.new(ctx)
|
14
|
+
task_runner.set_npm_config
|
17
15
|
super
|
18
|
-
command_runner.call(NPM_SET_REGISTRY_COMMAND)
|
19
|
-
command_runner.call(NPM_SET_ENGINE_STRICT_COMMAND)
|
20
16
|
end
|
21
17
|
end
|
22
18
|
end
|