From 31a71a3e8dc4e574f4cca43af7223aea6d2f1967 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Thu, 1 Mar 2018 17:16:26 -0500 Subject: [PATCH 01/12] built initial file structure --- README.md | 7 +------ hello_world.js | 0 package.json | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 hello_world.js create mode 100644 package.json diff --git a/README.md b/README.md index 468464f..db07aae 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,4 @@ assignment_node_hello_world =========================== - -Just Node.js saying hello to the world and such. - - - - +By Brennan Fulmer diff --git a/hello_world.js b/hello_world.js new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json new file mode 100644 index 0000000..a54dd6e --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "hello_world", + "version": "1.0.0", + "description": "Node_Hello_World", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/BrennanFulmer/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/BrennanFulmer/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/BrennanFulmer/assignment_node_hello_world#readme" +} From de030c346073107f58512dceadc44c1b27a2cbd3 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Thu, 1 Mar 2018 17:17:05 -0500 Subject: [PATCH 02/12] renamed js file to match json --- hello_world.js => index.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename hello_world.js => index.js (100%) diff --git a/hello_world.js b/index.js similarity index 100% rename from hello_world.js rename to index.js From 8b01fddf370c2af93dcbb1c674c078efe5ffc498 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Thu, 1 Mar 2018 17:51:20 -0500 Subject: [PATCH 03/12] added chalk and lodash --- .gitignore | 1 + index.js | 1 + package-lock.json | 62 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++++- 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/index.js b/index.js index e69de29..accefce 100644 --- a/index.js +++ b/index.js @@ -0,0 +1 @@ +console.log("Hello World"); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a951dfd --- /dev/null +++ b/package-lock.json @@ -0,0 +1,62 @@ +{ + "name": "hello_world", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz", + "integrity": "sha512-QUU4ofkDoMIVO7hcx1iPTISs88wsO8jA92RQIm4JAwZvFGGAV2hSAA1NX7oVj2Ej2Q6NDTcRDjPTFrMCRZoJ6g==", + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "5.2.0" + } + }, + "color-convert": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "lodash": { + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" + }, + "supports-color": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.2.0.tgz", + "integrity": "sha512-F39vS48la4YvTZUPVeTqsjsFNrvcMwrV3RLZINsmHo+7djCvuUzSIeXOnZ5hmjef4bajL1dNccN+tg5XAliO5Q==", + "requires": { + "has-flag": "3.0.0" + } + } + } +} diff --git a/package.json b/package.json index a54dd6e..9d131b1 100644 --- a/package.json +++ b/package.json @@ -15,5 +15,9 @@ "bugs": { "url": "https://github.com/BrennanFulmer/assignment_node_hello_world/issues" }, - "homepage": "https://github.com/BrennanFulmer/assignment_node_hello_world#readme" + "homepage": "https://github.com/BrennanFulmer/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.3.1", + "lodash": "^4.17.5" + } } From 50e3ea6bba395a10b33e7461c889337ad7a12ca5 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Thu, 1 Mar 2018 18:04:13 -0500 Subject: [PATCH 04/12] verified chalk is working --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index accefce..762b8c4 100644 --- a/index.js +++ b/index.js @@ -1 +1,8 @@ + +const chalk = require('chalk'); +console.log(chalk.blue('Hello world!')); + +var lodash = require("lodash"); +console.log(lodash.name); + console.log("Hello World"); From 49d8abeff7671c0b1ff6f9a40274127dd5836f2f Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Thu, 1 Mar 2018 18:10:15 -0500 Subject: [PATCH 05/12] basic setup completed --- index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 762b8c4..c413a1b 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,12 @@ +console.log("Hello World!"); + const chalk = require('chalk'); -console.log(chalk.blue('Hello world!')); +console.log(chalk.red('I am chalk')); -var lodash = require("lodash"); -console.log(lodash.name); +var _ = require('lodash'); +console.log(_.name); -console.log("Hello World"); +_.each([1, 2, 3], function(value) { + console.log(value); +}); From f18c8f4a693d3b412a91e8912a4098b5f8a5d66c Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Thu, 1 Mar 2018 18:11:54 -0500 Subject: [PATCH 06/12] added logger folder, and base file --- lib/logger.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/logger.js diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..e69de29 From bf7e9b448e22a7e75ab10942315dd0a4a2958ddd Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Sun, 4 Mar 2018 20:24:38 -0500 Subject: [PATCH 07/12] finished logger --- lib/logger.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/logger.js b/lib/logger.js index e69de29..8885291 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -0,0 +1,34 @@ + +/* + cd Documents/Viking/Node/hello_world + + https://www.vikingcodeschool.com/dashboard#/professional-development-with-javascript/node-js-hello-world +*/ + +const chalk = require('chalk'); + +function log(message, level) { + if (level == "info") { + info(message); + } else if (level == "warn") { + warn(message); + } else if (level == "error") { + error(message); + } +} + +function info(message) { + console.log(chalk.blue(message)); +} + +function warn(message) { + console.log(chalk.yellow(message)); +} + +function error(message) { + console.log(chalk.red(message)); +} + +log("test", "info"); +log("123", "warn"); +log("abc", "error"); From 88ebf91ada599201d21364c7ce7cd0bfc71ad0b0 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Sun, 4 Mar 2018 20:47:47 -0500 Subject: [PATCH 08/12] finished turning logger into functional module --- index.js | 16 +++++++++++++--- lib/logger.js | 52 +++++++++++++++++++++++---------------------------- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/index.js b/index.js index c413a1b..d0e9c21 100644 --- a/index.js +++ b/index.js @@ -1,12 +1,22 @@ -console.log("Hello World!"); +/* + cd Documents/Viking/Node/hello_world -const chalk = require('chalk'); -console.log(chalk.red('I am chalk')); + https://www.vikingcodeschool.com/dashboard#/professional-development-with-javascript/node-js-hello-world +*/ +const chalk = require('chalk'); var _ = require('lodash'); +var logger = require("./lib/logger"); + +console.log("Hello World!"); console.log(_.name); +console.log(chalk.red('chalk')); _.each([1, 2, 3], function(value) { console.log(value); }); + +logger.log("test", "info"); +logger.log("123", "warn"); +logger.log("abc", "error"); diff --git a/lib/logger.js b/lib/logger.js index 8885291..75dc4fb 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,34 +1,28 @@ -/* - cd Documents/Viking/Node/hello_world - - https://www.vikingcodeschool.com/dashboard#/professional-development-with-javascript/node-js-hello-world -*/ - const chalk = require('chalk'); -function log(message, level) { - if (level == "info") { - info(message); - } else if (level == "warn") { - warn(message); - } else if (level == "error") { - error(message); +var logger = { + log: function(message, level) { + if (level == "info") { + this.info(message); + } else if (level == "warn") { + this.warn(message); + } else if (level == "error") { + this.error(message); + } + }, + + info: function(message) { + console.log(chalk.blue(message)); + }, + + warn: function(message) { + console.log(chalk.yellow(message)); + }, + + error: function(message) { + console.log(chalk.red(message)); } -} - -function info(message) { - console.log(chalk.blue(message)); -} - -function warn(message) { - console.log(chalk.yellow(message)); -} - -function error(message) { - console.log(chalk.red(message)); -} +}; -log("test", "info"); -log("123", "warn"); -log("abc", "error"); +module.exports = logger; From c819734de2b71dc7aa751ac58e42bf9850762e00 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Sun, 4 Mar 2018 23:00:09 -0500 Subject: [PATCH 09/12] finished logging json files contents --- index.js | 7 ++++++- lib/logger.js | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d0e9c21..468dcda 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ const chalk = require('chalk'); var _ = require('lodash'); var logger = require("./lib/logger"); +var jason = require("./data/logs"); console.log("Hello World!"); console.log(_.name); @@ -18,5 +19,9 @@ _.each([1, 2, 3], function(value) { }); logger.log("test", "info"); -logger.log("123", "warn"); +logger.log("123", "warning"); logger.log("abc", "error"); + +_.each(jason, function(value, index) { + logger.log(value.message, value.level); +}); diff --git a/lib/logger.js b/lib/logger.js index 75dc4fb..c0a7f03 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -5,8 +5,8 @@ var logger = { log: function(message, level) { if (level == "info") { this.info(message); - } else if (level == "warn") { - this.warn(message); + } else if (level == "warning") { + this.warning(message); } else if (level == "error") { this.error(message); } @@ -16,7 +16,7 @@ var logger = { console.log(chalk.blue(message)); }, - warn: function(message) { + warning: function(message) { console.log(chalk.yellow(message)); }, From fd2ef9061197c578c918072837f173986ba8ec96 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Sun, 4 Mar 2018 23:04:43 -0500 Subject: [PATCH 10/12] ran js files through prettier --- index.js | 16 +++++----------- lib/logger.js | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 468dcda..2e3815f 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,12 @@ -/* - cd Documents/Viking/Node/hello_world - - https://www.vikingcodeschool.com/dashboard#/professional-development-with-javascript/node-js-hello-world -*/ - -const chalk = require('chalk'); -var _ = require('lodash'); +const chalk = require("chalk"); +var _ = require("lodash"); var logger = require("./lib/logger"); -var jason = require("./data/logs"); +var record = require("./data/logs"); console.log("Hello World!"); +console.log(chalk.red("chalk")); console.log(_.name); -console.log(chalk.red('chalk')); _.each([1, 2, 3], function(value) { console.log(value); @@ -22,6 +16,6 @@ logger.log("test", "info"); logger.log("123", "warning"); logger.log("abc", "error"); -_.each(jason, function(value, index) { +_.each(record, function(value, index) { logger.log(value.message, value.level); }); diff --git a/lib/logger.js b/lib/logger.js index c0a7f03..8b809ff 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,5 +1,5 @@ -const chalk = require('chalk'); +const chalk = require("chalk"); var logger = { log: function(message, level) { From 8ec8fc3c6206ad9149aa89917f54c3adf21cf557 Mon Sep 17 00:00:00 2001 From: Brennan_Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Sun, 4 Mar 2018 23:11:49 -0500 Subject: [PATCH 11/12] finished --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 2e3815f..1ff6d9b 100644 --- a/index.js +++ b/index.js @@ -16,6 +16,6 @@ logger.log("test", "info"); logger.log("123", "warning"); logger.log("abc", "error"); -_.each(record, function(value, index) { +_.each(record, function(value) { logger.log(value.message, value.level); }); From 4d33abbc59068c45ee1b135d68037e9db00b12a9 Mon Sep 17 00:00:00 2001 From: Brennan Fulmer <31666354+BrennanFulmer@users.noreply.github.com> Date: Tue, 24 Apr 2018 15:16:21 -0400 Subject: [PATCH 12/12] Update README.md added actual description --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index db07aae..d660568 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ assignment_node_hello_world =========================== By Brennan Fulmer + +In this assignment I learned the basics of Node and used Lodash and Chalk to display a series of error messages