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
Use this reference for safe file and configuration mutations in generators.
tree.read(path) reads file contents.tree.write(path, content) writes/creates files tracked by dry-run.tree.exists(path) checks whether a path is present in the virtual tree.tree.delete(path) removes files safely in generator context.generateFiles(tree, src, dest, vars) for template-based generation.updateJson(tree, path, updater) for structured JSON mutations.readProjectConfiguration(tree, project) and updateProjectConfiguration(...) for project settings.import { Tree, updateJson, generateFiles, joinPathFragments } from "@nx/devkit";
export default async function generator(tree: Tree, schema: { name: string }) {
const root = joinPathFragments("libs", schema.name);
generateFiles(tree, joinPathFragments(__dirname, "files"), root, { ...schema, tmpl: "" });
updateJson(tree, "nx.json", (json) => {
json.generators = json.generators ?? {};
return json;
});
}fs in generator runtime.