patch: update husky configuration

This commit is contained in:
Edwin Joassart 2023-10-19 14:34:16 +02:00
parent d952d5129e
commit 4ee8055b20
4 changed files with 36 additions and 30 deletions

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run lint-staged

View File

@ -14,18 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
import GithubSvg from "@fortawesome/fontawesome-free/svgs/brands/github.svg"; import GithubSvg from '@fortawesome/fontawesome-free/svgs/brands/github.svg';
import * as _ from "lodash"; import * as _ from 'lodash';
import * as React from "react"; import * as React from 'react';
import { Box, Checkbox, Flex, Txt } from "rendition"; import { Box, Checkbox, Flex, Txt } from 'rendition';
import { version, packageType } from "../../../../../package.json"; import { version, packageType } from '../../../../../package.json';
import * as settings from "../../models/settings"; import * as settings from '../../models/settings';
import * as analytics from "../../modules/analytics"; import * as analytics from '../../modules/analytics';
import { open as openExternal } from "../../os/open-external/services/open-external"; import { open as openExternal } from '../../os/open-external/services/open-external';
import { Modal } from "../../styled-components"; import { Modal } from '../../styled-components';
import * as i18next from "i18next"; import * as i18next from 'i18next';
import { etcherProInfo } from "../../utils/etcher-pro-specific"; import { etcherProInfo } from '../../utils/etcher-pro-specific';
interface Setting { interface Setting {
name: string; name: string;
@ -35,18 +35,18 @@ interface Setting {
async function getSettingsList(): Promise<Setting[]> { async function getSettingsList(): Promise<Setting[]> {
const list: Setting[] = [ const list: Setting[] = [
{ {
name: "errorReporting", name: 'errorReporting',
label: i18next.t("settings.errorReporting"), label: i18next.t('settings.errorReporting'),
}, },
{ {
name: "autoBlockmapping", name: 'autoBlockmapping',
label: i18next.t("settings.trimExtPartitions"), label: i18next.t('settings.trimExtPartitions'),
}, },
]; ];
if (["appimage", "nsis", "dmg"].includes(packageType)) { if (['appimage', 'nsis', 'dmg'].includes(packageType)) {
list.push({ list.push({
name: "updatesEnabled", name: 'updatesEnabled',
label: i18next.t("settings.autoUpdate"), label: i18next.t('settings.autoUpdate'),
}); });
} }
return list; return list;
@ -62,7 +62,7 @@ const InfoBox = (props: any) => (
<Box fontSize={14}> <Box fontSize={14}>
<Txt>{props.label}</Txt> <Txt>{props.label}</Txt>
<Txt code copy={props.value}> <Txt code copy={props.value}>
{props.value}{" "} {props.value}{' '}
</Txt> </Txt>
</Box> </Box>
); );
@ -89,7 +89,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
const toggleSetting = async (setting: string) => { const toggleSetting = async (setting: string) => {
const value = currentSettings[setting]; const value = currentSettings[setting];
analytics.logEvent("Toggle setting", { setting, value }); analytics.logEvent('Toggle setting', { setting, value });
await settings.set(setting, !value); await settings.set(setting, !value);
setCurrentSettings({ setCurrentSettings({
...currentSettings, ...currentSettings,
@ -101,7 +101,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
<Modal <Modal
titleElement={ titleElement={
<Txt fontSize={24} mb={24}> <Txt fontSize={24} mb={24}>
{i18next.t("settings.settings")} {i18next.t('settings.settings')}
</Txt> </Txt>
} }
done={() => toggleModal(false)} done={() => toggleModal(false)}
@ -122,7 +122,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
})} })}
{EPInfo !== undefined && ( {EPInfo !== undefined && (
<Flex flexDirection="column"> <Flex flexDirection="column">
<Txt fontSize={24}>{i18next.t("settings.systemInformation")}</Txt> <Txt fontSize={24}>{i18next.t('settings.systemInformation')}</Txt>
{EPInfo.get_serial() === undefined ? ( {EPInfo.get_serial() === undefined ? (
<InfoBox label="UUID" value={EPInfo.uuid} /> <InfoBox label="UUID" value={EPInfo.uuid} />
) : ( ) : (
@ -135,13 +135,13 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
alignItems="center" alignItems="center"
color="#00aeef" color="#00aeef"
style={{ style={{
width: "fit-content", width: 'fit-content',
cursor: "pointer", cursor: 'pointer',
fontSize: 14, fontSize: 14,
}} }}
onClick={() => onClick={() =>
openExternal( openExternal(
"https://github.com/balena-io/etcher/blob/master/CHANGELOG.md" 'https://github.com/balena-io/etcher/blob/master/CHANGELOG.md',
) )
} }
> >
@ -150,7 +150,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) {
fill="currentColor" fill="currentColor"
style={{ marginRight: 8 }} style={{ marginRight: 8 }}
/> />
<Txt style={{ borderBottom: "1px solid #00aeef" }}>{version}</Txt> <Txt style={{ borderBottom: '1px solid #00aeef' }}>{version}</Txt>
</Flex> </Flex>
</Flex> </Flex>
</Modal> </Modal>

2
npm-shrinkwrap.json generated
View File

@ -44,7 +44,7 @@
"esbuild-loader": "4.0.2", "esbuild-loader": "4.0.2",
"etcher-sdk": "8.7.2", "etcher-sdk": "8.7.2",
"file-loader": "6.2.0", "file-loader": "6.2.0",
"husky": "8.0.3", "husky": "^8.0.3",
"i18next": "23.6.0", "i18next": "23.6.0",
"immutable": "4.3.4", "immutable": "4.3.4",
"lint-staged": "15.0.1", "lint-staged": "15.0.1",

View File

@ -23,6 +23,7 @@
"lint-css": "prettier --write lib/**/*.css", "lint-css": "prettier --write lib/**/*.css",
"lint-ts": "balena-lint --fix --typescript typings lib tests scripts/clean-shrinkwrap.ts webpack.config.ts", "lint-ts": "balena-lint --fix --typescript typings lib tests scripts/clean-shrinkwrap.ts webpack.config.ts",
"lint": "npm run lint-ts && npm run lint-css", "lint": "npm run lint-ts && npm run lint-css",
"lint-staged": "lint-staged",
"sanity-checks": "bash scripts/ci/ensure-all-file-extensions-in-gitattributes.sh", "sanity-checks": "bash scripts/ci/ensure-all-file-extensions-in-gitattributes.sh",
"start": "./node_modules/.bin/electron .", "start": "./node_modules/.bin/electron .",
"test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts", "test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts",
@ -32,11 +33,12 @@
"test-windows": "npm run lint && npm run test-gui && npm run test-shared && npm run sanity-checks", "test-windows": "npm run lint && npm run test-gui && npm run test-shared && npm run sanity-checks",
"test": "echo npm run test-{linux,windows,macos}", "test": "echo npm run test-{linux,windows,macos}",
"watch": "webpack serve --no-optimization-minimize --config ./webpack.dev.config.ts", "watch": "webpack serve --no-optimization-minimize --config ./webpack.dev.config.ts",
"webpack": "webpack" "webpack": "webpack",
"prepare": "husky install"
}, },
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "lint-staged" "pre-commit": "npm run lint-staged"
} }
}, },
"lint-staged": { "lint-staged": {
@ -85,7 +87,7 @@
"esbuild-loader": "4.0.2", "esbuild-loader": "4.0.2",
"etcher-sdk": "8.7.2", "etcher-sdk": "8.7.2",
"file-loader": "6.2.0", "file-loader": "6.2.0",
"husky": "8.0.3", "husky": "^8.0.3",
"i18next": "23.6.0", "i18next": "23.6.0",
"immutable": "4.3.4", "immutable": "4.3.4",
"lint-staged": "15.0.1", "lint-staged": "15.0.1",