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,
|
||||
"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": {
|
||||
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
||||
"type": "boolean"
|
||||
|
||||
@ -3,9 +3,9 @@ import { <%= className %>ExecutorSchema } from './schema';
|
||||
export default async function runExecutor(
|
||||
options: <%= className %>ExecutorSchema,
|
||||
) {
|
||||
console.log('Executor ran for <%= className %>', options)
|
||||
console.log('Executor ran for <%= className %>', options);
|
||||
return {
|
||||
success: true
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -16,5 +16,5 @@ describe('<%= name %> generator', () => {
|
||||
await generator(appTree, options);
|
||||
const config = readProjectConfiguration(appTree, 'test');
|
||||
expect(config).toBeDefined();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
@ -14,7 +14,7 @@ interface NormalizedSchema extends <%= className %>GeneratorSchema {
|
||||
projectName: string;
|
||||
projectRoot: string;
|
||||
projectDirectory: string;
|
||||
parsedTags: string[]
|
||||
parsedTags: string[];
|
||||
}
|
||||
|
||||
function normalizeOptions(tree: Tree, options: <%= className %>GeneratorSchema): NormalizedSchema {
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
import { pluginGenerator } from './plugin';
|
||||
import {
|
||||
Tree,
|
||||
readProjectConfiguration,
|
||||
readJson,
|
||||
getProjects,
|
||||
joinPathFragments,
|
||||
readJson,
|
||||
readProjectConfiguration,
|
||||
Tree,
|
||||
} from '@nrwl/devkit';
|
||||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||
import { Schema } from './schema';
|
||||
import { Linter } from '@nrwl/linter';
|
||||
import { pluginGenerator } from './plugin';
|
||||
import { Schema } from './schema';
|
||||
|
||||
const getSchema: (overrides?: Partial<Schema>) => Schema = (
|
||||
overrides = {}
|
||||
@ -267,4 +268,12 @@ describe('NxPlugin Plugin Generator', () => {
|
||||
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,
|
||||
} from '@nrwl/devkit';
|
||||
import { libraryGenerator } from '@nrwl/js';
|
||||
import { Linter } from '@nrwl/linter';
|
||||
import { addSwcDependencies } from '@nrwl/js/src/utils/swc/add-swc-dependencies';
|
||||
import { Linter } from '@nrwl/linter';
|
||||
import { swcNodeVersion } from 'nx/src/utils/versions';
|
||||
import * as path from 'path';
|
||||
|
||||
@ -115,6 +115,8 @@ export async function pluginGenerator(host: Tree, schema: Schema) {
|
||||
|
||||
await addFiles(host, options);
|
||||
updateWorkspaceJson(host, options);
|
||||
|
||||
if (options.e2eTestRunner !== 'none') {
|
||||
await e2eProjectGenerator(host, {
|
||||
pluginName: options.name,
|
||||
projectDirectory: options.projectDirectory,
|
||||
@ -123,6 +125,8 @@ export async function pluginGenerator(host: Tree, schema: Schema) {
|
||||
standaloneConfig: options.standaloneConfig ?? true,
|
||||
minimal: options.minimal ?? false,
|
||||
});
|
||||
}
|
||||
|
||||
if (options.linter === Linter.EsLint && !options.skipLintChecks) {
|
||||
await pluginLintCheckGenerator(host, { projectName: options.name });
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ export interface Schema {
|
||||
skipTsConfig: boolean;
|
||||
skipFormat: boolean;
|
||||
skipLintChecks: boolean;
|
||||
e2eTestRunner?: 'jest' | 'none';
|
||||
tags?: string;
|
||||
unitTestRunner: 'jest' | 'none';
|
||||
linter: Linter;
|
||||
|
||||
@ -63,6 +63,12 @@
|
||||
"default": false,
|
||||
"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": {
|
||||
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
||||
"type": "boolean"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user