-
Notifications
You must be signed in to change notification settings - Fork 30
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
Feat: Improved DX #16
Conversation
BREAKING CHANGE: Cannot run scripts by executing files, like so: `$ ./scripts/minify.js` or with node `$ node ./scripts/minify.js`
An entry point for CLI. Allows executing functions as scripts, like so: `$ ./cli.js minify` Instead of: `$ ./minify.js`
`create` function allows to scaffold the project imperatively by invoking it
Allows to import from the npm package
Scripts now use `nue` CLI. CLI can also be run in terminal, like so: `$ nue minify` Instead of: `$ npm run minify`, etc...
`bin.js` is an entry point binary of the package. It: - welcomes, - invokes and reads template prompts, - scaffolds the template
TEMPORARY: New features scaffold a placeholder instead of a template. Does NOT break the previous method: `$ bun --bun start`
WOW. This is indeed a well-crafted pull request! I originally wanted this repository to be created with just the command |
@kon-pas I just pushed out a
I will publish a new npm version after we solve this one. Thank you! |
@kon-pas I'm having a hard time getting create-nue to work after merging this. Can you help with finalizing this PR? |
@tipiirai Sorry for not posting. |
@tipiirai If you are having any issues, please post errors logs and I will try to resolve it as soon, as possible.
I don't think that's the case. We prefixed with |
Please check the latest master / v0.1.4. I think it contains all the stuff on this PR. Unfortunately, I get "403 Forbidden - PUT https://registry.npmjs.org/create-nue - create-nue cannot be republished until 24 hours have passed." error when pushing to NPM, so I need to wait for that still. Check #9 |
Features
Improved DX to match scaffolding tools standards.
Templates can now be created via one of the following methods:
[1]
create-*
packages[1]
[2]
(probably not preferred, but possible)nue
CLI directly[2]
(also probably not preferred, but very hand to call internally)nue <script>
runs one of the provided scripts (in/scripts
as an exported funtion, see the changes below). Can also callnue render
, etc.[1]
- the package has to be published[2]
- the package has to be installed locallyAll of the above scaffold a placeholder, instead of a real template, because the original one is not suitable. This is a topic for another PR, which I can do once this PR gets accepted.
I saw that someone has published a fork of this repo, but it has many (unwanted?) changes. Hope this problem will be resolved soon.
create-nue
is a nice and clean name 👍Also, due to the already published
create-nue
package, there may be a name conflict and linking this PR may not work. In that case changename
and the key of"./scripts/bin.js"
inpackage.json
to something else, for examplecreate-nue-app
Changes
To focus only on the CLI part, I did not change the folder structure. I placed all scripts in
/scripts
, except forindex.js
.minify.js
,render.js
,compile.js
,server.js
) to exported functions. This is a breaking change. They are called viacreate()
or thenue
CLI.create.js
with a functioncreate()
that calls all of the scripts listed abovecli.js
which is an entry point for thenue
CLI. It accepts inline tags: a script name and options. A script name is one of the above, includingcreate
. Options are not yet parsed (they are a topic to discuss).bin.js
which is an entry point binary for the package (called vianpx create-nue
, etc). It parses user prompts and and then scaffolds the templateindex.js
to export thecreate()
functionnue
CLI or executecli.js
directly. The latter is an equivalent to what was done previously, so there shouldn't be new errors. The main use ofcli.js
is to parse options (which is not yet implemented)The reason for changing scripts to functions is to implement logic for parsing options in one place (for now it's
cli.js
). We could just have a function for parsing options, but having one file instead is a good pattern for CLI, and maybe anue-cli
package in the future.By the way, nice project! 👍