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

Commit 1101f07

Browse files
filipesilvaFoxandxss
authored andcommitted
refactor: add src folder (#3171)
* boilerplate, gulpfile, quickstart * move ts files up to cookbooks * move rest of ts files * fix tsconfig, default build task, json file * fix js examples * fix webpack example * remove a2docs.css references * fix aot examples * fix webpack run task * fix cb-i18n * fix upgrade examples * fix unit tests * fix comment in deployment index * removed unused typings.json * fix plunkers * fix js example paths * fix ts quickstart/setup prose * add src folder note to setup * broadly replace app/ -> src/app/ * broadly replace main.ts * broadly replaced index.html * broadly replace tsconfig * replace systemjs * fix filetrees * Minor prose fixes to aot, i18n cookbooks * remove char harp was complaining about * update new reactive forms example * fix quickstart jade error * fix mistakes uncovered by CI * fix bad filename errors * edit style guide 04-06 rule to use src * add changelog * Incorporate Jesus's feedback * fix snippet headers in toh1/2 * chore: tweak changelog and setup text
1 parent a7f2b64 commit 1101f07

File tree

1,283 files changed

+4016
-3559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,283 files changed

+4016
-3559
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ eplnkr.html
3131
public/docs/*/latest/guide/cheatsheet.json
3232
protractor-results.txt
3333
link-checker-results.txt
34-
*a2docs.css
3534
/dist
3635
/public/docs/dart
3736
/public/docs/ts/_cache

gulpfile.js

+21-60
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,23 @@ 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 = [
98-
'browser-test-shim.js',
97+
'src/browser-test-shim.js',
9998
'karma-test-shim.js',
10099
'karma.conf.js'
101100
];
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;
@@ -283,8 +271,8 @@ function runE2eTsTests(appDir, outputFile) {
283271
}
284272

285273
var config = {
286-
build: exampleConfig.build || 'tsc',
287-
run: exampleConfig.run || 'http-server:e2e'
274+
build: exampleConfig.build || 'build',
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:aot'], { 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/_includes/_util-fns.jade

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646

4747
//- NgModule related
4848
- var _AppModuleVsAppComp = 'AppModule'
49-
- var _appModuleTsVsAppCompTs = 'app/app.module.ts'
50-
- var _appModuleTsVsMainTs = 'app/app.module.ts'
49+
- var _appModuleTsVsAppCompTs = 'src/app/app.module.ts'
50+
- var _appModuleTsVsMainTs = 'src/app/app.module.ts'
5151
- var _bootstrapModule = 'bootstrapModule'
5252
- var _declsVsDirectives = 'declarations'
5353
- var _moduleVsComp = 'module'

public/docs/_examples/.gitignore

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
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
13+
protractor-helpers.js
14+
*/e2e-spec.js
1315
**/ts/**/*.js
1416
**/js-es6*/**/*.js
1517
**/ts-snippets/**/*.js
16-
*.d.ts
17-
18-
!**/*e2e-spec.js
19-
!systemjs.config.1.js
2018
!**/systemjs.config.extras.js
21-
!_boilerplate/*
22-
_boilerplate/a2docs.css
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+
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"build": "build",
3+
"run": "serve"
4+
}

public/docs/_examples/_boilerplate/package.json

+23-13
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,32 @@
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 -c=bs-config.json",
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:upgrade": "tsc",
24+
"serve:upgrade": "http-server",
25+
"build:cli": "ng build --no-progress",
26+
"serve:cli": "http-server dist/",
27+
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
28+
"serve:aot": "lite-server -c bs-config.aot.json",
1729
"start:webpack": "webpack-dev-server --inline --progress --port 8080",
1830
"test:webpack": "karma start karma.webpack.conf.js",
1931
"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",
22-
"build:babel": "babel app -d app --extensions \".es6\" --source-maps",
32+
"build:babel": "babel src -d src --extensions \".es6\" --source-maps",
2333
"copy-dist-files": "node ./copy-dist-files.js",
2434
"i18n": "ng-xi18n"
2535
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"description": "QuickStart",
3+
"basePath": "src/",
4+
"files": [
5+
"app/app.component.ts",
6+
"index.html"
7+
],
8+
"open": "app/app.component.ts",
9+
"tags": ["quickstart"]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"lib": [ "es2015", "dom" ],
10+
"noImplicitAny": true,
11+
"suppressImplicitAnyIndexErrors": true,
12+
"typeRoots": [
13+
"../../../node_modules/@types/"
14+
]
15+
},
16+
"compileOnSave": true,
17+
"exclude": [
18+
"node_modules/*",
19+
"**/*-aot.ts"
20+
]
21+
}

public/docs/_examples/animations/ts/plnkr.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"description": "Angular Animations",
3+
"basePath": "src/",
34
"files":[
45
"!**/*.d.ts",
56
"!**/*.js"

public/docs/_examples/animations/ts/index.html renamed to public/docs/_examples/animations/ts/src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<script src="systemjs.config.js"></script>
2020
<script>
21-
System.import('app').catch(function(err){ console.error(err); });
21+
System.import('main.js').catch(function(err){ console.error(err); });
2222
</script>
2323
</head>
2424

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2-
import { AppModule } from './app.module';
2+
import { AppModule } from './app/app.module';
33

44
platformBrowserDynamic().bootstrapModule(AppModule);

public/docs/_examples/architecture/ts/plnkr.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"description": "Intro to Angular",
3+
"basePath": "src/",
34
"files":[
45
"!**/*.d.ts",
56
"!**/*.js",

public/docs/_examples/architecture/ts/index.html renamed to public/docs/_examples/architecture/ts/src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<script src="systemjs.config.js"></script>
1717
<script>
18-
System.import('app').catch(function(err){ console.error(err); });
18+
System.import('main.js').catch(function(err){ console.error(err); });
1919
</script>
2020
</head>
2121

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// #docregion
22
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3-
import { AppModule } from './app.module';
3+
import { AppModule } from './app/app.module';
44

55
platformBrowserDynamic().bootstrapModule(AppModule);

public/docs/_examples/attribute-directives/ts/plnkr.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"description": "Attribute Directive",
3+
"basePath": "src/",
34
"files":[
45
"!**/*.d.ts",
56
"!**/*.js",

0 commit comments

Comments
 (0)