@open-norantec/herbal 1.0.2-alpha.29 → 1.0.2-alpha.30

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.
@@ -43,7 +43,6 @@ var _ = require("lodash");
43
43
  var fs = require("fs-extra");
44
44
  var path = require("node:path");
45
45
  var requireFromString = require("require-from-string");
46
- var reflect_declaration_1 = require("../transformers/reflect-declaration");
47
46
  var command = new commander_1.Command('herbal');
48
47
  var log = function (level) {
49
48
  var _a, _b;
@@ -196,11 +195,6 @@ command
196
195
  watch: false,
197
196
  executeAfterBuild: false,
198
197
  obfuscate: false,
199
- customTransformers: function (program) {
200
- return {
201
- before: [(0, reflect_declaration_1.transformer)(program)],
202
- };
203
- },
204
198
  getWatcher: handleGetWatcher,
205
199
  onGetFileContent: handleGetFileContent,
206
200
  onOutputFile: createHandleOutputFile(false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-norantec/herbal",
3
- "version": "1.0.2-alpha.29",
3
+ "version": "1.0.2-alpha.30",
4
4
  "description": "Herbal is a builder and toolchain for Nest.js applications",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,3 +0,0 @@
1
- import * as ts from 'typescript';
2
- export declare const DECORATOR_NAME_PREFIX = "\u03A6nt:method:";
3
- export declare function transformer(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.transformer = exports.DECORATOR_NAME_PREFIX = void 0;
13
- var ts = require("typescript");
14
- exports.DECORATOR_NAME_PREFIX = 'Φnt:method:';
15
- function transformer(program) {
16
- var checker = program.getTypeChecker();
17
- return function () {
18
- return function (sourceFile) {
19
- var newStatements = [];
20
- var visitNode = function (node) {
21
- var _a;
22
- if (ts.isClassDeclaration(node) && node.name) {
23
- var className = node.name.text;
24
- for (var _i = 0, _b = node.members; _i < _b.length; _i++) {
25
- var member = _b[_i];
26
- if (!ts.isPropertyDeclaration(member) || !member.name)
27
- continue;
28
- if (!ts.isIdentifier(member.name))
29
- continue;
30
- var propName = member.name.text;
31
- var symbol = checker.getSymbolAtLocation(member.name);
32
- if (!symbol)
33
- continue;
34
- var type = checker.getTypeOfSymbolAtLocation(symbol, member);
35
- var callSignatures = type.getCallSignatures();
36
- if (callSignatures.length === 0)
37
- continue;
38
- var returnType = callSignatures[0].getReturnType();
39
- var actualType = returnType;
40
- if (((_a = returnType.symbol) === null || _a === void 0 ? void 0 : _a.getName()) === 'Promise') {
41
- var typeArgs = returnType.typeArguments;
42
- if (typeArgs && typeArgs.length > 0) {
43
- actualType = typeArgs[0];
44
- }
45
- }
46
- var actualTypeStr = checker.typeToString(actualType, undefined, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.UseFullyQualifiedType);
47
- if (!actualTypeStr || actualTypeStr === 'void' || actualTypeStr === 'any')
48
- continue;
49
- newStatements.push(ts.factory.createExpressionStatement(ts.factory.createCallExpression(ts.factory.createIdentifier('Reflect.defineMetadata'), undefined, [
50
- ts.factory.createStringLiteral("".concat(exports.DECORATOR_NAME_PREFIX).concat(propName)),
51
- ts.factory.createStringLiteral(actualTypeStr),
52
- ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(className), ts.factory.createIdentifier('prototype')),
53
- ])));
54
- }
55
- }
56
- ts.forEachChild(node, visitNode);
57
- };
58
- ts.forEachChild(sourceFile, visitNode);
59
- return ts.factory.updateSourceFile(sourceFile, __spreadArray(__spreadArray([], sourceFile.statements, true), newStatements, true));
60
- };
61
- };
62
- }
63
- exports.transformer = transformer;