2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2017 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-06-18 17:04:27 +00:00
|
|
|
import { join } from 'path';
|
2021-12-09 08:06:04 +00:00
|
|
|
import { mkdirSync } from 'fs';
|
2021-06-18 17:04:27 +00:00
|
|
|
import { app } from 'electron';
|
Beta versions support: SxS support, in-app env/instance display (#1606)
* Script for beta config; unique data dir, in-app env/type display
To release a beta build, increment the version and add -beta-N to the
end, then go through all the standard release activities.
The prepare-build npm script then updates key bits of the package.json
to ensure that the beta build can be installed alongside a production
build. This includes a new name ('Signal Beta') and a different location
for application data.
Note: Beta builds can be installed alongside production builds.
As part of this, a couple new bits of data are shown across the app:
- Environment (development or test, not shown if production)
- App Instance (disabled in production; used for multiple accounts)
These are shown in:
- The window title - both environment and app instance. You can tell
beta builds because the app name, preceding these data bits, is
different.
- The about window - both environment and app instance. You can tell
beta builds from the version number.
- The header added to the debug log - just environment. The version
number will tell us if it's a beta build, and app instance isn't
helpful.
* Turn on single-window mode in non-production modes
Because it's really frightening when you see 'unable to read from db'
errors in the console.
* aply.sh: More instructions for initial setup and testing
* Gruntfile: Get consistent with use of package.json datas
* Linux: manually update desktop keys, since macros not available
2017-10-30 20:57:13 +00:00
|
|
|
|
2021-06-18 17:04:27 +00:00
|
|
|
import { start } from './base_config';
|
|
|
|
import config from './config';
|
2022-11-22 18:43:43 +00:00
|
|
|
import * as Errors from '../ts/types/errors';
|
2017-06-22 01:04:19 +00:00
|
|
|
|
2021-12-09 08:06:04 +00:00
|
|
|
let userData: string | undefined;
|
2021-08-11 19:29:07 +00:00
|
|
|
// Use separate data directory for benchmarks & development
|
|
|
|
if (config.has('storagePath')) {
|
2021-12-09 08:06:04 +00:00
|
|
|
userData = String(config.get('storagePath'));
|
2021-08-11 19:29:07 +00:00
|
|
|
} else if (config.has('storageProfile')) {
|
2021-12-09 08:06:04 +00:00
|
|
|
userData = join(
|
2017-06-22 01:04:19 +00:00
|
|
|
app.getPath('appData'),
|
2018-01-08 21:19:25 +00:00
|
|
|
`Signal-${config.get('storageProfile')}`
|
2017-06-22 01:04:19 +00:00
|
|
|
);
|
2021-12-09 08:06:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (userData !== undefined) {
|
|
|
|
try {
|
|
|
|
mkdirSync(userData, { recursive: true });
|
|
|
|
} catch (error) {
|
2022-11-22 18:43:43 +00:00
|
|
|
console.error('Failed to create userData', Errors.toLogFormat(error));
|
2021-12-09 08:06:04 +00:00
|
|
|
}
|
2017-06-22 01:04:19 +00:00
|
|
|
|
|
|
|
app.setPath('userData', userData);
|
|
|
|
}
|
|
|
|
|
2018-01-08 21:19:25 +00:00
|
|
|
console.log(`userData: ${app.getPath('userData')}`);
|
2017-06-22 01:04:19 +00:00
|
|
|
|
2018-08-28 21:53:05 +00:00
|
|
|
const userDataPath = app.getPath('userData');
|
2021-06-18 17:04:27 +00:00
|
|
|
const targetPath = join(userDataPath, 'config.json');
|
2018-08-28 21:53:05 +00:00
|
|
|
|
2022-01-11 19:12:55 +00:00
|
|
|
export const userConfig = start({
|
|
|
|
name: 'user',
|
|
|
|
targetPath,
|
|
|
|
throwOnFilesystemErrors: true,
|
|
|
|
});
|
2017-06-22 01:04:19 +00:00
|
|
|
|
2021-06-18 17:04:27 +00:00
|
|
|
export const get = userConfig.get.bind(userConfig);
|
|
|
|
export const remove = userConfig.remove.bind(userConfig);
|
|
|
|
export const set = userConfig.set.bind(userConfig);
|