Skip to content

Commit 841f761

Browse files
authored
chore: file rename & working code
1 parent 99ccf40 commit 841f761

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

Sources/ArchiveDetective/0main.swift

Lines changed: 0 additions & 10 deletions
This file was deleted.

Sources/ArchiveDetective/app.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
}

0 commit comments

Comments
 (0)