This is a command line application that will allow the user to query for 5 books using the Google Books API and save/remove them to a personal bookshelf.
These instructions assume that you have already downloaded Git and Node. These are some specific versions I am using:
- To clone this repo, simply open up your terminal and type in:
git clone [email protected]:VictorHeDev/google-books-cli.git
(or copy and paste) - Use your CLI and
cd
into the new directory that was downloaded. For example:cd google-books-cli
- Install the dependencies by running
npm install
ornpm i
- Run the application by typing
node .
when you are located in the root directory- If you would like to use it anywhere, you can globally install it:
sudo npm install -g .
and then runbooks
- If you would like to run the testing suite, run
npm test
- If you would like to use it anywhere, you can globally install it:
Axios
: used to simplify HTTP requests and parse JSON
Boxen
: used to style Welcome message and Reading List message
Chalk
: used to make the CLI colorful, pretty, and more pleasant to use
Dotenv
: used to hide API key (which later I found out I didn't need to make GET requests)
esm
: used to write ES6 code
Figlet
: used with Boxen to create pretty ASCII art text
Inquirer
: (very difficult to spell) used to interact with the CLI and display multiple choice responses instead of having to type directly into the interface
Jest
: first time trying this JavaScript testing suite
- Type in query and it should display a list of 5 books matching that query
- First create the initial file structure and research which dependencies I might want to add
- Make an API key in order to use the Google Books API and hide it away into a .env file that will not be pushed to GitHub
- Later learned that I do not need an API key in order to make GET requests
- Create a welcome message
- I can use the Axios library in order to abstract away having to parse the JSON data that is being sent back
- Validate and format request and response
- I specifically need to save the information about the book's title, author(s), and publisher
- A user should be able to select a book from the 5 displayed to save to a "Reading List"
- What ways can I save this?
- Array: which will disappear once the user closes out of the app -- not ideal
- In some sort of .txt, .csv, or .json file?
- What ways can I save this?
- Viewing a "Reading List" with all the books the user has selected from their queries--this is a local Reading List that is not attached to Google Book's account
- Need to use Inquirer to pull up the list
- Need to parse through the list and display it in the CLI
- Weather CLI
- Google Translate CLI
- Todo List CLI
- Joke & Quote CLI
- Figlet fonts
- More weather
- GitHub CLI
- How to use Chalk
- More Chalk
- Having to write JavaScript using ES5 syntax instead of usual ES6 (especially for import/export)
- Choosing a CLI tool -- chose between prompt.js, inquirer.js, commander.js
- Choosing between a flag interface or a prettier CLI with space and arrow keys
- Ultimately chose inquirer because I thought it would be the most fun to learn and has the best UI. I like how you can have many different options of inputs to choose from. Namely, I knew that I wanted a main menu interface, a way to select one or multiple books, and even though it wasn't totally necessary I wanted an option to reset the reading list.
- When using inquirer arrow key prompt, the chalk would override selected color (main menu highlight gets overridden by chalk)
- Edge cases and bugs such as parsing what is actually returned from the Google Books API
- Had to downgrade the chalk.js dependency version so I can use the require syntax in the top of the file (see their GitHub repo for more info)
- Ran into issues using esm and writing tests in jest. I like using the ES6 import/exports, but I also wanted to implement TDD in this project
- Also had to downgrade the boxen version to use require and not import/export using ES6
- Use chalk.js to create thematic logs
- Red for errors
- Green for success messages
- Write validator for query
- Needs to check for alphanumeric and spaces
- Regex: /^[a-z0-9]+$/i // used for loop instead for speed
- Check to see multiples of the same book are already in the reading list before adding
- Book output
- Figure out what to do and the colors needed
- set printType to "books" because we don't want box set collections
- Reading List
- If reading list is blank when checked, let the user know to add in more books
- Title by Author(s) published by Publisher format
- If Author(s) or Publisher is undefined, return an N/A
- Address code review feedback
- Edit the checkForValidTitle function to accept certain punctuation characters like: ! ? - : . ,
- Small bug related to entering a search term where one or more of the returned books do not have any listed authors - try using 'foo'
- Fixed this small bug -- I initially thought that if there's no author then it would send me an empty array. If there's no author then it would actually send back
undefined
so I was checking the length ofundefined
which does not exist
- Fixed this small bug -- I initially thought that if there's no author then it would send me an empty array. If there's no author then it would actually send back
- If entered a string of random characters which returns no results, an error message is shown but the prompt to select books from a list is still there. Strange user experience behavior
- Implemented an early return to solve the behavior
- Using 'nom test' fails to run the testing suite. See if I can get past this issue.
- I don't see a problem on my end, but I will see if I can get some others to clone the repo and test this on their end
- Add steps to resolve this issue in README
- Delete commented out code and overall cleanup of code