Skip to content

Commit 5863630

Browse files
authored
Merge branch 'main' into main
2 parents 107d411 + c10c344 commit 5863630

3 files changed

Lines changed: 137 additions & 3 deletions

File tree

.github/scripts/check-yaml.cjs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const fs = require("fs");
2+
const yaml = require("js-yaml");
3+
const glob = require("glob");
4+
5+
const SNAKE_CASE_REGEX = /^[a-z][a-z0-9_]*$/;
6+
7+
let hasError = false;
8+
const parsedFiles = [];
9+
10+
function checkKeys(obj, file, path = "") {
11+
if (typeof obj !== "object" || obj === null) return;
12+
13+
for (const key of Object.keys(obj)) {
14+
const fullPath = path ? `${path}.${key}` : key;
15+
16+
if (!SNAKE_CASE_REGEX.test(key)) {
17+
console.error(
18+
`❌ ${file} → clé invalide "${fullPath}" (snake_case requis)`
19+
);
20+
hasError = true;
21+
}
22+
23+
checkKeys(obj[key], file, fullPath);
24+
}
25+
}
26+
27+
const files = glob.sync("**/*.{yml,yaml}", {
28+
ignore: ["node_modules/**"]
29+
});
30+
31+
if (files.length === 0) {
32+
console.log("ℹ️ Aucun fichier YAML trouvé");
33+
process.exit(0);
34+
}
35+
36+
for (const file of files) {
37+
try {
38+
const content = fs.readFileSync(file, "utf8");
39+
const data = yaml.load(content);
40+
41+
checkKeys(data, file);
42+
43+
parsedFiles.push({
44+
file,
45+
data
46+
});
47+
} catch (err) {
48+
console.error(`❌ Erreur YAML dans ${file}`);
49+
console.error(err.message);
50+
hasError = true;
51+
}
52+
}
53+
54+
if (hasError) {
55+
console.error("\n⛔ Validation YAML échouée");
56+
process.exit(1);
57+
}
58+
59+
/**
60+
* OUTPUT FINAL
61+
* Tu peux le parser dans un autre step GitHub Actions
62+
*/
63+
console.log(JSON.stringify(parsedFiles, null, 2));

.github/workflows/yaml-lint.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: YAML format & snake_case check
2+
3+
on:
4+
push:
5+
paths:
6+
- "**/*.yml"
7+
- "**/*.yaml"
8+
pull_request:
9+
paths:
10+
- "**/*.yml"
11+
- "**/*.yaml"
12+
13+
jobs:
14+
yaml-check:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
26+
- name: Install dependencies
27+
run: npm install js-yaml glob
28+
29+
- name: Validate YAML files and keys
30+
run: node .github/scripts/check-yaml.cjs
31+

patterns/NationsGloryJava.yml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
# ===========================
22
# Commandes Joueur
33
# ===========================
4+
45
player_command:
56
pattern: "{timestamp} [INFO] {player} issued server command: {command}"
67

78
player_alias:
89
pattern: "{timestamp} [INFO] {player} issued alias: {command}"
910

11+
player_warp:
12+
pattern: "{timestamp} [INFO] [NationsGUI] {player} vient de payer 20 pour se téléporter au warp {region}"
13+
14+
player_back:
15+
pattern: "{timestamp} [INFO] [NationsUtils] Back du joueur {player} vers {world}, {x}, {y}, {z}"
16+
1017
# ===========================
1118
# NationsStats
1219
# ===========================
20+
1321
stats_login:
1422
pattern: "{timestamp} [INFO] [NationsStats] Connexion de {player} avec {money}$"
1523

1624
# ===========================
1725
# HDV — Hôtel des ventes
1826
# ===========================
27+
1928
hdv_sell:
2029
pattern: "{timestamp} [HDV] {player} vient de mettre en vente {qty}x ID:({itemid}) pour un prix unitaire de {unitprice} $/U (UUID:{uuid})"
2130

@@ -57,8 +66,8 @@ war_add:
5766
war_start:
5867
pattern: "{timestamp} [INFO] [NationsGUI] START WAR between {country_a} and {country_b} for reason {reason}"
5968

60-
war_surrender:
61-
pattern: "{timestamp} [INFO] [NationsGUI] {country_a} SURREND WAR AGAINST {country_b} APPLY REWARDS : {reward_type}#{amount}"
69+
war_surrend:
70+
pattern: "{timestamp} [INFO] [NationsGUI] {country} SURREND WAR AGAINST {country} APPLY REWARDS : {reward}#{amount}"
6271

6372
war_status_change:
6473
pattern: "{timestamp} [INFO] [NationsUtils] Change status of war request between {country_a} and {country_b} by {player} to {status}"
@@ -80,9 +89,37 @@ war_decrease_powerloss:
8089

8190
war_end_decrease_powerloss:
8291
pattern: "{timestamp} [INFO] [Factions] Decrease powerLoss from won in war against {country} from 1 to -9 (no powerLoss left)"
92+
93+
# ===========================
94+
# Factions
95+
# ===========================
96+
97+
chunk_access:
98+
pattern: "{timestamp} [INFO] [Factions] Player {player} set access to player {player} in chunk {x}, {z} to true"
99+
100+
chunk_unaccess:
101+
pattern: "{timestamp} [INFO] [Factions] Player {player} remove access to player {player} in chunk {x}, {z} to false"
102+
103+
faction_chat:
104+
pattern: "{timestamp} [INFO] [FactionChat] FACTION|{player}: {text}"
105+
106+
faction_invite:
107+
pattern: "{timestamp} [INFO] [NationsGUI] Player {player} invited {player} to join country {country}"
108+
109+
faction_uninvite:
110+
pattern: "{timestamp} [INFO] [NationsGUI] Player {player} cancelled invitation {player} to join country {country}"
111+
112+
faction_promote:
113+
pattern: "{timestamp} [INFO] [NationsGUI] Player {player} demoted to {rank} {player} in country {country}"
114+
115+
faction_demote:
116+
pattern: "{timestamp} [INFO] [NationsGUI] Player {player} prommoted to {rank} {player} in country {country}"
117+
118+
faction_perms:
119+
pattern: "{timestamp} [INFO] [FACTION] {player} changed faction permission {permission} to [{ALLY}, {LEADER}, {MEMBER}, {NEUTRAL}, {OFFICER}, {RECRUIT}]"
83120

84121
# ===========================
85-
# Transactions bancaires
122+
# Bank transactions
86123
# ===========================
87124

88125
bank_deposit:
@@ -117,6 +154,9 @@ combat_fired:
117154
combat_bullet:
118155
pattern: "{timestamp} MISE EN COMBAT DE {player} HIT BY BULLET"
119156

157+
player_death:
158+
pattern: "{timestamp} [INFO] [NationsUtils] Le joueur {player} est mort aux coordonnées : X{x}, Y{y}, Z{z}"
159+
120160
# ===========================
121161
# Intrusions / Divers
122162
# ===========================

0 commit comments

Comments
 (0)