test: fix e2e tests with latest devkit

This commit is contained in:
Hans Larsen 2018-04-02 20:59:42 -07:00 committed by Hans
parent af5bd5231c
commit 4dcbf38989
12 changed files with 99 additions and 86 deletions

35
package-lock.json generated
View File

@ -5,17 +5,17 @@
"requires": true,
"dependencies": {
"@angular-devkit/architect": {
"version": "github:angular/angular-devkit-architect-builds#4b8f9cb2a9f85c1d8337cc8cd78318c77c2254c1",
"version": "github:angular/angular-devkit-architect-builds#312482bda558ab5a42dc88fc61ea491f8872abae",
"requires": {
"rxjs": "5.5.8"
"rxjs": "6.0.0-smoosh.2"
}
},
"@angular-devkit/core": {
"version": "github:angular/angular-devkit-core-builds#059b03c11422c7092dcec70105a924fd1596caef",
"version": "github:angular/angular-devkit-core-builds#09fccf33358a618755cfa3bd5abe053bc916876f",
"requires": {
"ajv": "5.5.2",
"chokidar": "1.7.0",
"rxjs": "5.5.8",
"rxjs": "6.0.0-smoosh.2",
"source-map": "0.5.7"
},
"dependencies": {
@ -33,10 +33,10 @@
}
},
"@angular-devkit/schematics": {
"version": "github:angular/angular-devkit-schematics-builds#c4c63ed93242b4d0a7e56a33512aa95aa1157aca",
"version": "github:angular/angular-devkit-schematics-builds#219e8dbbba62f5413e9c4c06d98cb6485a166542",
"requires": {
"@ngtools/json-schema": "1.1.0",
"rxjs": "5.5.8"
"rxjs": "6.0.0-smoosh.2"
}
},
"@ngtools/json-schema": {
@ -45,15 +45,15 @@
"integrity": "sha1-w6DFRNYjkqzCgTpCyKDcb1j4aSI="
},
"@schematics/angular": {
"version": "github:angular/schematics-angular-builds#27fd3d8499ab09262261f2185ea3c6c218c0dea4",
"version": "github:angular/schematics-angular-builds#4364a63cad80cb4b2a70fb84916d21775649ed5b",
"requires": {
"typescript": "2.6.2"
}
},
"@schematics/update": {
"version": "github:angular/schematics-update-builds#3b6cfbfb6766b2c514036e0671b0f984174486b5",
"version": "github:angular/schematics-update-builds#1685d6e18e0c9d73c920fd3901c0abe9fef20817",
"requires": {
"rxjs": "5.5.8",
"rxjs": "6.0.0-smoosh.2",
"semver": "5.5.0",
"semver-intersect": "1.3.1"
}
@ -4913,11 +4913,11 @@
"dev": true
},
"rxjs": {
"version": "5.5.8",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.8.tgz",
"integrity": "sha512-Bz7qou7VAIoGiglJZbzbXa4vpX5BmTTN2Dj/se6+SwADtw4SihqBIiEa7VmTXJ8pynvq0iFr5Gx9VLyye1rIxQ==",
"version": "6.0.0-smoosh.2",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.0.0-smoosh.2.tgz",
"integrity": "sha512-IAickSl7xhGOHhhZp7XhhyIpHUm1QvHMMPQVAusotHiwE8szw4ntHVbouj0CiB5IMe4jep1dzsTNcvj2YUIP+w==",
"requires": {
"symbol-observable": "1.0.1"
"tslib": "1.9.0"
}
},
"safe-buffer": {
@ -5306,9 +5306,9 @@
}
},
"symbol-observable": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz",
"integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ="
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"sync-exec": {
"version": "0.6.2",
@ -5513,8 +5513,7 @@
"tslib": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz",
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==",
"dev": true
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ=="
},
"tslint": {
"version": "5.9.1",

View File

@ -41,11 +41,11 @@
},
"homepage": "https://github.com/angular/angular-cli",
"dependencies": {
"@angular-devkit/architect": "angular/angular-devkit-architect-builds#779e8fc",
"@angular-devkit/core": "angular/angular-devkit-core-builds#779e8fc",
"@angular-devkit/schematics": "angular/angular-devkit-schematics-builds#779e8fc",
"@schematics/angular": "angular/schematics-angular-builds#779e8fc",
"@schematics/update": "angular/schematics-update-builds#779e8fc",
"@angular-devkit/architect": "angular/angular-devkit-architect-builds#c11c6ca",
"@angular-devkit/core": "angular/angular-devkit-core-builds#c11c6ca",
"@angular-devkit/schematics": "angular/angular-devkit-schematics-builds#c11c6ca",
"@schematics/angular": "angular/schematics-angular-builds#c11c6ca",
"@schematics/update": "angular/schematics-update-builds#c11c6ca",
"ajv": "^6.1.1",
"chalk": "~2.2.0",
"common-tags": "^1.3.1",
@ -56,9 +56,10 @@
"node-modules-path": "^1.0.0",
"opn": "~5.1.0",
"resolve": "^1.1.7",
"rxjs": "^5.5.8",
"rxjs": "^6.0.0-rc.0",
"semver": "^5.3.0",
"silent-error": "^1.0.0",
"symbol-observable": "^1.2.0",
"yargs-parser": "^9.0.2"
},
"devDependencies": {

View File

@ -1,11 +1,14 @@
import { experimental } from '@angular-devkit/core';
import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node';
import { Architect, TargetSpecifier } from '@angular-devkit/architect';
import {
Architect, BuilderDescription, BuildEvent,
TargetSpecifier
} from '@angular-devkit/architect';
import { Command, Option } from './command';
import { from } from 'rxjs/observable/from';
import { of } from 'rxjs';
import { from } from 'rxjs';
import { concatMap, map, tap, toArray } from 'rxjs/operators';
import { WorkspaceLoader } from '../models/workspace-loader';
import { of } from 'rxjs/observable/of';
const stringUtils = require('ember-cli-string-utils');
@ -31,7 +34,7 @@ export abstract class ArchitectCommand extends Command {
target: string | undefined;
public async initialize(options: any) {
public async initialize(options: any): Promise<void> {
return this._loadWorkspaceAndArchitect().pipe(
concatMap(() => {
let targetSpec: TargetSpecifier;
@ -64,10 +67,11 @@ export abstract class ArchitectCommand extends Command {
const builderConfig = this._architect.getBuilderConfiguration(targetSpec);
return this._architect.getBuilderDescription(builderConfig).pipe(
tap((builderDesc) => this.mapArchitectOptions(builderDesc.schema))
tap<BuilderDescription>(builderDesc => { this.mapArchitectOptions(builderDesc.schema); })
);
})
).toPromise();
).toPromise()
.then(() => {});
}
public validate(options: any) {
@ -148,9 +152,10 @@ export abstract class ArchitectCommand extends Command {
protected async runArchitectTarget(targetSpec: TargetSpecifier): Promise<number> {
const runSingleTarget = (targetSpec: TargetSpecifier) => this._architect.run(
this._architect.getBuilderConfiguration(targetSpec), { logger: this._logger }
this._architect.getBuilderConfiguration(targetSpec),
{ logger: this._logger }
).pipe(
map(buildEvent => buildEvent.success ? 0 : 1)
map((buildEvent: BuildEvent) => buildEvent.success ? 0 : 1)
);
if (!targetSpec.project && this.target) {
@ -174,9 +179,11 @@ export abstract class ArchitectCommand extends Command {
const workspaceLoader = new WorkspaceLoader(this._host);
return workspaceLoader.loadWorkspace().pipe(
tap(workspace => this._workspace = workspace),
concatMap(workspace => new Architect(workspace).loadArchitect()),
tap(architect => this._architect = architect),
tap((workspace: experimental.workspace.Workspace) => this._workspace = workspace),
concatMap((workspace: experimental.workspace.Workspace) => {
return new Architect(workspace).loadArchitect();
}),
tap((architect: Architect) => this._architect = architect),
);
}
}

View File

@ -300,7 +300,7 @@ export abstract class SchematicCommand extends Command {
const workspaceLoader = new WorkspaceLoader(this._host);
workspaceLoader.loadWorkspace().pipe(take(1))
.subscribe(workspace => this._workspace = workspace);
.subscribe((workspace: experimental.workspace.Workspace) => this._workspace = workspace);
}
private readDefaults(collectionName: string, schematicName: string, options: any): any {

View File

@ -7,8 +7,7 @@ import {
normalize,
virtualFs
} from '@angular-devkit/core';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { Observable, of } from 'rxjs';
import { concatMap, tap } from 'rxjs/operators';
import * as fs from 'fs';
import { homedir } from 'os';

View File

@ -42,9 +42,10 @@
"node-modules-path": "^1.0.0",
"opn": "~5.1.0",
"resolve": "^1.1.7",
"rxjs": "^5.5.8",
"rxjs": "^6.0.0-rc.0",
"semver": "^5.1.0",
"silent-error": "^1.0.0",
"symbol-observable": "^1.2.0",
"yargs-parser": "^9.0.2"
},
"ng-update": {

View File

@ -40,8 +40,8 @@ export default function () {
{ input: 'src/cstring-script.js' },
{ input: 'src/input-script.js' },
{ input: 'src/lazy-script.js', lazy: true },
{ input: 'src/pre-rename-script.js', output: 'renamed-script' },
{ input: 'src/pre-rename-lazy-script.js', output: 'renamed-lazy-script', lazy: true }
{ input: 'src/pre-rename-script.js', bundleName: 'renamed-script' },
{ input: 'src/pre-rename-lazy-script.js', bundleName: 'renamed-lazy-script', lazy: true }
];
}))
.then(() => ng('build', '--extract-css'))

View File

@ -22,8 +22,8 @@ export default function () {
{ input: 'src/string-style.css' },
{ input: 'src/input-style.css' },
{ input: 'src/lazy-style.css', lazy: true },
{ input: 'src/pre-rename-style.css', output: 'renamed-style' },
{ input: 'src/pre-rename-lazy-style.css', output: 'renamed-lazy-style', lazy: true }
{ input: 'src/pre-rename-style.css', bundleName: 'renamed-style' },
{ input: 'src/pre-rename-lazy-style.css', bundleName: 'renamed-lazy-style', lazy: true }
];
}))
.then(() => ng('build', '--extract-css'))
@ -32,7 +32,10 @@ export default function () {
.then(() => expectFileToMatch('dist/test-project/styles.css', '.input-style'))
.then(() => expectFileToMatch('dist/test-project/lazy-style.css', '.lazy-style'))
.then(() => expectFileToMatch('dist/test-project/renamed-style.css', '.pre-rename-style'))
.then(() => expectFileToMatch('dist/test-project/renamed-lazy-style.css', '.pre-rename-lazy-style'))
.then(() => expectFileToMatch(
'dist/test-project/renamed-lazy-style.css',
'.pre-rename-lazy-style',
))
// index.html lists the right bundles
.then(() => expectFileToMatch('dist/test-project/index.html', oneLineTrim`
<link rel="stylesheet" href="styles.css">

View File

@ -11,8 +11,8 @@ export default function() {
appArchitect.build.configurations['prod-env'] = {
fileReplacements: [
{
from: 'src/environments/environment.ts',
to: 'src/environments/environment.prod.ts'
src: 'src/environments/environment.ts',
replaceWith: 'src/environments/environment.prod.ts'
}
],
};

View File

@ -42,13 +42,13 @@ export default function () {
options: {
outputPath: 'dist/test-project-server',
main: 'src/main.server.ts',
tsConfig: 'tsconfig.server.json'
tsConfig: 'src/tsconfig.server.json'
}
};
}))
.then(() => writeFile('./tsconfig.server.json', `
.then(() => writeFile('./src/tsconfig.server.json', `
{
"extends": "../../tsconfig.json",
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../dist-server",
"baseUrl": "./",
@ -60,7 +60,7 @@ export default function () {
"**/*.spec.ts"
],
"angularCompilerOptions": {
"entryModule": "src/app/app.server.module#AppServerModule"
"entryModule": "app/app.server.module#AppServerModule"
}
}
`))

View File

@ -1,9 +1,10 @@
import * as child_process from 'child_process';
import {blue, yellow} from 'chalk';
import {Subject, Observable} from 'rxjs';
import {Observable, concat, defer, EMPTY, from} from 'rxjs';
import {repeat, takeLast} from 'rxjs/operators';
import {getGlobalVariable} from './env';
import {rimraf} from './fs';
import {wait} from './utils';
import {catchError} from "rxjs/internal/operators";
const treeKill = require('tree-kill');
@ -152,16 +153,17 @@ export function execAndWaitForOutputToMatch(cmd: string, args: string[], match:
// happened just before the build (e.g. `git clean`).
// This seems to be due to host file system differences, see
// https://nodejs.org/docs/latest/api/fs.html#fs_caveats
return Observable.fromPromise(_exec({ waitForMatch: match }, cmd, args))
.concat(
Observable.defer(() =>
Observable.fromPromise(waitForAnyProcessOutputToMatch(match, 2500))
.repeat(20)
.catch(_x => Observable.empty())
)
)
.takeLast(1)
.toPromise();
return concat(
from(
_exec({ waitForMatch: match }, cmd, args)
),
defer(() => waitForAnyProcessOutputToMatch(match, 2500)).pipe(
repeat(20),
catchError(() => EMPTY),
),
).pipe(
takeLast(1),
).toPromise();
} else {
return _exec({ waitForMatch: match }, cmd, args);
}

View File

@ -73,30 +73,31 @@ function lastLogger() {
return logStack[logStack.length - 1];
}
(console as any).debug = (msg: string, ...args: any[]) => {
const logger = lastLogger();
if (logger) {
logger.debug(msg, { args });
}
};
console.log = (msg: string, ...args: any[]) => {
const logger = lastLogger();
if (logger) {
logger.info(msg, { args });
}
};
console.warn = (msg: string, ...args: any[]) => {
const logger = lastLogger();
if (logger) {
logger.warn(msg, { args });
}
};
console.error = (msg: string, ...args: any[]) => {
const logger = lastLogger();
if (logger) {
logger.error(msg, { args });
}
};
// This code doesn't work and I have no idea why and no intention to investigate at this point.
// (console as any).debug = (msg: string, ...args: any[]) => {
// const logger = lastLogger();
// if (logger) {
// logger.debug(msg, { args });
// }
// };
// console.log = (msg: string, ...args: any[]) => {
// const logger = lastLogger();
// if (logger) {
// logger.info(msg, { args });
// }
// };
// console.warn = (msg: string, ...args: any[]) => {
// const logger = lastLogger();
// if (logger) {
// logger.warn(msg, { args });
// }
// };
// console.error = (msg: string, ...args: any[]) => {
// const logger = lastLogger();
// if (logger) {
// logger.error(msg, { args });
// }
// };
const testGlob = argv.glob || 'tests/**/*.ts';
let currentFileName = null;