@@ -244,79 +244,8 @@ function measureLibrary() {
244
244
return Promise . all ( UMD_NAMES . map ( measure ) ) ;
245
245
}
246
246
247
- async function buildDocs ( ) {
248
- try {
249
- // INVESTIGATE json to stdout rather than FS?
250
- await Promise . all (
251
- MODULES . map ( module =>
252
- spawnPromise ( 'npx' , [ 'typedoc' ,
253
- `${ module === 'core' ?
254
- join ( process . cwd ( ) , 'src' ) :
255
- join ( process . cwd ( ) , 'src' , module ) } `,
256
- '--json' ,
257
- join ( process . cwd ( ) , 'dist' , 'typedocs' , `${ module } .json` )
258
- ] ) ) ) ;
259
- const entries = await Promise . all ( MODULES . map ( async ( module ) => {
260
247
261
- const buffer = await readFile ( join ( process . cwd ( ) , 'dist' , 'typedocs' , `${ module } .json` ) ) ;
262
- const typedoc = JSON . parse ( buffer . toString ( ) ) ;
263
- if ( ! typedoc . children ) {
264
- console . error ( 'typedoc fail' , module ) ;
265
- }
266
- // TODO infer the entryPoint from the package.json
267
- const entryPoint = typedoc . children . find ( ( c : any ) => c . name === '"public_api"' ) ;
268
- const allChildren = [ ] . concat ( ...typedoc . children . map ( child =>
269
- // TODO chop out the working directory and filename
270
- child . children ?
271
- child . children . map ( c => {
272
- return { ...c , path : dirname ( child . originalName . split ( process . cwd ( ) ) [ 1 ] ) } ;
273
- } ) :
274
- [ ]
275
- ) ) ;
276
- return ( entryPoint . children || [ ] )
277
- . filter ( c => c . name [ 0 ] !== 'ɵ' && c . name [ 0 ] !== '_' /* private */ )
278
- . map ( child => ( { ...allChildren . find ( c => child . target === c . id ) } ) )
279
- . reduce ( ( acc , child ) => ( { ...acc , [ encodeURIComponent ( child . name ) ] : child } ) , { } ) ;
280
- } ) ) ;
281
- const root = await rootPackage ;
282
- const pipes = [ 'MonoTypeOperatorFunction' , 'OperatorFunction' , 'AuthPipe' , 'UnaryFunction' ] ;
283
- const tocType = child => {
284
- const decorators : string [ ] = child . decorators && child . decorators . map ( d => d . name ) || [ ] ;
285
- if ( decorators . includes ( 'NgModule' ) ) {
286
- return 'NgModule' ;
287
- } else if ( child . kindString === 'Type alias' ) {
288
- return 'Type alias' ;
289
- } else if ( child . kindString === 'Variable' && child . defaultValue && child . defaultValue . startsWith ( 'new InjectionToken' ) ) {
290
- return 'InjectionToken' ;
291
- } else if ( child . type ) {
292
- return pipes . includes ( child . type . name ) ? 'Pipe' : child . type . name ;
293
- } else if ( child . signatures && child . signatures [ 0 ] && child . signatures [ 0 ] . type && pipes . includes ( child . signatures [ 0 ] . type . name ) ) {
294
- return 'Pipe' ;
295
- } else {
296
- return child . kindString ;
297
- }
298
- } ;
299
- const tableOfContents = entries . reduce ( ( acc , entry , index ) =>
300
- ( {
301
- ...acc , [ MODULES [ index ] ] : {
302
- name : ENTRY_NAMES [ index ] ,
303
- exports : Object . keys ( entry ) . reduce ( ( acc , key ) => ( { ...acc , [ key ] : tocType ( entry [ key ] ) } ) , { } )
304
- }
305
- } ) ,
306
- { }
307
- ) ;
308
- const afdoc = entries . reduce ( ( acc , entry , index ) => ( { ...acc , [ MODULES [ index ] ] : entry } ) , { table_of_contents : tableOfContents } ) ;
309
- return writeFile ( join ( process . cwd ( ) , `api-${ root . version } .json` ) , JSON . stringify ( afdoc , null , 2 ) ) ;
310
- } catch ( e ) {
311
- console . warn ( e ) ;
312
- return Promise . resolve ( ) ;
313
- }
314
- }
315
-
316
- Promise . all ( [
317
- buildDocs ( ) ,
318
- buildLibrary ( )
319
- ] ) . then ( measureLibrary ) . then ( stats =>
248
+ buildLibrary ( ) . then ( measureLibrary ) . then ( stats =>
320
249
console . log ( `
321
250
Package Size Gzipped
322
251
------------------------------------
0 commit comments