Up until now, you have seen the code side of your build tool. Now, you will see how it works end-to-end for each command. For your convenience, all of the external node modules have already been installed and the config.json file has also been created. In addition, the global alias named nobot has also been created by running the npm run init command.

Steps to run the build tool

Step 1: update the configuration file

The first step will be to update the config.json file. Head over to the config.json file in the code below and add links to the deploy (nobot-website) and template (nobot-template-rock-paper-scissors) repositories you created during the Introduction of the chapter.

Now, go to the .gitconfig file by clicking on it from the left pane and add your name and GitHub email. This file will store your name and the email that you will associate with your commits.

Click on the Save button at the bottom of the code, so that you do not have to add them again. Now, you can click on the Run button and access the terminal by switching from the Output tab to the Terminal tab.

Step 2: cloning repositories

Run the setup command in the terminal to clone your repositories.

Press + to interact
nobot setup

The repositories website and template should now exist under your repositories directory.

Step 3: running the server and opening the website in the browser

Now that you have the template and website repositories cloned, you can run a server to see your deployed game templates in a browser. To do this, open another terminal by clicking on the plus icon next to the current terminal.

Change into the website directory and run the run.sh script.

Press + to interact
# Enter this command first
cd usr/src/app/part2/repositories/website
# Followed by this command to run the server
sh run.sh

To see your game website in the browser, open a new terminal again and paste this command:

Press + to interact
google-chrome --no-sandbox http://localhost:9000

Now, when you head over to the Output tab, you will see the game website. Currently, it will have no games as we have not built any.

Step 4: release latest template version

Now suppose that one of my colleagues applies a fix to the template. This fix is for a problem that when saving the score to local storage, the result is saved across all games while you want it to be saved on a game-by-game basis. This means that you will need to use the nobot template command to release the latest version.

Note: When you run this and some other commands in this lesson, you will be prompted to enter the credentials for your GitHub account. When prompted for a username, enter your GitHub username, and when prompted for the password, enter the authentication token that you saved in the Introductory lesson.

Run the following command in the same terminal where you ran the nobot setup command:

Press + to interact
nobot template

Note: You might notice that running the nobot template command shows the message “Already up to date” in the terminal. This is because the scenario provided above is hypothetical and, in actuality, there are no changes to be released for now.

Step 5: build the game

Brilliant! You have the latest version of your template. Now, you can build five games by running the command for each ticket.

Press + to interact
nobot game GS-100

This will build and deploy one game to the website. Head over to the browser in the Output tab and refresh the link. You will see that the fire-water-earth-cute game is now available.

Note: On the website, the index.php script scans the releases directory and outputs tiles for each game that exists. So, every time you deploy a new game, the game tile will be added after you refresh the browser.

The build tool in action

[credential]
        helper = store
[user]
        email = "email@example.com"
        name = "First Last"


Your game has been built with the typing of the nobot game command and ticket ID, GS-100, and then the hit of an enter button. Here is a live URL where you can see what the deployed website will look like when you build and deploy all 5 game versions.

Repeat running the build tool for the remaining four implementations.

nobot game GS-101

nobot game GS-102

nobot game GS-103

nobot game GS-104

Now, you will have five games in the lobby on the website. They should pop up as tiles on the main lobby page. When you click on one, it should open a modal containing the game in an iframe. You should, then, be able to play the game you built with your tool.

Practice exercise

You have already learned how to send out automated emails in a previous lesson. If you want, you can revisit that lesson to refresh those concepts.

What you need to do now that a new template has been released is email your team with the update. You know that a new template is released when you use the nobot template command.

For your convenience, the nobot setup has been carried out and both the template and website repositories have already been cloned.

Here is what you need to do. Head over to src/commands/template.js from the directory below. Scroll down to the fse.copy function and add your code where specified. The transporter and message objects have already been set up with the credentials you used earlier in the course.

Your task is to complete the code in the src/commands/template.js file, click the Run button, and execute the command: nobot template to release a new template. Check your email to see if you received an email or not!

{
  "api": {
    "authKey": "NOBOT_123",
    "endpoint": "http://opencanvas.co.uk/nira/rest/api/latest/ticket"
  },
  "deploy": {
    "baseBranch": "master",
    "name": "website",
    "repo": "https://github.com/farrukhras/nobot-website.git",
    "coreDirectory": "core",
    "releaseDirectory": "releases"
  },
  "templates": {
    "rock-paper-scissors": {
      "baseBranch": "master",
      "repo": "https://github.com/farrukhras/nobot-template-rock-paper-scissors"
    }
  }
}
Send email for a released template