nestjs-docfy 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +112 -32
  2. package/dist/cli/detect-project.d.ts +13 -0
  3. package/dist/cli/detect-project.js +318 -0
  4. package/dist/cli/detect-project.js.map +1 -0
  5. package/dist/cli/errors.d.ts +15 -0
  6. package/dist/cli/errors.js +26 -0
  7. package/dist/cli/errors.js.map +1 -0
  8. package/dist/cli/extract-methods.d.ts +34 -0
  9. package/dist/cli/extract-methods.js +171 -0
  10. package/dist/cli/extract-methods.js.map +1 -0
  11. package/dist/cli/generate-file.d.ts +11 -0
  12. package/dist/cli/generate-file.js +127 -0
  13. package/dist/cli/generate-file.js.map +1 -0
  14. package/dist/cli/index.d.ts +2 -0
  15. package/dist/cli/index.js +130 -0
  16. package/dist/cli/index.js.map +1 -0
  17. package/dist/cli/logger.d.ts +5 -0
  18. package/dist/cli/logger.js +48 -0
  19. package/dist/cli/logger.js.map +1 -0
  20. package/dist/cli/merge-docs.d.ts +19 -0
  21. package/dist/cli/merge-docs.js +87 -0
  22. package/dist/cli/merge-docs.js.map +1 -0
  23. package/dist/cli/parse-args.d.ts +42 -0
  24. package/dist/cli/parse-args.js +85 -0
  25. package/dist/cli/parse-args.js.map +1 -0
  26. package/dist/cli/project-types.d.ts +18 -0
  27. package/dist/cli/project-types.js +3 -0
  28. package/dist/cli/project-types.js.map +1 -0
  29. package/dist/cli/resolve-tsconfig.d.ts +5 -0
  30. package/dist/cli/resolve-tsconfig.js +39 -0
  31. package/dist/cli/resolve-tsconfig.js.map +1 -0
  32. package/dist/cli/scan-controllers.d.ts +24 -0
  33. package/dist/cli/scan-controllers.js +157 -0
  34. package/dist/cli/scan-controllers.js.map +1 -0
  35. package/dist/cli/writer.d.ts +25 -0
  36. package/dist/cli/writer.js +115 -0
  37. package/dist/cli/writer.js.map +1 -0
  38. package/dist/docs.d.ts +4 -4
  39. package/dist/docs.js.map +1 -1
  40. package/package.json +11 -2
@@ -0,0 +1,42 @@
1
+ export type OutputFormat = 'ts' | 'js';
2
+ export interface CliOptions {
3
+ root: string;
4
+ tsconfig: string | undefined;
5
+ pattern: string;
6
+ out: string | undefined;
7
+ force: boolean;
8
+ dryRun: boolean;
9
+ quiet: boolean;
10
+ format: OutputFormat;
11
+ }
12
+ /**
13
+ * Validates that a resolved path stays inside the project root.
14
+ * Prevents path traversal via relative segments or symlink tricks.
15
+ */
16
+ export declare function assertWithinRoot(resolvedPath: string, root: string): void;
17
+ /**
18
+ * Validates and normalizes the glob pattern supplied via --pattern.
19
+ * Rejects patterns with characters that could cause shell injection or
20
+ * path traversal outside the root.
21
+ */
22
+ export declare function validateGlob(pattern: string): string;
23
+ /**
24
+ * Resolves and validates a path option (--root, --tsconfig, --out)
25
+ * against the declared root to prevent traversal.
26
+ * Returns the resolved absolute path.
27
+ */
28
+ export declare function resolveAndValidate(value: string, root: string, optionName: string): string;
29
+ /**
30
+ * Parses and validates the raw CLI option object produced by Commander.
31
+ * Returns a strongly-typed, safe CliOptions struct.
32
+ */
33
+ export declare function parseAndValidateOptions(raw: {
34
+ root?: string;
35
+ tsconfig?: string;
36
+ pattern?: string;
37
+ out?: string;
38
+ force?: boolean;
39
+ dryRun?: boolean;
40
+ quiet?: boolean;
41
+ format?: string;
42
+ }): CliOptions;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.assertWithinRoot = assertWithinRoot;
7
+ exports.validateGlob = validateGlob;
8
+ exports.resolveAndValidate = resolveAndValidate;
9
+ exports.parseAndValidateOptions = parseAndValidateOptions;
10
+ const path_1 = __importDefault(require("path"));
11
+ const errors_1 = require("./errors");
12
+ const ALLOWED_GLOB_CHARS = /^[a-zA-Z0-9_\-./\\*?[\]{}!@# ]+$/;
13
+ const VALID_FORMATS = ['ts', 'js'];
14
+ /**
15
+ * Validates that a resolved path stays inside the project root.
16
+ * Prevents path traversal via relative segments or symlink tricks.
17
+ */
18
+ function assertWithinRoot(resolvedPath, root) {
19
+ const normalRoot = path_1.default.resolve(root) + path_1.default.sep;
20
+ const normalTarget = path_1.default.resolve(resolvedPath);
21
+ if (!normalTarget.startsWith(normalRoot) && normalTarget !== path_1.default.resolve(root)) {
22
+ throw new errors_1.PathTraversalError(resolvedPath);
23
+ }
24
+ }
25
+ /**
26
+ * Validates and normalizes the glob pattern supplied via --pattern.
27
+ * Rejects patterns with characters that could cause shell injection or
28
+ * path traversal outside the root.
29
+ */
30
+ function validateGlob(pattern) {
31
+ if (!ALLOWED_GLOB_CHARS.test(pattern)) {
32
+ throw new Error(`Invalid --pattern: "${pattern}". Only alphanumeric characters, path separators, and glob wildcards are allowed.`);
33
+ }
34
+ // Reject attempts to escape the root via relative segments
35
+ const normalized = path_1.default.normalize(pattern.replace(/\*/g, '_'));
36
+ if (normalized.startsWith('..')) {
37
+ throw new Error(`Invalid --pattern: "${pattern}" resolves outside the project root.`);
38
+ }
39
+ return pattern;
40
+ }
41
+ /**
42
+ * Resolves and validates a path option (--root, --tsconfig, --out)
43
+ * against the declared root to prevent traversal.
44
+ * Returns the resolved absolute path.
45
+ */
46
+ function resolveAndValidate(value, root, optionName) {
47
+ let resolved;
48
+ try {
49
+ resolved = path_1.default.resolve(root, value);
50
+ }
51
+ catch {
52
+ throw new Error(`Invalid value for ${optionName}: "${value}"`);
53
+ }
54
+ assertWithinRoot(resolved, root);
55
+ return resolved;
56
+ }
57
+ /**
58
+ * Parses and validates the raw CLI option object produced by Commander.
59
+ * Returns a strongly-typed, safe CliOptions struct.
60
+ */
61
+ function parseAndValidateOptions(raw) {
62
+ const root = path_1.default.resolve(raw.root ?? '.');
63
+ const pattern = validateGlob(raw.pattern ?? '**/*.controller.ts');
64
+ const tsconfig = raw.tsconfig
65
+ ? resolveAndValidate(raw.tsconfig, root, '--tsconfig')
66
+ : undefined;
67
+ const out = raw.out
68
+ ? resolveAndValidate(raw.out, root, '--out')
69
+ : undefined;
70
+ const format = raw.format ?? 'ts';
71
+ if (!VALID_FORMATS.includes(format)) {
72
+ throw new Error(`Invalid --format: "${format}". Allowed values: ${VALID_FORMATS.join(', ')}.`);
73
+ }
74
+ return {
75
+ root,
76
+ tsconfig,
77
+ pattern,
78
+ out,
79
+ force: raw.force ?? false,
80
+ dryRun: raw.dryRun ?? false,
81
+ quiet: raw.quiet ?? false,
82
+ format: format,
83
+ };
84
+ }
85
+ //# sourceMappingURL=parse-args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-args.js","sourceRoot":"","sources":["../../src/cli/parse-args.ts"],"names":[],"mappings":";;;;;AAuBA,4CAMC;AAOD,oCAcC;AAOD,gDAaC;AAMD,0DAuCC;AAnHD,gDAAwB;AACxB,qCAA8C;AAe9C,MAAM,kBAAkB,GAAG,kCAAkC,CAAC;AAC9D,MAAM,aAAa,GAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAEnD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,YAAoB,EAAE,IAAY;IACjE,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,cAAI,CAAC,GAAG,CAAC;IACjD,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAChD,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,YAAY,KAAK,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,2BAAkB,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,OAAe;IAC1C,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb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C5C,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC;IAClC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAsB,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CACb,sBAAsB,MAAM,sBAAsB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9E,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,OAAO;QACP,GAAG;QACH,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,KAAK;QACzB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,KAAK;QAC3B,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,KAAK;QACzB,MAAM,EAAE,MAAsB;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type ProjectKind = 'simple' | 'nx' | 'nest-cli-monorepo' | 'generic-monorepo';
2
+ export interface ProjectApp {
3
+ /** Human-readable name of the app/lib */
4
+ name: string;
5
+ /** Absolute path to the app/lib root */
6
+ root: string;
7
+ /** Absolute path to the resolved tsconfig for this app */
8
+ tsconfig: string;
9
+ /** Glob pattern to find controllers within this app */
10
+ controllerGlob: string;
11
+ }
12
+ export interface ProjectContext {
13
+ kind: ProjectKind;
14
+ /** Absolute path to the workspace root */
15
+ root: string;
16
+ /** One entry per compilable unit (app or lib). Simple projects have exactly one entry. */
17
+ apps: ProjectApp[];
18
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=project-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-types.js","sourceRoot":"","sources":["../../src/cli/project-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Resolves the best tsconfig for a given app root, validating the result
3
+ * stays within the project root. Throws ConfigNotFoundError if none found.
4
+ */
5
+ export declare function resolveTsconfig(appRoot: string, projectRoot: string): string;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resolveTsconfig = resolveTsconfig;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const parse_args_1 = require("./parse-args");
10
+ const errors_1 = require("./errors");
11
+ const CANDIDATES = [
12
+ 'tsconfig.build.json',
13
+ 'tsconfig.app.json',
14
+ 'tsconfig.json',
15
+ ];
16
+ /**
17
+ * Resolves the best tsconfig for a given app root, validating the result
18
+ * stays within the project root. Throws ConfigNotFoundError if none found.
19
+ */
20
+ function resolveTsconfig(appRoot, projectRoot) {
21
+ for (const candidate of CANDIDATES) {
22
+ const resolved = path_1.default.join(appRoot, candidate);
23
+ try {
24
+ (0, parse_args_1.assertWithinRoot)(resolved, projectRoot);
25
+ }
26
+ catch {
27
+ continue;
28
+ }
29
+ try {
30
+ fs_1.default.accessSync(resolved);
31
+ return resolved;
32
+ }
33
+ catch {
34
+ continue;
35
+ }
36
+ }
37
+ throw new errors_1.ConfigNotFoundError(`No tsconfig found in "${appRoot}". Tried: ${CANDIDATES.join(', ')}`);
38
+ }
39
+ //# sourceMappingURL=resolve-tsconfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-tsconfig.js","sourceRoot":"","sources":["../../src/cli/resolve-tsconfig.ts"],"names":[],"mappings":";;;;;AAeA,0CAkBC;AAjCD,4CAAoB;AACpB,gDAAwB;AACxB,6CAAgD;AAChD,qCAA+C;AAE/C,MAAM,UAAU,GAAG;IACjB,qBAAqB;IACrB,mBAAmB;IACnB,eAAe;CAChB,CAAC;AAEF;;;GAGG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,WAAmB;IAClE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC;YACH,IAAA,6BAAgB,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,IAAI,CAAC;YACH,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;IACH,CAAC;IACD,MAAM,IAAI,4BAAmB,CAC3B,yBAAyB,OAAO,aAAa,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { ControllerInfo } from './extract-methods';
2
+ import type { ProjectApp } from './project-types';
3
+ export interface ScanResult {
4
+ controllers: ControllerInfo[];
5
+ errors: ScanError[];
6
+ }
7
+ export interface ScanError {
8
+ file: string;
9
+ message: string;
10
+ }
11
+ /**
12
+ * Derives the expected docs file path from a controller file path.
13
+ * e.g. users.controller.ts → users.controller.docs.ts
14
+ */
15
+ export declare function deriveDocsFilePath(controllerPath: string, format: 'ts' | 'js'): string;
16
+ /**
17
+ * Scans all controllers for a single app using static analysis only (ts-morph).
18
+ * Never executes any user code.
19
+ */
20
+ export declare function scanApp(app: ProjectApp, projectRoot: string, patternOverride: string | undefined, format: 'ts' | 'js'): ScanResult;
21
+ /**
22
+ * Scans all apps in a project context and merges results.
23
+ */
24
+ export declare function scanAllApps(apps: ProjectApp[], projectRoot: string, patternOverride: string | undefined, format: 'ts' | 'js'): ScanResult;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.deriveDocsFilePath = deriveDocsFilePath;
7
+ exports.scanApp = scanApp;
8
+ exports.scanAllApps = scanAllApps;
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const ts_morph_1 = require("ts-morph");
12
+ const parse_args_1 = require("./parse-args");
13
+ const extract_methods_1 = require("./extract-methods");
14
+ /**
15
+ * Resolves a real path safely, returning null on any error (broken symlink, etc.).
16
+ */
17
+ function safeRealpath(filePath) {
18
+ try {
19
+ return fs_1.default.realpathSync(filePath);
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ }
25
+ /**
26
+ * Returns true if a file path points to a generated/dist file that should
27
+ * be excluded from scanning.
28
+ */
29
+ function isGeneratedFile(filePath) {
30
+ const normalized = filePath.replace(/\\/g, '/');
31
+ return (normalized.includes('/dist/') ||
32
+ normalized.includes('/node_modules/') ||
33
+ filePath.endsWith('.d.ts') ||
34
+ filePath.endsWith('.js'));
35
+ }
36
+ /**
37
+ * Derives the expected docs file path from a controller file path.
38
+ * e.g. users.controller.ts → users.controller.docs.ts
39
+ */
40
+ function deriveDocsFilePath(controllerPath, format) {
41
+ const ext = path_1.default.extname(controllerPath);
42
+ const base = controllerPath.slice(0, -ext.length);
43
+ return `${base}.docs.${format}`;
44
+ }
45
+ /**
46
+ * Scans all controllers for a single app using static analysis only (ts-morph).
47
+ * Never executes any user code.
48
+ */
49
+ function scanApp(app, projectRoot, patternOverride, format) {
50
+ const controllers = [];
51
+ const errors = [];
52
+ let project;
53
+ try {
54
+ project = new ts_morph_1.Project({
55
+ tsConfigFilePath: app.tsconfig,
56
+ skipAddingFilesFromTsConfig: false,
57
+ skipFileDependencyResolution: true,
58
+ });
59
+ }
60
+ catch (err) {
61
+ errors.push({
62
+ file: app.tsconfig,
63
+ message: `Failed to load tsconfig: ${err instanceof Error ? err.message : String(err)}`,
64
+ });
65
+ return { controllers, errors };
66
+ }
67
+ // Determine which source files to scan
68
+ const glob = patternOverride ?? app.controllerGlob;
69
+ let sourceFiles = project.getSourceFiles();
70
+ // Filter to files matching the controller glob pattern
71
+ sourceFiles = sourceFiles.filter((sf) => {
72
+ const filePath = sf.getFilePath();
73
+ // Skip generated files unconditionally
74
+ if (isGeneratedFile(filePath))
75
+ return false;
76
+ // Validate the real path stays within the project root (symlink protection)
77
+ const real = safeRealpath(filePath);
78
+ if (!real)
79
+ return false;
80
+ try {
81
+ (0, parse_args_1.assertWithinRoot)(real, projectRoot);
82
+ }
83
+ catch {
84
+ return false;
85
+ }
86
+ // Match against controller naming convention
87
+ const baseName = path_1.default.basename(filePath);
88
+ if (glob === '**/*.controller.ts') {
89
+ return baseName.endsWith('.controller.ts') && !baseName.endsWith('.docs.ts');
90
+ }
91
+ // For custom globs, apply simple basename pattern match
92
+ const pattern = path_1.default.basename(glob).replace(/\*/g, '.*');
93
+ return new RegExp(pattern).test(baseName);
94
+ });
95
+ for (const sf of sourceFiles) {
96
+ const filePath = sf.getFilePath();
97
+ try {
98
+ const classes = sf.getClasses();
99
+ for (const cls of classes) {
100
+ // Only process classes decorated with @Controller
101
+ const hasController = cls.getDecorators().some((d) => {
102
+ try {
103
+ return d.getName() === 'Controller';
104
+ }
105
+ catch {
106
+ return false;
107
+ }
108
+ });
109
+ if (!hasController)
110
+ continue;
111
+ const className = cls.getName();
112
+ if (!className)
113
+ continue;
114
+ const controllerPath = (0, extract_methods_1.extractControllerPath)(cls);
115
+ const methods = (0, extract_methods_1.extractMethods)(cls);
116
+ const docsFilePath = deriveDocsFilePath(filePath, format);
117
+ const hasDocsFile = (() => {
118
+ try {
119
+ fs_1.default.accessSync(docsFilePath);
120
+ return true;
121
+ }
122
+ catch {
123
+ return false;
124
+ }
125
+ })();
126
+ controllers.push({
127
+ className,
128
+ filePath,
129
+ controllerPath,
130
+ methods,
131
+ hasDocsFile,
132
+ });
133
+ }
134
+ }
135
+ catch (err) {
136
+ errors.push({
137
+ file: filePath,
138
+ message: err instanceof Error ? err.message : String(err),
139
+ });
140
+ }
141
+ }
142
+ return { controllers, errors };
143
+ }
144
+ /**
145
+ * Scans all apps in a project context and merges results.
146
+ */
147
+ function scanAllApps(apps, projectRoot, patternOverride, format) {
148
+ const allControllers = [];
149
+ const allErrors = [];
150
+ for (const app of apps) {
151
+ const result = scanApp(app, projectRoot, patternOverride, format);
152
+ allControllers.push(...result.controllers);
153
+ allErrors.push(...result.errors);
154
+ }
155
+ return { controllers: allControllers, errors: allErrors };
156
+ }
157
+ //# sourceMappingURL=scan-controllers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-controllers.js","sourceRoot":"","sources":["../../src/cli/scan-controllers.ts"],"names":[],"mappings":";;;;;AA8CA,gDAIC;AAMD,0BAgGC;AAKD,kCAgBC;AA7KD,4CAAoB;AACpB,gDAAwB;AACxB,uCAAmC;AACnC,6CAAgD;AAChD,uDAA0F;AAa1F;;GAEG;AACH,SAAS,YAAY,CAAC,QAAgB;IACpC,IAAI,CAAC;QACH,OAAO,YAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,QAAgB;IACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,CACL,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC7B,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QACrC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC1B,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CACzB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,cAAsB,EAAE,MAAmB;IAC5E,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC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AC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { ControllerInfo } from './extract-methods';
2
+ export type WriteOutcome = 'created' | 'skipped' | 'merged' | 'dry' | 'error';
3
+ export interface WriteResult {
4
+ controllerClass: string;
5
+ docsFilePath: string;
6
+ outcome: WriteOutcome;
7
+ addedMethods?: string[];
8
+ error?: string;
9
+ }
10
+ export interface WriterOptions {
11
+ projectRoot: string;
12
+ outDir?: string;
13
+ force: boolean;
14
+ dryRun: boolean;
15
+ format: 'ts' | 'js';
16
+ }
17
+ /**
18
+ * Writes (or previews) the docs file for a single controller.
19
+ * Handles: create, skip, merge (--force), dry-run.
20
+ */
21
+ export declare function writeDocsFile(ctrl: ControllerInfo, opts: WriterOptions): WriteResult;
22
+ /**
23
+ * Writes docs files for all controllers and returns aggregated results.
24
+ */
25
+ export declare function writeAllDocs(controllers: ControllerInfo[], opts: WriterOptions): WriteResult[];
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.writeDocsFile = writeDocsFile;
7
+ exports.writeAllDocs = writeAllDocs;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const parse_args_1 = require("./parse-args");
11
+ const generate_file_1 = require("./generate-file");
12
+ const merge_docs_1 = require("./merge-docs");
13
+ const scan_controllers_1 = require("./scan-controllers");
14
+ /**
15
+ * Resolves the output path for a docs file, applying --out dir override
16
+ * when present, and validating the result stays within the project root.
17
+ */
18
+ function resolveOutputPath(ctrl, opts) {
19
+ const derived = (0, scan_controllers_1.deriveDocsFilePath)(ctrl.filePath, opts.format);
20
+ if (!opts.outDir)
21
+ return derived;
22
+ // --out: place the file in the specified directory, keeping only the basename
23
+ const outPath = path_1.default.join(opts.outDir, path_1.default.basename(derived));
24
+ (0, parse_args_1.assertWithinRoot)(outPath, opts.projectRoot);
25
+ return outPath;
26
+ }
27
+ /**
28
+ * Writes (or previews) the docs file for a single controller.
29
+ * Handles: create, skip, merge (--force), dry-run.
30
+ */
31
+ function writeDocsFile(ctrl, opts) {
32
+ let docsFilePath;
33
+ try {
34
+ docsFilePath = resolveOutputPath(ctrl, opts);
35
+ (0, parse_args_1.assertWithinRoot)(docsFilePath, opts.projectRoot);
36
+ }
37
+ catch (err) {
38
+ return {
39
+ controllerClass: ctrl.className,
40
+ docsFilePath: ctrl.filePath,
41
+ outcome: 'error',
42
+ error: err instanceof Error ? err.message : String(err),
43
+ };
44
+ }
45
+ const exists = (() => {
46
+ try {
47
+ fs_1.default.accessSync(docsFilePath);
48
+ return true;
49
+ }
50
+ catch {
51
+ return false;
52
+ }
53
+ })();
54
+ // --- DRY RUN ---
55
+ if (opts.dryRun) {
56
+ const content = (0, generate_file_1.renderDocsFile)(ctrl, docsFilePath, opts.format);
57
+ process.stdout.write(`\n${'─'.repeat(60)}\n`);
58
+ process.stdout.write(`[dry-run] ${docsFilePath}\n`);
59
+ process.stdout.write(`${'─'.repeat(60)}\n`);
60
+ process.stdout.write(content);
61
+ return { controllerClass: ctrl.className, docsFilePath, outcome: 'dry' };
62
+ }
63
+ // --- SKIP (file exists, no --force) ---
64
+ if (exists && !opts.force) {
65
+ return { controllerClass: ctrl.className, docsFilePath, outcome: 'skipped' };
66
+ }
67
+ // --- MERGE (file exists + --force) ---
68
+ if (exists && opts.force) {
69
+ try {
70
+ const existingContent = fs_1.default.readFileSync(docsFilePath, 'utf8');
71
+ const merged = (0, merge_docs_1.mergeDocsFile)(existingContent, ctrl);
72
+ if (merged) {
73
+ fs_1.default.writeFileSync(docsFilePath, merged.content, 'utf8');
74
+ return {
75
+ controllerClass: ctrl.className,
76
+ docsFilePath,
77
+ outcome: 'merged',
78
+ addedMethods: merged.addedMethods,
79
+ };
80
+ }
81
+ // Merge failed (unparseable file) — fall through to full overwrite
82
+ }
83
+ catch (err) {
84
+ return {
85
+ controllerClass: ctrl.className,
86
+ docsFilePath,
87
+ outcome: 'error',
88
+ error: err instanceof Error ? err.message : String(err),
89
+ };
90
+ }
91
+ }
92
+ // --- CREATE (new file, or full overwrite after failed merge) ---
93
+ try {
94
+ const dir = path_1.default.dirname(docsFilePath);
95
+ fs_1.default.mkdirSync(dir, { recursive: true });
96
+ const content = (0, generate_file_1.renderDocsFile)(ctrl, docsFilePath, opts.format);
97
+ fs_1.default.writeFileSync(docsFilePath, content, 'utf8');
98
+ return { controllerClass: ctrl.className, docsFilePath, outcome: 'created' };
99
+ }
100
+ catch (err) {
101
+ return {
102
+ controllerClass: ctrl.className,
103
+ docsFilePath,
104
+ outcome: 'error',
105
+ error: err instanceof Error ? err.message : String(err),
106
+ };
107
+ }
108
+ }
109
+ /**
110
+ * Writes docs files for all controllers and returns aggregated results.
111
+ */
112
+ function writeAllDocs(controllers, opts) {
113
+ return controllers.map((ctrl) => writeDocsFile(ctrl, opts));
114
+ }
115
+ //# sourceMappingURL=writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.js","sourceRoot":"","sources":["../../src/cli/writer.ts"],"names":[],"mappings":";;;;;AAgDA,sCA6EC;AAKD,oCAKC;AAvID,4CAAoB;AACpB,gDAAwB;AACxB,6CAAgD;AAChD,mDAAiD;AACjD,6CAA6C;AAC7C,yDAAwD;AAqBxD;;;GAGG;AACH,SAAS,iBAAiB,CACxB,IAAoB,EACpB,IAAmB;IAEnB,MAAM,OAAO,GAAG,IAAA,qCAAkB,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAE/D,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAEjC,8EAA8E;IAC9E,MAAM,OAAO,GAAG,cAA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AAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACvC,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,IAAA,8BAAc,EAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChE,YAAE,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAChD,OAAO,EAAE,eAAe,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAC/E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,eAAe,EAAE,IAAI,CAAC,SAAS;YAC/B,YAAY;YACZ,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAC1B,WAA6B,EAC7B,IAAmB;IAEnB,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC"}
package/dist/docs.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- type Constructor = new (...args: any[]) => any;
2
- export interface DocsConfig {
1
+ type Constructor<T = any> = new (...args: any[]) => T;
2
+ export interface DocsConfig<T = any> {
3
3
  /** Class-level decorators (e.g. ApiTags). Applied to the constructor. */
4
4
  classDecorators?: ClassDecorator[];
5
5
  /** Method-level decorators keyed by method name. */
6
- methods?: Record<string, MethodDecorator[]>;
6
+ methods?: Partial<Record<keyof T, MethodDecorator[]>>;
7
7
  }
8
8
  /**
9
9
  * Applies Swagger decorators to a controller class from outside the class file.
@@ -21,5 +21,5 @@ export interface DocsConfig {
21
21
  * },
22
22
  * });
23
23
  */
24
- export declare function docs(controllerClass: Constructor, config: DocsConfig): void;
24
+ export declare function docs<T>(controllerClass: Constructor<T>, config: DocsConfig<T>): void;
25
25
  export {};
package/dist/docs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../src/docs.ts"],"names":[],"mappings":";;AAyBA,oBA2BC;AA3CD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,IAAI,CAAC,eAA4B,EAAE,MAAkB;IACnE,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC/C,SAAS,CAAC,eAAe,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO;IAE5B,KAAK,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACtE,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAChD,eAAe,CAAC,SAAS,EACzB,UAAU,CACX,CAAC;QAEF,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CACV,0BAA0B,UAAU,kBAAkB,eAAe,CAAC,IAAI,IAAI;gBAC5E,uCAAuC,CAC1C,CAAC;YACF,SAAS;QACX,CAAC;QAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,SAAS,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"docs.js","sourceRoot":"","sources":["../src/docs.ts"],"names":[],"mappings":";;AAyBA,oBA2BC;AA3CD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,IAAI,CAAI,eAA+B,EAAE,MAAqB;IAC5E,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3B,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC/C,SAAS,CAAC,eAAe,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO;IAE5B,KAAK,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAkC,EAAE,CAAC;QACvG,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAChD,eAAe,CAAC,SAAS,EACzB,UAAU,CACX,CAAC;QAEF,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CACV,0BAA0B,UAAU,kBAAkB,eAAe,CAAC,IAAI,IAAI;gBAC5E,uCAAuC,CAC1C,CAAC;YACF,SAAS;QACX,CAAC;QAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,SAAS,CAAC,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-docfy",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Keep your NestJS controllers clean — Swagger docs live in a separate companion file by naming convention",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,8 +14,12 @@
14
14
  "types": "./dist/testing.d.ts"
15
15
  }
16
16
  },
17
+ "bin": {
18
+ "nestjs-docfy": "dist/cli/index.js"
19
+ },
17
20
  "files": [
18
- "dist"
21
+ "dist",
22
+ "package.json"
19
23
  ],
20
24
  "engines": {
21
25
  "node": ">=16.0.0"
@@ -77,5 +81,10 @@
77
81
  "ts-jest": "^29.2.5",
78
82
  "ts-node": "^10.9.2",
79
83
  "typescript": "^5.7.3"
84
+ },
85
+ "dependencies": {
86
+ "commander": "^15.0.0",
87
+ "picocolors": "^1.1.1",
88
+ "ts-morph": "^28.0.0"
80
89
  }
81
90
  }