Skip to content

Commit

Permalink
fix: enable parsing of more bank2ynab files (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
morremeyer authored Nov 7, 2023
1 parent ed7ab0b commit d00d1d4
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 147 deletions.
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "1.0.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "[Jest] ynap-parsers: current file",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--config",
"packages/ynap-parsers/jest.config.js"
],
"console": "integratedTerminal",
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}
]
}
123 changes: 7 additions & 116 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ynap-bank2ynab-converter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envelope-zero/ynap-bank2ynab-converter",
"version": "1.14.38",
"version": "1.14.39",
"license": "MIT",
"author": {
"email": "[email protected]",
Expand Down
23 changes: 15 additions & 8 deletions packages/ynap-bank2ynab-converter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ program

import { ParserConfig } from './parserconfig';

const CONFIG_URL = `https://raw.githubusercontent.com/bank2ynab/bank2ynab/${program.opts()["branch"]}/bank2ynab.conf`;
const CONFIG_URL = `https://raw.githubusercontent.com/bank2ynab/bank2ynab/${
program.opts()['branch']
}/bank2ynab.conf`;

const CONFIG_LINK = `https://github.com/bank2ynab/bank2ynab/blob/${program.opts()["branch"]}/bank2ynab.conf`;
const CONFIG_LINK = `https://github.com/bank2ynab/bank2ynab/blob/${
program.opts()['branch']
}/bank2ynab.conf`;

const SECTION = new RegExp(/^\s*\[([^\]]+)]/);
const KEY = new RegExp(/\s*(.*?)\s*[=:]\s*(.*)/);
const COMMENT = new RegExp(/^\s*[;#]/);

const blacklist = program.opts()["exclude"] || [];
const ignorelist = program.opts()['exclude'] || [];

interface Sections {
[k: string]: ConfigFields;
Expand Down Expand Up @@ -96,14 +100,14 @@ const script = async () => {

const config = parseConfig(configData);

console.log('Excluding', blacklist.length, 'items from blacklist.');
console.log('Excluding', ignorelist.length, 'items from ignorelist.');

const filteredConfig: ParserConfig[] = Object.keys(config)
.map((c) => ({ ...config[c], Name: c }))
.filter(
(c) =>
c.Name !== 'DEFAULT' &&
!blacklist.includes(c.Name) &&
!ignorelist.includes(c.Name) &&
!c.Plugin &&
c['Source Filename Pattern'] !== 'unknown!' &&
c['Input Columns'],
Expand All @@ -127,7 +131,7 @@ const script = async () => {
.map((s) => s.trim()),
headerRows: Number(c['Header Rows'] || '1'),
footerRows: Number(c['Footer Rows'] || '0'),
} as ParserConfig),
}) as ParserConfig,
);

console.log(
Expand All @@ -138,8 +142,11 @@ const script = async () => {
'configs.',
);

fs.writeFileSync(program.opts()["output"], JSON.stringify(filteredConfig, null, 2));
console.log('Saved configs to', program.opts()["output"].output);
fs.writeFileSync(
program.opts()['output'],
JSON.stringify(filteredConfig, null, 2),
);
console.log('Saved configs to', program.opts()['output'].output);
};

script();
3 changes: 1 addition & 2 deletions packages/ynap-parsers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@envelope-zero/ynap-parsers",
"version": "1.15.27",
"version": "1.15.28",
"description": "Parsers from various formats to YNAB CSV",
"main": "index.js",
"author": "Envelope Zero Team <[email protected]> (https://envelope-zero.org)",
Expand All @@ -23,7 +23,6 @@
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.0/xlsx-0.20.0.tgz"
},
"devDependencies": {
"@envelope-zero/ynap-bank2ynab-converter": "1.14.37",
"@types/iban": "0.0.35",
"@types/jest": "29.5.7",
"@types/lodash": "4.14.200",
Expand Down
Loading

0 comments on commit d00d1d4

Please sign in to comment.