feat(nx-plugin): allow skipping the creation of an e2e project (#12129)
This commit is contained in:
parent
8c2161cd96
commit
e80c2ee010
@ -80,6 +80,12 @@
|
|||||||
"default": false,
|
"default": false,
|
||||||
"description": "Do not eslint configuration for plugin json files."
|
"description": "Do not eslint configuration for plugin json files."
|
||||||
},
|
},
|
||||||
|
"e2eTestRunner": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["jest", "none"],
|
||||||
|
"description": "Test runner to use for end to end (E2E) tests.",
|
||||||
|
"default": "jest"
|
||||||
|
},
|
||||||
"standaloneConfig": {
|
"standaloneConfig": {
|
||||||
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
|||||||
@ -3,9 +3,9 @@ import { <%= className %>ExecutorSchema } from './schema';
|
|||||||
export default async function runExecutor(
|
export default async function runExecutor(
|
||||||
options: <%= className %>ExecutorSchema,
|
options: <%= className %>ExecutorSchema,
|
||||||
) {
|
) {
|
||||||
console.log('Executor ran for <%= className %>', options)
|
console.log('Executor ran for <%= className %>', options);
|
||||||
return {
|
return {
|
||||||
success: true
|
success: true
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,5 +16,5 @@ describe('<%= name %> generator', () => {
|
|||||||
await generator(appTree, options);
|
await generator(appTree, options);
|
||||||
const config = readProjectConfiguration(appTree, 'test');
|
const config = readProjectConfiguration(appTree, 'test');
|
||||||
expect(config).toBeDefined();
|
expect(config).toBeDefined();
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,7 +14,7 @@ interface NormalizedSchema extends <%= className %>GeneratorSchema {
|
|||||||
projectName: string;
|
projectName: string;
|
||||||
projectRoot: string;
|
projectRoot: string;
|
||||||
projectDirectory: string;
|
projectDirectory: string;
|
||||||
parsedTags: string[]
|
parsedTags: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeOptions(tree: Tree, options: <%= className %>GeneratorSchema): NormalizedSchema {
|
function normalizeOptions(tree: Tree, options: <%= className %>GeneratorSchema): NormalizedSchema {
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
import { pluginGenerator } from './plugin';
|
|
||||||
import {
|
import {
|
||||||
Tree,
|
getProjects,
|
||||||
readProjectConfiguration,
|
|
||||||
readJson,
|
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
|
readJson,
|
||||||
|
readProjectConfiguration,
|
||||||
|
Tree,
|
||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||||
import { Schema } from './schema';
|
|
||||||
import { Linter } from '@nrwl/linter';
|
import { Linter } from '@nrwl/linter';
|
||||||
|
import { pluginGenerator } from './plugin';
|
||||||
|
import { Schema } from './schema';
|
||||||
|
|
||||||
const getSchema: (overrides?: Partial<Schema>) => Schema = (
|
const getSchema: (overrides?: Partial<Schema>) => Schema = (
|
||||||
overrides = {}
|
overrides = {}
|
||||||
@ -267,4 +268,12 @@ describe('NxPlugin Plugin Generator', () => {
|
|||||||
expect(name).toEqual('@my-company/my-plugin');
|
expect(name).toEqual('@my-company/my-plugin');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('--e2eTestRunner', () => {
|
||||||
|
it('should allow the e2e project to be skipped', async () => {
|
||||||
|
await pluginGenerator(tree, getSchema({ e2eTestRunner: 'none' }));
|
||||||
|
const projects = getProjects(tree);
|
||||||
|
expect(projects.has('plugins-my-plugin-e2e')).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,8 +10,8 @@ import {
|
|||||||
updateProjectConfiguration,
|
updateProjectConfiguration,
|
||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
import { libraryGenerator } from '@nrwl/js';
|
import { libraryGenerator } from '@nrwl/js';
|
||||||
import { Linter } from '@nrwl/linter';
|
|
||||||
import { addSwcDependencies } from '@nrwl/js/src/utils/swc/add-swc-dependencies';
|
import { addSwcDependencies } from '@nrwl/js/src/utils/swc/add-swc-dependencies';
|
||||||
|
import { Linter } from '@nrwl/linter';
|
||||||
import { swcNodeVersion } from 'nx/src/utils/versions';
|
import { swcNodeVersion } from 'nx/src/utils/versions';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@ -115,6 +115,8 @@ export async function pluginGenerator(host: Tree, schema: Schema) {
|
|||||||
|
|
||||||
await addFiles(host, options);
|
await addFiles(host, options);
|
||||||
updateWorkspaceJson(host, options);
|
updateWorkspaceJson(host, options);
|
||||||
|
|
||||||
|
if (options.e2eTestRunner !== 'none') {
|
||||||
await e2eProjectGenerator(host, {
|
await e2eProjectGenerator(host, {
|
||||||
pluginName: options.name,
|
pluginName: options.name,
|
||||||
projectDirectory: options.projectDirectory,
|
projectDirectory: options.projectDirectory,
|
||||||
@ -123,6 +125,8 @@ export async function pluginGenerator(host: Tree, schema: Schema) {
|
|||||||
standaloneConfig: options.standaloneConfig ?? true,
|
standaloneConfig: options.standaloneConfig ?? true,
|
||||||
minimal: options.minimal ?? false,
|
minimal: options.minimal ?? false,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (options.linter === Linter.EsLint && !options.skipLintChecks) {
|
if (options.linter === Linter.EsLint && !options.skipLintChecks) {
|
||||||
await pluginLintCheckGenerator(host, { projectName: options.name });
|
await pluginLintCheckGenerator(host, { projectName: options.name });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ export interface Schema {
|
|||||||
skipTsConfig: boolean;
|
skipTsConfig: boolean;
|
||||||
skipFormat: boolean;
|
skipFormat: boolean;
|
||||||
skipLintChecks: boolean;
|
skipLintChecks: boolean;
|
||||||
|
e2eTestRunner?: 'jest' | 'none';
|
||||||
tags?: string;
|
tags?: string;
|
||||||
unitTestRunner: 'jest' | 'none';
|
unitTestRunner: 'jest' | 'none';
|
||||||
linter: Linter;
|
linter: Linter;
|
||||||
|
|||||||
@ -63,6 +63,12 @@
|
|||||||
"default": false,
|
"default": false,
|
||||||
"description": "Do not eslint configuration for plugin json files."
|
"description": "Do not eslint configuration for plugin json files."
|
||||||
},
|
},
|
||||||
|
"e2eTestRunner": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["jest", "none"],
|
||||||
|
"description": "Test runner to use for end to end (E2E) tests.",
|
||||||
|
"default": "jest"
|
||||||
|
},
|
||||||
"standaloneConfig": {
|
"standaloneConfig": {
|
||||||
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user