Skip to content

Commit

Permalink
feat($dev): Initial work on support for a TypeScript project (#16)
Browse files Browse the repository at this point in the history
Resolves #3
  • Loading branch information
orta authored and macklinu committed Jun 14, 2017
1 parent 2d210c1 commit 469614c
Show file tree
Hide file tree
Showing 28 changed files with 433 additions and 123 deletions.
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"files.exclude": {
"**/.git": true,
"generators": true,
"node_modules": true
},
"prettier.semi": false,
"prettier.printWidth": 120,
"prettier.singleQuote": true
}
9 changes: 8 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

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

## Development
## Setup

* Install yarn and run `yarn install` to install dependencies.

## Development

* Use `npm link` in this folder to make `yo` use this folder for the module module: `generator-danger-plugin`.
* Ensure the babel runner is watching for changes: `yarn build -- --watch`.
* Use `yo danger-plugin` to create a new project using the dev template.

* Run tests with `yarn test`
* 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).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $ yo danger-plugin

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

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

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"yeoman-generator",
"generator",
"boilerplate",
"danger",
"danger-plugin"
"danger"
],
"author": "Macklin Underdown <[email protected]>",
"license": "MIT",
Expand Down
139 changes: 100 additions & 39 deletions src/app/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,42 +61,7 @@ THE SOFTWARE IS PROVIDED \\"AS IS\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
"
`;

exports[`generator:app README.md contains plugin name 1`] = `
"# danger-plugin-fun-time
[![Build Status](https://travis-ci.org/macklinu/danger-plugin-fun-time.svg?branch=master)](https://travis-ci.org/macklinu/danger-plugin-fun-time)
[![npm version](https://badge.fury.io/js/danger-plugin-fun-time.svg)](https://badge.fury.io/js/danger-plugin-fun-time)
[![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)
> Danger plugin that tells you to have a fun time
## Usage
Install:
\`\`\`sh
yarn add danger-plugin-fun-time --dev
\`\`\`
At a glance:
\`\`\`js
// dangerfile.js
import funTime from 'danger-plugin-fun-time'
funTime()
\`\`\`
## Changelog
See the GitHub [release history](https://github.com/macklinu/danger-plugin-fun-time/releases).
## Contributing
See [CONTRIBUTING.md](contributing.md).
"
`;

exports[`generator:app package.json fills package.json with correct information 1`] = `
exports[`generator:app package.json fills package.json with correct JS information 1`] = `
Object {
"author": Object {
"email": "[email protected]",
Expand Down Expand Up @@ -157,9 +122,105 @@ Object {
"commit": "git-cz",
"commitmsg": "validate-commit-msg",
"docs": "esdoc -c .esdoc.json",
"lint": "tslint \\"src/**/*.ts\\"",
"precommit": "lint-staged",
"predocs": "rm -rf docs/",
"prepublish": "npm run build",
"prettier": "prettier",
"prettier-project": "npm run prettier-write -- 'src/**/*.{ts,tsx}'",
"prettier-write": "npm run prettier -- --parser typescript --no-semi --trailing-comma es5 --write --print-width 120",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"test": "jest",
},
"types": "types/index.d.ts",
"version": "0.0.0-development",
}
`;

exports[`generator:app package.json fills package.json with correct TS information 1`] = `
Object {
"author": Object {
"email": "[email protected]",
"name": "Macklin Underdown",
},
"bugs": Object {
"url": "https://github.com/macklinu/danger-plugin-fun-time/issues",
},
"config": Object {
"commitizen": Object {
"path": "cz-conventional-changelog",
},
},
"description": "Danger plugin that tells you to have a fun time",
"devDependencies": Object {
"@types/jest": "^19.2.4",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"danger": "*",
"husky": "^0.13.3",
"jest": "^20.0.1",
"lint-staged": "^3.4.1",
"prettier": "^1.3.1",
"semantic-release": "^6.3.6",
"ts-jest": "^20.0.0",
"tslint": "^5.4.3",
"typescript": "^2.3.2",
"validate-commit-msg": "^2.12.1",
},
"engines": Object {
"node": ">=4.0.0",
},
"homepage": "https://github.com/macklinu/danger-plugin-fun-time#readme",
"jest": Object {
"moduleFileExtensions": Array [
"ts",
"tsx",
"js",
],
"testPathIgnorePatterns": Array [
"\\\\.snap$",
"<rootDir>/node_modules/",
],
"testRegex": "(.test)\\\\.(ts|tsx)$",
"transform": Object {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js",
},
},
"keywords": Array [
"danger",
"danger-plugin",
"fun",
"time",
],
"license": "MIT",
"lint-staged": Object {
"*.@(ts|tsx)": Array [
"tslint --fix",
"npm run prettier-write --",
"git add",
],
},
"main": "dist/index.js",
"name": "danger-plugin-fun-time",
"optionalDependencies": Object {
"esdoc": "^0.5.2",
},
"repository": Object {
"type": "git",
"url": "https://github.com/macklinu/danger-plugin-fun-time.git",
},
"scripts": Object {
"build": "tsc",
"commit": "git-cz",
"commitmsg": "validate-commit-msg",
"docs": "esdoc -c .esdoc.json",
"lint": "tslint \\"src/**/*.ts\\"",
"precommit": "lint-staged",
"predocs": "rm -rf docs/",
"prepublish": "npm run build",
"prettier": "prettier",
"prettier-project": "npm run prettier-write -- 'src/**/*.{ts,tsx}'",
"prettier-write": "npm run prettier -- --parser typescript --no-semi --trailing-comma es5 --write --print-width 120",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"test": "jest",
},
Expand All @@ -186,13 +247,13 @@ exports[`generator:app src/ generates test file based on plugin name 1`] = `
`;

exports[`generator:app types/ generates TypeScript test file 1`] = `
"import jestTestRunner from './'
"import funTime from './'
jestTestRunner()
funTime()
"
`;

exports[`generator:app types/ generates TypeScript type defintion 1`] = `
"export default function jestTestRunner(): void
"export default function funTime(): void
"
`;
4 changes: 0 additions & 4 deletions src/app/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ export const defaultPackageJson = {
node: '>=4.0.0',
},
devDependencies: {
'babel-cli': '^6.24.1',
'babel-jest': '^20.0.1',
'babel-preset-env': '^1.4.0',
commitizen: '^2.9.6',
'cz-conventional-changelog': '^2.0.0',
husky: '^0.13.3',
Expand All @@ -29,7 +26,6 @@ export const defaultPackageJson = {
prettier: '^1.3.1',
'semantic-release': '^6.3.6',
typescript: '^2.3.2',
'typings-tester': '^0.2.2',
'validate-commit-msg': '^2.12.1',
},
optionalDependencies: {
Expand Down
Loading

0 comments on commit 469614c

Please sign in to comment.