gaunt-sloth-assistant
Version:
[](https://github.com/Galvanized-Pukeko/gaunt-sloth-assistant/actions/workflows/unit-tests.yml) [ {
return resolve(homedir(), GSLOTH_DIR);
}
/**
* Ensures the global .gsloth directory exists in the user's home directory
* Creates it if it doesn't exist
* @returns The resolved path to the global .gsloth directory
*/
export function ensureGlobalGslothDir() {
const globalDir = getGlobalGslothDir();
if (!existsSync(globalDir)) {
mkdirSync(globalDir, { recursive: true });
}
return globalDir;
}
/**
* Gets the global auth directory path
* @returns The resolved path to the global auth directory
*/
export function getGlobalAuthDir() {
const globalDir = getGlobalGslothDir();
return resolve(globalDir, GSLOTH_AUTH);
}
/**
* Ensures the global auth directory exists
* Creates it if it doesn't exist
* @returns The resolved path to the global auth directory
*/
export function ensureGlobalAuthDir() {
// First ensure parent directory exists
ensureGlobalGslothDir();
const authDir = getGlobalAuthDir();
if (!existsSync(authDir)) {
mkdirSync(authDir, { recursive: true });
}
return authDir;
}
/**
* Gets the path for a specific OAuth provider's storage file
* @param serverUrl The server URL or identifier for the OAuth provider
* @returns The resolved path where the OAuth data should be stored
*/
export function getOAuthStoragePath(serverUrl) {
const authDir = ensureGlobalAuthDir();
// Create a safe filename from the server URL
const safeFilename = serverUrl
.replace(/https?:\/\//, '')
.replace(/[^a-zA-Z0-9.-]/g, '_')
.replace(/_+/g, '_')
.toLowerCase();
return resolve(authDir, `${safeFilename}.json`);
}
//# sourceMappingURL=globalConfigUtils.js.map