Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 02f53cd

Browse files
committed
docs(cli-quickstart): ward's changes
1 parent 005d9b7 commit 02f53cd

File tree

4 files changed

+70
-52
lines changed

4 files changed

+70
-52
lines changed

public/docs/_examples/cli-quickstart/ts/e2e/app.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('angular2-cli-quickstart App', function() {
1111
// #docregion title
1212
it('should display message saying app works', () => {
1313
page.navigateTo();
14-
expect(page.getParagraphText()).toEqual('angular2-cli-quickstart works!');
14+
expect(page.getParagraphText()).toEqual('My First Angular 2 App');
1515
});
1616
// #enddocregion title
1717
});

public/docs/_examples/cli-quickstart/ts/src/app/angular2-cli-quickstart.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* tslint:disable:no-unused-variable */
12
// #docregion
23
import {
34
async,

public/docs/_examples/cli-quickstart/ts/src/app/angular2-cli-quickstart.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import {Component} from 'angular2/core';
88
})
99
// #docregion title
1010
export class Angular2CliQuickstartApp {
11-
title = 'My First Angular 2 App'
11+
title = 'My First Angular 2 App';
1212
}
1313
// #enddocregion title

public/docs/ts/latest/cli-quickstart.jade

Lines changed: 67 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ a(id="devenv")
4343

