File tree Expand file tree Collapse file tree 2 files changed +43
-10
lines changed Expand file tree Collapse file tree 2 files changed +43
-10
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import Foundation
2
+
3
+ @main
4
+ struct ArchiveDetective {
5
+ static func main( ) async {
6
+ print ( " Fetching JSON from source... " ) ; fflush ( stdout)
7
+
8
+ let jsonData : [ String : Any ]
9
+ do {
10
+ jsonData = try await JSONFetcher . fetch ( )
11
+ } catch {
12
+ print ( " Failed to fetch JSON: \( error) " ) ; fflush ( stdout)
13
+ return
14
+ }
15
+
16
+ print ( " Extracting GitHub repository links... " ) ; fflush ( stdout)
17
+ let repoLinks = RepoExtractor . extract ( from: jsonData)
18
+ print ( " \( repoLinks. count) repositories to check. " ) ; fflush ( stdout)
19
+
20
+ var results : [ Models . RepoStatus ] = [ ]
21
+ for (i, url) in repoLinks. enumerated ( ) {
22
+ print ( " Checking [ \( i + 1 ) / \( repoLinks. count) ]: \( url) " ) ; fflush ( stdout)
23
+ let status = await RepoStatusChecker . checkStatus ( for: url)
24
+ results. append ( status)
25
+ try ? await Task . sleep ( nanoseconds: 50_000_000 ) // 50ms delay
26
+ }
27
+
28
+ print ( " Updating README... " ) ; fflush ( stdout)
29
+ do {
30
+ try ReadmeUpdater . update ( with: results)
31
+ } catch {
32
+ print ( " Failed to update README: \( error) " ) ; fflush ( stdout)
33
+ }
34
+
35
+ print ( " \n Summary: " ) ; fflush ( stdout)
36
+ let archived = results. filter { $0. status == " Archived " } . count
37
+ let notFound = results. filter { $0. status == " Not Found " } . count
38
+ let forbidden = results. filter { $0. status? . contains ( " Forbidden " ) == true } . count
39
+ print ( " Archived: \( archived) " ) ; fflush ( stdout)
40
+ print ( " Not Found: \( notFound) " ) ; fflush ( stdout)
41
+ print ( " Forbidden: \( forbidden) " ) ; fflush ( stdout)
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments