The store’s site made it through a busy holiday week, one merge conflict and a reverted banana price included. After this lesson’s setup commit, no change goes straight onto main anymore. Each one waits in a pull request first, where you can read it before it reaches the site.
In this lesson, you’ll pick up the starting code from a ZIP or bring your own repository up to date, push it to GitHub, and file the week’s three jobs as issues. Start with what the project already holds.
Look Back at the Site So Far
The first three courses built an npm project with a Vite dev server, shared through a public generic-grocery repository on GitHub. The same habits still apply in this course. Run git status and git diff before you stage, stage files by name, and pull before you push.
This course starts from that site plus one setup commit, “Plan the move to pull requests”, which touches three files:
-
README.mdsays every change goes through a pull request. -
scripts/check.jsalso checks for a formatter, a linter, and pull requests. -
src/lib/closing-soon.jsis the previous developer’s unfinished “Closing soon” notice, unused so far.
Get the Starting Code
Both routes start from the same download:
The ZIP’s generic-grocery folder includes its hidden .git folder, so the history comes along. To keep your repository from the last course, follow the second route. Otherwise, start from the ZIP.
Start From the ZIP
Extract the ZIP, open the generic-grocery folder in VS Code, and open a terminal with Terminal → New Terminal. Install the packages and create the ignored .env file from its example:
$ npm install
$ cp .env.example .env
On macOS, leave npm’s blocked fsevents install script unapproved, because the site doesn’t need it. In .env, replace the placeholder with the store’s key, curb_pub_fake_7Rk3vNw5. Like every key in this course, it’s fake.
The ZIP has no GitHub repository, so create one as in the last course. Choose New repository from the + menu, name it generic-grocery, and make it Public. Leave the README, .gitignore, and license options off. Then push main to its HTTPS address:
$ git remote add origin https://github.com/generic-grocery-dev/generic-grocery.git
$ git push -u origin main
Use your own login in place of generic-grocery-dev. Git asks for your GitHub username, then for a password. As the password, paste a fine-grained token for this repository with Contents set to “Read and write”. The last course showed how to create one. If your credential helper already holds a token, then Git won’t ask. The push ends with branch 'main' set up to track 'origin/main'.
Note: If your account already has a generic-grocery repository, then the other route is shorter. To start fresh anyway, rename the old one under its Settings and give your token access to the new one under Repository access.
Keep Your Own Repository
On this route, you bring in only the setup commit’s three files. Extract the ZIP outside your project, such as in Downloads, because the folder has the same name. Then copy the files from a terminal in your own generic-grocery folder, adjusting ~/Downloads if needed:
$ cp ~/Downloads/generic-grocery/README.md .
$ cp ~/Downloads/generic-grocery/scripts/check.js scripts/
$ cp ~/Downloads/generic-grocery/src/lib/closing-soon.js src/lib/
$ git status
On branch main
Your branch is up to date with 'origin/main'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
modified: scripts/check.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/lib/closing-soon.js
no changes added to commit (use "git add" and/or "git commit -a")
Before you stage, read the changes. git diff README.md shows a new table row for closing-soon.js and a To do section that sends every change through a pull request. git diff scripts/check.js is long, so skim it and press Q to leave the pager. The untracked closing-soon.js isn’t in git diff, so open it in VS Code. It’s unfinished on purpose, because you’ll finish it as part of the week’s second issue.
Stage all three by name, because git commit -am only picks up tracked files and would quietly leave closing-soon.js behind:
$ git add README.md scripts/check.js src/lib/closing-soon.js
$ git commit -m "Plan the move to pull requests"
[main acdb4b0] Plan the move to pull requests
3 files changed, 366 insertions(+), 64 deletions(-)
create mode 100644 src/lib/closing-soon.js
$ git push
Your hash will differ, because it depends on the author and time. This is the last commit that goes straight onto main.
File the Week’s Issues
Issues never travel in a ZIP or a push, so you create them on GitHub. On your repository’s Issues tab, click New issue for each of these, with the bold text, minus its colon, as its title and the rest as its description:
-
Add ESLint and Prettier: Every change now goes through a pull request. Add a formatter and a linter first, so each pull request is checked the same way.
-
Show a closing-soon notice on the home page: In the store’s last hour, the home page should say the store is closing soon.
src/lib/closing-soon.jsis the previous developer’s unfinished start on it. -
Add a Christmas turkey pre-order page: Shoppers can pre-order a fresh turkey for pickup December 22 to 24, at $2.49 a pound. An AI assistant has drafted the page.
Copy each title exactly, because the check script looks issues up by title, whatever their numbers are.
Check That Everything Works
First, run npm run dev. Then hold Ctrl—or Cmd on macOS—and click the Local address to open the site in VS Code’s integrated browser. The home page shows the “Open now” badge and the store’s hours. Press Ctrl+C to stop the server.
Second, check that the history ends in the setup commit:
$ git log --oneline -6
e42b10e (HEAD -> main, origin/main) Plan the move to pull requests
e1d375f Mark bananas down to 49¢ a pound
7ec672f Revert "Mark bananas down to 49¢ a pound"
dcb9111 Mark bananas down to 49¢ a pound
7a43cc7 Merge branch 'main' of https://github.com/generic-grocery-dev/generic-grocery
6d8d05e Open at 8 a.m. on Thanksgiving
If the log ends in (END) or :, then it opened in a pager, and you can press Q to get your prompt back. origin/main next to main means GitHub has your commit.
Third, check the whole project. If an issue you created a moment ago is missing, then wait a minute and run the check again, because GitHub’s answers can lag behind. Here’s the end of the report:
$ npm run check
...
✔ GitHub has your public repository generic-grocery-dev/generic-grocery.
✔ GitHub's main is the same commit as yours.
! Issue #1 "Add ESLint and Prettier" is still open.
...
! There's no pull request "Add a Christmas turkey pre-order page" yet.
Next step: push the draft's branch, turkey-preorder, and open its
pull request with that title.
✔ Everything is committed.
All checks passed, with 4 thing(s) worth a look.
Every check passes. The four lines marked ! refer to the three issues and the turkey pull request, which make up this week’s work. Your report shows your own name and login. If you kept your own repository, then its issue numbers are higher.
The longest lines are wrapped here for display:
$ npm run check
npm notice run [email protected] check
npm notice run node scripts/check.js
Checking the Git repository in /Users/martin/projects/generic-grocery
✔ Git is installed (git version 2.43.0).
✔ The project folder is a Git repository.
✔ Your commits are labeled Martin Breuss <[email protected]>.
✔ .gitignore keeps notes.txt out of the repository.
✔ .gitignore keeps .DS_Store out of the repository.
✔ The history has 32 commit(s).
✔ npm is version 12 or later.
✔ You're on the main branch.
✔ package.json has "type": "module".
✔ package.json has a "check" script, so npm run check runs this report.
✔ .gitignore keeps node_modules/ out of the repository.
✔ package-lock.json is tracked, so every copy installs the same package versions.
✔ .gitignore keeps .env out of the repository.
✔ .env.example is committed, with a placeholder instead of the key.
✔ No tracked file holds a Generic Curbside secret key (curb_sec_...).
✔ origin is your GitHub repository, generic-grocery-dev/generic-grocery.
✔ main pushes to and pulls from origin/main.
✔ No file has leftover conflict markers.
✔ Thanksgiving's hours keep both changes: 8 a.m. to 1 p.m.
✔ GitHub has your public repository generic-grocery-dev/generic-grocery.
✔ GitHub's main is the same commit as yours.
! Issue #1 "Add ESLint and Prettier" is still open.
Next step: once its work is on main, close it: Closes #1 in a
pull request's description, or close it on GitHub. If you just
did, wait a minute: GitHub's answer can be a minute old.
! Issue #2 "Show a closing-soon notice on the home page" is still open.
Next step: once its work is on main, close it: Closes #2 in a
pull request's description, or close it on GitHub. If you just
did, wait a minute: GitHub's answer can be a minute old.
! Issue #3 "Add a Christmas turkey pre-order page" is still open.
Next step: once its work is on main, close it: Closes #3 in a
pull request's description, or close it on GitHub. If you just
did, wait a minute: GitHub's answer can be a minute old.
! There's no pull request "Add a Christmas turkey pre-order page" yet.
Next step: push the draft's branch, turkey-preorder, and open its
pull request with that title.
✔ Everything is committed.
All checks passed, with 4 thing(s) worth a look.
A line marked ✘ comes with a Next step, so follow it and run the check again. If a line puzzles you, then the button below opens a chat with the mentor and fills in a question. Paste your report after it:
The site runs, GitHub’s main ends in “Plan the move to pull requests”, and the first issue asks for a formatter and a linter. In the next lesson, you’ll tackle that issue on its own branch and format the whole project with Prettier.