@simplysm/sd-cli 12.7.4 → 12.7.6

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 (167) hide show
  1. package/dist/entry/sd-cli-ai-command.d.ts +3 -0
  2. package/dist/entry/{SdAiCommand.js → sd-cli-ai-command.js} +14 -9
  3. package/dist/entry/sd-cli-ai-command.js.map +1 -0
  4. package/dist/entry/{SdCliCordova.d.ts → sd-cli-cordova.d.ts} +1 -1
  5. package/dist/entry/{SdCliCordova.js → sd-cli-cordova.js} +33 -31
  6. package/dist/entry/sd-cli-cordova.js.map +1 -0
  7. package/dist/entry/{SdCliElectron.d.ts → sd-cli-electron.d.ts} +1 -1
  8. package/dist/entry/{SdCliElectron.js → sd-cli-electron.js} +18 -16
  9. package/dist/entry/sd-cli-electron.js.map +1 -0
  10. package/dist/entry/{SdCliLocalUpdate.js → sd-cli-local-update.js} +12 -11
  11. package/dist/entry/sd-cli-local-update.js.map +1 -0
  12. package/dist/entry/{SdCliProject.js → sd-cli-project.js} +36 -33
  13. package/dist/entry/sd-cli-project.js.map +1 -0
  14. package/dist/index.d.ts +30 -30
  15. package/dist/index.js +30 -30
  16. package/dist/index.js.map +1 -1
  17. package/dist/pkg-builders/client/{SdCliNgRoutesFileGenerator.js → sd-cli-ng-routes.file-generator.js} +13 -12
  18. package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js.map +1 -0
  19. package/dist/pkg-builders/client/{SdClientBuildRunner.d.ts → sd-client.build-runner.d.ts} +3 -3
  20. package/dist/pkg-builders/client/{SdClientBuildRunner.js → sd-client.build-runner.js} +34 -24
  21. package/dist/pkg-builders/client/sd-client.build-runner.js.map +1 -0
  22. package/dist/pkg-builders/client/{SdNgBundlerContext.js → sd-ng.bundler-context.js} +5 -5
  23. package/dist/pkg-builders/client/sd-ng.bundler-context.js.map +1 -0
  24. package/dist/pkg-builders/client/{SdNgBundler.d.ts → sd-ng.bundler.d.ts} +3 -3
  25. package/dist/pkg-builders/client/{SdNgBundler.js → sd-ng.bundler.js} +55 -96
  26. package/dist/pkg-builders/client/sd-ng.bundler.js.map +1 -0
  27. package/dist/pkg-builders/client/{createSdNgPlugin.d.ts → sd-ng.plugin-creator.d.ts} +2 -2
  28. package/dist/pkg-builders/client/{createSdNgPlugin.js → sd-ng.plugin-creator.js} +18 -15
  29. package/dist/pkg-builders/client/sd-ng.plugin-creator.js.map +1 -0
  30. package/dist/pkg-builders/lib/{SdCliIndexFileGenerator.js → sd-cli-index.file-generator.js} +8 -8
  31. package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +1 -0
  32. package/dist/pkg-builders/lib/{SdJsLibBuildRunner.d.ts → sd-js-lib.build-runner.d.ts} +2 -2
  33. package/dist/pkg-builders/lib/{SdJsLibBuildRunner.js → sd-js-lib.build-runner.js} +18 -15
  34. package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +1 -0
  35. package/dist/pkg-builders/lib/{SdTsLibBuildRunner.d.ts → sd-ts-lib.build-runner.d.ts} +2 -2
  36. package/dist/pkg-builders/lib/{SdTsLibBuildRunner.js → sd-ts-lib.build-runner.js} +17 -15
  37. package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +1 -0
  38. package/dist/pkg-builders/lib/{SdTsLibBuilder.d.ts → sd-ts-lib.builder.d.ts} +2 -2
  39. package/dist/pkg-builders/lib/{SdTsLibBuilder.js → sd-ts-lib.builder.js} +11 -10
  40. package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +1 -0
  41. package/dist/pkg-builders/{SdMultiBuildRunner.d.ts → sd-multi.build-runner.d.ts} +2 -2
  42. package/dist/pkg-builders/{SdMultiBuildRunner.js → sd-multi.build-runner.js} +13 -8
  43. package/dist/pkg-builders/sd-multi.build-runner.js.map +1 -0
  44. package/dist/pkg-builders/server/{SdServerBuildRunner.d.ts → sd-server.build-runner.d.ts} +3 -3
  45. package/dist/pkg-builders/server/{SdServerBuildRunner.js → sd-server.build-runner.js} +35 -32
  46. package/dist/pkg-builders/server/sd-server.build-runner.js.map +1 -0
  47. package/dist/pkg-builders/server/{SdServerBundler.d.ts → sd-server.bundler.d.ts} +2 -2
  48. package/dist/pkg-builders/server/{SdServerBundler.js → sd-server.bundler.js} +15 -13
  49. package/dist/pkg-builders/server/sd-server.bundler.js.map +1 -0
  50. package/dist/pkg-builders/server/{createSdServerPlugin.d.ts → sd-server.plugin-creator.d.ts} +2 -2
  51. package/dist/pkg-builders/server/{createSdServerPlugin.js → sd-server.plugin-creator.js} +11 -8
  52. package/dist/pkg-builders/server/sd-server.plugin-creator.js.map +1 -0
  53. package/dist/sd-cli.js +10 -10
  54. package/dist/sd-cli.js.map +1 -1
  55. package/dist/{ts-builder/SdTsCompiler.d.ts → ts-compiler/sd-ts-compiler.d.ts} +2 -2
  56. package/dist/{ts-builder/SdTsCompiler.js → ts-compiler/sd-ts-compiler.js} +72 -65
  57. package/dist/ts-compiler/sd-ts-compiler.js.map +1 -0
  58. package/dist/types/{build-plugin.type.d.ts → build-plugin.types.d.ts} +1 -1
  59. package/dist/types/build-plugin.types.js +3 -0
  60. package/dist/types/build-plugin.types.js.map +1 -0
  61. package/dist/types/{build-runner.type.d.ts → build-runner.types.d.ts} +2 -2
  62. package/dist/types/build-runner.types.js +3 -0
  63. package/dist/types/build-runner.types.js.map +1 -0
  64. package/dist/types/{build.type.d.ts → build.types.d.ts} +1 -1
  65. package/dist/types/build.types.js +2 -0
  66. package/dist/types/build.types.js.map +1 -0
  67. package/dist/types/common-configs.types.js +2 -0
  68. package/dist/types/common-configs.types.js.map +1 -0
  69. package/dist/types/config.types.js +2 -0
  70. package/dist/types/config.types.js.map +1 -0
  71. package/dist/types/{ts-compiler.type.d.ts → ts-compiler.types.d.ts} +3 -3
  72. package/dist/types/ts-compiler.types.js +5 -0
  73. package/dist/types/ts-compiler.types.js.map +1 -0
  74. package/dist/types/{workers.type.d.ts → worker.types.d.ts} +2 -2
  75. package/dist/types/worker.types.js +3 -0
  76. package/dist/types/worker.types.js.map +1 -0
  77. package/dist/utils/{SdCliConvertMessageUtil.d.ts → sd-cli-convert-message.utils.d.ts} +3 -3
  78. package/dist/utils/{SdCliConvertMessageUtil.js → sd-cli-convert-message.utils.js} +9 -6
  79. package/dist/utils/sd-cli-convert-message.utils.js.map +1 -0
  80. package/dist/utils/{SdCliPerformanceTime.js → sd-cli-performance-time.js} +1 -1
  81. package/dist/utils/sd-cli-performance-time.js.map +1 -0
  82. package/dist/workers/{build-runner-worker.js → build-runner.worker.js} +13 -10
  83. package/dist/workers/build-runner.worker.js.map +1 -0
  84. package/dist/workers/{server-worker.js → server.worker.js} +6 -5
  85. package/dist/workers/server.worker.js.map +1 -0
  86. package/package.json +7 -7
  87. package/src/entry/{SdAiCommand.ts → sd-cli-ai-command.ts} +18 -8
  88. package/src/entry/{SdCliCordova.ts → sd-cli-cordova.ts} +32 -32
  89. package/src/entry/{SdCliElectron.ts → sd-cli-electron.ts} +17 -17
  90. package/src/entry/{SdCliLocalUpdate.ts → sd-cli-local-update.ts} +11 -11
  91. package/src/entry/{SdCliProject.ts → sd-cli-project.ts} +36 -36
  92. package/src/index.ts +30 -30
  93. package/src/pkg-builders/client/{SdCliNgRoutesFileGenerator.ts → sd-cli-ng-routes.file-generator.ts} +14 -12
  94. package/src/pkg-builders/client/{SdClientBuildRunner.ts → sd-client.build-runner.ts} +52 -45
  95. package/src/pkg-builders/client/{SdNgBundlerContext.ts → sd-ng.bundler-context.ts} +4 -4
  96. package/src/pkg-builders/client/{SdNgBundler.ts → sd-ng.bundler.ts} +98 -130
  97. package/src/pkg-builders/client/{createSdNgPlugin.ts → sd-ng.plugin-creator.ts} +16 -16
  98. package/src/pkg-builders/lib/{SdCliIndexFileGenerator.ts → sd-cli-index.file-generator.ts} +7 -7
  99. package/src/pkg-builders/lib/{SdJsLibBuildRunner.ts → sd-js-lib.build-runner.ts} +16 -16
  100. package/src/pkg-builders/lib/{SdTsLibBuildRunner.ts → sd-ts-lib.build-runner.ts} +17 -17
  101. package/src/pkg-builders/lib/{SdTsLibBuilder.ts → sd-ts-lib.builder.ts} +10 -10
  102. package/src/pkg-builders/{SdMultiBuildRunner.ts → sd-multi.build-runner.ts} +12 -12
  103. package/src/pkg-builders/server/{SdServerBuildRunner.ts → sd-server.build-runner.ts} +34 -34
  104. package/src/pkg-builders/server/{SdServerBundler.ts → sd-server.bundler.ts} +15 -15
  105. package/src/pkg-builders/server/{createSdServerPlugin.ts → sd-server.plugin-creator.ts} +9 -9
  106. package/src/sd-cli.ts +10 -10
  107. package/src/{ts-builder/SdTsCompiler.ts → ts-compiler/sd-ts-compiler.ts} +146 -78
  108. package/src/types/{build-plugin.type.ts → build-plugin.types.ts} +1 -1
  109. package/src/types/{build-runner.type.ts → build-runner.types.ts} +2 -2
  110. package/src/types/{build.type.ts → build.types.ts} +1 -1
  111. package/src/types/{ts-compiler.type.ts → ts-compiler.types.ts} +3 -3
  112. package/src/types/{workers.type.ts → worker.types.ts} +2 -2
  113. package/src/utils/{SdCliConvertMessageUtil.ts → sd-cli-convert-message.utils.ts} +7 -7
  114. package/src/workers/{build-runner-worker.ts → build-runner.worker.ts} +12 -12
  115. package/src/workers/{server-worker.ts → server.worker.ts} +5 -5
  116. package/tsconfig.json +2 -1
  117. package/dist/entry/SdAiCommand.d.ts +0 -3
  118. package/dist/entry/SdAiCommand.js.map +0 -1
  119. package/dist/entry/SdCliCordova.js.map +0 -1
  120. package/dist/entry/SdCliElectron.js.map +0 -1
  121. package/dist/entry/SdCliLocalUpdate.js.map +0 -1
  122. package/dist/entry/SdCliProject.js.map +0 -1
  123. package/dist/pkg-builders/SdMultiBuildRunner.js.map +0 -1
  124. package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +0 -1
  125. package/dist/pkg-builders/client/SdClientBuildRunner.js.map +0 -1
  126. package/dist/pkg-builders/client/SdNgBundler.js.map +0 -1
  127. package/dist/pkg-builders/client/SdNgBundlerContext.js.map +0 -1
  128. package/dist/pkg-builders/client/createSdNgPlugin.js.map +0 -1
  129. package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +0 -1
  130. package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +0 -1
  131. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +0 -1
  132. package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +0 -1
  133. package/dist/pkg-builders/server/SdServerBuildRunner.js.map +0 -1
  134. package/dist/pkg-builders/server/SdServerBundler.js.map +0 -1
  135. package/dist/pkg-builders/server/createSdServerPlugin.js.map +0 -1
  136. package/dist/ts-builder/SdTsCompiler.js.map +0 -1
  137. package/dist/types/build-plugin.type.js +0 -2
  138. package/dist/types/build-plugin.type.js.map +0 -1
  139. package/dist/types/build-runner.type.js +0 -2
  140. package/dist/types/build-runner.type.js.map +0 -1
  141. package/dist/types/build.type.js +0 -2
  142. package/dist/types/build.type.js.map +0 -1
  143. package/dist/types/common-configs.type.js +0 -2
  144. package/dist/types/common-configs.type.js.map +0 -1
  145. package/dist/types/sd-configs.type.js +0 -2
  146. package/dist/types/sd-configs.type.js.map +0 -1
  147. package/dist/types/ts-compiler.type.js +0 -2
  148. package/dist/types/ts-compiler.type.js.map +0 -1
  149. package/dist/types/workers.type.js +0 -2
  150. package/dist/types/workers.type.js.map +0 -1
  151. package/dist/utils/SdCliConvertMessageUtil.js.map +0 -1
  152. package/dist/utils/SdCliPerformanceTime.js.map +0 -1
  153. package/dist/workers/build-runner-worker.js.map +0 -1
  154. package/dist/workers/server-worker.js.map +0 -1
  155. /package/dist/entry/{SdCliLocalUpdate.d.ts → sd-cli-local-update.d.ts} +0 -0
  156. /package/dist/entry/{SdCliProject.d.ts → sd-cli-project.d.ts} +0 -0
  157. /package/dist/pkg-builders/client/{SdCliNgRoutesFileGenerator.d.ts → sd-cli-ng-routes.file-generator.d.ts} +0 -0
  158. /package/dist/pkg-builders/client/{SdNgBundlerContext.d.ts → sd-ng.bundler-context.d.ts} +0 -0
  159. /package/dist/pkg-builders/lib/{SdCliIndexFileGenerator.d.ts → sd-cli-index.file-generator.d.ts} +0 -0
  160. /package/dist/types/{common-configs.type.d.ts → common-configs.types.d.ts} +0 -0
  161. /package/dist/types/{sd-configs.type.d.ts → config.types.d.ts} +0 -0
  162. /package/dist/utils/{SdCliPerformanceTime.d.ts → sd-cli-performance-time.d.ts} +0 -0
  163. /package/dist/workers/{build-runner-worker.d.ts → build-runner.worker.d.ts} +0 -0
  164. /package/dist/workers/{server-worker.d.ts → server.worker.d.ts} +0 -0
  165. /package/src/types/{common-configs.type.ts → common-configs.types.ts} +0 -0
  166. /package/src/types/{sd-configs.type.ts → config.types.ts} +0 -0
  167. /package/src/utils/{SdCliPerformanceTime.ts → sd-cli-performance-time.ts} +0 -0
