@@ -29,8 +29,51 @@ function getIncompleteItems(collection = {}) {
2929 } ) ) ;
3030}
3131
32+ function printVerboseSection ( label , collection = { } ) {
33+ const entries = Object . entries ( collection ) ;
34+ if ( entries . length === 0 ) {
35+ console . log ( `\n=== ${ label } (0 entries) ===` ) ;
36+ return ;
37+ }
38+
39+ console . log ( `\n=== ${ label } (${ entries . length } entries) ===` ) ;
40+
41+ // Sort by most-recently updated first for readability
42+ const sorted = entries . sort ( ( [ , a ] , [ , b ] ) => {
43+ const aTime = a ?. lastUpdated || a ?. firstAttempt || "" ;
44+ const bTime = b ?. lastUpdated || b ?. firstAttempt || "" ;
45+ return bTime . localeCompare ( aTime ) ;
46+ } ) ;
47+
48+ for ( const [ itemId , itemStatus ] of sorted ) {
49+ const platforms = itemStatus ?. platforms || { } ;
50+ const platformNames = Object . keys ( platforms ) . sort ( ) ;
51+ const allSuccess = platformNames . length > 0 && platformNames . every ( ( p ) => platforms [ p ] ?. success ) ;
52+ const statusIcon = allSuccess ? "✅" : "⚠️ " ;
53+ console . log ( `\n ${ statusIcon } ${ itemId } ` ) ;
54+ console . log ( ` firstAttempt : ${ itemStatus ?. firstAttempt || "(none)" } ` ) ;
55+ console . log ( ` lastUpdated : ${ itemStatus ?. lastUpdated || "(none)" } ` ) ;
56+ if ( platformNames . length === 0 ) {
57+ console . log ( ` platforms : (none)` ) ;
58+ } else {
59+ for ( const platform of platformNames ) {
60+ const p = platforms [ platform ] ;
61+ const icon = p ?. success ? "✅" : "❌" ;
62+ const flags = [
63+ p ?. seeded ? "seeded" : null ,
64+ p ?. markedManually ? "markedManually" : null ,
65+ ] . filter ( Boolean ) . join ( ", " ) ;
66+ const flagStr = flags ? ` [${ flags } ]` : "" ;
67+ const errStr = p ?. error ? ` -- ERROR: ${ p . error } ` : "" ;
68+ console . log ( ` ${ icon } ${ platform . padEnd ( 10 ) } @ ${ p ?. timestamp || "(no timestamp)" } ${ flagStr } ${ errStr } ` ) ;
69+ }
70+ }
71+ }
72+ }
73+
3274async function main ( ) {
33- const samplePostId = process . argv [ 2 ] || DEFAULT_SAMPLE_POST_ID ;
75+ const verbose = process . argv . includes ( "--verbose" ) || process . argv . includes ( "-v" ) ;
76+ const samplePostId = process . argv . find ( ( a ) => a . startsWith ( "--sample=" ) ) ?. slice ( 9 ) || DEFAULT_SAMPLE_POST_ID ;
3477
3578 try {
3679 const content = await fs . readFile ( CACHE_FILE , "utf8" ) ;
@@ -69,6 +112,18 @@ async function main() {
69112 } else {
70113 console . log ( `sample_post_missing=${ samplePostId } ` ) ;
71114 }
115+
116+ if ( verbose ) {
117+ console . log ( "\n========================================" ) ;
118+ console . log ( "VERBOSE CACHE DUMP" ) ;
119+ console . log ( "========================================" ) ;
120+ console . log ( `initialized : ${ cache . initialized || "(unknown)" } ` ) ;
121+ printVerboseSection ( "POSTS" , cache . posts ) ;
122+ printVerboseSection ( "LINKS" , cache . links ) ;
123+ console . log ( "\n========================================" ) ;
124+ console . log ( "END VERBOSE CACHE DUMP" ) ;
125+ console . log ( "========================================" ) ;
126+ }
72127 } catch ( error ) {
73128 console . log ( `cache_file_missing=${ CACHE_FILE } ` ) ;
74129 console . log ( `cache_error=${ error . message } ` ) ;
0 commit comments