fix: do not include incompatible files in workspace packages

Fixes `default.project.json` being copied if it
is present in a workspace package.
This commit is contained in:
daimond113 2025-01-30 23:45:31 +01:00
parent 3e4ef00f4a
commit 4009313281
No known key found for this signature in database
GPG key ID: 640DC95EC1190354
5 changed files with 29 additions and 18 deletions

View file

@ -19,7 +19,7 @@ use pesde::{
pesde::{DocEntry, DocEntryKind, IndexFileEntry, ScopeInfo, SCOPE_INFO_FILE}, pesde::{DocEntry, DocEntryKind, IndexFileEntry, ScopeInfo, SCOPE_INFO_FILE},
specifiers::DependencySpecifiers, specifiers::DependencySpecifiers,
traits::RefreshOptions, traits::RefreshOptions,
IGNORED_DIRS, IGNORED_FILES, ADDITIONAL_FORBIDDEN_FILES, IGNORED_DIRS, IGNORED_FILES,
}, },
MANIFEST_FILE_NAME, MANIFEST_FILE_NAME,
}; };
@ -35,8 +35,6 @@ use tokio::{
task::JoinSet, task::JoinSet,
}; };
const ADDITIONAL_FORBIDDEN_FILES: &[&str] = &["default.project.json"];
#[derive(Debug, Deserialize, Default)] #[derive(Debug, Deserialize, Default)]
struct DocEntryInfo { struct DocEntryInfo {
#[serde(default)] #[serde(default)]

View file

@ -20,7 +20,7 @@ use pesde::{
specifier::{VersionType, VersionTypeOrReq}, specifier::{VersionType, VersionTypeOrReq},
WorkspacePackageSource, WorkspacePackageSource,
}, },
PackageSources, IGNORED_DIRS, IGNORED_FILES, PackageSources, ADDITIONAL_FORBIDDEN_FILES, IGNORED_DIRS, IGNORED_FILES,
}, },
Project, RefreshedSources, DEFAULT_INDEX_NAME, MANIFEST_FILE_NAME, Project, RefreshedSources, DEFAULT_INDEX_NAME, MANIFEST_FILE_NAME,
}; };
@ -239,15 +239,24 @@ impl PublishCommand {
} }
for path in &paths { for path in &paths {
if path let Some(file_name) = path.file_name() else {
.file_name() continue;
.is_some_and(|n| n == "default.project.json") };
{
anyhow::bail!( if ADDITIONAL_FORBIDDEN_FILES.contains(&file_name.to_string_lossy().as_ref()) {
"default.project.json was included at `{}`, this should be generated by the {} script upon dependants installation", if file_name == "default.project.json" {
path.display(), anyhow::bail!(
ScriptName::RobloxSyncConfigGenerator "default.project.json was included at `{}`, this should be generated by the {} script upon dependants installation",
); path.display(),
ScriptName::RobloxSyncConfigGenerator
);
} else {
anyhow::bail!(
"forbidden file {} was included at `{}`",
file_name.to_string_lossy(),
path.display()
);
}
} }
} }

View file

@ -1,6 +1,6 @@
use crate::{ use crate::{
manifest::target::TargetKind, manifest::target::TargetKind,
source::{IGNORED_DIRS, IGNORED_FILES}, source::{ADDITIONAL_FORBIDDEN_FILES, IGNORED_DIRS, IGNORED_FILES},
}; };
use fs_err::tokio as fs; use fs_err::tokio as fs;
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
@ -209,7 +209,7 @@ async fn package_fs_copy(
continue; continue;
} }
if IGNORED_FILES.contains(&file_name) { if IGNORED_FILES.contains(&file_name) || ADDITIONAL_FORBIDDEN_FILES.contains(&file_name) {
continue; continue;
} }

View file

@ -9,7 +9,8 @@ use crate::{
git_index::{read_file, GitBasedSource}, git_index::{read_file, GitBasedSource},
specifiers::DependencySpecifiers, specifiers::DependencySpecifiers,
traits::{DownloadOptions, GetTargetOptions, PackageRef, RefreshOptions, ResolveOptions}, traits::{DownloadOptions, GetTargetOptions, PackageRef, RefreshOptions, ResolveOptions},
PackageSource, ResolveResult, VersionId, IGNORED_DIRS, IGNORED_FILES, PackageSource, ResolveResult, VersionId, ADDITIONAL_FORBIDDEN_FILES, IGNORED_DIRS,
IGNORED_FILES,
}, },
util::hash, util::hash,
Project, DEFAULT_INDEX_NAME, LOCKFILE_FILE_NAME, MANIFEST_FILE_NAME, Project, DEFAULT_INDEX_NAME, LOCKFILE_FILE_NAME, MANIFEST_FILE_NAME,
@ -447,9 +448,9 @@ impl PackageSource for GitPackageSource {
return false; return false;
} }
if pkg_ref.use_new_structure() && name == "default.project.json" { if pkg_ref.use_new_structure() && ADDITIONAL_FORBIDDEN_FILES.contains(&name) {
tracing::debug!( tracing::debug!(
"removing default.project.json from {}#{} at {path} - using new structure", "removing {name} from {}#{} at {path} - using new structure",
pkg_ref.repo, pkg_ref.repo,
pkg_ref.tree_id pkg_ref.tree_id
); );

View file

@ -36,6 +36,9 @@ pub mod workspace;
/// Files that will not be stored when downloading a package. These are only files which break pesde's functionality, or are meaningless and possibly heavy (e.g. `.DS_Store`) /// Files that will not be stored when downloading a package. These are only files which break pesde's functionality, or are meaningless and possibly heavy (e.g. `.DS_Store`)
pub const IGNORED_FILES: &[&str] = &["foreman.toml", "aftman.toml", "rokit.toml", ".DS_Store"]; pub const IGNORED_FILES: &[&str] = &["foreman.toml", "aftman.toml", "rokit.toml", ".DS_Store"];
/// Files that should be ignored in some contexts, usually only pesde packages
pub const ADDITIONAL_FORBIDDEN_FILES: &[&str] = &["default.project.json"];
/// Directories that will not be stored when downloading a package. These are only directories which break pesde's functionality, or are meaningless and possibly heavy /// Directories that will not be stored when downloading a package. These are only directories which break pesde's functionality, or are meaningless and possibly heavy
pub const IGNORED_DIRS: &[&str] = &[".git"]; pub const IGNORED_DIRS: &[&str] = &[".git"];