├── .editorconfig ├── .eslintrc.js ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── docs ├── README.md ├── deploy.md ├── installation.md ├── template-notes │ ├── README.md │ ├── about.md │ ├── customization.md │ └── related-projects.md └── usage.md ├── package.json └── src └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | 7 | [*.md] 8 | indent_size = 4 9 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-undef 2 | module.exports = { 3 | root: true, 4 | env: { 5 | browser: true, 6 | es2020: true 7 | }, 8 | extends: 'eslint:recommended', 9 | parserOptions: { 10 | ecmaVersion: 12, 11 | sourceType: 'module' 12 | }, 13 | rules: { 14 | semi: [ 15 | 2, 16 | 'always' 17 | ] 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | push: 5 | branches: master 6 | paths-ignore: 7 | - "docs/**" 8 | 9 | pull_request: 10 | branches: master 11 | paths-ignore: 12 | - "docs/**" 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - name: Checkout 🛎️ 20 | uses: actions/checkout@master 21 | 22 | - name: Install 🔧 23 | run: npm install 24 | 25 | - name: Lint 🧐 26 | run: npm run lint:check 27 | 28 | - name: Test 🚨 29 | run: npm test 30 | 31 | - name: Build 🏗️ 32 | run: npm run build 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | build/ 3 | 4 | npm-debug.log* 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // If you install the Editor Config extension, you can delete this file. Also you need some Prettier extension for a Prettier setting to work. 3 | "editor.tabSize": 2, 4 | "prettier.tabWidth": 2 5 | } 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 - 2021, 2024 MichaelCurrin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node Project Template 2 | > Starter template for creating a Node.js project including docs and a deploy pipeline 3 | 4 | 5 | 6 | [![Node CI](https://github.com/MichaelCurrin/node-project-template/workflows/Node%20CI/badge.svg)](https://github.com/MichaelCurrin/node-project-template/actions?query=workflow:"Node+CI") 7 | [![GitHub tag](https://img.shields.io/github/tag/MichaelCurrin/node-project-template)](https://github.com/MichaelCurrin/node-project-template/releases/) 8 | [![License](https://img.shields.io/badge/License-MIT-blue)](#license) 9 | 10 | [![Made with Node](https://img.shields.io/badge/dynamic/json?label=node&query=%24.engines%5B%22node%22%5D&url=https%3A%2F%2Fraw.githubusercontent.com%2FMichaelCurrin%2Fnode-project-template/%2Fmaster%2Fpackage.json&logo=node.js&logoColor=white)](https://nodejs.org "Go to Node.js homepage") 11 | 12 |
13 | 14 | node icon 18 | 19 |
20 | 21 |
22 | 23 | 24 | 25 |
26 | 27 | [![Use this template](https://img.shields.io/badge/Generate-Use_this_template-2ea44f?style=for-the-badge)](https://github.com/MichaelCurrin/node-project-template/generate) 28 | 29 |
30 | 31 | 32 | ## Preview 33 | 34 | _This is a placeholder section for a screenshot of your shiny new web app or CLI tool_. 35 | 36 | 37 | 38 |
39 | Sample screenshot 40 |
41 | 42 | 43 | ## Sample usage 44 | 45 | _TODO: Add just a few lines to show how to use your application - some samples below._ 46 | 47 | Run with NPX: 48 | 49 | ```sh 50 | $ npx foo 51 | ``` 52 | 53 | Install and run as a CLI tool: 54 | 55 | ```sh 56 | $ npm install foo 57 | $ foo --help 58 | ``` 59 | 60 | Use in your JS app: 61 | 62 | ```javascript 63 | import { foo } from "bar"; 64 | 65 | foo(123) 66 | ``` 67 | 68 | 69 | ## Documentation 70 | > How to install, run and deploy this project 71 | 72 |
73 | 74 | [![View Project Docs](https://img.shields.io/badge/View-Project_Docs-blue?style=for-the-badge)](/docs/) 75 | 76 |
77 | 78 | 79 | 80 | See the [Template Notes](/docs/template-notes/) section of the docs for info on this template and how to use it. 81 | 82 | 83 | ## License 84 | 85 | Released under [MIT](/LICENSE) by [@MichaelCurrin](https://github.com/MichaelCurrin). 86 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Node Project Template docs 2 | 3 | - [Installation](installation.md) 4 | - [Usage](usage.md) 5 | - [Deploy](deploy.md) 6 | -------------------------------------------------------------------------------- /docs/deploy.md: -------------------------------------------------------------------------------- 1 | # Deploy 2 | 3 | 4 | ## Build app 5 | 6 | Run a local production-optimized build. 7 | 8 | ```sh 9 | $ npm run build 10 | ``` 11 | 12 | 13 | ## Release 14 | 15 | This will run checks and tests, increment the tag version and push the new tagged commit. 16 | 17 | ```sh 18 | $ npm version minor 19 | ``` 20 | 21 | 22 | ## Deploy pipeline 23 | 24 | This project will run checks and build steps on [GitHub Actions](https://github.com/features/actions) on every commit or push on the `master` branch. 25 | 26 | See the [workflow](/.github/workflows/main.yml) config file. 27 | 28 | See results on the [Actions](https://github.com/MichaelCurrin/node-project-template/actions/) tab. 29 | 30 | 31 | ### Note 32 | > A comment on the limitation of this template project 33 | 34 | Add your deploy instructions here. Such as now to deploy to GH Pages, Netlify, Vercel, etc. 35 | 36 | With the current flow **nothing is persisted** after a build, so this on a CI flow and not a CD flow. 37 | 38 | If you want to deploy your React/Vue app to GitHub Pages, follow this page: [GH Pages workflow](https://github.com/MichaelCurrin/code-cookbook/blob/master/recipes/ci-cd/github-actions/workflows/node/gh-pages.md). 39 | -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | > How to install the app locally 3 | 4 | 5 | ## 1. Install system dependencies 6 | 7 | Install Node.js - follow these [instructions](https://gist.github.com/MichaelCurrin/aa1fc56419a355972b96bce23f3bccba). 8 | 9 | 10 | ## 2. Clone 11 | 12 | ```sh 13 | $ git clone git@github.com:MichaelCurrin/node-project-template.git 14 | $ cd node-project-template 15 | ``` 16 | 17 | ## 3. Install project dependencies 18 | 19 | ```sh 20 | $ npm install 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/template-notes/README.md: -------------------------------------------------------------------------------- 1 | # Template notes 2 | 3 | This directory includes notes for developers working with the template or using it. 4 | 5 | Use it as a guide when creating a project from the template repo and then you can delete this directory. 6 | -------------------------------------------------------------------------------- /docs/template-notes/about.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | 6 | 7 | This is a template project for new JavaScript projects, whether making a frontend app, server-side app or CLI tool. 8 | 9 | 10 | ## How to use this template 11 | 12 |
13 | 14 | [![Use this template](https://img.shields.io/badge/Use_template-Generate-2ea44f?style=for-the-badge&logo=github)](https://github.com/MichaelCurrin/node-project-template/generate) 15 | 16 |
17 | 18 | 1. Click the button above to generate a new repo based on this template. 19 | 2. Install the app locally using the [Installation](/docs/installation.md) doc. 20 | 3. Run it locally using the [Usage](/docs/usage.md) docs. 21 | 3. Follow the [Customization](/docs/customization.md) doc. 22 | 23 | 24 | ## What is included 25 | 26 | This template saves you time as it already contains boilerplate that will work for most projects: 27 | 28 | - Base files 29 | - [.gitignore](/.gitignore) file 30 | - [package.json](/package.json) file 31 | - [src](/src/) directory. 32 | - Linting with ESLint. 33 | - Boilerplate documentation in the [docs](/docs/) directory. 34 | - A CI [workflow](/.github/workflows/main.yml) to lint, test and build using GitHub Actions 35 | 36 | The `test` command in the package file is just a placeholder - you'll have to setup a test suite yourself as recommended in the Customization doc. 37 | 38 | 39 | ## Purpose 40 | 41 | Why does this project exist? I'm tired of running `git init` and `npm init` and starting with an empty repo each time. I know mostly what my git configs, `package.json` details and docs will look like and I don't want to have to type from memory or copy and paste - I want to get to the core code. 42 | 43 | So now I just use this repo as a starting point and reference, to make new projects faster to setup and also to keep them consistent. 44 | 45 | This project is deliberately open-ended so you can make choices about your own NPM commands and test framework. The only dependency here is _ESLint_. 46 | -------------------------------------------------------------------------------- /docs/template-notes/customization.md: -------------------------------------------------------------------------------- 1 | # Customization 2 | > Customize this app to make it your own 3 | 4 | Things to do once you've created a new project from this one: 5 | 6 | - [ ] Update title and description of the docs. 7 | - [ ] Add/update badges. 8 | - [ ] Update package.json with scripts and dependencies. 9 | - [ ] Develop your core app. 10 | - [ ] Choose a test framework (Jest, Jasmine, Enzyme, Mocha...) and write tests with it. Bonus points if you write tests before your app for true TDD! 11 | - [ ] Customize lint config: 12 | - Edit the exiting [.eslintrc.js](/.eslintrc.js) config. 13 | - Or create a new one: 14 | ```sh 15 | rm .eslintrc.js 16 | npx eslint --init 17 | ``` 18 | - Or add an `eslintConfig` field to [package.json](/package.json). 19 | - [ ] Update ignore file. 20 | - If you use Yarn, take out `npm-debug.log*` and add: 21 | ``` 22 | yarn-debug.log* 23 | yarn-error.log* 24 | ``` 25 | - [ ] Add other build tools like Prettier, Husky, Webpack, Vite, or Babel. 26 | - [ ] Customize your build flow: 27 | - For now JS scripts are just copied to `build` but you might use `dist` or `out` instead. 28 | - You might use TypeScript or Babel to handle this for you and then split out `build` and `compile` steps. 29 | - Or maybe you have no build command and so this can beremoved from [package.json](/package.json). 30 | - [ ] Update docs such as usage instructions and add sample image to `Preview` section. 31 | - [ ] Optional - setup the docs directory to server as a _Docsify_ docs site, then enable as GitHub Pages site. See my [Docsify quickstart instructions](https://github.com/MichaelCurrin/docsify-js-template#b-add-docsify-to-an-existing-projects-docs-directory) 32 | - [ ] Update license file details if needed (change type and put on your own name). 33 | - [ ] Customize CI/CD flow. 34 | - See [Deploy](deploy.md) doc for how this currently works. 35 | - If you need a more advanced workflow for GitHub Actions, see [Node workflow samples](https://github.com/MichaelCurrin/code-cookbook/tree/master/recipes/ci-cd/github-actions/workflows/node). 36 | - [ ] Add credits 37 | - [ ] Add a link back to the original repo in - https://github.com/MichaelCurrin/node-project-template 38 | - [ ] Copy the original license and then put your own name in `LICENSE` file. 39 | ```sh 40 | $ cp LICENSE LICENSE-source 41 | $ edit LICENSE 42 | ``` 43 | - [ ] Delete unneeded sections in `README.md` doc. 44 | - [ ] Delete the `template-notes` directory in `docs/`. 45 | - [ ] Containerize your app. See [Docker Node app quickstart](https://github.com/MichaelCurrin/docker-quickstarts/tree/master/examples/node_app) 46 | -------------------------------------------------------------------------------- /docs/template-notes/related-projects.md: -------------------------------------------------------------------------------- 1 | # Related Projects 2 | 3 | 4 | ## Python template 5 | 6 | - [![MichaelCurrin - py-project-template](https://img.shields.io/static/v1?label=MichaelCurrin&message=py-project-template&color=blue&logo=github)](https://github.com/MichaelCurrin/py-project-template) 7 | 8 | 9 | ## Deno template 10 | 11 | - [![MichaelCurrin - deno-project-template](https://img.shields.io/static/v1?label=MichaelCurrin&message=deno-project-template&color=blue&logo=github)](https://github.com/MichaelCurrin/deno-project-template) 12 | 13 | 14 | ## JavaScript package quickstarts 15 | 16 | If you are looking for some simple JS projects which are more detailed than this one, see my other repos: 17 | 18 | ### App frameworks 19 | 20 | - [react-quickstart](https://github.com/MichaelCurrin/react-quickstart) 21 | - Build and deploy a React app to GH Pages using GitHub Actions 22 | - [react-native-quickstart](https://github.com/MichaelCurrin/react-native-quickstart) 23 | - [preact-quickstart](https://github.com/MichaelCurrin/preact-quickstart) 24 | - [vue-quickstart](https://github.com/MichaelCurrin/vue-quickstart) 25 | - [vue-typescript-quickstart](https://github.com/MichaelCurrin/vue-typescript-quickstart) 26 | - [next-quickstart](https://github.com/MichaelCurrin/next-quickstart) 27 | 28 | ### Other 29 | 30 | - [vsc-extension-quickstart](https://github.com/MichaelCurrin/vsc-extension-quickstart) 31 | - [javascript-bundling-quickstarts](https://github.com/MichaelCurrin/javascript-bundling-quickstarts) 32 | - A couple of JS projects that use a mixture of bundle and compile tools like React, TypeScript and Babel. 33 | - [docsify-js-template](https://github.com/MichaelCurrin/docsify-js-template) 34 | - For running a markdown-based docs site without writing code. 35 | -------------------------------------------------------------------------------- /docs/usage.md: -------------------------------------------------------------------------------- 1 | # Usage 2 | > How to run the app locally 3 | 4 | 5 | ## Lint 6 | 7 | ```sh 8 | $ npm run lint:fix 9 | ``` 10 | 11 | 12 | ## Run tests 13 | 14 | ```sh 15 | $ npm test 16 | ``` 17 | 18 | 19 | ## Start dev server 20 | 21 | ```sh 22 | $ npm start 23 | ``` 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-project-template", 3 | "version": "1.3.0", 4 | "scripts": { 5 | "lint:check": "eslint .", 6 | "lint:fix": "eslint . --fix", 7 | "test": "echo 'TODO: Add a test runner and then update this command'", 8 | "serve": "echo 'TODO: Add your serve command here", 9 | "start": "npm run serve", 10 | "build": "mkdir -p build && cp src/*.js build # TODO: Replace with your build command", 11 | "preversion": "git fetch --tags && npm run lint:check && npm test", 12 | "version": "npm run build", 13 | "postversion": "git push --follow-tags" 14 | }, 15 | "devDependencies": { 16 | "eslint": "^7.7.0" 17 | }, 18 | "engines": { 19 | "node": ">=14" 20 | }, 21 | "displayName": "Node Project Template", 22 | "description": "Template for creating Node.js projects including docs and a deploy pipeline", 23 | "author": "MichaelCurrin", 24 | "license": "MIT", 25 | "homepage": "https://github.com/MichaelCurrin/node-project-template#readme", 26 | "repository": { 27 | "type": "git", 28 | "url": "https://github.com/MichaelCurrin/node-project-template" 29 | }, 30 | "bugs": "https://github.com/MichaelCurrin/node-project-template/issues", 31 | "keywords": [ 32 | "template", 33 | "skeleton", 34 | "quickstart" 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | console.log('Hello, world!'); 2 | --------------------------------------------------------------------------------