nick
nick

Reputation: 367

How to create custom node.js application starter scripts

I would like to create custom scripts for creating a new application just like npx create-react-app my-app. However, I would like to customize libraries and folder structure etc. However, I am not quite sure how to approach this. I thought about two ways but I am unsure which one will best fit my needs.

  1. Should I create a custom package then create the files I need with fs etc.
  2. A batch script to do the things I mentioned.

I found that express has this feature but it would be nice to be able to customize these settings. Are there any alternative and possibly more efficient methods for doing this?

Also, if I were to do it via nmp packages. How can I run them from the cli?

Thanks in advance!

Upvotes: 2

Views: 433

Answers (1)

Konstantin Tarkus
Konstantin Tarkus

Reputation: 38358

If customizations are not too advanced, you can start by creating a template repository and place a single setup script in it, which can be implemented by using inquirer npm module. Here is an example:

enter image description here

See https://github.com/kriasoft/nodejs-api-starter -> setup.js

Upvotes: 1

Related Questions