Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "1.1.0",
"name": "switchbot-controller",
"version": "1.2.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The version has been bumped to 1.2.0, but the package-lock.json file has not been updated accordingly. It still reflects version 1.1.0. This can lead to inconsistencies in installed dependencies and is a common source of bugs. Please run npm install to update the lock file to match the new version in package.json.

"description": "",
"type": "commonjs",
"main": "dist_electron/src/main/main.js",
Expand Down
9 changes: 5 additions & 4 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ const schema = {
},
};

// Migrate config from old app ("SwitchBot Client") to new app ("SwitchBot Controller").
// Electron uses productName for the userData directory, so the old config lives in a
// sibling directory, not in the current one.
// Migrate config from v1.1.0 ("app/switchbot-client-config.json") to v1.2.0.
// In v1.1.0 package.json name was "app", so userData was "%APPDATA%/app/".
// Now name is "switchbot-controller", so userData is "%APPDATA%/switchbot-controller/".
const newUserDataPath = app.getPath("userData");
const oldUserDataPath = path.join(path.dirname(newUserDataPath), "SwitchBot Client");
const oldUserDataPath = path.join(path.dirname(newUserDataPath), "app");
const oldConfigPath = path.join(oldUserDataPath, "switchbot-client-config.json");
const newConfigPath = path.join(newUserDataPath, "switchbot-controller-config.json");
if (fs.existsSync(oldConfigPath) && !fs.existsSync(newConfigPath)) {
try {
fs.mkdirSync(newUserDataPath, { recursive: true });
fs.copyFileSync(oldConfigPath, newConfigPath);
console.log("[Main] Migrated config from", oldConfigPath, "to", newConfigPath);
} catch (error) {
Expand Down
Loading