@simplysm/sd-cli 7.0.65 → 7.0.75

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 (74) hide show
  1. package/dist/SdCliBuildResultError.d.ts +5 -0
  2. package/dist/bin/sd-cli.d.ts +2 -0
  3. package/dist/bin/sd-cli.mjs +27 -6
  4. package/dist/build-tool/SdCliCacheCompilerHost.d.ts +10 -0
  5. package/dist/build-tool/SdCliCordova.d.ts +16 -0
  6. package/dist/build-tool/SdCliCordova.mjs +176 -0
  7. package/dist/build-tool/SdCliIndexFileGenerator.d.ts +13 -0
  8. package/dist/{entry-points → build-tool}/SdCliIndexFileGenerator.mjs +4 -3
  9. package/dist/build-tool/SdCliNgCacheCompilerHost.d.ts +11 -0
  10. package/dist/build-tool/SdCliPackageLinter.d.ts +8 -0
  11. package/dist/build-tool/SdCliPackageLinter.mjs +19 -2
  12. package/dist/builder/SdCliClientBuilder.d.ts +23 -0
  13. package/dist/builder/SdCliClientBuilder.mjs +69 -6
  14. package/dist/builder/SdCliJsLibBuilder.d.ts +14 -0
  15. package/dist/builder/SdCliServerBuilder.d.ts +25 -0
  16. package/dist/builder/SdCliServerBuilder.mjs +19 -10
  17. package/dist/builder/SdCliTsLibBuilder.d.ts +34 -0
  18. package/dist/builder/SdCliTsLibBuilder.mjs +84 -37
  19. package/dist/commons.d.ts +101 -0
  20. package/dist/entry-points/SdCliLocalUpdate.d.ts +13 -0
  21. package/dist/entry-points/SdCliNpm.d.ts +6 -0
  22. package/dist/entry-points/SdCliPrepare.d.ts +5 -0
  23. package/dist/entry-points/SdCliPrepare.mjs +2 -2
  24. package/dist/entry-points/SdCliWorkspace.d.ts +31 -0
  25. package/dist/entry-points/SdCliWorkspace.mjs +67 -51
  26. package/dist/index.d.ts +29 -0
  27. package/dist/index.mjs +5 -3
  28. package/dist/ng-tools/SdCliNgModuleGenerator.d.ts +28 -0
  29. package/dist/ng-tools/SdCliNgModuleGenerator.mjs +486 -0
  30. package/dist/ng-tools/babel/SdCliBbFileMetadata.d.ts +23 -0
  31. package/dist/ng-tools/babel/SdCliBbFileMetadata.mjs +187 -36
  32. package/dist/ng-tools/babel/SdCliBbRootMetadata.d.ts +22 -0
  33. package/dist/ng-tools/babel/SdCliBbRootMetadata.mjs +10 -7
  34. package/dist/ng-tools/babel/SdCliBbUtil.d.ts +5 -0
  35. package/dist/ng-tools/babel/SdCliBbUtil.mjs +2 -2
  36. package/dist/ng-tools/babel/TSdCliBbNgMetadata.d.ts +42 -0
  37. package/dist/ng-tools/babel/TSdCliBbNgMetadata.mjs +107 -76
  38. package/dist/ng-tools/babel/TSdCliBbTypeMetadata.d.ts +44 -0
  39. package/dist/ng-tools/commons.d.ts +9 -0
  40. package/dist/ng-tools/typescript/SdCliTsFileMetadata.d.ts +61 -0
  41. package/dist/ng-tools/typescript/SdCliTsFileMetadata.mjs +12 -12
  42. package/dist/ng-tools/typescript/SdCliTsRootMetadata.d.ts +8 -0
  43. package/dist/ng-tools/typescript/SdCliTsUtil.d.ts +5 -0
  44. package/dist/ng-tools/typescript/SdCliTsUtil.mjs +28 -0
  45. package/dist/packages/SdCliPackage.d.ts +23 -0
  46. package/dist/packages/SdCliPackage.mjs +53 -7
  47. package/dist/utils/SdCliBuildResultUtil.d.ts +9 -0
  48. package/dist/utils/SdCliConfigUtil.d.ts +7 -0
  49. package/dist/utils/SdCliNpmConfigUtil.d.ts +7 -0
  50. package/package.json +11 -8
  51. package/src/bin/sd-cli.ts +26 -5
  52. package/src/build-tool/SdCliCordova.ts +224 -0
  53. package/src/{entry-points → build-tool}/SdCliIndexFileGenerator.ts +3 -2
  54. package/src/build-tool/SdCliPackageLinter.ts +18 -2
  55. package/src/builder/SdCliClientBuilder.ts +84 -5
  56. package/src/builder/SdCliServerBuilder.ts +20 -9
  57. package/src/builder/SdCliTsLibBuilder.ts +101 -45
  58. package/src/commons.ts +43 -0
  59. package/src/entry-points/SdCliPrepare.ts +1 -1
  60. package/src/entry-points/SdCliWorkspace.ts +71 -56
  61. package/src/index.ts +4 -2
  62. package/src/ng-tools/SdCliNgModuleGenerator.ts +643 -0
  63. package/src/ng-tools/babel/SdCliBbFileMetadata.ts +234 -38
  64. package/src/ng-tools/babel/SdCliBbRootMetadata.ts +10 -6
  65. package/src/ng-tools/babel/SdCliBbUtil.ts +1 -1
  66. package/src/ng-tools/babel/TSdCliBbNgMetadata.ts +36 -22
  67. package/src/ng-tools/commons.ts +1 -1
  68. package/src/ng-tools/typescript/SdCliTsFileMetadata.ts +12 -12
  69. package/src/ng-tools/typescript/SdCliTsUtil.ts +29 -0
  70. package/src/packages/SdCliPackage.ts +56 -6
  71. package/tsconfig-build.json +1 -1
  72. package/tsconfig.json +3 -0
  73. package/dist/ng-tools/NgModuleGenerator.mjs +0 -278
  74. package/src/ng-tools/NgModuleGenerator.ts +0 -361
