neuefische / web-exercises

Session exercises
MIT License
17 stars 33 forks source link

web exercises

A monorepo containing exercises, challenges, demos and starters for the neue fische web bootcamps. All of the exercises are designed to work locally.

Structure of this Repository

Sessions and Exercises

A session is a collection of exercises that are used in a specific bootcamp session.

An exercise is any form of exercise, challenge, demo or starter that is used in the web bootcamps.

The folder structure is as follows:

sessions/<session-name>/<exercise-name>

Warning
Avoid nesting exercises in folders below this level. It makes it harder to discover exercises and to update them using tooling.

Templates

A template is a folder from which a new exercise can be created but than can also be used as a starter for a new project outside of this repository.

The folder structure is as follows:

templates/<template-name>

Warning
Never edit templates directly. They are created from recipes.

Recipes

A recipe is used to create (cook) templates. It contains instructions and files that are used by the cook script. If you want to change a template, you have to change its recipe instead.

The folder structure is as follows:

recipes/<recipe-name>

Read more about recipes to learn how to create and edit them.

Branch Naming Convention

The branches in this repository follow the following naming convention:

<session-name>_<exercise-name>

Note
You can do multiple exercises in one branch (e.g. demo-start and demo-end) if it makes sense. Pick a unique branch like <session-name>_demo. Note that the create script will not be able to automatically detect the correct exercise name in that case.

Create a new exercise

To create a new exercise run the following command:

npm run create

Note
Make sure to run this command from the root of the repository and to run npm i before.

This will ask you for the session name, exercise name and exercise type.

Note
If you follow the branch naming convention (session-name_exercise-name), the create script will automatically detect the session and exercise name from the branch name.

This repository contains templates for most types of exercises.

Creating a PR

To make it less cumbersome to create a PR for a new exercise once you're done, you can use the following command that copies all the necessary information to your clipboard. (You have to select the session and exercise folder.)

npm run get-pr

Getting Markdown for Curriculum

You can obtain a copyable markdown snippet for an exercise by running the following command:

npm run get

Note
You usally don't need this command as the markdown for the curriculum is already included in the PR markdown.

Available Templates

The following types of templates are available.

Empty

created via recipes/empty

A template that does not contain any code.

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type Empty

β†’ Use this template as a starter

HTML, CSS and JavaScript (with Jest support)

created via recipes/html-css-js

A template that contains HTML, CSS and JavaScript files with jest support.

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type HTML, CSS and JavaScript (with Jest support)

β†’ Use this template as a starter

HTML and CSS

created via recipes/html-css

A template that contains HTML and CSS files.

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type HTML and CSS

β†’ Use this template as a starter

JavaScript (with Jest support)

created via recipes/js

A template that contains only JavaScript files with jest support.

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type JavaScript (with Jest support)

β†’ Use this template as a starter

Minimal React

created via recipes/react-minimal

A template that contains a minimal React app. It uses react-scripts but only contains the bare minimum files from Create React App.

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type Minimal React

β†’ Use this template as a starter

React

created via recipes/react

A template from executing create-react-app to create a new React app.[^1]

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type Create React App

β†’ Use this template as a starter

Next.js (incl. Styled Components and Jest)

created via recipes/next

A template from executing npx create-next-app to create a new Next.js app. Our variant also includes Styled Components, Jest and SVGR.

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type Next.js (incl. Styled Components and Jest)

β†’ Use this template as a starter

Node.js Server (with Jest support)

created via recipes/node-server

A template that contains a Node.js server with Jest support.

πŸ“ Create a new exercise inside this repository

npm run create β†’ Select type Node.js Server (with Jest support)

β†’ Use this template as a starter

Exercise requirements

All exercises must at least contain:

Review new or changed exercises

All exercises must be reviewed before they are merged into the main branch. Create a pull request on GitHub and add the needs review label.

Exercises must be reviewed by at least one neue fische web coach.

Note
Exercises deliberately do not have to have passing tests to be merged. It is also fine to merge exercises with linting errors. Failing tests and linting errors can be part of the exercise itself.

Access exercises or templates

There a two ways to access the exercises or templates:

Locally

We are using ghcd (GitHub Clone Directory) which is a tool that "clones" (or rather downloads) a subdirectory of a GitHub repository. You can share the command containing the URL to the exercise folder on GitHub.

npx ghcd@latest neuefische/web-exercises/tree/main/sessions/js-array-methods/map

Note
While reviewing an exercise, you can share the command pointing to the respective branch. This way exercises can be reviewed locally before they are merged into the main branch.

Warning
ghcd does not support branch names containing slashes.

You can append the -i flag to the command to let ghcd initialize a new git repository in the "cloned" folder. This is recommended for all exercises in from the curriculum after git has been introduced.

Local development

To run commands in a workspace of the monorepo (an exercise folder) on your local machine:

  1. make sure you have run npm i in the root of this repository
  2. cd into the folder (cd sessions/session-name/exercise-name)
  3. run the script of you choice (npm run test)