Skip to content

Commit ee61248

Browse files
authored
Update angular schematics to 16.2.10 (#889)
1 parent 6abc677 commit ee61248

File tree

11 files changed

+435
-346
lines changed

11 files changed

+435
-346
lines changed

packages/devextreme-cli/src/applications/application.angular.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const latestVersions = require('../utility/latest-versions');
1010
const { extractToolingVersion, toolingVersionOptionName } = require('../utility/extract-tooling-version');
1111
const schematicsVersion = latestVersions['devextreme-schematics'] || 'latest';
1212

13-
const minNgCliVersion = new semver('12.0.0');
13+
const minNgCliVersion = new semver('16.0.0');
1414
const ngCliWithStandalone = new semver('17.0.0');
1515

1616
async function runSchematicCommand(schematicCommand, options, evaluatingOptions) {

packages/devextreme-schematics/package-lock.json

Lines changed: 354 additions & 230 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/devextreme-schematics/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
],
2323
"schematics": "./src/collection.json",
2424
"dependencies": {
25-
"@angular-devkit/core": "^12.2.18",
26-
"@angular-devkit/schematics": "^12.2.18",
27-
"@schematics/angular": "^12.2.18"
25+
"@angular-devkit/core": "^16.2.10",
26+
"@angular-devkit/schematics": "^16.2.10",
27+
"@schematics/angular": "^16.2.10"
2828
},
2929
"devDependencies": {
3030
"@types/jasmine": "~3.10.18",
31-
"@types/node": "ts4.3",
31+
"@types/node": "ts4.9",
3232
"@types/semver": "^7.5.7",
3333
"jasmine": "^2.99.0",
3434
"rxjs": "^6.6.7",
3535
"tslint": "^5.20.1",
36-
"typescript": "^4.3.1"
36+
"typescript": "^4.9.3"
3737
}
3838
}

