<li><ahref="#step-1-create-a-new-directory-under-your-assignments-repository">Step 1: Create a new directory under your assignments repository</a></li>
<li><ahref="#step-2-initialise-you-project-with-npm-init">Step 2: Initialise you project with npm init</a></li>
<h3id="step-1-create-repository-on-github">Step 1: Create repository on Github</h3>
<p>First create a repository under your github account. To do so, login to <ahref="https://github.com">Github</a> and on the top/right corner of the page select the '+' symbol and 'New repository'</p>
<h3id="step-2-clone-the-repository-to-your-own-machine">Step 2: Clone the repository to your own machine</h3>
<p>Now that you have a github repo, you need to <code>clone</code> it to your machine. Open a terminal and navigate (<code>cd</code> and <code>ls</code>) to a prefered directory on your machine where you want your assignments to reside (for instance the Desktop).</p>
<p>When this is done, select the "Clone or download" menu on your githib repo's page and copy the listed url:</p>
<h3id="step-1-create-a-new-directory-under-your-assignments-repository">Step 1: Create a new directory under your assignments repository</h3>
<p>If you have followed the previous section, you should now have a repositroy on your machine which is linked to your github account. Let's assume that your repo is named <code>cth2016-assignments/</code> and resides on your Desktop.</p>
<p>To create a new assigment, you need to point your terminal to the repo:</p>
<pre><code>$ cd ~/Desktop/cth2016-assignments/</code></pre>
<p>and then create a new directory, which I will call <code>assignment-x</code>. To do so, on the terminal, simply type:</p>
<pre><code>$ mkdir assignment-x
$ cd assignment-x </code></pre>
<p>This will create a new direcory <code>assignment-x</code> under <code>~/Desktop/cth2016-assignments/</code>. The <code>cd</code> command puts your terminal inside this newly created directory so that you can initialise your actual project in step 2.</p>
<h3id="step-2-initialise-you-project-with-npm-init">Step 2: Initialise you project with npm init</h3>
<p>Node has a package manager named <code>npm</code> (n-ode, p-ackage, m-anager) that automates the task of creating a project from scratch and configures it in a way that is compatible with other node projects. We will use <code>npm</code> during the module.</p>
<p>To initialise your new assignment under <code>assignment-x</code>, simply emit the follow command:</p>
<p>With this commad you will be asked various questions regarding your project's name, version, description, entry point, author, etc. which you can configure at will (press <'enter'> to select and move to the next configuration step).</p>
<p>A <code>package.json</code> file is created upon the completion of <code>npm init</code>. This file contains all the configurations you selected and can be edited manually.</p>
<p>This step is optional, yet recommended for your assignment. When making a node application, modules/libraries can be made part of your project using <code>npm</code>. Thousands of javascript libraries are available on <ahref="https://www.npmjs.com">www.npmjs.com</a> which you can install with a simple <code>npm</code> command.</p>
<p>As in the first session of the class on the Command Line Interface (CLI), we will be using <ahref="https://www.npmjs.com/package/commander">"commander"</a> for our applications. To install it for you assignment, use the following command:</p>
<p>This will create a <code>node_modules</code> directory next to <code>package.json</code> where the commander code is placed. All modules installed using <code>npm</code> will reside in this <code>node_modules</code> directory.</p>
<h3id="step-4-create-your-actual-assigment-scripts">Step 4: Create your actual assigment script(s)</h3>
<p>Now that you have an npm project created and installed commander it is time to create your script(s). For instance, in this example, I will create <code>index.js</code> file containing the code for the fake assignment. This file can be called anything (for instance, person.js as in the example in class during week1).</p>
<p>Though since I am not following a proper assignment per se, I will simply create a simple tri-lingual script that will output <code>"Hello!"</code>, <code>"Dag!"</code> or <code>"Allô!"</code> depending on a command line arguments passed to the script which can be of the type <code>en</code> (english), <code>nl</code> (nederlands), <code>fr</code> (français) or nothing.</p>
<p>To create <code>index.js</code> simply type (or, alternatively, create it with Sublime Text):</p>
<spanclass="co">// simplest tri-lingual program </span>
<spanclass="kw">var</span> program <spanclass="op">=</span><spanclass="at">require</span>(<spanclass="st">'commander'</span>)<spanclass="op">;</span>
<p>If you called you script another name (for instance, person.js), please change the above <code>index.js</code> with the name of your own script.</p>
<h3id="step-6-create-a-readme">Step 6: Create a README</h3>
<p>One of the interesting feature of commander is that it can auto generate a <code>"help"</code> output from your script based on the command line options you have listed in your program.</p>
<p>It is very common for command line scripts to feature such <code>--help</code> argument that when executed, displays what the program expects as input. Thus, for this class, each README you will create (for both assignments and final project) is expected to have (at least) this type of "helper documentation".</p>
<p>To initialise a README and add the <code>help</code> output from your script:</p>
<p>Alternatively, you can create the README with Sublime Text and copy/paste the result of the <code>--help</code> manually.</p>
<p>It is a very good practice to start the redaction with the <code>--help</code> as it signals how to use your script to people that may be interested in it.</p>
<h3id="step-7-add-your-created-files-to-git">Step 7: Add your created files to git</h3>
<p>This should indicate which directories and/or files are untracked by git.</p>
<p>If you have followed the previous steps, <code>git status</code> should simply signal that the current directory <code>./</code> is untracked. To add it to git:</p>
<p>To make sure git properly added the new assignment, simply type (again):</p>
<pre><code>$ git status</code></pre>
<p>and check that your <code>package.json</code>, <code>index.js</code> (or whatever you have called your file(s)), and <code>README</code> are marked as new files (green).</p>
<h3id="step-8-commit-your-changes-and-push-to-github">Step 8: Commit your changes and push to Github</h3>
<p>NOTE: <code>node_modules</code> is not be pushed to github, why? Because when someone will clone your project (your instructor for example), she/he will <code>npm install</code> it her/himself as it is listed as a dependency in <code>package.json</code>.</p>
<h2id="updating-your-assignment-as-you-make-progress">Updating your assignment as you make progress</h2>
<p>It is assumed that you will make many changes to your assigment while your a working on it.</p>
<p>The ususall cycle of working on some piece of code is to first (1) add you files to the repo (re: Step 7), (2) modify your files while you are working, and (3) when your code is working as inteted, commit your changes and push to github (re: Step 8).</p>
<p>The usual updating loop looks a bit like this:</p>
<olstyle="list-style-type: decimal">
<li><code>git status</code></li>
<li>(optional) <code>git add</code> xyz depending on what was added to the project while working on it.</li>
<li><code>git commit -a -m "message for the commit"</code></li>
<li><ahref="https://help.github.com/articles/set-up-git/">Github Help - Set Up Git</a></li>
<li><ahref="https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/">Github Help - Adding an existing project</a></li>