Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrangler init should populate example code #355

Closed
Electroid opened this issue Jan 31, 2022 · 5 comments · Fixed by #372 or #350
Closed

wrangler init should populate example code #355

Electroid opened this issue Jan 31, 2022 · 5 comments · Fixed by #372 or #350
Labels
polish Small improvements to the experience

Comments

@Electroid
Copy link
Contributor

Electroid commented Jan 31, 2022

After running wrangler init, no example code is provided (index.js or index.ts depending if they asked for TypeScript or not). It should populate a basic starter file. In the future, we can make this more complex by introducing different templates to choose from.

src/index.ts:

export default {
  async fetch(request: Request, env: Environment, ctx: ExecutionContext): Promise<Response> {
    return new Response("Hello!");
  }
}

export type Environment = {
  // MY_NAMESPACE: KvNamespace;
}

src/index.js:

export default {
  async fetch(request, env, ctx) {
    return new Response("Hello!");
  }
}

Also, should probably have a comment that links to the reference documentation?

@Electroid Electroid added the polish Small improvements to the experience label Jan 31, 2022
@petebacondarwin
Copy link
Contributor

Instead of asking wrangler init to do this. We should push ahead with implementing the create-workers-app package, which could then be run using npm init workers-app. See https://www.npmjs.com/package/create-qwik for an example of how this can work.

@threepointone
Copy link
Contributor

I'd like to push back on this, it'll become extremely complicated to keep adding features here. But this is what we were planning on doing with create-worker-app, and we should design and plan that separately.

@Electroid
Copy link
Contributor Author

Instead of asking wrangler init to do this. We should push ahead with implementing the create-workers-app package, which could then be run using npm init workers-app. See https://www.npmjs.com/package/create-qwik for an example of how this can work.

I'd like to push back on this, it'll become extremely complicated to keep adding features here. But this is what we were planning on doing with create-worker-app, and we should design and plan that separately.

Both great points. I do like the idea that we can just guide folks to create-workers-app. In fact, maybe wrangler init is just a legacy alias that asks if they want to run it?

My only qualm is leaving wrangler init half-baked; the entry point seems like a trivial addition that would make the experience much more useful. I agree the more complicated stuff can be left for a separate tool, but without the entry point, you feel like you got dropped off halfway to your destination.

@threepointone
Copy link
Contributor

I like the idea of an entry point. Ok let's try something and see how it feels.

threepointone added a commit that referenced this issue Feb 2, 2022
We got feedback that `wrangler init` felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step to `wrangler init` where we offer to create that file for you.

Fixes #355
@threepointone
Copy link
Contributor

#372

threepointone added a commit that referenced this issue Feb 2, 2022
We got feedback that `wrangler init` felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step to `wrangler init` where we offer to create that file for you.

Fixes #355
threepointone added a commit that referenced this issue Feb 2, 2022
We got feedback that `wrangler init` felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step to `wrangler init` where we offer to create that file for you.

Fixes #355
@Electroid Electroid added this to the 2.0 milestone Feb 3, 2022
threepointone added a commit that referenced this issue Feb 3, 2022
We got feedback that `wrangler init` felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step to `wrangler init` where we offer to create that file for you.

Fixes #355
threepointone added a commit that referenced this issue Feb 3, 2022
We got feedback that `wrangler init` felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step to `wrangler init` where we offer to create that file for you.

Fixes #355
threepointone added a commit that referenced this issue Feb 3, 2022
We got feedback that `wrangler init` felt incomplete, because the immediate next thing folks need is a starter source file. So this adds another step to `wrangler init` where we offer to create that file for you.

Fixes #355
mrbbot pushed a commit that referenced this issue Oct 31, 2023
mrbbot pushed a commit that referenced this issue Nov 1, 2023
mrbbot pushed a commit that referenced this issue Nov 1, 2023
mrbbot pushed a commit that referenced this issue Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polish Small improvements to the experience
Projects
None yet
3 participants