1
- import { chain , Rule , SchematicsException , Tree } from '@angular-devkit/schematics' ;
1
+ import {
2
+ chain ,
3
+ Rule ,
4
+ SchematicsException ,
5
+ Tree ,
6
+ } from '@angular-devkit/schematics' ;
2
7
import { addImportToModule } from '@schematics/angular/utility/ast-utils' ;
3
8
import { InsertChange } from '@schematics/angular/utility/change' ;
4
9
import { getWorkspace } from '@schematics/angular/utility/config' ;
@@ -11,9 +16,9 @@ import { getProjectStyleFile } from '../utils/project-style';
11
16
import { getProjectTargetOptions } from '../utils/project-targets' ;
12
17
import { Schema } from './schema' ;
13
18
14
- const NG_BOOTSTRAP_MODULE_NAME = " NgbModule" ;
15
- const NG_BOOTSTRAP_PACKAGE_NAME = " @ng-bootstrap/ng-bootstrap" ;
16
- const BOOTSTRAP_CSS_FILEPATH = " node_modules/bootstrap/dist/css/bootstrap.css" ;
19
+ const NG_BOOTSTRAP_MODULE_NAME = ' NgbModule' ;
20
+ const NG_BOOTSTRAP_PACKAGE_NAME = ' @ng-bootstrap/ng-bootstrap' ;
21
+ const BOOTSTRAP_CSS_FILEPATH = ' node_modules/bootstrap/dist/css/bootstrap.css' ;
17
22
const BOOTSTRAP_STYLE_IMPORT = `
18
23
/* Importing Bootstrap SCSS file. */
19
24
@import '~bootstrap/scss/bootstrap';
@@ -26,7 +31,7 @@ function addNgBootstrapModuleToAppModule(options: Schema) {
26
31
workspace ,
27
32
options . project || workspace . defaultProject !
28
33
) ;
29
- const buildOptions = getProjectTargetOptions ( project , " build" ) ;
34
+ const buildOptions = getProjectTargetOptions ( project , ' build' ) ;
30
35
31
36
const modulePath = getAppModulePath ( host , buildOptions . main ) ;
32
37
@@ -37,7 +42,7 @@ function addNgBootstrapModuleToAppModule(options: Schema) {
37
42
38
43
const source = ts . createSourceFile (
39
44
modulePath ,
40
- text . toString ( " utf-8" ) ,
45
+ text . toString ( ' utf-8' ) ,
41
46
ts . ScriptTarget . Latest ,
42
47
true
43
48
) ;
@@ -74,13 +79,13 @@ function addBootstrapStyle(options: Schema) {
74
79
const schematicsConfig = project . schematics ;
75
80
if (
76
81
schematicsConfig &&
77
- schematicsConfig [ " @schematics/angular:component" ]
82
+ schematicsConfig [ ' @schematics/angular:component' ]
78
83
) {
79
- const { styleext } = schematicsConfig [ " @schematics/angular:component" ] ;
84
+ const { styleext } = schematicsConfig [ ' @schematics/angular:component' ] ;
80
85
useBootstrapSCSS =
81
86
styleext &&
82
87
`.${ styleext } ` === path . extname ( styleFilePath ) &&
83
- styleext === " scss" ;
88
+ styleext === ' scss' ;
84
89
}
85
90
86
91
if ( useBootstrapSCSS ) {
@@ -94,7 +99,7 @@ function addBootstrapStyle(options: Schema) {
94
99
}
95
100
96
101
function injectBootstrapIntoStyleFile ( host : Tree , styleFilePath : string ) {
97
- const styleContent = host . read ( styleFilePath ) ! . toString ( " utf-8" ) ;
102
+ const styleContent = host . read ( styleFilePath ) ! . toString ( ' utf-8' ) ;
98
103
99
104
const recorder = host . beginUpdate ( styleFilePath ) ;
100
105
recorder . insertRight ( styleContent . length , BOOTSTRAP_STYLE_IMPORT ) ;
@@ -108,12 +113,12 @@ function addCSSFileToTarget(options: Schema, host: Tree, assetPath: string) {
108
113
workspace ,
109
114
options . project || workspace . defaultProject !
110
115
) ;
111
- const targetOptions = getProjectTargetOptions ( project , " build" ) ;
116
+ const targetOptions = getProjectTargetOptions ( project , ' build' ) ;
112
117
if ( ! targetOptions . styles ) {
113
118
targetOptions . styles = [ assetPath ] ;
114
119
} else {
115
- const existingStyles = targetOptions . styles . map ( s =>
116
- typeof s === " string" ? s : s . input
120
+ const existingStyles = targetOptions . styles . map ( ( s ) =>
121
+ typeof s === ' string' ? s : s . input
117
122
) ;
118
123
for ( const [ , stylePath ] of existingStyles . entries ( ) ) {
119
124
// If the given asset is already specified in the styles, we don't need to do anything.
@@ -123,7 +128,7 @@ function addCSSFileToTarget(options: Schema, host: Tree, assetPath: string) {
123
128
}
124
129
targetOptions . styles . unshift ( assetPath ) ;
125
130
}
126
- host . overwrite ( " angular.json" , JSON . stringify ( workspace , null , 2 ) ) ;
131
+ host . overwrite ( ' angular.json' , JSON . stringify ( workspace , null , 2 ) ) ;
127
132
}
128
133
129
134
/**
0 commit comments