@rxap/ts-morph 1.1.0-dev.2 → 1.1.0-dev.21
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 +147 -0
- package/README.md +1 -1
- package/package.json +6 -4
- package/src/index.d.ts +10 -0
- package/src/index.js +10 -0
- package/src/index.js.map +1 -1
- package/src/lib/angular/add-route.d.ts +4 -0
- package/src/lib/angular/add-route.js +59 -0
- package/src/lib/angular/add-route.js.map +1 -0
- package/src/lib/angular/build-route-object.d.ts +16 -0
- package/src/lib/angular/build-route-object.js +55 -0
- package/src/lib/angular/build-route-object.js.map +1 -0
- package/src/lib/angular/coerce-app-navigation.d.ts +12 -0
- package/src/lib/angular/coerce-app-navigation.js +55 -0
- package/src/lib/angular/coerce-app-navigation.js.map +1 -0
- package/src/lib/angular/coerce-app-routes.d.ts +4 -0
- package/src/lib/angular/coerce-app-routes.js +27 -0
- package/src/lib/angular/coerce-app-routes.js.map +1 -0
- package/src/lib/angular/coerce-component-import.d.ts +1 -1
- package/src/lib/angular/coerce-component-import.js +9 -7
- package/src/lib/angular/coerce-component-import.js.map +1 -1
- package/src/lib/angular/coerce-component-input.js +10 -10
- package/src/lib/angular/coerce-component-input.js.map +1 -1
- package/src/lib/angular/coerce-component.d.ts +1 -1
- package/src/lib/angular/coerce-component.js +15 -2
- package/src/lib/angular/coerce-component.js.map +1 -1
- package/src/lib/angular/coerce-layout-routes.d.ts +4 -0
- package/src/lib/angular/coerce-layout-routes.js +63 -0
- package/src/lib/angular/coerce-layout-routes.js.map +1 -0
- package/src/lib/angular/coerce-routes.d.ts +11 -0
- package/src/lib/angular/coerce-routes.js +35 -0
- package/src/lib/angular/coerce-routes.js.map +1 -0
- package/src/lib/angular/find-parent-route.d.ts +2 -0
- package/src/lib/angular/find-parent-route.js +54 -0
- package/src/lib/angular/find-parent-route.js.map +1 -0
- package/src/lib/angular/get-component-decorator-object.js +5 -5
- package/src/lib/angular/get-component-decorator-object.js.map +1 -1
- package/src/lib/coerce-array-element.js +6 -1
- package/src/lib/coerce-array-element.js.map +1 -1
- package/src/lib/coerce-decorator.js +5 -0
- package/src/lib/coerce-decorator.js.map +1 -1
- package/src/lib/coerce-default-class-export.d.ts +1 -1
- package/src/lib/coerce-default-class-export.js +3 -16
- package/src/lib/coerce-default-class-export.js.map +1 -1
- package/src/lib/coerce-default-export.d.ts +2 -0
- package/src/lib/coerce-default-export.js +14 -0
- package/src/lib/coerce-default-export.js.map +1 -0
- package/src/lib/coerce-dependency-injection.d.ts +1 -1
- package/src/lib/coerce-dependency-injection.js +36 -32
- package/src/lib/coerce-dependency-injection.js.map +1 -1
- package/src/lib/coerce-statements.d.ts +1 -1
- package/src/lib/coerce-statements.js +8 -3
- package/src/lib/coerce-statements.js.map +1 -1
- package/src/lib/data-property.d.ts +13 -6
- package/src/lib/data-property.js +50 -6
- package/src/lib/data-property.js.map +1 -1
- package/src/lib/find-function.js +1 -1
- package/src/lib/find-function.js.map +1 -1
- package/src/lib/identifier.d.ts +10 -0
- package/src/lib/identifier.js +16 -0
- package/src/lib/identifier.js.map +1 -0
- package/src/lib/nest/add-health-endpoint.js +1 -0
- package/src/lib/nest/add-health-endpoint.js.map +1 -1
- package/src/lib/nest/coerce-nest-cache-module-import.d.ts +4 -0
- package/src/lib/nest/coerce-nest-cache-module-import.js +25 -0
- package/src/lib/nest/coerce-nest-cache-module-import.js.map +1 -0
- package/src/lib/nest/coerce-nest-operation.d.ts +6 -5
- package/src/lib/nest/coerce-nest-operation.js +30 -26
- package/src/lib/nest/coerce-nest-operation.js.map +1 -1
- package/src/lib/nest/operation-id-utilities.d.ts +1 -1
- package/src/lib/nest/operation-id-utilities.js +3 -3
- package/src/lib/nest/operation-id-utilities.js.map +1 -1
- package/src/lib/type-import.d.ts +19 -4
- package/src/lib/type-import.js +33 -13
- package/src/lib/type-import.js.map +1 -1
- package/src/lib/upstream-options.d.ts +50 -6
- package/src/lib/upstream-options.js +70 -15
- package/src/lib/upstream-options.js.map +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoerceComponentInput = void 0;
|
|
4
|
-
const ts_morph_1 = require("
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
5
|
const coerce_accessor_declaration_1 = require("../coerce-accessor-declaration");
|
|
6
|
+
const coerce_decorator_1 = require("../coerce-decorator");
|
|
6
7
|
const coerce_imports_1 = require("../coerce-imports");
|
|
7
|
-
const ts_morph_2 = require("ts-morph");
|
|
8
8
|
const coerce_property_declaration_1 = require("../coerce-property-declaration");
|
|
9
9
|
const has_constructor_parameter_1 = require("../has-constructor-parameter");
|
|
10
|
-
const get_component_class_1 = require("./get-component-class");
|
|
11
10
|
const write_type_1 = require("../write-type");
|
|
11
|
+
const get_component_class_1 = require("./get-component-class");
|
|
12
12
|
function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initializer, alias, isRequired, asSetAccessor } = {}) {
|
|
13
|
-
const classDeclaration = sourceFileOrClassDeclaration instanceof
|
|
14
|
-
const sourceFile = sourceFileOrClassDeclaration instanceof
|
|
13
|
+
const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_1.ClassDeclaration ? sourceFileOrClassDeclaration : (0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration);
|
|
14
|
+
const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_1.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
|
|
15
15
|
if ((0, has_constructor_parameter_1.HasConstructorParameter)(classDeclaration, name, true)) {
|
|
16
16
|
throw new Error(`The component '${classDeclaration.getName()}' already has a constructor parameter that is a class member with the name '${name}'. Cannot add an input with the same name!`);
|
|
17
17
|
}
|
|
@@ -31,12 +31,12 @@ function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initia
|
|
|
31
31
|
if (isRequired) {
|
|
32
32
|
inputArgument['required'] = 'true';
|
|
33
33
|
}
|
|
34
|
-
inputDecoratorStructure.arguments = [
|
|
34
|
+
inputDecoratorStructure.arguments = [ts_morph_1.Writers.object(inputArgument)];
|
|
35
35
|
}
|
|
36
36
|
let propertyNode;
|
|
37
37
|
if (asSetAccessor) {
|
|
38
38
|
propertyNode = (0, coerce_accessor_declaration_1.CoerceSetAccessorDeclaration)(classDeclaration, name, { statements: `this._${name} = ${name};` }).set({
|
|
39
|
-
scope:
|
|
39
|
+
scope: ts_morph_1.Scope.Public,
|
|
40
40
|
parameters: [
|
|
41
41
|
{
|
|
42
42
|
name: name,
|
|
@@ -44,7 +44,7 @@ function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initia
|
|
|
44
44
|
},
|
|
45
45
|
],
|
|
46
46
|
});
|
|
47
|
-
(0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, '_' + name, { scope:
|
|
47
|
+
(0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, '_' + name, { scope: ts_morph_1.Scope.Private }).set({
|
|
48
48
|
type: (0, write_type_1.WriteType)(type, sourceFile),
|
|
49
49
|
initializer: initializer,
|
|
50
50
|
hasQuestionToken: !initializer && !isRequired,
|
|
@@ -53,14 +53,14 @@ function CoerceComponentInput(sourceFileOrClassDeclaration, name, type, { initia
|
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
propertyNode = (0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, name).set({
|
|
56
|
-
scope:
|
|
56
|
+
scope: ts_morph_1.Scope.Public,
|
|
57
57
|
type: (0, write_type_1.WriteType)(type, sourceFile),
|
|
58
58
|
initializer,
|
|
59
59
|
hasQuestionToken: !initializer && !isRequired,
|
|
60
60
|
hasExclamationToken: !initializer && isRequired,
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
(0,
|
|
63
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyNode, 'Input', inputDecoratorStructure);
|
|
64
64
|
return propertyNode;
|
|
65
65
|
}
|
|
66
66
|
exports.CoerceComponentInput = CoerceComponentInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-component-input.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-input.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"coerce-component-input.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component-input.ts"],"names":[],"mappings":";;;AAAA,uCAYkB;AAClB,gFAA8E;AAC9E,0DAAsD;AACtD,sDAAkD;AAClD,gFAA2E;AAC3E,4EAAuE;AAEvE,8CAA0C;AAC1C,+DAA0D;AAoD1D,SAAgB,oBAAoB,CAClC,4BAA2D,EAC3D,IAAY,EACZ,IAA0C,EAC1C,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,aAAa,KAA+B,EAAE;IAGhF,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,2BAAgB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAA,uCAAiB,EAAC,4BAA4B,CAAC,CAAC;IACnK,MAAM,UAAU,GAAG,4BAA4B,YAAY,qBAAU,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,4BAA4B,CAAC,aAAa,EAAE,CAAC;IAEpJ,IAAI,IAAA,mDAAuB,EAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QACzD,MAAM,IAAI,KAAK,CAAC,kBAAkB,gBAAgB,CAAC,OAAO,EAAG,+EAAgF,IAAK,4CAA4C,CAAC,CAAC;KACjM;IAED,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB,YAAY,EAAE,CAAE,OAAO,CAAE;QACzB,eAAe,EAAE,eAAe;KACjC,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAqC;QAChE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE,EAAE;KACd,CAAC;IAEF,IAAI,KAAK,IAA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AAE,UAAU,CAAC;YACjC,WAAW;YACX,gBAAgB,EAAE,CAAC,WAAW,IAAI,CAAC,UAAU;YAC7C,mBAAmB,EAAE,CAAC,WAAW,IAAI,UAAU;SAChD,CAAC,CAAC;KAEJ;IAED,IAAA,kCAAe,EAAC,YAAY,EAAE,OAAO,EAAE,uBAAuB,CAAC,CAAC;IAEhE,OAAO,YAAY,CAAC;AAEtB,CAAC;AAxED,oDAwEC"}
|
|
@@ -11,7 +11,18 @@ function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
|
|
|
11
11
|
const className = (0, utilities_1.classify)((0, utilities_1.CoerceSuffix)((0, utilities_1.dasherize)(name), '-component'));
|
|
12
12
|
const { prefix, changeDetection, } = options;
|
|
13
13
|
let { selector, template, templateUrl, styles, styleUrls, } = options;
|
|
14
|
-
|
|
14
|
+
if (selector !== false) {
|
|
15
|
+
selector !== null && selector !== void 0 ? selector : (selector = prefix ? `${prefix}-${(0, utilities_1.dasherize)(name)}` : (0, utilities_1.dasherize)(name));
|
|
16
|
+
if (selector.includes('{{prefix}}')) {
|
|
17
|
+
if (!prefix) {
|
|
18
|
+
throw new Error(`The selector '${selector}' contains a template expression '{{prefix}}' but no prefix is provided`);
|
|
19
|
+
}
|
|
20
|
+
selector = selector.replace('{{prefix}}', prefix);
|
|
21
|
+
}
|
|
22
|
+
if (selector.match(/\{\{.*}}/)) {
|
|
23
|
+
throw new Error(`The selector '${selector}' contains an invalid templates expression`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
15
26
|
if (templateUrl === true || !template) {
|
|
16
27
|
template = undefined;
|
|
17
28
|
templateUrl = `./${(0, utilities_1.dasherize)(name)}.component.html`;
|
|
@@ -36,8 +47,10 @@ function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
|
|
|
36
47
|
const classDeclaration = (0, coerce_class_1.CoerceClass)(sourceFile, className, classStructure);
|
|
37
48
|
const componentOptions = {
|
|
38
49
|
standalone: 'true',
|
|
39
|
-
selector: w => w.quote(selector),
|
|
40
50
|
};
|
|
51
|
+
if (selector) {
|
|
52
|
+
componentOptions['selector'] = w => w.quote(selector);
|
|
53
|
+
}
|
|
41
54
|
if (changeDetection) {
|
|
42
55
|
componentOptions['changeDetection'] = `ChangeDetectionStrategy.${changeDetection}`;
|
|
43
56
|
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-component.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAOkB;AAClB,kDAA8C;AAC9C,0DAAsD;AACtD,sDAAkD;
|
|
1
|
+
{"version":3,"file":"coerce-component.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component.ts"],"names":[],"mappings":";;;AAAA,+CAIyB;AACzB,uCAOkB;AAClB,kDAA8C;AAC9C,0DAAsD;AACtD,sDAAkD;AAkBlD,SAAgB,eAAe,CAC7B,UAAsB,EACtB,IAAY,EACZ,UAAkC,EAAE,EACpC,iBAAwE,EAAE;;IAE1E,MAAM,SAAS,GAAG,IAAA,oBAAQ,EAAC,IAAA,wBAAY,EAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;IACxE,MAAM,EACJ,MAAM,EACN,eAAe,GAChB,GAAG,OAAO,CAAC;IACZ,IAAI,EACF,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,MAAM,EACN,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,IAAI,QAAQ,KAAK,KAAK,EAAE;QACtB,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,MAAM,CAAC,CAAC,CAAC,GAAI,MAAO,IAAK,IAAA,qBAAS,EAAC,IAAI,CAAE,EAAE,CAAC,CAAC,CAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,EAAC;QAC3E,IAAI,QAAQ,CAAC,QAAQ,C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AAC;IACjF,IAAI,CAAC,wBAAwB,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,4DAA6D,SAAU,GAAG,CAAC,CAAC;KAC7F;IACD,IAAI,CAAC,CAAC,wBAAwB,YAAY,kCAAuB,CAAC,EAAE;QAClE,MAAM,IAAI,KAAK,CAAC,6CAA8C,SAAU,uCAAuC,CAAC,CAAC;KAClH;IAED,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;AACxD,CAAC;AAxGD,0CAwGC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SourceFile } from 'ts-morph';
|
|
2
|
+
import { CoerceRoutesOptions } from './coerce-routes';
|
|
3
|
+
export type CoerceLayoutRoutesOptions = CoerceRoutesOptions;
|
|
4
|
+
export declare function CoerceLayoutRoutes(sourceFile: SourceFile, options?: CoerceLayoutRoutesOptions): import("ts-morph").VariableDeclaration;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceLayoutRoutes = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
6
|
+
const coerce_routes_1 = require("./coerce-routes");
|
|
7
|
+
function CoerceLayoutRoutes(sourceFile, options = {}) {
|
|
8
|
+
var _a;
|
|
9
|
+
const variableDeclaration = (0, coerce_routes_1.CoerceRoutes)(sourceFile, Object.assign(Object.assign({}, options), { initializer: (_a = options.initializer) !== null && _a !== void 0 ? _a : (w => {
|
|
10
|
+
w.writeLine('[');
|
|
11
|
+
w.indent(() => {
|
|
12
|
+
ts_morph_1.Writers.object({
|
|
13
|
+
path: w => w.quote(''),
|
|
14
|
+
component: 'LayoutComponent',
|
|
15
|
+
canActivateChild: '[StatusCheckGuard]',
|
|
16
|
+
children: w => {
|
|
17
|
+
w.writeLine('[');
|
|
18
|
+
w.indent(() => {
|
|
19
|
+
ts_morph_1.Writers.object({
|
|
20
|
+
path: w => w.quote('**'),
|
|
21
|
+
redirectTo: w => w.quote('')
|
|
22
|
+
})(w);
|
|
23
|
+
});
|
|
24
|
+
w.write(']');
|
|
25
|
+
},
|
|
26
|
+
providers: w => {
|
|
27
|
+
w.write('[');
|
|
28
|
+
w.indent(() => {
|
|
29
|
+
w.write('APP_NAVIGATION_PROVIDER');
|
|
30
|
+
w.write(',');
|
|
31
|
+
w.newLine();
|
|
32
|
+
w.write('NavigationService');
|
|
33
|
+
});
|
|
34
|
+
w.write(']');
|
|
35
|
+
}
|
|
36
|
+
})(w);
|
|
37
|
+
w.write(',');
|
|
38
|
+
});
|
|
39
|
+
ts_morph_1.Writers.object({
|
|
40
|
+
path: w => w.quote('**'),
|
|
41
|
+
redirectTo: w => w.quote('')
|
|
42
|
+
})(w);
|
|
43
|
+
w.newLine();
|
|
44
|
+
w.write(']');
|
|
45
|
+
}) }));
|
|
46
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, [
|
|
47
|
+
{
|
|
48
|
+
namedImports: ['LayoutComponent', 'NavigationService'],
|
|
49
|
+
moduleSpecifier: '@rxap/layout'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
namedImports: ['StatusCheckGuard'],
|
|
53
|
+
moduleSpecifier: '@rxap/ngx-status-check'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
namedImports: ['APP_NAVIGATION_PROVIDER'],
|
|
57
|
+
moduleSpecifier: './app.navigation'
|
|
58
|
+
}
|
|
59
|
+
]);
|
|
60
|
+
return variableDeclaration;
|
|
61
|
+
}
|
|
62
|
+
exports.CoerceLayoutRoutes = CoerceLayoutRoutes;
|
|
63
|
+
//# sourceMappingURL=coerce-layout-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-layout-routes.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-layout-routes.ts"],"names":[],"mappings":";;;AAAA,uCAGkB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,CAAC,CAAC;wBAC/B,CAAC,CAAC,CAAC;wBACH,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBACf,CAAC;iBACF,CAAC,CAAC,CAAC,CAAC,CAAC;gBACN,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;YAEH,kBAAO,CAAC,MAAM,CAAC;gBACb,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;gBACxB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;aAC7B,CAAC,CAAC,CAAC,CAAC,CAAC;YACN,CAAC,CAAC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACf,CAAC,CAAC,IACF,CAAC;IAEH,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB;YACE,YAAY,EAAE,CAAE,iBAAiB,EAAE,mBAAmB,CAAE;YACxD,eAAe,EAAE,cAAc;SAChC;QACD;YACE,YAAY,EAAE,CAAE,kBAAkB,CAAE;YACpC,eAAe,EAAE,wBAAwB;SAC1C;QACD;YACE,YAAY,EAAE,CAAE,yBAAyB,CAAE;YAC3C,eAAe,EAAE,kBAAkB;SACpC;KACF,CAAC,CAAC;IAEH,OAAO,mBAAmB,CAAC;AAE7B,CAAC;AA7DD,gDA6DC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SourceFile, WriterFunction } from 'ts-morph';
|
|
2
|
+
import { AngularRoute } from './build-route-object';
|
|
3
|
+
export interface CoerceRoutesOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
initializer?: string | WriterFunction;
|
|
6
|
+
itemList?: Array<{
|
|
7
|
+
route: AngularRoute;
|
|
8
|
+
path?: string[];
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare function CoerceRoutes(sourceFile: SourceFile, options?: CoerceRoutesOptions): import("ts-morph").VariableDeclaration;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceRoutes = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const coerce_default_export_1 = require("../coerce-default-export");
|
|
6
|
+
const coerce_imports_1 = require("../coerce-imports");
|
|
7
|
+
const coerce_variable_declaration_1 = require("../coerce-variable-declaration");
|
|
8
|
+
const add_route_1 = require("./add-route");
|
|
9
|
+
function CoerceRoutes(sourceFile, options = {}) {
|
|
10
|
+
var _a;
|
|
11
|
+
const { name = 'ROUTES', initializer = `[{ path: '**', redirectTo: '' }]` } = options;
|
|
12
|
+
// region remove a route declaration if the initializer is an empty array to ensure the initializer is set
|
|
13
|
+
let variableDeclaration = (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, name, { initializer: '[]', type: 'Route[]' });
|
|
14
|
+
if (variableDeclaration.getInitializerIfKindOrThrow(ts_morph_1.SyntaxKind.ArrayLiteralExpression).getElements().length === 0) {
|
|
15
|
+
variableDeclaration.getVariableStatementOrThrow().remove();
|
|
16
|
+
}
|
|
17
|
+
// endregion
|
|
18
|
+
variableDeclaration = (0, coerce_variable_declaration_1.CoerceVariableDeclaration)(sourceFile, name, {
|
|
19
|
+
initializer,
|
|
20
|
+
type: 'Route[]'
|
|
21
|
+
});
|
|
22
|
+
(0, coerce_default_export_1.CoerceDefaultExport)(variableDeclaration);
|
|
23
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, [
|
|
24
|
+
{
|
|
25
|
+
namedImports: ['Route'],
|
|
26
|
+
moduleSpecifier: '@angular/router'
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
for (const { route, path } of (_a = options.itemList) !== null && _a !== void 0 ? _a : []) {
|
|
30
|
+
(0, add_route_1.AddRoute)(sourceFile, route, path, name);
|
|
31
|
+
}
|
|
32
|
+
return variableDeclaration;
|
|
33
|
+
}
|
|
34
|
+
exports.CoerceRoutes = CoerceRoutes;
|
|
35
|
+
//# sourceMappingURL=coerce-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-routes.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-routes.ts"],"names":[],"mappings":";;;AAAA,uCAIkB;AAClB,oEAA+D;AAC/D,sDAAkD;AAClD,gFAA2E;AAC3E,2CAAuC;AASvC,SAAgB,YAAY,CAAC,UAAsB,EAAE,UAA+B,EAAE;;IAEpF,MAAM,EACJ,IAAI,GAAG,QAAQ,EACf,WAAW,GAAG,kCAAkC,EACjD,GAAG,OAAO,CAAC;IAEZ,0GAA0G;IAC1G,IAAI,mBAAmB,GAAG,IAAA,uDAAyB,EAAC,UAAU,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9G,IAAI,mBAAmB,CAAC,2BAA2B,CAAC,qBAAU,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;QACjH,mBAAmB,CAAC,2BAA2B,EAAE,CAAC,MAAM,EAAE,CAAC;KAC5D;IACD,YAAY;IACZ,mBAAmB,GAAG,IAAA,uDAAyB,EAAC,UAAU,EAAE,IAAI,EAAE;QAChE,WAAW;QACX,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;IACH,IAAA,2CAAmB,EAAC,mBAAmB,CAAC,CAAC;IACzC,IAAA,8BAAa,EAAC,UAAU,EAAE;QACxB;YACE,YAAY,EAAE,CAAE,OAAO,CAAE;YACzB,eAAe,EAAE,iBAAiB;SACnC;KACF,CAAC,CAAC;IAEH,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,MAAA,OAAO,CAAC,QAAQ,mCAAI,EAAE,EAAE;QACpD,IAAA,oBAAQ,EAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KACzC;IAED,OAAO,mBAAmB,CAAC;AAE7B,CAAC;AA/BD,oCA+BC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindParentRoute = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
function FindParentRoute(ale, path) {
|
|
6
|
+
var _a;
|
|
7
|
+
for (const e of ale.getElements()) {
|
|
8
|
+
if (e instanceof ts_morph_1.ObjectLiteralExpression) {
|
|
9
|
+
const pathProperty = e.getProperty('path');
|
|
10
|
+
if (pathProperty && pathProperty instanceof ts_morph_1.PropertyAssignment) {
|
|
11
|
+
const initializer = pathProperty.getInitializerIfKind(ts_morph_1.SyntaxKind.StringLiteral);
|
|
12
|
+
if (initializer) {
|
|
13
|
+
const fragment = path.pop();
|
|
14
|
+
if (initializer.getLiteralText() === fragment) {
|
|
15
|
+
const childrenProperty = (_a = e.getProperty('children')) !== null && _a !== void 0 ? _a : e.addProperty({
|
|
16
|
+
name: 'children',
|
|
17
|
+
initializer: '[]',
|
|
18
|
+
kind: ts_morph_1.StructureKind.PropertyAssignment,
|
|
19
|
+
});
|
|
20
|
+
if (childrenProperty instanceof ts_morph_1.PropertyAssignment) {
|
|
21
|
+
const children = childrenProperty.getInitializerIfKindOrThrow(ts_morph_1.SyntaxKind.ArrayLiteralExpression);
|
|
22
|
+
if (path.length) {
|
|
23
|
+
// console.log('Continue search for parent route');
|
|
24
|
+
return FindParentRoute(children, path);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// console.log('Found parent route');
|
|
28
|
+
return children;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// console.log('Children property is not a PropertyAssignment');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// console.log('Path property does not match', initializer.getLiteralText(), fragment);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// console.log('Path property has no StringLiteral initializer');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// console.log('Element has no path property');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// console.log('Element is not an ObjectLiteralExpression');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
exports.FindParentRoute = FindParentRoute;
|
|
54
|
+
//# sourceMappingURL=find-parent-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-parent-route.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/find-parent-route.ts"],"names":[],"mappings":";;;AAAA,uCAMkB;AAElB,SAAgB,eAAe,CAAC,GAA2B,EAAE,IAAc;;IACzE,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,WAAW,EAAE,EAAE;QACjC,IAAI,CAAC,YAAY,kCAAuB,EAAE;YACxC,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC3C,IAAI,YAAY,IAAI,YAAY,YAAY,6BAAkB,EAAE;gBAC9D,MAAM,WAAW,GAAG,YAAY,CAAC,oBAAoB,CAAC,qBAAU,CAAC,aAAa,CAAC,CAAC;gBAChF,IAAI,WAAW,EAAE;oBACf,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;oBAC5B,IAAI,WAAW,CAAC,cAAc,EAAE,KAAK,QAAQ,EAAE;wBAC7C,MAAM,gBAAgB,GAAG,MAAA,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,mCAAI,CAAC,CAAC,WAAW,CAAC;4BAClE,IAAI,EAAE,UAAU;4BAChB,WAAW,EAAE,IAAI;4BACjB,IAAI,EAAE,wBAAa,CAAC,kBAAkB;yBACvC,CAAC,CAAC;wBACH,IAAI,gBAAgB,YAAY,6BAAkB,EAAE;4BAClD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,2BAA2B,CAAC,qBAAU,CAAC,sBAAsB,CAAC,CAAC;4BACjG,IAAI,IAAI,CAAC,MAAM,EAAE;gCACf,mDAAmD;gCACnD,OAAO,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;6BACxC;iCAAM;gCACL,qCAAqC;gCACrC,OAAO,QAAQ,CAAC;6BACjB;yBACF;6BAAM;4BACL,gEAAgE;yBACjE;qBACF;yBAAM;wBACL,uFAAuF;qBACxF;iBACF;qBAAM;oBACL,iEAAiE;iBAClE;aACF;iBAAM;gBACL,+CAA+C;aAChD;SACF;aAAM;YACL,4DAA4D;SAC7D;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAxCD,0CAwCC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetComponentDecoratorObject = void 0;
|
|
4
|
-
const ts_morph_1 = require("
|
|
5
|
-
const
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const get_component_class_1 = require("./get-component-class");
|
|
6
6
|
function GetComponentDecoratorObject(sourceFileOrClassDeclaration) {
|
|
7
|
-
const classDeclaration = sourceFileOrClassDeclaration instanceof
|
|
7
|
+
const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_1.ClassDeclaration ? sourceFileOrClassDeclaration : (0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration);
|
|
8
8
|
const componentDecorator = classDeclaration.getDecorator('Component');
|
|
9
9
|
let componentOptions = componentDecorator.getArguments()[0];
|
|
10
10
|
if (!componentOptions) {
|
|
11
|
-
componentOptions = componentDecorator.addArgument(
|
|
11
|
+
componentOptions = componentDecorator.addArgument(ts_morph_1.Writers.object({}));
|
|
12
12
|
}
|
|
13
|
-
if (!(componentOptions instanceof
|
|
13
|
+
if (!(componentOptions instanceof ts_morph_1.ObjectLiteralExpression)) {
|
|
14
14
|
throw new Error('The Component options is not an object literal expression');
|
|
15
15
|
}
|
|
16
16
|
return componentOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-component-decorator-object.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/get-component-decorator-object.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"get-component-decorator-object.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/get-component-decorator-object.ts"],"names":[],"mappings":";;;AAAA,uCAKkB;AAClB,+DAA0D;AAE1D,SAAgB,2BAA2B,CACzC,4BAA2D;IAG3D,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,2BAAgB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAA,uCAAiB,EAAC,4BAA4B,CAAC,CAAC;IAGnK,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,YAAY,CAAC,WAAW,CAAE,CAAC;IACvE,IAAI,gBAAgB,GAAG,kBAAkB,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAE5D,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,kBAAkB,CAAC,WAAW,CAAC,kBAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;KACvE;IAED,IAAI,CAAC,CAAC,gBAAgB,YAAY,kCAAuB,CAAC,EAAE;QAC1D,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;KAC9E;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAnBD,kEAmBC"}
|
|
@@ -36,7 +36,12 @@ function CoerceArrayElement(array, element, findExisting, insertAt) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
if (insertAt) {
|
|
39
|
-
|
|
39
|
+
const index = insertAt(array);
|
|
40
|
+
if (index < 0) {
|
|
41
|
+
console.warn('The insertAt function returned a negative index - normalizing to 0');
|
|
42
|
+
return array.insertElement(0, element);
|
|
43
|
+
}
|
|
44
|
+
return array.insertElement(index, element);
|
|
40
45
|
}
|
|
41
46
|
return array.addElement(element);
|
|
42
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-array-element.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-array-element.ts"],"names":[],"mappings":";;;AAAA,uCAOkB;AAElB,SAAgB,gCAAgC,CAAC,QAAgB,EAAE,KAAa;IAC9E,OAAO,CAAC,CAAa,EAAE,EAAE;QACvB,IAAI,CAAC,YAAY,kCAAuB,EAAE;YACxC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,YAAY,6BAAkB,EAAE;gBACxC,MAAM,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,qBAAU,CAAC,aAAa,CAAC,CAAC;gBAC3D,IAAI,CAAC,EAAE;oBACL,OAAO,CAAC,CAAC,cAAc,EAAE,KAAK,KAAK,CAAC;iBACrC;aACF;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAbD,4EAaC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,OAAO,CAAC;AAC3D,CAAC;AAFD,gEAEC;AAED,SAAgB,kBAAkB,CAChC,KAA6B,EAC7B,OAAgC,EAChC,YAAyC,EACzC,QAAoD;IAGpD,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;SACpD;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;SAC3F;KACF;IAED,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;QACnC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE;YACnB,OAAO,CAAC,CAAC;SACV;KACF;IAED,IAAI,QAAQ,EAAE;QACZ,OAAO,KAAK,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"coerce-array-element.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-array-element.ts"],"names":[],"mappings":";;;AAAA,uCAOkB;AAElB,SAAgB,gCAAgC,CAAC,QAAgB,EAAE,KAAa;IAC9E,OAAO,CAAC,CAAa,EAAE,EAAE;QACvB,IAAI,CAAC,YAAY,kCAAuB,EAAE;YACxC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,YAAY,6BAAkB,EAAE;gBACxC,MAAM,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,qBAAU,CAAC,aAAa,CAAC,CAAC;gBAC3D,IAAI,CAAC,EAAE;oBACL,OAAO,CAAC,CAAC,cAAc,EAAE,KAAK,KAAK,CAAC;iBACrC;aACF;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAbD,4EAaC;AAED,SAAgB,0BAA0B,CAAC,OAAe;IACxD,OAAO,CAAC,CAAa,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,OAAO,CAAC;AAC3D,CAAC;AAFD,gEAEC;AAED,SAAgB,kBAAkB,CAChC,KAA6B,EAC7B,OAAgC,EAChC,YAAyC,EACzC,QAAoD;IAGpD,IAAI,CAAC,YAAY,EAAE;QACjB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;SACpD;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,wEAAwE,CAAC,CAAC;SAC3F;KACF;IAED,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;QACnC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE;YACnB,OAAO,CAAC,CAAC;SACV;KACF;IAED,IAAI,QAAQ,EAAE;QACZ,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,KAAK,GAAG,CAAC,EAAE;YACb,OAAO,CAAC,IAAI,CAAC,oEAAoE,CAAC,CAAC;YACnF,OAAO,KAAK,CAAC,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SACxC;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;KAC5C;IAED,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAEnC,CAAC;AAhCD,gDAgCC"}
|
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CoerceDecorator = void 0;
|
|
4
4
|
const find_function_1 = require("./find-function");
|
|
5
5
|
function CoerceDecorator(decoratableNode, name, structure = {}, compareTo = find_function_1.FindByNameFunction) {
|
|
6
|
+
const match = name.match(/(.+)<(.+)>/);
|
|
7
|
+
if (match) {
|
|
8
|
+
name = match[1];
|
|
9
|
+
structure.typeArguments = match[2].split(',');
|
|
10
|
+
}
|
|
6
11
|
let decorator = decoratableNode.getDecorator(compareTo(Object.assign(Object.assign({}, structure), { name })));
|
|
7
12
|
if (!decorator) {
|
|
8
13
|
decorator = decoratableNode.addDecorator({ name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-decorator.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-decorator.ts"],"names":[],"mappings":";;;AAMA,mDAGyB;AAEzB,SAAgB,eAAe,CAC7B,eAAgC,EAChC,IAAY,EACZ,YAAqE,EAAE,EACvE,YAA4F,kCAAkB;IAE9G,IAAI,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,SAAS,iCACjD,SAAS,KACZ,IAAI,IACJ,CAAC,CAAC;IACJ,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KAC1B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"coerce-decorator.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-decorator.ts"],"names":[],"mappings":";;;AAMA,mDAGyB;AAEzB,SAAgB,eAAe,CAC7B,eAAgC,EAChC,IAAY,EACZ,YAAqE,EAAE,EACvE,YAA4F,kCAAkB;IAE9G,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACvC,IAAI,KAAK,EAAE;QACT,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,SAAS,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAC/C;IACD,IAAI,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,SAAS,iCACjD,SAAS,KACZ,IAAI,IACJ,CAAC,CAAC;IACJ,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KAC1B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AApBD,0CAoBC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ClassDeclaration, SourceFile } from 'ts-morph';
|
|
2
|
-
export declare function CoerceDefaultClassExport(sourceFileOrClassDeclaration: SourceFile | ClassDeclaration
|
|
2
|
+
export declare function CoerceDefaultClassExport(sourceFileOrClassDeclaration: SourceFile | ClassDeclaration): void;
|
|
@@ -2,26 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoerceDefaultClassExport = void 0;
|
|
4
4
|
const ts_morph_1 = require("ts-morph");
|
|
5
|
-
|
|
5
|
+
const coerce_default_export_1 = require("./coerce-default-export");
|
|
6
|
+
function CoerceDefaultClassExport(sourceFileOrClassDeclaration) {
|
|
6
7
|
const classDeclaration = sourceFileOrClassDeclaration instanceof ts_morph_1.SourceFile ? sourceFileOrClassDeclaration.getClasses().filter(cd => !cd.isDefaultExport())[0] : sourceFileOrClassDeclaration;
|
|
7
|
-
const sourceFile = sourceFileOrClassDeclaration instanceof ts_morph_1.SourceFile ? sourceFileOrClassDeclaration : sourceFileOrClassDeclaration.getSourceFile();
|
|
8
8
|
if (!ts_morph_1.ClassDeclaration) {
|
|
9
9
|
throw new Error('No class declaration');
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
console.log('standalone', sourceFile.getExportAssignments().map(ed => ed.getExpression().getText()));
|
|
13
|
-
if (!sourceFile.getExportAssignments().some(ed => ed.getExpression().getText() === classDeclaration.getName())) {
|
|
14
|
-
sourceFile.addExportAssignment({
|
|
15
|
-
isExportEquals: false,
|
|
16
|
-
expression: classDeclaration.getName(),
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
if (!sourceFile.getClasses().some(cd => cd.isDefaultExport() && cd.getName() === classDeclaration.getName())) {
|
|
22
|
-
classDeclaration.setIsDefaultExport(true);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
11
|
+
(0, coerce_default_export_1.CoerceDefaultExport)(classDeclaration);
|
|
25
12
|
}
|
|
26
13
|
exports.CoerceDefaultClassExport = CoerceDefaultClassExport;
|
|
27
14
|
//# sourceMappingURL=coerce-default-class-export.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-default-class-export.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-default-class-export.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;
|
|
1
|
+
{"version":3,"file":"coerce-default-class-export.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-default-class-export.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAClB,mEAA8D;AAE9D,SAAgB,wBAAwB,CAAC,4BAA2D;IAElG,MAAM,gBAAgB,GAAG,4BAA4B,YAAY,qBAAU,CAAC,CAAC,CAAC,4BAA4B,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC;IAE9L,IAAI,CAAC,2BAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;KACzC;IAED,IAAA,2CAAmB,EAAC,gBAAgB,CAAC,CAAC;AAExC,CAAC;AAVD,4DAUC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceDefaultExport = void 0;
|
|
4
|
+
function CoerceDefaultExport(node) {
|
|
5
|
+
const sourceFile = node.getSourceFile();
|
|
6
|
+
if (!sourceFile.getExportAssignments().some(ed => ed.getExpression().getText() === node.getName())) {
|
|
7
|
+
sourceFile.addExportAssignment({
|
|
8
|
+
isExportEquals: false,
|
|
9
|
+
expression: node.getName(),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.CoerceDefaultExport = CoerceDefaultExport;
|
|
14
|
+
//# sourceMappingURL=coerce-default-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-default-export.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-default-export.ts"],"names":[],"mappings":";;;AAMA,SAAgB,mBAAmB,CAAC,IAAgE;IAElG,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IAExC,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE;QAClG,UAAU,CAAC,mBAAmB,CAAC;YAC7B,cAAc,EAAE,KAAK;YACrB,UAAU,EAAE,IAAI,CAAC,OAAO,EAAG;SAC5B,CAAC,CAAC;KACJ;AAEH,CAAC;AAXD,kDAWC"}
|
|
@@ -9,6 +9,6 @@ export interface InjectionDefinition {
|
|
|
9
9
|
optional?: boolean;
|
|
10
10
|
type?: string;
|
|
11
11
|
scope?: Scope;
|
|
12
|
-
module
|
|
12
|
+
module: Module;
|
|
13
13
|
}
|
|
14
14
|
export declare function CoerceDependencyInjection(sourceFile: SourceFile, definition: InjectionDefinition, structures?: Array<OptionalKind<ImportDeclarationStructure>>): void;
|
|
@@ -2,55 +2,59 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoerceDependencyInjection = exports.Module = void 0;
|
|
4
4
|
const ts_morph_1 = require("ts-morph");
|
|
5
|
-
const
|
|
5
|
+
const coerce_decorator_1 = require("./coerce-decorator");
|
|
6
6
|
const coerce_imports_1 = require("./coerce-imports");
|
|
7
|
+
const coerce_property_declaration_1 = require("./coerce-property-declaration");
|
|
7
8
|
var Module;
|
|
8
9
|
(function (Module) {
|
|
9
10
|
Module["ANGULAR"] = "@angular/core";
|
|
10
11
|
Module["NEST"] = "@nestjs/common";
|
|
11
12
|
})(Module || (exports.Module = Module = {}));
|
|
12
13
|
function CoerceDependencyInjection(sourceFile, definition, structures = []) {
|
|
13
|
-
var _a, _b
|
|
14
|
-
if (!definition.module) {
|
|
15
|
-
definition.module = Module.ANGULAR;
|
|
16
|
-
}
|
|
14
|
+
var _a, _b;
|
|
17
15
|
const classDeclaration = sourceFile.getClasses()[0];
|
|
18
16
|
if (!classDeclaration) {
|
|
19
17
|
throw new Error('Could not find class declaration');
|
|
20
18
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
if (constructorDeclaration.getParameter(definition.parameterName)) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const constructorParameter = {
|
|
27
|
-
name: definition.parameterName,
|
|
28
|
-
type: (_a = definition.type) !== null && _a !== void 0 ? _a : definition.injectionToken,
|
|
29
|
-
scope: (_b = definition.scope) !== null && _b !== void 0 ? _b : ts_morph_1.Scope.Public,
|
|
19
|
+
const propertyDeclaration = (0, coerce_property_declaration_1.CoercePropertyDeclaration)(classDeclaration, definition.parameterName, {
|
|
20
|
+
scope: (_a = definition.scope) !== null && _a !== void 0 ? _a : ts_morph_1.Scope.Public,
|
|
30
21
|
isReadonly: true,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
});
|
|
23
|
+
if (definition.module === Module.ANGULAR) {
|
|
24
|
+
if (definition.optional) {
|
|
25
|
+
propertyDeclaration.setInitializer(`inject(${definition.injectionToken}, { optional: true })`);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
propertyDeclaration.setInitializer(`inject(${definition.injectionToken})`);
|
|
29
|
+
}
|
|
30
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
31
|
+
namedImports: ['inject'],
|
|
32
|
+
moduleSpecifier: definition.module,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'Inject', {
|
|
37
|
+
arguments: [definition.injectionToken],
|
|
42
38
|
});
|
|
43
|
-
|
|
39
|
+
if (definition.optional) {
|
|
40
|
+
(0, coerce_decorator_1.CoerceDecorator)(propertyDeclaration, 'Optional', {
|
|
41
|
+
arguments: [],
|
|
42
|
+
});
|
|
43
|
+
propertyDeclaration.setType(`${definition.type} | null`);
|
|
44
|
+
propertyDeclaration.setInitializer('null');
|
|
45
|
+
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
46
|
+
namedImports: ['Optional'],
|
|
47
|
+
moduleSpecifier: definition.module,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
propertyDeclaration.setType((_b = definition.type) !== null && _b !== void 0 ? _b : definition.injectionToken);
|
|
52
|
+
}
|
|
44
53
|
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
45
|
-
namedImports: ['
|
|
54
|
+
namedImports: ['Inject'],
|
|
46
55
|
moduleSpecifier: definition.module,
|
|
47
56
|
});
|
|
48
57
|
}
|
|
49
|
-
constructorDeclaration.addParameter(constructorParameter);
|
|
50
|
-
(0, coerce_imports_1.CoerceImports)(sourceFile, {
|
|
51
|
-
namedImports: ['Inject'],
|
|
52
|
-
moduleSpecifier: definition.module,
|
|
53
|
-
});
|
|
54
58
|
(0, coerce_imports_1.CoerceImports)(sourceFile, structures);
|
|
55
59
|
}
|
|
56
60
|
exports.CoerceDependencyInjection = CoerceDependencyInjection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce-dependency-injection.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-dependency-injection.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"coerce-dependency-injection.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-dependency-injection.ts"],"names":[],"mappings":";;;AAAA,uCAKkB;AAClB,yDAAqD;AACrD,qDAAiD;AACjD,+EAA0E;AAE1E,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,mCAAyB,CAAA;IACzB,iCAAuB,CAAA;AACzB,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAWD,SAAgB,yBAAyB,CACvC,UAAsB,EACtB,UAA+B,EAC/B,aAA8D,EAAE;;IA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AAE,UAAU,CAAC,MAAM;aACnC,CAAC,CAAC;SACJ;aAAM;YACL,mBAAmB,CAAC,OAAO,CAAC,MAAA,UAAU,CAAC,IAAI,mCAAI,UAAU,CAAC,cAAc,CAAC,CAAC;SAC3E;QACD,IAAA,8BAAa,EAAC,UAAU,EAAE;YACxB,YAAY,EAAE,CAAE,QAAQ,CAAE;YAC1B,eAAe,EAAE,UAAU,CAAC,MAAM;SACnC,CAAC,CAAC;KACJ;IAED,IAAA,8BAAa,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AAnDD,8DAmDC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { StatementedNode, StatementStructures, WriterFunction } from 'ts-morph';
|
|
2
|
-
export declare function CoerceStatements(node: StatementedNode, statements: (string | WriterFunction | StatementStructures)[] | string | WriterFunction): void;
|
|
2
|
+
export declare function CoerceStatements(node: StatementedNode, statements: (string | WriterFunction | StatementStructures)[] | string | WriterFunction, overwrite?: boolean): void;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CoerceStatements = void 0;
|
|
4
|
-
function CoerceStatements(node, statements) {
|
|
5
|
-
if (
|
|
6
|
-
|
|
4
|
+
function CoerceStatements(node, statements, overwrite = false) {
|
|
5
|
+
if (overwrite) {
|
|
6
|
+
const length = node.getStatements().length;
|
|
7
|
+
if (length > 0) {
|
|
8
|
+
node.removeStatements([0, length - 1]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (node.getStatements().length === 0) {
|
|
7
12
|
node.addStatements(statements);
|
|
8
13
|
}
|
|
9
14
|
}
|