nx 19.5.0-beta.2 → 19.5.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -59,7 +59,7 @@ npx nx@latest init
59
59
  - [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
60
60
  - [Intro to Nx](https://nx.dev/getting-started/intro)
61
61
  - [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
62
- - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
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
65
  width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.5.0-beta.2",
3
+ "version": "19.5.0-beta.4",
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": {
@@ -71,7 +71,7 @@
71
71
  "yargs-parser": "21.1.1",
72
72
  "node-machine-id": "1.1.12",
73
73
  "ora": "5.3.0",
74
- "@nrwl/tao": "19.5.0-beta.2"
74
+ "@nrwl/tao": "19.5.0-beta.4"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@swc-node/register": "^1.8.0",
@@ -86,16 +86,16 @@
86
86
  }
87
87
  },
88
88
  "optionalDependencies": {
89
- "@nx/nx-darwin-x64": "19.5.0-beta.2",
90
- "@nx/nx-darwin-arm64": "19.5.0-beta.2",
91
- "@nx/nx-linux-x64-gnu": "19.5.0-beta.2",
92
- "@nx/nx-linux-x64-musl": "19.5.0-beta.2",
93
- "@nx/nx-win32-x64-msvc": "19.5.0-beta.2",
94
- "@nx/nx-linux-arm64-gnu": "19.5.0-beta.2",
95
- "@nx/nx-linux-arm64-musl": "19.5.0-beta.2",
96
- "@nx/nx-linux-arm-gnueabihf": "19.5.0-beta.2",
97
- "@nx/nx-win32-arm64-msvc": "19.5.0-beta.2",
98
- "@nx/nx-freebsd-x64": "19.5.0-beta.2"
89
+ "@nx/nx-darwin-x64": "19.5.0-beta.4",
90
+ "@nx/nx-darwin-arm64": "19.5.0-beta.4",
91
+ "@nx/nx-linux-x64-gnu": "19.5.0-beta.4",
92
+ "@nx/nx-linux-x64-musl": "19.5.0-beta.4",
93
+ "@nx/nx-win32-x64-msvc": "19.5.0-beta.4",
94
+ "@nx/nx-linux-arm64-gnu": "19.5.0-beta.4",
95
+ "@nx/nx-linux-arm64-musl": "19.5.0-beta.4",
96
+ "@nx/nx-linux-arm-gnueabihf": "19.5.0-beta.4",
97
+ "@nx/nx-win32-arm64-msvc": "19.5.0-beta.4",
98
+ "@nx/nx-freebsd-x64": "19.5.0-beta.4"
99
99
  },
100
100
  "nx-migrations": {
101
101
  "migrations": "./migrations.json",
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const workspace_root_1 = require("../src/utils/workspace-root");
4
- const package_json_workspaces_1 = require("../src/plugins/package-json-workspaces");
4
+ const package_json_1 = require("../src/plugins/package-json");
5
5
  const plugin = {
6
6
  name: 'nx-all-package-jsons-plugin',
7
7
  createNodes: [
8
8
  '*/**/package.json',
9
- (f) => (0, package_json_workspaces_1.createNodeFromPackageJson)(f, workspace_root_1.workspaceRoot),
9
+ (f) => (0, package_json_1.createNodeFromPackageJson)(f, workspace_root_1.workspaceRoot),
10
10
  ],
11
11
  };
12
12
  module.exports = plugin;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsNxInfixCommand = exports.yargsRunCommand = void 0;
4
+ const yargs_1 = require("yargs");
4
5
  const shared_options_1 = require("../yargs-utils/shared-options");
5
6
  const params_1 = require("../../utils/params");
6
7
  exports.yargsRunCommand = {
@@ -29,6 +30,11 @@ exports.yargsNxInfixCommand = {
29
30
  describe: 'Run a target for a project',
30
31
  handler: async (args) => {
31
32
  const exitCode = await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
33
+ // Yargs parses <target> as 'undefined' if running just 'nx'
34
+ if (!args.target || args.target === 'undefined') {
35
+ (0, yargs_1.showHelp)();
36
+ process.exit(1);
37
+ }
32
38
  return (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args, 0));
33
39
  });
34
40
  process.exit(exitCode);
@@ -9,7 +9,7 @@ exports.getProjects = getProjects;
9
9
  exports.getRelativeProjectJsonSchemaPath = getRelativeProjectJsonSchemaPath;
10
10
  const minimatch_1 = require("minimatch");
11
11
  const path_1 = require("path");
12
- const package_json_workspaces_1 = require("../../plugins/package-json-workspaces");
12
+ const package_json_1 = require("../../plugins/package-json");
13
13
  const project_json_1 = require("../../plugins/project-json/build-nodes/project-json");
14
14
  const angular_json_1 = require("../../adapter/angular-json");
15
15
  const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
@@ -132,7 +132,7 @@ function readAndCombineAllProjectConfigurations(tree) {
132
132
  const patterns = [
133
133
  '**/project.json',
134
134
  'project.json',
135
- ...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })),
135
+ ...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })),
136
136
  ];
137
137
  const globbedFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(tree.root, patterns);
138
138
  const createdFiles = findCreatedProjectFiles(tree, patterns);
@@ -147,7 +147,7 @@ function readAndCombineAllProjectConfigurations(tree) {
147
147
  }
148
148
  else if ((0, path_1.basename)(projectFile) === 'package.json') {
149
149
  const packageJson = (0, json_1.readJson)(tree, projectFile);
150
- const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, tree.root, projectFile, (0, nx_json_1.readNxJson)(tree));
150
+ const config = (0, package_json_1.buildProjectConfigurationFromPackageJson)(packageJson, tree.root, projectFile, (0, nx_json_1.readNxJson)(tree));
151
151
  if (!rootMap[config.root]) {
152
152
  (0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
153
153
  // Inferred targets, tags, etc don't show up when running generators
Binary file
@@ -1,8 +1,8 @@
1
1
  import { NxJsonConfiguration } from '../../config/nx-json';
2
2
  import { ProjectConfiguration } from '../../config/workspace-json-project-json';
3
3
  import { PackageJson } from '../../utils/package-json';
4
- import { CreateNodes } from '../../project-graph/plugins';
5
- export declare const createNodes: CreateNodes;
4
+ import { CreateNodesV2 } from '../../project-graph/plugins';
5
+ export declare const createNodesV2: CreateNodesV2;
6
6
  export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (string: any) => any): (p: string) => boolean;
7
7
  export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string): {
8
8
  projects: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = void 0;
3
+ exports.createNodesV2 = void 0;
4
4
  exports.buildPackageJsonWorkspacesMatcher = buildPackageJsonWorkspacesMatcher;
5
5
  exports.createNodeFromPackageJson = createNodeFromPackageJson;
6
6
  exports.buildProjectConfigurationFromPackageJson = buildProjectConfigurationFromPackageJson;
@@ -16,18 +16,40 @@ const logger_1 = require("../../utils/logger");
16
16
  const output_1 = require("../../utils/output");
17
17
  const package_json_1 = require("../../utils/package-json");
18
18
  const path_1 = require("../../utils/path");
19
- exports.createNodes = [
20
- (0, globs_1.combineGlobPatterns)('package.json', '**/package.json'),
21
- (p, _, { workspaceRoot }) => {
22
- const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, f));
23
- const matcher = buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson);
24
- if (matcher(p)) {
25
- return createNodeFromPackageJson(p, workspaceRoot);
26
- }
27
- // The given package.json is not part of the workspaces configuration.
28
- return {};
19
+ const plugins_1 = require("../../project-graph/plugins");
20
+ const path_2 = require("path");
21
+ exports.createNodesV2 = [
22
+ (0, globs_1.combineGlobPatterns)('package.json', '**/package.json', 'project.json', '**/project.json'),
23
+ (configFiles, _, context) => {
24
+ const { packageJsons, projectJsonRoots } = splitConfigFiles(configFiles);
25
+ const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, f));
26
+ const isInPackageJsonWorkspaces = buildPackageJsonWorkspacesMatcher(context.workspaceRoot, readJson);
27
+ const isNextToProjectJson = (packageJsonPath) => {
28
+ return projectJsonRoots.has((0, node_path_1.dirname)(packageJsonPath));
29
+ };
30
+ return (0, plugins_1.createNodesFromFiles)((packageJsonPath, options, context) => {
31
+ if (!isInPackageJsonWorkspaces(packageJsonPath) &&
32
+ !isNextToProjectJson(packageJsonPath)) {
33
+ // Skip if package.json is not part of the package.json workspaces and not next to a project.json.
34
+ return null;
35
+ }
36
+ return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot);
37
+ }, packageJsons, _, context);
29
38
  },
30
39
  ];
