Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@schematics/angular): add migratiom to remove
defaultProject
i…
…n workspace config This option is deprecated in Angular CLI and will be removed in a future major version.
- Loading branch information
1 parent
4cbfb87
commit e49220f
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/schematics/angular/migrations/update-14/remove-default-project-option.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { Rule } from '@angular-devkit/schematics'; | ||
import { updateWorkspace } from '../../utility/workspace'; | ||
|
||
/** Migration to remove 'defaultProject' option from angular.json. */ | ||
export default function (): Rule { | ||
return updateWorkspace((workspace) => { | ||
delete workspace.extensions['defaultProject']; | ||
}); | ||
} |
51 changes: 51 additions & 0 deletions
51
packages/schematics/angular/migrations/update-14/remove-default-project-option_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { EmptyTree } from '@angular-devkit/schematics'; | ||
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; | ||
import { WorkspaceSchema } from '../../utility/workspace-models'; | ||
|
||
describe(`Migration to remove 'defaultProject' option.`, () => { | ||
const schematicName = 'remove-default-project-option'; | ||
const schematicRunner = new SchematicTestRunner( | ||
'migrations', | ||
require.resolve('../migration-collection.json'), | ||
); | ||
|
||
let tree: UnitTestTree; | ||
beforeEach(() => { | ||
tree = new UnitTestTree(new EmptyTree()); | ||
}); | ||
|
||
it(`should remove 'defaultProject'`, async () => { | ||
const angularConfig: WorkspaceSchema = { | ||
version: 1, | ||
projects: {}, | ||
defaultProject: 'foo', | ||
}; | ||
|
||
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2)); | ||
const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); | ||
const { defaultProject } = JSON.parse(newTree.readContent('/angular.json')); | ||
|
||
expect(defaultProject).toBeUndefined(); | ||
}); | ||
|
||
it(`should not error when 'defaultProject' is not defined`, async () => { | ||
const angularConfig: WorkspaceSchema = { | ||
version: 1, | ||
projects: {}, | ||
}; | ||
|
||
tree.create('/angular.json', JSON.stringify(angularConfig, undefined, 2)); | ||
const newTree = await schematicRunner.runSchematicAsync(schematicName, {}, tree).toPromise(); | ||
const { defaultProject } = JSON.parse(newTree.readContent('/angular.json')); | ||
|
||
expect(defaultProject).toBeUndefined(); | ||
}); | ||
}); |