@simplysm/sd-cli 12.13.21 → 12.13.23

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 (237) hide show
  1. package/package.json +12 -12
  2. package/src/entry/{sd-cli-cordova.ts → SdCliCordova.ts} +2 -2
  3. package/src/entry/{sd-cli-electron.ts → SdCliElectron.ts} +3 -3
  4. package/src/entry/{sd-cli-local-update.ts → SdCliLocalUpdate.ts} +6 -4
  5. package/src/entry/{sd-cli-project.ts → SdCliProject.ts} +55 -71
  6. package/src/pkg-builders/SdProjectBuildRunner.ts +347 -0
  7. package/src/pkg-builders/client/{sd-client.build-runner.ts → SdClientBuildRunner.ts} +31 -38
  8. package/src/pkg-builders/client/{sd-ng.bundler.ts → SdNgBundler.ts} +22 -31
  9. package/src/pkg-builders/client/{sd-ng.bundler-context.ts → SdNgBundlerContext.ts} +7 -9
  10. package/src/pkg-builders/client/{sd-ng.plugin-creator.ts → createSdNgPlugin.ts} +11 -94
  11. package/src/pkg-builders/commons/{scope-path.ts → ScopePathSet.ts} +3 -3
  12. package/src/pkg-builders/commons/SdBuildRunnerBase.ts +47 -0
  13. package/src/pkg-builders/lib/{sd-cli-db-context.file-generator.ts → SdCliDbContextFileGenerator.ts} +1 -1
  14. package/src/pkg-builders/lib/{sd-js-lib.build-runner.ts → SdJsLibBuildRunner.ts} +13 -32
  15. package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +47 -0
  16. package/src/pkg-builders/lib/{sd-ts-lib.builder.ts → SdTsLibBuilder.ts} +12 -14
  17. package/src/pkg-builders/server/{sd-server.build-runner.ts → SdServerBuildRunner.ts} +25 -48
  18. package/src/pkg-builders/server/{sd-server.bundler.ts → SdServerBundler.ts} +26 -23
  19. package/src/pkg-builders/server/{sd-server.plugin-creator.ts → createSdServerPlugin.ts} +9 -7
  20. package/src/sd-cli-entry.ts +6 -12
  21. package/src/sd-cli.ts +1 -15
  22. package/src/ts-compiler/{sd-dependency-analyzer.ts → SdDepAnalyzer.ts} +5 -9
  23. package/src/ts-compiler/{sd-dependency-cache.ts → SdDepCache.ts} +1 -137
  24. package/src/ts-compiler/{sd-style-bundler.ts → SdStyleBundler.ts} +5 -5
  25. package/src/ts-compiler/{sd-ts-compiler.ts → SdTsCompiler.ts} +17 -144
  26. package/src/types/{build.types.ts → build/ISdBuildMessage.ts} +0 -6
  27. package/src/types/build/ISdBuildResult.ts +9 -0
  28. package/src/types/build/ISdTsCompilerOptions.ts +15 -0
  29. package/src/types/build/ISdTsCompilerResult.ts +12 -0
  30. package/src/types/build/TStylesheetBundlingResult.ts +15 -0
  31. package/src/types/{common-configs.types.ts → common-config/INpmConfig.ts} +0 -6
  32. package/src/types/common-config/ITsConfig.ts +5 -0
  33. package/src/types/{config.types.ts → config/ISdProjectConfig.ts} +0 -1
  34. package/src/types/plugin/ISdCliNgPluginResultCache.ts +9 -0
  35. package/src/types/{build-plugin.types.ts → plugin/ISdCliServerPluginResultCache.ts} +0 -7
  36. package/src/types/worker/ISdBuildRunnerWorkerType.ts +24 -0
  37. package/src/types/worker/IServerWorkerType.ts +8 -0
  38. package/src/utils/{sd-cli-convert-message.utils.ts → SdCliConvertMessageUtils.ts} +6 -3
  39. package/src/{entry/utils → utils}/loadProjConfAsync.ts +10 -6
  40. package/src/workers/build-runner.worker.ts +30 -29
  41. package/src/workers/server.worker.ts +7 -7
  42. package/tests/deps/sd-dependency-analyzer.spec.ts +38 -69
  43. package/tests/deps/sd-dependency-cache.spec.ts +3 -6
  44. package/dist/entry/sd-cli-ai-command.d.ts +0 -3
  45. package/dist/entry/sd-cli-ai-command.js +0 -65
  46. package/dist/entry/sd-cli-ai-command.js.map +0 -1
  47. package/dist/entry/sd-cli-cordova.d.ts +0 -16
  48. package/dist/entry/sd-cli-cordova.js +0 -398
  49. package/dist/entry/sd-cli-cordova.js.map +0 -1
  50. package/dist/entry/sd-cli-electron.d.ts +0 -18
  51. package/dist/entry/sd-cli-electron.js +0 -129
  52. package/dist/entry/sd-cli-electron.js.map +0 -1
  53. package/dist/entry/sd-cli-local-update.d.ts +0 -11
  54. package/dist/entry/sd-cli-local-update.js +0 -84
  55. package/dist/entry/sd-cli-local-update.js.map +0 -1
  56. package/dist/entry/sd-cli-postinstall.d.ts +0 -3
  57. package/dist/entry/sd-cli-postinstall.js +0 -39
  58. package/dist/entry/sd-cli-postinstall.js.map +0 -1
  59. package/dist/entry/sd-cli-project.d.ts +0 -22
  60. package/dist/entry/sd-cli-project.js +0 -325
  61. package/dist/entry/sd-cli-project.js.map +0 -1
  62. package/dist/entry/utils/loadProjConfAsync.d.ts +0 -5
  63. package/dist/entry/utils/loadProjConfAsync.js +0 -8
  64. package/dist/entry/utils/loadProjConfAsync.js.map +0 -1
  65. package/dist/fix/convert-extends-sd-modal-base-to-interface.d.ts +0 -1
  66. package/dist/fix/convert-extends-sd-modal-base-to-interface.js +0 -289
  67. package/dist/fix/convert-extends-sd-modal-base-to-interface.js.map +0 -1
  68. package/dist/fix/convert-extends-sd-print-template-base-to-interface.d.ts +0 -1
  69. package/dist/fix/convert-extends-sd-print-template-base-to-interface.js +0 -179
  70. package/dist/fix/convert-extends-sd-print-template-base-to-interface.js.map +0 -1
  71. package/dist/fix/convert-flat-pages-to-flat-menus.d.ts +0 -1
  72. package/dist/fix/convert-flat-pages-to-flat-menus.js +0 -68
  73. package/dist/fix/convert-flat-pages-to-flat-menus.js.map +0 -1
  74. package/dist/fix/convert-get-menus-to-usable-menus.d.ts +0 -1
  75. package/dist/fix/convert-get-menus-to-usable-menus.js +0 -48
  76. package/dist/fix/convert-get-menus-to-usable-menus.js.map +0 -1
  77. package/dist/fix/convert-modal-show-params.d.ts +0 -1
  78. package/dist/fix/convert-modal-show-params.js +0 -29
  79. package/dist/fix/convert-modal-show-params.js.map +0 -1
  80. package/dist/fix/convert-print-params.d.ts +0 -1
  81. package/dist/fix/convert-print-params.js +0 -37
  82. package/dist/fix/convert-print-params.js.map +0 -1
  83. package/dist/fix/convert-private-to-hash.d.ts +0 -1
  84. package/dist/fix/convert-private-to-hash.js +0 -59
  85. package/dist/fix/convert-private-to-hash.js.map +0 -1
  86. package/dist/fix/convert-sd-angular-symbol-names.d.ts +0 -1
  87. package/dist/fix/convert-sd-angular-symbol-names.js +0 -23
  88. package/dist/fix/convert-sd-angular-symbol-names.js.map +0 -1
  89. package/dist/fix/convert-sd-icon-to-fa-icon.d.ts +0 -1
  90. package/dist/fix/convert-sd-icon-to-fa-icon.js +0 -80
  91. package/dist/fix/convert-sd-icon-to-fa-icon.js.map +0 -1
  92. package/dist/fix/convert-sd-sheet-bindings-safety.d.ts +0 -1
  93. package/dist/fix/convert-sd-sheet-bindings-safety.js +0 -57
  94. package/dist/fix/convert-sd-sheet-bindings-safety.js.map +0 -1
  95. package/dist/fix/convert-select-modal-button-to-select-button.d.ts +0 -1
  96. package/dist/fix/convert-select-modal-button-to-select-button.js +0 -64
  97. package/dist/fix/convert-select-modal-button-to-select-button.js.map +0 -1
  98. package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.d.ts +0 -1
  99. package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js +0 -38
  100. package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js.map +0 -1
  101. package/dist/fix/convert-to-use-perms-signal.d.ts +0 -1
  102. package/dist/fix/convert-to-use-perms-signal.js +0 -99
  103. package/dist/fix/convert-to-use-perms-signal.js.map +0 -1
  104. package/dist/fix/core/convert-symbol.d.ts +0 -1
  105. package/dist/fix/core/convert-symbol.js +0 -93
  106. package/dist/fix/core/convert-symbol.js.map +0 -1
  107. package/dist/fix/core/get-ts-morph-source-files.d.ts +0 -1
  108. package/dist/fix/core/get-ts-morph-source-files.js +0 -8
  109. package/dist/fix/core/get-ts-morph-source-files.js.map +0 -1
  110. package/dist/fix/core/remove-named-import.d.ts +0 -1
  111. package/dist/fix/core/remove-named-import.js +0 -14
  112. package/dist/fix/core/remove-named-import.js.map +0 -1
  113. package/dist/fix/core/remove-symbol.d.ts +0 -1
  114. package/dist/fix/core/remove-symbol.js +0 -76
  115. package/dist/fix/core/remove-symbol.js.map +0 -1
  116. package/dist/fix/remove-sd-angular-symbol-names.d.ts +0 -1
  117. package/dist/fix/remove-sd-angular-symbol-names.js +0 -9
  118. package/dist/fix/remove-sd-angular-symbol-names.js.map +0 -1
  119. package/dist/fix/remove-unused-imports.d.ts +0 -1
  120. package/dist/fix/remove-unused-imports.js +0 -42
  121. package/dist/fix/remove-unused-imports.js.map +0 -1
  122. package/dist/fix/remove-unused-injects.d.ts +0 -1
  123. package/dist/fix/remove-unused-injects.js +0 -38
  124. package/dist/fix/remove-unused-injects.js.map +0 -1
  125. package/dist/fix/remove-unused-protected-readonly.d.ts +0 -1
  126. package/dist/fix/remove-unused-protected-readonly.js +0 -52
  127. package/dist/fix/remove-unused-protected-readonly.js.map +0 -1
  128. package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.d.ts +0 -9
  129. package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js +0 -89
  130. package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js.map +0 -1
  131. package/dist/pkg-builders/client/sd-client.build-runner.d.ts +0 -7
  132. package/dist/pkg-builders/client/sd-client.build-runner.js +0 -119
  133. package/dist/pkg-builders/client/sd-client.build-runner.js.map +0 -1
  134. package/dist/pkg-builders/client/sd-ng.bundler-context.d.ts +0 -22
  135. package/dist/pkg-builders/client/sd-ng.bundler-context.js +0 -91
  136. package/dist/pkg-builders/client/sd-ng.bundler-context.js.map +0 -1
  137. package/dist/pkg-builders/client/sd-ng.bundler.d.ts +0 -27
  138. package/dist/pkg-builders/client/sd-ng.bundler.js +0 -489
  139. package/dist/pkg-builders/client/sd-ng.bundler.js.map +0 -1
  140. package/dist/pkg-builders/client/sd-ng.plugin-creator.d.ts +0 -13
  141. package/dist/pkg-builders/client/sd-ng.plugin-creator.js +0 -223
  142. package/dist/pkg-builders/client/sd-ng.plugin-creator.js.map +0 -1
  143. package/dist/pkg-builders/commons/build-runner.base.d.ts +0 -29
  144. package/dist/pkg-builders/commons/build-runner.base.js +0 -114
  145. package/dist/pkg-builders/commons/build-runner.base.js.map +0 -1
  146. package/dist/pkg-builders/commons/scope-path.d.ts +0 -7
  147. package/dist/pkg-builders/commons/scope-path.js +0 -14
  148. package/dist/pkg-builders/commons/scope-path.js.map +0 -1
  149. package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.d.ts +0 -9
  150. package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js +0 -134
  151. package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js.map +0 -1
  152. package/dist/pkg-builders/lib/sd-cli-index.file-generator.d.ts +0 -10
  153. package/dist/pkg-builders/lib/sd-cli-index.file-generator.js +0 -61
  154. package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +0 -1
  155. package/dist/pkg-builders/lib/sd-js-lib.build-runner.d.ts +0 -8
  156. package/dist/pkg-builders/lib/sd-js-lib.build-runner.js +0 -50
  157. package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +0 -1
  158. package/dist/pkg-builders/lib/sd-ts-lib.build-runner.d.ts +0 -7
  159. package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +0 -41
  160. package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +0 -1
  161. package/dist/pkg-builders/lib/sd-ts-lib.builder.d.ts +0 -14
  162. package/dist/pkg-builders/lib/sd-ts-lib.builder.js +0 -65
  163. package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +0 -1
  164. package/dist/pkg-builders/sd-multi.build-runner.d.ts +0 -14
  165. package/dist/pkg-builders/sd-multi.build-runner.js +0 -228
  166. package/dist/pkg-builders/sd-multi.build-runner.js.map +0 -1
  167. package/dist/pkg-builders/server/sd-server.build-runner.d.ts +0 -7
  168. package/dist/pkg-builders/server/sd-server.build-runner.js +0 -264
  169. package/dist/pkg-builders/server/sd-server.build-runner.js.map +0 -1
  170. package/dist/pkg-builders/server/sd-server.bundler.d.ts +0 -22
  171. package/dist/pkg-builders/server/sd-server.bundler.js +0 -153
  172. package/dist/pkg-builders/server/sd-server.bundler.js.map +0 -1
  173. package/dist/pkg-builders/server/sd-server.plugin-creator.d.ts +0 -13
  174. package/dist/pkg-builders/server/sd-server.plugin-creator.js +0 -62
  175. package/dist/pkg-builders/server/sd-server.plugin-creator.js.map +0 -1
  176. package/dist/sd-cli-entry.d.ts +0 -2
  177. package/dist/sd-cli-entry.js +0 -263
  178. package/dist/sd-cli-entry.js.map +0 -1
  179. package/dist/sd-cli.d.ts +0 -2
  180. package/dist/sd-cli.js +0 -97
  181. package/dist/sd-cli.js.map +0 -1
  182. package/dist/ts-compiler/sd-dependency-analyzer.d.ts +0 -15
  183. package/dist/ts-compiler/sd-dependency-analyzer.js +0 -302
  184. package/dist/ts-compiler/sd-dependency-analyzer.js.map +0 -1
  185. package/dist/ts-compiler/sd-dependency-cache.d.ts +0 -43
  186. package/dist/ts-compiler/sd-dependency-cache.js +0 -310
  187. package/dist/ts-compiler/sd-dependency-cache.js.map +0 -1
  188. package/dist/ts-compiler/sd-style-bundler.d.ts +0 -16
  189. package/dist/ts-compiler/sd-style-bundler.js +0 -118
  190. package/dist/ts-compiler/sd-style-bundler.js.map +0 -1
  191. package/dist/ts-compiler/sd-ts-compiler.d.ts +0 -8
  192. package/dist/ts-compiler/sd-ts-compiler.js +0 -522
  193. package/dist/ts-compiler/sd-ts-compiler.js.map +0 -1
  194. package/dist/types/build-plugin.types.d.ts +0 -14
  195. package/dist/types/build-plugin.types.js +0 -2
  196. package/dist/types/build-plugin.types.js.map +0 -1
  197. package/dist/types/build-runner.types.d.ts +0 -10
  198. package/dist/types/build-runner.types.js +0 -2
  199. package/dist/types/build-runner.types.js.map +0 -1
  200. package/dist/types/build.types.d.ts +0 -15
  201. package/dist/types/build.types.js +0 -2
  202. package/dist/types/build.types.js.map +0 -1
  203. package/dist/types/common-configs.types.d.ts +0 -24
  204. package/dist/types/common-configs.types.js +0 -2
  205. package/dist/types/common-configs.types.js.map +0 -1
  206. package/dist/types/config.types.d.ts +0 -109
  207. package/dist/types/config.types.js +0 -2
  208. package/dist/types/config.types.js.map +0 -1
  209. package/dist/types/ts-compiler.types.d.ts +0 -37
  210. package/dist/types/ts-compiler.types.js +0 -2
  211. package/dist/types/ts-compiler.types.js.map +0 -1
  212. package/dist/types/worker.types.d.ts +0 -67
  213. package/dist/types/worker.types.js +0 -2
  214. package/dist/types/worker.types.js.map +0 -1
  215. package/dist/utils/sd-cli-convert-message.utils.d.ts +0 -21
  216. package/dist/utils/sd-cli-convert-message.utils.js +0 -137
  217. package/dist/utils/sd-cli-convert-message.utils.js.map +0 -1
  218. package/dist/utils/sd-cli-performance-time.d.ts +0 -9
  219. package/dist/utils/sd-cli-performance-time.js +0 -51
  220. package/dist/utils/sd-cli-performance-time.js.map +0 -1
  221. package/dist/workers/build-runner.worker.d.ts +0 -1
  222. package/dist/workers/build-runner.worker.js +0 -49
  223. package/dist/workers/build-runner.worker.js.map +0 -1
  224. package/dist/workers/server.worker.d.ts +0 -1
  225. package/dist/workers/server.worker.js +0 -50
  226. package/dist/workers/server.worker.js.map +0 -1
  227. package/src/pkg-builders/commons/build-runner.base.ts +0 -184
  228. package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +0 -57
  229. package/src/pkg-builders/sd-multi.build-runner.ts +0 -304
  230. package/src/types/build-runner.types.ts +0 -11
  231. package/src/types/ts-compiler.types.ts +0 -43
  232. package/src/types/worker.types.ts +0 -51
  233. /package/src/entry/{sd-cli-ai-command.ts → SdCliAiCommand.ts} +0 -0
  234. /package/src/entry/{sd-cli-postinstall.ts → SdCliPostinstall.ts} +0 -0
  235. /package/src/pkg-builders/client/{sd-cli-ng-routes.file-generator.ts → SdCliNgRoutesFileGenerator.ts} +0 -0
  236. /package/src/pkg-builders/lib/{sd-cli-index.file-generator.ts → SdCliIndexFileGenerator.ts} +0 -0
  237. /package/src/utils/{sd-cli-performance-time.ts → SdCliPerformanceTimer.ts} +0 -0
