Skip to content

Commit

Permalink
fix(misc): update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Jun 27, 2024
1 parent ae2df1b commit dc5e10a
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 578 deletions.
4 changes: 2 additions & 2 deletions packages/cypress/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ describe('@nx/cypress/plugin', () => {
],
"metadata": {
"description": "Runs Cypress Tests in CI",
"nonAtomizedTarget": "e2e",
"example": {
"command": "npx cypress run --help",
"example": {
Expand All @@ -361,6 +360,7 @@ describe('@nx/cypress/plugin', () => {
],
},
},
"nonAtomizedTarget": "e2e",
"technologies": [
"cypress",
],
Expand All @@ -384,7 +384,6 @@ describe('@nx/cypress/plugin', () => {
],
"metadata": {
"description": "Runs Cypress Tests in src/test.cy.ts in CI",
"nonAtomizedTarget": "e2e",
"example": {
"command": "npx cypress run --help",
"example": {
Expand All @@ -394,6 +393,7 @@ describe('@nx/cypress/plugin', () => {
],
},
},
"nonAtomizedTarget": "e2e",
"technologies": [
"cypress",
],
Expand Down
28 changes: 12 additions & 16 deletions packages/cypress/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { NX_PLUGIN_OPTIONS } from '../utils/constants';
import { loadConfigFile } from '@nx/devkit/src/utils/config-utils';
import { hashObject } from 'nx/src/devkit-internals';
import { globWithWorkspaceContext } from 'nx/src/utils/workspace-context';
import type { PackageManagerCommands } from 'nx/src/utils/package-manager';

export interface CypressPluginOptions {
ciTargetName?: string;
Expand All @@ -46,6 +45,8 @@ function writeTargetsToCache(cachePath: string, results: CypressTargets) {

const cypressConfigGlob = '**/cypress.config.{js,ts,mjs,cjs}';

const pmc = getPackageManagerCommand();

export const createNodesV2: CreateNodesV2<CypressPluginOptions> = [
cypressConfigGlob,
async (configFiles, options, context) => {
Expand All @@ -55,11 +56,10 @@ export const createNodesV2: CreateNodesV2<CypressPluginOptions> = [
`cypress-${optionsHash}.hash`
);
const targetsCache = readTargetsCache(cachePath);
const pmc = getPackageManagerCommand();
try {
return await createNodesFromFiles(
(configFile, options, context) =>
createNodesInternal(configFile, options, context, targetsCache, pmc),
createNodesInternal(configFile, options, context, targetsCache),
configFiles,
options,
context
Expand All @@ -80,17 +80,15 @@ export const createNodes: CreateNodes<CypressPluginOptions> = [
logger.warn(
'`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.'
);
const pmc = getPackageManagerCommand();
return createNodesInternal(configFile, options, context, {}, pmc);
return createNodesInternal(configFile, options, context, {});
},
];

async function createNodesInternal(
configFilePath: string,
options: CypressPluginOptions,
context: CreateNodesContext,
targetsCache: CypressTargets,
pmc: PackageManagerCommands
targetsCache: CypressTargets
) {
options = normalizeOptions(options);
const projectRoot = dirname(configFilePath);
Expand All @@ -115,8 +113,7 @@ async function createNodesInternal(
configFilePath,
projectRoot,
options,
context,
pmc
context
);
const { targets, metadata } = targetsCache[hash];

Expand Down Expand Up @@ -187,8 +184,7 @@ async function buildCypressTargets(
configFilePath: string,
projectRoot: string,
options: CypressPluginOptions,
context: CreateNodesContext,
pmc: PackageManagerCommands
context: CreateNodesContext
): Promise<CypressTargets> {
const cypressConfig = await loadConfigFile(
join(context.workspaceRoot, configFilePath)
Expand Down Expand Up @@ -218,7 +214,7 @@ async function buildCypressTargets(
metadata: {
technologies: ['cypress'],
description: 'Runs Cypress Tests',
example: {
help: {
command: `${pmc.exec} cypress run --help`,
example: {
args: ['--dev', '--headed'],
Expand Down Expand Up @@ -284,7 +280,7 @@ async function buildCypressTargets(
technologies: ['cypress'],
description: `Runs Cypress Tests in ${relativeSpecFilePath} in CI`,
nonAtomizedTarget: options.targetName,
example: {
help: {
command: `${pmc.exec} cypress run --help`,
example: {
args: ['--dev', '--headed'],
Expand All @@ -309,7 +305,7 @@ async function buildCypressTargets(
technologies: ['cypress'],
description: 'Runs Cypress Tests in CI',
nonAtomizedTarget: options.targetName,
example: {
help: {
command: `${pmc.exec} cypress run --help`,
example: {
args: ['--dev', '--headed'],
Expand All @@ -332,7 +328,7 @@ async function buildCypressTargets(
metadata: {
technologies: ['cypress'],
description: 'Runs Cypress Component Tests',
example: {
help: {
command: `${pmc.exec} cypress run --help`,
example: {
args: ['--dev', '--headed'],
Expand All @@ -348,7 +344,7 @@ async function buildCypressTargets(
metadata: {
technologies: ['cypress'],
description: 'Opens Cypress',
example: {
help: {
command: `${pmc.exec} cypress open --help`,
example: {
args: ['--dev', '--e2e'],
Expand Down
27 changes: 9 additions & 18 deletions packages/eslint/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
isFlatConfig,
} from '../utils/config-file';
import { resolveESLintClass } from '../utils/resolve-eslint-class';
import type { PackageManagerCommands } from 'nx/src/utils/package-manager';

const pmc = getPackageManagerCommand();

export interface EslintPluginOptions {
targetName?: string;
Expand Down Expand Up @@ -62,8 +63,7 @@ const internalCreateNodes = async (
configFilePath: string,
options: EslintPluginOptions,
context: CreateNodesContext,
projectsCache: Record<string, CreateNodesResult['projects']>,
pmc: PackageManagerCommands
projectsCache: Record<string, CreateNodesResult['projects']>
): Promise<CreateNodesResult> => {
options = normalizeOptions(options);
const configDir = dirname(configFilePath);
Expand Down Expand Up @@ -150,8 +150,7 @@ const internalCreateNodes = async (
childProjectRoot,
eslintVersion,
options,
context,
pmc
context
);

if (project) {
Expand Down Expand Up @@ -179,8 +178,7 @@ const internalCreateNodesV2 = async (
allProjectRoots: string[],
projectRootsByEslintRoots: Map<string, string[]>,
lintableFilesPerProjectRoot: Map<string, string[]>,
projectsCache: Record<string, CreateNodesResult['projects']>,
pmc: PackageManagerCommands
projectsCache: Record<string, CreateNodesResult['projects']>
): Promise<CreateNodesResult> => {
const configDir = dirname(configFilePath);

Expand Down Expand Up @@ -243,8 +241,7 @@ const internalCreateNodesV2 = async (
projectRoot,
eslintVersion,
options,
context,
pmc
context
);

if (project) {
Expand Down Expand Up @@ -277,7 +274,6 @@ export const createNodesV2: CreateNodesV2<EslintPluginOptions> = [
const { eslintConfigFiles, projectRoots, projectRootsByEslintRoots } =
splitConfigFiles(configFiles);
const lintableFilesPerProjectRoot = new Map<string, string[]>();
const pmc = getPackageManagerCommand();

try {
return await createNodesFromFiles(
Expand All @@ -290,8 +286,7 @@ export const createNodesV2: CreateNodesV2<EslintPluginOptions> = [
projectRoots,
projectRootsByEslintRoots,
lintableFilesPerProjectRoot,
targetsCache,
pmc
targetsCache
),
eslintConfigFiles,
options,
Expand All @@ -309,8 +304,7 @@ export const createNodes: CreateNodes<EslintPluginOptions> = [
logger.warn(
'`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.'
);
const pmc = getPackageManagerCommand();
return internalCreateNodes(configFilePath, options, context, {}, pmc);
return internalCreateNodes(configFilePath, options, context, {});
},
];

Expand Down Expand Up @@ -411,8 +405,7 @@ function getProjectUsingESLintConfig(
projectRoot: string,
eslintVersion: string,
options: EslintPluginOptions,
context: CreateNodesContext | CreateNodesContextV2,
pmc: PackageManagerCommands
context: CreateNodesContext | CreateNodesContextV2
): CreateNodesResult['projects'][string] | null {
const rootEslintConfig = [
baseEsLintConfigFile,
Expand Down Expand Up @@ -449,7 +442,6 @@ function getProjectUsingESLintConfig(
projectRoot,
context.workspaceRoot,
options,
pmc,
standaloneSrcPath
),
};
Expand All @@ -461,7 +453,6 @@ function buildEslintTargets(
projectRoot: string,
workspaceRoot: string,
options: EslintPluginOptions,
pmc: PackageManagerCommands,
standaloneSrcPath?: string
) {
const isRootProject = projectRoot === '.';
Expand Down
18 changes: 7 additions & 11 deletions packages/jest/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import { getGlobPatternsFromPackageManagerWorkspaces } from 'nx/src/plugins/pack
import { combineGlobPatterns } from 'nx/src/utils/globs';
import { minimatch } from 'minimatch';
import { hashObject } from 'nx/src/devkit-internals';
import type { PackageManagerCommands } from 'nx/src/utils/package-manager';

const pmc = getPackageManagerCommand();

export interface JestPluginOptions {
targetName?: string;
Expand Down Expand Up @@ -58,11 +59,10 @@ export const createNodesV2: CreateNodesV2<JestPluginOptions> = [
const cachePath = join(workspaceDataDirectory, `jest-${optionsHash}.hash`);
const targetsCache = readTargetsCache(cachePath);

const pmc = getPackageManagerCommand();
try {
return await createNodesFromFiles(
(configFile, options, context) =>
createNodesInternal(configFile, options, context, targetsCache, pmc),
createNodesInternal(configFile, options, context, targetsCache),
configFiles,
options,
context
Expand All @@ -84,17 +84,15 @@ export const createNodes: CreateNodes<JestPluginOptions> = [
'`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.'
);

const pmc = getPackageManagerCommand();
return createNodesInternal(...args, {}, pmc);
return createNodesInternal(...args, {});
},
];

async function createNodesInternal(
configFilePath,
options,
context,
targetsCache: Record<string, JestTargets>,
pmc: PackageManagerCommands
targetsCache: Record<string, JestTargets>
) {
const projectRoot = dirname(configFilePath);

Expand Down Expand Up @@ -140,8 +138,7 @@ async function createNodesInternal(
configFilePath,
projectRoot,
options,
context,
pmc
context
);

const { targets, metadata } = targetsCache[hash];
Expand All @@ -161,8 +158,7 @@ async function buildJestTargets(
configFilePath: string,
projectRoot: string,
options: JestPluginOptions,
context: CreateNodesContext,
pmc: PackageManagerCommands
context: CreateNodesContext
): Promise<Pick<ProjectConfiguration, 'targets' | 'metadata'>> {
const absConfigFilePath = resolve(context.workspaceRoot, configFilePath);

Expand Down
Loading

0 comments on commit dc5e10a

Please sign in to comment.