forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontribute.ngdoc
186 lines (123 loc) · 6.12 KB
/
contribute.ngdoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
@ngdoc overview
@name Develop
@description
# Building and Testing AngularJS
This document describes how to set up your development environment to build and test AngularJS, and
explains the basic mechanics of using `git`, `node`, `yarn`, `grunt`, and `bower`.
See the [contributing guidelines](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md)
for how to contribute your own code to AngularJS.
1. {@link misc/contribute#installing-dependencies Installing Dependencies}
2. {@link misc/contribute#forking-angularjs-on-github Forking AngularJS on Github}
3. {@link misc/contribute#building-angularjs Building AngularJS}
4. {@link misc/contribute#running-a-local-development-web-server Running a Local Development Web Server}
5. {@link misc/contribute#running-the-unit-test-suite Running the Unit Test Suite}
6. {@link misc/contribute#running-the-end-to-end-test-suite Running the End-to-end Test Suite}
## Installing Dependencies
Before you can build AngularJS, you must install and configure the following dependencies on your
machine:
* [Git](http://git-scm.com/): The [Github Guide to
Installing Git](https://help.github.com/articles/set-up-git) is a good source of information.
* [Node.js v6.x (LTS)](http://nodejs.org): 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.
We recommend using [nvm](https://github.com/creationix/nvm) (or [nvm-windows](https://github.com/coreybutler/nvm-windows))
to manage and install Node.js, which makes it easy to change the version of Node.js per project.
* [Yarn](https://yarnpkg.com): We use Yarn to install our Node.js module dependencies (rather than using npm).
There are detailed installation instructions available at https://yarnpkg.com/en/docs/install.
* [Java](http://www.java.com): We minify JavaScript using our
[Closure Tools](https://developers.google.com/closure/) jar. Make sure you have Java (version 7 or higher)
installed and included in your [PATH](http://docs.oracle.com/javase/tutorial/essential/environment/paths.html)
variable.
* [Grunt](http://gruntjs.com): We use Grunt as our build system. Install the grunt command-line tool globally with:
```shell
yarn global add grunt-cli
```
## Forking AngularJS on Github
To create a Github account, follow the instructions [here](https://github.com/signup/free).
Afterwards, go ahead and [fork](http://help.github.com/forking) the [main AngularJS repository](https://github.com/angular/angular.js).
## Building AngularJS
To build AngularJS, you clone the source code repository and use Grunt to generate the non-minified and
minified AngularJS files:
```shell
# Clone your Github repository:
git clone https://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:
yarn install
# Build AngularJS (which will install `bower` dependencies automatically):
grunt package
```
<div class="alert alert-warning">
**Note:** If you're using Windows, you must use an elevated command prompt (right click, run as
Administrator). This is because `grunt package` creates some symbolic links.
</div>
<div class="alert alert-warning">
**Note:** If you're using Linux, and `yarn install` fails with the message
'Please try running this command again as root/Administrator.', you may need to globally install `grunt` and `bower`:
<ul>
<li>sudo yarn global add grunt-cli</li>
<li>sudo yarn global add bower</li>
</ul>
</div>
The build output can be located under the `build` directory. It consists of the following files and
directories:
* `angular-<version>.zip` — The complete zip file, containing all of the release build
artifacts.
* `angular.js` — The non-minified AngularJS script.
* `angular.min.js` — The minified AngularJS script.
* `angular-scenario.js` — The AngularJS End2End test runner.
* `docs/` — A directory that contains all of the files needed to run `docs.angularjs.org`.
* `docs/index.html` — The main page for the documentation.
* `docs/docs-scenario.html` — The End2End test runner for the documentation application.
## Running a Local Development Web Server
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.
1. To start the web server, run:
```shell
grunt webserver
```
2. To access the local server, enter the following URL into your web browser:
```text
http://localhost:8000/
```
By default, it serves the contents of the AngularJS project directory.
3. To access the locally served docs, visit this URL:
```text
http://localhost:8000/build/docs/
```
## Running the Unit Test Suite
We write unit and integration tests with Jasmine and execute them with Karma. To run all of the
tests once on Chrome run:
```shell
grunt test:unit
```
To run the tests on other browsers (Chrome, ChromeCanary, Firefox and Safari are pre-configured) use:
```shell
grunt test:unit --browsers=Chrome,Firefox
```
Note there should be _no spaces between browsers_. `Chrome, Firefox` is INVALID.
During development, however, it's more productive to continuously run unit tests every time the source or test files
change. To execute tests in this mode run:
1. To start the Karma server, capture Chrome browser and run unit tests, run:
```shell
grunt autotest
```
2. 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):
```text
http://localhost:9876/
```
3. To re-run tests just change any source or test file.
To learn more about all of the preconfigured Grunt tasks run:
```shell
grunt --help
```
## Running the End-to-end Test Suite
AngularJS's end to end tests are run with Protractor. Simply run:
```shell
grunt test:e2e
```
This will start the webserver and run the tests on Chrome.