@equinor/fusion-framework-cli-plugin-ai-index 1.0.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.
- package/CHANGELOG.md +63 -0
- package/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/esm/bin/apply-metadata.js +63 -0
- package/dist/esm/bin/apply-metadata.js.map +1 -0
- package/dist/esm/bin/delete-removed-files.js +36 -0
- package/dist/esm/bin/delete-removed-files.js.map +1 -0
- package/dist/esm/bin/embed.js +196 -0
- package/dist/esm/bin/embed.js.map +1 -0
- package/dist/esm/bin/execute-pipeline.js +40 -0
- package/dist/esm/bin/execute-pipeline.js.map +1 -0
- package/dist/esm/bin/file-stream.js +22 -0
- package/dist/esm/bin/file-stream.js.map +1 -0
- package/dist/esm/bin/get-diff.js +29 -0
- package/dist/esm/bin/get-diff.js.map +1 -0
- package/dist/esm/bin/index.js +2 -0
- package/dist/esm/bin/index.js.map +1 -0
- package/dist/esm/bin/types.js +2 -0
- package/dist/esm/bin/types.js.map +1 -0
- package/dist/esm/command.js +82 -0
- package/dist/esm/command.js.map +1 -0
- package/dist/esm/command.options.js +48 -0
- package/dist/esm/command.options.js.map +1 -0
- package/dist/esm/config.js +2 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/index.js +13 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/utils/generate-chunk-id.js +18 -0
- package/dist/esm/utils/generate-chunk-id.js.map +1 -0
- package/dist/esm/utils/git/file-changes.js +196 -0
- package/dist/esm/utils/git/file-changes.js.map +1 -0
- package/dist/esm/utils/git/git-client.js +39 -0
- package/dist/esm/utils/git/git-client.js.map +1 -0
- package/dist/esm/utils/git/index.js +9 -0
- package/dist/esm/utils/git/index.js.map +1 -0
- package/dist/esm/utils/git/metadata.js +41 -0
- package/dist/esm/utils/git/metadata.js.map +1 -0
- package/dist/esm/utils/git/status.js +34 -0
- package/dist/esm/utils/git/status.js.map +1 -0
- package/dist/esm/utils/git/types.js +2 -0
- package/dist/esm/utils/git/types.js.map +1 -0
- package/dist/esm/utils/markdown/index.js +3 -0
- package/dist/esm/utils/markdown/index.js.map +1 -0
- package/dist/esm/utils/markdown/parser.js +72 -0
- package/dist/esm/utils/markdown/parser.js.map +1 -0
- package/dist/esm/utils/markdown/types.js +2 -0
- package/dist/esm/utils/markdown/types.js.map +1 -0
- package/dist/esm/utils/package-resolver.js +40 -0
- package/dist/esm/utils/package-resolver.js.map +1 -0
- package/dist/esm/utils/ts-doc/constants.js +13 -0
- package/dist/esm/utils/ts-doc/constants.js.map +1 -0
- package/dist/esm/utils/ts-doc/extractors.js +175 -0
- package/dist/esm/utils/ts-doc/extractors.js.map +1 -0
- package/dist/esm/utils/ts-doc/index.js +3 -0
- package/dist/esm/utils/ts-doc/index.js.map +1 -0
- package/dist/esm/utils/ts-doc/parser.js +37 -0
- package/dist/esm/utils/ts-doc/parser.js.map +1 -0
- package/dist/esm/utils/ts-doc/types.js +2 -0
- package/dist/esm/utils/ts-doc/types.js.map +1 -0
- package/dist/esm/utils/types.js +2 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/esm/version.js +3 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/bin/apply-metadata.d.ts +1 -0
- package/dist/types/bin/delete-removed-files.d.ts +1 -0
- package/dist/types/bin/embed.d.ts +1 -0
- package/dist/types/bin/execute-pipeline.d.ts +1 -0
- package/dist/types/bin/file-stream.d.ts +1 -0
- package/dist/types/bin/get-diff.d.ts +1 -0
- package/dist/types/bin/index.d.ts +1 -0
- package/dist/types/bin/types.d.ts +1 -0
- package/dist/types/command.d.ts +2 -0
- package/dist/types/command.options.d.ts +62 -0
- package/dist/types/config.d.ts +33 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/utils/generate-chunk-id.d.ts +8 -0
- package/dist/types/utils/git/file-changes.d.ts +21 -0
- package/dist/types/utils/git/git-client.d.ts +17 -0
- package/dist/types/utils/git/index.d.ts +5 -0
- package/dist/types/utils/git/metadata.d.ts +7 -0
- package/dist/types/utils/git/status.d.ts +12 -0
- package/dist/types/utils/git/types.d.ts +33 -0
- package/dist/types/utils/markdown/index.d.ts +2 -0
- package/dist/types/utils/markdown/parser.d.ts +21 -0
- package/dist/types/utils/markdown/types.d.ts +11 -0
- package/dist/types/utils/package-resolver.d.ts +14 -0
- package/dist/types/utils/ts-doc/constants.d.ts +5 -0
- package/dist/types/utils/ts-doc/extractors.d.ts +28 -0
- package/dist/types/utils/ts-doc/index.d.ts +2 -0
- package/dist/types/utils/ts-doc/parser.d.ts +23 -0
- package/dist/types/utils/ts-doc/types.d.ts +20 -0
- package/dist/types/utils/types.d.ts +17 -0
- package/dist/types/version.d.ts +1 -0
- package/package.json +72 -0
- package/src/bin/apply-metadata.ts +77 -0
- package/src/bin/delete-removed-files.ts +49 -0
- package/src/bin/embed.ts +262 -0
- package/src/bin/execute-pipeline.ts +48 -0
- package/src/bin/file-stream.ts +34 -0
- package/src/bin/get-diff.ts +33 -0
- package/src/bin/index.ts +1 -0
- package/src/bin/types.ts +48 -0
- package/src/command.options.ts +58 -0
- package/src/command.ts +100 -0
- package/src/config.ts +39 -0
- package/src/index.ts +19 -0
- package/src/utils/generate-chunk-id.ts +17 -0
- package/src/utils/git/file-changes.ts +213 -0
- package/src/utils/git/git-client.ts +43 -0
- package/src/utils/git/index.ts +19 -0
- package/src/utils/git/metadata.ts +47 -0
- package/src/utils/git/status.ts +48 -0
- package/src/utils/git/types.ts +36 -0
- package/src/utils/markdown/index.ts +5 -0
- package/src/utils/markdown/parser.ts +92 -0
- package/src/utils/markdown/types.ts +20 -0
- package/src/utils/package-resolver.ts +44 -0
- package/src/utils/ts-doc/constants.ts +13 -0
- package/src/utils/ts-doc/extractors.ts +246 -0
- package/src/utils/ts-doc/index.ts +5 -0
- package/src/utils/ts-doc/parser.ts +51 -0
- package/src/utils/ts-doc/types.ts +26 -0
- package/src/utils/types.ts +18 -0
- package/src/version.ts +2 -0
- package/tsconfig.json +27 -0
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/utils/markdown/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
import { readPackageUp } from 'read-package-up';
|
|
3
|
+
/**
|
|
4
|
+
* Map of package base directories to package.json
|
|
5
|
+
*/
|
|
6
|
+
const packageMap = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Resolves which package a file path belongs to.
|
|
9
|
+
* First checks the cache map, then uses read-package-up if no match found.
|
|
10
|
+
*
|
|
11
|
+
* @param filePath - Absolute or relative file path (e.g., '/path/to/packages/cli/src/index.ts')
|
|
12
|
+
* @returns Package.json if found, undefined otherwise
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const packageJson = await resolvePackage('/path/to/packages/cli/src/index.ts');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export async function resolvePackage(filePath) {
|
|
20
|
+
// Check cache: iterate through known package directories
|
|
21
|
+
for (const packageRoot of packageMap.keys()) {
|
|
22
|
+
if (filePath.startsWith(packageRoot)) {
|
|
23
|
+
const packageJson = packageMap.get(packageRoot);
|
|
24
|
+
if (packageJson) {
|
|
25
|
+
return packageJson;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Not in cache, resolve using read-package-up
|
|
30
|
+
// readPackageUp expects a directory path, not a file path
|
|
31
|
+
const dirPath = dirname(filePath);
|
|
32
|
+
const result = await readPackageUp({ cwd: dirPath, normalize: false });
|
|
33
|
+
if (result) {
|
|
34
|
+
// Cache using the package directory (where package.json is located)
|
|
35
|
+
const packageDir = dirname(result.path);
|
|
36
|
+
packageMap.set(packageDir, result.packageJson);
|
|
37
|
+
}
|
|
38
|
+
return result?.packageJson;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=package-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-resolver.js","sourceRoot":"","sources":["../../../src/utils/package-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,EAAuB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAgB;IACnD,yDAAyD;IACzD,KAAK,MAAM,WAAW,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5C,IAAI,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YAChD,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,WAAW,CAAC;YACrB,CAAC;QACH,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,0DAA0D;IAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAEvE,IAAI,MAAM,EAAE,CAAC;QACX,oEAAoE;QACpE,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxC,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,MAAM,EAAE,WAAW,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SyntaxKind } from 'ts-morph';
|
|
2
|
+
/**
|
|
3
|
+
* Supported TSDoc node kinds for top-level processing
|
|
4
|
+
*/
|
|
5
|
+
export const nodeKinds = [
|
|
6
|
+
SyntaxKind.FunctionDeclaration,
|
|
7
|
+
SyntaxKind.ClassDeclaration,
|
|
8
|
+
SyntaxKind.InterfaceDeclaration,
|
|
9
|
+
SyntaxKind.TypeAliasDeclaration,
|
|
10
|
+
SyntaxKind.VariableStatement,
|
|
11
|
+
SyntaxKind.EnumDeclaration,
|
|
12
|
+
];
|
|
13
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/utils/ts-doc/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,CAAC,mBAAmB;IAC9B,UAAU,CAAC,gBAAgB;IAC3B,UAAU,CAAC,oBAAoB;IAC/B,UAAU,CAAC,oBAAoB;IAC/B,UAAU,CAAC,iBAAiB;IAC5B,UAAU,CAAC,eAAe;CAC3B,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { SyntaxKind, Node, } from 'ts-morph';
|
|
2
|
+
import { generateChunkId } from '../generate-chunk-id.js';
|
|
3
|
+
import { nodeKinds } from './constants.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a TypescriptDocument from the given parameters.
|
|
6
|
+
* @param sourceFile - The source file containing the node.
|
|
7
|
+
* @param pageContent - The content of the document.
|
|
8
|
+
* @param tsKind - The TypeScript node kind name.
|
|
9
|
+
* @param tsName - The name of the TypeScript node.
|
|
10
|
+
* @param options - Optional parsing configuration.
|
|
11
|
+
* @param sourceOverride - Optional source path override (for cases where source needs transformation).
|
|
12
|
+
* @returns A TypeScript document with metadata.
|
|
13
|
+
*/
|
|
14
|
+
const createTypescriptDocument = (sourceFile, pageContent, tsKind, tsName, options) => {
|
|
15
|
+
const source = sourceFile.getFilePath().replace(/^\/+/, '');
|
|
16
|
+
return {
|
|
17
|
+
id: generateChunkId(source),
|
|
18
|
+
pageContent,
|
|
19
|
+
metadata: {
|
|
20
|
+
source,
|
|
21
|
+
...(options?.projectRoot && { rootPath: options.projectRoot }),
|
|
22
|
+
attributes: {
|
|
23
|
+
type: 'tsdoc',
|
|
24
|
+
ts_kind: tsKind,
|
|
25
|
+
ts_name: tsName,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Extracts a TSDoc document from a class node, including TSDoc, constructor, and public member signatures.
|
|
32
|
+
* @param classNode - The ClassDeclaration node to process.
|
|
33
|
+
* @param sourceFile - The source file containing the node.
|
|
34
|
+
* @param options - Optional parsing configuration.
|
|
35
|
+
* @returns A TypeScript document with TSDoc and class interface, or null if no TSDoc is found.
|
|
36
|
+
*/
|
|
37
|
+
export const extractDocumentFromClassNode = (classNode, sourceFile, _options) => {
|
|
38
|
+
// Find TSDoc comment (/** ... */)
|
|
39
|
+
const docCommentRange = classNode
|
|
40
|
+
.getLeadingCommentRanges()
|
|
41
|
+
.find((range) => range.getText().startsWith('/**'));
|
|
42
|
+
if (!docCommentRange) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const docComment = docCommentRange.getText();
|
|
46
|
+
const className = classNode.getName() || 'AnonymousClass';
|
|
47
|
+
// Start with class TSDoc and declaration (without body)
|
|
48
|
+
const classSignature = `${classNode.getText({ includeJsDocComments: false }).split('{')[0].trim()} {`;
|
|
49
|
+
let pageContent = `${docComment}\n${classSignature}`;
|
|
50
|
+
// Add constructor with TSDoc if present
|
|
51
|
+
const constructorNode = classNode.getConstructors()[0]; // Get the first constructor (if any)
|
|
52
|
+
if (constructorNode) {
|
|
53
|
+
const constructorDocCommentRange = constructorNode
|
|
54
|
+
.getLeadingCommentRanges()
|
|
55
|
+
.find((range) => range.getText().startsWith('/**'));
|
|
56
|
+
if (constructorDocCommentRange) {
|
|
57
|
+
const constructorDocComment = constructorDocCommentRange.getText();
|
|
58
|
+
const constructorSignature = constructorNode
|
|
59
|
+
.getText({ includeJsDocComments: false })
|
|
60
|
+
.split('{')[0]
|
|
61
|
+
.trim();
|
|
62
|
+
pageContent += `\n ${constructorDocComment}\n ${constructorSignature}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Add public methods and properties with TSDoc
|
|
66
|
+
const publicMembers = [
|
|
67
|
+
...classNode.getMethods().filter((m) => m.hasModifier(SyntaxKind.PublicKeyword)),
|
|
68
|
+
...classNode.getProperties().filter((p) => p.hasModifier(SyntaxKind.PublicKeyword)),
|
|
69
|
+
];
|
|
70
|
+
publicMembers.forEach((member) => {
|
|
71
|
+
const memberDocCommentRange = member
|
|
72
|
+
.getLeadingCommentRanges()
|
|
73
|
+
.find((range) => range.getText().startsWith('/**'));
|
|
74
|
+
if (memberDocCommentRange) {
|
|
75
|
+
const memberDocComment = memberDocCommentRange.getText();
|
|
76
|
+
let memberSignature = '';
|
|
77
|
+
if (member.getKind() === SyntaxKind.MethodDeclaration) {
|
|
78
|
+
memberSignature = member
|
|
79
|
+
.getText({ includeJsDocComments: false })
|
|
80
|
+
.split('{')[0]
|
|
81
|
+
.trim();
|
|
82
|
+
}
|
|
83
|
+
else if (member.getKind() === SyntaxKind.PropertyDeclaration) {
|
|
84
|
+
memberSignature = member
|
|
85
|
+
.getText({ includeJsDocComments: false })
|
|
86
|
+
.trim();
|
|
87
|
+
}
|
|
88
|
+
pageContent += `\n ${memberDocComment}\n ${memberSignature}`;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
pageContent += '\n}';
|
|
92
|
+
return createTypescriptDocument(sourceFile, pageContent, classNode.getKindName(), className, _options);
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Extracts a TSDoc document from a single node.
|
|
96
|
+
* @param node - The TypeScript node to process.
|
|
97
|
+
* @param sourceFile - The source file containing the node.
|
|
98
|
+
* @param options - Optional parsing configuration.
|
|
99
|
+
* @param nodeOptions - Optional node-specific configuration (e.g., skipKindCheck for VariableStatement).
|
|
100
|
+
* @returns A TypeScript document with TSDoc metadata, or null if no TSDoc is found.
|
|
101
|
+
*/
|
|
102
|
+
export const extractDocumentFromNode = (node, sourceFile, options, nodeOptions) => {
|
|
103
|
+
const kind = node.getKind();
|
|
104
|
+
// Skip if not in our target kinds unless skipKindCheck is true
|
|
105
|
+
if (!nodeOptions?.skipKindCheck && !nodeKinds.includes(kind)) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
// Handle ClassDeclaration separately
|
|
109
|
+
if (kind === SyntaxKind.ClassDeclaration) {
|
|
110
|
+
return extractDocumentFromClassNode(node, sourceFile, options);
|
|
111
|
+
}
|
|
112
|
+
// Handle VariableStatement (e.g., `export const bundleApp = ...`)
|
|
113
|
+
if (kind === SyntaxKind.VariableStatement) {
|
|
114
|
+
const declaration = node
|
|
115
|
+
.getDeclarations()
|
|
116
|
+
.find((d) => d.getKind() === SyntaxKind.VariableDeclaration);
|
|
117
|
+
if (!declaration) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const initializer = declaration.getInitializer();
|
|
121
|
+
if (!initializer ||
|
|
122
|
+
!(initializer.getKind() === SyntaxKind.ArrowFunction ||
|
|
123
|
+
initializer.getKind() === SyntaxKind.FunctionExpression)) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
// Get the TSDoc comment from the VariableStatement
|
|
127
|
+
const docCommentRange = node
|
|
128
|
+
.getLeadingCommentRanges()
|
|
129
|
+
.find((range) => range.getText().startsWith('/**'));
|
|
130
|
+
if (!docCommentRange) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const nodeName = declaration.getName() || 'missing_name_of_node';
|
|
134
|
+
const docComment = docCommentRange.getText();
|
|
135
|
+
// Only include the TSDoc comment for functions/lambdas
|
|
136
|
+
return createTypescriptDocument(sourceFile, docComment, initializer.getKindName(), nodeName, options);
|
|
137
|
+
}
|
|
138
|
+
// Get name if node has one
|
|
139
|
+
const nodeName = Node.hasName(node) ? node.getName() : 'missing_name_of_node';
|
|
140
|
+
// Find TSDoc comment (/** ... */)
|
|
141
|
+
const docCommentRange = node
|
|
142
|
+
.getLeadingCommentRanges()
|
|
143
|
+
.find((range) => range.getText().startsWith('/**'));
|
|
144
|
+
if (!docCommentRange) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const docComment = docCommentRange.getText();
|
|
148
|
+
let pageContent = docComment;
|
|
149
|
+
// For interfaces and type aliases, include the full code
|
|
150
|
+
if (kind === SyntaxKind.InterfaceDeclaration || kind === SyntaxKind.TypeAliasDeclaration) {
|
|
151
|
+
pageContent = `${docComment}\n${node.getText()}`;
|
|
152
|
+
}
|
|
153
|
+
// For other nodes (e.g., FunctionDeclaration), include only TSDoc
|
|
154
|
+
else if (kind !== SyntaxKind.FunctionDeclaration) {
|
|
155
|
+
return null; // Skip unsupported kinds
|
|
156
|
+
}
|
|
157
|
+
return createTypescriptDocument(sourceFile, pageContent, node.getKindName(), nodeName, options);
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Processes a TypeScript source file to extract TSDoc documents.
|
|
161
|
+
* @param sourceFile - The source file to process.
|
|
162
|
+
* @param options - Optional parsing configuration.
|
|
163
|
+
* @returns An array of TypeScript documents with TSDoc metadata.
|
|
164
|
+
*/
|
|
165
|
+
export const processSourceFile = (sourceFile, options) => {
|
|
166
|
+
const documents = [];
|
|
167
|
+
sourceFile.forEachDescendant((node) => {
|
|
168
|
+
const document = extractDocumentFromNode(node, sourceFile, options);
|
|
169
|
+
if (document) {
|
|
170
|
+
documents.push(document);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return documents;
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=extractors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractors.js","sourceRoot":"","sources":["../../../../src/utils/ts-doc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uB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QACpE,IAAI,QAAQ,EAAE,CAAC;YACb,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/ts-doc/index.ts"],"names":[],"mappings":"AAGA,6BAA6B;AAC7B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { assert } from 'node:console';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { Project } from 'ts-morph';
|
|
4
|
+
import { processSourceFile } from './extractors.js';
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a file is a TypeScript or TSX file based on its extension.
|
|
7
|
+
* @param filePath - The path to the file.
|
|
8
|
+
* @returns True if the file ends with .ts or .tsx, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export const isTypescriptFile = (filePath) => {
|
|
11
|
+
return filePath.endsWith('.ts') || filePath.endsWith('.tsx');
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Parses TSDoc from a string of TypeScript code.
|
|
15
|
+
* @param content - The TypeScript code content.
|
|
16
|
+
* @param options - Optional parsing configuration.
|
|
17
|
+
* @returns An array of TypeScript documents with TSDoc metadata.
|
|
18
|
+
*/
|
|
19
|
+
export const parseTsDocSync = (content, options) => {
|
|
20
|
+
const project = new Project({ useInMemoryFileSystem: true });
|
|
21
|
+
const sourceFile = project.createSourceFile('temp.ts', content);
|
|
22
|
+
return processSourceFile(sourceFile, options);
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Parses TSDoc from a TypeScript file by path.
|
|
26
|
+
* @param file - The source file object.
|
|
27
|
+
* @param options - Optional parsing configuration.
|
|
28
|
+
* @returns An array of TypeScript documents with TSDoc metadata.
|
|
29
|
+
* @throws If the file is not a TypeScript file.
|
|
30
|
+
*/
|
|
31
|
+
export const parseTsDocFromFileSync = (file, options) => {
|
|
32
|
+
assert(isTypescriptFile(file.path), `File ${file.path} is not a TypeScript file`);
|
|
33
|
+
const project = new Project({ useInMemoryFileSystem: true });
|
|
34
|
+
const sourceFile = project.createSourceFile(file.relativePath ?? file.path, readFileSync(file.path, 'utf8'));
|
|
35
|
+
return processSourceFile(sourceFile, options);
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../src/utils/ts-doc/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,QAAgB,EAAW,EAAE;IAC5D,OAAO,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAAe,EACf,OAA2B,EACL,EAAE;IACxB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,IAAgB,EAChB,OAA2B,EACL,EAAE;IACxB,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,IAAI,CAAC,IAAI,2BAA2B,CAAC,CAAC;IAClF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CACzC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,EAC9B,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAChC,CAAC;IACF,OAAO,iBAAiB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/utils/ts-doc/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|