Skip to content

Commit

Permalink
fix(material/schematics): remove usages of deprecated defaultProject …
Browse files Browse the repository at this point in the history
…option (#24641)

The CLI has deprecated the `defaultProject` option which is causing errors in the snapshot check. These changes fix up our usages.
  • Loading branch information
crisbeto authored Mar 22, 2022
1 parent 5f4148f commit ff12d09
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 52 deletions.
3 changes: 1 addition & 2 deletions integration/harness-e2e-cli/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,5 @@
}
}
}
},
"defaultProject": "harness-e2e-cli"
}
}
3 changes: 1 addition & 2 deletions integration/ng-add/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,5 @@
}
}
}
},
"defaultProject": "ng-add"
}
}
3 changes: 1 addition & 2 deletions integration/ng-update-v13/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,5 @@
}
}
}
},
"defaultProject": "ng-update"
}
}
2 changes: 0 additions & 2 deletions src/cdk/schematics/ng-generate/drag-drop/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ describe('CDK drag-drop schematic', () => {
'angular.json',
JSON.stringify({
version: 1,
defaultProject: 'material',
projects: {
material: {
projectType: 'application',
Expand Down Expand Up @@ -173,7 +172,6 @@ describe('CDK drag-drop schematic', () => {
'angular.json',
JSON.stringify({
version: 1,
defaultProject: 'material',
projects: {
material: {
projectType: 'application',
Expand Down
8 changes: 7 additions & 1 deletion src/cdk/schematics/utils/get-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ import {SchematicsException} from '@angular-devkit/schematics';
*/
export function getProjectFromWorkspace(
workspace: WorkspaceDefinition,
projectName = workspace.extensions.defaultProject as string,
projectName: string | undefined,
): ProjectDefinition {
if (!projectName) {
// TODO(crisbeto): some schematics APIs have the project name as optional so for now it's
// simpler to allow undefined and checking it at runtime. Eventually we should clean this up.
throw new SchematicsException('Project name is required.');
}

const project = workspace.projects.get(projectName);

if (!project) {
Expand Down
Loading

0 comments on commit ff12d09

Please sign in to comment.