Closed kon-pas closed 12 months ago
WOW. This is indeed a well-crafted pull request! I originally wanted this repository to be created with just the command npm create nue
but I had troubles pushing it live and I had simultaneous pressures to push the whole thing in production so I decided to do this later. But looks like you did it! Big thank you! Merging this now to master, but I see we need a dev- branch, which I will create too.
@kon-pas I just pushed out a dev
branch where you can continue with this.
pnpm link
and pnpm create nue
worked perfectly, but then the pnpm start
command in the new project directory raised this error "sh: ./scripts/minify.js: Permission denied". Do we need to prefix all commands with node
?
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.
I was working to finalize the template scaffolding. With the new PR #18 this should work, at least for Linux. create-nue
has to be published, but until then you can use create-nue-app
which is a copy of this PR #18. I will delete/deprecate create-nue-app
once create-nue
package works.
@tipiirai If you are having any issues, please post errors logs and I will try to resolve it as soon, as possible.
"sh: ./scripts/minify.js: Permission denied". Do we need to prefix all commands with
node
?
I don't think that's the case. We prefixed with node
to run the script on Windows (which I believe the CLI from the new PR #18 resolved). If you are still having the Permission denied
issue, try changing the permission of all scripts. chmod a+x <script>
should work. I did this in PR #18 but who knows.
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:
Execute the package
[1]
Shorthand for executing the
create-*
packages[1]
Use package entry point binary
[2]
(probably not preferred, but possible)Use
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.Imperatively by calling the package function
[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! 👍