Skip to content

Commit

Permalink
v0.3.2: bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkoschubert committed May 27, 2018
1 parent 744c1e1 commit efbb855
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 51 deletions.
5 changes: 4 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@ Todo:
☐ Help pages for every command
Bugs:
✔ Manual selection of tasks doesn't work anymore @critical @done(18-05-22 16:31)
✔ CSS and JS files without a protocol can't be loaded @high @done(18-05-22 17:00)
✔ CSS and JS files without a protocol can't be loaded @high @done(18-05-22 17:00)
✔ URL class is not global in nodejs < 10 @critical @done(18-05-27 22:11)
✔ Inline JS and CSS can't be loaded when there are no external files @high @done(18-05-27 22:12)
☐ On Google the protocol doesn't upgrade to SSL automatically @low
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node --harmony
#!/usr/bin/env node

'use strict'

Expand Down
101 changes: 53 additions & 48 deletions lib/tasks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const URL = require('url').URL;
const got = require('got');
const chalk = require('chalk');
const sslCert = require('get-ssl-certificate');
Expand Down Expand Up @@ -238,39 +239,42 @@ class Tasks {
widths: [5, 20, 0]
});

if (typeof fonts.google !== 'undefined') {
const gf = this.cp.countFonts(fonts.google);
this.ui.info('Google Fonts loaded: ' + chalk.red(gf.length) + '\n');
gf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.google, f))]);
});
}
if (typeof fonts.wordpress !== 'undefined') {
const wf = this.cp.countFonts(fonts.wordpress);
if (typeof fonts.google !== 'undefined') console.log('');
this.ui.info('Fonts from wordpress.com loaded: ' + chalk.red(wf.length) + '\n');
wf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.wordpress, f))]);
});
}
if (typeof fonts.internal !== 'undefined') {
const intf = this.cp.countFonts(fonts.internal);
if (typeof fonts.wordpress !== 'undefined') console.log('');
this.ui.info('Fonts directly from the site: ' + chalk.red(intf.length) + '\n');
intf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.internal, f))]);
});
if (Object.keys(fonts).length === 0) {
this.ui.info('There were no Fonts found.');
} else {
if (typeof fonts.google !== 'undefined') {
const gf = this.cp.countFonts(fonts.google);
this.ui.info('Google Fonts loaded: ' + chalk.red(gf.length) + '\n');
gf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.google, f))]);
});
}
if (typeof fonts.wordpress !== 'undefined') {
const wf = this.cp.countFonts(fonts.wordpress);
if (typeof fonts.google !== 'undefined') console.log('');
this.ui.info('Fonts from wordpress.com loaded: ' + chalk.red(wf.length) + '\n');
wf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.wordpress, f))]);
});
}
if (typeof fonts.internal !== 'undefined') {
const intf = this.cp.countFonts(fonts.internal);
if (typeof fonts.wordpress !== 'undefined') console.log('');
this.ui.info('Fonts directly from the site: ' + chalk.red(intf.length) + '\n');
intf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.internal, f))]);
});

}
if (typeof fonts.inline !== 'undefined') {
const inlf = this.cp.countFonts(fonts.inline);
if (typeof fonts.iternal !== 'undefined') console.log('');
this.ui.info('Inline Fonts from the CSS: ' + chalk.red(inlf.length) + '\n');
inlf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.inline, f))]);
});
}
}
if (typeof fonts.inline !== 'undefined') {
const inlf = this.cp.countFonts(fonts.inline);
if (typeof fonts.iternal !== 'undefined') console.log('');
this.ui.info('Inline Fonts from the CSS: ' + chalk.red(inlf.length) + '\n');
inlf.forEach((f, i) => {
this.ui.tableitem([chalk.yellow(String(i + 1) + '.'), f, chalk.dim(this.cp.getFontStyles(fonts.inline, f))]);
});
}

this.remove('fonts');
}
}
Expand Down Expand Up @@ -421,7 +425,7 @@ class Tasks {
});
return this.processMultipleItems(this.data.js, this.loadExternalItem).then(res => {

this.data.js = res;
this.data.js = (res !== 404) ? res : [];
this.ui.message({
verbose: chalk.dim('-> Looking for Inline JavaScript')
}, {
Expand Down Expand Up @@ -451,7 +455,7 @@ class Tasks {
});
return this.processMultipleItems(this.data.css, this.loadExternalItem).then(res => {

this.data.css = res;
this.data.css = (res !== 404) ? res : [];
this.ui.message({
verbose: chalk.dim('-> Looking for Inline CSS')
}, {
Expand Down Expand Up @@ -501,20 +505,22 @@ class Tasks {
processMultipleItems(array, fn) {
const self = this;
var results = [];
return array.reduce((p, item) => {
return p.then(() => {
return fn(item).then((data) => {
self.ui.message({
verbose: chalk.dim('-> ' + item.url)
}, {
code: data.statusCode,
msg: data.statusMessage
}, false);
results.push(data);
return results;
if (array.length !== 0) {
return array.reduce((p, item) => {
return p.then(() => {
return fn(item).then((data) => {
self.ui.message({
verbose: chalk.dim('-> ' + item.url)
}, {
code: data.statusCode,
msg: data.statusMessage
}, false);
results.push(data);
return results;
});
});
});
}, Promise.resolve());
}, Promise.resolve());
} else return Promise.resolve(404);
}


Expand Down Expand Up @@ -556,9 +562,8 @@ class Tasks {
url = url.replace(/(https?:)?\/\//, ''); // delete the protocol
url = (url.startsWith('/')) ? url.substr(1) : url; // get rid of trailing slash
url = (url.endsWith('/')) ? url : url + '/'; // ensure that it ends with a slash
url = 'http://' + url; // set unsecure protocol
// upgrade protocol if needed
return got(url).then(res => {
return got('http://' + url).then(res => {
url = (url != res.url) ? res.url : url;
this.data.html = {
url: new URL(url)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gdpr-cli",
"version": "0.3.1",
"version": "0.3.2",
"description": "Checks websites for GDPR compliance",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit efbb855

Please sign in to comment.