Skip to content

Commit 8e963da

Browse files
alan-agius4alexeagle
authored andcommitted
fix(@schematics/angular): update @angular peerDependencies for new libraries
1 parent c45fd96 commit 8e963da

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/schematics/angular/library/files/__projectRoot__/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "<%= dasherize(packageName) %>",
33
"version": "0.0.1",
44
"peerDependencies": {
5-
"@angular/common": "^6.0.0-rc.0 || ^6.0.0",
6-
"@angular/core": "^6.0.0-rc.0 || ^6.0.0"
5+
"@angular/common": "^<%= angularLatestVersion %>",
6+
"@angular/core": "^<%= angularLatestVersion %>"
77
}
88
}

packages/schematics/angular/library/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export default function (options: LibraryOptions): Rule {
211211
distRoot,
212212
relativePathToWorkspaceRoot,
213213
prefix,
214+
angularLatestVersion: latestVersions.Angular.replace('~', '').replace('^', ''),
214215
}),
215216
// TODO: Moving inside `branchAndMerge` should work but is bugged right now.
216217
// The __projectRoot__ is being used meanwhile.

packages/schematics/angular/library/index_spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ describe('Library Schematic', () => {
6363
expect(fileContent).toMatch(/"name": "foo"/);
6464
});
6565

66+
it('should have the latest Angular major versions in package.json named "foo"', () => {
67+
const tree = schematicRunner.runSchematic('library', defaultOptions, workspaceTree);
68+
const fileContent = getJsonFileContent(tree, '/projects/foo/package.json');
69+
const angularVersion = latestVersions.Angular.replace('~', '').replace('^', '');
70+
expect(fileContent.peerDependencies['@angular/core']).toBe(`^${angularVersion}`);
71+
});
72+
6673
it('should create a tsconfig for library', () => {
6774
const tree = schematicRunner.runSchematic('library', defaultOptions, workspaceTree);
6875
const fileContent = getJsonFileContent(tree, '/projects/foo/tsconfig.lib.json');

0 commit comments

Comments
 (0)