Skip to content

Commit

Permalink
feat(project): add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyBeldone committed May 16, 2019
1 parent 55b3cec commit 944a631
Show file tree
Hide file tree
Showing 16 changed files with 6,692 additions and 419 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": [
[
"@babel/env"
]
]
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/*
dist/*
29 changes: 29 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"extends": ["airbnb-base", "prettier"],
"plugins": ["prettier", "jest"],
"parser": "babel-eslint",
"rules": {
"prettier/prettier": "error",
"no-console": 0,
"max-len": [
"error",
{
"code": 80,
"ignoreTrailingComments": true,
"ignoreUrls": true,
"ignoreComments": true
}
]
},
"globals": {
"describe": true,
"it": true,
"expect": true
},
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
}
}
64 changes: 63 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
node_modules/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

dist
Empty file added .npmignore
Empty file.
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 80,
"bracketSpacing": true,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 4,
"semi": true,
"arrowParens": "avoid"
}
13 changes: 13 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
["@semantic-release/git", {
"assets": ["package.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
"@semantic-release/github"
]
}
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: node_js
node_js:
- stable
sudo: false
cache: yarn

jobs:
include:
- stage: install
script: yarn
skip_cleanup: true
- stage: test
script: yarn test
skip_cleanup: true
- stage: release
node_js: lts/*
deploy:
if: branch == master && !fork
provider: script
skip_cleanup: true
script:
- npx semantic-release
Empty file added CODE_OF_CONDUCT.md
Empty file.
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing

Contributions are welcome! This package uses [commitizen](https://github.com/commitizen/cz-cli) and [semantic-release](https://github.com/semantic-release/semantic-release) to keep consistent commit messages and versioning according to the standard conventions.

## How to contribute

Suggest a new feature/update by [creating an issue](https://github.com/JimmyBeldone/open-source-starter/issues/new). Once approved, you can do the following:

### Fork this repo

Click "Fork" on the top right of the page and GitHub will clone the repository and add it to your account automatically.

### Download the forked repo

Click "Clone or download" and copy the HTTPS link to your forked repo, and clone the repo to your computer by typing it in your terminal like this:

```bash
git clone <your-HTTPS-link>
```

Which should look like this, for your reference:

```bash
git clone https://github.com/JimmyBeldone/open-source-starter.git
```

### Make your changes

Make your changes to the codebase that you cloned, and make sure to add comments to each line of changes to explain what you did and when ready to make a commit, do the following:

1. `git add .` to all all of the changed files

2. `yarn commit` to run the Commitizen cli prompts for consistent commit messages

- Make sure to include the reference number for the issue that your changes are for when prompted.

### Push to your own GitHub account

After following the steps above on your computer, hit `git push` to push the changes to your GitHub repository.

### Make a pull request

Navigate to the [main page of this package](https://github.com/JimmyBeldone/open-source-starter) again and click "Make pull request" near the top left of the page to start a pull request. Add notes about what you did and make sure to reference the issue that the pull request takes care of in the description.

### Next steps

We'll review your pull request, run tests on it and if all is good, merge it into the main codebase!
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<h1 align="center" style="border-bottom: none;">Open Source Starter </h1>
<h3 align="center">Pre-configured starter for open source Node projects with automated releases</h3>
<p align="center">
<a href="https://travis-ci.com/JimmyBeldone/open-source-starter">
<img alt="travis build" src="https://travis-ci.com/JimmyBeldone/open-source-starter.svg?branch=master">
</a>
<a href="#badge">
<img alt="release number" src="https://badgen.net/github/release/JimmyBeldone/open-source-starter/stable">
</a>
<a href="#badge">
<img alt="dependencies status" src="https://badgen.net/david/dep/JimmyBeldone/open-source-starter">
</a>
<a href="#badge">
<img alt="dev dependencies status" src="https://badgen.net/david/dev/JimmyBeldone/open-source-starter">
</a>
</p>
<p align="center">
<a href="http://commitizen.github.io/cz-cli/">
<img alt="commitizen" src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg">
</a>
<a href="https://github.com/semantic-release/semantic-release">
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
</a>
<a href="https://github.com/prettier/prettier">
<img alt="prettier" src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg">
</a>
<a href="https://github.com/JimmyBeldone/open-source-starter/blob/master/LICENSE">
<img alt="license" src="https://badgen.net/github/license/JimmyBeldone/open-source-starter">
</a>
</p>

This starter provides all necessary setup to quickly start an open source project, with fully automated release, tests, generate `CHANGELOG.md`, version bump, publish to NPM.

## Content

### **[Babel](https://babeljs.io/)** : Use next generation JavaScript

> All `.js` files in `src/` will be compiled with Babel and added in the `dist/` folder
*Config : `.babelrc`*

### **[ESLint](https://eslint.org/)** : A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease

*config: `.eslintrc`*

### **[Prettier](https://prettier.io/)** : Opinionated code formatter

*config: `.prettierrc`*

### **[Husky](https://github.com/typicode/husky)** : Use git hooks with ease

> Here it just call [lint-staged](https://github.com/okonet/lint-staged) on `pre-commit`
*config: `"husky"` in `package.json`*

### **[lint-staged](https://github.com/okonet/lint-staged)** : Run linters against staged git files

> Here it calls [ESLint](https://eslint.org/) and [Prettier](https://prettier.io/) on `git add`
*config: `"lint-staged"` in `package.json`*

### **[Commitizen](https://github.com/commitizen/cz-cli)** : Conventional commit messages CLI

### **[Semantic Release](https://github.com/semantic-release/semantic-release)** : Fully automated version management and package publishing

### **[Jest](https://jestjs.io/)** : JavaScript Testing Framework

> Add your test files either in `src/` with `my-file.spec.js` format, or in the `__tests__` folder at your project root directory
*config : `jest.config.js`*

### **[TravisCI](https://travis-ci.com/)** : Free continuous integration platform for GitHub projects

*config: `.travis.yml`*

## Requirements

- NPM account (signup on [https://www.npmjs.com/](https://www.npmjs.com/))
- TravisCI account (signup on [https://travis-ci.com/](https://travis-ci.com/))

***note:** this repo use TravisCI, but you can use any continuous integration system you want, see **semantic-release-cli [documentation](https://github.com/semantic-release/cli)** for or more informations.*

## Installation

1. Fork or clone this repo `git clone https://github.com/JimmyBeldone/open-source-starter.git`
2. Update the `package.json` file with your repo's information
3. Configure semantic-release with semantic-release-cli : `npx semantic-release-cli setup`.
![semantic-release-cli](https://github.com/semantic-release/semantic-release/raw/master/media/semantic-release-cli.png)
Once you entered the required informations, semantic-release-cli will add the necessary tokens to your Travis repository settings.
4. You're all set !

## Usage

### **Stage a file**

```bash
git add src/my-file.js
```

From now on when you will use `git add` on a file in `src/`, it will be automatically linted and prettified.

### **Use conventional commit**

```bash
yarn commit
```

This script will open [Commitizen](https://github.com/commitizen/cz-cli) to help you write conventional commit

### **Release / Publish**

All you need to do is **merge on master branch**, simple as that.

It will :

1. Triggers Travis build
2. Run your test during Travis build
3. Run semantic-release steps :
- Analyse your commits
- Bump version
- Add release notes
- Generate `CHANGELOG.md`
- Publish to NPM & Github

## License

MIT

Copyright (c) 2019 Jimmy Beldone
48 changes: 48 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// Automatically clear mock calls and instances between every test
clearMocks: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: ["src/**/*.{js,jsx,mjs}"],
collectCoverageFrom: ['src/**/*.js'],

// Ignore coverage
coveragePathIgnorePatterns: ['<rootDir>/dist', '<rootDir>/node_modules'],

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',

// An array of file extensions your modules use
moduleFileExtensions: ['js', 'json'],

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: ["<rootDir>/testSetup.js"],

// The test environment that will be used for testing
testEnvironment: 'jsdom',

// The glob patterns Jest uses to detect test files
testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)+(spec|test).js?(x)'],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ['\\\\node_modules\\\\'],

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: ['<rootDir>/node_modules/'],

// Indicates whether each individual test should be reported during the run
verbose: false,

// Add jest-extended
// setupFilesAfterEnv: ["<rootDir>/test/testSetup.js"]

// transform: {
// '^.+\\.jsx?$': 'babel-jest',
// },
};
Loading

0 comments on commit 944a631

Please sign in to comment.