Skip to content

Commit fe82aea

Browse files
authored
feat(typescript): Migrate to TypeScript (#1)
* feat(typescript): Migrate to TypeScript * build(scripts): Create typedoc script * docs(readme): Use HTTPS to get gzip size shield * ci(travis): Remove deploy-docs script since we deploy to Netlify * build: Change the package to be semantically released * chore(dependencies): Remove unused dependencies * ci(codecov): Replace coveralls for codecov
1 parent 512852d commit fe82aea

File tree

14 files changed

+9229
-170
lines changed

14 files changed

+9229
-170
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
max_line_length = 100
10+
indent_size = 2
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.gitignore

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
node_modules/
22
dist/
3-
yarn.lock
43
*-lock.json
5-
.nyc_output
4+
.nyc_output
5+
coverage
6+
.DS_Store
7+
*.log
8+
.vscode
9+
.idea
10+
compiled
11+
.awcache
12+
.rpt2_cache
13+
docs

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: node_js
2+
cache:
3+
directories:
4+
- ~/.npm
5+
notifications:
6+
email: false
7+
node_js:
8+
- '10'
9+
- '11'
10+
- '8'
11+
script:
12+
- npm run test:prod && npm run build
13+
after_success:
14+
- npm run travis-deploy-once "npm run report-coverage"
15+
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then npm run travis-deploy-once "npm run semantic-release"; fi
16+
branches:
17+
except:
18+
- /^v\d+\.\d+\.\d+$/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<p align="center">
66
<a href="https://www.npmjs.org/package/format-string-by-pattern"><img src="https://img.shields.io/npm/v/format-string-by-pattern.svg?style=flat" alt="npm"></a>
77
<a href="https://david-dm.org/arthurdenner/format-string-by-pattern"><img src="https://david-dm.org/arthurdenner/format-string-by-pattern/status.svg" alt="dependencies Status"></a>
8-
<a href="https://unpkg.com/format-string-by-pattern/dist/format-string-by-pattern.umd.js"><img src="http://img.badgesize.io/https://unpkg.com/format-string-by-pattern/dist/format-string-by-pattern.umd.js?compression=gzip" alt="gzip size"></a>
8+
<a href="https://unpkg.com/format-string-by-pattern/dist/format-string-by-pattern.umd.js"><img src="https://img.badgesize.io/https://unpkg.com/format-string-by-pattern/dist/format-string-by-pattern.umd.js?compression=gzip" alt="gzip size"></a>
99
<a href="https://packagephobia.now.sh/result?p=format-string-by-pattern"><img src="https://packagephobia.now.sh/badge?p=format-string-by-pattern" alt="install size"></a>
1010
</p>
1111

jest.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
transform: {
3+
'.(ts|tsx)': 'ts-jest',
4+
},
5+
testEnvironment: 'node',
6+
testRegex: '(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$',
7+
moduleFileExtensions: ['ts', 'tsx', 'js'],
8+
coveragePathIgnorePatterns: ['/node_modules/', '/test/'],
9+
coverageThreshold: {
10+
global: {
11+
branches: 90,
12+
functions: 95,
13+
lines: 95,
14+
statements: 95,
15+
},
16+
},
17+
collectCoverageFrom: ['src/*.{js,ts}'],
18+
};

