Complete Nx plugin development toolkit: create custom generators, executors, and extend Nx workspaces with reusable automation
93
94%
Does it follow best practices?
Impact
92%
1.00xAverage score across 5 eval scenarios
Passed
No known issues
You've inherited an Nx workspace with a custom generator that creates shared libraries. The generator has several bugs that developers have reported:
Fix the generator implementation to address all reported issues.
/tmp/nx-workspacetools/my-plugin/src/generators/library/generator.tstools/my-plugin/src/generators/library/schema.jsontools/my-plugin/src/generators/library/files/The generator currently looks like this:
import { Tree } from '@nx/devkit';
import { writeFileSync } from 'fs';
export default async function (tree: Tree, options: any) {
// Create library directory
writeFileSync(`libs/${options.name}/src/index.ts`,
`export * from './lib/${options.name}';`
);
writeFileSync(`libs/${options.name}/README.md`,
`# ${options.name}`
);
return { success: true };
}The schema.json is:
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"directory": {
"type": "string"
}
}
}Create these files in your output: