ts-morph-extensions 2.24.0-alpha.3
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/README.md +49 -0
- package/dist/dto/decorator.d.ts +8 -0
- package/dist/dto/decorator.d.ts.map +1 -0
- package/dist/dto/decorator.js +36 -0
- package/dist/dto/decorator.js.map +1 -0
- package/dist/dto/graph.d.ts +20 -0
- package/dist/dto/graph.d.ts.map +1 -0
- package/dist/dto/graph.js +66 -0
- package/dist/dto/graph.js.map +1 -0
- package/dist/dto/identifier.d.ts +9 -0
- package/dist/dto/identifier.d.ts.map +1 -0
- package/dist/dto/identifier.js +23 -0
- package/dist/dto/identifier.js.map +1 -0
- package/dist/dto/parameter.d.ts +10 -0
- package/dist/dto/parameter.d.ts.map +1 -0
- package/dist/dto/parameter.js +19 -0
- package/dist/dto/parameter.js.map +1 -0
- package/dist/dto/provider.d.ts +28 -0
- package/dist/dto/provider.d.ts.map +1 -0
- package/dist/dto/provider.js +62 -0
- package/dist/dto/provider.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +15 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +28 -0
- package/dist/logger.js.map +1 -0
- package/dist/project/projectRegistry.d.ts +26 -0
- package/dist/project/projectRegistry.d.ts.map +1 -0
- package/dist/project/projectRegistry.js +130 -0
- package/dist/project/projectRegistry.js.map +1 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.d.ts +7 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.d.ts.map +1 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.js +72 -0
- package/dist/tsConfig/relativeToAbsolutePathConverter.js.map +1 -0
- package/dist/tsConfig/tsconfigParser.d.ts +35 -0
- package/dist/tsConfig/tsconfigParser.d.ts.map +1 -0
- package/dist/tsConfig/tsconfigParser.js +156 -0
- package/dist/tsConfig/tsconfigParser.js.map +1 -0
- package/dist/utils/dedupeSet.d.ts +5 -0
- package/dist/utils/dedupeSet.d.ts.map +1 -0
- package/dist/utils/dedupeSet.js +17 -0
- package/dist/utils/dedupeSet.js.map +1 -0
- package/dist/utils/fileSystem.d.ts +12 -0
- package/dist/utils/fileSystem.d.ts.map +1 -0
- package/dist/utils/fileSystem.js +73 -0
- package/dist/utils/fileSystem.js.map +1 -0
- package/dist/utils/objects.d.ts +2 -0
- package/dist/utils/objects.d.ts.map +1 -0
- package/dist/utils/objects.js +7 -0
- package/dist/utils/objects.js.map +1 -0
- package/dist/utils/ts/assertions.d.ts +3 -0
- package/dist/utils/ts/assertions.d.ts.map +1 -0
- package/dist/utils/ts/assertions.js +9 -0
- package/dist/utils/ts/assertions.js.map +1 -0
- package/dist/utils/ts/decorators.d.ts +8 -0
- package/dist/utils/ts/decorators.d.ts.map +1 -0
- package/dist/utils/ts/decorators.js +42 -0
- package/dist/utils/ts/decorators.js.map +1 -0
- package/dist/utils/ts/identifier.d.ts +3 -0
- package/dist/utils/ts/identifier.d.ts.map +1 -0
- package/dist/utils/ts/identifier.js +14 -0
- package/dist/utils/ts/identifier.js.map +1 -0
- package/dist/utils/ts/providers.d.ts +6 -0
- package/dist/utils/ts/providers.d.ts.map +1 -0
- package/dist/utils/ts/providers.js +29 -0
- package/dist/utils/ts/providers.js.map +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasDecorator = hasDecorator;
|
|
4
|
+
exports.getDecorator = getDecorator;
|
|
5
|
+
exports.hasParentWithDecorator = hasParentWithDecorator;
|
|
6
|
+
exports.hasGraphDecorator = hasGraphDecorator;
|
|
7
|
+
exports.getDecoratedMethods = getDecoratedMethods;
|
|
8
|
+
const decorator_1 = require("../../dto/decorator");
|
|
9
|
+
const ts_morph_1 = require("ts-morph");
|
|
10
|
+
function hasDecorator(node, decoratorNames) {
|
|
11
|
+
return getDecorator(node, decoratorNames) !== undefined;
|
|
12
|
+
}
|
|
13
|
+
function getDecorator(node, decoratorNames) {
|
|
14
|
+
if (!node?.getDecorators())
|
|
15
|
+
return undefined;
|
|
16
|
+
for (const decorator of node.getDecorators()) {
|
|
17
|
+
const decoratorName = decorator.getExpression().getChildren()[0].getText();
|
|
18
|
+
if (decoratorNames.includes(decoratorName)) {
|
|
19
|
+
return new decorator_1.Decorator(decorator);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function hasParentWithDecorator(node, decoratorNames) {
|
|
24
|
+
const parent = node?.getParent();
|
|
25
|
+
if (!parent)
|
|
26
|
+
return false;
|
|
27
|
+
if (ts_morph_1.Node.isMethodDeclaration(parent) && hasDecorator(parent, decoratorNames))
|
|
28
|
+
return true;
|
|
29
|
+
return hasParentWithDecorator(parent, decoratorNames);
|
|
30
|
+
}
|
|
31
|
+
function hasGraphDecorator(node) {
|
|
32
|
+
if (node?.getKind() !== ts_morph_1.SyntaxKind.ClassDeclaration)
|
|
33
|
+
return false;
|
|
34
|
+
return hasDecorator(node, ['Graph', 'graph']);
|
|
35
|
+
}
|
|
36
|
+
function getDecoratedMethods(node, decoratorNames) {
|
|
37
|
+
return node
|
|
38
|
+
.getDescendants()
|
|
39
|
+
.filter(ts_morph_1.Node.isMethodDeclaration)
|
|
40
|
+
.filter(method => hasDecorator(method, decoratorNames));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../src/utils/ts/decorators.ts"],"names":[],"mappings":";;AAGA,oCAEC;AAED,oCAQC;AAED,wDAKC;AAED,8CAGC;AAED,kDAKC;AAlCD,mDAAgD;AAChD,uCAAiF;AAEjF,SAAgB,YAAY,CAAC,IAAmC,EAAE,cAAwB;IACxF,OAAO,YAAY,CAAC,I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AAc,CAAC,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier.d.ts","sourceRoot":"","sources":["../../../src/utils/ts/identifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,UAAU,gDAOpE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDefinition = getDefinition;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
function getDefinition(node, declarationKind) {
|
|
6
|
+
if (!ts_morph_1.Node.isIdentifier(node))
|
|
7
|
+
return;
|
|
8
|
+
for (const definition of node.getDefinitionNodes()) {
|
|
9
|
+
if (definition.getKind() === declarationKind) {
|
|
10
|
+
return definition;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifier.js","sourceRoot":"","sources":["../../../src/utils/ts/identifier.ts"],"names":[],"mappings":";;AAEA,sCAOC;AATD,uCAA4C;AAE5C,SAAgB,aAAa,CAAC,IAAU,EAAE,eAA2B;IACnE,IAAI,CAAC,eAAI,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO;IACrC,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;QACnD,IAAI,UAAU,CAAC,OAAO,EAAE,KAAK,eAAe,EAAE,CAAC;YAC7C,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Node, ArrowFunction, FunctionTypeNode } from "ts-morph";
|
|
2
|
+
import { Provider } from "../../dto/provider";
|
|
3
|
+
export declare function getHookDeclaration(node: ArrowFunction): Node<import("ts-morph").ts.Node> | undefined;
|
|
4
|
+
export declare function getHookDecarationFromTypedProvider(node: FunctionTypeNode): Node<import("ts-morph").ts.Node> | undefined;
|
|
5
|
+
export declare function getAncestorProvider(node: Node | undefined): Provider | undefined;
|
|
6
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../src/utils/ts/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,gBAAgB,EAAc,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAI9C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,gDAKrD;AAED,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,gBAAgB,gDAMxE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAKhF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHookDeclaration = getHookDeclaration;
|
|
4
|
+
exports.getHookDecarationFromTypedProvider = getHookDecarationFromTypedProvider;
|
|
5
|
+
exports.getAncestorProvider = getAncestorProvider;
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
const provider_1 = require("../../dto/provider");
|
|
8
|
+
const decorators_1 = require("./decorators");
|
|
9
|
+
const identifier_1 = require("./identifier");
|
|
10
|
+
function getHookDeclaration(node) {
|
|
11
|
+
const body = node.getBody();
|
|
12
|
+
if (ts_morph_1.Node.isCallExpression(body)) {
|
|
13
|
+
return (0, identifier_1.getDefinition)(body.getExpression(), ts_morph_1.SyntaxKind.VariableDeclaration);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function getHookDecarationFromTypedProvider(node) {
|
|
17
|
+
const typeReference = node.getChildrenOfKind(ts_morph_1.SyntaxKind.TypeReference)[0];
|
|
18
|
+
const arg = typeReference.getTypeArguments()[0];
|
|
19
|
+
if (ts_morph_1.Node.isTypeQuery(arg)) {
|
|
20
|
+
return (0, identifier_1.getDefinition)(arg.getExprName(), ts_morph_1.SyntaxKind.VariableDeclaration);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getAncestorProvider(node) {
|
|
24
|
+
const parent = node?.getFirstAncestorByKind(ts_morph_1.SyntaxKind.MethodDeclaration);
|
|
25
|
+
if (parent && (0, decorators_1.hasDecorator)(parent, ['provides', 'Provides'])) {
|
|
26
|
+
return new provider_1.Provider(parent);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/utils/ts/providers.ts"],"names":[],"mappings":";;AAKA,gDAKC;AAED,gFAMC;AAED,kDAKC;AAzBD,uCAA6E;AAC7E,iDAA8C;AAC9C,6CAA4C;AAC5C,6CAA6C;AAE7C,SAAgB,kBAAkB,CAAC,IAAmB;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC5B,IAAI,eAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,IAAA,0BAAa,EAAC,IAAI,CAAC,aAAa,EAAE,EAAE,qBAAU,CAAC,mBAAmB,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC;AAED,SAAgB,kCAAkC,CAAC,IAAsB;IACvE,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC,qBAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC;IAChD,IAAI,eAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAA,0BAAa,EAAC,GAAG,CAAC,WAAW,EAAE,EAAE,qBAAU,CAAC,mBAAmB,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAgB,mBAAmB,CAAC,IAAsB;IACxD,MAAM,MAAM,GAAG,IAAI,EAAE,sBAAsB,CAAC,qBAAU,CAAC,iBAAiB,CAAC,CAAC;IAC1E,IAAI,MAAM,IAAI,IAAA,yBAAY,EAAC,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,mBAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ts-morph-extensions",
|
|
3
|
+
"version": "2.24.0-alpha.3",
|
|
4
|
+
"description": "Extensions and utilities for working with ts-morph projects and TypeScript configurations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"build:watch": "tsc --watch",
|
|
10
|
+
"clean": "rm -rf dist",
|
|
11
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"jsonc-parser": "^3.2.1",
|
|
15
|
+
"ts-morph": "^25.0.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"ts-morph": "^25.0.1",
|
|
19
|
+
"typescript": "^5.0.0"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"license": "ISC"
|
|
25
|
+
}
|