@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,292 +0,0 @@
1
- import { SdCliBbFileMetadata } from "./SdCliBbFileMetadata";
2
- import path from "path";
3
- import { INpmConfig } from "../../commons";
4
- import { SdCliNpmConfigUtil } from "../../utils/SdCliNpmConfigUtil";
5
- import { NeverEntryError, StringUtil } from "@simplysm/sd-core-common";
6
- import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
7
- import { TSdCliBbTypeMetadata } from "./TSdCliBbTypeMetadata";
8
- import { TSdCliMetaRef } from "../commons";
9
-
10
- export class SdCliBbRootMetadata {
11
- private readonly _depMap: Map<string, { rootPath: string; entryFilePath?: string }>;
12
- private readonly _fileMetaCache = new Map<string, SdCliBbFileMetadata>();
13
-
14
- public constructor(packagePath: string) {
15
- const allDepPaths = this._getAllDepPaths(packagePath);
16
- this._depMap = this._getDepMap(allDepPaths);
17
- // const ngDepPaths = this._getNgDepPaths(allDepPaths);
18
- // this._entryMap = this._getEntryMap(ngDepPaths);
19
- }
20
-
21
- public removeCaches(filePaths: string[]): void {
22
- for (const filePath of filePaths) {
23
- this._fileMetaCache.delete(filePath);
24
- }
25
- }
26
-
27
- public getEntryFileMetaRecord(): Record<string, SdCliBbFileMetadata> {
28
- const result: Record<string, SdCliBbFileMetadata> = {};
29
- for (const moduleName of this._depMap.keys()) {
30
- const entryFilePath = this._depMap.get(moduleName)?.entryFilePath;
31
- if (entryFilePath !== undefined) {
32
- result[moduleName] = this._fileMetaCache.getOrCreate(entryFilePath, () => new SdCliBbFileMetadata(entryFilePath))!;
33
- }
34
- }
35
- return result;
36
- }
37
-
38
- public findMeta(ref: TSdCliMetaRef): TSdCliBbMetadata | TSdCliBbMetadata[] {
39
- let filePath: string | undefined;
40
- if ("moduleName" in ref) {
41
- filePath = this._depMap.get(ref.moduleName)?.entryFilePath;
42
- if (filePath === undefined) {
43
- const fileRootPath = this._depMap.get(ref.moduleName.split("/")[0])?.rootPath;
44
- if (fileRootPath !== undefined) {
45
- filePath = path.resolve(fileRootPath, ref.moduleName.split("/").slice(1).join("/"));
46
- }
47
- }
48
- }
49
- else {
50
- filePath = ref.filePath;
51
- }
52
-
53
- if (filePath === undefined) {
54
- throw new NeverEntryError();
55
- }
56
-
57
- const fileMeta = this._fileMetaCache.getOrCreate(filePath, () => new SdCliBbFileMetadata(filePath!));
58
- if (ref.name === "*") {
59
- const result: TSdCliBbMetadata[] = [];
60
- for (const exp of fileMeta.exports) {
61
- const meta = exp.target;
62
- if (typeof meta !== "string" && "__TSdCliMetaRef__" in meta) {
63
- const resultMeta = this.findMeta(meta);
64
- if (resultMeta instanceof Array) {
65
- result.push(...resultMeta);
66
- }
67
- else {
68
- result.push(resultMeta);
69
- }
70
- }
71
- else {
72
- result.push(meta);
73
- }
74
- }
75
- return result;
76
- }
77
- else {
78
- const meta = fileMeta.findMetaFromOutside(ref.name);
79
- if (meta === undefined) {
80
- throw new NeverEntryError();
81
- }
82
-
83
- if (typeof meta !== "string" && "__TSdCliMetaRef__" in meta) {
84
- return this.findMeta(meta);
85
- }
86
- return meta;
87
- }
88
- }
89
-
90
- public findExportRef(localRef: { filePath: string; name: string }): { moduleName: string; name: string } | undefined {
91
- const record = this.getEntryFileMetaRecord();
92
- for (const moduleName of Object.keys(record)) {
93
- const entryFileMeta = record[moduleName];
94
- for (const exp of entryFileMeta.exports) {
95
- if (
96
- typeof exp.target !== "string" &&
97
- "filePath" in exp.target &&
98
- exp.target.filePath === localRef.filePath
99
- ) {
100
- if (exp.target.name === "*") {
101
- return { moduleName, name: localRef.name };
102
- }
103
- else if (exp.target.name === localRef.name) {
104
- return { moduleName, name: exp.exportedName };
105
- }
106
- }
107
- }
108
- }
109
-
110
- return undefined;
111
- }
112
-
113
- private _getAllDepPaths(packagePath: string): string[] {
114
- const loadedModuleNames: string[] = [];
115
- const results: string[] = [];
116
-
117
- const fn = (currPath: string): void => {
118
- const npmConfig = FsUtil.readJson(path.resolve(currPath, "package.json")) as INpmConfig;
119
-
120
- const deps = SdCliNpmConfigUtil.getDependencies(npmConfig);
121
-
122
- for (const moduleName of deps.defaults) {
123
- if (loadedModuleNames.includes(moduleName)) continue;
124
- loadedModuleNames.push(moduleName);
125
-
126
- const modulePath = FsUtil.findAllParentChildDirPaths("node_modules/" + moduleName, currPath, process.cwd()).first();
127
- if (StringUtil.isNullOrEmpty(modulePath)) {
128
- continue;
129
- }
130
-
131
- results.push(modulePath);
132
-
133
- fn(modulePath);
134
- }
135
- };
136
-
137
- fn(packagePath);
138
-
139
- return results;
140
- }
141
-
142
- // private _getNgDepPaths(allDepPaths: string[]): string[] {
143
- // const results: string[] = [];
144
- //
145
- // for (const depPath of allDepPaths) {
146
- // const npmConfig = FsUtil.readJson(path.resolve(depPath, "package.json")) as INpmConfig;
147
- // const defaultDeps = SdCliNpmConfigUtil.getDependencies(npmConfig).defaults;
148
- // if (npmConfig.name === "@angular/core" || defaultDeps.includes("@angular/core")) {
149
- // results.push(depPath);
150
- // }
151
- // }
152
- //
153
- // return results;
154
- // }
155
-
156
- private _getDepMap(ngDepPaths: string[]): Map<string, { rootPath: string; entryFilePath?: string }> {
157
- const entryMap = new Map<string, { rootPath: string; entryFilePath?: string }>();
158
- for (const ngDepPath of ngDepPaths) {
159
- const npmConfig = FsUtil.readJson(path.resolve(ngDepPath, "package.json")) as INpmConfig;
160
-
161
- const entryFilePath = npmConfig["es2020"] ?? npmConfig["es2015"] ?? npmConfig["browser"] ?? npmConfig["module"] ?? npmConfig["main"] ?? npmConfig["default"];
162
- if (entryFilePath === undefined) {
163
- entryMap.set(npmConfig.name, {
164
- rootPath: ngDepPath,
165
- entryFilePath: undefined
166
- });
167
- }
168
- else if (typeof entryFilePath === "string") {
169
- const realPath = this._getRealFilePath(path.resolve(ngDepPath, entryFilePath));
170
- if (realPath?.endsWith(".json")) {
171
- continue;
172
- }
173
-
174
- entryMap.set(npmConfig.name, {
175
- rootPath: ngDepPath,
176
- entryFilePath: realPath
177
- });
178
- }
179
- else {
180
- for (const key of Object.keys(entryMap)) {
181
- const exportPath = path.resolve(ngDepPath, key);
182
- const exportResult = this._getGlobExportResult(PathUtil.posix(npmConfig.name, key), exportPath);
183
- for (const exportResultItem of exportResult) {
184
- const exportRealPath = this._getRealFilePath(exportResultItem.target);
185
- if (exportResultItem.target.endsWith(".json")) {
186
- continue;
187
- }
188
-
189
- entryMap.set(exportResultItem.name, {
190
- rootPath: ngDepPath,
191
- entryFilePath: exportRealPath
192
- });
193
- }
194
- }
195
- }
196
-
197
- if (npmConfig.exports) {
198
- const exportKeys = Object.keys(npmConfig.exports);
199
- for (const exportKey of exportKeys) {
200
- if (
201
- exportKey.startsWith("./locales") ||
202
- exportKey.startsWith("./testing") ||
203
- exportKey.startsWith("./upgrade")
204
- ) {
205
- continue;
206
- }
207
-
208
- const expEntryFilePath = npmConfig.exports[exportKey]["es2020"] ??
209
- npmConfig.exports[exportKey]["es2015"] ??
210
- npmConfig.exports[exportKey]["browser"] ??
211
- npmConfig.exports[exportKey]["module"] ??
212
- npmConfig.exports[exportKey]["main"] ??
213
- npmConfig.exports[exportKey]["default"];
214
- if (typeof expEntryFilePath === "string") {
215
- if (expEntryFilePath.endsWith(".json")) {
216
- continue;
217
- }
218
-
219
- const exportPath = path.resolve(ngDepPath, expEntryFilePath);
220
- const exportResult = this._getGlobExportResult(PathUtil.posix(npmConfig.name, exportKey), exportPath);
221
- for (const exportResultItem of exportResult) {
222
- if (exportResultItem.target.endsWith(".json")) {
223
- continue;
224
- }
225
-
226
- const exportRealPath = this._getRealFilePath(exportResultItem.target);
227
- entryMap.set(exportResultItem.name, {
228
- rootPath: ngDepPath,
229
- entryFilePath: exportRealPath
230
- });
231
- }
232
- }
233
- }
234
- }
235
- }
236
-
237
- return entryMap;
238
- }
239
-
240
- private _getRealFilePath(itemPath: string): string | undefined {
241
- if (!FsUtil.exists(itemPath)) {
242
- for (const ext of [".mjs", ".cjs", ".js"]) {
243
- if (FsUtil.exists(itemPath + ext)) {
244
- return itemPath + ext;
245
- }
246
- }
247
- }
248
- else if (FsUtil.stat(itemPath).isFile()) {
249
- return itemPath;
250
- }
251
- else {
252
- for (const fileName of ["index.mjs", "index.cjs", "index.js"]) {
253
- if (FsUtil.exists(path.resolve(itemPath, fileName))) {
254
- return path.resolve(itemPath, fileName);
255
- }
256
- }
257
- }
258
-
259
- return undefined;
260
- }
261
-
262
- private _getGlobExportResult(globName: string, globTarget: string): { name: string; target: string }[] {
263
- if (globName.includes("*") && globTarget.includes("*")) {
264
- const result: { name: string; target: string }[] = [];
265
-
266
- const regexpText = globTarget.replace(/[\\/.*]/g, (item) => (
267
- item === "/" || item === "\\" ? "[\\\\/]"
268
- : item === "." ? "\\."
269
- : item === "*" ? "(.*)"
270
- : item
271
- ));
272
-
273
- const targets = FsUtil.glob(globTarget);
274
- for (const target of targets) {
275
- const targetNameMatch = new RegExp(regexpText).exec(target);
276
- if (!targetNameMatch || typeof targetNameMatch[1] === "undefined") {
277
- throw new NeverEntryError();
278
- }
279
- const targetName = targetNameMatch[1];
280
- const name = globName.replace("*", targetName);
281
- result.push({ name, target });
282
- }
283
-
284
- return result;
285
- }
286
- else {
287
- return [{ name: globName, target: globTarget }];
288
- }
289
- }
290
- }
291
-
292
- export type TSdCliBbMetadata = TSdCliBbTypeMetadata | TSdCliMetaRef | string;
@@ -1,15 +0,0 @@
1
- import { Node, SourceLocation } from "@babel/types";
2
- import { SdCliBuildResultError } from "../../SdCliBuildResultError";
3
-
4
- export class SdCliBbUtil {
5
- public static error(message: string, filePath?: string, meta?: Node | SourceLocation["start"]): SdCliBuildResultError {
6
- return new SdCliBuildResultError({
7
- filePath,
8
- line: meta && "loc" in meta ? meta.loc?.start.line : meta && "line" in meta ? meta.line : undefined,
9
- char: meta && "loc" in meta ? meta.loc?.start.column : meta && "column" in meta ? meta.column : undefined,
10
- code: undefined,
11
- severity: "error",
12
- message: message
13
- });
14
- }
15
- }
@@ -1,251 +0,0 @@
1
- import { NeverEntryError } from "@simplysm/sd-core-common";
2
- import { SdCliBbFileMetadata } from "./SdCliBbFileMetadata";
3
- import { SdCliBbArrayMetadata, SdCliBbVariableMetadata } from "./TSdCliBbTypeMetadata";
4
- import { TSdCliBbMetadata } from "./SdCliBbRootMetadata";
5
-
6
- export type TSdCliBbNgMetadata =
7
- SdCliBbNgModuleMetadata
8
- | SdCliBbNgInjectableMetadata
9
- | SdCliBbNgDirectiveMetadata
10
- | SdCliBbNgComponentMetadata
11
- | SdCliBbNgPipeMetadata;
12
-
13
- export class SdCliBbNgModuleMetadata {
14
- public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
15
- private readonly _className: string) {
16
- }
17
-
18
- private _defCache?: ISdCliBbNgModuleDef;
19
-
20
- public get def(): ISdCliBbNgModuleDef {
21
- if (this._defCache) return this._defCache;
22
-
23
- const result: ISdCliBbNgModuleDef = {
24
- exports: [],
25
- providers: []
26
- };
27
-
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) {
43
- if (
44
- isExpressionStatement(meta) &&
45
- isAssignmentExpression(meta.expression) &&
46
- isMemberExpression(meta.expression.left) &&
47
- isIdentifier(meta.expression.left.object) &&
48
- meta.expression.left.object.name === this._className &&
49
- isIdentifier(meta.expression.left.property)
50
- ) {
51
- if (meta.expression.left.property.name === "ɵmod") {
52
- if (
53
- isCallExpression(meta.expression.right) &&
54
- meta.expression.right.arguments.length > 0 &&
55
- isObjectExpression(meta.expression.right.arguments[0])
56
- ) {
57
- const expObjMeta = new SdCliBbObjectMetadata(this._fileMeta, meta.expression.right.arguments[0]);
58
- const expVal = expObjMeta.getPropValue("exports");
59
- if (expVal !== undefined) {
60
- if (expVal instanceof SdCliBbArrayMetadata) {
61
- for (const expMeta of expVal.value.filterExists()) {
62
- result.exports.push(expMeta);
63
- }
64
- }
65
- else {
66
- throw new NeverEntryError();
67
- }
68
- }
69
- }
70
- else {
71
- throw new NeverEntryError();
72
- }
73
- }
74
-
75
- if (meta.expression.left.property.name === "ɵinj") {
76
- if (
77
- isCallExpression(meta.expression.right) &&
78
- meta.expression.right.arguments.length > 0 &&
79
- isObjectExpression(meta.expression.right.arguments[0])
80
- ) {
81
- const provObjMeta = new SdCliBbObjectMetadata(this._fileMeta, meta.expression.right.arguments[0]);
82
- const provVal = provObjMeta.getPropValue("providers");
83
- if (provVal !== undefined) {
84
- const provMetas = this._getProviderMetas(provVal);
85
- for (const provMeta of provMetas) {
86
- result.providers.push(provMeta);
87
- }
88
- }
89
- }
90
- else {
91
- throw new NeverEntryError();
92
- }
93
- }
94
- }
95
- }*/
96
-
97
- /*if (this._className.includes("Http") && this._className.includes("Client")) {
98
- console.log(this._className, result.providers.map((item) => item instanceof SdCliBbClassMetadata ? item.name : item instanceof SdCliBbObjectMetadata ? (item.getPropValue("provide") as SdCliBbClassMetadata).name : undefined));
99
- console.log([
100
- this._fileMeta.findMetaFromInside("JsonpClientBackend"),
101
- this._fileMeta.findMetaFromInside("JsonpCallbackContext"),
102
- this._fileMeta.findMetaFromInside("HTTP_INTERCEPTORS"),
103
- this._fileMeta.findMetaFromInside("HttpClient"),
104
- this._fileMeta.findMetaFromInside("HttpHandler"),
105
- this._fileMeta.findMetaFromInside("HttpXhrBackend"),
106
- this._fileMeta.findMetaFromInside("HttpBackend"),
107
- this._fileMeta.findMetaFromInside("HttpXsrfInterceptor"),
108
- this._fileMeta.findMetaFromInside("HttpXsrfTokenExtractor"),
109
- this._fileMeta.findMetaFromInside("XSRF_COOKIE_NAME"),
110
- this._fileMeta.findMetaFromInside("XSRF_HEADER_NAME")
111
- ]);
112
- }*/
113
-
114
- this._defCache = result;
115
- return result;
116
- }
117
-
118
- private _getExportAndProviderMetas(meta: TSdCliBbMetadata): TSdCliBbMetadata[] {
119
- const result: TSdCliBbMetadata[] = [];
120
-
121
- if (meta instanceof SdCliBbArrayMetadata) {
122
- for (const metaItem of meta.value.filterExists()) {
123
- result.push(...this._getExportAndProviderMetas(metaItem));
124
- }
125
- }
126
- else if (meta instanceof SdCliBbVariableMetadata) {
127
- if (meta.value !== undefined) {
128
- result.push(...this._getExportAndProviderMetas(meta.value));
129
- }
130
- }
131
- else {
132
- result.push(meta);
133
- }
134
-
135
- return result;
136
- }
137
- }
138
-
139
- export class SdCliBbNgInjectableMetadata {
140
-
141
- public constructor(
142
- // @ts-expect-error
143
- private readonly _fileMeta: SdCliBbFileMetadata,
144
- // @ts-expect-error
145
- private readonly _className: string) {
146
- }
147
- }
148
-
149
- export class SdCliBbNgDirectiveMetadata {
150
- public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
151
- private readonly _className: string) {
152
- }
153
-
154
- private _selectorCache?: string;
155
-
156
- public get selector(): string {
157
- if (this._selectorCache !== undefined) return this._selectorCache;
158
-
159
- const argObjMeta = this._fileMeta.getNgDecoArg(this._className);
160
- const val = argObjMeta?.getPropValue("selector") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵdir", "selector");
161
- if (typeof val === "string") {
162
- this._selectorCache = val;
163
- return this._selectorCache;
164
- }
165
- else {
166
- throw new NeverEntryError();
167
- }
168
- }
169
- }
170
-
171
- export class SdCliBbNgComponentMetadata {
172
- public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
173
- private readonly _className: string) {
174
- }
175
-
176
- private _selectorCache?: string;
177
-
178
- public get selector(): string {
179
- if (this._selectorCache !== undefined) return this._selectorCache;
180
-
181
- const argObjMeta = this._fileMeta.getNgDecoArg(this._className);
182
- const val = argObjMeta?.getPropValue("selector") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵcmp", "selector");
183
- if (typeof val === "string") {
184
- this._selectorCache = val;
185
- return this._selectorCache;
186
- }
187
- else {
188
- throw new NeverEntryError();
189
- }
190
- }
191
- }
192
-
193
- export class SdCliBbNgPipeMetadata {
194
- public constructor(private readonly _fileMeta: SdCliBbFileMetadata,
195
- private readonly _className: string) {
196
- }
197
-
198
- private _pipeNameCache?: string;
199
-
200
- public get pipeName(): string {
201
- if (this._pipeNameCache !== undefined) return this._pipeNameCache;
202
-
203
- const argObjMeta = this._fileMeta.getNgDecoArg(this._className);
204
- const val = argObjMeta?.getPropValue("name") ?? this._fileMeta.getNgDecoPropValue(this._className, "ɵpipe", "name");
205
- if (typeof val === "string") {
206
- this._pipeNameCache = val;
207
- return val;
208
- }
209
- else {
210
- throw new NeverEntryError();
211
- }
212
- }
213
- }
214
-
215
- interface ISdCliBbNgModuleDef {
216
- exports: TSdCliBbMetadata[];
217
- providers: TSdCliBbMetadata[];
218
- }
219
-
220
- /*
221
- class SdCliNgMetadataUtil {
222
- public static getDecoPropValue(fileMeta: SdCliBbFileMetadata, className: string, decoName: string, propName: string): TSdCliBbMetadata | undefined {
223
- for (const meta of fileMeta.rawMetas) {
224
- if (
225
- isExpressionStatement(meta) &&
226
- isAssignmentExpression(meta.expression) &&
227
- isMemberExpression(meta.expression.left) &&
228
- isIdentifier(meta.expression.left.object) &&
229
- meta.expression.left.object.name === className &&
230
- isIdentifier(meta.expression.left.property)
231
- ) {
232
- if (meta.expression.left.property.name === decoName) {
233
- if (
234
- isCallExpression(meta.expression.right) &&
235
- meta.expression.right.arguments.length > 0 &&
236
- isObjectExpression(meta.expression.right.arguments[0])
237
- ) {
238
- const dirObjMeta = new SdCliBbObjectMetadata(fileMeta, meta.expression.right.arguments[0]);
239
- return dirObjMeta.getPropValue(propName);
240
- }
241
- else {
242
- throw new NeverEntryError();
243
- }
244
- }
245
- }
246
- }
247
-
248
- throw new NeverEntryError();
249
- }
250
- }
251
- */