@@ -1,4 +1,4 @@
1
- import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
1
+ import { FsUtil, Logger, PathUtil, SdProcess } from "@simplysm/sd-core-node";
2
2
  import path from "path";
3
3
  import { INpmConfig, ISdCliConfig, ISdCliPackageBuildResult } from "../commons";
4
4
  import { SdCliPackage } from "../packages/SdCliPackage";
@@ -11,7 +11,6 @@ import { SdServiceServer } from "@simplysm/sd-service-server";
11
11
  import { SdCliNpm } from "./SdCliNpm";
12
12
  import { SdCliLocalUpdate } from "./SdCliLocalUpdate";
13
13
  import { NextHandleFunction } from "connect";
14
- import { SdCliIndexFileGenerator } from "./SdCliIndexFileGenerator";
15
14
 
16
15
  export class SdCliWorkspace {
17
16
  private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
@@ -24,7 +23,7 @@ export class SdCliWorkspace {
24
23
  this._npmConfig = FsUtil.readJson(npmConfigFilePath);
25
24
  }
26
25
 
27
- public async watchAsync(opt: { confFileRelPath: string; optNames: string[] }): Promise<void> {
26
+ public async watchAsync(opt: { confFileRelPath: string; optNames: string[]; pkgs: string[] }): Promise<void> {
28
27
  this._logger.debug("프로젝트 설정 가져오기...");
29
28
  const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), true, opt.optNames);
30
29
 
@@ -34,14 +33,7 @@ export class SdCliWorkspace {
34
33
  }
35
34
 
36
35
  this._logger.debug("패키지 목록 구성...");
37
- const pkgs = await this._getPackagesAsync(config);
38
-
39
- this._logger.debug("패키지 인덱스 생성기 실행...");
40
- await pkgs.parallelAsync(async (pkg) => {
41
- if (pkg.config.type === "library" && pkg.config.autoIndex) {
42
- await new SdCliIndexFileGenerator(pkg.rootPath, pkg.config.autoIndex).watchAsync();
43
- }
44
- });
36
+ const pkgs = await this._getPackagesAsync(config, opt.pkgs);
45
37
 
46
38
  this._logger.debug("패키지 이벤트 설정...");
47
39
  let changeCount = 0;
@@ -74,23 +66,42 @@ export class SdCliWorkspace {
74
66
  });
