@auto-it/core
Advanced tools
Comparing version 6.5.1-canary.f65ea64.16 to 6.5.2-canary.406.5732.27
@@ -489,3 +489,3 @@ "use strict"; | ||
data: { | ||
body: '# My Content\n<!-- GITHUB_RELEASE PR BODY: default -->\nSome long thing\n<!-- GITHUB_RELEASE PR BODY: default -->\n' | ||
body: '# My Content\n<!-- GITHUB_RELEASE PR BODY: default -->\n\n\nSome long thing\n<!-- GITHUB_RELEASE PR BODY: default -->\n' | ||
} | ||
@@ -653,5 +653,3 @@ }); | ||
case 1: | ||
_a.apply(void 0, [_b.sent()]).toEqual({ | ||
login: 'lisowski54@gmail.com' | ||
}); | ||
_a.apply(void 0, [_b.sent()]).toEqual({}); | ||
return [2 /*return*/]; | ||
@@ -658,0 +656,0 @@ } |
@@ -261,2 +261,6 @@ "use strict"; | ||
name: 'Andrew Lisowski', | ||
email: 'andrew@users.noreply.github.com' | ||
}), | ||
make_commit_from_msg_1.default('Second (#123)', { | ||
name: 'Andrew Lisowski', | ||
email: 'lisowski54@gmail.com' | ||
@@ -280,2 +284,6 @@ }), | ||
}); | ||
getUserByUsername.mockReturnValueOnce({ | ||
login: 'andrew', | ||
name: 'Andrew Lisowski' | ||
}); | ||
getUserByEmail.mockReturnValueOnce({ | ||
@@ -760,2 +768,43 @@ login: 'adam', | ||
}); }); | ||
test('should find ignore closed prs', function () { return __awaiter(_this, void 0, void 0, function () { | ||
var gh, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
gh = new release_1.default(git); | ||
getGitLog.mockReturnValueOnce([ | ||
make_commit_from_msg_1.default('Doom Patrol enabled', { | ||
hash: '1' | ||
}), | ||
make_commit_from_msg_1.default('Autobots roll out!', { | ||
hash: '2' | ||
}) | ||
]); | ||
graphql.mockReturnValueOnce({ | ||
hash_1: { | ||
edges: [ | ||
{ | ||
node: { | ||
labels: { | ||
edges: [{ node: { name: 'major', state: 'CLOSED' } }] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}); | ||
// PR with no label, should become patch | ||
graphql.mockReturnValueOnce({ | ||
hash_2: { | ||
edges: [{ node: { labels: undefined } }] | ||
} | ||
}); | ||
_a = expect; | ||
return [4 /*yield*/, gh.generateReleaseNotes('1234', '123')]; | ||
case 1: | ||
_a.apply(void 0, [_b.sent()]).toMatchSnapshot(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
test('should include PRs merged to other PRs', function () { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -762,0 +811,0 @@ var gh, _a; |
@@ -1,10 +0,10 @@ | ||
interface IAuthorArgs { | ||
interface IAuthorOptions { | ||
name?: string; | ||
email?: string; | ||
} | ||
export interface IRepoArgs { | ||
export interface IRepoOptions { | ||
owner?: string; | ||
repo?: string; | ||
} | ||
export interface ILogArgs { | ||
export interface ILogOptions { | ||
verbose?: boolean; | ||
@@ -43,3 +43,3 @@ veryVerbose?: boolean; | ||
} | ||
export interface IChangelogOptions extends IAuthorArgs { | ||
export interface IChangelogOptions extends IAuthorOptions { | ||
noVersionPrefix?: boolean; | ||
@@ -51,3 +51,3 @@ dryRun?: boolean; | ||
} | ||
export interface IReleaseOptions extends IAuthorArgs { | ||
export interface IReleaseOptions extends IAuthorOptions { | ||
noVersionPrefix?: boolean; | ||
@@ -74,3 +74,3 @@ dryRun?: boolean; | ||
} | ||
export declare type GlobalArgs = { | ||
export declare type GlobalOptions = { | ||
githubApi?: string; | ||
@@ -80,4 +80,4 @@ baseBranch?: string; | ||
plugins?: string[]; | ||
} & IRepoArgs & ILogArgs; | ||
export declare type ApiArgs = GlobalArgs & (IInitOptions | ICreateLabelsOptions | ILabelOptions | IPRCheckOptions | IPRStatusOptions | ICommentOptions | IChangelogOptions | IPRBodyOptions | IReleaseOptions | IVersionOptions | ICanaryOptions | IShipItOptions); | ||
} & IRepoOptions & ILogOptions; | ||
export declare type ApiOptions = GlobalOptions & (IInitOptions | ICreateLabelsOptions | ILabelOptions | IPRCheckOptions | IPRStatusOptions | ICommentOptions | IChangelogOptions | IPRBodyOptions | IReleaseOptions | IVersionOptions | ICanaryOptions | IShipItOptions); | ||
export {}; |
import { ReposCreateReleaseResponse, Response } from '@octokit/rest'; | ||
import { AsyncParallelHook, AsyncSeriesBailHook, SyncHook, SyncWaterfallHook } from 'tapable'; | ||
import { ApiArgs, ICanaryOptions, IChangelogOptions, ICommentOptions, ICreateLabelsOptions, IInitOptions, ILabelOptions, IPRCheckOptions, IPRStatusOptions, IReleaseOptions, IShipItOptions } from './auto-args'; | ||
import { ApiOptions, ICanaryOptions, IChangelogOptions, ICommentOptions, ICreateLabelsOptions, IInitOptions, ILabelOptions, IPRCheckOptions, IPRStatusOptions, IReleaseOptions, IShipItOptions } from './auto-args'; | ||
import Changelog from './changelog'; | ||
@@ -48,3 +48,3 @@ import Git from './git'; | ||
logger: ILogger; | ||
args: ApiArgs; | ||
options: ApiOptions; | ||
baseBranch: string; | ||
@@ -56,3 +56,3 @@ config?: IAutoConfig; | ||
semVerLabels?: Map<VersionLabel, string>; | ||
constructor(args?: ApiArgs); | ||
constructor(options?: ApiOptions); | ||
/** | ||
@@ -59,0 +59,0 @@ * Load the .autorc from the file system, set up defaults, combine with CLI args |
@@ -115,4 +115,4 @@ "use strict"; | ||
var Auto = /** @class */ (function () { | ||
function Auto(args) { | ||
if (args === void 0) { args = {}; } | ||
function Auto(options) { | ||
if (options === void 0) { options = {}; } | ||
var _this = this; | ||
@@ -127,5 +127,9 @@ this.prefixRelease = function (release) { | ||
}; | ||
this.args = args; | ||
this.baseBranch = args.baseBranch || 'master'; | ||
this.logger = logger_1.default(args.veryVerbose ? 'veryVerbose' : args.verbose ? 'verbose' : undefined); | ||
this.options = options; | ||
this.baseBranch = options.baseBranch || 'master'; | ||
this.logger = logger_1.default(options.veryVerbose | ||
? 'veryVerbose' | ||
: options.verbose | ||
? 'verbose' | ||
: undefined); | ||
this.hooks = make_hooks_1.makeHooks(); | ||
@@ -157,3 +161,3 @@ this.hooks.onCreateRelease.tap('Link onCreateChangelog', function (release) { | ||
_c = [{}]; | ||
return [4 /*yield*/, configLoader.loadConfig(this.args)]; | ||
return [4 /*yield*/, configLoader.loadConfig(this.options)]; | ||
case 1: | ||
@@ -160,0 +164,0 @@ config = _b.apply(_a, [__assign.apply(void 0, _c.concat([(_d.sent()), { baseBranch: this.baseBranch }]))]); |
@@ -295,3 +295,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var changelogTitles; | ||
var changelogTitles, labelSections; | ||
var _this = this; | ||
@@ -318,2 +318,3 @@ return __generator(this, function (_a) { | ||
title = _c.sent(); | ||
lines = new Set(); | ||
return [4 /*yield*/, Promise.all(labelCommits.map(function (commit) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -332,3 +333,4 @@ var _a, line, _b, _c, _d; | ||
_a = __read.apply(void 0, [_e.sent(), 2]), line = _a[1]; | ||
return [2 /*return*/, line]; | ||
lines.add(line); | ||
return [2 /*return*/]; | ||
} | ||
@@ -338,7 +340,6 @@ }); | ||
case 2: | ||
lines = _c.sent(); | ||
sections.push(__spread([ | ||
title | ||
], lines.sort(function (a, b) { return a.split('\n').length - b.split('\n').length; })).join('\n')); | ||
return [2 /*return*/]; | ||
_c.sent(); | ||
return [2 /*return*/, __spread([ | ||
title | ||
], __spread(lines).sort(function (a, b) { return a.split('\n').length - b.split('\n').length; })).join('\n')]; | ||
} | ||
@@ -349,3 +350,4 @@ }); | ||
case 1: | ||
_a.sent(); | ||
labelSections = _a.sent(); | ||
labelSections.map(function (section) { return sections.push(section); }); | ||
return [2 /*return*/]; | ||
@@ -352,0 +354,0 @@ } |
import cosmiconfig from 'cosmiconfig'; | ||
import { ApiArgs } from './auto-args'; | ||
import { ApiOptions } from './auto-args'; | ||
import { ILogger } from './utils/logger'; | ||
@@ -11,3 +11,3 @@ export default class Config { | ||
*/ | ||
loadConfig(args: ApiArgs): Promise<{ | ||
loadConfig(args: ApiOptions): Promise<{ | ||
labels: import("./release").ILabelDefinitionMap; | ||
@@ -14,0 +14,0 @@ skipReleaseLabels: any; |
@@ -15,3 +15,3 @@ import Octokit from '@octokit/rest'; | ||
export default class Git { | ||
readonly ghub: Octokit; | ||
readonly github: Octokit; | ||
readonly options: IGitOptions; | ||
@@ -18,0 +18,0 @@ private readonly baseUrl; |
@@ -129,3 +129,3 @@ "use strict"; | ||
.plugin(plugin_throttling_1.default); | ||
this.ghub = new gitHub({ | ||
this.github = new gitHub({ | ||
baseUrl: this.baseUrl, | ||
@@ -148,3 +148,3 @@ auth: this.options.token, | ||
}); | ||
this.ghub.hook.error('request', function (error) { | ||
this.github.hook.error('request', function (error) { | ||
if (error && error.headers && error.headers.authorization) { | ||
@@ -161,3 +161,3 @@ delete error.headers.authorization; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.ghub.repos.getLatestRelease({ | ||
case 0: return [4 /*yield*/, this.github.repos.getLatestRelease({ | ||
owner: this.options.owner, | ||
@@ -262,3 +262,3 @@ repo: this.options.repo | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.ghub.issues.listLabelsOnIssue(args)]; | ||
return [4 /*yield*/, this.github.issues.listLabelsOnIssue(args)]; | ||
case 2: | ||
@@ -293,3 +293,3 @@ labels = _a.sent(); | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.ghub.issues.get(args)]; | ||
return [4 /*yield*/, this.github.issues.get(args)]; | ||
case 2: | ||
@@ -321,3 +321,3 @@ info = _a.sent(); | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.ghub.issues.listLabelsForRepo(args)]; | ||
return [4 /*yield*/, this.github.issues.listLabelsForRepo(args)]; | ||
case 2: | ||
@@ -368,3 +368,3 @@ labels = _a.sent(); | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.ghub.search.users({ | ||
return [4 /*yield*/, this.github.search.users({ | ||
q: "in:email " + email | ||
@@ -374,5 +374,3 @@ })]; | ||
search = (_a.sent()).data; | ||
return [2 /*return*/, search && search.items.length > 0 | ||
? search.items[0] | ||
: { login: email }]; | ||
return [2 /*return*/, search && search.items.length > 0 ? search.items[0] : {}]; | ||
case 2: | ||
@@ -394,3 +392,3 @@ error_1 = _a.sent(); | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.ghub.users.getByUsername({ | ||
return [4 /*yield*/, this.github.users.getByUsername({ | ||
username: username | ||
@@ -423,3 +421,3 @@ })]; | ||
this.logger.verbose.info('Getting pull request info using:', args); | ||
return [4 /*yield*/, this.ghub.pulls.get(args)]; | ||
return [4 /*yield*/, this.github.pulls.get(args)]; | ||
case 1: | ||
@@ -443,3 +441,3 @@ result = _a.sent(); | ||
this.logger.verbose.info('Searching repo using:\n', options); | ||
return [4 /*yield*/, this.ghub.search.issuesAndPullRequests(options)]; | ||
return [4 /*yield*/, this.github.search.issuesAndPullRequests(options)]; | ||
case 1: | ||
@@ -483,3 +481,3 @@ result = _a.sent(); | ||
this.logger.verbose.info('Creating status using:\n', args); | ||
return [4 /*yield*/, this.ghub.repos.createStatus(args)]; | ||
return [4 /*yield*/, this.github.repos.createStatus(args)]; | ||
case 1: | ||
@@ -504,3 +502,3 @@ result = _a.sent(); | ||
: tinycolor2_1.default.random().toString('hex6'); | ||
return [4 /*yield*/, this.ghub.issues.createLabel({ | ||
return [4 /*yield*/, this.github.issues.createLabel({ | ||
name: label.name, | ||
@@ -531,3 +529,3 @@ owner: this.options.owner, | ||
: tinycolor2_1.default.random().toString('hex6'); | ||
return [4 /*yield*/, this.ghub.issues.updateLabel({ | ||
return [4 /*yield*/, this.github.issues.updateLabel({ | ||
current_name: label.name, | ||
@@ -555,3 +553,3 @@ owner: this.options.owner, | ||
this.logger.verbose.info("Creating \"" + label + "\" label to PR " + pr); | ||
return [4 /*yield*/, this.ghub.issues.addLabels({ | ||
return [4 /*yield*/, this.github.issues.addLabels({ | ||
issue_number: pr, | ||
@@ -578,3 +576,3 @@ owner: this.options.owner, | ||
this.logger.verbose.info("Locking #" + issue + " issue..."); | ||
return [4 /*yield*/, this.ghub.issues.lock({ | ||
return [4 /*yield*/, this.github.issues.lock({ | ||
issue_number: issue, | ||
@@ -600,3 +598,3 @@ owner: this.options.owner, | ||
this.logger.verbose.info('Getting project from GitHub'); | ||
return [4 /*yield*/, this.ghub.repos.get({ | ||
return [4 /*yield*/, this.github.repos.get({ | ||
owner: this.options.owner, | ||
@@ -621,3 +619,3 @@ repo: this.options.repo | ||
this.logger.verbose.info('Getting pull requests...'); | ||
return [4 /*yield*/, this.ghub.pulls.list(__assign({ owner: this.options.owner.toLowerCase(), repo: this.options.repo.toLowerCase() }, options))]; | ||
return [4 /*yield*/, this.github.pulls.list(__assign({ owner: this.options.owner.toLowerCase(), repo: this.options.repo.toLowerCase() }, options))]; | ||
case 1: | ||
@@ -639,3 +637,3 @@ result = (_a.sent()).data; | ||
this.logger.verbose.info("Getting commits for PR #" + pr); | ||
return [4 /*yield*/, this.ghub.pulls.listCommits({ | ||
return [4 /*yield*/, this.github.pulls.listCommits({ | ||
owner: this.options.owner.toLowerCase(), | ||
@@ -663,3 +661,3 @@ repo: this.options.repo.toLowerCase(), | ||
this.logger.verbose.info('Getting previous comments on:', pr); | ||
return [4 /*yield*/, this.ghub.issues.listComments({ | ||
return [4 /*yield*/, this.github.issues.listComments({ | ||
owner: this.options.owner, | ||
@@ -681,3 +679,3 @@ repo: this.options.repo, | ||
this.logger.verbose.info("Deleting comment: " + commentId); | ||
return [4 /*yield*/, this.ghub.issues.deleteComment({ | ||
return [4 /*yield*/, this.github.issues.deleteComment({ | ||
owner: this.options.owner, | ||
@@ -708,3 +706,3 @@ repo: this.options.repo, | ||
this.logger.verbose.info('Creating new comment'); | ||
return [4 /*yield*/, this.ghub.issues.createComment({ | ||
return [4 /*yield*/, this.github.issues.createComment({ | ||
owner: this.options.owner, | ||
@@ -734,3 +732,3 @@ repo: this.options.repo, | ||
this.logger.verbose.info('Getting previous pr body on:', pr); | ||
return [4 /*yield*/, this.ghub.issues.get({ | ||
return [4 /*yield*/, this.github.issues.get({ | ||
owner: this.options.owner, | ||
@@ -743,3 +741,3 @@ repo: this.options.repo, | ||
this.logger.veryVerbose.info('Got PR description\n', issue.data.body); | ||
regex = new RegExp("(" + id + ")\\s(.+)\\s(" + id + ")"); | ||
regex = new RegExp("(" + id + ")\\s*(.*)\\s*(" + id + ")"); | ||
body = issue.data.body; | ||
@@ -755,3 +753,3 @@ if (body.match(regex)) { | ||
this.logger.verbose.info('Creating new pr body'); | ||
return [4 /*yield*/, this.ghub.issues.update({ | ||
return [4 /*yield*/, this.github.issues.update({ | ||
owner: this.options.owner, | ||
@@ -778,3 +776,3 @@ repo: this.options.repo, | ||
this.logger.verbose.info('Creating release on GitHub for tag:', tag); | ||
return [4 /*yield*/, this.ghub.repos.createRelease({ | ||
return [4 /*yield*/, this.github.repos.createRelease({ | ||
owner: this.options.owner, | ||
@@ -781,0 +779,0 @@ repo: this.options.repo, |
@@ -185,2 +185,5 @@ "use strict"; | ||
if (result.edges.length > 0) { | ||
if (result.edges[0].node.state === 'CLOSED') { | ||
return; | ||
} | ||
var labels = result.edges[0].node.labels | ||
@@ -668,6 +671,6 @@ ? result.edges[0].node.labels.edges.map(function (edge) { return edge.node; }) | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resolvedAuthors, prCommits, author; | ||
var resolvedAuthors, prCommits, author, _a; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -678,3 +681,3 @@ resolvedAuthors = []; | ||
case 1: | ||
prCommits = _a.sent(); | ||
prCommits = _b.sent(); | ||
if (!prCommits) { | ||
@@ -698,15 +701,23 @@ return [2 /*return*/, commit]; | ||
case 2: | ||
resolvedAuthors = _a.sent(); | ||
return [3 /*break*/, 5]; | ||
resolvedAuthors = _b.sent(); | ||
return [3 /*break*/, 8]; | ||
case 3: | ||
if (!commit.authorEmail) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.git.getUserByEmail(commit.authorEmail)]; | ||
if (!commit.authorEmail) return [3 /*break*/, 8]; | ||
if (!commit.authorEmail.includes('@users.noreply.github.com')) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.git.getUserByUsername(commit.authorEmail.split('@users')[0])]; | ||
case 4: | ||
author = _a.sent(); | ||
_a = _b.sent(); | ||
return [3 /*break*/, 7]; | ||
case 5: return [4 /*yield*/, this.git.getUserByEmail(commit.authorEmail)]; | ||
case 6: | ||
_a = _b.sent(); | ||
_b.label = 7; | ||
case 7: | ||
author = _a; | ||
resolvedAuthors.push(__assign({ email: commit.authorEmail, name: commit.authorName }, author)); | ||
_a.label = 5; | ||
case 5: | ||
_b.label = 8; | ||
case 8: | ||
commit.authors = resolvedAuthors.map(function (author) { return (__assign({}, author, (author && author.login ? { username: author.login } : {}))); }); | ||
commit.authors.map(function (author) { | ||
_this.logger.veryVerbose.info("Found author: " + author.username); | ||
_this.logger.veryVerbose.info("Found author: " + author.username + " " + author.email + " " + author.name); | ||
}); | ||
@@ -713,0 +724,0 @@ return [2 /*return*/, commit]; |
@@ -40,3 +40,7 @@ "use strict"; | ||
} | ||
// For pkg bundle | ||
if (!plugin) { | ||
plugin = try_require_1.default(path.join(__dirname, '../../../../../plugins/', pluginPath, 'dist/index.js')); | ||
} | ||
if (!plugin) { | ||
logger.log.warn("Could not find plugin: " + pluginPath); | ||
@@ -43,0 +47,0 @@ return; |
{ | ||
"name": "@auto-it/core", | ||
"version": "6.5.1-canary.f65ea64.16+f65ea64", | ||
"version": "6.5.2-canary.406.5732.27+0a2871a", | ||
"description": "Node API for using auto.", | ||
@@ -82,3 +82,3 @@ "main": "dist/auto.js", | ||
}, | ||
"gitHead": "f65ea64b090faa24cfd7065ba512d9f20c559b89" | ||
"gitHead": "0a2871a3e811ef4e3b45ce6847adeef6ac12affa" | ||
} |
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
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
660804
90
9731