Skip to content

feat: support XDG Base Directory Specification for config location#208

Merged
pchuri merged 2 commits into
pchuri:mainfrom
iliadmitriev:feat/xdg-config-path
Jun 26, 2026
Merged

feat: support XDG Base Directory Specification for config location#208
pchuri merged 2 commits into
pchuri:mainfrom
iliadmitriev:feat/xdg-config-path

Conversation

@iliadmitriev

Copy link
Copy Markdown
Contributor

Summary

Replaces the hardcoded ~/.confluence-cli/ config path with XDG-aware resolution.

Resolution precedence

  1. CONFLUENCE_CONFIG_DIR env var — explicit override
  2. ~/.confluence-cli/ — if it already exists and XDG doesn't (backwards compat)
  3. $XDG_CONFIG_HOME/confluence-cli/ — defaults to ~/.config/confluence-cli/

New installs go to ~/.config/confluence-cli/. Existing users at ~/.confluence-cli/ are unaffected — the CLI continues using the legacy location until migrated.

Changes

File Change
lib/config.js Added resolveConfigDir(), getConfigDir(), getConfigFile() with memoized resolution. Exported new functions + _resetConfigDirCache().
lib/analytics.js Uses getConfigDir() instead of its own hardcoded path
tests/config.test.js +9 tests: resolution precedence, env overrides, cache reset, exports
tests/analytics.test.js Updated expected paths + clean XDG env vars
tests/with-client.test.js Added getConfigDir/getConfigFile to config mock
README.md New Config file location section + updated stale references

Testing

All 761 tests pass (752 original + 9 new). Manual testing confirmed: CONFLUENCE_CONFIG_DIR override, legacy fallback, XDG_CONFIG_HOME support, and new-install XDG default all work correctly.

Resolves config directory using XDG Base Directory spec:
1. CONFLUENCE_CONFIG_DIR env var (explicit override)
2. ~/.confluence-cli/ if it already exists (backwards compat)
3. $XDG_CONFIG_HOME/confluence-cli/ (defaults to ~/.config/confluence-cli/)

New installs go to XDG path. Existing users at legacy path are
unaffected. Exports getConfigDir(), getConfigFile(), and
_resetConfigDirCache() for downstream consumers and testing.

Updated analytics module to use getConfigDir() instead of its
own hardcoded path, so stats.json follows config resolution.

@pchuri pchuri left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the well-crafted contribution! The XDG resolution logic is clean, the backwards-compatibility fallback is handled correctly, and the test coverage covers all the branching paths. Approving.

@pchuri

pchuri commented Jun 26, 2026

Copy link
Copy Markdown
Owner

The CI is failing due to an ESLint no-unused-vars error in tests/config.test.jsfs is imported on line 1 but never used directly in the test file (the mocked version is accessed via jest.doMock). Removing that import should fix all three Node version failures.

@iliadmitriev

Copy link
Copy Markdown
Contributor Author

Thanks a million, fixed an issue.

@iliadmitriev iliadmitriev requested a review from pchuri June 26, 2026 03:32
@pchuri pchuri merged commit b8d63fd into pchuri:main Jun 26, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Jun 26, 2026
# [2.15.0](v2.14.1...v2.15.0) (2026-06-26)

### Features

* support XDG Base Directory Specification for config location ([#208](#208)) ([b8d63fd](b8d63fd))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.15.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@iliadmitriev iliadmitriev deleted the feat/xdg-config-path branch June 26, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants