@glpkg/config
A CLI tool for managing GitLab configuration - securely save and load tokens from your user config directory.
Installation
# From npm Registry
npm install -g @glpkg/config
# Or use directly with npx
npx @glpkg/config [command]
Features
- Secure token storage with restricted permissions (0600)
- Cross-platform support (Linux, macOS, Windows)
- Simple CLI interface
- Programmatic API for other tools
Usage
gitlab-config [command] [options]
Commands
save - Store GitLab Token
Save your GitLab personal access token:
gitlab-config save YOUR_TOKEN
The token is stored in ~/.config/gitlab-config/token with restricted permissions (0600).
get - Display Stored Token
View the stored token:
gitlab-config get
check - Check Token Status
Check if a token is configured:
gitlab-config check
remove - Remove Token
Remove the stored token:
gitlab-config remove
Programmatic Usage
You can also use @glpkg/config as a library:
import { saveToken, getToken, hasToken, removeToken } from '@glpkg/config';
// Save a token
saveToken('glpat-xxxxxxxxxxxx');
// Check if token exists
if (hasToken()) {
// Get the token
const token = getToken();
console.log(token);
}
// Remove the token
removeToken();
API Reference
saveToken(token: string): void
Stores the GitLab token securely.
getToken(): string | null
Returns the stored token, or null if not configured.
hasToken(): boolean
Returns true if a token is stored.
removeToken(): void
Removes the stored token.
Token Precedence
When glpkg tools look for a token, they check in this order:
- Command-line option (
--token) - User config (via @glpkg/config) ← Recommended
- Environment variable (
GITLAB_AUTH_TOKEN)
Security Notes
- Tokens are stored with restricted file permissions (0600)
- The config directory is
~/.config/gitlab-config/ - Never commit tokens to version control
- Use environment variables in CI/CD pipelines
Integration with Other Tools
@glpkg/config is used by:
- @glpkg/installer - For reading stored tokens
- @glpkg/publisher - For reading stored tokens
When you configure a token with gitlab-config save, both installer and publisher use it automatically.