Commit 12482c65 authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[FEATURE] cleanup logging and improve ads display

parent 66dbb5c9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"sgalinskiProducts": { "sgalinskiProducts": {
"icon": "sgalinski.svg", "icon": "sgalinski.svg",
"title": "Did you already hear about our other products?", "title": "Did you already hear about our other products?",
"message": "We offer products and tools around TYPO3\nand the web that help you to do your work more efficiently.\n\nVisit our website and learn more!", "message": "We offer products and tools around TYPO3\nand the web, that help you to do your work more efficiently.\n\nVisit our website and learn more!",
"link": "https://www.sgalinski.de/en/typo3-products-web-development/" "link": "https://www.sgalinski.de/products/"
} }
} }
...@@ -89,7 +89,8 @@ module.exports = class Logger { ...@@ -89,7 +89,8 @@ module.exports = class Logger {
summary: _title, summary: _title,
body: _message, body: _message,
icon: path.join(__dirname, 'icons', icon), icon: path.join(__dirname, 'icons', icon),
sound: 'message-new-instant', sound: 'dialog-information',
timeout: _options.timeout ? _options.timeout : 5000,
actions: { actions: {
default: '' default: ''
} }
......
...@@ -116,10 +116,39 @@ module.exports = class task { ...@@ -116,10 +116,39 @@ module.exports = class task {
*/ */
_runAd() { _runAd() {
const pickedAd = adService.getRandomAd(); const pickedAd = adService.getRandomAd();
pickedAd.timeout = 15000;
this._logger.displayNotification( this._logger.displayNotification(
pickedAd.title, pickedAd.title,
pickedAd.message, pickedAd.message,
pickedAd pickedAd,
); );
console.log();
let messageParts = pickedAd.message.split('\n');
messageParts.unshift('');
messageParts.unshift(`🔥 ${pickedAd.title} 🔥`);
messageParts.unshift('');
messageParts.push(pickedAd.link);
messageParts.push('');
messageParts.forEach((_messagePart) => {
let addedWhitespaces = '';
for (let index = 60; index > _messagePart.length; index--) {
addedWhitespaces += ' ';
}
this._logger.info(chalk.bgBlue(chalk.whiteBright(` ${_messagePart + addedWhitespaces} `)));
});
console.log();
this._logger.info(
chalk.bgYellow(' ')
);
this._logger.info(
chalk.bgYellow(chalk.black(' Are you tired of seeing this message? Buy a license now: '))
);
this._logger.info(
chalk.bgYellow(chalk.black(' https://www.sgalinski.de/typo3-produkte-webentwicklung/sgc/ '))
);
this._logger.info(
chalk.bgYellow(' ')
);
console.log();
} }
}; };
...@@ -112,10 +112,6 @@ module.exports = class Css extends Task { ...@@ -112,10 +112,6 @@ module.exports = class Css extends Task {
let fileName = path.basename(_fileName).replace('.scss', newSuffix); let fileName = path.basename(_fileName).replace('.scss', newSuffix);
let distDirectory = this._getFullPath(this._config.directories.css); let distDirectory = this._getFullPath(this._config.directories.css);
if (!fs.existsSync(distDirectory)) {
console.log(`${distDirectory} 'does not exist. Create now!'`);
fs.mkdirSync(distDirectory);
}
return `${distDirectory}/${fileName}`; return `${distDirectory}/${fileName}`;
} }
...@@ -129,10 +125,6 @@ module.exports = class Css extends Task { ...@@ -129,10 +125,6 @@ module.exports = class Css extends Task {
let fileName = path.basename(_fileName).replace('.css', '.css.map'); let fileName = path.basename(_fileName).replace('.css', '.css.map');
let sourceMapDirectory = this._getFullPath(this._config.directories.cssSourceMaps); let sourceMapDirectory = this._getFullPath(this._config.directories.cssSourceMaps);
if (!fs.existsSync(sourceMapDirectory)) {
console.log(`${sourceMapDirectory} 'does not exist. Create now!'`);
fs.mkdirSync(sourceMapDirectory);
}
return `${sourceMapDirectory}/${fileName}`; return `${sourceMapDirectory}/${fileName}`;
} }
...@@ -300,11 +292,6 @@ module.exports = class Css extends Task { ...@@ -300,11 +292,6 @@ module.exports = class Css extends Task {
}); });
let distDirectory = config.dest; let distDirectory = config.dest;
if (!fs.existsSync(distDirectory)) {
console.log(`${distDirectory} 'does not exist. Create now!'`);
fs.mkdirSync(distDirectory);
}
await this._writeFile(path.join(distDirectory, filename), html); await this._writeFile(path.join(distDirectory, filename), html);
} catch (_error) { } catch (_error) {
if (_error.message.indexOf('ENOENT: no such file') >= 0) { if (_error.message.indexOf('ENOENT: no such file') >= 0) {
......
...@@ -3,6 +3,7 @@ const Task = require('../task'); ...@@ -3,6 +3,7 @@ const Task = require('../task');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const chalk = require('chalk'); const chalk = require('chalk');
const mkdirp = require('mkdirp');
const globby = require('globby'); const globby = require('globby');
const browserify = require('browserify'); const browserify = require('browserify');
const babelify = require('babelify'); const babelify = require('babelify');
...@@ -92,13 +93,7 @@ module.exports = class Js extends Task { ...@@ -92,13 +93,7 @@ module.exports = class Js extends Task {
? '.bundled.min.js' ? '.bundled.min.js'
: '.bundled.js'; : '.bundled.js';
let fileName = path.basename(_fileName).replace('.js', newSuffix); let fileName = path.basename(_fileName).replace('.js', newSuffix);
let distDirectory = this._getFullPath(this._config.directories.javascriptDest); let distDirectory = this._getFullPath(this._config.directories.javascriptDest);
if (!fs.existsSync(distDirectory)) {
console.log(`${distDirectory} 'does not exist. Create now!'`);
fs.mkdirSync(distDirectory);
}
return `${distDirectory}/${fileName}`; return `${distDirectory}/${fileName}`;
} }
...@@ -109,13 +104,7 @@ module.exports = class Js extends Task { ...@@ -109,13 +104,7 @@ module.exports = class Js extends Task {
*/ */
_getSourceMapsPath(_fileName) { _getSourceMapsPath(_fileName) {
let fileName = path.basename(_fileName).replace('.js', '.js.map'); let fileName = path.basename(_fileName).replace('.js', '.js.map');
let sourceMapDirectory = this._getFullPath(this._config.directories.javascriptSourceMaps); let sourceMapDirectory = this._getFullPath(this._config.directories.javascriptSourceMaps);
if (!fs.existsSync(sourceMapDirectory)) {
console.log(`${sourceMapDirectory} 'does not exist. Create now!'`);
fs.mkdirSync(sourceMapDirectory);
}
return `${sourceMapDirectory}/${fileName}`; return `${sourceMapDirectory}/${fileName}`;
} }
...@@ -165,6 +154,12 @@ module.exports = class Js extends Task { ...@@ -165,6 +154,12 @@ module.exports = class Js extends Task {
)); ));
} }
let outputDirectory = path.dirname(_output);
if (!fs.existsSync(outputDirectory)) {
mkdirp.sync(outputDirectory);
this._logger.info(`Created directory ${chalk.dim(outputDirectory)}`);
}
// create the stream for writing the outFile // create the stream for writing the outFile
let outFile = fs.createWriteStream(_output, 'utf-8'); let outFile = fs.createWriteStream(_output, 'utf-8');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment