nx 21.1.2 → 21.2.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -105,6 +105,7 @@
105
105
  "typescript",
106
106
  "@nrwl/angular",
107
107
  "@angular-devkit/build-angular",
108
+ "@angular/build",
108
109
  "@angular-devkit/core",
109
110
  "@angular-devkit/architect",
110
111
  "@swc/core", //Optional, used in JS analysis if available
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p style="text-align: center;">
2
2
  <picture>
3
3
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
- <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
4
+ <img alt="Nx - Smart Repos · Fast Builds" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
5
  </picture>
6
6
  </p>
7
7
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  <hr>
22
22
 
23
- # Nx: Smart Monorepos · Fast CI
23
+ # Nx: Smart Repos · Fast Builds
24
24
 
25
25
  Nx is a build system, optimized for monorepos, with plugins for popular frameworks and tools and advanced CI capabilities including caching and distribution.
26
26
 
@@ -62,5 +62,5 @@ npx nx@latest init
62
62
  - [Blog Posts About Nx](https://nx.dev/blog)
63
63
 
64
64
  <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
65
- width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
65
+ width="100%" alt="Nx - Smart Repos · Fast Builds"></a></p>
66
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "21.1.2",
3
+ "version": "21.2.0-beta.1",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -83,16 +83,16 @@
83
83
  }
84
84
  },
85
85
  "optionalDependencies": {
86
- "@nx/nx-darwin-arm64": "21.1.2",
87
- "@nx/nx-darwin-x64": "21.1.2",
88
- "@nx/nx-freebsd-x64": "21.1.2",
89
- "@nx/nx-linux-arm-gnueabihf": "21.1.2",
90
- "@nx/nx-linux-arm64-gnu": "21.1.2",
91
- "@nx/nx-linux-arm64-musl": "21.1.2",
92
- "@nx/nx-linux-x64-gnu": "21.1.2",
93
- "@nx/nx-linux-x64-musl": "21.1.2",
94
- "@nx/nx-win32-arm64-msvc": "21.1.2",
95
- "@nx/nx-win32-x64-msvc": "21.1.2"
86
+ "@nx/nx-darwin-arm64": "21.2.0-beta.1",
87
+ "@nx/nx-darwin-x64": "21.2.0-beta.1",
88
+ "@nx/nx-freebsd-x64": "21.2.0-beta.1",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.2.0-beta.1",
90
+ "@nx/nx-linux-arm64-gnu": "21.2.0-beta.1",
91
+ "@nx/nx-linux-arm64-musl": "21.2.0-beta.1",
92
+ "@nx/nx-linux-x64-gnu": "21.2.0-beta.1",
93
+ "@nx/nx-linux-x64-musl": "21.2.0-beta.1",
94
+ "@nx/nx-win32-arm64-msvc": "21.2.0-beta.1",
95
+ "@nx/nx-win32-x64-msvc": "21.2.0-beta.1"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
@@ -93,6 +93,10 @@ if (!patched) {
93
93
  () => { };
94
94
  }
95
95
  catch (e) { }
96
+ try {
97
+ require('@angular/build/private').assertCompatibleAngularVersion = () => { };
98
+ }
99
+ catch (e) { }
96
100
  patched = true;
97
101
  }
