nuejs / create-nue

A recommended way to start a Nue project
https://nuejs.org
139 stars 30 forks source link

Feat: Template scaffolding via binaries, new CLI #18

Closed kon-pas closed 11 months ago

kon-pas commented 12 months ago

NOTE To use, the package has to be published with the name create-nue. I have published a copy of this as create-nue-app. It can be used in the same way, just need to add the -app suffix, like so pnpm create nue-app.

NOTE I wanted to get this done as fast as I could, so there are some changes that should be discussed first. As I've already made them, I'm willing to undo them, or implement differently.

Features

It is now possible to scaffold the template via package binaries:

npm create nue@latest
npx create-nue@latest
yarn create nue
pnpm create nue
bunx create-nue@latest

If the package is installed globally, the following also works:

create-nue

Or via calling an exported function:

import create from 'create-nue'
await create({ name: 'hello-nue' })

All of the above worked for me on Linux, but I didn't test them all on Windows. I'm afraid there may be some path resolving problems.

Also, I have made a simple CLI and published it as nuekit-cli. nue-cli wasn't available for some reason, even though I couldn't find a package with that name. nuekit-cli is just a temporary package, its code may become a part of nuekit in the future. I will unpublish it, if you wish. It uses scripts from /scripts with minor updates.

create-nue uses nuekit-cli because I didn't want to pollute the template with code non-related to the person's project. The other reasonable option is to put them in .nue, or similar, hidden to the end user directory. It is a topic to discuss.

And finally, I have implemented simple prompts and user messages. I will finish this later.

Changes

I have updated the directory structure - now the code related to create-nue itself is in /src and the code related to the template is in /src/template. This is a change that I thought may improve readability, but is invasive to the project. I will undo this, if you wish.

nuekit-cli is based on this project's scripts and the code from PR #16. Those scripts are no longer used by create-nue, but I didn't delete them.

I have cleaned-up the template's package.json - it is no longer create-nue's package.json.

tipiirai commented 12 months ago

Hey. Looks like we were working simultaneously! I basically rewrote everything under the scripts directory. Please check that out!

kon-pas commented 12 months ago

Hey. Looks like we were working simultaneously!

Ouch!

I think we should differ the CLI from create-nue. I think create-nue should only scaffold the project, while the other scripts should be somewhere else.

tipiirai commented 12 months ago

The original purpose of this repository is to show how Nue JS compilation and server-side rendering works. Maybe the project names is misleading? I'm happy to do the npm create flow later since it feels so buggy with so many moving parts.

kon-pas commented 12 months ago

Right, I must have missed that out. I was more trying to make a scaffolding tool for nue, where you get a project template comfortably, like create-vue for vue, create-svelte for svelte, etc. I was trying to differ the nue-related stuff only to be in the /template, and thought that /scripts are not related to nue.

to show how Nue JS compilation and server-side rendering works

With that in mind, having a CLI isn't a good call πŸ‘

kon-pas commented 12 months ago

@tipiirai After reflection, the name create-nue is indeed misleading πŸ˜…

If we ditch npm create for now, I think having the cli.js and basically the whole PR #16 is unnecessary, since that was the point of it. If we don't need an entry point for CLI, nor pass any inline arguments, it's better to just call ./<script> than ./cli.js <script>

tipiirai commented 12 months ago

If you can start from scratch β€”Β In your opinion, what would be the best "starter kit" for Nue?

tipiirai commented 11 months ago

Closing this one because of breaking changes and particularly because of this: #27