@bepack/cli 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +254 -0
- package/README.zh-CN.md +254 -0
- package/assets/bepack-logo-horizontal.png +0 -0
- package/dist/cli.js +10 -0
- package/dist/index.d.ts +618 -0
- package/dist/index.js +1 -0
- package/package.json +79 -0
- package/reference.md +822 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 XiaoYangx666
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/bepack-logo-horizontal.png" alt="BePack" width="400" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
A modern build and release toolchain for Minecraft Bedrock add-ons.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@bepack/cli"><img src="https://img.shields.io/npm/v/@bepack/cli.svg?style=flat-square" alt="npm version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@bepack/cli"><img src="https://img.shields.io/npm/dm/@bepack/cli.svg?style=flat-square" alt="npm downloads" /></a>
|
|
12
|
+
<a href="https://github.com/XiaoYangx666/BEPack/blob/main/LICENSE"><img src="https://img.shields.io/github/license/XiaoYangx666/BEPack.svg?style=flat-square" alt="license" /></a>
|
|
13
|
+
<a href="https://github.com/XiaoYangx666/BEPack"><img src="https://img.shields.io/github/stars/XiaoYangx666/BEPack.svg?style=flat-square" alt="GitHub stars" /></a>
|
|
14
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/node/v/@bepack/cli.svg?style=flat-square" alt="Node.js version" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
# BEPack
|
|
18
|
+
|
|
19
|
+
[中文](./README.zh-CN.md) | English
|
|
20
|
+
|
|
21
|
+
BePack is a build tool for Minecraft Bedrock add-ons. It keeps behavior-pack and resource-pack manifests, Script API dependencies, TypeScript builds, local copying, and `.mcpack` / `.mcaddon` releases in one workflow.
|
|
22
|
+
|
|
23
|
+
## What you can do with it
|
|
24
|
+
|
|
25
|
+
- Create a BePack configuration from scratch or import it from existing manifests.
|
|
26
|
+
- Keep `manifest.json` in sync without overwriting fields that BePack does not own.
|
|
27
|
+
- Build a Behavior Pack's TypeScript Script API entry into its `scripts/` directory.
|
|
28
|
+
- Resolve supported `@minecraft/*` dependencies and write their concrete versions to your project.
|
|
29
|
+
- Copy packs into a Minecraft development folder and create release archives.
|
|
30
|
+
|
|
31
|
+
## Requirements
|
|
32
|
+
|
|
33
|
+
- Node.js 20 or later.
|
|
34
|
+
- A Minecraft Bedrock behavior pack, resource pack, or both.
|
|
35
|
+
- `package.json` when you use managed Script API dependencies.
|
|
36
|
+
|
|
37
|
+
## Create a new project
|
|
38
|
+
|
|
39
|
+
For a new behavior-pack project, start with [create-mcbe](https://www.npmjs.com/package/create-mcbe):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm create mcbe
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use create-mcbe's documentation for its prompts and command-line options. You can install BePack globally:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g @bepack/cli
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
You can also install it locally with `npm install -D @bepack/cli`; in that case, use `npx bepack` or package scripts.
|
|
52
|
+
|
|
53
|
+
If you need a fresh BePack configuration, generate one and then edit the generated values to match your project:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bepack init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The starter config contains a BP, a TypeScript entry at `src/main.ts`, and generated UUIDs. Run the first build with dependency installation:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
bepack build --install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Add BePack to an existing project
|
|
66
|
+
|
|
67
|
+
When a project already has a pack manifest, import that manifest instead of re-entering UUIDs and versions by hand:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Behavior pack only
|
|
71
|
+
bepack init --from-bp bp/manifest.json
|
|
72
|
+
|
|
73
|
+
# Behavior pack and resource pack
|
|
74
|
+
bepack init --from-bp bp/manifest.json --from-rp rp/manifest.json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This creates `bepack.config.ts` from the pack roots, names, UUIDs, versions, manifest format, and supported Script API dependencies it finds. A BP script module is also converted into a TypeScript build configuration when possible.
|
|
78
|
+
|
|
79
|
+
Useful variations:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Generate JavaScript or ESM JavaScript config instead of TypeScript
|
|
83
|
+
bepack init --format js
|
|
84
|
+
bepack init --format mjs
|
|
85
|
+
|
|
86
|
+
# Run from outside the project directory
|
|
87
|
+
bepack init --cwd path/to/project --from-bp bp/manifest.json
|
|
88
|
+
|
|
89
|
+
# Replace an existing generated config deliberately
|
|
90
|
+
bepack init --from-bp bp/manifest.json --force
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Minimal configuration
|
|
94
|
+
|
|
95
|
+
BePack loads `bepack.config.ts`, `bepack.config.mjs`, or `bepack.config.js` from the project directory. This is a typical Script API behavior-pack setup:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { defineConfig } from "@bepack/cli";
|
|
99
|
+
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
name: "my-addon",
|
|
102
|
+
version: "1.0.0",
|
|
103
|
+
target: "latest",
|
|
104
|
+
|
|
105
|
+
packs: {
|
|
106
|
+
bp: {
|
|
107
|
+
root: "bp",
|
|
108
|
+
uuid: "<behavior-pack-header-uuid>",
|
|
109
|
+
moduleUuid: "<script-module-uuid>",
|
|
110
|
+
compile: {
|
|
111
|
+
entry: "src/main.ts",
|
|
112
|
+
},
|
|
113
|
+
dependencies: {
|
|
114
|
+
"@minecraft/server": "stable",
|
|
115
|
+
"@minecraft/server-ui": "stable",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
pack: {
|
|
121
|
+
outDir: "dist",
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Generate new UUIDs for a new pack; do not reuse another add-on's UUIDs. For a data-only behavior pack, omit `moduleUuid` and `compile`. For a resource-pack-only project, configure `packs.rp` with its `root`, header `uuid`, and resources `moduleUuid` instead.
|
|
127
|
+
|
|
128
|
+
## Recommended project layout
|
|
129
|
+
|
|
130
|
+
The exact folder names are configurable. This layout matches the example above:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
my-addon/
|
|
134
|
+
├── bepack.config.ts
|
|
135
|
+
├── package.json
|
|
136
|
+
├── tsconfig.json
|
|
137
|
+
├── src/
|
|
138
|
+
│ └── main.ts # TypeScript source entry
|
|
139
|
+
├── bp/
|
|
140
|
+
│ ├── manifest.json
|
|
141
|
+
│ └── scripts/ # generated JavaScript output
|
|
142
|
+
└── dist/ # .mcpack / .mcaddon output
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
When using a resource pack too, add an `rp/` directory and a `packs.rp` entry. BePack maintains the BP/RP manifest relationship when both packs are configured.
|
|
146
|
+
|
|
147
|
+
## Everyday workflow
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Resolve configured Script API dependencies, update manifests, and build
|
|
151
|
+
bepack build --install
|
|
152
|
+
|
|
153
|
+
# Build once after dependencies are already installed
|
|
154
|
+
bepack build
|
|
155
|
+
|
|
156
|
+
# Watch files and rebuild during development
|
|
157
|
+
bepack dev
|
|
158
|
+
|
|
159
|
+
# Create a distributable archive
|
|
160
|
+
bepack pack
|
|
161
|
+
|
|
162
|
+
# Build and package in one command
|
|
163
|
+
bepack build --pack
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Use `bepack install` on its own when you only want to update managed dependencies and manifests. Set `target` in the config, or temporarily override it while installing and building:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
bepack install --target 1.21.120
|
|
170
|
+
bepack build --install --target 1.21.120
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`stable`, `beta`, `preview`, and exact versions can be used for the supported `@minecraft/*` dependency entries. BePack resolves selectors such as `stable` to concrete package versions before updating `package.json` and the BP manifest.
|
|
174
|
+
|
|
175
|
+
## Run in Minecraft during development
|
|
176
|
+
|
|
177
|
+
Configure a copy target once, then add `--copy` to `dev` or `build`:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
export default defineConfig({
|
|
181
|
+
// name, version, and packs omitted
|
|
182
|
+
copy: {
|
|
183
|
+
defaultTarget: "minecraft",
|
|
184
|
+
targets: {
|
|
185
|
+
minecraft: {
|
|
186
|
+
type: "gameRoot",
|
|
187
|
+
path: "C:/Users/you/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
dev: {
|
|
192
|
+
copy: true,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Initial build, then rebuild and copy whenever a watched file changes
|
|
199
|
+
bepack dev
|
|
200
|
+
|
|
201
|
+
# Or copy a completed build once
|
|
202
|
+
bepack build --copy
|
|
203
|
+
bepack copy --target minecraft
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`gameRoot` writes behavior packs to `development_behavior_packs` and resource packs to `development_resource_packs`. You can also use a custom target when your BP and RP need separate destination paths. See the reference guide for the full target syntax.
|
|
207
|
+
|
|
208
|
+
## Package releases
|
|
209
|
+
|
|
210
|
+
Set an output name and directory with `pack`. `{name}` and `{version}` are replaced from the top-level config:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
export default defineConfig({
|
|
214
|
+
// name: "my-addon", version: "1.0.0", packs: ...
|
|
215
|
+
pack: {
|
|
216
|
+
name: "{name}-{version}",
|
|
217
|
+
outDir: "releases",
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
bepack pack
|
|
224
|
+
bepack pack --name my-addon-preview
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
| Configured packs | Output |
|
|
228
|
+
| ---------------- | ---------- |
|
|
229
|
+
| BP only | `.mcpack` |
|
|
230
|
+
| RP only | `.mcpack` |
|
|
231
|
+
| BP and RP | `.mcaddon` |
|
|
232
|
+
|
|
233
|
+
## Commands at a glance
|
|
234
|
+
|
|
235
|
+
| Command | Purpose |
|
|
236
|
+
| ------------------------- | --------------------------------------------------------------------- |
|
|
237
|
+
| `bepack init` | Create a config, or import one with `--from-bp` / `--from-rp`. |
|
|
238
|
+
| `bepack install` | Resolve managed dependencies and update `package.json` and manifests. |
|
|
239
|
+
| `bepack manifest` | Update manifests without running dependency installation. |
|
|
240
|
+
| `bepack build` | Patch manifests and compile the configured BP source. |
|
|
241
|
+
| `bepack dev` | Build once, then watch and rebuild. |
|
|
242
|
+
| `bepack copy` | Copy configured packs to a development target. |
|
|
243
|
+
| `bepack pack` | Create a `.mcpack` or `.mcaddon`. |
|
|
244
|
+
| `bepack config --summary` | Inspect the resolved configuration. |
|
|
245
|
+
|
|
246
|
+
All commands accept `--cwd <project-dir>` and `--config <path>` when the current directory or config filename is different. Add `--dry-run` to preview file-writing commands, or `--json` for machine-readable output. Run `bepack <command> --help` for every command option.
|
|
247
|
+
|
|
248
|
+
## More documentation
|
|
249
|
+
|
|
250
|
+
This README covers the common path: create or import a project, configure packs, build, copy, and package. For complete configuration fields, custom copy targets, inclusion rules, dependency-resolution extensions, plugins, hooks, and replacement tokens, read [the reference guide](./reference.md).
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
MIT
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./assets/bepack-logo-horizontal.png" alt="BePack" width="400" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
Minecraft Bedrock 附加包的现代化构建与发布工具链。
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@bepack/cli"><img src="https://img.shields.io/npm/v/@bepack/cli.svg?style=flat-square" alt="npm version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@bepack/cli"><img src="https://img.shields.io/npm/dm/@bepack/cli.svg?style=flat-square" alt="npm downloads" /></a>
|
|
12
|
+
<a href="https://github.com/XiaoYangx666/BEPack/blob/main/LICENSE"><img src="https://img.shields.io/github/license/XiaoYangx666/BEPack.svg?style=flat-square" alt="license" /></a>
|
|
13
|
+
<a href="https://github.com/XiaoYangx666/BEPack"><img src="https://img.shields.io/github/stars/XiaoYangx666/BEPack.svg?style=flat-square" alt="GitHub stars" /></a>
|
|
14
|
+
<a href="https://nodejs.org"><img src="https://img.shields.io/node/v/@bepack/cli.svg?style=flat-square" alt="Node.js version" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
# BEPack
|
|
18
|
+
|
|
19
|
+
[English](./README.md) | 中文
|
|
20
|
+
|
|
21
|
+
BePack 是 Minecraft 基岩版附加包的构建工具。它将行为包和资源包的 `manifest.json`、Script API 依赖、TypeScript 构建、本地复制,以及 `.mcpack` / `.mcaddon` 发布包整合到同一套工作流中。
|
|
22
|
+
|
|
23
|
+
## 能做什么
|
|
24
|
+
|
|
25
|
+
- 从零创建 BePack 配置,或从已有 manifest 导入配置。
|
|
26
|
+
- 同步 `manifest.json`,同时保留不由 BePack 管理的字段。
|
|
27
|
+
- 将行为包的 TypeScript Script API 入口构建到 `scripts/` 目录。
|
|
28
|
+
- 解析受支持的 `@minecraft/*` 依赖,并将具体版本写入项目。
|
|
29
|
+
- 将包复制到 Minecraft 开发目录,并生成发布压缩包。
|
|
30
|
+
|
|
31
|
+
## 环境要求
|
|
32
|
+
|
|
33
|
+
- Node.js 20 或更高版本。
|
|
34
|
+
- 一个 Minecraft 基岩版行为包、资源包,或两者兼有。
|
|
35
|
+
- 使用受管理的 Script API 依赖时,需要 `package.json`。
|
|
36
|
+
|
|
37
|
+
## 创建新项目
|
|
38
|
+
|
|
39
|
+
创建新的行为包项目时,推荐先使用 [create-mcbe](https://www.npmjs.com/package/create-mcbe):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm create mcbe
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
具体交互选项和命令行参数请查看 create-mcbe 项目文档。可以全局安装 BePack:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g @bepack/cli
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
也可以使用 `npm install -D @bepack/cli` 安装到项目中;此时使用 `npx bepack` 或 package script。
|
|
52
|
+
|
|
53
|
+
如果需要新的 BePack 配置,执行以下命令后再按项目实际情况修改生成的内容:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bepack init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
初始配置会包含一个 BP、位于 `src/main.ts` 的 TypeScript 入口和自动生成的 UUID。首次构建时安装依赖:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
bepack build --install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 接入已有项目
|
|
66
|
+
|
|
67
|
+
已有包的 manifest 时,不必手动重新填写 UUID 和版本号;直接从 manifest 导入配置最快:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# 仅行为包
|
|
71
|
+
bepack init --from-bp bp/manifest.json
|
|
72
|
+
|
|
73
|
+
# 同时有行为包和资源包
|
|
74
|
+
bepack init --from-bp bp/manifest.json --from-rp rp/manifest.json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
该命令会根据读取到的包根目录、名称、UUID、版本、manifest 格式和受支持的 Script API 依赖创建 `bepack.config.ts`。如果 BP 存在脚本模块,也会在可行时生成对应的 TypeScript 构建配置。
|
|
78
|
+
|
|
79
|
+
常用变体:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# 生成 JavaScript 或 ESM JavaScript 配置,而非 TypeScript
|
|
83
|
+
bepack init --format js
|
|
84
|
+
bepack init --format mjs
|
|
85
|
+
|
|
86
|
+
# 在项目目录外执行
|
|
87
|
+
bepack init --cwd path/to/project --from-bp bp/manifest.json
|
|
88
|
+
|
|
89
|
+
# 明确覆盖已有的生成配置
|
|
90
|
+
bepack init --from-bp bp/manifest.json --force
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 最小配置
|
|
94
|
+
|
|
95
|
+
BePack 会从项目目录加载 `bepack.config.ts`、`bepack.config.mjs` 或 `bepack.config.js`。以下是常见的 Script API 行为包配置:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { defineConfig } from "@bepack/cli";
|
|
99
|
+
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
name: "my-addon",
|
|
102
|
+
version: "1.0.0",
|
|
103
|
+
target: "latest",
|
|
104
|
+
|
|
105
|
+
packs: {
|
|
106
|
+
bp: {
|
|
107
|
+
root: "bp",
|
|
108
|
+
uuid: "<behavior-pack-header-uuid>",
|
|
109
|
+
moduleUuid: "<script-module-uuid>",
|
|
110
|
+
compile: {
|
|
111
|
+
entry: "src/main.ts",
|
|
112
|
+
},
|
|
113
|
+
dependencies: {
|
|
114
|
+
"@minecraft/server": "stable",
|
|
115
|
+
"@minecraft/server-ui": "stable",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
pack: {
|
|
121
|
+
outDir: "dist",
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
新包请生成新的 UUID,不要复用其他附加包的 UUID。纯数据行为包可省略 `moduleUuid` 和 `compile`。仅资源包项目则配置 `packs.rp`,并提供它的 `root`、头部 `uuid` 和资源模块 `moduleUuid`。
|
|
127
|
+
|
|
128
|
+
## 推荐目录结构
|
|
129
|
+
|
|
130
|
+
目录名称都可通过配置调整;以下结构对应上面的示例:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
my-addon/
|
|
134
|
+
├── bepack.config.ts
|
|
135
|
+
├── package.json
|
|
136
|
+
├── tsconfig.json
|
|
137
|
+
├── src/
|
|
138
|
+
│ └── main.ts # TypeScript 源码入口
|
|
139
|
+
├── bp/
|
|
140
|
+
│ ├── manifest.json
|
|
141
|
+
│ └── scripts/ # 生成的 JavaScript 输出
|
|
142
|
+
└── dist/ # .mcpack / .mcaddon 输出
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
如需资源包,添加 `rp/` 目录和 `packs.rp` 配置即可。BP 和 RP 同时配置时,BePack 会维护它们在 manifest 中的关联关系。
|
|
146
|
+
|
|
147
|
+
## 日常工作流
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# 解析配置的 Script API 依赖、更新 manifest 并构建
|
|
151
|
+
bepack build --install
|
|
152
|
+
|
|
153
|
+
# 依赖已安装时,只构建一次
|
|
154
|
+
bepack build
|
|
155
|
+
|
|
156
|
+
# 开发时监听文件并自动重建
|
|
157
|
+
bepack dev
|
|
158
|
+
|
|
159
|
+
# 生成发布压缩包
|
|
160
|
+
bepack pack
|
|
161
|
+
|
|
162
|
+
# 一次完成构建和打包
|
|
163
|
+
bepack build --pack
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
如果只想更新受管理的依赖和 manifest,可单独执行 `bepack install`。可以在配置中设置 `target`,也可以在安装并构建时临时指定目标 Minecraft 版本:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
bepack install --target 1.21.120
|
|
170
|
+
bepack build --install --target 1.21.120
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
受支持的 `@minecraft/*` 依赖可使用 `stable`、`beta`、`preview` 或精确版本。BePack 会先把如 `stable` 这样的选择器解析为具体包版本,再更新 `package.json` 和 BP manifest。
|
|
174
|
+
|
|
175
|
+
## 开发时复制到 Minecraft
|
|
176
|
+
|
|
177
|
+
配置一次复制目标,然后在 `dev` 或 `build` 中加 `--copy`:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
export default defineConfig({
|
|
181
|
+
// 此处省略 name、version 和 packs
|
|
182
|
+
copy: {
|
|
183
|
+
defaultTarget: "minecraft",
|
|
184
|
+
targets: {
|
|
185
|
+
minecraft: {
|
|
186
|
+
type: "gameRoot",
|
|
187
|
+
path: "C:/Users/you/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
dev: {
|
|
192
|
+
copy: true,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# 首次构建;之后每次监听到文件变化都会重建并复制
|
|
199
|
+
bepack dev
|
|
200
|
+
|
|
201
|
+
# 或仅复制一次已完成的构建
|
|
202
|
+
bepack build --copy
|
|
203
|
+
bepack copy --target minecraft
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`gameRoot` 会将行为包复制到 `development_behavior_packs`,将资源包复制到 `development_resource_packs`。如果 BP 和 RP 需要不同的目标路径,可使用自定义目标;完整写法请见参考文档。
|
|
207
|
+
|
|
208
|
+
## 打包发布
|
|
209
|
+
|
|
210
|
+
通过 `pack` 设置输出名称和目录。`{name}` 和 `{version}` 会替换为顶层配置中的值:
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
export default defineConfig({
|
|
214
|
+
// name: "my-addon", version: "1.0.0", packs: ...
|
|
215
|
+
pack: {
|
|
216
|
+
name: "{name}-{version}",
|
|
217
|
+
outDir: "releases",
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
bepack pack
|
|
224
|
+
bepack pack --name my-addon-preview
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
| 已配置的包 | 输出 |
|
|
228
|
+
| ---------- | ---------- |
|
|
229
|
+
| 仅 BP | `.mcpack` |
|
|
230
|
+
| 仅 RP | `.mcpack` |
|
|
231
|
+
| BP 和 RP | `.mcaddon` |
|
|
232
|
+
|
|
233
|
+
## 命令速查
|
|
234
|
+
|
|
235
|
+
| 命令 | 用途 |
|
|
236
|
+
| ------------------------- | ----------------------------------------------------- |
|
|
237
|
+
| `bepack init` | 创建配置,或用 `--from-bp` / `--from-rp` 导入配置。 |
|
|
238
|
+
| `bepack install` | 解析受管理的依赖,并更新 `package.json` 和 manifest。 |
|
|
239
|
+
| `bepack manifest` | 不安装依赖,仅更新 manifest。 |
|
|
240
|
+
| `bepack build` | 修补 manifest 并编译已配置的 BP 源码。 |
|
|
241
|
+
| `bepack dev` | 先构建一次,随后监听并重建。 |
|
|
242
|
+
| `bepack copy` | 复制已配置的包到开发目标。 |
|
|
243
|
+
| `bepack pack` | 生成 `.mcpack` 或 `.mcaddon`。 |
|
|
244
|
+
| `bepack config --summary` | 查看解析后的配置摘要。 |
|
|
245
|
+
|
|
246
|
+
所有命令都支持 `--cwd <项目目录>` 和 `--config <路径>`,可用于在非项目目录执行或使用不同的配置文件名。对于会写入文件的命令,可添加 `--dry-run` 预览;如需机器可读输出,可添加 `--json`。使用 `bepack <命令> --help` 查看每个命令的全部参数。
|
|
247
|
+
|
|
248
|
+
## 更多文档
|
|
249
|
+
|
|
250
|
+
本 README 覆盖最常见的路径:创建或导入项目、配置包、构建、复制与打包。完整配置字段、自定义复制目标、包含规则、依赖解析扩展、插件、Hook 和替换标记请阅读 [参考文档](./reference.md)。
|
|
251
|
+
|
|
252
|
+
## 许可证
|
|
253
|
+
|
|
254
|
+
MIT
|
|
Binary file
|