mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-21 13:57:17 +00:00

- upgrade pretty_bytes to 6.1.1 - upgrade electron-remote to 2.1.0 - upgrade semver to 7.5.4 + @types/semver to 7.5.6 - upgrade chai to 4.3.11 + @types/chai to 4.3.10 - upgrade mocha to 10.2.0 + @types/mocha to 10.0.6 - upgrade sinon to 17.0.1 + @types/sinon to 17.0.2 - remove useless @types - upgrade @svgr/webpack to 8.1.0 - upgrade @sentry/electron to 4.15.1 - upgrade tslib to 2.6.2 - upgrade immutable to 4.3.4 - upgrade redux to 4.2.1 - upgrade ts-node to 10.9.2 & ts-loader to 9.5.1 - remove mini-css-extract-plugin - upgrade husky to 8.0.3 - upgrade uuid to 9.0.1 - upgrade lint-staged to 15.2.1 - upgrade @types/node to 18.11.9 - upgrade @fortawesome/fontawesome-free to 6.5.1 - upgrade i18next to 23.7.8 & react-i18next to 11.18.6 - bump react, react-dom + related @types to 17.0.2 and rendition to 35.1.0 - fix getuid for ts - fix @types/react being in wrong deps - upgrade @types/tmp to 0.2.6 - upgrade typescript to 5.3.3 - upgrade @types/mime-types to 2.1.4 - remove d3 from deps - upgrade electron-updater to 6.1.7 - upgrade rendition to 35.1.2 - upgrade node-ipc to 9.2.3 - upgrade @types/node-ipc to 9.2.3 - upgrade electron to 27.1.3 - upgrade @electron-forge/* to 7.2.0 - upgrade @reforged/marker-appimage to 3.3.2 - upgrade style-loader to 3.3.3 - upgrade balena-lint to 7.2.4 - run CI with node 18.19 - add xxhash-addon to sidecar assets Change-type: patch
194 lines
4.4 KiB
TypeScript
194 lines
4.4 KiB
TypeScript
/*
|
|
* Copyright 2016 balena.io
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import { Dictionary } from 'lodash';
|
|
import { outdent } from 'outdent';
|
|
import prettyBytes from 'pretty-bytes';
|
|
import '../gui/app/i18n';
|
|
import * as i18next from 'i18next';
|
|
|
|
export const progress: Dictionary<(quantity: number) => string> = {
|
|
successful: (quantity: number) => {
|
|
return i18next.t('message.flashSucceed', { count: quantity });
|
|
},
|
|
|
|
failed: (quantity: number) => {
|
|
return i18next.t('message.flashFail', { count: quantity });
|
|
},
|
|
};
|
|
|
|
export const info = {
|
|
flashComplete: (
|
|
imageBasename: string,
|
|
[drive]: [{ description: string; displayName: string }],
|
|
{ failed, successful }: { failed: number; successful: number },
|
|
) => {
|
|
const targets = [];
|
|
if (failed + successful === 1) {
|
|
targets.push(
|
|
i18next.t('message.toDrive', {
|
|
description: drive.description,
|
|
name: drive.displayName,
|
|
}),
|
|
);
|
|
} else {
|
|
if (successful) {
|
|
targets.push(
|
|
i18next.t('message.toTarget', {
|
|
count: successful,
|
|
num: successful,
|
|
}),
|
|
);
|
|
}
|
|
if (failed) {
|
|
targets.push(
|
|
i18next.t('message.andFailTarget', { count: failed, num: failed }),
|
|
);
|
|
}
|
|
}
|
|
return i18next.t('message.succeedTo', {
|
|
name: imageBasename,
|
|
target: targets.join(' '),
|
|
});
|
|
},
|
|
};
|
|
|
|
export const compatibility = {
|
|
sizeNotRecommended: () => {
|
|
return i18next.t('message.sizeNotRecommended');
|
|
},
|
|
|
|
tooSmall: () => {
|
|
return i18next.t('message.tooSmall');
|
|
},
|
|
|
|
locked: () => {
|
|
return i18next.t('message.locked');
|
|
},
|
|
|
|
system: () => {
|
|
return i18next.t('message.system');
|
|
},
|
|
|
|
containsImage: () => {
|
|
return i18next.t('message.containsImage');
|
|
},
|
|
|
|
// The drive is large and therefore likely not a medium you want to write to.
|
|
largeDrive: () => {
|
|
return i18next.t('message.largeDrive');
|
|
},
|
|
} as const;
|
|
|
|
export const warning = {
|
|
tooSmall: (source: { size: number }, target: { size: number }) => {
|
|
return outdent({ newline: ' ' })`
|
|
${i18next.t('message.sourceLarger', {
|
|
byte: prettyBytes(source.size - target.size),
|
|
})}
|
|
`;
|
|
},
|
|
|
|
exitWhileFlashing: () => {
|
|
return i18next.t('message.exitWhileFlashing');
|
|
},
|
|
|
|
looksLikeWindowsImage: () => {
|
|
return i18next.t('message.looksLikeWindowsImage');
|
|
},
|
|
|
|
missingPartitionTable: () => {
|
|
return i18next.t('message.missingPartitionTable', {
|
|
type: i18next.t('message.image'),
|
|
});
|
|
},
|
|
|
|
driveMissingPartitionTable: () => {
|
|
return i18next.t('message.missingPartitionTable', {
|
|
type: i18next.t('message.drive'),
|
|
});
|
|
},
|
|
|
|
largeDriveSize: () => {
|
|
return i18next.t('message.largeDriveSize');
|
|
},
|
|
|
|
systemDrive: () => {
|
|
return i18next.t('message.systemDrive');
|
|
},
|
|
|
|
sourceDrive: () => {
|
|
return i18next.t('message.sourceDrive');
|
|
},
|
|
};
|
|
|
|
export const error = {
|
|
notEnoughSpaceInDrive: () => {
|
|
return i18next.t('message.noSpace');
|
|
},
|
|
|
|
genericFlashError: (err: Error) => {
|
|
return i18next.t('message.genericFlashError', { error: err.message });
|
|
},
|
|
|
|
validation: () => {
|
|
return i18next.t('message.validation');
|
|
},
|
|
|
|
openSource: (sourceName: string, errorMessage: string) => {
|
|
return i18next.t('message.openError', {
|
|
source: sourceName,
|
|
error: errorMessage,
|
|
});
|
|
},
|
|
|
|
flashFailure: (
|
|
imageBasename: string,
|
|
drives: Array<{ description: string; displayName: string }>,
|
|
) => {
|
|
const target =
|
|
drives.length === 1
|
|
? i18next.t('message.toDrive', {
|
|
description: drives[0].description,
|
|
name: drives[0].displayName,
|
|
})
|
|
: i18next.t('message.toTarget', {
|
|
count: drives.length,
|
|
num: drives.length,
|
|
});
|
|
return i18next.t('message.flashError', {
|
|
image: imageBasename,
|
|
targets: target,
|
|
});
|
|
},
|
|
|
|
driveUnplugged: () => {
|
|
return i18next.t('message.unplug');
|
|
},
|
|
|
|
inputOutput: () => {
|
|
return i18next.t('message.cannotWrite');
|
|
},
|
|
|
|
childWriterDied: () => {
|
|
return i18next.t('message.childWriterDied');
|
|
},
|
|
|
|
unsupportedProtocol: () => {
|
|
return i18next.t('message.badProtocol');
|
|
},
|
|
};
|