Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Nov 7, 2019
0 parents commit c62c8c4
Show file tree
Hide file tree
Showing 13 changed files with 8,700 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = function(api) {
const plugins = [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-object-rest-spread',
]
const presets = [
[
'@babel/preset-env',
api.env('es5')
? { forceAllTransforms: true }
: { targets: { node: 'current' } },
],
]

if (api.env(['test', 'coverage', 'es5'])) {
plugins.push('@babel/plugin-transform-runtime')
}
if (api.env('coverage')) {
plugins.push('babel-plugin-istanbul')
}

return { plugins, presets }
}
38 changes: 38 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 2
jobs:
build:
docker:
- image: circleci/node:10

steps:
- checkout
- restore_cache:
name: Restore Yarn Package Cache
keys:
- v1-yarn-packages-{{ checksum "yarn.lock" }}

- run:
name: Setup NPM Token
command: |
yarn config set registry "https://registry.npmjs.org/"
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
echo "registry=https://registry.npmjs.org/" >> .npmrc
- run:
name: Install Dependencies
command: yarn install --frozen-lockfile
- save_cache:
name: Save Yarn Package Cache
key: v1-yarn-packages-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn

- run:
name: build
command: yarn run prepublishOnly
- run:
name: upload test coverage
command: yarn codecov || true
- run:
name: release
command: yarn run semantic-release || true
13 changes: 13 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"@jedwards1211/eslint-config",
"eslint-config-prettier",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint/eslint-plugin"],
"env": {
"es6": true
}
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage
.nyc_output
node_modules
es
.eslintcache
/*.js
/*.js.flow
/*.d.ts
!/.babelrc.js
12 changes: 12 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**
!**/*.js
!**/*.js.flow
!**/*.d.ts
!/*.md
!yarn.lock
/src
/test
/coverage
/flow-typed
__tests__
/.*
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016-present Andy Edwards

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# typescript-library-skeleton

[![CircleCI](https://circleci.com/gh/jedwards1211/typescript-library-skeleton.svg?style=svg)](https://circleci.com/gh/jedwards1211/typescript-library-skeleton)
[![Coverage Status](https://codecov.io/gh/jedwards1211/typescript-library-skeleton/branch/master/graph/badge.svg)](https://codecov.io/gh/jedwards1211/typescript-library-skeleton)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![npm version](https://badge.fury.io/js/typescript-library-skeleton.svg)](https://badge.fury.io/js/typescript-library-skeleton)

This is my personal skeleton for creating an typescript library npm package. You are welcome to use it.

## Quick start

```sh
npx 0-60 clone https://github.com/jedwards1211/typescript-library-skeleton.git
```

## Tools used

- babel 7
- typescript
- mocha
- chai
- istanbul
- nyc
- eslint
- prettier
- husky
- semantic-release
- renovate
- Circle CI
- Codecov.io
144 changes: 144 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"name": "typescript-library-skeleton",
"version": "0.0.0-development",
"description": "my personal ES2015 library project skeleton",
"main": "index.js",
"sideEffects": false,
"scripts": {
"lint": "eslint $npm_package_config_lint",
"lint:fix": "eslint $npm_package_config_lint",
"lint:watch": "esw --watch $npm_package_config_lint",
"prettier": "prettier --write $npm_package_config_prettier",
"prettier:check": "prettier --list-different $npm_package_config_prettier",
"tsc": "tsc --noEmit",
"tsc:watch": "npm run tsc -- --watch",
"clean": "rimraf es lib $(cd src; ls) *.js *.d.ts",
"build": "npm run clean && npm run build:types && npm run build:js",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir es --extensions \".ts\" --source-maps inline && cross-env BABEL_ENV=es5 babel src --out-dir . --extensions \".ts\"",
"test": "cross-env NODE_ENV=test BABEL_ENV=es5 mocha $npm_package_config_mocha && cross-env NODE_ENV=test BABEL_ENV=coverage nyc --reporter=lcov --reporter=text mocha $npm_package_config_mocha",
"test:watch": "cross-env NODE_ENV=test BABEL_ENV=test mocha --watch $npm_package_config_mocha",
"test:debug": "cross-env NODE_ENV=test BABEL_ENV=test mocha --inspect-brk $npm_package_config_mocha",
"codecov": "nyc report --reporter=text-lcov > coverage.lcov; codecov",
"prepublishOnly": "npm run clean && npm run prettier:check && npm run lint && npm test && npm run build",
"open:coverage": "open coverage/lcov-report/index.html",
"semantic-release": "semantic-release"
},
"config": {
"lint": "--cache --ext .ts src test",
"prettier": ".babelrc.js *.json *.md *.ts '{src,test}/**/*.ts'",
"mocha": "-r @babel/register test/configure.ts 'test/**/*.ts' 'src/**/*.spec.ts'",
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && npm run lint && npm run tsc",
"commit-msg": "commitlint -e $GIT_PARAMS",
"pre-push": "npm test"
}
},
"lint-staged": {
"*.{js,ts,json,css,md}": [
"prettier --write",
"git add"
]
},
"commitlint": {
"extends": [
"@jedwards1211/commitlint-config"
]
},
"prettier": {
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
},
"nyc": {
"include": [
"src/**/*.ts"
],
"require": [
"@babel/register"
],
"sourceMap": false,
"instrument": false
},
"repository": {
"type": "git",
"url": "https://github.com/jedwards1211/typescript-library-skeleton.git"
},
"keywords": [
"typescript"
],
"author": "Andy Edwards",
"license": "MIT",
"bugs": {
"url": "https://github.com/jedwards1211/typescript-library-skeleton/issues"
},
"homepage": "https://github.com/jedwards1211/typescript-library-skeleton#readme",
"devDependencies": {
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.6",
"@babel/preset-typescript": "^7.7.2",
"@babel/register": "^7.0.0",
"@commitlint/cli": "^6.0.2",
"@commitlint/config-conventional": "^6.0.2",
"@jedwards1211/commitlint-config": "^1.0.0",
"@jedwards1211/eslint-config": "^2.0.0",
"@types/chai": "^4.2.0",
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.6",
"@typescript-eslint/eslint-plugin": "^2.6.1",
"@typescript-eslint/parser": "^2.6.1",
"@typescript-eslint/typescript-estree": "^2.6.1",
"babel-eslint": "^10.0.1",
"babel-plugin-istanbul": "^5.1.0",
"chai": "^4.2.0",
"codecov": "^3.1.0",
"copy": "^0.3.2",
"cross-env": "^5.2.0",
"eslint": "^5.9.0",
"eslint-config-prettier": "^3.3.0",
"eslint-watch": "^4.0.2",
"husky": "^1.1.4",
"istanbul": "^0.4.5",
"lint-staged": "^8.0.4",
"mocha": "^6.2.1",
"nyc": "^13.1.0",
"prettier": "^1.15.2",
"prettier-eslint": "^8.8.2",
"rimraf": "^2.6.0",
"semantic-release": "^15.1.4",
"typescript": "^3.7.2"
},
"dependencies": {
"@babel/runtime": "^7.1.5"
},
"renovate": {
"extends": [
":separateMajorReleases",
":combinePatchMinorReleases",
":ignoreUnstable",
":prImmediately",
":renovatePrefix",
":updateNotScheduled",
":preserveSemverRanges",
":semanticPrefixFixDepsChoreOthers",
":automergeDisabled",
"group:monorepos"
],
"automerge": true,
"major": {
"automerge": false
}
}
}
Empty file added src/index.ts
Empty file.
5 changes: 5 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}
5 changes: 5 additions & 0 deletions test/configure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-env node */

if (process.argv.indexOf('--watch') >= 0) {
before(() => process.stdout.write('\u001b[2J\u001b[1;1H\u001b[3J'))
}
64 changes: 64 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"include": ["./src"],
"exclude": ["node_modules", "./src/spec.ts", "./test"],
"compilerOptions": {
/* Basic Options */
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */

/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
// "declarationDir": "lib" /* Output directory for generated declaration files. */
}
}
Loading

0 comments on commit c62c8c4

Please sign in to comment.