From 7108c642f4ff6dc5f0c4d30b8a8960064ff8e90f Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 31 Dec 2021 01:52:28 +0100 Subject: test: Add tests for main package - Changed jest to run from the root package and reference the packages as projects. This required moving the base jest config file away from the project root. - Module isolation seems to prevent ts-jest from loading the shared package, so we disabled it for now. - To better facilitate mocking, services should be split into interfaces and implementation - Had to downgrade to chald 4.1.2 as per https://github.com/chalk/chalk/releases/tag/v5.0.0 at least until https://github.com/microsoft/TypeScript/issues/46452 is resolved. --- .gitignore | 1 + config/build-common.js | 47 ------ config/buildConstants.js | 40 +++++ config/esbuild-config.js | 42 ----- config/esbuildConfig.js | 42 +++++ config/jest.config.base.js | 26 +++ config/utils.js | 10 ++ jest.config.js | 25 +-- package.json | 6 +- packages/main/esbuild.config.js | 5 +- packages/main/jest.config.js | 3 + packages/main/package.json | 3 +- packages/main/src/compositionRoot.ts | 4 +- .../main/src/controllers/__tests__/config.spec.ts | 184 +++++++++++++++++++++ .../src/controllers/__tests__/nativeTheme.spec.ts | 71 ++++++++ packages/main/src/controllers/config.ts | 16 +- .../main/src/services/ConfigPersistenceService.ts | 106 +----------- .../services/impl/ConfigPersistenceServiceImpl.ts | 128 ++++++++++++++ packages/main/src/utils/index.ts | 2 +- packages/main/src/utils/logging.ts | 16 +- packages/main/tsconfig.json | 1 + packages/preload/esbuild.config.js | 5 +- packages/preload/jest.config.js | 2 +- packages/preload/package.json | 3 +- .../__tests__/SophieRendererImpl.spec.ts | 36 ++-- packages/preload/tsconfig.json | 3 + packages/renderer/package.json | 2 +- packages/renderer/vite.config.js | 3 +- packages/service-inject/esbuild.config.js | 5 +- packages/service-preload/esbuild.config.js | 5 +- packages/service-shared/esbuild.config.js | 5 +- packages/shared/esbuild.config.js | 5 +- scripts/build.js | 2 +- scripts/update-electron-vendors.js | 2 +- scripts/watch.js | 4 +- tsconfig.json | 4 +- yarn.lock | 36 ++-- 37 files changed, 607 insertions(+), 293 deletions(-) delete mode 100644 config/build-common.js create mode 100644 config/buildConstants.js delete mode 100644 config/esbuild-config.js create mode 100644 config/esbuildConfig.js create mode 100644 config/jest.config.base.js create mode 100644 config/utils.js create mode 100644 packages/main/jest.config.js create mode 100644 packages/main/src/controllers/__tests__/config.spec.ts create mode 100644 packages/main/src/controllers/__tests__/nativeTheme.spec.ts create mode 100644 packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts diff --git a/.gitignore b/.gitignore index 22394d6..3dfcfec 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ !.yarn/plugins !.yarn/releases !.yarn/versions +coverage/ dist/ node_modules/ *.tsbuildinfo diff --git a/config/build-common.js b/config/build-common.js deleted file mode 100644 index ff5a218..0000000 --- a/config/build-common.js +++ /dev/null @@ -1,47 +0,0 @@ -import { readFileSync } from 'fs'; -import { dirname, join } from 'path'; -import { fileURLToPath } from 'url'; - -const thisDir = fileURLToDirname(import.meta.url); - -// We import this from a vite config, where top-level await is not available (es2021), -// so we have to use the synchronous filesystem API. -const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8'); - -const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson); - -/** @type {string} */ -export const banner = `/*! - * Copyright (C) 2021-2022 Sophie contributors - * - * This file is part of Sophie. - * - * Sophie is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * SPDX-License-Identifier: AGPL-3.0-only - */ -`; - -/** @type {string} */ -export const chrome = `chrome${chromeVersion}`; - -/** @type {string} */ -export const node = `node${nodeVersion}`; - -/** - * @param {string} url - * @returns {string} - */ -export function fileURLToDirname(url) { - return dirname(fileURLToPath(url)); -} diff --git a/config/buildConstants.js b/config/buildConstants.js new file mode 100644 index 0000000..4952907 --- /dev/null +++ b/config/buildConstants.js @@ -0,0 +1,40 @@ +import { readFileSync } from 'fs'; +import { join } from 'path'; + +import { fileURLToDirname } from './utils.js'; + +const thisDir = fileURLToDirname(import.meta.url); + +// We import this from a vite config, where top-level await is not available (es2021), +// so we have to use the synchronous filesystem API. +const electronVendorsJson = readFileSync(join(thisDir, '../.electron-vendors.cache.json'), 'utf8'); + +const { chrome: chromeVersion, node: nodeVersion } = JSON.parse(electronVendorsJson); + +/** @type {string} */ +export const banner = `/*! + * Copyright (C) 2021-2022 Sophie contributors + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ +`; + +/** @type {string} */ +export const chrome = `chrome${chromeVersion}`; + +/** @type {string} */ +export const node = `node${nodeVersion}`; diff --git a/config/esbuild-config.js b/config/esbuild-config.js deleted file mode 100644 index 5cef85f..0000000 --- a/config/esbuild-config.js +++ /dev/null @@ -1,42 +0,0 @@ -import { banner } from './build-common.js'; - -/** @type {string} */ -const mode = process.env.MODE || 'development'; - -/** @type {boolean} */ -const isDevelopment = mode === 'development'; - -/** @type {string} */ -const modeString = JSON.stringify(mode); - -/** - * @param {import('esbuild').BuildOptions} config - * @param {Record} [extraMetaEnvVars] - * @returns {import('esbuild').BuildOptions} - */ -export function getConfig(config, extraMetaEnvVars) { - return { - logLevel: 'info', - bundle: true, - treeShaking: !isDevelopment, - minify: !isDevelopment, - banner: { - js: banner, - }, - ...config, - sourcemap: isDevelopment ? (config.sourcemap || true) : false, - define: { - 'process.env.NODE_ENV': modeString, - 'process.env.MODE': modeString, - 'import.meta.env': JSON.stringify({ - DEV: isDevelopment, - MODE: mode, - PROD: !isDevelopment, - ...extraMetaEnvVars, - }), - }, - plugins: [ - ...(config.plugins || []), - ], - }; -} diff --git a/config/esbuildConfig.js b/config/esbuildConfig.js new file mode 100644 index 0000000..05386b1 --- /dev/null +++ b/config/esbuildConfig.js @@ -0,0 +1,42 @@ +import { banner } from './buildConstants.js'; + +/** @type {string} */ +const mode = process.env.MODE || 'development'; + +/** @type {boolean} */ +const isDevelopment = mode === 'development'; + +/** @type {string} */ +const modeString = JSON.stringify(mode); + +/** + * @param {import('esbuild').BuildOptions} config + * @param {Record} [extraMetaEnvVars] + * @returns {import('esbuild').BuildOptions} + */ +export function getConfig(config, extraMetaEnvVars) { + return { + logLevel: 'info', + bundle: true, + treeShaking: !isDevelopment, + minify: !isDevelopment, + banner: { + js: banner, + }, + ...config, + sourcemap: isDevelopment ? (config.sourcemap || true) : false, + define: { + 'process.env.NODE_ENV': modeString, + 'process.env.MODE': modeString, + 'import.meta.env': JSON.stringify({ + DEV: isDevelopment, + MODE: mode, + PROD: !isDevelopment, + ...extraMetaEnvVars, + }), + }, + plugins: [ + ...(config.plugins || []), + ], + }; +} diff --git a/config/jest.config.base.js b/config/jest.config.base.js new file mode 100644 index 0000000..f265c1c --- /dev/null +++ b/config/jest.config.base.js @@ -0,0 +1,26 @@ +import { join } from 'path'; + +import { fileURLToDirname } from './utils.js'; + +const dirname = fileURLToDirname(import.meta.url); + +/** @type {import('ts-jest').InitialOptionsTsJest} */ +export default { + preset: 'ts-jest/presets/default-esm', + globals: { + 'ts-jest': { + useESM: true, + }, + }, + moduleNameMapper: { + '@sophie/(.+)': join(dirname, '../packages/$1/src/index.ts'), + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + resetMocks: true, + restoreMocks: true, + testEnvironment: 'node', + testPathIgnorePatterns: [ + '/dist/', + '/node_modules/', + ], +}; diff --git a/config/utils.js b/config/utils.js new file mode 100644 index 0000000..d3e13d9 --- /dev/null +++ b/config/utils.js @@ -0,0 +1,10 @@ +import { dirname } from 'path'; +import { fileURLToPath } from 'url'; + +/** + * @param {string} url + * @returns {string} + */ +export function fileURLToDirname(url) { + return dirname(fileURLToPath(url)); +} diff --git a/jest.config.js b/jest.config.js index 1aa0cbb..414e49f 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,27 +1,6 @@ -import { join } from 'path'; - -import { fileURLToDirname } from './config/build-common.js'; - -const dirname = fileURLToDirname(import.meta.url); - /** @type {import('ts-jest').InitialOptionsTsJest} */ export default { - preset: 'ts-jest/presets/default-esm', - globals: { - 'ts-jest': { - isolatedModules: true, - useESM: true, - }, - }, - moduleNameMapper: { - '@sophie/(.+)': join(dirname, 'packages/$1/src/index.ts'), - '^(\\.{1,2}/.*)\\.js$': '$1', - }, - resetMocks: true, - restoreMocks: true, - testEnvironment: 'node', - testPathIgnorePatterns: [ - '/dist/', - '/node_modules/', + projects: [ + '/packages/*', ], }; diff --git a/package.json b/package.json index 22748f7..ab2fc9f 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "main": "packages/main/dist/index.cjs", "scripts": { "clean": "rimraf dist packages/*/dist packages/*/tsconfig.tsbuildinfo .vite", - "test": "yarn workspaces foreach -vpt run test", + "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js", "build": "node scripts/build.js", "precompile": "cross-env MODE=production yarn run build", "compile": "yarn precompile && yarn compile:electron-builder", @@ -38,7 +38,7 @@ ], "devDependencies": { "@electron/fuses": "^1.5.0", - "@types/jest": "^27.0.3", + "@types/jest": "^27.4.0", "@vitejs/plugin-react": "^1.1.3", "chokidar": "^3.5.2", "cross-env": "^7.0.3", @@ -51,7 +51,7 @@ "rollup": "^2.62.0", "ts-jest": "^27.1.2", "typescript": "^4.5.4", - "vite": "^2.7.9" + "vite": "^2.7.10" }, "packageManager": "yarn@3.1.1", "dependencies": { diff --git a/packages/main/esbuild.config.js b/packages/main/esbuild.config.js index a39534d..af52f27 100644 --- a/packages/main/esbuild.config.js +++ b/packages/main/esbuild.config.js @@ -1,5 +1,6 @@ -import { node, fileURLToDirname } from '../../config/build-common.js'; -import { getConfig } from '../../config/esbuild-config.js'; +import { node } from '../../config/buildConstants.js'; +import { getConfig } from '../../config/esbuildConfig.js'; +import { fileURLToDirname } from '../../config/utils.js'; const externalPackages = ['electron']; diff --git a/packages/main/jest.config.js b/packages/main/jest.config.js new file mode 100644 index 0000000..b86463c --- /dev/null +++ b/packages/main/jest.config.js @@ -0,0 +1,3 @@ +import rootConfig from '../../config/jest.config.base.js'; + +export default rootConfig; diff --git a/packages/main/package.json b/packages/main/package.json index 99451bd..eb2ecf6 100644 --- a/packages/main/package.json +++ b/packages/main/package.json @@ -10,7 +10,7 @@ "dependencies": { "@sophie/service-shared": "workspace:*", "@sophie/shared": "workspace:*", - "chalk": "^5.0.0", + "chalk": "^4.1.2", "electron": "16.0.5", "json5": "^2.2.0", "lodash-es": "^4.17.21", @@ -27,6 +27,7 @@ "@types/node": "^17.0.5", "electron-devtools-installer": "^3.2.0", "esbuild": "^0.14.9", + "jest": "^27.4.5", "rimraf": "^3.0.2", "typescript": "^4.5.4" } diff --git a/packages/main/src/compositionRoot.ts b/packages/main/src/compositionRoot.ts index eb6f50f..d420bd6 100644 --- a/packages/main/src/compositionRoot.ts +++ b/packages/main/src/compositionRoot.ts @@ -22,12 +22,12 @@ import { app } from 'electron'; import { initConfig } from './controllers/config'; import { initNativeTheme } from './controllers/nativeTheme'; -import { ConfigPersistenceService } from './services/ConfigPersistenceService'; +import { ConfigPersistenceServiceImpl } from './services/impl/ConfigPersistenceServiceImpl'; import { MainStore } from './stores/MainStore'; import { Disposer } from './utils'; export async function init(store: MainStore): Promise { - const configPersistenceService = new ConfigPersistenceService(app.getPath('userData')); + const configPersistenceService = new ConfigPersistenceServiceImpl(app.getPath('userData')); const disposeConfigController = await initConfig(store.config, configPersistenceService); const disposeNativeThemeController = initNativeTheme(store); diff --git a/packages/main/src/controllers/__tests__/config.spec.ts b/packages/main/src/controllers/__tests__/config.spec.ts new file mode 100644 index 0000000..9471ca9 --- /dev/null +++ b/packages/main/src/controllers/__tests__/config.spec.ts @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2021-2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { jest } from '@jest/globals'; +import { mocked } from 'jest-mock'; +import ms from 'ms'; + +import { initConfig } from '../config'; +import type { ConfigPersistenceService } from '../../services/ConfigPersistenceService'; +import { Config, config as configModel } from '../../stores/Config'; +import { Disposer, silenceLogger } from '../../utils'; + +let config: Config; +let persistenceService: ConfigPersistenceService = { + readConfig: jest.fn(), + writeConfig: jest.fn(), + watchConfig: jest.fn(), +}; +let lessThanThrottleMs = ms('0.1s'); +let throttleMs = ms('1s'); + +beforeAll(() => { + jest.useFakeTimers(); + silenceLogger(); +}); + +beforeEach(() => { + config = configModel.create(); +}); + +describe('when initializing', () => { + describe('when there is no config file', () => { + beforeEach(() => { + mocked(persistenceService.readConfig).mockResolvedValueOnce({ + found: false, + }); + }); + + it('should create a new config file', async () => { + await initConfig(config, persistenceService); + expect(persistenceService.writeConfig).toBeCalledTimes(1); + }); + + it('should bail if there is an an error creating the config file', async () => { + mocked(persistenceService.writeConfig).mockRejectedValue(new Error('boo')); + await expect(() => initConfig(config, persistenceService)).rejects.toBeInstanceOf(Error); + }); + }); + + describe('when there is a valid config file', () => { + beforeEach(() => { + mocked(persistenceService.readConfig).mockResolvedValueOnce({ + found: true, + data: { + themeSource: 'dark', + }, + }); + }); + + it('should read the existing config file is there is one', async () => { + await initConfig(config, persistenceService); + expect(persistenceService.writeConfig).not.toBeCalled(); + expect(config.themeSource).toBe('dark'); + }); + + it('should bail if it cannot set up a watcher', async () => { + mocked(persistenceService.watchConfig).mockImplementationOnce(() => { + throw new Error('boo'); + }); + await expect(() => initConfig(config, persistenceService)).rejects.toBeInstanceOf(Error); + }); + }); + + it('should not apply an invalid config file', async () => { + mocked(persistenceService.readConfig).mockResolvedValueOnce({ + found: true, + data: { + themeSource: -1, + }, + }); + await initConfig(config, persistenceService); + expect(config.themeSource).not.toBe(-1); + }); + + it('should bail if it cannot determine whether there is a config file', async () => { + mocked(persistenceService.readConfig).mockRejectedValue(new Error('boo')); + await expect(() => initConfig(config, persistenceService)).rejects.toBeInstanceOf(Error); + }); +}); + +describe('when it has loaded the config', () => { + let sutDisposer: Disposer; + let watcherDisposer: Disposer = jest.fn(); + let configChangedCallback: () => Promise; + + beforeEach(async () => { + mocked(persistenceService.readConfig).mockResolvedValueOnce({ + found: true, + data: {}, + }); + mocked(persistenceService.watchConfig).mockReturnValueOnce(watcherDisposer); + sutDisposer = await initConfig(config, persistenceService, throttleMs); + configChangedCallback = mocked(persistenceService.watchConfig).mock.calls[0][0]; + jest.resetAllMocks(); + }); + + it('should throttle saving changes to the config file', () => { + mocked(persistenceService.writeConfig).mockResolvedValue(undefined); + config.setThemeSource('dark'); + jest.advanceTimersByTime(lessThanThrottleMs); + config.setThemeSource('light'); + jest.advanceTimersByTime(throttleMs); + expect(persistenceService.writeConfig).toBeCalledTimes(1); + }); + + it('should handle config writing errors gracefully', () => { + mocked(persistenceService.writeConfig).mockRejectedValue(new Error('boo')); + config.setThemeSource('dark'); + jest.advanceTimersByTime(throttleMs); + expect(persistenceService.writeConfig).toBeCalledTimes(1); + }); + + it('should read the config file when it has changed', async () => { + mocked(persistenceService.readConfig).mockResolvedValueOnce({ + found: true, + data: { + themeSource: 'dark', + }, + }); + await configChangedCallback(); + // Do not write back the changes we have just read. + expect(persistenceService.writeConfig).not.toBeCalled(); + expect(config.themeSource).toBe('dark'); + }); + + it('should not apply an invalid config file when it has changed', async () => { + mocked(persistenceService.readConfig).mockResolvedValueOnce({ + found: true, + data: { + themeSource: -1, + }, + }); + await configChangedCallback(); + expect(config.themeSource).not.toBe(-1); + }); + + it('should handle config writing errors gracefully', async () => { + mocked(persistenceService.readConfig).mockRejectedValue(new Error('boo')); + await configChangedCallback(); + }); + + describe('when it was disposed', () => { + beforeEach(() => { + sutDisposer(); + }); + + it('should dispose the watcher', () => { + expect(watcherDisposer).toBeCalled(); + }); + + it('should not listen to store changes any more', () => { + config.setThemeSource('dark'); + jest.advanceTimersByTime(2 * throttleMs); + expect(persistenceService.writeConfig).not.toBeCalled(); + }); + }); +}); diff --git a/packages/main/src/controllers/__tests__/nativeTheme.spec.ts b/packages/main/src/controllers/__tests__/nativeTheme.spec.ts new file mode 100644 index 0000000..cfb557c --- /dev/null +++ b/packages/main/src/controllers/__tests__/nativeTheme.spec.ts @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2021-2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { jest } from '@jest/globals'; +import { mocked } from 'jest-mock'; + +import { createMainStore, MainStore } from '../../stores/MainStore'; +import { Disposer } from '../../utils'; + +let shouldUseDarkColors = false; + +jest.unstable_mockModule('electron', () => ({ + nativeTheme: { + themeSource: 'system', + get shouldUseDarkColors() { + return shouldUseDarkColors; + }, + on: jest.fn(), + off: jest.fn(), + }, +})); + +const { nativeTheme } = await import('electron'); +const { initNativeTheme } = await import('../nativeTheme'); + +let store: MainStore; +let disposeSut: Disposer; + +beforeEach(() => { + store = createMainStore(); + disposeSut = initNativeTheme(store); +}); + +it('should register a nativeTheme updated listener', () => { + expect(nativeTheme.on).toBeCalledWith('updated', expect.anything()); +}); + +it('should synchronize themeSource changes to the nativeTheme', () => { + store.config.setThemeSource('dark'); + expect(nativeTheme.themeSource).toBe('dark'); +}); + +it('should synchronize shouldUseDarkColors changes to the store', () => { + const listener = mocked(nativeTheme.on).mock.calls.find(([event]) => event === 'updated')![1]; + shouldUseDarkColors = true; + listener(); + expect(store.shared.shouldUseDarkColors).toBe(true); +}); + +it('should remove the listener on dispose', () => { + const listener = mocked(nativeTheme.on).mock.calls.find(([event]) => event === 'updated')![1]; + disposeSut(); + expect(nativeTheme.off).toBeCalledWith('updated', listener); +}); diff --git a/packages/main/src/controllers/config.ts b/packages/main/src/controllers/config.ts index 600a142..d3559c8 100644 --- a/packages/main/src/controllers/config.ts +++ b/packages/main/src/controllers/config.ts @@ -60,12 +60,8 @@ export async function initConfig( if (!await readConfig()) { log.info('Config file was not found'); - try { - await writeConfig(); - log.info('Created config file'); - } catch (err) { - log.error('Failed to initialize config', err); - } + await writeConfig(); + log.info('Created config file'); } const disposeOnSnapshot = onSnapshot(config, debounce((snapshot) => { @@ -73,12 +69,16 @@ export async function initConfig( if (lastSnapshotOnDisk !== snapshot) { writeConfig().catch((err) => { log.error('Failed to write config on config change', err); - }) + }); } }, debounceTime)); const disposeWatcher = persistenceService.watchConfig(async () => { - await readConfig(); + try { + await readConfig(); + } catch (err) { + log.error('Failed to read config', err); + } }, debounceTime); return () => { diff --git a/packages/main/src/services/ConfigPersistenceService.ts b/packages/main/src/services/ConfigPersistenceService.ts index b2109f6..b3ad162 100644 --- a/packages/main/src/services/ConfigPersistenceService.ts +++ b/packages/main/src/services/ConfigPersistenceService.ts @@ -17,112 +17,16 @@ * * SPDX-License-Identifier: AGPL-3.0-only */ -import { watch } from 'fs'; -import { readFile, stat, writeFile } from 'fs/promises'; -import JSON5 from 'json5'; -import throttle from 'lodash-es/throttle'; -import { join } from 'path'; import type { ConfigSnapshotOut } from '../stores/Config'; -import { Disposer, getLogger } from '../utils'; - -const log = getLogger('configPersistence'); +import { Disposer } from '../utils'; export type ReadConfigResult = { found: true; data: unknown; } | { found: false; }; -export class ConfigPersistenceService { - private readonly configFilePath: string; - - private writingConfig = false; - - private timeLastWritten: Date | null = null; - - constructor( - private readonly userDataDir: string, - private readonly configFileName: string = 'config.json5', - ) { - this.configFileName = configFileName; - this.configFilePath = join(this.userDataDir, this.configFileName); - } - - async readConfig(): Promise { - let configStr; - try { - configStr = await readFile(this.configFilePath, 'utf8'); - } catch (err) { - if ((err as NodeJS.ErrnoException).code === 'ENOENT') { - log.debug('Config file', this.configFilePath, 'was not found'); - return { found: false }; - } - throw err; - } - log.info('Read config file', this.configFilePath); - return { - found: true, - data: JSON5.parse(configStr), - }; - } - - async writeConfig(configSnapshot: ConfigSnapshotOut): Promise { - const configJson = JSON5.stringify(configSnapshot, { - space: 2, - }); - this.writingConfig = true; - try { - await writeFile(this.configFilePath, configJson, 'utf8'); - const { mtime } = await stat(this.configFilePath); - log.trace('Config file', this.configFilePath, 'last written at', mtime); - this.timeLastWritten = mtime; - } finally { - this.writingConfig = false; - } - log.info('Wrote config file', this.configFilePath); - } - - watchConfig(callback: () => Promise, throttleMs: number): Disposer { - log.debug('Installing watcher for', this.userDataDir); - - const configChanged = throttle(async () => { - let mtime: Date; - try { - const stats = await stat(this.configFilePath); - mtime = stats.mtime; - log.trace('Config file last modified at', mtime); - } catch (err) { - if ((err as NodeJS.ErrnoException).code === 'ENOENT') { - log.debug('Config file', this.configFilePath, 'was deleted after being changed'); - return; - } - throw err; - } - if (!this.writingConfig - && (this.timeLastWritten === null || mtime > this.timeLastWritten)) { - log.debug( - 'Found a config file modified at', - mtime, - 'whish is newer than last written', - this.timeLastWritten, - ); - return callback(); - } - }, throttleMs); - - const watcher = watch(this.userDataDir, { - persistent: false, - }); +export interface ConfigPersistenceService { + readConfig(): Promise; - watcher.on('change', (eventType, filename) => { - if (eventType === 'change' - && (filename === this.configFileName || filename === null)) { - configChanged()?.catch((err) => { - console.log('Unhandled error while listening for config changes', err); - }); - } - }); + writeConfig(configSnapshot: ConfigSnapshotOut): Promise; - return () => { - log.trace('Removing watcher for', this.configFilePath); - watcher.close(); - }; - } + watchConfig(callback: () => Promise, throttleMs: number): Disposer; } diff --git a/packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts b/packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts new file mode 100644 index 0000000..bffc38c --- /dev/null +++ b/packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts @@ -0,0 +1,128 @@ + +/* + * Copyright (C) 2021-2022 Kristóf Marussy + * + * This file is part of Sophie. + * + * Sophie is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: AGPL-3.0-only + */ +import { watch } from 'fs'; +import { readFile, stat, writeFile } from 'fs/promises'; +import JSON5 from 'json5'; +import throttle from 'lodash-es/throttle'; +import { join } from 'path'; + +import type { ConfigPersistenceService, ReadConfigResult } from '../ConfigPersistenceService'; +import type { ConfigSnapshotOut } from '../../stores/Config'; +import { Disposer, getLogger } from '../../utils'; + +const log = getLogger('configPersistence'); + +export class ConfigPersistenceServiceImpl implements ConfigPersistenceService { + private readonly configFilePath: string; + + private writingConfig = false; + + private timeLastWritten: Date | null = null; + + constructor( + private readonly userDataDir: string, + private readonly configFileName: string = 'config.json5', + ) { + this.configFileName = configFileName; + this.configFilePath = join(this.userDataDir, this.configFileName); + } + + async readConfig(): Promise { + let configStr; + try { + configStr = await readFile(this.configFilePath, 'utf8'); + } catch (err) { + if ((err as NodeJS.ErrnoException).code === 'ENOENT') { + log.debug('Config file', this.configFilePath, 'was not found'); + return { found: false }; + } + throw err; + } + log.info('Read config file', this.configFilePath); + return { + found: true, + data: JSON5.parse(configStr), + }; + } + + async writeConfig(configSnapshot: ConfigSnapshotOut): Promise { + const configJson = JSON5.stringify(configSnapshot, { + space: 2, + }); + this.writingConfig = true; + try { + await writeFile(this.configFilePath, configJson, 'utf8'); + const { mtime } = await stat(this.configFilePath); + log.trace('Config file', this.configFilePath, 'last written at', mtime); + this.timeLastWritten = mtime; + } finally { + this.writingConfig = false; + } + log.info('Wrote config file', this.configFilePath); + } + + watchConfig(callback: () => Promise, throttleMs: number): Disposer { + log.debug('Installing watcher for', this.userDataDir); + + const configChanged = throttle(async () => { + let mtime: Date; + try { + const stats = await stat(this.configFilePath); + mtime = stats.mtime; + log.trace('Config file last modified at', mtime); + } catch (err) { + if ((err as NodeJS.ErrnoException).code === 'ENOENT') { + log.debug('Config file', this.configFilePath, 'was deleted after being changed'); + return; + } + throw err; + } + if (!this.writingConfig + && (this.timeLastWritten === null || mtime > this.timeLastWritten)) { + log.debug( + 'Found a config file modified at', + mtime, + 'whish is newer than last written', + this.timeLastWritten, + ); + return callback(); + } + }, throttleMs); + + const watcher = watch(this.userDataDir, { + persistent: false, + }); + + watcher.on('change', (eventType, filename) => { + if (eventType === 'change' + && (filename === this.configFileName || filename === null)) { + configChanged()?.catch((err) => { + console.log('Unhandled error while listening for config changes', err); + }); + } + }); + + return () => { + log.trace('Removing watcher for', this.configFilePath); + watcher.close(); + }; + } +} diff --git a/packages/main/src/utils/index.ts b/packages/main/src/utils/index.ts index 9a57e02..2b85989 100644 --- a/packages/main/src/utils/index.ts +++ b/packages/main/src/utils/index.ts @@ -22,4 +22,4 @@ import { IDisposer } from 'mobx-state-tree'; export type Disposer = IDisposer; -export { getLogger } from './logging'; +export { getLogger, silenceLogger } from './logging'; diff --git a/packages/main/src/utils/logging.ts b/packages/main/src/utils/logging.ts index 6c4cba2..ed40365 100644 --- a/packages/main/src/utils/logging.ts +++ b/packages/main/src/utils/logging.ts @@ -18,17 +18,17 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import chalk, { ChalkInstance } from 'chalk'; +import chalk, { Chalk } from 'chalk'; import loglevel, { Logger } from 'loglevel'; import prefix from 'loglevel-plugin-prefix'; -if (import.meta.env.DEV) { +if (import.meta.env?.DEV) { loglevel.setLevel('debug'); } else { loglevel.setLevel('info'); } -const COLORS: Partial> = { +const COLORS: Partial> = { TRACE: chalk.magenta, DEBUG: chalk.cyan, INFO: chalk.blue, @@ -37,7 +37,7 @@ const COLORS: Partial> = { CRITICAL: chalk.red, }; -function getColor(level: string): ChalkInstance { +function getColor(level: string): Chalk { return COLORS[level] ?? chalk.gray; } @@ -52,3 +52,11 @@ prefix.apply(loglevel, { export function getLogger(loggerName: string): Logger { return loglevel.getLogger(loggerName); } + +export function silenceLogger(): void { + loglevel.disableAll(); + const loggers = loglevel.getLoggers(); + for (const loggerName of Object.keys(loggers)) { + loggers[loggerName].disableAll(); + } +} diff --git a/packages/main/tsconfig.json b/packages/main/tsconfig.json index 10f5765..1401445 100644 --- a/packages/main/tsconfig.json +++ b/packages/main/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "noEmit": true, "types": [ + "@types/jest", "node" ] }, diff --git a/packages/preload/esbuild.config.js b/packages/preload/esbuild.config.js index de51fc5..b73a071 100644 --- a/packages/preload/esbuild.config.js +++ b/packages/preload/esbuild.config.js @@ -1,5 +1,6 @@ -import { chrome, fileURLToDirname } from '../../config/build-common.js'; -import { getConfig } from '../../config/esbuild-config.js'; +import { chrome } from '../../config/buildConstants.js'; +import { getConfig } from '../../config/esbuildConfig.js'; +import { fileURLToDirname } from '../../config/utils.js'; export default getConfig({ absWorkingDir: fileURLToDirname(import.meta.url), diff --git a/packages/preload/jest.config.js b/packages/preload/jest.config.js index faecf9a..e474c4c 100644 --- a/packages/preload/jest.config.js +++ b/packages/preload/jest.config.js @@ -1,4 +1,4 @@ -import rootConfig from '../../jest.config.js'; +import rootConfig from '../../config/jest.config.base.js'; /** @type {import('ts-jest').InitialOptionsTsJest} */ export default { diff --git a/packages/preload/package.json b/packages/preload/package.json index e6dd0ee..9818ba8 100644 --- a/packages/preload/package.json +++ b/packages/preload/package.json @@ -6,7 +6,6 @@ "type": "module", "types": "dist-types/index.d.ts", "scripts": { - "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "typecheck": "tsc" }, "dependencies": { @@ -16,7 +15,7 @@ "mobx-state-tree": "^5.1.0" }, "devDependencies": { - "@types/jest": "^27.0.3", + "@types/jest": "^27.4.0", "jest": "^27.4.5", "jest-mock": "^27.4.2", "jsdom": "^19.0.0", diff --git a/packages/preload/src/contextBridge/__tests__/SophieRendererImpl.spec.ts b/packages/preload/src/contextBridge/__tests__/SophieRendererImpl.spec.ts index 41937c2..fdd1cc5 100644 --- a/packages/preload/src/contextBridge/__tests__/SophieRendererImpl.spec.ts +++ b/packages/preload/src/contextBridge/__tests__/SophieRendererImpl.spec.ts @@ -18,7 +18,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { describe, it, jest } from '@jest/globals'; +import { jest } from '@jest/globals'; import { mocked } from 'jest-mock'; import log from 'loglevel'; import type { IJsonPatch } from 'mobx-state-tree'; @@ -67,7 +67,9 @@ const invalidAction = { action: 'not-a-valid-action', } as unknown as Action; -log.disableAll(); +beforeAll(() => { + log.disableAll(); +}); describe('createSophieRenderer', () => { it('registers a shared store patch listener', () => { @@ -95,59 +97,59 @@ describe('SophieRendererImpl', () => { }); describe('onSharedStoreChange', () => { - it('requests a snapshot from the main process', async () => { + it('should request a snapshot from the main process', async () => { mocked(ipcRenderer.invoke).mockResolvedValueOnce(snapshot); await sut.onSharedStoreChange(listener); expect(ipcRenderer.invoke).toBeCalledWith(RendererToMainIpcMessage.GetSharedStoreSnapshot); expect(listener.onSnapshot).toBeCalledWith(snapshot); }); - it('catches IPC errors without exposing them', async () => { + it('should catch IPC errors without exposing them', async () => { mocked(ipcRenderer.invoke).mockRejectedValue(new Error('s3cr3t')); await expect(sut.onSharedStoreChange(listener)).rejects.not.toHaveProperty( 'message', expect.stringMatching(/s3cr3t/), ); - expect(listener.onSnapshot).toBeCalledTimes(0); + expect(listener.onSnapshot).not.toBeCalled(); }); - it('does not pass on invalid snapshots', async () => { + it('should not pass on invalid snapshots', async () => { mocked(ipcRenderer.invoke).mockResolvedValueOnce(invalidSnapshot); await expect(sut.onSharedStoreChange(listener)).rejects.toBeInstanceOf(Error); - expect(listener.onSnapshot).toBeCalledTimes(0); + expect(listener.onSnapshot).not.toBeCalled(); }); }); describe('dispatchAction', () => { - it('dispatched valid actions', () => { + it('should dispatch valid actions', () => { sut.dispatchAction(action); expect(ipcRenderer.send).toBeCalledWith(RendererToMainIpcMessage.DispatchAction, action); }); - it('does not dispatch invalid actions', () => { + it('should not dispatch invalid actions', () => { expect(() => sut.dispatchAction(invalidAction)).toThrowError(); - expect(ipcRenderer.send).toBeCalledTimes(0); + expect(ipcRenderer.send).not.toBeCalled(); }); }); describe('when no listener is registered', () => { - it('discards the received patch without any error', () => { + it('should discard the received patch without any error', () => { onSharedStorePatch(event, patch); }); }); function itRefusesToRegisterAnotherListener() { - it('refuses to register another listener', async () => { + it('should refuse to register another listener', async () => { await expect(sut.onSharedStoreChange(listener)).rejects.toBeInstanceOf(Error); }); } function itDoesNotPassPatchesToTheListener( - name: string = 'does not pass patches to the listener', + name: string = 'should not pass patches to the listener', ) { it(name, () => { onSharedStorePatch(event, patch); - expect(listener.onPatch).toBeCalledTimes(0); + expect(listener.onPatch).not.toBeCalled(); }); } @@ -157,12 +159,12 @@ describe('SophieRendererImpl', () => { await sut.onSharedStoreChange(listener); }); - it('passes patches to the listener', () => { + it('should pass patches to the listener', () => { onSharedStorePatch(event, patch); expect(listener.onPatch).toBeCalledWith(patch); }); - it('catches listener errors', () => { + it('should catch listener errors', () => { mocked(listener.onPatch).mockImplementation(() => { throw new Error(); }); onSharedStorePatch(event, patch); }); @@ -176,7 +178,7 @@ describe('SophieRendererImpl', () => { listener.onPatch.mockRestore(); }); - itDoesNotPassPatchesToTheListener('does not pass on patches any more'); + itDoesNotPassPatchesToTheListener('should not pass on patches any more'); }); }); diff --git a/packages/preload/tsconfig.json b/packages/preload/tsconfig.json index 0f27305..741d435 100644 --- a/packages/preload/tsconfig.json +++ b/packages/preload/tsconfig.json @@ -6,6 +6,9 @@ "dom", "dom.iterable", "esnext" + ], + "types": [ + "@types/jest" ] }, "references": [ diff --git a/packages/renderer/package.json b/packages/renderer/package.json index 2a26b2b..0a9f4ef 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -30,6 +30,6 @@ "remotedev": "^0.2.9", "rimraf": "^3.0.2", "typescript": "^4.5.4", - "vite": "^2.7.9" + "vite": "^2.7.10" } } diff --git a/packages/renderer/vite.config.js b/packages/renderer/vite.config.js index 6f3d351..82ce33d 100644 --- a/packages/renderer/vite.config.js +++ b/packages/renderer/vite.config.js @@ -4,7 +4,8 @@ import { builtinModules } from 'module'; import { join } from 'path'; import react from '@vitejs/plugin-react'; -import { banner, chrome, fileURLToDirname } from '../../config/build-common.js'; +import { banner, chrome } from '../../config/buildConstants.js'; +import { fileURLToDirname } from '../../config/utils.js'; const thisDir = fileURLToDirname(import.meta.url); diff --git a/packages/service-inject/esbuild.config.js b/packages/service-inject/esbuild.config.js index 3f1d6d0..2169c8e 100644 --- a/packages/service-inject/esbuild.config.js +++ b/packages/service-inject/esbuild.config.js @@ -1,5 +1,6 @@ -import { chrome, fileURLToDirname } from '../../config/build-common.js'; -import { getConfig } from '../../config/esbuild-config.js'; +import { chrome } from '../../config/buildConstants.js'; +import { getConfig } from '../../config/esbuildConfig.js'; +import { fileURLToDirname } from '../../config/utils.js'; export default getConfig({ absWorkingDir: fileURLToDirname(import.meta.url), diff --git a/packages/service-preload/esbuild.config.js b/packages/service-preload/esbuild.config.js index 3c67b31..b73a071 100644 --- a/packages/service-preload/esbuild.config.js +++ b/packages/service-preload/esbuild.config.js @@ -1,5 +1,6 @@ -import { chrome, fileURLToDirname } from "../../config/build-common.js"; -import { getConfig } from '../../config/esbuild-config.js'; +import { chrome } from '../../config/buildConstants.js'; +import { getConfig } from '../../config/esbuildConfig.js'; +import { fileURLToDirname } from '../../config/utils.js'; export default getConfig({ absWorkingDir: fileURLToDirname(import.meta.url), diff --git a/packages/service-shared/esbuild.config.js b/packages/service-shared/esbuild.config.js index 8df2edf..071ca7d 100644 --- a/packages/service-shared/esbuild.config.js +++ b/packages/service-shared/esbuild.config.js @@ -1,5 +1,6 @@ -import { chrome, fileURLToDirname } from '../../config/build-common.js'; -import { getConfig } from '../../config/esbuild-config.js'; +import { chrome } from '../../config/buildConstants.js'; +import { getConfig } from '../../config/esbuildConfig.js'; +import { fileURLToDirname } from '../../config/utils.js'; export default getConfig({ absWorkingDir: fileURLToDirname(import.meta.url), diff --git a/packages/shared/esbuild.config.js b/packages/shared/esbuild.config.js index fbaa6f1..b134931 100644 --- a/packages/shared/esbuild.config.js +++ b/packages/shared/esbuild.config.js @@ -1,5 +1,6 @@ -import { chrome, fileURLToDirname } from '../../config/build-common.js'; -import { getConfig } from '../../config/esbuild-config.js'; +import { chrome } from '../../config/buildConstants.js'; +import { getConfig } from '../../config/esbuildConfig.js'; +import { fileURLToDirname } from '../../config/utils.js'; export default getConfig({ absWorkingDir: fileURLToDirname(import.meta.url), diff --git a/scripts/build.js b/scripts/build.js index 9b9b26e..ef2b998 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -2,7 +2,7 @@ import { build as esbuildBuild } from 'esbuild'; import { join } from 'path'; import { build as viteBuild } from 'vite'; -import { fileURLToDirname } from '../config/build-common.js'; +import { fileURLToDirname } from '../config/utils.js'; const thisDir = fileURLToDirname(import.meta.url); diff --git a/scripts/update-electron-vendors.js b/scripts/update-electron-vendors.js index fea8b9d..b2f4ca4 100644 --- a/scripts/update-electron-vendors.js +++ b/scripts/update-electron-vendors.js @@ -3,7 +3,7 @@ import electronPath from 'electron'; import { writeFile } from 'fs/promises'; import { join, resolve } from 'path'; -import { fileURLToDirname } from '../config/build-common.js'; +import { fileURLToDirname } from '../config/utils.js'; /** * Returns versions of electron vendors diff --git a/scripts/watch.js b/scripts/watch.js index 82a8feb..b635fac 100644 --- a/scripts/watch.js +++ b/scripts/watch.js @@ -5,7 +5,7 @@ import electronPath from 'electron'; import { join } from 'path'; import { createServer } from 'vite'; -import { fileURLToDirname } from '../config/build-common.js'; +import { fileURLToDirname } from '../config/utils.js'; /** @type {string} */ const thisDir = fileURLToDirname(import.meta.url); @@ -127,7 +127,7 @@ function setupMainPackageWatcher(viteDevServer) { const path = '/'; process.env.VITE_DEV_SERVER_URL = `${protocol}//${host}:${port}${path}`; - /** @type {import('child_process').ChildProcessWithoutNullStreams | null} */ + /** @type {import('child_process').ChildProcessByStdio | null} */ let spawnProcess = null; return setupEsbuildWatcher( diff --git a/tsconfig.json b/tsconfig.json index dfffc9d..255f334 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "module": "es2022", - "target": "es2021", + "module": "esnext", + "target": "esnext", "moduleResolution": "node", "esModuleInterop": true, "allowSyntheticDefaultImports": true, diff --git a/yarn.lock b/yarn.lock index 15e8ac9..12a41fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1203,10 +1203,11 @@ __metadata: "@types/lodash-es": ^4.17.5 "@types/ms": ^0.7.31 "@types/node": ^17.0.5 - chalk: ^5.0.0 + chalk: ^4.1.2 electron: 16.0.5 electron-devtools-installer: ^3.2.0 esbuild: ^0.14.9 + jest: ^27.4.5 json5: ^2.2.0 lodash-es: ^4.17.21 loglevel: ^1.8.0 @@ -1224,7 +1225,7 @@ __metadata: resolution: "@sophie/preload@workspace:packages/preload" dependencies: "@sophie/shared": "workspace:*" - "@types/jest": ^27.0.3 + "@types/jest": ^27.4.0 electron: 16.0.5 jest: ^27.4.5 jest-mock: ^27.4.2 @@ -1261,7 +1262,7 @@ __metadata: remotedev: ^0.2.9 rimraf: ^3.0.2 typescript: ^4.5.4 - vite: ^2.7.9 + vite: ^2.7.10 languageName: unknown linkType: soft @@ -1441,13 +1442,13 @@ __metadata: languageName: node linkType: hard -"@types/jest@npm:^27.0.3": - version: 27.0.3 - resolution: "@types/jest@npm:27.0.3" +"@types/jest@npm:^27.4.0": + version: 27.4.0 + resolution: "@types/jest@npm:27.4.0" dependencies: jest-diff: ^27.0.0 pretty-format: ^27.0.0 - checksum: 3683a9945821966f6dccddf337219a5d682633687c9d30df859223db553589f63e9b2c34e69f0cc845c86ffcf115742f25c12ea03c8d33d2244890fdc0af61e2 + checksum: d2350267f954f9a2e4a15e5f02fbf19a77abfb9fd9e57a954de1fb0e9a0d3d5f8d3646ac7d9c42aeb4b4d828d2e70624ec149c85bb50a48634a54eed8429e1f8 languageName: node linkType: hard @@ -2344,7 +2345,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.1": +"chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.1, chalk@npm:^4.1.2": version: 4.1.2 resolution: "chalk@npm:4.1.2" dependencies: @@ -2354,13 +2355,6 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^5.0.0": - version: 5.0.0 - resolution: "chalk@npm:5.0.0" - checksum: 6eba7c518b9aa5fe882ae6d14a1ffa58c418d72a3faa7f72af56641f1bbef51b645fca1d6e05d42357b7d3c846cd504c0b7b64d12309cdd07867e3b4411e0d01 - languageName: node - linkType: hard - "char-regex@npm:^1.0.2": version: 1.0.2 resolution: "char-regex@npm:1.0.2" @@ -7001,7 +6995,7 @@ __metadata: resolution: "sophie@workspace:." dependencies: "@electron/fuses": ^1.5.0 - "@types/jest": ^27.0.3 + "@types/jest": ^27.4.0 "@vitejs/plugin-react": ^1.1.3 chokidar: ^3.5.2 cross-env: ^7.0.3 @@ -7016,7 +7010,7 @@ __metadata: rollup: ^2.62.0 ts-jest: ^27.1.2 typescript: ^4.5.4 - vite: ^2.7.9 + vite: ^2.7.10 languageName: unknown linkType: soft @@ -7673,9 +7667,9 @@ __metadata: languageName: node linkType: hard -"vite@npm:^2.7.9": - version: 2.7.9 - resolution: "vite@npm:2.7.9" +"vite@npm:^2.7.10": + version: 2.7.10 + resolution: "vite@npm:2.7.10" dependencies: esbuild: ^0.13.12 fsevents: ~2.3.2 @@ -7698,7 +7692,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 6a13e0678fec4d5811d4e1bc796a98644856e4d7a56b5e56dbe513834c871d2313a065e4b82469de910568c0d6c762133517c6b7bccff4514f9acf5ed47f1f61 + checksum: 1757108547ca34bd01a8ee3973cb04b484492c9e5690fc75f54bbcbde5965ab6e0a5b8355c336adf0a9117aa0fdae3053af3aafa9e5eb783282fffa948cfbe11 languageName: node linkType: hard -- cgit v1.2.3-54-g00ecf