@@ -1,16 +1,16 @@
1
1
  import { EventEmitter } from "events";
2
- import { FsUtil, Logger, PathUtil, SdFsWatcher, TNormPath } from "@simplysm/sd-core-node";
2
+ import { FsUtils, SdLogger, PathUtils, SdFsWatcher, type TNormPath } from "@simplysm/sd-core-node";
3
3
  import path from "path";
4
- import { SdNgBundler } from "./SdNgBundler";
5
- import { SdCliNgRoutesFileGenerator } from "./SdCliNgRoutesFileGenerator";
6
- import { SdCliCordova } from "../../entry/SdCliCordova";
7
- import { SdCliElectron } from "../../entry/SdCliElectron";
8
- import { ISdClientPackageConfig, ISdProjectConfig } from "../../types/sd-configs.type";
9
- import { INpmConfig } from "../../types/common-configs.type";
10
- import { ISdBuildMessage, ISdBuildRunnerResult } from "../../types/build.type";
4
+ import { SdNgBundler } from "./sd-ng.bundler";
5
+ import { SdCliNgRoutesFileGenerator } from "./sd-cli-ng-routes.file-generator";
6
+ import { SdCliCordova } from "../../entry/sd-cli-cordova";
7
+ import { SdCliElectron } from "../../entry/sd-cli-electron";
8
+ import { type ISdClientPackageConfig, type ISdProjectConfig } from "../../types/config.types";
9
+ import { type INpmConfig } from "../../types/common-configs.types";
10
+ import { type ISdBuildMessage, type ISdBuildRunnerResult } from "../../types/build.types";
11
11
 
