Merge pull request #3281 from balena-io/104

Fix saving settings, update electron
This commit is contained in:
bulldozer-balena[bot] 2020-08-21 12:59:24 +00:00 committed by GitHub
commit ff08cb44f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 751 additions and 340 deletions

View File

@ -9,12 +9,6 @@ S3_BUCKET = artifacts.ci.balena-cloud.com
# This directory will be completely deleted by the `clean` rule
BUILD_DIRECTORY ?= dist
# See http://stackoverflow.com/a/20763842/1641422
BUILD_DIRECTORY_PARENT = $(dir $(BUILD_DIRECTORY))
ifeq ($(wildcard $(BUILD_DIRECTORY_PARENT).),)
$(error $(BUILD_DIRECTORY_PARENT) does not exist)
endif
BUILD_TEMPORARY_DIRECTORY = $(BUILD_DIRECTORY)/.tmp
$(BUILD_DIRECTORY):
@ -91,7 +85,7 @@ TARGET_ARCH ?= $(HOST_ARCH)
# ---------------------------------------------------------------------
# Electron
# ---------------------------------------------------------------------
electron-develop: | $(BUILD_TEMPORARY_DIRECTORY)
electron-develop:
$(RESIN_SCRIPTS)/electron/install.sh \
-b $(shell pwd) \
-r $(TARGET_ARCH) \

View File

@ -92,14 +92,17 @@ async function load(): Promise<void> {
const loaded = load();
export async function set(key: string, value: any): Promise<void> {
export async function set(
key: string,
value: any,
writeConfigFileFn = writeConfigFile,
): Promise<void> {
debug('set', key, value);
await loaded;
const previousValue = settings[key];
settings[key] = value;
try {
// Use exports.writeConfigFile() so it can be mocked in tests
await exports.writeConfigFile(CONFIG_PATH, settings);
await writeConfigFileFn(CONFIG_PATH, settings);
} catch (error) {
// Revert to previous value if persisting settings failed
settings[key] = previousValue;

View File

@ -26,7 +26,6 @@ import {
Theme as renditionTheme,
} from 'rendition';
import styled from 'styled-components';
import { space } from 'styled-system';
import { colors, theme } from './theme';
@ -86,7 +85,6 @@ export const ChangeButton = styled(Button)`
color: #8f9297;
}
}
${space}
}
`;

View File

@ -150,10 +150,6 @@ export const error = {
].join('');
},
elevationRequired: () => {
return 'This should should be run with root/administrator permissions.';
},
flashFailure: (
imageBasename: string,
drives: Array<{ description: string; displayName: string }>,

1033
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,6 @@
"@balena/lint": "^5.0.4",
"@fortawesome/fontawesome-free": "^5.13.1",
"@svgr/webpack": "^5.4.0",
"@types/bluebird": "^3.5.30",
"@types/chai": "^4.2.7",
"@types/copy-webpack-plugin": "^6.0.0",
"@types/mime-types": "^2.1.0",
@ -62,7 +61,6 @@
"@types/node": "^12.12.39",
"@types/node-ipc": "^9.1.2",
"@types/react-dom": "^16.8.4",
"@types/request": "^2.48.4",
"@types/semver": "^7.1.0",
"@types/sinon": "^9.0.0",
"@types/terser-webpack-plugin": "^4.1.0",
@ -73,13 +71,13 @@
"css-loader": "^4.2.1",
"d3": "^4.13.0",
"debug": "^4.2.0",
"electron": "9.2.0",
"electron": "9.2.1",
"electron-builder": "^22.7.0",
"electron-mocha": "^9.1.0",
"electron-notarize": "^1.0.0",
"electron-rebuild": "^1.11.0",
"electron-updater": "^4.3.2",
"etcher-sdk": "^4.1.23",
"etcher-sdk": "^4.1.24",
"file-loader": "^6.0.0",
"husky": "^4.2.5",
"immutable": "^3.8.1",
@ -87,7 +85,6 @@
"lodash": "^4.17.10",
"mini-css-extract-plugin": "^0.10.0",
"mocha": "^8.0.1",
"nan": "^2.14.0",
"native-addon-loader": "^2.0.1",
"node-ipc": "^9.1.1",
"omit-deep-lodash": "1.1.4",
@ -97,7 +94,7 @@
"react": "^16.8.5",
"react-dom": "^16.8.5",
"redux": "^4.0.5",
"rendition": "^17.0.0",
"rendition": "^18.1.0",
"resin-corvus": "^2.0.5",
"semver": "^7.3.2",
"simple-progress-webpack-plugin": "^1.1.2",
@ -105,7 +102,6 @@
"spectron": "^11.0.0",
"string-replace-loader": "^2.3.0",
"styled-components": "^5.1.0",
"styled-system": "^5.1.5",
"sudo-prompt": "^9.0.0",
"sys-class-rgb-led": "^2.1.0",
"tmp": "^0.2.1",

View File

@ -44,16 +44,15 @@ describe('Browser: settings', () => {
await settings.set('foo', 'bar');
expect(await settings.get('foo')).to.equal('bar');
const writeConfigFileStub = stub(settings, 'writeConfigFile');
const writeConfigFileStub = stub();
writeConfigFileStub.returns(Promise.reject(new Error('settings error')));
const p = settings.set('foo', 'baz');
const p = settings.set('foo', 'baz', writeConfigFileStub);
await checkError(p, async (error) => {
expect(error).to.be.an.instanceof(Error);
expect(error.message).to.equal('settings error');
expect(await settings.get('foo')).to.equal('bar');
});
writeConfigFileStub.restore();
});
});
@ -83,15 +82,17 @@ describe('Browser: settings', () => {
await settings.set('foo', 'bar');
expect(await settings.get('foo')).to.equal('bar');
const writeConfigFileStub = stub(settings, 'writeConfigFile');
const writeConfigFileStub = stub();
writeConfigFileStub.returns(Promise.reject(new Error('settings error')));
await checkError(settings.set('foo', 'baz'), async (error) => {
expect(error).to.be.an.instanceof(Error);
expect(error.message).to.equal('settings error');
expect(await settings.get('foo')).to.equal('bar');
});
writeConfigFileStub.restore();
await checkError(
settings.set('foo', 'baz', writeConfigFileStub),
async (error) => {
expect(error).to.be.an.instanceof(Error);
expect(error.message).to.equal('settings error');
expect(await settings.get('foo')).to.equal('bar');
},
);
});
});
});

View File

@ -129,6 +129,10 @@ const commonConfig = {
},
module: {
rules: [
{
test: /\.css$/,
use: 'css-loader',
},
{
test: /\.svg$/,
use: '@svgr/webpack',