packages/devextreme-schematics/src/add-app-template/index_spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,33 @@ const schematicRunner = new SchematicTestRunner('@schematics/angular', angularSc
2525
let appTree: UnitTestTree;
2626

2727
beforeEach(async () => {
28-
appTree = await schematicRunner.runSchematicAsync('workspace', workspaceOptions).toPromise();
29-
appTree = await schematicRunner.runSchematicAsync('application', appOptions, appTree).toPromise();
28+
appTree = await schematicRunner.runSchematic('workspace', workspaceOptions);
29+
appTree = await schematicRunner.runSchematic('application', appOptions, appTree);
3030
});
3131

3232
describe('add-app-template', () => {
3333
it('should add DevExtreme', async () => {
3434
const runner = new SchematicTestRunner('schematics', collectionPath);
35-
const tree = await runner.runSchematicAsync('add-app-template', { }, appTree).toPromise();
35+
const tree = await runner.runSchematic('add-app-template', { }, appTree);
3636
const packageConfig = JSON.parse(tree.readContent('package.json'));
3737

3838
expect('devextreme' in packageConfig.dependencies).toBe(true);
3939
});
4040

4141
it('should consider the `project` option', async () => {
42-
appTree = await schematicRunner.runSchematicAsync('application', {
42+
appTree = await schematicRunner.runSchematic('application', {
4343
name: 'testApp2',
4444
inlineStyle: false,
4545
inlineTemplate: false,
4646
routing: true,
4747
style: 'scss',
4848
projectRoot: 'projects/testApp2'
49-
}, appTree).toPromise();
49+
}, appTree);
5050

5151
const runner = new SchematicTestRunner('schematics', collectionPath);
52-
const tree = await runner.runSchematicAsync('add-app-template', {
52+
const tree = await runner.runSchematic('add-app-template', {
5353
project: 'testApp2'
54-
}, appTree).toPromise();
54+
}, appTree);
5555

5656
expect(tree.files)
5757
.toContain('/devextreme.json');
@@ -63,7 +63,7 @@ describe('add-app-template', () => {
6363

6464
it('should consider the `updateBudgets` option', async () => {
6565
const runner = new SchematicTestRunner('schematics', collectionPath);
66-
const tree = await runner.runSchematicAsync('add-app-template', { updateBudgets: true }, appTree).toPromise();
66+
const tree = await runner.runSchematic('add-app-template', { updateBudgets: true }, appTree);
6767

6868
const angularContent = JSON.parse(tree.readContent('/angular.json'));
6969
const budgets = angularContent.projects.testApp.architect.build.configurations.production.budgets;

packages/devextreme-schematics/src/add-app-template/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/schema",
33
"$id": "SchematicsDevextremeAddAppTemplate",
4-
"title": "Add a DevExtreme layout template to an Anular application",
4+
"title": "Add a DevExtreme layout template to an Angular application",
55
"type": "object",
66
"properties": {
77
"layout": {
@@ -43,7 +43,7 @@
4343
},
4444
"globalNgCliVersion": {
4545
"type":"string",
46-
"default": "^12.0.0"
46+
"default": "^16.2.0"
4747
},
4848
"empty": {
4949
"type": "boolean",

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040

4141
import {
4242
modifyJSONFile,
43-
parseJson
4443
} from '../utility/modify-json-file';
4544

4645
import {
@@ -318,8 +317,6 @@ const modifyRoutingModule = (host: Tree, routingModulePath: string) => {
318317

319318
export default function(options: any): Rule {
320319
return async (host: Tree) => {
321-
const ngConfig = host.read('./angular.json')!.toString();
322-
const defaultProjectName = parseJson(ngConfig).defaultProject;
323320
const project = await getProjectName(host, options.project);
324321
const workspace = await getWorkspace(host);
325322
const ngProject = workspace.projects.get(project);
@@ -373,13 +370,6 @@ export default function(options: any): Rule {
373370
});
374371
}
375372

376-
if (override) {
377-
if (project === defaultProjectName) {
378-
rules.push(modifyContentByTemplate('./', workspaceFilesSource, 'e2e/src/app.e2e-spec.ts', { title }));
379-
rules.push(modifyContentByTemplate('./', workspaceFilesSource, 'e2e/src/app.po.ts'));
380-
}
381-
}
382-
383373
return chain(rules);
384374
};
385375
}

packages/devextreme-schematics/src/add-layout/index_spec.ts

Lines changed: 33 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,30 @@ describe('layout', () => {
2525

2626
const workspaceOptions: WorkspaceOptions = {
2727
name: 'workspace',
28-
version: '6.0.0'
28+
version: '16.0.0'
2929
};
3030

3131
const options: any = {
3232
layout: 'side-nav-outer-toolbar',
3333
resolveConflicts: 'override',
34-
globalNgCliVersion: '^12.2.0'
34+
globalNgCliVersion: '^16.2.0'
3535
};
3636

3737
const angularSchematicsCollection = require.resolve('../../node_modules/@schematics/angular/collection.json');
38-
const schematicRunner = new SchematicTestRunner('@schematics/angular', angularSchematicsCollection);
38+
const schematicRunner = new SchematicTestRunner(
39+
'@schematics/angular',
40+
angularSchematicsCollection,
41+
);
3942
let appTree: UnitTestTree;
4043

4144
beforeEach(async () => {
42-
appTree = await schematicRunner.runSchematicAsync('workspace', workspaceOptions).toPromise();
43-
appTree = await schematicRunner.runSchematicAsync('application', appOptions, appTree).toPromise();
45+
appTree = await schematicRunner.runSchematic('workspace', workspaceOptions);
46+
appTree = await schematicRunner.runSchematic('application', appOptions, appTree);
4447
});
4548

4649
it('should add layout with override', async () => {
4750
const runner = new SchematicTestRunner('schematics', collectionPath);
48-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
51+
const tree = await runner.runSchematic('add-layout', options, appTree);
4952

5053
expect(tree.files)
5154
.toContain('/devextreme.json');
@@ -108,12 +111,6 @@ describe('layout', () => {
108111
'ChangePasswordFormModule, ' +
109112
'LoginFormModule }');
110113

111-
const testContent = tree.readContent('/e2e/src/app.e2e-spec.ts');
112-
expect(testContent).toMatch(/'Welcome to TestApp!'/);
113-
114-
const testUtilsContent = tree.readContent('/e2e/src/app.po.ts');
115-
expect(testUtilsContent).toMatch(/'app-root .dx-drawer-content .dx-card p:nth-child\(2\)'/);
116-
117114
const appContent = tree.readContent('/src/app/app.component.ts');
118115
expect(appContent).toContain('templateUrl: \'./app.component.html\',');
119116
expect(appContent).toContain('styleUrls: [\'./app.component.scss\']');
@@ -127,7 +124,7 @@ describe('layout', () => {
127124

128125
it('should add npm scripts', async () => {
129126
const runner = new SchematicTestRunner('schematics', collectionPath);
130-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
127+
const tree = await runner.runSchematic('add-layout', options, appTree);
131128
const packageConfig = JSON.parse(tree.readContent('package.json'));
132129
expect(packageConfig.scripts['build-themes']).toBe('devextreme build');
133130
expect(packageConfig.scripts['postinstall']).toBe('npm run build-themes');
@@ -142,7 +139,7 @@ describe('layout', () => {
142139
});
143140

144141
const runner = new SchematicTestRunner('schematics', collectionPath);
145-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
142+
const tree = await runner.runSchematic('add-layout', options, appTree);
146143
const navigationMenu = tree.readContent(
147144
'/src/app/shared/components/side-navigation-menu/side-navigation-menu.component.ts');
148145

@@ -160,7 +157,7 @@ describe('layout', () => {
160157
});
161158

162159
const runner = new SchematicTestRunner('schematics', collectionPath);
163-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
160+
const tree = await runner.runSchematic('add-layout', options, appTree);
164161
const packageConfig = JSON.parse(tree.readContent('package.json'));
165162
expect(packageConfig.scripts['origin-build-themes']).toBe('prev value 1');
166163
expect(packageConfig.scripts['origin-postinstall']).toBe('prev value 2');
@@ -170,26 +167,26 @@ describe('layout', () => {
170167

171168
it('should add angular/cdk dependency', async () => {
172169
const runner = new SchematicTestRunner('schematics', collectionPath);
173-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
170+
const tree = await runner.runSchematic('add-layout', options, appTree);
174171
const packageConfig = JSON.parse(tree.readContent('package.json'));
175172

176173
expect(packageConfig.dependencies['@angular/cdk']).toBeDefined();
177174
});
178175

179176
it('should choose angular/cdk version such as angular/cli', async () => {
180177
const runner = new SchematicTestRunner('schematics', collectionPath);
181-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
178+
const tree = await runner.runSchematic('add-layout', options, appTree);
182179
const packageConfig = JSON.parse(tree.readContent('package.json'));
183180

184-
expect(packageConfig.dependencies['@angular/cdk']).toBe('~12.2.0');
181+
expect(packageConfig.dependencies['@angular/cdk']).toBe('~16.2.0');
185182
});
186183

187184
it('should update budgets if updateBudgets option is true', async () => {
188185
const runner = new SchematicTestRunner('schematics', collectionPath);
189-
const tree = await runner.runSchematicAsync('add-layout', {
186+
const tree = await runner.runSchematic('add-layout', {
190187
...options,
191188
updateBudgets: true
192-
}, appTree).toPromise();
189+
}, appTree);
193190

194191
const angularContent = JSON.parse(tree.readContent('/angular.json'));
195192
const budgets = angularContent.projects.testApp.architect.build.configurations.production.budgets;
@@ -204,7 +201,7 @@ describe('layout', () => {
204201

205202
it('should not update budgets if updateBudgets option is not defined or false', async () => {
206203
const runner = new SchematicTestRunner('schematics', collectionPath);
207-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
204+
const tree = await runner.runSchematic('add-layout', options, appTree);
208205

209206
const angularContent = JSON.parse(tree.readContent('/angular.json'));
210207
const budgets = angularContent.projects.testApp.architect.build.configurations.production.budgets;
@@ -222,7 +219,7 @@ describe('layout', () => {
222219
const runner = new SchematicTestRunner('schematics', collectionPath);
223220

224221
options.resolveConflicts = 'createNew';
225-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
222+
const tree = await runner.runSchematic('add-layout', options, appTree);
226223

227224
expect(tree.files).toContain('/src/app/app1.component.ts');
228225

@@ -243,14 +240,14 @@ describe('layout', () => {
243240
});
244241

245242
it('should add routing to layout', async () => {
246-
let newAppTree = await schematicRunner.runSchematicAsync('workspace', workspaceOptions).toPromise();
243+
let newAppTree = await schematicRunner.runSchematic('workspace', workspaceOptions);
247244

248245
appOptions.routing = false;
249-
newAppTree = await schematicRunner.runSchematicAsync(
250-
'application', appOptions, newAppTree).toPromise();
246+
newAppTree = await schematicRunner.runSchematic(
247+
'application', appOptions, newAppTree);
251248

252249
const runner = new SchematicTestRunner('schematics', collectionPath);
253-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
250+
const tree = await runner.runSchematic('add-layout', options, appTree);
254251

255252
expect(tree.files).toContain('/src/app/app-routing.module.ts');
256253
const moduleContent = tree.readContent('/src/app/app-routing.module.ts');
@@ -269,24 +266,24 @@ describe('layout', () => {
269266
const runner = new SchematicTestRunner('schematics', collectionPath);
270267
options.layout = 'side-nav-inner-toolbar';
271268
options.resolveConflicts = 'override';
272-
const tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
269+
const tree = await runner.runSchematic('add-layout', options, appTree);
273270
const content = tree.readContent('/src/app/app.component.html');
274271

275272
expect(content).toContain('app-side-nav-inner-toolbar title="{{appInfo.title}}"');
276273
});
277274

278275
it('should consider the `project` option', async () => {
279-
appTree = await schematicRunner.runSchematicAsync('application', {
276+
appTree = await schematicRunner.runSchematic('application', {
280277
...appOptions,
281278
name: 'testApp2',
282279
projectRoot: 'projects/testApp2'
283-
}, appTree).toPromise();
280+
}, appTree);
284281

285282
const runner = new SchematicTestRunner('schematics', collectionPath);
286-
const tree = await runner.runSchematicAsync('add-layout', {
283+
const tree = await runner.runSchematic('add-layout', {
287284
...options,
288285
project: 'testApp2'
289-
}, appTree).toPromise();
286+
}, appTree);
290287

291288
expect(tree.files)
292289
.toContain('/devextreme.json');
@@ -295,19 +292,19 @@ describe('layout', () => {
295292
});
296293

297294
it('should merge build commands in devextreme.json file', async () => {
298-
appTree = await schematicRunner.runSchematicAsync('application', {
295+
appTree = await schematicRunner.runSchematic('application', {
299296
...appOptions,
300297
name: 'testApp2',
301298
prefix: 'app2',
302299
projectRoot: 'projects/testApp2'
303-
}, appTree).toPromise();
300+
}, appTree);
304301

305302
const runner = new SchematicTestRunner('schematics', collectionPath);
306-
let tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
307-
tree = await runner.runSchematicAsync('add-layout', {
303+
let tree = await runner.runSchematic('add-layout', options, appTree);
304+
tree = await runner.runSchematic('add-layout', {
308305
...options,
309306
project: 'testApp2'
310-
}, appTree).toPromise();
307+
}, appTree);
311308

312309
const appContent = tree.readContent('projects/testApp2/src/app/app.component.ts');
313310
expect(appContent).toContain('selector: \'app2-root\',');
@@ -316,25 +313,4 @@ describe('layout', () => {
316313
expect(content).toContain('"inputFile": "src/themes/metadata.base.json",');
317314
expect(content).toContain('"inputFile": "projects/testApp2/src/themes/metadata.base.json",');
318315
});
319-
320-
it('should add e2e tests only for default project', async () => {
321-
appTree = await schematicRunner.runSchematicAsync('application', {
322-
...appOptions,
323-
name: 'testApp2',
324-
projectRoot: 'projects/testApp2'
325-
}, appTree).toPromise();
326-
327-
const runner = new SchematicTestRunner('schematics', collectionPath);
328-
let tree = await runner.runSchematicAsync('add-layout', options, appTree).toPromise();
329-
tree = await runner.runSchematicAsync('add-layout', {
330-
...options,
331-
project: 'testApp2'
332-
}, appTree).toPromise();
333-
334-
const testContent = tree.readContent('/e2e/src/app.e2e-spec.ts');
335-
expect(testContent).toContain('Welcome to TestApp!');
336-
337-
const testUtilsContent = tree.readContent('/e2e/src/app.po.ts');
338-
expect(testUtilsContent).toMatch(/'app-root .dx-drawer-content .dx-card p:nth-child\(2\)'/);
339-
});
340316
});

packages/devextreme-schematics/src/add-layout/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
},
5050
"globalNgCliVersion": {
5151
"type":"string",
52-
"default": "12.2.0"
52+
"default": "16.2.0"
5353
}
5454
}
5555
}

packages/devextreme-schematics/src/add-sample-views/index_spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ describe('sample views', () => {
3030
let appTree: UnitTestTree;
3131

3232
beforeEach(async () => {
33-
appTree = await schematicRunner.runSchematicAsync('workspace', workspaceOptions).toPromise();
34-
appTree = await schematicRunner.runSchematicAsync('application', appOptions, appTree).toPromise();
33+
appTree = await schematicRunner.runSchematic('workspace', workspaceOptions);
34+
appTree = await schematicRunner.runSchematic('application', appOptions, appTree);
3535
});
3636

3737
it('should add sample views', async () => {
3838
const runner = new SchematicTestRunner('schematics', collectionPath);
39-
let tree = await runner.runSchematicAsync('add-layout', { layout: 'side-nav-outer-toolbar' }, appTree).toPromise();
40-
tree = await runner.runSchematicAsync('add-sample-views', sampleViewsOptions, tree).toPromise();
39+
let tree = await runner.runSchematic('add-layout', { layout: 'side-nav-outer-toolbar' }, appTree);
40+
tree = await runner.runSchematic('add-sample-views', sampleViewsOptions, tree);
4141

4242
const moduleContent = tree.readContent('/src/app/app-routing.module.ts');
4343

0 commit comments

Comments
 (0)