@bepack/cli 0.1.0-beta.2 → 0.1.0-beta.4
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 +12 -3
- package/README.zh-CN.md +12 -3
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +46 -9
- package/dist/index.js +1 -1
- package/package.json +3 -2
- package/reference.md +120 -11
package/README.md
CHANGED
|
@@ -78,7 +78,9 @@ bepack init --from-bp bp/manifest.json
|
|
|
78
78
|
bepack init --from-bp bp/manifest.json --from-rp rp/manifest.json
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
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
|
|
81
|
+
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 becomes a TypeScript build configuration only when a matching source file (`src/<entry>.ts`, `.mts`, `.js` or `.mjs`) actually exists — a pack whose scripts already live inside it keeps compilation disabled instead of generating an entry that would fail the first build. Missing `tsconfig.json` (when a TypeScript source exists) is reported and disables type checking in the generated config.
|
|
82
|
+
|
|
83
|
+
`--dry-run` prints what would be created without writing anything.
|
|
82
84
|
|
|
83
85
|
Useful variations:
|
|
84
86
|
|
|
@@ -160,13 +162,15 @@ bepack build
|
|
|
160
162
|
# Watch files and rebuild during development
|
|
161
163
|
bepack dev
|
|
162
164
|
|
|
163
|
-
# Create a distributable archive
|
|
165
|
+
# Create a distributable archive (builds first)
|
|
164
166
|
bepack pack
|
|
165
167
|
|
|
166
168
|
# Build and package in one command
|
|
167
169
|
bepack build --pack
|
|
168
170
|
```
|
|
169
171
|
|
|
172
|
+
`bepack pack` builds first, so a bare `pack` can never ship stale `scripts/*.js` output; use `bepack pack --no-build` to zip the pack folders exactly as they are on disk.
|
|
173
|
+
|
|
170
174
|
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:
|
|
171
175
|
|
|
172
176
|
```bash
|
|
@@ -178,6 +182,8 @@ bepack build --install --target 1.21.120
|
|
|
178
182
|
|
|
179
183
|
`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.
|
|
180
184
|
|
|
185
|
+
The version written to `manifest.json` comes from, in order: an exact version in your config (`"@minecraft/server": "2.10.0"` — always wins), the version resolved by `bepack install` / `build --install` (online), then the version already stored in the manifest (offline `build` / `dev` / `manifest` never touch the network). Every write is logged — `manifest @minecraft/server: 2.0.0 -> 2.10.0 (specifier "stable", install)` or `... kept from manifest ... — run \`bepack install\` to refresh` — so a stale channel version is never silent again.
|
|
186
|
+
|
|
181
187
|
## Customize the Rolldown build
|
|
182
188
|
|
|
183
189
|
`packs.bp.compile` covers the common cases. When you need the rest of Rolldown (extra plugins, `resolve.alias`, `treeshake`, `sourcemap`, ...), pass your own options inline, through a function, or through a config file:
|
|
@@ -260,6 +266,7 @@ export default defineConfig({
|
|
|
260
266
|
```bash
|
|
261
267
|
bepack pack
|
|
262
268
|
bepack pack --name my-addon-preview
|
|
269
|
+
bepack pack --no-build # zip the pack folders as-is, without building first
|
|
263
270
|
```
|
|
264
271
|
|
|
265
272
|
| Configured packs | Output |
|
|
@@ -268,6 +275,8 @@ bepack pack --name my-addon-preview
|
|
|
268
275
|
| RP only | `.mcpack` |
|
|
269
276
|
| BP and RP | `.mcaddon` |
|
|
270
277
|
|
|
278
|
+
When a pack is packed selectively (always for BP, and for RP once `packs.rp.include` is set), BePack lists the top-level entries the include list leaves out and tells you to add them to `packs.bp.include` / `packs.rp.include` — files such as a `README_中文.md` next to `manifest.json` are no longer dropped silently.
|
|
279
|
+
|
|
271
280
|
### Pack optimization (`__brarchive`)
|
|
272
281
|
|
|
273
282
|
Bedrock 1.26.40 introduced Mojang's **pack optimizer**, which stores a pack's loose files in `__brarchive/` archives. BePack can produce the same layout:
|
|
@@ -303,7 +312,7 @@ copy: { defaultTarget: "minecraft", optimize: true }
|
|
|
303
312
|
| `bepack build` | Patch manifests, type-check with `tsc`, then compile the configured BP source. |
|
|
304
313
|
| `bepack dev` | Build once, then watch and rebuild (type checking on by default). |
|
|
305
314
|
| `bepack copy` | Copy configured packs to a development target. |
|
|
306
|
-
| `bepack pack` |
|
|
315
|
+
| `bepack pack` | Build, then create a `.mcpack` or `.mcaddon` (`--no-build` to skip). |
|
|
307
316
|
| `bepack config --summary` | Inspect the resolved configuration. |
|
|
308
317
|
|
|
309
318
|
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.
|
package/README.zh-CN.md
CHANGED
|
@@ -78,7 +78,9 @@ bepack init --from-bp bp/manifest.json
|
|
|
78
78
|
bepack init --from-bp bp/manifest.json --from-rp rp/manifest.json
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
该命令会根据读取到的包根目录、名称、UUID、版本、manifest 格式和受支持的 Script API 依赖创建 `bepack.config.ts
|
|
81
|
+
该命令会根据读取到的包根目录、名称、UUID、版本、manifest 格式和受支持的 Script API 依赖创建 `bepack.config.ts`。只有当确实存在匹配的源文件(`src/<入口>.ts`、`.mts`、`.js` 或 `.mjs`)时,脚本模块才会生成 TypeScript 构建配置——脚本已经在包里的项目会保持编译关闭,而不是生成一个首次构建就会失败的入口。存在 TypeScript 源码但缺少 `tsconfig.json` 时会给出提示,并在生成的配置里关闭类型检查。
|
|
82
|
+
|
|
83
|
+
`--dry-run` 只打印将要创建的文件,不写盘。
|
|
82
84
|
|
|
83
85
|
常用变体:
|
|
84
86
|
|
|
@@ -160,13 +162,15 @@ bepack build
|
|
|
160
162
|
# 开发时监听文件并自动重建
|
|
161
163
|
bepack dev
|
|
162
164
|
|
|
163
|
-
#
|
|
165
|
+
# 生成发布压缩包(会先构建)
|
|
164
166
|
bepack pack
|
|
165
167
|
|
|
166
168
|
# 一次完成构建和打包
|
|
167
169
|
bepack build --pack
|
|
168
170
|
```
|
|
169
171
|
|
|
172
|
+
`bepack pack` 默认先构建再打包,因此单独执行 `pack` 不会再把旧的 `scripts/*.js` 打进产物;想直接压缩磁盘上的包目录时用 `bepack pack --no-build`。
|
|
173
|
+
|
|
170
174
|
如果只想更新受管理的依赖和 manifest,可单独执行 `bepack install`。可以在配置中设置 `target`,也可以在安装并构建时临时指定目标 Minecraft 版本:
|
|
171
175
|
|
|
172
176
|
```bash
|
|
@@ -178,6 +182,8 @@ bepack build --install --target 1.21.120
|
|
|
178
182
|
|
|
179
183
|
受支持的 `@minecraft/*` 依赖可使用 `stable`、`beta`、`preview` 或精确版本。BePack 会先把如 `stable` 这样的选择器解析为具体包版本,再更新 `package.json` 和 BP manifest。
|
|
180
184
|
|
|
185
|
+
写入 `manifest.json` 的版本按这个优先级决定:配置里的精确版本(`"@minecraft/server": "2.10.0"`,永远优先)→ `bepack install` / `build --install` 联网解析的结果 → manifest 里已有的版本(`build` / `dev` / `manifest` **不联网**,频道说明符离线时复用旧值)。每次写入都会打印来源:`manifest @minecraft/server: 2.0.0 -> 2.10.0 (specifier "stable", install)` 或 `... kept from manifest ... — run \`bepack install\` to refresh`,不会再出现"版本被悄悄写死"的情况。
|
|
186
|
+
|
|
181
187
|
## 自定义 Rolldown 构建
|
|
182
188
|
|
|
183
189
|
`packs.bp.compile` 覆盖了常见场景。需要 Rolldown 的其它能力时(额外插件、`resolve.alias`、`treeshake`、`sourcemap` 等),可以用内联选项、函数或配置文件传入:
|
|
@@ -260,6 +266,7 @@ export default defineConfig({
|
|
|
260
266
|
```bash
|
|
261
267
|
bepack pack
|
|
262
268
|
bepack pack --name my-addon-preview
|
|
269
|
+
bepack pack --no-build # 不构建,直接压缩磁盘上的包目录
|
|
263
270
|
```
|
|
264
271
|
|
|
265
272
|
| 已配置的包 | 输出 |
|
|
@@ -268,6 +275,8 @@ bepack pack --name my-addon-preview
|
|
|
268
275
|
| 仅 RP | `.mcpack` |
|
|
269
276
|
| BP 和 RP | `.mcaddon` |
|
|
270
277
|
|
|
278
|
+
选择性打包时(BP 始终如此,RP 在设置了 `packs.rp.include` 之后如此),BePack 会列出被 include 列表跳过的顶层条目,并提示把它们加到 `packs.bp.include` / `packs.rp.include`——像 `manifest.json` 旁边的 `README_中文.md` 不会再被无声丢弃。
|
|
279
|
+
|
|
271
280
|
### Pack 优化(`__brarchive`)
|
|
272
281
|
|
|
273
282
|
1.26.40 起官方提供 **pack optimizer**:把包里的散文件装进 `__brarchive/` 归档。BePack 可以在打包时生成同样的结构:
|
|
@@ -303,7 +312,7 @@ copy: { defaultTarget: "minecraft", optimize: true }
|
|
|
303
312
|
| `bepack build` | 修补 manifest,用 `tsc` 类型检查,再编译已配置的 BP 源码。 |
|
|
304
313
|
| `bepack dev` | 先构建一次,随后监听并重建(类型检查默认开启)。 |
|
|
305
314
|
| `bepack copy` | 复制已配置的包到开发目标。 |
|
|
306
|
-
| `bepack pack` |
|
|
315
|
+
| `bepack pack` | 先构建,再生成 `.mcpack` 或 `.mcaddon`(`--no-build` 跳过构建)。 |
|
|
307
316
|
| `bepack config --summary` | 查看解析后的配置摘要。 |
|
|
308
317
|
|
|
309
318
|
所有命令都支持 `--cwd <项目目录>` 和 `--config <路径>`,可用于在非项目目录执行或使用不同的配置文件名。对于会写入文件的命令,可添加 `--dry-run` 预览;如需机器可读输出,可添加 `--json`。使用 `bepack <命令> --help` 查看每个命令的全部参数。
|