Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 728f86d

Browse files
alan-agius4CaerusKaru
authored andcommitted
fix(common): don't run universal schematic if server target already e… (#1241)
1 parent d37d4bf commit 728f86d

File tree

6 files changed

+27
-2
lines changed

6 files changed

+27
-2
lines changed

integration/express-engine-ivy/angular.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"e2e": {
135135
"builder": "@angular-devkit/build-angular:protractor",
136136
"options": {
137+
"webdriverUpdate": false,
137138
"protractorConfig": "e2e/protractor.conf.js"
138139
}
139140
},

integration/express-engine-ve/angular.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"e2e": {
135135
"builder": "@angular-devkit/build-angular:protractor",
136136
"options": {
137+
"webdriverUpdate": false,
137138
"protractorConfig": "e2e/protractor.conf.js"
138139
}
139140
},

integration/hapi-engine-ivy/angular.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"e2e": {
135135
"builder": "@angular-devkit/build-angular:protractor",
136136
"options": {
137+
"webdriverUpdate": false,
137138
"protractorConfig": "e2e/protractor.conf.js"
138139
}
139140
},

integration/hapi-engine-ve/angular.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"e2e": {
135135
"builder": "@angular-devkit/build-angular:protractor",
136136
"options": {
137+
"webdriverUpdate": false,
137138
"protractorConfig": "e2e/protractor.conf.js"
138139
}
139140
},

modules/common/schematics/install/index.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,20 @@ describe('Universal Schematic', () => {
5252
'server.ts',
5353
]);
5454
});
55+
56+
it(`should work when server target already exists`, async () => {
57+
let tree = await schematicRunner
58+
.runExternalSchematicAsync('@schematics/angular', 'universal', defaultOptions, appTree)
59+
.toPromise();
60+
61+
tree = await schematicRunner
62+
.runSchematicAsync('install', defaultOptions, tree)
63+
.toPromise();
64+
65+
const contents = JSON.parse(tree.readContent('/projects/bar/tsconfig.server.json'));
66+
expect(contents.files).toEqual([
67+
'src/main.server.ts',
68+
'server.ts',
69+
]);
70+
});
5571
});

modules/common/schematics/install/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
externalSchematic,
1111
Rule,
1212
SchematicsException,
13+
noop,
1314
} from '@angular-devkit/schematics';
1415
import {normalize, join, parseJsonAst, JsonParseMode} from '@angular-devkit/core';
1516
import {updateWorkspace} from '@schematics/angular/utility/workspace';
@@ -120,9 +121,13 @@ function updateServerTsConfigRule(options: UniversalOptions): Rule {
120121
}
121122

122123
export default function (options: UniversalOptions): Rule {
123-
return () => {
124+
return async host => {
125+
const clientProject = await getClientProject(host, options.clientProject);
126+
124127
return chain([
125-
externalSchematic('@schematics/angular', 'universal', options),
128+
clientProject.targets.has('server')
129+
? noop()
130+
: externalSchematic('@schematics/angular', 'universal', options),
126131
addScriptsRule(options),
127132
updateServerTsConfigRule(options),
128133
updateConfigFileRule(options),

0 commit comments

Comments
 (0)