Go to GitHub and create a new repository for yourself namedfirst-tutorial
After you click create, it takes you to the repo. Copy the URL for the repo, it should look like:https://github.com/your-username/first-tutorial.git
Open a terminal locally and find a place to clone your repo. Entergit clone https://github.com/your-username/first-tutorial.git with the repo URL you copied in place of that URL to clone it
Create a.gitignore file in your repo and add this to it:
node_modules
package-lock.json
Add anything else that may interfere such as.DS_Store if you are on a mac.
This is the file that describes the structure of a tutorial. It contains all the lessons, lesson titles, descriptions, test text and all the other verbiage that will be displayed to a user. Enter this markdown into the file and save it:
# Introduction
This is an introduction to your tutorial. It will show up on the first page when your tutorial is started.
## 1. Create index.html
> Optional summary for Level 1
Here's where you can put a description, examples, and instructions for the lesson.
### 1.1 Level 1 Step 1
This is the test text. Create an`index.html` file to pass this lesson.
#### HINTS
- This is a hint to help people through the test
- Second hint for 1.1, don't worry if the hints don't show up yet
The above tutorial has an introduction page and one lesson.
Create and checkout a new orphan branch withgit checkout --orphan v0.1.0.
This will make a branch that isn't created from master, so it has no commit history. It will hold the tests for your tutorial. Each test is its own commit. You can also add an optional commit for a solution to each test.
Check yourgit status
Delete the tutorial file from this branch withgit rm -f TUTORIAL.md
These scripts will be for CodeRoad and for you to test things.
From the terminal, in yourcoderoad folder, runnpm install --save mocha mocha-tap-reporter to install some depenedencies
Go back to the main repo folder and add your changes withgit add .
Commit your files withgit commit -m "INIT"
The message ofINIT in all caps is necessary. This message is used to add project setup files and anthing else you want to add before a user starts the tutorial.
Push and Create a branch on your remote withgit push -u origin v0.1.0
Go back to the main repo folder and add the test file to be committed withgit add coderoad/.
Commit it withgit commit -m "1.1"
That stands for "Lesson 1 Step 1 Setup & Tests". You can put an additional note after it, but it has to start with those letters so CodeRoad knows that this is the test for the 1.1 step.
After that, add the index file withgit add index.html
Commit the file withgit commit -m "1.1S"
That stands for "Lesson 1 Step 1 Solution", and it's the solution to the test.
Take a quick look at the commit history withgit log. You can see the messages there, they align with the titles you put in the markdown and there's one commit for the test (1.1) and an optional commit for the solution (1.1S)
Push your changes to GitHub withgit push origin v0.1.0
Go back to your master branch withgit checkout masterYou can think of these two branches like separate repositories, the branches will never merge and the files will always be different, even if some look the same.
Create a new file namedcoderoad.yaml and add this to it:
version:'0.1.0'
config:
testRunner:
command: ./node_modules/.bin/mocha
args:
tap:--reporter=mocha-tap-reporter
directory: coderoad
setup:
commands:
- cd coderoad&& npm install
repo:
uri: https://github.com/moT01/first-tut
branch: v0.1.0
dependencies:
-name: node
version:'>=10'
levels:
-id:'1'
steps:
-id:'1.1'
Replace therepo uri URL with your GitHub repo, note that it's just the username and repo in the URL. This file links everything together. You can see the repo URL and the branch that you created. And the1. and1.1 ID's that match the markdown. You can also add commands that will run when a lesson has started, as well as a host of other things.
Add this withgit add .
Commit it withgit commit -m "create yaml"
The commit messages on master can be whatever you want.
You created the three things a tutorial needs from you; the markdown, the commits, and the yaml. Now you can build it. If you haven't installed the CodeRoad CLI tools, usenpm install -g @coderoad/cli to do so.
Runcoderoad build from the terminal on the master branch
If you didn't get any errors, it will have created atutorial.json file which is what CodeRoad uses to find all the files, commits, and instructions you created. You should see it in your repo now.
Success! You can see the introduction page. It may not be a bad idea to take a look at the markdown file again to see it next to the running tutorial.
Notice that when you click thestart button, you can see thatnpm install is run in thecoderoad folder, and the dependencies are installed. This is an instruction in yourcoderoad.yaml file.
After you click start, open up any file and presscmd+s to save. This will run the tests. They should fail. After that, create theindex.html file, and save it. The tests should run and pass this time 😄
Keep this VS Code window open and go back to your other one.