diff options
Diffstat (limited to 'crates/shirabe/src/repository')
7 files changed, 55 insertions, 31 deletions
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 9e5e48c..591497d 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -4,10 +4,9 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::metadata_minifier::MetadataMinifier; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ - Countable, InvalidArgumentException, JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE, - LogicException, PHP_EOL, PhpMixed, RuntimeException, UnexpectedValueException, - extension_loaded, hash, http_build_query, in_array, json_decode, parse_url_all, realpath, - strtolower, strtr, urlencode, var_export, + Countable, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, + UnexpectedValueException, extension_loaded, hash, http_build_query, in_array, json_decode, + parse_url_all, realpath, strtolower, strtr, urlencode, var_export, }; use shirabe_semver::compiling_matcher::CompilingMatcher; @@ -22,6 +21,7 @@ use crate::downloader::TransportException; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::package::BasePackageHandle; use crate::package::PackageInterface; @@ -2976,7 +2976,10 @@ impl ComposerRepository { .map(|(k, v)| (k.clone(), Box::new(v.clone()))) .collect(), ); - json = JsonFile::encode(&as_mixed, 0); + json = JsonFile::encode_with_options( + &as_mixed, + JsonEncodeOptions::none(), + ); } } self.cache.write(ck, &json); @@ -3168,7 +3171,7 @@ impl ComposerRepository { .map(|(k, v)| (k.clone(), Box::new(v.clone()))) .collect(), ); - json = JsonFile::encode(&as_mixed, 0); + json = JsonFile::encode_with_options(&as_mixed, JsonEncodeOptions::none()); } if !self.cache.is_read_only() { self.cache.write(cache_key, &json); @@ -3346,7 +3349,13 @@ impl ComposerRepository { .map(|(k, v)| (k.clone(), Box::new(v.clone()))) .collect(), ); - json = JsonFile::encode(&as_mixed, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + json = JsonFile::encode_with_options( + &as_mixed, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, + ); } if !self.cache.is_read_only() { self.cache.write(cache_key, &json); diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index d5c4a89..ca7e9dd 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -13,6 +13,7 @@ use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; use crate::repository::vcs::VcsDriverBase; @@ -341,17 +342,17 @@ impl ForgejoDriver { )?; if self.inner.should_cache(identifier) { if let Some(ref composer_map) = c { - // TODO(phase-b): JsonFile::encode_with_options does not exist; use encode - let encoded = JsonFile::encode( + let encoded = JsonFile::encode_with_options( &PhpMixed::Array( composer_map .iter() .map(|(k, v)| (k.clone(), Box::new(v.clone()))) .collect(), ), - (shirabe_php_shim::JSON_UNESCAPED_UNICODE - | shirabe_php_shim::JSON_UNESCAPED_SLASHES) - as i64, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, ); self.inner .cache diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 8a0dffd..85288bd 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -16,6 +16,7 @@ use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; use crate::repository::vcs::VcsDriverBase; @@ -264,7 +265,7 @@ impl GitBitbucketDriver { if self.inner.should_cache(identifier) { self.inner.cache.as_mut().unwrap().write( identifier, - &JsonFile::encode_with_indent( + &JsonFile::encode_with_options( &PhpMixed::Array( composer .clone() @@ -273,9 +274,10 @@ impl GitBitbucketDriver { .map(|(k, v)| (k, Box::new(v))) .collect(), ), - shirabe_php_shim::JSON_UNESCAPED_UNICODE - | shirabe_php_shim::JSON_UNESCAPED_SLASHES, - JsonFile::INDENT_DEFAULT, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, ), )?; } diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index 0b9066b..076f4a0 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -16,6 +16,7 @@ use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; use crate::repository::vcs::VcsDriverBase; @@ -278,10 +279,12 @@ impl GitHubDriver { self.inner.cache.as_mut().map(|c| { c.write( identifier, - &JsonFile::encode( + &JsonFile::encode_with_options( &php_value, - shirabe_php_shim::JSON_UNESCAPED_UNICODE - | shirabe_php_shim::JSON_UNESCAPED_SLASHES, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, ), ) }); diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index e8701bf..6f2c4e9 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -16,6 +16,7 @@ use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; use crate::repository::vcs::VcsDriverBase; @@ -276,7 +277,7 @@ impl GitLabDriver { self.inner.cache.as_mut().map(|c| { c.write( identifier, - &JsonFile::encode( + &JsonFile::encode_with_options( &PhpMixed::Array( composer_map .clone() @@ -284,8 +285,10 @@ impl GitLabDriver { .map(|(k, v)| (k, Box::new(v))) .collect(), ), - shirabe_php_shim::JSON_UNESCAPED_UNICODE - | shirabe_php_shim::JSON_UNESCAPED_SLASHES, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, ), ) }); diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 23ea703..fc5abb9 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -5,14 +5,15 @@ use chrono::{DateTime, TimeZone, Utc}; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ - JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE, PhpMixed, RuntimeException, array_key_exists, - is_array, max, sprintf, stripos, strrpos, strtr, substr, trim, + PhpMixed, RuntimeException, array_key_exists, is_array, max, sprintf, stripos, strrpos, strtr, + substr, trim, }; use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::VcsDriverBase; use crate::util::Filesystem; @@ -203,12 +204,15 @@ impl SvnDriver { }; if self.should_cache(identifier) { - let encoded = JsonFile::encode( + let encoded = JsonFile::encode_with_options( &composer .clone() .map(PhpMixed::from) .unwrap_or(PhpMixed::Null), - JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, ); self.inner .cache diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs index 15dd722..8c3b571 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs @@ -3,14 +3,13 @@ use chrono::{DateTime, Utc}; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - JSON_UNESCAPED_SLASHES, JSON_UNESCAPED_UNICODE, PhpMixed, extension_loaded, -}; +use shirabe_php_shim::{PhpMixed, extension_loaded}; use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; +use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::VcsDriverInterface; use crate::util::Filesystem; @@ -188,9 +187,12 @@ pub trait VcsDriver: VcsDriverInterface { .map(|(k, v)| (k.clone(), Box::new(v.clone()))) .collect(), ); - let encoded = JsonFile::encode( + let encoded = JsonFile::encode_with_options( &composer_mixed, - JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, + JsonEncodeOptions { + pretty_print: false, + ..Default::default() + }, ); self.cache_mut().map(|c| c.write(identifier, &encoded)); } |
