Skip to content

Commit 595bb48

Browse files
author
TheDonDope
committed
Implement application decoupling
- Implements the application decoupling as discussed in #913. - Excludes karma.conf.js, protractor.conf.js and test-main.js from the copy build task, so that those files will not be copied over to /dist/** directory. Furthermore also excludes the tsconfig.json from this copy process, as it was copied over before too. - Updates the protractor configuration and associated gulp task. - Adds a e2e.singleRun gulp task to the gulpfile to leave the script in the package.json more compact. Also updates the README to include the new folder and file structure.
2 parents a26180d + 8ad5161 commit 595bb48

Some content is hidden

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

47 files changed

+39
-20
lines changed

README.md

Lines changed: 7 additions & 6 deletions

gulpfile.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,11 @@ gulp.task('test', (done: any) =>
115115
runSequence('build.test',
116116
'karma.start',
117117
done));
118+
119+
// --------------
120+
// E2E Test
121+
gulp.task('e2e.singleRun', (done: any) =>
122+
runSequence('build.prod',
123+
'build.js.e2e',
124+
'e2e',
125+
done));

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
"build.test": "gulp build.test --color",
1414
"build.test.watch": "gulp build.test.watch --color",
1515
"generate.manifest": "gulp generate.manifest --color",
16-
"e2e": "protractor",
17-
"e2e.live": "protractor --elementExplorer",
16+
"e2e": "protractor src/browser/protractor.conf.js",
17+
"e2e.live": "protractor src/browser/protractor.conf.js --elementExplorer",
18+
"e2e.singleRun": "gulp e2e.singleRun --color",
1819
"gulp": "gulp",
1920
"karma": "karma",
2021
"karma.start": "karma start",
@@ -27,8 +28,7 @@
2728
"start": "gulp serve.dev --color",
2829
"tasks.list": "gulp --tasks-simple --color",
2930
"test": "gulp test --color",
30-
"e2e.ci": "gulp build.prod --color && gulp build.js.e2e --color && gulp e2e --color",
31-
"tests.all": "npm test && npm run e2e.ci",
31+
"tests.all": "npm test && npm run e2e.singleRun",
3232
"webdriver-start": "webdriver-manager start",
3333
"webdriver-update": "webdriver-manager update"
3434
},
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

karma.conf.js renamed to src/browser/karma.conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = function(config) {
88
config.set({
99

1010
// base path that will be used to resolve all patterns (eg. files, exclude)
11-
basePath: './',
11+
basePath: '../../',
1212

1313

1414
// frameworks to use
@@ -47,7 +47,7 @@ module.exports = function(config) {
4747
// suppress annoying 404 warnings for resources, images, etc.
4848
{ pattern: 'dist/dev/assets/**/*', watched: false, included: false, served: true },
4949

50-
'test-main.js'
50+
'src/browser/test-main.js'
5151
],
5252

5353
// must go along with above, suppress annoying 404 warnings.

protractor.conf.js renamed to src/browser/protractor.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const config = {
22
baseUrl: 'http://localhost:5555/',
33

44
specs: [
5-
'./dist/dev/**/*.e2e-spec.js'
5+
'../../dist/dev/**/*.e2e-spec.js'
66
],
77

88
exclude: [],
File renamed without changes.
File renamed without changes.
File renamed without changes.

tools/config/seed.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ export class SeedConfig {
102102
BOOTSTRAP_DIR = 'app';
103103

104104
/**
105-
* The directory where the client files are located.
106-
* The default directory is `client`.
105+
* The directory where the browser files are located.
106+
* The default directory is `browser`.
107107
* @type {string}
108108
*/
109-
APP_CLIENT = argv['client'] || 'client';
109+
APP_BROWSER = argv['browser'] || 'browser';
110110

111111
/**
112112
* The bootstrap file to be used to boot the application. The file to be used is dependent if the hot-loader option is
@@ -128,7 +128,7 @@ export class SeedConfig {
128128
* The base folder of the applications source files.
129129
* @type {string}
130130
*/
131-
APP_SRC = `src/${this.APP_CLIENT}`;
131+
APP_SRC = `src/${this.APP_BROWSER}`;
132132

133133
/**
134134
* The folder of the applications asset files.

tools/tasks/seed/build.assets.dev.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export = () => {
1111
let paths: string[] = [
1212
join(APP_SRC, '**'),
1313
'!' + join(APP_SRC, '**', '*.ts'),
14-
'!' + join(APP_SRC, '**', '*.scss')
14+
'!' + join(APP_SRC, '**', '*.scss'),
15+
'!' + join(APP_SRC, '*.js'), // Do not copy `karma.conf.js`, `protractor.conf.js`, `test-main.js`
16+
'!' + join(APP_SRC, '*.json') // Do not copy `tsconfig.json`
1517
].concat(TEMP_FILES.map((p) => { return '!' + p; }));
1618

1719
return gulp.src(paths)

tools/tasks/seed/build.assets.prod.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export = () => {
2626
'!' + join(APP_SRC, '**', '*.css'),
2727
'!' + join(APP_SRC, '**', '*.html'),
2828
'!' + join(APP_SRC, '**', '*.scss'),
29+
'!' + join(APP_SRC, '*.js'), // Do not copy `karma.conf.js`, `protractor.conf.js`, `test-main.js`
30+
'!' + join(APP_SRC, '*.json'), // Do not copy `tsconfig.json`
2931
'!' + join(ASSETS_SRC, '**', '*.js')
3032
].concat(TEMP_FILES.map((p) => { return '!' + p; })))
3133
.pipe(onlyDirs(es))

tools/tasks/seed/e2e.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import * as express from 'express';
22
import * as gulp from 'gulp';
33
import { protractor } from 'gulp-protractor';
4+
import { join } from 'path';
5+
6+
import { APP_SRC } from '../../config';
7+
48

59
class Protractor {
610
server(port: number, dir: string) {
@@ -23,7 +27,7 @@ export = (done: any) => {
2327
.then((server: any) => {
2428
gulp
2529
.src('./dist/dev/**/*.e2e-spec.js')
26-
.pipe(protractor({ configFile: 'protractor.conf.js' }))
30+
.pipe(protractor({ configFile: join(process.cwd(), APP_SRC, 'protractor.conf.js') }))
2731
.on('error', (error: string) => { throw error; })
2832
.on('end', () => { server.close(done); });
2933
});

tools/tasks/seed/karma.start.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import * as karma from 'karma';
22
import { join } from 'path';
33

4+
import { APP_SRC } from '../../config';
5+
46
/**
57
* Executes the build process, running all unit tests using `karma`.
68
*/
79
export = (done: any) => {
810
new (<any>karma).Server({
9-
configFile: join(process.cwd(), 'karma.conf.js'),
11+
configFile: join(process.cwd(), APP_SRC, 'karma.conf.js'),
1012
singleRun: true
1113
}).start(done);
1214
};

0 commit comments

Comments
 (0)