Skip to content

Commit

Permalink
Add version key to config
Browse files Browse the repository at this point in the history
  • Loading branch information
whatuserever committed Feb 15, 2025
1 parent 101a1db commit 304e55e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/main/src/backend/commonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type {
Spreadsheet,
} from './export/outputVendors/googleSheets/googleSheetsInternalAPI';
export interface Config {
version: number;
outputVendors: {
[OutputVendorName.GOOGLE_SHEETS]?: GoogleSheetsConfig;
[OutputVendorName.YNAB]?: YnabConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from 'zod';
import { type Config } from '../../commonTypes';
import { isOriginalConfig } from './versions/original';
import { v1ConfigSchema } from './versions/v1';
import { migrateOriginalToV1, v1ConfigSchema } from './versions/v1';

const latestConfigSchema = v1ConfigSchema;

Expand All @@ -13,7 +13,7 @@ export function migrateConfig(config: unknown): Config {
let currentConfig = config;
// original config does not have version key and must be handled separately
if (isOriginalConfig(config)) {
return config as Config;
currentConfig = migrateOriginalToV1(config);
}
let currentVersion = getConfigVersion(currentConfig);

Expand Down
1 change: 1 addition & 0 deletions packages/main/src/backend/configManager/defaultConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type Config } from '../commonTypes';

const DEFAULT_CONFIG: Config = {
version: 1,
scraping: {
numDaysBack: 40,
showBrowser: false,
Expand Down
1 change: 1 addition & 0 deletions packages/preload/src/commonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum OutputVendorName {
}

export interface Config {
version: number;
outputVendors: {
[OutputVendorName.GOOGLE_SHEETS]?: GoogleSheetsConfig;
[OutputVendorName.YNAB]?: YnabConfig;
Expand Down
1 change: 1 addition & 0 deletions packages/renderer/src/store/Store.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describe('Store', () => {
});

export const dummyConfig: Config = {
version: 1,
scraping: {
numDaysBack: 40,
showBrowser: false,
Expand Down
1 change: 1 addition & 0 deletions packages/renderer/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum OutputVendorName {
}

export interface Config {
version: number;
outputVendors: {
[OutputVendorName.GOOGLE_SHEETS]?: GoogleSheetsConfig;
[OutputVendorName.YNAB]?: YnabConfig;
Expand Down

0 comments on commit 304e55e

Please sign in to comment.