# @soptq/node-project-template

> Baseline configuration files for node projects

Latest version **0.7.2** (published 2024-02-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @soptq/node-project-template
pnpm add @soptq/node-project-template
yarn add @soptq/node-project-template
bun add @soptq/node-project-template
```

Provides the command `applyProjectTemplate`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.2 |
| Published | 2024-02-25 |
| First published | 2024-02-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18.3.0 |
| Dependencies | 20 |
| Unpacked size | 32 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | soptq |

## Links

- npm: https://www.npmjs.com/package/@soptq/node-project-template
- Repository: https://github.com/Soptq/node-project-template
- Issues: https://github.com/Soptq/node-project-template/issues
- npm.io page: https://npm.io/package/@soptq/node-project-template

## Dependencies (20)

- [xo](https://npm.io/package/xo.md) ^0.50.0
- [jest](https://npm.io/package/jest.md) ^28.1.1
- [extend](https://npm.io/package/extend.md) ^3.0.2
- [opener](https://npm.io/package/opener.md) ^1.5.2
- [semver](https://npm.io/package/semver.md) ^7.3.7
- [del-cli](https://npm.io/package/del-cli.md) ^4.0.1
- [nodemon](https://npm.io/package/nodemon.md) ^2.0.16
- [ts-jest](https://npm.io/package/ts-jest.md) ^28.0.5
- [ts-node](https://npm.io/package/ts-node.md) ^10.8.1
- [depcheck](https://npm.io/package/depcheck.md) ^1.4.3
- [foundry-js](https://npm.io/package/foundry-js.md) ^1.0.128
- [@types/jest](https://npm.io/package/@types/jest.md) ^28.1.1
- [@types/node](https://npm.io/package/@types/node.md) ^17.0.42
- [readline-sync](https://npm.io/package/readline-sync.md) ^1.4.10
- [git-config-path](https://npm.io/package/git-config-path.md) ^2.0.0
- [@tsconfig/node18](https://npm.io/package/@tsconfig/node18.md) ^1.0.1
- [parse-git-config](https://npm.io/package/parse-git-config.md) ^3.0.0
- [npm-check-updates](https://npm.io/package/npm-check-updates.md) ^13.1.5
- [sort-package-json](https://npm.io/package/sort-package-json.md) ^1.57.0
- [@soptq/solidity-docgen](https://npm.io/package/@soptq/solidity-docgen.md) ^0.5.1-7.a2

## Recent versions

- 0.7.2 (latest) — 2024-02-25

## README

# Node Project Template
[![npm version](https://badge.fury.io/js/@msamblanet%2Fnode-project-template.svg)](https://badge.fury.io/js/@msamblanet%2Fnode-project-template)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

This repository is part of a collection of my personal node.js libraries and templates.  I am making them available to the public - feel free to offer suggestions, report issues, or make PRs via GitHub.

Setting up node.js projects with typescript support, unit testing, linting, etc requires a significant number of configuration files across all your projects.  This project is designed to be included as a dev-dependency to your projects and can apply a common set of configuration files to the project, making maintenance slightly easier.

To summarize, this project provides a self-updating template which provides for:

- Typescript support (compiling into mjs modules)
- Execution via ts-node and nodemon
- Unit testing and code coverage via Jest
- Linting via XO
- Integration with npm-check-updates and depcheck to detect updated and unused dependencies

## Getting started

- Make a new project in your GIT and clone it
- In your new project run the following:
    - ```npm i --save-dev @msamblanet/node-project-template```
    - ```npx applyProjectTemplate```
        - You will be prompted for some basic project details.  Defaults will be infered from your GIT, OS, and Folder information.
        - The script will automatically copy the template project files in and replace basic project data in package.json for you.
- Review the configuration files and begin work on your project
    - The template assumes that:
        - Any local TS definitions for 3rd party modules are at ```src/@types```
        - Your module imports are at ```src/index.ts```
        - The code to run when running the project is located at ```src/main.ts```
        - Your tests are named ```test/**/*.test.ts```

### Inherited configuration

For configurations which support inheritence, inheritence is used to simplify configuration.  For example, if a future release determines we should to update our configuration of ```tsconfig.json```...
    - Commit and Branch like you would for any change
    - Update @msamblanet/node-project-template
    - For these dependencies, you are done because configuration changes are inherited from the node-modules folder.

### Non-Inherited Updates

Not all the dependencies support inheritence.  For example, if ```.editorconfig``` were updated, to apply this setting you would:
    - Commit and Branch like you would for any change
    - Update the dependency as normal
    - Run your tests to verify functionality is not broken
    - ```npm run applyProjectTemplate```
    - Review the differences in GIT to ensure nothing project-specific was accidentally overwritten (```git diff```)
    - Run your tests to verify functionality is not broken

## Configuration

Configuration can be performed in your project's ```package.json``` to redirect or suppress changes to settings and files.  If you find that ```applyProjectTemplate``` is overriding a setting of your, you can add settings to ```package.json``` to control this.

@TODO: Document these in details.  Until these are documented, you will need to review ```src/update.js``` to inspect the details of how this works.

## What's Included

- GitHub dependabot configuration
- VSCode Debugger configuration
- .editorconfig
- eslint configuration
- .gitignore
- Template HISTORY.md, LICENSE, README.md, and TODO.md files
- Template main, index, and test files.
- Jest coniguration
- TypeScript configuration (for building CJS and MJS targets)
- Lots of ```npm run``` commands
    - ```dev``` - Runs ```src/main.ts``` script locally
    - ```debug``` - Runs ```src/main.ts``` script locally with the JS inspector enabled
    - ```nodemon``` - Runs ```src/main.ts``` script locally via nodemon (to restart on file changes)
    - ```prod``` - Series of commands related to production use of the app
      - ```prod:init``` - Initializes the app for prod use (default is to ```npm ci --only=production```)
      - ```prod:start``` - Starts the application in production (using previously built code)
    - ```test``` - Runs all of the Jest unit tests
        - ```test:open``` - Opens the coverage report in a local browser window
        - ```test:debug``` - Same but has the JS inspector enabled
        - ```test:watch``` - Runs all of the Jest unit tests in watch mode (to retest on changes)
    - ```lint``` - Runs XO as a linter
        - ```lint:fix``` - Runs XO with the fix option
    - ```build``` - Performs a build:clean and build:gen to build the code
        - ```build:clean``` - Deletes the dist folder
        - ```build:check``` - Runs tsc without output to verify the code
        - ```build:gen``` - Runs tsc to compile the typescript
    - ```prepack``` - This is automatically executed by npm just before npm packages for release.  It runs a lint, build:check, and build to generate the library for packaging.
    - ```lib``` - Series of commands for managing dependencies
        - ```lib:check``` - Reports on updated dependencies WITHOUT installing any
        - ```lib:update:patch``` - Update and install all available patch level updates
        - ```lib:update:minor``` - Update and install all available patch and minor level updates
        - ```lib:update:latest``` - Update and install all available dependencies to the latest version (MAY INCLUDE BREAKING CHANGES)
        - ```lib:update:doctor``` - Run NCU in "doctor" mode to update all libraries - uses unit tests to see if any individual update breaks the system
            - For more info, run ```npx ncu --doctor```
        - ```lib:unused``` - Checks for unused dependencies
    - ```applyProjectTemplate``` - Convience macro to replace ```npx applyProjectTemplate```

---
_Source: https://npm.io/package/@soptq/node-project-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
