Skip to content

Commit 80c1b38

Browse files
authored
chore: update root /templates to use wrangler generate instead of create-cloudflare@v1 (#3452)
* chore: update templates to use --no-delegate-c3 for all init commands. * update templates to use wrangler generate * prettier fixes * remove mention of c3 since template instructions now rely on wrangler generate * prettier fix
1 parent 77a43d2 commit 80c1b38

File tree

39 files changed

+242
-175
lines changed

39 files changed

+242
-175
lines changed

templates/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ There are a few ways to quickly jumpstart your next project using one of the tem
1212

1313
1. **Local development, via CLI quickstart utility**
1414

15-
We recommend using the `npm create cloudflare@1 [folder-name] [template-name]` command to create new projects with templates.
16-
17-
You may select the name of any subdirectory within this repository to create your project; for example, `worker-typescript` and `examples/fast-google-fonts` are both valid subdirectory names.
15+
We recommend using the `npx wrangler generate [folder-name] [template-name]` command to create new projects with templates.
1816

1917
To create a `my-project` directory using the [`worker-typescript`](/worker-typescript) template, you would run the following command:
2018

21-
`npm create cloudflare@1 my-project worker-typescript`
19+
`npx wrangler generate my-project worker-typescript`
20+
21+
Each template also comes with explicit installation and setup instructions in the README.
2222

2323
1. **Local development, via full repository clone**
2424

templates/experimental/worker-cobol/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ A Cloudflare worker that runs COBOL.
1111
To create a `my-project` directory using this template, run:
1212

1313
```sh
14-
$ npm init cloudflare my-project worker-cobol
14+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-cobol
1515
# or
16-
$ yarn create cloudflare my-project worker-cobol
16+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-cobol
1717
# or
18-
$ pnpm create cloudflare my-project worker-cobol
18+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-cobol
1919
```
20-
21-
> **Note:** Each command invokes [`create-cloudflare`](https://www.npmjs.com/package/create-cloudflare) for project creation.

templates/experimental/worker-dart/README.md

+16-9
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,31 @@ Your [Dart](https://dart.dev/) code in [index.dart](https://github.com/cloudflar
44

55
In addition to [Wrangler](https://github.com/cloudflare/wrangler) you will need to [install Dart](https://dart.dev/get-dart).
66

7-
#### Wrangler
7+
## Setup
88

9-
To generate using [wrangler](https://github.com/cloudflare/wrangler)
9+
To create a `my-project` directory using this template, run:
1010

11-
```
12-
wrangler generate projectname https://github.com/cloudflare/dart-worker-hello-world
11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-dart
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-dart
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-dart
1317
```
1418

1519
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
1620

17-
#### Dart
21+
## Dart
1822

1923
After installing Dart per the linked instructions above,
2024

21-
```
25+
```sh
2226
cd projectname
27+
```
2328

24-
# run once to get dependencies
29+
Then run the following to get dependencies:
30+
31+
```sh
2532
pub get
2633

2734
dart2js -O2 --server-mode -o index.js index.dart
@@ -31,11 +38,11 @@ That will compile your code into index.js, after which you can run `wrangler dep
3138

3239
For more information on how Dart translates to JavaScript, see the [docs for dart2js](https://dart.dev/tools/dart2js) and the [interop guide](https://dart.dev/web/js-interop).
3340

34-
#### Errors
41+
## Errors
3542

3643
Dart `2.13.0` and above require the `dart2js --server-mode` flag when using native JavaScript classes. Server mode is used to compile JS to run on server side VMs such as nodejs. If this flag is not used, the following errors are displayed:
3744

38-
```
45+
```sh
3946
index.dart:4:7:
4047
Error: JS interop class 'Request' conflicts with natively supported class '_Request' in 'dart:html'.
4148
class Request {

templates/experimental/worker-emscripten/README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ This template requires [Docker](https://docs.docker.com/install/) for providing
1616
To create a `my-project` directory using this template, run:
1717

1818
```sh
19-
$ npm init cloudflare my-project worker-emscripten
19+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-emscripten
2020
# or
21-
$ yarn create cloudflare my-project worker-emscripten
21+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-emscripten
2222
# or
23-
$ pnpm create cloudflare my-project worker-emscripten
23+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-emscripten
2424
```
2525

26-
> **Note:** Each command invokes [`create-cloudflare`](https://www.npmjs.com/package/create-cloudflare) for project creation.
27-
2826
## Credits
2927

3028
Shoutout to [Surma](https://twitter.com/dassurma) for his [webpack-emscripten-wasm](https://gist.github.com/surma/b2705b6cca29357ebea1c9e6e15684cc) gist that was instrumental in getting this working!

templates/experimental/worker-fsharp/README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ To authenticate wrangler commands it is recomended you [configure wrangler](http
3333

3434
### Generate a New Project
3535

36-
To create a new project based on this template execute:
37-
38-
```
39-
wrangler generate projectname https://github.com/fable-compiler/cfworker-hello-world
36+
To create a `my-project` directory using this template, run:
37+
38+
```sh
39+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-fsharp
40+
# or
41+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-fsharp
42+
# or
43+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-fsharp
4044
```
4145

4246
### Build and Deploy to Dev

templates/experimental/worker-kotlin/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ Your Kotlin code in [main.kt](https://github.com/cloudflare/kotlin-worker-hello-
44

55
In addition to [Wrangler v2.x](https://github.com/cloudflare/wrangler2) you will need to install Kotlin, including a JDK and support for Gradle projects. The easiest way to do this is using the free Community Edition of [IntelliJ IDEA](https://kotlinlang.org/docs/tutorials/jvm-get-started.html).
66

7+
## Setup
8+
9+
To create a `my-project` directory using this template, run:
10+
11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-kotlin
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-kotlin
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-kotlin
17+
```
18+
719
## Wrangler
820

921
Configure the [wrangler.toml](wrangler.toml) by filling in the `account_id` from the Workers pages of your Cloudflare Dashboard.

templates/experimental/worker-perl/README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@ Your Perl code in [index.pl](https://github.com/cloudflare/perl-worker-hello-wor
44

55
In addition to [Wrangler](https://github.com/cloudflare/wrangler) you will need to install Perl 5 and [Perlito](https://github.com/fglock/Perlito), a compiler from Perl to Java and JavaScript. Clone Perlito from GitHub (last tested on commit 97c296f), don't install the older version available on CPAN.
66

7-
#### Wrangler
7+
## Setup
88

9-
To generate using [wrangler](https://github.com/cloudflare/wrangler)
9+
To create a `my-project` directory using this template, run:
1010

11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-perl
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-perl
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-perl
1117
```
12-
wrangler generate projectname https://github.com/cloudflare/perl-worker-hello-world
13-
```
18+
19+
## Wrangler
20+
21+
Wrangler is used to develop, deploy, and configure your Worker via CLI.
1422

1523
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
1624

17-
#### Perlito
25+
## Perlito
1826

1927
Assuming you've cloned the Perlito repo to `~/Perlito` and `perl` on your path is Perl 5, run
2028

21-
```
29+
```sh
2230
cd projectname
2331
echo -e "const window = this;\n" > index.js && \
2432
perl ~/Perlito/perlito5.pl -Cjs index.pl >> index.js

templates/experimental/worker-php/README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ Your PHP code in [index.php](https://github.com/cloudflare/php-worker-hello-worl
44

55
This project uses [babel-preset-php](https://gitlab.com/kornelski/babel-preset-php) to convert PHP to JavaScript.
66

7-
#### Wrangler
7+
## Setup
88

9-
To generate using [wrangler](https://github.com/cloudflare/wrangler)
9+
To create a `my-project` directory using this template, run:
1010

11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-php
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-php
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-php
1117
```
12-
wrangler generate projectname https://github.com/cloudflare/php-worker-hello-world
13-
```
18+
19+
## Wrangler
20+
21+
Wrangler is used to develop, deploy, and configure your Worker via CLI.
1422

1523
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
1624

17-
#### babel-preset-php
25+
## babel-preset-php
1826

19-
```
27+
```sh
2028
cd projectname
2129

2230
# run once to install babel-preset-php and dependencies

templates/experimental/worker-python/README.md

+18-8
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,29 @@ Your Python code in [index.py](https://github.com/cloudflare/python-worker-hello
44

55
In addition to [Wrangler](https://github.com/cloudflare/wrangler2) and [npm](https://www.npmjs.com/get-npm), you will need to install [Transcrypt](https://www.transcrypt.org/docs/html/installation_use.html), including Python 3.7 and virtualenv.
66

7-
#### Wrangler
7+
## Setup
88

9-
- Clone repository (`git clone https://github.com/cloudflare/python-worker-hello-world`)
10-
- Run `npm install`
11-
- Update `wrangler.toml` with your project `name`, `account_id`, and `route` as required
9+
To create a `my-project` directory using this template, run:
1210

13-
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/wrangler/).
11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-python
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-python
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-python
17+
```
18+
19+
## Wrangler
20+
21+
Wrangler is used to develop, deploy, and configure your Worker via CLI.
1422

15-
#### Transcrypt
23+
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
24+
25+
## Transcrypt
1626

1727
Before building your project, you'll need to do one-time setup of Transcrypt. Assuming you have Python 3.7 and virtualenv installed per the linked instructions above, that setup on unix systems looks like the following (for windows see [virtualenv docs](https://virtualenv.pypa.io/en/latest/user_guide.html#activators)):
1828

19-
```
29+
```sh
2030
cd projectname
2131

2232
virtualenv env
@@ -34,7 +44,7 @@ For more information on how Python translates to Javascript, see the [Transcrypt
3444

3545
Because of aliases, for a KV namespace binding named `KV` you can use `KV.put` normally, but need to use `KV.js_get` instead of `KV.get`. For example, a handler using KV might look like:
3646

37-
```
47+
```sh
3848
def handleRequest(request):
3949
return KV.js_get('foo').then(
4050
lambda v: __new__(Response('Python Worker hello world! ' + v, {

templates/experimental/worker-reason/README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@ Your [Reason](https://reasonml.github.io/) code in [Demo.re](https://github.com/
44

55
In addition to [Wrangler](https://github.com/cloudflare/wrangler) you will need to [install BuckleScript](https://reasonml.github.io/docs/en/installation) using npm or Yarn.
66

7-
#### Wrangler
7+
## Setup
88

9-
To generate using [wrangler](https://github.com/cloudflare/wrangler)
9+
To create a `my-project` directory using this template, run:
1010

11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-reason
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-reason
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-reason
1117
```
12-
wrangler generate projectname https://github.com/cloudflare/reason-worker-hello-world
13-
```
18+
19+
## Wrangler
20+
21+
Wrangler is used to develop, deploy, and configure your Worker via CLI.
1422

1523
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
1624

17-
#### BuckleScript
25+
## BuckleScript
1826

1927
After installing BuckleScript per the linked instructions above,
2028

21-
```
29+
```sh
2230
cd projectname
2331

2432
# assuming you installed BuckleScript globally, need to run this once

templates/experimental/worker-rust/README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ This template is designed for compiling Rust to WebAssembly and publishing the r
1111
To create a `my-project` directory using this template, run:
1212

1313
```sh
14-
$ npm init cloudflare my-project worker-rust
14+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-rust
1515
# or
16-
$ yarn create cloudflare my-project worker-rust
16+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-rust
1717
# or
18-
$ pnpm create cloudflare my-project worker-rust
18+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-rust
1919
```
2020

21-
> **Note:** Each command invokes [`create-cloudflare`](https://www.npmjs.com/package/create-cloudflare) for project creation.
21+
## Wrangler
22+
23+
Wrangler is used to develop, deploy, and configure your Worker via CLI.
24+
25+
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
2226

2327
## Usage
2428

templates/experimental/worker-scala-kv/README.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,29 @@
44

55
In addition to [Wrangler](https://github.com/cloudflare/wrangler) you will need to install the Scala build tool [sbt](https://www.scala-sbt.org/1.x/docs/Setup.html), including a JDK.
66

7-
#### Wrangler
7+
## Setup
88

9-
To generate using [wrangler](https://github.com/cloudflare/wrangler)
9+
To create a `my-project` directory using this template, run:
1010

11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-scala-kv
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-scala-kv
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-scala-kv
1117
```
12-
wrangler generate projectname https://github.com/cloudflare/scala-worker-kv
13-
```
1418

15-
When editing wrangler.toml to include your account_id, you will also need to add your kv namespace id to the binding under kv-namespaces.
19+
## Wrangler
20+
21+
Wrangler is used to develop, deploy, and configure your Worker via CLI.
1622

1723
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
1824

19-
#### sbt
25+
## sbt
2026

2127
After installing sbt per the linked instructions above,
2228

23-
```
29+
```sh
2430
cd projectname
2531
sbt fullOptJS
2632
```

templates/experimental/worker-scala/README.md

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@ Your Scala code in [Main.scala](https://github.com/cloudflare/scala-worker-hello
44

55
In addition to [Wrangler](https://github.com/cloudflare/wrangler) you will need to install the Scala build tool [sbt](https://www.scala-sbt.org/1.x/docs/Setup.html), including a JDK.
66

7-
#### Wrangler
7+
## Setup
88

9-
To generate using [wrangler](https://github.com/cloudflare/wrangler)
9+
To create a `my-project` directory using this template, run:
1010

11+
```sh
12+
$ npx wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-scala
13+
# or
14+
$ yarn wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-scala
15+
# or
16+
$ pnpm wrangler generate my-project https://github.com/cloudflare/workers-sdk/templates/experimental/worker-scala
1117
```
12-
wrangler generate projectname https://github.com/cloudflare/scala-worker-hello-world
13-
```
18+
19+
## Wrangler
20+
21+
Wrangler is used to develop, deploy, and configure your Worker via CLI.
1422

1523
Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler).
1624

17-
#### sbt
25+
## sbt
1826

1927
After installing sbt per the linked instructions above,
2028

21-
```
29+
```sh
2230
cd projectname
2331
sbt fullOptJS
2432
```

0 commit comments

Comments
 (0)