This directory contains local Nx generators for this workspace.
Generates a new package in the monorepo with all the necessary boilerplate files.
# To generate a new package, run this command and follow the prompt
npx nx g @tools/generators:package
# Preview changes without writing files
npx nx g @tools/generators:package --dry-run-
name(required): The name of the package (without @aligent/ scope)- Must start with a lowercase letter
- Can only contain lowercase letters, numbers, and hyphens
-
description(required): A brief description of the package
The generator creates:
package.json- Package configuration with @aligent scopeproject.json- Nx project configurationtsconfig.json- TypeScript configuration (root)tsconfig.lib.json- TypeScript configuration for library codetsconfig.spec.json- TypeScript configuration for testsvitest.config.mjs- Vitest testing configurationeslint.config.mjs- ESLint configurationREADME.md- Package documentationsrc/index.ts- Main entry pointsrc/lib/hello.ts- Example library codesrc/lib/hello.spec.ts- Example test file
It also:
- Adds a TypeScript project reference to the root
tsconfig.json - Formats all generated files according to the workspace Prettier configuration
To create additional generators:
-
Create a new directory under
tools/generators/(e.g.,tools/generators/my-generator/) -
Add the following files:
schema.json- JSON schema defining generator optionsschema.d.ts- TypeScript types for the schemagenerator.ts- Generator implementation (must export default function)files/- Template files directory (optional)
-
Register the generator in
tools/generators/generators.json -
Run your generator:
npx nx g @tools/generators:my-generator
Template files in the files/ directory use EJS syntax:
<%= variableName %>- Interpolate a variable- File names ending with
__template__will have that suffix removed - Directory structure in
files/is preserved in the generated output