Skip to content

Commit ff12d09

Browse files
authored
fix(material/schematics): remove usages of deprecated defaultProject option (#24641)
The CLI has deprecated the `defaultProject` option which is causing errors in the snapshot check. These changes fix up our usages.
1 parent 5f4148f commit ff12d09

File tree

6 files changed

+80
-52
lines changed

6 files changed

+80
-52
lines changed

integration/harness-e2e-cli/angular.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,5 @@
9696
}
9797
}
9898
}
99-
},
100-
"defaultProject": "harness-e2e-cli"
99+
}
101100
}

integration/ng-add/angular.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,5 @@
9797
}
9898
}
9999
}
100-
},
101-
"defaultProject": "ng-add"
100+
}
102101
}

integration/ng-update-v13/angular.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,5 @@
9696
}
9797
}
9898
}
99-
},
100-
"defaultProject": "ng-update"
99+
}
101100
}

src/cdk/schematics/ng-generate/drag-drop/index.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ describe('CDK drag-drop schematic', () => {
6060
'angular.json',
6161
JSON.stringify({
6262
version: 1,
63-
defaultProject: 'material',
6463
projects: {
6564
material: {
6665
projectType: 'application',
@@ -173,7 +172,6 @@ describe('CDK drag-drop schematic', () => {
173172
'angular.json',
174173
JSON.stringify({
175174
version: 1,
176-
defaultProject: 'material',
177175
projects: {
178176
material: {
179177
projectType: 'application',

src/cdk/schematics/utils/get-project.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ import {SchematicsException} from '@angular-devkit/schematics';
1515
*/
1616
export function getProjectFromWorkspace(
1717
workspace: WorkspaceDefinition,
18-
projectName = workspace.extensions.defaultProject as string,
18+
projectName: string | undefined,
1919
): ProjectDefinition {
20+
if (!projectName) {
21+
// TODO(crisbeto): some schematics APIs have the project name as optional so for now it's
22+
// simpler to allow undefined and checking it at runtime. Eventually we should clean this up.
23+
throw new SchematicsException('Project name is required.');
24+
}
25+
2026
const project = workspace.projects.get(projectName);
2127

2228
if (!project) {

0 commit comments

Comments
 (0)