75
67
  }
76
68
 
77
- this._logger.debug("빌드를 시작합니다...");
78
- const pkgNames = pkgs.map((item) => item.name);
79
- const buildCompletedPackageNames: string[] = [];
80
- await pkgs.parallelAsync(async (pkg) => {
81
- await Wait.until(() => !pkg.allDependencies.some((dep) => pkgNames.includes(dep) && !buildCompletedPackageNames.includes(dep)));
82
- if (pkg.config.type === "client") {
83
- const middlewares = (await pkg.watchAsync()) as NextHandleFunction[];
84
69
 
85
- const serverInfo = this._serverInfoMap.getOrCreate(pkg.config.server, { middlewares: [], clientInfos: [] });
86
- serverInfo.middlewares.push(...middlewares);
87
- serverInfo.clientInfos.push({ pkgKey: pkg.name.split("/").last()! });
88
- }
89
- else {
90
- await pkg.watchAsync();
91
- }
92
- buildCompletedPackageNames.push(pkg.name);
93
- });
70
+ if (changeCount === 0) {
71
+ this._logger.log("빌드를 시작합니다...");
72
+ }
73
+ changeCount++;
74
+
75
+ try {
76
+ const pkgNames = pkgs.map((item) => item.name);
77
+ const buildCompletedPackageNames: string[] = [];
78
+ await pkgs.parallelAsync(async (pkg) => {
79
+ await Wait.until(() => !pkg.allDependencies.some((dep) => pkgNames.includes(dep) && !buildCompletedPackageNames.includes(dep)));
80
+ if (pkg.config.type === "client") {
81
+ const middlewares = (await pkg.watchAsync()) as NextHandleFunction[];
82
+
83
+ const serverInfo = this._serverInfoMap.getOrCreate(pkg.config.server, { middlewares: [], clientInfos: [] });
84
+ serverInfo.middlewares.push(...middlewares);
85
+ serverInfo.clientInfos.push({ pkgKey: pkg.name.split("/").last()! });
86
+ }
87
+ else {
88
+ await pkg.watchAsync();
89
+ }
90
+ buildCompletedPackageNames.push(pkg.name);
91
+ });
92
+ }
93
+ catch (err) {
94
+ this._loggingResults(totalResultMap);
95
+ this._loggingOpenClientHrefs();
96
+ throw err;
97
+ }
98
+
99
+ changeCount--;
100
+ if (changeCount === 0) {
101
+ this._loggingResults(totalResultMap);
102
+ this._loggingOpenClientHrefs();
103
+ this._logger.info("모든 빌드가 완료되었습니다.");
104
+ }
94
105
  }
95
106
 
96
107
  private _isServerRestarting = false;
@@ -107,18 +118,22 @@ export class SdCliWorkspace {
107
118
  }
108
119
  const entryFilePath = path.resolve(pkg.rootPath, entryFileRelPath);
109
120
 
