diff --git a/docs/docs/config-yml.md b/docs/docs/config-yml.md index 51e11123..9ad16b4d 100644 --- a/docs/docs/config-yml.md +++ b/docs/docs/config-yml.md @@ -40,10 +40,6 @@ config: directory: coderoad ## Commits to load to setup the test runner. Optional. setup: - ## A list of commits to load to setup the tutorial - commits: - - commit1 - - commit2 ## A list of commands to run to configure the tutorial commands: - npm install @@ -57,7 +53,7 @@ config: ## The uri path to the repo containing the code commits. Required. uri: https://github.com/coderoad/fcc-learn-npm ## The branch on the repo uri that contains the code commits. Required. - branch: v0.3.0 + branch: v0.4.1 ## A list of tutorial dependencies to ensure the environment is setup for the tutorial. Optional. ## The dependencies will be checked by running `dependency.name` --version and comparing it to the version provided. ## @@ -68,31 +64,23 @@ config: version: '>=10' ## A level is made up of levels: - - id: L1 + - id: '1' steps: ## Example 1: Opening files - - id: L1S1 + - id: '1.1' ## Setup for the first task. Required. setup: ## Files to open in a text editor when the task loads. Optional. files: - package.json - ## Commits to load when the task loads. These should include failing tests. Required. - commits: - - commit3 ## Solution for the first task. Required. solution: ## Files to open when the solution loads. Optional. files: - package.json - ## Commits that complete the task. All tests should pass when the commits load. These commits will not be loaded by the tutorial user in normal tutorial activity. - commits: - - commit4 ## Example Two: Running commands - - id: L1S2 + - id: '1.2' setup: - commits: - - commit5 ## CLI commands that are run when the task loads. Optional. commands: - npm install @@ -102,12 +90,10 @@ levels: commands: - npm install ## Example Three: Watchers - - id: L1S3 + - id: '1.3' setup: files: - package.json - commits: - - commit7 ## Listeners that run tests when a file or directory changes. watchers: - package.json @@ -118,25 +104,14 @@ levels: commits: - commit8 ## Example Four: Subtasks - - id: L1S4 + - id: '1.4' setup: - commits: - - commit8 commands: ## A filter is a regex that limits the test results - filter: '^Example 2' ## A feature that shows subtasks: all filtered active test names and the status of the tests (pass/fail). - subtasks: true - solution: - commits: - - commit9 - - id: L2 + - id: '2' steps: - - id: L2S1 - setup: - commits: - - commit10 - solution: - commits: - - commit7 + - id: '2.1' ``` diff --git a/docs/docs/create-a-practice-tutorial.md b/docs/docs/create-a-practice-tutorial.md index 709e087d..0fdfeae6 100644 --- a/docs/docs/create-a-practice-tutorial.md +++ b/docs/docs/create-a-practice-tutorial.md @@ -9,17 +9,21 @@ sidebar_label: Create a Practice Tutorial Follow these instructions carefully to create your first CodeRoad tutorial. ### Create a repo + - Go to GitHub and create a new repository for yourself named `first-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. Enter `git 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: + ```md node_modules package-lock.json ``` + Add anything else that may interfere such as `.DS_Store` if you are on a mac. ### Create the markdown + - Create a new file in your repo named `TUTORIAL.md`. 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: @@ -29,42 +33,48 @@ This is the file that describes the structure of a tutorial. It contains all the This is an introduction to your tutorial. It will show up on the first page when your tutorial is started. -## L1 Create index.html +## 1. Create index.html -> Optional summary for L1 +> Optional summary for Level 1 -Here's where you can put a description, examples, and instructions for the lesson. +Here's where you can put a description, examples, and instructions for the lesson. -### L1S1 Level 1 Step 1 +### 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 L1S1, don't worry if the hints don't show up yet +- 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. ### Commit to github + - Back in the terminal, add all your new files to be committed with `git add .` - Commit them with `git commit -m "create markdown"` - Push them to github with `git push origin master` ### Create a version branch + - Create and checkout a new orphan branch with `git 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 your `git status` - Delete the tutorial file from this branch with `git rm -f TUTORIAL.md` ### Create your project files + This branch is also where users create their projects, modify files for a tutorial, and most anything they need to do. + - Make a new folder named `coderoad` on your branch. This folder will hold as much of the CodeRoad stuff as it can so users aren't confused with extra files in their projects. -- Go to the `coderoad` folder in your terminal and run `npm init`. Press enter until you are through the setup. + +- Go to the `coderoad` folder in your terminal and run `npm init`. Press enter until you are through the setup. - Open the `package.json` file you just made and make it look like this... ```js @@ -90,41 +100,43 @@ These scripts will be for CodeRoad and you to test things. - Commit your files with `git commit -m "INIT"` The message of `INIT` 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 with `git push -u origin v0.1.0` + +- Push and Create a branch on your remote with `git push -u origin v0.1.0` ### Create the first test + - Go in the `coderoad` folder and create new folder named `test` in it - Create a file named `first-tutorial.test.js` in the `test` folder - Add this to the file: ```js -const assert = require('assert'); -const fs = require('fs'); -const util = require('util'); -const path = require('path'); +const assert = require('assert') +const fs = require('fs') +const util = require('util') +const path = require('path') -const readdir = util.promisify(fs.readdir); +const readdir = util.promisify(fs.readdir) const getRootDir = async (dir = process.cwd()) => { - const pathToRoot = path.join(dir, '..'); - const rootDir = await readdir(pathToRoot); + const pathToRoot = path.join(dir, '..') + const rootDir = await readdir(pathToRoot) if (!rootDir) { - throw new Error(`Could not find folder ${pathToRoot}`); + throw new Error(`Could not find folder ${pathToRoot}`) } - return rootDir; + return rootDir } -describe("first-tutorial folder", () => { - let rootDir; +describe('first-tutorial folder', () => { + let rootDir before(async () => { - rootDir = await getRootDir(); - }); + rootDir = await getRootDir() + }) it('should have an index.html file', async () => { assert(rootDir.indexOf('index.html') >= 0) - }); -}); + }) +}) ``` This will be the test for the one lesson in your tutorial. You can see that it checks for the existence of an `index.html` file in the root folder. @@ -132,25 +144,30 @@ This will be the test for the one lesson in your tutorial. You can see that it c - In the `coderoad` folder, run `npm run programmatic-test` from the terminal It will fail since `index.html` doesn't exist. + - Create an `index.html` file in the main repo folder and run the test again It should pass this time. So when a user creates the `index.html` file, this test will run, and the lesson will pass. ### Commit your first test + - Go back to the main repo folder and add the test file to be committed with `git add coderoad/.` -- Commit it with `git commit -m "L1S1Q"` +- Commit it with `git 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. -That stands for "Lesson 1 Step 1 Question". 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 L1S1 step. - After that, add the index file with `git add index.html` -- Commit the file with `git commit -m "L1S1A"` +- Commit the file with `git commit -m "1.1S"` -That stands for "Lesson 1 Step 1 Answer", and it's the solution to the test. -- Take a quick look at the commit history with `git 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 (`L1S1Q`) and an optional commit for the solution (`L1S1A`) +That stands for "Lesson 1 Step 1 Solution", and it's the solution to the test. + +- Take a quick look at the commit history with `git 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 with `git push origin v0.1.0` ### Create the YAML file + - Go back your your master branch with `git checkout master` -You 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. + You 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 named `coderoad.yaml` and add this to it: ```yml @@ -164,36 +181,41 @@ config: commands: - npm install directory: coderoad - repo: + repo: uri: https://github.com/moT01/first-tut branch: v0.1.0 dependencies: - name: node version: '>=10' levels: - - id: L1 + - id: '1' steps: - - id: L1S1 + - id: '1.1' setup: subtasks: false ``` -Replace the `repo 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 the `L1` and `L1S1` id's that match the markdown. You can also add commands that will run when a lesson is started, as well as a host of other things. +Replace the `repo 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 the `1.` and `1.1` id's that match the markdown. You can also add commands that will run when a lesson is started, as well as a host of other things. - Add this with `git add .` - Commit it with `git commit -m "create yaml"` The commit messages on master can be whatever you want. + - Push it to github with `git push origin master` ### Build the config.json file + 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, use `npm install -g @coderoad/cli` to do so. + - Run `coderoad build` from the terminal on the master branch If you didn't get any errors, it will have created a `tutorial.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. ### Open your tutorial + To check out your tutorial, install the CodeRoad extension to VS Code if you haven't already + - Open a new VS Code window - Put a **single empty folder** in the workspace - Open the command palette with `ctrl+shift+p` @@ -204,7 +226,8 @@ To check out your tutorial, install the CodeRoad extension to VS Code if you hav - Find the `tutorial.json` file that you created in your repo folder and upload it ### Review -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. + +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 the `start` button, you can see that `npm install` is run in the `coderoad` folder, and the dependencies are installed. This is an instruction in your `coderoad.yaml` file. @@ -213,93 +236,105 @@ After you click start, open up any file and press `cmd+s` to save. This will run Keep this VS Code window open and go back to your other one. ### Add a second lesson + Your tutorial probably needs more than one lesson. + - Go back to the markdown file and add this at the bottom (make sure there's an empty line between the two lessons): ```md -## L2 Add DOCTYPE +## 2. Add DOCTYPE > Add a DOCTYPE to an HTML file HTML files should have a `DOCTYPE`. You can add one at the top of the `index.html` file like this: ``. -### L2S1 +### 2.1 Add the DOCTYPE #### HINTS -* Add `` at the top of `index.html` and save the file +- Add `` at the top of `index.html` and save the file ``` -#### Use git to: +#### Use git to + - Add all the files - Commit the files with any message - Push the changes to github ### Add second lesson test + - Checkout your version branch again - Add a new test to your `.test` file below the other one, it can look like this: ```js -const readFile = util.promisify(fs.readFile); +const readFile = util.promisify(fs.readFile) const getIndexFile = async (dir = process.cwd()) => { - const pathToIndex = path.join(dir, '..', 'index.html'); - const indexFile = await readFile(pathToIndex); + const pathToIndex = path.join(dir, '..', 'index.html') + const indexFile = await readFile(pathToIndex) if (!indexFile) { - throw new Error(`Could not find ${pathToIndex}`); + throw new Error(`Could not find ${pathToIndex}`) } - return indexFile; + return indexFile } -describe("index.html", () => { - let indexFile; +describe('index.html', () => { + let indexFile before(async () => { - indexFile = await getIndexFile(); - }); + indexFile = await getIndexFile() + }) it('should have a DOCTYPE', () => { - assert(//i.test(indexFile)); - }); -}); + assert(//i.test(indexFile)) + }) +}) ``` -That should check if `` was added to the `index.html` file. +That should check if `` was added to the `index.html` file. + - Run the test to make sure it fails (`npm run programmatic-test` from the `coderoad` folder) There should be one passing and one failing test + - Add `!` to the `index.html` file - Run the test again to see if it passed after adding that ### Commit second test -#### Go to the root folder and: + +#### Go to the root folder and + - Add **only** the `.test` file to git to be committed -- Commit it with a message of "L2S1Q" +- Commit it with a message of "2.1" - Add the `index.html` file to be committed -- Commit it with a message of "L2S1A" +- Commit it with a message of "2.1S" - Push your changes to github to your `v0.1.0` branch ### Update the YAML + You added another lesson in the markdown, and the tests for it. Just need to update the YAML + - Go back to the master branch - Add this at the bottom of the `.yaml` file, make sure the indentation is perfect and aligns with the first lesson: ```yml - - id: L2 - steps: - - id: L2S1 - setup: - files: - - index.html +- id: '2' + steps: + - id: '2.1' + setup: + files: + - index.html ``` - Add, Commit, and Push your changes ### Rebuild + - Run `coderoad build` again on your master branch (cross your fingers). ### Restart the tutorial + - Go back to your CodeRoad tutorial if its still open - In order to start over, close CodeRoad - Delete All the files from the workspace, but leave the top level folder there diff --git a/docs/docs/edit-tutorial.md b/docs/docs/edit-tutorial.md index ca2287a3..84c23c77 100644 --- a/docs/docs/edit-tutorial.md +++ b/docs/docs/edit-tutorial.md @@ -38,14 +38,14 @@ Choose the commit you want to edit ```text pick b73feaf INIT -pick 0a3aa83 L1S1Q -pick 0d67935 L2S1Q +pick 0a3aa83 1.1 +pick 0d67935 2.1 ``` -Let's say we want to edit step `L1S1Q` Change the word pick to "edit" or "e" +Let's say we want to edit step `1.1` Change the word pick to "edit" or "e" ```text -e 0a3aa83 L1S1Q +e 0a3aa83 1.1 ``` Save the modified rebase summary file and your rebase will start. Git will run through the commits until the first flagged "edit", then stop at the commit. @@ -62,21 +62,21 @@ If you encounter any merge conflicts along the way, resolve them, add the change ### Adding Additional Commits -Let's say we wanted to add an additional commit after the `L1S1Q`. +Let's say we wanted to add an additional commit after the `1.1`. ```text pick b73feaf INIT -pick 0a3aa83 L1S1Q -pick 0d67935 L2S1Q +pick 0a3aa83 1.1 +pick 0d67935 2.1 ``` To cause the rebase to pause after a commit, use the word "break" or "b". ```text pick b73feaf INIT -pick 0a3aa83 L1S1Q +pick 0a3aa83 1.1 break -pick 0d67935 L2S1Q +pick 0d67935 2.1 ``` Save the rebase summary file to start the process. The process should stop at the "break". @@ -91,20 +91,20 @@ If you encounter any merge conflicts along the way, resolve them, add the change ### Rewording a Commit -Let's say we wanted to change the title of commit "L2S1Q" to "L1S1A". +Let's say we wanted to change the title of commit "2.1" to "1.2". ```text pick b73feaf INIT -pick 0a3aa83 L1S1Q -pick 0d67935 L2S1Q +pick 0a3aa83 1.1 +pick 0d67935 2.1 ``` You can use the "reword" or "r" method. ```text pick b73feaf INIT -pick 0a3aa83 L1S1Q -reword 0d67935 L2S1Q +pick 0a3aa83 1.1 +reword 0d67935 2.1 ``` When you're finished, just save the file and the commits will be updated. diff --git a/docs/docs/git-timeline.md b/docs/docs/git-timeline.md index 295ec210..46b4ec32 100644 --- a/docs/docs/git-timeline.md +++ b/docs/docs/git-timeline.md @@ -10,15 +10,15 @@ A CodeRoad tutorial runs on Git commits. These will be the commits on the versio - Basic project setup code - test runner dependencies - .vscode workspace configurations -2. L1S1Q +2. 1.1 - add unit tests - add unit testing dependencies - add scaffolding code (if needed) -3. L1S1A +3. 1.1S - the code required to make the tests pass Then repeat steps 2 & 3. -The commit messages for these must start with those case sensitive letters. "L1S1Q" stands for "Lesson 1 Step 1 Question" and "L1S1A" stand for "Lesson 1 Step 1 Answer". The `L1S1` part of each commit message needs to match the id's from the markdown and yaml. +The commit messages for these must start with a level & step number. "1.1" stands for "Lesson 1 Step 1 Setup" and "1.1S" stand for "Lesson 1 Step 1 Solution". The `1.1` part of each commit message needs to match the id's from the markdown and yaml. -You can add additional text after those required characters if you want. \ No newline at end of file +You can add additional text after those required characters if you want. diff --git a/docs/docs/markdown.md b/docs/docs/markdown.md index a3f4ebd1..cd943577 100644 --- a/docs/docs/markdown.md +++ b/docs/docs/markdown.md @@ -15,50 +15,50 @@ See a rough example below: > Tutorial introduction paragraph -## L1 Lesson 1 +## 1. Lesson 1 > Lesson 1 summary Lesson 1 decription and instructions. -### L1S1 Lesson 1 Step 1 +### 1.1 Lesson 1 Step 1 -Test text for L1S1 +Test text for 1.1 #### HINTS -* This is a hint for L1S1 -* This is another hint for L1S1 +- This is a hint for 1.1 +- This is another hint for 1.1 -## L2 Lesson 2 +## 2. Lesson 2 > Lessons 2 summary Lesson 2 content. -### L2S1 Lesson 2 Step 1 +### 2.1 Lesson 2 Step 1 Test text #### HINTS -* Hint for L2S1 +- Hint for 2.1 -### L2S2 Lesson 2 Step 2 +### 2.2 Lesson 2 Step 2 -Test text for L2S2 +Test text for 2.2 #### HINTS -* Hint for L2S2 +- Hint for 2.2 ``` #### Explanation -The example above has an introduction page and two lessons. +The example above has an introduction page and two lessons. The introduction page is first thing users will see when they start a tutorial. It shows an overview of all the lessons and displays the lesson summary. -Lessons need to start with `## Lx ` where `x` is the lesson number. The text after `Lx` will display as the lesson title. +Lessons need to start with `## x.` where `x` is the lesson number. The text after `x.` will display as the lesson title. -The "Steps", or test text, need to start with `LxSy` where `x` matches the lesson number and `y` is the number for a "step". \ No newline at end of file +The "Steps", or test text, need to start with `x.y` where `x` matches the lesson number and `y` is the number for a "step". diff --git a/docs/docs/yaml.md b/docs/docs/yaml.md index a03ab081..f433a831 100644 --- a/docs/docs/yaml.md +++ b/docs/docs/yaml.md @@ -16,29 +16,29 @@ An example of this for the markdown on the previous page might look like this: version: '0.1.0' config: testRunner: - command: npm run programmatic-test + command: ./node_modules/.bin/mocha args: filter: --grep tap: --reporter=mocha-tap-reporter - repo: + repo: uri: https://github.com/username/repo branch: v0.1.0 dependencies: - name: node version: '>=10' levels: - - id: L1 + - id: '1' steps: - - id: L1S1 + - id: '1.1' setup: subtasks: false - - id: L2 + - id: '2' steps: - - id: L2S1 + - id: '2.1' setup: files: - index.html - - id: L2S2 + - id: '2.2' setup: subtasks: false ``` @@ -54,7 +54,7 @@ Here's an example of many available options and what they do: # This is a YAML-formatted file. ## Your personal version of the tutorial ## -version: "0.1.0" +version: '0.1.0' ## Data used to configure and setup the tutorial ## config: @@ -82,15 +82,15 @@ config: ## App versions helps to ensure compatability with the Extension appVersions: ## Ensure compatability with a minimal VSCode CodeRoad version - vscode: ">=0.7.0" + vscode: '>=0.7.0' ## Repo information to load code from ## repo: ## The uri path to the repo containing the code commits. Required. ## - uri: "" + uri: '' ## The branch on the repo uri that contains the code commits. Required. - branch: "" + branch: '' ## A list of tutorial dependencies to ensure the environment is setup for the tutorial. Optional. ## The dependencies will be checked by running `dependency.name` --version and comparing it to the version provided. @@ -104,10 +104,10 @@ config: ## A level is made up of levels: - - id: L1 + - id: '1' steps: ## Example 1: Opening files - - id: L1S1 + - id: '1.1' ## Setup for the first task. Required. setup: ## Files to open in a text editor when the task loads. Optional. @@ -119,18 +119,16 @@ levels: files: - package.json ## Example Two: Running commands - - id: L1S2 + - id: '1.2' setup: ## CLI commands that are run when the task loads. Optional. commands: - npm install solution: - commits: - - commit6 commands: - npm install ## Example Three: Watchers - - id: L1S3 + - id: '1.3' setup: files: - package.json @@ -142,10 +140,10 @@ levels: files: - package.json ## Example Four: Subtasks - - id: L1S4 + - id: '1.4' setup: ## A filter is a regex that limits the test results - filter: "^Example 2" + filter: '^Example 2' ## A feature that shows subtasks: all filtered active test names and the status of the tests (pass/fail). subtasks: true -``` \ No newline at end of file +```