Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into setLogo
Browse files Browse the repository at this point in the history
  • Loading branch information
baruchiro committed Dec 15, 2024
2 parents a525d58 + 2e6b993 commit ea77923
Show file tree
Hide file tree
Showing 75 changed files with 684 additions and 1,327 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
strategy:
fail-fast: true
matrix:
os:
os:
- macos-13
- macos-latest
- ubuntu-latest
- windows-latest
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ jobs:
strategy:
fail-fast: true
matrix:
os:
os:
- macos-13
- macos-latest
- ubuntu-latest
- windows-latest
Expand All @@ -84,7 +85,7 @@ jobs:
with:
cache: 'yarn'
node-version-file: '.node-version'

- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@d33c176a9b784876d966f80fb1b461808edc0641
# Only install Snapcraft on Ubuntu
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Close stale issues and PRs'
on:
workflow_dispatch:
schedule:
- cron: '30 1 * * *'

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
ascending: true
days-before-close: 14
stale-issue-message: 'Issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
stale-pr-message: 'Pull request has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
close-issue-reason: 'not_planned'
exempt-issue-labels: 'not-stale'
exempt-pr-labels: 'not-stale'
12 changes: 3 additions & 9 deletions .nano-staged.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@ export default {
* @param {string[]} filenames
* @return {string[]}
*/
'{package-lock.json,packages/**/{*.ts,*.tsx,tsconfig.json}}': ({
filenames,
}) => {
'{package-lock.json,packages/**/{*.ts,*.tsx,tsconfig.json}}': ({ filenames }) => {
// if dependencies was changed run type checking for all packages
if (filenames.some((f) => f.endsWith('package-lock.json'))) {
return ['yarn typecheck'];
}

// else run type checking for staged packages
const fileNameToPackageName = (filename) =>
filename
.replace(resolve(process.cwd(), 'packages') + sep, '')
.split(sep)[0];
return [...new Set(filenames.map(fileNameToPackageName))].map(
(p) => `yarn typecheck:${p}`,
);
filename.replace(resolve(process.cwd(), 'packages') + sep, '').split(sep)[0];
return [...new Set(filenames.map(fileNameToPackageName))].map((p) => `yarn typecheck:${p}`);
},
};
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"singleQuote": true
"singleQuote": true,
"printWidth": 120
}
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ In some cases you may get gibberish when you open the CSV file in Excel. In this
1. Select your CSV file.
1. For the "Encoding"/"File Origin", select `Unicode UTF-8 (65001)`.

### How to Report a Problem

כדי לדווח על בעיה, אפשר להשתמש בכפתור ״דיווח על בעיה״. אם נדמה לכם שהכפתור לא עובד, או שנדרשים לעזרה ספציפית, אפשר להיעזר בתיבת הדיווח כדי לראות את הלוגים האחרונים, וגם כדי לראות את מיקום קובץ הלוג שאותו אפשר לבדוק או לשלוח בנפרד.