40
+ function splitConfigFiles(configFiles) {
41
+ const packageJsons = [];
42
+ const projectJsonRoots = new Set();
43
+ for (const configFile of configFiles) {
44
+ if ((0, path_2.basename)(configFile) === 'package.json') {
45
+ packageJsons.push(configFile);
46
+ }
47
+ else {
48
+ projectJsonRoots.add((0, node_path_1.dirname)(configFile));
49
+ }
50
+ }
51
+ return { packageJsons, projectJsonRoots };
52
+ }
31
53
  function buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson) {
32
54
  const patterns = getGlobPatternsFromPackageManagerWorkspaces(workspaceRoot, readJson);
33
55
  const negativePatterns = patterns.filter((p) => p.startsWith('!'));
@@ -0,0 +1,2 @@
1
+ export * from './create-nodes';
2
+ export declare const name = "nx/core/package-json";
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.name = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("./create-nodes"), exports);
6
- exports.name = 'nx/core/package-json-workspaces';
6
+ exports.name = 'nx/core/package-json';
@@ -6,18 +6,21 @@ exports.readNameFromPackageJson = readNameFromPackageJson;
6
6
  const node_path_1 = require("node:path");
7
7
  const to_project_name_1 = require("../../../config/to-project-name");
8
8
  const fileutils_1 = require("../../../utils/fileutils");
9
+ const plugins_1 = require("../../../project-graph/plugins");
9
10
  exports.ProjectJsonProjectsPlugin = {
10
11
  name: 'nx/core/project-json',
11
- createNodes: [
12
+ createNodesV2: [
12
13
  '{project.json,**/project.json}',
13
- (file, _, { workspaceRoot }) => {
14
- const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, file));
15
- const project = buildProjectFromProjectJson(json, file);
16
- return {
17
- projects: {
18
- [project.root]: project,
19
- },
20
- };
14
+ (configFiles, _, context) => {
15
+ return (0, plugins_1.createNodesFromFiles)((file) => {
16
+ const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, file));
17
+ const project = buildProjectFromProjectJson(json, file);
18
+ return {
19
+ projects: {
20
+ [project.root]: project,
21
+ },
22
+ };
23
+ }, configFiles, _, context);
21
24
  },
22
25
  ],
23
26
  };
@@ -18,7 +18,7 @@ const project_graph_1 = require("./project-graph");
18
18
  const angular_json_1 = require("../adapter/angular-json");
19
19
  const ignore_1 = require("../utils/ignore");
20
20
  const project_configuration_utils_1 = require("./utils/project-configuration-utils");
21
- const package_json_workspaces_1 = require("../plugins/package-json-workspaces");
21
+ const package_json_1 = require("../plugins/package-json");
22
22
  const workspace_context_1 = require("../utils/workspace-context");
23
23
  const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
