UNPKG

1.9 kBJavaScriptView Raw
1var https = require("https");
2var fs = require("fs");
3var url = require("url");
4var path = require("path");
5
6var protos = [
7 "https://raw.githubusercontent.com/SteamDatabase/GameTracking-CSGO/master/Protobufs/base_gcmessages.proto",
8 "https://raw.githubusercontent.com/SteamDatabase/GameTracking-CSGO/master/Protobufs/cstrike15_gcmessages.proto",
9 "https://raw.githubusercontent.com/SteamDatabase/GameTracking-CSGO/master/Protobufs/engine_gcmessages.proto",
10 "https://raw.githubusercontent.com/SteamDatabase/GameTracking-CSGO/master/Protobufs/gcsdk_gcmessages.proto",
11 "https://raw.githubusercontent.com/SteamDatabase/GameTracking-CSGO/master/Protobufs/steammessages.proto",
12 "https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/steammessages_clientserver.proto",
13 "https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/steammessages_clientserver_2.proto",
14 "https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/steammessages_base.proto",
15 "https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/encrypted_app_ticket.proto"
16];
17
18function download(downloadUrl) {
19 var fileName = path.basename(url.parse(downloadUrl).pathname);
20
21 console.log("\tDownloading " + fileName);
22 var file = fs.createWriteStream(__dirname + "/protos/" + fileName);
23 var request = https.get(downloadUrl, function(response) {
24 response.pipe(file);
25 });
26}
27
28console.log("Updating protobufs...");
29
30var oldProtos = fs.readdirSync(__dirname + "/protos/");
31oldProtos.forEach(function(fileName) {
32 if (fileName.indexOf(".proto") != -1) {
33 console.log("\tRemoving old protobuf file: " + fileName);
34 fs.unlinkSync(__dirname + "/protos/" + fileName);
35 }
36});
37
38protos.forEach(function(url) {
39 download(url);
40});
41
42console.log("Update complete!");