-
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
- Loading branch information
1 parent
6a3af4b
commit 393bc06
Showing
8 changed files
with
2,102 additions
and
519 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
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-next.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.