Skip to content

Support Chrome profile selection across macOS, Linux, and Windows#81

Open
a-magdy wants to merge 10 commits into
mainfrom
quick-patch
Open

Support Chrome profile selection across macOS, Linux, and Windows#81
a-magdy wants to merge 10 commits into
mainfrom
quick-patch

Conversation

@a-magdy
Copy link
Copy Markdown

@a-magdy a-magdy commented May 8, 2026

Summary

Lets users on multiple Chrome profiles point the CLI at the right one
instead of always reading from Default.

  • Auto-detect: picks the first Chrome profile signed in with an
    @eficode.com email.
  • Override: set CHROME_PROFILE to an account email
    (first.last@eficode.com), a profile display name (Eficode), or a
    profile directory name (Default, Profile 2).
  • Cross-platform: resolves the Chrome user-data dir on macOS, Linux,
    and Windows. If the dir isn't found, falls back to
    chrome-cookies-secure's built-in default — same behavior as before.
  • Lazy: profile resolution runs per-call, not at module import.

Why

chrome-cookies-secure only accepts a profile directory name and has
no auto-detection. Users with a personal + work Chrome setup either had
to manually look up their profile dir or couldn't authenticate at all.

Other changes in this branch

  • Bumps chrome-cookies-secure from ^1.3.2 to ^3.0.2 (needed for
    the profile argument).
  • Adds npm start (tsc && node lib/cli.js) for local dev.
  • Adds .env.example and ignores .env. Loading .env is optional
    (node --env-file=.env lib/cli.js).
  • Adds engines.node: ">=16".
  • Adds test/cookies.test.ts (7 cases) with on-disk profile fixtures —
    no fs mocking.
  • Migrates mocked imports from ts-jest/utils (deprecated, removed
    in ts-jest v28) to jest-mock.
  • Strips the deprecated husky.sh sourcing from .husky/pre-commit
    and .husky/pre-push (warned by husky v8+, fails in v10).
  • Restores cli.ts to tsconfig.json include so lib/cli.js is
    produced for the bin entry.

Test plan

  • With no CHROME_PROFILE set and an @eficode.com Chrome profile
    signed in, npm start authenticates successfully.
  • CHROME_PROFILE=your.name@eficode.com resolves correctly.
  • CHROME_PROFILE="Eficode" (display name) and "Profile 2"
    (directory name) both work.
  • On a machine with no @eficode.com profile, falls back to
    Default (regression check).
  • Verify on Linux or Windows if available.
  • npm test — all 35 tests pass.
  • npm run build produces lib/cli.js.
  • git commit triggers lint-staged; git push triggers
    typecheck + test.

a-magdy added 8 commits May 7, 2026 08:02
…tion

Allowing the user to select the chrome profile
Defaulting to a chrome profile logged in with an email ending with @eficode.com
  - Resolve Chrome profile lazily inside getCookiesFromBrowser; fall
    back to chrome-cookies-secure's own default when no match is found
  - Add getChromeUserDataDir() with macOS, Linux, and Windows paths so
    auto-detect and email/display-name lookup work on all three OSes
  - Drop --env-file=.env from npm start so the script works without
    a .env file; document .env as an optional way to set CHROME_PROFILE
  - Add unit tests for resolveProfile with on-disk profile fixtures
  - Migrate test imports from ts-jest/utils to jest-mock (deprecated
    in ts-jest v27, removed in v28)
  - Strip deprecated husky.sh sourcing from pre-commit and pre-push
    hooks (warned by husky v8+, fails in v10)
  - Restore cli.ts to tsconfig include so lib/cli.js is built
  - Pin engines.node to >=16
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds cross-platform Chrome profile selection to the CLI’s cookie-reading flow so users with multiple Chrome profiles can authenticate using the intended work profile (with optional override via CHROME_PROFILE).

Changes:

  • Added Chrome user-data directory discovery and per-call profile resolution (email / display name / directory name) when fetching cookies.
  • Updated dependencies and runtime/tooling (notably chrome-cookies-secure upgrade, Node engine floor, npm start).
  • Expanded documentation and tests, including on-disk Chrome profile fixtures and updated Jest mocking imports.

Reviewed changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/cookies.ts Adds Chrome user-data dir detection, profile resolution logic, and passes the resolved profile into cookie retrieval.
test/cookies.test.ts Introduces unit tests for profile resolution behavior using real fixture directories/files.
test/data/chrome-profiles/**/Preferences Adds minimal Preferences fixtures to support deterministic profile resolution tests.
test/auth.test.ts Migrates mocked import to jest-mock.
test/projects.test.ts Migrates mocked import to jest-mock.
test/worktimes.test.ts Migrates mocked import to jest-mock.
test/phases.test.ts Migrates mocked import to jest-mock and applies formatting cleanups in the touched block.
package.json Bumps chrome-cookies-secure, adds Node engine constraint and start script, adjusts lint-staged.
package-lock.json Locks updated dependency tree for chrome-cookies-secure@3.x and transitive updates.
README.md Documents Chrome profile auto-detect/override and optional .env loading.
.env.example Provides an example configuration for CHROME_PROFILE.
.gitignore Ignores local .env files.
.husky/pre-commit Updates pre-commit hook contents to run lint-staged without sourcing husky.sh.
.husky/pre-push Updates pre-push hook contents to run typecheck + tests without sourcing husky.sh.
tsconfig.json Adjusts TS output formatting and updates exclusion patterns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cookies.ts
Comment thread package.json Outdated
a-magdy and others added 2 commits May 8, 2026 10:27
Copilot finished work on behalf of a-magdy May 8, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants