@rxap/ts-morph 1.0.1-dev.0 → 1.1.0-dev.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 +10 -0
- package/README.md +1 -1
- package/package.json +4 -4
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/lib/angular/coerce-component.d.ts +20 -0
- package/src/lib/angular/coerce-component.js +62 -0
- package/src/lib/angular/coerce-component.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.1.0-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@1.0.1...@rxap/ts-morph@1.1.0-dev.0) (2024-02-09)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add CoerceComponent function ([da5c690](https://gitlab.com/rxap/packages/commit/da5c69085f1b8b336ab0c04e4c0e2d571054a755))
|
|
11
|
+
|
|
12
|
+
## [1.0.1](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@1.0.1-dev.0...@rxap/ts-morph@1.0.1) (2024-02-07)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @rxap/ts-morph
|
|
15
|
+
|
|
6
16
|
## [1.0.1-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@0.1.0-dev.21...@rxap/ts-morph@1.0.1-dev.0) (2024-02-07)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0
|
|
2
|
+
"version": "1.1.0-dev.0",
|
|
3
3
|
"name": "@rxap/ts-morph",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "2.6.2"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@rxap/utilities": "^16.0.0
|
|
9
|
+
"@rxap/utilities": "^16.0.0",
|
|
10
10
|
"ts-morph": "^18.0.0",
|
|
11
11
|
"tslib": "2.6.2"
|
|
12
12
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"packageGroup": [
|
|
29
29
|
{
|
|
30
30
|
"package": "@rxap/utilities",
|
|
31
|
-
"version": "16.0.0
|
|
31
|
+
"version": "16.0.0"
|
|
32
32
|
}
|
|
33
33
|
]
|
|
34
34
|
},
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"directory": "packages/ts-morph"
|
|
43
43
|
},
|
|
44
44
|
"type": "commonjs",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c72606219a2dc28185f6e21617ec127d7c82715c",
|
|
46
46
|
"main": "./src/index.js",
|
|
47
47
|
"types": "./src/index.d.ts"
|
|
48
48
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from './lib/nest/operation-id-utilities';
|
|
|
28
28
|
export * from './lib/nest/remove-nest-module-provider';
|
|
29
29
|
export * from './lib/nest/remove-nest-provider-to-array';
|
|
30
30
|
export * from './lib/angular/coerce-app-config-provider';
|
|
31
|
+
export * from './lib/angular/coerce-component';
|
|
31
32
|
export * from './lib/add-provider-to-array';
|
|
32
33
|
export * from './lib/coerce-array-element';
|
|
33
34
|
export * from './lib/coerce-class-constructor';
|
package/src/index.js
CHANGED
|
@@ -34,6 +34,7 @@ tslib_1.__exportStar(require("./lib/nest/remove-nest-provider-to-array"), export
|
|
|
34
34
|
// endregion
|
|
35
35
|
// region angular
|
|
36
36
|
tslib_1.__exportStar(require("./lib/angular/coerce-app-config-provider"), exports);
|
|
37
|
+
tslib_1.__exportStar(require("./lib/angular/coerce-component"), exports);
|
|
37
38
|
// endregion
|
|
38
39
|
// region
|
|
39
40
|
tslib_1.__exportStar(require("./lib/add-provider-to-array"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,0EAAgD;AAChD,0EAAgD;AAChD,4EAAkD;AAClD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,mFAAyD;AACzD,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,+DAAqC;AACrC,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,gEAAsC;AACtC,kEAAwC;AACxC,4DAAkC;AAClC,YAAY"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,0EAAgD;AAChD,0EAAgD;AAChD,4EAAkD;AAClD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,mFAAyD;AACzD,yEAA+C;AAC/C,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,+DAAqC;AACrC,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,gEAAsC;AACtC,kEAAwC;AACxC,4DAAkC;AAClC,YAAY"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ClassDeclarationStructure, ObjectLiteralExpression, OptionalKind, SourceFile } from 'ts-morph';
|
|
2
|
+
export interface CoerceComponentOptions {
|
|
3
|
+
selector?: string;
|
|
4
|
+
template?: string;
|
|
5
|
+
styles?: string;
|
|
6
|
+
/**
|
|
7
|
+
* true - use the component name to generate the templateUrl
|
|
8
|
+
*/
|
|
9
|
+
templateUrl?: string | true;
|
|
10
|
+
/**
|
|
11
|
+
* true - use the component name to generate a styleUrl
|
|
12
|
+
*/
|
|
13
|
+
styleUrls?: string | string[] | true;
|
|
14
|
+
}
|
|
15
|
+
export declare function CoerceComponent(sourceFile: SourceFile, name: string, options?: CoerceComponentOptions, classStructure?: Omit<OptionalKind<ClassDeclarationStructure>, 'name'>): {
|
|
16
|
+
classDeclaration: import("ts-morph").ClassDeclaration;
|
|
17
|
+
componentDecoratorObject: ObjectLiteralExpression;
|
|
18
|
+
providersArray: import("ts-morph").ArrayLiteralExpression;
|
|
19
|
+
importsArray: import("ts-morph").ArrayLiteralExpression;
|
|
20
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceComponent = void 0;
|
|
4
|
+
const coerce_decorator_1 = require("../coerce-decorator");
|
|
5
|
+
const utilities_1 = require("@rxap/utilities");
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
const coerce_class_1 = require("../coerce-class");
|
|
8
|
+
const get_coerce_array_literal_form_object_literal_1 = require("../get-coerce-array-literal-form-object-literal");
|
|
9
|
+
function CoerceComponent(sourceFile, name, options = {}, classStructure = {}) {
|
|
10
|
+
var _a;
|
|
11
|
+
const className = (0, utilities_1.CoerceSuffix)((0, utilities_1.dasherize)(name), '-component');
|
|
12
|
+
let { selector, template, templateUrl, styles, styleUrls, } = options;
|
|
13
|
+
selector !== null && selector !== void 0 ? selector : (selector = (0, utilities_1.dasherize)(name));
|
|
14
|
+
if (templateUrl === true) {
|
|
15
|
+
template = undefined;
|
|
16
|
+
templateUrl = `./${(0, utilities_1.dasherize)(name)}.component.html`;
|
|
17
|
+
}
|
|
18
|
+
if (styleUrls === true) {
|
|
19
|
+
styles = undefined;
|
|
20
|
+
styleUrls = [`./${(0, utilities_1.dasherize)(name)}.component.scss`];
|
|
21
|
+
}
|
|
22
|
+
if (!templateUrl) {
|
|
23
|
+
template !== null && template !== void 0 ? template : (template = '');
|
|
24
|
+
}
|
|
25
|
+
if (!styleUrls) {
|
|
26
|
+
styles !== null && styles !== void 0 ? styles : (styles = '[]');
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(styleUrls)) {
|
|
29
|
+
styleUrls = `['${styleUrls.join('\',\n\'')}']`;
|
|
30
|
+
}
|
|
31
|
+
if (!(styleUrls === null || styleUrls === void 0 ? void 0 : styleUrls.startsWith('['))) {
|
|
32
|
+
styleUrls = `[${styleUrls}]`;
|
|
33
|
+
}
|
|
34
|
+
(_a = classStructure.isExported) !== null && _a !== void 0 ? _a : (classStructure.isExported = true);
|
|
35
|
+
const classDeclaration = (0, coerce_class_1.CoerceClass)(sourceFile, className, classStructure);
|
|
36
|
+
const componentDecoratorDeclaration = (0, coerce_decorator_1.CoerceDecorator)(classDeclaration, 'Component', {
|
|
37
|
+
arguments: [
|
|
38
|
+
ts_morph_1.Writers.object({
|
|
39
|
+
standalone: 'true',
|
|
40
|
+
selector: w => w.quote(selector),
|
|
41
|
+
template: template !== undefined ? w => w.quote(template) : undefined,
|
|
42
|
+
templateUrl: templateUrl !== undefined ? w => w.quote(templateUrl) : undefined,
|
|
43
|
+
styles: styles !== undefined ? w => w.quote(styles) : undefined,
|
|
44
|
+
styleUrls: styleUrls !== undefined ? w => w.quote(styleUrls) : undefined,
|
|
45
|
+
providers: '[]',
|
|
46
|
+
imports: '[]',
|
|
47
|
+
}),
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
const componentDecoratorObject = componentDecoratorDeclaration.getArguments()[0];
|
|
51
|
+
if (!componentDecoratorObject) {
|
|
52
|
+
throw new Error(`Could not find component decorator object for component '${className}'`);
|
|
53
|
+
}
|
|
54
|
+
if (!(componentDecoratorObject instanceof ts_morph_1.ObjectLiteralExpression)) {
|
|
55
|
+
throw new Error(`Component decorator object for component '${className}' is not an object literal expression`);
|
|
56
|
+
}
|
|
57
|
+
const providersArray = (0, get_coerce_array_literal_form_object_literal_1.GetCoerceArrayLiteralFromObjectLiteral)(componentDecoratorObject, 'providers');
|
|
58
|
+
const importsArray = (0, get_coerce_array_literal_form_object_literal_1.GetCoerceArrayLiteralFromObjectLiteral)(componentDecoratorObject, 'providers');
|
|
59
|
+
return { classDeclaration, componentDecoratorObject, providersArray, importsArray };
|
|
60
|
+
}
|
|
61
|
+
exports.CoerceComponent = CoerceComponent;
|
|
62
|
+
//# sourceMappingURL=coerce-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-component.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/angular/coerce-component.ts"],"names":[],"mappings":";;;AAAA,0DAE6B;AAC7B,+CAGyB;AACzB,uCAMkB;AAClB,kDAA8C;AAC9C,kHAAyG;AAgBzG,SAAgB,eAAe,CAC7B,UAAsB,EACtB,IAAY,EACZ,UAAkC,EAAE,EACpC,iBAAwE,EAAE;;IAE1E,MAAM,SAAS,GAAG,IAAA,wBAAY,EAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,IAAI,EACF,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,MAAM,EACN,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,IAAA,qBAAS,EAAC,IAAI,CAAC,EAAC;IAC7B,IAAI,WAAW,KAAK,IAAI,EAAE;QACxB,QAAQ,GAAG,SAAS,CAAC;QACrB,WAAW,GAAG,KAAM,IAAA,qBAAS,EAAC,IAAI,CAAE,iBAAiB,CAAC;KACvD;IACD,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,MAAM,GAAG,SAAS,CAAC;QACnB,SAAS,GAAG,CAAE,KAAM,IAAA,qBAAS,EAAC,IAAI,CAAE,iBAAiB,CAAE,CAAC;KACzD;IACD,IAAI,CAAC,WAAW,EAAE;QAChB,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,EAAE,EAAC;KACjB;IACD,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,aAAN,MAAM,cAAN,MAAM,IAAN,MAAM,GAAK,IAAI,EAAC;KACjB;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAC5B,SAAS,GAAG,KAAM,SAAS,CAAC,IAAI,CAAC,SAAS,CAAE,IAAI,CA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