https://github.com/swiftsoftwaregroup/cli-js
Template for Command Line Interface (CLI) tool for Node.js and JavaScript
https://github.com/swiftsoftwaregroup/cli-js
Last synced: 5 months ago
JSON representation
Template for Command Line Interface (CLI) tool for Node.js and JavaScript
- Host: GitHub
- URL: https://github.com/swiftsoftwaregroup/cli-js
- Owner: swiftsoftwaregroup
- License: apache-2.0
- Created: 2024-07-20T11:37:47.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-20T12:48:57.000Z (almost 2 years ago)
- Last Synced: 2025-01-26T22:03:18.666Z (over 1 year ago)
- Language: JavaScript
- Size: 51.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cli-js
Template for Command Line Interface (CLI) tool for Node.js and JavaScript
## Development
### Setup for macOS
#### Nvm
`nvm` is node.js version manager.
```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
```
Close and reopen terminal.
#### Node.js
Install via `nvm`:
```bash
nvm install v20.15.1
```
Make sure you do not have default node set:
```bash
nvm unalias default
```
Activate node 20.15.1:
```bash
nvm use 20.15.1
```
#### Configure npm
Configure `npm` (Node Package Manager) to save versions of packages in `packages.json`. This way you can have the same stable environment on all development machines:
```bash
nvm use 20.15.1
npm config set save=true
npm config set save-exact=true
```
### Work on macOS
Configure project:
```bash
source configure.sh
```
Open the project in Visual Studio Code:
```bash
code .
```
### Run
```bash
chmod +x cli.js
echo "John" > name.txt
./cli.js greet name.txt
./cli.js greet --language es name.txt
./cli.js greet -l bg name.txt
```
### Test
```bash
npm test
```
### Generate Docs
```bash
npm run docs
open ./docs/index.html
```
### Use as a global tool
#### Install
```bash
npm install --global .
```
#### Run
```bash
echo "John" > name.txt
cli-js greet name.txt
cli-js greet --language es name.txt
cli-js greet -l bg name.txt
```
### How to create a new project
```bash
# create new project
npm init --yes --init-version 0.1.0 --init-license Apache-2.0
# add packages
npm install commander fs
npm install --save-dev jest jsdoc docdash
```