1
0
Fork 0

Merge branch 'master' of gitlab.libraryofcode.org:engineering/cloudservices

refactor/models
Matthew 2020-08-08 19:23:05 -04:00
commit 35055412a9
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
6 changed files with 87 additions and 85 deletions

View File

@ -12,7 +12,6 @@
"license": "AGPL-3.0-only",
"private": false,
"dependencies": {
"@ghaiklor/x509": "^1.0.0",
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"eris": "bsian03/eris#dev",
@ -22,12 +21,13 @@
"helmet": "^3.21.2",
"ioredis": "^4.14.1",
"jsonwebtoken": "^8.5.1",
"moment": "^2.24.0",
"moment": "^2.27.0",
"moment-precise-range-plugin": "^1.3.0",
"mongoose": "^5.7.4",
"nodemailer": "^6.3.1",
"signale": "^1.4.0",
"uuid": "^3.3.3"
"uuid": "^3.3.3",
"x509": "bsian03/node-x509"
},
"devDependencies": {
"@types/express": "^4.17.6",

View File

@ -59,8 +59,11 @@ export default class Client extends Eris.Client {
}
public async errorEvents() {
process.on('unhandledRejection', (error) => {
this.signale.error(error);
process.on('unhandledRejection', (error: Error) => {
this.util.handleError(error);
});
this.on('error', (error) => {
this.util.handleError(error);
});
}

View File

@ -1,6 +1,6 @@
import fs from 'fs';
import moment from 'moment';
import x509 from '@ghaiklor/x509';
import x509 from 'x509';
import { createPaginationEmbed } from 'eris-pagination';
import { Message } from 'eris';
import { Client, Command, RichEmbed } from '../class';

View File

@ -22,23 +22,23 @@ export default class Pull extends Command {
try {
pull = await this.client.util.exec('git pull', { cwd: '/opt/CloudServices' });
} catch (error) {
const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Could not fetch latest commit***\n`
const updatedMessage = updateMessage.content.replace(`***${this.client.stores.emojis.loading} Fetching latest commit...***`, `***${this.client.stores.emojis.error} Could not fetch latest commit***\n`
+ `\`\`\`\n${error.message}\n\`\`\``);
this.client.updating = false;
return updateMessage.edit(updatedMessage);
}
if (pull.includes('Already up to date') && args[0] !== '-f') {
const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.success} ***No updates available***`);
const updatedMessage = updateMessage.content.replace(`***${this.client.stores.emojis.loading} Fetching latest commit...***`, `***${this.client.stores.emojis.success} No updates available***`);
this.client.updating = false;
return updateMessage.edit(updatedMessage);
}
if (!pull.includes('origin/master') && !pull.includes(' changed, ')) {
const updatedMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.error} ***Unexpected git output***`);
const updatedMessage = updateMessage.content.replace(`***${this.client.stores.emojis.loading} Fetching latest commit...***`, `***${this.client.stores.emojis.error} Unexpected git output***`);
this.client.updating = false;
return updateMessage.edit(updatedMessage);
}
const continueMessage = updateMessage.content.replace(`${this.client.stores.emojis.loading} ***Fetching latest commit...***`, `${this.client.stores.emojis.success} ***${pull.includes('Already up to date') ? 'No updates available' : 'Fetched latest commit'}***\n`
+ `${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`);
const continueMessage = updateMessage.content.replace(`***${this.client.stores.emojis.loading} Fetching latest commit...***`, `***${this.client.stores.emojis.success} ${pull.includes('Already up to date') ? 'No updates available' : 'Fetched latest commit'}***\n`
+ `***${this.client.stores.emojis.loading} Reinstalling dependencies...***`);
const passedPull = await updateMessage.edit(continueMessage);
@ -47,16 +47,16 @@ export default class Pull extends Command {
install = await this.client.util.exec('yarn install', { cwd: '/opt/CloudServices' });
} catch (error) {
this.client.updating = false;
const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.error} ***Failed to reinstall dependencies***\n`
const updatedMessage = passedPull.content.replace(`***${this.client.stores.emojis.loading} Reinstalling dependencies...***`, `***${this.client.stores.emojis.error} Failed to reinstall dependencies***\n`
+ `\`\`\`\n${error.message}\n\`\`\``);
return updateMessage.edit(updatedMessage);
}
let updatedPackages: Message;
if (install.includes('Already up-to-date')) {
const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.success} ***No dependency updates available***\n${this.client.stores.emojis.loading} ***Rebuilding files...***`);
const updatedMessage = passedPull.content.replace(`***${this.client.stores.emojis.loading} Reinstalling dependencies...***`, `***${this.client.stores.emojis.success} No dependency updates available***\n***${this.client.stores.emojis.loading} Rebuilding files...***`);
updatedPackages = await updateMessage.edit(updatedMessage);
} else {
const updatedMessage = passedPull.content.replace(`${this.client.stores.emojis.loading} ***Reinstalling dependencies...***`, `${this.client.stores.emojis.success} ***Updated dependencies***\n${this.client.stores.emojis.loading} ***Rebuilding files...***`);
const updatedMessage = passedPull.content.replace(`***${this.client.stores.emojis.loading} Reinstalling dependencies...***`, `***${this.client.stores.emojis.success} Updated dependencies***\n***${this.client.stores.emojis.loading} Rebuilding files...***`);
updatedPackages = await updateMessage.edit(updatedMessage);
}
@ -64,7 +64,7 @@ export default class Pull extends Command {
try {
build = await this.client.util.exec('yarn run build', { cwd: '/opt/CloudServices' });
} catch (error) {
let updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***\n`);
let updatedMessage = updatedPackages.content.replace(`***${this.client.stores.emojis.loading} Rebuilding files...***`, `***${this.client.stores.emojis.error} Failed to rebuild files***\n`);
if (error.message.length < 1800) updatedMessage += `\`\`\`\n${error.message}\n\`\`\``;
else {
const split = this.client.util.splitString(error.message, 1975);
@ -83,7 +83,7 @@ export default class Pull extends Command {
this.client.updating = false;
return updateMessage.edit(updatedMessage);
}
const finalMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.success} ***Files rebuilt***`);
const finalMessage = updatedPackages.content.replace(`***${this.client.stores.emojis.loading} Rebuilding files...***`, `***${this.client.stores.emojis.success} Files rebuilt***`);
this.client.updating = false;
this.client.buildError = false;
return updateMessage.edit(finalMessage);

2
types/x509.d.ts vendored
View File

@ -1,4 +1,4 @@
declare module '@ghaiklor/x509' {
declare module 'x509' {
namespace Certificate {
interface Issuer {
countryName: string,

View File

@ -28,13 +28,6 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.10.3.tgz#7e71d892b0d6e7d04a1af4c3c79d72c1f10f5315"
integrity sha512-oJtNJCMFdIMwXGmx+KxuaD7i3b8uS7TTFYW/FNG2BT8m+fmGHoiPYoH0Pe3gya07WuFmM5FCDIr1x0irkD/hyA==
"@ghaiklor/x509@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@ghaiklor/x509/-/x509-1.0.0.tgz#d35a9136d13827ddf29a30bcfd9e7fa2f54cda9b"
integrity sha512-IZYf5TrQ/nNxNnvEr5U+XpRXIyNbzek6ZcVIiT8oX9+fUIkuL2qtbodEgva7vUjUhj02a1KkKQwYddgayJnh3g==
dependencies:
nan "2.14.0"
"@types/body-parser@*":
version "1.19.0"
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.0.tgz#0685b3c47eb3006ffed117cdd55164b61f80538f"
@ -1896,10 +1889,10 @@ moment-precise-range-plugin@^1.3.0:
resolved "https://registry.yarnpkg.com/moment-precise-range-plugin/-/moment-precise-range-plugin-1.3.0.tgz#60ac075fdfd14689f6d102af751d171a80b4ab60"
integrity sha1-YKwHX9/RRon20QKvdR0XGoC0q2A=
moment@^2.24.0:
version "2.25.3"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.25.3.tgz#252ff41319cf41e47761a1a88cab30edfe9808c0"
integrity sha512-PuYv0PHxZvzc15Sp8ybUCoQ+xpyPWvjOuK72a5ovzp2LI32rJXOiIfyoFoYvG3s6EwwrdkMyWuRiEHSZRLJNdg==
moment@^2.27.0:
version "2.27.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d"
integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==
mongodb@3.5.7:
version "3.5.7"
@ -1972,10 +1965,10 @@ mute-stream@0.0.8:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==
nan@2.14.0:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
nan@2.14.1:
version "2.14.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01"
integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==
natural-compare@^1.4.0:
version "1.4.0"
@ -2985,3 +2978,9 @@ x-xss-protection@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/x-xss-protection/-/x-xss-protection-1.3.0.tgz#3e3a8dd638da80421b0e9fff11a2dbe168f6d52c"
integrity sha512-kpyBI9TlVipZO4diReZMAHWtS0MMa/7Kgx8hwG/EuZLiA6sg4Ah/4TRdASHhRRN3boobzcYgFRUFSgHRge6Qhg==
x509@bsian03/node-x509:
version "0.3.4"
resolved "https://codeload.github.com/bsian03/node-x509/tar.gz/cc32d7f590ec43cb856effbb4202921f3fa9aef3"
dependencies:
nan "2.14.1"