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

[create-hono] Make the app name change based on a project name #1563

Closed
yusukebe opened this issue Oct 11, 2023 · 10 comments
Closed

[create-hono] Make the app name change based on a project name #1563

yusukebe opened this issue Oct 11, 2023 · 10 comments
Labels
enhancement New feature or request.

Comments

@yusukebe
Copy link
Member

What is the feature you are proposing?

Currently, the application name of a project created by create-hono is fixed as my-app. This is bad for DX as we can only use a fixed name. Therefore, we need to modify create-hono so that the application name is based on the directory name.

@yusukebe yusukebe added the enhancement New feature or request. label Oct 11, 2023
@sor4chi
Copy link
Contributor

sor4chi commented Oct 12, 2023

Hi, @yusukebe
Does that mean that all the parts inside of the template app that are my-app should be dynamic?

eg. wrangler.toml in "cloudflare-workers" template

@sor4chi
Copy link
Contributor

sor4chi commented Oct 12, 2023

As for the directory name, like this video

Unspecified -> asking (default is my-app)
specified -> folder name (.)

How about this?

2023-10-12.23.08.16.mov

@yusukebe
Copy link
Member Author

Hi @sor4chi,

Super cool! I love it.

@yusukebe
Copy link
Member Author

Does that mean that all the parts inside of the template app that are my-app should be dynamic?

Ideally, yes. But actually, we don't do that.

As you mentioned, the name field in wrangler.toml should be dynamic:

https://github.com/honojs/starter/blob/main/templates/cloudflare-workers/wrangler.toml#L1

Alternatively, we could make the name field in package.json dynamic. However, since Deno has no config files, we don't apply that to all templates.

Anyway, I think we should make it flexible.

@sor4chi
Copy link
Contributor

sor4chi commented Oct 12, 2023

Okay. In my plan,

Create a REPLACE_FILE_LIST and put some paths like . /package.json or . /wrangler.toml.

I would like to set [DYNAMIC_APP_NAME] for the part of my-app and try to replace [DYNAMIC_APP_NAME] in REPLACE_FILE_LIST.

What do you think?

@yusukebe
Copy link
Member Author

Using "magic strings" like [DYNAMIC_APP_NAME] is good!

I think we can make a "hook". The hook will be fired after clone. The following is pseudo code:

type Hook = (args: { projectName: string; templateName: string; directoryPath: string }) => void

const cloudflareWorkersHook:Hook = (arg) => {
  if (arg.templateName !== 'cloudflare-workers') return
  const wranglerTomlPath = getWranglerTomlPath(arg.directoryPath)
  rewriteNameInWranglerToml(wranglerTomlPath, arg.projectName)
}

@yusukebe
Copy link
Member Author

And one more thing we need to consider is testing. There are no tests in the project currently, but we need them.

@yusukebe
Copy link
Member Author

Or like the following:

type Hook = (args: { projectName: string; directoryPath: string }) => void;

const rewriteWranglerHook: Hook = () => {}

addHook('cloudflare-worker', rewriteWranglerHook)

@sor4chi
Copy link
Contributor

sor4chi commented Oct 12, 2023

wow, nice idea! I will get on with it for now!

@yusukebe
Copy link
Member Author

This can be closed! Thanks @sor4chi !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants