forked from danger/danger-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdangerfile.lite.ts
35 lines (29 loc) · 1.38 KB
/
dangerfile.lite.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as fs from "fs"
import { DangerDSLType } from "./source/dsl/DangerDSL"
declare var danger: DangerDSLType
declare function warn(params: string): void
const hasChangelog = danger.git.modified_files.includes("CHANGELOG.md")
const isTrivial = danger.github && (danger.github.pr.body + danger.github.pr.title).includes("#trivial")
if (!hasChangelog && !isTrivial) {
warn(
"Please add a changelog entry for your changes. You can find it in `CHANGELOG.md` \n\nPlease add your change and name to the master section."
)
}
import dtsGenerator from "./scripts/danger-dts"
const currentDTS = dtsGenerator()
const savedDTS = fs.readFileSync("source/danger.d.ts").toString()
if (currentDTS !== savedDTS) {
const message = "There are changes to the Danger DSL which are not reflected in the current danger.d.ts."
const idea = "Please run <code>yarn declarations</code> and update this PR."
fail(`${message}\n - ${idea}`)
}
// Always ensure we name all CI providers in the README. These
// regularly get forgotten on a PR adding a new one.
const sentence = danger.utils.sentence
import { realProviders } from "./source/ci_source/providers"
const readme = fs.readFileSync("README.md").toString()
const names = realProviders.map(p => new p({}).name)
const missing = names.filter(n => !readme.includes(n))
if (missing.length) {
warn(`These providers are missing from the README: ${sentence(missing)}`)
}