Skip to content

Commit

Permalink
test(@angular-devkit/build-angular): refactor platform server test to…
Browse files Browse the repository at this point in the history
… use universal schematic

Using `@nguniversal/express-engine` requires a lot of maintenance and manual updates to set the correct versions of `@angular-devkit/architect` and `'@angular-devkit/core`.  This is because `@nguniversal/express-engine` can rely on different versions of this packages from the local built versions which would cause package installations failure.
  • Loading branch information
alan-agius4 committed Nov 9, 2020
1 parent 2f2ca78 commit b5218d4
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions tests/legacy-cli/e2e/tests/build/platform-server.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
import { normalize } from 'path';
import { getGlobalVariable } from '../../utils/env';
import { appendToFile, expectFileToMatch, writeFile } from '../../utils/fs';
import { appendToFile, expectFileToMatch, replaceInFile, writeFile } from '../../utils/fs';
import { installPackage } from '../../utils/packages';
import { exec, ng, silentNpm } from '../../utils/process';
import { isPrereleaseCli, updateJsonFile } from '../../utils/project';
import { exec, ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';

const snapshots = require('../../ng-snapshot/package.json');

export default async function () {
const argv = getGlobalVariable('argv');
const veEnabled = argv['ve'];
const tag = (await isPrereleaseCli()) ? 'next' : 'latest';

// @nguniversal/express-engine currently relies on ^0.1100.0-rc.2 of @angular-devkit/architect
// which is not present in the local package registry and not semver compatible with ^11.0.0-next.7
const { stdout: stdout1 } = await silentNpm('pack', '@angular-devkit/[email protected]', '--registry=https://registry.npmjs.org');
await silentNpm('publish', stdout1.trim(), '--registry=http://localhost:4873', '--tag=minor');

// @nguniversal/express-engine currently relies on ^11.0.0-rc.2 of @angular-devkit/core
// which is not present in the local package registry and not semver compatible prerelease version of ^11.0.0-next.7
const { stdout: stdout2 } = await silentNpm('pack', '@angular-devkit/[email protected]', '--registry=https://registry.npmjs.org');
await silentNpm('publish', stdout2.trim(), '--registry=http://localhost:4873', '--tag=minor');

await ng('add', `@nguniversal/express-engine@${tag}`);
await ng('generate', 'universal', '--client-project', 'test-project');

const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
if (isSnapshotBuild) {
Expand Down Expand Up @@ -82,6 +71,8 @@ export default async function () {
);
}

await replaceInFile('tsconfig.server.json', 'src/main.server.ts', 'server.ts');
await replaceInFile('angular.json', 'src/main.server.ts', 'server.ts');

await ng('run', 'test-project:server:production', '--optimization', 'false');

Expand Down

0 comments on commit b5218d4

Please sign in to comment.