diff --git a/e2e/nx-plugin/src/nx-plugin.test.ts b/e2e/nx-plugin/src/nx-plugin.test.ts index 1a28894e94b116..93917c8b999d05 100644 --- a/e2e/nx-plugin/src/nx-plugin.test.ts +++ b/e2e/nx-plugin/src/nx-plugin.test.ts @@ -48,21 +48,6 @@ describe('Nx Plugin', () => { }); }, 90000); - // the test invoke ensureNxProject, which points to @nrwl/workspace collection - // which walks up the directory to find it in the next repo itself, so it - // doesn't use the collection we are building - // we should change it to point to the right collection using relative path - // TODO: Re-enable this to work with pnpm - it(`should run the plugin's e2e tests`, async () => { - const plugin = uniq('plugin-name'); - runCLI( - `generate @nrwl/nx-plugin:plugin ${plugin} --linter=eslint --e2eTestRunner jest` - ); - const e2eResults = runCLI(`e2e ${plugin}-e2e`); - expect(e2eResults).toContain('Successfully ran target e2e'); - expect(await killPorts()).toBeTruthy(); - }, 250000); - it('should be able to generate a migration', async () => { const plugin = uniq('plugin'); const version = '1.0.0'; diff --git a/e2e/utils/create-project-utils.ts b/e2e/utils/create-project-utils.ts index 706edbc3a957e4..d60ac9e50e352d 100644 --- a/e2e/utils/create-project-utils.ts +++ b/e2e/utils/create-project-utils.ts @@ -215,12 +215,10 @@ export function runCreateWorkspace( export function runCreatePlugin( name: string, { - pluginName, packageManager, extraArgs, useDetectedPm = false, }: { - pluginName?: string; packageManager?: 'npm' | 'yarn' | 'pnpm'; extraArgs?: string; useDetectedPm?: boolean; @@ -232,11 +230,7 @@ export function runCreatePlugin( let command = `${ pm.runUninstalledPackage - } create-nx-plugin@${getPublishedVersion()} ${name}`; - - if (pluginName) { - command += ` --pluginName=${pluginName} --no-nxCloud`; - } + } create-nx-plugin@${getPublishedVersion()} ${name} --no-nxCloud`; if (packageManager && !useDetectedPm) { command += ` --package-manager=${packageManager}`; diff --git a/e2e/workspace-create/src/create-nx-plugin.test.ts b/e2e/workspace-create/src/create-nx-plugin.test.ts index 4611479b83609a..6ffb3b967eee84 100644 --- a/e2e/workspace-create/src/create-nx-plugin.test.ts +++ b/e2e/workspace-create/src/create-nx-plugin.test.ts @@ -14,13 +14,11 @@ describe('create-nx-plugin', () => { afterEach(() => cleanupProject()); - it('should be able to create a plugin repo and run plugin e2e', () => { - const wsName = uniq('ws-plugin'); + it('should be able to create a plugin repo build a plugin', () => { const pluginName = uniq('plugin'); - runCreatePlugin(wsName, { + runCreatePlugin(pluginName, { packageManager, - pluginName, }); checkFilesExist( @@ -31,6 +29,12 @@ describe('create-nx-plugin', () => { `executors.json` ); - expect(() => runCLI(`e2e e2e`)).not.toThrow(); + runCLI(`build ${pluginName}`); + + checkFilesExist( + `dist/package.json`, + `dist/generators.json`, + `dist/executors.json` + ); }); }); diff --git a/packages/nx-plugin/src/generators/lint-checks/generator.ts b/packages/nx-plugin/src/generators/lint-checks/generator.ts index 880e5bb82fefe1..783aea3dc0d27c 100644 --- a/packages/nx-plugin/src/generators/lint-checks/generator.ts +++ b/packages/nx-plugin/src/generators/lint-checks/generator.ts @@ -186,27 +186,35 @@ function updateProjectEslintConfig( const eslintPath = `${options.root}/.eslintrc.json`; const eslintConfig = readJson(host, eslintPath); eslintConfig.overrides ??= []; - if ( - !eslintConfig.overrides.some( + let entry: ESLint.ConfigOverride = + eslintConfig.overrides.find( (x) => Object.keys(x.rules ?? {}).includes('@nx/nx/nx-plugin-checks') || Object.keys(x.rules ?? {}).includes('@nrwl/nx/nx-plugin-checks') - ) - ) { - eslintConfig.overrides.push({ - files: [ + ); + const newentry = !entry; + entry ??= { files: [] }; + entry.files = [ + ...new Set([ + ...(entry.files ?? []), + ...[ './package.json', packageJson.generators, packageJson.executors, packageJson.schematics, packageJson.builders, ].filter((f) => !!f), - parser: 'jsonc-eslint-parser', - rules: { - '@nrwl/nx/nx-plugin-checks': 'error', - }, - }); + ]), + ]; + entry.parser = 'jsonc-eslint-parser'; + entry.rules ??= { + '@nrwl/nx/nx-plugin-checks': 'error', + }; + + if (newentry) { + eslintConfig.overrides.push(entry); } + writeJson(host, eslintPath, eslintConfig); } diff --git a/packages/nx-plugin/src/generators/migration/files/migration/__name__/__name__.spec.ts__tmpl__ b/packages/nx-plugin/src/generators/migration/files/migration/__name__/__name__.spec.ts__tmpl__ new file mode 100644 index 00000000000000..70e86d21509628 --- /dev/null +++ b/packages/nx-plugin/src/generators/migration/files/migration/__name__/__name__.spec.ts__tmpl__ @@ -0,0 +1,17 @@ +import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; +import { Tree } from '@nx/devkit'; + +import update from './<%= name %>'; + +describe('<%= name %> migration', () => { + let tree: Tree; + + beforeEach(() => { + tree = createTreeWithEmptyWorkspace({layout: 'apps-libs'}); + }); + + it('should run successfully', async () => { + await update(tree); + // ... expect changes made + }); +});