moomodding 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/moo.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import "../dist/index.js";
3
+ import "../dist/cli.js";
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,111 @@
1
+ import { Command } from "commander";
2
+ import pc from "picocolors";
3
+ import { loginCommand } from "./commands/login.js";
4
+ import { whoamiCommand } from "./commands/whoami.js";
5
+ import { initCommand } from "./commands/init.js";
6
+ import { listCommand } from "./commands/list.js";
7
+ import { cloneCommand } from "./commands/clone.js";
8
+ import { pushCommand } from "./commands/push.js";
9
+ import { pullCommand } from "./commands/pull.js";
10
+ import { devCommand } from "./commands/dev.js";
11
+ import { clearAuth, loadConfig, saveConfig } from "./core/config.js";
12
+ const program = new Command();
13
+ program
14
+ .name("moo")
15
+ .description("MooModding Developer CLI — Build, test, and sync MooMoo.io mods with zero friction.")
16
+ .version("1.0.2");
17
+ // 1. Auth Commands
18
+ program
19
+ .command("login [token]")
20
+ .description("Log in to your MooModding account")
21
+ .action(async (token) => {
22
+ await loginCommand(token);
23
+ });
24
+ program
25
+ .command("logout")
26
+ .description("Log out and clear local credentials")
27
+ .action(() => {
28
+ clearAuth();
29
+ console.log(pc.green("[success] Logged out successfully."));
30
+ });
31
+ program
32
+ .command("whoami")
33
+ .description("Display current user and storage quota")
34
+ .action(async () => {
35
+ await whoamiCommand();
36
+ });
37
+ // 2. Project Lifecycle Commands
38
+ program
39
+ .command("init [dir]")
40
+ .description("Scaffold a new MooMoo mod project")
41
+ .option("-n, --name <name>", "Mod display name")
42
+ .option("-t, --type <type>", "Mod type ('hook' or 'bundle_replacement')", "hook")
43
+ .action(async (dir, options) => {
44
+ await initCommand(dir, options);
45
+ });
46
+ program
47
+ .command("list")
48
+ .alias("ls")
49
+ .description("List your cloud mods and storage usage")
50
+ .action(async () => {
51
+ await listCommand();
52
+ });
53
+ program
54
+ .command("clone <slug> [dir]")
55
+ .description("Clone a cloud mod into a local directory")
56
+ .action(async (slug, dir) => {
57
+ await cloneCommand(slug, dir);
58
+ });
59
+ program
60
+ .command("push")
61
+ .description("Scan directory and push mod files to cloud")
62
+ .action(async () => {
63
+ await pushCommand();
64
+ });
65
+ program
66
+ .command("pull")
67
+ .description("Pull latest mod files from cloud")
68
+ .action(async () => {
69
+ await pullCommand();
70
+ });
71
+ program
72
+ .command("dev")
73
+ .description("Start file watcher for live cloud sync on save")
74
+ .action(() => {
75
+ devCommand();
76
+ });
77
+ // 3. Configuration command
78
+ program
79
+ .command("config <action> [key] [value]")
80
+ .description("View or update CLI config (e.g. moo config set api https://moomodding.io)")
81
+ .action((action, key, value) => {
82
+ const config = loadConfig();
83
+ if (action === "get") {
84
+ if (key) {
85
+ console.log(config[key] || pc.gray("(undefined)"));
86
+ }
87
+ else {
88
+ console.log(JSON.stringify(config, null, 2));
89
+ }
90
+ }
91
+ else if (action === "set") {
92
+ if (!key || value === undefined) {
93
+ console.log(pc.red("Usage: moo config set <key> <value>"));
94
+ return;
95
+ }
96
+ if (key === "api" || key === "apiUrl") {
97
+ config.apiUrl = value;
98
+ saveConfig(config);
99
+ console.log(pc.green(`[success] API URL updated: ${value}`));
100
+ }
101
+ else {
102
+ config[key] = value;
103
+ saveConfig(config);
104
+ console.log(pc.green(`[success] '${key}' updated.`));
105
+ }
106
+ }
107
+ else {
108
+ console.log(pc.red("Invalid action. Usage: moo config get [key] | moo config set <key> <value>"));
109
+ }
110
+ });
111
+ program.parse(process.argv);
@@ -4,18 +4,18 @@ import pc from "picocolors";
4
4
  import { api } from "../core/client.js";
