Skip to content

Commit

Permalink
fix: bump nx to >=16.5.1 (#3767)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj committed Jul 14, 2023
1 parent b2c4d74 commit 0bbd74d
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 281 deletions.
4 changes: 2 additions & 2 deletions libs/commands/run/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
} from "@lerna/core";
import { TargetDependencyConfig } from "@nx/devkit";
import { existsSync } from "fs-extra";
import { runMany } from "nx/src/command-line/run-many";
import { runOne } from "nx/src/command-line/run-one";
import { runMany } from "nx/src/command-line/run-many/run-many";
import { runOne } from "nx/src/command-line/run/run-one";
import pMap from "p-map";
import path from "path";
import { performance } from "perf_hooks";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ProjectFileMap, ProjectGraph, ProjectGraphProjectNode, workspaceRoot } from "@nx/devkit";
import { readJson } from "fs-extra";
import { sortBy } from "lodash";
import { reduce, sortBy } from "lodash";
import minimatch from "minimatch";
import { resolve } from "npm-package-arg";
import { join } from "path";
Expand Down Expand Up @@ -62,6 +62,13 @@ export async function createProjectGraphWithPackages(
};
});

// order dependencies to create consistent results when iterating over them
projectGraphWithOrderedNodes.dependencies = reduce(
sortBy(Object.keys(projectGraphWithOrderedNodes.dependencies)),
(prev, next) => ({ ...prev, [next]: projectGraphWithOrderedNodes.dependencies[next] }),
{}
);

// populate local npm package dependencies
Object.values(projectGraphWithOrderedNodes.dependencies).forEach((projectDeps) => {
const workspaceDeps = projectDeps.filter(
Expand Down
19 changes: 1 addition & 18 deletions libs/core/src/lib/command/detect-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,7 @@ export async function detectProjects(packageConfigs: string[]): Promise<{
projectFileMap: ProjectFileMap;
}> {
const _projectGraph = await createProjectGraphAsync();

let projectFileMap: ProjectFileMap;

// if we are using Nx >= 16.3.1, we can use the helper function to create the file map
// otherwise, we need to use the old "files" property on the node data
if (createProjectFileMapUsingProjectGraph) {
projectFileMap = await createProjectFileMapUsingProjectGraph(_projectGraph);
} else {
projectFileMap = Object.entries(_projectGraph.nodes).reduce(
(map, [key, node]) => ({
...map,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key]: (node.data as any).files,
}),
{}
);
}

const projectFileMap = await createProjectFileMapUsingProjectGraph(_projectGraph);
const projectGraph = await createProjectGraphWithPackages(_projectGraph, projectFileMap, packageConfigs);

return {
Expand Down
2 changes: 1 addition & 1 deletion libs/core/src/lib/test-helpers/create-project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
process.env.NX_DAEMON = "false";
process.env.NX_CACHE_PROJECT_GRAPH = "false";

import { fileHasher } from "nx/src/hasher/impl";
import { ProjectGraphDependency, ProjectGraphProjectNode } from "@nx/devkit";
import { fileHasher } from "nx/src/hasher/file-hasher";
import { Package, RawManifest } from "../package";
import {
ProjectGraphProjectNodeWithPackage,
Expand Down
2 changes: 1 addition & 1 deletion libs/test-helpers/src/lib/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import execa from "execa";
import { fileHasher } from "nx/src/hasher/impl";
import { fileHasher } from "nx/src/hasher/file-hasher";
import { setWorkspaceRoot } from "nx/src/utils/workspace-root";
import path, { join } from "path";
import yargs from "yargs";
Expand Down
Loading

0 comments on commit 0bbd74d

Please sign in to comment.