diff --git a/e2e/angular/src/plugin.test.ts b/e2e/angular/src/plugin.test.ts index dc80e58868130..7a1c69ead7d4d 100644 --- a/e2e/angular/src/plugin.test.ts +++ b/e2e/angular/src/plugin.test.ts @@ -153,10 +153,32 @@ function runNgNew(projectName: string, cwd: string): void { const pmc = getPackageManagerCommand({ packageManager }); const command = `${pmc.runUninstalledPackage} @angular/cli@${angularCliVersion} new ${projectName} --package-manager=${packageManager}`; - cwd = join(tmpProjPath(), cwd); - ensureDirSync(cwd); + const fullCwd = join(tmpProjPath(), cwd); + ensureDirSync(fullCwd); execSync(command, { - cwd, + cwd: fullCwd, + stdio: isVerbose() ? 'inherit' : 'pipe', + env: process.env, + encoding: 'utf-8', + }); + + // ensure angular packages are installed with ~ instead of ^ to prevent + // potential failures when new minor versions are released + function updateAngularDependencies(dependencies: any): void { + Object.keys(dependencies).forEach((key) => { + if (key.startsWith('@angular/') || key.startsWith('@angular-devkit/')) { + dependencies[key] = dependencies[key].replace(/^\^/, '~'); + } + }); + } + updateJson(join(cwd, projectName, 'package.json'), (json) => { + updateAngularDependencies(json.dependencies ?? {}); + updateAngularDependencies(json.devDependencies ?? {}); + return json; + }); + + execSync(pmc.install, { + cwd: join(fullCwd, projectName), stdio: isVerbose() ? 'inherit' : 'pipe', env: process.env, encoding: 'utf-8', diff --git a/e2e/utils/create-project-utils.ts b/e2e/utils/create-project-utils.ts index 24c0866163692..6c72b4210b8f4 100644 --- a/e2e/utils/create-project-utils.ts +++ b/e2e/utils/create-project-utils.ts @@ -486,6 +486,29 @@ export function runNgNew( env: process.env, encoding: 'utf-8', }); + + // ensure angular packages are installed with ~ instead of ^ to prevent + // potential failures when new minor versions are released + function updateAngularDependencies(dependencies: any): void { + Object.keys(dependencies).forEach((key) => { + if (key.startsWith('@angular/') || key.startsWith('@angular-devkit/')) { + dependencies[key] = dependencies[key].replace(/^\^/, '~'); + } + }); + } + updateJson('package.json', (json) => { + updateAngularDependencies(json.dependencies ?? {}); + updateAngularDependencies(json.devDependencies ?? {}); + return json; + }); + + execSync(pmc.install, { + cwd: join(e2eCwd, projName), + stdio: isVerbose() ? 'inherit' : 'pipe', + env: process.env, + encoding: 'utf-8', + }); + copySync(tmpProjPath(), tmpBackupNgCliProjPath()); if (isVerboseE2ERun()) { diff --git a/packages/js/src/utils/package-json/sort-fields.ts b/packages/js/src/utils/package-json/sort-fields.ts index c268d07e8fafe..49632b510778a 100644 --- a/packages/js/src/utils/package-json/sort-fields.ts +++ b/packages/js/src/utils/package-json/sort-fields.ts @@ -14,7 +14,7 @@ export function sortPackageJsonFields(tree: Tree, projectRoot: string) { 'main', 'module', 'types', - 'exported', + 'exports', ]); const orderedBottomFields = new Set([ 'dependencies', diff --git a/packages/react/src/generators/library/library.spec.ts b/packages/react/src/generators/library/library.spec.ts index 5125f61fe1660..91f2b67d58f4c 100644 --- a/packages/react/src/generators/library/library.spec.ts +++ b/packages/react/src/generators/library/library.spec.ts @@ -1027,8 +1027,8 @@ module.exports = withNx( "main", "module", "types", - "nx", "exports", + "nx", ] `); expect(readJson(tree, 'mylib/tsconfig.json')).toMatchInlineSnapshot(`