Skip to content

Commit

Permalink
Improve logs format
Browse files Browse the repository at this point in the history
  • Loading branch information
ukupat committed Sep 24, 2024
1 parent b920cdc commit 05a45f8
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 31 deletions.
22 changes: 8 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33960,7 +33960,7 @@ const trello_1 = __nccwpck_require__(9763);
const logger_1 = __importDefault(__nccwpck_require__(2358));
const matchCardIds_1 = __importDefault(__nccwpck_require__(9812));
async function addCardLinksToPullRequest(conf, cardIds) {
logger_1.default.logStep('ADD CARD LINKS TO PR');
logger_1.default.log('🔗 ADD CARD LINKS TO PR');
const bodyCardIds = await getCardIdsFromBody(conf);
const commentsCardIds = await getCardIdsFromComments(conf);
const linkedCardIds = [...bodyCardIds, ...commentsCardIds];
Expand Down Expand Up @@ -34005,11 +34005,10 @@ const github_1 = __nccwpck_require__(2649);
const trello_1 = __nccwpck_require__(9763);
const logger_1 = __importDefault(__nccwpck_require__(2358));
async function addLabelToCards(conf, cardIds, head) {
logger_1.default.logStep('ADD LABEL TO CARDS');
if (!conf.trelloAddLabelsToCards) {
logger_1.default.log('Skipping label adding');
return;
}
logger_1.default.log('🏷️ ADD LABELS TO CARDS');
const branchLabel = await getBranchLabel(head);
if (!branchLabel) {
logger_1.default.log('Could not find branch label');
Expand Down Expand Up @@ -34077,7 +34076,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const trello_1 = __nccwpck_require__(9763);
const logger_1 = __importDefault(__nccwpck_require__(2358));
async function addPullRequestLinkToCards(cardIds, pr) {
logger_1.default.logStep('ADD PR LINK TO CARDS');
logger_1.default.log('🔗 ADD PR LINK TO CARDS');
const link = pr.html_url || pr.url;
return Promise.all(cardIds.map(async (cardId) => {
const existingAttachments = await (0, trello_1.getCardAttachments)(cardId);
Expand Down Expand Up @@ -34387,7 +34386,7 @@ const matchCardIds_1 = __importDefault(__nccwpck_require__(9812));
const isPullRequestInDraft_1 = __importDefault(__nccwpck_require__(3031));
const logger_1 = __importDefault(__nccwpck_require__(2358));
async function getCardIds(conf, head) {
logger_1.default.logStep('FIND CARDS');
logger_1.default.log('🔎 FIND CARDS');
const pr = await (0, github_1.getPullRequest)();
let cardIds = (0, matchCardIds_1.default)(conf, pr.body || '');
if (conf.githubIncludeNewCardCommand) {
Expand Down Expand Up @@ -34575,7 +34574,7 @@ const isPullRequestInDraft_1 = __importDefault(__nccwpck_require__(3031));
const isPullRequestApproved_1 = __importDefault(__nccwpck_require__(4414));
const logger_1 = __importDefault(__nccwpck_require__(2358));
async function moveOrArchiveCards(conf, cardIds, pr) {
logger_1.default.logStep('MOVE OR ARCHIVE CARDS');
logger_1.default.log('🕺 MOVE OR ARCHIVE CARDS');
const isDraft = (0, isPullRequestInDraft_1.default)(pr);
const isChangesRequested = await (0, isChangesRequestedInReview_1.default)();
const isApproved = await (0, isPullRequestApproved_1.default)();
Expand Down Expand Up @@ -34649,10 +34648,10 @@ const isPullRequestInDraft_1 = __importDefault(__nccwpck_require__(3031));
const isPullRequestApproved_1 = __importDefault(__nccwpck_require__(4414));
const logger_1 = __importDefault(__nccwpck_require__(2358));
async function updateCardMembers(conf, cardIds, pr) {
logger_1.default.logStep('UPDATE CARD MEMBERS');
if (!conf.trelloAddMembersToCards) {
return logger_1.default.log('Skipping members updating');
return;
}
logger_1.default.log('👩‍💻 UPDATE CARD MEMBERS');
const inReview = await isPullRequestInReview(conf, pr);
if (inReview) {
await assignReviewers(conf, cardIds);
Expand Down Expand Up @@ -34933,14 +34932,9 @@ exports["default"] = isPullRequestInDraft;

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports["default"] = {
logStep: (...message) => {
if (!process.env.JEST_WORKER_ID) {
console.log(...message); // eslint-disable-line no-console
}
},
log: (...message) => {
if (!process.env.JEST_WORKER_ID) {
console.log('\t', ...message); // eslint-disable-line no-console
console.log(...message); // eslint-disable-line no-console
}
},
error: (...message) => {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/addCardLinksToPullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import logger from './utils/logger'
import matchCardIds from './utils/matchCardIds'

export default async function addCardLinksToPullRequest(conf: Conf, cardIds: string[]) {
logger.logStep('ADD CARD LINKS TO PR')
logger.log('🔗 ADD CARD LINKS TO PR')

const bodyCardIds = await getCardIdsFromBody(conf)
const commentsCardIds = await getCardIdsFromComments(conf)
Expand Down
6 changes: 2 additions & 4 deletions src/actions/addLabelToCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import { addLabelToCard, getBoardLabels, getCardInfo } from './api/trello'
import logger from './utils/logger'

export default async function addLabelToCards(conf: Conf, cardIds: string[], head?: PRHead) {
logger.logStep('ADD LABEL TO CARDS')

if (!conf.trelloAddLabelsToCards) {
logger.log('Skipping label adding')

return
}
logger.log('🏷️ ADD LABELS TO CARDS')

const branchLabel = await getBranchLabel(head)

if (!branchLabel) {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/addPullRequestLinkToCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { addAttachmentToCard, getCardAttachments } from './api/trello'
import logger from './utils/logger'

export default async function addPullRequestLinkToCards(cardIds: string[], pr: PR) {
logger.logStep('ADD PR LINK TO CARDS')
logger.log('🔗 ADD PR LINK TO CARDS')

const link = pr.html_url || pr.url

Expand Down
2 changes: 1 addition & 1 deletion src/actions/getCardIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import isPullRequestInDraft from './utils/isPullRequestInDraft'
import logger from './utils/logger'

export default async function getCardIds(conf: Conf, head?: PRHead) {
logger.logStep('FIND CARDS')
logger.log('🔎 FIND CARDS')

const pr = await getPullRequest()
let cardIds = matchCardIds(conf, pr.body || '')
Expand Down
2 changes: 1 addition & 1 deletion src/actions/moveOrArchiveCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import isPullRequestApproved from './utils/isPullRequestApproved'
import logger from './utils/logger'

export default async function moveOrArchiveCards(conf: Conf, cardIds: string[], pr: PR) {
logger.logStep('MOVE OR ARCHIVE CARDS')
logger.log('🕺 MOVE OR ARCHIVE CARDS')

const isDraft = isPullRequestInDraft(pr)
const isChangesRequested = await isChangesRequestedInReview()
Expand Down
6 changes: 3 additions & 3 deletions src/actions/updateCardMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import isPullRequestApproved from './utils/isPullRequestApproved'
import logger from './utils/logger'

export default async function updateCardMembers(conf: Conf, cardIds: string[], pr: PR) {
logger.logStep('UPDATE CARD MEMBERS')

if (!conf.trelloAddMembersToCards) {
return logger.log('Skipping members updating')
return
}
logger.log('👩‍💻 UPDATE CARD MEMBERS')

const inReview = await isPullRequestInReview(conf, pr)

if (inReview) {
Expand Down
7 changes: 1 addition & 6 deletions src/actions/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
export default {
logStep: (...message: any[]) => {
if (!process.env.JEST_WORKER_ID) {
console.log(...message) // eslint-disable-line no-console
}
},
log: (...message: any[]) => {
if (!process.env.JEST_WORKER_ID) {
console.log('\t', ...message) // eslint-disable-line no-console
console.log(...message) // eslint-disable-line no-console
}
},
error: (...message: any[]) => {
Expand Down

0 comments on commit 05a45f8

Please sign in to comment.