@simplysm/sd-cli 7.3.1 → 10.0.4

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 (217) hide show
  1. package/.eslintrc.cjs +18 -0
  2. package/dist/build-cluster.js +75 -0
  3. package/dist/build-cluster.js.map +1 -0
  4. package/dist/builders/SdCliJsLibLinter.d.ts +18 -0
  5. package/dist/builders/SdCliJsLibLinter.js +69 -0
  6. package/dist/builders/SdCliJsLibLinter.js.map +1 -0
  7. package/dist/builders/SdCliTsLibBuilder.d.ts +20 -0
  8. package/dist/builders/SdCliTsLibBuilder.js +205 -0
  9. package/dist/builders/SdCliTsLibBuilder.js.map +1 -0
  10. package/dist/commons.d.ts +3 -117
  11. package/dist/commons.js +2 -0
  12. package/dist/commons.js.map +1 -0
  13. package/dist/entry/SdCliProject.d.ts +28 -0
  14. package/dist/entry/SdCliProject.js +269 -0
  15. package/dist/entry/SdCliProject.js.map +1 -0
  16. package/dist/sd-cli.js +118 -0
  17. package/dist/sd-cli.js.map +1 -0
  18. package/dist/utils/SdCliBuildResultUtil.d.ts +1 -4
  19. package/dist/utils/SdCliBuildResultUtil.js +37 -0
  20. package/dist/utils/SdCliBuildResultUtil.js.map +1 -0
  21. package/dist/utils/SdCliConfigUtil.js +69 -0
  22. package/dist/utils/SdCliConfigUtil.js.map +1 -0
  23. package/package.json +10 -59
  24. package/src/build-cluster.ts +82 -0
  25. package/src/builders/SdCliJsLibLinter.ts +84 -0
  26. package/src/builders/SdCliTsLibBuilder.ts +265 -0
  27. package/src/commons.ts +3 -123
  28. package/src/entry/SdCliProject.ts +351 -0
  29. package/src/sd-cli.ts +135 -0
  30. package/src/utils/SdCliBuildResultUtil.ts +5 -38
  31. package/tsconfig.json +18 -0
  32. package/README.md +0 -105
  33. package/assets/client-files/assets/icons/icon-128x128.png +0 -0
  34. package/assets/client-files/assets/icons/icon-144x144.png +0 -0
  35. package/assets/client-files/assets/icons/icon-152x152.png +0 -0
  36. package/assets/client-files/assets/icons/icon-192x192.png +0 -0
  37. package/assets/client-files/assets/icons/icon-384x384.png +0 -0
  38. package/assets/client-files/assets/icons/icon-512x512.png +0 -0
  39. package/assets/client-files/assets/icons/icon-72x72.png +0 -0
  40. package/assets/client-files/assets/icons/icon-96x96.png +0 -0
  41. package/assets/client-files/favicon.ico +0 -0
  42. package/dist/SdCliBuildResultError.d.ts +0 -5
  43. package/dist/SdCliBuildResultError.mjs +0 -8
  44. package/dist/bin/sd-cli.d.ts +0 -2
  45. package/dist/bin/sd-cli.mjs +0 -410
  46. package/dist/build-tool/SdCliCacheCompilerHost.d.ts +0 -10
  47. package/dist/build-tool/SdCliCacheCompilerHost.mjs +0 -51
  48. package/dist/build-tool/SdCliCordova.d.ts +0 -16
  49. package/dist/build-tool/SdCliCordova.mjs +0 -212
  50. package/dist/build-tool/SdCliElectron.d.ts +0 -9
  51. package/dist/build-tool/SdCliElectron.mjs +0 -71
  52. package/dist/build-tool/SdCliGithubApi.d.ts +0 -13
  53. package/dist/build-tool/SdCliGithubApi.mjs +0 -92
  54. package/dist/build-tool/SdCliIndexFileGenerator.d.ts +0 -13
  55. package/dist/build-tool/SdCliIndexFileGenerator.mjs +0 -62
  56. package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +0 -12
  57. package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +0 -43
  58. package/dist/build-tool/SdCliPackageLinter.d.ts +0 -8
  59. package/dist/build-tool/SdCliPackageLinter.mjs +0 -62
  60. package/dist/builder/SdCliClientBuilder.d.ts +0 -26
  61. package/dist/builder/SdCliClientBuilder.mjs +0 -761
  62. package/dist/builder/SdCliJsLibBuilder.d.ts +0 -14
  63. package/dist/builder/SdCliJsLibBuilder.mjs +0 -54
  64. package/dist/builder/SdCliServerBuilder.d.ts +0 -28
  65. package/dist/builder/SdCliServerBuilder.mjs +0 -482
  66. package/dist/builder/SdCliTsLibBuilder.d.ts +0 -35
  67. package/dist/builder/SdCliTsLibBuilder.mjs +0 -317
  68. package/dist/commons.mjs +0 -2
  69. package/dist/entry-points/SdCliFileCrypto.d.ts +0 -7
  70. package/dist/entry-points/SdCliFileCrypto.mjs +0 -72
  71. package/dist/entry-points/SdCliLocalUpdate.d.ts +0 -13
  72. package/dist/entry-points/SdCliLocalUpdate.mjs +0 -100
  73. package/dist/entry-points/SdCliPrepare.d.ts +0 -5
  74. package/dist/entry-points/SdCliPrepare.mjs +0 -86
  75. package/dist/entry-points/SdCliProject.d.ts +0 -34
  76. package/dist/entry-points/SdCliProject.mjs +0 -416
  77. package/dist/entry-points/SdCliProjectGenerator.d.ts +0 -44
  78. package/dist/entry-points/SdCliProjectGenerator.mjs +0 -326
  79. package/dist/entry-points/file/base/fc_package_eslintrc.d.ts +0 -3
  80. package/dist/entry-points/file/base/fc_package_eslintrc.mjs +0 -31
  81. package/dist/entry-points/file/base/fc_package_npmconfig.d.ts +0 -9
  82. package/dist/entry-points/file/base/fc_package_npmconfig.mjs +0 -32
  83. package/dist/entry-points/file/base/fc_package_tsconfig.d.ts +0 -5
  84. package/dist/entry-points/file/base/fc_package_tsconfig.mjs +0 -13
  85. package/dist/entry-points/file/client/fc_package_AppModule.d.ts +0 -1
  86. package/dist/entry-points/file/client/fc_package_AppModule.mjs +0 -37
  87. package/dist/entry-points/file/client/fc_package_AppPage.d.ts +0 -1
  88. package/dist/entry-points/file/client/fc_package_AppPage.mjs +0 -14
  89. package/dist/entry-points/file/client/fc_package_Page.d.ts +0 -4
  90. package/dist/entry-points/file/client/fc_package_Page.mjs +0 -19
  91. package/dist/entry-points/file/client/fc_package_client_main.d.ts +0 -1
  92. package/dist/entry-points/file/client/fc_package_client_main.mjs +0 -19
  93. package/dist/entry-points/file/client/fc_package_index.d.ts +0 -3
  94. package/dist/entry-points/file/client/fc_package_index.mjs +0 -88
  95. package/dist/entry-points/file/client/fc_package_manifest.d.ts +0 -5
  96. package/dist/entry-points/file/client/fc_package_manifest.mjs +0 -54
  97. package/dist/entry-points/file/client/fc_package_polyfills.d.ts +0 -1
  98. package/dist/entry-points/file/client/fc_package_polyfills.mjs +0 -11
  99. package/dist/entry-points/file/client/fc_package_styles.d.ts +0 -1
  100. package/dist/entry-points/file/client/fc_package_styles.mjs +0 -7
  101. package/dist/entry-points/file/db/fc_package_DbContext.d.ts +0 -3
  102. package/dist/entry-points/file/db/fc_package_DbContext.mjs +0 -14
  103. package/dist/entry-points/file/db/fc_package_DbModel.d.ts +0 -4
  104. package/dist/entry-points/file/db/fc_package_DbModel.mjs +0 -12
  105. package/dist/entry-points/file/project/fc_project_editor_config.d.ts +0 -1
  106. package/dist/entry-points/file/project/fc_project_editor_config.mjs +0 -22
  107. package/dist/entry-points/file/project/fc_project_eslintrc.d.ts +0 -1
  108. package/dist/entry-points/file/project/fc_project_eslintrc.mjs +0 -30
  109. package/dist/entry-points/file/project/fc_project_gitattributes.d.ts +0 -1
  110. package/dist/entry-points/file/project/fc_project_gitattributes.mjs +0 -6
  111. package/dist/entry-points/file/project/fc_project_gitignore.d.ts +0 -1
  112. package/dist/entry-points/file/project/fc_project_gitignore.mjs +0 -27
  113. package/dist/entry-points/file/project/fc_project_npmconfig.d.ts +0 -7
  114. package/dist/entry-points/file/project/fc_project_npmconfig.mjs +0 -37
  115. package/dist/entry-points/file/project/fc_project_readme.d.ts +0 -3
  116. package/dist/entry-points/file/project/fc_project_readme.mjs +0 -13
  117. package/dist/entry-points/file/project/fc_project_simplysm.d.ts +0 -1
  118. package/dist/entry-points/file/project/fc_project_simplysm.mjs +0 -2
  119. package/dist/entry-points/file/project/fc_project_tsconfig.d.ts +0 -1
  120. package/dist/entry-points/file/project/fc_project_tsconfig.mjs +0 -25
  121. package/dist/entry-points/file/server/fc_package_server_main.d.ts +0 -5
  122. package/dist/entry-points/file/server/fc_package_server_main.mjs +0 -60
  123. package/dist/index.d.ts +0 -54
  124. package/dist/index.mjs +0 -55
  125. package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +0 -29
  126. package/dist/ng-tools/SdCliNgModuleGenerator.mjs +0 -502
  127. package/dist/ng-tools/babel/SdCliBbFileMetadata.d.ts +0 -25
  128. package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +0 -539
  129. package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +0 -23
  130. package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +0 -247
  131. package/dist/ng-tools/babel/SdCliBbUtil.d.ts +0 -5
  132. package/dist/ng-tools/babel/SdCliBbUtil.mjs +0 -14
  133. package/dist/ng-tools/babel/TSdCliBbNgMetadata.d.ts +0 -42
  134. package/dist/ng-tools/babel/TSdCliBbNgMetadata.mjs +0 -216
  135. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +0 -55
  136. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.mjs +0 -151
  137. package/dist/ng-tools/commons.d.ts +0 -9
  138. package/dist/ng-tools/commons.mjs +0 -2
  139. package/dist/ng-tools/typescript/SdCliTsFileMetadata.d.ts +0 -61
  140. package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +0 -325
  141. package/dist/ng-tools/typescript/SdCliTsRootMetadata.d.ts +0 -8
  142. package/dist/ng-tools/typescript/SdCliTsRootMetadata.mjs +0 -28
  143. package/dist/ng-tools/typescript/SdCliTsUtil.d.ts +0 -5
  144. package/dist/ng-tools/typescript/SdCliTsUtil.mjs +0 -28
  145. package/dist/packages/SdCliPackage.d.ts +0 -22
  146. package/dist/packages/SdCliPackage.mjs +0 -206
  147. package/dist/utils/SdCliBuildResultUtil.mjs +0 -63
  148. package/dist/utils/SdCliConfigUtil.mjs +0 -69
  149. package/dist/utils/SdCliNpmConfigUtil.d.ts +0 -7
  150. package/dist/utils/SdCliNpmConfigUtil.mjs +0 -15
  151. package/dist/worker/build-worker.mjs +0 -67
  152. package/dist/worker/server-worker.mjs +0 -67
  153. package/docs/client-add-page.md +0 -8
  154. package/docs/client-router.md +0 -85
  155. package/docs/client-sw.md +0 -101
  156. package/docs/conf-orm.md +0 -81
  157. package/docs/conf-usage.md +0 -5
  158. package/docs/lib-local-update.md +0 -50
  159. package/docs/lib-ts-paths.md +0 -25
  160. package/lib/cordova-entry.js +0 -22
  161. package/src/SdCliBuildResultError.ts +0 -9
  162. package/src/bin/sd-cli.ts +0 -493
  163. package/src/build-tool/SdCliCacheCompilerHost.ts +0 -79
  164. package/src/build-tool/SdCliCordova.ts +0 -263
  165. package/src/build-tool/SdCliElectron.ts +0 -84
  166. package/src/build-tool/SdCliGithubApi.ts +0 -111
  167. package/src/build-tool/SdCliIndexFileGenerator.ts +0 -79
  168. package/src/build-tool/SdCliNgCacheCompilerHost.ts +0 -58
  169. package/src/build-tool/SdCliPackageLinter.ts +0 -74
  170. package/src/builder/SdCliClientBuilder.ts +0 -871
  171. package/src/builder/SdCliJsLibBuilder.ts +0 -70
  172. package/src/builder/SdCliServerBuilder.ts +0 -552
  173. package/src/builder/SdCliTsLibBuilder.ts +0 -450
  174. package/src/entry-points/SdCliFileCrypto.ts +0 -87
  175. package/src/entry-points/SdCliLocalUpdate.ts +0 -121
  176. package/src/entry-points/SdCliPrepare.ts +0 -86
  177. package/src/entry-points/SdCliProject.ts +0 -491
  178. package/src/entry-points/SdCliProjectGenerator.ts +0 -402
  179. package/src/entry-points/file/base/fc_package_eslintrc.ts +0 -30
  180. package/src/entry-points/file/base/fc_package_npmconfig.ts +0 -43
  181. package/src/entry-points/file/base/fc_package_tsconfig.ts +0 -12
  182. package/src/entry-points/file/client/fc_package_AppModule.ts +0 -36
  183. package/src/entry-points/file/client/fc_package_AppPage.ts +0 -13
  184. package/src/entry-points/file/client/fc_package_Page.ts +0 -19
  185. package/src/entry-points/file/client/fc_package_client_main.ts +0 -18
  186. package/src/entry-points/file/client/fc_package_index.ts +0 -87
  187. package/src/entry-points/file/client/fc_package_manifest.ts +0 -53
  188. package/src/entry-points/file/client/fc_package_polyfills.ts +0 -10
  189. package/src/entry-points/file/client/fc_package_styles.ts +0 -6
  190. package/src/entry-points/file/db/fc_package_DbContext.ts +0 -14
  191. package/src/entry-points/file/db/fc_package_DbModel.ts +0 -11
  192. package/src/entry-points/file/project/fc_project_editor_config.ts +0 -21
  193. package/src/entry-points/file/project/fc_project_eslintrc.ts +0 -29
  194. package/src/entry-points/file/project/fc_project_gitattributes.ts +0 -5
  195. package/src/entry-points/file/project/fc_project_gitignore.ts +0 -26
  196. package/src/entry-points/file/project/fc_project_npmconfig.ts +0 -36
  197. package/src/entry-points/file/project/fc_project_readme.ts +0 -12
  198. package/src/entry-points/file/project/fc_project_simplysm.ts +0 -1
  199. package/src/entry-points/file/project/fc_project_tsconfig.ts +0 -24
  200. package/src/entry-points/file/server/fc_package_server_main.ts +0 -62
  201. package/src/index.ts +0 -54
  202. package/src/ng-tools/SdCliNgModuleGenerator.ts +0 -672
  203. package/src/ng-tools/babel/SdCliBbFileMetadata.ts +0 -629
  204. package/src/ng-tools/babel/SdCliBbRootMetadata.ts +0 -292
  205. package/src/ng-tools/babel/SdCliBbUtil.ts +0 -15
  206. package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +0 -251
  207. package/src/ng-tools/babel/TSdCliBbTypeMetadata.ts +0 -212
  208. package/src/ng-tools/commons.ts +0 -3
  209. package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +0 -384
  210. package/src/ng-tools/typescript/SdCliTsRootMetadata.ts +0 -32
  211. package/src/ng-tools/typescript/SdCliTsUtil.ts +0 -29
  212. package/src/packages/SdCliPackage.ts +0 -259
  213. package/src/utils/SdCliNpmConfigUtil.ts +0 -16
  214. package/src/worker/build-worker.ts +0 -73
  215. package/src/worker/server-worker.ts +0 -72
  216. /package/dist/{worker/build-worker.d.ts → build-cluster.d.ts} +0 -0
  217. /package/dist/{worker/server-worker.d.ts → sd-cli.d.ts} +0 -0
