Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

[enhancement] Update deprecated devDependency github to @octokit/rest #4673

Merged
merged 1 commit into from Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -47,6 +47,7 @@
"typescript": ">=2.1.0 || >=2.1.0-dev || >=2.2.0-dev || >=2.3.0-dev || >=2.4.0-dev || >=2.5.0-dev || >=2.6.0-dev || >=2.7.0-dev || >=2.8.0-dev || >=2.9.0-dev || >=3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev"
},
"devDependencies": {
"@octokit/rest": "^16.24.3",
"@types/babel__code-frame": "^7.0.1",
"@types/chai": "^3.5.0",
"@types/diff": "^3.2.0",
Expand All @@ -60,7 +61,6 @@
"@types/rimraf": "^2.0.2",
"@types/semver": "^5.3.30",
"chai": "^3.5.0",
"github": "^8.2.1",
"husky": "^0.14.3",
"json-stringify-pretty-compact": "^1.2.0",
"mocha": "^6.1.3",
Expand Down
53 changes: 19 additions & 34 deletions scripts/generate-changelog.ts
Expand Up @@ -23,55 +23,40 @@

// tslint:disable:no-console

import GitHubApi = require("github");
import * as Octokit from "@octokit/rest";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";

import { camelize } from "../lib/utils";

const github = new GitHubApi({
const octokit = new Octokit({
host: "api.github.com",
protocol: "https",
timeout: 5000,
request: {
timeout: 5000
}
});

const repoInfo = {
owner: "palantir",
repo: "tslint",
};

const tokenFile = path.join(os.homedir(), "github_token.txt");

// authenticate
const auth: GitHubApi.Auth = {
token: fs
.readFileSync(tokenFile, "utf8")
.toString()
.trim(),
type: "oauth",
};
console.log("Using OAuth token " + auth.token + "\n");

// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // ignores TLS certificate error
github.authenticate(auth);

const commits: ICommit[] = [];
github.repos
const commitList: ICommit[] = [];
octokit.repos
.getLatestRelease(repoInfo)
.then(value => {
console.log("Getting commits " + value.tag_name + "..master");
.then(({ data: { tag_name } }) => {
console.log("Getting commits " + tag_name + "..master");
// get the commits between the most recent release and the head of master
return github.repos.compareCommits({
base: value.tag_name,
return octokit.repos.compareCommits({
base: tag_name,
head: "master",
...repoInfo,
});
})
.then(value => {
.then(({ data: { commits } }) => {
// for each commit, get the PR, and extract changelog entries
const promises: Array<Promise<any>> = [];
for (const commitInfo of value.commits) {
for (const commitInfo of commits) {
const commit: ICommit = {
fields: [],
sha: commitInfo.sha,
Expand All @@ -81,7 +66,7 @@ github.repos
: commitInfo.author.login,
title: commitInfo.commit.message,
};
commits.push(commit);
commitList.push(commit);

// check for a pull request number in the commit title
const match = (commitInfo.commit.message as string).match(/\(#(\d+)\)/);
Expand All @@ -90,14 +75,14 @@ github.repos

// get the PR text
promises.push(
github.issues
octokit.issues
.get({
number: commit.pushRequestNum,
issue_number: commit.pushRequestNum,
...repoInfo,
})
.then(comment => {
.then(({ data: { body } }) => {
// extract the changelog entries
const lines = (comment.body as string).split("\r\n");
const lines = body.split("\r\n");
for (const line of lines) {
const fieldMatch = line.match(/^(\[[a-z\-]+\])/);
if (fieldMatch) {
Expand All @@ -117,7 +102,7 @@ github.repos
const entries: IField[] = [];
const noFields: string[] = [];
const contributors = new Set<string>();
for (const commit of commits) {
for (const commit of commitList) {
if (commit.fields.length > 0) {
for (const field of commit.fields) {
if (field.tag !== "[no-log]") {
Expand Down