Skip to content

Commit

Permalink
Merge pull request #205 from damassi/master
Browse files Browse the repository at this point in the history
Fix Lodash isArray deprecation
  • Loading branch information
orta committed Mar 30, 2017
2 parents 749728c + 6604d78 commit d388b29
Show file tree
Hide file tree
Showing 5 changed files with 985 additions and 885 deletions.
23 changes: 12 additions & 11 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

### 0.14.2

* Moved `@types/chalk` from dependencies to devDependencies - orta
* Replaced deprecated `lodash.isarray` package with `Array.isArray` - damassi

### 0.14.1

* Moved `@types/chalk` from dependencies to devDependencies - orta
* Killed some stray console logs - orta
* Updated the danger.d.ts - orta

Expand All @@ -18,7 +19,7 @@
We use TypeScript in Danger, and a lot of my work in Artsy now uses TypeScript (see: [JS2017 at Artsy](http://artsy.github.io/blog/2017/02/05/Front-end-JavaScript-at-Artsy-2017/#TypeScrip1t)), so I wanted to
explore using TypeScript in Dangerfiles.

This is built on top of Jest's custom transformers, so if you are already using Jest with TypeScript, then
This is built on top of Jest's custom transformers, so if you are already using Jest with TypeScript, then
you can change the `dangerfile.js` to `dangerfile.ts` and nothing should need changing ( except that you might have
new warnings/errors ) (_note:_ in changing this for Danger, I had to also add the `dangerfile.ts` to the `"exclude"`
section of the `tsconfig.json` so that it didn't change the project's root folder.)
Expand All @@ -30,11 +31,11 @@
* Added a two new `git` DSL functions: `git.JSONDiffForFile(filename)` and `git.JSONPatchForFile(filename)`.

* `git.JSONPatchForFile`

This will generate a rfc6902 JSON patch between two files inside your repo. These patch files are useful as a standard, but are pretty tricky to work with in something like a Dangerfile, where rule terseness takes priority.

* `git.JSONDiffForFile`

This uses `JSONPatchForFile` to generate an object that represents all changes inside a Dangerfile as a single object, with keys for the changed paths. For example with a change like this:

```diff
Expand Down Expand Up @@ -62,12 +63,12 @@
}
```
The keys: `added` and `removed` only exist on the object if:

* `before` and `after` are both objects - in which case `added` and `removed` are the added or removed keys
* `before` and `after` are both arrays - in which case `added` and `removed` are the added or removed values

* Exposed all global functions ( like `warn`, `fail`, `git`, `schedule`, ... ) on the `danger` object. - orta

This is specifically to simplify building library code. It should not affect end-users. If you want to
look at making a Danger JS Plugin, I'd recommend exposing a function which takes the `danger` object and working from that. If you're interested, there is an active discussion on plugin support in the DangerJS issues.

Expand All @@ -80,7 +81,7 @@
* Add `danger.utils` DSL, which includes `danger.utils.href()` and `danger.utils.sentence()` - macklinu

We were finding that a lot of Dangerfiles needed similar functions, so we've added a `utils` object
to offer functions that are going to be used across the board. If you can think of more
to offer functions that are going to be used across the board. If you can think of more
functions you use, we'd love to add them. Ideally you shouldn't need to use anything but Danger + utils
to write your Dangerfiles.

Expand All @@ -92,7 +93,7 @@
* Adds `danger.github.utils` - which currently has only one function: `fileLinks` - orta

Most of the time people are working with a list of files (e.g. modified, or created) and then
want to present clickable links to those. As the logic to figure the URLs is very GitHub specific,
want to present clickable links to those. As the logic to figure the URLs is very GitHub specific,
we've moved that into it's own object with space to grow.

```js
Expand Down Expand Up @@ -124,7 +125,7 @@
});
```

Or if you wanted something simpler,
Or if you wanted something simpler,

```js
schedule((resolved) => {
Expand Down Expand Up @@ -154,7 +155,7 @@

### 0.11.0 - 0.11.2

* Add support for [Docker Cloud](https://cloud.docker.com) - camacho
* Add support for [Docker Cloud](https://cloud.docker.com) - camacho

### 0.10.1

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "danger",
"version": "0.14.1",
"version": "0.14.2",
"description": "Unit tests for Team Culture",
"main": "distribution/danger.js",
"typings": "distribution/danger.d.ts",
Expand Down Expand Up @@ -107,7 +107,6 @@
"jsonpointer": "^4.0.1",
"lodash.find": "^4.6.0",
"lodash.includes": "^4.3.0",
"lodash.isarray": "^4.0.0",
"lodash.isobject": "^2.4.1",
"lodash.keys": "^4.0.8",
"node-fetch": "^1.6.3",
Expand Down
1 change: 0 additions & 1 deletion source/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
declare module "parse-diff";
declare module "lodash.includes";
declare module "lodash.find";
declare module "lodash.isarray";
declare module "lodash.isobject";
declare module "lodash.keys";
declare module "jest-runtime";
Expand Down
3 changes: 1 addition & 2 deletions source/platforms/github/GitHubGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import * as parseDiff from "parse-diff"

// At what point should we just import lodash?
import * as includes from "lodash.includes"
import * as isarray from "lodash.isarray"
import * as isobject from "lodash.isobject"
import * as keys from "lodash.keys"
import * as find from "lodash.find"
Expand Down Expand Up @@ -114,7 +113,7 @@ export default async function gitDSLForGitHub(api: GitHubAPI): Promise<GitDSL> {
// added or removed. This makes it really easy to act on specific
// changes to JSON DSLs

if (isarray(diff.after) && isarray(diff.before)) {
if (Array.isArray(diff.after) && Array.isArray(diff.before)) {
const arrayBefore = diff.before as any[]
const arrayAfter = diff.after as any[]

Expand Down

0 comments on commit d388b29

Please sign in to comment.