@mafly/bdev-cli 0.1.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/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # bdev
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@mafly/bdev-cli.svg)](https://www.npmjs.com/package/@mafly/bdev-cli)
4
+ [![license](https://img.shields.io/github/license/Nekoplii/bdev.svg)](./LICENSE)
5
+
3
6
  A simple CLI tool for Minecraft Bedrock Edition addon development.
4
7
 
5
8
  ---
package/dist/index.js CHANGED
@@ -6,11 +6,12 @@ import { devCommand } from "./commands/dev.js";
6
6
  import { packageCommand } from "./commands/package.js";
7
7
  import { doctorCommand } from "./commands/doctor.js";
8
8
  import { setConfigCommand, getConfigCommand, setPathCommand, } from "./commands/config.js";
9
+ import { getVersion } from "./utils/version.js";
9
10
  const program = new Command();
10
11
  program
11
12
  .name("bdev")
12
13
  .description("Modern CLI tool for Minecraft Bedrock Edition Addon development")
13
- .version("0.1.0");
14
+ .version(getVersion());
14
15
  program
15
16
  .command("init [directory]")
16
17
  .description("Scaffold a new Bedrock addon project")
@@ -0,0 +1 @@
1
+ export declare function getVersion(): string;
@@ -0,0 +1,23 @@
1
+ import fs from "node:fs";
2
+ export function getVersion() {
3
+ if (typeof __BDEV_VERSION__ !== "undefined") {
4
+ return __BDEV_VERSION__;
5
+ }
6
+ if (process.env.BDEV_VERSION) {
7
+ return process.env.BDEV_VERSION;
8
+ }
9
+ try {
10
+ const pkgUrl = new URL("../../package.json", import.meta.url);
11
+ if (fs.existsSync(pkgUrl)) {
12
+ const raw = fs.readFileSync(pkgUrl, "utf-8");
13
+ const pkg = JSON.parse(raw);
14
+ if (pkg.version) {
15
+ return pkg.version;
16
+ }
17
+ }
18
+ }
19
+ catch {
20
+ // Fallback
21
+ }
22
+ return "0.0.0-dev";
23
+ }
@@ -2,11 +2,15 @@ export interface BedrockCommandRequest {
2
2
  header: {
3
3
  version: number;
4
4
  requestId: string;
5
+ messageType: "commandRequest";
5
6
  messagePurpose: "commandRequest";
6
7
  };
7
8
  body: {
8
- commandLine: string;
9
9
  version: number;
10
+ commandLine: string;
11
+ origin: {
12
+ type: "player";
13
+ };
10
14
  };
11
15
  }
12
16
  export declare class BedrockHotReloadServer {
@@ -35,13 +35,17 @@ export class BedrockHotReloadServer {
35
35
  server.on("connection", (socket) => {
36
36
  this.clients.add(socket);
37
37
  logger.success(pc.green("Minecraft connected to WebSocket hot reload!"));
38
- // Send welcome message in Minecraft chat
39
- this.sendCommandToSocket(socket, 'tellraw @a {"rawtext":[{"text":"§a[bdev] Connected to hot reload server!"}]}');
38
+ // Delay welcome message 500ms so Bedrock completes internal handshake
39
+ setTimeout(() => {
40
+ if (socket.readyState === WebSocket.OPEN) {
41
+ this.sendCommandToSocket(socket, 'tellraw @a {"rawtext":[{"text":"§a[bdev] Connected to hot reload server!"}]}');
42
+ }
43
+ }, 500);
40
44
  socket.on("message", (data) => {
41
45
  try {
42
46
  const res = JSON.parse(data.toString());
43
47
  if (res?.body?.statusCode && res.body.statusCode !== 0) {
44
- logger.warn(`Minecraft command warning: ${res.body.statusMessage || "Error"}`);
48
+ logger.warn(`Minecraft command response: ${res.body.statusMessage || "Error"}`);
45
49
  }
46
50
  }
47
51
  catch {
@@ -65,15 +69,20 @@ export class BedrockHotReloadServer {
65
69
  }
66
70
  }
67
71
  sendCommandToSocket(socket, commandLine) {
72
+ const formatted = commandLine.startsWith("/") ? commandLine : `/${commandLine}`;
68
73
  const payload = {
69
74
  header: {
70
75
  version: 1,
71
76
  requestId: uuidv4(),
77
+ messageType: "commandRequest",
72
78
  messagePurpose: "commandRequest",
73
79
  },
74
80
  body: {
75
- commandLine,
76
81
  version: 1,
82
+ commandLine: formatted,
83
+ origin: {
84
+ type: "player",
85
+ },
77
86
  },
78
87
  };
79
88
  socket.send(JSON.stringify(payload));
@@ -84,7 +93,7 @@ export class BedrockHotReloadServer {
84
93
  }
85
94
  // Notify in game chat and execute reload command
86
95
  this.sendCommand('tellraw @a {"rawtext":[{"text":"§e[bdev] Reloading scripts..."}]}');
87
- this.sendCommand("reload");
96
+ this.sendCommand("/reload");
88
97
  }
89
98
  get clientCount() {
90
99
  return this.clients.size;
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@mafly/bdev-cli",
3
- "version": "0.1.0",
3
+ "version": "1.0.2",
4
4
  "description": "Modern CLI tool for Minecraft Bedrock Edition Addon development",
5
5
  "author": "Mafly",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Nekoplii/bdev.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/Nekoplii/bdev/issues"
13
+ },
14
+ "homepage": "https://github.com/Nekoplii/bdev#readme",
7
15
  "publishConfig": {
8
16
  "access": "public"
9
17
  },