11import {
2- BuilderContext ,
32 createBuilder ,
4- targetFromTargetString
3+ targetFromTargetString ,
54} from '@angular-devkit/architect' ;
6- import {
7- ExecutionTransformer ,
8- executeDevServerBuilder
9- } from '@angular-devkit/build-angular' ;
10- import {
5+ import type { BuilderContext } from '@angular-devkit/architect' ;
6+ import { executeDevServerBuilder } from '@angular-devkit/build-angular' ;
7+ import type { ExecutionTransformer } from '@angular-devkit/build-angular' ;
8+ import type {
119 DevServerBuilderOptions ,
12- DevServerBuilderOutput
10+ DevServerBuilderOutput ,
1311} from '@angular-devkit/build-angular/src/dev-server' ;
14- import { IndexHtmlTransform } from '@angular-devkit/build-angular/src/utils/index-file/write- index-html' ;
12+ import type { IndexHtmlTransform } from '@angular-devkit/build-angular/src/utils/index-file/index-html-generator ' ;
1513import { ScriptsWebpackPlugin } from '@angular-devkit/build-angular/src/webpack/plugins' ;
16- import { json } from '@angular-devkit/core' ;
14+ import type { json } from '@angular-devkit/core' ;
1715import * as CopyWebpackPlugin from 'copy-webpack-plugin' ;
1816import { basename } from 'path' ;
19- import { Observable , from } from 'rxjs' ;
17+ import { from } from 'rxjs' ;
18+ import type { Observable } from 'rxjs' ;
2019import { switchMap } from 'rxjs/operators' ;
21- import { Configuration } from 'webpack' ;
20+ import type { Configuration } from 'webpack' ;
2221
23- import { FormattedAssets , prepareServerConfig } from '../utils' ;
22+ import { prepareServerConfig } from '../utils' ;
23+ import type { FormattedAssets } from '../utils' ;
2424import { augmentIndexHtml } from '../utils/append-scripts' ;
2525
2626import { createConsoleLogServer } from './log-server' ;
27- import { CordovaServeBuilderSchema } from './schema' ;
27+ import type { CordovaServeBuilderSchema } from './schema' ;
2828
2929export type CordovaDevServerBuilderOptions = CordovaServeBuilderSchema &
3030 json . JsonObject ;
3131
3232export function serveCordova (
3333 options : CordovaServeBuilderSchema ,
34- context : BuilderContext
34+ context : BuilderContext ,
3535) : Observable < DevServerBuilderOutput > {
3636 const { devServerTarget, port, host, ssl } = options ;
3737 const root = context . workspaceRoot ;
3838 const devServerTargetSpec = targetFromTargetString ( devServerTarget ) ;
3939
4040 async function setup ( ) {
41- const devServerTargetOptions = ( await context . getTargetOptions ( devServerTargetSpec ) ) as DevServerBuilderOptions ;
42- const devServerName = await context . getBuilderNameForTarget ( devServerTargetSpec ) ;
41+ const devServerTargetOptions = ( await context . getTargetOptions (
42+ devServerTargetSpec ,
43+ ) ) as DevServerBuilderOptions ;
44+ const devServerName = await context . getBuilderNameForTarget (
45+ devServerTargetSpec ,
46+ ) ;
4347
4448 devServerTargetOptions . port = port ;
4549 devServerTargetOptions . host = host ;
4650 devServerTargetOptions . ssl = ssl ;
4751 // tslint:disable-next-line: no-unnecessary-type-assertion
48- const formattedOptions = await context . validateOptions ( devServerTargetOptions , devServerName ) as DevServerBuilderOptions ;
52+ const formattedOptions = ( await context . validateOptions (
53+ devServerTargetOptions ,
54+ devServerName ,
55+ ) ) as DevServerBuilderOptions ;
4956 const formattedAssets = prepareServerConfig ( options , root ) ;
5057 if ( options . consolelogs && options . consolelogsPort ) {
5158 await createConsoleLogServer ( host , options . consolelogsPort ) ;
@@ -58,14 +65,17 @@ export function serveCordova(
5865 executeDevServerBuilder (
5966 formattedOptions ,
6067 context ,
61- getTransforms ( formattedAssets , context )
62- )
63- )
68+ getTransforms ( formattedAssets , context ) ,
69+ ) ,
70+ ) ,
6471 ) ;
6572}
6673export default createBuilder < CordovaDevServerBuilderOptions , any > ( serveCordova ) ;
6774
68- function getTransforms ( formattedAssets : FormattedAssets , context : BuilderContext ) {
75+ function getTransforms (
76+ formattedAssets : FormattedAssets ,
77+ context : BuilderContext ,
78+ ) {
6979 return {
7080 webpackConfiguration : cordovaServeTransform ( formattedAssets , context ) ,
7181 indexHtml : indexHtmlTransformFactory ( formattedAssets , context ) ,
@@ -74,10 +84,10 @@ function getTransforms(formattedAssets: FormattedAssets, context: BuilderContext
7484
7585const cordovaServeTransform : (
7686 formattedAssets : FormattedAssets ,
77- context : BuilderContext
87+ context : BuilderContext ,
7888) => ExecutionTransformer < Configuration > = (
7989 formattedAssets ,
80- { workspaceRoot }
90+ { workspaceRoot } ,
8191) => browserWebpackConfig => {
8292 const scriptExtras = formattedAssets . globalScriptsByBundleName . map (
8393 ( script : { bundleName : any ; paths : any } ) => {
@@ -89,30 +99,30 @@ const cordovaServeTransform: (
8999 scripts : script . paths ,
90100 basePath : workspaceRoot ,
91101 } ) ;
92- }
102+ } ,
93103 ) ;
94104
95105 const copyWebpackPluginInstance = new CopyWebpackPlugin ( {
96- patterns : formattedAssets . copyWebpackPluginPatterns ,
106+ patterns : formattedAssets . copyWebpackPluginPatterns ,
97107 } ) ;
98108
99- // tslint: disable-next-line: no-non-null-assertion
109+ // eslint- disable-next-line @typescript-eslint/ no-non-null-assertion
100110 browserWebpackConfig . plugins ! . push (
101111 ...scriptExtras ,
102- copyWebpackPluginInstance
112+ copyWebpackPluginInstance ,
103113 ) ;
104114 return browserWebpackConfig ;
105115} ;
106116
107117export const indexHtmlTransformFactory : (
108118 formattedAssets : FormattedAssets ,
109- context : BuilderContext
119+ context : BuilderContext ,
110120) => IndexHtmlTransform = ( { globalScriptsByBundleName } ) => (
111- indexTransform : string
121+ indexTransform : string ,
112122) => {
113123 const augmentedHtml = augmentIndexHtml (
114124 indexTransform ,
115- globalScriptsByBundleName
125+ globalScriptsByBundleName ,
116126 ) ;
117127 return Promise . resolve ( augmentedHtml ) ;
118128} ;
0 commit comments