From 0c9583053ca9beea1ee257677657e383e106f29a Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Wed, 18 Mar 2020 03:56:43 -0700 Subject: [PATCH 1/7] Update README.md --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bfeccc1..3a199a7 100644 --- a/README.md +++ b/README.md @@ -1 +1,27 @@ -# notes \ No newline at end of file +# LAB - Class 01 + +## Notes + +### Author: Joel Watson + +### Links and Resources + +- [submission PR](http://xyz.com) +- [ci/cd](http://xyz.com) (GitHub Actions) +- [back-end server url](http://xyz.com) (when applicable) + +### Setup + +#### How to initialize/run your application (where applicable) + +Example of adding a note to the database (must use -a or --add) + +- `node index.js notes --add "Hello, I am an example note"` + +#### Tests + +- `npm test` + +#### UML + +![UML](https://drive.google.com/file/d/1i69phC6ir_q-i4TmDu9l6QAEp18bsrp7/view?usp=sharing) From 1106b634e5ef2100161283d4560326ea2b98eac7 Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Wed, 18 Mar 2020 04:02:40 -0700 Subject: [PATCH 2/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a199a7..c13abdf 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ Example of adding a note to the database (must use -a or --add) #### UML -![UML](https://drive.google.com/file/d/1i69phC6ir_q-i4TmDu9l6QAEp18bsrp7/view?usp=sharing) +![UML](https://drive.google.com/uc?export=view&id=1i69phC6ir_q-i4TmDu9l6QAEp18bsrp7) From 0a26be38fa035be1ddc4b5a149d8a24f9e6f9569 Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Wed, 18 Mar 2020 04:10:07 -0700 Subject: [PATCH 3/7] Update Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a199a7..4533abe 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ Example of adding a note to the database (must use -a or --add) #### UML -![UML](https://drive.google.com/file/d/1i69phC6ir_q-i4TmDu9l6QAEp18bsrp7/view?usp=sharing) +![UML](https://raw.githubusercontent.com/JoelMWatson/data-structures-and-algorithms/master/assets/notes.jpg) From 2f0b9e7535efcf3e3125a81eda3c09f459d16a21 Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Wed, 18 Mar 2020 19:25:51 -0700 Subject: [PATCH 4/7] Update annotations for jsdoc --- index.js | 2 +- lib/input.js | 3 ++- lib/notes.js | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f287a2e..5d68c75 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ 'use strict'; /** - * Simple Notes App + * A simple node.js application with a notes command * @module index */ diff --git a/lib/input.js b/lib/input.js index 3aa2020..a41fd23 100644 --- a/lib/input.js +++ b/lib/input.js @@ -16,7 +16,7 @@ function Input() { builder: { add: { alias: ['a', 'add'], - describe: 'Note title', + describe: 'Note Text', type: 'string', }, }, @@ -32,6 +32,7 @@ function Input() { } /** + * Checks to make sure the input from the user is a valid one * @return {Boolean} if input is a valid command or not */ Input.prototype.valid = function() { diff --git a/lib/notes.js b/lib/notes.js index f2eaf55..c01f887 100644 --- a/lib/notes.js +++ b/lib/notes.js @@ -14,6 +14,7 @@ function Notes() { } /** + * Takes a command from the user and executes the command if it exists * @param command a command recieved from user. */ Notes.prototype.execute = function (command) { @@ -26,7 +27,8 @@ Notes.prototype.execute = function (command) { }; /** - * @param note_text the text to be used to create and add a new note. + * Creates a new note object and then adds that new note object to db + * @param note_text the text to be used to create the note object. */ Notes.prototype.add = function (note_text) { let id = Math.ceil(Math.random() * 999); From cd7e8576879ed63b0286d958f51e9be9e58efa9a Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Wed, 18 Mar 2020 19:57:30 -0700 Subject: [PATCH 5/7] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 806edb8..91da012 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ ### Links and Resources - [submission PR](http://xyz.com) -- [ci/cd](http://xyz.com) (GitHub Actions) -- [back-end server url](http://xyz.com) (when applicable) +- [ci/cd](https://github.com/401-advanced-javascript-joel/notes/runs/518200179) (GitHub Actions) ### Setup From 38a271c09a676d2a814720bd031e17da33fe9fdf Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Wed, 18 Mar 2020 20:07:01 -0700 Subject: [PATCH 6/7] Updating readme and package.json for npm --- README.md | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 91da012..5c5f811 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ ### Links and Resources -- [submission PR](http://xyz.com) +- [submission PR](https://github.com/401-advanced-javascript-joel/notes/pull/1) - [ci/cd](https://github.com/401-advanced-javascript-joel/notes/runs/518200179) (GitHub Actions) +- [NPM](https://www.npmjs.com/package/@fellowjoel/notes) ### Setup diff --git a/package.json b/package.json index 3359449..a76eba6 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "notes", + "name": "@fellowjoel/notes", "version": "1.0.0", "description": "A command line application using Node.js called notes which will allow the user to specify a note (words) to be added to a database.", "main": "index.js", From 62e87dfbe92bd7dd3a5170b00d18171f2c8815d0 Mon Sep 17 00:00:00 2001 From: Joel Watson Date: Thu, 19 Mar 2020 13:35:53 -0700 Subject: [PATCH 7/7] Added missing bin to make executable --- index.js | 2 ++ lib/input.js | 29 ++++++++++++++++------------- package-lock.json | 2 +- package.json | 5 ++++- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 5d68c75..67fbfb9 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,6 @@ +#!/usr/bin/env node 'use strict'; + /** * A simple node.js application with a notes command * @module index diff --git a/lib/input.js b/lib/input.js index a41fd23..2f24898 100644 --- a/lib/input.js +++ b/lib/input.js @@ -11,24 +11,21 @@ const yargs = require('yargs'); */ function Input() { let formatted = yargs.command({ - command: 'notes', - describe: 'Adds a note to the notes library', + command: ['add','a'], + describe: 'Adds a note to the notes library.', builder: { - add: { - alias: ['a', 'add'], - describe: 'Note Text', + note: { + describe: 'A text note to be added to the library.', type: 'string', }, }, }).argv; - - if (formatted._ === 'notes') { - if (formatted.add) { - this.command = { action: 'add', payload: formatted.add }; - } else { - this.command = {}; - } + if (formatted.add || formatted.a) { + this.command = { action: 'add', payload: formatted.add || formatted.a }; + } else { + this.command = {}; } + } /** @@ -38,7 +35,13 @@ function Input() { Input.prototype.valid = function() { if (!this.command) return false; if (!this.command.action) return false; - return true; + switch (this.command.action) { + case 'add': + return typeof this.command.payload === 'string'; + default: + break; + } + return false; }; module.exports = Input; diff --git a/package-lock.json b/package-lock.json index 8205184..b0a8a46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "notes", + "name": "@fellowjoel/notes", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index a76eba6..779ebde 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,11 @@ { "name": "@fellowjoel/notes", - "version": "1.0.0", + "version": "1.0.1", "description": "A command line application using Node.js called notes which will allow the user to specify a note (words) to be added to a database.", "main": "index.js", + "bin": { + "notes": "./index.js" + }, "scripts": { "test": "jest --verbose --coverage", "start": "node index.js",