fix(angular): fix imports into nx from ng-add (#13645)
This commit is contained in:
parent
9453a7526c
commit
2c819048bc
@ -1,10 +1,10 @@
|
||||
import {
|
||||
createExecutorContext,
|
||||
getProjectConfigByPath,
|
||||
nxBaseCypressPreset,
|
||||
NxComponentTestingOptions,
|
||||
} from '@nrwl/cypress/plugins/cypress-preset';
|
||||
import {
|
||||
createExecutorContext,
|
||||
getProjectConfigByPath,
|
||||
getTempTailwindPath,
|
||||
isCtProjectUsingBuildProject,
|
||||
} from '@nrwl/cypress/src/utils/ct-helpers';
|
||||
|
||||
@ -1,20 +1,6 @@
|
||||
import {
|
||||
ExecutorContext,
|
||||
normalizePath,
|
||||
ProjectConfiguration,
|
||||
ProjectGraph,
|
||||
readNxJson,
|
||||
stripIndents,
|
||||
TargetConfiguration,
|
||||
workspaceRoot,
|
||||
} from '@nrwl/devkit';
|
||||
import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph';
|
||||
import { dirname, extname, join, relative } from 'path';
|
||||
import { workspaceRoot } from '@nrwl/devkit';
|
||||
import { dirname, join, relative } from 'path';
|
||||
import { lstatSync } from 'fs';
|
||||
import {
|
||||
createProjectRootMappings,
|
||||
findProjectForPath,
|
||||
} from 'nx/src/project-graph/utils/find-project-for-path';
|
||||
|
||||
interface BaseCypressPreset {
|
||||
videosFolder: string;
|
||||
@ -81,59 +67,3 @@ export function nxE2EPreset(pathToConfig: string) {
|
||||
fixturesFolder: 'src/fixtures',
|
||||
};
|
||||
}
|
||||
|
||||
export function getProjectConfigByPath(
|
||||
graph: ProjectGraph,
|
||||
configPath: string
|
||||
): ProjectConfiguration {
|
||||
const configFileFromWorkspaceRoot = relative(workspaceRoot, configPath);
|
||||
const normalizedPathFromWorkspaceRoot = normalizePath(
|
||||
lstatSync(configPath).isFile()
|
||||
? configFileFromWorkspaceRoot.replace(extname(configPath), '')
|
||||
: configFileFromWorkspaceRoot
|
||||
);
|
||||
|
||||
const projectRootMappings = createProjectRootMappings(graph.nodes);
|
||||
const componentTestingProjectName = findProjectForPath(
|
||||
normalizedPathFromWorkspaceRoot,
|
||||
projectRootMappings
|
||||
);
|
||||
if (
|
||||
!componentTestingProjectName ||
|
||||
!graph.nodes[componentTestingProjectName]?.data
|
||||
) {
|
||||
throw new Error(
|
||||
stripIndents`Unable to find the project configuration that includes ${normalizedPathFromWorkspaceRoot}.
|
||||
Found project name? ${componentTestingProjectName}.
|
||||
Graph has data? ${!!graph.nodes[componentTestingProjectName]?.data}`
|
||||
);
|
||||
}
|
||||
// make sure name is set since it can be undefined
|
||||
graph.nodes[componentTestingProjectName].data.name ??=
|
||||
componentTestingProjectName;
|
||||
return graph.nodes[componentTestingProjectName].data;
|
||||
}
|
||||
|
||||
export function createExecutorContext(
|
||||
graph: ProjectGraph,
|
||||
targets: Record<string, TargetConfiguration>,
|
||||
projectName: string,
|
||||
targetName: string,
|
||||
configurationName: string
|
||||
): ExecutorContext {
|
||||
const projectConfigs = readProjectsConfigurationFromProjectGraph(graph);
|
||||
return {
|
||||
cwd: process.cwd(),
|
||||
projectGraph: graph,
|
||||
target: targets[targetName],
|
||||
targetName,
|
||||
configurationName,
|
||||
root: workspaceRoot,
|
||||
isVerbose: false,
|
||||
projectName,
|
||||
workspace: {
|
||||
...readNxJson(),
|
||||
...projectConfigs,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
import type { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
||||
import { ProjectGraph } from 'nx/src/config/project-graph';
|
||||
import { join } from 'path';
|
||||
import type { ExecutorContext, ProjectGraph } from '@nrwl/devkit';
|
||||
import {
|
||||
normalizePath,
|
||||
ProjectConfiguration,
|
||||
readNxJson,
|
||||
stripIndents,
|
||||
TargetConfiguration,
|
||||
workspaceRoot,
|
||||
} from '@nrwl/devkit';
|
||||
import { extname, join, relative } from 'path';
|
||||
import { lstatSync } from 'fs';
|
||||
import {
|
||||
createProjectRootMappings,
|
||||
findProjectForPath,
|
||||
} from 'nx/src/project-graph/utils/find-project-for-path';
|
||||
import { readProjectsConfigurationFromProjectGraph } from 'nx/src/project-graph/project-graph';
|
||||
|
||||
export const CY_FILE_MATCHER = new RegExp(/\.cy\.[tj]sx?$/);
|
||||
/**
|
||||
@ -41,3 +54,59 @@ export function isCtProjectUsingBuildProject(
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function getProjectConfigByPath(
|
||||
graph: ProjectGraph,
|
||||
configPath: string
|
||||
): ProjectConfiguration {
|
||||
const configFileFromWorkspaceRoot = relative(workspaceRoot, configPath);
|
||||
const normalizedPathFromWorkspaceRoot = normalizePath(
|
||||
lstatSync(configPath).isFile()
|
||||
? configFileFromWorkspaceRoot.replace(extname(configPath), '')
|
||||
: configFileFromWorkspaceRoot
|
||||
);
|
||||
|
||||
const projectRootMappings = createProjectRootMappings(graph.nodes);
|
||||
const componentTestingProjectName = findProjectForPath(
|
||||
normalizedPathFromWorkspaceRoot,
|
||||
projectRootMappings
|
||||
);
|
||||
if (
|
||||
!componentTestingProjectName ||
|
||||
!graph.nodes[componentTestingProjectName]?.data
|
||||
) {
|
||||
throw new Error(
|
||||
stripIndents`Unable to find the project configuration that includes ${normalizedPathFromWorkspaceRoot}.
|
||||
Found project name? ${componentTestingProjectName}.
|
||||
Graph has data? ${!!graph.nodes[componentTestingProjectName]?.data}`
|
||||
);
|
||||
}
|
||||
// make sure name is set since it can be undefined
|
||||
graph.nodes[componentTestingProjectName].data.name ??=
|
||||
componentTestingProjectName;
|
||||
return graph.nodes[componentTestingProjectName].data;
|
||||
}
|
||||
|
||||
export function createExecutorContext(
|
||||
graph: ProjectGraph,
|
||||
targets: Record<string, TargetConfiguration>,
|
||||
projectName: string,
|
||||
targetName: string,
|
||||
configurationName: string
|
||||
): ExecutorContext {
|
||||
const projectConfigs = readProjectsConfigurationFromProjectGraph(graph);
|
||||
return {
|
||||
cwd: process.cwd(),
|
||||
projectGraph: graph,
|
||||
target: targets[targetName],
|
||||
targetName,
|
||||
configurationName,
|
||||
root: workspaceRoot,
|
||||
isVerbose: false,
|
||||
projectName,
|
||||
workspace: {
|
||||
...readNxJson(),
|
||||
...projectConfigs,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
"dependencies": {
|
||||
"@nrwl/devkit": "file:../devkit",
|
||||
"@phenomnomnominal/tsquery": "4.1.1",
|
||||
"nx": "file:../nx",
|
||||
"tmp": "~0.2.1",
|
||||
"tslib": "^2.3.0"
|
||||
},
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
import {
|
||||
createExecutorContext,
|
||||
getProjectConfigByPath,
|
||||
nxBaseCypressPreset,
|
||||
NxComponentTestingOptions,
|
||||
} from '@nrwl/cypress/plugins/cypress-preset';
|
||||
@ -21,6 +19,10 @@ import { normalizeOptions } from '@nrwl/webpack/src/executors/webpack/lib/normal
|
||||
import { getWebpackConfig } from '@nrwl/webpack/src/executors/webpack/lib/get-webpack-config';
|
||||
import { resolveCustomWebpackConfig } from '@nrwl/webpack/src/utils/webpack/custom-webpack';
|
||||
import { buildBaseWebpackConfig } from './webpack-fallback';
|
||||
import {
|
||||
createExecutorContext,
|
||||
getProjectConfigByPath,
|
||||
} from '@nrwl/cypress/src/utils/ct-helpers';
|
||||
|
||||
/**
|
||||
* React nx preset for Cypress Component Testing
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user