@simplysm/sd-cli 7.0.59 → 7.0.66
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/dist/SdCliBuildResultError.d.ts +5 -0
- package/dist/SdCliBuildResultError.mjs +8 -0
- package/dist/bin/sd-cli.d.ts +2 -0
- package/dist/bin/sd-cli.mjs +3 -3
- package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
- package/dist/build-tool/SdCliCordova.d.ts +16 -0
- package/dist/build-tool/SdCliCordova.mjs +171 -0
- package/dist/build-tool/SdCliIndexFileGenerator.d.ts +13 -0
- package/dist/{entry-points → build-tool}/SdCliIndexFileGenerator.mjs +4 -3
- package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
- package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
- package/dist/build-tool/SdCliPackageLinter.mjs +19 -2
- package/dist/builder/SdCliClientBuilder.d.ts +23 -0
- package/dist/builder/SdCliClientBuilder.mjs +68 -6
- package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
- package/dist/builder/SdCliServerBuilder.d.ts +25 -0
- package/dist/builder/SdCliServerBuilder.mjs +11 -13
- package/dist/builder/SdCliTsLibBuilder.d.ts +34 -0
- package/dist/builder/SdCliTsLibBuilder.mjs +90 -20
- package/dist/commons.d.ts +85 -0
- package/dist/entry-points/SdCliLocalUpdate.d.ts +13 -0
- package/dist/entry-points/SdCliNpm.d.ts +6 -0
- package/dist/entry-points/SdCliPrepare.d.ts +5 -0
- package/dist/entry-points/SdCliWorkspace.d.ts +28 -0
- package/dist/entry-points/SdCliWorkspace.mjs +12 -16
- package/dist/index.d.ts +29 -0
- package/dist/index.mjs +30 -0
- package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +26 -0
- package/dist/ng-tools/SdCliNgModuleGenerator.mjs +404 -0
- package/dist/ng-tools/babel/SdCliBbFileMetadata.d.ts +23 -0
- package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +482 -0
- package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +22 -0
- package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +174 -0
- package/dist/ng-tools/babel/SdCliBbUtil.d.ts +5 -0
- package/dist/ng-tools/babel/SdCliBbUtil.mjs +14 -0
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.d.ts +42 -0
- package/dist/ng-tools/babel/TSdCliBbNgMetadata.mjs +200 -0
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +44 -0
- package/dist/ng-tools/babel/TSdCliBbTypeMetadata.mjs +127 -0
- package/dist/ng-tools/commons.d.ts +9 -0
- package/dist/ng-tools/commons.mjs +2 -0
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.d.ts +61 -0
- package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +326 -0
- package/dist/ng-tools/typescript/SdCliTsRootMetadata.d.ts +8 -0
- package/dist/ng-tools/typescript/SdCliTsRootMetadata.mjs +28 -0
- package/dist/ng-tools/typescript/SdCliTsUtil.d.ts +5 -0
- package/dist/ng-tools/typescript/SdCliTsUtil.mjs +28 -0
- package/dist/packages/SdCliPackage.d.ts +23 -0
- package/dist/packages/SdCliPackage.mjs +2 -3
- package/dist/utils/SdCliBuildResultUtil.d.ts +9 -0
- package/dist/utils/SdCliConfigUtil.d.ts +7 -0
- package/dist/utils/SdCliNpmConfigUtil.d.ts +7 -0
- package/dist/utils/SdCliNpmConfigUtil.mjs +3 -3
- package/package.json +16 -7
- package/src/SdCliBuildResultError.ts +9 -0
- package/src/bin/sd-cli.ts +2 -2
- package/src/build-tool/SdCliCordova.ts +219 -0
- package/src/{entry-points → build-tool}/SdCliIndexFileGenerator.ts +3 -2
- package/src/build-tool/SdCliPackageLinter.ts +18 -2
- package/src/builder/SdCliClientBuilder.ts +83 -5
- package/src/builder/SdCliServerBuilder.ts +10 -12
- package/src/builder/SdCliTsLibBuilder.ts +105 -21
- package/src/commons.ts +24 -0
- package/src/entry-points/SdCliWorkspace.ts +14 -17
- package/src/index.ts +29 -0
- package/src/ng-tools/SdCliNgModuleGenerator.ts +538 -0
- package/src/ng-tools/babel/SdCliBbFileMetadata.ts +568 -0
- package/src/ng-tools/babel/SdCliBbRootMetadata.ts +211 -0
- package/src/ng-tools/babel/SdCliBbUtil.ts +15 -0
- package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +234 -0
- package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +177 -0
- package/src/ng-tools/commons.ts +3 -0
- package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +385 -0
- package/src/ng-tools/typescript/SdCliTsRootMetadata.ts +32 -0
- package/src/ng-tools/typescript/SdCliTsUtil.ts +29 -0
- package/src/packages/SdCliPackage.ts +1 -2
- package/src/utils/SdCliNpmConfigUtil.ts +2 -2
- package/tsconfig-build.json +6 -2
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { FsUtil } from "@simplysm/sd-core-node";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { NeverEntryError } from "@simplysm/sd-core-common";
|
|
4
|
+
import { TSdCliMetaRef } from "../commons";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { SdCliTsUtil } from "./SdCliTsUtil";
|
|
7
|
+
|
|
8
|
+
export class SdCliTsFileMetadata {
|
|
9
|
+
public readonly sourceFile: ts.SourceFile;
|
|
10
|
+
|
|
11
|
+
public constructor(public readonly filePath: string) {
|
|
12
|
+
const fileContent = FsUtil.readFile(filePath);
|
|
13
|
+
this.sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.ES2017);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private _directExportClassesCache?: { exportedName: string; target: SdCliTsClassMetadata }[];
|
|
17
|
+
|
|
18
|
+
public get directExportClasses(): { exportedName: string; target: SdCliTsClassMetadata }[] {
|
|
19
|
+
if (this._directExportClassesCache) return this._directExportClassesCache;
|
|
20
|
+
|
|
21
|
+
const result: { exportedName: string; target: SdCliTsClassMetadata }[] = [];
|
|
22
|
+
this.sourceFile.forEachChild((node) => {
|
|
23
|
+
if (!node.modifiers || !node.modifiers.some((item) => item.kind === ts.SyntaxKind.ExportKeyword)) return;
|
|
24
|
+
if (!ts.isClassDeclaration(node)) return;
|
|
25
|
+
if (node.name === undefined) {
|
|
26
|
+
throw new NeverEntryError();
|
|
27
|
+
}
|
|
28
|
+
result.push({ exportedName: node.name.text, target: new SdCliTsClassMetadata(this, node) });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
this._directExportClassesCache = result;
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public get imports(): TSdCliMetaRef[] {
|
|
36
|
+
const result: TSdCliMetaRef[] = [];
|
|
37
|
+
|
|
38
|
+
ts.forEachChild(this.sourceFile, (node) => {
|
|
39
|
+
if (ts.isImportDeclaration(node)) {
|
|
40
|
+
if (ts.isStringLiteral(node.moduleSpecifier)) {
|
|
41
|
+
if (node.importClause) {
|
|
42
|
+
if (node.moduleSpecifier.text.includes(".")) {
|
|
43
|
+
const moduleFilePath = path.resolve(path.dirname(this.filePath), node.moduleSpecifier.text);
|
|
44
|
+
|
|
45
|
+
if (node.importClause.namedBindings) {
|
|
46
|
+
if (ts.isNamedImports(node.importClause.namedBindings)) {
|
|
47
|
+
for (const el of node.importClause.namedBindings.elements) {
|
|
48
|
+
result.push({
|
|
49
|
+
filePath: moduleFilePath,
|
|
50
|
+
name: el.name.text,
|
|
51
|
+
__TSdCliMetaRef__: "__TSdCliMetaRef__" as const
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw SdCliTsUtil.error("'import * as [name] from ...'을 'import [name] from ...'로 변경하세요.", this.sourceFile, node);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
result.push({
|
|
61
|
+
filePath: moduleFilePath,
|
|
62
|
+
name: "default",
|
|
63
|
+
__TSdCliMetaRef__: "__TSdCliMetaRef__" as const
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const moduleName = node.moduleSpecifier.text;
|
|
69
|
+
if (node.importClause.namedBindings) {
|
|
70
|
+
if (ts.isNamedImports(node.importClause.namedBindings)) {
|
|
71
|
+
for (const el of node.importClause.namedBindings.elements) {
|
|
72
|
+
result.push({
|
|
73
|
+
moduleName,
|
|
74
|
+
name: el.propertyName?.text ?? el.name.text,
|
|
75
|
+
__TSdCliMetaRef__: "__TSdCliMetaRef__" as const
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const nsUseList = this._findNamespaceUse(node.importClause.namedBindings.name.text);
|
|
81
|
+
for (const nsUse of nsUseList) {
|
|
82
|
+
result.push({
|
|
83
|
+
moduleName,
|
|
84
|
+
name: nsUse,
|
|
85
|
+
__TSdCliMetaRef__: "__TSdCliMetaRef__" as const
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (node.importClause.name) {
|
|
91
|
+
const nsUseList = this._findNamespaceUse(node.importClause.name.text);
|
|
92
|
+
for (const nsUse of nsUseList) {
|
|
93
|
+
result.push({
|
|
94
|
+
moduleName: moduleName,
|
|
95
|
+
name: nsUse,
|
|
96
|
+
__TSdCliMetaRef__: "__TSdCliMetaRef__" as const
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw new NeverEntryError();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// 무시
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new NeverEntryError();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else if (ts.isExportDeclaration(node)) {
|
|
114
|
+
if (
|
|
115
|
+
node.exportClause &&
|
|
116
|
+
ts.isNamedExports(node.exportClause) &&
|
|
117
|
+
node.moduleSpecifier &&
|
|
118
|
+
ts.isStringLiteral(node.moduleSpecifier)
|
|
119
|
+
) {
|
|
120
|
+
if (node.moduleSpecifier.text.includes(".")) {
|
|
121
|
+
const moduleFilePath = path.resolve(path.dirname(this.filePath), node.moduleSpecifier.text);
|
|
122
|
+
for (const el of node.exportClause.elements) {
|
|
123
|
+
if (el.propertyName && el.name.text !== el.propertyName.text) {
|
|
124
|
+
throw new NeverEntryError();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
result.push({
|
|
128
|
+
filePath: moduleFilePath,
|
|
129
|
+
name: el.name.text,
|
|
130
|
+
__TSdCliMetaRef__: "__TSdCliMetaRef__" as const
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw new NeverEntryError();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
throw new NeverEntryError();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private _findNamespaceUse(localName: string): string[] {
|
|
148
|
+
const fn = (parent: ts.Node): string[] => {
|
|
149
|
+
const result: string[] = [];
|
|
150
|
+
ts.forEachChild(parent, (node) => {
|
|
151
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
152
|
+
if (
|
|
153
|
+
ts.isIdentifier(node.expression) &&
|
|
154
|
+
node.expression.text === localName &&
|
|
155
|
+
ts.isIdentifier(node.name)
|
|
156
|
+
) {
|
|
157
|
+
result.push(node.name.text);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
result.push(...fn(node));
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
return result;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return fn(this.sourceFile);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public getMetaFromNode(node: ts.Node): TSdCliTsMetadata {
|
|
172
|
+
if (ts.isClassDeclaration(node)) {
|
|
173
|
+
return new SdCliTsClassMetadata(this, node);
|
|
174
|
+
}
|
|
175
|
+
else if (ts.isStringLiteral(node)) {
|
|
176
|
+
return node.text;
|
|
177
|
+
}
|
|
178
|
+
else if (ts.isNoSubstitutionTemplateLiteral(node)) {
|
|
179
|
+
return node.text;
|
|
180
|
+
}
|
|
181
|
+
else if (node.kind === ts.SyntaxKind.NullKeyword) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
throw new NeverEntryError();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export class SdCliTsClassMetadata {
|
|
190
|
+
public constructor(private readonly _fileMeta: SdCliTsFileMetadata,
|
|
191
|
+
private readonly _node: ts.ClassDeclaration) {
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private _ngDeclCache?: TSdCliTsNgMetadata;
|
|
195
|
+
|
|
196
|
+
public get ngDecl(): TSdCliTsNgMetadata | undefined {
|
|
197
|
+
if (this._ngDeclCache !== undefined) return this._ngDeclCache;
|
|
198
|
+
|
|
199
|
+
if (!this._node.decorators) return undefined;
|
|
200
|
+
|
|
201
|
+
for (const deco of this._node.decorators) {
|
|
202
|
+
if (!ts.isCallExpression(deco.expression)) continue;
|
|
203
|
+
if (!ts.isIdentifier(deco.expression.expression)) {
|
|
204
|
+
throw new NeverEntryError();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (deco.expression.expression.text === "Injectable") {
|
|
208
|
+
this._ngDeclCache = new SdCliTsNgInjectableMetadata(this._fileMeta, deco);
|
|
209
|
+
return this._ngDeclCache;
|
|
210
|
+
}
|
|
211
|
+
else if (deco.expression.expression.text === "Directive") {
|
|
212
|
+
this._ngDeclCache = new SdCliTsNgDirectiveMetadata(this._fileMeta, deco);
|
|
213
|
+
return this._ngDeclCache;
|
|
214
|
+
}
|
|
215
|
+
else if (deco.expression.expression.text === "Component") {
|
|
216
|
+
this._ngDeclCache = new SdCliTsNgComponentMetadata(this._fileMeta, deco);
|
|
217
|
+
return this._ngDeclCache;
|
|
218
|
+
}
|
|
219
|
+
else if (deco.expression.expression.text === "Pipe") {
|
|
220
|
+
this._ngDeclCache = new SdCliTsNgPipeMetadata(this._fileMeta, deco);
|
|
221
|
+
return this._ngDeclCache;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export class SdCliTsObjectMetadata {
|
|
230
|
+
public constructor(private readonly _fileMeta: SdCliTsFileMetadata,
|
|
231
|
+
private readonly _node: ts.ObjectLiteralExpression) {
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private readonly _getPropValueCache = new Map<string, TSdCliTsMetadata | undefined>();
|
|
235
|
+
|
|
236
|
+
public getPropValue(propName: string): TSdCliTsMetadata | undefined {
|
|
237
|
+
if (this._getPropValueCache.has(propName)) {
|
|
238
|
+
return this._getPropValueCache.get(propName);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const prop = this._node.properties.single((item) => (
|
|
242
|
+
ts.isPropertyAssignment(item) &&
|
|
243
|
+
ts.isIdentifier(item.name) &&
|
|
244
|
+
item.name.text === propName
|
|
245
|
+
)) as ts.PropertyAssignment | undefined;
|
|
246
|
+
if (!prop) {
|
|
247
|
+
this._getPropValueCache.set(propName, undefined);
|
|
248
|
+
return undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const result = this._fileMeta.getMetaFromNode(prop.initializer);
|
|
252
|
+
this._getPropValueCache.set(propName, result);
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export type TSdCliTsMetadata = SdCliTsClassMetadata
|
|
258
|
+
| SdCliTsObjectMetadata
|
|
259
|
+
| TSdCliMetaRef
|
|
260
|
+
| string
|
|
261
|
+
| null;
|
|
262
|
+
|
|
263
|
+
export class SdCliTsNgInjectableMetadata {
|
|
264
|
+
public constructor(private readonly _fileMeta: SdCliTsFileMetadata,
|
|
265
|
+
private readonly _node: ts.Decorator) {
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
private _providedInCache?: string;
|
|
269
|
+
|
|
270
|
+
public get providedIn(): string | undefined {
|
|
271
|
+
if (this._providedInCache !== undefined) return this._providedInCache;
|
|
272
|
+
|
|
273
|
+
if (!ts.isCallExpression(this._node.expression)) throw new NeverEntryError();
|
|
274
|
+
|
|
275
|
+
if (this._node.expression.arguments.length > 0 && ts.isObjectLiteralExpression(this._node.expression.arguments[0])) {
|
|
276
|
+
const decoArg = new SdCliTsObjectMetadata(this._fileMeta, this._node.expression.arguments[0]);
|
|
277
|
+
const decoArgSelectorVal = decoArg.getPropValue("providedIn");
|
|
278
|
+
if (typeof decoArgSelectorVal === "string") {
|
|
279
|
+
this._providedInCache = decoArgSelectorVal;
|
|
280
|
+
return decoArgSelectorVal;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export class SdCliTsNgDirectiveMetadata {
|
|
289
|
+
public constructor(private readonly _fileMeta: SdCliTsFileMetadata,
|
|
290
|
+
private readonly _node: ts.Decorator) {
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private _selectorCache?: string;
|
|
294
|
+
|
|
295
|
+
public get selector(): string {
|
|
296
|
+
if (this._selectorCache !== undefined) return this._selectorCache;
|
|
297
|
+
|
|
298
|
+
if (!ts.isCallExpression(this._node.expression)) throw new NeverEntryError();
|
|
299
|
+
|
|
300
|
+
if (this._node.expression.arguments.length > 0 && ts.isObjectLiteralExpression(this._node.expression.arguments[0])) {
|
|
301
|
+
const decoArg = new SdCliTsObjectMetadata(this._fileMeta, this._node.expression.arguments[0]);
|
|
302
|
+
const decoArgSelectorVal = decoArg.getPropValue("selector");
|
|
303
|
+
if (typeof decoArgSelectorVal === "string") {
|
|
304
|
+
this._selectorCache = decoArgSelectorVal;
|
|
305
|
+
return decoArgSelectorVal;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
throw new NeverEntryError();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export class SdCliTsNgComponentMetadata {
|
|
314
|
+
public constructor(private readonly _fileMeta: SdCliTsFileMetadata,
|
|
315
|
+
private readonly _node: ts.Decorator) {
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private _selectorCache?: string;
|
|
319
|
+
|
|
320
|
+
public get selector(): string {
|
|
321
|
+
if (this._selectorCache !== undefined) return this._selectorCache;
|
|
322
|
+
|
|
323
|
+
if (!ts.isCallExpression(this._node.expression)) throw new NeverEntryError();
|
|
324
|
+
|
|
325
|
+
if (this._node.expression.arguments.length > 0 && ts.isObjectLiteralExpression(this._node.expression.arguments[0])) {
|
|
326
|
+
const decoArg = new SdCliTsObjectMetadata(this._fileMeta, this._node.expression.arguments[0]);
|
|
327
|
+
const decoArgSelectorVal = decoArg.getPropValue("selector");
|
|
328
|
+
if (typeof decoArgSelectorVal === "string") {
|
|
329
|
+
this._selectorCache = decoArgSelectorVal;
|
|
330
|
+
return decoArgSelectorVal;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
throw new NeverEntryError();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
private _templateCache?: string;
|
|
338
|
+
|
|
339
|
+
public get template(): string {
|
|
340
|
+
if (this._templateCache !== undefined) return this._templateCache;
|
|
341
|
+
|
|
342
|
+
if (!ts.isCallExpression(this._node.expression)) throw new NeverEntryError();
|
|
343
|
+
|
|
344
|
+
if (this._node.expression.arguments.length > 0 && ts.isObjectLiteralExpression(this._node.expression.arguments[0])) {
|
|
345
|
+
const decoArg = new SdCliTsObjectMetadata(this._fileMeta, this._node.expression.arguments[0]);
|
|
346
|
+
const decoArgSelectorVal = decoArg.getPropValue("template");
|
|
347
|
+
if (typeof decoArgSelectorVal === "string") {
|
|
348
|
+
this._templateCache = decoArgSelectorVal;
|
|
349
|
+
return decoArgSelectorVal;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
throw new NeverEntryError();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export class SdCliTsNgPipeMetadata {
|
|
358
|
+
public constructor(private readonly _fileMeta: SdCliTsFileMetadata,
|
|
359
|
+
private readonly _node: ts.Decorator) {
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private _pipeNameCache?: string;
|
|
363
|
+
|
|
364
|
+
public get pipeName(): string {
|
|
365
|
+
if (this._pipeNameCache !== undefined) return this._pipeNameCache;
|
|
366
|
+
|
|
367
|
+
if (!ts.isCallExpression(this._node.expression)) throw new NeverEntryError();
|
|
368
|
+
|
|
369
|
+
if (this._node.expression.arguments.length > 0 && ts.isObjectLiteralExpression(this._node.expression.arguments[0])) {
|
|
370
|
+
const decoArg = new SdCliTsObjectMetadata(this._fileMeta, this._node.expression.arguments[0]);
|
|
371
|
+
const decoArgSelectorVal = decoArg.getPropValue("name");
|
|
372
|
+
if (typeof decoArgSelectorVal === "string") {
|
|
373
|
+
this._pipeNameCache = decoArgSelectorVal;
|
|
374
|
+
return decoArgSelectorVal;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
throw new NeverEntryError();
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export type TSdCliTsNgMetadata = SdCliTsNgInjectableMetadata
|
|
383
|
+
| SdCliTsNgDirectiveMetadata
|
|
384
|
+
| SdCliTsNgComponentMetadata
|
|
385
|
+
| SdCliTsNgPipeMetadata;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { FsUtil } from "@simplysm/sd-core-node";
|
|
4
|
+
import { SdCliTsFileMetadata } from "./SdCliTsFileMetadata";
|
|
5
|
+
|
|
6
|
+
export class SdCliTsRootMetadata {
|
|
7
|
+
private readonly _fileMetaCache = new Map<string, SdCliTsFileMetadata>();
|
|
8
|
+
|
|
9
|
+
public constructor(private readonly _packagePath: string) {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public removeCaches(filePaths: string[]): void {
|
|
13
|
+
for (const filePath of filePaths) {
|
|
14
|
+
this._fileMetaCache.delete(filePath);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public getFileMetas(): SdCliTsFileMetadata[] {
|
|
19
|
+
const tsconfigPath = path.resolve(this._packagePath, "tsconfig-build.json");
|
|
20
|
+
const tsconfig = FsUtil.readJson(tsconfigPath);
|
|
21
|
+
const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this._packagePath, tsconfig.angularCompilerOptions);
|
|
22
|
+
|
|
23
|
+
const result: SdCliTsFileMetadata[] = [];
|
|
24
|
+
for (const fileName of parsedTsconfig.fileNames) {
|
|
25
|
+
const filePath = path.resolve(fileName);
|
|
26
|
+
const fileMeta = this._fileMetaCache.getOrCreate(filePath, () => new SdCliTsFileMetadata(filePath));
|
|
27
|
+
result.push(fileMeta);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { SdCliBuildResultError } from "../../SdCliBuildResultError";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export class SdCliTsUtil {
|
|
6
|
+
public static error(message: string, sourceFile: ts.SourceFile, meta?: ts.Node): SdCliBuildResultError {
|
|
7
|
+
if (meta) {
|
|
8
|
+
const pos = sourceFile.getLineAndCharacterOfPosition(meta.getStart());
|
|
9
|
+
return new SdCliBuildResultError({
|
|
10
|
+
filePath: path.resolve(sourceFile.fileName),
|
|
11
|
+
line: pos.line,
|
|
12
|
+
char: pos.character,
|
|
13
|
+
code: undefined,
|
|
14
|
+
severity: "error",
|
|
15
|
+
message: message
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return new SdCliBuildResultError({
|
|
20
|
+
filePath: path.resolve(sourceFile.fileName),
|
|
21
|
+
line: undefined,
|
|
22
|
+
char: undefined,
|
|
23
|
+
code: undefined,
|
|
24
|
+
severity: "error",
|
|
25
|
+
message: message
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -96,8 +96,7 @@ export class SdCliPackage extends EventEmitter {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
if (this.config.type === "library") {
|
|
99
|
-
|
|
100
|
-
return isTs ? new SdCliTsLibBuilder(this.rootPath) : new SdCliJsLibBuilder(this.rootPath);
|
|
99
|
+
return isTs ? new SdCliTsLibBuilder(this.rootPath, this.config, this._workspaceRootPath) : new SdCliJsLibBuilder(this.rootPath);
|
|
101
100
|
}
|
|
102
101
|
else if (this.config.type === "server") {
|
|
103
102
|
return new SdCliServerBuilder(this.rootPath, this.config, this._workspaceRootPath);
|
|
@@ -5,11 +5,11 @@ export class SdCliNpmConfigUtil {
|
|
|
5
5
|
return {
|
|
6
6
|
defaults: [
|
|
7
7
|
...Object.keys(npmConfig.dependencies ?? {}),
|
|
8
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => !npmConfig.peerDependenciesMeta?.[item]
|
|
8
|
+
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => !npmConfig.peerDependenciesMeta?.[item]?.optional)
|
|
9
9
|
].distinct(),
|
|
10
10
|
optionals: [
|
|
11
11
|
...Object.keys(npmConfig.optionalDependencies ?? {}),
|
|
12
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => npmConfig.peerDependenciesMeta?.[item]
|
|
12
|
+
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => npmConfig.peerDependenciesMeta?.[item]?.optional)
|
|
13
13
|
].distinct()
|
|
14
14
|
};
|
|
15
15
|
}
|
package/tsconfig-build.json
CHANGED