12
12
  export class SdClientBuildRunner extends EventEmitter {
13
- private _logger = Logger.get(["simplysm", "sd-cli", "SdClientBuildRunner"]);
13
+ private _logger = SdLogger.get(["simplysm", "sd-cli", "SdClientBuildRunner"]);
14
14
  private _pkgConf: ISdClientPackageConfig;
15
15
  private _npmConf: INpmConfig;
16
16
  private _ngBundlers?: SdNgBundler[];
@@ -23,16 +23,16 @@ export class SdClientBuildRunner extends EventEmitter {
23
23
  ) {
24
24
  super();
25
25
  this._pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdClientPackageConfig;
26
- this._npmConf = FsUtil.readJson(path.resolve(_pkgPath, "package.json")) as INpmConfig;
26
+ this._npmConf = FsUtils.readJson(path.resolve(_pkgPath, "package.json")) as INpmConfig;
27
27
 
28
28
  const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
29
- FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
29
+ FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
30
30
  );
31
31
  this._watchScopePathSet = new Set(
32
32
  [
33
33
  path.resolve(this._pkgPath, "../"),
34
- ...localUpdatePaths
35
- ].map((item) => PathUtil.norm(item)),
34
+ ...localUpdatePaths,
35
+ ].map((item) => PathUtils.norm(item)),
36
36
  );