24
24
  class WholeFileChange {
@@ -150,7 +150,7 @@ function getProjectsSync(root, nxJson) {
150
150
  const patterns = [
151
151
  '**/project.json',
152
152
  'project.json',
153
- ...(0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(root, fileutils_1.readJsonFile),
153
+ ...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(root, fileutils_1.readJsonFile),
154
154
  ];
155
155
  const projectFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(root, patterns);
156
156
  const rootMap = {};
@@ -162,7 +162,7 @@ function getProjectsSync(root, nxJson) {
162
162
  }
163
163
  else if ((0, path_1.basename)(projectFile) === 'package.json') {
164
164
  const packageJson = (0, fileutils_1.readJsonFile)(projectFile);
165
- const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, root, projectFile, nxJson);
165
+ const config = (0, package_json_1.buildProjectConfigurationFromPackageJson)(packageJson, root, projectFile, nxJson);
166
166
  if (!rootMap[config.root]) {
167
167
  (0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
168
168
  // Inferred targets, tags, etc don't show up when running generators
@@ -101,9 +101,6 @@ async function loadNxPlugins(plugins, root = workspace_root_1.workspaceRoot) {
101
101
  async function normalizePlugins(plugins, root) {
102
102
  plugins ??= [];
103
103
  return [
104
- // This plugin adds targets that we want to be able to overwrite
105
- // in any user-land plugin, so it has to be first :).
106
- (0, path_1.join)(__dirname, '../../plugins/project-json/build-nodes/package-json-next-to-project-json'),
107
104
  ...plugins,
108
105
  // Most of the nx core node plugins go on the end, s.t. it overwrites any other plugins
109
106
  ...(await getDefaultPlugins(root)),
@@ -115,7 +112,7 @@ async function getDefaultPlugins(root) {
115
112
  ...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
116
113
  ? [(0, path_1.join)(__dirname, '../../adapter/angular-json')]
117
114
  : []),
118
- (0, path_1.join)(__dirname, '../../plugins/package-json-workspaces'),
115
+ (0, path_1.join)(__dirname, '../../plugins/package-json'),
119
116
  (0, path_1.join)(__dirname, '../../plugins/project-json/build-nodes/project-json'),
120
117
  ];
121
118
  }
@@ -211,7 +211,9 @@ async function loadNxPluginAsync(pluginConfiguration, paths, root) {
211
211
  async function importPluginModule(pluginPath) {
212
212
  const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
213
213
  if (m.default &&
214
- ('createNodes' in m.default || 'createDependencies' in m.default)) {
214
+ ('createNodes' in m.default ||
215
+ 'createNodesV2' in m.default ||
216
+ 'createDependencies' in m.default)) {
215
217
  return m.default;
216
218
  }
217
219
  return m;
@@ -48,7 +48,9 @@ async function createNodesFromFiles(createNodes, configFiles, options, context)
48
48
  ...context,
49
49
  configFiles,
50
50
  });
51
- results.push([file, value]);
51
+ if (value) {
52
+ results.push([file, value]);
53
+ }
52
54
  }
53
55
  catch (e) {
54
56
  errors.push([file, e]);
@@ -762,9 +762,14 @@ function resolveCommandSyntacticSugar(target, key) {
762
762
  * @returns The normalized target configuration
763
763
  */
764
764
  function normalizeTarget(target, project) {
765
+ target = {
766
+ ...target,
767
+ configurations: {
768
+ ...target.configurations,
769
+ },
770
+ };
765
771
  target = resolveCommandSyntacticSugar(target, project.root);
766
772
  target.options = resolveNxTokensInOptions(target.options, project, `${project.root}:${target}`);
767
- target.configurations ??= {};
768
773
  for (const configuration in target.configurations) {
769
774
  target.configurations[configuration] = resolveNxTokensInOptions(target.configurations[configuration], project, `${project.root}:${target}:${configuration}`);
770
775
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDefaultPluginsSync = getDefaultPluginsSync;
4
4
  const angular_json_1 = require("../adapter/angular-json");
5
5
  const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
6
- const PackageJsonWorkspacesPlugin = require("../plugins/package-json-workspaces");
6
+ const PackageJsonWorkspacesPlugin = require("../plugins/package-json");
7
7
  /**
8
8
  * @todo(@agentender) v20: Remove this fn when we remove readWorkspaceConfig
9
9
  */
@@ -1,2 +0,0 @@
1
- export * from './create-nodes';
2
- export declare const name = "nx/core/package-json-workspaces";
@@ -1,3 +0,0 @@
1
- import { NxPluginV2 } from '../../../project-graph/plugins';
2
- export declare const PackageJsonProjectsNextToProjectJsonPlugin: NxPluginV2;
3
- export default PackageJsonProjectsNextToProjectJsonPlugin;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PackageJsonProjectsNextToProjectJsonPlugin = void 0;
4
- const path_1 = require("path");
5
- const fs_1 = require("fs");
6
- const fileutils_1 = require("../../../utils/fileutils");
7
- const package_json_1 = require("../../../utils/package-json");
8
- const package_json_workspaces_1 = require("../../package-json-workspaces");
9
- // TODO: Remove this one day, this should not need to be done.
10
- exports.PackageJsonProjectsNextToProjectJsonPlugin = {
11
- // Its not a problem if plugins happen to have same name, and this
12
- // will look least confusing in the source map.
13
- name: 'nx/core/package-json',
14
- createNodes: [
15
- '{project.json,**/project.json}',
16
- (file, _, { workspaceRoot }) => {
17
- const project = createProjectFromPackageJsonNextToProjectJson(file, workspaceRoot);
18
- return project
19
- ? {
20
- projects: {
21
- [project.name]: project,
22
- },
23
- }
24
- : {};
25
- },
26
- ],
27
- };
28
- exports.default = exports.PackageJsonProjectsNextToProjectJsonPlugin;
29
- function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspaceRoot) {
30
- const root = (0, path_1.dirname)(projectJsonPath);
31
- const relativePackageJsonPath = (0, path_1.join)(root, 'package.json');
32
- const packageJsonPath = (0, path_1.join)(workspaceRoot, relativePackageJsonPath);
33
- const readJson = (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(workspaceRoot, f));
34
- // Do not create projects for package.json files
35
- // that are part of the package manager workspaces
36
- // Those package.json files will be processed later on
37
- const matcher = (0, package_json_workspaces_1.buildPackageJsonWorkspacesMatcher)(workspaceRoot, readJson);
38
- if (!(0, fs_1.existsSync)(packageJsonPath) || matcher(relativePackageJsonPath)) {
39
- return null;
40
- }
41
- try {
42
- const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
43
- let { nx, name } = packageJson;
44
- return {
45
- ...nx,
46
- name,
47
- root,
48
- targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson),
49
- metadata: (0, package_json_1.getMetadataFromPackageJson)(packageJson),
50
- tags: (0, package_json_1.getTagsFromPackageJson)(packageJson),
51
- };
52
- }
53
- catch (e) {
54
- console.log(e);
55
- return null;
56
- }
57
- }