Skip to content

Commit

Permalink
chore(core): try and fix failing e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry authored and AgentEnder committed Feb 29, 2024
1 parent 2f3127c commit 0f439f8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
22 changes: 11 additions & 11 deletions docs/generated/devkit/CreateNodesContext.md
Expand Up @@ -6,32 +6,32 @@ Context for [CreateNodesFunction](../../devkit/documents/CreateNodesFunction)

### Properties

- [matchingFiles](../../devkit/documents/CreateNodesContext#matchingfiles): string[]
- [allConfigFiles](../../devkit/documents/CreateNodesContext#allconfigfiles): string[]
- [matchingConfigFiles](../../devkit/documents/CreateNodesContext#matchingconfigfiles): string[]
- [nxJsonConfiguration](../../devkit/documents/CreateNodesContext#nxjsonconfiguration): NxJsonConfiguration<string[] | "\*">
- [workspaceFiles](../../devkit/documents/CreateNodesContext#workspacefiles): string[]
- [workspaceRoot](../../devkit/documents/CreateNodesContext#workspaceroot): string

## Properties

### matchingFiles
### allConfigFiles

`Readonly` **matchingFiles**: `string`[]
`Readonly` **allConfigFiles**: `string`[]

The subset of non-ignored files which match the createNodes pattern
All configuration files identified in the workspace

---

### nxJsonConfiguration
### matchingConfigFiles

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

---
The subset of configuration files which match the createNodes pattern

### workspaceFiles
---

`Readonly` **workspaceFiles**: `string`[]
### nxJsonConfiguration

All non-ignored files in the workspace
`Readonly` **nxJsonConfiguration**: [`NxJsonConfiguration`](../../devkit/documents/NxJsonConfiguration)\<`string`[] \| `"*"`\>

---

Expand Down
Expand Up @@ -3,7 +3,7 @@ import type {
TargetConfiguration,
} from 'nx/src/config/workspace-json-project-json';
import type { Tree } from 'nx/src/generators/tree';
import type { CreateNodes } from 'nx/src/utils/nx-plugin';
import type { CreateNodes } from 'nx/src/project-graph/plugins';
import { requireNx } from '../../nx';
const {
readNxJson,
Expand Down Expand Up @@ -48,8 +48,8 @@ export async function replaceProjectConfigurationsWithPlugin<T = unknown>(
const nodes = await createNodesFunction(configFile, pluginOptions, {
workspaceRoot: tree.root,
nxJsonConfiguration: readNxJson(tree),
workspaceFiles: configFiles,
matchingFiles: configFiles,
allConfigFiles: configFiles,
matchingConfigFiles: configFiles,
});
const node = nodes.projects[Object.keys(nodes.projects)[0]];

Expand Down
6 changes: 3 additions & 3 deletions packages/devkit/src/utils/update-package-scripts.ts
Expand Up @@ -4,7 +4,7 @@ import type {
CreateNodes,
CreateNodesFunction,
CreateNodesResult,
} from 'nx/src/utils/nx-plugin';
} from 'nx/src/project-graph/plugins';
import type { PackageJson } from 'nx/src/utils/package-json';
import { basename, dirname } from 'path';
import * as yargs from 'yargs-parser';
Expand Down Expand Up @@ -70,8 +70,8 @@ async function processProject(
{
nxJsonConfiguration,
workspaceRoot,
workspaceFiles,
matchingFiles,
allConfigFiles: workspaceFiles,
matchingConfigFiles: matchingFiles,
}
);

Expand Down
16 changes: 10 additions & 6 deletions packages/eslint/src/plugins/plugin.ts
Expand Up @@ -26,6 +26,9 @@ export const createNodes: CreateNodes<EslintPluginOptions> = [
(configFilePath, options, context) => {
options = normalizeOptions(options);

// TODO: Figure out why this is required to protect against failures in e2e-run
(context as any).workspaceFiles = context.workspaceFiles ?? [];

const configDir = dirname(configFilePath);
if (configDir === '.') {
return {
Expand Down Expand Up @@ -53,24 +56,23 @@ function getProjectsUsingRootESLintConfig(
context: CreateNodesContext
): CreateNodesResult['projects'] {
const projects: CreateNodesResult['projects'] = {};
const workspaceFiles = context.workspaceFiles ?? [];

// If there's no src folder, it's not a standalone project, so a project.json would be explicitly required to add the root to the mapping
const isStandaloneWorkspace =
workspaceFiles.some((f) => f.startsWith('src')) &&
workspaceFiles.includes('package.json');
context.workspaceFiles.some((f) => f.startsWith('src')) &&
context.workspaceFiles.includes('package.json');
if (isStandaloneWorkspace) {
projects['.'] = {
targets: buildEslintTargets([configFilePath], '.', options, true),
};
} else if (workspaceFiles.includes('project.json')) {
} else if (context.workspaceFiles.includes('project.json')) {
projects['.'] = {
targets: buildEslintTargets([configFilePath], '.', options),
};
}

// Some nested projects may require a lint target based on this root level config as well (in the case they don't have their own)
const childProjectRoots = workspaceFiles
const childProjectRoots = context.workspaceFiles
.filter(
(f) =>
f.includes('/') &&
Expand All @@ -82,7 +84,9 @@ function getProjectsUsingRootESLintConfig(
const childProjectsWithoutEslintConfig = childProjectRoots.filter(
(childProjectRoot) =>
!ESLINT_CONFIG_FILENAMES.some((eslintConfigFile) =>
workspaceFiles.includes(join(childProjectRoot, eslintConfigFile))
context.workspaceFiles.includes(
join(childProjectRoot, eslintConfigFile)
)
)
);

Expand Down
Expand Up @@ -225,7 +225,7 @@ export function buildProjectsConfigurationsFromProjectPathsAndPlugins(
nxJsonConfiguration: nxJson,
workspaceRoot: root,
allConfigFiles,
matchingConfigFiles
matchingConfigFiles,
}).catch((e) =>
shutdownPluginWorkers().then(() => {
throw e;
Expand Down

0 comments on commit 0f439f8

Please sign in to comment.