@@ -1,184 +0,0 @@
1
- import { EventEmitter } from "events";
2
- import {
3
- FsUtils,
4
- ISdFsWatcherChangeInfo,
5
- PathUtils,
6
- SdFsWatcher,
7
- SdLogger,
8
- TNormPath,
9
- } from "@simplysm/sd-core-node";
10
- import { ISdProjectConfig, TSdPackageConfig } from "../../types/config.types";
11
- import { ISdBuildMessage, ISdBuildRunnerResult } from "../../types/build.types";
12
- import path from "path";
13
- import { ScopePathSet } from "./scope-path";
14
-
15
- export abstract class BuildRunnerBase<
16
- T extends "server" | "library" | "client",
17
- > extends EventEmitter {
18
- protected abstract _logger: SdLogger;
19
-
20
- protected _pkgName: string;
21
- protected _pkgConf: TSdPackageConfig<T>;
22
-
23
- protected _watchScopePathSet: ScopePathSet;
24
-
25
- override on(event: "change", listener: () => void): this;
26
- override on(event: "complete", listener: (result: ISdBuildRunnerResult) => void): this;
27
- override on(event: string | symbol, listener: (...args: any[]) => void): this {
28
- super.on(event, listener);
29
- return this;
30
- }
31
-
32
- constructor(
33
- protected _projConf: ISdProjectConfig,
34
- protected _pkgPath: TNormPath,
35
- workspaceGlobs: string[],
36
- protected _emitOnly: boolean,
37
- protected _noEmit: boolean,
38
- ) {
39
- super();
40
-
41
- this._pkgName = path.basename(_pkgPath);
42
- this._pkgConf = _projConf.packages[this._pkgName] as TSdPackageConfig<T>;
43
-
44
- const workspacePaths = workspaceGlobs
45
- .mapMany((item) => [
46
- PathUtils.posix(this._pkgPath, "../../", item, "src"),
47
- PathUtils.posix(this._pkgPath, "../../", item, "public"),
48
- PathUtils.posix(this._pkgPath, "../../", item, "public-dev"),
49
- ])
50
- .mapMany((item) => FsUtils.glob(item));
51
- const localUpdatePaths = Object.keys(_projConf.localUpdates ?? {}).mapMany((key) => [
52
- ...FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key, "dist")),
53
- ...FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key, "src/**/*.scss")),
54
- ]);
55
- this._watchScopePathSet = new ScopePathSet(
56
- [...workspacePaths, ...localUpdatePaths].map((item) => PathUtils.norm(item)),
57
- );
58
- }
59
-
60
- async buildAsync(): Promise<ISdBuildRunnerResult> {
61
- if (!this._noEmit) {
62
- const distPath = path.resolve(this._pkgPath, "dist");
63
- if (FsUtils.exists(distPath)) {
64
- this._debug("dist 초기화...");
65
- FsUtils.remove(distPath);
66
- }
67
- }
68
-
69
- const result = await this._runAsync(false, false, false);
70
- return {
71
- affectedFilePathSet: result.affectedFileSet,
72
- buildMessages: result.buildMessages,
73
- emitFileSet: result.emitFileSet,
74
- };
75
- }
76
-
77
- async watchAsync() {
78
- this.emit("change");
79
-
80
- if (!this._noEmit) {
81
- const distPath = path.resolve(this._pkgPath, "dist");
82
- if (FsUtils.exists(distPath)) {
83
- this._debug("dist 초기화...");
84
- FsUtils.remove(distPath);
85
- }
86
- }
87
-
88
- const result = await this._runAsync(
89
- !this._pkgConf.forceProductionMode,
90
- this._emitOnly,
91
- this._noEmit,
92
- );
93
- const res: ISdBuildRunnerResult = {
94
- affectedFilePathSet: result.affectedFileSet,
95
- buildMessages: result.buildMessages,
96
- emitFileSet: result.emitFileSet,
97
- };
98
- this.emit("complete", res);
99
-
100
- this._debug("WATCH...");
101
-
102
- let lastWatchFileSet = result.watchFileSet;
103
- SdFsWatcher.watch(this._watchScopePathSet.toArray()).onChange(
104
- { delay: 300 },
105
- async (changeInfos) => {
106
- const modifiedFileSet = this._getModifiedFileSet(changeInfos, lastWatchFileSet);
107
-
108
- if (modifiedFileSet.size < 1) return;
109
-
110
- this.emit("change");
111
-
112
- let watchResult: IBuildRunnerRunResult;
113
- try {
114
- watchResult = await this._runAsync(
115
- !this._pkgConf.forceProductionMode,
116
- this._emitOnly,
117
- this._noEmit,
118
- modifiedFileSet,
119
- );
120
-
121
- lastWatchFileSet = watchResult.watchFileSet;
122
- } catch (err) {
123
- watchResult = {
124
- affectedFileSet: modifiedFileSet,
125
- buildMessages: [
126
- {
127
- filePath: undefined,
128
- line: undefined,
129
- char: undefined,
130
- code: undefined,
131
- severity: "error",
132
- message: `파일 변경 처리 중 오류 발생: ${err}`,
133
- type: "watch",
134
- },
135
- ],
136
- emitFileSet: new Set(),
137
- };
138
- }
139
-
140
- this.emit("complete", {
141
- affectedFilePathSet: watchResult.affectedFileSet,
142
- buildMessages: watchResult.buildMessages,
143
- emitFileSet: watchResult.emitFileSet,
144
- });
145
- },
146
- );
147
- }
148
-
149
- protected _getModifiedFileSet(
150
- changeInfos: ISdFsWatcherChangeInfo[],
151
- lastWatchFileSet?: Set<TNormPath>,
152
- ) {
153
- let arr: TNormPath[];
154
- if (!lastWatchFileSet) {
155
- arr = changeInfos.map((item) => item.path);
156
- } else {
157
- arr = changeInfos
158
- .filter((item) =>
159
- Array.from(lastWatchFileSet).some((item1) => item.path.startsWith(path.dirname(item1))),
160
- )
161
- .map((item) => item.path);
162
- }
163
-
164
- return new Set(arr);
165
- }
166
-
167
- protected abstract _runAsync(
168
- dev: boolean,
169
- emitOnly: boolean,
170
- noEmit: boolean,
171
- modifiedFileSet?: Set<TNormPath>,
172
- ): Promise<IBuildRunnerRunResult>;
173
-
174
- protected _debug(msg: string): void {
175
- this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
176
- }
177
- }
178
-
179
- export interface IBuildRunnerRunResult {
180
- watchFileSet?: Set<TNormPath>;
181
- affectedFileSet: Set<TNormPath>;
182
- buildMessages: ISdBuildMessage[];
183
- emitFileSet: Set<TNormPath>;
184
- }
@@ -1,57 +0,0 @@
1
- import { PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
2
- import { SdTsLibBuilder } from "./sd-ts-lib.builder";
3
- import { BuildRunnerBase, IBuildRunnerRunResult } from "../commons/build-runner.base";
4
- import { SdCliIndexFileGenerator } from "./sd-cli-index.file-generator";
5
- import { SdCliDbContextFileGenerator } from "./sd-cli-db-context.file-generator";
6
-
7
- export class SdTsLibBuildRunner extends BuildRunnerBase<"library"> {
8
- protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdTsLibBuildRunner"]);
9
-
10
- #builder?: SdTsLibBuilder;
11
-
12
- protected override async _runAsync(
13
- dev: boolean,
14
- emitOnly: boolean,
15
- noEmit: boolean,
16
- modifiedFileSet?: Set<TNormPath>,
17
- ): Promise<IBuildRunnerRunResult> {
18
- // 최초한번
19
- if (!modifiedFileSet) {
20
- if (!noEmit) {
21
- // index
22
- if (!this._pkgConf.noGenIndex) {
23
- this._debug("GEN index.ts...");
24
- new SdCliIndexFileGenerator().watch(this._pkgPath, this._pkgConf.polyfills);
25
- }
26
-
27
- // db-context
28
- if (this._pkgConf.dbContext != null) {
29
- this._debug(`GEN ${this._pkgConf.dbContext}.ts...`);
30
- new SdCliDbContextFileGenerator().watch(this._pkgPath, this._pkgConf.dbContext);
31
- }
32
- }
33
- }
34
-
35
- this._debug(`BUILD...`);
36
- this.#builder ??= new SdTsLibBuilder(
37
- PathUtils.norm(this._pkgPath),
38
- dev,
39
- emitOnly,
40
- noEmit,
41
- this._watchScopePathSet,
42
- );
43
- const buildResult = await this.#builder.buildAsync(modifiedFileSet ?? new Set());
44
-
45
- this._debug(`빌드 완료`);
46
- const watchFileSet = new Set(
47
- Array.from(buildResult.watchFileSet).filter((item) => this._watchScopePathSet.inScope(item)),
48
- );
49
-
50
- return {
51
- watchFileSet,
52
- affectedFileSet: buildResult.affectedFileSet,
53
- buildMessages: buildResult.results,
54
- emitFileSet: buildResult.emitFileSet,
55
- };
56
- }
57
- }
@@ -1,304 +0,0 @@
1
- import { FsUtils, PathUtils, SdLogger, SdWorker, TNormPath } from "@simplysm/sd-core-node";
2
- import path from "path";
3
- import { EventEmitter } from "events";
4
- import { ISdServerPackageConfig } from "../types/config.types";
5
- import { ISdBuildMessage, ISdBuildRunnerResult } from "../types/build.types";
6
- import { TSdBuildRunnerWorkerType, TServerWorkerType } from "../types/worker.types";
7
- import { INpmConfig } from "../types/common-configs.types";
8
- import { ISdBuildRunnerWorkerRequest } from "../types/build-runner.types";
9
-
10
- export class SdMultiBuildRunner extends EventEmitter {
11
- #logger = SdLogger.get(["simplysm", "sd-cli", "SdMultiBuildRunner"]);
12
-
13
- #busyCount = 0;
14
-
15
- #resultCache = new Map<TNormPath, ISdBuildMessage[]>();
16
- #serverInfoMap = new Map<
17
- string,
18
- {
19
- pkgInfo?: { path: string; conf: ISdServerPackageConfig } | { port: number }; // persist
20
- worker?: SdWorker<TServerWorkerType>; // persist
21
- port?: number; // run server result
22
- hasChanges: boolean;
23
-
24
- clientPath?: string;
25
- clientChangedFileSet: Set<string>;
26
-
27
- // from client
28
- clients: Record<
29
- string,
30
- {
31
- buildTypes: ("web" | "electron" | "cordova")[];
32
- path: string;
33
- changedFileSet: Set<string>;
34
- }
35
- >; // persist
36
- }
37
- >();
38
-
39
- override on(event: "change", listener: () => void): this;
40
- override on(event: "complete", listener: (result: ISdBuildMessage[]) => void): this;
41
- override on(event: string | symbol, listener: (...args: any[]) => void): this {
42
- super.on(event, listener);
43
- return this;
44
- }
45
-
46
- async runAsync(req: ISdBuildRunnerWorkerRequest & { cmd: "watch" }): Promise<void>;
47
- async runAsync(req: ISdBuildRunnerWorkerRequest & { cmd: "build" }): Promise<ISdBuildMessage[]>;
48
- async runAsync(req: ISdBuildRunnerWorkerRequest): Promise<ISdBuildMessage[] | void> {
49
- const worker = new SdWorker<TSdBuildRunnerWorkerType>(
50
- import.meta.resolve("../workers/build-runner.worker"),
51
- )
52
- .on("change", () => {
53
- if (this.#busyCount === 0) {
54
- this.emit("change");
55
- }
56
- this.#busyCount++;
57
- })
58
- .on("complete", (result) => this.#onComplete(req, result));
59
-
60
- return await worker.run("run", [req]);
61
- /*const pkgConf = req.projConf.packages[path.basename(req.pkgPath)]!;
62
-
63
- const buildRunnerType =
64
- pkgConf.type === "server"
65
- ? SdServerBuildRunner
66
- : pkgConf.type === "client"
67
- ? SdClientBuildRunner
68
- : FsUtil.exists(path.resolve(req.pkgPath, "tsconfig.json"))
69
- ? SdTsLibBuildRunner
70
- : SdJsLibBuildRunner;
71
-
72
- const builder = new buildRunnerType(req.projConf, req.pkgPath)
73
- .on("change", () => this.#onMessage(req, { type: "change" }))
74
- .on("complete", (result) => this.#onMessage(req, { type: "complete", result }));
75
-
76
- if (req.cmd === "build") {
77
- const res = await builder.buildAsync();
78
- return res.buildMessages;
79
- } else {
80
- await builder.watchAsync();
81
- return;
82
- }*/
83
- }
84
-
85
- #onComplete(req: ISdBuildRunnerWorkerRequest, result: ISdBuildRunnerResult) {
86
- this.#resultCache.delete(req.pkgPath);
87
- for (const affectedFilePath of result.affectedFilePathSet) {
88
- this.#resultCache.delete(affectedFilePath);
89
- }
90
-
91
- for (const buildMessage of result.buildMessages) {
92
- if (!buildMessage.filePath || PathUtils.isChildPath(buildMessage.filePath, req.pkgPath)) {
93
- const cacheItem = this.#resultCache.getOrCreate(buildMessage.filePath ?? req.pkgPath, []);
94
- cacheItem.push(buildMessage);
95
- }
96
- }
97
-
98
- if (req.noEmit) {
99
- setTimeout(() => {
100
- this.#busyCount--;
101
- if (this.#busyCount === 0) {
102
- const messages = Array.from(this.#resultCache.values()).mapMany();
103
- this.emit("complete", messages);
104
- }
105
- }, 300);
106
- } else {
107
- const pkgConf = req.projConf.packages[path.basename(req.pkgPath)]!;
108
-
109
- if (pkgConf.type === "server") {
110
- const pkgName = path.basename(req.pkgPath);
111
- const serverInfo = this.#serverInfoMap.getOrCreate(pkgName, {
112
- hasChanges: true,
113
- clientChangedFileSet: new Set(),
114
- clients: {},
115
- });
116
-
117
- const serverPkgConf = req.projConf.packages[pkgName] as ISdServerPackageConfig;
118
- serverInfo.pkgInfo = {
119
- path: req.pkgPath,
120
- conf: serverPkgConf,
121
- };
122
-
123
- serverInfo.hasChanges = true;
124
- } else if (pkgConf.type === "client") {
125
- const pkgName = path.basename(req.pkgPath);
126
-
127
- if (pkgConf.server != null) {
128
- const serverInfo = this.#serverInfoMap.getOrCreate(
129
- typeof pkgConf.server === "string" ? pkgConf.server : pkgConf.server.port.toString(),
130
- {
131
- hasChanges: true,
132
- clientChangedFileSet: new Set(),
133
- clients: {},
134
- },
135
- );
136
-
137
- if (typeof pkgConf.server !== "string") {
138
- serverInfo.pkgInfo = pkgConf.server;
139
- }
140
-
141
- serverInfo.clients[pkgName] = serverInfo.clients[pkgName] ?? {
142
- path: path.resolve(req.pkgPath, "dist"),
143
- buildTypes: (pkgConf.builder ? Object.keys(pkgConf.builder) : ["web"]) as any,
144
- changedFileSet: new Set(),
145
- };
146
- serverInfo.clients[pkgName].changedFileSet.adds(...result.emitFileSet);
147
- } else {
148
- const serverInfo = this.#serverInfoMap.getOrCreate(pkgName, {
149
- hasChanges: true,
150
- clientPath: path.resolve(req.pkgPath, "dist"),
151
- clientChangedFileSet: new Set(),
152
- clients: {},
153
- });
154
-
155
- serverInfo.clientChangedFileSet.adds(...result.emitFileSet);
156
- }
157
- }
158
-
159
- setTimeout(async () => {
160
- this.#busyCount--;
161
- if (this.#busyCount === 0) {
162
- for (const serverPkgNameOrPort of this.#serverInfoMap.keys()) {
163
- const serverInfo = this.#serverInfoMap.get(serverPkgNameOrPort)!;
164
- if (serverInfo.pkgInfo && serverInfo.hasChanges) {
165
- this.#logger.debug("서버 재시작...");
166
- try {
167
- const restartServerResult = await this.#restartServerAsync(
168
- serverInfo.pkgInfo,
169
- serverInfo.worker,
170
- );
171
- serverInfo.worker = restartServerResult.worker;
172
- serverInfo.port = restartServerResult.port;
173
- serverInfo.hasChanges = false;
174
- } catch (err) {
175
- this.#logger.error(err);
176
- }
177
- }
178
-
179
- if (serverInfo.worker) {
180
- this.#logger.debug("클라이언트 설정...");
181
- await serverInfo.worker.run("setPathProxy", [
182
- {
183
- ...Object.keys(serverInfo.clients).toObject(
184
- (key) => key,
185
- (key) => serverInfo.clients[key].path,
186
- ),
187
- node_modules: path.resolve(process.cwd(), "node_modules"),
188
- },
189
- ]);
190
-
191
- if (Object.keys(serverInfo.clients).length > 0) {
192
- for (const clientName of Object.keys(serverInfo.clients)) {
193
- this.#logger.debug(`${clientName} 클라이언트 새로고침...`);
194
- await serverInfo.worker.run("broadcastReload", [
195
- clientName,
196
- new Set(
197
- Array.from(serverInfo.clients[clientName].changedFileSet)
198
- .filter((item) => !item.endsWith(".map"))
199
- .map((item) => path.relative(serverInfo.clients[clientName].path, item)),
200
- ),
201
- ]);
202
- serverInfo.clients[clientName].changedFileSet = new Set();
203
- }
204
- } else if (serverInfo.clientChangedFileSet.size > 0) {
205
- this.#logger.debug("클라이언트 새로고침...");
206
- await serverInfo.worker.run("broadcastReload", [
207
- undefined,
208
- new Set(
209
- Array.from(serverInfo.clientChangedFileSet)
210
- .filter((item) => !item.endsWith(".map"))
211
- .map((item) => path.relative(serverInfo.clientPath!, item)),
212
- ),
213
- ]);
214
- serverInfo.clientChangedFileSet = new Set();
215
- }
216
- }
217
- }
218
-
219
- const clientPaths: string[] = [];
220
- for (const serverInfo of this.#serverInfoMap.values()) {
221
- if (Object.keys(serverInfo.clients).length > 0) {
222
- for (const clientPkgName of Object.keys(serverInfo.clients)) {
223
- for (const buildType of serverInfo.clients[clientPkgName].buildTypes) {
224
- if (buildType === "web") {
225
- clientPaths.push(`http://localhost:${serverInfo.port}/${clientPkgName}/`);
226
- } else {
227
- clientPaths.push(
228
- `http://localhost:${serverInfo.port}/${clientPkgName}/${buildType}/`,
229
- );
230
- }
231
- }
232
- }
233
- } else {
234
- clientPaths.push(`http://localhost:${serverInfo.port}/`);
235
- }
236
- }
237
- if (clientPaths.length > 0) {
238
- this.#logger.info("클라이언트 개발 서버 접속 주소\n" + clientPaths.join("\n"));
239
- }
240
-
241
- const messages = Array.from(this.#resultCache.values()).mapMany();
242
- this.emit("complete", messages);
243
- }
244
- }, 300);
245
- }
246
- }
247
-
248
- async #restartServerAsync(
249
- pkgInfo: { path: string; conf: ISdServerPackageConfig } | { port: number },
250
- prevWorker?: SdWorker<TServerWorkerType>,
251
- ): Promise<{
252
- worker: SdWorker<TServerWorkerType>;
253
- port: number;
254
- }> {
255
- const logger = SdLogger.get([
256
- "simplysm",
257
- "sd-cli",
258
- "SdMultiBuildRunner",
259
- "#restartServerAsync",
260
- ]);
261
-
262
- if (prevWorker) {
263
- await prevWorker.killAsync();
264
- }
265
-
266
- const npmConf =
267
- "path" in pkgInfo
268
- ? (FsUtils.readJson(path.resolve(pkgInfo.path, "package.json")) as INpmConfig)
269
- : undefined;
270
-
271
- const worker = new SdWorker<TServerWorkerType>(
272
- import.meta.resolve("../workers/server.worker"),
273
- {
274
- env: {
275
- NODE_ENV: "development",
276
- TZ: "Asia/Seoul",
277
- SD_VERSION: npmConf?.version ?? "serverless",
278
- ...("path" in pkgInfo ? pkgInfo.conf.env : {}),
279
- },
280
- },
281
- );
282
- const port = await worker.run("listen", [pkgInfo]);
283
- logger.debug("서버가 시작되었습니다.");
284
-
285
- return { worker, port };
286
- }
287
- }
288
-
289
- /*
290
- interface IRequest {
291
- cmd: "watch" | "build";
292
- pkgPath: TNormPath;
293
- projConf: ISdProjectConfig;
294
- }
295
-
296
- type TResponse =
297
- | {
298
- type: "change";
299
- }
300
- | {
301
- type: "complete";
302
- result: ISdBuildRunnerResult;
303
- };
304
- */
@@ -1,11 +0,0 @@
1
- import { TNormPath } from "@simplysm/sd-core-node";
2
- import { ISdProjectConfig } from "./config.types";
3
-
4
- export interface ISdBuildRunnerWorkerRequest {
5
- cmd: "watch" | "build";
6
- pkgPath: TNormPath;
7
- projConf: ISdProjectConfig;
8
- workspaces: string[];
9
- emitOnly: boolean;
10
- noEmit: boolean;
11
- }
@@ -1,43 +0,0 @@
1
- import { CompilerOptions } from "typescript";
2
- import esbuild from "esbuild";
3
- import { ISdBuildMessage } from "./build.types";
4
- import { TNormPath } from "@simplysm/sd-core-node";
5
- import { ScopePathSet } from "../pkg-builders/commons/scope-path";
6
-
7
- export interface SdTsCompilerOptions {
8
- pkgPath: TNormPath;
9
- additionalOptions: CompilerOptions;
10
- isForBundle: boolean;
11
- isDevMode: boolean;
12
- isEmitOnly: boolean;
13
- isNoEmit: boolean;
14
- watchScopePathSet: ScopePathSet;
15
- globalStyleFilePath?: TNormPath;
16
- /*processWebWorker?: (
17
- workerFile: string,
18
- containingFile: string,
19
- ) => string;*/
20
- }
21
-
22
- export interface ISdTsCompilerResult {
23
- messages: ISdBuildMessage[];
24
- stylesheetBundlingResultMap: Map<TNormPath, TStylesheetBundlingResult>;
25
- emittedFilesCacheMap: Map<TNormPath, { outAbsPath?: TNormPath; text: string }[]>;
26
- emitFileSet: Set<TNormPath>;
27
- watchFileSet: Set<TNormPath>;
28
- affectedFileSet: Set<TNormPath>;
29
- }
30
-
31
- export type TStylesheetBundlingResult =
32
- | {
33
- errors: esbuild.PartialMessage[];
34
- warnings: esbuild.PartialMessage[];
35
- contents?: string;
36
- }
37
- | {
38
- errors: undefined;
39
- warnings: esbuild.PartialMessage[];
40
- metafile: esbuild.Metafile;
41
- outputFiles: esbuild.OutputFile[];
42
- contents: string;
43
- };
@@ -1,51 +0,0 @@
1
- import { ISdBuildRunnerWorkerRequest } from "./build-runner.types";
2
- import { ISdBuildMessage, ISdBuildRunnerResult } from "./build.types";
3
- import { ESLint } from "eslint";
4
- import { TNormPath } from "@simplysm/sd-core-node";
5
- import { ComponentStylesheetResult } from "@angular/build/src/tools/esbuild/angular/component-stylesheets";
6
-
7
- export interface TServerWorkerType {
8
- methods: {
9
- listen: { params: [{ path: string } | { port: number }]; returnType: number };
10
- setPathProxy: { params: [Record<string, string | number>]; returnType: void };
11
- broadcastReload: { params: [string | undefined, Set<string>]; returnType: void };
12
- };
13
- events: {};
14
- }
15
-
16
- export interface TSdLintWorkerType {
17
- methods: {
18
- lint: { params: [{ cwd: string; fileSet: Set<string> }]; returnType: ESLint.LintResult[] };
19
- };
20
- events: {};
21
- }
22
-
23
- // export interface TSdTsCompileWorkerType {
24
- // methods: {
25
- // initialize: { params: [SdTsCompilerOptions]; returnType: void };
26
- // compile: { params: [Set<TNormPath>]; returnType: ISdTsCompilerResult };
27
- // };
28
- // events: {};
29
- // }
30
-
31
- export interface TSdBuildRunnerWorkerType {
32
- methods: {
33
- run: { params: [ISdBuildRunnerWorkerRequest]; returnType: ISdBuildMessage[] | void };
34
- };
35
- events: {
36
- change: void;
37
- complete: ISdBuildRunnerResult;
38
- };
39
- }
40
-
41
- export interface TStyleBundlerWorkerType {
42
- methods: {
43
- prepare: { params: [string, boolean]; returnType: void };
44
- bundle: {
45
- params: [string, TNormPath, TNormPath | null];
46
- returnType: ComponentStylesheetResult;
47
- };
48
- invalidate: { params: [Set<TNormPath>]; returnType: void };
49
- };
50
- events: {};
51
- }