Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-walle-mw committed Aug 24, 2018
0 parents commit 663b607
Show file tree
Hide file tree
Showing 14 changed files with 6,890 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# Generated
dist/

# rollup cache
.rpt2_cache

# Jetbrains
.idea
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
src/
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
sudo: required

language: node_js

node_js:
- '10'

cache:
directories:
- ~/.npm

notifications:
email: true

before_install:
- npm install -g yarn@latest

install:
- yarn install

script:
- yarn lint
- yarn test --coverage
- yarn build
- yarn coveralls

after_success:
- yarn travis-deploy-once "yarn semantic-release"

branches:
except:
- /^v\d+\.\d+\.\d+$/
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# typescript-lib-boilerplate

A boilerplate to create typescript libaries with
* rollup
* jest
* travis
* coveralls
* semantic-release
28 changes: 28 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"globals": {
"ts-jest": {
"useBabelrc": true,
"tsConfigFile": "./tsconfig.spec.json"
}
},
"testURL": "http://localhost/",
"transform": {
"^.+\\.tsx?$": "ts-jest",
"^.+\\.jsx?$": "<rootDir>/node_modules/babel-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"moduleNameMapper": {
"^~(.*)$": "<rootDir>/src/$1",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(svg)$": "<rootDir>/__mocks__/svgMock.js",
"\\.(css)$": "<rootDir>/__mocks__/styleMock.js"
}
}
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "typescript-lib-boilerplate",
"version": "0.0.0-development",
"main": "dist/index.js",
"repository": "git@github.com:TobiasWalle/typescript-lib-boilerplate.git",
"author": "Tobias Walle",
"license": "MIT",
"private": false,
"scripts": {
"prepublish": "run-s validate build",
"validate": "run-s check-types lint test",
"check-types": "tsc --noEmit",
"test": "jest --config jest.config.json",
"lint": "tslint -p tsconfig.json",
"build": "run-s build:clear build:bundle",
"build:clear": "rimraf ./dist",
"build:bundle": "rimraf ./dist",
"coveralls": "cat coverage/lcov.info | node node_modules/.bin/coveralls",
"setup-semantic-release": "semantic-release-cli setup",
"travis-deploy-once": "travis-deploy-once",
"semantic-release": "semantic-release"
},
"devDependencies": {
"@types/jest": "^23.3.1",
"@types/node": "^10.9.1",
"coveralls": "^3.0.2",
"jest": "^23.5.0",
"npm-run-all": "^4.1.3",
"rimraf": "^2.6.2",
"rollup": "^0.64.1",
"rollup-plugin-typescript": "^0.8.1",
"rollup-plugin-typescript2": "^0.16.1",
"semantic-release": "^15.9.9",
"semantic-release-cli": "^4.0.7",
"ts-jest": "^23.1.4",
"tslint": "^5.11.0",
"typescript": "^3.0.1",
"travis-deploy-once": "^5.0.2"
}
}
13 changes: 13 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import typescript from 'rollup-plugin-typescript2';

export default {
input: 'src/index.ts',
output: {
format: 'cjs',
file: 'dist/index.js',
sourcemap: true,
},
plugins: [
typescript()
]
}
11 changes: 11 additions & 0 deletions src/hello-world.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { sayHello } from './hello-world';

describe('sayHello', () => {
it('should say hello', () => {
console.info = jest.fn();

sayHello('User');

expect(console.info).toHaveBeenCalledWith('Hello User');
});
});
3 changes: 3 additions & 0 deletions src/hello-world.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function sayHello(name: string): void {
console.info(`Hello ${name}`);
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './hello-world';
28 changes: 28 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"pretty": true,
"target": "es6",
"module": "esnext",
"lib": [
"esnext",
"DOM"
],
"jsx": "react",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"composite": false,
"strict": true,
"noUnusedLocals": true,
"moduleResolution": "node",
"types": [
"node",
"jest"
],
"outDir": "./dist",
"esModuleInterop": true
},
"include": [
"src/**/*"
]
}
10 changes: 10 additions & 0 deletions tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs"
},
"include": [
"./src/**/*.spec.ts",
"./src/**/*.spec.tsx"
]
}
22 changes: 22 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"quotemark": [true, "single", "jsx-double"],
"interface-name": false,
"no-empty-interface": false,
"arrow-parens": false,
"variable-name": false,
"no-empty": false,
"object-literal-sort-keys": false,
"trailing-comma": false,
"no-console": [true, "log"],
"max-line-length": [false],
"no-unused-expression": [true, "allow-tagged-template"],
"no-namespace": false
},
"rulesDirectory": []
}
Loading

0 comments on commit 663b607

Please sign in to comment.