@@ -3,22 +3,20 @@ import { json } from '@angular-devkit/core';
3
3
import { Schema } from './schema' ;
4
4
import util from 'util' ;
5
5
import { exec } from 'child_process' ;
6
- import fs from 'fs' ;
7
- import inquirer from 'inquirer' ;
8
6
9
7
export const execAsync = util . promisify ( exec ) ;
10
8
11
9
export default createBuilder < any > (
12
10
async ( builderConfig : Schema , context : BuilderContext ) : Promise < BuilderOutput > => {
13
11
try {
14
- context . reportStatus ( `Executing " ${ builderConfig . noBuild } "... ` ) ;
12
+ context . reportStatus ( `Starting Build ` ) ;
15
13
// const child = childProcess.spawn(options.command, options.args, { stdio: 'pipe' });
16
14
17
15
const configuration = 'production' ;
18
16
19
17
const overrides = {
20
18
// this is an example how to override the workspace set of options
21
- ...( { sourceMap : true } )
19
+ ...( { sourceMap : true , budgets : [ ] } )
22
20
} ;
23
21
24
22
const build = await context . scheduleTarget ( {
@@ -30,31 +28,11 @@ export default createBuilder<any>(
30
28
const result = await build . result ;
31
29
32
30
if ( result . success ) {
33
- const file = fs . readdirSync ( builderConfig . outputPath ) . filter ( f => f . includes ( 'es2015' ) ) ;
34
- const filesToRemove = file . filter ( f => f . includes ( 'polyfills' ) || f . includes ( 'runtime' ) ) ;
35
- let filesToShow = file . filter ( f => ! filesToRemove . includes ( f ) && f . endsWith ( '.js' ) ) ;
36
-
37
- let mainFile = filesToShow [ 0 ] ;
38
- let promptAvailableBundles ;
39
-
40
- if ( filesToShow . length > 1 ) {
41
- promptAvailableBundles = await inquirer
42
- . prompt ( [
43
- {
44
- type : 'list' ,
45
- name : 'bundleName' ,
46
- message : 'Select the bundle to run the analyzer?' ,
47
- choices : filesToShow ,
48
- } ,
49
- ] )
50
- . catch ( error => {
51
- context . logger . info ( error ) ;
52
- } ) ;
53
-
54
- mainFile = promptAvailableBundles . bundleName ;
31
+ const mainFile = '*es2015.*.js' ;
32
+ let explorerCommand = `npx source-map-explorer ${ builderConfig . outputPath } /${ mainFile } ` ;
33
+ if ( builderConfig . gzip ) {
34
+ explorerCommand = `${ explorerCommand } --gzip` ;
55
35
}
56
-
57
- const explorerCommand = `npx source-map-explorer ${ builderConfig . outputPath } /${ mainFile } ` ;
58
36
const { stdout, stderr } = await execAsync ( explorerCommand ) ;
59
37
context . logger . info ( stdout ) ;
60
38
context . logger . info ( stderr ) ;
0 commit comments