Skip to content

Commit 41947cb

Browse files
committed
chore: fix gulp serve-and-sync tasks and many broken example links
The serve-and-sync tasks wait for `_copy-example-boilerplate` to finish Differentiates app compile, spec compile, and test failures StyleGuide (for documentators) up-to-date
1 parent c2c3177 commit 41947cb

File tree

17 files changed

+75
-1616
lines changed

17 files changed

+75
-1616
lines changed

gulpfile.js

+22-13
Original file line numberDiff line numberDiff line change
@@ -231,19 +231,33 @@ function runE2eTsTests(appDir, outputFile) {
231231
}
232232

233233
function runProtractor(prepPromise, appDir, appRunSpawnInfo, outputFile) {
234+
var specFilename = path.resolve(`${appDir}/../e2e-spec.ts`);
234235
return prepPromise
235236
.catch(function(){
236-
var emsg = `AppDir failed during compile: ${appDir}\n\n`;
237+
var emsg = `Application at ${appDir} failed to transpile.\n\n`;
237238
gutil.log(emsg);
238239
fs.appendFileSync(outputFile, emsg);
239240
return Promise.reject(emsg);
240241
})
241242
.then(function (data) {
243+
var transpileError = false;
244+
242245
// start protractor
243-
var specFilename = path.resolve(`${appDir}/../e2e-spec.ts`);
246+
244247
var spawnInfo = spawnExt('npm', [ 'run', 'protractor', '--', 'protractor.config.js',
245248
`--specs=${specFilename}`, '--params.appDir=' + appDir, '--params.outputFile=' + outputFile], { cwd: EXAMPLES_PROTRACTOR_PATH });
246-
return spawnInfo.promise;
249+
250+
spawnInfo.proc.stderr.on('data', function (data) {
251+
transpileError = transpileError || /npm ERR! Exit status 100/.test(data.toString());
252+
});
253+
return spawnInfo.promise.catch(function(err) {
254+
if (transpileError) {
255+
var emsg = `${specFilename} failed to transpile.\n\n`;
256+
gutil.log(emsg);
257+
fs.appendFileSync(outputFile, emsg);
258+
}
259+
return Promise.reject(emsg);
260+
});
247261
})
248262
.then(
249263
function() { return finish(true);},
@@ -373,7 +387,6 @@ gulp.task('_copy-example-boilerplate', copyExampleBoilerplate);
373387
// copies boilerplate files to locations
374388
// where an example app is found
375389
// also copies certain web files (e.g., styles.css) to ~/_examples/**/dart/**/web
376-
// also copies protractor.config.js file
377390
function copyExampleBoilerplate() {
378391
gutil.log('Copying example boilerplate files');
379392
var sourceFiles = _exampleBoilerplateFiles.map(function(fn) {
@@ -390,8 +403,7 @@ function copyExampleBoilerplate() {
390403
.then(function() {
391404
return copyFiles(dartWebSourceFiles, dartExampleWebPaths);
392405
})
393-
// copy files from _examples/_protractor dir to each subdir that
394-
// contains a e2e-spec file.
406+
// copy certain files from _examples/_protractor dir to each subdir that contains an e2e-spec file.
395407
.then(function() {
396408
var protractorSourceFiles =
397409
_exampleProtractorBoilerplateFiles
@@ -474,11 +486,8 @@ gulp.task('build-js-api-docs', ['_shred-api-examples'], function() {
474486
return buildApiDocs('js');
475487
});
476488

477-
gulp.task('build-plunkers', function() {
478-
return copyExampleBoilerplate()
479-
.then(function() {
480-
return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log });
481-
});
489+
gulp.task('build-plunkers', ['_copy-example-boilerplate'], function() {
490+
return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log });
482491
});
483492

484493
gulp.task('build-dart-cheatsheet', [], function() {
@@ -586,11 +595,11 @@ gulp.task('_harp-compile', function() {
586595
});
587596
});
588597

589-
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide'], function() {
598+
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() {
590599
return docShredder.shred( _devguideShredOptions);
591600
});
592601

593-
gulp.task('_shred-devguide-shared-jade', ['_shred-clean-devguide-shared-jade'], function() {
602+
gulp.task('_shred-devguide-shared-jade', ['_shred-clean-devguide-shared-jade', '_copy-example-boilerplate'], function() {
594603
return docShredder.shred( _devguideShredJadeOptions);
595604
});
596605

public/docs/_examples/_protractor/protractor.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function sendKeys(element, str) {
118118
// better to create a resolved promise here but ... don't know how with protractor;
119119
}
120120

121+
// See http://jasmine.github.io/2.1/custom_reporter.html
121122
function Reporter(options) {
122123
var _defaultOutputFile = path.resolve(process.cwd(), "../../../../", 'protractor-results.txt');
123124
options.outputFile = options.outputFile || _defaultOutputFile;
@@ -143,7 +144,7 @@ function Reporter(options) {
143144
};
144145

145146
this.specStarted = function(spec) {
146-
147+
147148
};
148149

149150
this.specDone = function(spec) {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './validate.directive';
1+
export * from './validator.directive';
+5-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
11
/// <reference path="../_protractor/e2e.d.ts" />
2-
/*global browser, element, by */
3-
describe('Getting Started E2E Tests', function() {
2+
describe('Documentation StyleGuide E2E Tests', function() {
43

5-
// #docregion shared
64
let expectedMsg = 'My First Angular 2 App';
75

8-
// tests shared across languages
9-
function sharedTests(basePath: string) {
10-
beforeEach(function () {
11-
browser.get(basePath + 'index.html');
12-
});
13-
14-
it('should display: '+ expectedMsg, function() {
15-
expect(element(by.id('output')).getText()).toEqual(expectedMsg);
16-
});
17-
}
18-
// #enddocregion
19-
20-
describe('Getting Started in JavaScript', function() {
21-
sharedTests('gettingstarted/js/');
6+
beforeEach(function () {
7+
browser.get('');
228
});
239

24-
describe('Getting Started in TypeScript', function() {
25-
sharedTests('gettingstarted/ts/');
10+
it('should display: ' + expectedMsg, function() {
11+
expect(element(by.id('output')).getText()).toEqual(expectedMsg);
2612
});
27-
2813
});
+12-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
(function() {
1+
(function(app) {
2+
23
// #docregion
34
// #docregion class-w-annotations
4-
var AppComponent = ng
5+
app.AppComponent =
56
// #docregion component
6-
.Component({
7+
ng.core.Component({
78
selector: 'my-app',
89
// #enddocregion
910
// #docregion view
@@ -19,26 +20,24 @@ var AppComponent = ng
1920

2021
// #docregion bootstrap
2122
document.addEventListener('DOMContentLoaded', function() {
22-
ng.bootstrap(AppComponent);
23+
ng.platformBrowserDynamic.bootstrap(app.AppComponent);
2324
});
2425
// #enddocregion
2526
// #enddocregion
2627

27-
})();
28+
})(window.app || (window.app = {}));
2829

2930
/* Non DSL Approach */
30-
(function() {
31+
(function(app) {
3132

3233
// #docregion no-dsl
33-
function AppComponent () {}
34+
app.AppComponent = function AppComponent () {}
3435

35-
AppComponent.annotations = [
36-
new ng.ComponentAnnotation({
37-
selector: 'my-app'
38-
}),
39-
new ng.ViewAnnotation({
36+
app.AppComponent.annotations = [
37+
new ng.core.Component({
38+
selector: 'my-app',
4039
template: '<h1 id="output">My First Angular 2 App</h1>'
4140
})
4241
];
4342
// #enddocregion
44-
})();
43+
})(window.app || (window.app = {}));

public/docs/_examples/styleguide/js/example-config.json

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
<!-- #docregion -->
2-
<!DOCTYPE html>
32
<html>
3+
<head>
44
<title>Documentation Style</title>
5-
<meta charset="UTF-8">
65
<meta name="viewport" content="width=device-width, initial-scale=1">
76
<link rel="stylesheet" href="styles.css">
87

9-
<!-- Polyfill(s) for older browsers -->
108
<script src="node_modules/core-js/client/shim.min.js"></script>
119

1210
<script src="node_modules/zone.js/dist/zone.js"></script>
1311
<script src="node_modules/reflect-metadata/Reflect.js"></script>
14-
<script src="node_modules/systemjs/dist/system.src.js"></script>
1512

16-
<script src="systemjs.config.js"></script>
17-
<script>
18-
System.import('app').catch(function(err){ console.error(err); });
19-
</script>
13+
<script src="node_modules/rxjs/bundles/Rx.umd.js"></script>
14+
<script src="node_modules/@angular/core/core.umd.js"></script>
15+
<script src="node_modules/@angular/common/common.umd.js"></script>
16+
<script src="node_modules/@angular/compiler/compiler.umd.js"></script>
17+
<script src="node_modules/@angular/platform-browser/platform-browser.umd.js"></script>
18+
<script src="node_modules/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js"></script>
19+
20+
<script src='app.js'></script>
2021
</head>
2122

2223
<body>
2324
<my-app>foo2</my-app>
2425
</body>
26+
2527
</html>

public/docs/_examples/styleguide/ts/app.js

-46
This file was deleted.

public/docs/_examples/styleguide/ts/app.ts

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Component } from '@angular/core';
2+
@Component({
3+
selector: 'my-app',
4+
template: '<h1 id="output">My First Angular 2 App</h1>'
5+
})
6+
export class AppComponent { }
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { bootstrap } from '@angular/platform-browser-dynamic';
2+
3+
import { AppComponent } from './app.component';
4+
5+
bootstrap(AppComponent);

public/docs/_examples/styleguide/ts/dummy.spec.js

-9
This file was deleted.

public/docs/_examples/styleguide/ts/example-config.json

Whitespace-only changes.

public/docs/ts/latest/cookbook/component-communication.jade

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ figure.image-display
6060

6161
E2E test that all children were instantiated and displayed as expected:
6262

63-
+makeExample('cb-component-communication/e2e-spec.js', 'parent-to-child')
63+
+makeExample('cb-component-communication/e2e-spec.ts', 'parent-to-child')
6464

6565
:marked
6666
[Back to top](#top)
@@ -90,7 +90,7 @@ figure.image-display
9090

9191
E2E tests of input property setter with empty and non-empty names:
9292

93-
+makeExample('cb-component-communication/e2e-spec.js', 'parent-to-child-setter')
93+
+makeExample('cb-component-communication/e2e-spec.ts', 'parent-to-child-setter')
9494

9595
:marked
9696
[Back to top](#top)
@@ -128,7 +128,7 @@ figure.image-display
128128
Test that ***both*** input properties are set initially and that button clicks trigger
129129
the expected `ngOnChanges` calls and values:
130130

131-
+makeExample('cb-component-communication/e2e-spec.js', 'parent-to-child-onchanges')
131+
+makeExample('cb-component-communication/e2e-spec.ts', 'parent-to-child-onchanges')
132132

133133
:marked
134134
[Back to top](#top)
@@ -167,7 +167,7 @@ figure.image-display
167167

168168
Test that clicking the *Agree* and *Disagree* buttons update the appropriate counters:
169169

170-
+makeExample('cb-component-communication/e2e-spec.js', 'child-to-parent')
170+
+makeExample('cb-component-communication/e2e-spec.ts', 'child-to-parent')
171171

172172
:marked
173173
[Back to top](#top)
@@ -217,7 +217,7 @@ a(id="countdown-tests")
217217
match the seconds displayed in the child's status message.
218218
Test also that clicking the *Stop* button pauses the countdown timer:
219219

220-
+makeExample('cb-component-communication/e2e-spec.js', 'countdown-timer-tests')
220+
+makeExample('cb-component-communication/e2e-spec.ts', 'countdown-timer-tests')
221221

222222
:marked
223223
[Back to top](#top)
@@ -327,7 +327,7 @@ figure.image-display
327327
Tests click buttons of both the parent `MissionControlComponent` and the `AstronautComponent` children
328328
and verify that the *History* meets expectations:
329329

330-
+makeExample('cb-component-communication/e2e-spec.js', 'bidirectional-service')
330+
+makeExample('cb-component-communication/e2e-spec.ts', 'bidirectional-service')
331331

332332
:marked
333333
[Back to top](#top)

0 commit comments

Comments
 (0)