Skip to content

Commit

Permalink
fix(npm): update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed May 2, 2022
1 parent aa2100e commit 036eae2
Show file tree
Hide file tree
Showing 3 changed files with 1,975 additions and 3,369 deletions.
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
"author": "Jamie Mason (https://github.com/JamieMason)",
"bugs": "https://github.com/JamieMason/eslint-formatter-git-log/issues",
"dependencies": {
"chalk": "2.4.2"
"chalk": "4.1.2"
},
"devDependencies": {
"@types/eslint": "6.1.1",
"@types/jest": "24.0.18",
"@types/node": "12.7.2",
"eslint": "6.2.2",
"jest": "24.9.0",
"prettier": "1.18.2",
"rimraf": "3.0.0",
"ts-jest": "24.0.2",
"tslint": "5.19.0",
"typescript": "3.5.3"
"@types/eslint": "8.4.1",
"@types/jest": "27.4.1",
"@types/node": "17.0.31",
"eslint": "8.14.0",
"jest": "28.0.3",
"prettier": "2.6.2",
"rimraf": "3.0.2",
"ts-jest": "27.1.4",
"tslint": "5.20.1",
"typescript": "4.6.4"
},
"files": [
"dist"
Expand All @@ -40,9 +40,12 @@
"eslint": ">=5.0.0"
},
"repository": "JamieMason/eslint-formatter-git-log",
"resolutions": {
"chalk": "4.1.2"
},
"scripts": {
"build": "tsc --project .",
"format": "prettier --write './src/**/*.ts' './test/**/*.ts'",
"format": "prettier --write './src/**/*.ts'",
"lint": "tslint --fix --project ./tsconfig.json",
"prebuild": "rimraf ./dist",
"prelint": "npm run format",
Expand Down
73 changes: 37 additions & 36 deletions src/formatters/git-log.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Chalk } from 'chalk';
import chalk from 'chalk';
import { execSync } from 'child_process';
import { getUserEmail } from './get-user-email';
Expand Down Expand Up @@ -73,21 +74,21 @@ interface FinalConfig {
/** Which methods of https://github.com/chalk/chalk to use when formatting */
style: {
/** @example "error" */
error: typeof chalk;
error: Chalk;
/** @example "/Users/guybrush/Dev/grogrates/src/index.js" */
filePath: typeof chalk;
filePath: Chalk;
/** @example "warning" */
warning: typeof chalk;
warning: Chalk;
/** @example "161:12" */
location: typeof chalk;
location: Chalk;
/** @example "no-process-exit" */
rule: typeof chalk;
rule: Chalk;
/** @example "bda304e570" */
commit: typeof chalk;
commit: Chalk;
/** @example "(1 year, 2 months ago)" */
date: typeof chalk;
date: Chalk;
/** @example "<[email protected]>" */
email: typeof chalk;
email: Chalk;
};
}

Expand Down Expand Up @@ -150,38 +151,38 @@ export const createGitLogFormatter: CreateGitLogFormatter = (config) => {
).replace('%s', `${emailRegExp}`);
const totalWarningsLabel = getConfig<string>('label.totalWarnings');
const totalErrorsLabel = getConfig<string>('label.totalErrors');
const styledError = getConfig<typeof chalk>('style.error');
const styledFilePath = getConfig<typeof chalk>('style.filePath');
const styledWarning = getConfig<typeof chalk>('style.warning');
const styledLocation = getConfig<typeof chalk>('style.location');
const styledRule = getConfig<typeof chalk>('style.rule');
const styledCommit = getConfig<typeof chalk>('style.commit');
const styledDate = getConfig<typeof chalk>('style.date');
const styledEmail = getConfig<typeof chalk>('style.email');
const styledError = getConfig<Chalk>('style.error');
const styledFilePath = getConfig<Chalk>('style.filePath');
const styledWarning = getConfig<Chalk>('style.warning');
const styledLocation = getConfig<Chalk>('style.location');
const styledRule = getConfig<Chalk>('style.rule');
const styledCommit = getConfig<Chalk>('style.commit');
const styledDate = getConfig<Chalk>('style.date');
const styledEmail = getConfig<Chalk>('style.email');
const WARNING = styledWarning(warningLabel);
const ERROR = styledError(errorLabel);

const mergeMessageWith = (result: EslintResult) => (
message: EslintMessage,
): ResultItem => {
const { filePath } = result;
const { line } = message;
const command = `git blame --date=relative --show-email -L ${line},${line} -- "${filePath}"`;
const blame = execSync(command, { encoding: 'utf8' });
const commitMatch = blame.match(/^[^ ]+/) || [''];
const dateMatch = blame.match(/> (.+ ago)/) || ['', ''];
const emailMatch = blame.match(/<([^>]+)>/) || ['', ''];
const commit = commitMatch[0];
const date = dateMatch[1].trim();
const email = emailMatch[1];
return {
commit,
date,
email,
message,
result,
const mergeMessageWith =
(result: EslintResult) =>
(message: EslintMessage): ResultItem => {
const { filePath } = result;
const { line } = message;
const command = `git blame --date=relative --show-email -L ${line},${line} -- "${filePath}"`;
const blame = execSync(command, { encoding: 'utf8' });
const commitMatch = blame.match(/^[^ ]+/) || [''];
const dateMatch = blame.match(/> (.+ ago)/) || ['', ''];
const emailMatch = blame.match(/<([^>]+)>/) || ['', ''];
const commit = commitMatch[0];
const date = dateMatch[1].trim();
const email = emailMatch[1];
return {
commit,
date,
email,
message,
result,
};
};
};

const rightAlignToCol1 = (col1Contents: string) =>
' '.repeat(locationColumnWidth - col1Contents.length);
Expand Down
Loading

0 comments on commit 036eae2

Please sign in to comment.