Skip to content

Commit

Permalink
feat(devkit): mark ExecutorContext props required
Browse files Browse the repository at this point in the history
  • Loading branch information
edbzn committed Oct 23, 2023
1 parent cc8d8e8 commit d72ecd6
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 28 deletions.
15 changes: 4 additions & 11 deletions docs/generated/devkit/ExecutorContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,19 @@ Enable verbose logging

### nxJsonConfiguration

`Optional` **nxJsonConfiguration**: [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>
**nxJsonConfiguration**: [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>

The contents of nx.json.

@todo(vsavkin): mark this as required for v17

---

### projectGraph

`Optional` **projectGraph**: [`ProjectGraph`](../../devkit/documents/ProjectGraph)
**projectGraph**: [`ProjectGraph`](../../devkit/documents/ProjectGraph)

A snapshot of the project graph as
it existed when the Nx command was kicked off

@todo(vsavkin) mark this required for v17

---

### projectName
Expand All @@ -76,12 +72,10 @@ The name of the project being executed on

### projectsConfigurations

`Optional` **projectsConfigurations**: [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)
**projectsConfigurations**: [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations)

Projects config

@todo(vsavkin): mark this as required for v17

---

### root
Expand Down Expand Up @@ -119,8 +113,7 @@ it existed when the Nx command was kicked off

### workspace

`Optional` **workspace**: [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations) & [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>
**workspace**: [`ProjectsConfigurations`](../../devkit/documents/ProjectsConfigurations) & [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)<`string`[] \| `"*"`\>

Deprecated. Use projectsConfigurations or nxJsonConfiguration
The full workspace configuration
@todo(vsavkin): remove after v17
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import { scheduleTarget } from 'nx/src/adapter/ngcli-adapter';
import { executeWebpackDevServerBuilder } from '../webpack-dev-server/webpack-dev-server.impl';
import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph';
import { getExecutorInformation } from 'nx/src/command-line/run/executor-utils';
import {
getDynamicRemotes,
getStaticRemotes,
validateDevRemotes,
} from '../utilities/module-federation';
import { validateDevRemotes } from '../utilities/module-federation';
import { existsSync } from 'fs';
import { extname, join } from 'path';
import {
Expand Down Expand Up @@ -64,6 +60,10 @@ export function executeModuleFederationDevServerBuilder(
projectsConfigurations:
readProjectsConfigurationFromProjectGraph(projectGraph),
nxJsonConfiguration: readNxJson(),
workspace: {
version: 2,
projects: workspaceProjects,
},
}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
joinPathFragments,
parseTargetString,
readCachedProjectGraph,
readNxJson,
} from '@nx/devkit';
import { WebpackNxBuildCoordinationPlugin } from '@nx/webpack/src/plugins/webpack-nx-build-coordination-plugin';
import { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
Expand All @@ -19,7 +18,6 @@ import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs';
import { from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { getRootTsConfigPath } from '@nx/js';
import { join } from 'path';

type BuildTargetOptions = {
tsConfig: string;
Expand All @@ -36,12 +34,19 @@ export function executeWebpackDevServerBuilder(

const options = normalizeOptions(rawOptions);

const projectsConfigurations = {
version: 2,
projects: {},
};
const parsedBrowserTarget = parseTargetString(options.browserTarget, {
cwd: context.currentDirectory,
projectGraph: readCachedProjectGraph(),
projectName: context.target.project,
root: context.workspaceRoot,
isVerbose: false,
projectsConfigurations,
workspace: projectsConfigurations,
nxJsonConfiguration: {},
});
const browserTargetProjectConfiguration = readCachedProjectConfiguration(
parsedBrowserTarget.project
Expand Down
4 changes: 4 additions & 0 deletions packages/cypress/src/utils/ct-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,9 @@ export function createExecutorContext(
projectName,
projectsConfigurations,
nxJsonConfiguration,
workspace: {
version: 2,
projects: projectsConfigurations.projects,
},
};
}
4 changes: 4 additions & 0 deletions packages/cypress/src/utils/find-target-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,9 @@ function createExecutorContext(
projectName,
projectsConfigurations,
nxJsonConfiguration,
workspace: {
version: 2,
projects: projectsConfigurations.projects,
},
};
}
4 changes: 4 additions & 0 deletions packages/devkit/src/utils/convert-nx-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export function convertNxExecutor(executor: Executor) {
projectGraph: null,
taskGraph: null,
isVerbose: false,
workspace: {
version: 2,
projects: projectsConfigurations.projects,
},
};
return executor(options, context);
};
Expand Down
8 changes: 8 additions & 0 deletions packages/js/src/executors/tsc/tsc.impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ describe('tscExecutor', () => {
projects: {},
},
nxJsonConfiguration: {},
projectGraph: {
nodes: {},
dependencies: {},
},
workspace: {
version: 2,
projects: {},
},
isVerbose: false,
projectName: 'example',
targetName: 'build',
Expand Down
7 changes: 7 additions & 0 deletions packages/next/plugins/component-testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@ export function nxComponentTestingPreset(
let buildFileReplacements = [];
let buildOuputPath = `dist/${ctProjectName}/.next`;
if (buildTarget) {
const projectsConfigurations = {
version: 2,
projects: {},
};
const parsedBuildTarget = parseTargetString(buildTarget, {
cwd: process.cwd(),
root: workspaceRoot,
isVerbose: false,
projectName: ctProjectName,
projectGraph: graph,
projectsConfigurations,
workspace: projectsConfigurations,
nxJsonConfiguration: {},
});
const buildProjectConfig = graph.nodes[parsedBuildTarget.project]?.data;
const buildExecutorContext = createExecutorContext(
Expand Down
14 changes: 4 additions & 10 deletions packages/nx/src/config/misc-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,13 @@ export interface ExecutorContext {
/**
* Projects config
*
* @todo(vsavkin): mark this as required for v17
*/
projectsConfigurations?: ProjectsConfigurations;
projectsConfigurations: ProjectsConfigurations;

/**
* The contents of nx.json.
*
* @todo(vsavkin): mark this as required for v17
*/
nxJsonConfiguration?: NxJsonConfiguration;
nxJsonConfiguration: NxJsonConfiguration;

/**
* The current working directory
Expand All @@ -219,10 +216,8 @@ export interface ExecutorContext {
/**
* A snapshot of the project graph as
* it existed when the Nx command was kicked off
*
* @todo(vsavkin) mark this required for v17
*/
projectGraph?: ProjectGraph;
projectGraph: ProjectGraph;

/**
* A snapshot of the task graph as
Expand All @@ -233,7 +228,6 @@ export interface ExecutorContext {
/**
* Deprecated. Use projectsConfigurations or nxJsonConfiguration
* The full workspace configuration
* @todo(vsavkin): remove after v17
*/
workspace?: ProjectsConfigurations & NxJsonConfiguration;
workspace: ProjectsConfigurations & NxJsonConfiguration;
}

0 comments on commit d72ecd6

Please sign in to comment.