@@ -1,629 +0,0 @@
1
- import {
2
- Declaration,
3
- Expression,
4
- File,
5
- isArrayExpression,
6
- isAssignmentExpression,
7
- isCallExpression,
8
- isClassDeclaration,
9
- isConditionalExpression,
10
- isExportDeclaration,
11
- isExportDefaultDeclaration,
12
- isExportNamedDeclaration,
13
- isExportSpecifier,
14
- isExpressionStatement,
15
- isFunctionDeclaration,
16
- isIdentifier,
17
- isImportDeclaration,
18
- isImportDefaultSpecifier,
19
- isImportNamespaceSpecifier,
20
- isImportSpecifier,
21
- isMemberExpression,
22
- isObjectExpression,
23
- isSpreadElement,
24
- isStringLiteral,
25
- isVariableDeclaration,
26
- PatternLike,
27
- SpreadElement,
28
- Statement,
29
- traverseFast
30
- } from "@babel/types";
31
- import babelParser, { ParseError } from "@babel/parser";
32
- import { FsUtil } from "@simplysm/sd-core-node";
33
- import path from "path";
34
- import { TSdCliBbMetadata } from "./SdCliBbRootMetadata";
35
- import {
36
- SdCliBbArrayMetadata,
37
- SdCliBbClassMetadata,
38
- SdCliBbConditionMetadata,
39
- SdCliBbFunctionMetadata,
40
- SdCliBbObjectMetadata,
41
- SdCliBbVariableMetadata
42
- } from "./TSdCliBbTypeMetadata";
43
- import { SdCliBbUtil } from "./SdCliBbUtil";
44
- import { NeverEntryError } from "@simplysm/sd-core-common";
45
-
46
- export class SdCliBbFileMetadata {
47
- public readonly ast: File & { errors: ParseError[] };
48
- public readonly rawMetas: Statement[];
49
-
50
- public constructor(public readonly filePath: string) {
51
- let realFilePath: string | undefined;
52
- for (const ext of ["", ".mjs", ".cjs", ".js"/*, "/index.mjs", "/index.cjs", "/index.js"*/]) {
53
- if (FsUtil.exists(filePath + ext) && !FsUtil.stat(filePath + ext).isDirectory()) {
54
- realFilePath = filePath + ext;
55
- break;
56
- }
57
- }
58
- if (realFilePath === undefined) {
59
- throw SdCliBbUtil.error("파일을 찾을 수 없습니다.", filePath);
60
- }
61
-
62
- const fileContent = FsUtil.readFile(realFilePath);
63
- try {
64
- this.ast = babelParser.parse(fileContent, { sourceType: "module" });
65
- }
66
- catch (err) {
67
- throw SdCliBbUtil.error(err.message, this.filePath, err.loc);
68
- }
69
- this.rawMetas = this.ast.program.body;
70
- }
71
-
72
- private _exportsCache?: { exportedName: string; target: TSdCliBbMetadata }[];
73
-
74
- public get exports(): { exportedName: string; target: TSdCliBbMetadata }[] {
75
- if (this._exportsCache) return this._exportsCache;
76
-
77
- const result: { exportedName: string; target: TSdCliBbMetadata }[] = [];
78
- for (const rawMeta of this.rawMetas) {
79
- if (!isExportDeclaration(rawMeta)) continue;
80
-
81
- if (isExportNamedDeclaration(rawMeta)) {
82
- if (rawMeta.declaration) {
83
- if (isVariableDeclaration(rawMeta.declaration)) {
84
- for (const decl of rawMeta.declaration.declarations) {
85
- if (isIdentifier(decl.id)) {
86
- result.push({
87
- exportedName: decl.id.name,
88
- target: new SdCliBbVariableMetadata(this, decl)
89
- });
90
- }
91
- else {
92
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
93
- }
94
- }
95
- }
96
- else if (isClassDeclaration(rawMeta.declaration)) {
97
- result.push({
98
- exportedName: rawMeta.declaration.id.name,
99
- target: new SdCliBbClassMetadata(this, rawMeta.declaration)
100
- });
101
- }
102
- else if (isFunctionDeclaration(rawMeta.declaration)) {
103
- if (rawMeta.declaration.id) {
104
- result.push({
105
- exportedName: rawMeta.declaration.id.name,
106
- target: new SdCliBbFunctionMetadata(this, rawMeta.declaration)
107
- });
108
- }
109
- else {
110
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
111
- }
112
- }
113
- else {
114
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
115
- }
116
- }
117
- else {
118
- for (const specifier of rawMeta.specifiers) {
119
- if (isExportSpecifier(specifier)) {
120
- const exportedName = isIdentifier(specifier.exported) ? specifier.exported.name : undefined;
121
- if (exportedName === undefined) {
122
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
123
- }
124
-
125
- if (rawMeta.source) {
126
- if (rawMeta.source.value.startsWith(".")) {
127
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
128
- result.push({
129
- exportedName,
130
- target: {
131
- filePath: moduleFilePath,
132
- name: specifier.local.name,
133
- __TSdCliMetaRef__: "__TSdCliMetaRef__"
134
- }
135
- });
136
- }
137
- else {
138
- const moduleName = rawMeta.source.value;
139
- result.push({
140
- exportedName,
141
- target: { moduleName, name: specifier.local.name, __TSdCliMetaRef__: "__TSdCliMetaRef__" }
142
- });
143
- }
144
- }
145
- else {
146
- result.push({
147
- exportedName,
148
- target: this.findMetaFromInside(specifier.local.name)
149
- });
150
- }
151
- }
152
- else {
153
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
154
- }
155
- }
156
- }
157
- }
158
- else if (isExportDefaultDeclaration(rawMeta)) {
159
- result.push({
160
- exportedName: "default",
161
- target: this.getMetaFromRaw(rawMeta.declaration)
162
- });
163
- }
164
- else {
165
- if (rawMeta.source.value.startsWith(".")) {
166
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
167
- result.push({
168
- exportedName: "*",
169
- target: {
170
- filePath: moduleFilePath,
171
- name: "*",
172
- __TSdCliMetaRef__: "__TSdCliMetaRef__"
173
- }
174
- });
175
- }
176
- else {
177
- const moduleName = rawMeta.source.value;
178
- result.push({
179
- exportedName: "*",
180
- target: { moduleName, name: "*", __TSdCliMetaRef__: "__TSdCliMetaRef__" }
181
- });
182
- }
183
- }
184
- }
185
-
186
- this._exportsCache = result;
187
- return result;
188
- }
189
-
190
- private readonly _findMetaFromOutsideCache = new Map<string, TSdCliBbMetadata>();
191
-
192
- public findMetaFromOutside(name: string): TSdCliBbMetadata | undefined {
193
- const cache = this._findMetaFromOutsideCache.get(name);
194
- if (cache !== undefined) return cache;
195
-
196
- for (const rawMeta of this.rawMetas) {
197
- if (isExportNamedDeclaration(rawMeta)) {
198
- if (rawMeta.declaration) {
199
- if (isVariableDeclaration(rawMeta.declaration)) {
200
- for (const decl of rawMeta.declaration.declarations) {
201
- if (isIdentifier(decl.id)) {
202
- if (decl.id.name === name) {
203
- const result = new SdCliBbVariableMetadata(this, decl);
204
- this._findMetaFromOutsideCache.set(name, result);
205
- return result;
206
- }
207
- }
208
- else {
209
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
210
- }
211
- }
212
- }
213
- else if (isClassDeclaration(rawMeta.declaration)) {
214
- if (rawMeta.declaration.id.name === name) {
215
- const result = new SdCliBbClassMetadata(this, rawMeta.declaration);
216
- this._findMetaFromOutsideCache.set(name, result);
217
- return result;
218
- }
219
- }
220
- else if (isFunctionDeclaration(rawMeta.declaration)) {
221
- if (rawMeta.declaration.id) {
222
- if (rawMeta.declaration.id.name === name) {
223
- const result = new SdCliBbFunctionMetadata(this, rawMeta.declaration);
224
- this._findMetaFromOutsideCache.set(name, result);
225
- return result;
226
- }
227
- }
228
- else {
229
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
230
- }
231
- }
232
- else {
233
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
234
- }
235
- }
236
- else {
237
- for (const specifier of rawMeta.specifiers) {
238
- if (isExportSpecifier(specifier)) {
239
- const exportedName = isIdentifier(specifier.exported) ? specifier.exported.name : undefined;
240
- if (exportedName === undefined) {
241
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
242
- }
243
- else if (exportedName === name) {
244
- if (rawMeta.source) {
245
- if (rawMeta.source.value.startsWith(".")) {
246
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
247
- const result = {
248
- filePath: moduleFilePath,
249
- name: specifier.local.name,
250
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
251
- };
252
- this._findMetaFromOutsideCache.set(name, result);
253
- return result;
254
- }
255
- else {
256
- const moduleName = rawMeta.source.value;
257
- const result = {
258
- moduleName,
259
- name: specifier.local.name,
260
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
261
- };
262
- this._findMetaFromOutsideCache.set(name, result);
263
- return result;
264
- }
265
- }
266
- else {
267
- const result = this.findMetaFromInside(specifier.local.name);
268
- this._findMetaFromOutsideCache.set(name, result);
269
- return result;
270
- }
271
- }
272
- }
273
- }
274
- }
275
- }
276
- else if (isExportDefaultDeclaration(rawMeta) && name === "default") {
277
- const result = this.getMetaFromRaw(rawMeta.declaration);
278
- if (Array.isArray(result)) {
279
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
280
- }
281
- this._findMetaFromOutsideCache.set(name, result);
282
- return result;
283
- }
284
- }
285
-
286
- // throw SdCliBbUtil.error(`'${name}'에 대한 선언을 찾을 수 없습니다.`, this.filePath);
287
- return undefined;
288
- }
289
-
290
- private readonly _findMetaFromInsideCache = new Map<string, TSdCliBbMetadata>();
291
-
292
- public findMetaFromInside(localName: string, excludeExport?: boolean): TSdCliBbMetadata {
293
- const cache = this._findMetaFromInsideCache.get(localName);
294
- if (cache !== undefined) return cache;
295
-
296
- for (const rawMeta of this.rawMetas) {
297
- if (isClassDeclaration(rawMeta) && rawMeta.id.name === localName) {
298
- return new SdCliBbClassMetadata(this, rawMeta);
299
- }
300
- else if (!excludeExport && isExportNamedDeclaration(rawMeta)) {
301
- for (const specifier of rawMeta.specifiers) {
302
- if (isExportSpecifier(specifier)) {
303
- const exportedName = isIdentifier(specifier.exported) ? specifier.exported.name : undefined;
304
- if (exportedName === undefined) {
305
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
306
- }
307
- else if (exportedName === localName) {
308
- if (rawMeta.source) {
309
- if (rawMeta.source.value.startsWith(".")) {
310
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
311
- const result = {
312
- filePath: moduleFilePath,
313
- name: specifier.local.name,
314
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
315
- };
316
- this._findMetaFromInsideCache.set(localName, result);
317
- return result;
318
- }
319
- else {
320
- const moduleName = rawMeta.source.value;
321
- const result = {
322
- moduleName,
323
- name: specifier.local.name,
324
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
325
- };
326
- this._findMetaFromInsideCache.set(localName, result);
327
- return result;
328
- }
329
- }
330
- else {
331
- const localImportName = isIdentifier(specifier.local) ? specifier.local.name : undefined;
332
-
333
- if (localImportName === undefined) {
334
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
335
- }
336
- else if (exportedName !== localImportName) {
337
- const result = this.findMetaFromInside(localImportName);
338
- this._findMetaFromInsideCache.set(localImportName, result);
339
- return result;
340
- }
341
- else {
342
- const result = this.findMetaFromInside(localImportName, true);
343
- this._findMetaFromInsideCache.set(localImportName, result);
344
- return result;
345
- }
346
- }
347
- }
348
- }
349
- }
350
- }
351
- // else if (!excludeExport && isExportDefaultDeclaration(rawMeta) && localName === "default") {
352
- // const result = this.getMetaFromRaw(rawMeta.declaration);
353
- // if (Array.isArray(result)) {
354
- // throw new NeverEntryError();
355
- // }
356
- // this._findMetaFromInsideCache.set(localName, result);
357
- // return result;
358
- // }
359
- else if (isImportDeclaration(rawMeta)) {
360
- for (const specifier of rawMeta.specifiers) {
361
- if (isImportSpecifier(specifier)) {
362
- const impLocalName = isIdentifier(specifier.local) ? specifier.local.name : undefined;
363
- if (impLocalName === undefined) {
364
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
365
- }
366
- else if (impLocalName === localName) {
367
- if (isIdentifier(specifier.imported)) {
368
- if (rawMeta.source.value.startsWith(".")) {
369
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
370
- const result = {
371
- filePath: moduleFilePath,
372
- name: specifier.imported.name,
373
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
374
- };
375
- this._findMetaFromInsideCache.set(localName, result);
376
- return result;
377
- }
378
- else {
379
- const moduleName = rawMeta.source.value;
380
- const result = {
381
- moduleName,
382
- name: specifier.imported.name,
383
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
384
- };
385
- this._findMetaFromInsideCache.set(localName, result);
386
- return result;
387
- }
388
- }
389
- else {
390
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
391
- }
392
- }
393
- }
394
- else if (isImportDefaultSpecifier(specifier)) {
395
- if (specifier.local.name === localName) {
396
- if (rawMeta.source.value.startsWith(".")) {
397
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
398
- const result = {
399
- filePath: moduleFilePath,
400
- name: "default",
401
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
402
- };
403
- this._findMetaFromInsideCache.set(localName, result);
404
- return result;
405
- }
406
- else {
407
- const moduleName = rawMeta.source.value;
408
- const result = {
409
- moduleName,
410
- name: "default",
411
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
412
- };
413
- this._findMetaFromInsideCache.set(localName, result);
414
- return result;
415
- }
416
- }
417
- }
418
- else if (isImportNamespaceSpecifier(specifier)) {
419
- if (specifier.local.name === localName) {
420
- if (rawMeta.source.value.startsWith(".")) {
421
- const moduleFilePath = path.resolve(path.dirname(this.filePath), rawMeta.source.value);
422
- const result = {
423
- filePath: moduleFilePath,
424
- name: "*",
425
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
426
- };
427
- this._findMetaFromInsideCache.set(localName, result);
428
- return result;
429
- }
430
- else {
431
- const moduleName = rawMeta.source.value;
432
- const result = {
433
- moduleName,
434
- name: "*",
435
- __TSdCliMetaRef__: "__TSdCliMetaRef__" as const
436
- };
437
- this._findMetaFromInsideCache.set(localName, result);
438
- return result;
439
- // throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
440
- }
441
- }
442
- }
443
- }
444
- }
445
- else if (isVariableDeclaration(rawMeta)) {
446
- for (const decl of rawMeta.declarations) {
447
- if (isIdentifier(decl.id)) {
448
- if (decl.id.name === localName) {
449
- const result = new SdCliBbVariableMetadata(this, decl);
450
- this._findMetaFromInsideCache.set(localName, result);
451
- return result;
452
- }
453
- }
454
- else {
455
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
456
- }
457
- }
458
- }
459
- else if (isFunctionDeclaration(rawMeta)) {
460
- if (rawMeta.id) {
461
- if (rawMeta.id.name === localName) {
462
- const result = new SdCliBbFunctionMetadata(this, rawMeta);
463
- this._findMetaFromInsideCache.set(localName, result);
464
- return result;
465
- }
466
- }
467
- else {
468
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
469
- }
470
- }
471
- }
472
-
473
- throw SdCliBbUtil.error(`'${localName}'에 대한 내부선언을 찾을 수 없습니다.`, this.filePath);
474
- }
475
-
476
- public getMetaFromRaw(rawMeta: Declaration | Expression | PatternLike | SpreadElement): TSdCliBbMetadata {
477
- if (isIdentifier(rawMeta)) {
478
- return this.findMetaFromInside(rawMeta.name);
479
- }
480
- else if (isClassDeclaration(rawMeta)) {
481
- return new SdCliBbClassMetadata(this, rawMeta);
482
- }
483
- else if (isFunctionDeclaration(rawMeta)) {
484
- return new SdCliBbFunctionMetadata(this, rawMeta);
485
- }
486
- else if (isArrayExpression(rawMeta)) {
487
- return new SdCliBbArrayMetadata(this, rawMeta);
488
- }
489
- else if (isObjectExpression(rawMeta)) {
490
- return new SdCliBbObjectMetadata(this, rawMeta);
491
- }
492
- else if (isStringLiteral(rawMeta)) {
493
- return rawMeta.value;
494
- }
495
- else if (isSpreadElement(rawMeta)) {
496
- return this.getMetaFromRaw(rawMeta.argument);
497
- }
498
- else if (isConditionalExpression(rawMeta)) {
499
- return new SdCliBbConditionMetadata(this, rawMeta);
500
- }
501
-
502
- throw SdCliBbUtil.error("예상치 못한 방식의 코드가 발견되었습니다.", this.filePath, rawMeta);
503
- }
504
-
505
- private readonly _getNgDecoArgCache = new Map<string, SdCliBbObjectMetadata | undefined>();
506
-
507
- public getNgDecoArg(className: string): SdCliBbObjectMetadata | undefined {
508
- if (this._getNgDecoArgCache.has(className)) {
509
- return this._getNgDecoArgCache.get(className)!;
510
- }
511
-
512
- for (const meta of this.rawMetas) {
513
- // 'compilationMode: partial' 일때
514
- if (
515
- isExpressionStatement(meta) &&
516
- isCallExpression(meta.expression) &&
517
- (
518
- (
519
- isMemberExpression(meta.expression.callee) &&
520
- isIdentifier(meta.expression.callee.property) &&
521
- meta.expression.callee.property.name === "ɵɵngDeclareClassMetadata"
522
- ) ||
523
- (
524
- isIdentifier(meta.expression.callee) &&
525
- meta.expression.callee.name === "ngDeclareClassMetadata"
526
- )
527
- ) &&
528
- isObjectExpression(meta.expression.arguments[0])
529
- ) {
530
- const objMeta = new SdCliBbObjectMetadata(this, meta.expression.arguments[0]);
531
- const typePropVal = objMeta.getPropValue("type");
532
- if (
533
- typePropVal instanceof SdCliBbClassMetadata &&
534
- typePropVal.name === className
535
- ) {
536
- const decos = objMeta.getPropValue("decorators");
537
- if (
538
- decos instanceof SdCliBbArrayMetadata &&
539
- decos.value[0] instanceof SdCliBbObjectMetadata
540
- ) {
541
- const args = decos.value[0].getPropValue("args");
542
- if (
543
- args instanceof SdCliBbArrayMetadata &&
544
- args.value[0] instanceof SdCliBbObjectMetadata
545
- ) {
546
- this._getNgDecoArgCache.set(className, args.value[0]);
547
- return args.value[0];
548
- }
549
- }
550
- else {
551
- throw new NeverEntryError();
552
- }
553
- }
554
- }
555
- }
556
-
557
- // 'compilationMode: full' 일때
558
- let result: SdCliBbObjectMetadata | undefined;
559
- traverseFast(this.ast, (node) => {
560
- if (
561
- isCallExpression(node) &&
562
- (
563
- (
564
- isMemberExpression(node.callee) &&
565
- isIdentifier(node.callee.property) &&
566
- node.callee.property.name === "ɵsetClassMetadata"
567
- ) ||
568
- (
569
- isIdentifier(node.callee) &&
570
- node.callee.name === "setClassMetadata"
571
- )
572
- ) &&
573
- isIdentifier(node.arguments[0]) &&
574
- node.arguments[0].name === className &&
575
- isArrayExpression(node.arguments[1])
576
- ) {
577
- const decos = new SdCliBbArrayMetadata(this, node.arguments[1]);
578
- if (decos.value[0] instanceof SdCliBbObjectMetadata) {
579
- const args = decos.value[0].getPropValue("args");
580
- if (
581
- args instanceof SdCliBbArrayMetadata &&
582
- args.value[0] instanceof SdCliBbObjectMetadata
583
- ) {
584
- result = args.value[0];
585
- }
586
- }
587
- else {
588
- throw new NeverEntryError();
589
- }
590
- }
591
- });
592
-
593
- // if (result === undefined) {
594
- // throw new NeverEntryError(this.filePath + "," + className);
595
- // }
596
-
597
- this._getNgDecoArgCache.set(className, result);
598
- return result;
599
- }
600
-
601
- public getNgDecoPropValue(className: string, decoName: string, propName: string): TSdCliBbMetadata | undefined {
602
- for (const meta of this.rawMetas) {
603
- if (
604
- isExpressionStatement(meta) &&
605
- isAssignmentExpression(meta.expression) &&
606
- isMemberExpression(meta.expression.left) &&
607
- isIdentifier(meta.expression.left.object) &&
608
- meta.expression.left.object.name === className &&
609
- isIdentifier(meta.expression.left.property)
610
- ) {
611
- if (meta.expression.left.property.name === decoName) {
612
- if (
613
- isCallExpression(meta.expression.right) &&
614
- meta.expression.right.arguments.length > 0 &&
615
- isObjectExpression(meta.expression.right.arguments[0])
616
- ) {
617
- const dirObjMeta = new SdCliBbObjectMetadata(this, meta.expression.right.arguments[0]);
618
- return dirObjMeta.getPropValue(propName);
619
- }
620
- else {
621
- throw new NeverEntryError();
622
- }
623
- }
624
- }
625
- }
626
-
627
- throw new NeverEntryError();
628
- }
629
- }