Skip to content

Commit e6ce3bf

Browse files
committed
refactor: fix lint, setup generator
1 parent e33de22 commit e6ce3bf

File tree

4 files changed

+55
-10
lines changed

4 files changed

+55
-10
lines changed

tools/zod2md-jsdocs/eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ module.exports = tseslint.config(
4444
'@nx/dependency-checks': 'error',
4545
},
4646
},
47+
// Nx compiles the sync generators on the fly with SWC and there the .js ending is not working
48+
{
49+
files: ['**/sync-*.ts'],
50+
rules: {
51+
'n/file-extension-in-import': 'off',
52+
},
53+
},
4754
{
4855
files: ['**/package.json', '**/generators.json'],
4956
rules: {

tools/zod2md-jsdocs/src/lib/generators/sync-zod2md-setup/README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,54 @@ This is especially useful when integrating the sync generator into CI or workspa
8787

8888
---
8989

90-
## Registering / Testing the generator
90+
## Register a Global Sync Generator
9191

92-
To register the generator in your workspace:
92+
Global sync generators are registered in the _nx.json_ file like this:
9393

94-
```bash
95-
nx g @tooling/zod2md-jsdocs:sync-zod2md-setup --register
94+
_nx.json_
95+
96+
```json
97+
{
98+
"sync": {
99+
"globalGenerators": ["./tools/zod2md-jsdocs:sync-zod2md-setup"]
100+
}
101+
}
102+
```
103+
104+
## Register a Local Sync Generator
105+
106+
Local sync generators are registered in the project's `package.json` or `project.json` file under the `syncGenerators` property for specific targets:
107+
108+
_package.json_
109+
110+
```json
111+
{
112+
"name": "my-project",
113+
"nx": {
114+
"targets": {
115+
"build": {
116+
"syncGenerators": ["./tools/zod2md-jsdocs:sync-zod2md-setup"]
117+
}
118+
}
119+
}
120+
}
96121
```
97122

123+
_project.json_
124+
125+
```json
126+
{
127+
"name": "my-project",
128+
"targets": {
129+
"build": {
130+
"syncGenerators": ["./tools/zod2md-jsdocs:sync-zod2md-setup"]
131+
}
132+
}
133+
}
134+
```
135+
136+
With this configuration, the sync generator will run automatically before the specified target (e.g., `build`).
137+
98138
## Notes
99139

100140
- This is a **sync generator**, not a build step

tools/zod2md-jsdocs/src/lib/generators/sync-zod2md-setup/sync-zod2md-setup.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import * as path from 'node:path';
1111
import {
1212
GENERATE_DOCS_TARGET_NAME,
1313
PATCH_TS_TARGET_NAME,
14-
} from '../../plugin/constants.js';
15-
import { DEFAULT_ZOD2MD_CONFIG_FILE_NAME } from '../configuration/constants.js';
14+
} from '../../plugin/constants';
15+
import { DEFAULT_ZOD2MD_CONFIG_FILE_NAME } from '../configuration/constants';
1616
import {
1717
type PluginDefinition,
1818
addZod2MdTransformToTsConfig,
1919
getFirstExistingTsConfig,
20-
} from '../configuration/tsconfig.js';
20+
} from '../configuration/tsconfig';
2121

2222
const missingTsconfig = 'missing-tsconfig' as const;
2323
const missingTarget = 'missing-target' as const;

tools/zod2md-jsdocs/src/lib/plugin/nx-plugin.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ const createNodesV2: CreateNodesV2 = [
4949
projects: 'self',
5050
},
5151
],
52-
syncGenerators: [
53-
'./tools/zod2md-jsdocs/dist:sync-zod2md-setup',
54-
],
52+
syncGenerators: ['./tools/zod2md-jsdocs:sync-zod2md-setup'],
5553
},
5654
[GENERATE_DOCS_TARGET_NAME]: createDocsTargetConfig({
5755
config,

0 commit comments

Comments
 (0)