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_release_workflow(project_name)
The GitHub Actions workflow, .github/workflows/release.yml, that builds and
releases the project when its version changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
The project name, shown in the 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(namespace, project_name)
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 |