37
37
  }
38
38
 
@@ -45,13 +45,14 @@ export class SdClientBuildRunner extends EventEmitter {
45
45
 
46
46
  public async buildAsync(): Promise<ISdBuildRunnerResult> {
47
47
  this._debug("dist 초기화...");
48
- FsUtil.remove(path.resolve(this._pkgPath, "dist"));
48
+ FsUtils.remove(path.resolve(this._pkgPath, "dist"));
49
49
 
50
50
  this._debug("GEN .config...");
51
51
  const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
52
- FsUtil.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
52
+ FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
53
53
 
54
- if (this._npmConf.dependencies && Object.keys(this._npmConf.dependencies).includes("@angular/router")) {
54
+ if (this._npmConf.dependencies && Object.keys(this._npmConf.dependencies)
55
+ .includes("@angular/router")) {
55
56
  this._debug(`GEN routes.ts...`);
56
57
  SdCliNgRoutesFileGenerator.run(this._pkgPath, undefined, this._pkgConf.noLazyRoute);
57
58
  }
@@ -68,16 +69,17 @@ export class SdClientBuildRunner extends EventEmitter {
68
69
  this.emit("change");
69
70
 
70
71
  this._debug("dist 초기화...");
71
- FsUtil.remove(path.resolve(this._pkgPath, "dist"));
72
+ FsUtils.remove(path.resolve(this._pkgPath, "dist"));
72
73
 
73
- if (this._npmConf.dependencies && Object.keys(this._npmConf.dependencies).includes("@angular/router")) {
74
+ if (this._npmConf.dependencies && Object.keys(this._npmConf.dependencies)
75
+ .includes("@angular/router")) {
74
76
  this._debug(`WATCH GEN routes.ts...`);
75
77
  SdCliNgRoutesFileGenerator.watch(this._pkgPath, this._pkgConf.noLazyRoute);
76
78
  }
77
79
 
78
80
  this._debug("GEN .config...");
79
81
  const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
80
- FsUtil.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
82
+ FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
81
83
 
82
84
  const result = await this._runAsync({ dev: !this._pkgConf.forceProductionMode });
83
85
  const res: ISdBuildRunnerResult = {
@@ -89,26 +91,27 @@ export class SdClientBuildRunner extends EventEmitter {
89
91
 
90
92
  this._debug("WATCH...");
91
93
  let lastWatchFileSet = result.watchFileSet;
92
- SdFsWatcher.watch(Array.from(this._watchScopePathSet)).onChange({ delay: 100 }, async (changeInfos) => {
93
- const currentChangeInfos = changeInfos.filter((item) => lastWatchFileSet.has(item.path));
94
- if (currentChangeInfos.length < 1) return;
95
-
96
- this.emit("change");
97
-
98
- for (const ngBundler of this._ngBundlers!) {
99
- ngBundler.markForChanges(currentChangeInfos.map((item) => item.path));
100
- }
101
-
102
- const watchResult = await this._runAsync({ dev: !this._pkgConf.forceProductionMode });
103
- const watchRes: ISdBuildRunnerResult = {
104
- affectedFilePathSet: watchResult.affectedFileSet,
105
- buildMessages: watchResult.buildMessages,
106
- emitFileSet: watchResult.emitFileSet,
107
- };
108
- this.emit("complete", watchRes);
109
-
110
- lastWatchFileSet = watchResult.watchFileSet;
111
- });
94
+ SdFsWatcher.watch(Array.from(this._watchScopePathSet))
95
+ .onChange({ delay: 100 }, async (changeInfos) => {
96
+ const currentChangeInfos = changeInfos.filter((item) => lastWatchFileSet.has(item.path));
97
+ if (currentChangeInfos.length < 1) return;
98
+
99
+ this.emit("change");
100
+
101
+ for (const ngBundler of this._ngBundlers!) {
102
+ ngBundler.markForChanges(currentChangeInfos.map((item) => item.path));
103
+ }
104
+
105
+ const watchResult = await this._runAsync({ dev: !this._pkgConf.forceProductionMode });
106
+ const watchRes: ISdBuildRunnerResult = {
107
+ affectedFilePathSet: watchResult.affectedFileSet,
108
+ buildMessages: watchResult.buildMessages,
109
+ emitFileSet: watchResult.emitFileSet,
110
+ };
111
+ this.emit("complete", watchRes);
112
+
113
+ lastWatchFileSet = watchResult.watchFileSet;
114
+ });
112
115
  }
113
116
 
114
117
  private async _runAsync(opt: { dev: boolean }): Promise<{
@@ -142,19 +145,23 @@ export class SdClientBuildRunner extends EventEmitter {
142
145
  pkgPath: this._pkgPath,
143
146
  outputPath:
144
147
  ngBundlerBuilderType === "web"
145
- ? PathUtil.norm(this._pkgPath, "dist")
148
+ ? PathUtils.norm(this._pkgPath, "dist")
146
149
  : ngBundlerBuilderType === "electron" && !opt.dev
147
- ? PathUtil.norm(this._pkgPath, ".electron/src")
150
+ ? PathUtils.norm(this._pkgPath, ".electron/src")
148
151
  : ngBundlerBuilderType === "cordova" && !opt.dev
149
- ? PathUtil.norm(this._pkgPath, ".cordova/www")
150
- : PathUtil.norm(this._pkgPath, "dist", ngBundlerBuilderType),
152
+ ? PathUtils.norm(this._pkgPath, ".cordova/www")
153
+ : PathUtils.norm(this._pkgPath, "dist", ngBundlerBuilderType),
151
154
  env: {
152
155
  ...this._pkgConf.env,
153
156
  ...this._pkgConf.builder?.[ngBundlerBuilderType]?.env,
154
157
  },
155
158
  external:
156
- ngBundlerBuilderType === "electron" ? (this._pkgConf.builder?.electron?.reinstallDependencies ?? []) : [],
157
- cordovaConfig: ngBundlerBuilderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
159
+ ngBundlerBuilderType === "electron"
160
+ ? (this._pkgConf.builder?.electron?.reinstallDependencies ?? [])
161
+ : [],
162
+ cordovaConfig: ngBundlerBuilderType === "cordova"
163
+ ? this._pkgConf.builder!.cordova
164
+ : undefined,
158
165
  watchScopePaths: Array.from(this._watchScopePathSet),
159
166
  }),
160
167
  );
@@ -1,7 +1,7 @@
1
1
  import esbuild from "esbuild";
2
2
  import path from "path";
3
- import { Logger } from "@simplysm/sd-core-node";
4
- import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
3
+ import { SdLogger } from "@simplysm/sd-core-node";
4
+ import { SdCliConvertMessageUtils } from "../../utils/sd-cli-convert-message.utils";
5
5
 
6
6
  // import { InitialFileRecord } from "@angular/build/src/tools/esbuild/bundler-context";
7
7
 
@@ -15,7 +15,7 @@ interface InitialFileRecord {
15
15
  }
16
16
 
17
17
  export class SdNgBundlerContext {
18
- readonly #logger = Logger.get(["simplysm", "sd-cli", "SdNgBundlerContext"]);
18
+ readonly #logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundlerContext"]);
19
19
 
20
20
  private _context?: esbuild.BuildContext;
21
21
 
@@ -48,7 +48,7 @@ export class SdNgBundlerContext {
48
48
 
49
49
  this.#debug(`convert results...`);
50
50
 
51
- const results = SdCliConvertMessageUtil.convertToBuildMessagesFromEsbuild(esbuildResult, this._pkgPath);
51
+ const results = SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(esbuildResult, this._pkgPath);
52
52
 
53
53
  const initialFiles = new Map<string, InitialFileRecord>();
54
54
 
@@ -1,11 +1,11 @@
1
1
  import path from "path";
2
- import esbuild, { Metafile } from "esbuild";
3
- import { FsUtil, Logger, PathUtil, TNormPath } from "@simplysm/sd-core-node";
2
+ import esbuild, { type Metafile } from "esbuild";
3
+ import { FsUtils, PathUtils, SdLogger, type TNormPath } from "@simplysm/sd-core-node";
4
4
  import { fileURLToPath } from "url";
5
5
  import nodeStdLibBrowser from "node-stdlib-browser";
6
6
  import nodeStdLibBrowserPlugin from "node-stdlib-browser/helpers/esbuild/plugin";
7
7
  import browserslist from "browserslist";
8
- import { SdNgBundlerContext } from "./SdNgBundlerContext";
8
+ import { SdNgBundlerContext } from "./sd-ng.bundler-context";
9
9
  import { MemoryLoadResultCache } from "@angular/build/src/tools/esbuild/load-result-cache";
10
10
  import {
11
11
  convertOutputFile,
@@ -13,35 +13,41 @@ import {
13
13
  transformSupportedBrowsersToTargets,
14
14
  } from "@angular/build/src/tools/esbuild/utils";
15
15
  import {
16
- BuildOutputFile,
16
+ type BuildOutputFile,
17
17
  BuildOutputFileType,
18
- InitialFileRecord,
18
+ type InitialFileRecord,
19
19
  } from "@angular/build/src/tools/esbuild/bundler-context";
20
20
  import { extractLicenses } from "@angular/build/src/tools/esbuild/license-extractor";
21
21
  import {
22
- HintMode,
22
+ type HintMode,
23
23
  IndexHtmlGenerator,
24
- IndexHtmlProcessResult,
24
+ type IndexHtmlProcessResult,
25
25
  } from "@angular/build/src/utils/index-file/index-html-generator";
26
- import { Entrypoint } from "@angular/build/src/utils/index-file/augment-index-html";
26
+ import { type Entrypoint } from "@angular/build/src/utils/index-file/augment-index-html";
27
27
  import { CrossOrigin } from "@angular/build/src/builders/application/schema";
28
28
  import { augmentAppWithServiceWorkerEsbuild } from "@angular/build/src/utils/service-worker";
29
- import { createSourcemapIgnorelistPlugin } from "@angular/build/src/tools/esbuild/sourcemap-ignorelist-plugin";
30
- import { StylesheetPluginFactory } from "@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
29
+ import {
30
+ createSourcemapIgnorelistPlugin,
31
+ } from "@angular/build/src/tools/esbuild/sourcemap-ignorelist-plugin";
32
+ import {
33
+ StylesheetPluginFactory,
34
+ } from "@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
31
35
  import { SassStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/sass-language";
32
36
  import { CssStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/css-language";
33
- import { createCssResourcePlugin } from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
37
+ import {
38
+ createCssResourcePlugin,
39
+ } from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
34
40
  import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
35
- import { createSdNgPlugin } from "./createSdNgPlugin";
36
- import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTime";
37
- import { INpmConfig } from "../../types/common-configs.type";
38
- import { ISdClientBuilderCordovaConfig } from "../../types/sd-configs.type";
39
- import { ISdCliNgPluginResultCache } from "../../types/build-plugin.type";
40
- import { ISdBuildMessage } from "../../types/build.type";
41
+ import { createSdNgPlugin } from "./sd-ng.plugin-creator";
42
+ import { SdCliPerformanceTimer } from "../../utils/sd-cli-performance-time";
43
+ import { type INpmConfig } from "../../types/common-configs.types";
44
+ import { type ISdClientBuilderCordovaConfig } from "../../types/config.types";
45
+ import { type ISdCliNgPluginResultCache } from "../../types/build-plugin.types";
46
+ import { type ISdBuildMessage } from "../../types/build.types";
41
47
  import nodeModule from "node:module";
42
48
 
43
49
  export class SdNgBundler {
44
- readonly #logger = Logger.get(["simplysm", "sd-cli", "SdNgBundler"]);
50
+ readonly #logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundler"]);
45
51
 
46
52
  readonly #modifiedFileSet = new Set<TNormPath>();
47
53
  readonly #ngResultCache: ISdCliNgPluginResultCache = {
@@ -75,7 +81,7 @@ export class SdNgBundler {
75
81
  watchScopePaths: TNormPath[];
76
82
  },
77
83
  ) {
78
- this.#pkgNpmConf = FsUtil.readJson(path.resolve(this._opt.pkgPath, "package.json"));
84
+ this.#pkgNpmConf = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json"));
79
85
  this.#mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
80
86
  this.#tsConfigFilePath = path.resolve(this._opt.pkgPath, "tsconfig.json");
81
87
  this.#swConfFilePath = path.resolve(this._opt.pkgPath, "ngsw-config.json");
@@ -92,8 +98,8 @@ export class SdNgBundler {
92
98
 
93
99
  public markForChanges(filePaths: string[]): void {
94
100
  for (const filePath of filePaths) {
95
- this.#modifiedFileSet.add(PathUtil.norm(filePath));
96
- this.#styleLoadResultCache.invalidate(PathUtil.norm(filePath));
101
+ this.#modifiedFileSet.add(PathUtils.norm(filePath));
102
+ this.#styleLoadResultCache.invalidate(PathUtils.norm(filePath));
97
103
  }
98
104
  // this._sourceFileCache.invalidate(filePaths);
99
105
  }
@@ -128,7 +134,8 @@ export class SdNgBundler {
128
134
  this.#debug(`convert result...`);
129
135
 
130
136
  const outputFiles: BuildOutputFile[] = bundlingResults.mapMany(
131
- (item) => item.outputFiles?.map((file) => convertOutputFile(file, BuildOutputFileType.Root)) ?? [],
137
+ (item) => item.outputFiles?.map((file) => convertOutputFile(file, BuildOutputFileType.Root))
138
+ ?? [],
132
139
  );
133
140
  const initialFiles = new Map<string, InitialFileRecord>();
134
141
  const metafile: {
@@ -175,7 +182,11 @@ export class SdNgBundler {
175
182
  type: "gen-index",
176
183
  });
177
184
  }
178
- outputFiles.push(createOutputFile("index.html", genIndexHtmlResult.csrContent, BuildOutputFileType.Root));
185
+ outputFiles.push(createOutputFile(
186
+ "index.html",
187
+ genIndexHtmlResult.csrContent,
188
+ BuildOutputFileType.Root,
189
+ ));
179
190
  });
180
191
 
181
192
  await perf.run("assets", async () => {
@@ -195,13 +206,17 @@ export class SdNgBundler {
195
206
  });
196
207
 
197
208
  //-- service worker
198
- if (FsUtil.exists(this.#swConfFilePath)) {
209
+ if (FsUtils.exists(this.#swConfFilePath)) {
199
210
  this.#debug(`prepare service worker...`);
200
211
 
201
212
  await perf.run("prepare service worker", async () => {
202
213
  try {
203
214
  const serviceWorkerResult = await this._genServiceWorkerAsync(outputFiles, assetFiles);
204
- outputFiles.push(createOutputFile("ngsw.json", serviceWorkerResult.manifest, BuildOutputFileType.Root));
215
+ outputFiles.push(createOutputFile(
216
+ "ngsw.json",
217
+ serviceWorkerResult.manifest,
218
+ BuildOutputFileType.Root,
219
+ ));
205
220
  assetFiles.push(...serviceWorkerResult.assetFiles);
206
221
  }
207
222
  catch (err) {
@@ -224,21 +239,21 @@ export class SdNgBundler {
224
239
  const emitFileSet = new Set<TNormPath>();
225
240
  perf.run("write output file", () => {
226
241
  for (const outputFile of outputFiles) {
227
- const distFilePath = PathUtil.norm(this._opt.outputPath, outputFile.path);
242
+ const distFilePath = PathUtils.norm(this._opt.outputPath, outputFile.path);
228
243
  const prev = this.#outputCache.get(distFilePath);
229
244
  if (prev !== Buffer.from(outputFile.contents).toString("base64")) {
230
- FsUtil.writeFile(distFilePath, outputFile.contents);
245
+ FsUtils.writeFile(distFilePath, outputFile.contents);
231
246
  this.#outputCache.set(distFilePath, Buffer.from(outputFile.contents).toString("base64"));
232
- emitFileSet.add(PathUtil.norm(outputFile.path));
247
+ emitFileSet.add(PathUtils.norm(outputFile.path));
233
248
  }
234
249
  }
235
250
  for (const assetFile of assetFiles) {
236
- const prev = this.#outputCache.get(PathUtil.norm(assetFile.source));
237
- const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
251
+ const prev = this.#outputCache.get(PathUtils.norm(assetFile.source));
252
+ const curr = FsUtils.lstat(assetFile.source).mtime.getTime();
238
253
  if (prev !== curr) {
239
- FsUtil.copy(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
240
- this.#outputCache.set(PathUtil.norm(assetFile.source), curr);
241
- emitFileSet.add(PathUtil.norm(assetFile.destination));
254
+ FsUtils.copy(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
255
+ this.#outputCache.set(PathUtils.norm(assetFile.source), curr);
256
+ emitFileSet.add(PathUtils.norm(assetFile.destination));
242
257
  }
243
258
  }
244
259
  });
@@ -248,9 +263,9 @@ export class SdNgBundler {
248
263
  return {
249
264
  watchFileSet: new Set([
250
265
  ...this.#ngResultCache.watchFileSet!,
251
- ...this.#styleLoadResultCache.watchFiles.map((item) => PathUtil.norm(item)),
252
- ...assetFiles.map((item) => PathUtil.norm(item.source)),
253
- PathUtil.norm(this.#indexHtmlFilePath),
266
+ ...this.#styleLoadResultCache.watchFiles.map((item) => PathUtils.norm(item)),
267
+ ...assetFiles.map((item) => PathUtils.norm(item.source)),
268
+ PathUtils.norm(this.#indexHtmlFilePath),
254
269
  ]),
255
270
  affectedFileSet: this.#ngResultCache.affectedFileSet!,
256
271
  results,
@@ -339,28 +354,29 @@ export class SdNgBundler {
339
354
  { input: "public", glob: "**/*", output: "." },
340
355
  ...(this._opt.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
341
356
  ...(this._opt.dev && this._opt.builderType === "cordova"
342
- ? Object.keys(this._opt.cordovaConfig?.platform ?? { browser: {} }).mapMany((platform) => [
343
- {
344
- input: `.cordova/platforms/${platform}/platform_www/plugins`,
345
- glob: "**/*",
346
- output: `cordova-${platform}/plugins`,
347
- },
348
- {
349
- input: `.cordova/platforms/${platform}/platform_www`,
350
- glob: "cordova.js",
351
- output: `cordova-${platform}`,
352
- },
353
- {
354
- input: `.cordova/platforms/${platform}/platform_www`,
355
- glob: "cordova_plugins.js",
356
- output: `cordova-${platform}`,
357
- },
358
- {
359
- input: `.cordova/platforms/${platform}/www`,
360
- glob: "config.xml",
361
- output: `cordova-${platform}`,
362
- },
363
- ])
357
+ ? Object.keys(this._opt.cordovaConfig?.platform ?? { browser: {} })
358
+ .mapMany((platform) => [
359
+ {
360
+ input: `.cordova/platforms/${platform}/platform_www/plugins`,
361
+ glob: "**/*",
362
+ output: `cordova-${platform}/plugins`,
363
+ },
364
+ {
365
+ input: `.cordova/platforms/${platform}/platform_www`,
366
+ glob: "cordova.js",
367
+ output: `cordova-${platform}`,
368
+ },
369
+ {
370
+ input: `.cordova/platforms/${platform}/platform_www`,
371
+ glob: "cordova_plugins.js",
372
+ output: `cordova-${platform}`,
373
+ },
374
+ {
375
+ input: `.cordova/platforms/${platform}/www`,
376
+ glob: "config.xml",
377
+ output: `cordova-${platform}`,
378
+ },
379
+ ])
364
380
  : []),
365
381
  ],
366
382
  this._opt.pkgPath,
@@ -391,9 +407,10 @@ export class SdNgBundler {
391
407
  }
392
408
 
393
409
  private _getAppContext() {
394
- const workerEntries = FsUtil.glob(path.resolve(this._opt.pkgPath, "src/workers/*.ts")).toObject(
395
- (p) => "workers/" + path.basename(p, path.extname(p)),
396
- );
410
+ const workerEntries = FsUtils.glob(path.resolve(this._opt.pkgPath, "src/workers/*.ts"))
411
+ .toObject(
412
+ (p) => "workers/" + path.basename(p, path.extname(p)),
413
+ );
397
414
 
398
415
  return new SdNgBundlerContext(this._opt.pkgPath, {
399
416
  absWorkingDir: this._opt.pkgPath,
@@ -411,7 +428,7 @@ export class SdNgBundler {
411
428
  pure: ["forwardRef"],
412
429
  outdir: this._opt.pkgPath,
413
430
  outExtension: undefined,
414
- sourcemap: this._opt.dev,
431
+ sourcemap: false, //this._opt.dev,
415
432
  chunkNames: "[name]-[hash]",
416
433
  tsconfig: this.#tsConfigFilePath,
417
434
  write: false,
@@ -435,7 +452,6 @@ export class SdNgBundler {
435
452
  entryNames: "[dir]/[name]",
436
453
  entryPoints: {
437
454
  main: this.#mainFilePath,
438
- // polyfills: 'angular:polyfills',
439
455
  // TODO: Polyfills Bundler 분리
440
456
  polyfills: path.resolve(this._opt.pkgPath, "src/polyfills.ts"),
441
457
  ...(this._opt.builderType === "cordova"
@@ -489,32 +505,12 @@ export class SdNgBundler {
489
505
  target: this.#browserTarget,
490
506
  format: "esm",
491
507
  splitting: true,
492
- inject: [PathUtil.posix(fileURLToPath(import.meta.resolve("node-stdlib-browser/helpers/esbuild/shim")))],
508
+ inject: [
509
+ PathUtils.posix(fileURLToPath(import.meta.resolve(
510
+ "node-stdlib-browser/helpers/esbuild/shim"))),
511
+ ],
493
512
  }),
494
513
  plugins: [
495
- /*...(this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins
496
- ? [
497
- {
498
- name: "cordova:plugin-empty",
499
- setup: ({ onResolve }) => {
500
- onResolve({ filter: new RegExp("(" + this._opt.cordovaConfig!.plugins!.join("|") + ")") }, () => {
501
- return {
502
- path: `./cordova-empty.js`,
503
- external: true,
504
- };
505
- });
506
- },
507
- },
508
- ]
509
- : []),*/
510
- // createVirtualModulePlugin({
511
- // namespace: "angular:polyfills",
512
- // loadContent: () => ({
513
- // contents: `import "./src/polyfills.ts";`,
514
- // loader: 'js',
515
- // resolveDir: this._opt.pkgPath
516
- // })
517
- // }) as esbuild.Plugin,
518
514
  createSourcemapIgnorelistPlugin(),
519
515
  createSdNgPlugin({
520
516
  modifiedFileSet: this.#modifiedFileSet,
@@ -523,38 +519,20 @@ export class SdNgBundler {
523
519
  result: this.#ngResultCache,
524
520
  watchScopePaths: this._opt.watchScopePaths,
525
521
  }),
526
- // createCompilerPlugin({
527
- // sourcemap: this._opt.dev,
528
- // tsconfig: this._tsConfigFilePath,
529
- // jit: false,
530
- // advancedOptimizations: true,
531
- // thirdPartySourcemaps: false,
532
- // fileReplacements: undefined,
533
- // sourceFileCache: this._sourceFileCache,
534
- // loadResultCache: this._sourceFileCache.loadResultCache,
535
- // incremental: this._opt.dev
536
- // }, {
537
- // workspaceRoot: this._opt.pkgPath,
538
- // optimization: !this._opt.dev,
539
- // sourcemap: this._opt.dev ? 'inline' : false,
540
- // outputNames: {bundles: '[name]', media: 'media/[name]'},
541
- // includePaths: [],
542
- // externalDependencies: [],
543
- // target: this._browserTarget,
544
- // inlineStyleLanguage: 'scss',
545
- // preserveSymlinks: false,
546
- // tailwindConfiguration: undefined
547
- // }) as esbuild.Plugin,
548
- ...(this._opt.builderType === "electron" ? [] : [nodeStdLibBrowserPlugin(nodeStdLibBrowser)]),
522
+ ...(this._opt.builderType === "electron"
523
+ ? []
524
+ : [nodeStdLibBrowserPlugin(nodeStdLibBrowser)]),
549
525
  // {
550
- // name: "sd-load-file",
551
- // setup: ({onLoad}) => {
552
- // onLoad({filter: /.*/}, (args) => {
553
- // this.#loadFilePathSet.add(args.path);
554
- // return null;
526
+ // name: "log-circular",
527
+ // setup(build) {
528
+ // build.onEnd(result => {
529
+ // if (result.metafile) {
530
+ // const analysis = esbuild.analyzeMetafile(result.metafile);
531
+ // console.log(analysis);
532
+ // }
555
533
  // });
556
- // }
557
- // }
534
+ // },
535
+ // },
558
536
  ],
559
537
  });
560
538
  }
@@ -562,7 +540,7 @@ export class SdNgBundler {
562
540
  private _getStyleContext(): SdNgBundlerContext {
563
541
  const pluginFactory = new StylesheetPluginFactory(
564
542
  {
565
- sourcemap: this._opt.dev,
543
+ sourcemap: false,//this._opt.dev,
566
544
  includePaths: [],
567
545
  },
568
546
  this.#styleLoadResultCache,
@@ -576,7 +554,7 @@ export class SdNgBundler {
576
554
  logLevel: "silent",
577
555
  minify: !this._opt.dev,
578
556
  metafile: true,
579
- sourcemap: this._opt.dev,
557
+ sourcemap: false,//this._opt.dev,
580
558
  outdir: this._opt.pkgPath,
581
559
  write: false,
582
560
  platform: "browser",
@@ -587,19 +565,9 @@ export class SdNgBundler {
587
565
  mainFields: ["style", "sass"],
588
566
  legalComments: !this._opt.dev ? "none" : "eof",
589
567
  entryPoints: {
590
- // styles: 'angular:styles/global;styles'
591
568
  styles: path.resolve(this._opt.pkgPath, "src/styles.scss"),
592
569
  },
593
570
  plugins: [
594
- // createVirtualModulePlugin({
595
- // namespace: "angular:styles/global",
596
- // transformPath: (currPath) => currPath.split(';', 2)[1],
597
- // loadContent: () => ({
598
- // contents: `@import 'src/styles.scss';`,
599
- // loader: 'css',
600
- // resolveDir: this._opt.pkgPath
601
- // }),
602
- // }) as esbuild.Plugin,
603
571
  pluginFactory.create(SassStylesheetLanguage),
604
572
  pluginFactory.create(CssStylesheetLanguage),
605
573
  createCssResourcePlugin(this.#styleLoadResultCache),
@@ -620,7 +588,7 @@ export class SdNgBundler {
620
588
  logLevel: "silent",
621
589
  minify: !this._opt.dev,
622
590
  outdir: this._opt.pkgPath,
623
- sourcemap: this._opt.dev,
591
+ sourcemap: false,//this._opt.dev,
624
592
  tsconfig: this.#tsConfigFilePath,
625
593
  write: false,
626
594
  preserveSymlinks: false,