-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(angular): support angular v16.1 (#17155)
- Loading branch information
1 parent
09e5b03
commit 1fcba1a
Showing
25 changed files
with
3,736 additions
and
1,309 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
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
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
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
42 changes: 42 additions & 0 deletions
42
packages/angular/src/migrations/update-16-4-0/update-angular-cli.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,42 @@ | ||
import { readJson, Tree, writeJson } from '@nx/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; | ||
import updateAngularCli, { angularCliVersion } from './update-angular-cli'; | ||
|
||
describe('update-angular-cli migration', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); | ||
}); | ||
|
||
it('should update @angular/cli version when defined as a dev dependency', async () => { | ||
writeJson(tree, 'package.json', { | ||
devDependencies: { '@angular/cli': '~13.3.0' }, | ||
}); | ||
|
||
await updateAngularCli(tree); | ||
|
||
const { devDependencies } = readJson(tree, 'package.json'); | ||
expect(devDependencies['@angular/cli']).toBe(angularCliVersion); | ||
}); | ||
|
||
it('should update @angular/cli version when defined as a dependency', async () => { | ||
writeJson(tree, 'package.json', { | ||
dependencies: { '@angular/cli': '~13.3.0' }, | ||
}); | ||
|
||
await updateAngularCli(tree); | ||
|
||
const { dependencies } = readJson(tree, 'package.json'); | ||
expect(dependencies['@angular/cli']).toBe(angularCliVersion); | ||
}); | ||
|
||
it('should not add @angular/cli to package.json when it is not set', async () => { | ||
const initialPackageJson = readJson(tree, 'package.json'); | ||
|
||
await updateAngularCli(tree); | ||
|
||
const packageJson = readJson(tree, 'package.json'); | ||
expect(packageJson).toStrictEqual(initialPackageJson); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
packages/angular/src/migrations/update-16-4-0/update-angular-cli.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,23 @@ | ||
import { formatFiles, Tree, updateJson } from '@nx/devkit'; | ||
|
||
export const angularCliVersion = '~16.1.0'; | ||
|
||
export default async function (tree: Tree) { | ||
let shouldFormat = false; | ||
|
||
updateJson(tree, 'package.json', (json) => { | ||
if (json.devDependencies?.['@angular/cli']) { | ||
json.devDependencies['@angular/cli'] = angularCliVersion; | ||
shouldFormat = true; | ||
} else if (json.dependencies?.['@angular/cli']) { | ||
json.dependencies['@angular/cli'] = angularCliVersion; | ||
shouldFormat = true; | ||
} | ||
|
||
return json; | ||
}); | ||
|
||
if (shouldFormat) { | ||
await formatFiles(tree); | ||
} | ||
} |
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
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
Oops, something went wrong.
1fcba1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev