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

Commit f7b14e4

Browse files
committed
boilerplate, gulpfile, quickstart
1 parent 452c16d commit f7b14e4

21 files changed

+220
-107
lines changed

gulpfile.js

Lines changed: 19 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,15 @@ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
8484
});
8585

8686
var _exampleBoilerplateFiles = [
87-
'a2docs.css',
87+
'src/styles.css',
88+
'src/systemjs.config.js',
89+
'src/tsconfig.json',
90+
'bs-config.json',
91+
'bs-config.e2e.json',
8892
'package.json',
89-
'styles.css',
90-
'systemjs.config.js',
91-
'tsconfig.json',
9293
'tslint.json'
9394
];
9495

95-
var _exampleDartWebBoilerPlateFiles = ['a2docs.css', 'styles.css'];
96-
9796
var _exampleUnitTestingBoilerplateFiles = [
9897
'browser-test-shim.js',
9998
'karma-test-shim.js',
@@ -102,8 +101,6 @@ var _exampleUnitTestingBoilerplateFiles = [
102101

103102
var _exampleConfigFilename = 'example-config.json';
104103

105-
var _styleLessName = 'a2docs.less';
106-
107104
// Gulp flags:
108105
//
109106
// --lang=[all | ts | js | dart | 'ts|js' | 'ts|js|dart' | ...]
@@ -182,21 +179,12 @@ function runE2e() {
182179
// fast; skip all setup
183180
promise = Promise.resolve(true);
184181
} else {
185-
/*
186-
// Not 'fast'; do full setup
187-
var spawnInfo = spawnExt('npm', ['install'], { cwd: EXAMPLES_PATH});
188-
promise = spawnInfo.promise.then(function() {
189-
copyExampleBoilerplate();
190-
spawnInfo = spawnExt('npm', ['run', 'webdriver:update'], {cwd: EXAMPLES_PATH});
191-
return spawnInfo.promise;
192-
});
193-
*/
194182
// Not 'fast'; do full setup
195183
gutil.log('runE2e: install _examples stuff');
196184
var spawnInfo = spawnExt('npm', ['install'], { cwd: EXAMPLES_PATH});
197185
promise = spawnInfo.promise
186+
.then(copyExampleBoilerplate)
198187
.then(function() {
199-
buildStyles(copyExampleBoilerplate, _.noop);
200188
gutil.log('runE2e: update webdriver');
201189
spawnInfo = spawnExt('npm', ['run', 'webdriver:update'], {cwd: EXAMPLES_PATH});
202190
return spawnInfo.promise;
@@ -284,7 +272,7 @@ function runE2eTsTests(appDir, outputFile) {
284272

285273
var config = {
286274
build: exampleConfig.build || 'tsc',
287-
run: exampleConfig.run || 'http-server:e2e'
275+
run: exampleConfig.run || 'serve:e2e'
288276
};
289277

290278
var appBuildSpawnInfo = spawnExt('npm', ['run', config.build], { cwd: appDir });
@@ -350,7 +338,7 @@ function runProtractorAoT(appDir, outputFile) {
350338
promise = promise.then(() =>
351339
spawnExt('node', [copyFileCmd], { cwd: appDir }).promise );
352340
}
353-
var aotRunSpawnInfo = spawnExt('npm', ['run', 'http-server:e2e', 'aot', '--', '-s'], { cwd: appDir });
341+
var aotRunSpawnInfo = spawnExt('npm', ['run', 'serve:e2e', 'aot', '--', '-s'], { cwd: appDir });
354342
return runProtractor(promise, appDir, aotRunSpawnInfo, outputFile);
355343
}
356344

@@ -364,7 +352,7 @@ function runE2eDartTests(appDir, outputFile) {
364352
gutil.log('AppDir for Dart e2e: ' + appDir);
365353
gutil.log('Deploying from: ' + deployDir);
366354

367-
var appRunSpawnInfo = spawnExt('npm', ['run', 'http-server:e2e', '--', deployDir, '-s'], { cwd: httpLaunchDir });
355+
var appRunSpawnInfo = spawnExt('npm', ['run', 'serve:e2e', '--', deployDir, '-s'], { cwd: httpLaunchDir });
368356
if (!appRunSpawnInfo.proc.pid) {
369357
gutil.log('http-server failed to launch over ' + deployDir);
370358
return false;
@@ -448,7 +436,7 @@ gulp.task('help', taskListing.withFilters(function(taskName) {
448436
}));
449437

450438
// requires admin access because it adds symlinks
451-
gulp.task('add-example-boilerplate', function(done) {
439+
gulp.task('add-example-boilerplate', function() {
452440
var realPath = path.join(EXAMPLES_PATH, '/node_modules');
453441
var nodeModulesPaths = excludeDartPaths(getNodeModulesPaths(EXAMPLES_PATH));
454442

@@ -457,55 +445,31 @@ gulp.task('add-example-boilerplate', function(done) {
457445
fsUtils.addSymlink(realPath, linkPath);
458446
});
459447

460-
return buildStyles(copyExampleBoilerplate, done);
448+
return copyExampleBoilerplate();
461449
});
462450

463451

464452
// copies boilerplate files to locations
465453
// where an example app is found
466454
gulp.task('_copy-example-boilerplate', function (done) {
467-
return argv.fast ? done() : buildStyles(copyExampleBoilerplate, done);
455+
return argv.fast ? done() : copyExampleBoilerplate();
468456
});
469457

470-
//Builds Angular Docs CSS file from Bootstrap npm LESS source
471-
//and copies the result to the _examples folder to be included as
472-
//part of the example boilerplate.
473-
function buildStyles(cb, done){
474-
gulp.src(path.join(STYLES_SOURCE_PATH, _styleLessName))
475-
.pipe(less())
476-
.pipe(gulp.dest(BOILERPLATE_PATH)).on('end', function(){
477-
cb().then(function() { done(); });
478-
});
479-
}
480-
481458
// copies boilerplate files to locations
482459
// where an example app is found
483460
// also copies certain web files (e.g., styles.css) to ~/_examples/**/dart/**/web
484461
function copyExampleBoilerplate() {
485462
gutil.log('Copying example boilerplate files');
486-
var sourceFiles = _exampleBoilerplateFiles.map(function(fn) {
487-
return path.join(BOILERPLATE_PATH, fn);
488-
});
489463
var examplePaths = excludeDartPaths(getExamplePaths(EXAMPLES_PATH));
490464

491-
var dartWebSourceFiles = _exampleDartWebBoilerPlateFiles.map(function(fn){
492-
return path.join(BOILERPLATE_PATH, fn);
493-
});
494-
var dartExampleWebPaths = getDartExampleWebPaths(EXAMPLES_PATH);
495-
496465
// Make boilerplate files read-only to avoid that they be edited by mistake.
497466
var destFileMode = '444';
498-
return copyFiles(sourceFiles, examplePaths, destFileMode)
499-
.then(function() {
500-
return copyFiles(dartWebSourceFiles, dartExampleWebPaths, destFileMode);
501-
})
467+
return copyFiles(_exampleBoilerplateFiles, BOILERPLATE_PATH, examplePaths, destFileMode)
502468
// copy the unit test boilerplate
503469
.then(function() {
504-
var unittestSourceFiles =
505-
_exampleUnitTestingBoilerplateFiles
506-
.map(function(name) { return path.join(EXAMPLES_TESTING_PATH, name); });
507470
var unittestPaths = getUnitTestingPaths(EXAMPLES_PATH);
508-
return copyFiles(unittestSourceFiles, unittestPaths, destFileMode);
471+
return copyFiles(_exampleUnitTestingBoilerplateFiles,
472+
EXAMPLES_TESTING_PATH, unittestPaths, destFileMode);
509473
})
510474
.catch(function(err) {
511475
gutil.log(err);
@@ -582,9 +546,6 @@ function deleteExampleBoilerPlate() {
582546
var unittestPaths = getUnitTestingPaths(EXAMPLES_PATH);
583547

584548
return deleteFiles(_exampleBoilerplateFiles, examplePaths)
585-
.then(function() {
586-
return deleteFiles(_exampleDartWebBoilerPlateFiles, dartExampleWebPaths);
587-
})
588549
.then(function() {
589550
return deleteFiles(_exampleUnitTestingBoilerplateFiles, unittestPaths);
590551
});
@@ -1053,15 +1014,15 @@ function harpJsonSetJade2NgTo(v) {
10531014
// Copies fileNames into destPaths, setting the mode of the
10541015
// files at the destination as optional_destFileMode if given.
10551016
// returns a promise
1056-
function copyFiles(fileNames, destPaths, optional_destFileMode) {
1017+
function copyFiles(fileNames, originPath, destPaths, optional_destFileMode) {
10571018
var copy = Q.denodeify(fsExtra.copy);
10581019
var chmod = Q.denodeify(fsExtra.chmod);
10591020
var copyPromises = [];
10601021
destPaths.forEach(function(destPath) {
10611022
fileNames.forEach(function(fileName) {
1062-
var baseName = path.basename(fileName);
1063-
var destName = path.join(destPath, baseName);
1064-
var p = copy(fileName, destName, { clobber: true});
1023+
var originName = path.join(originPath, fileName);
1024+
var destName = path.join(destPath, fileName);
1025+
var p = copy(originName, destName, { clobber: true});
10651026
if(optional_destFileMode !== undefined) {
10661027
p = p.then(function () {
10671028
return chmod(destName, optional_destFileMode);

public/docs/_examples/.gitignore

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
# _exampleBoilerplateFiles
2-
.editorconfig
3-
karma.conf.js
4-
karma-test-shim.js
5-
package.json
6-
*/**/styles.css
7-
systemjs.config.js
8-
*/**/tsconfig.json
9-
tslint.json
10-
wallaby.js
1+
# _boilerplate files
2+
!_boilerplate/*
3+
*/*/src/styles.css
4+
*/*/src/systemjs.config.js
5+
*/*/src/tsconfig.json
6+
*/*/bs-config.e2e.json
7+
*/*/bs-config.json
8+
*/*/package.json
9+
*/*/tslint.json
1110

11+
# example files
1212
_test-output
1313
**/ts/**/*.js
1414
**/js-es6*/**/*.js
1515
**/ts-snippets/**/*.js
16-
*.d.ts
17-
18-
!**/*e2e-spec.js
19-
!systemjs.config.1.js
20-
!**/systemjs.config.extras.js
21-
!_boilerplate/*
22-
_boilerplate/a2docs.css
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"open": false,
3+
"logLevel": "silent",
4+
"port": 8080,
5+
"server": {
6+
"baseDir": "src",
7+
"routes": {
8+
"/node_modules": "node_modules"
9+
},
10+
"middleware": {
11+
"0": null
12+
}
13+
}
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"server": {
3+
"baseDir": "src",
4+
"routes": {
5+
"/node_modules": "node_modules"
6+
}
7+
}
8+
}

public/docs/_examples/_boilerplate/package.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@
44
"private": true,
55
"description": "Example package.json, only contains needed scripts for examples. See _examples/package.json for master package.json.",
66
"scripts": {
7-
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
8-
"e2e": "tsc && concurrently \"http-server\" \"protractor protractor.config.js\"",
9-
"http-server": "tsc && http-server",
10-
"http-server:e2e": "http-server",
11-
"http-server:cli": "http-server dist/",
12-
"lite": "lite-server",
13-
"lite:aot": "lite-server -c aot/bs-config.json",
14-
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
15-
"tsc": "tsc",
16-
"tsc:w": "tsc -w",
7+
"build": "tsc -p src/",
8+
"build:watch": "tsc -p src/ -w",
9+
"build:e2e": "tsc -p e2e/",
10+
"serve": "lite-server",
11+
"serve:e2e": "lite-server -c=bs-config.e2e.json",
12+
"prestart": "npm run build",
13+
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
14+
"pree2e": "webdriver-manager update && npm run build:e2e",
15+
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
16+
"protractor": "protractor protractor.config.js",
17+
"pretest": "npm run build",
18+
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
19+
"pretest:once": "npm run build",
20+
"test:once": "karma start karma.conf.js --single-run",
21+
"lint": "tslint ./src/**/*.ts -t verbose",
22+
23+
"build:cli": "ng build --no-progress",
24+
"serve:cli": "http-server dist/",
25+
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
26+
"serve:aot": "lite-server -c aot/bs-config.json",
1727
"start:webpack": "webpack-dev-server --inline --progress --port 8080",
1828
"test:webpack": "karma start karma.webpack.conf.js",
1929
"build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --bail",
20-
"build:cli": "ng build --no-progress",
21-
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
2230
"build:babel": "babel app -d app --extensions \".es6\" --source-maps",
2331
"copy-dist-files": "node ./copy-dist-files.js",
2432
"i18n": "ng-xi18n"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"open": false,
3+
"logLevel": "silent",
4+
"port": 8080,
5+
"server": {
6+
"baseDir": "dist",
7+
"middleware": {
8+
"0": null
9+
}
10+
}
11+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"build": "build:cli",
3-
"run": "http-server:cli"
3+
"run": "serve:cli"
44
}

0 commit comments

Comments
 (0)