1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
<?php
if (!isset($_SERVER['argv'])) die("This script can only be run in a CLI environment.");
// Projects
$secrets = json_decode(file_get_contents("./secrets.json"), true);
$equivalents = [];
$descriptions = [];
$projects = [];
print("GitLab > equestria.dev\n");
$gitea = [];
$page = 1;
$current = json_decode(file_get_contents("https://source.equestria.dev/api/v4/groups/2/projects?page=$page&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true);
array_push($gitea, ...$current);
while (count($current) > 0) {
$page++;
$current = json_decode(file_get_contents("https://source.equestria.dev/api/v4/groups/2/projects?page=$page&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true);
array_push($gitea, ...$current);
}
foreach ($gitea as $project) {
if ($project["visibility"] !== "public") continue;
print(" " . $project["name"] . "\n");
$languages = json_decode(file_get_contents("https://source.equestria.dev/api/v4/projects/$project[id]/languages?private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true);
$readme_dl = json_decode(@file_get_contents("https://source.equestria.dev/api/v4/projects/$project[id]/repository/files/README.md?ref=HEAD&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true);
$commit = json_decode(file_get_contents("https://source.equestria.dev/api/v4/projects/$project[id]/repository/commits?per_page=1&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true)[0];
$stats = json_decode(file_get_contents("https://source.equestria.dev/api/v4/projects/$project[id]?statistics=true&per_page=1&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true)["statistics"];
if (isset($readme_dl) && $readme_dl !== false) {
$readme = base64_decode($readme_dl["content"]);
} else {
$readme = null;
}
$projects[] = [
"id" => md5($project["path_with_namespace"]),
"owner" => $project["namespace"]["path"],
"name" => $project["path"],
"display_name" => $project["name"] ?? $project["path"],
"description" => $project["description"],
"source" => $project["web_url"],
"icon" => $project["avatar_url"] ?? null,
"website" => $project["web_url"],
"size" => $stats["storage_size"],
"language" => array_keys($languages)[0] ?? null,
"languages" => $languages,
"update" => strtotime($project["updated_at"]),
"commit" => isset($commit) ? strtotime($commit["created_at"]) : strtotime($project["updated_at"]),
"archive" => $project["archived"],
"readme" => $readme
];
}
print("GitLab > minteck.org\n");
$minteckorg = [];
$page = 1;
$current = json_decode(file_get_contents("https://source.equestria.dev/api/v4/groups/7/projects?page=$page&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true);
array_push($minteckorg, ...$current);
while (count($current) > 0) {
$page++;
$current = json_decode(file_get_contents("https://source.equestria.dev/api/v4/groups/7/projects?page=$page&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true);
array_push($minteckorg, ...$current);
}
foreach ($minteckorg as $project) {
if ($project["visibility"] !== "public") continue;
print(" " . $project["name"] . "\n");
$languages = json_decode(file_get_contents("https://source.equestria.dev/api/v4/projects/$project[id]/languages?private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true);
$commit = json_decode(file_get_contents("https://source.equestria.dev/api/v4/projects/$project[id]/repository/commits?per_page=1&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true)[0];
$stats = json_decode(file_get_contents("https://source.equestria.dev/api/v4/projects/$project[id]?statistics=true&per_page=1&private_token=" . $secrets["gitlab"], false, stream_context_create(["ssl"=>["verify_peer"=>false,"verify_peer_name"=>false]])), true)["statistics"];
$projects[] = [
"archive" => true,
"id" => md5($project["path_with_namespace"]),
"owner" => $project["namespace"]["path"],
"name" => $project["path"],
"display_name" => $project["name"] ?? $project["path"],
"description" => $project["description"],
"source" => $project["web_url"],
"icon" => $project["avatar_url"] ?? null,
"website" => $project["web_url"],
"size" => $stats["storage_size"],
"language" => array_keys($languages)[0] ?? null,
"languages" => $languages,
"update" => strtotime($project["updated_at"]),
"commit" => isset($commit) ? strtotime($commit["created_at"]) : strtotime($project["updated_at"])
];
}
/*print("GitHub > CloudburstSys\n");
$cloudburst = json_decode(file_get_contents("https://api.github.com/users/CloudburstSys/repos?per_page=100", false, stream_context_create([
"http" => [
"header" => "User-Agent: Mozilla/5.0 (+equestria.dev-horses/1.0) PHP/" . PHP_VERSION . "\r\nAuthorization: Bearer " . $secrets["github"] . "\r\n"
]
])), true);
foreach ($cloudburst as $project) {
print(" " . $project["name"] . "\n");
$languages = json_decode(file_get_contents("https://api.github.com/repos/CloudburstSys/$project[name]/languages", false, stream_context_create([
"http" => [
"header" => "User-Agent: Mozilla/5.0 (+equestria.dev-horses/1.0) PHP/" . PHP_VERSION . "\r\nAuthorization: Bearer " . $secrets["github"] . "\r\n"
]
])), true);
$commit = json_decode(file_get_contents("https://api.github.com/repos/CloudburstSys/$project[name]/commits?per_page=1", false, stream_context_create([
"http" => [
"header" => "User-Agent: Mozilla/5.0 (+equestria.dev-horses/1.0) PHP/" . PHP_VERSION . "\r\nAuthorization: Bearer " . $secrets["github"] . "\r\n"
]
])), true)[0];
if (!$project["fork"]) {
$projects[] = [
"archive" => true,
"id" => md5("conep.one/" . $project["id"]),
"owner" => "conep.one",
"name" => $project["name"],
"display_name" => $equivalents[$project["name"]] ?? $project["name"],
"description" => $descriptions[$project["name"]] ?? $project["description"],
"source" => $project["html_url"],
"icon" => null,
"website" => trim($project["homepage"] ?? "") === "" ? $project["html_url"] : $project["homepage"],
"size" => $project["size"],
"language" => $project["language"],
"languages" => $languages,
"update" => strtotime($project["updated_at"]),
"commit" => isset($commit) ? strtotime($commit["commit"]["author"]["date"]) : strtotime($project["updated_at"])
];
}
}*/
file_put_contents("./data/projects.json", json_encode($projects, JSON_PRETTY_PRINT));
// Icons
echo("Icons!\n");
foreach ($projects as $project) {
if (isset($project["icon"])) {
echo($project["name"] . "\n");
file_put_contents("../assets/projects/" . $project["id"] . ".png", file_get_contents($project["icon"]));
}
}
|