Socket
Socket
Sign inDemoInstall

danger

Package Overview
Dependencies
Maintainers
3
Versions
320
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

danger - npm Package Compare versions

Comparing version 11.1.4 to 11.2.0

2

distribution/commands/danger-process.js

@@ -71,3 +71,3 @@ #! /usr/bin/env node

console.log(chalk_1.default.red("Could not find a source code hosting platform for ".concat(source.name, ".")));
console.log("Currently Danger JS only supports GitHub and BitBucket Server, if you want other platforms, consider the Ruby version or help out.");
console.log("Platform '".concat(source.name, "' is not supported with Danger JS, if you want other platforms, consider the Ruby version or help out."));
process.exitCode = 1;

@@ -74,0 +74,0 @@ }

@@ -1665,2 +1665,8 @@ //

interface GitLabDiscussion {
id: string //40 character hex
individual_note: boolean
notes: GitLabNote[]
}
interface GitLabDiscussionTextPosition {

@@ -1677,2 +1683,6 @@ position_type: "text"

interface GitLabDiscussionCreationOptions {
position?: GitLabDiscussionTextPosition
}
interface GitLabInlineNote extends GitLabNote {

@@ -1679,0 +1689,0 @@ position: {

@@ -119,2 +119,5 @@ "use strict";

var sortByFile = function (a, b) {
if (a.file === undefined && b.file === undefined) {
return 0;
}
if (a.file === undefined) {

@@ -127,6 +130,9 @@ return -1;

if (a.file == b.file) {
if (a.line == undefined) {
if (a.line === undefined && b.line === undefined) {
return 0;
}
if (a.line === undefined) {
return -1;
}
if (b.line == undefined) {
if (b.line === undefined) {
return 1;

@@ -133,0 +139,0 @@ }

@@ -183,2 +183,7 @@ import { Gitlab } from "@gitbeaker/node";

}
export interface GitLabDiscussion {
id: string;
individual_note: boolean;
notes: GitLabNote[];
}
export interface GitLabDiscussionTextPosition {

@@ -194,2 +199,5 @@ position_type: "text";

}
export interface GitLabDiscussionCreationOptions {
position?: GitLabDiscussionTextPosition;
}
export interface GitLabInlineNote extends GitLabNote {

@@ -196,0 +204,0 @@ position: {

@@ -187,3 +187,3 @@ "use strict";

this.getUserID = function () { return __awaiter(_this, void 0, void 0, function () {
var perilID, info, useGitHubActionsID;
var perilID, useGitHubActionsID, info;
return __generator(this, function (_a) {

@@ -196,8 +196,2 @@ switch (_a.label) {

}
return [4 /*yield*/, this.getUserInfo()];
case 1:
info = _a.sent();
if (info.id) {
return [2 /*return*/, info.id];
}
useGitHubActionsID = process.env["GITHUB_WORKFLOW"];

@@ -210,2 +204,8 @@ if (useGitHubActionsID) {

}
return [4 /*yield*/, this.getUserInfo()];
case 1:
info = _a.sent();
if (info.id) {
return [2 /*return*/, info.id];
}
return [2 /*return*/, undefined];

@@ -212,0 +212,0 @@ }

import GitLabAPI from "./gitlab/GitLabAPI";
import { Platform, Comment } from "./platform";
import { Comment, Platform } from "./platform";
import { GitDSL, GitJSONDSL } from "../dsl/GitDSL";
import { GitLabDSL, GitLabJSONDSL, GitLabNote } from "../dsl/GitLabDSL";
import { GitLabDiscussion, GitLabDSL, GitLabJSONDSL, GitLabNote } from "../dsl/GitLabDSL";
declare class GitLab implements Platform {

@@ -16,8 +16,15 @@ readonly api: GitLabAPI;

updateOrCreateComment: (dangerID: string, newComment: string) => Promise<string>;
createComment: (comment: string) => Promise<any>;
createInlineComment: (git: GitDSL, comment: string, path: string, line: number) => Promise<string>;
createComment: (comment: string) => Promise<GitLabNote>;
createInlineComment: (git: GitDSL, comment: string, path: string, line: number) => Promise<GitLabDiscussion>;
updateInlineComment: (comment: string, id: string) => Promise<GitLabNote>;
deleteInlineComment: (id: string) => Promise<boolean>;
deleteMainComment: (dangerID: string) => Promise<boolean>;
deleteNotes: (notes: GitLabNote[]) => Promise<boolean>;
/**
* Only fetches the discussions where danger owns the top note
*/
getDangerDiscussions: (dangerID: string) => Promise<GitLabDiscussion[]>;
reduceNotesFromDiscussions: (discussions: GitLabDiscussion[]) => GitLabNote[];
getDangerNotes: (dangerID: string) => Promise<GitLabNote[]>;
getDangerNoteFilter: (dangerID: string) => Promise<(note: GitLabNote) => boolean>;
updateStatus: () => Promise<boolean>;

@@ -24,0 +31,0 @@ getFileContents: (path: string, slug?: string | undefined, ref?: string | undefined) => Promise<string>;

@@ -49,2 +49,11 @@ "use strict";

};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -55,2 +64,4 @@ exports.gitlabJSONToGitLabDSL = void 0;

var d = (0, debug_1.debug)("GitLab");
var useThreads = function () { return process.env.DANGER_GITLAB_USE_THREADS === "1" ||
process.env.DANGER_GITLAB_USE_THREADS === "true"; };
var GitLab = /** @class */ (function () {

@@ -144,3 +155,4 @@ function GitLab(api) {

body: note.body,
// XXX: we should re-use the logic in getDangerNotes, need to check what inline comment template we're using if any
// XXX: we should re-use the logic in getDangerNotes, need to check what inline comment template we're using if
// any
ownedByDanger: note.author.id === dangerUserID && note.body.includes(dangerID),

@@ -153,3 +165,3 @@ };

this.updateOrCreateComment = function (dangerID, newComment) { return __awaiter(_this, void 0, void 0, function () {
var notes, note, _i, notes_1, deleteme;
var discussions, firstDiscussion, existingNote, newOrUpdatedNote;
return __generator(this, function (_a) {

@@ -159,37 +171,27 @@ switch (_a.label) {

d("updateOrCreateComment", { dangerID: dangerID, newComment: newComment });
return [4 /*yield*/, this.getDangerNotes(dangerID)];
return [4 /*yield*/, this.getDangerDiscussions(dangerID)];
case 1:
notes = _a.sent();
if (!notes.length) return [3 /*break*/, 7];
return [4 /*yield*/, this.api.updateMergeRequestNote(notes[0].id, newComment)
// delete the rest
];
discussions = _a.sent();
firstDiscussion = discussions.shift();
existingNote = firstDiscussion === null || firstDiscussion === void 0 ? void 0 : firstDiscussion.notes[0];
// Delete all notes from all other danger discussions (discussions cannot be deleted as a whole):
return [4 /*yield*/, this.deleteNotes(this.reduceNotesFromDiscussions(discussions))]; //delete the rest
case 2:
// update the first
note = _a.sent();
_i = 0, notes_1 = notes;
_a.label = 3;
// Delete all notes from all other danger discussions (discussions cannot be deleted as a whole):
_a.sent(); //delete the rest
if (!existingNote) return [3 /*break*/, 4];
return [4 /*yield*/, this.api.updateMergeRequestNote(existingNote.id, newComment)];
case 3:
if (!(_i < notes_1.length)) return [3 /*break*/, 6];
deleteme = notes_1[_i];
if (deleteme === notes[0]) {
return [3 /*break*/, 5];
}
return [4 /*yield*/, this.api.deleteMergeRequestNote(deleteme.id)];
case 4:
_a.sent();
_a.label = 5;
// update the existing comment
newOrUpdatedNote = _a.sent();
return [3 /*break*/, 6];
case 4: return [4 /*yield*/, this.createComment(newComment)];
case 5:
_i++;
return [3 /*break*/, 3];
case 6: return [3 /*break*/, 9];
case 7: return [4 /*yield*/, this.api.createMergeRequestNote(newComment)];
case 8:
// create a new note
note = _a.sent();
_a.label = 9;
case 9:
// create a new comment
newOrUpdatedNote = _a.sent();
_a.label = 6;
case 6:
// create URL from note
// "https://gitlab.com/group/project/merge_requests/154#note_132143425"
return [2 /*return*/, "".concat(this.api.mergeRequestURL, "#note_").concat(note.id)];
return [2 /*return*/, "".concat(this.api.mergeRequestURL, "#note_").concat(newOrUpdatedNote.id)];
}

@@ -200,4 +202,10 @@ });

return __generator(this, function (_a) {
d("createComment", { comment: comment });
return [2 /*return*/, this.api.createMergeRequestNote(comment)];
switch (_a.label) {
case 0:
d("createComment", { comment: comment });
if (!useThreads()) return [3 /*break*/, 2];
return [4 /*yield*/, this.api.createMergeRequestDiscussion(comment)];
case 1: return [2 /*return*/, (_a.sent()).notes[0]];
case 2: return [2 /*return*/, this.api.createMergeRequestNote(comment)];
}
});

@@ -215,10 +223,12 @@ }); };

return [2 /*return*/, this.api.createMergeRequestDiscussion(comment, {
position_type: "text",
base_sha: mr.diff_refs.base_sha,
start_sha: mr.diff_refs.start_sha,
head_sha: mr.diff_refs.head_sha,
old_path: path,
old_line: null,
new_path: path,
new_line: line,
position: {
position_type: "text",
base_sha: mr.diff_refs.base_sha,
start_sha: mr.diff_refs.start_sha,
head_sha: mr.diff_refs.head_sha,
old_path: path,
old_line: null,
new_path: path,
new_line: line,
},
})];

@@ -257,43 +267,92 @@ }

this.deleteMainComment = function (dangerID) { return __awaiter(_this, void 0, void 0, function () {
var notes, _i, notes_2, note;
var discussions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getDangerNotes(dangerID)];
case 0: return [4 /*yield*/, this.getDangerDiscussions(dangerID)];
case 1:
notes = _a.sent();
_i = 0, notes_2 = notes;
_a.label = 2;
discussions = _a.sent();
return [4 /*yield*/, this.deleteNotes(this.reduceNotesFromDiscussions(discussions))];
case 2: return [2 /*return*/, _a.sent()];
}
});
}); };
this.deleteNotes = function (notes) { return __awaiter(_this, void 0, void 0, function () {
var _i, notes_1, note;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_i = 0, notes_1 = notes;
_a.label = 1;
case 1:
if (!(_i < notes_1.length)) return [3 /*break*/, 4];
note = notes_1[_i];
d("deleteNotes", { id: note.id });
return [4 /*yield*/, this.api.deleteMergeRequestNote(note.id)];
case 2:
if (!(_i < notes_2.length)) return [3 /*break*/, 5];
note = notes_2[_i];
d("deleteMainComment", { id: note.id });
return [4 /*yield*/, this.api.deleteMergeRequestNote(note.id)];
_a.sent();
_a.label = 3;
case 3:
_a.sent();
_a.label = 4;
case 4:
_i++;
return [3 /*break*/, 2];
case 5: return [2 /*return*/, notes.length > 0];
return [3 /*break*/, 1];
case 4: return [2 /*return*/, notes.length > 0];
}
});
}); };
/**
* Only fetches the discussions where danger owns the top note
*/
this.getDangerDiscussions = function (dangerID) { return __awaiter(_this, void 0, void 0, function () {
var noteFilter, discussions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getDangerNoteFilter(dangerID)];
case 1:
noteFilter = _a.sent();
return [4 /*yield*/, this.api.getMergeRequestDiscussions()];
case 2:
discussions = _a.sent();
return [2 /*return*/, discussions.filter(function (_a) {
var notes = _a.notes;
return notes.length && noteFilter(notes[0]);
})];
}
});
}); };
this.reduceNotesFromDiscussions = function (discussions) {
return discussions.reduce(function (acc, _a) {
var notes = _a.notes;
return __spreadArray(__spreadArray([], acc, true), notes, true);
}, []);
};
this.getDangerNotes = function (dangerID) { return __awaiter(_this, void 0, void 0, function () {
var dangerUserId, notes;
var noteFilter, notes;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.api.getUser()];
case 0: return [4 /*yield*/, this.getDangerNoteFilter(dangerID)];
case 1:
dangerUserId = (_a.sent()).id;
noteFilter = _a.sent();
return [4 /*yield*/, this.api.getMergeRequestNotes()];
case 2:
notes = _a.sent();
return [2 /*return*/, notes.filter(function (_a) {
var id = _a.author.id, body = _a.body, system = _a.system, type = _a.type;
return [2 /*return*/, notes.filter(noteFilter)];
}
});
}); };
this.getDangerNoteFilter = function (dangerID) { return __awaiter(_this, void 0, void 0, function () {
var dangerUserId;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.api.getUser()];
case 1:
dangerUserId = (_a.sent()).id;
return [2 /*return*/, function (_a) {
var id = _a.author.id, body = _a.body, system = _a.system;
return !system && // system notes are generated when the user interacts with the UI e.g. changing a PR title
type == null && // we only want "normal" comments on the main body of the MR;
id === dangerUserId &&
//we do not check the `type` - it's `null` most of the time,
// only in discussions/threads this is `DiscussionNote` for all notes. But even if danger only creates a
// normal `null`-comment, any user replying to that comment will turn it into a `DiscussionNote`-typed one.
// So we cannot assume anything here about danger's note type.
body.includes((0, githubIssueTemplate_1.dangerIDToString)(dangerID));
} // danger-id-(dangerID) is included in a hidden comment in the githubIssueTemplate
)];
}];
}