package.json

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
{
22
"name": "format-string-by-pattern",
3-
"version": "1.0.0",
3+
"version": "0.0.0-semantically-released",
44
"description": "A module that formats a string based on a pattern",
5-
"main": "dist/format-string-by-pattern.js",
6-
"umd:main": "dist/format-string-by-pattern.umd.js",
7-
"module": "dist/format-string-by-pattern.m.js",
8-
"source": "src/format-string-by-pattern.js",
5+
"main": "dist/format-string-by-pattern.umd.js",
6+
"module": "dist/format-string-by-pattern.es5.js",
7+
"typings": "dist/types/format-string-by-pattern.d.ts",
98
"author": {
109
"name": "Arthur Denner",
1110
"email": "[email protected]"
1211
},
1312
"license": "MIT",
1413
"scripts": {
15-
"build": "npm run test && microbundle -o dist -i src",
16-
"prepublishOnly": "git push && git push --tags",
17-
"preversion": "npm run build",
18-
"test": "xo && nyc ava",
19-
"test:watch": "npm test -- --watch"
14+
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
15+
"prebuild": "rimraf dist docs",
16+
"build": "tsc --module commonjs && rollup -c rollup.config.ts && npm run typedoc",
17+
"start": "rollup -c rollup.config.ts -w",
18+
"test": "jest --coverage",
19+
"test:watch": "jest --coverage --watch",
20+
"test:prod": "npm run lint && npm run test -- --no-cache",
21+
"typedoc": "typedoc src",
22+
"report-coverage": "cat ./coverage/lcov.info | codecov",
23+
"commit": "git-cz",
24+
"semantic-release": "semantic-release",
25+
"semantic-release-prepare": "ts-node tools/semantic-release-prepare",
26+
"precommit": "lint-staged",
27+
"travis-deploy-once": "travis-deploy-once"
2028
},
2129
"files": [
2230
"dist"
@@ -26,22 +34,60 @@
2634
"string",
2735
"pattern"
2836
],
29-
"xo": {
30-
"prettier": true,
31-
"space": true
32-
},
33-
"devDependencies": {
34-
"ava": "1.0.0-beta.4",
35-
"microbundle": "^0.4.4",
36-
"nyc": "^11.7.1",
37-
"xo": "^0.21.0"
38-
},
3937
"repository": {
4038
"type": "git",
4139
"url": "https://github.com/arthurdenner/format-string-by-pattern.git"
4240
},
4341
"bugs": {
4442
"url": "https://github.com/arthurdenner/format-string-by-pattern/issues"
4543
},
46-
"homepage": "https://github.com/arthurdenner/format-string-by-pattern#readme"
44+
"homepage": "https://github.com/arthurdenner/format-string-by-pattern#readme",
45+
"engines": {
46+
"node": ">=6.0.0"
47+
},
48+
"lint-staged": {
49+
"{src,test}/**/*.ts": [
50+
"prettier --write",
51+
"git add"
52+
]
53+
},
54+
"config": {
55+
"commitizen": {
56+
"path": "node_modules/cz-conventional-changelog"
57+
}
58+
},
59+
"commitlint": {
60+
"extends": [
61+
"@commitlint/config-conventional"
62+
]
63+
},
64+
"devDependencies": {
65+
"@commitlint/cli": "^7.1.2",
66+
"@commitlint/config-conventional": "^7.1.2",
67+
"@types/jest": "^23.3.2",
68+
"@types/node": "^10.11.0",
69+
"codecov.io": "^0.1.6",
70+
"commitizen": "^3.0.0",
71+
"cross-env": "^5.2.0",
72+
"cz-conventional-changelog": "^2.1.0",
73+
"husky": "^1.0.1",
74+
"jest": "^23.6.0",
75+
"jest-config": "^23.6.0",
76+
"lint-staged": "^8.0.0",
77+
"prettier": "^1.14.3",
78+
"rimraf": "^2.6.2",
79+
"rollup": "^0.67.0",
80+
"rollup-plugin-sourcemaps": "^0.4.2",
81+
"rollup-plugin-terser": "^4.0.4",
82+
"rollup-plugin-typescript2": "^0.18.0",
83+
"semantic-release": "^15.13.3",
84+
"travis-deploy-once": "^5.0.9",
85+
"ts-jest": "^23.10.2",
86+
"ts-node": "^7.0.1",
87+
"tslint": "^5.11.0",
88+
"tslint-config-prettier": "^1.15.0",
89+
"tslint-config-standard": "^8.0.1",
90+
"typedoc": "^0.12.0",
91+
"typescript": "^3.0.3"
92+
}
4793
}

rollup.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { terser } from 'rollup-plugin-terser';
2+
import sourceMaps from 'rollup-plugin-sourcemaps';
3+
import typescript from 'rollup-plugin-typescript2';
4+
5+
const pkg = require('./package.json');
6+
7+
export default {
8+
input: 'src/index.ts',
9+
output: [
10+
{ file: pkg.main, name: 'format-string-by-pattern', format: 'umd', sourcemap: true },
11+
{ file: pkg.module, format: 'es', sourcemap: true },
12+
],
13+
watch: {
14+
include: 'src/**',
15+
},
16+
plugins: [typescript({ useTsconfigDeclarationDir: true }), sourceMaps(), terser()],
17+
};

src/index.test.js

Lines changed: 0 additions & 138 deletions
This file was deleted.

0 commit comments

Comments
 (0)