Skip to content

Commit d58428d

Browse files
alan-agius4angular-robot[bot]
authored andcommitted
feat(@angular/cli): remove deprecated defaultProject from workspace configuration
The deprecated 'defaultProject' workspace option has been removed BREAKING CHANGE: The deprecated `defaultProject` workspace option has been removed. The project to use will be determined from the current working directory.
1 parent ada4d69 commit d58428d

File tree

17 files changed

+87
-68
lines changed

17 files changed

+87
-68
lines changed

packages/angular/cli/lib/config/workspace-schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
"type": "string",
2121
"description": "Path where new projects will be created."
2222
},
23-
"defaultProject": {
24-
"type": "string",
25-
"description": "Default project name used in commands.",
26-
"x-deprecated": "The project to use will be determined from the current working directory."
27-
},
2823
"projects": {
2924
"type": "object",
3025
"patternProperties": {

packages/angular/cli/src/command-builder/schematics-command-module.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,6 @@ export abstract class SchematicsCommandModule
356356
return 0;
357357
}
358358

359-
private defaultProjectDeprecationWarningShown = false;
360359
private getProjectName(): string | undefined {
361360
const { workspace, logger } = this.context;
362361
if (!workspace) {
@@ -368,20 +367,6 @@ export abstract class SchematicsCommandModule
368367
return projectName;
369368
}
370369

371-
const defaultProjectName = workspace.extensions['defaultProject'];
372-
if (typeof defaultProjectName === 'string' && defaultProjectName) {
373-
if (!this.defaultProjectDeprecationWarningShown) {
374-
logger.warn(tags.oneLine`
375-
DEPRECATED: The 'defaultProject' workspace option has been deprecated.
376-
The project to use will be determined from the current working directory.
377-
`);
378-
379-
this.defaultProjectDeprecationWarningShown = true;
380-
}
381-
382-
return defaultProjectName;
383-
}
384-
385370
return undefined;
386371
}
387372

packages/angular/cli/src/utilities/config.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ function findProjectByPath(workspace: AngularWorkspace, location: string): strin
302302
return projects[0][1];
303303
}
304304

305-
let defaultProjectDeprecationWarningShown = false;
306305
export function getProjectByCwd(workspace: AngularWorkspace): string | null {
307306
if (workspace.projects.size === 1) {
308307
// If there is only one project, return that one.
@@ -314,21 +313,6 @@ export function getProjectByCwd(workspace: AngularWorkspace): string | null {
314313
return project;
315314
}
316315

317-
const defaultProject = workspace.extensions['defaultProject'];
318-
if (defaultProject && typeof defaultProject === 'string') {
319-
// If there is a default project name, return it.
320-
if (!defaultProjectDeprecationWarningShown) {
321-
console.warn(
322-
`DEPRECATED: The 'defaultProject' workspace option has been deprecated. ` +
323-
`The project to use will be determined from the current working directory.`,
324-
);
325-
326-
defaultProjectDeprecationWarningShown = true;
327-
}
328-
329-
return defaultProject;
330-
}
331-
332316
return null;
333317
}
334318

packages/angular_devkit/core/src/workspace/json/reader.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ import { WorkspaceHost } from '../host';
2020
import { JsonWorkspaceMetadata, JsonWorkspaceSymbol } from './metadata';
2121
import { createVirtualAstObject } from './utilities';
2222

23-
const ANGULAR_WORKSPACE_EXTENSIONS = Object.freeze([
24-
'cli',
25-
'defaultProject',
26-
'newProjectRoot',
27-
'schematics',
28-
]);
23+
const ANGULAR_WORKSPACE_EXTENSIONS = Object.freeze(['cli', 'newProjectRoot', 'schematics']);
2924
const ANGULAR_PROJECT_EXTENSIONS = Object.freeze(['cli', 'schematics', 'projectType', 'i18n']);
3025

3126
interface ParserContext {

packages/angular_devkit/core/src/workspace/json/reader_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ describe('readJsonWorkpace Parsing', () => {
7777

7878
expect(Array.from(workspace.projects.keys())).toEqual(['my-app', 'my-app-e2e']);
7979
expect(workspace.extensions['newProjectRoot']).toBe('projects');
80-
expect(workspace.extensions['defaultProject']).toBe('my-app');
8180
expect(workspace.projects.get('my-app')!.extensions['schematics']).toEqual({
8281
'@schematics/angular:component': { styleext: 'scss' },
8382
});

packages/angular_devkit/core/src/workspace/json/test/angular.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,5 @@
133133
}
134134
}
135135
}
136-
},
137-
"defaultProject": "my-app"
138-
}
136+
}
137+
}

packages/angular_devkit/core/src/workspace/json/test/cases/AddProject2.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,5 @@
136136
"new": {
137137
"root": "src"
138138
}
139-
},
140-
"defaultProject": "my-app"
141-
}
139+
}
140+
}

packages/angular_devkit/core/src/workspace/json/test/cases/AddProject3.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,5 @@
136136
"1": {
137137
"root": "src"
138138
}
139-
},
140-
"defaultProject": "my-app"
139+
}
141140
}

packages/angular_devkit/core/src/workspace/json/test/cases/ProjectAddTarget.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,5 @@
136136
}
137137
}
138138
}
139-
},
140-
"defaultProject": "my-app"
141-
}
139+
}
140+
}

packages/angular_devkit/core/src/workspace/json/test/cases/ProjectDeleteTarget.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,5 @@
127127
}
128128
}
129129
}
130-
},
131-
"defaultProject": "my-app"
132-
}
130+
}
131+
}

0 commit comments

Comments
 (0)