Skip to content

Commit 008d237

Browse files
committed
feat: small fix angular 20 for app
1 parent 8489f87 commit 008d237

File tree

1 file changed

+11
-11
lines changed
  • packages/devextreme-schematics/src/add-view

1 file changed

+11
-11
lines changed

packages/devextreme-schematics/src/add-view/index.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from '../utility/routing';
2424

2525
import { getSourceFile } from '../utility/source';
26-
import { getAngularVersion, isAngularVersionHigherThan } from '../utility/angular-version';
26+
import { isAngularVersionHigherThan } from '../utility/angular-version';
2727

2828
import { strings, basename, normalize, dirname, Path } from '@angular-devkit/core';
2929

@@ -107,7 +107,8 @@ export function addViewToRouting(options: any) {
107107

108108
const name = options.name.replace(/^pages\//, '');
109109
const componentName = getRouteComponentName(name);
110-
const path = isAngularVersionHigherThan(host, 20) ? `./pages/${name}/${name}.ts` : `./pages/${name}/${name}.component.ts`;
110+
const path = isAngularVersionHigherThan(host, 20) ? `./pages/${name}/${name}.component` : `./pages/${name}/${name}.component.ts`;
111+
111112
const importChanges = insertImport(source, routingModulePath, componentName, path);
112113
applyChanges(host, [importChanges], routingModulePath);
113114
}
@@ -139,11 +140,11 @@ function overwriteModuleContent(options: any, path: string, content: string) {
139140
};
140141
}
141142

142-
function getComponentFileNames(name: string, angularVersion: number) {
143+
function getComponentFileNames(name: string, host: Tree) {
143144
const baseName = strings.dasherize(basename(normalize(name)));
144145
const path = `${dirname(name as Path)}/${baseName}`;
145146

146-
if (angularVersion >= 20) {
147+
if (isAngularVersionHigherThan(host, 20)) {
147148
return {
148149
path,
149150
ts: `${path}/${baseName}.ts` as Path,
@@ -160,8 +161,8 @@ function getComponentFileNames(name: string, angularVersion: number) {
160161
};
161162
}
162163

163-
function addContentToView(options: any, angularVersion: number) {
164-
const { html } = getComponentFileNames(options.name, angularVersion);
164+
function addContentToView(options: any, host: Tree) {
165+
const { html } = getComponentFileNames(options.name, host);
165166
const title = humanize(strings.dasherize(basename(normalize(options.name))));
166167
const content = `<h2>${title}</h2>
167168
<div class="content-block">
@@ -172,8 +173,8 @@ function addContentToView(options: any, angularVersion: number) {
172173
return overwriteModuleContent(options, html, content);
173174
}
174175

175-
async function addContentToTS(options: any, angularVersion: number) {
176-
const { ts, html, style } = getComponentFileNames(options.name, angularVersion);
176+
async function addContentToTS(options: any, host: Tree) {
177+
const { ts, html, style } = getComponentFileNames(options.name, host);
177178
const name = strings.dasherize(basename(normalize(options.name)));
178179
const componentName = strings.classify(basename(normalize(name)));
179180
const content = `import { Component } from '@angular/core';
@@ -198,7 +199,6 @@ export default function(options: any): Rule {
198199
const project = await getProjectName(host, options.project);
199200
const module = getModuleName(addRoute, options.module);
200201
const name = getPathForView(options.name);
201-
const angularVersion = getAngularVersion(host);
202202

203203
const rules = [externalSchematic('../node_modules/@schematics/angular', 'component', {
204204
name,
@@ -209,8 +209,8 @@ export default function(options: any): Rule {
209209
prefix: options.prefix,
210210
standalone: true
211211
}),
212-
addContentToView({ name, project }, angularVersion) as any,
213-
addContentToTS({ name, project }, angularVersion) as any
212+
addContentToView({ name, project }, host) as any,
213+
addContentToTS({ name, project }, host) as any
214214
];
215215

216216
if (addRoute) {

0 commit comments

Comments
 (0)