Skip to content

Commit

Permalink
feat(core): move task hashing into daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed May 17, 2023
1 parent 70f7c65 commit 0848031
Show file tree
Hide file tree
Showing 126 changed files with 2,163 additions and 3,215 deletions.
42 changes: 32 additions & 10 deletions docs/generated/devkit/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ It only uses language primitives and immutable objects

### Classes

- [Hasher](../../devkit/documents/nx_devkit#hasher)
- [ProjectGraphBuilder](../../devkit/documents/nx_devkit#projectgraphbuilder)
- [Workspaces](../../devkit/documents/nx_devkit#workspaces)

Expand Down Expand Up @@ -57,6 +56,7 @@ It only uses language primitives and immutable objects
- [TargetDependencyConfig](../../devkit/documents/nx_devkit#targetdependencyconfig)
- [Task](../../devkit/documents/nx_devkit#task)
- [TaskGraph](../../devkit/documents/nx_devkit#taskgraph)
- [TaskHasher](../../devkit/documents/nx_devkit#taskhasher)
- [Tree](../../devkit/documents/nx_devkit#tree)
- [Workspace](../../devkit/documents/nx_devkit#workspace)

Expand All @@ -67,6 +67,7 @@ It only uses language primitives and immutable objects
- [Executor](../../devkit/documents/nx_devkit#executor)
- [Generator](../../devkit/documents/nx_devkit#generator)
- [GeneratorCallback](../../devkit/documents/nx_devkit#generatorcallback)
- [Hasher](../../devkit/documents/nx_devkit#hasher)
- [ImplicitDependencyEntry](../../devkit/documents/nx_devkit#implicitdependencyentry)
- [ModuleFederationLibrary](../../devkit/documents/nx_devkit#modulefederationlibrary)
- [PackageManager](../../devkit/documents/nx_devkit#packagemanager)
Expand Down Expand Up @@ -116,6 +117,7 @@ It only uses language primitives and immutable objects
- [getProjects](../../devkit/documents/nx_devkit#getprojects)
- [getWorkspaceLayout](../../devkit/documents/nx_devkit#getworkspacelayout)
- [getWorkspacePath](../../devkit/documents/nx_devkit#getworkspacepath)
- [hashArray](../../devkit/documents/nx_devkit#hasharray)
- [installPackagesTask](../../devkit/documents/nx_devkit#installpackagestask)
- [isStandaloneProject](../../devkit/documents/nx_devkit#isstandaloneproject)
- [joinPathFragments](../../devkit/documents/nx_devkit#joinpathfragments)
Expand Down Expand Up @@ -174,14 +176,6 @@ Type of dependency between projects

## Classes

### Hasher

**Hasher**: `Object`

The default hasher used by executors.

---

### ProjectGraphBuilder

**ProjectGraphBuilder**: `Object`
Expand Down Expand Up @@ -456,6 +450,12 @@ Graph of Tasks to be executed

---

### TaskHasher

**TaskHasher**: `Object`

---

### Tree

**Tree**: `Object`
Expand Down Expand Up @@ -575,6 +575,12 @@ A callback function that is executed after changes are made to the file system

---

### Hasher

Ƭ **Hasher**: [`TaskHasher`](../../devkit/documents/nx_devkit#taskhasher)

---

### ImplicitDependencyEntry

Ƭ **ImplicitDependencyEntry**<`T`\>: `Object`
Expand Down Expand Up @@ -1105,7 +1111,7 @@ will change to Promise<{ [id: string]: TaskStatus }> after Nx 15 is released.
| `options` | [`DefaultTasksRunnerOptions`](../../devkit/documents/nx_devkit#defaulttasksrunneroptions) |
| `context?` | `Object` |
| `context.daemon?` | `DaemonClient` |
| `context.hasher?` | [`Hasher`](../../devkit/documents/nx_devkit#hasher) |
| `context.hasher?` | [`TaskHasher`](../../devkit/documents/nx_devkit#taskhasher) |
| `context.initiatingProject?` | `string` |
| `context.nxArgs` | `NxArgs` |
| `context.nxJson` | [`NxJsonConfiguration`](../../devkit/documents/nx_devkit#nxjsonconfiguration)<`string`[] \| `"*"`\> |
Expand Down Expand Up @@ -1461,6 +1467,22 @@ all projects are configured using project.json

---

### hashArray

**hashArray**(`content`): `string`

#### Parameters

| Name | Type |
| :-------- | :--------- |
| `content` | `string`[] |

#### Returns

`string`

---

### installPackagesTask

**installPackagesTask**(`tree`, `alwaysRun?`, `cwd?`, `packageManager?`): `void`
Expand Down
42 changes: 32 additions & 10 deletions docs/generated/packages/devkit/documents/nx_devkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ It only uses language primitives and immutable objects

### Classes

- [Hasher](../../devkit/documents/nx_devkit#hasher)
- [ProjectGraphBuilder](../../devkit/documents/nx_devkit#projectgraphbuilder)
- [Workspaces](../../devkit/documents/nx_devkit#workspaces)

Expand Down Expand Up @@ -57,6 +56,7 @@ It only uses language primitives and immutable objects
- [TargetDependencyConfig](../../devkit/documents/nx_devkit#targetdependencyconfig)
- [Task](../../devkit/documents/nx_devkit#task)
- [TaskGraph](../../devkit/documents/nx_devkit#taskgraph)
- [TaskHasher](../../devkit/documents/nx_devkit#taskhasher)
- [Tree](../../devkit/documents/nx_devkit#tree)
- [Workspace](../../devkit/documents/nx_devkit#workspace)

Expand All @@ -67,6 +67,7 @@ It only uses language primitives and immutable objects
- [Executor](../../devkit/documents/nx_devkit#executor)
- [Generator](../../devkit/documents/nx_devkit#generator)
- [GeneratorCallback](../../devkit/documents/nx_devkit#generatorcallback)
- [Hasher](../../devkit/documents/nx_devkit#hasher)
- [ImplicitDependencyEntry](../../devkit/documents/nx_devkit#implicitdependencyentry)
- [ModuleFederationLibrary](../../devkit/documents/nx_devkit#modulefederationlibrary)
- [PackageManager](../../devkit/documents/nx_devkit#packagemanager)
Expand Down Expand Up @@ -116,6 +117,7 @@ It only uses language primitives and immutable objects
- [getProjects](../../devkit/documents/nx_devkit#getprojects)
- [getWorkspaceLayout](../../devkit/documents/nx_devkit#getworkspacelayout)
- [getWorkspacePath](../../devkit/documents/nx_devkit#getworkspacepath)
- [hashArray](../../devkit/documents/nx_devkit#hasharray)
- [installPackagesTask](../../devkit/documents/nx_devkit#installpackagestask)
- [isStandaloneProject](../../devkit/documents/nx_devkit#isstandaloneproject)
- [joinPathFragments](../../devkit/documents/nx_devkit#joinpathfragments)
Expand Down Expand Up @@ -174,14 +176,6 @@ Type of dependency between projects

## Classes

### Hasher

**Hasher**: `Object`

The default hasher used by executors.

---

### ProjectGraphBuilder

**ProjectGraphBuilder**: `Object`
Expand Down Expand Up @@ -456,6 +450,12 @@ Graph of Tasks to be executed

---

### TaskHasher

**TaskHasher**: `Object`

---

### Tree

**Tree**: `Object`
Expand Down Expand Up @@ -575,6 +575,12 @@ A callback function that is executed after changes are made to the file system

---

### Hasher

Ƭ **Hasher**: [`TaskHasher`](../../devkit/documents/nx_devkit#taskhasher)

---

### ImplicitDependencyEntry

Ƭ **ImplicitDependencyEntry**<`T`\>: `Object`
Expand Down Expand Up @@ -1105,7 +1111,7 @@ will change to Promise<{ [id: string]: TaskStatus }> after Nx 15 is released.
| `options` | [`DefaultTasksRunnerOptions`](../../devkit/documents/nx_devkit#defaulttasksrunneroptions) |
| `context?` | `Object` |
| `context.daemon?` | `DaemonClient` |
| `context.hasher?` | [`Hasher`](../../devkit/documents/nx_devkit#hasher) |
| `context.hasher?` | [`TaskHasher`](../../devkit/documents/nx_devkit#taskhasher) |
| `context.initiatingProject?` | `string` |
| `context.nxArgs` | `NxArgs` |
| `context.nxJson` | [`NxJsonConfiguration`](../../devkit/documents/nx_devkit#nxjsonconfiguration)<`string`[] \| `"*"`\> |
Expand Down Expand Up @@ -1461,6 +1467,22 @@ all projects are configured using project.json

---

### hashArray

**hashArray**(`content`): `string`

#### Parameters

| Name | Type |
| :-------- | :--------- |
| `content` | `string`[] |

#### Returns

`string`

---

### installPackagesTask

**installPackagesTask**(`tree`, `alwaysRun?`, `cwd?`, `packageManager?`): `void`
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/recipes/plugins/project-graph-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Plugins should export a function named `processProjectGraph` that handles updati

- A `ProjectGraph`

- `graph.nodes` lists all the projects currently known to Nx. `node.data.files` lists the files belonging to a particular project.
- `graph.nodes` lists all the projects currently known to Nx.
- `graph.dependencies` lists the dependencies between projects.

- A `Context`
Expand Down
57 changes: 0 additions & 57 deletions e2e/nx-init/src/nx-project-graph.test.ts

This file was deleted.

18 changes: 8 additions & 10 deletions e2e/react-native/src/react-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import {
checkFilesExist,
cleanupProject,
expectTestsPass,
getPackageManagerCommand,
isOSX,
killPorts,
newProject,
promisifiedTreeKill,
readJson,
runCLI,
runCLIAsync,
runCommand,
runCommandUntil,
uniq,
updateFile,
Expand Down Expand Up @@ -168,30 +170,26 @@ describe('react native', () => {
// Add npm package with native modules
updateFile(join('package.json'), (content) => {
const json = JSON.parse(content);
json.dependencies['react-native-image-picker'] = '1.0.0';
json.dependencies['react-native-gesture-handler'] = '1.0.0';
json.dependencies['react-native-safe-area-contex'] = '1.0.0';
json.dependencies['react-native-config'] = '1.0.0';
json.dependencies['@react-native-async-storage/async-storage'] = '1.0.0';
json.dependencies['react-native-image-picker'] = '5.3.1';
json.dependencies['@react-native-async-storage/async-storage'] = '1.18.1';
return JSON.stringify(json, null, 2);
});
runCommand(`${getPackageManagerCommand().install}`);

// Add import for Nx to pick up
updateFile(join('apps', appName, 'src/app/App.tsx'), (content) => {
return `import AsyncStorage from '@react-native-async-storage/async-storage';import Config from 'react-native-config';\n${content}`;
return `import AsyncStorage from '@react-native-async-storage/async-storage';${content}`;
});

await runCLIAsync(
`sync-deps ${appName} --include=react-native-gesture-handler,react-native-safe-area-context,react-native-image-picker`
`sync-deps ${appName} --include=react-native-image-picker`
);

const result = readJson(join('apps', appName, 'package.json'));
expect(result).toMatchObject({
dependencies: {
'react-native-image-picker': '*',
'react-native-gesture-handler': '*',
'react-native-safe-area-context': '*',
'react-native': '*',
'react-native-config': '*',
'@react-native-async-storage/async-storage': '*',
},
});
Expand Down
1 change: 1 addition & 0 deletions graph/client-e2e/src/fixtures/affected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1806,5 +1806,6 @@
"affected": ["cart", "cart-e2e"],
"focus": null,
"groupByFolder": false,
"fileMap": {},
"exclude": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -1833,5 +1833,6 @@
"affected": [],
"focus": null,
"groupByFolder": false,
"fileMap": {},
"exclude": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const customSelectedStateConfig: ProjectGraphStateNodeConfig = {
type: 'notifyGraphUpdateGraph',
projects: ctx.projects,
dependencies: ctx.dependencies,
fileMap: ctx.fileMap,
affectedProjects: ctx.affectedProjects,
workspaceLayout: ctx.workspaceLayout,
groupByFolder: ctx.groupByFolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const focusedStateConfig: ProjectGraphStateNodeConfig = {
type: 'notifyGraphUpdateGraph',
projects: ctx.projects,
dependencies: ctx.dependencies,
fileMap: ctx.fileMap,
affectedProjects: ctx.affectedProjects,
workspaceLayout: ctx.workspaceLayout,
groupByFolder: ctx.groupByFolder,
Expand Down
4 changes: 4 additions & 0 deletions graph/client/src/app/feature-projects/machines/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GraphPerfReport } from '../../interfaces';
/* eslint-disable @nx/enforce-module-boundaries */
// nx-ignore-next-line
import {
ProjectFileMap,
ProjectGraphDependency,
ProjectGraphProjectNode,
} from 'nx/src/config/project-graph';
Expand Down Expand Up @@ -58,6 +59,7 @@ export type ProjectGraphMachineEvents =
projects: ProjectGraphProjectNode[];
dependencies: Record<string, ProjectGraphDependency[]>;
affectedProjects: string[];
fileMap: ProjectFileMap;
workspaceLayout: {
libsDir: string;
appsDir: string;
Expand All @@ -67,6 +69,7 @@ export type ProjectGraphMachineEvents =
type: 'updateGraph';
projects: ProjectGraphProjectNode[];
dependencies: Record<string, ProjectGraphDependency[]>;
fileMap: ProjectFileMap;
};

// The context (extended state) of the machine
Expand All @@ -88,6 +91,7 @@ export interface ProjectGraphContext {
};
graphActor: ActorRef<GraphRenderEvents>;
lastPerfReport: GraphPerfReport;
fileMap: ProjectFileMap;
tracing: {
start: string;
end: string;
Expand Down
Loading

1 comment on commit 0848031

@vercel
Copy link

@vercel vercel bot commented on 0848031 May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.