Skip to content

Commit

Permalink
v0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
linda-rian committed Oct 3, 2018
1 parent 2770b98 commit a246daf
Show file tree
Hide file tree
Showing 10 changed files with 1,279 additions and 376 deletions.
19 changes: 15 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
language: node_js
cache: yarn
sudo: false
cache:
yarn: true
directories:
- node_modules
node_js:
- stable
- "6"
- "4"
- stable
- '8'
- '6'
deploy:
provider: npm
email: [email protected]
api_key: $NPM_API_KEY
on:
tags: true
repo: ramoona/banks-db
1 change: 1 addition & 0 deletions banks/gb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = [
require('./barclaycard'),
require('./barclays'),
require('./curve'),
require('./epayments'),
require('./halifax'),
require('./hsbc'),
require('./lloydstsb'),
Expand Down
3 changes: 2 additions & 1 deletion banks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ module.exports = [
require('./tw/index'),
require('./ua/index'),
require('./us/index'),
require('./uy/index')
require('./uy/index'),
require('./za/index')
];
4 changes: 2 additions & 2 deletions banks/pl/millennium.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"url": "https://www.bankmillennium.pl/",
"color": "#c82059",
"prefixes": [
487474,
512748,
512792,
534714,
542757,
487474
542757
]
}
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions banks/za/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = [
require('./absa'),
require('./capitec')
];
97 changes: 45 additions & 52 deletions lint.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,59 @@
const fs = require('fs-promise');
const path = require('path');
const helper = require('./helper');
const JSV = require('JSV').JSV;
const { JSV } = require('JSV');
const jsonfile = require('jsonfile-promised');
const helper = require('./helper');

const linter = JSV.createEnvironment();

const lintBank = (bank, bankPath, bankName, country, schema) =>
new Promise((resolve, reject) => {
const report = linter.validate(bank, schema);
bankName = bankName.replace(/\.json$/, '');
const lintBank = (bank, bankPath, bankName, country, schema) => new Promise((resolve, reject) => {
const report = linter.validate(bank, schema);
bankName = bankName.replace(/\.json$/, '');

if (report.errors.length > 0) {
report.errors.forEach(i => console.error(i));
reject(bankPath);
} else if (bank.country !== country) {
reject(`${bankPath} :\ncountry folder doesn't match with bank country`);
} else if (bank.name !== bankName) {
reject(`${bankPath}:\nJSON filename doesn't match with bank name`);
} else if (!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(bank.color)) {
reject(`${bankPath}: \ninvalid color format (use HEX)`);
} else {
bank.prefixes.sort();
if (/[A-F]\w*/.test(bank.color)) {
bank.color = bank.color.toLowerCase();
helper.warn(`${bankPath}: bank color was changed to lowercase`);
}
resolve(bank);
if (report.errors.length > 0) {
report.errors.forEach(i => console.error(i));
reject(bankPath);
} else if (bank.country !== country) {
reject(new Error(`${bankPath} :\ncountry folder doesn't match with bank country`));
} else if (bank.name !== bankName) {
reject(new Error(`${bankPath}:\nJSON filename doesn't match with bank name`));
} else if (!/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(bank.color)) {
reject(new Error(`${bankPath}: \ninvalid color format (use HEX)`));
} else {
bank.prefixes.sort();
if (/[A-F]\w*/.test(bank.color)) {
bank.color = bank.color.toLowerCase();
helper.warn(`${bankPath}: bank color was changed to lowercase`);
}
})
;
resolve(bank);
}
});

const lint = (files, schema) =>
new Promise((resolve, reject) => {
const countries = files.filter(file =>
fs.lstatSync(path.join(__dirname, `banks/${file}`)).isDirectory());
const lint = (files, schema) => new Promise((resolve, reject) => {
const countries = files.filter(file => fs.lstatSync(path.join(__dirname, `banks/${file}`)).isDirectory());

countries.reduce((countryPromise, country) => {
const banks = fs.readdirSync(
path.join(__dirname, `banks/${country}`)).filter(file => /\.json$/.test(file)
);
return countryPromise.then(() =>
banks.reduce((bankPromise, bankName) => {
const bankPath = `banks/${country}/${bankName}`;
const fullPath = path.join(__dirname, bankPath);
return bankPromise.then(() =>
jsonfile.readFile(path.join(__dirname, bankPath))
.then(bank => lintBank(bank, bankPath, bankName, country, schema))
.then(bank => jsonfile.writeFile(fullPath, bank, { spaces: 2 }))
.then(() => {
helper.success(`banks/${country}/${bankName}`);
})
.catch(reject)
);
}, Promise.resolve()));
}, Promise.resolve());
countries.reduce((countryPromise, country) => {
const banks = fs.readdirSync(
path.join(__dirname, `banks/${country}`)
).filter(file => /\.json$/.test(file));

if (/\.json/.test(files.join())) {
reject('JSON must not be placed straight in banks folder');
}
})
;
return countryPromise.then(() => banks.reduce((bankPromise, bankName) => {
const bankPath = `banks/${country}/${bankName}`;
const fullPath = path.join(__dirname, bankPath);
return bankPromise.then(() => jsonfile.readFile(path.join(__dirname, bankPath))
.then(bank => lintBank(bank, bankPath, bankName, country, schema))
.then(bank => jsonfile.writeFile(fullPath, bank, { spaces: 2 }))
.then(() => {
helper.success(`banks/${country}/${bankName}`);
})
.catch(reject));
}, Promise.resolve()));
}, Promise.resolve());

if (/\.json/.test(files.join())) {
reject(new Error('JSON must not be placed straight in banks folder'));
}
});

jsonfile.readFile(path.join(__dirname, 'schema.json')).then((schema) => {
fs.readdir(path.join(__dirname, 'banks')).then(files => lint(files, schema)).catch((err) => {
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "banks-db",
"version": "0.12.0",
"version": "0.13.0",
"description": "Bankcards BIN database",
"author": "Linda Rian <[email protected]>",
"repository": "ramoona/banks-db",
Expand All @@ -14,16 +14,16 @@
"db"
],
"devDependencies": {
"JSV": "^4.0.2",
"ava": "^0.21.0",
"chalk": "^2.0.1",
"eslint": "^4.2.0",
"eslint-config-airbnb": "^15.0.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"fs-promise": "^2.0.3",
"jsonfile-promised": "0.0.1"
"JSV": "4.x.x",
"ava": "0.x.x",
"chalk": "2.x.x",
"eslint": "5.x.x",
"eslint-config-airbnb": "17.x.x",
"eslint-plugin-import": "2.x.x",
"eslint-plugin-jsx-a11y": "6.x.x",
"eslint-plugin-react": "7.x.x",
"fs-promise": "2.x.x",
"jsonfile-promised": "0.x.x"
},
"scripts": {
"test": "ava && node lint.js && eslint *.js",
Expand Down
Loading

0 comments on commit a246daf

Please sign in to comment.