Skip to content

Commit

Permalink
feat(core): restore cached dependencies from non-project-files
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Sep 18, 2023
1 parent 1286c7a commit ebc36dd
Show file tree
Hide file tree
Showing 22 changed files with 318 additions and 86 deletions.
30 changes: 30 additions & 0 deletions docs/generated/devkit/BaseFileData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Interface: BaseFileData

Some metadata about a file

## Hierarchy

- **`BaseFileData`**

[`ProjectFileData`](../../devkit/documents/ProjectFileData)

[`NonProjectFileData`](../../devkit/documents/NonProjectFileData)

## Table of contents

### Properties

- [file](../../devkit/documents/BaseFileData#file): string
- [hash](../../devkit/documents/BaseFileData#hash): string

## Properties

### file

**file**: `string`

---

### hash

**hash**: `string`
30 changes: 2 additions & 28 deletions docs/generated/devkit/FileData.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
# Interface: FileData
# Type alias: FileData

Some metadata about a file

## Table of contents

### Properties

- [deps](../../devkit/documents/FileData#deps): (string | [string, string])[]
- [file](../../devkit/documents/FileData#file): string
- [hash](../../devkit/documents/FileData#hash): string

## Properties

### deps

`Optional` **deps**: (`string` \| [`string`, `string`])[]

---

### file

**file**: `string`

---

### hash

**hash**: `string`
Ƭ **FileData**: [`ProjectFileData`](../../devkit/documents/ProjectFileData) \| [`NonProjectFileData`](../../devkit/documents/NonProjectFileData)
45 changes: 45 additions & 0 deletions docs/generated/devkit/NonProjectFileData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Interface: NonProjectFileData

Represents metadata about a file that **does not** belong to a project.

## Hierarchy

- [`BaseFileData`](../../devkit/documents/BaseFileData)

**`NonProjectFileData`**

## Table of contents

### Properties

- [deps](../../devkit/documents/NonProjectFileData#deps): ProjectGraphDependency[]
- [file](../../devkit/documents/NonProjectFileData#file): string
- [hash](../../devkit/documents/NonProjectFileData#hash): string

## Properties

### deps

`Optional` **deps**: [`ProjectGraphDependency`](../../devkit/documents/ProjectGraphDependency)[]

Dependencies which were created with this file as the source file.

---

### file

**file**: `string`

#### Inherited from

[BaseFileData](../../devkit/documents/BaseFileData).[file](../../devkit/documents/BaseFileData#file)

---

### hash

**hash**: `string`

#### Inherited from

[BaseFileData](../../devkit/documents/BaseFileData).[hash](../../devkit/documents/BaseFileData#hash)
48 changes: 48 additions & 0 deletions docs/generated/devkit/ProjectFileData.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Interface: ProjectFileData

Represents metadata about a file that belongs to a project.

## Hierarchy

- [`BaseFileData`](../../devkit/documents/BaseFileData)

**`ProjectFileData`**

## Table of contents

### Properties

- [deps](../../devkit/documents/ProjectFileData#deps): (string | [target: string, type: string])[]
- [file](../../devkit/documents/ProjectFileData#file): string
- [hash](../../devkit/documents/ProjectFileData#hash): string

## Properties

### deps

`Optional` **deps**: (`string` \| [target: string, type: string])[]

An array of dependencies. If an element is just a string,
the dependency is assumed to be a static dependency targetting
that string. If the element is a tuple, the first element inside of it
is the target project, with the second element being the type of dependency.

---

### file

**file**: `string`

#### Inherited from

[BaseFileData](../../devkit/documents/BaseFileData).[file](../../devkit/documents/BaseFileData#file)

---

### hash

**hash**: `string`

#### Inherited from

[BaseFileData](../../devkit/documents/BaseFileData).[hash](../../devkit/documents/BaseFileData#hash)
2 changes: 1 addition & 1 deletion docs/generated/devkit/ProjectFileMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ A list of files separated by the project they belong to

## Indexable

[projectName: `string`]: [`FileData`](../../devkit/documents/FileData)[]
[projectName: `string`]: [`ProjectFileData`](../../devkit/documents/ProjectFileData)[]
25 changes: 20 additions & 5 deletions docs/generated/devkit/ProjectGraphBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ The ProjectGraphProcessor has been deprecated. Use a [CreateNodes](../../devkit/

### Properties

- [allWorkspaceFiles](../../devkit/documents/ProjectGraphBuilder#allworkspacefiles): FileData[]
- [graph](../../devkit/documents/ProjectGraphBuilder#graph): ProjectGraph
- [nonProjectFiles](../../devkit/documents/ProjectGraphBuilder#nonprojectfiles): NonProjectFileData[]
- [projectFileMap](../../devkit/documents/ProjectGraphBuilder#projectfilemap): ProjectFileMap
- [removedEdges](../../devkit/documents/ProjectGraphBuilder#removededges): Object

Expand All @@ -40,23 +42,36 @@ The ProjectGraphProcessor has been deprecated. Use a [CreateNodes](../../devkit/

### constructor

**new ProjectGraphBuilder**(`graph?`, `fileMap?`)
**new ProjectGraphBuilder**(`graph?`, `projectFileMap?`, `nonProjectFiles?`)

#### Parameters

| Name | Type |
| :--------- | :-------------------------------------------------------- |
| `graph?` | [`ProjectGraph`](../../devkit/documents/ProjectGraph) |
| `fileMap?` | [`ProjectFileMap`](../../devkit/documents/ProjectFileMap) |
| Name | Type |
| :----------------- | :------------------------------------------------------------------ |
| `graph?` | [`ProjectGraph`](../../devkit/documents/ProjectGraph) |
| `projectFileMap?` | [`ProjectFileMap`](../../devkit/documents/ProjectFileMap) |
| `nonProjectFiles?` | [`NonProjectFileData`](../../devkit/documents/NonProjectFileData)[] |

## Properties

### allWorkspaceFiles

`Private` `Readonly` **allWorkspaceFiles**: [`FileData`](../../devkit/documents/FileData)[]

---

### graph

`Readonly` **graph**: [`ProjectGraph`](../../devkit/documents/ProjectGraph)

---

### nonProjectFiles

`Private` `Readonly` **nonProjectFiles**: [`NonProjectFileData`](../../devkit/documents/NonProjectFileData)[]

---

### projectFileMap

`Private` `Readonly` **projectFileMap**: [`ProjectFileMap`](../../devkit/documents/ProjectFileMap)
Expand Down
5 changes: 4 additions & 1 deletion docs/generated/devkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@ It only uses language primitives and immutable objects

### Interfaces

- [BaseFileData](../../devkit/documents/BaseFileData)
- [CreateDependenciesContext](../../devkit/documents/CreateDependenciesContext)
- [CreateNodesContext](../../devkit/documents/CreateNodesContext)
- [DefaultTasksRunnerOptions](../../devkit/documents/DefaultTasksRunnerOptions)
- [ExecutorContext](../../devkit/documents/ExecutorContext)
- [ExecutorsJson](../../devkit/documents/ExecutorsJson)
- [FileChange](../../devkit/documents/FileChange)
- [FileData](../../devkit/documents/FileData)
- [GeneratorsJson](../../devkit/documents/GeneratorsJson)
- [Hash](../../devkit/documents/Hash)
- [HasherContext](../../devkit/documents/HasherContext)
- [ImplicitJsonSubsetDependency](../../devkit/documents/ImplicitJsonSubsetDependency)
- [JsonParseOptions](../../devkit/documents/JsonParseOptions)
- [JsonSerializeOptions](../../devkit/documents/JsonSerializeOptions)
- [MigrationsJson](../../devkit/documents/MigrationsJson)
- [NonProjectFileData](../../devkit/documents/NonProjectFileData)
- [NxAffectedConfig](../../devkit/documents/NxAffectedConfig)
- [NxJsonConfiguration](../../devkit/documents/NxJsonConfiguration)
- [ProjectConfiguration](../../devkit/documents/ProjectConfiguration)
- [ProjectFileData](../../devkit/documents/ProjectFileData)
- [ProjectFileMap](../../devkit/documents/ProjectFileMap)
- [ProjectGraph](../../devkit/documents/ProjectGraph)
- [ProjectGraphDependency](../../devkit/documents/ProjectGraphDependency)
Expand Down Expand Up @@ -67,6 +69,7 @@ It only uses language primitives and immutable objects
- [CustomHasher](../../devkit/documents/CustomHasher)
- [DynamicDependency](../../devkit/documents/DynamicDependency)
- [Executor](../../devkit/documents/Executor)
- [FileData](../../devkit/documents/FileData)
- [Generator](../../devkit/documents/Generator)
- [GeneratorCallback](../../devkit/documents/GeneratorCallback)
- [Hasher](../../devkit/documents/Hasher)
Expand Down
5 changes: 4 additions & 1 deletion docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@ It only uses language primitives and immutable objects

### Interfaces

- [BaseFileData](../../devkit/documents/BaseFileData)
- [CreateDependenciesContext](../../devkit/documents/CreateDependenciesContext)
- [CreateNodesContext](../../devkit/documents/CreateNodesContext)
- [DefaultTasksRunnerOptions](../../devkit/documents/DefaultTasksRunnerOptions)
- [ExecutorContext](../../devkit/documents/ExecutorContext)
- [ExecutorsJson](../../devkit/documents/ExecutorsJson)
- [FileChange](../../devkit/documents/FileChange)
- [FileData](../../devkit/documents/FileData)
- [GeneratorsJson](../../devkit/documents/GeneratorsJson)
- [Hash](../../devkit/documents/Hash)
- [HasherContext](../../devkit/documents/HasherContext)
- [ImplicitJsonSubsetDependency](../../devkit/documents/ImplicitJsonSubsetDependency)
- [JsonParseOptions](../../devkit/documents/JsonParseOptions)
- [JsonSerializeOptions](../../devkit/documents/JsonSerializeOptions)
- [MigrationsJson](../../devkit/documents/MigrationsJson)
- [NonProjectFileData](../../devkit/documents/NonProjectFileData)
- [NxAffectedConfig](../../devkit/documents/NxAffectedConfig)
- [NxJsonConfiguration](../../devkit/documents/NxJsonConfiguration)
- [ProjectConfiguration](../../devkit/documents/ProjectConfiguration)
- [ProjectFileData](../../devkit/documents/ProjectFileData)
- [ProjectFileMap](../../devkit/documents/ProjectFileMap)
- [ProjectGraph](../../devkit/documents/ProjectGraph)
- [ProjectGraphDependency](../../devkit/documents/ProjectGraphDependency)
Expand Down Expand Up @@ -67,6 +69,7 @@ It only uses language primitives and immutable objects
- [CustomHasher](../../devkit/documents/CustomHasher)
- [DynamicDependency](../../devkit/documents/DynamicDependency)
- [Executor](../../devkit/documents/Executor)
- [FileData](../../devkit/documents/FileData)
- [Generator](../../devkit/documents/Generator)
- [GeneratorCallback](../../devkit/documents/GeneratorCallback)
- [Hasher](../../devkit/documents/Hasher)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ImportDeclaration, ImportSpecifier, Node } from 'typescript';
import { FileChangeRecorder } from '../../utils/file-change-recorder';
import { ngrxVersion } from '../../utils/versions';
import { getProjectsFilteredByDependencies } from '../utils/projects';
import { readProjectFileMapCache } from 'nx/src/project-graph/nx-deps-cache';
import { readFileMapCache } from 'nx/src/project-graph/nx-deps-cache';
import { fileDataDepTarget } from 'nx/src/config/project-graph';

let tsquery: typeof import('@phenomnomnominal/tsquery').tsquery;
Expand All @@ -35,7 +35,7 @@ export default async function (tree: Tree): Promise<void> {

ensureTypescript();
tsquery = require('@phenomnomnominal/tsquery').tsquery;
const cachedFileMap = readProjectFileMapCache().projectFileMap;
const cachedFileMap = readFileMapCache().fileMap.projectFileMap;

const filesWithNxAngularImports: FileData[] = [];
for (const { graphNode } of projects) {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/utils/graph-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function findFilesInCircularPath(

for (let i = 0; i < circularPath.length - 1; i++) {
const next = circularPath[i + 1].name;
const files: FileData[] = projectFileMap[circularPath[i].name] || [];
const files = projectFileMap[circularPath[i].name] || [];
filePathChain.push(
files
.filter(
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/utils/project-graph-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from 'nx/src/project-graph/utils/find-project-for-path';
import { readNxJson } from 'nx/src/config/configuration';
import { TargetProjectLocator } from '@nx/js/src/internal';
import { readProjectFileMapCache } from 'nx/src/project-graph/nx-deps-cache';
import { readFileMapCache } from 'nx/src/project-graph/nx-deps-cache';

export function ensureGlobalProjectGraph(ruleName: string) {
/**
Expand All @@ -37,7 +37,7 @@ export function ensureGlobalProjectGraph(ruleName: string) {
globalThis.projectRootMappings = createProjectRootMappings(
projectGraph.nodes
);
globalThis.projectFileMap = readProjectFileMapCache().projectFileMap;
globalThis.projectFileMap = readFileMapCache().fileMap.projectFileMap;
globalThis.targetProjectLocator = new TargetProjectLocator(
projectGraph.nodes,
projectGraph.externalNodes
Expand Down
4 changes: 2 additions & 2 deletions packages/js/src/utils/package-json/update-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { writeFileSync } from 'fs-extra';
import { fileExists } from 'nx/src/utils/fileutils';
import type { PackageJson } from 'nx/src/utils/package-json';
import { existsSync } from 'fs';
import { readProjectFileMapCache } from 'nx/src/project-graph/nx-deps-cache';
import { readFileMapCache } from 'nx/src/project-graph/nx-deps-cache';

import { getRelativeDirectoryToProjectRoot } from '../get-main-file-dir';

Expand Down Expand Up @@ -57,7 +57,7 @@ export function updatePackageJson(
): void {
let packageJson: PackageJson;
if (fileMap == null) {
fileMap = readProjectFileMapCache()?.projectFileMap || {};
fileMap = readFileMapCache()?.fileMap?.projectFileMap || {};
}

if (options.updateBuildableProjectDepsInPackageJson) {
Expand Down
Loading

0 comments on commit ebc36dd

Please sign in to comment.