-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Artivain/unstable
🎉 Version 1.3.0
- Loading branch information
Showing
8 changed files
with
170 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,4 +105,4 @@ dist | |
|
||
**/private.json | ||
**/config.json | ||
updaterbk | ||
updaterFiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,76 @@ | ||
const AutoGitUpdate = require('auto-git-update'); | ||
const { params } = require("../config.json"); | ||
|
||
const config = { | ||
repository: 'https://github.com/Artivain/artibot', | ||
tempLocation: '../updaterbk', | ||
branch: "main", | ||
exitOnComplete: true | ||
}; | ||
|
||
const updater = new AutoGitUpdate(config); | ||
|
||
updater.setLogConfig({ | ||
logDebug: true, | ||
logDetail: true, | ||
logGeneral: true, | ||
logWarning: true, | ||
logError: true | ||
}); | ||
updater.autoUpdate(); | ||
// if ran with npm run updater | ||
if (require.main === module) { | ||
|
||
if (params.checkForUpdates != "stable" && params.checkForUpdates != "unstable") { | ||
console.error("[Updater] Erreur de configuration"); | ||
process.exit(1); | ||
}; | ||
|
||
const config = { | ||
repository: 'https://github.com/Artivain/artibot', | ||
tempLocation: '../updaterFiles', | ||
exitOnComplete: true, | ||
branch: (params.checkForUpdates == "stable" ? "main" : "unstable") | ||
}; | ||
|
||
const updater = new AutoGitUpdate(config); | ||
|
||
updater.setLogConfig({ | ||
logDebug: true, | ||
logDetail: true, | ||
logGeneral: true, | ||
logWarning: true, | ||
logError: true | ||
}); | ||
updater.autoUpdate(); | ||
|
||
} else { | ||
|
||
module.exports = { | ||
async checkUpdates() { | ||
if (params.checkForUpdates != "stable" && params.checkForUpdates != "unstable") { | ||
return console.log("[Updater] Vérification des mises à jours désactivée dans la configuration") | ||
} | ||
|
||
const config = { | ||
repository: 'https://github.com/Artivain/artibot', | ||
tempLocation: '../../updaterFiles', | ||
exitOnComplete: false, | ||
branch: (params.checkForUpdates == "stable" ? "main" : "unstable") | ||
}; | ||
|
||
const updater = new AutoGitUpdate(config); | ||
|
||
updater.setLogConfig({ | ||
logDebug: false, | ||
logDetail: false, | ||
logGeneral: false, | ||
logWarning: true, | ||
logError: true | ||
}); | ||
|
||
return updater.compareVersions(); | ||
}, | ||
|
||
async doUpdates(options) { | ||
if (params.checkForUpdates != "stable" && params.checkForUpdates != "unstable") { | ||
throw "Erreur de configuration" | ||
}; | ||
|
||
const autoUpdater = new AutoGitUpdate(options); | ||
|
||
autoUpdater.setLogConfig({ | ||
logDebug: true, | ||
logDetail: true, | ||
logGeneral: true, | ||
logWarning: true, | ||
logError: true | ||
}); | ||
return autoUpdater.autoUpdate(); | ||
} | ||
}; | ||
|
||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const updater = require("../../../ab-core/updater"); | ||
|
||
module.exports = { | ||
name: "update", | ||
description: "Installe les mises à jour du bot", | ||
ownerOnly: true, | ||
|
||
execute(message, args, config) { | ||
// Check if config is valid | ||
if (config.checkForUpdates != "stable" && config.checkForUpdates != "unstable") { | ||
message.reply("Le canal des mises à jour n'est pas défini dans la config!"); | ||
return | ||
} | ||
|
||
// If the owner really wants to do the update, let's do it | ||
if (args[0] == "force") { | ||
updater.checkUpdates().then(response => { | ||
if (response.upToDate) { | ||
message.reply(`Artibot est déjà à jours (v${response.currentVersion}).`); | ||
return | ||
}; | ||
|
||
message.reply("Début des mises à jours... Consulter la console pour plus de détails.") | ||
|
||
const options = { | ||
repository: 'https://github.com/Artivain/artibot', | ||
tempLocation: '../updaterFiles', | ||
exitOnComplete: false, | ||
branch: (config.checkForUpdates == "stable" ? "main" : "unstable") | ||
}; | ||
|
||
updater.doUpdates(options) | ||
.then(response => { | ||
if (!response) { | ||
message.reply("Une erreur est survenue pendant la mise à jour. Consulter la console pour plus de détails."); | ||
return | ||
} | ||
message.reply( | ||
"Les mises à jour ont bien été installées.\n" + | ||
"Le bot va maintenant s'éteindre tout seul.\n" + | ||
"Si votre hébergement le supporte, le bot devrait revenir de lui même bientôt." | ||
).then(() => { | ||
process.exit(1); | ||
}); | ||
}) | ||
.catch(e => { | ||
message.reply("Une erreur est survenue pendant la mise à jour. Consulter la console pour plus de détails."); | ||
console.error("[Updater] Problème avec la mise à jour: " + e); | ||
}); | ||
}); | ||
} else { | ||
updater.checkUpdates().then(response => { | ||
if (response.upToDate) { | ||
message.reply(`Artibot est à jours (v${response.currentVersion}).`); | ||
} else { | ||
message.reply( | ||
`Une mise à jour est disponible: v${response.currentVersion} --> v${response.remoteVersion}.\n` + | ||
"**Bien lire la documentation avant de faire la mise à jour!**\n" + | ||
"Pour faire la mise à jour, faire la commande `update force`." | ||
); | ||
} | ||
}); | ||
}; | ||
}, | ||
}; |
Oops, something went wrong.