@simplysm/sd-cli 7.0.65 → 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.
Files changed (70) hide show
  1. package/dist/SdCliBuildResultError.d.ts +5 -0
  2. package/dist/bin/sd-cli.d.ts +2 -0
  3. package/dist/bin/sd-cli.mjs +3 -3
  4. package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
  5. package/dist/build-tool/SdCliCordova.d.ts +16 -0
  6. package/dist/build-tool/SdCliCordova.mjs +171 -0
  7. package/dist/build-tool/SdCliIndexFileGenerator.d.ts +13 -0
  8. package/dist/{entry-points → build-tool}/SdCliIndexFileGenerator.mjs +4 -3
  9. package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
  10. package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
  11. package/dist/build-tool/SdCliPackageLinter.mjs +19 -2
  12. package/dist/builder/SdCliClientBuilder.d.ts +23 -0
  13. package/dist/builder/SdCliClientBuilder.mjs +68 -6
  14. package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
  15. package/dist/builder/SdCliServerBuilder.d.ts +25 -0
  16. package/dist/builder/SdCliServerBuilder.mjs +11 -13
  17. package/dist/builder/SdCliTsLibBuilder.d.ts +34 -0
  18. package/dist/builder/SdCliTsLibBuilder.mjs +83 -36
  19. package/dist/commons.d.ts +85 -0
  20. package/dist/entry-points/SdCliLocalUpdate.d.ts +13 -0
  21. package/dist/entry-points/SdCliNpm.d.ts +6 -0
  22. package/dist/entry-points/SdCliPrepare.d.ts +5 -0
  23. package/dist/entry-points/SdCliWorkspace.d.ts +28 -0
  24. package/dist/entry-points/SdCliWorkspace.mjs +12 -16
  25. package/dist/index.d.ts +29 -0
  26. package/dist/index.mjs +5 -3
  27. package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +26 -0
  28. package/dist/ng-tools/SdCliNgModuleGenerator.mjs +404 -0
  29. package/dist/ng-tools/babel/SdCliBbFileMetadata.d.ts +23 -0
  30. package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +187 -36
  31. package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +22 -0
  32. package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +10 -7
  33. package/dist/ng-tools/babel/SdCliBbUtil.d.ts +5 -0
  34. package/dist/ng-tools/babel/SdCliBbUtil.mjs +2 -2
  35. package/dist/ng-tools/babel/TSdCliBbNgMetadata.d.ts +42 -0
  36. package/dist/ng-tools/babel/TSdCliBbNgMetadata.mjs +107 -76
  37. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +44 -0
  38. package/dist/ng-tools/commons.d.ts +9 -0
  39. package/dist/ng-tools/typescript/SdCliTsFileMetadata.d.ts +61 -0
  40. package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +13 -12
  41. package/dist/ng-tools/typescript/SdCliTsRootMetadata.d.ts +8 -0
  42. package/dist/ng-tools/typescript/SdCliTsUtil.d.ts +5 -0
  43. package/dist/ng-tools/typescript/SdCliTsUtil.mjs +28 -0
  44. package/dist/packages/SdCliPackage.d.ts +23 -0
  45. package/dist/packages/SdCliPackage.mjs +2 -3
  46. package/dist/utils/SdCliBuildResultUtil.d.ts +9 -0
  47. package/dist/utils/SdCliConfigUtil.d.ts +7 -0
  48. package/dist/utils/SdCliNpmConfigUtil.d.ts +7 -0
  49. package/package.json +11 -6
  50. package/src/bin/sd-cli.ts +2 -2
  51. package/src/build-tool/SdCliCordova.ts +219 -0
  52. package/src/{entry-points → build-tool}/SdCliIndexFileGenerator.ts +3 -2
  53. package/src/build-tool/SdCliPackageLinter.ts +18 -2
  54. package/src/builder/SdCliClientBuilder.ts +83 -5
  55. package/src/builder/SdCliServerBuilder.ts +10 -12
  56. package/src/builder/SdCliTsLibBuilder.ts +100 -44
  57. package/src/commons.ts +24 -0
  58. package/src/entry-points/SdCliWorkspace.ts +14 -17
  59. package/src/index.ts +4 -2
  60. package/src/ng-tools/{NgModuleGenerator.ts → SdCliNgModuleGenerator.ts} +241 -64
  61. package/src/ng-tools/babel/SdCliBbFileMetadata.ts +234 -38
  62. package/src/ng-tools/babel/SdCliBbRootMetadata.ts +10 -6
  63. package/src/ng-tools/babel/SdCliBbUtil.ts +1 -1
  64. package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +36 -22
  65. package/src/ng-tools/commons.ts +1 -1
  66. package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +13 -12
  67. package/src/ng-tools/typescript/SdCliTsUtil.ts +29 -0
  68. package/src/packages/SdCliPackage.ts +1 -2
  69. package/tsconfig-build.json +1 -1
  70. package/dist/ng-tools/NgModuleGenerator.mjs +0 -278
