@drazenbebic/wdid 0.1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -0
  3. package/dist/index.js +129 -0
  4. package/package.json +71 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # wdid
2
+
3
+ > What did I do? — a small CLI that summarizes your git activity as a tidy table, so you can fill in your timesheet without trying to remember Tuesday.
4
+
5
+ `wdid` reads `git log` for your author across one or more repos and renders the output as a colorized table with **Date**, **Ticket** (JIRA-style `ABC-123`, parsed from the commit subject), and **Description**.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install -g @drazenbebic/wdid
11
+ ```
12
+
13
+ This puts a `wdid` binary on your `PATH`.
14
+
15
+ ## Usage
16
+
17
+ ```sh
18
+ wdid # all commits authored by you, across all branches
19
+ wdid today # commits from today
20
+ wdid 2026-05-27 # commits from a specific day (YYYY-MM-DD)
21
+ wdid --from 2026-05-01 --to 2026-05-07 # a date range
22
+ wdid --author "Jane Doe" # someone else's commits
23
+ wdid --repo ../api ../web # query multiple repos at once
24
+ ```
25
+
26
+ By default `wdid` uses `git config user.name` as the author and the current working directory as the repo.
27
+
28
+ ### Example output
29
+
30
+ ```
31
+ ┌────────────┬──────────────┬──────────────────────────────────────────────────┐
32
+ │ Date │ Ticket │ Description │
33
+ ├────────────┼──────────────┼──────────────────────────────────────────────────┤
34
+ │ 2026-05-27 │ ABC-123 │ feat(ABC-123): add login flow │
35
+ │ 2026-05-27 │ — │ chore: bump deps │
36
+ │ 2026-05-26 │ ABC-119 │ fix(ABC-119): handle empty payload │
37
+ └────────────┴──────────────┴──────────────────────────────────────────────────┘
38
+ ```
39
+
40
+ If a commit doesn't reference a ticket, the Ticket column is left blank (rendered as `—`).
41
+
42
+ ## Options
43
+
44
+ | Option | Description |
45
+ | ------------------ | --------------------------------------------------------------------- |
46
+ | `[date]` | A `YYYY-MM-DD` date or the literal `today`. Omit to show all history. |
47
+ | `--from <date>` | Start date (inclusive). |
48
+ | `--to <date>` | End date (inclusive). |
49
+ | `--author <name>` | Override the git author. Defaults to `git config user.name`. |
50
+ | `--repo <path...>` | One or more repo paths to query. Defaults to the current directory. |
51
+
52
+ ## Development
53
+
54
+ This project uses [pnpm](https://pnpm.io) (see the `packageManager` field in `package.json`).
55
+
56
+ ```sh
57
+ pnpm install
58
+ pnpm run build # bundle to dist/index.js with tsup
59
+ pnpm run dev # watch mode
60
+ pnpm run typecheck # tsc --noEmit
61
+ pnpm run lint # eslint
62
+ pnpm run format # prettier --write .
63
+ node dist/index.js today
64
+ ```
65
+
66
+ ## Releasing
67
+
68
+ This repo uses [release-please](https://github.com/googleapis/release-please) to manage versions and changelogs. Merge a [Conventional Commit](https://www.conventionalcommits.org/) to `main` (e.g. `feat: ...`, `fix: ...`) and release-please will open a release PR; merging that PR cuts a release and publishes to npm via GitHub Actions.
69
+
70
+ ## License
71
+
72
+ [MIT](./LICENSE)
package/dist/index.js ADDED
@@ -0,0 +1,129 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { Command } from "commander";
5
+
6
+ // src/git.ts
7
+ import { execFile } from "child_process";
8
+ import { promisify } from "util";
9
+ var execFileAsync = promisify(execFile);
10
+ var FIELD_SEP = "";
11
+ var RECORD_SEP = "";
12
+ var JIRA_TICKET_RE = /\b([A-Z][A-Z0-9]+-\d+)\b/;
13
+ function extractTicket(message) {
14
+ const match = message.match(JIRA_TICKET_RE);
15
+ return match ? match[1] : null;
16
+ }
17
+ async function getGitUserName(cwd) {
18
+ const { stdout } = await execFileAsync("git", ["config", "user.name"], {
19
+ cwd
20
+ });
21
+ return stdout.trim();
22
+ }
23
+ async function getCommits(opts) {
24
+ const args = [
25
+ "log",
26
+ "--all",
27
+ "--author-date-order",
28
+ "--regexp-ignore-case",
29
+ `--author=${opts.author}`,
30
+ `--pretty=format:%cs${FIELD_SEP}%s${RECORD_SEP}`
31
+ ];
32
+ if (opts.from) args.push(`--after=${opts.from} 00:00`);
33
+ if (opts.to) args.push(`--before=${opts.to} 23:59`);
34
+ const { stdout } = await execFileAsync("git", args, {
35
+ cwd: opts.cwd,
36
+ maxBuffer: 32 * 1024 * 1024
37
+ });
38
+ return stdout.split(RECORD_SEP).map((r) => r.trim()).filter((r) => r.length > 0).map((record) => {
39
+ const [date = "", subject = ""] = record.split(FIELD_SEP);
40
+ return {
41
+ date,
42
+ ticket: extractTicket(subject),
43
+ description: subject
44
+ };
45
+ });
46
+ }
47
+
48
+ // src/format.ts
49
+ import Table from "cli-table3";
50
+ import chalk from "chalk";
51
+ function renderTable(entries) {
52
+ const table = new Table({
53
+ head: [
54
+ chalk.bold.cyan("Date"),
55
+ chalk.bold.cyan("Ticket"),
56
+ chalk.bold.cyan("Description")
57
+ ],
58
+ style: { head: [], border: [] },
59
+ wordWrap: true,
60
+ colWidths: [12, 14, 80]
61
+ });
62
+ for (const entry of entries) {
63
+ table.push([
64
+ chalk.dim(entry.date),
65
+ entry.ticket ? chalk.yellow(entry.ticket) : chalk.gray("\u2014"),
66
+ entry.description
67
+ ]);
68
+ }
69
+ return table.toString();
70
+ }
71
+ function renderEmpty() {
72
+ return chalk.gray("No commits found for the given filters.");
73
+ }
74
+ function renderError(message) {
75
+ return chalk.red(`error: ${message}`);
76
+ }
77
+
78
+ // src/index.ts
79
+ function isIsoDate(value) {
80
+ return /^\d{4}-\d{2}-\d{2}$/.test(value);
81
+ }
82
+ function resolveDate(input) {
83
+ if (input === "today") {
84
+ return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
85
+ }
86
+ if (!isIsoDate(input)) {
87
+ throw new Error(`invalid date "${input}" \u2014 expected YYYY-MM-DD or "today"`);
88
+ }
89
+ return input;
90
+ }
91
+ async function run(dateArg, options) {
92
+ const repos = options.repo && options.repo.length > 0 ? options.repo : [process.cwd()];
93
+ let from = options.from ? resolveDate(options.from) : void 0;
94
+ let to = options.to ? resolveDate(options.to) : void 0;
95
+ if (dateArg) {
96
+ const day = resolveDate(dateArg);
97
+ from = day;
98
+ to = day;
99
+ }
100
+ const allEntries = [];
101
+ for (const cwd of repos) {
102
+ const author = options.author ?? await getGitUserName(cwd);
103
+ const entries = await getCommits({ author, from, to, cwd });
104
+ allEntries.push(...entries);
105
+ }
106
+ allEntries.sort((a, b) => b.date.localeCompare(a.date));
107
+ if (allEntries.length === 0) {
108
+ process.stdout.write(renderEmpty() + "\n");
109
+ return;
110
+ }
111
+ process.stdout.write(renderTable(allEntries) + "\n");
112
+ }
113
+ var program = new Command();
114
+ program.name("wdid").description("What did I do? \u2014 summarize your git commits as a table").argument("[date]", 'a YYYY-MM-DD date or "today"; omit to show all history').option("--from <date>", 'start date (YYYY-MM-DD or "today")').option("--to <date>", 'end date (YYYY-MM-DD or "today")').option(
115
+ "--author <name>",
116
+ "override the git author (defaults to git config user.name)"
117
+ ).option(
118
+ "--repo <path...>",
119
+ "one or more repo paths to query (defaults to current directory)"
120
+ ).action(async (dateArg, options) => {
121
+ try {
122
+ await run(dateArg, options);
123
+ } catch (err) {
124
+ const message = err instanceof Error ? err.message : String(err);
125
+ process.stderr.write(renderError(message) + "\n");
126
+ process.exitCode = 1;
127
+ }
128
+ });
129
+ program.parseAsync(process.argv);
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@drazenbebic/wdid",
3
+ "version": "0.1.0",
4
+ "description": "What did I do? — summarize your git activity per day as a tidy table, grouped by JIRA ticket.",
5
+ "keywords": [
6
+ "git",
7
+ "log",
8
+ "cli",
9
+ "timesheet",
10
+ "toggl",
11
+ "standup",
12
+ "jira"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "Your Name <you@example.com>",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/your-org/wdid.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/your-org/wdid/issues"
22
+ },
23
+ "homepage": "https://github.com/your-org/wdid#readme",
24
+ "type": "module",
25
+ "main": "dist/index.js",
26
+ "bin": {
27
+ "wdid": "dist/index.js"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "engines": {
35
+ "node": ">=20"
36
+ },
37
+ "packageManager": "pnpm@9.12.0",
38
+ "scripts": {
39
+ "build": "tsup",
40
+ "dev": "tsup --watch",
41
+ "start": "node dist/index.js",
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "eslint .",
44
+ "lint:fix": "eslint . --fix",
45
+ "format": "prettier --write .",
46
+ "format:check": "prettier --check .",
47
+ "test": "vitest run",
48
+ "test:watch": "vitest",
49
+ "prepublishOnly": "pnpm run build"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dependencies": {
55
+ "chalk": "^5.6.2",
56
+ "cli-table3": "^0.6.5",
57
+ "commander": "^14.0.3"
58
+ },
59
+ "devDependencies": {
60
+ "@eslint/js": "^10.0.1",
61
+ "@types/node": "^20.19.41",
62
+ "eslint": "^10.4.0",
63
+ "eslint-config-prettier": "^10.1.8",
64
+ "globals": "^17.6.0",
65
+ "prettier": "^3.8.3",
66
+ "tsup": "^8.5.1",
67
+ "typescript": "^6.0.3",
68
+ "typescript-eslint": "^8.60.0",
69
+ "vitest": "^4.1.7"
70
+ }
71
+ }