aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-22 23:40:47 +0900
committernsfisis <nsfisis@gmail.com>2026-06-22 23:40:47 +0900
commit99ef82a9807578c1e5749156a027949efaba75c4 (patch)
treee5f6bfb4c74c1ced20a9bc1c884f811f582e38eb /crates/shirabe/src/repository
parentffd3e239a56172d2a336fb4d6253c01f6b1a0100 (diff)
downloadphp-shirabe-99ef82a9807578c1e5749156a027949efaba75c4.tar.gz
php-shirabe-99ef82a9807578c1e5749156a027949efaba75c4.tar.zst
php-shirabe-99ef82a9807578c1e5749156a027949efaba75c4.zip
feat(json): resolve bundled Composer schema files via build.rs
JsonFile's schema paths previously relied on php_dir() (__DIR__), which has no runtime equivalent. Add a build.rs that copies composer-schema.json and composer-lock-schema.json next to the built executable, and resolve them with std::env::current_exe(). FilesystemRepository now embeds InstalledVersions.php directly via include_str! instead of reading it through php_dir(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository')
-rw-r--r--crates/shirabe/src/repository/filesystem_repository.rs32
1 files changed, 13 insertions, 19 deletions
diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs
index 86887d1..2f74eaf 100644
--- a/crates/shirabe/src/repository/filesystem_repository.rs
+++ b/crates/shirabe/src/repository/filesystem_repository.rs
@@ -9,8 +9,8 @@ use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
Exception, InvalidArgumentException, LogicException, PhpMixed, SORT_NATURAL,
UnexpectedValueException, array_flip, dirname, r#eval, file_get_contents, get_class,
- get_class_err, get_debug_type, in_array, is_array, is_null, is_string, ksort, php_dir,
- realpath, sort, sort_with_flags, str_repeat, strtr, trim, usort, var_export,
+ get_class_err, get_debug_type, in_array, is_array, is_null, is_string, ksort, realpath, sort,
+ sort_with_flags, str_repeat, strtr, trim, usort, var_export,
};
use crate::config::is_php_integer_key;
@@ -329,25 +329,19 @@ impl FilesystemRepository {
&format!("{}/installed.php", repo_dir),
&format!("<?php return {};\n", self.dump_to_php_code(&versions, 0),),
);
- let installed_versions_class =
- file_get_contents(&format!("{}/../InstalledVersions.php", php_dir(),));
-
- // this normally should not happen but during upgrades of Composer when it is installed in the project it is a possibility
- if let Some(class_content) = installed_versions_class {
- self.filesystem.borrow_mut().file_put_contents_if_modified(
- &format!("{}/InstalledVersions.php", repo_dir),
- &class_content,
- );
+ self.filesystem.borrow_mut().file_put_contents_if_modified(
+ &format!("{}/InstalledVersions.php", repo_dir),
+ include_str!("../../../../composer/src/Composer/InstalledVersions.php"),
+ );
- // make sure the in memory state is up to date with on disk
- InstalledVersions::reload(versions);
+ // make sure the in memory state is up to date with on disk
+ InstalledVersions::reload(versions);
- // make sure the selfDir matches the expected data at runtime if the class was loaded from the vendor dir, as it may have been
- // loaded from the Composer sources, causing packages to appear twice in that case if the installed.php is loaded in addition to the
- // in memory loaded data from above
- InstalledVersions::set_self_dir(repo_dir.replace('\\', "/"));
- InstalledVersions::set_installed_is_local_dir(true);
- }
+ // make sure the selfDir matches the expected data at runtime if the class was loaded from the vendor dir, as it may have been
+ // loaded from the Composer sources, causing packages to appear twice in that case if the installed.php is loaded in addition to the
+ // in memory loaded data from above
+ InstalledVersions::set_self_dir(repo_dir.replace('\\', "/"));
+ InstalledVersions::set_installed_is_local_dir(true);
}
Ok(())