From ca02cd96a4eba1b34b77aed50652b00c7d60925d Mon Sep 17 00:00:00 2001 From: Ali HD <85040609+alihd-tech@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:19:09 +0330 Subject: [PATCH 01/10] Prepare standalone npm CLI distribution --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9af507b..42c1024 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "code-life-balance", - "version": "0.1.0", + "version": "1.1.0", "private": true, "license": "MIT", "repository": { @@ -17,7 +17,9 @@ "test:report": "node --test packages/report/index.test.mjs", "test": "node --test packages/core/index.test.mjs packages/report/index.test.mjs", "typecheck": "tsc --noEmit", - "check": "pnpm test && pnpm typecheck && pnpm build" + "check": "pnpm test && pnpm typecheck && pnpm build && pnpm test:npm-cli", + "build:npm-cli": "node scripts/build-npm-cli.mjs", + "test:npm-cli": "pnpm build:npm-cli && node dist/npm/cli/index.mjs --help && npm pack --dry-run ./dist/npm" }, "dependencies": { "@base-ui/react": "^1.5.0", From a842ff509f418eb14722db51394167fa1b33edd6 Mon Sep 17 00:00:00 2001 From: Ali HD <85040609+alihd-tech@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:19:11 +0330 Subject: [PATCH 02/10] Add standalone npm CLI packager --- scripts/build-npm-cli.mjs | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 scripts/build-npm-cli.mjs diff --git a/scripts/build-npm-cli.mjs b/scripts/build-npm-cli.mjs new file mode 100644 index 0000000..a88d70c --- /dev/null +++ b/scripts/build-npm-cli.mjs @@ -0,0 +1,67 @@ +import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises" +import { resolve } from "node:path" + +const root = process.cwd() +const out = resolve(root, "dist/npm") +const rootPackage = JSON.parse(await readFile(resolve(root, "package.json"), "utf8")) + +await rm(out, { recursive: true, force: true }) +await mkdir(resolve(out, "cli"), { recursive: true }) +await mkdir(resolve(out, "packages/core"), { recursive: true }) +await mkdir(resolve(out, "packages/github-client"), { recursive: true }) +await mkdir(resolve(out, "packages/report"), { recursive: true }) + +await cp(resolve(root, "cli/index.mjs"), resolve(out, "cli/index.mjs")) +await cp(resolve(root, "packages/core/index.mjs"), resolve(out, "packages/core/index.mjs")) +await cp(resolve(root, "packages/github-client/index.mjs"), resolve(out, "packages/github-client/index.mjs")) +await cp(resolve(root, "packages/report/index.mjs"), resolve(out, "packages/report/index.mjs")) +await cp(resolve(root, "LICENSE"), resolve(out, "LICENSE")) +await cp(resolve(root, "docs/npm-cli-readme.md"), resolve(out, "README.md")) + +const packageJson = { + name: "code-life-balance", + version: rootPackage.version, + description: "Privacy-first GitHub activity and code-life balance reports from your local machine.", + type: "module", + bin: { + "code-life-balance": "./cli/index.mjs" + }, + files: [ + "cli", + "packages/core", + "packages/github-client", + "packages/report", + "README.md", + "LICENSE" + ], + engines: { + node: ">=20" + }, + license: "MIT", + repository: { + type: "git", + url: "git+https://github.com/alihd-tech/CodeLifeBalance.git" + }, + homepage: "https://github.com/alihd-tech/CodeLifeBalance#readme", + bugs: { + url: "https://github.com/alihd-tech/CodeLifeBalance/issues" + }, + keywords: [ + "github", + "developer", + "activity", + "analytics", + "cli", + "privacy", + "productivity", + "code-life-balance" + ] +} + +await writeFile( + resolve(out, "package.json"), + JSON.stringify(packageJson, null, 2) + "\n", + "utf8" +) + +console.log(`Built npm CLI package at ${out}`) From c2ff738ca398a04543773dfe42bbd1a73d512238 Mon Sep 17 00:00:00 2001 From: Ali HD <85040609+alihd-tech@users.noreply.github.com> Date: Mon, 21 Sep 2026 23:19:13 +0330 Subject: [PATCH 03/10] Add npm CLI package documentation --- docs/npm-cli-readme.md | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 docs/npm-cli-readme.md diff --git a/docs/npm-cli-readme.md b/docs/npm-cli-readme.md new file mode 100644 index 0000000..7f33e6f --- /dev/null +++ b/docs/npm-cli-readme.md @@ -0,0 +1,62 @@ +# Code Life Balance CLI + +Run Code Life Balance locally without sending your GitHub credential or generated report to Code Life Balance infrastructure. + +## Run without installing + +```bash +npx code-life-balance --username octocat --timezone Europe/Helsinki +``` + +Or install globally: + +```bash +npm install --global code-life-balance +code-life-balance --username octocat +``` + +## Authentication + +The CLI resolves credentials in this order: + +1. `GITHUB_TOKEN`, when present. +2. Your existing `gh auth token` session. +3. No token for public-only username analysis. + +For private owned-repository analysis: + +```bash +gh auth login +code-life-balance --include-private --timezone Europe/Helsinki +``` + +Private mode verifies that the authenticated token owner matches the username being analyzed. + +## Options + +```text +--username GitHub username +--timezone IANA timezone, default UTC +--workday-start <0-23> Workday start hour, default 9 +--workday-end <1-24> Workday end hour, default 18 +--output-dir Output directory +--theme SVG theme +--card-style