Skip to content

Commit

Permalink
feat(misc): bump swc-helpers version to match new swc-core requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Apr 18, 2023
1 parent 041a50d commit ddd08c1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 38 deletions.
15 changes: 0 additions & 15 deletions e2e/nx-plugin/src/nx-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
8 changes: 1 addition & 7 deletions e2e/utils/create-project-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}`;
Expand Down
14 changes: 9 additions & 5 deletions e2e/workspace-create/src/create-nx-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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`
);
});
});
30 changes: 19 additions & 11 deletions packages/nx-plugin/src/generators/lint-checks/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,27 +186,35 @@ function updateProjectEslintConfig(
const eslintPath = `${options.root}/.eslintrc.json`;
const eslintConfig = readJson<ESLint.Config>(host, eslintPath);
eslintConfig.overrides ??= [];
if (
!eslintConfig.overrides.some(
let entry: ESLint.ConfigOverride<ESLint.RulesRecord> =
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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
});
});

0 comments on commit ddd08c1

Please sign in to comment.