cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.47k stars 630 forks source link

🐛 BUG: remove `init` from list of commands when running `npx wrangler` #5701

Open rita3ko opened 3 months ago

rita3ko commented 3 months ago

Which Cloudflare product(s) does this pertain to?

Wrangler core

What version(s) of the tool(s) are you using?

⛅️ wrangler 3.51.2

What version of Node are you using?

No response

What operating system and version are you using?

mac

Describe the Bug

Observed behavior

running npx wrangler lists wrangler init command, which then tells you it's deprecated

Expected behavior

not list it

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

kornelski commented 3 months ago

npx wrangler generate displays the same message.

However, I without this message I would not have known that npm create cloudflare exists, and I would be lost not knowing how to start using Wrangler.

irvinebroque commented 1 month ago

Came here with same problem, but different suggestion on how we solve it.

When I run npx wrangler@latest init from a directory without a wrangler.toml file — npm create cloudflare runs — this is what should happen!

brendan@N64W27QG5Q test % npx wrangler@latest init

 ⛅️ wrangler 3.61.0
-------------------

Using npm as package manager.
▲ [WARNING] The `init` command is no longer supported. Please use `npm create cloudflare\@2.5.0` instead.

  The `init` command will be removed in a future version.

Running `npm create cloudflare\@2.5.0`...

...but when I run this from a directory that has a wrangler.toml already, the old wrangler init runs:

brendan@N64W27QG5Q remix-d1 % npx wrangler init
 ⛅️ wrangler 3.57.1 (update available 3.61.0)
-------------------------------------------------------
Using npm as package manager, as there is already a package-lock.json file.
▲ [WARNING] wrangler.toml already exists!

✔ Do you want to continue initializing this project? … yes
? Would you like to create a Worker at src/index.ts? › - Use arrow-keys. Return to submit.
    None
❯   Fetch handler
    Scheduled handler

...and if I run wrangler generate, in either scenario, ye ole wrangler init command runs:

brendan@N64W27QG5Q test % npx wrangler@latest generate

 ⛅️ wrangler 3.61.0
-------------------

Using npm as package manager.
▲ [WARNING] The `init` command is no longer supported. Please use `npm create cloudflare\@2.5.0` instead.

  The `init` command will be removed in a future version.

✨ Created wrangler.toml
✖ Would you like to use git to manage this Worker? … yes

What should we do about it?

  1. In all cases, we should run npm create cloudflare@latest. There should never be a case where we run the old init command runs, regardless of where you run it from.
  2. We should remove the deprecation message about wrangler init and wrangler generate. It's just noise. There are tons of projects floating out there that reference the command directly. We should make things clear and easy and simple for people coming from these paths. We already hide init and generate from Wrangler's list of commands, and in the docs.