Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const modifyJson = require('../utility/modify-json-file');
const schematicsVersion = latestVersions['devextreme-schematics'] || 'latest';

const minNgCliVersion = new semver('21.0.0');
const ngCliWithZoneless = new semver('21.0.0');

async function runSchematicCommand(schematicCommand, options, evaluatingOptions) {
const collectionName = 'devextreme-schematics';
Expand Down Expand Up @@ -100,7 +99,6 @@ const bumpAngular = (appPath, versionTag) => {

const create = async(appName, options) => {
const layout = await getLayoutInfo(options.layout);
const currentNgVersion = ngVersion.getNgCliVersion().version;
const depsVersionTag = extractDepsVersionTag(options);

const commandArguments = [
Expand All @@ -115,10 +113,6 @@ const create = async(appName, options) => {
'--ai-config=none'
];

if(ngCliWithZoneless.compare(currentNgVersion) <= 0) {
commandArguments.push('--zoneless=false');
}

await runNgCommand(commandArguments, options);

const appPath = path.join(process.cwd(), appName);
Expand All @@ -140,8 +134,7 @@ const create = async(appName, options) => {
const addTemplate = async(appName, options, evaluatingOptions) => {
const schematicOptions = {
...(appName && { project: appName }),
...options,
globalNgCliVersion: ngVersion.getNgCliVersion().version
...options
};
runSchematicCommand('add-app-template', schematicOptions, evaluatingOptions);
};
Expand Down
18 changes: 1 addition & 17 deletions packages/devextreme-cli/src/utility/ng-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ const getLocalNgVersion = () => {
}
};

const getPublicNgVersion = () => {
const version = execSync('npm view @angular/cli@v21-lts version').toString();
return new semver(version);
};

const getNgCliVersion = () => {
let ngCliVersion = getLocalNgVersion();
if(!ngCliVersion) {
ngCliVersion = getPublicNgVersion();
}

return ngCliVersion;
};

module.exports = {
getLocalNgVersion,
getPublicNgVersion,
getNgCliVersion
getLocalNgVersion
};
34 changes: 32 additions & 2 deletions packages/devextreme-cli/testing/verifying.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,39 @@ const verifyThemesAreBuilt = (env) => {
return missing.map(outputFile => `${env.engine}: '${outputFile}' was not generated on the application creation`);
};

const verifyZoneless = (env) => {
if(env.engine !== 'angular') {
return [];
}

const problems = [];
const { dependencies = {}, devDependencies = {} } = readJson(path.join(env.appPath, 'package.json'));

if('zone.js' in dependencies || 'zone.js' in devDependencies) {
problems.push(`${env.engine}: package.json has the 'zone.js' dependency`);
}

const { projects } = readJson(path.join(env.appPath, 'angular.json'));
Object.keys(projects).forEach(projectName => {
const polyfills = projects[projectName].architect.build.options.polyfills || [];

if([].concat(polyfills).includes('zone.js')) {
problems.push(`${env.engine}: angular.json has the 'zone.js' polyfill in the '${projectName}' project`);
}
});

const appConfig = fs.readFileSync(path.join(env.appPath, 'src/app/app.config.ts'), 'utf8');
if(appConfig.includes('provideZoneChangeDetection')) {
problems.push(`${env.engine}: app.config.ts uses provideZoneChangeDetection`);
}

return problems;
};

const verify = (env) => [
...verifyNoInstallScripts(env),
...verifyThemesAreBuilt(env)
...verifyThemesAreBuilt(env),
...verifyZoneless(env)
];

(function verifyProcess() {
Expand All @@ -56,5 +86,5 @@ const verify = (env) => [
process.exit(1);
}

console.log('The generated applications need no install scripts.');
console.log('The generated applications passed verification.');
})();
3 changes: 1 addition & 2 deletions packages/devextreme-schematics/src/add-app-template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export default function(options: any): Rule {
resolveConflicts: options.resolveConflicts,
project: options.project,
skipInstall: true,
updateBudgets: options.updateBudgets,
globalNgCliVersion: options.globalNgCliVersion
updateBudgets: options.updateBudgets
})
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@
"description": "The DevExtreme version",
"default": "26.1.6"
},
"globalNgCliVersion": {
"type":"string",
"default": "^17.2.0"
},
"empty": {
"type": "boolean",
"description": "Specifies whether to skip sample views generation",
Expand Down
1 change: 0 additions & 1 deletion packages/devextreme-schematics/src/add-layout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ A schematic that adds a DevExtreme layout to a DevExtreme Angular application.

- skip-install (boolean)
Specifies whether to skip the dependency package installation

Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { ApplicationConfig<% if (!zoneless) { %>, provideZoneChangeDetection<% } %> } from '@angular/core';
import { provideRouter, withHashLocation } from '@angular/router';
import { routes } from './app.routes';
import {
AppInfoService,
AuthGuardService,
AuthService,
ScreenService,
} from './shared/services';

export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
providers: [<% if (!zoneless) { %>
provideZoneChangeDetection({ eventCoalescing: true }),<% } %>
Comment thread
vorobey marked this conversation as resolved.
Resolved
provideRouter(routes, withHashLocation()),
AuthGuardService,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing our services?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've added for our services @Injectable({ providedIn: 'root' }). So here no reason to left them in providers array. It's debatable decision.
Leaving them in providers array is more transparent choice and matches our previous generated apps. But it seems @Injectable({ providedIn: 'root' }) is current angular convention because ng generate service does the same thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus - smaller app.config might be easier to restore by user if we overwrite smth

AuthService,
ScreenService,
AppInfoService,
]
};
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<dx-drawer
class="drawer"
position="before"
[closeOnOutsideClick]="shaderEnabled"
[openedStateMode]="menuMode"
[revealMode]="menuRevealMode"
[minSize]="minMenuSize"
[shading]="shaderEnabled"
[closeOnOutsideClick]="shaderEnabled()"
[openedStateMode]="menuMode()"
[revealMode]="menuRevealMode()"
[minSize]="minMenuSize()"
[shading]="shaderEnabled()"
[(opened)]="menuOpened">

<app-side-navigation-menu
[compactMode]="!menuOpened"
[selectedItem]="selectedRoute"
[class]="swatchClassName"
[compactMode]="!menuOpened()"
[selectedItem]="selectedRoute()"
[class]="swatchClassName()"
*dxTemplate="let dataMenu of 'panel'"
(selectedItemChanged)="navigationChanged($event)"
(openMenu)="navigationClick()">
<dx-toolbar id="navigation-header">
@if (minMenuSize !== 0) {
@if (minMenuSize() !== 0) {
<dxi-toolbar-item
location="before"
cssClass="menu-button"
Expand All @@ -38,8 +38,8 @@

<div class="container">
<app-header
[menuToggleEnabled]="minMenuSize === 0"
(menuToggle)="menuOpened = !menuOpened;">
[menuToggleEnabled]="minMenuSize() === 0"
(menuToggle)="menuOpened.set(!menuOpened())">
</app-header>

<dx-scroll-view class="layout-body with-footer">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { Component, OnInit, Input, ViewChild, signal } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { CommonModule } from '@angular/common';

Expand Down Expand Up @@ -27,32 +27,32 @@ import { ThemeService } from '../../shared/services/theme.service';
})
export class SideNavInnerToolbarComponent implements OnInit {
@ViewChild(DxScrollViewComponent, { static: true }) scrollView!: DxScrollViewComponent;
selectedRoute = '';
selectedRoute = signal('');

menuOpened!: boolean;
temporaryMenuOpened = false;
menuOpened = signal(false);
temporaryMenuOpened = signal(false);

@Input()
title!: string;

menuMode: DxDrawerTypes.OpenedStateMode = 'shrink';
menuRevealMode: DxDrawerTypes.RevealMode = 'expand';
minMenuSize = 0;
shaderEnabled = false;
swatchClassName = 'dx-swatch-additional';
menuMode = signal<DxDrawerTypes.OpenedStateMode>('shrink');
menuRevealMode = signal<DxDrawerTypes.RevealMode>('expand');
minMenuSize = signal(0);
shaderEnabled = signal(false);
swatchClassName = signal('dx-swatch-additional');

constructor(protected themeService: ThemeService, private screen: ScreenService, private router: Router) {
themeService.isDark.subscribe((isDark) => {
this.swatchClassName = 'dx-swatch-additional' + (isDark ? '-dark' : '');
this.swatchClassName.set('dx-swatch-additional' + (isDark ? '-dark' : ''));
})
}

ngOnInit() {
this.menuOpened = this.screen.sizes['screen-large'];
this.menuOpened.set(this.screen.sizes['screen-large']);

this.router.events.subscribe(val => {
if (val instanceof NavigationEnd) {
this.selectedRoute = val.urlAfterRedirects.split('?')[0];
this.selectedRoute.set(val.urlAfterRedirects.split('?')[0]);
}
});

Expand All @@ -65,30 +65,30 @@ export class SideNavInnerToolbarComponent implements OnInit {
const isXSmall = this.screen.sizes['screen-x-small'];
const isLarge = this.screen.sizes['screen-large'];

this.menuMode = isLarge ? 'shrink' : 'overlap';
this.menuRevealMode = isXSmall ? 'slide' : 'expand';
this.minMenuSize = isXSmall ? 0 : 60;
this.shaderEnabled = !isLarge;
this.menuMode.set(isLarge ? 'shrink' : 'overlap');
this.menuRevealMode.set(isXSmall ? 'slide' : 'expand');
this.minMenuSize.set(isXSmall ? 0 : 60);
this.shaderEnabled.set(!isLarge);
}

toggleMenu = (e: DxToolbarTypes.ItemClickEvent) => {
this.menuOpened = !this.menuOpened;
this.menuOpened.update((opened) => !opened);
e.event?.stopPropagation();
}

get hideMenuAfterNavigation() {
return this.menuMode === 'overlap' || this.temporaryMenuOpened;
return this.menuMode() === 'overlap' || this.temporaryMenuOpened();
}

get showMenuAfterClick() {
return !this.menuOpened;
return !this.menuOpened();
}

navigationChanged(event: DxTreeViewTypes.ItemClickEvent) {
const path = (event.itemData as any).path;
const pointerEvent = event.event;

if (path && this.menuOpened) {
if (path && this.menuOpened()) {
if (event.node?.selected) {
pointerEvent?.preventDefault();
} else {
Expand All @@ -97,8 +97,8 @@ export class SideNavInnerToolbarComponent implements OnInit {
}

if (this.hideMenuAfterNavigation) {
this.temporaryMenuOpened = false;
this.menuOpened = false;
this.temporaryMenuOpened.set(false);
this.menuOpened.set(false);
pointerEvent?.stopPropagation();
}
} else {
Expand All @@ -108,8 +108,8 @@ export class SideNavInnerToolbarComponent implements OnInit {

navigationClick() {
if (this.showMenuAfterClick) {
this.temporaryMenuOpened = true;
this.menuOpened = true;
this.temporaryMenuOpened.set(true);
this.menuOpened.set(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<app-header
class="layout-header"
[menuToggleEnabled]="true"
(menuToggle)="menuOpened = !menuOpened;"
(menuToggle)="menuOpened.set(!menuOpened())"
[title]="title">
</app-header>

<dx-drawer
class="layout-body"
position="before"
[closeOnOutsideClick]="shaderEnabled"
[openedStateMode]="menuMode"
[revealMode]="menuRevealMode"
[minSize]="minMenuSize"
[shading]="shaderEnabled"
[closeOnOutsideClick]="shaderEnabled()"
[openedStateMode]="menuMode()"
[revealMode]="menuRevealMode()"
[minSize]="minMenuSize()"
[shading]="shaderEnabled()"
[(opened)]="menuOpened">

<app-side-navigation-menu
[compactMode]="!menuOpened"
[selectedItem]="selectedRoute"
[class]="swatchClassName"
[compactMode]="!menuOpened()"
[selectedItem]="selectedRoute()"
[class]="swatchClassName()"
*dxTemplate="let dataMenu of 'panel'"
(selectedItemChanged)="navigationChanged($event)"
(openMenu)="navigationClick()">
Expand Down
Loading
Loading