Rename project from "Cheating Daddy" to "Mastermind" across all files, update version to 0.6.0, and implement migration functionality for users with existing configurations. Enhance onboarding experience with migration options and update relevant documentation.
Build and Release / build (x64, ubuntu-latest, linux) (push) Has been skipped
Build and Release / build (arm64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, windows-latest, win32) (push) Has been cancelled
Build and Release / release (push) Has been cancelled
Build and Release / build (x64, ubuntu-latest, linux) (push) Has been skipped
Build and Release / build (arm64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, macos-latest, darwin) (push) Has been cancelled
Build and Release / build (x64, windows-latest, win32) (push) Has been cancelled
Build and Release / release (push) Has been cancelled
This commit is contained in:
@@ -51,6 +51,22 @@ function getConfigDir() {
|
||||
const platform = os.platform();
|
||||
let configDir;
|
||||
|
||||
if (platform === 'win32') {
|
||||
configDir = path.join(os.homedir(), 'AppData', 'Roaming', 'mastermind-config');
|
||||
} else if (platform === 'darwin') {
|
||||
configDir = path.join(os.homedir(), 'Library', 'Application Support', 'mastermind-config');
|
||||
} else {
|
||||
configDir = path.join(os.homedir(), '.config', 'mastermind-config');
|
||||
}
|
||||
|
||||
return configDir;
|
||||
}
|
||||
|
||||
// Get the old config directory path for migration
|
||||
function getOldConfigDir() {
|
||||
const platform = os.platform();
|
||||
let configDir;
|
||||
|
||||
if (platform === 'win32') {
|
||||
configDir = path.join(os.homedir(), 'AppData', 'Roaming', 'cheating-daddy-config');
|
||||
} else if (platform === 'darwin') {
|
||||
@@ -62,6 +78,43 @@ function getConfigDir() {
|
||||
return configDir;
|
||||
}
|
||||
|
||||
// Check if old config directory exists
|
||||
function hasOldConfig() {
|
||||
const oldDir = getOldConfigDir();
|
||||
return fs.existsSync(oldDir);
|
||||
}
|
||||
|
||||
// Migrate config from old directory to new directory if needed
|
||||
function migrateFromOldConfig() {
|
||||
const oldDir = getOldConfigDir();
|
||||
const newDir = getConfigDir();
|
||||
|
||||
if (!fs.existsSync(oldDir)) {
|
||||
console.log('No old config found to migrate');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fs.existsSync(newDir)) {
|
||||
// NOTE: Does not matter if the new config directory already exists, we will overwrite it with the old config
|
||||
fs.rmSync(newDir, { recursive: true, force: true });
|
||||
console.log('New config directory already exists, overwriting with old config');
|
||||
}
|
||||
|
||||
console.log(`Migrating config from ${oldDir} to ${newDir}...`);
|
||||
try {
|
||||
const parentDir = path.dirname(newDir);
|
||||
if (!fs.existsSync(parentDir)) {
|
||||
fs.mkdirSync(parentDir, { recursive: true });
|
||||
}
|
||||
fs.renameSync(oldDir, newDir);
|
||||
console.log('Migration successful');
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('Migration failed:', error.message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// File paths
|
||||
function getConfigPath() {
|
||||
return path.join(getConfigDir(), 'config.json');
|
||||
@@ -469,6 +522,10 @@ module.exports = {
|
||||
initializeStorage,
|
||||
getConfigDir,
|
||||
|
||||
// Migration
|
||||
hasOldConfig,
|
||||
migrateFromOldConfig,
|
||||
|
||||
// Config
|
||||
getConfig,
|
||||
setConfig,
|
||||
|
||||
Reference in New Issue
Block a user