Core - Scaffold Module
anvil.lib.scaffold
The files anvil init and the build write next to a project's code: the npm, TypeScript,
esbuild, VS Code and GitHub workflow files, the Python entry point and .gitignore. JSON
files are returned as dicts, the others as text.
code_workspace(name, path, preview=False, dev_res_path=None, dev_beh_path=None)
The project's VS Code workspace: the project folder and the development pack folders of Minecraft and Minecraft Preview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the project folder in the workspace. |
required |
path
|
str | Path
|
The project folder. |
required |
preview
|
bool
|
Whether the development packs are Minecraft Preview's. |
False
|
dev_res_path
|
str | Path
|
The development resource packs folder, when it is not the game's. |
None
|
dev_beh_path
|
str | Path
|
The development behavior packs folder, when it is not the game's. |
None
|
esbuild_js()
The esbuild.js that bundles the TypeScript scripts. It reads minify and
scriptui from anvilconfig.json and takes the output folder as --outdir=.
github_workflows(project_name)
The GitHub Actions files that build and release the project when its version changes, by their path in the project.
release.yml runs one focused workflow per job: anvil-version.yml detects a new
version, anvil-package.yml builds the brarchive .mcaddon or .mcworld,
anvil-marketplace-zip.yml builds the Marketplace zip with loose packs, and
anvil-publish.yml creates the release. The package and the zip build at the same
time on separate runners. A zip that fails to build, or a world without a world
preset, only leaves the zip out of the release. The anvil-setup action they share
installs exactly the Anvil version recorded in anvilconfig.json
(anvil.anvil_version), with the version of Anvil that wrote it as the fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
The project name, shown in the release workflow name. |
required |
gitignore()
The project's .gitignore.
main_py()
The project's Python entry point, scripts/python/main.py.
package_json(project_name, version, description, author)
The project's package.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
The npm package name. |
required |
version
|
str
|
The package version. |
required |
description
|
str
|
The package description. |
required |
author
|
str
|
The package author. |
required |
ts_constants()
The constants.ts that gives the scripts the project's namespace and name.
tsconfig(out_dir)
The project's tsconfig.json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dir
|
str | Path
|
The behavior pack folder. Scripts compile to its |
required |
vscode_launch(source_map_root, local_root, script_uuid, project_name)
The .vscode/launch.json that attaches the Minecraft script debugger.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_map_root
|
str | Path
|
The folder of the compiled scripts and their source maps. |
required |
local_root
|
str | Path
|
The folder of the TypeScript sources. |
required |
script_uuid
|
str
|
The UUID of the behavior pack's script module. |
required |
project_name
|
str
|
The project name, shown in the debug configuration. |
required |
write_github_workflows(project_name)
Writes the files of github_workflows into the project, replacing older ones.