Skip to content

Commit

Permalink
[Peril] Updates the Danger DSL with Peril typings
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jan 25, 2018
1 parent f0a7cf9 commit d46565b
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

## Master

* Peril typings to the Danger DSL. [@orta][]

## 3.1.1

* Allows `danger runner` (the hidden command which runs the process) to accept
Expand Down
45 changes: 43 additions & 2 deletions source/danger.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,36 @@ declare module "danger" {
danger: DangerDSLJSONType
}

/**
* The available Peril interface, it is possible that this is not
* always up to date with true DSL in Peril, but I'll be giving it
* a good shot.
*/

interface PerilDSL {
/**
* A set of key:value string based on ENV vars that have
* been set to be exposed to your Peril config
*/
env: any

/**
* Allows you to schedule a task declared in your Peril config to run in a certain timeframe,
* e.g `runTask("reminder_pr_merge", "in 2 days", { number: 2 })`. For more details on how this
* works, see the Peril documentation.
* @param taskName the name found in your Peril config
* @param time the time interval (uses human-internal module)
* @param data data which will be passed through to the script
*/
runTask: (taskName: string, time: string, data: any) => void

/**
* When running a task, the data passed in when the task
* was originally scheduled.
*/
data?: any
}

/**
* The root of the Danger JSON DSL.
*/
Expand Down Expand Up @@ -94,8 +124,13 @@ declare module "danger" {
* GitHub user identities and some useful utility functions
* for displaying links to files.
*
* Also provides an authenticated API so you can work directly
* with the GitHub API. That is an instance of the "github" npm module.
* Provides an authenticated API so you can work directly
* with the GitHub API. This is an instance of the "@ocktokit/rest" npm
* module.
*
* Finally, if running through Peril on an event other than a PR
* this is the full JSON from the webhook. You can find the full
* typings for those webhooks [at github-webhook-event-types](https://github.com/orta/github-webhook-event-types).
*/
readonly github: GitHubDSL

Expand All @@ -105,6 +140,12 @@ declare module "danger" {
* for making hrefs easily.
*/
readonly utils: DangerUtilsDSL

/**
* When Peril is running your Dangerfile, the Danger DSL is
* extended with additional options.
*/
readonly peril?: PerilDSL
}
/**
* The representation of what running a Dangerfile generates.
Expand Down
45 changes: 43 additions & 2 deletions source/dsl/DangerDSL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ export interface DangerJSON {
danger: DangerDSLJSONType
}

/**
* The available Peril interface, it is possible that this is not
* always up to date with true DSL in Peril, but I'll be giving it
* a good shot.
*/

export interface PerilDSL {
/**
* A set of key:value string based on ENV vars that have
* been set to be exposed to your Peril config
*/
env: any

/**
* Allows you to schedule a task declared in your Peril config to run in a certain timeframe,
* e.g `runTask("reminder_pr_merge", "in 2 days", { number: 2 })`. For more details on how this
* works, see the Peril documentation.
* @param taskName the name found in your Peril config
* @param time the time interval (uses human-internal module)
* @param data data which will be passed through to the script
*/
runTask: (taskName: string, time: string, data: any) => void

/**
* When running a task, the data passed in when the task
* was originally scheduled.
*/
data?: any
}

/**
* The root of the Danger JSON DSL.
*/
Expand Down Expand Up @@ -62,8 +92,13 @@ export interface DangerDSLType {
* GitHub user identities and some useful utility functions
* for displaying links to files.
*
* Also provides an authenticated API so you can work directly
* with the GitHub API. That is an instance of the "github" npm module.
* Provides an authenticated API so you can work directly
* with the GitHub API. This is an instance of the "@ocktokit/rest" npm
* module.
*
* Finally, if running through Peril on an event other than a PR
* this is the full JSON from the webhook. You can find the full
* typings for those webhooks [at github-webhook-event-types](https://github.com/orta/github-webhook-event-types).
*/
readonly github: GitHubDSL

Expand All @@ -73,6 +108,12 @@ export interface DangerDSLType {
* for making hrefs easily.
*/
readonly utils: DangerUtilsDSL

/**
* When Peril is running your Dangerfile, the Danger DSL is
* extended with additional options.
*/
readonly peril?: PerilDSL
}

/// End of Danger DSL definition
Expand Down

0 comments on commit d46565b

Please sign in to comment.