1717import * as fs from 'fs' ;
1818import { Observable , Subject } from 'rxjs' ;
1919import { filter } from 'rxjs/operators' ;
20- import { build_event_stream as bes } from './build_event_stream ' ;
20+ import { BuildEvent } from 'angular_cli/third_party/github.com/bazelbuild/bazel/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream_pb ' ;
2121
2222function updateUi ( s : string , ...more : Array < { } > ) {
2323 console . error ( '-->' , s , ...more ) ;
@@ -31,40 +31,43 @@ type payloadType = 'unknown'|'progress'|'started'|'unstructuredCommandLine'|
3131 'testResult' | 'testSummary' | 'buildFinished' | 'buildToolLogs' | 'buildMetrics' ;
3232
3333function filterType ( s : payloadType ) {
34- return filter ( ( evt : bes . BuildEvent ) => {
35- if ( ! evt . id ) {
34+ return filter ( ( evt : BuildEvent ) => {
35+ const id = evt . getId ( ) ;
36+ if ( ! id ) {
3637 throw new Error ( `expected BuildEvent to contain id
3738 ${ JSON . stringify ( evt ) } ` ) ;
3839 }
39- return Object . keys ( evt . id ) [ 0 ] === s ;
40+ return Object . keys ( id ) [ 0 ] === s ;
4041 } ) ;
4142}
4243
4344async function main ( argv : string [ ] ) : Promise < 0 | 1 > {
44- const s = new Subject < bes . BuildEvent > ( ) ;
45- const o : Observable < bes . BuildEvent > = s . asObservable ( ) ;
45+ const s = new Subject < BuildEvent > ( ) ;
46+ const o : Observable < BuildEvent > = s . asObservable ( ) ;
4647 o . pipe ( filterType ( 'testSummary' ) ) . subscribe ( {
47- next : ( evt : bes . BuildEvent ) => {
48- if ( ! evt . id || ! evt . id . testSummary || ! evt . testSummary ) {
48+ next : ( evt : BuildEvent ) => {
49+ const id = evt . getId ( ) ;
50+ if ( ! id || ! id . getTestSummary ( ) || ! evt . getTestSummary ( ) ) {
4951 throw new Error (
5052 `expected BuildEvent to contain id, testSummary, id.testSummary
5153 ${ JSON . stringify ( evt ) } ` ) ;
5254 }
5355 updateUi ( 'Test result' , {
54- label : evt . id . testSummary . label ,
55- overallStatus : evt . testSummary . overallStatus ,
56+ label : id . getTestSummary ( ) ! . getLabel ( ) ,
57+ overallStatus : evt . getTestSummary ( ) ! . getOverallStatus ( ) ,
5658 } ) ;
5759 }
5860 } ) ;
5961
6062 o . pipe ( filterType ( 'buildFinished' ) ) . subscribe ( {
61- next : ( evt : bes . BuildEvent ) => {
62- if ( ! evt . finished || ! evt . finished . exitCode ) {
63+ next : ( evt : BuildEvent ) => {
64+ const finished = evt . getFinished ( ) ;
65+ if ( ! finished || ! finished . getExitCode ( ) ) {
6366 throw new Error (
6467 `expected BuildEvent to contain finished, finished.exitCode
6568 ${ JSON . stringify ( evt ) } ` ) ;
6669 }
67- const exitName = evt . finished . exitCode . name ;
70+ const exitName = finished . getExitCode ( ) ! . getName ( ) ;
6871 switch ( exitName ) {
6972 case 'SUCCESS' :
7073 updateUi ( 'Thumbs up' ) ;
0 commit comments