-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement from scratch - done (in ~100 lines as a whole) #23
Labels
Comments
tunnckoCore
changed the title
Reimplement from scratch
Reimplement from scratch - done (in 50 lines)
Sep 29, 2018
tunnckoCore
changed the title
Reimplement from scratch - done (in 50 lines)
Reimplement from scratch - done (in ~100 lines as a whole)
Sep 29, 2018
The continuation import { parse, plugins } from 'parse-commit-message';
import detector from 'detect-next-version';
const sha = 'ede8c2677df83475009012fef7bb0a4b3e467eb3';
const apiCommits = [
{ sha, message: 'fix: qux baz', author: { name: 'Charlike Mike Reagent ' } },
{ sha, message: 'fix: 123 qq', author: { name: 'Charlike Mike Reagent ' } },
{ sha, message: 'feat: foz', author: { name: 'Charlike Mike Reagent ' } },
];
const author = {
login: 'tunnckoCore',
id: 5038030,
};
/* eslint-disable no-param-reassign */
const context = {
payload: {
repository: {
full_name: 'tunnckoCoreLabs/qq5',
},
commits: apiCommits,
author,
},
};
const commits = context.payload.commits.map((commit) => {
const cmt = parse(commit.message, plugins);
cmt.sha = commit.sha;
cmt.author = context.payload.author;
cmt.repository = context.payload.repository.full_name;
return cmt;
});
detector('@tunnckocore/qq5', commits).then(console.log);
// { increment: 'minor',
// patch:
// [ { header: [Object],
// body: null,
// footer: null,
// mentions: [],
// increment: 'patch',
// isBreaking: false,
// sha: 'ede8c2677df83475009012fef7bb0a4b3e467eb3',
// author: [Object],
// repository: 'tunnckoCoreLabs/qq5' },
// { header: [Object],
// body: null,
// footer: null,
// mentions: [],
// increment: 'patch',
// isBreaking: false,
// sha: 'ede8c2677df83475009012fef7bb0a4b3e467eb3',
// author: [Object],
// repository: 'tunnckoCoreLabs/qq5' } ],
// minor:
// [ { header: [Object],
// body: null,
// footer: null,
// mentions: [],
// increment: 'minor',
// isBreaking: false,
// sha: 'ede8c2677df83475009012fef7bb0a4b3e467eb3',
// author: [Object],
// repository: 'tunnckoCoreLabs/qq5' } ],
// pkg:
// { name: '@tunnckocore/qq5',
// version: '0.1.0',
// main: 'index.js',
// license: 'MIT',
// publishConfig: { access: 'public', tag: 'latest' } },
// lastVersion: '0.1.0',
// nextVersion: '0.2.0' } |
the render to release body export default function render(locals) {
const tpl = [];
const { repository: repo, lastVersion: from, nextVersion: to } = locals;
/* eslint-disable no-param-reassign */
locals.compareLink = `https://github.com/${repo}/compare/${from}..v${to}`;
tpl.push(`## [v${to}](${locals.compareLink}) (${locals.date})`, '');
['major', 'minor', 'patch'].forEach((type) => {
if (locals[type]) {
let heading = null;
if (locals.major) {
heading = '### :exclamation: BREAKING CHANGES! :scream:';
}
if (locals.minor) {
heading = '### :tada: New Features';
}
if (locals.patch) {
heading = '### :bug: Bug Fixes';
}
tpl.push(heading, '');
locals[type].forEach((commit) => {
const profile = (commit.author && commit.author.login) || '';
let hash = commit.sha ? commit.sha.slice(0, 7) : null;
hash = hash ? `(#${hash}) ` : '';
tpl.push(`- ${commit.header.toString()} ${hash}${profile}`);
});
const excludeSignOff = (zz) => {
const val = zz
.split('\n')
.filter((x) => !x.startsWith('Signed-off-by'));
return val;
};
locals[type].forEach((commit) => {
if (commit.body) {
tpl.push('', excludeSignOff(commit.body));
}
if (commit.footer) {
tpl.push('', excludeSignOff(commit.footer));
}
if (commit.mentions && commit.mentions.length > 0) {
tpl.push('', commit.mentions.join(' '));
}
});
tpl.push('', '');
}
});
const link = `[\`v${locals.from}...v${locals.to}\`](${locals.compareLink})`;
return tpl
.concat('', link)
.filter((x) => x !== null && x !== ' ')
.join('\n')
.trim();
} |
Merged
tunnckoCore
pushed a commit
that referenced
this issue
Nov 30, 2018
…lease/app resolves #23 Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just because of the few updates and new packages that I published from locally.
yarn add detect-next-version@next
(28 lines)recommended-bump
(~24 lines), and@tunnckocore/package-json
(~10 lines)So, the implementation is near 50 lines, excluding the template and release rendering.
The text was updated successfully, but these errors were encountered: