Skip to content

Commit 469614c

Browse files
ortamacklinu
authored andcommitted
feat($dev): Initial work on support for a TypeScript project (#16)
Resolves #3
1 parent 2d210c1 commit 469614c

28 files changed

+433
-123
lines changed

.vscode/settings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files.exclude": {
3+
"**/.git": true,
4+
"generators": true,
5+
"node_modules": true
6+
},
7+
"prettier.semi": false,
8+
"prettier.printWidth": 120,
9+
"prettier.singleQuote": true
10+
}

CONTRIBUTING.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
Thanks for your interest in contributing to this package! Here are some things to consider when getting started in this repo.
44

5-
## Development
5+
## Setup
66

77
* Install yarn and run `yarn install` to install dependencies.
8+
9+
## Development
10+
11+
* Use `npm link` in this folder to make `yo` use this folder for the module module: `generator-danger-plugin`.
12+
* Ensure the babel runner is watching for changes: `yarn build -- --watch`.
13+
* Use `yo danger-plugin` to create a new project using the dev template.
14+
815
* Run tests with `yarn test`
916
* When committing use `yarn commit` instead of `git commit`. This will prompt you to input various fields for a [conventional commit message](https://github.com/semantic-release/semantic-release#default-commit-message-format), which semantic-release uses to determine the next package version number when deploying to NPM (major, minor, patch).

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $ yo danger-plugin
2323

2424
This will create a new directory ready for Danger plugin development with the following technologies:
2525

26-
* [Babel](https://babeljs.io/)
26+
* [Babel](https://babeljs.io/) or [TypeScript](http://www.typescriptlang.org)
2727
* [Jest](http://facebook.github.io/jest/)
2828
* [semantic-release](https://github.com/semantic-release/semantic-release) for simple NPM package deployment from [Travis CI](https://travis-ci.org/)
2929

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"yeoman-generator",
2727
"generator",
2828
"boilerplate",
29-
"danger",
30-
"danger-plugin"
29+
"danger"
3130
],
3231
"author": "Macklin Underdown <[email protected]>",
3332
"license": "MIT",

src/app/__snapshots__/index.test.js.snap

+100-39
Original file line numberDiff line numberDiff line change
@@ -61,42 +61,7 @@ THE SOFTWARE IS PROVIDED \\"AS IS\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
6161
"
6262
`;
6363

64-
exports[`generator:app README.md contains plugin name 1`] = `
65-
"# danger-plugin-fun-time
66-
67-
[![Build Status](https://travis-ci.org/macklinu/danger-plugin-fun-time.svg?branch=master)](https://travis-ci.org/macklinu/danger-plugin-fun-time)
68-
[![npm version](https://badge.fury.io/js/danger-plugin-fun-time.svg)](https://badge.fury.io/js/danger-plugin-fun-time)
69-
[![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)
70-
71-
> Danger plugin that tells you to have a fun time
72-
73-
## Usage
74-
75-
Install:
76-
77-
\`\`\`sh
78-
yarn add danger-plugin-fun-time --dev
79-
\`\`\`
80-
81-
At a glance:
82-
83-
\`\`\`js
84-
// dangerfile.js
85-
import funTime from 'danger-plugin-fun-time'
86-
87-
funTime()
88-
\`\`\`
89-
## Changelog
90-
91-
See the GitHub [release history](https://github.com/macklinu/danger-plugin-fun-time/releases).
92-
93-
## Contributing
94-
95-
See [CONTRIBUTING.md](contributing.md).
96-
"
97-
`;
98-
99-
exports[`generator:app package.json fills package.json with correct information 1`] = `
64+
exports[`generator:app package.json fills package.json with correct JS information 1`] = `
10065
Object {
10166
"author": Object {
10267
"email": "[email protected]",
@@ -157,9 +122,105 @@ Object {
157122
"commit": "git-cz",
158123
"commitmsg": "validate-commit-msg",
159124
"docs": "esdoc -c .esdoc.json",
125+
"lint": "tslint \\"src/**/*.ts\\"",
126+
"precommit": "lint-staged",
127+
"predocs": "rm -rf docs/",
128+
"prepublish": "npm run build",
129+
"prettier": "prettier",
130+
"prettier-project": "npm run prettier-write -- 'src/**/*.{ts,tsx}'",
131+
"prettier-write": "npm run prettier -- --parser typescript --no-semi --trailing-comma es5 --write --print-width 120",
132+
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
133+
"test": "jest",
134+
},
135+
"types": "types/index.d.ts",
136+
"version": "0.0.0-development",
137+
}
138+
`;
139+
140+
exports[`generator:app package.json fills package.json with correct TS information 1`] = `
141+
Object {
142+
"author": Object {
143+
"email": "[email protected]",
144+
"name": "Macklin Underdown",
145+
},
146+
"bugs": Object {
147+
"url": "https://github.com/macklinu/danger-plugin-fun-time/issues",
148+
},
149+
"config": Object {
150+
"commitizen": Object {
151+
"path": "cz-conventional-changelog",
152+
},
153+
},
154+
"description": "Danger plugin that tells you to have a fun time",
155+
"devDependencies": Object {
156+
"@types/jest": "^19.2.4",
157+
"commitizen": "^2.9.6",
158+
"cz-conventional-changelog": "^2.0.0",
159+
"danger": "*",
160+
"husky": "^0.13.3",
161+
"jest": "^20.0.1",
162+
"lint-staged": "^3.4.1",
163+
"prettier": "^1.3.1",
164+
"semantic-release": "^6.3.6",
165+
"ts-jest": "^20.0.0",
166+
"tslint": "^5.4.3",
167+
"typescript": "^2.3.2",
168+
"validate-commit-msg": "^2.12.1",
169+
},
170+
"engines": Object {
171+
"node": ">=4.0.0",
172+
},
173+
"homepage": "https://github.com/macklinu/danger-plugin-fun-time#readme",
174+
"jest": Object {
175+
"moduleFileExtensions": Array [
176+
"ts",
177+
"tsx",
178+
"js",
179+
],
180+
"testPathIgnorePatterns": Array [
181+
"\\\\.snap$",
182+
"<rootDir>/node_modules/",
183+
],
184+
"testRegex": "(.test)\\\\.(ts|tsx)$",
185+
"transform": Object {
186+
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js",
187+
},
188+
},
189+
"keywords": Array [
190+
"danger",
191+
"danger-plugin",
192+
"fun",
193+
"time",
194+
],
195+
"license": "MIT",
196+
"lint-staged": Object {
197+
"*.@(ts|tsx)": Array [
198+
"tslint --fix",
199+
"npm run prettier-write --",
200+
"git add",
201+
],
202+
},
203+
"main": "dist/index.js",
204+
"name": "danger-plugin-fun-time",
205+
"optionalDependencies": Object {
206+
"esdoc": "^0.5.2",
207+
},
208+
"repository": Object {
209+
"type": "git",
210+
"url": "https://github.com/macklinu/danger-plugin-fun-time.git",
211+
},
212+
"scripts": Object {
213+
"build": "tsc",
214+
"commit": "git-cz",
215+
"commitmsg": "validate-commit-msg",
216+
"docs": "esdoc -c .esdoc.json",
217+
"lint": "tslint \\"src/**/*.ts\\"",
160218
"precommit": "lint-staged",
161219
"predocs": "rm -rf docs/",
162220
"prepublish": "npm run build",
221+
"prettier": "prettier",
222+
"prettier-project": "npm run prettier-write -- 'src/**/*.{ts,tsx}'",
223+
"prettier-write": "npm run prettier -- --parser typescript --no-semi --trailing-comma es5 --write --print-width 120",
163224
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
164225
"test": "jest",
165226
},
@@ -186,13 +247,13 @@ exports[`generator:app src/ generates test file based on plugin name 1`] = `
186247
`;
187248

188249
exports[`generator:app types/ generates TypeScript test file 1`] = `
189-
"import jestTestRunner from './'
250+
"import funTime from './'
190251
191-
jestTestRunner()
252+
funTime()
192253
"
193254
`;
194255

195256
exports[`generator:app types/ generates TypeScript type defintion 1`] = `
196-
"export default function jestTestRunner(): void
257+
"export default function funTime(): void
197258
"
198259
`;

src/app/defaults.js

-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export const defaultPackageJson = {
1818
node: '>=4.0.0',
1919
},
2020
devDependencies: {
21-
'babel-cli': '^6.24.1',
22-
'babel-jest': '^20.0.1',
23-
'babel-preset-env': '^1.4.0',
2421
commitizen: '^2.9.6',
2522
'cz-conventional-changelog': '^2.0.0',
2623
husky: '^0.13.3',
@@ -29,7 +26,6 @@ export const defaultPackageJson = {
2926
prettier: '^1.3.1',
3027
'semantic-release': '^6.3.6',
3128
typescript: '^2.3.2',
32-
'typings-tester': '^0.2.2',
3329
'validate-commit-msg': '^2.12.1',
3430
},
3531
optionalDependencies: {

0 commit comments

Comments
 (0)