How do you generate cloudflare/templates with Wrangler?

The documentation in the cloudflare/templates repository says that "cloudflare-create" is sunsetting and to use "wrangler generate" instead. However, the wrangler generate command has no documentation for how to do this either.
5 Replies
Hello, I’m Allie!
I'm not sure what you mean? From [email protected]:
wrangler generate [name] [template]

✨ Generate a new Worker project from an existing Worker template. See https://github.com/cloudflare/templates

Positionals:
name Name of the Workers project [string]
template The URL of a GitHub template [string]

Flags:
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
-c, --config Path to .toml configuration file [string]
-e, --env Environment to use for operations and .env files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
wrangler generate [name] [template]

✨ Generate a new Worker project from an existing Worker template. See https://github.com/cloudflare/templates

Positionals:
name Name of the Workers project [string]
template The URL of a GitHub template [string]

Flags:
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
-c, --config Path to .toml configuration file [string]
-e, --env Environment to use for operations and .env files [string]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
The readme on the repo hasn't updated in a while, but it should still work...
quisi.do
quisi.doOP2y ago
I suppose the part that wasn't clear was that you do not need to specify a [template] when using generate in order to get a specific template from the cloudflare/templates repository. It implies that you need to specify a template path, like workers-typescript, but that throws an error that the template can't be found. I resolved this by not specifying a template, at which point it asked me which template I wanted to use.
Hello, I’m Allie!
I think the reason there was that the template is worker-typescript, not workers-typescript:
⛅️ wrangler 2.9.0
-------------------
Creating a worker in yee from worker-typescript
✨ Success!
⛅️ wrangler 2.9.0
-------------------
Creating a worker in yee from worker-typescript
✨ Success!
quisi.do
quisi.doOP2y ago
You were able to do wrangler generate xyz worker-typescript?
Want results from more Discord servers?
Add your server