Skip to content

Commit

Permalink
Merge pull request #191 from danger/dev_deps
Browse files Browse the repository at this point in the history
Fail when any types dependency is shipped to library consumers
  • Loading branch information
orta committed Mar 22, 2017
2 parents 38291a7 + b5366e0 commit 7194dbc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

// Add your own contribution below

### 0.14.0 - 0.14.1
### 0.14.2

* Moved `@types/chalk` from dependencies to devDependencies - orta

### 0.14.1

* Killed some stray console logs - orta
* Updated the danger.d.ts - orta

### 0.14.0

* TypeScript Dangerfiles are now support in Danger - orta

Expand Down
13 changes: 13 additions & 0 deletions dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ const checkForLockfileDiff = (packageDiff) => {
}
}

// Don't ship @types dependencies to consumers of Danger
const checkForTypesInDeps = (packageDiff) => {
if (packageDiff.dependencies) {
const typesDeps = packageDiff.dependencies.added.filter((dep: string) => dep.startsWith("@types"))
if (typesDeps.length) {
const message = `@types dependencies were added to package.json, as a dependency for others.`
const idea = `You need to move ${sentence(typesDeps)} into "devDependencies"?`
fail(`${message}<br/><i>${idea}</i>`)
}
}
}

// As `JSONDiffForFile` is an async function, we want to add it to Danger's scheduler
// then it can continue after eval has taken place.

Expand All @@ -93,6 +105,7 @@ schedule(async () => {
checkForRelease(packageDiff)
checkForNewDependencies(packageDiff)
checkForLockfileDiff(packageDiff)
checkForTypesInDeps(packageDiff)
})

// Some good old-fashioned maintainance upkeep
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
},
"homepage": "https://github.com/danger/danger-js#readme",
"devDependencies": {
"@types/chalk": "^0.4.31",
"@types/commander": "^2.3.31",
"@types/debug": "0.0.29",
"@types/jest": "^19.2.1",
Expand All @@ -95,7 +96,6 @@
"typescript": "2.2.1"
},
"dependencies": {
"@types/chalk": "^0.4.31",
"babel-polyfill": "^6.20.0",
"chalk": "^1.1.1",
"commander": "^2.9.0",
Expand Down

0 comments on commit 7194dbc

Please sign in to comment.