Support Chrome profile selection across macOS, Linux, and Windows#81
Open
a-magdy wants to merge 10 commits into
Open
Support Chrome profile selection across macOS, Linux, and Windows#81a-magdy wants to merge 10 commits into
a-magdy wants to merge 10 commits into
Conversation
…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
There was a problem hiding this comment.
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-secureupgrade, 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lets users on multiple Chrome profiles point the CLI at the right one
instead of always reading from
Default.@eficode.comemail.CHROME_PROFILEto an account email(
first.last@eficode.com), a profile display name (Eficode), or aprofile directory name (
Default,Profile 2).and Windows. If the dir isn't found, falls back to
chrome-cookies-secure's built-in default — same behavior as before.Why
chrome-cookies-secureonly accepts a profile directory name and hasno 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
chrome-cookies-securefrom^1.3.2to^3.0.2(needed forthe
profileargument).npm start(tsc && node lib/cli.js) for local dev..env.exampleand ignores.env. Loading.envis optional(
node --env-file=.env lib/cli.js).engines.node: ">=16".test/cookies.test.ts(7 cases) with on-disk profile fixtures —no
fsmocking.mockedimports fromts-jest/utils(deprecated, removedin ts-jest v28) to
jest-mock.husky.shsourcing from.husky/pre-commitand
.husky/pre-push(warned by husky v8+, fails in v10).cli.tstotsconfig.jsonincludesolib/cli.jsisproduced for the
binentry.Test plan
CHROME_PROFILEset and an@eficode.comChrome profilesigned in,
npm startauthenticates successfully.CHROME_PROFILE=your.name@eficode.comresolves correctly.CHROME_PROFILE="Eficode"(display name) and"Profile 2"(directory name) both work.
@eficode.comprofile, falls back toDefault(regression check).npm test— all 35 tests pass.npm run buildproduceslib/cli.js.git committriggerslint-staged;git pushtriggerstypecheck+test.