Skip to content

Commit 4e93779

Browse files
authored
fix(schematics): add stylePreprocessorOptions to config and put official schematics (#12345)
1 parent 423cb0a commit 4e93779

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

projects/igniteui-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"igniteui-theming": "^1.1.2"
8787
},
8888
"igxDevDependencies": {
89-
"@igniteui/angular-schematics": "~15.0.1100-rc.0"
89+
"@igniteui/angular-schematics": "~15.0.1100"
9090
},
9191
"ng-update": {
9292
"migrations": "./migrations/migration-collection.json"

projects/igniteui-angular/schematics/utils/dependency-handler.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ export const logSuccess = (options: Options): Rule => (tree: Tree, context: Sche
9494
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9595
export const addDependencies = (options: Options) => async (tree: Tree, context: SchematicContext): Promise<void> => {
9696
const pkgJson = require('../../package.json');
97+
const workspaceHost = createHost(tree);
98+
const { workspace } = await workspaces.readWorkspace(tree.root.path, workspaceHost);
9799

98-
await includeDependencies(pkgJson, context, tree);
100+
await includeDependencies(workspaceHost, workspace, pkgJson, context, tree);
99101

102+
await includeStylePreprocessorOptions(workspaceHost, workspace, context, tree)
100103

101104
addPackageToPkgJson(tree, schematicsPackage, pkgJson.igxDevDependencies[schematicsPackage], PackageTarget.DEV);
102105
};
@@ -152,23 +155,36 @@ const addHammerToConfig =
152155
context.logger.warn(`Could not find a matching scripts array property under ${config} options. ` +
153156
`It could require you to manually update it to 'scripts': [ ${hammerjsFilePath}] `);
154157
}
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);
155172

156173
// if there are no elements in the architect[config]options.stylePreprocessorOptions.includePaths that contain node_modules
157174
const stylePrepropPath = 'node_modules';
158175
if (!projectOptions?.stylePreprocessorOptions?.includePaths?.some(el => el.includes(stylePrepropPath))) {
159176
if (projectOptions?.stylePreprocessorOptions?.includePaths) {
160177
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"] }`);
162183
}
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"] }`);
165184
}
166185
};
167186

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> => {
172188
for (const pkg of Object.keys(pkgJson.dependencies)) {
173189
const version = pkgJson.dependencies[pkg];
174190
const entry = DEPENDENCIES_MAP.find(e => e.name === pkg);

0 commit comments

Comments
 (0)