98
102
  function mockReadWorkspace(ngCoreWorkspace) {
@@ -95,7 +95,9 @@ function addPluginDependencies() {
95
95
  const angularCliVersion = packageJson.devDependencies['@angular/cli'] ??
96
96
  packageJson.dependencies?.['@angular/cli'] ??
97
97
  packageJson.devDependencies['@angular-devkit/build-angular'] ??
98
- packageJson.dependencies?.['@angular-devkit/build-angular'];
98
+ packageJson.dependencies?.['@angular-devkit/build-angular'] ??
99
+ packageJson.devDependencies['@angular/build'] ??
100
+ packageJson.dependencies?.['@angular/build'];
99
101
  for (const dep of peerDepsToInstall) {
100
102
  if (!packageJson.devDependencies[dep] && !packageJson.dependencies?.[dep]) {
101
103
  packageJson.devDependencies[dep] = angularCliVersion;
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupStandaloneWorkspace = setupStandaloneWorkspace;
4
4
  const fs_1 = require("fs");
5
- const path_1 = require("path");
5
+ const node_path_1 = require("node:path");
6
6
  const angular_json_1 = require("../../../../adapter/angular-json");
7
7
  const fileutils_1 = require("../../../../utils/fileutils");
8
- const path_2 = require("../../../../utils/path");
8
+ const path_1 = require("../../../../utils/path");
9
9
  const utils_1 = require("../utils");
10
10
  async function setupStandaloneWorkspace(repoRoot, cacheableOperations, workspaceTargets) {
11
- const angularJsonPath = (0, path_1.join)(repoRoot, 'angular.json');
11
+ const angularJsonPath = (0, node_path_1.join)(repoRoot, 'angular.json');
12
12
  const angularJson = (0, fileutils_1.readJsonFile)(angularJsonPath);
13
13
  const workspaceCapabilities = getWorkspaceCapabilities(angularJson.projects);
14
14
  createNxJson(repoRoot, angularJson, cacheableOperations, workspaceCapabilities, workspaceTargets);
@@ -24,9 +24,9 @@ async function setupStandaloneWorkspace(repoRoot, cacheableOperations, workspace
24
24
  // update its targets outputs and delete angular.json
25
25
  const projects = (0, angular_json_1.toNewFormat)(angularJson).projects;
26
26
  for (const [projectName, project] of Object.entries(projects ?? {})) {
27
- updateProjectOutputs(repoRoot, project);
28
- (0, fileutils_1.writeJsonFile)((0, path_1.join)(project.root, 'project.json'), {
29
- $schema: (0, path_2.normalizePath)((0, path_1.relative)((0, path_1.join)(repoRoot, project.root), (0, path_1.join)(repoRoot, 'node_modules/nx/schemas/project-schema.json'))),
27
+ updateProjectOutputs(repoRoot, projectName, project, cacheableOperations);
28
+ (0, fileutils_1.writeJsonFile)((0, node_path_1.join)(project.root, 'project.json'), {
29
+ $schema: (0, path_1.normalizePath)((0, node_path_1.relative)((0, node_path_1.join)(repoRoot, project.root), (0, node_path_1.join)(repoRoot, 'node_modules/nx/schemas/project-schema.json'))),
30
30
  name: projectName,
31
31
  ...project,
32
32
  root: undefined,
@@ -36,7 +36,7 @@ async function setupStandaloneWorkspace(repoRoot, cacheableOperations, workspace
36
36
  }
37
37
  function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjectConfigFile, test, karmaProjectConfigFile, }, workspaceTargets) {
38
38
  (0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, {});
39
- const nxJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(repoRoot, 'nx.json'));
39
+ const nxJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(repoRoot, 'nx.json'));
40
40
  nxJson.namedInputs = {
41
41
  sharedGlobals: [],
42
42
  default: ['{projectRoot}/**/*', 'sharedGlobals'],
@@ -70,7 +70,7 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
70
70
  }
71
71
  if (workspaceTargets.includes('test')) {
72
72
  const inputs = ['default', '^production'];
73
- if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'karma.conf.js'))) {
73
+ if ((0, fileutils_1.fileExists)((0, node_path_1.join)(repoRoot, 'karma.conf.js'))) {
74
74
  inputs.push('{workspaceRoot}/karma.conf.js');
75
75
  }
76
76
  nxJson.targetDefaults.test = {
@@ -80,10 +80,10 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
80
80
  }
81
81
  if (workspaceTargets.includes('lint')) {
82
82
  const inputs = ['default'];
83
- if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, '.eslintrc.json'))) {
83
+ if ((0, fileutils_1.fileExists)((0, node_path_1.join)(repoRoot, '.eslintrc.json'))) {
84
84
  inputs.push('{workspaceRoot}/.eslintrc.json');
85
85
  }
86
- if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.cjs'))) {
86
+ if ((0, fileutils_1.fileExists)((0, node_path_1.join)(repoRoot, 'eslint.config.cjs'))) {
87
87
  inputs.push('{workspaceRoot}/eslint.config.cjs');
88
88
  }
89
89
  nxJson.targetDefaults.lint = {
@@ -97,11 +97,30 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
97
97
  inputs: ['default', '^production'],
98
98
  };
99
99
  }
100
- (0, fileutils_1.writeJsonFile)((0, path_1.join)(repoRoot, 'nx.json'), nxJson);
100
+ (0, fileutils_1.writeJsonFile)((0, node_path_1.join)(repoRoot, 'nx.json'), nxJson);
101
101
  }
102
- function updateProjectOutputs(repoRoot, project) {
103
- Object.values(project.targets ?? {}).forEach((target) => {
104
- if ([
102
+ function updateProjectOutputs(repoRoot, projectName, project, cacheableOperations) {
103
+ Object.entries(project.targets ?? {}).forEach(([targetName, target]) => {
104
+ if (target.executor === '@angular/build:application' ||
105
+ target.executor === '@angular-devkit/build-angular:application') {
106
+ if (target.options.outputPath) {
107
+ if (typeof target.options.outputPath === 'string') {
108
+ target.outputs = ['{options.outputPath}'];
109
+ }
110
+ else if (target.options.outputPath.base) {
111
+ target.outputs = ['{options.outputPath.base}'];
112
+ }
113
+ else if (cacheableOperations.includes(targetName)) {
114
+ target.cache = false;
115
+ }
116
+ }
117
+ else {
118
+ target.options.outputPath = node_path_1.posix.join('dist', projectName);
119
+ target.outputs = ['{options.outputPath}'];
120
+ }
121
+ }
122
+ else if ([
123
+ '@angular-devkit/build-angular:browser-esbuild',
105
124
  '@angular-devkit/build-angular:browser',
106
125
  '@angular-builders/custom-webpack:browser',
107
126
  'ngx-build-plus:browser',
@@ -109,7 +128,12 @@ function updateProjectOutputs(repoRoot, project) {
109
128
  '@angular-builders/custom-webpack:server',
110
129
  'ngx-build-plus:server',
111
130
  ].includes(target.executor)) {
112
- target.outputs = ['{options.outputPath}'];
131
+ if (target.options.outputPath) {
132
+ target.outputs = ['{options.outputPath}'];
133
+ }
134
+ else if (cacheableOperations.includes(targetName)) {
135
+ target.cache = false;
136
+ }
113
137
  }
114
138
  else if (target.executor === '@angular-eslint/builder:lint') {
115
139
  target.outputs = ['{options.outputFile}'];
@@ -117,10 +141,11 @@ function updateProjectOutputs(repoRoot, project) {
117
141
  else if (target.executor === '@angular-devkit/build-angular:ng-packagr' ||
118
142
  target.executor === '@angular/build:ng-packagr') {
119
143
  try {
120
- const ngPackageJsonPath = (0, path_1.join)(repoRoot, target.options.project);
144
+ const ngPackagrProject = target.options.project ?? node_path_1.posix.join(project.root, 'ng-package.json');
145
+ const ngPackageJsonPath = (0, node_path_1.join)(repoRoot, ngPackagrProject);
121
146
  const ngPackageJson = (0, fileutils_1.readJsonFile)(ngPackageJsonPath);
122
- const outputPath = (0, path_1.relative)(repoRoot, (0, path_1.resolve)((0, path_1.dirname)(ngPackageJsonPath), ngPackageJson.dest));
123
- target.outputs = [`{workspaceRoot}/${(0, path_2.normalizePath)(outputPath)}`];
147
+ const outputPath = (0, node_path_1.relative)(repoRoot, (0, node_path_1.resolve)((0, node_path_1.dirname)(ngPackageJsonPath), ngPackageJson.dest));
148
+ target.outputs = [`{workspaceRoot}/${(0, path_1.normalizePath)(outputPath)}`];
124
149
  }
125
150
  catch { }
126
151
  }
@@ -153,19 +178,20 @@ function getWorkspaceCapabilities(projects) {
153
178
  return capabilities;
154
179
  }
155
180
  function projectUsesKarmaBuilder(project) {
156
- return Object.values(project.architect ?? {}).some((target) => target.builder === '@angular-devkit/build-angular:karma');
181
+ return Object.values(project.architect ?? {}).some((target) => target.builder === '@angular/build:karma' ||
182
+ target.builder === '@angular-devkit/build-angular:karma');
157
183
  }
158
184
  function projectHasKarmaConfig(project) {
159
- return (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'karma.conf.js'));
185
+ return (0, fileutils_1.fileExists)((0, node_path_1.join)(project.root, 'karma.conf.js'));
160
186
  }
161
187
  function projectHasEslintConfig(project) {
162
- return ((0, fileutils_1.fileExists)((0, path_1.join)(project.root, '.eslintrc.json')) ||
163
- (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.js')) ||
164
- (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.mjs')) ||
165
- (0, fileutils_1.fileExists)((0, path_1.join)(project.root, 'eslint.config.cjs')));
188
+ return ((0, fileutils_1.fileExists)((0, node_path_1.join)(project.root, '.eslintrc.json')) ||
189
+ (0, fileutils_1.fileExists)((0, node_path_1.join)(project.root, 'eslint.config.js')) ||
190
+ (0, fileutils_1.fileExists)((0, node_path_1.join)(project.root, 'eslint.config.mjs')) ||
191
+ (0, fileutils_1.fileExists)((0, node_path_1.join)(project.root, 'eslint.config.cjs')));
166
192
  }
167
193
  function replaceNgWithNxInPackageJsonScripts(repoRoot) {
168
- const packageJsonPath = (0, path_1.join)(repoRoot, 'package.json');
194
+ const packageJsonPath = (0, node_path_1.join)(repoRoot, 'package.json');
169
195
  const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
170
196
  packageJson.scripts ??= {};
171
197
  Object.keys(packageJson.scripts).forEach((script) => {
@@ -44,7 +44,7 @@ exports.parserConfiguration = {
44
44
  */
45
45
  exports.commandsObject = yargs
46
46
  .parserConfiguration(exports.parserConfiguration)
47
- .usage(chalk.bold('Smart Monorepos · Fast CI'))
47
+ .usage(chalk.bold('Smart Repos · Fast Builds'))
48
48
  .demandCommand(1, '')
49
49
  .command(command_object_1.yargsRegisterCommand)
50
50
  .command(command_object_22.yargsAddCommand)