Skip to content
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

feat(core): add emoji feature to commently #703

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
},
"license": "MIT",
"dependencies": {
"@types/node": "10.14.22"
"@types/node": "10.14.22",
"commently-cli": "^6.27.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this change is needed

}
}
9 changes: 7 additions & 2 deletions packages/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ const args = arg({
'--help': Boolean,
'--verbose': Boolean,

'--emoji': String,

// Aliases
'-m': '--message',
'-t': '--title',
'-h': '--help',
'-v': '--verbose'
'-v': '--verbose',
'-e': '--emoji',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to use this over the --message or --title flag?

});

if (args['--help']) {
Expand All @@ -41,6 +44,7 @@ if (args['--help']) {
--useHistory Boolean : Keep a history of the comments in the comment created by this library
--help, -h Boolean : Show the help dialog
--verbose, -v Boolean : Output the debug log
--emoji, -e Boolean : Output the debug log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description here is wrong, please update

`);
process.exit(0);
}
Expand All @@ -59,7 +63,8 @@ const commently = new Commently({
repo: args['--repo'],
title: args['--title'],
key: args['--key'],
useHistory: args['--useHistory']
useHistory: args['--useHistory'],
emoji: args['--emoji'] || '💬'
});

commently
Expand Down
8 changes: 7 additions & 1 deletion packages/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ interface CommentlyArgs {
repo?: string;
/** The title at the top of the comment */
title?: string;
/** The emoji to use in the comment */
emoji?: string;
/** The unique key to identify the comment by, not shown to end users */
key?: string;
/** Key a history of the comments in the comment created by this library */
useHistory?: boolean;

}

interface User {
Expand All @@ -38,6 +41,7 @@ export default class Commently {
private readonly footer: string;
private readonly delim: string;
private readonly debug: debug.IDebugger;
private readonly emoji: string;

constructor(args: CommentlyArgs) {
this.debug = debug('commently');
Expand All @@ -46,6 +50,7 @@ export default class Commently {
const slug = ('slug' in env && env.slug) || '';
const [owner, repo] = slug.split('/');
const prNumber = args.pr || ('pr' in env && Number(env.pr));
this.emoji = args.emoji || '💬'; // Default to speech balloon emoji if not provided

if (!prNumber) {
throw new Error(
Expand All @@ -59,6 +64,7 @@ export default class Commently {
this.repo = args.repo || repo;
this.useHistory = 'useHistory' in args ? Boolean(args.useHistory) : true;


if (!this.owner) {
throw new Error(
"A owner wasn't provided as an argument (--owner) or detected in the CI environment."
Expand All @@ -72,7 +78,7 @@ export default class Commently {
}

this.issueId = prNumber;
this.header = `<!-- \n ${this.key}-id: ${this.issueId} \n -->\n${this.title}\n`;
this.header = `<!-- \n ${this.key}-id: ${this.issueId} \n -->\n${this.emoji} ${this.title}\n`;
this.footer = `Courtesy of your **[${this.key}](https://github.com/intuit/commently)** bot :package::rocket:`;
this.delim = `<!-- ${this.key}-section -->\n\n`;

Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1735,17 +1735,17 @@
resolved "https://registry.yarnpkg.com/@types/command-line-usage/-/command-line-usage-5.0.1.tgz#99424950da567ba67b6b65caee57ff03c4e751ec"
integrity sha512-/xUgezxxYePeXhg5S04hUjxG9JZi+rJTs1+4NwpYPfSaS7BeDa6tVJkH6lN9Cb6rl8d24Fi2uX0s0Ngg2JT6gg==

"@types/[email protected].7":
version "4.1.7"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.7.tgz#7cc0ea761509124709b8b2d1090d8f6c17aadb82"
integrity sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==
"@types/[email protected].12":
version "4.1.12"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.12.tgz#a155f21690871953410df4b6b6f53187f0500917"
integrity sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==
dependencies:
"@types/ms" "*"

"@types/[email protected].1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@types/env-ci/-/env-ci-3.1.1.tgz#e1ff1b648c01b0f5202de5633c00f711f0f3ac03"
integrity sha512-JuX+LHsvhktApmZxmBrG458kfSvPAvs2Kqhyrow3IKtDsbcRco7NFgpsNthjp8EQxKA6PMw3DrY/IH8ZAuTYlQ==
"@types/[email protected].4":
version "3.1.4"
resolved "https://registry.yarnpkg.com/@types/env-ci/-/env-ci-3.1.4.tgz#2fd9f39b10c8407ebf5887d68398413606ae00f9"
integrity sha512-WwSUcrqHNzRz+3nIZYO+p1OxJ/yDNSKFTpor06W+L2ie/K76a/Wb49LxHHiJMH44UeK7GM2kyWpL++e09v4qkA==

"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
Expand Down