Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d4b6e68
refactor: add task derivation for build
Dec 15, 2025
db41274
refactor: adjust build target for bin scripts
Dec 15, 2025
9e32cff
refactor: add plugin in nx.json
Dec 15, 2025
86ab1d2
refactor: adjust project.json files
Dec 15, 2025
fbcaae1
refactor: npm dedupe
Dec 15, 2025
58b3eea
refactor: fix lint
Dec 15, 2025
e392ed7
refactor: fix lint 2
Dec 15, 2025
66b25e6
Merge branch 'main' into chore/add-plugin-for-build
BioPhoton Jan 19, 2026
6cc5a33
refactor: setup ts plugin
BioPhoton Jan 19, 2026
6944b65
refactor: wip
BioPhoton Jan 19, 2026
2364c4e
refactor: wip
BioPhoton Jan 19, 2026
8daea18
refactor: wip
BioPhoton Jan 19, 2026
f2e2052
refactor: wip
BioPhoton Jan 19, 2026
ebc13b8
refactor: wip
BioPhoton Jan 19, 2026
9f22be1
refactor: nx add @nx/js
BioPhoton Jan 19, 2026
5d36ac8
refactor: first try tsc:build target
BioPhoton Jan 19, 2026
11fd408
Merge branch 'main' into chore/add-plugin-for-build
BioPhoton Jan 25, 2026
1fc70d5
refactor: reset
BioPhoton Jan 25, 2026
299203b
refactor: setup sync generator
BioPhoton Jan 25, 2026
e4b2a4d
refactor: fix build
BioPhoton Jan 25, 2026
9cb2e2f
refactor: fix lint
BioPhoton Jan 25, 2026
17dd42f
refactor: fix comments
BioPhoton Jan 25, 2026
148fe46
refactor: docs updates
BioPhoton Jan 25, 2026
c0236cb
Merge branch 'main' into chore/add-plugin-for-build
BioPhoton Jan 26, 2026
bb3eadd
refactor: cleanup imports
BioPhoton Jan 26, 2026
06f526a
refactor: wip
BioPhoton Jan 26, 2026
e58c1fc
refactor: wip
BioPhoton Jan 26, 2026
6a16e58
refactor: wip
BioPhoton Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
"releaseTagPattern": "v{version}"
},
"plugins": [
"./tools/zod2md-jsdocs/src/nx-plugin.ts",
"./tools/zod2md-jsdocs/src/lib/plugin/nx-plugin.ts",
{
"plugin": "@push-based/nx-verdaccio",
"options": {
Expand Down
8 changes: 2 additions & 6 deletions packages/models/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/models/src",
"projectType": "library",
"implicitDependencies": ["zod2md-jsdocs"],
"targets": {
"build": {
"dependsOn": [
"^build",
"generate-docs",
{ "projects": "zod2md-jsdocs", "target": "build" },
{ "projects": "zod2md-jsdocs", "target": "ts-patch" }
]
"dependsOn": ["^build", "generate-docs", "ts-patch"]
},
"lint": {},
"unit-test": {},
Expand Down
31 changes: 24 additions & 7 deletions testing/test-nx-utils/src/lib/utils/nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { libraryGenerator } from '@nx/js';
import type { LibraryGeneratorSchema } from '@nx/js/src/generators/library/schema';
import path from 'node:path';
import { createTreeWithEmptyWorkspace } from 'nx/src/generators/testing-utils/create-tree-with-empty-workspace';
import { executeProcess } from '@code-pushup/utils';
import { executeProcess } from '@code-pushup/test-utils';

export function executorContext<
T extends { projectName: string; cwd?: string },
Expand Down Expand Up @@ -95,11 +95,28 @@ export async function nxShowProjectJson<T extends ProjectConfiguration>(
cwd: string,
project: string,
) {
const { code, stderr, stdout } = await executeProcess({
command: 'npx',
args: ['nx', 'show', `project --json ${project}`],
cwd,
});
try {
const { stderr, stdout } = await executeProcess({
command: 'npx',
args: ['nx', 'show', 'project', '--json', project],
cwd,
});

return { code, stderr, projectJson: JSON.parse(stdout) as T };
return {
code: 0,
stderr,
projectJson: JSON.parse(stdout) as T,
};
} catch (error: unknown) {
const execError = error as {
code?: number;
stderr?: string;
stdout?: string;
};
return {
code: execError.code ?? 1,
stderr: execError.stderr ?? String(error),
projectJson: JSON.parse(execError.stdout ?? '{}') as T,
};
}
}
1 change: 1 addition & 0 deletions testing/test-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './lib/utils/file-system.js';
export * from './lib/utils/create-npm-workshpace.js';
export * from './lib/utils/project-graph.js';
export * from './lib/utils/test-folder-setup.js';
export * from './lib/utils/execute-process.js';
12 changes: 12 additions & 0 deletions testing/test-utils/src/lib/utils/execute-process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';

export async function executeProcess(cfg: {
command: string;
args: string[];
cwd: string;
}) {
const execFileAsync = promisify(execFile);
const { command, args, cwd } = cfg;
return await execFileAsync(command, args, { cwd });
}
45 changes: 5 additions & 40 deletions tools/zod2md-jsdocs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,9 @@ A comprehensive toolset for generating and enhancing TypeScript documentation fr

## What's Included

This package provides two main components:
This package provides the following components:

1. **[Nx Plugin](./docs/zod2md-jsdocs-nx-plugin.md)** - Automatically generates documentation targets for projects with Zod schemas
2. **[TypeScript Transformer](./docs/zod2md-jsdocs-ts-transformer.md)** - Enhances generated type definitions with JSDoc comments and schema metadata

## Quick Start

### Using the Nx Plugin

Add the plugin to your `nx.json`:

```jsonc
{
"plugins": ["./tools/zod2md-jsdocs/src/nx-plugin.ts"],
}
```

Create a `zod2md.config.ts` in your project, and you'll automatically get a `generate-docs` target.

[Learn more about the Nx Plugin →](./docs/zod2md-jsdocs-nx-plugin.md)

### Using the TypeScript Transformer

1. Install ts-patch: `ts-patch install`
2. Add to your `tsconfig.json`:

```json
{
"compilerOptions": {
"plugins": [
{
"transform": "./tools/zod2md-jsdocs/dist/src",
"afterDeclarations": true,
"baseUrl": "https://github.com/code-pushup/cli/blob/main/packages/<PROJECT-NAME>/docs/models-reference.md"
}
]
}
}
```

[Learn more about the TypeScript Transformer →](./docs/zod2md-jsdocs-ts-transformer.md)
1. **[Nx Plugin](./src/lib/plugin/README.md)** - Automatically generates documentation targets for projects with Zod schemas
2. **[Nx Configuration Generator](./src/lib/generators/configuration/README.md)** - Automatically generates documentation targets for projects with Zod schemas
3. **[Nx Sync Zod2Md Setup Generator](./src/lib/generators/sync-zod2md-setup/README.md)** - Automatically generates documentation targets for projects with Zod schemas
4. **[TypeScript Transformer](./src/lib/transformers/README.md)** - Enhances generated type definitions with JSDoc comments and schema metadata
80 changes: 0 additions & 80 deletions tools/zod2md-jsdocs/docs/zod2md-jsdocs-nx-plugin.md

This file was deleted.

46 changes: 44 additions & 2 deletions tools/zod2md-jsdocs/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
const tseslint = require('typescript-eslint');
const baseConfig = require('../../eslint.config.js').default;

module.exports = [
module.exports = tseslint.config(
...baseConfig,
{
files: ['**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname,
},
},
},
{
files: ['**/*.ts'],
rules: {
// Nx plugins don't yet support ESM: https://github.com/nrwl/nx/issues/15682
'unicorn/prefer-module': 'off',
// used instead of verbatimModuleSyntax tsconfig flag (requires ESM)
'@typescript-eslint/consistent-type-imports': [
'warn',
{
fixStyle: 'inline-type-imports',
disallowTypeAnnotations: false,
},
],
'@typescript-eslint/consistent-type-exports': [
'warn',
{ fixMixedExportsWithInlineTypeSpecifier: true },
],
// `import path from 'node:path'` incompatible with CJS runtime, prefer `import * as path from 'node:path'`
'unicorn/import-style': [
'warn',
{ styles: { 'node:path': { namespace: true } } },
],
// `import { logger } from '@nx/devkit' is OK here
'no-restricted-imports': 'off',
},
},
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': 'error',
},
},
];
{
files: ['**/package.json', '**/generators.json'],
rules: {
'@nx/nx-plugin-checks': 'error',
},
},
);
19 changes: 19 additions & 0 deletions tools/zod2md-jsdocs/generators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"generators": {
"sync-zod2md-setup": {
"factory": "./src/lib/generators/sync-zod2md-setup/sync-zod2md-setup",
"schema": "./src/lib/generators/sync-zod2md-setup/schema.json",
"description": "sync-zod2md-setup generator"
},
"configuration": {
"factory": "./src/lib/generators/configuration/configuration",
"schema": "./src/lib/generators/configuration/schema.json",
"description": "configuration generator"
},
"sync-zod2md-docs": {
"factory": "./src/lib/generators/sync-zod2md-docs/sync-zod2md-docs",
"schema": "./src/lib/generators/sync-zod2md-docs/schema.json",
"description": "sync-zod2md-docs generator"
}
}
}
8 changes: 5 additions & 3 deletions tools/zod2md-jsdocs/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"name": "@code-pushup/zod2md-jsdocs",
"name": "@tooling/zod2md-jsdocs",
"version": "0.0.0",
"description": "TypeScript transformers enhancing models with JSDoc and schema metadata",
"type": "commonjs",
"main": "./src/index.js",
"dependencies": {
"@nx/devkit": "22.3.3",
"ts-patch": "^3.3.0",
"typescript": "5.7.3",
"@nx/devkit": "22.3.3"
"zod2md": "^0.2.4"
},
"files": [
"src"
]
],
"generators": "./generators.json"
}
51 changes: 48 additions & 3 deletions tools/zod2md-jsdocs/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,53 @@
"sourceRoot": "tools/zod2md-jsdocs/src",
"projectType": "library",
"targets": {
"lint": {},
"build": {},
"build": {
"options": {
"assets": [
"{projectRoot}/*.md",
{
"input": "./tools/zod2md-jsdocs/src",
"glob": "**/!(*.ts)",
"output": "./src"
},
{
"input": "./tools/zod2md-jsdocs/src",
"glob": "**/*.d.ts",
"output": "./src"
},
{
"input": "./tools/zod2md-jsdocs",
"glob": "generators.json",
"output": "."
},
{
"input": "./tools/zod2md-jsdocs",
"glob": "executors.json",
"output": "."
}
]
}
},
"lint": {
"options": {
"lintFilePatterns": [
"tools/zod2md-jsdocs/**/*.ts",
"tools/zod2md-jsdocs/package.json",
"tools/zod2md-jsdocs/generators.json"
]
}
},
"lint-report": {
"options": {
"lintFilePatterns": [
"tools/zod2md-jsdocs/**/*.ts",
"tools/zod2md-jsdocs/package.json",
"tools/zod2md-jsdocs/generators.json"
]
}
},
"unit-test": {},
"int-test": {},
"ts-patch": {
"command": "ts-patch install",
"cache": true,
Expand All @@ -17,5 +61,6 @@
}
]
}
}
},
"tags": ["scope:tooling", "type:feature", "publishable"]
}
5 changes: 2 additions & 3 deletions tools/zod2md-jsdocs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { annotateTypeDefinitions } from './lib/transformers.js';
import { annotateTypeDefinitions } from './lib/transformers/transformers.js';

export {
annotateTypeDefinitions,
generateJSDocComment,
} from './lib/transformers.js';

} from './lib/transformers/transformers.js';
export default annotateTypeDefinitions;
Loading
Loading