4444
**Install [node and npm](https://nodejs.org/en/download/)** if not already on your machine.
4545

46-
Then you **install [Angular-CLI](https://github.com/angular/angular-cli)** and generate a new project by running the following commands:
46+
Then **install [Angular-CLI](https://github.com/angular/angular-cli)** and generate a new project by running the following commands:
4747

4848
code-example(format="").
4949
npm install -g angular-cli
@@ -58,42 +58,43 @@ code-example(format="").
5858
- link to the style guide
5959

6060
:marked
61-
The CLI has also initialized a git repo for the project, so we have everything we need.
61+
The CLI has also initialized a git repo for the project.
6262

63-
**We're all set.** Let's serve our app.
63+
**Let's serve our app.**
6464

6565
a(id="serve-and-test")
6666
.l-main-section
6767
:marked
6868
## Serve & test
69-
We're now ready to serve the app that the CLI has generated for us.
7069

71-
We run `ng serve` to serve, watch our files and rebuild the app whenever we change one.
70+
Run `ng serve` to launch the server, watch our files, and rebuild the app whenever we make changes.
7271

73-
Opening a browser on `http://localhost:4200/` greets us with the following message:
72+
Open a browser on `http://localhost:4200/`; the app greets us with a message:
7473

7574
figure.image-display
7675
img(src='/resources/images/devguide/cli-quickstart/app-works.png' alt="Our app works!")
7776

7877
.alert.is-important
7978
:marked
80-
When using Windows, Angular-CLI commands that involve building the application need an administrator prompt. This is because the CLI build step makes heavy usage of symlinks and in Windows those require admin rights.
79+
_Windows Developers_: perform these commands in a console window opened as an administrator.
80+
The Angular-CLI build steps create symlinks which require administrator rights under Windows.
8181

8282
.l-verbose-section
8383
:marked
84-
talk about serve
84+
talk about the server
8585

8686
:marked
8787
Now we're ready to write some code... or are we? We certainly could start writing code right now, but our tests would break.
8888

8989
:marked
9090
### Tests?
9191

92-
What tests? Why, the ones the ones that Angular-CLI created with the initial project! They are configured to run on [Google Chrome](https://www.google.com/chrome/) so make sure to have it installed before running them.
92+
What tests? The Angular-CLI created tests for our initial project!
93+
They are configured to run on [Google Chrome](https://www.google.com/chrome/) so make sure it is installed before running them.
9394

94-
To run the end-to-end tests, we leave the current `ng serve` console running, open a new prompt and type `ng e2e`. We should see a the following output after a few console messages:
95+
Open a new terminal (or console) window and run the *end-to-end (e2e)* tests with the command: `ng e2e`.
96+
Look for the following output after a few console messages:
9597
code-example(format="").
96-
(...)
9798
Spec started
9899

99100
angular2-cli-quickstart App
@@ -104,16 +105,16 @@ code-example(format="").
104105
:marked
105106
Looks all green and good. Always a good sign.
106107

107-
Now we run our unit tests once via `ng test --build=false --watch=false`, and we should see a similar message:
108+
Keep the server running in the original window and run the *unit tests* with the command: `ng test --build=false --watch=false`.
109+
After more console output, we should see a message like this:
108110

109111
code-example(format="").
110-
(...)
111112
Chrome 49.0.2623 (Windows 10 0.0.0): Executed 2 of 2 SUCCESS (0.016 secs / 0.009 secs)
112113

113114
:marked
114-
It's always a good idea to run tests before and after making changes, that way we can guarantee that our apps behave the way we expect them to.
115+
It's a good idea to run tests before and after making changes to confirm that our app behaves as we expect it to.
115116

116-
*Now* we're ready to start coding.
117+
*At last* we are ready to write some code.
117118

118119
.l-verbose-section
119120
:marked
@@ -126,20 +127,21 @@ code-example(format="").
126127
a(id="edit")
127128
.l-main-section
128129
:marked
129-
## Edit our app
130+
## Edit the app
130131

131-
It's time to make this project more our own. We begin by opening `angular2-cli-quickstart` in our favourite editor.
132+
We open the `angular2-cli-quickstart` projecd folder in our favourite editor.
132133

133-
Our root component is named after the project, and since we initialized the project with the name `angular2-cli-quickstart`, our root component is `Angular2CliQuickstartApp` and can be found in `src/app/angular2-cli-quickstart.component.ts`
134+
The root component is named after the project. We created the project with the name `angular2-cli-quickstart`,
135+
so our root component is `Angular2CliQuickstartApp` and can be found in `src/app/angular2-cli-quickstart.component.ts`
134136

135137
Open it and update the title:
136138

137139
+makeExample('cli-quickstart/ts/src/app/angular2-cli-quickstart.component.ts', 'title', 'src/app/angular2-cli-quickstart.component.ts')(format=".")
138140

139141
:marked
140-
Our browser reloads automatically, and we see the new message. It's looks nice, but we can make it better.
142+
The browser reloads automatically and we see the revised title. That's nice, but we can make look better.
141143

142-
Open `src/app/angular2-cli-quickstart.component.css` and add in
144+
Open `src/app/angular2-cli-quickstart.component.css` and give the app some style
143145

144146
+makeExample('cli-quickstart/ts/src/app/angular2-cli-quickstart.component.css', null, 'src/app/angular2-cli-quickstart.component.css')(format=".")
145147

@@ -152,32 +154,35 @@ figure.image-display
152154
:marked
153155
### Re-test and fix
154156

155-
We've made a few changes and we should commit them to Git soon.
157+
We've made a few changes that we should commit to source control.
156158

157-
But first, let's run our tests again. We leave `ng serve` running and on a new console do `ng e2e` and then `ng test --build=false --watch=false`.
159+
Before we do, let's run our tests again.
160+
While `ng serve` continues to run in the original window,
161+
enter `ng e2e` again. This time the *e2e* test fails.
158162

159163
code-example(format="").
160-
(...)
161164
1) angular2-cli-quickstart App should display message saying app works
162165
- Expected 'My First Angular 2 App' to equal 'angular2-cli-quickstart works!'.
163166

164167
Executed 1 of 1 spec (1 FAILED) in 1 sec.
165168

169+
:marked
170+
Run the unit tests again: `ng test --build=false --watch=false`. They fail too.
166171
code-example(format="").
167-
(...)
168172
Chrome 49.0.2623 (Windows 10 0.0.0) App: Angular2CliQuickstart should have as title 'angular2-cli-quickstart works!' FAILED
169173
Expected 'My First Angular 2 App' to equal 'angular2-cli-quickstart works!'.
170-
(...)
174+
...
171175
Chrome 49.0.2623 (Windows 10 0.0.0): Executed 2 of 2 (1 FAILED) (0.038 secs / 0.022 secs)
172176

173177
:marked
174-
Our tests broke - as they should. We changed the title of our app, and our tests were looking for it.
175-
176-
Make the following changes to our tests:
178+
Our tests broke - as they should. We changed the title of our app, and our tests are looking for the original title.
177179

178-
+makeExample('cli-quickstart/ts/e2e/app.e2e.ts', 'title', 'e2e/app.e2e.ts')(format=".")
180+
Fix the expected *title* text in both tests:
179181

180-
+makeExample('cli-quickstart/ts/src/app/angular2-cli-quickstart.component.spec.ts', 'title', 'src/app/angular2-cli-quickstart.component.spec.ts')(format=".")
182+
+makeTabs(
183+
'cli-quickstart/ts/e2e/app.e2e.ts, cli-quickstart/ts/src/app/angular2-cli-quickstart.component.spec.ts',
184+
'title, title',
185+
'e2e/app.e2e.ts, src/app/angular2-cli-quickstart.component.spec.ts')(format=".")
181186

182187
:marked
183188
Run our tests again and... all green! We are back in business.
@@ -190,53 +195,66 @@ code-example(format="").
190195
a(id="github-pages")
191196
.l-main-section
192197
:marked
193-
### Pushing to production
198+
## Push to production (Optional)
194199

195-
We now have a fully featured app marked green on all tests. Next stop: the production environment.
200+
Next stop: the production environment.
196201

197202
Angular-CLI has a nifty command that helps us push our app onto [GitHub Pages](https://pages.github.com/) hosting.
198203

199-
To begin we'll need to [create a GitHub Account](https://github.com/join) if we don't have one already.
200-
Afterwards we'll also need to [setup SSH keys on github](https://help.github.com/articles/generating-an-ssh-key/) if we haven't yet.
201-
202-
After that's done, run `ng github-pages:deploy`.
204+
.l-sub-section
205+
:marked
206+
[Create a free GitHub Account](https://github.com/join) if you don't have one.
207+
and [setup SSH keys](https://help.github.com/articles/generating-an-ssh-key/)
208+
if you haven't done that.
209+
:marked
210+
Close all windows/processes (like `ng serve`!) that are using the app files and folders.
211+
212+
Run `ng github-pages:deploy`.
203213

204214
.alert.is-important
205215
:marked
206-
The `ng github-pages:deploy` command will perform a series of git operations that will add and remove files. Make sure you close all windows/processes (like `ng serve`!) that are using the app files and folders, otherwise these git operations might fail.
207-
208-
If that happens, we might be left in the `gh-pages` branch instead of the `master` branch. Simply `git checkout master`, close open windows that might be using these files, and try `ng github-pages:deploy`.
216+
The `ng github-pages:deploy` command performs a series of git operations that add and remove files.
217+
It can fail if those files are held by another process.
218+
219+
If the command fails, we might be left in the `gh-pages` branch instead of the `master` branch.
209220

221+
Run `git branch` and look for the _starred_ branch name.
222+
If it isn't `master`, run `git checkout master`,
223+
close open windows that might be using these files, and try `ng github-pages:deploy` again.
224+
210225
:marked
211-
The first time we run this command, it will create a github repository. Every other time we call it, it will use the existing one.
226+
This command creates a new github repository the first time we run it.
227+
Subsequent calls use this existing repo.
212228

213-
The console will prompt us to get a github token that will allow the CLI to create a repo for us - don't worry, it will only be used once and we can safely delete it after the repo is created. Deleting it will invalidate it.
229+
The command prompts us for a github token that will allow the CLI to create a repo for us.
230+
Don't worry, the token is used only once and we can safely delete it after the repo is created.
231+
Deleting the token invalidates it.
214232

215-
First go to [https://github.com/settings/tokens](https://github.com/settings/tokens), and click `Generate new token`.
233+
### Get a token
234+
Go to [https://github.com/settings/tokens](https://github.com/settings/tokens), and click *Generate new token*.
216235

217236
figure.image-display
218237
img(src='/resources/images/devguide/cli-quickstart/gh-token-1.png' alt="Generate new token")
219238

220239
:marked
221-
Github will ask us to login again, and afterwards we can choose a description and scope for the token.
240+
We must login again and then choose a description and scope for the token.
222241

223-
Name the token `angular-cli`, chose as scope `public_repo` and then `Generate token` at the bottom.
242+
Name the token `angular-cli`, chose as scope *public_repo*, and then click *Generate token* at the bottom.
224243
figure.image-display
225244
img(src='/resources/images/devguide/cli-quickstart/gh-token-2.png' alt="Description and scope")
226245

227246
:marked
228247
On the next screen, copy the token, paste it in the console window that asked us for the token, and press enter.
229248

230-
Keep this page open so that at the end we can delete the token.
249+
Keep this page open so we can delete the token when we're done.
231250
figure.image-display
232251
img(src='/resources/images/devguide/cli-quickstart/gh-token-3.png' alt="Copy and delete")
233252

234253
:marked
235-
The console will also ask us for our github username, and afterwards will create the repository, build our app and deploy it as a Github Page.
236-
237-
The whole process should look like this:
254+
The command prompts for our github username. Then it creates the repository, builds the app, and deploys it as a Github Page.
255+
The entire process we just described looks like this:
238256

239-
code-example(format="." language="bash").
257+
code-example(format="." language="").
240258
$ ng github-pages:deploy
241259
Built project successfully. Stored in "dist/".
242260

@@ -277,4 +295,3 @@ code-example(format="." language="bash").
277295

278296
Angular-CLI will help us do the rest, and we can push it online at any time.
279297

280-

0 commit comments

Comments
 (0)