aboutsummaryrefslogtreecommitdiff
path: root/hooks/update.js
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/update.js')
-rw-r--r--hooks/update.js92
1 files changed, 48 insertions, 44 deletions
diff --git a/hooks/update.js b/hooks/update.js
index 412c733..edfa79c 100644
--- a/hooks/update.js
+++ b/hooks/update.js
@@ -13,57 +13,61 @@ module.exports = async () => {
for (let pkg of list) {
spinner.text = "Fetching package lists... " + Math.round((index / list.length) * 100) + "%";
let dir = pkg.substring(0, 1).replace(/[^a-zA-Z0-9]/gm, "#");
- let pack = (await axios.get("https://twipkg.cdn.minteck.org/" + dir + "/" + pkg + ".json")).data;
-
- let verdata = (await axios.get(pack.version)).data;
- pack.verdata = {
- latest: verdata.commit.short_id,
- publisher: {
- name: verdata.commit.author_name,
- email: verdata.commit.author_email
- },
- date: verdata.commit.created_at
- }
-
- if (typeof pack.pointrelease === "string") {
- pack.verdata.latest = pack.pointrelease;
- }
-
- let signRaw = { error: "404 Not Found" };
try {
- signRaw = (await axios.get(pack.signature.replace("{version}", verdata.commit.id))).data;
- } catch (e) {}
- pack.sign = {
- signed: false,
- verified: false,
- key: null,
- signer: {
- name: null,
- email: null
- }
- }
- if (signRaw.error !== "404 Not Found") {
- pack.sign.signed = true;
- if (signRaw.verification_status === "verified") {
- pack.sign.verified = true;
- } else {
- pack.sign.verified = false;
+ let pack = (await axios.get("https://twipkg.cdn.minteck.org/" + dir + "/" + pkg + ".json")).data;
+
+ let verdata = (await axios.get(pack.version)).data;
+ pack.verdata = {
+ latest: verdata.commit.short_id,
+ publisher: {
+ name: verdata.commit.author_name,
+ email: verdata.commit.author_email
+ },
+ date: verdata.commit.created_at
}
- if (signRaw.gpg_key_user_name) {
- pack.sign.signer.name = signRaw.gpg_key_user_name;
+
+ if (typeof pack.pointrelease === "string") {
+ pack.verdata.latest = pack.pointrelease;
}
- if (signRaw.gpg_key_user_email) {
- pack.sign.signer.email = signRaw.gpg_key_user_email;
+
+ let signRaw = { error: "404 Not Found" };
+ try {
+ signRaw = (await axios.get(pack.signature.replace("{version}", verdata.commit.id))).data;
+ } catch (e) {}
+ pack.sign = {
+ signed: false,
+ verified: false,
+ key: null,
+ signer: {
+ name: null,
+ email: null
+ }
}
- if (signRaw.gpg_key_primary_keyid) {
- pack.sign.key = signRaw.gpg_key_primary_keyid;
+ if (signRaw.error !== "404 Not Found") {
+ pack.sign.signed = true;
+ if (signRaw.verification_status === "verified") {
+ pack.sign.verified = true;
+ } else {
+ pack.sign.verified = false;
+ }
+ if (signRaw.gpg_key_user_name) {
+ pack.sign.signer.name = signRaw.gpg_key_user_name;
+ }
+ if (signRaw.gpg_key_user_email) {
+ pack.sign.signer.email = signRaw.gpg_key_user_email;
+ }
+ if (signRaw.gpg_key_primary_keyid) {
+ pack.sign.key = signRaw.gpg_key_primary_keyid;
+ }
}
- }
- if (!fs.existsSync(home + "/repository/" + dir)) {
- fs.mkdirSync(home + "/repository/" + dir);
+ if (!fs.existsSync(home + "/repository/" + dir)) {
+ fs.mkdirSync(home + "/repository/" + dir);
+ }
+ fs.writeFileSync(home + "/repository/" + dir + "/" + pkg + ".json", JSON.stringify(pack));
+ } catch (e) {
+ console.log("\n" + c.yellow("warn:") + " package '" + pkg + "' is not available on the repository yet");
}
- fs.writeFileSync(home + "/repository/" + dir + "/" + pkg + ".json", JSON.stringify(pack));
index++;
}