@@ -1,25 +1,32 @@
1
1
  import {
2
2
  Declaration,
3
3
  Expression,
4
+ File,
4
5
  isArrayExpression,
6
+ isAssignmentExpression,
7
+ isCallExpression,
5
8
  isClassDeclaration,
6
9
  isExportDeclaration,
7
10
  isExportDefaultDeclaration,
8
11
  isExportNamedDeclaration,
9
12
  isExportSpecifier,
13
+ isExpressionStatement,
10
14
  isFunctionDeclaration,
11
15
  isIdentifier,
12
16
  isImportDeclaration,
17
+ isImportDefaultSpecifier,
13
18
  isImportSpecifier,
19
+ isMemberExpression,
14
20
  isObjectExpression,
15
21
  isSpreadElement,
16
22
  isStringLiteral,
17
23
  isVariableDeclaration,
18
24
  PatternLike,
19
25
  SpreadElement,
20
- Statement
26
+ Statement,
27
+ traverseFast
21
28
  } from "@babel/types";
22
- import babelParser from "@babel/parser";
29
+ import babelParser, { ParseResult } from "@babel/parser";
23
30
  import { FsUtil } from "@simplysm/sd-core-node";
24
31
  import path from "path";
25
32
  import { TSdCliBbMetadata } from "./SdCliBbRootMetadata";
@@ -31,14 +38,16 @@ import {
31
38
  SdCliBbVariableMetadata
32
39
  } from "./TSdCliBbTypeMetadata";
33
40
  import { SdCliBbUtil } from "./SdCliBbUtil";
41
+ import { NeverEntryError } from "@simplysm/sd-core-common";
34
42
 
