feat: Split des packages

This commit is contained in:
Max batleforc 2025-05-27 19:49:29 +02:00
parent d026347897
commit 9ecece1a5b
No known key found for this signature in database
GPG Key ID: 25D243AB4B6AC9E7
24 changed files with 185 additions and 41 deletions

37
Cargo.lock generated
View File

@ -404,15 +404,12 @@ dependencies = [
"chrono", "chrono",
"clickhouse", "clickhouse",
"clickhouse_pool", "clickhouse_pool",
"config",
"database", "database",
"poise", "poise",
"serde", "serde",
"tokio", "tokio",
"tokio-cron-scheduler",
"toml",
"tool_tracing",
"tracing", "tracing",
"uuid",
] ]
[[package]] [[package]]
@ -524,6 +521,26 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93a719913643003b84bd13022b4b7e703c09342cd03b679c4641c7d2e50dc34d" checksum = "93a719913643003b84bd13022b4b7e703c09342cd03b679c4641c7d2e50dc34d"
[[package]]
name = "cli"
version = "0.1.0"
dependencies = [
"bot",
"chrono",
"clickhouse",
"clickhouse_pool",
"config",
"database",
"poise",
"serde",
"tokio",
"tokio-cron-scheduler",
"toml",
"tool_tracing",
"tracing",
"uuid",
]
[[package]] [[package]]
name = "clickhouse" name = "clickhouse"
version = "0.13.2" version = "0.13.2"
@ -583,6 +600,18 @@ dependencies = [
"url", "url",
] ]
[[package]]
name = "config"
version = "0.1.0"
dependencies = [
"database",
"poise",
"serde",
"toml",
"tool_tracing",
"tracing",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.9.4"

View File

@ -2,14 +2,16 @@
[workspace] [workspace]
resolver = '2' resolver = '2'
members = [ members = [
'apps/bot', 'apps/cli',
'libs/tool_tracing', 'libs/tool_tracing',
'libs/clickhouse_pool', 'libs/clickhouse_pool',
'libs/database', 'libs/database',
'libs/bot',
'libs/config',
] ]
[workspace.dependencies] [workspace.dependencies]
poise = { git = "https://github.com/serenity-rs/poise", branch = "current" } poise = { git = 'https://github.com/serenity-rs/poise', branch = 'current' }
tokio = { version = '1.45.0', features = [ tokio = { version = '1.45.0', features = [
'macros', 'macros',
'rt-multi-thread', 'rt-multi-thread',
@ -19,11 +21,11 @@ serde = '1.0'
tracing = '0.1' tracing = '0.1'
serde_json = '1.0' serde_json = '1.0'
clickhouse = { version = '0.13', features = ['native-tls', 'uuid', 'chrono'] } clickhouse = { version = '0.13', features = ['native-tls', 'uuid', 'chrono'] }
uuid = { version = "1.16", features = ["serde", "v4"] } uuid = { version = '1.16', features = ['serde', 'v4'] }
chrono = { version = "0.4.41", features = ["serde"] } chrono = { version = '0.4.41', features = ['serde'] }
[profile.release] [profile.release]
lto = true lto = true
[patch.crates-io] [patch.crates-io]
serenity = { git = "https://github.com/serenity-rs/serenity", branch = "current" } serenity = { git = 'https://github.com/serenity-rs/serenity', branch = 'current' }

View File

@ -24,7 +24,6 @@
- [ ] [ADMIN] trivial add-question : Ajout de question + réponse ou X réponse - [ ] [ADMIN] trivial add-question : Ajout de question + réponse ou X réponse
- [ ] [ADMIN] trivial del-question : Suppression de question - [ ] [ADMIN] trivial del-question : Suppression de question
- [ ] [ADMIN] trivial load-question : Charge un fichier/lien de question - [ ] [ADMIN] trivial load-question : Charge un fichier/lien de question
- [ ] [ADMIN] trivial choose-chan : Choix du channel
- [ ] trivial scoreboard : Scoreboard - [ ] trivial scoreboard : Scoreboard
- [ ] trivial score : Score d'une personne par défaut le sien - [ ] trivial score : Score d'une personne par défaut le sien
- [ ] trivial top : Top X par défaut 3 - [ ] trivial top : Top X par défaut 3

View File

@ -1,5 +1,5 @@
[package] [package]
name = "bot" name = "cli"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
@ -20,5 +20,7 @@ tokio-cron-scheduler = { version = "0.14", features = [
"tracing-subscriber", "tracing-subscriber",
"signal", "signal",
] } ] }
config = { path = "../../libs/config" }
bot = { path = "../../libs/bot" }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,8 +1,8 @@
{ {
"name": "bot", "name": "cli",
"$schema": "../../node_modules/nx/schemas/project-schema.json", "$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application", "projectType": "application",
"sourceRoot": "apps/bot/src", "sourceRoot": "apps/cli/src",
"targets": { "targets": {
"build": { "build": {
"cache": true, "cache": true,
@ -11,7 +11,7 @@
"{options.target-dir}" "{options.target-dir}"
], ],
"options": { "options": {
"target-dir": "dist/target/bot" "target-dir": "dist/target/cli"
}, },
"configurations": { "configurations": {
"production": { "production": {
@ -26,7 +26,7 @@
"{options.target-dir}" "{options.target-dir}"
], ],
"options": { "options": {
"target-dir": "dist/target/bot" "target-dir": "dist/target/cli"
}, },
"configurations": { "configurations": {
"production": { "production": {
@ -41,7 +41,7 @@
"{options.target-dir}" "{options.target-dir}"
], ],
"options": { "options": {
"target-dir": "dist/target/bot" "target-dir": "dist/target/cli"
} }
}, },
"run": { "run": {
@ -50,7 +50,7 @@
"{options.target-dir}" "{options.target-dir}"
], ],
"options": { "options": {
"target-dir": "dist/target/bot" "target-dir": "dist/target/cli"
}, },
"configurations": { "configurations": {
"production": { "production": {

View File

@ -2,10 +2,6 @@ use bot::start_bot;
use config::parse_local_config; use config::parse_local_config;
use tracing::{error, info}; use tracing::{error, info};
pub mod bot;
pub mod config;
pub mod dotenv;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
println!(include_str!("banner.art")); println!(include_str!("banner.art"));

17
libs/bot/Cargo.toml Normal file
View File

@ -0,0 +1,17 @@
[package]
name = "bot"
version = "0.1.0"
edition = "2021"
[dependencies]
poise = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true }
tracing = { workspace = true }
clickhouse_pool = { path = "../../libs/clickhouse_pool" }
clickhouse = { workspace = true }
chrono = { workspace = true }
config = { path = "../../libs/config" }
database = { path = "../../libs/database" }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

43
libs/bot/project.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "bot",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/bot/src",
"targets": {
"build": {
"executor": "@monodon/rust:check",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
}
},
"test": {
"cache": true,
"executor": "@monodon/rust:test",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
},
"configurations": {
"production": {
"release": true
}
}
},
"lint": {
"cache": true,
"executor": "@monodon/rust:lint",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/bot"
}
}
},
"tags": []
}

View File

@ -1,4 +1,4 @@
use crate::bot::{Data, Error}; use crate::{Data, Error};
use poise::serenity_prelude::{self as serenity, ActivityData}; use poise::serenity_prelude::{self as serenity, ActivityData};
use tracing::info; use tracing::info;

View File

@ -2,7 +2,7 @@ use clickhouse_pool::traits::Model;
use database::guild::Guild; use database::guild::Guild;
use tracing::{info, warn}; use tracing::{info, warn};
use crate::bot::{Context, Error}; use crate::{Context, Error};
/// Check if the guild has been initialized, if it is check if user is in list of admins /// Check if the guild has been initialized, if it is check if user is in list of admins
/// If not, check the user's permissions /// If not, check the user's permissions

View File

@ -7,7 +7,7 @@ use tracing::info;
use trivia::trivia; use trivia::trivia;
use utility::{age::age, help::help, server::servers}; use utility::{age::age, help::help, server::servers};
use crate::config::Config; use config::Config;
pub mod event; pub mod event;
pub mod helper; pub mod helper;

View File

@ -1,5 +1,5 @@
use crate::bot::helper::is_user_admin_right; use crate::helper::is_user_admin_right;
use crate::bot::{Context, Error}; use crate::{Context, Error};
use clickhouse_pool::traits::Model; use clickhouse_pool::traits::Model;
use database::trivial::{Trivial, TrivialRewardKind}; use database::trivial::{Trivial, TrivialRewardKind};
use poise::serenity_prelude::{Channel, Role}; use poise::serenity_prelude::{Channel, Role};

View File

@ -1,5 +1,5 @@
use crate::bot::helper::is_user_admin_right; use crate::helper::is_user_admin_right;
use crate::bot::{Context, Error}; use crate::{Context, Error};
use clickhouse_pool::traits::Model; use clickhouse_pool::traits::Model;
use database::trivial::Trivial; use database::trivial::Trivial;
use poise::serenity_prelude; use poise::serenity_prelude;

View File

@ -1,5 +1,5 @@
use crate::bot::helper::is_user_admin_right; use crate::helper::is_user_admin_right;
use crate::bot::{Context, Error}; use crate::{Context, Error};
use clickhouse_pool::traits::Model; use clickhouse_pool::traits::Model;
use database::trivial::Trivial; use database::trivial::Trivial;
use poise::{ use poise::{

View File

@ -2,7 +2,7 @@ pub mod config;
pub mod create; pub mod create;
pub mod list; pub mod list;
use crate::bot::{Context, Error}; use crate::{Context, Error};
use config::config; use config::config;
use create::create; use create::create;
use list::list; use list::list;

View File

@ -1,4 +1,4 @@
use crate::bot::{Context, Error}; use crate::{Context, Error};
use poise::serenity_prelude as serenity; use poise::serenity_prelude as serenity;
use tracing::instrument; use tracing::instrument;

View File

@ -1,4 +1,4 @@
use crate::bot::{Context, Error}; use crate::{Context, Error};
use poise::builtins::PrettyHelpConfiguration; use poise::builtins::PrettyHelpConfiguration;
use tracing::instrument; use tracing::instrument;

View File

@ -1,4 +1,4 @@
use crate::bot::{Context, Error}; use crate::{Context, Error};
use tracing::instrument; use tracing::instrument;
/// Lists all servers the bot is in /// Lists all servers the bot is in

13
libs/config/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "config"
version = "0.1.0"
edition = "2021"
[dependencies]
poise = { workspace = true }
serde = { workspace = true }
database = { path = "../../libs/database" }
tool_tracing = { path = "../../libs/tool_tracing" }
toml = "0.8"
tracing = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

43
libs/config/project.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "config",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/config/src",
"targets": {
"build": {
"executor": "@monodon/rust:check",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/config"
}
},
"test": {
"cache": true,
"executor": "@monodon/rust:test",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/config"
},
"configurations": {
"production": {
"release": true
}
}
},
"lint": {
"cache": true,
"executor": "@monodon/rust:lint",
"outputs": [
"{options.target-dir}"
],
"options": {
"target-dir": "dist/target/config"
}
}
},
"tags": []
}

View File

@ -4,7 +4,7 @@ use serde::Deserialize;
use std::{env, fs::read_to_string, path::PathBuf}; use std::{env, fs::read_to_string, path::PathBuf};
use tool_tracing::tracing_kind::Tracing; use tool_tracing::tracing_kind::Tracing;
use crate::dotenv; pub mod dotenv;
const BOT_NAME: &str = "BOT_NAME"; const BOT_NAME: &str = "BOT_NAME";
const BOT_TOKEN: &str = "BOT_TOKEN"; const BOT_TOKEN: &str = "BOT_TOKEN";