MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / package_size

Function package_size

xtask/src/main.rs:566–613  ·  view source on GitHub ↗
(args: Vec<String>)

Source from the content-addressed store, hash-verified

564}
565
566fn package_size(args: Vec<String>) -> Result<()> {
567 let enforce = args.iter().any(|arg| arg == "--enforce");
568 let package_dir = Path::new("target/package");
569 if !package_dir.exists() {
570 fs::create_dir_all(package_dir)
571 .with_context(|| format!("create {}", package_dir.display()))?;
572 } else {
573 fs::remove_dir_all(package_dir)
574 .with_context(|| format!("remove {}", package_dir.display()))?;
575 }
576 run(
577 "cargo",
578 &[
579 "package",
580 "--workspace",
581 "--exclude",
582 "xtask",
583 "--locked",
584 "--no-verify",
585 "--allow-dirty",
586 ],
587 )?;
588
589 let limit = 10 * 1024 * 1024;
590 let mut failures = Vec::new();
591 for entry in WalkDir::new(package_dir).max_depth(1) {
592 let entry = entry?;
593 let path = entry.path();
594 if path.extension().and_then(|ext| ext.to_str()) != Some("crate") {
595 continue;
596 }
597 let size = entry.metadata()?.len();
598 println!("{} {} bytes", path.display(), size);
599 if size > limit {
600 failures.push((path.to_path_buf(), size));
601 }
602 }
603
604 if enforce && !failures.is_empty() {
605 let details = failures
606 .iter()
607 .map(|(path, size)| format!("{} ({size} bytes)", path.display()))
608 .collect::<Vec<_>>()
609 .join(", ");
610 bail!("crate package size limit exceeded: {details}");
611 }
612 Ok(())
613}
614
615fn download_assets(args: &[String]) -> Result<()> {
616 let targets = asset_download_targets(args)?;

Callers 2

mainFunction · 0.85
release_build_assetsFunction · 0.85

Calls 8

iterMethod · 0.80
lenMethod · 0.80
pushMethod · 0.80
runFunction · 0.70
pathMethod · 0.45
extensionMethod · 0.45
metadataMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected