@simplysm/sd-cli 7.3.2 → 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
@@ -0,0 +1,351 @@
1
+ import path from "path";
2
+ import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
3
+ import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
4
+ import { INpmConfig, ISdCliPackageBuildResult, TSdCliPackageConfig } from "../commons";
5
+ import cp from "child_process";
6
+ import { fileURLToPath } from "url";
7
+ import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
8
+ import semver from "semver";
9
+ import { NotImplementError, Wait } from "@simplysm/sd-core-common";
10
+
11
+ export class SdCliProject {
12
+ public static async watchAsync(opt: {
13
+ rootPath: string;
14
+ confFileRelPath: string;
15
+ optNames: string[];
16
+ pkgNames: string[];
17
+ }): Promise<void> {
18
+ const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "watchAsync"]);
19
+
20
+ logger.debug("프로젝트 설정 가져오기...");
21
+ const projConf = await SdCliConfigUtil.loadConfigAsync(path.resolve(opt.rootPath, opt.confFileRelPath), false, opt.optNames);
22
+
23
+ logger.debug("프로젝트 package.json 가져오기...");
24
+ const projNpmConf = FsUtil.readJson(path.resolve(opt.rootPath, "package.json"));
25
+
26
+ logger.debug("패키지 목록 구성...");
27
+ const allPkgPaths = await projNpmConf.workspaces?.mapManyAsync(async (item) => await FsUtil.globAsync(item));
28
+ let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
29
+ if (opt.pkgNames.length !== 0) {
30
+ pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
31
+ }
32
+
33
+ logger.debug("빌드 프로세스 준비...");
34
+ const cluster = await this._prepareClusterAsync();
35
+
36
+ logger.debug("빌드 프로세스 이벤트 준비...");
37
+ const resultCache = new Map<string, ISdCliPackageBuildResult[]>();
38
+ let busyCount = 0;
39
+ cluster.on("message", (message: any) => {
40
+ if (message.type === "change") {
41
+ if (busyCount === 0) {
42
+ logger.log("빌드를 시작합니다...");
43
+ }
44
+ busyCount++;
45
+ }
46
+ else if (message.type === "complete") {
47
+ for (const affectedFilePath of message.result.affectedFilePaths) {
48
+ resultCache.delete(affectedFilePath);
49
+ }
50
+
51
+ for (const buildResult of message.result.buildResults) {
52
+ const cacheItem = resultCache.getOrCreate(buildResult.filePath ?? "none", []);
53
+ cacheItem.push(buildResult);
54
+ }
55
+
56
+ setTimeout(() => {
57
+ busyCount--;
58
+ if (busyCount === 0) {
59
+ const buildResults = Array.from(resultCache.values()).mapMany();
60
+ this._logging(buildResults, logger);
61
+ }
62
+ }, 300);
63
+ }
64
+ });
65
+
66
+ logger.debug("빌드 프로세스 명령 전송...");
67
+ busyCount++;
68
+ logger.log("빌드를 시작합니다...");
69
+
70
+ await pkgPaths.parallelAsync(async (pkgPath) => {
71
+ await this._runCommandAsync(cluster, "watch", pkgPath);
72
+ });
73
+
74
+ busyCount--;
75
+ if (busyCount === 0) {
76
+ const buildResults = Array.from(resultCache.values()).mapMany();
77
+ this._logging(buildResults, logger);
78
+ }
79
+ }
80
+
81
+ public static async buildAsync(opt: {
82
+ rootPath: string;
83
+ confFileRelPath: string;
84
+ optNames: string[];
85
+ pkgNames: string[];
86
+ }): Promise<void> {
87
+ const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "buildAsync"]);
88
+
89
+ logger.debug("프로젝트 설정 가져오기...");
90
+ const projConf = await SdCliConfigUtil.loadConfigAsync(path.resolve(opt.rootPath, opt.confFileRelPath), false, opt.optNames);
91
+
92
+ logger.debug("프로젝트 package.json 가져오기...");
93
+ const projNpmConf = FsUtil.readJson(path.resolve(opt.rootPath, "package.json"));
94
+
95
+ logger.debug("패키지 목록 구성...");
96
+ const allPkgPaths = await projNpmConf.workspaces?.mapManyAsync(async (item) => await FsUtil.globAsync(item));
97
+ let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
98
+ if (opt.pkgNames.length !== 0) {
99
+ pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
100
+ }
101
+
102
+ logger.debug("프로젝트 및 패키지 버전 설정...");
103
+ await this._upgradeVersionAsync(opt.rootPath, projNpmConf, allPkgPaths);
104
+
105
+ logger.debug("빌드 프로세스 준비...");
106
+ const cluster = await this._prepareClusterAsync();
107
+
108
+ logger.debug("빌드 프로세스 명령 전달...");
109
+ const results = (
110
+ await pkgPaths.parallelAsync(async (pkgPath) => {
111
+ return await this._runCommandAsync(cluster, "build", pkgPath);
112
+ })
113
+ ).mapMany();
114
+
115
+ logger.debug("빌드 프로세스 닫기...");
116
+ this._closeCluster(cluster);
117
+
118
+ this._logging(results, logger);
119
+ }
120
+
121
+ public static async publishAsync(opt: {
122
+ rootPath: string;
123
+ noBuild: boolean;
124
+ confFileRelPath: string;
125
+ optNames: string[];
126
+ pkgNames: string[]
127
+ }): Promise<void> {
128
+ const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "publishAsync"]);
129
+
130
+ logger.debug("프로젝트 설정 가져오기...");
131
+ const projConf = await SdCliConfigUtil.loadConfigAsync(path.resolve(opt.rootPath, opt.confFileRelPath), false, opt.optNames);
132
+
133
+ logger.debug("프로젝트 package.json 가져오기...");
134
+ const projNpmConf = FsUtil.readJson(path.resolve(opt.rootPath, "package.json"));
135
+
136
+ if (opt.noBuild) {
137
+ logger.warn("빌드하지 않고, 배포하는것은 상당히 위험합니다.");
138
+ await this._waitSecMessageAsync("프로세스를 중지하려면, 'CTRL+C'를 누르세요.", 5);
139
+ }
140
+
141
+ // GIT 사용중일 경우, 커밋되지 않은 수정사항이 있는지 확인
142
+ if (FsUtil.exists(path.resolve(process.cwd(), ".git"))) {
143
+ logger.debug("GIT 커밋여부 확인...");
144
+ const gitStatusResult = await SdProcess.spawnAsync("git status");
145
+ if (gitStatusResult.includes("Changes") || gitStatusResult.includes("Untracked")) {
146
+ throw new Error("커밋되지 않은 정보가 있습니다.\n" + gitStatusResult);
147
+ }
148
+ }
149
+
150
+ logger.debug("패키지 목록 구성...");
151
+ const allPkgPaths = await projNpmConf.workspaces?.mapManyAsync(async (item) => await FsUtil.globAsync(item));
152
+ let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
153
+ if (opt.pkgNames.length !== 0) {
154
+ pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
155
+ }
156
+
157
+ logger.debug("프로젝트 및 패키지 버전 설정...");
158
+ await this._upgradeVersionAsync(opt.rootPath, projNpmConf, allPkgPaths);
159
+
160
+ // 빌드
161
+ if (!opt.noBuild) {
162
+ logger.debug("빌드 프로세스 준비...");
163
+ const cluster = await this._prepareClusterAsync();
164
+
165
+ logger.debug("빌드 프로세스 명령 전달...");
166
+ const results = (
167
+ await pkgPaths.parallelAsync(async (pkgPath) => {
168
+ return await this._runCommandAsync(cluster, "build", pkgPath);
169
+ })
170
+ ).mapMany();
171
+
172
+ logger.debug("빌드 프로세스 닫기...");
173
+ this._closeCluster(cluster);
174
+
175
+ this._logging(results, logger);
176
+ }
177
+
178
+ // GIT 사용중일경우, 새 버전 커밋 및 TAG 생성
179
+ if (FsUtil.exists(path.resolve(process.cwd(), ".git"))) {
180
+ logger.debug("새 버전 커밋 및 TAG 생성...");
181
+ await SdProcess.spawnAsync("git add .");
182
+ await SdProcess.spawnAsync(`git commit -m "v${projNpmConf.version}"`);
183
+ await SdProcess.spawnAsync(`git tag -a "v${projNpmConf.version}" -m "v${projNpmConf.version}"`);
184
+
185
+ logger.debug("새 버전 푸쉬...");
186
+ await SdProcess.spawnAsync("git push");
187
+ await SdProcess.spawnAsync("git push --tags");
188
+ }
189
+
190
+ logger.debug("배포 시작...");
191
+ await pkgPaths.parallelAsync(async (pkgPath) => {
192
+ const pkgName = path.basename(pkgPath);
193
+ const pkgConf = projConf.packages[pkgName];
194
+ if (pkgConf?.publish == null) return;
195
+
196
+ logger.debug(`[${pkgName}] 배포 시작...`);
197
+ await this._publishPkgAsync(pkgPath, pkgConf.publish);
198
+ logger.debug(`[${pkgName}] 배포 완료`);
199
+ });
200
+
201
+ logger.info(`모든 배포가 완료되었습니다. (v${projNpmConf.version})`);
202
+ }
203
+
204
+ private static async _publishPkgAsync(pkgPath: string, pkgPubConf: TSdCliPackageConfig["publish"]): Promise<void> {
205
+ if (pkgPubConf === "npm") {
206
+ await SdProcess.spawnAsync("yarn npm publish --access public", { cwd: pkgPath });
207
+ }
208
+ else {
209
+ throw new NotImplementError();
210
+ }
211
+ }
212
+
213
+ private static async _waitSecMessageAsync(msg: string, sec: number): Promise<void> {
214
+ for (let i = sec; i > 0; i--) {
215
+ if (i !== sec) {
216
+ process.stdout.cursorTo(0);
217
+ }
218
+ process.stdout.write(`${msg} ${i}`);
219
+ await Wait.time(1000);
220
+ }
221
+
222
+ process.stdout.cursorTo(0);
223
+ process.stdout.clearLine(0);
224
+ }
225
+
226
+ private static async _upgradeVersionAsync(projPath: string, projNpmConf: INpmConfig, allPkgPaths: string[]): Promise<void> {
227
+ // 작업공간 package.json 버전 설정
228
+ const newVersion = semver.inc(projNpmConf.version, "patch")!;
229
+ projNpmConf.version = newVersion;
230
+
231
+ const pkgNames = await allPkgPaths.mapAsync(async (pkgPath) => {
232
+ const pkgNpmConf = await FsUtil.readJsonAsync(path.resolve(pkgPath, "package.json"));
233
+ return pkgNpmConf.name;
234
+ });
235
+
236
+ const updateDepVersion = (deps: Record<string, string> | undefined): void => {
237
+ if (!deps) return;
238
+ for (const depName of Object.keys(deps)) {
239
+ if (pkgNames.includes(depName)) {
240
+ deps[depName] = newVersion;
241
+ }
242
+ }
243
+ };
244
+ updateDepVersion(projNpmConf.dependencies);
245
+ updateDepVersion(projNpmConf.optionalDependencies);
246
+ updateDepVersion(projNpmConf.devDependencies);
247
+ updateDepVersion(projNpmConf.peerDependencies);
248
+
249
+ const projNpmConfFilePath = path.resolve(projPath, "package.json");
250
+ await FsUtil.writeJsonAsync(projNpmConfFilePath, projNpmConf, { space: 2 });
251
+
252
+ // 각 패키지 package.json 버전 설정
253
+ await allPkgPaths.parallelAsync(async (pkgPath) => {
254
+ const pkgNpmConfFilePath = path.resolve(pkgPath, "package.json");
255
+ const pkgNpmConf = await FsUtil.readJsonAsync(pkgNpmConfFilePath);
256
+ pkgNpmConf.version = newVersion;
257
+
258
+ updateDepVersion(pkgNpmConf.dependencies);
259
+ updateDepVersion(pkgNpmConf.optionalDependencies);
260
+ updateDepVersion(pkgNpmConf.devDependencies);
261
+ updateDepVersion(pkgNpmConf.peerDependencies);
262
+
263
+ await FsUtil.writeJsonAsync(pkgNpmConfFilePath, pkgNpmConf, { space: 2 });
264
+ });
265
+ }
266
+
267
+ private static _logging(buildResults: ISdCliPackageBuildResult[], logger: Logger): void {
268
+ const messages = buildResults.filter((item) => item.severity === "message");
269
+ const suggestions = buildResults.filter((item) => item.severity === "suggestion");
270
+ const warnings = buildResults.filter((item) => item.severity === "warning");
271
+ const errors = buildResults.filter((item) => item.severity === "error");
272
+
273
+ if (messages.length > 0) {
274
+ logger.log("\n" + messages.map((item) => SdCliBuildResultUtil.getMessage(item)).join("\n"));
275
+ }
276
+ if (suggestions.length > 0) {
277
+ logger.info("\n" + suggestions.map((item) => SdCliBuildResultUtil.getMessage(item)).join("\n"));
278
+ }
279
+ if (warnings.length > 0) {
280
+ logger.warn("\n" + warnings.map((item) => SdCliBuildResultUtil.getMessage(item)).join("\n"));
281
+ }
282
+ if (errors.length > 0) {
283
+ logger.error("\n" + errors.map((item) => SdCliBuildResultUtil.getMessage(item)).join("\n"));
284
+ }
285
+
286
+ logger.info("모든 빌드가 완료되었습니다.");
287
+ }
288
+
289
+ private static async _prepareClusterAsync(): Promise<cp.ChildProcess> {
290
+ const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "_runBuildClusterAsync"]);
291
+
292
+ return await new Promise<cp.ChildProcess>(async (resolve, reject) => {
293
+ const cluster = cp.fork(
294
+ fileURLToPath(await import.meta.resolve!("../build-cluster")),
295
+ [],
296
+ {
297
+ stdio: ["pipe", "pipe", "pipe", "ipc"],
298
+ env: process.env
299
+ }
300
+ );
301
+
302
+ cluster.stdout!.pipe(process.stdout);
303
+ cluster.stderr!.pipe(process.stderr);
304
+
305
+ cluster.on("exit", (code) => {
306
+ if (code != null && code !== 0) {
307
+ const err = new Error(`오류와 함께 닫힘 (${code})`);
308
+ logger.error(err);
309
+ reject(err);
310
+ return;
311
+ }
312
+ });
313
+
314
+ cluster.on("error", (err) => {
315
+ logger.error(err);
316
+ reject(err);
317
+ });
318
+
319
+ cluster.on("message", (message) => {
320
+ if (message === "ready") {
321
+ logger.debug("빌드 클러스터 프로세스가 준비되었습니다.");
322
+ resolve(cluster);
323
+ }
324
+ });
325
+ });
326
+ }
327
+
328
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", pkgPath: string): Promise<void>;
329
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", pkgPath: string): Promise<ISdCliPackageBuildResult[]>;
330
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", pkgPath: string): Promise<ISdCliPackageBuildResult[] | void> {
331
+ await new Promise<ISdCliPackageBuildResult[] | void>((resolve) => {
332
+ const cb = (message): void => {
333
+ if (cmd === "watch" && message.type === "ready" && message.cmd === cmd && message.pkgPath === pkgPath) {
334
+ cluster.off("message", cb);
335
+ resolve();
336
+ }
337
+ else if (cmd === "build" && message.type === "complete" && message.cmd === cmd && message.pkgPath === pkgPath) {
338
+ cluster.off("message", cb);
339
+ resolve(message.result);
340
+ }
341
+ };
342
+ cluster.on("message", cb);
343
+
344
+ cluster.send({ cmd, pkgPath });
345
+ });
346
+ }
347
+
348
+ private static _closeCluster(cluster: cp.ChildProcess): void {
349
+ cluster.kill("SIGKILL");
350
+ }
351
+ }
package/src/sd-cli.ts ADDED
@@ -0,0 +1,135 @@
1
+ import yargs from "yargs";
2
+ import { hideBin } from "yargs/helpers";
3
+ import { SdCliProject } from "./entry/SdCliProject";
4
+ import { Logger, LoggerSeverity } from "@simplysm/sd-core-node";
5
+ import { EventEmitter } from "events";
6
+
7
+ EventEmitter.defaultMaxListeners = 0;
8
+
9
+ const argv = (
10
+ await yargs(hideBin(process.argv))
11
+ .help("help", "도움말")
12
+ .alias("help", "h")
13
+ .options({
14
+ debug: {
15
+ type: "boolean",
16
+ describe: "디버그 로그를 표시할 것인지 여부",
17
+ default: false
18
+ }
19
+ })
20
+ .command(
21
+ "watch",
22
+ "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.",
23
+ (cmd) => cmd.version(false).hide("help").hide("debug")
24
+ .options({
25
+ config: {
26
+ string: true,
27
+ describe: "simplysm.json 파일 경로"
28
+ },
29
+ options: {
30
+ string: true,
31
+ array: true,
32
+ describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)"
33
+ },
34
+ packages: {
35
+ string: true,
36
+ array: true,
37
+ describe: "수행할 패키지 설정"
38
+ }
39
+ })
40
+ )
41
+ .command(
42
+ "build",
43
+ "프로젝트의 각 패키지에 대한 빌드를 수행합니다.",
44
+ (cmd) => cmd.version(false).hide("help").hide("debug")
45
+ .options({
46
+ config: {
47
+ string: true,
48
+ describe: "simplysm.json 파일 경로"
49
+ },
50
+ options: {
51
+ string: true,
52
+ array: true,
53
+ describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)"
54
+ },
55
+ packages: {
56
+ string: true,
57
+ array: true,
58
+ describe: "수행할 패키지 설정"
59
+ }
60
+ })
61
+ )
62
+ .command(
63
+ "publish",
64
+ "프로젝트의 각 패키지를 배포합니다.",
65
+ (cmd) => cmd.version(false).hide("help").hide("debug")
66
+ .options({
67
+ noBuild: {
68
+ type: "boolean",
69
+ describe: "빌드를 하지않고 배포합니다.",
70
+ default: false
71
+ },
72
+ config: {
73
+ type: "string",
74
+ describe: "simplysm.json 파일 경로"
75
+ },
76
+ options: {
77
+ type: "string",
78
+ array: true,
79
+ describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)"
80
+ },
81
+ packages: {
82
+ type: "string",
83
+ array: true,
84
+ describe: "수행할 패키지 설정"
85
+ }
86
+ })
87
+ )
88
+ .parseAsync()
89
+ ) as any;
90
+
91
+ if (Boolean(argv.debug)) {
92
+ process.env["SD_DEBUG"] = "true";
93
+ Logger.setConfig({
94
+ console: {
95
+ level: LoggerSeverity.debug
96
+ }
97
+ });
98
+ }
99
+ else {
100
+ Logger.setConfig({
101
+ dot: true
102
+ });
103
+ }
104
+
105
+ if (argv._[0] === "watch") {
106
+ await SdCliProject
107
+ .watchAsync({
108
+ rootPath: process.cwd(),
109
+ confFileRelPath: argv.config ?? "simplysm.json",
110
+ optNames: argv.options ?? [],
111
+ pkgNames: argv.packages ?? []
112
+ });
113
+ }
114
+ else if (argv._[0] === "build") {
115
+ await SdCliProject
116
+ .buildAsync({
117
+ rootPath: process.cwd(),
118
+ confFileRelPath: argv.config ?? "simplysm.json",
119
+ optNames: argv.options ?? [],
120
+ pkgNames: argv.packages ?? []
121
+ });
122
+ }
123
+ else if (argv._[0] === "publish") {
124
+ await SdCliProject
125
+ .publishAsync({
126
+ rootPath: process.cwd(),
127
+ noBuild: argv.noBuild,
128
+ confFileRelPath: argv.config ?? "simplysm.json",
129
+ optNames: argv.options ?? [],
130
+ pkgNames: argv.packages ?? []
131
+ });
132
+ }
133
+ else {
134
+ throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
135
+ }
@@ -2,14 +2,13 @@ import ts from "typescript";
2
2
  import os from "os";