@@ -300,0 +359,0 @@ });

import { RepoMetaData } from "../../dsl/BitBucketServerDSL";
import { api as fetch } from "../../api/fetch";
import { GitLabDiscussionTextPosition, GitLabInlineNote, GitLabMR, GitLabMRChange, GitLabMRCommit, GitLabNote, GitLabUserProfile, GitLabApproval } from "../../dsl/GitLabDSL";
import { GitLabApproval, GitLabDiscussion, GitLabDiscussionCreationOptions, GitLabInlineNote, GitLabMR, GitLabMRChange, GitLabMRCommit, GitLabNote, GitLabUserProfile } from "../../dsl/GitLabDSL";
import { Env } from "../../ci_source/ci_source";

@@ -16,6 +15,7 @@ export declare type GitLabAPIToken = string;

readonly repoCredentials: GitLabAPICredentials;
fetch: typeof fetch;
private api;
private readonly api;
private readonly hostURL;
private readonly d;
private readonly repoSlug;
private readonly prId;
constructor(repoMetadata: RepoMetaData, repoCredentials: GitLabAPICredentials);

@@ -124,5 +124,6 @@ get projectURL(): string;

getMergeRequestCommits: () => Promise<GitLabMRCommit[]>;
getMergeRequestDiscussions: () => Promise<GitLabDiscussion[]>;
getMergeRequestNotes: () => Promise<GitLabNote[]>;
getMergeRequestInlineNotes: () => Promise<GitLabInlineNote[]>;
createMergeRequestDiscussion: (content: string, position: GitLabDiscussionTextPosition) => Promise<string>;
createMergeRequestDiscussion: (content: string, options?: GitLabDiscussionCreationOptions | undefined) => Promise<GitLabDiscussion>;
createMergeRequestNote: (body: string) => Promise<GitLabNote>;

