body method

  1. @override
String body(
  1. String path,
  2. String baseName,
  3. String className
)
override

Defines the actual body code. path is passed relative to lib, baseName is the filename, and className is the filename converted to Pascal case.

実際の本体コードを定義します。pathlibからの相対パス、baseNameにファイル名が渡され、classNameにファイル名をパスカルケースに変換した値が渡されます。

Implementation

@override
String body(String path, String baseName, String className) {
  return r"""
/**
 * For more details on how to configure Wrangler, refer to:
 * https://developers.cloudflare.com/workers/wrangler/configuration/
 */
{
	"$schema": "node_modules/wrangler/config-schema.json",
	"name": "cloudflaretest",
	"main": "src/index.ts",
	"compatibility_date": "2026-06-29",
	"compatibility_flags": [
		"nodejs_compat",
		"global_fetch_strictly_public"
	],
	"assets": {
		// The path to the directory containing the `index.html` file to be served at `/`
		"directory": "./public"
	},
	"observability": {
		"logs": {
			"enabled": true,
			"invocation_logs": true
		},
		"traces": {
			"enabled": true
		}
	},
	"upload_source_maps": true
	/**
	 * Smart Placement
	 * https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
	 */
	// "placement": {  "mode": "smart" }
	/**
	 * Bindings
	 * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including
	 * databases, object storage, AI inference, real-time communication and more.
	 * https://developers.cloudflare.com/workers/runtime-apis/bindings/
	 */
	/**
	 * Environment Variables
	 * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
	 * Note: Use secrets to store sensitive data.
	 * https://developers.cloudflare.com/workers/configuration/secrets/
	 */
	// "vars": {  "MY_VARIABLE": "production_value" }
	/**
	 * Service Bindings (communicate between multiple Workers)
	 * https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
	 */
	// "services": [  {   "binding": "MY_SERVICE",   "service": "my-service"  } ]
}
""";
}