fix(nx-plugin): allow create-package without e2eProject (#27572)

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.
This commit is contained in:
Isaac Mann 2024-08-21 16:49:41 -04:00 committed by GitHub
parent ca89950920
commit ecbd2cba04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 9 deletions

View File

@ -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"],

View File

@ -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`;
@ -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();
});

View File

@ -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"]