Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions modules/express-engine/schematics/install/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,14 @@ describe('Universal Schematic', () => {
expect(schematicRunner.tasks[0].name).toBe('node-package');
expect((schematicRunner.tasks[0].options as {command: string}).command).toBe('install');
});

it('should not add Universal files', () => {
const noUniversal = Object.assign({}, defaultOptions);
noUniversal.skipUniversal = true;

const tree = schematicRunner.runSchematic('ng-add', noUniversal, appTree);
const filePath = '/src/server.main.ts';
const contents = tree.readContent(filePath);
expect(contents).toMatch('');
});
});
11 changes: 10 additions & 1 deletion modules/express-engine/schematics/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ function updateConfigFile(options: UniversalOptions): Rule {
]
}
};

// We have to check if the project config has a server target, because
// if the Universal step in this schematic isn't run, it can't be guaranteed
// to exist
if (!clientProject.architect.server) {
return;
}

clientProject.architect.server.configurations = serverConfig;

const workspacePath = getWorkspacePath(host);
Expand Down Expand Up @@ -118,7 +126,8 @@ export default function (options: UniversalOptions): Rule {
]);

return chain([
externalSchematic('@schematics/angular', 'universal', options),
options.skipUniversal ?
noop() : externalSchematic('@schematics/angular', 'universal', options),
updateConfigFile(options),
mergeWith(rootSource),
addDependenciesAndScripts(options),
Expand Down
5 changes: 5 additions & 0 deletions modules/express-engine/schematics/install/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"description": "Skip adding Express server file.",
"type": "boolean",
"default": false
},
"skipUniversal": {
"description": "Skip the Angular Universal schematic",
"type": "boolean",
"default": false
}
},
"required": [
Expand Down
4 changes: 4 additions & 0 deletions modules/express-engine/schematics/install/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ export interface Schema {
* Skip adding Express server file.
*/
skipServer?: boolean;
/**
* Skip the Angular Universal schematic
*/
skipUniversal?: boolean;
}