From 414e57416c657e8f82efed5116819433aed614a4 Mon Sep 17 00:00:00 2001 From: Ramoona Date: Mon, 29 Feb 2016 23:43:26 +0300 Subject: [PATCH] release 0.7.0 --- CHANGELOG.md | 11 +++++++++++ lint.js | 36 +++++++++++++++++++----------------- package.json | 6 ++++-- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af234b3..6faae7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## 0.7.0 +* Banks separated by country +* Removed manual requires of each bank JSON +* Normalized color format (HEX, lowercase) and add linter to check and fix it in future +* Added: + * Gazprombank (RU) +* Updated: + * Alfabank (RU) + * Raiffeisen (RU) + * Sberbank (RU) + ## 0.6.0 * Added `result.code` for easier usage [from [#34](https://github.com/ramoona/banks-db/issues/34)] * Added fix for undefined card number [from [#33](https://github.com/ramoona/banks-db/issues/33)] diff --git a/lint.js b/lint.js index ea0753a..d0fa5a1 100644 --- a/lint.js +++ b/lint.js @@ -13,26 +13,30 @@ function showError(filePath, error) { fs.readdir(path.join(__dirname, 'banks'), (err, files) => { if (err) throw err; - const countries = files.filter(file => fs.lstatSync(path.join(__dirname, - 'banks/' + file)).isDirectory()); + const countries = files.filter(file => + fs.lstatSync(path.join(__dirname, 'banks/' + file)).isDirectory()); countries.forEach(country => { - const banks = fs.readdirSync(path.join(__dirname, 'banks/' + - country)).filter(file => /\.json$/.test(file)); + const banks = fs.readdirSync( + path.join(__dirname, 'banks/' + country)).filter(file => /\.json$/.test(file) + ); - jsonfile.readFile(path.join(__dirname, 'schema.json'), (err4, schema) => { - if (err4) throw err4; + jsonfile.readFile(path.join(__dirname, 'schema.json'), (err1, schema) => { + if (err1) throw err1; banks.forEach(name => { const bankPath = 'banks/' + country + '/' + name; - jsonfile.readFile(path.join(__dirname, bankPath), (err5, bank) => { - if (err5) throw err5; + + jsonfile.readFile(path.join(__dirname, bankPath), (err2, bank) => { + if (err2) throw err2; const report = linter.validate(bank, schema); name = name.replace(/\.json$/, ''); - if (report.errors.length === 0 && bank.country === country && bank.name === name) { - console.log(chalk.green('OK ') + chalk.white('banks/' + country + '/' + name)); + if (report.errors.length > 0) { + showError(bankPath); + report.errors.forEach(i => console.error(i)); + process.exit(1); } else if (bank.country !== country) { showError(bankPath, ':\ncountry folder doesn\'t match with bank country'); process.exit(1); @@ -40,16 +44,14 @@ fs.readdir(path.join(__dirname, 'banks'), (err, files) => { showError(bankPath, ':\nJSON filename doesn\'t match with bank name'); process.exit(1); } else { - showError(bankPath); - report.errors.forEach(i => console.error(i)); - process.exit(1); + console.log(chalk.green('OK ') + chalk.white('banks/' + country + '/' + name)); } if (/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(bank.color)) { if (/[A-F]\w*/.test(bank.color)) { bank.color = bank.color.toLowerCase(); - jsonfile.writeFile(path.join(__dirname, bankPath), bank, { spaces: 2 }, err1 => { - if (err1) throw err1; + jsonfile.writeFile(path.join(__dirname, bankPath), bank, { spaces: 2 }, err3 => { + if (err3) throw err3; }); } } else { @@ -62,8 +64,8 @@ fs.readdir(path.join(__dirname, 'banks'), (err, files) => { }); }); -fs.readdir(path.join(__dirname, 'banks'), (err2, items) => { - if (err2) throw err2; +fs.readdir(path.join(__dirname, 'banks'), (err4, items) => { + if (err4) throw err4; if (/\.json/.test(items.join())) { showError('banks/', ': JSON must not be placed straght in banks folder'); diff --git a/package.json b/package.json index cc22cd4..aefbc2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "banks-db", - "version": "0.6.0", + "version": "0.7.0", "description": "Bankcards BIN database", "author": "Linda Rian ", "repository": "Ramoona/banks-db", @@ -22,7 +22,9 @@ "jsonfile" : "2.2.3" }, "scripts": { - "test": "ava && node lint.js && eslint *.js" + "test": "ava && node lint.js && eslint *.js", + "build": "node build-indexes.js", + "prepublish": "npm run build && npm test" }, "license": "CC-BY-4.0" }