@simplysm/sd-cli 7.0.249 → 7.0.267
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 +95 -0
- package/assets/client-files/assets/icons/icon-128x128.png +0 -0
- package/assets/client-files/assets/icons/icon-144x144.png +0 -0
- package/assets/client-files/assets/icons/icon-152x152.png +0 -0
- package/assets/client-files/assets/icons/icon-192x192.png +0 -0
- package/assets/client-files/assets/icons/icon-384x384.png +0 -0
- package/assets/client-files/assets/icons/icon-512x512.png +0 -0
- package/assets/client-files/assets/icons/icon-72x72.png +0 -0
- package/assets/client-files/assets/icons/icon-96x96.png +0 -0
- package/assets/client-files/favicon.ico +0 -0
- package/dist/bin/sd-cli.mjs +212 -15
- package/dist/build-tool/SdCliCordova.mjs +3 -3
- package/dist/build-tool/SdCliElectron.mjs +3 -2
- package/dist/build-tool/SdCliIndexFileGenerator.mjs +2 -3
- package/dist/builder/SdCliClientBuilder.d.ts +2 -0
- package/dist/builder/SdCliClientBuilder.mjs +57 -20
- package/dist/builder/SdCliServerBuilder.d.ts +2 -0
- package/dist/builder/SdCliServerBuilder.mjs +27 -13
- package/dist/builder/SdCliTsLibBuilder.mjs +18 -12
- package/dist/commons.d.ts +6 -1
- package/dist/entry-points/SdCliPrepare.mjs +34 -34
- package/dist/entry-points/SdCliProjectGenerator.d.ts +44 -0
- package/dist/entry-points/SdCliProjectGenerator.mjs +320 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +6 -6
- package/dist/entry-points/SdCliWorkspace.mjs +61 -107
- package/dist/entry-points/file/base/fc_package_eslintrc.d.ts +3 -0
- package/dist/entry-points/file/base/fc_package_eslintrc.mjs +31 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.d.ts +9 -0
- package/dist/entry-points/file/base/fc_package_npmconfig.mjs +32 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.d.ts +5 -0
- package/dist/entry-points/file/base/fc_package_tsconfig.mjs +13 -0
- package/dist/entry-points/file/client/fc_package_AppModule.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppModule.mjs +37 -0
- package/dist/entry-points/file/client/fc_package_AppPage.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_AppPage.mjs +14 -0
- package/dist/entry-points/file/client/fc_package_Page.d.ts +4 -0
- package/dist/entry-points/file/client/fc_package_Page.mjs +19 -0
- package/dist/entry-points/file/client/fc_package_client_main.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_client_main.mjs +19 -0
- package/dist/entry-points/file/client/fc_package_index.d.ts +3 -0
- package/dist/entry-points/file/client/fc_package_index.mjs +88 -0
- package/dist/entry-points/file/client/fc_package_manifest.d.ts +5 -0
- package/dist/entry-points/file/client/fc_package_manifest.mjs +54 -0
- package/dist/entry-points/file/client/fc_package_polyfills.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_polyfills.mjs +11 -0
- package/dist/entry-points/file/client/fc_package_styles.d.ts +1 -0
- package/dist/entry-points/file/client/fc_package_styles.mjs +7 -0
- package/dist/entry-points/file/db/fc_package_DbContext.d.ts +3 -0
- package/dist/entry-points/file/db/fc_package_DbContext.mjs +14 -0
- package/dist/entry-points/file/db/fc_package_DbModel.d.ts +4 -0
- package/dist/entry-points/file/db/fc_package_DbModel.mjs +12 -0
- package/dist/entry-points/file/project/fc_project_editor_config.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_editor_config.mjs +22 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_eslintrc.mjs +30 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitattributes.mjs +6 -0
- package/dist/entry-points/file/project/fc_project_gitignore.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_gitignore.mjs +17 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.d.ts +7 -0
- package/dist/entry-points/file/project/fc_project_npmconfig.mjs +35 -0
- package/dist/entry-points/file/project/fc_project_readme.d.ts +3 -0
- package/dist/entry-points/file/project/fc_project_readme.mjs +13 -0
- package/dist/entry-points/file/project/fc_project_simplysm.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_simplysm.mjs +2 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.d.ts +1 -0
- package/dist/entry-points/file/project/fc_project_tsconfig.mjs +25 -0
- package/dist/entry-points/file/server/fc_package_server_main.d.ts +4 -0
- package/dist/entry-points/file/server/fc_package_server_main.mjs +60 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.mjs +24 -1
- package/dist/ng-tools/SdCliNgModuleGenerator.mjs +35 -36
- package/dist/packages/SdCliPackage.d.ts +1 -0
- package/dist/packages/SdCliPackage.mjs +69 -63
- package/dist/utils/SdCliBuildResultUtil.mjs +2 -2
- package/docs/client-add-page.md +8 -0
- package/docs/client-router.md +85 -0
- package/docs/client-sw.md +101 -0
- package/docs/conf-orm.md +81 -0
- package/docs/conf-usage.md +5 -0
- package/docs/lib-local-update.md +50 -0
- package/docs/lib-ts-paths.md +25 -0
- package/package.json +10 -8
- package/src/SdCliBuildResultError.ts +9 -9
- package/src/bin/sd-cli.ts +244 -15
- package/src/build-tool/SdCliCacheCompilerHost.ts +77 -77
- package/src/build-tool/SdCliCordova.ts +2 -2
- package/src/build-tool/SdCliElectron.ts +2 -1
- package/src/build-tool/SdCliGithubApi.ts +110 -110
- package/src/build-tool/SdCliIndexFileGenerator.ts +79 -80
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +58 -58
- package/src/build-tool/SdCliPackageLinter.ts +74 -74
- package/src/builder/SdCliClientBuilder.ts +73 -22
- package/src/builder/SdCliJsLibBuilder.ts +70 -70
- package/src/builder/SdCliServerBuilder.ts +34 -14
- package/src/builder/SdCliTsLibBuilder.ts +450 -445
- package/src/commons.ts +6 -1
- package/src/entry-points/SdCliFileCrypto.ts +87 -87
- package/src/entry-points/SdCliPrepare.ts +55 -55
- package/src/entry-points/SdCliProjectGenerator.ts +395 -0
- package/src/entry-points/SdCliWorkspace.ts +74 -122
- package/src/entry-points/file/base/fc_package_eslintrc.ts +30 -0
- package/src/entry-points/file/base/fc_package_npmconfig.ts +43 -0
- package/src/entry-points/file/base/fc_package_tsconfig.ts +12 -0
- package/src/entry-points/file/client/fc_package_AppModule.ts +36 -0
- package/src/entry-points/file/client/fc_package_AppPage.ts +13 -0
- package/src/entry-points/file/client/fc_package_Page.ts +19 -0
- package/src/entry-points/file/client/fc_package_client_main.ts +18 -0
- package/src/entry-points/file/client/fc_package_index.ts +87 -0
- package/src/entry-points/file/client/fc_package_manifest.ts +53 -0
- package/src/entry-points/file/client/fc_package_polyfills.ts +10 -0
- package/src/entry-points/file/client/fc_package_styles.ts +6 -0
- package/src/entry-points/file/db/fc_package_DbContext.ts +14 -0
- package/src/entry-points/file/db/fc_package_DbModel.ts +11 -0
- package/src/entry-points/file/project/fc_project_editor_config.ts +21 -0
- package/src/entry-points/file/project/fc_project_eslintrc.ts +29 -0
- package/src/entry-points/file/project/fc_project_gitattributes.ts +5 -0
- package/src/entry-points/file/project/fc_project_gitignore.ts +16 -0
- package/src/entry-points/file/project/fc_project_npmconfig.ts +34 -0
- package/src/entry-points/file/project/fc_project_readme.ts +12 -0
- package/src/entry-points/file/project/fc_project_simplysm.ts +1 -0
- package/src/entry-points/file/project/fc_project_tsconfig.ts +24 -0
- package/src/entry-points/file/server/fc_package_server_main.ts +62 -0
- package/src/index.ts +55 -32
- package/src/ng-tools/SdCliNgModuleGenerator.ts +639 -640
- package/src/ng-tools/babel/SdCliBbFileMetadata.ts +568 -568
- package/src/ng-tools/babel/SdCliBbRootMetadata.ts +239 -239
- package/src/ng-tools/babel/SdCliBbUtil.ts +15 -15
- package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +234 -234
- package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +177 -177
- package/src/ng-tools/commons.ts +3 -3
- package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +384 -384
- package/src/ng-tools/typescript/SdCliTsRootMetadata.ts +32 -32
- package/src/ng-tools/typescript/SdCliTsUtil.ts +29 -29
- package/src/packages/SdCliPackage.ts +76 -59
- package/src/utils/SdCliBuildResultUtil.ts +76 -76
- package/src/utils/SdCliConfigUtil.ts +94 -94
- package/src/utils/SdCliNpmConfigUtil.ts +16 -16
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ArrayExpression,
|
|
3
|
-
ClassDeclaration,
|
|
4
|
-
FunctionDeclaration,
|
|
5
|
-
isAssignmentExpression,
|
|
6
|
-
isExpressionStatement,
|
|
7
|
-
isIdentifier,
|
|
8
|
-
isMemberExpression,
|
|
9
|
-
isObjectProperty,
|
|
10
|
-
ObjectExpression,
|
|
11
|
-
VariableDeclarator
|
|
12
|
-
} from "@babel/types";
|
|
13
|
-
import { NeverEntryError } from "@simplysm/sd-core-common";
|
|
14
|
-
import { SdCliBbFileMetadata } from "./SdCliBbFileMetadata";
|
|
15
|
-
import {
|
|
16
|
-
SdCliBbNgComponentMetadata,
|
|
17
|
-
SdCliBbNgDirectiveMetadata,
|
|
18
|
-
SdCliBbNgInjectableMetadata,
|
|
19
|
-
SdCliBbNgModuleMetadata,
|
|
20
|
-
SdCliBbNgPipeMetadata,
|
|
21
|
-
TSdCliBbNgMetadata
|
|
22
|
-
} from "./TSdCliBbNgMetadata";
|
|
23
|
-
import { TSdCliBbMetadata } from "./SdCliBbRootMetadata";
|
|
24
|
-
|
|
25
|
-
export type TSdCliBbTypeMetadata = SdCliBbClassMetadata |
|
|
26
|
-
SdCliBbVariableMetadata |
|
|
27
|
-
SdCliBbFunctionMetadata |
|
|
28
|
-
SdCliBbObjectMetadata |
|
|
29
|
-
SdCliBbArrayMetadata;
|
|
30
|
-
|
|
31
|
-
export class SdCliBbClassMetadata {
|
|
32
|
-
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
33
|
-
private readonly _rawMeta: ClassDeclaration) {
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public get filePath(): string {
|
|
37
|
-
return this._fileMeta.filePath;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public get name(): string {
|
|
41
|
-
return this._rawMeta.id.name;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private _ngDeclCache?: TSdCliBbNgMetadata | "none";
|
|
45
|
-
|
|
46
|
-
public get ngDecl(): TSdCliBbNgMetadata | undefined {
|
|
47
|
-
if (this._ngDeclCache !== undefined) {
|
|
48
|
-
return this._ngDeclCache === "none" ? undefined : this._ngDeclCache;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (const meta of this._fileMeta.rawMetas) {
|
|
52
|
-
if (
|
|
53
|
-
isExpressionStatement(meta) &&
|
|
54
|
-
isAssignmentExpression(meta.expression) &&
|
|
55
|
-
isMemberExpression(meta.expression.left) &&
|
|
56
|
-
isIdentifier(meta.expression.left.object) &&
|
|
57
|
-
meta.expression.left.object.name === this._rawMeta.id.name &&
|
|
58
|
-
isIdentifier(meta.expression.left.property)
|
|
59
|
-
) {
|
|
60
|
-
if (meta.expression.left.property.name === "ɵmod") {
|
|
61
|
-
this._ngDeclCache = new SdCliBbNgModuleMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
62
|
-
return this._ngDeclCache;
|
|
63
|
-
}
|
|
64
|
-
else if (meta.expression.left.property.name === "ɵprov") {
|
|
65
|
-
this._ngDeclCache = new SdCliBbNgInjectableMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
66
|
-
return this._ngDeclCache;
|
|
67
|
-
}
|
|
68
|
-
else if (meta.expression.left.property.name === "ɵdir") {
|
|
69
|
-
this._ngDeclCache = new SdCliBbNgDirectiveMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
70
|
-
return this._ngDeclCache;
|
|
71
|
-
}
|
|
72
|
-
else if (meta.expression.left.property.name === "ɵcmp") {
|
|
73
|
-
this._ngDeclCache = new SdCliBbNgComponentMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
74
|
-
return this._ngDeclCache;
|
|
75
|
-
}
|
|
76
|
-
else if (meta.expression.left.property.name === "ɵpipe") {
|
|
77
|
-
this._ngDeclCache = new SdCliBbNgPipeMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
78
|
-
return this._ngDeclCache;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this._ngDeclCache = "none";
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export class SdCliBbVariableMetadata {
|
|
89
|
-
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
90
|
-
private readonly _rawMeta: VariableDeclarator) {
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public get filePath(): string {
|
|
94
|
-
return this._fileMeta.filePath;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public get name(): string {
|
|
98
|
-
if (!isIdentifier(this._rawMeta.id)) throw new NeverEntryError();
|
|
99
|
-
return this._rawMeta.id.name;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private _valueCache?: TSdCliBbMetadata;
|
|
103
|
-
|
|
104
|
-
public get value(): TSdCliBbMetadata | undefined {
|
|
105
|
-
if (this._valueCache === undefined) {
|
|
106
|
-
this._valueCache = this._rawMeta.init == null ? undefined : this._fileMeta.getMetaFromRaw(this._rawMeta.init);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return this._valueCache;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export class SdCliBbFunctionMetadata {
|
|
114
|
-
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
115
|
-
private readonly _rawMeta: FunctionDeclaration) {
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
public get filePath(): string {
|
|
119
|
-
return this._fileMeta.filePath;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
public get name(): string {
|
|
123
|
-
if (!isIdentifier(this._rawMeta.id)) throw new NeverEntryError();
|
|
124
|
-
return this._rawMeta.id.name;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export class SdCliBbObjectMetadata {
|
|
129
|
-
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
130
|
-
private readonly _metadata: ObjectExpression) {
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private readonly _getPropValueCache = new Map<string, TSdCliBbMetadata | undefined>();
|
|
134
|
-
|
|
135
|
-
public getPropValue(propName: string): TSdCliBbMetadata | undefined {
|
|
136
|
-
if (this._getPropValueCache.has(propName)) {
|
|
137
|
-
return this._getPropValueCache.get(propName);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const prop = this._metadata.properties
|
|
141
|
-
.single((item) => (
|
|
142
|
-
isObjectProperty(item) &&
|
|
143
|
-
isIdentifier(item.key) &&
|
|
144
|
-
item.key.name === propName
|
|
145
|
-
));
|
|
146
|
-
if (prop && !isObjectProperty(prop)) {
|
|
147
|
-
throw new NeverEntryError();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (!prop) {
|
|
151
|
-
this._getPropValueCache.set(propName, undefined);
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const result = this._fileMeta.getMetaFromRaw(prop.value);
|
|
156
|
-
this._getPropValueCache.set(propName, result);
|
|
157
|
-
return result;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export class SdCliBbArrayMetadata {
|
|
162
|
-
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
163
|
-
private readonly _metadata: ArrayExpression) {
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
private _valueCache?: (TSdCliBbMetadata | undefined)[];
|
|
167
|
-
|
|
168
|
-
public get value(): (TSdCliBbMetadata | undefined)[] {
|
|
169
|
-
if (this._valueCache === undefined) {
|
|
170
|
-
this._valueCache = [];
|
|
171
|
-
for (const el of this._metadata.elements) {
|
|
172
|
-
this._valueCache.push(el ? this._fileMeta.getMetaFromRaw(el) : undefined);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return this._valueCache;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ArrayExpression,
|
|
3
|
+
ClassDeclaration,
|
|
4
|
+
FunctionDeclaration,
|
|
5
|
+
isAssignmentExpression,
|
|
6
|
+
isExpressionStatement,
|
|
7
|
+
isIdentifier,
|
|
8
|
+
isMemberExpression,
|
|
9
|
+
isObjectProperty,
|
|
10
|
+
ObjectExpression,
|
|
11
|
+
VariableDeclarator
|
|
12
|
+
} from "@babel/types";
|
|
13
|
+
import { NeverEntryError } from "@simplysm/sd-core-common";
|
|
14
|
+
import { SdCliBbFileMetadata } from "./SdCliBbFileMetadata";
|
|
15
|
+
import {
|
|
16
|
+
SdCliBbNgComponentMetadata,
|
|
17
|
+
SdCliBbNgDirectiveMetadata,
|
|
18
|
+
SdCliBbNgInjectableMetadata,
|
|
19
|
+
SdCliBbNgModuleMetadata,
|
|
20
|
+
SdCliBbNgPipeMetadata,
|
|
21
|
+
TSdCliBbNgMetadata
|
|
22
|
+
} from "./TSdCliBbNgMetadata";
|
|
23
|
+
import { TSdCliBbMetadata } from "./SdCliBbRootMetadata";
|
|
24
|
+
|
|
25
|
+
export type TSdCliBbTypeMetadata = SdCliBbClassMetadata |
|
|
26
|
+
SdCliBbVariableMetadata |
|
|
27
|
+
SdCliBbFunctionMetadata |
|
|
28
|
+
SdCliBbObjectMetadata |
|
|
29
|
+
SdCliBbArrayMetadata;
|
|
30
|
+
|
|
31
|
+
export class SdCliBbClassMetadata {
|
|
32
|
+
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
33
|
+
private readonly _rawMeta: ClassDeclaration) {
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public get filePath(): string {
|
|
37
|
+
return this._fileMeta.filePath;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public get name(): string {
|
|
41
|
+
return this._rawMeta.id.name;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private _ngDeclCache?: TSdCliBbNgMetadata | "none";
|
|
45
|
+
|
|
46
|
+
public get ngDecl(): TSdCliBbNgMetadata | undefined {
|
|
47
|
+
if (this._ngDeclCache !== undefined) {
|
|
48
|
+
return this._ngDeclCache === "none" ? undefined : this._ngDeclCache;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
for (const meta of this._fileMeta.rawMetas) {
|
|
52
|
+
if (
|
|
53
|
+
isExpressionStatement(meta) &&
|
|
54
|
+
isAssignmentExpression(meta.expression) &&
|
|
55
|
+
isMemberExpression(meta.expression.left) &&
|
|
56
|
+
isIdentifier(meta.expression.left.object) &&
|
|
57
|
+
meta.expression.left.object.name === this._rawMeta.id.name &&
|
|
58
|
+
isIdentifier(meta.expression.left.property)
|
|
59
|
+
) {
|
|
60
|
+
if (meta.expression.left.property.name === "ɵmod") {
|
|
61
|
+
this._ngDeclCache = new SdCliBbNgModuleMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
62
|
+
return this._ngDeclCache;
|
|
63
|
+
}
|
|
64
|
+
else if (meta.expression.left.property.name === "ɵprov") {
|
|
65
|
+
this._ngDeclCache = new SdCliBbNgInjectableMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
66
|
+
return this._ngDeclCache;
|
|
67
|
+
}
|
|
68
|
+
else if (meta.expression.left.property.name === "ɵdir") {
|
|
69
|
+
this._ngDeclCache = new SdCliBbNgDirectiveMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
70
|
+
return this._ngDeclCache;
|
|
71
|
+
}
|
|
72
|
+
else if (meta.expression.left.property.name === "ɵcmp") {
|
|
73
|
+
this._ngDeclCache = new SdCliBbNgComponentMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
74
|
+
return this._ngDeclCache;
|
|
75
|
+
}
|
|
76
|
+
else if (meta.expression.left.property.name === "ɵpipe") {
|
|
77
|
+
this._ngDeclCache = new SdCliBbNgPipeMetadata(this._fileMeta, this._rawMeta.id.name);
|
|
78
|
+
return this._ngDeclCache;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this._ngDeclCache = "none";
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class SdCliBbVariableMetadata {
|
|
89
|
+
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
90
|
+
private readonly _rawMeta: VariableDeclarator) {
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public get filePath(): string {
|
|
94
|
+
return this._fileMeta.filePath;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public get name(): string {
|
|
98
|
+
if (!isIdentifier(this._rawMeta.id)) throw new NeverEntryError();
|
|
99
|
+
return this._rawMeta.id.name;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private _valueCache?: TSdCliBbMetadata;
|
|
103
|
+
|
|
104
|
+
public get value(): TSdCliBbMetadata | undefined {
|
|
105
|
+
if (this._valueCache === undefined) {
|
|
106
|
+
this._valueCache = this._rawMeta.init == null ? undefined : this._fileMeta.getMetaFromRaw(this._rawMeta.init);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return this._valueCache;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class SdCliBbFunctionMetadata {
|
|
114
|
+
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
115
|
+
private readonly _rawMeta: FunctionDeclaration) {
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public get filePath(): string {
|
|
119
|
+
return this._fileMeta.filePath;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public get name(): string {
|
|
123
|
+
if (!isIdentifier(this._rawMeta.id)) throw new NeverEntryError();
|
|
124
|
+
return this._rawMeta.id.name;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export class SdCliBbObjectMetadata {
|
|
129
|
+
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
130
|
+
private readonly _metadata: ObjectExpression) {
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private readonly _getPropValueCache = new Map<string, TSdCliBbMetadata | undefined>();
|
|
134
|
+
|
|
135
|
+
public getPropValue(propName: string): TSdCliBbMetadata | undefined {
|
|
136
|
+
if (this._getPropValueCache.has(propName)) {
|
|
137
|
+
return this._getPropValueCache.get(propName);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const prop = this._metadata.properties
|
|
141
|
+
.single((item) => (
|
|
142
|
+
isObjectProperty(item) &&
|
|
143
|
+
isIdentifier(item.key) &&
|
|
144
|
+
item.key.name === propName
|
|
145
|
+
));
|
|
146
|
+
if (prop && !isObjectProperty(prop)) {
|
|
147
|
+
throw new NeverEntryError();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!prop) {
|
|
151
|
+
this._getPropValueCache.set(propName, undefined);
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const result = this._fileMeta.getMetaFromRaw(prop.value);
|
|
156
|
+
this._getPropValueCache.set(propName, result);
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export class SdCliBbArrayMetadata {
|
|
162
|
+
public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
|
|
163
|
+
private readonly _metadata: ArrayExpression) {
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private _valueCache?: (TSdCliBbMetadata | undefined)[];
|
|
167
|
+
|
|
168
|
+
public get value(): (TSdCliBbMetadata | undefined)[] {
|
|
169
|
+
if (this._valueCache === undefined) {
|
|
170
|
+
this._valueCache = [];
|
|
171
|
+
for (const el of this._metadata.elements) {
|
|
172
|
+
this._valueCache.push(el ? this._fileMeta.getMetaFromRaw(el) : undefined);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return this._valueCache;
|
|
176
|
+
}
|
|
177
|
+
}
|
package/src/ng-tools/commons.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type TSdCliMetaRef =
|
|
2
|
-
({ filePath: string; name: string } | { moduleName: string; name: string })
|
|
3
|
-
& { __TSdCliMetaRef__: "__TSdCliMetaRef__" };
|
|
1
|
+
export type TSdCliMetaRef =
|
|
2
|
+
({ filePath: string; name: string } | { moduleName: string; name: string })
|
|
3
|
+
& { __TSdCliMetaRef__: "__TSdCliMetaRef__" };
|