דרך נוספת היא לפתוח את ״כלי הפיתוח״ ולצלם לנו מסך של ההודעות שכתובות שם ([ולשלוח בדיסקורד](https://discord.gg/XWWg7xvJyS)).

<details>
<summary>איך לפתוח את כלי הפיתוח</summary>


![alt text](./docs/toggle-developer-tools.png)

![alt text](./docs/dev-tools-console.png)
</details>

## Release

<details>
Expand Down
Binary file added docs/dev-tools-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/toggle-developer-tools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ directories:
output: dist
buildResources: buildResources

artifactName: '${productName}.${ext}'

files:
- packages/**/dist/**

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"electron-builder": "24.13.3",
"eslint": "8.57.0",
"eslint-config-prettier": "^9.1.0",
"happy-dom": "14.12.0",
"happy-dom": "15.10.2",
"jsdom": "^24.1.1",
"nano-staged": "0.8.0",
"playwright": "1.44.1",
Expand Down Expand Up @@ -82,7 +82,7 @@
"eslint-plugin-react-hooks": "^4.6.2",
"events": "^3.3.0",
"googleapis": "^139.0.0",
"israeli-bank-scrapers-core": "5.2.0",
"israeli-bank-scrapers-core": "5.2.2",
"keytar": "^7.9.0",
"lodash": "^4.17.21",
"mobx": "^6.12.4",
Expand All @@ -99,5 +99,9 @@
"svelte": "^4.2.19",
"web-vitals": "^4.2.3",
"ynab": "^1.19.0"
},
"resolutions": {
"underscore": "1.12.1",
"ws": "8.17.1"
}
}
16 changes: 4 additions & 12 deletions packages/main/src/backend/commonTypes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
type CompanyTypes,
type ScraperCredentials,
} from 'israeli-bank-scrapers-core';
import { type CompanyTypes, type ScraperCredentials } from 'israeli-bank-scrapers-core';
import { type Transaction } from 'israeli-bank-scrapers-core/lib/transactions';
import { type Account, type BudgetSummary } from 'ynab';
import { type EventPublisher } from './eventEmitters/EventEmitter';
Expand All @@ -27,6 +24,7 @@ export interface Config {
chromiumPath?: string;
maxConcurrency?: number;
timeout: number;
periodicScrapingIntervalHours?: number;
};
useReactUI?: boolean;
}
Expand All @@ -38,14 +36,8 @@ export enum OutputVendorName {
CSV = 'csv',
}

export type OutputVendorConfigs = Exclude<
Config['outputVendors'][OutputVendorName],
undefined
>;
export type OutputVendorConfig<T extends OutputVendorName> = Exclude<
Config['outputVendors'][T],
undefined
>;
export type OutputVendorConfigs = Exclude<Config['outputVendors'][OutputVendorName], undefined>;
export type OutputVendorConfig<T extends OutputVendorName> = Exclude<Config['outputVendors'][T], undefined>;

interface OutputVendorConfigBase {
active: boolean;
Expand Down
9 changes: 2 additions & 7 deletions packages/main/src/backend/configManager/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { existsSync, promises as fs } from 'fs';
import configExample from './defaultConfig';
import logger from '/@/logging/logger';

export async function getConfig(
configPath: string = configFilePath,
): Promise<Config> {
export async function getConfig(configPath: string = configFilePath): Promise<Config> {
const configFromFile = await getConfigFromFile(configPath);
if (configFromFile) {
const decrypted = (await decrypt(configFromFile)) as string;
Expand All @@ -31,10 +29,7 @@ export async function getConfig(
return configExample;
}

export async function updateConfig(
configPath: string,
configToUpdate: Config,
): Promise<void> {
export async function updateConfig(configPath: string, configToUpdate: Config): Promise<void> {
const stringifiedConfig = JSON.stringify(configToUpdate, null, 2);
const encryptedConfigStr = await encrypt(stringifiedConfig);
await fs.writeFile(configPath, encryptedConfigStr);
Expand Down
3 changes: 1 addition & 2 deletions packages/main/src/backend/configManager/encryption/salt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ export default async function SALT(defaultValue?: string): Promise<string> {
const existedSALT = await loadSALT();
if (existedSALT) return existedSALT;

if (!defaultValue)
throw Error('SALT not existed and no default value provided');
if (!defaultValue) throw Error('SALT not existed and no default value provided');

await saveSALT(defaultValue);
return defaultValue;
Expand Down
29 changes: 13 additions & 16 deletions packages/main/src/backend/eventEmitters/EventEmitter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// eslint-disable-next-line max-classes-per-file
import {
type EnrichedTransaction,
type OutputVendorName,
} from '@/backend/commonTypes';
import Emittery from 'emittery';
import { type CompanyTypes } from 'israeli-bank-scrapers-core';
import type { EnrichedTransaction, OutputVendorName } from '../commonTypes';

export enum EventNames {
IMPORT_PROCESS_START = 'IMPORT_PROCESS_START',
Expand Down Expand Up @@ -93,13 +90,7 @@ export interface ExporterEventParams {
export class ExporterEvent extends BudgetTrackingEvent {
allTransactions: EnrichedTransaction[];

constructor({
message,
allTransactions,
status,
error,
exporterName,
}: ExporterEventParams) {
constructor({ message, allTransactions, status, error, exporterName }: ExporterEventParams) {
super({
message,
accountType: AccountType.EXPORTER,
Expand All @@ -124,6 +115,15 @@ export class ExporterEndEvent extends ExporterEvent {
}
}

export class ImportStartEvent extends BudgetTrackingEvent {
nextAutomaticScrapeDate?: Date | null;

constructor(message: string, nextAutomaticScrapeDate?: Date | null) {
super({ message });
this.nextAutomaticScrapeDate = nextAutomaticScrapeDate;
}
}

export class DownalodChromeEvent extends BudgetTrackingEvent {
percent: number;

Expand All @@ -134,7 +134,7 @@ export class DownalodChromeEvent extends BudgetTrackingEvent {
}

export interface EventDataMap {
[EventNames.IMPORT_PROCESS_START]: BudgetTrackingEvent;
[EventNames.IMPORT_PROCESS_START]: ImportStartEvent;
[EventNames.DOWNLOAD_CHROME]: DownalodChromeEvent;
[EventNames.IMPORTER_START]: ImporterEvent;
[EventNames.IMPORTER_PROGRESS]: ImporterEvent;
Expand All @@ -155,7 +155,4 @@ export class BudgetTrackingEventEmitter extends Emittery<EventDataMap> {}

export type EventPublisher = Pick<BudgetTrackingEventEmitter, 'emit'>;

export type EventSubscriber = Pick<
BudgetTrackingEventEmitter,
'on' | 'once' | 'off' | 'onAny' | 'anyEvent' | 'offAny'
>;
export type EventSubscriber = Pick<BudgetTrackingEventEmitter, 'on' | 'once' | 'off' | 'onAny' | 'anyEvent' | 'offAny'>;
5 changes: 1 addition & 4 deletions packages/main/src/backend/eventEmitters/loggerEmitter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
BudgetTrackingEventEmitter,
type EventPublisher,
} from '@/backend/eventEmitters/EventEmitter';
import { BudgetTrackingEventEmitter, type EventPublisher } from '@/backend/eventEmitters/EventEmitter';

interface Logger {
info: (...params: unknown[]) => void;
Expand Down
16 changes: 4 additions & 12 deletions packages/main/src/backend/export/exportTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import outputVendors from '@/backend/export/outputVendors';
import _ from 'lodash';
import logger from '/@/logging/logger';

type ExecutionResult = Partial<
Record<OutputVendorName, ExportTransactionsResult>
>;
type ExecutionResult = Partial<Record<OutputVendorName, ExportTransactionsResult>>;

export async function createTransactionsInExternalVendors(
outputVendorsConfig: Config['outputVendors'],
Expand All @@ -38,10 +36,7 @@ export async function createTransactionsInExternalVendors(
};

await outputVendor.init?.(outputVendorsConfig);
await eventPublisher.emit(
EventNames.EXPORTER_START,
new ExporterEvent({ message: 'Starting', ...baseEvent }),
);
await eventPublisher.emit(EventNames.EXPORTER_START, new ExporterEvent({ message: 'Starting', ...baseEvent }));
try {
const exportTransactionsResult = await outputVendor.exportTransactions(
{
Expand All @@ -57,8 +52,7 @@ export async function createTransactionsInExternalVendors(
message: 'Finished',
...baseEvent,
status: AccountStatus.DONE,
exportedTransactionsNum:
exportTransactionsResult.exportedTransactionsNum,
exportedTransactionsNum: exportTransactionsResult.exportedTransactionsNum,
}),
);
executionResult[outputVendor.name] = exportTransactionsResult;
Expand All @@ -78,9 +72,7 @@ export async function createTransactionsInExternalVendors(

await Promise.all(exportPromises);
if (!Object.keys(executionResult).length) {
const error = new Error(
'You need to set at least one output vendor to be active',
);
const error = new Error('You need to set at least one output vendor to be active');
throw error;
}

Expand Down
18 changes: 4 additions & 14 deletions packages/main/src/backend/export/outputVendors/csv/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import {
type ExportTransactionsFunction,
type OutputVendor,
} from '@/backend/commonTypes';
import {
mergeTransactions,
sortByDate,
} from '@/backend/transactions/transactions';
import { mergeTransactions, sortByDate } from '@/backend/transactions/transactions';
import { parse } from 'csv-parse/sync';
import { stringify } from 'csv-stringify/sync';
import { promises as fs } from 'fs';
Expand Down Expand Up @@ -86,21 +83,14 @@ export const serializeTransactions = (transactions: EnrichedTransaction[]) => {
});
};

const exportTransactions: ExportTransactionsFunction = async ({
transactionsToCreate,
outputVendorsConfig,
}) => {
const exportTransactions: ExportTransactionsFunction = async ({ transactionsToCreate, outputVendorsConfig }) => {
const { filePath } = outputVendorsConfig.csv!.options;
const savedTransactions = await parseTransactionsFile(filePath);
const mergedTransactions = mergeTransactions(
savedTransactions,
transactionsToCreate,
);
const mergedTransactions = mergeTransactions(savedTransactions, transactionsToCreate);
const sorted = sortByDate(mergedTransactions);
await writeCsvFile(filePath, serializeTransactions(sorted));
return {
exportedTransactionsNum:
mergedTransactions.length - savedTransactions.length,
exportedTransactionsNum: mergedTransactions.length - savedTransactions.length,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import ElectronGoogleOAuth2 from 'electron-google-oauth2';
import { clientId, clientSecret, redirectUri, scopes } from './googleAuth';

export default () => {
if (!clientId || !clientSecret)
throw Error("No 'clientId' or 'clientSecret' for google login");
if (!clientId || !clientSecret) throw Error("No 'clientId' or 'clientSecret' for google login");

// @ts-expect-error - The package 'electron-google-oauth2' is my own package, I don't know why it's not recognized
const electronGoogleOAuth2 = new ElectronGoogleOAuth2.default(
clientId,
clientSecret,
scopes,
{
successRedirectURL: redirectUri,
},
);
const electronGoogleOAuth2 = new ElectronGoogleOAuth2.default(clientId, clientSecret, scopes, {
successRedirectURL: redirectUri,
});

return electronGoogleOAuth2.openAuthWindowAndGetTokens();
};
Loading

0 comments on commit ea77923

Please sign in to comment.