35
43
  export class SdCliBbFileMetadata {
36
- public readonly rawMetas: Statement[] = [];
44
+ public readonly ast: ParseResult<File>;
45
+ public readonly rawMetas: Statement[];
37
46
 
38
47
  public constructor(public readonly filePath: string) {
39
48
  let realFilePath: string | undefined;
40
49
  for (const ext of ["", ".mjs", ".cjs", ".js"]) {
41
- if (FsUtil.exists(filePath + ext) && !FsUtil.isDirectory(filePath + ext)) {
50
+ if (FsUtil.exists(filePath + ext) && !FsUtil.stat(filePath + ext).isDirectory()) {
42
51
  realFilePath = filePath + ext;
43
52
  break;
44
53
  }
@@ -48,7 +57,8 @@ export class SdCliBbFileMetadata {
48
57
  }
49
58
 
50
59
  const fileContent = FsUtil.readFile(realFilePath);
51
- this.rawMetas = babelParser.parse(fileContent, { sourceType: "module" }).program.body;
60
+ this.ast = babelParser.parse(fileContent, { sourceType: "module" });
61
+ this.rawMetas = this.ast.program.body;
52
62
  }
53
63
 
54
64
  private _exportsCache?: { exportedName: string; target: TSdCliBbMetadata }[];
@@ -61,44 +71,81 @@ export class SdCliBbFileMetadata {
61
71
  if (!isExportDeclaration(rawMeta)) continue;
62
72
 
63
73
  if (isExportNamedDeclaration(rawMeta)) {
64
- for (const specifier of rawMeta.specifiers) {
65
- if (isExportSpecifier(specifier)) {
66
- const exportedName = isIdentifier(specifier.exported) ? specifier.exported.name : undefined;
67
- if (exportedName === undefined) {
68
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
69
- }
70
-
71
- if (rawMeta.source) {
72
- if (rawMeta.source.value.includes(".")) {
73
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
74
+ if (rawMeta.declaration) {
75
+ if (isVariableDeclaration(rawMeta.declaration)) {
76
+ for (const decl of rawMeta.declaration.declarations) {
77
+ if (isIdentifier(decl.id)) {
74
78
  result.push({
75
- exportedName,
76
- target: {
77
- filePath: moduleFilePath,
78
- name: specifier.local.name,
79
- __TDeclRef__: "__TDeclRef__"
80
- }
79
+ exportedName: decl.id.name,
80
+ target: new SdCliBbVariableMetadata(this, decl)
81
81
  });
82
82
  }
83
83
  else {
84
- const moduleName = rawMeta.source.value;
85
- result.push({
86
- exportedName,
87
- target: { moduleName, name: specifier.local.name, __TDeclRef__: "__TDeclRef__" }
88
- });
84
+ throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
89
85
  }
90
86
  }
91
- else {
87
+ }
88
+ else if (isClassDeclaration(rawMeta.declaration)) {
89
+ result.push({
90
+ exportedName: rawMeta.declaration.id.name,
91
+ target: new SdCliBbClassMetadata(this, rawMeta.declaration)
92
+ });
93
+ }
94
+ else if (isFunctionDeclaration(rawMeta.declaration)) {
95
+ if (rawMeta.declaration.id) {
92
96
  result.push({
93
- exportedName,
94
- target: this._findMetaFromInside(specifier.local.name)
97
+ exportedName: rawMeta.declaration.id.name,
98
+ target: new SdCliBbFunctionMetadata(this, rawMeta.declaration)
95
99
  });
96
100
  }
101
+ else {
102
+ throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
103
+ }
97
104
  }
98
105
  else {
99
106
  throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
100
107
  }
101
108
  }
109
+ else {
110
+ for (const specifier of rawMeta.specifiers) {
111
+ if (isExportSpecifier(specifier)) {
112
+ const exportedName = isIdentifier(specifier.exported) ? specifier.exported.name : undefined;
113
+ if (exportedName === undefined) {
114
+ throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
115
+ }
116
+
117
+ if (rawMeta.source) {
118
+ if (rawMeta.source.value.includes(".")) {
119
+ const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
120
+ result.push({
121
+ exportedName,
122
+ target: {
123
+ filePath: moduleFilePath,
124
+ name: specifier.local.name,
125
+ __TSdCliMetaRef__: "__TSdCliMetaRef__"
126
+ }
127
+ });
128
+ }
129
+ else {
130
+ const moduleName = rawMeta.source.value;
131
+ result.push({
132
+ exportedName,
133
+ target: { moduleName, name: specifier.local.name, __TSdCliMetaRef__: "__TSdCliMetaRef__" }
134
+ });
135
+ }
136
+ }
137
+ else {
138
+ result.push({
139
+ exportedName,
140
+ target: this._findMetaFromInside(specifier.local.name)
141
+ });
142
+ }
143
+ }
144
+ else {
145
+ throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
146
+ }
147
+ }
148
+ }
102
149
  }
103
150
  else if (isExportDefaultDeclaration(rawMeta)) {
104
151
  result.push({
@@ -114,7 +161,7 @@ export class SdCliBbFileMetadata {
114
161
  target: {
115
162
  filePath: moduleFilePath,
116
163
  name: "*",
117
- __TDeclRef__: "__TDeclRef__"
164
+ __TSdCliMetaRef__: "__TSdCliMetaRef__"
118
165
  }
119
166
  });
120
167
  }
@@ -130,7 +177,7 @@ export class SdCliBbFileMetadata {
130
177
 
131
178
  private readonly _findMetaFromOutsideCache = new Map<string, TSdCliBbMetadata>();
132
179
 
133
- public findMetaFromOutside(name: string): TSdCliBbMetadata {
180
+ public findMetaFromOutside(name: string): TSdCliBbMetadata | undefined {
134
181
  const cache = this._findMetaFromOutsideCache.get(name);
135
182
  if (cache !== undefined) return cache;
136
183
 
@@ -188,7 +235,7 @@ export class SdCliBbFileMetadata {
188
235
  const result = {
189
236
  filePath: moduleFilePath,
190
237
  name: specifier.local.name,
191
- __TDeclRef__: "__TDeclRef__" as const
238
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
192
239
  };
193
240
  this._findMetaFromOutsideCache.set(name, result);
194
241
  return result;
@@ -198,7 +245,7 @@ export class SdCliBbFileMetadata {
198
245
  const result = {
199
246
  moduleName,
200
247
  name: specifier.local.name,
201
- __TDeclRef__: "__TDeclRef__" as const
248
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
202
249
  };
203
250
  this._findMetaFromOutsideCache.set(name, result);
204
251
  return result;
@@ -224,7 +271,7 @@ export class SdCliBbFileMetadata {
224
271
  }
225
272
  }
226
273
 
227
- throw SdCliBbUtil.error(`'${name}'에 대한 'export'를 찾을 수 없습니다.`, this.filePath);
274
+ return undefined;
228
275
  }
229
276
 
230
277
  private readonly _findMetaFromInsideCache = new Map<string, TSdCliBbMetadata>();
@@ -251,7 +298,7 @@ export class SdCliBbFileMetadata {
251
298
  const result = {
252
299
  filePath: moduleFilePath,
253
300
  name: specifier.local.name,
254
- __TDeclRef__: "__TDeclRef__" as const
301
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
255
302
  };
256
303
  this._findMetaFromInsideCache.set(localName, result);
257
304
  return result;
@@ -261,7 +308,7 @@ export class SdCliBbFileMetadata {
261
308
  const result = {
262
309
  moduleName,
263
310
  name: specifier.local.name,
264
- __TDeclRef__: "__TDeclRef__" as const
311
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
265
312
  };
266
313
  this._findMetaFromInsideCache.set(localName, result);
267
314
  return result;
@@ -293,7 +340,7 @@ export class SdCliBbFileMetadata {
293
340
  const result = {
294
341
  filePath: moduleFilePath,
295
342
  name: specifier.imported.name,
296
- __TDeclRef__: "__TDeclRef__" as const
343
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
297
344
  };
298
345
  this._findMetaFromInsideCache.set(localName, result);
299
346
  return result;
@@ -303,7 +350,7 @@ export class SdCliBbFileMetadata {
303
350
  const result = {
304
351
  moduleName,
305
352
  name: specifier.imported.name,
306
- __TDeclRef__: "__TDeclRef__" as const
353
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
307
354
  };
308
355
  this._findMetaFromInsideCache.set(localName, result);
309
356
  return result;
@@ -314,6 +361,30 @@ export class SdCliBbFileMetadata {
314
361
  }
315
362
  }
316
363
  }
364
+ else if (isImportDefaultSpecifier(specifier)) {
365
+ if (specifier.local.name === localName) {
366
+ if (rawMeta.source.value.includes(".")) {
367
+ const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
368
+ const result = {
369
+ filePath: moduleFilePath,
370
+ name: "default",
371
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
372
+ };
373
+ this._findMetaFromInsideCache.set(localName, result);
374
+ return result;
375
+ }
376
+ else {
377
+ const moduleName = rawMeta.source.value;
378
+ const result = {
379
+ moduleName,
380
+ name: "default",
381
+ __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
382
+ };
383
+ this._findMetaFromInsideCache.set(localName, result);
384
+ return result;
385
+ }
386
+ }
387
+ }
317
388
  }
318
389
  }
319
390
  else if (isVariableDeclaration(rawMeta)) {
@@ -369,4 +440,129 @@ export class SdCliBbFileMetadata {
369
440
 
370
441
  throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
371
442
  }
443
+
444
+ private readonly _getNgDecoArgCache = new Map<string, SdCliBbObjectMetadata>();
445
+
446
+ public getNgDecoArg(className: string): SdCliBbObjectMetadata {
447
+ if (this._getNgDecoArgCache.has(className)) {
448
+ return this._getNgDecoArgCache.get(className)!;
449
+ }
450
+
451
+ for (const meta of this.rawMetas) {
452
+ // 'compilationMode: partial' 일때
453
+ if (
454
+ isExpressionStatement(meta) &&
455
+ isCallExpression(meta.expression) &&
456
+ (
457
+ (
458
+ isMemberExpression(meta.expression.callee) &&
459
+ isIdentifier(meta.expression.callee.property) &&
460
+ meta.expression.callee.property.name === "ɵɵngDeclareClassMetadata"
461
+ ) ||
462
+ (
463
+ isIdentifier(meta.expression.callee) &&
464
+ meta.expression.callee.name === "ngDeclareClassMetadata"
465
+ )
466
+ ) &&
467
+ isObjectExpression(meta.expression.arguments[0])
468
+ ) {
469
+ const objMeta = new SdCliBbObjectMetadata(this, meta.expression.arguments[0]);
470
+ const typePropVal = objMeta.getPropValue("type");
471
+ if (
472
+ typePropVal instanceof SdCliBbClassMetadata &&
473
+ typePropVal.name === className
474
+ ) {
475
+ const decos = objMeta.getPropValue("decorators");
476
+ if (
477
+ decos instanceof SdCliBbArrayMetadata &&
478
+ decos.value[0] instanceof SdCliBbObjectMetadata
479
+ ) {
480
+ const args = decos.value[0].getPropValue("args");
481
+ if (
482
+ args instanceof SdCliBbArrayMetadata &&
483
+ args.value[0] instanceof SdCliBbObjectMetadata
484
+ ) {
485
+ this._getNgDecoArgCache.set(className, args.value[0]);
486
+ return args.value[0];
487
+ }
488
+ }
489
+ else {
490
+ throw new NeverEntryError();
491
+ }
492
+ }
493
+ }
494
+ }
495
+
496
+ // 'compilationMode: full' 일때
497
+ let result: SdCliBbObjectMetadata | undefined;
498
+ traverseFast(this.ast, (node) => {
499
+ if (
500
+ isCallExpression(node) &&
501
+ (
502
+ (
503
+ isMemberExpression(node.callee) &&
504
+ isIdentifier(node.callee.property) &&
505
+ node.callee.property.name === "ɵsetClassMetadata"
506
+ ) ||
507
+ (
508
+ isIdentifier(node.callee) &&
509
+ node.callee.name === "setClassMetadata"
510
+ )
511
+ ) &&
512
+ isIdentifier(node.arguments[0]) &&
513
+ node.arguments[0].name === className &&
514
+ isArrayExpression(node.arguments[1])
515
+ ) {
516
+ const decos = new SdCliBbArrayMetadata(this, node.arguments[1]);
517
+ if (decos.value[0] instanceof SdCliBbObjectMetadata) {
518
+ const args = decos.value[0].getPropValue("args");
519
+ if (
520
+ args instanceof SdCliBbArrayMetadata &&
521
+ args.value[0] instanceof SdCliBbObjectMetadata
522
+ ) {
523
+ result = args.value[0];
524
+ }
525
+ }
526
+ else {
527
+ throw new NeverEntryError();
528
+ }
529
+ }
530
+ });
531
+
532
+ if (result === undefined) {
533
+ throw new NeverEntryError(this.filePath + "," + className);
534
+ }
535
+
536
+ this._getNgDecoArgCache.set(className, result);
537
+ return result;
538
+ }
539
+
540
+ public getNgDecoPropValue(className: string, decoName: string, propName: string): TSdCliBbMetadata | undefined {
541
+ for (const meta of this.rawMetas) {
542
+ if (
543
+ isExpressionStatement(meta) &&
544
+ isAssignmentExpression(meta.expression) &&
545
+ isMemberExpression(meta.expression.left) &&
546
+ isIdentifier(meta.expression.left.object) &&
547
+ meta.expression.left.object.name === className &&
548
+ isIdentifier(meta.expression.left.property)
549
+ ) {
550
+ if (meta.expression.left.property.name === decoName) {
551
+ if (
552
+ isCallExpression(meta.expression.right) &&
553
+ meta.expression.right.arguments.length > 0 &&
554
+ isObjectExpression(meta.expression.right.arguments[0])
555
+ ) {
556
+ const dirObjMeta = new SdCliBbObjectMetadata(this, meta.expression.right.arguments[0]);
557
+ return dirObjMeta.getPropValue(propName);
558
+ }
559
+ else {
560
+ throw new NeverEntryError();
561
+ }
562
+ }
563
+ }
564
+ }
565
+
566
+ throw new NeverEntryError();
567
+ }
372
568
  }
@@ -43,7 +43,7 @@ export class SdCliBbRootMetadata {
43
43
  const result: TSdCliBbMetadata[] = [];
44
44
  for (const exp of fileMeta.exports) {
45
45
  const meta = exp.target;
46
- if (typeof meta !== "string" && "__TDeclRef__" in meta) {
46
+ if (typeof meta !== "string" && "__TSdCliMetaRef__" in meta) {
47
47
  const resultMeta = this.findMeta(meta);
48
48
  if (resultMeta instanceof Array) {
49
49
  result.push(...resultMeta);
@@ -60,7 +60,11 @@ export class SdCliBbRootMetadata {
60
60
  }
61
61
  else {
62
62
  const meta = fileMeta.findMetaFromOutside(ref.name);
63
- if (typeof meta !== "string" && "__TDeclRef__" in meta) {
63
+ if (meta === undefined) {
64
+ throw new NeverEntryError();
65
+ }
66
+
67
+ if (typeof meta !== "string" && "__TSdCliMetaRef__" in meta) {
64
68
  return this.findMeta(meta);
65
69
  }
66
70
  return meta;
@@ -78,7 +82,7 @@ export class SdCliBbRootMetadata {
78
82
  exp.target.filePath === localRef.filePath
79
83
  ) {
80
84
  if (exp.target.name === "*") {
81
- throw new NeverEntryError();
85
+ return { moduleName, name: localRef.name };
82
86
  }
83
87
  else if (exp.target.name === localRef.name) {
84
88
  return { moduleName, name: exp.exportedName };
@@ -139,7 +143,7 @@ export class SdCliBbRootMetadata {
139
143
  const npmConfig = FsUtil.readJson(path.resolve(ngDepPath, "package.json")) as INpmConfig;
140
144
 
141
145
  const entryFilePath = npmConfig["es2015"] ?? npmConfig["browser"] ?? npmConfig["module"] ?? npmConfig["main"] ?? npmConfig["default"];
142
- if (entryFilePath !== undefined) {
146
+ if (typeof entryFilePath === "string") {
143
147
  entryMap.set(npmConfig.name, path.resolve(ngDepPath, entryFilePath));
144
148
  }
145
149
 
@@ -148,7 +152,7 @@ export class SdCliBbRootMetadata {
148
152
  for (const exportKey of exportKeys) {
149
153
  if (
150
154
  exportKey.includes("/locales") ||
151
- exportKey.endsWith("/package.json") ||
155
+ exportKey.endsWith(".json") ||
152
156
  exportKey.endsWith("/testing") ||
153
157
  exportKey.endsWith("/upgrade")
154
158
  ) {
@@ -160,7 +164,7 @@ export class SdCliBbRootMetadata {
160
164
  npmConfig.exports[exportKey]["module"] ??
161
165
  npmConfig.exports[exportKey]["main"] ??
162
166
  npmConfig.exports[exportKey]["default"];
163
- if (expEntryFilePath !== undefined) {
167
+ if (typeof expEntryFilePath === "string") {
164
168
  const exportPath = path.resolve(ngDepPath, expEntryFilePath);
165
169
  const exportResult = this._getGlobExportResult(PathUtil.posix(npmConfig.name, exportKey), exportPath);
166
170
  for (const exportResultItem of exportResult) {
@@ -9,7 +9,7 @@ export class SdCliBbUtil {
9
9
  char: meta?.loc?.start.column,
10
10
  code: undefined,
11
11
  severity: "error",
12
- message: "예상치 못한 방식의 코드가 발견되었습니다."
12
+ message: message
13
13
  });
14
14
  }
15
15
  }
@@ -1,14 +1,6 @@
1
- import {
2
- isAssignmentExpression,
3
- isCallExpression,
4
- isExpressionStatement,
5
- isIdentifier,
6
- isMemberExpression,
7
- isObjectExpression
8
- } from "@babel/types";
9
1
  import { NeverEntryError } from "@simplysm/sd-core-common";
10
2
  import { SdCliBbFileMetadata } from "./SdCliBbFileMetadata";
11
- import { SdCliBbArrayMetadata, SdCliBbObjectMetadata, SdCliBbVariableMetadata } from "./TSdCliBbTypeMetadata";
3
+ import { SdCliBbArrayMetadata, SdCliBbVariableMetadata } from "./TSdCliBbTypeMetadata";
12
4
  import { TSdCliBbMetadata } from "./SdCliBbRootMetadata";
13
5
 
14
6
  export type TSdCliBbNgMetadata =
@@ -33,7 +25,21 @@ export class SdCliBbNgModuleMetadata {
33
25
  providers: []
34
26
  };
35
27
 
36
- for (const meta of this._fileMeta.rawMetas) {
28
+ const argObjMeta = this._fileMeta.getNgDecoArg(this._className);
29
+
30
+ const expVal = argObjMeta.getPropValue("exports") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵmod", "exports");
31
+ if (expVal !== undefined) {
32
+ const expMetas = this._getExportAndProviderMetas(expVal);
33
+ result.exports.push(...expMetas);
34
+ }
35
+
36
+ const provVal = argObjMeta.getPropValue("providers") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵmod", "providers");
37
+ if (provVal !== undefined) {
38
+ const provMetas = this._getExportAndProviderMetas(provVal);
39
+ result.providers.push(...provMetas);
40
+ }
41
+
42
+ /*for (const meta of this._fileMeta.rawMetas) {
37
43
  if (
38
44
  isExpressionStatement(meta) &&
39
45
  isAssignmentExpression(meta.expression) &&
@@ -86,24 +92,23 @@ export class SdCliBbNgModuleMetadata {
86
92
  }
87
93
  }
88
94
  }
89
- }
95
+ }*/
90
96
 
91
97
  this._defCache = result;
92
98
  return result;
93
99
  }
94
100
 
95
-
96
- private _getProviderMetas(meta: TSdCliBbMetadata): TSdCliBbMetadata[] {
101
+ private _getExportAndProviderMetas(meta: TSdCliBbMetadata): TSdCliBbMetadata[] {
97
102
  const result: TSdCliBbMetadata[] = [];
98
103
 
99
104
  if (meta instanceof SdCliBbArrayMetadata) {
100
105
  for (const metaItem of meta.value.filterExists()) {
101
- result.push(...this._getProviderMetas(metaItem));
106
+ result.push(...this._getExportAndProviderMetas(metaItem));
102
107
  }
103
108
  }
104
109
  else if (meta instanceof SdCliBbVariableMetadata) {
105
110
  if (meta.value !== undefined) {
106
- result.push(...this._getProviderMetas(meta.value));
111
+ result.push(...this._getExportAndProviderMetas(meta.value));
107
112
  }
108
113
  }
109
114
  else {
@@ -115,8 +120,12 @@ export class SdCliBbNgModuleMetadata {
115
120
  }
116
121
 
117
122
  export class SdCliBbNgInjectableMetadata {
118
- public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
119
- private readonly _className: string) {
123
+
124
+ public constructor(
125
+ // @ts-expect-error
126
+ private readonly _fileMeta: SdCliBbFileMetadata,
127
+ // @ts-expect-error
128
+ private readonly _className: string) {
120
129
  }
121
130
  }
122
131
 
@@ -130,10 +139,11 @@ export class SdCliBbNgDirectiveMetadata {
130
139
  public get selector(): string {
131
140
  if (this._selectorCache !== undefined) return this._selectorCache;
132
141
 
133
- const val = SdCliNgMetadataUtil.getDecoPropValue(this._fileMeta, this._className, "ɵdir", "selector");
142
+ const argObjMeta = this._fileMeta.getNgDecoArg(this._className);
143
+ const val = argObjMeta.getPropValue("selector") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵdir", "selector");
134
144
  if (typeof val === "string") {
135
145
  this._selectorCache = val;
136
- return val;
146
+ return this._selectorCache;
137
147
  }
138
148
  else {
139
149
  throw new NeverEntryError();
@@ -151,10 +161,11 @@ export class SdCliBbNgComponentMetadata {
151
161
  public get selector(): string {
152
162
  if (this._selectorCache !== undefined) return this._selectorCache;
153
163
 
154
- const val = SdCliNgMetadataUtil.getDecoPropValue(this._fileMeta, this._className, "ɵcmp", "selector");
164
+ const argObjMeta = this._fileMeta.getNgDecoArg(this._className);
165
+ const val = argObjMeta.getPropValue("selector") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵcmp", "selector");
155
166
  if (typeof val === "string") {
156
167
  this._selectorCache = val;
157
- return val;
168
+ return this._selectorCache;
158
169
  }
159
170
  else {
160
171
  throw new NeverEntryError();
@@ -172,7 +183,8 @@ export class SdCliBbNgPipeMetadata {
172
183
  public get pipeName(): string {
173
184
  if (this._pipeNameCache !== undefined) return this._pipeNameCache;
174
185
 
175
- const val = SdCliNgMetadataUtil.getDecoPropValue(this._fileMeta, this._className, "ɵpipe", "name");
186
+ const argObjMeta = this._fileMeta.getNgDecoArg(this._className);
187
+ const val = argObjMeta.getPropValue("name") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵpipe", "name");
176
188
  if (typeof val === "string") {
177
189
  this._pipeNameCache = val;
178
190
  return val;
@@ -188,6 +200,7 @@ interface ISdCliBbNgModuleDef {
188
200
  providers: TSdCliBbMetadata[];
189
201
  }
190
202
 
203
+ /*
191
204
  class SdCliNgMetadataUtil {
192
205
  public static getDecoPropValue(fileMeta: SdCliBbFileMetadata, className: string, decoName: string, propName: string): TSdCliBbMetadata | undefined {
193
206
  for (const meta of fileMeta.rawMetas) {
@@ -218,3 +231,4 @@ class SdCliNgMetadataUtil {
218
231
  throw new NeverEntryError();
219
232
  }
220
233
  }
234
+ */
@@ -1,3 +1,3 @@
1
1
  export type TSdCliMetaRef =
2
2
  ({ filePath: string; name: string } | { moduleName: string; name: string })
3
- & { __TDeclRef__: "__TDeclRef__" };
3
+ & { __TSdCliMetaRef__: "__TSdCliMetaRef__" };