3
3
  import path from "path";
4
4
  import { ISdCliPackageBuildResult } from "../commons";
5
- import webpack from "webpack";
6
5
 
7
6
  export class SdCliBuildResultUtil {
8
- public static convertFromTsDiag(diag: ts.Diagnostic): ISdCliPackageBuildResult | undefined {
9
- const severity = diag.category === ts.DiagnosticCategory.Error ? "error"
10
- : diag.category === ts.DiagnosticCategory.Warning ? "warning"
11
- : undefined;
12
- if (!severity) return undefined;
7
+ public static convertFromTsDiag(diag: ts.Diagnostic): ISdCliPackageBuildResult {
8
+ const severity = diag.category === ts.DiagnosticCategory.Error ? "error" as const
9
+ : diag.category === ts.DiagnosticCategory.Warning ? "warning" as const
10
+ : diag.category === ts.DiagnosticCategory.Suggestion ? "suggestion" as const
11
+ : "message" as const;
13
12
 
14
13
  const code = `TS${diag.code}`;
15
14
  const message = ts.flattenDiagnosticMessageText(diag.messageText, os.EOL);
@@ -30,39 +29,7 @@ export class SdCliBuildResultUtil {
30
29
  };
31
30
  }
32
31
 
33
- public static convertFromWebpackStats(stats: webpack.Stats): ISdCliPackageBuildResult[] {
34
- const results: ISdCliPackageBuildResult[] = [];
35
-
36
- for (const statWarn of stats.compilation.warnings) {
37
- if (stats.compilation.options.ignoreWarnings?.some((ignoreWarning) => ignoreWarning(statWarn, stats.compilation))) continue;
38
-
39
- results.push(this._convertFromWebpackError("warning", statWarn));
40
- }
41
-
42
- for (const statErr of stats.compilation.errors) {
43
- results.push(this._convertFromWebpackError("error", statErr));
44
- }
45
-
46
- return results;
47
- }
48
-
49
- private static _convertFromWebpackError(severity: "warning" | "error", err: webpack.WebpackError): ISdCliPackageBuildResult {
50
- return {
51
- filePath: (err.file as string | undefined) ?? (err.module as webpack.Module | undefined)?.["request"],
52
- line: err.file ? err.loc?.["start"]?.line : undefined, // eslint-disable-line
53
- char: err.file ? err.loc?.["start"]?.column : undefined, // eslint-disable-line
54
- code: err.name,
55
- severity,
56
- message: err.message
57
- };
58
- }
59
-
60
-
61
32
  public static getMessage(result: ISdCliPackageBuildResult): string {
62
- if (result.code === "ESLintError") {
63
- return result.message;
64
- }
65
-
66
33
  let str = "";
67
34
  if (result.filePath !== undefined) {
68
35
  str += `${result.filePath}(${result.line ?? 0}, ${result.char ?? 0}): `;
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": [
5
+ "ES2021"
6
+ ],
7
+ "outDir": "./dist",
8
+ "baseUrl": ".",
9
+ "paths": {
10
+ "@simplysm/sd-core-common": [
11
+ "../sd-core-common/src/index.ts"
12
+ ],
13
+ "@simplysm/sd-core-node": [
14
+ "../sd-core-node/src/index.ts"
15
+ ]
16
+ }
17
+ }
18
+ }
package/README.md DELETED
@@ -1,105 +0,0 @@
1
- ## 심플리즘 패키지 - CLI
2
-
3
- ## Requirements
4
-
5
- * node v16.x.x
6
-
7
- ## 프로젝트 생성 방법
8
-
9
- ### 1. 폴더생성
10
-
11
- ``` bat
12
- mkdir sample
13
- cd sample
14
- ```
15
-
16
- ### 2. sd-cli 설치
17
-
18
- ``` bat
19
- yarn set version berry
20
- yarn config set nodeLinker node-modules
21
- yarn plugin import interactive-tools
22
-
23
- yarn add @simplysm/sd-cli@~7.1.0
24
- yarn upgrade-interactive
25
- ```
26
-
27
- ### 3. 프로젝트 초기화
28
-
29
- ``` bat
30
- :: npx sd-cli init --help 참고
31
- npx sd-cli init "샘플프로젝트" "홍길동" https://github.com/my/sample.git
32
- ```
33
-
34
- 필요시 아래 작업 수행
35
-
36
- * package.json 버전 변경 (초기값: 1.0.0)
37
- * [라이브러리 패키지 로컬업데이트 설정](docs/lib-local-update.md)
38
-
39
- ### 4. 각종 패키지 추가
40
-
41
- #### 서버 패키지 추가
42
-
43
- ``` bat
44
- :: npx sd-cli add server --help 참고
45
- npx sd-cli add server
46
- ```
47
-
48
- #### 클라이언트 패키지 추가
49
-
50
- ``` bat
51
- :: npx sd-cli add client --help 참고
52
- npx sd-cli add client admin 관리자 server
53
- ```
54
-
55
- 추가 작업
56
-
57
- * [클라이언트 패키지에 Router 기능 추가](docs/client-router.md)
58
- * [클라이언트 패키지에 ServiceWorker 기능 추가](docs/client-sw.md)
59
-
60
- #### 일반 라이브러리 패키지 추가
61
-
62
- ``` bat
63
- :: npx sd-cli add ts-lib --help 참고
64
- npx sd-cli add ts-lib common 공통모듈
65
- ```
66
-
67
- #### 브라우저용 라이브러리 패키지 추가
68
-
69
- ``` bat
70
- :: npx sd-cli add ts-lib --help 참고
71
- npx sd-cli add ts-lib browser-common "브라우저 공통" --useDom
72
- ```
73
-
74
- #### Angular용 라이브러리 패키지 추가
75
-
76
- ``` bat
77
- :: npx sd-cli add ts-lib --help 참고
78
- npx sd-cli add ts-lib client-common "클라이언트 공통" --isForAngular
79
- ```
80
-
81
- #### DB 라이브러리 패키지 추가
82
-
83
- ``` bat
84
- :: npx sd-cli add db-lib --help 참고
85
- npx sd-cli add db-lib main
86
- ```
87
-
88
- 추가 작업
89
-
90
- * [각 패키지에 orm 설정](docs/conf-orm.md)
91
- * [DB 라이브러리 패키지에 모델 추가](#DB-라이브러리-패키지에-모델-추가)
92
- * [테스트 환경 구성](docs/add-tests.md)
93
-
94
- ### 패키지별 세부기능 추가
95
-
96
- #### DB 라이브러리 패키지에 모델 추가
97
-
98
- ``` bat
99
- :: npx sd-cli add db-model --help 참고
100
- npx sd-cli add db-model main base Employee 직원
101
- ```
102
-
103
- 주의사항
104
-
105
- * DB 라이브러리 추가가 먼저 되어야 함
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes