moomodding 1.0.2 → 1.1.0

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/dist/cli.js CHANGED
@@ -8,12 +8,13 @@ import { cloneCommand } from "./commands/clone.js";
8
8
  import { pushCommand } from "./commands/push.js";
9
9
  import { pullCommand } from "./commands/pull.js";
10
10
  import { devCommand } from "./commands/dev.js";
11
+ import { publishCommand } from "./commands/publish.js";
11
12
  import { clearAuth, loadConfig, saveConfig } from "./core/config.js";
12
13
  const program = new Command();
13
14
  program
14
15
  .name("moo")
15
16
  .description("MooModding Developer CLI — Build, test, and sync MooMoo.io mods with zero friction.")
16
- .version("1.0.2");
17
+ .version("1.1.0");
17
18
  // 1. Auth Commands
18
19
  program
19
20
  .command("login [token]")
@@ -39,7 +40,10 @@ program
39
40
  .command("init [dir]")
40
41
  .description("Scaffold a new MooMoo mod project")
41
42
  .option("-n, --name <name>", "Mod display name")
42
- .option("-t, --type <type>", "Mod type ('hook' or 'bundle_replacement')", "hook")
43
+ .option("-t, --type <type>", "Mod type ('hook', 'bundle_replacement', or 'html_replacement')", "hook")
44
+ .option("-c, --community", "Scaffold as open-source community mod")
45
+ .option("-d, --description <desc>", "Mod description for community showcase")
46
+ .option("-v, --version <version>", "Initial mod version", "1.0.0")
43
47
  .action(async (dir, options) => {
44
48
  await initCommand(dir, options);
45
49
  });
@@ -51,10 +55,10 @@ program
51
55
  await listCommand();
52
56
  });
53
57
  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
+ .command("clone <target> [dir]")
59
+ .description("Clone a cloud mod or inspect community mod (@author/slug)")
60
+ .action(async (target, dir) => {
61
+ await cloneCommand(target, dir);
58
62
  });
59
63
  program
60
64
  .command("push")
@@ -74,6 +78,19 @@ program
74
78
  .action(() => {
75
79
  devCommand();
76
80
  });
81
+ program
82
+ .command("publish [version]")
83
+ .description("Publish a release version to the Community Gallery (e.g. moo publish patch, moo publish 1.2.0)")
84
+ .option("-m, --message <changelog>", "Release changelog notes")
85
+ .option("--changelog <changelog>", "Release changelog notes")
86
+ .option("--status <status>", "Visibility status ('active', 'unlisted', 'archived')", "active")
87
+ .option("-d, --description <desc>", "Update mod description")
88
+ .option("--desc <desc>", "Update mod description")
89
+ .option("--youtube <url>", "YouTube showcase or tutorial video URL")
90
+ .option("-y, --yes", "Skip confirmation prompt")
91
+ .action(async (version, options) => {
92
+ await publishCommand(version, options);
93
+ });
77
94
  // 3. Configuration command
78
95
  program
79
96
  .command("config <action> [key] [value]")
@@ -4,36 +4,101 @@ 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("[error] Mod slug is required."));
8
- console.log(pc.gray(`Example: ${pc.cyan("moo clone elite-combat-suite")}`));
7
+ console.log(pc.red("[error] Mod identifier is required."));
8
+ console.log(pc.gray(`Examples:`));
9
+ console.log(pc.gray(` moo clone my-private-mod`));
10
+ console.log(pc.gray(` moo clone @author/community-slug`));
9
11
  process.exit(1);
10
12
  }
11
- const cleanSlug = modSlug.trim().toLowerCase();
12
- const destDir = path.resolve(process.cwd(), targetDirName || cleanSlug);
13
- console.log(pc.cyan(`[clone] Downloading '${cleanSlug}'...`));
13
+ const rawInput = modSlug.trim();
14
+ let isCommunity = false;
15
+ let author = "";
16
+ let slug = "";
17
+ if (rawInput.startsWith("community:")) {
18
+ const parts = rawInput.replace(/^community:/, "").split("/");
19
+ author = parts[0];
20
+ slug = parts[1] || "";
21
+ isCommunity = true;
22
+ }
23
+ else if (rawInput.startsWith("@")) {
24
+ const parts = rawInput.replace(/^@/, "").split("/");
25
+ author = parts[0];
26
+ slug = parts[1] || "";
27
+ isCommunity = true;
28
+ }
29
+ else if (rawInput.includes("/")) {
30
+ const parts = rawInput.split("/");
31
+ author = parts[0];
32
+ slug = parts[1] || "";
33
+ isCommunity = true;
34
+ }
35
+ else {
36
+ slug = rawInput.toLowerCase();
37
+ }
38
+ if (isCommunity && (!author || !slug)) {
39
+ console.log(pc.red("[error] Invalid community mod format. Use: @author/slug or community:author/slug"));
40
+ process.exit(1);
41
+ }
42
+ const destDir = path.resolve(process.cwd(), targetDirName || slug);
43
+ if (isCommunity) {
44
+ console.log(pc.cyan(`[clone] Inspecting community mod '@${author}/${slug}'...`));
45
+ }
46
+ else {
47
+ console.log(pc.cyan(`[clone] Downloading personal cloud mod '${slug}'...`));
48
+ }
14
49
  console.log(pc.gray(`Destination: ${destDir}`));
15
50
  try {
16
- const res = await api.get(`/api/developer/mods/${cleanSlug}/pull`);
17
- if (!res.success || !res.files) {
18
- console.log(pc.red(`[error] Failed to clone mod: ${res.message || "Unknown error"}`));
19
- process.exit(1);
51
+ let files = {};
52
+ let modInfo = {};
53
+ if (isCommunity) {
54
+ // Fetch open-source code from public community endpoint
55
+ const res = await api.get(`/api/community-mods/${encodeURIComponent(author)}/${encodeURIComponent(slug)}/inspect-code`, {
56
+ requiresAuth: false
57
+ });
58
+ if (!res.success || !res.files) {
59
+ console.log(pc.red(`[error] Failed to fetch community mod: ${res.message || "Mod not found"}`));
60
+ process.exit(1);
61
+ }
62
+ files = res.files;
63
+ modInfo = {
64
+ name: slug.replace(/-/g, " ").replace(/\b\w/g, c => c.toUpperCase()),
65
+ slug: slug,
66
+ type: "hook",
67
+ version: "1.0.0",
68
+ entry_point: Object.keys(files).includes("src/index.ts") ? "src/index.ts" : Object.keys(files)[0] || "src/index.ts",
69
+ is_active: true,
70
+ community: true,
71
+ forked_from: `@${author}/${slug}`
72
+ };
73
+ }
74
+ else {
75
+ // Fetch personal cloud mod from developer API
76
+ const res = await api.get(`/api/developer/mods/${slug}/pull`);
77
+ if (!res.success || !res.files) {
78
+ console.log(pc.red(`[error] Failed to clone cloud mod: ${res.message || "Unknown error"}`));
79
+ process.exit(1);
80
+ }
81
+ files = res.files;
82
+ modInfo = res.mod;
20
83
  }
21
84
  if (!fs.existsSync(destDir)) {
22
85
  fs.mkdirSync(destDir, { recursive: true });
23
86
  }
24
87
  // 1. Write mod.json
25
88
  const modJson = {
26
- name: res.mod.name,
27
- slug: res.mod.slug,
28
- type: res.mod.type || "hook",
29
- version: res.mod.version || "1.0.0",
30
- entry: res.mod.entry_point || "src/index.ts",
31
- is_active: res.mod.is_active ?? true
89
+ name: modInfo.name,
90
+ slug: modInfo.slug,
91
+ type: modInfo.type || "hook",
92
+ version: modInfo.version || "1.0.0",
93
+ entry: modInfo.entry_point || "src/index.ts",
94
+ is_active: modInfo.is_active ?? true,
95
+ community: modInfo.community ?? false,
96
+ forked_from: modInfo.forked_from || undefined
32
97
  };
33
98
  fs.writeFileSync(path.join(destDir, "mod.json"), JSON.stringify(modJson, null, 2), "utf-8");
34
99
  // 2. Write all files and recreate directories (with Path Traversal protection)
35
100
  let writtenCount = 0;
36
- for (const [relPath, content] of Object.entries(res.files)) {
101
+ for (const [relPath, content] of Object.entries(files)) {
37
102
  if (typeof content !== "string")
38
103
  continue;
39
104
  const resolvedPath = path.resolve(destDir, relPath);
@@ -53,7 +118,10 @@ export async function cloneCommand(modSlug, targetDirName) {
53
118
  if (!fs.existsSync(mooIgnorePath)) {
54
119
  fs.writeFileSync(mooIgnorePath, `node_modules/\n.git/\n.vscode/\n.idea/\ndist/\nbuild/\n*.log\n.env\n.DS_Store\n`, "utf-8");
55
120
  }
56
- console.log(pc.green(`[success] Cloned '${res.mod.name}' successfully.`));
121
+ console.log(pc.green(`[success] Cloned '${modInfo.name}' successfully.`));
122
+ if (modInfo.forked_from) {
123
+ console.log(pc.magenta(`Forked from: ${modInfo.forked_from}`));
124
+ }
57
125
  console.log(pc.gray(`Files written: ${writtenCount}`));
58
126
  console.log(pc.gray(`Next steps:\n cd ${path.basename(destDir)}\n moo dev\n`));
59
127
  }
@@ -1,6 +1,9 @@
1
1
  export interface InitOptions {
2
2
  name?: string;
3
- type?: "hook" | "bundle_replacement";
3
+ type?: "hook" | "bundle_replacement" | "html_replacement";
4
+ version?: string;
5
+ community?: boolean;
6
+ description?: string;
4
7
  template?: string;
5
8
  }
6
9
  export declare function initCommand(targetDirName?: string, options?: InitOptions): Promise<void>;
@@ -7,7 +7,11 @@ 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.cyan(`[init] Initializing mod project: ${modName}`));
10
+ const isCommunity = Boolean(options.community);
11
+ console.log(pc.cyan(`[init] Initializing mod project: ${modName} (${modType})`));
12
+ if (isCommunity) {
13
+ console.log(pc.magenta(`[community] Open-Source Community project mode enabled.`));
14
+ }
11
15
  if (!fs.existsSync(dir)) {
12
16
  fs.mkdirSync(dir, { recursive: true });
13
17
  }
@@ -16,21 +20,47 @@ export async function initCommand(targetDirName, options = {}) {
16
20
  console.log(pc.yellow(`[warn] Directory already contains 'mod.json'.`));
17
21
  return;
18
22
  }
19
- // 1. Write minimal mod.json (Notice: NO file list here, auto-scanned!)
23
+ const entryPoint = modType === "html_replacement" ? "src/index.html" : "src/index.ts";
24
+ // 1. Write mod.json
20
25
  const modConfig = {
21
26
  name: modName,
22
27
  slug: cleanSlug,
23
28
  type: modType,
24
- version: "1.0.0",
25
- entry: "src/index.ts"
29
+ version: options.version || "1.0.0",
30
+ entry: entryPoint,
31
+ community: isCommunity,
32
+ description: options.description || `${modName} - Built with MooModding Developer CLI`,
33
+ status: "active"
26
34
  };
27
35
  fs.writeFileSync(modJsonPath, JSON.stringify(modConfig, null, 2), "utf-8");
28
- // 2. Create src folder and src/index.ts
36
+ // 2. Create src folder and entry files
29
37
  const srcDir = path.join(dir, "src");
30
38
  if (!fs.existsSync(srcDir)) {
31
39
  fs.mkdirSync(srcDir, { recursive: true });
32
40
  }
33
- const indexTsContent = `/**
41
+ if (modType === "html_replacement") {
42
+ const indexHtmlContent = `<!DOCTYPE html>
43
+ <html>
44
+ <head>
45
+ <meta charset="utf-8">
46
+ <title>${modName}</title>
47
+ <style>
48
+ body { margin: 0; background: #0b0e14; color: #fff; font-family: sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; }
49
+ .card { padding: 24px; border: 1px solid #7ee559; border-radius: 8px; text-align: center; }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <div class="card">
54
+ <h1>${modName}</h1>
55
+ <p>Custom HTML Client Replacement active.</p>
56
+ </div>
57
+ </body>
58
+ </html>
59
+ `;
60
+ fs.writeFileSync(path.join(srcDir, "index.html"), indexHtmlContent, "utf-8");
61
+ }
62
+ else {
63
+ const indexTsContent = `/**
34
64
  * ${modName}
35
65
  * Created with MooModding Developer CLI
36
66
  * Entry point: src/index.ts
@@ -47,7 +77,8 @@ if (typeof window !== "undefined") {
47
77
  console.log("[${modName}] Ready.");
48
78
  }
49
79
  `;
50
- fs.writeFileSync(path.join(srcDir, "index.ts"), indexTsContent, "utf-8");
80
+ fs.writeFileSync(path.join(srcDir, "index.ts"), indexTsContent, "utf-8");
81
+ }
51
82
  // 3. Create .mooignore
52
83
  const mooIgnoreContent = `# MooModding CLI Ignore List
53
84
  node_modules/
@@ -68,14 +99,15 @@ MooMoo.io mod - Built with MooModding.io developer tools.
68
99
 
69
100
  ## Commands
70
101
 
71
- - \`moo push\`: Push files to MooModding cloud storage.
72
102
  - \`moo dev\`: Start watcher mode (auto-sync on save).
103
+ - \`moo push\`: Push files to MooModding cloud workspace.
73
104
  - \`moo pull\`: Pull latest files from cloud.
105
+ ${isCommunity ? "- `moo publish [patch|minor|major]`: Publish release to Community Gallery.\n" : ""}
74
106
  `;
75
107
  fs.writeFileSync(path.join(dir, "README.md"), readmeContent, "utf-8");
76
108
  console.log(pc.green(`[success] Mod project scaffolded successfully.`));
77
109
  console.log(pc.gray(`Directory: ${dir}`));
78
110
  console.log(pc.gray(`Config: mod.json`));
79
- console.log(pc.gray(`Entry point: src/index.ts`));
111
+ console.log(pc.gray(`Entry point: ${entryPoint}`));
80
112
  console.log(pc.gray(`Next steps:\n ${targetDirName ? `cd ${targetDirName}\n ` : ""}moo dev\n`));
81
113
  }
@@ -0,0 +1,11 @@
1
+ export interface PublishOptions {
2
+ changelog?: string;
3
+ message?: string;
4
+ status?: "active" | "unlisted" | "archived";
5
+ description?: string;
6
+ desc?: string;
7
+ youtube?: string;
8
+ yes?: boolean;
9
+ rootDir?: string;
10
+ }
11
+ export declare function publishCommand(versionArg?: string, options?: PublishOptions): Promise<boolean>;
@@ -0,0 +1,144 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import readline from "readline";
4
+ import pc from "picocolors";
5
+ import { scanModDirectory } from "../core/scanner.js";
6
+ import { api } from "../core/client.js";
7
+ /**
8
+ * Calculates incremented semver given a base version and bump type.
9
+ */
10
+ function bumpSemver(version, type) {
11
+ const cleanVer = version.replace(/^v/, "");
12
+ const parts = cleanVer.split(".").map(p => parseInt(p, 10) || 0);
13
+ while (parts.length < 3)
14
+ parts.push(0);
15
+ let [major, minor, patch] = parts;
16
+ if (type === "major") {
17
+ major++;
18
+ minor = 0;
19
+ patch = 0;
20
+ }
21
+ else if (type === "minor") {
22
+ minor++;
23
+ patch = 0;
24
+ }
25
+ else {
26
+ patch++;
27
+ }
28
+ return `${major}.${minor}.${patch}`;
29
+ }
30
+ function promptConfirm(question) {
31
+ const rl = readline.createInterface({
32
+ input: process.stdin,
33
+ output: process.stdout
34
+ });
35
+ return new Promise(resolve => {
36
+ rl.question(question, answer => {
37
+ rl.close();
38
+ const normalized = answer.trim().toLowerCase();
39
+ resolve(normalized === "y" || normalized === "yes" || normalized === "");
40
+ });
41
+ });
42
+ }
43
+ export async function publishCommand(versionArg, options = {}) {
44
+ const rootDir = options.rootDir || process.cwd();
45
+ const modConfigPath = path.join(rootDir, "mod.json");
46
+ if (!fs.existsSync(modConfigPath)) {
47
+ console.log(pc.red("[error] 'mod.json' not found."));
48
+ console.log(pc.gray(`Run 'moo init' to scaffold a project or navigate to your mod directory.`));
49
+ return false;
50
+ }
51
+ let modConfig;
52
+ try {
53
+ modConfig = JSON.parse(fs.readFileSync(modConfigPath, "utf-8"));
54
+ }
55
+ catch {
56
+ console.log(pc.red("[error] 'mod.json' is not valid JSON."));
57
+ return false;
58
+ }
59
+ const currentVersion = (modConfig.version || "1.0.0").trim();
60
+ let targetVersion = currentVersion;
61
+ if (versionArg) {
62
+ const lowerArg = versionArg.toLowerCase();
63
+ if (lowerArg === "patch" || lowerArg === "minor" || lowerArg === "major") {
64
+ targetVersion = bumpSemver(currentVersion, lowerArg);
65
+ }
66
+ else {
67
+ targetVersion = versionArg.replace(/^v/, "");
68
+ }
69
+ }
70
+ // Validate semver format
71
+ if (!/^[0-9]+\.[0-9]+(\.[0-9]+)?(-[a-zA-Z0-9.]+)?$/.test(targetVersion)) {
72
+ console.log(pc.red(`[error] Invalid semver version: '${targetVersion}'. Use format like 1.0.0 or bump keyword (patch, minor, major).`));
73
+ return false;
74
+ }
75
+ const modName = modConfig.name || path.basename(rootDir);
76
+ const modSlug = modConfig.slug || path.basename(rootDir).toLowerCase().replace(/[^a-z0-9_-]/g, "-");
77
+ const changelog = (options.message || options.changelog || `Release v${targetVersion} via CLI`).trim();
78
+ const status = options.status || modConfig.status || "active";
79
+ const description = options.desc || options.description || modConfig.description || "";
80
+ const youtube = options.youtube || modConfig.youtube_url || null;
81
+ console.log(pc.cyan(`[publish] Preparing release for '${modName}'...`));
82
+ console.log(pc.gray(`Current version: v${currentVersion}`));
83
+ console.log(pc.yellow(`Release version: v${targetVersion}`));
84
+ console.log(pc.gray(`Status: ${status}`));
85
+ console.log(pc.gray(`Changelog: ${changelog}`));
86
+ // Scan files
87
+ const { files, fileCount, totalBytes } = scanModDirectory(rootDir);
88
+ if (fileCount === 0) {
89
+ console.log(pc.red("[error] No source files found to publish."));
90
+ return false;
91
+ }
92
+ const totalMb = totalBytes / (1024 * 1024);
93
+ if (totalMb > 15) {
94
+ console.log(pc.red(`[error] Release payload (${totalMb.toFixed(1)} MB) exceeds 15 MB limit.`));
95
+ return false;
96
+ }
97
+ console.log(pc.gray(`Scanning complete: ${fileCount} files (${(totalBytes / 1024).toFixed(1)} KB)`));
98
+ if (!options.yes) {
99
+ const confirmed = await promptConfirm(`Publish "${modName}" v${targetVersion} to Community Gallery? [Y/n]: `);
100
+ if (!confirmed) {
101
+ console.log(pc.gray("[cancelled] Publish aborted by user."));
102
+ return false;
103
+ }
104
+ }
105
+ console.log(pc.cyan(`[publish] Uploading release package to MooModding repository...`));
106
+ try {
107
+ const payload = {
108
+ name: modName,
109
+ slug: modSlug,
110
+ version: targetVersion,
111
+ changelog: changelog,
112
+ description: description,
113
+ type: modConfig.type || "hook",
114
+ entry_point: modConfig.entry || "src/index.ts",
115
+ status: status,
116
+ youtube_url: youtube,
117
+ files: files
118
+ };
119
+ const res = await api.post("/api/developer/mods/publish", payload);
120
+ if (res.success && res.release) {
121
+ // Update mod.json with the published version and status
122
+ modConfig.version = targetVersion;
123
+ modConfig.community = true;
124
+ if (description)
125
+ modConfig.description = description;
126
+ if (status)
127
+ modConfig.status = status;
128
+ fs.writeFileSync(modConfigPath, JSON.stringify(modConfig, null, 2), "utf-8");
129
+ console.log(pc.green(`\n[success] v${targetVersion} published successfully to Community Gallery!`));
130
+ console.log(pc.gray(`Author: @${res.release.author}`));
131
+ console.log(pc.gray(`Status: ${res.release.status}`));
132
+ console.log(pc.cyan(`Web URL: ${res.release.web_url}\n`));
133
+ return true;
134
+ }
135
+ else {
136
+ console.log(pc.red(`[error] Publish failed: ${res.message || "Unknown error"}`));
137
+ return false;
138
+ }
139
+ }
140
+ catch (err) {
141
+ console.log(pc.red(`[error] Publish request failed: ${err.message}`));
142
+ return false;
143
+ }
144
+ }
package/dist/data/hats.js CHANGED
@@ -98,6 +98,13 @@ export const hats = [
98
98
  "scale": 120,
99
99
  "desc": "like and subscribe"
100
100
  },
101
+ {
102
+ "id": 59,
103
+ "name": "Megalodon Hat",
104
+ "price": 0,
105
+ "scale": 120,
106
+ "desc": "when make chicken v5, me fan"
107
+ },
101
108
  {
102
109
  "id": 57,
103
110
  "name": "Pumpkin",
package/dist/moo.umd.js CHANGED
@@ -117,6 +117,13 @@
117
117
  "scale": 120,
118
118
  "desc": "like and subscribe"
119
119
  },
120
+ {
121
+ "id": 59,
122
+ "name": "Megalodon Hat",
123
+ "price": 0,
124
+ "scale": 120,
125
+ "desc": "when make chicken v5, me fan"
126
+ },
120
127
  {
121
128
  "id": 57,
122
129
  "name": "Pumpkin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moomodding",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Official MooModding.io Developer CLI & Game SDK - Build, test, and sync MooMoo.io mods seamlessly.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",