daily-git-summary 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/INSTALL.md +71 -0
- package/QUICKSTART.md +96 -0
- package/README.md +248 -0
- package/bin/daily-summary +4 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +218 -0
- package/dist/cli.js.map +1 -0
- package/dist/fileManager.d.ts +28 -0
- package/dist/fileManager.d.ts.map +1 -0
- package/dist/fileManager.js +137 -0
- package/dist/fileManager.js.map +1 -0
- package/dist/git.d.ts +14 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +74 -0
- package/dist/git.js.map +1 -0
- package/dist/markdown.d.ts +10 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +125 -0
- package/dist/markdown.js.map +1 -0
- package/dist/parser.d.ts +31 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +136 -0
- package/dist/parser.js.map +1 -0
- package/dist/time.d.ts +34 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +110 -0
- package/dist/time.js.map +1 -0
- package/dist/types.d.ts +49 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ensureDirectoryExists = ensureDirectoryExists;
|
|
37
|
+
exports.getOutputPath = getOutputPath;
|
|
38
|
+
exports.isInGitignore = isInGitignore;
|
|
39
|
+
exports.addToGitignore = addToGitignore;
|
|
40
|
+
exports.getRelativePath = getRelativePath;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const DEFAULT_SUMMARY_FOLDER = '.daily-git-summary';
|
|
44
|
+
/**
|
|
45
|
+
* Ensures a directory exists, creating it if necessary
|
|
46
|
+
*/
|
|
47
|
+
function ensureDirectoryExists(dirPath) {
|
|
48
|
+
if (!fs.existsSync(dirPath)) {
|
|
49
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the output file path based on options
|
|
54
|
+
*/
|
|
55
|
+
function getOutputPath(cwd, dateStr, options) {
|
|
56
|
+
// If custom output is specified, use it directly
|
|
57
|
+
if (options.output) {
|
|
58
|
+
return path.resolve(cwd, options.output);
|
|
59
|
+
}
|
|
60
|
+
const filename = `daily-summary-${dateStr}.md`;
|
|
61
|
+
// If folder usage is disabled, save in current directory
|
|
62
|
+
if (options.useFolder === false) {
|
|
63
|
+
return path.resolve(cwd, filename);
|
|
64
|
+
}
|
|
65
|
+
// Use specified folder or default
|
|
66
|
+
const folderName = options.folder || DEFAULT_SUMMARY_FOLDER;
|
|
67
|
+
const folderPath = path.resolve(cwd, folderName);
|
|
68
|
+
// Ensure the folder exists
|
|
69
|
+
ensureDirectoryExists(folderPath);
|
|
70
|
+
return path.join(folderPath, filename);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Checks if a pattern exists in .gitignore
|
|
74
|
+
*/
|
|
75
|
+
function isInGitignore(repoPath, pattern) {
|
|
76
|
+
const gitignorePath = path.join(repoPath, '.gitignore');
|
|
77
|
+
if (!fs.existsSync(gitignorePath)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const content = fs.readFileSync(gitignorePath, 'utf-8');
|
|
81
|
+
const lines = content.split('\n').map(line => line.trim());
|
|
82
|
+
// Check for exact match or pattern match
|
|
83
|
+
return lines.some(line => {
|
|
84
|
+
if (line === pattern)
|
|
85
|
+
return true;
|
|
86
|
+
if (line === `/${pattern}`)
|
|
87
|
+
return true;
|
|
88
|
+
if (line === `${pattern}/`)
|
|
89
|
+
return true;
|
|
90
|
+
if (line === `/${pattern}/`)
|
|
91
|
+
return true;
|
|
92
|
+
return false;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Adds a pattern to .gitignore if it doesn't exist
|
|
97
|
+
*/
|
|
98
|
+
function addToGitignore(repoPath, pattern) {
|
|
99
|
+
const gitignorePath = path.join(repoPath, '.gitignore');
|
|
100
|
+
// Check if already in gitignore
|
|
101
|
+
if (isInGitignore(repoPath, pattern)) {
|
|
102
|
+
return {
|
|
103
|
+
added: false,
|
|
104
|
+
message: `${pattern} is already in .gitignore`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
let content = '';
|
|
109
|
+
// Read existing content if file exists
|
|
110
|
+
if (fs.existsSync(gitignorePath)) {
|
|
111
|
+
content = fs.readFileSync(gitignorePath, 'utf-8');
|
|
112
|
+
// Ensure there's a newline at the end
|
|
113
|
+
if (content.length > 0 && !content.endsWith('\n')) {
|
|
114
|
+
content += '\n';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Add comment and pattern
|
|
118
|
+
content += `\n# Daily git summary files\n${pattern}/\n`;
|
|
119
|
+
// Write back to file
|
|
120
|
+
fs.writeFileSync(gitignorePath, content, 'utf-8');
|
|
121
|
+
return {
|
|
122
|
+
added: true,
|
|
123
|
+
message: `Added ${pattern}/ to .gitignore`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new Error(`Failed to update .gitignore: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Gets the relative path for display purposes
|
|
132
|
+
*/
|
|
133
|
+
function getRelativePath(from, to) {
|
|
134
|
+
const relativePath = path.relative(from, to);
|
|
135
|
+
return relativePath || path.basename(to);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=fileManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileManager.js","sourceRoot":"","sources":["../src/fileManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,sDAIC;AAKD,sCA6BC;AAKD,sCAkBC;AAKD,wCAqCC;AAKD,0CAGC;AAvHD,uCAAyB;AACzB,2CAA6B;AAE7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;QACH,CAAC;QAED,0BAA0B;QAC1B,OAAO,IAAI,gCAAgC,OAAO,KAAK,CAAC;QAExD,qBAAqB;QACrB,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAElD,OAAO;YACL,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,SAAS,OAAO,iBAAiB;SAC3C,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9G,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,IAAY,EAAE,EAAU;IACtD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7C,OAAO,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CommitInfo, TimeRange } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches git commits within a specific time range for the current user
|
|
4
|
+
*/
|
|
5
|
+
export declare function fetchCommits(repoPath: string, timeRange: TimeRange): Promise<CommitInfo[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the current branch name
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCurrentBranch(repoPath: string): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the current directory is a git repository
|
|
12
|
+
*/
|
|
13
|
+
export declare function isGitRepository(repoPath: string): Promise<boolean>;
|
|
14
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhD;;GAEG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,UAAU,EAAE,CAAC,CAmDvB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASxE;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGxE"}
|
package/dist/git.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.fetchCommits = fetchCommits;
|
|
7
|
+
exports.getCurrentBranch = getCurrentBranch;
|
|
8
|
+
exports.isGitRepository = isGitRepository;
|
|
9
|
+
const simple_git_1 = __importDefault(require("simple-git"));
|
|
10
|
+
/**
|
|
11
|
+
* Fetches git commits within a specific time range for the current user
|
|
12
|
+
*/
|
|
13
|
+
async function fetchCommits(repoPath, timeRange) {
|
|
14
|
+
const git = (0, simple_git_1.default)(repoPath);
|
|
15
|
+
// Check if we're in a git repository
|
|
16
|
+
const isRepo = await git.checkIsRepo();
|
|
17
|
+
if (!isRepo) {
|
|
18
|
+
throw new Error('Not a git repository');
|
|
19
|
+
}
|
|
20
|
+
// Get current user info
|
|
21
|
+
const userName = await git.getConfig('user.name');
|
|
22
|
+
const userEmail = await git.getConfig('user.email');
|
|
23
|
+
if (!userName.value && !userEmail.value) {
|
|
24
|
+
throw new Error('Git user not configured');
|
|
25
|
+
}
|
|
26
|
+
// Format dates for git log
|
|
27
|
+
const fromStr = timeRange.from.toISOString();
|
|
28
|
+
const toStr = timeRange.to.toISOString();
|
|
29
|
+
// Fetch commits with detailed information
|
|
30
|
+
const author = userEmail.value || userName.value || '';
|
|
31
|
+
const log = await git.log([
|
|
32
|
+
'--all',
|
|
33
|
+
`--author=${author}`,
|
|
34
|
+
`--after=${fromStr}`,
|
|
35
|
+
`--before=${toStr}`,
|
|
36
|
+
]);
|
|
37
|
+
// Transform to our CommitInfo format
|
|
38
|
+
const commits = await Promise.all(log.all.map(async (commit) => {
|
|
39
|
+
// Get files changed in this commit
|
|
40
|
+
const diffSummary = await git.diffSummary([`${commit.hash}^`, commit.hash]);
|
|
41
|
+
const filesChanged = diffSummary.files.map(f => f.file);
|
|
42
|
+
return {
|
|
43
|
+
hash: commit.hash,
|
|
44
|
+
message: commit.message,
|
|
45
|
+
author: commit.author_name,
|
|
46
|
+
timestamp: new Date(commit.date),
|
|
47
|
+
filesChanged,
|
|
48
|
+
};
|
|
49
|
+
}));
|
|
50
|
+
// Sort by timestamp (oldest first)
|
|
51
|
+
commits.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
|
|
52
|
+
return commits;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the current branch name
|
|
56
|
+
*/
|
|
57
|
+
async function getCurrentBranch(repoPath) {
|
|
58
|
+
const git = (0, simple_git_1.default)(repoPath);
|
|
59
|
+
try {
|
|
60
|
+
const branch = await git.branch();
|
|
61
|
+
return branch.current;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return 'unknown';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Checks if the current directory is a git repository
|
|
69
|
+
*/
|
|
70
|
+
async function isGitRepository(repoPath) {
|
|
71
|
+
const git = (0, simple_git_1.default)(repoPath);
|
|
72
|
+
return await git.checkIsRepo();
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sour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,10 @@
|
|
|
1
|
+
import { DailySummary } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a markdown summary from daily commit data
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateMarkdown(summary: DailySummary): string;
|
|
6
|
+
/**
|
|
7
|
+
* Formats commits for terminal display (with colors)
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatForTerminal(summary: DailySummary, chalk: any): string;
|
|
10
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,SAAS,CAAC;AAQrD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAuH9D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,CA+C3E"}
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMarkdown = generateMarkdown;
|
|
4
|
+
exports.formatForTerminal = formatForTerminal;
|
|
5
|
+
const time_1 = require("./time");
|
|
6
|
+
const parser_1 = require("./parser");
|
|
7
|
+
/**
|
|
8
|
+
* Generates a markdown summary from daily commit data
|
|
9
|
+
*/
|
|
10
|
+
function generateMarkdown(summary) {
|
|
11
|
+
const sections = [];
|
|
12
|
+
// Title
|
|
13
|
+
sections.push(`# Daily Summary - ${summary.date}`);
|
|
14
|
+
sections.push("");
|
|
15
|
+
// Overview section
|
|
16
|
+
sections.push("## Overview");
|
|
17
|
+
sections.push(`- **Period**: ${(0, time_1.formatTimeRange)(summary.timeRange, summary.timezone || "Asia/Manila")}`);
|
|
18
|
+
sections.push(`- **Commits**: ${summary.totalCommits}`);
|
|
19
|
+
sections.push(`- **Files Changed**: ${summary.totalFilesChanged}`);
|
|
20
|
+
sections.push(`- **Current Branch**: \`${summary.currentBranch}\``);
|
|
21
|
+
sections.push("");
|
|
22
|
+
// Check if there are any commits
|
|
23
|
+
if (summary.totalCommits === 0) {
|
|
24
|
+
sections.push("## What I Did Yesterday");
|
|
25
|
+
sections.push("");
|
|
26
|
+
sections.push("_No commits found in this time period._");
|
|
27
|
+
sections.push("");
|
|
28
|
+
return sections.join("\n");
|
|
29
|
+
}
|
|
30
|
+
// What I Did Yesterday section
|
|
31
|
+
sections.push("## What I Did Yesterday");
|
|
32
|
+
sections.push("");
|
|
33
|
+
for (const [type, commits] of Object.entries(summary.groupedCommits)) {
|
|
34
|
+
const displayName = (0, parser_1.getTypeDisplayName)(type);
|
|
35
|
+
const count = commits.length;
|
|
36
|
+
sections.push(`### ${displayName} (${count} commit${count !== 1 ? "s" : ""})`);
|
|
37
|
+
sections.push("");
|
|
38
|
+
for (const commit of commits) {
|
|
39
|
+
const scopeStr = commit.scope ? `(${commit.scope})` : "";
|
|
40
|
+
const breakingStr = commit.isBreaking ? "⚠️ " : "";
|
|
41
|
+
const issueStr = commit.issueNumbers.length > 0
|
|
42
|
+
? ` [${commit.issueNumbers.map((n) => `#${n}`).join(", ")}]`
|
|
43
|
+
: "";
|
|
44
|
+
sections.push(`- ${breakingStr}${type}${scopeStr}: ${commit.description}${issueStr}`);
|
|
45
|
+
}
|
|
46
|
+
sections.push("");
|
|
47
|
+
}
|
|
48
|
+
// Files Most Changed section
|
|
49
|
+
if (summary.fileChangeFrequency.size > 0) {
|
|
50
|
+
sections.push("## Files Most Changed");
|
|
51
|
+
sections.push("");
|
|
52
|
+
const sortedFiles = Array.from(summary.fileChangeFrequency.entries())
|
|
53
|
+
.sort((a, b) => b[1] - a[1])
|
|
54
|
+
.slice(0, 10); // Top 10 files
|
|
55
|
+
sortedFiles.forEach(([file, count], index) => {
|
|
56
|
+
sections.push(`${index + 1}. \`${file}\` (${count} change${count !== 1 ? "s" : ""})`);
|
|
57
|
+
});
|
|
58
|
+
sections.push("");
|
|
59
|
+
}
|
|
60
|
+
// Suggested For Today section
|
|
61
|
+
const wipCommits = (0, parser_1.findWIPCommits)(summary.commits);
|
|
62
|
+
const issueNumbers = (0, parser_1.extractIssueNumbers)(summary.commits);
|
|
63
|
+
if (wipCommits.length > 0 ||
|
|
64
|
+
issueNumbers.length > 0 ||
|
|
65
|
+
(summary.currentBranch !== "main" && summary.currentBranch !== "master")) {
|
|
66
|
+
sections.push("## Suggested For Today");
|
|
67
|
+
sections.push("");
|
|
68
|
+
// Current branch suggestion
|
|
69
|
+
if (summary.currentBranch !== "main" &&
|
|
70
|
+
summary.currentBranch !== "master" &&
|
|
71
|
+
summary.currentBranch !== "unknown") {
|
|
72
|
+
sections.push(`- Continue work on branch: \`${summary.currentBranch}\``);
|
|
73
|
+
}
|
|
74
|
+
// WIP commits
|
|
75
|
+
for (const wip of wipCommits) {
|
|
76
|
+
sections.push(`- Complete WIP: "${wip.description}"`);
|
|
77
|
+
}
|
|
78
|
+
// Related issues
|
|
79
|
+
if (issueNumbers.length > 0) {
|
|
80
|
+
sections.push(`- Related issues: ${issueNumbers.map((n) => `#${n}`).join(", ")}`);
|
|
81
|
+
}
|
|
82
|
+
sections.push("");
|
|
83
|
+
}
|
|
84
|
+
// Footer
|
|
85
|
+
sections.push("---");
|
|
86
|
+
sections.push("");
|
|
87
|
+
sections.push("_Generated by daily-git-summary_");
|
|
88
|
+
sections.push("");
|
|
89
|
+
return sections.join("\n");
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Formats commits for terminal display (with colors)
|
|
93
|
+
*/
|
|
94
|
+
function formatForTerminal(summary, chalk) {
|
|
95
|
+
const sections = [];
|
|
96
|
+
// Title
|
|
97
|
+
sections.push(chalk.bold.blue(`\n📊 Daily Summary - ${summary.date}\n`));
|
|
98
|
+
// Overview
|
|
99
|
+
sections.push(chalk.bold("Overview:"));
|
|
100
|
+
sections.push(` Period: ${(0, time_1.formatTimeRange)(summary.timeRange, summary.timezone || "Asia/Manila")}`);
|
|
101
|
+
sections.push(` Commits: ${chalk.green(summary.totalCommits)}`);
|
|
102
|
+
sections.push(` Files Changed: ${chalk.green(summary.totalFilesChanged)}`);
|
|
103
|
+
sections.push(` Branch: ${chalk.cyan(summary.currentBranch)}`);
|
|
104
|
+
sections.push("");
|
|
105
|
+
if (summary.totalCommits === 0) {
|
|
106
|
+
sections.push(chalk.yellow("No commits found in this time period."));
|
|
107
|
+
return sections.join("\n");
|
|
108
|
+
}
|
|
109
|
+
// Commits by type
|
|
110
|
+
sections.push(chalk.bold("What I Did Yesterday:\n"));
|
|
111
|
+
for (const [type, commits] of Object.entries(summary.groupedCommits)) {
|
|
112
|
+
const displayName = (0, parser_1.getTypeDisplayName)(type);
|
|
113
|
+
const count = commits.length;
|
|
114
|
+
sections.push(chalk.bold.underline(`${displayName} (${count}):`));
|
|
115
|
+
for (const commit of commits) {
|
|
116
|
+
const scopeStr = commit.scope ? chalk.gray(`(${commit.scope})`) : "";
|
|
117
|
+
const breakingStr = commit.isBreaking ? chalk.red("⚠️ ") : "";
|
|
118
|
+
const shortHash = chalk.gray(`[${commit.raw.hash.substring(0, 7)}]`);
|
|
119
|
+
sections.push(` ${breakingStr}${type}${scopeStr}: ${commit.description} ${shortHash}`);
|
|
120
|
+
}
|
|
121
|
+
sections.push("");
|
|
122
|
+
}
|
|
123
|
+
return sections.join("\n");
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":";;AAWA,4CAuHC;AAKD,8CA+CC;AArLD,iCAAyC;AACzC,qCAIkB;AAElB;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAAqB;IACpD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,QAAQ;IACR,QAAQ,CAAC,IAAI,C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;YAC/D,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;YAErE,QAAQ,CAAC,IAAI,CACX,KAAK,WAAW,GAAG,IAAI,GAAG,QAAQ,KAAK,MAAM,CAAC,WAAW,IAAI,SAAS,EAAE,CACzE,CAAC;QACJ,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CommitInfo, ParsedCommit, GroupedCommits } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a conventional commit message
|
|
4
|
+
* Format: type(scope)!: description
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseCommitMessage(commit: CommitInfo): ParsedCommit;
|
|
7
|
+
/**
|
|
8
|
+
* Groups parsed commits by their type
|
|
9
|
+
*/
|
|
10
|
+
export declare function groupCommitsByType(commits: ParsedCommit[]): GroupedCommits;
|
|
11
|
+
/**
|
|
12
|
+
* Gets the display name for a commit type
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTypeDisplayName(type: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Counts total files changed across all commits
|
|
17
|
+
*/
|
|
18
|
+
export declare function countTotalFilesChanged(commits: CommitInfo[]): number;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a frequency map of files changed
|
|
21
|
+
*/
|
|
22
|
+
export declare function getFileChangeFrequency(commits: CommitInfo[]): Map<string, number>;
|
|
23
|
+
/**
|
|
24
|
+
* Finds WIP (Work In Progress) commits
|
|
25
|
+
*/
|
|
26
|
+
export declare function findWIPCommits(commits: ParsedCommit[]): ParsedCommit[];
|
|
27
|
+
/**
|
|
28
|
+
* Extracts unique issue numbers from commits
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractIssueNumbers(commits: ParsedCommit[]): string[];
|
|
31
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAgBnE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,CAoCnE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,cAAc,CA6B1E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAUpE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUjF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAKtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,EAAE,CAUrE"}
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCommitMessage = parseCommitMessage;
|
|
4
|
+
exports.groupCommitsByType = groupCommitsByType;
|
|
5
|
+
exports.getTypeDisplayName = getTypeDisplayName;
|
|
6
|
+
exports.countTotalFilesChanged = countTotalFilesChanged;
|
|
7
|
+
exports.getFileChangeFrequency = getFileChangeFrequency;
|
|
8
|
+
exports.findWIPCommits = findWIPCommits;
|
|
9
|
+
exports.extractIssueNumbers = extractIssueNumbers;
|
|
10
|
+
// Conventional commit types and their display names
|
|
11
|
+
const COMMIT_TYPES = {
|
|
12
|
+
feat: 'Features',
|
|
13
|
+
fix: 'Bug Fixes',
|
|
14
|
+
refactor: 'Refactoring',
|
|
15
|
+
perf: 'Performance',
|
|
16
|
+
style: 'Style',
|
|
17
|
+
test: 'Tests',
|
|
18
|
+
docs: 'Documentation',
|
|
19
|
+
build: 'Build',
|
|
20
|
+
ops: 'Operations',
|
|
21
|
+
chore: 'Chores',
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Parses a conventional commit message
|
|
25
|
+
* Format: type(scope)!: description
|
|
26
|
+
*/
|
|
27
|
+
function parseCommitMessage(commit) {
|
|
28
|
+
const message = commit.message.trim();
|
|
29
|
+
// Regex to match conventional commit format
|
|
30
|
+
// Matches: type(scope)!: description or type: description
|
|
31
|
+
const conventionalRegex = /^(\w+)(?:\(([^)]+)\))?(!)?:\s*(.+)$/;
|
|
32
|
+
const match = message.match(conventionalRegex);
|
|
33
|
+
let type = 'other';
|
|
34
|
+
let scope;
|
|
35
|
+
let description = message;
|
|
36
|
+
let isBreaking = false;
|
|
37
|
+
if (match) {
|
|
38
|
+
type = match[1].toLowerCase();
|
|
39
|
+
scope = match[2];
|
|
40
|
+
isBreaking = match[3] === '!';
|
|
41
|
+
description = match[4];
|
|
42
|
+
}
|
|
43
|
+
// Extract issue numbers (#123, #456)
|
|
44
|
+
const issueRegex = /#(\d+)/g;
|
|
45
|
+
const issueNumbers = [];
|
|
46
|
+
let issueMatch;
|
|
47
|
+
while ((issueMatch = issueRegex.exec(message)) !== null) {
|
|
48
|
+
issueNumbers.push(issueMatch[1]);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
type,
|
|
52
|
+
scope,
|
|
53
|
+
description,
|
|
54
|
+
isBreaking,
|
|
55
|
+
issueNumbers,
|
|
56
|
+
raw: commit,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Groups parsed commits by their type
|
|
61
|
+
*/
|
|
62
|
+
function groupCommitsByType(commits) {
|
|
63
|
+
const grouped = {};
|
|
64
|
+
for (const commit of commits) {
|
|
65
|
+
if (!grouped[commit.type]) {
|
|
66
|
+
grouped[commit.type] = [];
|
|
67
|
+
}
|
|
68
|
+
grouped[commit.type].push(commit);
|
|
69
|
+
}
|
|
70
|
+
// Sort types by priority (feat, fix, refactor, etc., then other)
|
|
71
|
+
const priorityOrder = ['feat', 'fix', 'refactor', 'perf', 'docs', 'style', 'test', 'build', 'ops', 'chore'];
|
|
72
|
+
const sortedGrouped = {};
|
|
73
|
+
// Add prioritized types first
|
|
74
|
+
for (const type of priorityOrder) {
|
|
75
|
+
if (grouped[type]) {
|
|
76
|
+
sortedGrouped[type] = grouped[type];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Add remaining types
|
|
80
|
+
for (const type in grouped) {
|
|
81
|
+
if (!sortedGrouped[type]) {
|
|
82
|
+
sortedGrouped[type] = grouped[type];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return sortedGrouped;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets the display name for a commit type
|
|
89
|
+
*/
|
|
90
|
+
function getTypeDisplayName(type) {
|
|
91
|
+
return COMMIT_TYPES[type] || 'Other';
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Counts total files changed across all commits
|
|
95
|
+
*/
|
|
96
|
+
function countTotalFilesChanged(commits) {
|
|
97
|
+
const uniqueFiles = new Set();
|
|
98
|
+
for (const commit of commits) {
|
|
99
|
+
for (const file of commit.filesChanged) {
|
|
100
|
+
uniqueFiles.add(file);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return uniqueFiles.size;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Creates a frequency map of files changed
|
|
107
|
+
*/
|
|
108
|
+
function getFileChangeFrequency(commits) {
|
|
109
|
+
const frequency = new Map();
|
|
110
|
+
for (const commit of commits) {
|
|
111
|
+
for (const file of commit.filesChanged) {
|
|
112
|
+
frequency.set(file, (frequency.get(file) || 0) + 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return frequency;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Finds WIP (Work In Progress) commits
|
|
119
|
+
*/
|
|
120
|
+
function findWIPCommits(commits) {
|
|
121
|
+
return commits.filter(commit => commit.description.toLowerCase().includes('wip') ||
|
|
122
|
+
commit.description.toLowerCase().startsWith('work in progress'));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Extracts unique issue numbers from commits
|
|
126
|
+
*/
|
|
127
|
+
function extractIssueNumbers(commits) {
|
|
128
|
+
const issues = new Set();
|
|
129
|
+
for (const commit of commits) {
|
|
130
|
+
for (const issue of commit.issueNumbers) {
|
|
131
|
+
issues.add(issue);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return Array.from(issues).sort();
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";;AAoBA,gDAoCC;AAKD,gDA6BC;AAKD,gDAEC;AAKD,wDAUC;AAKD,wDAUC;AAKD,wCAKC;AAKD,kDAUC;AAtJD,oDAAoD;AACpD,MAAM,YAAY,GAA2B;IAC3C,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,WAAW;IAChB,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,YAAY;IACjB,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF;;;GAGG;AACH,SAAgB,kBAAkB,CAAC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CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,OAAqB;IAC1D,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACvC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,OAAuB;IACpD,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAC7B,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;QAChD,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAChE,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,OAAuB;IACzD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAEjC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/time.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TimeRange, TimeConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a time string in HH:MM format and returns [hours, minutes]
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseTimeString(timeStr: string): [number, number];
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the time range for a daily summary with optional custom times.
|
|
8
|
+
*
|
|
9
|
+
* @param targetDate - The date to calculate the range for (defaults to today)
|
|
10
|
+
* @param config - Optional time configuration (start/end times and timezone)
|
|
11
|
+
* @returns TimeRange object with from and to dates in UTC
|
|
12
|
+
*/
|
|
13
|
+
export declare function calculateTimeRange(targetDate?: Date, config?: Partial<TimeConfig>): TimeRange;
|
|
14
|
+
/**
|
|
15
|
+
* Calculates the time range for a specific date string (YYYY-MM-DD)
|
|
16
|
+
*
|
|
17
|
+
* @param dateStr - Date string in YYYY-MM-DD format
|
|
18
|
+
* @param config - Optional time configuration
|
|
19
|
+
* @returns TimeRange object with from and to dates in UTC
|
|
20
|
+
*/
|
|
21
|
+
export declare function calculateTimeRangeForDate(dateStr: string, config?: Partial<TimeConfig>): TimeRange;
|
|
22
|
+
/**
|
|
23
|
+
* Formats a date range for display
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatTimeRange(range: TimeRange, timezone?: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the date string for the summary filename
|
|
28
|
+
*/
|
|
29
|
+
export declare function getDateString(date?: Date, timezone?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Validates a timezone string
|
|
32
|
+
*/
|
|
33
|
+
export declare function isValidTimezone(timezone: string): boolean;
|
|
34
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAMhD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAcjE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAkC7F;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAKlG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,GAAE,MAAyB,GAAG,MAAM,CAW7F;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAE,MAAyB,GAAG,MAAM,CAItF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOzD"}
|