5
5
  export async function cloneCommand(modSlug, targetDirName) {
6
6
  if (!modSlug) {
7
- console.log(pc.red("❌ Hata: İndirilecek mod slug'ı belirtilmedi."));
8
- console.log(pc.gray(`Örnek kullanım: ${pc.cyan("moo clone elite-combat-suite")}`));
7
+ console.log(pc.red("[error] Mod slug is required."));
8
+ console.log(pc.gray(`Example: ${pc.cyan("moo clone elite-combat-suite")}`));
9
9
  process.exit(1);
10
10
  }
11
11
  const cleanSlug = modSlug.trim().toLowerCase();
12
12
  const destDir = path.resolve(process.cwd(), targetDirName || cleanSlug);
13
- console.log(pc.bold(pc.green(`\n📥 Mod İndiriliyor: ${cleanSlug}`)));
14
- console.log(pc.gray(`Hedef: ${destDir}`));
13
+ console.log(pc.cyan(`[clone] Downloading '${cleanSlug}'...`));
14
+ console.log(pc.gray(`Destination: ${destDir}`));
15
15
  try {
16
16
  const res = await api.get(`/api/developer/mods/${cleanSlug}/pull`);
17
17
  if (!res.success || !res.files) {
18
- console.log(pc.red(`❌ Mod indirilemedi: ${res.message || "Bilinmeyen hata"}`));
18
+ console.log(pc.red(`[error] Failed to clone mod: ${res.message || "Unknown error"}`));
19
19
  process.exit(1);
20
20
  }
21
21
  if (!fs.existsSync(destDir)) {
@@ -31,17 +31,21 @@ export async function cloneCommand(modSlug, targetDirName) {
31
31
  is_active: res.mod.is_active ?? true
32
32
  };
33
33
  fs.writeFileSync(path.join(destDir, "mod.json"), JSON.stringify(modJson, null, 2), "utf-8");
34
- // 2. Write all files and recreate directories
34
+ // 2. Write all files and recreate directories (with Path Traversal protection)
35
35
  let writtenCount = 0;
36
36
  for (const [relPath, content] of Object.entries(res.files)) {
37
37
  if (typeof content !== "string")
38
38
  continue;
39
- const filePath = path.join(destDir, relPath);
40
- const parentDir = path.dirname(filePath);
39
+ const resolvedPath = path.resolve(destDir, relPath);
40
+ if (!resolvedPath.startsWith(destDir + path.sep) && resolvedPath !== destDir) {
41
+ console.warn(pc.yellow(`[warn] Security: Skipped invalid path: ${relPath}`));
42
+ continue;
43
+ }
44
+ const parentDir = path.dirname(resolvedPath);
41
45
  if (!fs.existsSync(parentDir)) {
42
46
  fs.mkdirSync(parentDir, { recursive: true });
43
47
  }
44
- fs.writeFileSync(filePath, content, "utf-8");
48
+ fs.writeFileSync(resolvedPath, content, "utf-8");
45
49
  writtenCount++;
46
50
  }
47
51
  // 3. Write default .mooignore if missing
@@ -49,12 +53,12 @@ export async function cloneCommand(modSlug, targetDirName) {
49
53
  if (!fs.existsSync(mooIgnorePath)) {
50
54
  fs.writeFileSync(mooIgnorePath, `node_modules/\n.git/\n.vscode/\n.idea/\ndist/\nbuild/\n*.log\n.env\n.DS_Store\n`, "utf-8");
51
55
  }
52
- console.log(pc.green(`\n✅ '${res.mod.name}' başarıyla indirildi!`));
53
- console.log(`📄 Toplam ${writtenCount} dosya yerel dizine yazıldı.`);
54
- console.log(pc.gray(`\nGeliştirmeye başlamak için:\n cd ${path.basename(destDir)}\n moo dev\n`));
56
+ console.log(pc.green(`[success] Cloned '${res.mod.name}' successfully.`));
57
+ console.log(pc.gray(`Files written: ${writtenCount}`));
58
+ console.log(pc.gray(`Next steps:\n cd ${path.basename(destDir)}\n moo dev\n`));
55
59
  }
56
60
  catch (err) {
57
- console.log(pc.red(`❌ İndirme hatası: ${err.message}`));
61
+ console.log(pc.red(`[error] Clone error: ${err.message}`));
58
62
  process.exit(1);
59
63
  }
60
64
  }
@@ -6,8 +6,8 @@ import { pushCommand } from "./push.js";
6
6
  export function devCommand(rootDir = process.cwd()) {
7
7
  const modConfigPath = path.join(rootDir, "mod.json");
8
8
  if (!fs.existsSync(modConfigPath)) {
9
- console.log(pc.red("❌ 'mod.json' bulunamadı."));
10
- console.log(pc.gray(`Lütfen mod kök dizininde çalıştırın veya yeni başlatmak için: ${pc.cyan("moo init")}`));
9
+ console.log(pc.red("[error] 'mod.json' not found."));
10
+ console.log(pc.gray(`Please run this command in a mod root directory or run 'moo init'.`));
11
11
  process.exit(1);
12
12
  }
13
13
  let modConfig;
@@ -15,13 +15,12 @@ export function devCommand(rootDir = process.cwd()) {
15
15
  modConfig = JSON.parse(fs.readFileSync(modConfigPath, "utf-8"));
16
16
  }
17
17
  catch {
18
- console.log(pc.red("❌ 'mod.json' okunamadı."));
18
+ console.log(pc.red("[error] Failed to parse 'mod.json'."));
19
19
  process.exit(1);
20
20
  }
21
- console.log(pc.bold(pc.green(`\n⚡ MooModding Canlı İzleme Modu (Hot-Sync)`)));
22
- console.log(`📦 Mod: ${pc.bold(pc.white(modConfig.name || "Mod"))} (${pc.cyan(modConfig.slug)})`);
23
- console.log(pc.gray(`👀 Dizin izleniyor: ${rootDir}`));
24
- console.log(pc.gray(`💡 İpucu: Kodunuzda Ctrl+S yaptığınız anda otomatik buluta aktarılır.\n`));
21
+ console.log(pc.cyan(`[watch] Starting live sync for '${modConfig.name || "Mod"}' (${modConfig.slug})`));
22
+ console.log(pc.gray(`Watching directory: ${rootDir}`));
23
+ console.log(pc.gray(`Changes will automatically sync to cloud on save. Press Ctrl+C to stop.\n`));
25
24
  // Initial push to verify state
26
25
  pushCommand({ rootDir, silent: false }).then(() => {
27
26
  let debounceTimer = null;
@@ -47,7 +46,7 @@ export function devCommand(rootDir = process.cwd()) {
47
46
  });
48
47
  const handleChange = (filePath, eventType) => {
49
48
  const rel = path.relative(rootDir, filePath).replace(/\\/g, "/");
50
- console.log(pc.gray(`[${new Date().toLocaleTimeString()}] 📝 ${eventType.toUpperCase()}: ${rel}`));
49
+ console.log(pc.gray(`[${new Date().toLocaleTimeString()}] [${eventType}] ${rel}`));
51
50
  if (debounceTimer)
52
51
  clearTimeout(debounceTimer);
53
52
  debounceTimer = setTimeout(async () => {
@@ -62,11 +61,11 @@ export function devCommand(rootDir = process.cwd()) {
62
61
  }
63
62
  }, 300);
64
63
  };
65
- watcher.on("change", (fp) => handleChange(fp, "değişti"));
66
- watcher.on("add", (fp) => handleChange(fp, "eklendi"));
67
- watcher.on("unlink", (fp) => handleChange(fp, "silindi"));
64
+ watcher.on("change", (fp) => handleChange(fp, "change"));
65
+ watcher.on("add", (fp) => handleChange(fp, "add"));
66
+ watcher.on("unlink", (fp) => handleChange(fp, "delete"));
68
67
  process.on("SIGINT", () => {
69
- console.log(pc.yellow("\n🛑 Canlı izleme modu sonlandırıldı."));
68
+ console.log(pc.yellow("\n[watch] Watcher stopped."));
70
69
  watcher.close();
71
70
  process.exit(0);
72
71
  });
@@ -7,13 +7,13 @@ export async function initCommand(targetDirName, options = {}) {
7
7
  const cleanSlug = path.basename(dir).toLowerCase().replace(/[^a-z0-9_-]/g, "-");
8
8
  const modName = options.name || cleanSlug.replace(/-/g, " ").replace(/\b\w/g, c => c.toUpperCase());
9
9
  const modType = options.type || "hook";
10
- console.log(pc.bold(pc.green(`\n🌱 MooModding Mod Projesi Başlatılıyor: ${modName}`)));
10
+ console.log(pc.cyan(`[init] Initializing mod project: ${modName}`));
11
11
  if (!fs.existsSync(dir)) {
12
12
  fs.mkdirSync(dir, { recursive: true });
13
13
  }
14
14
  const modJsonPath = path.join(dir, "mod.json");
15
15
  if (fs.existsSync(modJsonPath)) {
16
- console.log(pc.yellow(`⚠️ Dikkat: Bu dizinde zaten bir 'mod.json' mevcut.`));
16
+ console.log(pc.yellow(`[warn] Directory already contains 'mod.json'.`));
17
17
  return;
18
18
  }
19
19
  // 1. Write minimal mod.json (Notice: NO file list here, auto-scanned!)
@@ -36,15 +36,15 @@ export async function initCommand(targetDirName, options = {}) {
36
36
  * Entry point: src/index.ts
37
37
  */
38
38
 
39
- console.log("[${modName}] Mod yüklendi!");
39
+ console.log("[${modName}] Mod loaded.");
40
40
 
41
- // MooMoo WebSocket paket kancası örneği
41
+ // MooMoo WebSocket packet hook example
42
42
  if (typeof window !== "undefined") {
43
43
  // @ts-ignore
44
44
  window.__myMooModLoaded = true;
45
45
 
46
- // Örnek: Chat veya paket dinleyici
47
- console.log("[${modName}] Hazır.");
46
+ // Example: Chat or packet listener
47
+ console.log("[${modName}] Ready.");
48
48
  }
49
49
  `;
50
50
  fs.writeFileSync(path.join(srcDir, "index.ts"), indexTsContent, "utf-8");
@@ -64,18 +64,18 @@ build/
64
64
  // 4. Create README.md
65
65
  const readmeContent = `# ${modName}
66
66
 
67
- MooMoo.io modu - MooModding.io ile geliştirilmektedir.
67
+ MooMoo.io mod - Built with MooModding.io developer tools.
68
68
 
69
- ## Komutlar
69
+ ## Commands
70
70
 
71
- - \`moo push\`: Mod dosyalarını MooModding bulutuna senkronize eder.
72
- - \`moo dev\`: Canlı izleme modu (her \`Ctrl+S\` kaydedildiğinde anında buluta gönderir).
73
- - \`moo pull\`: Buluttaki en son sürümü yerel dizine çeker.
71
+ - \`moo push\`: Push files to MooModding cloud storage.
72
+ - \`moo dev\`: Start watcher mode (auto-sync on save).
73
+ - \`moo pull\`: Pull latest files from cloud.
74
74
  `;
75
75
  fs.writeFileSync(path.join(dir, "README.md"), readmeContent, "utf-8");
76
- console.log(pc.green(`✅ Mod şablonu başarıyla oluşturuldu!\n`));
77
- console.log(`📁 Dizin: ${pc.cyan(dir)}`);
78
- console.log(`📄 Yapılandırma: ${pc.bold("mod.json")}`);
79
- console.log(`📝 Giriş Dosyası: ${pc.bold("src/index.ts")}`);
80
- console.log(pc.gray(`\nBaşlamak için:\n ${targetDirName ? `cd ${targetDirName}\n ` : ""}moo dev\n`));
76
+ console.log(pc.green(`[success] Mod project scaffolded successfully.`));
77
+ console.log(pc.gray(`Directory: ${dir}`));
78
+ console.log(pc.gray(`Config: mod.json`));
79
+ console.log(pc.gray(`Entry point: src/index.ts`));
80
+ console.log(pc.gray(`Next steps:\n ${targetDirName ? `cd ${targetDirName}\n ` : ""}moo dev\n`));
81
81
  }
@@ -2,33 +2,33 @@ import pc from "picocolors";
2
2
  import { api } from "../core/client.js";
3
3
  export async function listCommand() {
4
4
  try {
5
- console.log(pc.bold(pc.green("\n🐄 MooModding.io — Bulut Modlarınız")));
6
- console.log(pc.gray("Modlar yükleniyor...\n"));
5
+ console.log(pc.bold(pc.cyan("\nMooModding Cloud Mods")));
6
+ console.log(pc.gray("Fetching mod list...\n"));
7
7
  const res = await api.get("/api/developer/mods/list");
8
8
  if (!res.success || !res.mods || res.mods.length === 0) {
9
- console.log(pc.yellow("Henüz kayıtlı bir modunuz bulunmuyor."));
10
- console.log(pc.gray(`Yeni mod başlatmak için: ${pc.cyan("moo init <mod-adi>")}\n`));
9
+ console.log(pc.yellow("[info] You have no saved mods yet."));
10
+ console.log(pc.gray(`Scaffold a new mod: ${pc.cyan("moo init <mod-name>")}\n`));
11
11
  return;
12
12
  }
13
- console.log(pc.bold(` ${"AD / SLUG".padEnd(28)} ${"TÜR".padEnd(14)} ${"BOYUT".padEnd(10)} ${"DURUM".padEnd(10)} ${"SÜRÜM"}`));
13
+ console.log(pc.bold(` ${"NAME".padEnd(28)} ${"TYPE".padEnd(14)} ${"SIZE".padEnd(10)} ${"STATUS".padEnd(10)} ${"VERSION"}`));
14
14
  console.log(pc.gray("─".repeat(70)));
15
15
  for (const m of res.mods) {
16
16
  const kb = (m.storage_size_bytes / 1024).toFixed(1) + " KB";
17
- const status = m.is_active ? pc.green("Aktif") : pc.gray("Pasif");
17
+ const status = m.is_active ? pc.green("active") : pc.gray("inactive");
18
18
  const slug = pc.cyan(m.slug);
19
- const type = m.type === "bundle_replacement" ? "Tam Paket" : "Kanca (Hook)";
19
+ const type = m.type === "bundle_replacement" ? "bundle" : "hook";
20
20
  console.log(` ${m.name.padEnd(28)} ${type.padEnd(14)} ${kb.padEnd(10)} ${status.padEnd(18)} v${m.version || "1.0.0"}`);
21
- console.log(pc.gray(` ↳ Slug: ${slug} (${m.file_count || 1} dosya)`));
21
+ console.log(pc.gray(` ↳ slug: ${slug} (${m.file_count || 1} files)`));
22
22
  }
23
23
  console.log(pc.gray("─".repeat(70)));
24
24
  if (res.quota) {
25
25
  const usedMb = (res.quota.used_bytes / (1024 * 1024)).toFixed(2);
26
26
  const maxMb = (res.quota.max_bytes / (1024 * 1024)).toFixed(0);
27
- console.log(pc.gray(`Toplam Kullanım: ${usedMb} MB / ${maxMb} MB\n`));
27
+ console.log(pc.gray(`Storage Quota: ${usedMb} MB / ${maxMb} MB\n`));
28
28
  }
29
- console.log(pc.gray(`Yerel dizine indirmek için: ${pc.cyan("moo clone <slug>")}\n`));
29
+ console.log(pc.gray(`Clone into local folder: ${pc.cyan("moo clone <slug>")}\n`));
30
30
  }
31
31
  catch (err) {
32
- console.log(pc.red(`❌ Mod listesi alınamadı: ${err.message}`));
32
+ console.log(pc.red(`[error] Failed to list mods: ${err.message}`));
33
33
  }
34
34
  }
@@ -57,39 +57,39 @@ function askQuestion(query, hideInput = false) {
57
57
  }
58
58
  export async function loginCommand(explicitToken) {
59
59
  const apiUrl = getApiUrl();
60
- console.log(pc.bold(pc.green("\n🐄 MooModding.io — Developer CLI Girişi")));
61
- console.log(pc.gray(`Bağlanılan Sunucu: ${apiUrl}\n`));
60
+ console.log(pc.bold(pc.cyan("\nMooModding Developer CLI Login")));
61
+ console.log(pc.gray(`Server: ${apiUrl}\n`));
62
62
  // Case 1: Direct token passed via command line (moo login moo_pat_...)
63
63
  if (explicitToken && explicitToken.trim()) {
64
64
  await verifyAndSaveToken(explicitToken.trim());
65
65
  return;
66
66
  }
67
- console.log(pc.cyan("Giriş yöntemi seçin:"));
68
- console.log(` 1) Kullanıcı Adı ve Şifre ile Hızlı Giriş ${pc.green("(Önerilen)")}`);
69
- console.log(` 2) Kişisel Erişim Belirteci (Personal Access Token) ile Giriş\n`);
70
- const choice = await askQuestion(pc.bold("Seçiminiz (1 veya 2, varsayılan 1): "));
67
+ console.log(pc.cyan("Select authentication method:"));
68
+ console.log(` 1) Username and Password ${pc.green("(Recommended)")}`);
69
+ console.log(` 2) Personal Access Token (PAT)\n`);
70
+ const choice = await askQuestion(pc.bold("Choice (1 or 2, default 1): "));
71
71
  if (choice === "2") {
72
- console.log(pc.yellow(`\nWeb arayüzünden token oluşturun: ${apiUrl}/settings?tab=developer-tokens`));
73
- const token = await askQuestion(pc.bold("Kişisel Erişim Belirtecinizi (PAT) yapıştırın: "));
72
+ console.log(pc.yellow(`\nGenerate token in settings: ${apiUrl}/settings?tab=developer-tokens`));
73
+ const token = await askQuestion(pc.bold("Paste your Personal Access Token: "));
74
74
  if (!token) {
75
- console.log(pc.red("❌ Giriş iptal edildi: Boş token."));
75
+ console.log(pc.red("[error] Login cancelled: Empty token."));
76
76
  process.exit(1);
77
77
  }
78
78
  await verifyAndSaveToken(token);
79
79
  }
80
80
  else {
81
81
  // Direct credential login
82
- const username = await askQuestion(pc.bold("Kullanıcı Adı veya E-posta: "));
82
+ const username = await askQuestion(pc.bold("Username or Email: "));
83
83
  if (!username) {
84
- console.log(pc.red("❌ Kullanıcı adı boş olamaz."));
84
+ console.log(pc.red("[error] Username cannot be empty."));
85
85
  process.exit(1);
86
86
  }
87
- const password = await askQuestion(pc.bold("Şifre: "), true);
87
+ const password = await askQuestion(pc.bold("Password: "), true);
88
88
  if (!password) {
89
- console.log(pc.red("❌ Şifre boş olamaz."));
89
+ console.log(pc.red("[error] Password cannot be empty."));
90
90
  process.exit(1);
91
91
  }
92
- console.log(pc.gray("\nGiriş yapılıyor..."));
92
+ console.log(pc.gray("\nAuthenticating..."));
93
93
  try {
94
94
  const res = await api.post("/api/developer/auth/login", {
95
95
  username,
@@ -98,43 +98,43 @@ export async function loginCommand(explicitToken) {
98
98
  }, { requiresAuth: false });
99
99
  if (res.success && res.token) {
100
100
  setAuth(res.token, res.user);
101
- console.log(pc.green(`\n✅ Başarıyla giriş yapıldı!`));
102
- console.log(`👤 Hoş geldin, ${pc.bold(pc.white(res.user.username))} (${res.user.email})`);
103
- console.log(pc.gray(`\nArtık 'moo init', 'moo clone' veya 'moo dev' komutlarını kullanabilirsiniz.\n`));
101
+ console.log(pc.green(`[success] Successfully authenticated.`));
102
+ console.log(pc.gray(`User: ${res.user.username} (${res.user.email})`));
103
+ console.log(pc.gray(`You can now use 'moo init', 'moo clone', or 'moo dev'.\n`));
104
104
  }
105
105
  else {
106
- console.log(pc.red(`❌ Giriş başarısız: ${res.message || "Bilinmeyen hata"}`));
106
+ console.log(pc.red(`[error] Login failed: ${res.message || "Unknown error"}`));
107
107
  process.exit(1);
108
108
  }
109
109
  }
110
110
  catch (err) {
111
- console.log(pc.red(`❌ Giriş başarısız: ${err.message}`));
111
+ console.log(pc.red(`[error] Login failed: ${err.message}`));
112
112
  process.exit(1);
113
113
  }
114
114
  }
115
115
  }
116
116
  async function verifyAndSaveToken(token) {
117
- console.log(pc.gray("Token doğrulanıyor..."));
117
+ console.log(pc.gray("Verifying token..."));
118
118
  try {
119
119
  setAuth(token);
120
120
  const res = await api.get("/api/developer/whoami");
121
121
  if (res.success && res.user) {
122
122
  setAuth(token, res.user);
123
- console.log(pc.green(`\n✅ Token onaylandı ve kaydedildi!`));
124
- console.log(`👤 Kullanıcı: ${pc.bold(pc.white(res.user.username))} (${res.user.email})`);
123
+ console.log(pc.green(`[success] Token verified and saved.`));
124
+ console.log(pc.gray(`User: ${res.user.username} (${res.user.email})`));
125
125
  if (res.quota) {
126
126
  const usedMb = (res.quota.used_bytes / (1024 * 1024)).toFixed(2);
127
127
  const maxMb = (res.quota.max_bytes / (1024 * 1024)).toFixed(0);
128
- console.log(`💾 Depolama Kotası: ${usedMb} MB / ${maxMb} MB\n`);
128
+ console.log(pc.gray(`Storage Quota: ${usedMb} MB / ${maxMb} MB\n`));
129
129
  }
130
130
  }
131
131
  else {
132
- console.log(pc.red("❌ Token doğrulanamadı."));
132
+ console.log(pc.red("[error] Token verification failed."));
133
133
  process.exit(1);
134
134
  }
135
135
  }
136
136
  catch (err) {
137
- console.log(pc.red(`❌ Hata: ${err.message}`));
137
+ console.log(pc.red(`[error] Verification error: ${err.message}`));
138
138
  process.exit(1);
139
139
  }
140
140
  }
@@ -5,7 +5,7 @@ import { api } from "../core/client.js";
5
5
  export async function pullCommand(rootDir = process.cwd()) {
6
6
  const modConfigPath = path.join(rootDir, "mod.json");
7
7
  if (!fs.existsSync(modConfigPath)) {
8
- console.log(pc.red("❌ 'mod.json' bulunamadı. Lütfen mod kök dizininde çalıştırın."));
8
+ console.log(pc.red("[error] 'mod.json' not found. Please run this command inside a mod root directory."));
9
9
  process.exit(1);
10
10
  }
11
11
  let modConfig;
@@ -13,37 +13,41 @@ export async function pullCommand(rootDir = process.cwd()) {
13
13
  modConfig = JSON.parse(fs.readFileSync(modConfigPath, "utf-8"));
14
14
  }
15
15
  catch {
16
- console.log(pc.red("❌ 'mod.json' dosyası okunamadı."));
16
+ console.log(pc.red("[error] Failed to parse 'mod.json'."));
17
17
  process.exit(1);
18
18
  }
19
19
  const slug = modConfig.slug;
20
20
  if (!slug) {
21
- console.log(pc.red("❌ 'mod.json' içinde 'slug' alanı tanımlı değil."));
21
+ console.log(pc.red("[error] Missing 'slug' field in 'mod.json'."));
22
22
  process.exit(1);
23
23
  }
24
- console.log(pc.gray(`📥 '${slug}' için buluttan en son dosyalar çekiliyor...`));
24
+ console.log(pc.cyan(`[pull] Pulling latest files for '${slug}' from cloud...`));
25
25
  try {
26
26
  const res = await api.get(`/api/developer/mods/${slug}/pull`);
27
27
  if (!res.success || !res.files) {
28
- console.log(pc.red(`❌ Çekme başarısız: ${res.message || "Bilinmeyen hata"}`));
28
+ console.log(pc.red(`[error] Pull failed: ${res.message || "Unknown error"}`));
29
29
  process.exit(1);
30
30
  }
31
31
  let updatedCount = 0;
32
32
  for (const [relPath, content] of Object.entries(res.files)) {
33
33
  if (typeof content !== "string")
34
34
  continue;
35
- const destPath = path.join(rootDir, relPath);
36
- const parent = path.dirname(destPath);
35
+ const resolvedPath = path.resolve(rootDir, relPath);
36
+ if (!resolvedPath.startsWith(rootDir + path.sep) && resolvedPath !== rootDir) {
37
+ console.warn(pc.yellow(`[warn] Security: Skipped invalid path: ${relPath}`));
38
+ continue;
39
+ }
40
+ const parent = path.dirname(resolvedPath);
37
41
  if (!fs.existsSync(parent)) {
38
42
  fs.mkdirSync(parent, { recursive: true });
39
43
  }
40
- fs.writeFileSync(destPath, content, "utf-8");
44
+ fs.writeFileSync(resolvedPath, content, "utf-8");
41
45
  updatedCount++;
42
46
  }
43
- console.log(pc.green(`✅ ${updatedCount} dosya buluttan yerel dizine eşitlendi!\n`));
47
+ console.log(pc.green(`[success] Synced ${updatedCount} files from cloud.\n`));
44
48
  }
45
49
  catch (err) {
46
- console.log(pc.red(`❌ Hata: ${err.message}`));
50
+ console.log(pc.red(`[error] Pull error: ${err.message}`));
47
51
  process.exit(1);
48
52
  }
49
53
  }
@@ -8,8 +8,8 @@ export async function pushCommand(options = {}) {
8
8
  const modConfigPath = path.join(rootDir, "mod.json");
9
9
  if (!fs.existsSync(modConfigPath)) {
10
10
  if (!options.silent) {
11
- console.log(pc.red("❌ 'mod.json' bulunamadı."));
12
- console.log(pc.gray(`Lütfen modun kök dizininde olduğunuzdan emin olun veya yeni başlatmak için: ${pc.cyan("moo init")}`));
11
+ console.log(pc.red("[error] 'mod.json' not found."));
12
+ console.log(pc.gray(`Run 'moo init' to scaffold a new project or navigate to your mod directory.`));
13
13
  }
14
14
  return false;
15
15
  }
@@ -19,17 +19,17 @@ export async function pushCommand(options = {}) {
19
19
  }
20
20
  catch {
21
21
  if (!options.silent) {
22
- console.log(pc.red("❌ 'mod.json' dosyası geçerli bir JSON değil."));
22
+ console.log(pc.red("[error] 'mod.json' is not valid JSON."));
23
23
  }
24
24
  return false;
25
25
  }
26
26
  if (!options.silent) {
27
- console.log(pc.gray(`📦 '${modConfig.name || "Mod"}' dizini taranıyor...`));
27
+ console.log(pc.gray(`[push] Scanning '${modConfig.name || "Mod"}' directory...`));
28
28
  }
29
29
  const { files, fileCount, totalBytes } = scanModDirectory(rootDir);
30
30
  if (fileCount === 0) {
31
31
  if (!options.silent) {
32
- console.log(pc.yellow("⚠️ Senkronize edilecek dosya bulunamadı."));
32
+ console.log(pc.yellow("[warn] No files found to synchronize."));
33
33
  }
34
34
  return false;
35
35
  }
@@ -37,12 +37,12 @@ export async function pushCommand(options = {}) {
37
37
  const totalMb = totalBytes / (1024 * 1024);
38
38
  if (totalMb > 15) {
39
39
  if (!options.silent) {
40
- console.log(pc.red(`❌ Hata: Mod boyutu (${totalMb.toFixed(1)} MB) izin verilen 15 MB sınırını aşıyor!`));
40
+ console.log(pc.red(`[error] Mod size (${totalMb.toFixed(1)} MB) exceeds allowed 15 MB limit.`));
41
41
  }
42
42
  return false;
43
43
  }
44
44
  if (!options.silent) {
45
- console.log(pc.gray(`🚀 ${fileCount} dosya paketlendi (${(totalBytes / 1024).toFixed(1)} KB). Buluta aktarılıyor...`));
45
+ console.log(pc.gray(`[push] Uploading ${fileCount} files (${(totalBytes / 1024).toFixed(1)} KB) to cloud...`));
46
46
  }
47
47
  try {
48
48
  const payload = {
@@ -57,24 +57,24 @@ export async function pushCommand(options = {}) {
57
57
  const res = await api.post("/api/developer/mods/sync", payload);
58
58
  if (res.success) {
59
59
  if (!options.silent) {
60
- console.log(pc.green(`\n✅ '${modConfig.name}' başarıyla senkronize edildi!`));
61
- console.log(`📡 Mod Slug: ${pc.cyan(res.mod.slug)} (${res.mod.size_bytes} bayt)`);
60
+ console.log(pc.green(`[success] Mod '${modConfig.name}' synced successfully.`));
61
+ console.log(pc.gray(`Slug: ${res.mod.slug} (${res.mod.size_bytes} bytes)`));
62
62
  if (res.play_url) {
63
- console.log(`🎮 Oyunda test et: ${pc.bold(pc.white(res.play_url))}\n`);
63
+ console.log(pc.cyan(`Test in-game: ${res.play_url}\n`));
64
64
  }
65
65
  }
66
66
  else {
67
- console.log(pc.green(`[${new Date().toLocaleTimeString()}] ✅ Senkronize edildi: ${modConfig.name}`));
67
+ console.log(pc.green(`[${new Date().toLocaleTimeString()}] [synced] ${modConfig.name}`));
68
68
  }
69
69
  return true;
70
70
  }
71
71
  else {
72
- console.log(pc.red(`❌ Senkronizasyon başarısız: ${res.message || "Bilinmeyen hata"}`));
72
+ console.log(pc.red(`[error] Sync failed: ${res.message || "Unknown error"}`));
73
73
  return false;
74
74
  }
75
75
  }
76
76
  catch (err) {
77
- console.log(pc.red(`❌ Senkronizasyon hatası: ${err.message}`));
77
+ console.log(pc.red(`[error] Sync error: ${err.message}`));
78
78
  return false;
79
79
  }
80
80
  }
@@ -4,27 +4,27 @@ import { api } from "../core/client.js";
4
4
  export async function whoamiCommand() {
5
5
  const config = loadConfig();
6
6
  if (!config.token) {
7
- console.log(pc.yellow("⚠️ Giriş yapılmamış."));
8
- console.log(pc.gray(`Giriş yapmak için: ${pc.cyan("moo login")}`));
7
+ console.log(pc.yellow("[warn] Not authenticated."));
8
+ console.log(pc.gray(`Run: ${pc.cyan("moo login")}`));
9
9
  return;
10
10
  }
11
11
  try {
12
12
  const res = await api.get("/api/developer/whoami");
13
13
  if (res.success && res.user) {
14
- console.log(pc.bold(pc.green("\n🐄 MooModding.io — Oturum Bilgisi")));
15
- console.log(`👤 Kullanıcı Adı : ${pc.bold(pc.white(res.user.username))}`);
16
- console.log(`📧 E-posta : ${res.user.email}`);
17
- console.log(`🌐 Sunucu API : ${getApiUrl()}`);
14
+ console.log(pc.bold(pc.cyan("\nMooModding CLI Account Info")));
15
+ console.log(`Username : ${pc.bold(pc.white(res.user.username))}`);
16
+ console.log(`Email : ${res.user.email}`);
17
+ console.log(`API URL : ${getApiUrl()}`);
18
18
  if (res.quota) {
19
19
  const usedMb = (res.quota.used_bytes / (1024 * 1024)).toFixed(2);
20
20
  const maxMb = (res.quota.max_bytes / (1024 * 1024)).toFixed(0);
21
21
  const percent = ((res.quota.used_bytes / res.quota.max_bytes) * 100).toFixed(1);
22
- console.log(`💾 Depolama : ${usedMb} MB / ${maxMb} MB (%${percent})`);
22
+ console.log(`Storage : ${usedMb} MB / ${maxMb} MB (${percent}%)`);
23
23
  }
24
24
  console.log("");
25
25
  }
26
26
  }
27
27
  catch (err) {
28
- console.log(pc.red(`❌ Kimlik doğrulama başarısız: ${err.message}`));
28
+ console.log(pc.red(`[error] Authentication failed: ${err.message}`));
29
29
  }
30
30
  }