From 5c7cabbf4c55f6dcea5c815515732b9f1ebeb1d1 Mon Sep 17 00:00:00 2001 From: reaby Date: Wed, 20 Nov 2024 21:18:13 +0200 Subject: [PATCH 01/31] fix typeof Migrate --- core/migrations/00-create-map.ts | 33 +++++++++++++-------------- migrate.ts | 39 +++++++++++++++++++------------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/core/migrations/00-create-map.ts b/core/migrations/00-create-map.ts index 1d81218..41972f8 100644 --- a/core/migrations/00-create-map.ts +++ b/core/migrations/00-create-map.ts @@ -2,16 +2,16 @@ import { DataTypes } from 'sequelize'; import type { Migration } from '../../migrate'; export const up: Migration = async ({ context: sequelize }) => { - await sequelize.getQueryInterface().createTable('maps', { - uuid: { - type: DataTypes.STRING, - allowNull: false, - primaryKey: true, - }, - name: { - type: DataTypes.STRING, - allowNull: false, - }, + await sequelize.getQueryInterface().createTable('maps', { + uuid: { + type: DataTypes.STRING, + allowNull: false, + primaryKey: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, author: { type: DataTypes.STRING, allowNull: false @@ -21,21 +21,20 @@ export const up: Migration = async ({ context: sequelize }) => { }, authorTime: { type: DataTypes.INTEGER, - allowNull:false + allowNull: false }, environment: { - type:DataTypes.STRING + type: DataTypes.STRING }, updatedAt: { type: DataTypes.DATE }, - createdAt: - { + createdAt: { type: DataTypes.DATE } - }); + }); }; export const down: Migration = async ({ context: sequelize }) => { - await sequelize.getQueryInterface().dropTable('maps'); -}; \ No newline at end of file + await sequelize.getQueryInterface().dropTable('maps'); +}; diff --git a/migrate.ts b/migrate.ts index b6eb810..2927111 100644 --- a/migrate.ts +++ b/migrate.ts @@ -1,39 +1,46 @@ -import { Umzug, SequelizeStorage } from 'umzug'; +import { Umzug, SequelizeStorage, type MigrationParams } from 'umzug'; import { Sequelize } from 'sequelize'; import log from './core/log'; -const sequelize = new Sequelize(process.env['DATABASE'] ?? "", { +const sequelize = new Sequelize(process.env['DATABASE'] ?? '', { logging(sql, timing) { - log.info("$d7c" + sql); - }, + log.info('$d7c' + sql); + } }); (async () => { try { - log.info("$fffMigrating:") - for (const path of ["./core/migrations/", "./userdata/migrations/"]) { + log.info('$fffMigrating:'); + for (const path of ['./core/migrations/', './userdata/migrations/']) { const migrator = new Umzug({ migrations: { - glob: [path + '*.ts', { cwd: process.cwd() }], + glob: [path + '*.ts', { cwd: process.cwd() }] }, context: sequelize, storage: new SequelizeStorage({ - sequelize, + sequelize }), logger: { - debug: (message) => { }, - error: (message) => { log.info("$f00" + message) }, - warn: (message) => { log.info("$fa0" + message) }, - info: (message) => { } + debug: (message) => {}, + error: (message) => { + log.info('$f00' + message); + }, + warn: (message) => { + log.info('$fa0' + message); + }, + info: (message) => {} //info: (message) => { log.info("$5bf" + message.event + " $fff" + message.name) }, } }); - log.info("$5bfRunning migrations for " + path); + log.info('$5bfRunning migrations for ' + path); await migrator.up(); - log.info("$0f0Success!"); + log.info('$0f0Success!'); } + process.exit(0); } catch (e: any) { - log.error("$f00error occurred"); + log.error('$f00error occurred'); } -})(); \ No newline at end of file +})(); + +export type Migration = (params: MigrationParams, context: Sequelize) => Promise; From 1cccbdc20db5fa0f84afe7b5466c45bb359aafdc Mon Sep 17 00:00:00 2001 From: reaby Date: Sun, 24 Nov 2024 13:22:43 +0200 Subject: [PATCH 02/31] 0.8.0-dev, BREAKING CHANGE: all templates named from .twig to .xml.twig to enhance compability between ides!! --- core/plugins/database/index.ts | 6 +- core/plugins/debugtool/index.ts | 2 +- .../{widget.twig => widget.xml.twig} | 2 +- .../maps/{maplist.twig => maplist.xml.twig} | 3 +- core/plugins/maps/mapsWindow.ts | 64 +++++++---- core/plugins/pay2play/index.ts | 2 +- .../pay2play/{widget.twig => widget.xml.twig} | 2 +- core/plugins/tm2020/openplanet/index.ts | 2 +- .../{opdetect.twig => opdetect.xml.twig} | 2 +- core/plugins/tmnf/freezone/index.ts | 6 +- core/plugins/tmnf/talimit/index.ts | 2 +- .../talimit/{widget.twig => widget.xml.twig} | 2 +- core/plugins/tmnf/togglechat/index.ts | 2 +- .../{widget.twig => widget.xml.twig} | 2 +- core/plugins/tmnf/ui/index.ts | 2 +- .../tmnf/ui/{widget.twig => widget.xml.twig} | 0 core/plugins/tmx/index.ts | 22 ++-- core/plugins/votes/index.ts | 22 ++-- .../votes/{widget.twig => widget.xml.twig} | 2 +- core/plugins/widgets/.dedimania/index.ts | 4 +- .../{widget.twig => widget.xml.twig} | 2 +- core/plugins/widgets/bestcps/index.ts | 2 +- .../bestcps/{widget.twig => widget.xml.twig} | 2 +- core/plugins/widgets/checkpoints/index.ts | 2 +- .../{widget.twig => widget.xml.twig} | 10 +- core/plugins/widgets/favourite/index.ts | 2 +- .../{widget.twig => widget.xml.twig} | 2 +- core/plugins/widgets/map/index.ts | 2 +- .../map/{widget.twig => widget.xml.twig} | 2 +- core/plugins/widgets/maplikes/index.ts | 2 +- .../maplikes/{widget.twig => widget.xml.twig} | 2 +- core/plugins/widgets/menu/index.ts | 4 +- .../widgets/menu/{menu.twig => menu.xml.twig} | 100 +++++++++--------- .../{menuButton.twig => menuButton.xml.twig} | 2 +- core/plugins/widgets/menu/menuWidget.ts | 4 +- core/plugins/widgets/records/index.ts | 2 +- .../records/{widget.twig => widget.xml.twig} | 2 +- core/templates/confirm.twig | 9 -- core/templates/confirm.xml.twig | 9 ++ core/templates/list.twig | 72 ------------- core/templates/list.xml.twig | 80 ++++++++++++++ core/templates/manialink.twig | 3 - core/templates/manialink.xml.twig | 3 + core/templates/widget.twig | 19 ---- core/templates/widget.xml.twig | 22 ++++ core/templates/window.twig | 18 ---- core/templates/window.xml.twig | 19 ++++ core/ui/confirm.ts | 11 +- core/ui/listwindow.ts | 2 +- core/ui/manialink.ts | 4 +- core/ui/widget.ts | 2 +- documentation/devs/class/uimanager.md | 4 +- package.json | 2 +- 53 files changed, 304 insertions(+), 270 deletions(-) rename core/plugins/debugtool/{widget.twig => widget.xml.twig} (75%) rename core/plugins/maps/{maplist.twig => maplist.xml.twig} (94%) rename core/plugins/pay2play/{widget.twig => widget.xml.twig} (90%) rename core/plugins/tm2020/openplanet/{opdetect.twig => opdetect.xml.twig} (97%) rename core/plugins/tmnf/talimit/{widget.twig => widget.xml.twig} (86%) rename core/plugins/tmnf/togglechat/{widget.twig => widget.xml.twig} (88%) rename core/plugins/tmnf/ui/{widget.twig => widget.xml.twig} (100%) rename core/plugins/votes/{widget.twig => widget.xml.twig} (96%) rename core/plugins/widgets/.dedimania/{widget.twig => widget.xml.twig} (97%) rename core/plugins/widgets/bestcps/{widget.twig => widget.xml.twig} (94%) rename core/plugins/widgets/checkpoints/{widget.twig => widget.xml.twig} (73%) rename core/plugins/widgets/favourite/{widget.twig => widget.xml.twig} (92%) rename core/plugins/widgets/map/{widget.twig => widget.xml.twig} (92%) rename core/plugins/widgets/maplikes/{widget.twig => widget.xml.twig} (93%) rename core/plugins/widgets/menu/{menu.twig => menu.xml.twig} (97%) rename core/plugins/widgets/menu/{menuButton.twig => menuButton.xml.twig} (90%) rename core/plugins/widgets/records/{widget.twig => widget.xml.twig} (97%) delete mode 100644 core/templates/confirm.twig create mode 100644 core/templates/confirm.xml.twig delete mode 100644 core/templates/list.twig create mode 100644 core/templates/list.xml.twig delete mode 100644 core/templates/manialink.twig create mode 100644 core/templates/manialink.xml.twig delete mode 100644 core/templates/widget.twig create mode 100644 core/templates/widget.xml.twig delete mode 100644 core/templates/window.twig create mode 100644 core/templates/window.xml.twig diff --git a/core/plugins/database/index.ts b/core/plugins/database/index.ts index 70a7398..a7cc392 100644 --- a/core/plugins/database/index.ts +++ b/core/plugins/database/index.ts @@ -133,7 +133,7 @@ export default class GenericDb extends Plugin { async syncPlayer(player: PlayerType) { let dbPlayer = await Player.findByPk(player.login); if (dbPlayer == null) { - dbPlayer = await Player.create({ + await Player.create({ login: player.login, nickname: player.nickname, path: player.path @@ -144,10 +144,6 @@ export default class GenericDb extends Plugin { path: player.path }); } - if (dbPlayer && dbPlayer.customNick) { - tmc.cli('Setting nickname to ' + dbPlayer.customNick); - player.set('nickname', dbPlayer.customNick); - } } async syncPlayers() { diff --git a/core/plugins/debugtool/index.ts b/core/plugins/debugtool/index.ts index 9776ef3..8bcaaae 100644 --- a/core/plugins/debugtool/index.ts +++ b/core/plugins/debugtool/index.ts @@ -9,7 +9,7 @@ export default class DebugTool extends Plugin { async onLoad() { if (process.env.DEBUG == "true") { - this.widget = new Widget("core/plugins/debugtool/widget.twig"); + this.widget = new Widget("core/plugins/debugtool/widget.xml.twig"); this.widget.pos = { x: 159, y: -60, z: 0 }; tmc.addCommand("//addfake", this.cmdFakeUsers.bind(this), "Connect Fake users"); tmc.addCommand("//removefake", this.cmdRemoveFakeUsers.bind(this), "Connect Fake users"); diff --git a/core/plugins/debugtool/widget.twig b/core/plugins/debugtool/widget.xml.twig similarity index 75% rename from core/plugins/debugtool/widget.twig rename to core/plugins/debugtool/widget.xml.twig index 0a0b27e..466b56f 100644 --- a/core/plugins/debugtool/widget.twig +++ b/core/plugins/debugtool/widget.xml.twig @@ -1,4 +1,4 @@ -{% extends 'core/templates/widget.twig' %} +{% extends 'core/templates/widget.xml.twig' %} {% block content %}