Skip to content

Commit

Permalink
fix(nx-plugin): allow create-package without e2eProject (#27572)
Browse files Browse the repository at this point in the history
Current behavior:
`nx g create-package create-my-plugin --project my-plugin` fails because
`e2eProject` defaults to the root project.

Expected behavior:
`nx g create-package create-my-plugin --project my-plugin` succeeds.
  • Loading branch information
isaacplmann authored Aug 21, 2024
1 parent ca89950 commit ecbd2cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@
"e2eProject": {
"type": "string",
"description": "The name of the e2e project.",
"alias": "p",
"$default": { "$source": "projectName" },
"x-prompt": "What is the name of the e2e project?"
"x-prompt": "What is the name of the e2e project? Leave blank to skip e2e tests"
}
},
"required": ["name", "project"],
Expand Down
22 changes: 21 additions & 1 deletion e2e/plugin/src/nx-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,26 @@ describe('Nx Plugin', () => {
}, 90000);
});

it('should be able to generate a create-package plugin without e2e tests', async () => {
const plugin = uniq('plugin');
const createAppName = `create-${plugin}-app`;
runCLI(
`generate @nx/plugin:plugin ${plugin} --e2eTestRunner jest --publishable`
);
runCLI(
`generate @nx/plugin:create-package ${createAppName} --project=${plugin}`
);

const buildResults = runCLI(`build ${createAppName}`);
expect(buildResults).toContain('Done compiling TypeScript files');

checkFilesExist(
`libs/${plugin}/src/generators/preset`,
`libs/${createAppName}`,
`dist/libs/${createAppName}/bin/index.js`
);
});

it('should be able to generate a create-package plugin ', async () => {
const plugin = uniq('plugin');
const createAppName = `create-${plugin}-app`;
Expand All @@ -449,7 +469,7 @@ describe('Nx Plugin', () => {
const plugin = uniq('plugin');
expect(() =>
runCLI(
`generate @nx/plugin:create-package ${plugin} --project=invalid-plugin`
`generate @nx/plugin:create-package create-${plugin} --project=invalid-plugin`
)
).toThrow();
});
Expand Down
6 changes: 1 addition & 5 deletions packages/plugin/src/generators/create-package/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@
"e2eProject": {
"type": "string",
"description": "The name of the e2e project.",
"alias": "p",
"$default": {
"$source": "projectName"
},
"x-prompt": "What is the name of the e2e project?"
"x-prompt": "What is the name of the e2e project? Leave blank to skip e2e tests"
}
},
"required": ["name", "project"]
Expand Down

0 comments on commit ecbd2cb

Please sign in to comment.