Git and GitHub
In this first assignment, the goal is to gain experience with Git. This is also an opportunity to refresh your JavaScript skills from CS 290, as JavaScript will be the primary language for this course. If you’re already familiar with Git and JavaScript, this should be straightforward.
The following steps are designed to help you become comfortable with Git. Your grade will be based on your Git usage, not the final result.
Don’t forget to check the grading rubric and submit your GitHub Classroom repository link in the Canvas assignment.
If you need a refresher on Git, please refer to the lecture notes.
Create a Local Git Repo and Make Some Commits
While most of the time you might start with a remote repository on GitHub, this assignment will begin with a local repository. Your first task is to create a simple Node.js project and use Git to manage its development.
Here are the steps:
-
On your development machine, create a new project directory (e.g.,
assignment-1/
). -
Initialize it as a Git repository using
git init
. -
In your
assignment-1/
directory, runnpm init
to initialize the project as an NPM package. Follow the prompts and provide reasonable answers (there are no wrong answers). -
The
npm init
command creates apackage.json
file. Add this file to version control and COMMIT it. -
Create a file named
.gitignore
in yourassignment-1/
directory. -
Add the following line to ignore the dependency cache created by NPM:
node_modules/ -
Add the
.gitignore
file to version control and COMMIT it. This is a special file that tells Git to ignore certain files and directories. We often don’t want to track build artifacts, dependencies, or other files that can be generated from the source code. -
Create a file named
asciiArt.js
in yourassignment-1/
directory. This file will contain your ASCII art generating program. -
Ensure your program can capture the string the user wants to convert to ASCII art. Allow the user to pass the string on the command line, like this:
Terminal window node asciiArt.js "This is the string to turn into ASCII art"In a Node.js program, access command-line arguments via
process.argv
. Capture the first argument after the program name and print it to the terminal usingconsole.log()
. Refer to the Node.js documentation for details onprocess.argv
. -
Add the initial version of
asciiArt.js
to version control and COMMIT it. -
Run the following command in your terminal to install the Figlet library:
Terminal window npm install figletAfter installation, a
node_modules/
directory and apackage-lock.json
file will be created. Also,package.json
will be modified. -
Modify
asciiArt.js
to use Figlet to generate ASCII art from the user-provided string and print the result. Refer to Figlet’s documentation page. -
Once your program generates ASCII art successfully, COMMIT the following:
- Your modifications to
asciiArt.js
- The modifications to
package.json
made when you installed Figlet - The new
package-lock.json
file
- Your modifications to
-
Run
git log
to print your project’s commit history. -
Take a screenshot of the entire commit history and save it in your
assignment-1/
directory. -
Add the screenshot to version control and make a final COMMIT.
Mirror Your Local Repo on GitHub
Your second task is to mirror your Git repo on GitHub. Here are the steps:
-
Find and click the link to GitHub Classroom in the Canvas assignment.
-
This link will direct you to a page where you’ll select your name. This connects your real name with your GitHub username in our GitHub Classroom, helping the TAs and instructor find your code.
-
After selecting your name, you’ll be brought to a page with an “accept this assignment” button. Clicking this generates a private repo for you in the CS 362 GitHub Classroom. After a few seconds, the page will provide a link to that repo on GitHub.
-
Follow the provided link to navigate to your repo. Copy either the HTTPS or SSH URL for the GitHub repo and use it to set up that repo as a remote for your local
/assignment-1
directory. -
Push the commits from your local repo to GitHub.
Once you see all your commits on GitHub, your assignment is submitted. Please do submit your GitHub Classroom link in the Canvas assignment.