110
- this._logger.log(`서버(${pkg.name}) 재시작...`);
111
121
  try {
112
122
  const serverInfo = this._serverInfoMap.getOrCreate(path.basename(pkg.rootPath), {
113
123
  middlewares: [],
114
124
  clientInfos: []
115
125
  });
116
126
  if (serverInfo.server) {
127
+ this._logger.log(`[${pkg.name}] 기존 서버 중지...`);
117
128
  await serverInfo.server.closeAsync();
118
129
  delete serverInfo.server;
119
130
  }
120
131
 
121
- serverInfo.server = (await import("file:///" + entryFilePath + "?update=" + Uuid.new().toString())).default as SdServiceServer | undefined;
132
+ this._logger.log(`[${pkg.name}] 서버 시작중...`);
133
+
134
+ const serverMainPath = "file:///" + PathUtil.posix(entryFilePath) + "?update=" + Uuid.new().toString().replace(/-/g, "");
135
+ const serverModule = await import(serverMainPath);
136
+ serverInfo.server = serverModule.default as SdServiceServer | undefined;
122
137
  if (!serverInfo.server) {
123
138
  this._logger.error(`${entryFilePath}(0, 0): 'SdServiceServer'를 'export'해야 합니다.`);
124
139
  this._isServerRestarting = false;
@@ -127,7 +142,7 @@ export class SdCliWorkspace {
127
142
  serverInfo.server.devMiddlewares = serverInfo.middlewares;
128
143
  await Wait.until(() => serverInfo.server!.isOpen);
129
144
 
130
- this._logger.log(`서버(${pkg.name}) 재시작 완료`);
145
+ this._logger.log(`[${pkg.name}] 서버가 시작되었습니다.`);
131
146
  }
132
147
  catch (err) {
133
148
  this._logger.error(`서버(${pkg.name}) 재시작중 오류 발생`, err);
@@ -136,19 +151,12 @@ export class SdCliWorkspace {
136
151
  this._isServerRestarting = false;
137
152
  }
138
153
 
139
- public async buildAsync(opt: { confFileRelPath: string; optNames: string[] }): Promise<void> {
154
+ public async buildAsync(opt: { confFileRelPath: string; optNames: string[]; pkgs: string[] }): Promise<void> {
140
155
  this._logger.debug("프로젝트 설정 가져오기...");
141
156
  const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), false, opt.optNames);
142
157
 
143
158
  this._logger.debug("패키지 목록 구성...");
144
- const pkgs = await this._getPackagesAsync(config);
145
-
146
- this._logger.debug("패키지 인덱스 생성기 실행...");
147
- await pkgs.parallelAsync(async (pkg) => {
148
- if (pkg.config.type === "library" && pkg.config.autoIndex) {
149
- await new SdCliIndexFileGenerator(pkg.rootPath, pkg.config.autoIndex).runAsync();
150
- }
151
- });
159
+ const pkgs = await this._getPackagesAsync(config, opt.pkgs);
152
160
 
153
161
  this._logger.debug("프로젝트 및 패키지 버전 설정...");
154
162
  await this._upgradeVersionAsync(pkgs);
@@ -162,26 +170,32 @@ export class SdCliWorkspace {
162
170
  const pkgNames = pkgs.map((item) => item.name);
163
171
  const buildCompletedPackageNames: string[] = [];
164
172
  const totalResultMap = new Map<string, ISdCliPackageBuildResult[]>();
165
- await pkgs.parallelAsync(async (pkg) => {
166
- await Wait.until(() => !pkg.allDependencies.some((dep) => pkgNames.includes(dep) && !buildCompletedPackageNames.includes(dep)));
173
+ try {
174
+ await pkgs.parallelAsync(async (pkg) => {
175
+ await Wait.until(() => !pkg.allDependencies.some((dep) => pkgNames.includes(dep) && !buildCompletedPackageNames.includes(dep)));
167
176
 
168
- this._logger.debug(`[${pkg.name}] 빌드를 시작합니다...`);
169
- totalResultMap.set(pkg.name, await pkg.buildAsync());
170
- this._logger.debug(`[${pkg.name}] 빌드가 완료되었습니다.`);
177
+ this._logger.debug(`[${pkg.name}] 빌드를 시작합니다...`);
178
+ totalResultMap.set(pkg.name, await pkg.buildAsync());
179
+ this._logger.debug(`[${pkg.name}] 빌드가 완료되었습니다.`);
171
180
 
172
- buildCompletedPackageNames.push(pkg.name);
173
- });
181
+ buildCompletedPackageNames.push(pkg.name);
182
+ });
174
183
 
175
- this._loggingResults(totalResultMap);
176
- if (Array.from(totalResultMap.values()).mapMany().some((item) => item.severity === "error")) {
177
- throw new Error("빌드중 오류가 발생하였습니다.");
184
+ this._loggingResults(totalResultMap);
185
+ if (Array.from(totalResultMap.values()).mapMany().some((item) => item.severity === "error")) {
186
+ throw new Error("빌드중 오류가 발생하였습니다.");
187
+ }
188
+ else {
189
+ this._logger.info("모든 빌드가 완료되었습니다.");
190
+ }
178
191
  }
179
- else {
180
- this._logger.info("모든 빌드가 완료되었습니다.");
192
+ catch (err) {
193
+ this._loggingResults(totalResultMap);
194
+ throw new err;
181
195
  }
182
196
  }
183
197
 
184
- public async publishAsync(opt: { noBuild: boolean; confFileRelPath: string; optNames: string[] }): Promise<void> {
198
+ public async publishAsync(opt: { noBuild: boolean; confFileRelPath: string; optNames: string[]; pkgs: string[] }): Promise<void> {
185
199
  this._logger.debug("프로젝트 설정 가져오기...");
186
200
  const config = await SdCliConfigUtil.loadConfigAsync(path.resolve(this._rootPath, opt.confFileRelPath), false, opt.optNames);
187
201
 
@@ -200,7 +214,7 @@ export class SdCliWorkspace {
200
214
  }
201
215
 
202
216
  this._logger.debug("패키지 목록 구성...");
203
- const pkgs = await this._getPackagesAsync(config);
217
+ const pkgs = await this._getPackagesAsync(config, opt.pkgs);
204
218
 
205
219
  this._logger.debug("프로젝트 및 패키지 버전 설정...");
206
220
  await this._upgradeVersionAsync(pkgs);
@@ -273,16 +287,17 @@ export class SdCliWorkspace {
273
287
  process.stdout.clearLine(0);
274
288
  }
275
289
 
276
- private async _getPackagesAsync(conf: ISdCliConfig): Promise<SdCliPackage[]> {
290
+ private async _getPackagesAsync(conf: ISdCliConfig, pkgs: string[]): Promise<SdCliPackage[]> {
277
291
  const pkgRootPaths = await this._npmConfig.workspaces?.mapManyAsync(async (item) => await FsUtil.globAsync(item));
278
292
  if (!pkgRootPaths) {
279
293
  throw new Error("최상위 'package.json'에서 'workspaces'를 찾을 수 없습니다.");
280
294
  }
281
295
 
282
-
283
296
  return pkgRootPaths.map((pkgRootPath) => {
297
+ if (pkgs.length > 0 && !pkgs.includes(path.basename(pkgRootPath))) return undefined;
284
298
  const pkgConfig = conf.packages[path.basename(pkgRootPath)];
285
- return pkgConfig ? new SdCliPackage(this._rootPath, pkgRootPath, pkgConfig) : undefined;
299
+ if (!pkgConfig) return undefined;
300
+ return new SdCliPackage(this._rootPath, pkgRootPath, pkgConfig);
286
301
  }).filterExists();
287
302
  }
288
303
 
package/src/index.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from "./build-tool/SdCliCacheCompilerHost";
2
+ export * from "./build-tool/SdCliCordova";
3
+ export * from "./build-tool/SdCliIndexFileGenerator";
2
4
  export * from "./build-tool/SdCliNgCacheCompilerHost";
3
5
  export * from "./build-tool/SdCliPackageLinter";
4
6
  export * from "./builder/SdCliClientBuilder";
@@ -6,7 +8,6 @@ export * from "./builder/SdCliJsLibBuilder";
6
8
  export * from "./builder/SdCliServerBuilder";
7
9
  export * from "./builder/SdCliTsLibBuilder";
8
10
  export * from "./commons";
9
- export * from "./entry-points/SdCliIndexFileGenerator";
10
11
  export * from "./entry-points/SdCliLocalUpdate";
11
12
  export * from "./entry-points/SdCliNpm";
12
13
  export * from "./entry-points/SdCliPrepare";
@@ -17,9 +18,10 @@ export * from "./ng-tools/babel/SdCliBbUtil";
17
18
  export * from "./ng-tools/babel/TSdCliBbNgMetadata";
18
19
  export * from "./ng-tools/babel/TSdCliBbTypeMetadata";
19
20
  export * from "./ng-tools/commons";
20
- export * from "./ng-tools/NgModuleGenerator";
21
+ export * from "./ng-tools/SdCliNgModuleGenerator";
21
22
  export * from "./ng-tools/typescript/SdCliTsFileMetadata";
22
23
  export * from "./ng-tools/typescript/SdCliTsRootMetadata";
24
+ export * from "./ng-tools/typescript/SdCliTsUtil";
23
25
  export * from "./packages/SdCliPackage";
24
26
  export * from "./SdCliBuildResultError";
25
27
  export * from "./utils/SdCliBuildResultUtil";