Comparing version 12.1.0 to 12.2.0
@@ -222,1 +222,2 @@ import { Env, CISource } from "../ci_source"; | ||
} | ||
export declare const githubActionsWorkflowWarningCheck: () => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GitHubActions = void 0; | ||
exports.githubActionsWorkflowWarningCheck = exports.GitHubActions = void 0; | ||
var ci_source_helpers_1 = require("../ci_source_helpers"); | ||
@@ -288,2 +288,11 @@ var fs_1 = require("fs"); | ||
exports.GitHubActions = GitHubActions; | ||
var githubActionsWorkflowWarningCheck = function () { | ||
var eventName = process.env.GITHUB_EVENT_NAME; | ||
var isPR = eventName === "pull_request"; | ||
if (!isPR) { | ||
console.log("Note: Running Danger on with generalised GitHub Actions support, this does not include `danger.github.pr`."); | ||
console.log(" If you expected a PR run, change your workflow's 'on' to be pull_request."); | ||
} | ||
}; | ||
exports.githubActionsWorkflowWarningCheck = githubActionsWorkflowWarningCheck; | ||
//# sourceMappingURL=GitHubActions.js.map |
@@ -54,2 +54,3 @@ "use strict"; | ||
var path_1 = require("path"); | ||
var GitHubActions_1 = require("../../ci_source/providers/GitHubActions"); | ||
var d = (0, debug_1.debug)("process_runner"); | ||
@@ -74,2 +75,3 @@ var runRunner = function (app, config) { return __awaiter(void 0, void 0, void 0, function () { | ||
source = _a; | ||
d("Got a CI: ".concat(source === null || source === void 0 ? void 0 : source.name)); | ||
// This does not set a failing exit code, because it's also likely | ||
@@ -82,2 +84,6 @@ // danger is running on a CI run on the merge of a PR, and not just | ||
} | ||
// Extra logging for GitHub Actions | ||
if (source && source.isPR && source.name === "GitHub Actions") { | ||
(0, GitHubActions_1.githubActionsWorkflowWarningCheck)(); | ||
} | ||
if (!(source && source.isPR)) return [3 /*break*/, 4]; | ||
@@ -84,0 +90,0 @@ configPlatform = config && config.platform; |
@@ -52,3 +52,3 @@ "use strict"; | ||
ui.pause(0.5); | ||
ui.say("You will want to add a new step in an existing workflow yaml file."); | ||
ui.say("You will want to add a new step in an existing workflow yaml file which uses `on: pull_request`."); | ||
ui.pause(0.2); | ||
@@ -77,3 +77,3 @@ ui.say("The step should look like this:"); | ||
ui.pause(0.1); | ||
ui.say("To get started, add a new step in an existing workflow file."); | ||
ui.say("To get started, add a new step in an existing workflow file which uses `on: pull_request`."); | ||
ui.say("The step should look like this:"); | ||
@@ -80,0 +80,0 @@ ui.say(""); |
@@ -9,3 +9,3 @@ import { InitState } from "./interfaces"; | ||
export declare const generateDefaultDangerfile: (state: InitState) => any; | ||
export declare const formatDangerfile: (dangerfile: string, initState: InitState, dangerfileState: ReturnType<typeof generateDangerfileState>) => any; | ||
export declare const formatDangerfile: (dangerfile: string, dangerfileState: ReturnType<typeof generateDangerfileState>) => any; | ||
export declare const createImport: (state: InitState) => "import {danger, warn} from 'danger'" | "const {danger, warn} = require('danger')"; | ||
@@ -12,0 +12,0 @@ export declare const changelogRule = "\n// Check for a CHANGELOG entry\nconst hasChangelog = danger.git.modified_files.some(f => f === 'CHANGELOG.md')\nconst description = danger.github.pr.body + danger.github.pr.title\nconst isTrivial = description.includes('#trivial')\n\nif (!hasChangelog && !isTrivial) {\n warn('Please add a changelog entry for your changes.')\n}\n"; |
@@ -59,6 +59,6 @@ "use strict"; | ||
var dangerfile = "".concat((0, exports.createImport)(state), "\n\n ").concat(rules.join("\n"), "\n "); | ||
return (0, exports.formatDangerfile)(dangerfile, state, dangerfileState); | ||
return (0, exports.formatDangerfile)(dangerfile, dangerfileState); | ||
}; | ||
exports.generateDefaultDangerfile = generateDefaultDangerfile; | ||
var formatDangerfile = function (dangerfile, initState, dangerfileState) { | ||
var formatDangerfile = function (dangerfile, dangerfileState) { | ||
if (dangerfileState.hasPrettier) { | ||
@@ -70,3 +70,3 @@ // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
// Always include this | ||
var always = { editorconfig: true, parser: "typescript", filepath: process.cwd() + " /" + initState.filename }; | ||
var always = { editorconfig: true, parser: "typescript" }; | ||
var settings = localPrettier ? __assign(__assign({}, always), localPrettier) : always; | ||
@@ -73,0 +73,0 @@ return format(dangerfile, settings); |
@@ -8,2 +8,6 @@ import { Octokit as GitHubNodeAPI } from "@octokit/rest"; | ||
export declare type APIToken = string; | ||
export interface GitHubFile { | ||
filename: string; | ||
patch: string; | ||
} | ||
/** This represent the GitHub API */ | ||
@@ -60,2 +64,3 @@ export declare class GitHubAPI { | ||
})[]>; | ||
getPullRequestFiles: (page?: number) => Promise<GitHubFile[]>; | ||
getPullRequestDiff: () => Promise<string>; | ||
@@ -62,0 +67,0 @@ getFileContents: (path: string, repoSlug: string, ref: string) => Promise<any>; |
@@ -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)); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -434,15 +443,66 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}); }; | ||
this.getPullRequestFiles = function (page) { | ||
if (page === void 0) { page = 1; } | ||
return __awaiter(_this, void 0, void 0, function () { | ||
var repo, prID, perPage, url, response, data, linkHeader, hasNextPage, nextPageNumber, nextPageFiles, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
repo = this.repoMetadata.repoSlug; | ||
prID = this.repoMetadata.pullRequestID; | ||
perPage = 100; | ||
url = "repos/".concat(repo, "/pulls/").concat(prID, "/files?page=").concat(page, "&per_page=").concat(perPage); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 6, , 7]); | ||
return [4 /*yield*/, this.get(url, { | ||
Accept: "application/vnd.github.v3.diff", | ||
})]; | ||
case 2: | ||
response = _a.sent(); | ||
return [4 /*yield*/, response.json()]; | ||
case 3: | ||
data = _a.sent(); | ||
if (!response.ok) { | ||
throw new Error("GitHub 'List pull request files' API returned an error: ".concat(data.message)); | ||
} | ||
linkHeader = response.headers.get("Link"); | ||
hasNextPage = linkHeader && linkHeader.includes('rel="next"'); | ||
if (!hasNextPage) return [3 /*break*/, 5]; | ||
nextPageNumber = page + 1; | ||
return [4 /*yield*/, this.getPullRequestFiles(nextPageNumber)]; | ||
case 4: | ||
nextPageFiles = _a.sent(); | ||
return [2 /*return*/, __spreadArray(__spreadArray([], data, true), nextPageFiles, true)]; | ||
case 5: return [2 /*return*/, data]; | ||
case 6: | ||
error_1 = _a.sent(); | ||
console.error("Failed to fetch GitHub pull request files:", error_1); | ||
throw error_1; | ||
case 7: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
this.getPullRequestDiff = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var repo, prID, res; | ||
// This is a hack to get the file patch into a format that parse-diff accepts | ||
// as the GitHub API for listing pull request files is missing file names in the patch. | ||
function prefixedPatch(file) { | ||
return "\ndiff --git a/".concat(file.filename, " b/").concat(file.filename, "\n--- a/").concat(file.filename, "\n+++ b/").concat(file.filename, "\n").concat(file.patch, "\n"); | ||
} | ||
var files, diff, error_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
repo = this.repoMetadata.repoSlug; | ||
prID = this.repoMetadata.pullRequestID; | ||
return [4 /*yield*/, this.get("repos/".concat(repo, "/pulls/").concat(prID), { | ||
Accept: "application/vnd.github.v3.diff", | ||
})]; | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.getPullRequestFiles()]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2 /*return*/, res.ok ? res.text() : ""]; | ||
files = _a.sent(); | ||
diff = files.map(prefixedPatch).join("\n"); | ||
return [2 /*return*/, diff]; | ||
case 2: | ||
error_2 = _a.sent(); | ||
console.error("Failed to fetch pull request diff:", error_2); | ||
return [2 /*return*/, ""]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
@@ -522,3 +582,3 @@ }); | ||
this.updateStatus = function (passed, message, url, dangerID, ciCommitHash) { return __awaiter(_this, void 0, void 0, function () { | ||
var repo, prJSON, ref, state, context, statusURL, res, error_1; | ||
var repo, prJSON, ref, state, context, statusURL, res, error_3; | ||
return __generator(this, function (_a) { | ||
@@ -555,5 +615,5 @@ switch (_a.label) { | ||
case 4: | ||
error_1 = _a.sent(); | ||
error_3 = _a.sent(); | ||
this.d("Posting a status to: ".concat(statusURL, " failed, this is the response:")); | ||
this.d((error_1 && error_1.message) || error_1); | ||
this.d((error_3 && error_3.message) || error_3); | ||
return [3 /*break*/, 5]; | ||
@@ -560,0 +620,0 @@ case 5: return [2 /*return*/]; |
{ | ||
"name": "danger", | ||
"version": "12.1.0", | ||
"version": "12.2.0", | ||
"description": "Unit tests for Team Culture", | ||
@@ -57,2 +57,3 @@ "main": "distribution/danger.js", | ||
"test:watch": "jest --watch", | ||
"type-check": "tsc --noEmit", | ||
"lint": "eslint \"source/*.ts\" \"source/**/*.ts\"", | ||
@@ -107,3 +108,3 @@ "lint:fix": "yarn --silent lint --fix", | ||
"@types/jest": "^28.0.0", | ||
"@types/json5": "^0.0.30", | ||
"@types/json5": "^2.2.0", | ||
"@types/jsonpointer": "^4.0.0", | ||
@@ -160,3 +161,3 @@ "@types/jsonwebtoken": "^9.0.0", | ||
"hyperlinker": "^1.0.0", | ||
"json5": "^2.1.0", | ||
"json5": "^2.2.3", | ||
"jsonpointer": "^5.0.0", | ||
@@ -163,0 +164,0 @@ "jsonwebtoken": "^9.0.0", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1411561
21632
125
Updatedjson5@^2.2.3