@@ -129,0 +130,0 @@ updateMergeRequestNote: (id: number, body: string) => Promise<GitLabNote>;

@@ -38,5 +38,13 @@ "use strict";

};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGitLabAPICredentialsFromEnv = void 0;
var fetch_1 = require("../../api/fetch");
var node_1 = require("@gitbeaker/node");

@@ -55,4 +63,4 @@ var debug_1 = require("../../debug");

else if (envCIAPI) {
// GitLab >= v11.7 supplies the API Endpoint in an environment variable and we can work out our host value from that.
// See https://docs.gitlab.com/ce/ci/variables/predefined_variables.html
// GitLab >= v11.7 supplies the API Endpoint in an environment variable and we can work out our host value from
// that. See https://docs.gitlab.com/ce/ci/variables/predefined_variables.html
var hostRegex = /^(https?):\/\/([^\/]+)\//i;

@@ -98,4 +106,4 @@ if (hostRegex.test(envCIAPI)) {

case 0:
this.d("getMergeRequestInfo for repo: ".concat(this.repoMetadata.repoSlug, " pr: ").concat(this.repoMetadata.pullRequestID));
return [4 /*yield*/, this.api.MergeRequests.show(this.repoMetadata.repoSlug, Number(this.repoMetadata.pullRequestID))];
this.d("getMergeRequestInfo for repo: ".concat(this.repoSlug, " pr: ").concat(this.prId));
return [4 /*yield*/, this.api.MergeRequests.show(this.repoSlug, this.prId)];
case 1:

@@ -111,3 +119,3 @@ mr = (_a.sent());

return __generator(this, function (_a) {
mr = this.api.MergeRequests.edit(this.repoMetadata.repoSlug, Number(this.repoMetadata.pullRequestID), changes);
mr = this.api.MergeRequests.edit(this.repoSlug, this.prId, changes);
this.d("updateMergeRequestInfo", mr);

@@ -122,5 +130,5 @@ return [2 /*return*/, mr];

case 0:
this.d("getMergeRequestApprovals for repo: ".concat(this.repoMetadata.repoSlug, " pr: ").concat(this.repoMetadata.pullRequestID));
return [4 /*yield*/, this.api.MergeRequests.approvals(this.repoMetadata.repoSlug, {
mergerequestIid: Number(this.repoMetadata.pullRequestID),
this.d("getMergeRequestApprovals for repo: ".concat(this.repoSlug, " pr: ").concat(this.prId));
return [4 /*yield*/, this.api.MergeRequests.approvals(this.repoSlug, {
mergerequestIid: this.prId,
})];

@@ -139,4 +147,4 @@ case 1:

case 0:
this.d("getMergeRequestChanges for repo: ".concat(this.repoMetadata.repoSlug, " pr: ").concat(this.repoMetadata.pullRequestID));
return [4 /*yield*/, this.api.MergeRequests.changes(this.repoMetadata.repoSlug, Number(this.repoMetadata.pullRequestID))];
this.d("getMergeRequestChanges for repo: ".concat(this.repoSlug, " pr: ").concat(this.prId));
return [4 /*yield*/, this.api.MergeRequests.changes(this.repoSlug, this.prId)];
case 1:

@@ -154,4 +162,4 @@ mr = (_a.sent());

case 0:
this.d("getMergeRequestCommits", this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID);
return [4 /*yield*/, this.api.MergeRequests.commits(this.repoMetadata.repoSlug, Number(this.repoMetadata.pullRequestID))];
this.d("getMergeRequestCommits", this.repoSlug, this.prId);
return [4 /*yield*/, this.api.MergeRequests.commits(this.repoSlug, this.prId)];
case 1:

@@ -164,2 +172,17 @@ commits = (_a.sent());

}); };
this.getMergeRequestDiscussions = function () { return __awaiter(_this, void 0, void 0, function () {
var api, discussions;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.d("getMergeRequestDiscussions", this.repoSlug, this.prId);
api = this.api.MergeRequestDiscussions;
return [4 /*yield*/, api.all(this.repoSlug, this.prId, {})];
case 1:
discussions = (_a.sent());
this.d("getMergeRequestDiscussions", discussions);
return [2 /*return*/, discussions];
}
});
}); };
this.getMergeRequestNotes = function () { return __awaiter(_this, void 0, void 0, function () {

@@ -170,5 +193,5 @@ var api, notes;

case 0:
this.d("getMergeRequestNotes", this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID);
this.d("getMergeRequestNotes", this.repoSlug, this.prId);
api = this.api.MergeRequestNotes;
return [4 /*yield*/, api.all(this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, {})];
return [4 /*yield*/, api.all(this.repoSlug, this.prId, {})];
case 1:

@@ -196,3 +219,3 @@ notes = (_a.sent());

}); };
this.createMergeRequestDiscussion = function (content, position) { return __awaiter(_this, void 0, void 0, function () {
this.createMergeRequestDiscussion = function (content, options) { return __awaiter(_this, void 0, void 0, function () {
var api, result, e_1;

@@ -202,3 +225,3 @@ return __generator(this, function (_a) {

case 0:
this.d("createMergeRequestDiscussion", this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, content, position);
this.d("createMergeRequestDiscussion", this.repoSlug, this.prId, content, options);
api = this.api.MergeRequestDiscussions;

@@ -208,9 +231,7 @@ _a.label = 1;

_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, api.create(this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, content, {
position: position,
})];
return [4 /*yield*/, api.create(this.repoSlug, this.prId, content, options)];
case 2:
result = _a.sent();
this.d("createMergeRequestDiscussion", result);
return [2 /*return*/, result]; // not sure why?
return [2 /*return*/, result];
case 3:

@@ -225,8 +246,7 @@ e_1 = _a.sent();

this.createMergeRequestNote = function (body) { return __awaiter(_this, void 0, void 0, function () {
var api, note, e_2;
var note, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.d("createMergeRequestNote", this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, body);
api = this.api.MergeRequestNotes;
this.d("createMergeRequestNote", this.repoSlug, this.prId, body);
_a.label = 1;

@@ -236,3 +256,3 @@ case 1:

this.d("createMergeRequestNote");
return [4 /*yield*/, api.create(this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, body)];
return [4 /*yield*/, this.api.MergeRequestNotes.create(this.repoSlug, this.prId, body)];
case 2:

@@ -251,12 +271,11 @@ note = (_a.sent());

this.updateMergeRequestNote = function (id, body) { return __awaiter(_this, void 0, void 0, function () {
var api, note, e_3;
var note, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.d("updateMergeRequestNote", this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, id, body);
api = this.api.MergeRequestNotes;
this.d("updateMergeRequestNote", this.repoSlug, this.prId, id, body);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, api.edit(this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, id, body)];
return [4 /*yield*/, this.api.MergeRequestNotes.edit(this.repoSlug, this.prId, id, body)];
case 2:

@@ -276,12 +295,11 @@ note = (_a.sent());

this.deleteMergeRequestNote = function (id) { return __awaiter(_this, void 0, void 0, function () {
var api, e_4;
var e_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.d("deleteMergeRequestNote", this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, id);
api = this.api.MergeRequestNotes;
this.d("deleteMergeRequestNote", this.repoSlug, this.prId, id);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, api.remove(this.repoMetadata.repoSlug, this.repoMetadata.pullRequestID, id)];
return [4 /*yield*/, this.api.MergeRequestNotes.remove(this.repoSlug, this.prId, id)];
case 2:

@@ -306,3 +324,3 @@ _a.sent();

api = this.api.RepositoryFiles;
projectId = slug || this.repoMetadata.repoSlug;
projectId = slug || this.repoSlug;
if (!!ref) return [3 /*break*/, 2];

@@ -344,3 +362,3 @@ return [4 /*yield*/, this.getMergeRequestInfo()];

api = this.api.Repositories;
projectId = this.repoMetadata.repoSlug;
projectId = this.repoSlug;
return [4 /*yield*/, api.compare(projectId, base, head)];

@@ -359,13 +377,12 @@ case 1:

return __awaiter(_this, void 0, void 0, function () {
var mr;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
var mr, noDuplicates;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.getMergeRequestInfo()];
case 1:
mr = _b.sent();
(_a = mr.labels).push.apply(_a, labels);
return [4 /*yield*/, this.updateMergeRequestInfo({ labels: mr.labels.join(",") })];
mr = _a.sent();
noDuplicates = new Set(__spreadArray(__spreadArray([], mr.labels, true), labels, true));
return [4 /*yield*/, this.updateMergeRequestInfo({ labels: Array.from(noDuplicates).join(",") })];
case 2:
_b.sent();
_a.sent();
return [2 /*return*/, true];

@@ -403,9 +420,10 @@ }

};
this.fetch = fetch_1.api;
this.api = new node_1.Gitlab(repoCredentials);
this.hostURL = repoCredentials.host;
this.repoSlug = repoMetadata.repoSlug;
this.prId = Number(repoMetadata.pullRequestID);
}
Object.defineProperty(GitLabAPI.prototype, "projectURL", {
get: function () {
return "".concat(this.hostURL, "/").concat(this.repoMetadata.repoSlug);
return "".concat(this.hostURL, "/").concat(this.repoSlug);
},

@@ -417,3 +435,3 @@ enumerable: false,

get: function () {
return "".concat(this.projectURL, "/merge_requests/").concat(this.repoMetadata.pullRequestID);
return "".concat(this.projectURL, "/merge_requests/").concat(this.prId);
},

@@ -420,0 +438,0 @@ enumerable: false,

@@ -277,3 +277,7 @@ "use strict";

issueURL = undefined;
if (!(!hasMessages || this.options.removePreviousComments)) return [3 /*break*/, 8];
if (!(!hasMessages || this.options.removePreviousComments)) return [3 /*break*/, 9];
if (!(process.env["DANGER_SKIP_WHEN_EMPTY"] === "true")) return [3 /*break*/, 3];
this.log("Skip posting to platform ".concat(this.platform.name, "."));
return [3 /*break*/, 9];
case 3:
if (!hasMessages) {

@@ -286,22 +290,22 @@ this.log("Found no issues or messages from Danger. Removing any existing messages on ".concat(this.platform.name, "."));

return [4 /*yield*/, this.platform.deleteMainComment(dangerID)];
case 3:
case 4:
_b.sent();
return [4 /*yield*/, this.platform.getInlineComments(dangerID)];
case 4:
case 5:
previousComments = _b.sent();
_i = 0, previousComments_1 = previousComments;
_b.label = 5;
case 5:
if (!(_i < previousComments_1.length)) return [3 /*break*/, 8];
_b.label = 6;
case 6:
if (!(_i < previousComments_1.length)) return [3 /*break*/, 9];
comment = previousComments_1[_i];
if (!(comment && comment.ownedByDanger)) return [3 /*break*/, 7];
if (!(comment && comment.ownedByDanger)) return [3 /*break*/, 8];
return [4 /*yield*/, this.deleteInlineComment(comment)];
case 6:
case 7:
_b.sent();
_b.label = 7;
case 7:
_b.label = 8;
case 8:
_i++;
return [3 /*break*/, 5];
case 8:
if (!hasMessages) return [3 /*break*/, 17];
return [3 /*break*/, 6];
case 9:
if (!hasMessages) return [3 /*break*/, 18];
if (fails.length > 0) {

@@ -319,18 +323,18 @@ s = fails.length === 1 ? "" : "s";

mergedResults = (0, DangerResults_1.regularResults)(results);
if (!(git !== undefined)) return [3 /*break*/, 11];
if (!(git !== undefined)) return [3 /*break*/, 12];
return [4 /*yield*/, this.platform.getInlineComments(dangerID)];
case 9:
case 10:
previousComments = _b.sent();
inline = (0, DangerResults_1.inlineResults)(results);
return [4 /*yield*/, this.sendInlineComments(inline, git, previousComments)];
case 10:
case 11:
inlineLeftovers = _b.sent();
inlineLeftovers = this.options.ignoreOutOfDiffComments ? DangerResults_1.emptyDangerResults : inlineLeftovers;
mergedResults = (0, DangerResults_1.sortResults)((0, DangerResults_1.mergeResults)(mergedResults, inlineLeftovers));
_b.label = 11;
case 11:
if (!(0, DangerResults_1.isEmptyResults)(mergedResults)) return [3 /*break*/, 12];
_b.label = 12;
case 12:
if (!(0, DangerResults_1.isEmptyResults)(mergedResults)) return [3 /*break*/, 13];
this.platform.deleteMainComment(dangerID);
return [3 /*break*/, 17];
case 12:
return [3 /*break*/, 18];
case 13:
commitID = void 0;

@@ -353,27 +357,27 @@ if (this.ciSource.commitHash !== undefined) {

}
if (!this.options.newComment) return [3 /*break*/, 14];
if (!this.options.newComment) return [3 /*break*/, 15];
return [4 /*yield*/, this.platform.createComment(dangerID, comment)];
case 13:
case 14:
issueURL = _b.sent();
return [3 /*break*/, 16];
case 14: return [4 /*yield*/, this.platform.updateOrCreateComment(dangerID, comment)];
case 15:
return [3 /*break*/, 17];
case 15: return [4 /*yield*/, this.platform.updateOrCreateComment(dangerID, comment)];
case 16:
issueURL = _b.sent();
_b.label = 16;
case 16:
this.log("Feedback: ".concat(issueURL));
_b.label = 17;
case 17:
if (!!this.options.noPublishCheck) return [3 /*break*/, 19];
this.log("Feedback: ".concat(issueURL));
_b.label = 18;
case 18:
if (!!this.options.noPublishCheck) return [3 /*break*/, 20];
return [4 /*yield*/, this.updatePrStatus(!failed, issueURL, results, dangerID)];
case 18:
case 19:
_b.sent();
_b.label = 19;
case 19:
if (!this.options.verbose) return [3 /*break*/, 21];
_b.label = 20;
case 20:
if (!this.options.verbose) return [3 /*break*/, 22];
return [4 /*yield*/, this.handleResultsPostingToSTDOUT(results)];
case 20:
case 21:
_b.sent();
_b.label = 21;
case 21:
_b.label = 22;
case 22:
// Write to the GitHub Env if a sub-process has included a reference to github's job summary

@@ -380,0 +384,0 @@ if ((_a = results.github) === null || _a === void 0 ? void 0 : _a.stepSummary) {

{
"name": "danger",
"version": "11.1.4",
"version": "11.2.0",
"description": "Unit tests for Team Culture",

@@ -5,0 +5,0 @@ "main": "distribution/danger.js",

@@ -30,3 +30,2 @@ <p align="center">

[![Build Status](https://ci.appveyor.com/api/projects/status/ep5hgeox3lbc5c7f?svg=true)](https://ci.appveyor.com/project/orta/danger-js/branch/main)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/danger)

@@ -33,0 +32,0 @@ ## For example?

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc