@simplysm/sd-cli 10.0.36 → 10.0.39

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 (87) hide show
  1. package/dist/SdLinter.js.map +1 -1
  2. package/dist/SdTsIncrementalBuilder.d.ts +17 -4
  3. package/dist/SdTsIncrementalBuilder.js +29 -33
  4. package/dist/SdTsIncrementalBuilder.js.map +1 -1
  5. package/dist/build-cluster.js +98 -30
  6. package/dist/build-cluster.js.map +1 -1
  7. package/dist/builders/SdCliClientBuilder.d.ts +6 -2
  8. package/dist/builders/SdCliClientBuilder.js +107 -97
  9. package/dist/builders/SdCliClientBuilder.js.map +1 -1
  10. package/dist/builders/SdCliJsLibLinter.js.map +1 -1
  11. package/dist/builders/SdCliServerBuilder.d.ts +2 -1
  12. package/dist/builders/SdCliServerBuilder.js +68 -13
  13. package/dist/builders/SdCliServerBuilder.js.map +1 -1
  14. package/dist/builders/SdCliTsLibBuilder.d.ts +5 -2
  15. package/dist/builders/SdCliTsLibBuilder.js +64 -10
  16. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  17. package/dist/commons.d.ts +28 -2
  18. package/dist/commons.js.map +1 -1
  19. package/dist/entry/SdCliElectron.d.ts +7 -0
  20. package/dist/entry/SdCliElectron.js +42 -0
  21. package/dist/entry/SdCliElectron.js.map +1 -0
  22. package/dist/entry/SdCliLocalUpdate.d.ts +3 -3
  23. package/dist/entry/SdCliLocalUpdate.js +20 -26
  24. package/dist/entry/SdCliLocalUpdate.js.map +1 -1
  25. package/dist/entry/SdCliProject.d.ts +3 -3
  26. package/dist/entry/SdCliProject.js +87 -36
  27. package/dist/entry/SdCliProject.js.map +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.js +2 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/sd-cli.d.ts +1 -1
  32. package/dist/sd-cli.js +62 -16
  33. package/dist/sd-cli.js.map +1 -1
  34. package/dist/server-worker.js.map +1 -1
  35. package/dist/utils/SdCliBuildResultUtil.js +1 -1
  36. package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
  37. package/dist/utils/SdCliViteElectronMainPlugin.d.ts +6 -0
  38. package/dist/utils/SdCliViteElectronMainPlugin.js +81 -0
  39. package/dist/utils/SdCliViteElectronMainPlugin.js.map +1 -0
  40. package/dist/utils/SdCliViteExternalPlugin.d.ts +7 -0
  41. package/dist/utils/SdCliViteExternalPlugin.js +98 -0
  42. package/dist/utils/SdCliViteExternalPlugin.js.map +1 -0
  43. package/dist/utils/SdCliViteLoggerPlugin.d.ts +6 -0
  44. package/dist/utils/SdCliViteLoggerPlugin.js +24 -0
  45. package/dist/utils/SdCliViteLoggerPlugin.js.map +1 -0
  46. package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +2 -0
  47. package/dist/utils/SdCliViteNodeGlobalPlugin.js +29 -0
  48. package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +1 -0
  49. package/dist/utils/SdCliViteReactSwcPlugin.d.ts +2 -0
  50. package/dist/utils/SdCliViteReactSwcPlugin.js +141 -0
  51. package/dist/utils/SdCliViteReactSwcPlugin.js.map +1 -0
  52. package/dist/utils/SdCliViteWatchWithResolutionsPlugin.d.ts +2 -0
  53. package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js +26 -0
  54. package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js.map +1 -0
  55. package/dist/utils/getElectronReactExternals.d.ts +1 -0
  56. package/dist/utils/getElectronReactExternals.js +17 -0
  57. package/dist/utils/getElectronReactExternals.js.map +1 -0
  58. package/dist/utils/sdCliTsDefineTransformer.d.ts +4 -0
  59. package/dist/utils/sdCliTsDefineTransformer.js +26 -0
  60. package/dist/utils/sdCliTsDefineTransformer.js.map +1 -0
  61. package/package.json +25 -10
  62. package/src/SdLinter.ts +2 -2
  63. package/src/SdTsIncrementalBuilder.ts +116 -94
  64. package/src/build-cluster.ts +173 -111
  65. package/src/builders/SdCliClientBuilder.ts +226 -204
  66. package/src/builders/SdCliServerBuilder.ts +311 -240
  67. package/src/builders/SdCliTsLibBuilder.ts +160 -89
  68. package/src/commons.ts +66 -34
  69. package/src/entry/SdCliElectron.ts +55 -0
  70. package/src/entry/SdCliLocalUpdate.ts +104 -101
  71. package/src/entry/SdCliProject.ts +452 -401
  72. package/src/index.ts +1 -0
  73. package/src/sd-cli.ts +185 -141
  74. package/src/utils/SdCliBuildResultUtil.ts +1 -2
  75. package/src/utils/SdCliViteElectronMainPlugin.ts +86 -0
  76. package/src/utils/SdCliViteExternalPlugin.ts +112 -0
  77. package/src/utils/SdCliViteLoggerPlugin.ts +29 -0
  78. package/src/utils/SdCliViteNodeGlobalPlugin.ts +31 -0
  79. package/src/utils/SdCliViteReactSwcPlugin.ts +154 -0
  80. package/src/utils/SdCliViteWatchWithResolutionsPlugin.ts +29 -0
  81. package/src/utils/getElectronReactExternals.ts +19 -0
  82. package/src/utils/sdCliTsDefineTransformer.ts +31 -0
  83. package/.eslintrc.cjs +0 -18
  84. package/dist/utils/SdCliConfigUtil.d.ts +0 -7
  85. package/dist/utils/SdCliConfigUtil.js +0 -69
  86. package/dist/utils/SdCliConfigUtil.js.map +0 -1
  87. package/src/utils/SdCliConfigUtil.ts +0 -94
