mirror of
https://github.com/kopia/kopia.git
synced 2026-05-12 08:46:09 -04:00
* build(deps): bump the kopia-ui-npm-dependencies group across 1 directory with 9 updates Bumps the kopia-ui-npm-dependencies group with 7 updates in the /app directory: | Package | From | To | | --- | --- | --- | | [electron-log](https://github.com/megahertz/electron-log) | `5.1.2` | `5.1.5` | | [electron-store](https://github.com/sindresorhus/electron-store) | `8.2.0` | `10.0.0` | | [electron-updater](https://github.com/electron-userland/electron-builder/tree/HEAD/packages/electron-updater) | `6.3.0-alpha.6` | `6.3.0-alpha.7` | | [uuid](https://github.com/uuidjs/uuid) | `9.0.1` | `10.0.0` | | [@electron/notarize](https://github.com/electron/notarize) | `2.3.0` | `2.3.2` | | [@playwright/test](https://github.com/microsoft/playwright) | `1.42.1` | `1.45.1` | | [electron](https://github.com/electron/electron) | `29.1.6` | `31.2.0` | Updates `electron-log` from 5.1.2 to 5.1.5 - [Changelog](https://github.com/megahertz/electron-log/blob/master/CHANGELOG.md) - [Commits](https://github.com/megahertz/electron-log/compare/v5.1.2...v5.1.5) Updates `electron-store` from 8.2.0 to 10.0.0 - [Release notes](https://github.com/sindresorhus/electron-store/releases) - [Commits](https://github.com/sindresorhus/electron-store/compare/v8.2.0...v10.0.0) Updates `electron-updater` from 6.3.0-alpha.6 to 6.3.0-alpha.7 - [Release notes](https://github.com/electron-userland/electron-builder/releases) - [Changelog](https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/CHANGELOG.md) - [Commits](https://github.com/electron-userland/electron-builder/commits/electron-updater@6.3.0-alpha.7/packages/electron-updater) Updates `uuid` from 9.0.1 to 10.0.0 - [Changelog](https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md) - [Commits](https://github.com/uuidjs/uuid/compare/v9.0.1...v10.0.0) Updates `@electron/notarize` from 2.3.0 to 2.3.2 - [Release notes](https://github.com/electron/notarize/releases) - [Changelog](https://github.com/electron/notarize/blob/main/.releaserc.json) - [Commits](https://github.com/electron/notarize/compare/v2.3.0...v2.3.2) Updates `@playwright/test` from 1.42.1 to 1.45.1 - [Release notes](https://github.com/microsoft/playwright/releases) - [Commits](https://github.com/microsoft/playwright/compare/v1.42.1...v1.45.1) Updates `electron` from 29.1.6 to 31.2.0 - [Release notes](https://github.com/electron/electron/releases) - [Changelog](https://github.com/electron/electron/blob/main/docs/breaking-changes.md) - [Commits](https://github.com/electron/electron/compare/v29.1.6...v31.2.0) Updates `playwright` from 1.42.1 to 1.45.1 - [Release notes](https://github.com/microsoft/playwright/releases) - [Commits](https://github.com/microsoft/playwright/compare/v1.42.1...v1.45.1) Updates `playwright-core` from 1.42.1 to 1.45.1 - [Release notes](https://github.com/microsoft/playwright/releases) - [Commits](https://github.com/microsoft/playwright/compare/v1.42.1...v1.45.1) --- updated-dependencies: - dependency-name: electron-log dependency-type: direct:production update-type: version-update:semver-patch dependency-group: kopia-ui-npm-dependencies - dependency-name: electron-store dependency-type: direct:production update-type: version-update:semver-major dependency-group: kopia-ui-npm-dependencies - dependency-name: electron-updater dependency-type: direct:production update-type: version-update:semver-patch dependency-group: kopia-ui-npm-dependencies - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-major dependency-group: kopia-ui-npm-dependencies - dependency-name: "@electron/notarize" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: kopia-ui-npm-dependencies - dependency-name: "@playwright/test" dependency-type: direct:development update-type: version-update:semver-minor dependency-group: kopia-ui-npm-dependencies - dependency-name: electron dependency-type: direct:development update-type: version-update:semver-major dependency-group: kopia-ui-npm-dependencies - dependency-name: playwright dependency-type: direct:development update-type: version-update:semver-minor dependency-group: kopia-ui-npm-dependencies - dependency-name: playwright-core dependency-type: direct:development update-type: version-update:semver-minor dependency-group: kopia-ui-npm-dependencies ... Signed-off-by: dependabot[bot] <support@github.com> * upgraded app to ES modules * renamed notarize.js and sign.js to CommonJS --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jarek Kowalski <jaak@jkowalski.net>
150 lines
3.6 KiB
JavaScript
150 lines
3.6 KiB
JavaScript
const fs = await import('fs');
|
|
const path = await import('path');
|
|
const Electron = await import('electron');
|
|
const log = await import("electron-log");
|
|
|
|
let configs = {};
|
|
const configFileSuffix = ".config";
|
|
|
|
let myConfigDir = "";
|
|
let isPortable = false;
|
|
let firstRun = false;
|
|
|
|
// returns the list of directories to be checked for portable configurations
|
|
function portableConfigDirs() {
|
|
let result = [];
|
|
|
|
if (process.env.KOPIA_UI_PORTABLE_CONFIG_DIR) {
|
|
result.push(process.env.KOPIA_UI_PORTABLE_CONFIG_DIR);
|
|
}
|
|
|
|
if (process.platform == "darwin") {
|
|
// on Mac support 'repositories' directory next to the KopiaUI.app
|
|
result.push(path.join(path.dirname(Electron.app.getPath("exe")), "..", "..", "..", "repositories"));
|
|
} else {
|
|
// on other platforms support 'repositories' directory next to directory
|
|
// containing executable or 'repositories' subdirectory.
|
|
result.push(path.join(path.dirname(Electron.app.getPath("exe")), "repositories"));
|
|
result.push(path.join(path.dirname(Electron.app.getPath("exe")), "..", "repositories"));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
function globalConfigDir() {
|
|
if (!myConfigDir) {
|
|
// try portable config dirs in order.
|
|
portableConfigDirs().forEach(d => {
|
|
if (myConfigDir) {
|
|
return;
|
|
}
|
|
|
|
d = path.normalize(d)
|
|
|
|
if (!fs.existsSync(d)) {
|
|
return;
|
|
}
|
|
|
|
myConfigDir = d;
|
|
isPortable = true;
|
|
});
|
|
|
|
// still not set, fall back to per-user config dir.
|
|
// we use the same directory that is used by Kopia CLI.
|
|
if (!myConfigDir) {
|
|
myConfigDir = path.join(Electron.app.getPath("appData"), "kopia");
|
|
}
|
|
}
|
|
|
|
return myConfigDir;
|
|
}
|
|
|
|
export function allConfigs() {
|
|
let result = [];
|
|
|
|
for (let k in configs) {
|
|
result.push(k);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
export function addNewConfig() {
|
|
let id;
|
|
|
|
if (!configs) {
|
|
// first repository is always named "repository" to match Kopia CLI.
|
|
id = "repository";
|
|
} else {
|
|
id = "repository-" + new Date().valueOf();
|
|
}
|
|
|
|
configs[id] = true;
|
|
return id;
|
|
}
|
|
|
|
Electron.ipcMain.on('config-list-fetch', (event, arg) => {
|
|
emitConfigListUpdated();
|
|
});
|
|
|
|
function emitConfigListUpdated() {
|
|
Electron.ipcMain.emit('config-list-updated-event', allConfigs());
|
|
};
|
|
|
|
export function deleteConfigIfDisconnected(repoID) {
|
|
if (repoID === "repository") {
|
|
// never delete default repository config
|
|
return false;
|
|
}
|
|
|
|
if (!fs.existsSync(path.join(globalConfigDir(), repoID + configFileSuffix))) {
|
|
delete (configs[repoID]);
|
|
emitConfigListUpdated();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
export function loadConfigs() {
|
|
fs.mkdirSync(globalConfigDir(), { recursive: true, mode: 0o700 });
|
|
let entries = fs.readdirSync(globalConfigDir());
|
|
|
|
let count = 0;
|
|
entries.filter(e => path.extname(e) == configFileSuffix).forEach(v => {
|
|
const repoID = v.replace(configFileSuffix, "");
|
|
configs[repoID] = true;
|
|
count++;
|
|
});
|
|
|
|
if (!configs["repository"]) {
|
|
configs["repository"] = true;
|
|
firstRun = true;
|
|
}
|
|
};
|
|
|
|
|
|
export function isPortableConfig() {
|
|
globalConfigDir();
|
|
return isPortable;
|
|
};
|
|
|
|
export function isFirstRun() {
|
|
return firstRun;
|
|
}
|
|
|
|
export function configDir() {
|
|
return globalConfigDir();
|
|
}
|
|
|
|
export function configForRepo(repoID) {
|
|
let c = configs[repoID];
|
|
if (c) {
|
|
return c;
|
|
}
|
|
|
|
configs[repoID] = true;
|
|
emitConfigListUpdated();
|
|
return c;
|
|
}
|