knowhow-server
Version:
A personal workflow engine that can manage and use any network connected host
127 lines (120 loc) • 7.55 kB
HTML
<a href="http://github.com/angular/angular.js/edit/master/docs/content/misc/contribute.ngdoc" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable=""></code>
<div><span class="hint"></span>
</div>
</h1>
<div><div class="develop-page"><h2 id="building-and-testing-angularjs">Building and Testing AngularJS</h2>
<p>This document describes how to set up your development environment to build and test AngularJS, and
explains the basic mechanics of using <code>git</code>, <code>node</code>, <code>npm</code>, <code>grunt</code>, and <code>bower</code>.</p>
<p>See the <a href="https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md">contributing guidelines</a>
for how to contribute your own code to AngularJS.</p>
<ol>
<li><a href="#building-and-testing-angularjs_installing-dependencies">Installing Dependencies</a></li>
<li><a href="#building-and-testing-angularjs_forking-angular-on-github">Forking Angular on Github</a></li>
<li><a href="#building-and-testing-angularjs_building-angularjs">Building AngularJS</a></li>
<li><a href="#building-and-testing-angularjs_running-a-local-development-web-server">Running a Local Development Web Server</a></li>
<li><a href="#building-and-testing-angularjs_running-the-unit-test-suite">Running the Unit Test Suite</a></li>
<li><a href="#building-and-testing-angularjs_running-the-end-to-end-test-suite">Running the End-to-end Test Suite</a></li>
</ol>
<h3 id="building-and-testing-angularjs_installing-dependencies">Installing Dependencies</h3>
<p>Before you can build AngularJS, you must install and configure the following dependencies on your
machine:</p>
<ul>
<li><p><a href="http://git-scm.com/">Git</a>: The <a href="https://help.github.com/articles/set-up-git">Github Guide to Installing Git</a> is a good source of information.</p>
</li>
<li><p><a href="http://nodejs.org">Node.js</a>: We use Node to generate the documentation, run a
development web server, run tests, and generate distributable files. Depending on your system, you can install Node either from source or as a
pre-packaged bundle.</p>
</li>
<li><p><a href="http://www.java.com">Java</a>: We minify JavaScript using our
<a href="https://developers.google.com/closure/">Closure Tools</a> jar. Make sure you have Java (version 6 or higher) installed
and included in your <a href="http://docs.oracle.com/javase/tutorial/essential/environment/paths.html">PATH</a> variable.</p>
</li>
<li><p><a href="http://gruntjs.com">Grunt</a>: We use Grunt as our build system. Install the grunt command-line tool globally with:</p>
<pre><code class="lang-shell">npm install -g grunt-cli</code></pre>
</li>
<li><p><a href="http://bower.io/">Bower</a>: We use Bower to manage client-side packages for the docs. Install the <code>bower</code> command-line tool globally with:</p>
<pre><code class="lang-shell">npm install -g bower</code></pre>
</li>
</ul>
<p><strong>Note:</strong> You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to install Grunt &
Bower globally.</p>
<h3 id="building-and-testing-angularjs_forking-angular-on-github">Forking Angular on Github</h3>
<p>To create a Github account, follow the instructions <a href="https://github.com/signup/free">here</a>.
Afterwards, go ahead and <a href="http://help.github.com/forking">fork</a> the <a href="https://github.com/angular/angular.js">main AngularJS repository</a>.</p>
<h3 id="building-and-testing-angularjs_building-angularjs">Building AngularJS</h3>
<p>To build AngularJS, you clone the source code repository and use Grunt to generate the non-minified and
minified AngularJS files:</p>
<pre><code class="lang-shell"># Clone your Github repository:
git clone git@github.com:<github username>/angular.js.git
# Go to the AngularJS directory:
cd angular.js
# Add the main AngularJS repository as an upstream remote to your repository:
git remote add upstream https://github.com/angular/angular.js.git
# Install node.js dependencies:
npm install
# Install bower components:
bower install
# Build AngularJS:
grunt package</code></pre>
<div class="alert alert-warning">
<strong>Note:</strong> If you're using Windows, you must use an elevated command prompt (right click, run as
Administrator). This is because <code>grunt package</code> creates some symbolic links.
</div>
<p>The build output can be located under the <code>build</code> directory. It consists of the following files and
directories:</p>
<ul>
<li><p><code>angular-<version>.zip</code> — The complete zip file, containing all of the release build
artifacts.</p>
</li>
<li><p><code>angular.js</code> — The non-minified <code>angular</code> script.</p>
</li>
<li><p><code>angular.min.js</code> — The minified <code>angular</code> script.</p>
</li>
<li><p><code>angular-scenario.js</code> — The <code>angular</code> End2End test runner.</p>
</li>
<li><p><code>docs/</code> — A directory that contains all of the files needed to run <code>docs.angularjs.org</code>.</p>
</li>
<li><p><code>docs/index.html</code> — The main page for the documentation.</p>
</li>
<li><p><code>docs/docs-scenario.html</code> — The End2End test runner for the documentation application.</p>
</li>
</ul>
<h3 id="building-and-testing-angularjs_running-a-local-development-web-server">Running a Local Development Web Server</h3>
<p>To debug code and run end-to-end tests, it is often useful to have a local HTTP server. For this purpose, we have
made available a local web server based on Node.js.</p>
<ol>
<li><p>To start the web server, run:</p>
<pre><code class="lang-shell">grunt webserver</code></pre>
</li>
<li><p>To access the local server, enter the following URL into your web browser:</p>
<pre><code>http://localhost:8000/</code></pre>
<p>By default, it serves the contents of the AngularJS project directory.</p>
</li>
</ol>
<h3 id="building-and-testing-angularjs_running-the-unit-test-suite">Running the Unit Test Suite</h3>
<p>We write unit and integration tests with Jasmine and execute them with Karma. To run all of the
tests once on Chrome run:</p>
<pre><code class="lang-shell">grunt test:unit</code></pre>
<p>To run the tests on other browsers (Chrome, ChromeCanary, Firefox, Opera and Safari are pre-configured) use:</p>
<pre><code class="lang-shell">grunt test:unit --browsers Opera,Firefox</code></pre>
<p>Note there should be <em>no spaces between browsers</em>. <code>Opera, Firefox</code> is INVALID.</p>
<p>During development it's however more productive to continuously run unit tests every time the source or test files
change. To execute tests in this mode run:</p>
<ol>
<li><p>To start the Karma server, capture Chrome browser and run unit tests, run:</p>
<pre><code class="lang-shell">grunt autotest</code></pre>
</li>
<li><p>To capture more browsers, open this URL in the desired browser (URL might be different if you have multiple instance
of Karma running, read Karma's console output for the correct URL):</p>
<pre><code class="lang-shell">http://localhost:9876/</code></pre>
</li>
<li><p>To re-run tests just change any source or test file.</p>
</li>
</ol>
<p>To learn more about all of the preconfigured Grunt tasks run:</p>
<pre><code class="lang-shell">grunt --help</code></pre>
<h3 id="building-and-testing-angularjs_running-the-end-to-end-test-suite">Running the End-to-end Test Suite</h3>
<p>Simply run:</p>
<pre><code class="lang-shell">grunt test:e2e</code></pre>
<p>This will start the webserver and run the tests.</p>
</div></div>