@@ -1,122 +1,125 @@
1
+ import {FsUtil, Logger, PathUtil, SdFsWatcher} from "@simplysm/sd-core-node";
1
2
  import path from "path";
2
- import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
3
- import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
3
+ import {pathToFileURL} from "url";
4
+ import {ISdCliConfig} from "../commons";
4
5
 
5
6
  export class SdCliLocalUpdate {
6
- public static async runAsync(opt: { rootPath: string; confFileRelPath: string; }): Promise<void> {
7
- const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "runAsync"]);
8
-
9
- logger.debug("프로젝트 설정 가져오기...");
10
- const conf = await SdCliConfigUtil.loadConfigAsync(path.resolve(opt.rootPath, opt.confFileRelPath), false);
11
- if (!conf.localUpdates) return;
12
-
13
- logger.debug("로컬 업데이트 구성...");
14
- const updatePathInfos = await this._getUpdatePathInfosAsync(opt.rootPath, conf.localUpdates);
15
- logger.debug("로컬 업데이트 구성 완료", updatePathInfos);
16
-
17
- logger.log("로컬 라이브러리 업데이트 시작...");
18
- for (const updatePathInfo of updatePathInfos) {
19
- if (!FsUtil.exists(updatePathInfo.source)) {
20
- logger.warn(`소스경로를 찾을 없어 무시됩니다(${updatePathInfo.source})`);
21
- return;
22
- }
23
-
24
- // 소스경로에서 대상경로로 파일 복사
25
- await FsUtil.copyAsync(updatePathInfo.source, updatePathInfo.target, (src) => {
26
- return !src.includes("node_modules") && !src.endsWith("package.json");
27
- });
7
+ public static async runAsync(opt: {
8
+ confFileRelPath: string;
9
+ optNames: string[];
10
+ }): Promise<void> {
11
+ const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "runAsync"]);
12
+
13
+ logger.debug("프로젝트 설정 가져오기...");
14
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
15
+ if (!projConf.localUpdates) return;
16
+
17
+ logger.debug("로컬 업데이트 구성...");
18
+ const updatePathInfos = await this._getUpdatePathInfosAsync(projConf.localUpdates);
19
+
20
+ logger.log("로컬 라이브러리 업데이트...");
21
+ for (const updatePathInfo of updatePathInfos) {
22
+ if (!FsUtil.exists(updatePathInfo.source)) {
23
+ logger.warn(`소스경로를 찾을 수 없어 무시됩니다(${updatePathInfo.source})`);
24
+ return;
25
+ }
26
+
27
+ // 소스경로에서 대상경로로 파일 복사
28
+ await FsUtil.copyAsync(updatePathInfo.source, updatePathInfo.target, (src) => {
29
+ return !src.includes("node_modules") && !src.endsWith("package.json");
30
+ });
31
+ }
32
+ logger.info("로컬 라이브러리 업데이트 완료");
28
33
  }
29
- logger.info("로컬 라이브러리 업데이트 완료");
30
- }
31
34
 
32
- public static async watchAsync(opt: { rootPath: string; confFileRelPath: string; }): Promise<void> {
33
- const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "watchAsync"]);
35
+ public static async watchAsync(opt: {
36
+ confFileRelPath: string;
37
+ optNames: string[];
38
+ }): Promise<void> {
39
+ const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "watchAsync"]);
34
40
 
35
- logger.debug("프로젝트 설정 가져오기...");
36
- const conf = await SdCliConfigUtil.loadConfigAsync(path.resolve(opt.rootPath, opt.confFileRelPath), false);
37
- if (!conf.localUpdates) return;
41
+ logger.debug("프로젝트 설정 가져오기...");
42
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
43
+ if (!projConf.localUpdates) return;
38
44
 
39
- logger.debug("로컬 업데이트 구성...");
40
- const updatePathInfos = await this._getUpdatePathInfosAsync(opt.rootPath, conf.localUpdates);
41
- logger.debug("로컬 업데이트 구성 완료", updatePathInfos);
45
+ logger.debug("로컬 업데이트 구성...");
46
+ const updatePathInfos = await this._getUpdatePathInfosAsync(projConf.localUpdates);
42
47
 
43
- const watchPaths = (await updatePathInfos.mapManyAsync(async (item) => await this._getWatchPathsAsync(item.source))).distinct();
48
+ const watchPaths = (await updatePathInfos.mapManyAsync(async (item) => await this._getWatchPathsAsync(item.source))).distinct();
44
49
 
45
- const watcher = SdFsWatcher.watch(watchPaths);
46
- watcher.onChange({ delay: 1000 }, async (changedInfos) => {
47
- const changeFilePaths = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
48
- if (changeFilePaths.length === 0) return;
50
+ const watcher = SdFsWatcher.watch(watchPaths);
51
+ watcher.onChange({delay: 1000}, async (changedInfos) => {
52
+ const changeFilePaths = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
53
+ if (changeFilePaths.length === 0) return;
49
54
 
50
- logger.log("로컬 라이브러리 변경감지...");
51
- for (const changedFilePath of changeFilePaths) {
52
- if (!FsUtil.exists(changedFilePath)) continue;
55
+ logger.log("로컬 라이브러리 변경감지...");
56
+ for (const changedFilePath of changeFilePaths) {
57
+ if (!FsUtil.exists(changedFilePath)) continue;
53
58
 
54
- for (const updatePathInfo of updatePathInfos) {
55
- if (!PathUtil.isChildPath(changedFilePath, updatePathInfo.source)) continue;
59
+ for (const updatePathInfo of updatePathInfos) {
60
+ if (!PathUtil.isChildPath(changedFilePath, updatePathInfo.source)) continue;
56
61
 
57
- const sourceRelPath = path.relative(updatePathInfo.source, changedFilePath);
58
- if (sourceRelPath.includes("node_modules")) continue;
59
- if (sourceRelPath.includes("package.json")) continue;
62
+ const sourceRelPath = path.relative(updatePathInfo.source, changedFilePath);
60
63
 
61
- const targetFilePath = path.resolve(updatePathInfo.target, sourceRelPath);
64
+ const targetFilePath = path.resolve(updatePathInfo.target, sourceRelPath);
62
65
 
63
- logger.debug(`변경파일감지(복사): ${changedFilePath} => ${targetFilePath}`);
64
- await FsUtil.copyAsync(changedFilePath, targetFilePath);
66
+ logger.debug(`변경파일감지(복사): ${changedFilePath} => ${targetFilePath}`);
67
+ await FsUtil.copyAsync(changedFilePath, targetFilePath);
68
+ }
69
+ }
70
+
71
+ const watchWatchPaths = (await updatePathInfos.mapManyAsync(async (item) => await this._getWatchPathsAsync(item.source))).distinct();
72
+ watcher.add(watchWatchPaths);
73
+
74
+ logger.info("로컬 라이브러리 복사 완료");
75
+ });
76
+ }
77
+
78
+ private static async _getUpdatePathInfosAsync(record: Record<string, string>): Promise<IUpdatePathInfo[]> {
79
+ const result: IUpdatePathInfo[] = [];
80
+ for (const pkgGlobPath of Object.keys(record)) {
81
+ // "node_modules'에서 로컬업데이트 설정에 맞는 패키지를 "glob"하여 대상 패키지경로 목록 가져오기
82
+ const targetPaths = [
83
+ ...await FsUtil.globAsync(path.resolve(process.cwd(), "node_modules", pkgGlobPath)),
84
+ ...await FsUtil.globAsync(path.resolve(process.cwd(), "packages", "*", "node_modules", pkgGlobPath))
85
+ ];
86
+
87
+ result.push(
88
+ ...targetPaths
89
+ .map((targetPath) => {
90
+ // 대상의 명칭 추출
91
+ const regexpText = pkgGlobPath.replace(/[\\/.*]/g, (item) => (
92
+ item === "/" ? "[\\\\\\/]"
93
+ : item === "." ? "\\."
94
+ : item === "*" ? "(.*)"
95
+ : item
96
+ ));
97
+ const targetNameMatch = new RegExp(regexpText).exec(targetPath);
98
+ if (!targetNameMatch || typeof targetNameMatch[1] === "undefined") return undefined;
99
+ const targetName = targetNameMatch[1];
100
+
101
+ // 가져올 소스 경로 추출
102
+ const sourcePath = path.resolve(record[pkgGlobPath].replace(/\*/g, targetName));
103
+ return {source: sourcePath, target: targetPath};
104
+ })
105
+ .filterExists()
106
+ );
65
107
  }
66
- }
67
-
68
- const watchWatchPaths = (await updatePathInfos.mapManyAsync(async (item) => await this._getWatchPathsAsync(item.source))).distinct();
69
- watcher.add(watchWatchPaths);
70
-
71
- logger.info("로컬 라이브러리 복사 완료");
72
- });
73
- }
74
-
75
- private static async _getWatchPathsAsync(sourcePath: string): Promise<string[]> {
76
- return await FsUtil.globAsync(path.resolve(sourcePath, "**"), {
77
- ignore: [
78
- "**/node_modules/**",
79
- "**/package.json"
80
- ]
81
- });
82
- }
83
-
84
- private static async _getUpdatePathInfosAsync(rootPath: string, record: Record<string, string>): Promise<IUpdatePathInfo[]> {
85
- const result: IUpdatePathInfo[] = [];
86
- for (const pkgGlobPath of Object.keys(record)) {
87
- // "node_modules'에서 로컬업데이트 설정에 맞는 패키지를 "glob"하여 대상 패키지경로 목록 가져오기
88
- const targetPaths = [
89
- ...await FsUtil.globAsync(path.resolve(rootPath, "node_modules", pkgGlobPath)),
90
- ...await FsUtil.globAsync(path.resolve(rootPath, "**", "node_modules", pkgGlobPath))
91
- ];
92
-
93
- result.push(
94
- ...targetPaths
95
- .map((targetPath) => {
96
- // 대상의 명칭 추출
97
- const regexpText = pkgGlobPath.replace(/[\\/.*]/g, (item) => (
98
- item === "/" ? "[\\\\\\/]"
99
- : item === "." ? "\\."
100
- : item === "*" ? "(.*)"
101
- : item
102
- ));
103
- const targetNameMatch = new RegExp(regexpText).exec(targetPath);
104
- if (!targetNameMatch || typeof targetNameMatch[1] === "undefined") return undefined;
105
- const targetName = targetNameMatch[1];
106
-
107
- // 가져올 소스 경로 추출
108
- const sourcePath = path.resolve(record[pkgGlobPath].replace(/\*/g, targetName));
109
- return { source: sourcePath, target: targetPath };
110
- })
111
- .filterExists()
112
- );
108
+
109
+ return result;
113
110
  }
114
111
 
115
- return result;
116
- }
112
+ private static async _getWatchPathsAsync(sourcePath: string): Promise<string[]> {
113
+ return await FsUtil.globAsync(path.resolve(sourcePath, "**"), {
114
+ ignore: [
115
+ "**/node_modules/**",
116
+ "**/package.json"
117
+ ]
118
+ });
119
+ }
117
120
  }
118
121
 
119
122
  interface IUpdatePathInfo {
120
- source: string;
121
- target: string;
123
+ source: string;
124
+ target: string;
122
125
  }