@@ -157,7 +157,10 @@ fn main() {
157157 Commands :: Serve { port, dir, watch } => {
158158 serve ( port, dir, watch) ;
159159 }
160- Commands :: Bundle { output, no_optimize } => {
160+ Commands :: Bundle {
161+ output,
162+ no_optimize,
163+ } => {
161164 bundle ( output, no_optimize) ;
162165 }
163166 Commands :: New { name } => {
@@ -450,7 +453,14 @@ fn watch_and_rebuild(dir: &PathBuf) {
450453
451454fn rebuild_wasm ( ) {
452455 let status = Command :: new ( "wasm-pack" )
453- . args ( [ "build" , "crates/presentar" , "--target" , "web" , "--out-dir" , "../../www/pkg" ] )
456+ . args ( [
457+ "build" ,
458+ "crates/presentar" ,
459+ "--target" ,
460+ "web" ,
461+ "--out-dir" ,
462+ "../../www/pkg" ,
463+ ] )
454464 . stdout ( std:: process:: Stdio :: null ( ) )
455465 . stderr ( std:: process:: Stdio :: null ( ) )
456466 . status ( ) ;
@@ -466,7 +476,14 @@ fn bundle(output: PathBuf, no_optimize: bool) {
466476
467477 // Build with wasm-pack
468478 let status = Command :: new ( "wasm-pack" )
469- . args ( [ "build" , "crates/presentar" , "--target" , "web" , "--release" , "--out-dir" ] )
479+ . args ( [
480+ "build" ,
481+ "crates/presentar" ,
482+ "--target" ,
483+ "web" ,
484+ "--release" ,
485+ "--out-dir" ,
486+ ] )
470487 . arg ( format ! ( "../../{}" , output. join( "pkg" ) . display( ) ) )
471488 . status ( )
472489 . expect ( "wasm-pack failed" ) ;
@@ -687,7 +704,11 @@ fn analyze_manifest_quality(manifest: &presentar_yaml::Manifest) -> QualityScore
687704 let structural_score = {
688705 let widget_score = ( widget_count. min ( 20 ) as f64 / 20.0 ) * 10.0 ; // Up to 10 points for widgets
689706 let section_score = ( section_count. min ( 5 ) as f64 / 5.0 ) * 8.0 ; // Up to 8 points for sections
690- let layout_score = if manifest. layout . columns > 0 { 7.0 } else { 0.0 } ; // 7 points for grid layout
707+ let layout_score = if manifest. layout . columns > 0 {
708+ 7.0
709+ } else {
710+ 0.0
711+ } ; // 7 points for grid layout
691712 widget_score + section_score + layout_score
692713 } ;
693714
@@ -755,11 +776,10 @@ fn analyze_manifest_quality(manifest: &presentar_yaml::Manifest) -> QualityScore
755776 // Consistency (10 points max)
756777 let consistency_score = {
757778 // Check for consistent naming conventions
758- let ids_consistent = manifest
759- . layout
760- . sections
761- . iter ( )
762- . all ( |s| s. id . chars ( ) . all ( |c| c. is_ascii_lowercase ( ) || c == '-' || c == '_' ) ) ;
779+ let ids_consistent = manifest. layout . sections . iter ( ) . all ( |s| {
780+ s. id . chars ( )
781+ . all ( |c| c. is_ascii_lowercase ( ) || c == '-' || c == '_' )
782+ } ) ;
763783
764784 let widgets_have_types = manifest
765785 . layout
@@ -972,7 +992,10 @@ fn deploy(
972992 if !skip_build {
973993 println ! ( "Step 1: Building production bundle..." ) ;
974994 if dry_run {
975- println ! ( " [dry-run] Would run: presentar bundle --output {}" , source. display( ) ) ;
995+ println ! (
996+ " [dry-run] Would run: presentar bundle --output {}" ,
997+ source. display( )
998+ ) ;
976999 } else {
9771000 bundle ( source. clone ( ) , false ) ;
9781001 }
@@ -981,7 +1004,10 @@ fn deploy(
9811004
9821005 // Verify source directory exists
9831006 if !dry_run && !source. exists ( ) {
984- eprintln ! ( "Error: Source directory '{}' does not exist" , source. display( ) ) ;
1007+ eprintln ! (
1008+ "Error: Source directory '{}' does not exist" ,
1009+ source. display( )
1010+ ) ;
9851011 eprintln ! ( "Run 'presentar bundle' first or use --skip-build with existing files" ) ;
9861012 std:: process:: exit ( 1 ) ;
9871013 }
@@ -1030,8 +1056,12 @@ fn deploy_to_s3(
10301056 println ! ( "Files that would be uploaded:" ) ;
10311057 for ( path, content_type) in & files {
10321058 let rel_path = path. strip_prefix ( source) . unwrap_or ( path) ;
1033- println ! ( " {} ({}, {} bytes)" , rel_path. display( ) , content_type,
1034- fs:: metadata( path) . map( |m| m. len( ) ) . unwrap_or( 0 ) ) ;
1059+ println ! (
1060+ " {} ({}, {} bytes)" ,
1061+ rel_path. display( ) ,
1062+ content_type,
1063+ fs:: metadata( path) . map( |m| m. len( ) ) . unwrap_or( 0 )
1064+ ) ;
10351065 }
10361066 } else {
10371067 // Upload files using AWS CLI
@@ -1094,7 +1124,10 @@ fn deploy_to_s3(
10941124 println ! ( "Dry run complete. No files were uploaded." ) ;
10951125 } else {
10961126 println ! ( "Deployment complete!" ) ;
1097- println ! ( " URL: https://{}.s3.{}.amazonaws.com/index.html" , bucket, region) ;
1127+ println ! (
1128+ " URL: https://{}.s3.{}.amazonaws.com/index.html" ,
1129+ bucket, region
1130+ ) ;
10981131 if distribution. is_some ( ) {
10991132 println ! ( " Note: CloudFront may take a few minutes to propagate" ) ;
11001133 }
@@ -1109,8 +1142,11 @@ fn deploy_to_cloudflare(source: &PathBuf, project: Option<&str>, dry_run: bool)
11091142 println ! ( " Project: {}" , project) ;
11101143
11111144 if dry_run {
1112- println ! ( " [dry-run] Would run: npx wrangler pages deploy {} --project-name {}" ,
1113- source. display( ) , project) ;
1145+ println ! (
1146+ " [dry-run] Would run: npx wrangler pages deploy {} --project-name {}" ,
1147+ source. display( ) ,
1148+ project
1149+ ) ;
11141150 } else {
11151151 let status = Command :: new ( "npx" )
11161152 . args ( [ "wrangler" , "pages" , "deploy" ] )
@@ -1138,7 +1174,10 @@ fn deploy_to_vercel(source: &PathBuf, dry_run: bool) {
11381174 println ! ( "Step 2: Deploying to Vercel..." ) ;
11391175
11401176 if dry_run {
1141- println ! ( " [dry-run] Would run: vercel deploy {} --prod" , source. display( ) ) ;
1177+ println ! (
1178+ " [dry-run] Would run: vercel deploy {} --prod" ,
1179+ source. display( )
1180+ ) ;
11421181 } else {
11431182 let status = Command :: new ( "vercel" )
11441183 . args ( [ "deploy" , "--prod" ] )
@@ -1165,7 +1204,10 @@ fn deploy_to_netlify(source: &PathBuf, dry_run: bool) {
11651204 println ! ( "Step 2: Deploying to Netlify..." ) ;
11661205
11671206 if dry_run {
1168- println ! ( " [dry-run] Would run: netlify deploy --dir {} --prod" , source. display( ) ) ;
1207+ println ! (
1208+ " [dry-run] Would run: netlify deploy --dir {} --prod" ,
1209+ source. display( )
1210+ ) ;
11691211 } else {
11701212 let status = Command :: new ( "netlify" )
11711213 . args ( [ "deploy" , "--prod" ] )
@@ -1200,7 +1242,11 @@ fn deploy_to_local(source: &PathBuf, dest: Option<&str>, dry_run: bool) {
12001242 println ! ( " [dry-run] Would copy {} files" , files. len( ) ) ;
12011243 for ( path, _) in & files {
12021244 let rel_path = path. strip_prefix ( source) . unwrap_or ( path) ;
1203- println ! ( " {} -> {}" , rel_path. display( ) , dest_path. join( rel_path) . display( ) ) ;
1245+ println ! (
1246+ " {} -> {}" ,
1247+ rel_path. display( ) ,
1248+ dest_path. join( rel_path) . display( )
1249+ ) ;
12041250 }
12051251 } else {
12061252 // Use cp -r for simplicity
@@ -1510,23 +1556,41 @@ layout:
15101556 #[ test]
15111557 fn test_get_content_type ( ) {
15121558 assert_eq ! ( get_content_type( & PathBuf :: from( "index.html" ) ) , "text/html" ) ;
1513- assert_eq ! ( get_content_type( & PathBuf :: from( "app.js" ) ) , "application/javascript" ) ;
1514- assert_eq ! ( get_content_type( & PathBuf :: from( "app.wasm" ) ) , "application/wasm" ) ;
1559+ assert_eq ! (
1560+ get_content_type( & PathBuf :: from( "app.js" ) ) ,
1561+ "application/javascript"
1562+ ) ;
1563+ assert_eq ! (
1564+ get_content_type( & PathBuf :: from( "app.wasm" ) ) ,
1565+ "application/wasm"
1566+ ) ;
15151567 assert_eq ! ( get_content_type( & PathBuf :: from( "style.css" ) ) , "text/css" ) ;
1516- assert_eq ! ( get_content_type( & PathBuf :: from( "data.json" ) ) , "application/json" ) ;
1517- assert_eq ! ( get_content_type( & PathBuf :: from( "logo.svg" ) ) , "image/svg+xml" ) ;
1568+ assert_eq ! (
1569+ get_content_type( & PathBuf :: from( "data.json" ) ) ,
1570+ "application/json"
1571+ ) ;
1572+ assert_eq ! (
1573+ get_content_type( & PathBuf :: from( "logo.svg" ) ) ,
1574+ "image/svg+xml"
1575+ ) ;
15181576 assert_eq ! ( get_content_type( & PathBuf :: from( "photo.png" ) ) , "image/png" ) ;
15191577 assert_eq ! ( get_content_type( & PathBuf :: from( "photo.jpg" ) ) , "image/jpeg" ) ;
15201578 assert_eq ! ( get_content_type( & PathBuf :: from( "photo.jpeg" ) ) , "image/jpeg" ) ;
15211579 assert_eq ! ( get_content_type( & PathBuf :: from( "anim.gif" ) ) , "image/gif" ) ;
1522- assert_eq ! ( get_content_type( & PathBuf :: from( "favicon.ico" ) ) , "image/x-icon" ) ;
1580+ assert_eq ! (
1581+ get_content_type( & PathBuf :: from( "favicon.ico" ) ) ,
1582+ "image/x-icon"
1583+ ) ;
15231584 assert_eq ! ( get_content_type( & PathBuf :: from( "font.woff" ) ) , "font/woff" ) ;
15241585 assert_eq ! ( get_content_type( & PathBuf :: from( "font.woff2" ) ) , "font/woff2" ) ;
15251586 assert_eq ! ( get_content_type( & PathBuf :: from( "font.ttf" ) ) , "font/ttf" ) ;
15261587 assert_eq ! ( get_content_type( & PathBuf :: from( "config.yaml" ) ) , "text/yaml" ) ;
15271588 assert_eq ! ( get_content_type( & PathBuf :: from( "config.yml" ) ) , "text/yaml" ) ;
15281589 assert_eq ! ( get_content_type( & PathBuf :: from( "readme.txt" ) ) , "text/plain" ) ;
1529- assert_eq ! ( get_content_type( & PathBuf :: from( "unknown.xyz" ) ) , "application/octet-stream" ) ;
1590+ assert_eq ! (
1591+ get_content_type( & PathBuf :: from( "unknown.xyz" ) ) ,
1592+ "application/octet-stream"
1593+ ) ;
15301594 }
15311595
15321596 #[ test]
@@ -1563,9 +1627,15 @@ layout:
15631627 let files = collect_deploy_files ( & temp_dir) ;
15641628
15651629 assert_eq ! ( files. len( ) , 3 ) ;
1566- assert ! ( files. iter( ) . any( |( p, t) | p. ends_with( "index.html" ) && t == "text/html" ) ) ;
1567- assert ! ( files. iter( ) . any( |( p, t) | p. ends_with( "app.js" ) && t == "application/javascript" ) ) ;
1568- assert ! ( files. iter( ) . any( |( p, t) | p. ends_with( "app.wasm" ) && t == "application/wasm" ) ) ;
1630+ assert ! ( files
1631+ . iter( )
1632+ . any( |( p, t) | p. ends_with( "index.html" ) && t == "text/html" ) ) ;
1633+ assert ! ( files
1634+ . iter( )
1635+ . any( |( p, t) | p. ends_with( "app.js" ) && t == "application/javascript" ) ) ;
1636+ assert ! ( files
1637+ . iter( )
1638+ . any( |( p, t) | p. ends_with( "app.wasm" ) && t == "application/wasm" ) ) ;
15691639
15701640 // Cleanup
15711641 let _ = fs:: remove_dir_all ( & temp_dir) ;
0 commit comments