@@ -94,9 +94,12 @@ export const logSuccess = (options: Options): Rule => (tree: Tree, context: Sche
94
94
// eslint-disable-next-line @typescript-eslint/no-unused-vars
95
95
export const addDependencies = ( options : Options ) => async ( tree : Tree , context : SchematicContext ) : Promise < void > => {
96
96
const pkgJson = require ( '../../package.json' ) ;
97
+ const workspaceHost = createHost ( tree ) ;
98
+ const { workspace } = await workspaces . readWorkspace ( tree . root . path , workspaceHost ) ;
97
99
98
- await includeDependencies ( pkgJson , context , tree ) ;
100
+ await includeDependencies ( workspaceHost , workspace , pkgJson , context , tree ) ;
99
101
102
+ await includeStylePreprocessorOptions ( workspaceHost , workspace , context , tree )
100
103
101
104
addPackageToPkgJson ( tree , schematicsPackage , pkgJson . igxDevDependencies [ schematicsPackage ] , PackageTarget . DEV ) ;
102
105
} ;
@@ -152,23 +155,36 @@ const addHammerToConfig =
152
155
context . logger . warn ( `Could not find a matching scripts array property under ${ config } options. ` +
153
156
`It could require you to manually update it to 'scripts': [ ${ hammerjsFilePath } ] ` ) ;
154
157
}
158
+ } ;
159
+
160
+ const includeStylePreprocessorOptions = async ( workspaceHost : workspaces . WorkspaceHost , workspace : workspaces . WorkspaceDefinition , context : SchematicContext , tree : Tree ) : Promise < void > => {
161
+ await Promise . all ( Array . from ( workspace . projects . values ( ) ) . map ( async ( project ) => {
162
+ await addStylePreprocessorOptions ( project , tree , "build" , context ) ;
163
+ await addStylePreprocessorOptions ( project , tree , "test" , context ) ;
164
+ } ) ) ;
165
+
166
+ await workspaces . writeWorkspace ( workspace , workspaceHost ) ;
167
+ } ;
168
+
169
+ const addStylePreprocessorOptions =
170
+ async ( project : workspaces . ProjectDefinition , tree : Tree , config : string , context : SchematicContext ) : Promise < void > => {
171
+ const projectOptions = getTargetedProjectOptions ( project , config , context ) ;
155
172
156
173
// if there are no elements in the architect[config]options.stylePreprocessorOptions.includePaths that contain node_modules
157
174
const stylePrepropPath = 'node_modules' ;
158
175
if ( ! projectOptions ?. stylePreprocessorOptions ?. includePaths ?. some ( el => el . includes ( stylePrepropPath ) ) ) {
159
176
if ( projectOptions ?. stylePreprocessorOptions ?. includePaths ) {
160
177
projectOptions ?. stylePreprocessorOptions ?. includePaths . push ( stylePrepropPath ) ;
161
- return ;
178
+ } else if ( ! projectOptions ?. stylePreprocessorOptions ) {
179
+ projectOptions [ "stylePreprocessorOptions" ] = { includePaths : [ stylePrepropPath ] } ;
180
+ } else {
181
+ context . logger . warn ( `Could not find a matching stylePreprocessorOptions includePaths array property under ${ config } options. ` +
182
+ `It could require you to manually update it to "stylePreprocessorOptions": { "includePaths": ["node_modules"] }` ) ;
162
183
}
163
- context . logger . warn ( `Could not find a matching stylePreprocessorOptions includePaths array property under ${ config } options. ` +
164
- `It could require you to manually update it to "stylePreprocessorOptions": { "includePaths": ["node_modules"] }` ) ;
165
184
}
166
185
} ;
167
186
168
- const includeDependencies = async ( pkgJson : any , context : SchematicContext , tree : Tree ) : Promise < void > => {
169
- const workspaceHost = createHost ( tree ) ;
170
- const { workspace } = await workspaces . readWorkspace ( tree . root . path , workspaceHost ) ;
171
-
187
+ const includeDependencies = async ( workspaceHost : workspaces . WorkspaceHost , workspace : workspaces . WorkspaceDefinition , pkgJson : any , context : SchematicContext , tree : Tree ) : Promise < void > => {
172
188
for ( const pkg of Object . keys ( pkgJson . dependencies ) ) {
173
189
const version = pkgJson . dependencies [ pkg ] ;
174
190
const entry = DEPENDENCIES_MAP . find ( e => e . name === pkg ) ;
0 commit comments