-
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 v18.2.0 (#27379)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
- Loading branch information
1 parent
0d97039
commit c0f5c15
Showing
10 changed files
with
2,077 additions
and
396 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
8 changes: 7 additions & 1 deletion
8
packages/angular/src/executors/utilities/esbuild-extensions.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
42 changes: 42 additions & 0 deletions
42
packages/angular/src/migrations/update-19-6-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-19-6-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 = '~18.2.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.