@simplysm/sd-cli 12.5.23 → 12.5.24
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.
- package/dist/entry/SdCliElectron.js +2 -2
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.js +5 -7
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.js +4 -4
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/SdMultiBuildRunner.d.ts +3 -10
- package/dist/pkg-builders/SdMultiBuildRunner.js +132 -116
- package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -1
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +6 -5
- package/dist/pkg-builders/client/SdClientBuildRunner.js +16 -8
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -1
- package/dist/pkg-builders/client/SdNgBundler.js +1 -0
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -1
- package/dist/pkg-builders/client/createSdNgPlugin.js +3 -3
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +6 -1
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +25 -26
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +2 -3
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +7 -11
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -1
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +5 -1
- package/dist/pkg-builders/server/SdServerBuildRunner.js +32 -29
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -1
- package/dist/pkg-builders/server/createSdServerPlugin.js +3 -3
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -1
- package/dist/ts-builder/SdTsCompiler.js +172 -160
- package/dist/ts-builder/SdTsCompiler.js.map +1 -1
- package/dist/types/build-runner.type.d.ts +7 -0
- package/dist/types/build-runner.type.js +2 -0
- package/dist/types/build-runner.type.js.map +1 -0
- package/dist/types/workers.type.d.ts +14 -0
- package/dist/workers/build-runner-worker.js +45 -0
- package/dist/workers/build-runner-worker.js.map +1 -0
- package/package.json +5 -5
- package/src/entry/SdCliElectron.ts +2 -2
- package/src/entry/SdCliLocalUpdate.ts +7 -7
- package/src/entry/SdCliProject.ts +4 -4
- package/src/index.ts +1 -1
- package/src/pkg-builders/SdMultiBuildRunner.ts +122 -120
- package/src/pkg-builders/client/SdClientBuildRunner.ts +26 -22
- package/src/pkg-builders/client/SdNgBundler.ts +1 -0
- package/src/pkg-builders/client/createSdNgPlugin.ts +3 -3
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +39 -26
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +12 -13
- package/src/pkg-builders/server/SdServerBuildRunner.ts +44 -29
- package/src/pkg-builders/server/createSdServerPlugin.ts +3 -3
- package/src/ts-builder/SdTsCompiler.ts +220 -216
- package/src/types/build-runner.type.ts +8 -0
- package/src/types/workers.type.ts +13 -0
- package/src/workers/build-runner-worker.ts +52 -0
- package/tsconfig.json +1 -1
- package/dist/ts-builder/SdTsCompileWorker.d.ts +0 -9
- package/dist/ts-builder/SdTsCompileWorker.js +0 -16
- package/dist/ts-builder/SdTsCompileWorker.js.map +0 -1
- package/dist/workers/compile-worker.js +0 -27
- package/dist/workers/compile-worker.js.map +0 -1
- package/src/ts-builder/SdTsCompileWorker.ts +0 -21
- package/src/workers/compile-worker.ts +0 -31
- /package/dist/workers/{compile-worker.d.ts → build-runner-worker.d.ts} +0 -0
|
@@ -135,7 +135,7 @@ export class SdCliElectron {
|
|
|
135
135
|
},
|
|
136
136
|
...(pkgConf.builder.electron.installerIcon !== undefined
|
|
137
137
|
? {
|
|
138
|
-
icon: path.resolve(pkgPath,
|
|
138
|
+
icon: path.resolve(pkgPath, pkgConf.builder.electron.installerIcon),
|
|
139
139
|
}
|
|
140
140
|
: {}),
|
|
141
141
|
removePackageScripts: false,
|
|
@@ -209,7 +209,7 @@ export class SdCliElectron {
|
|
|
209
209
|
},
|
|
210
210
|
...(opt.config.installerIcon !== undefined
|
|
211
211
|
? {
|
|
212
|
-
icon: path.resolve(opt.pkgPath,
|
|
212
|
+
icon: path.resolve(opt.pkgPath, opt.config.installerIcon),
|
|
213
213
|
}
|
|
214
214
|
: {}),
|
|
215
215
|
removePackageScripts: false,
|
|
@@ -45,9 +45,9 @@ export class SdCliLocalUpdate {
|
|
|
45
45
|
const updatePathInfos = this.#getUpdatePathInfos(projConf.localUpdates);
|
|
46
46
|
logger.debug("로컬 업데이트 구성");
|
|
47
47
|
|
|
48
|
-
const watchPaths = updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)).distinct();
|
|
48
|
+
// const watchPaths = updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)).distinct();
|
|
49
49
|
|
|
50
|
-
const watcher = SdFsWatcher.watch(
|
|
50
|
+
const watcher = SdFsWatcher.watch(updatePathInfos.map((item) => item.source));
|
|
51
51
|
watcher.onChange({ delay: 500 }, (changedInfos) => {
|
|
52
52
|
const changedFileInfos = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event));
|
|
53
53
|
if (changedFileInfos.length === 0) return;
|
|
@@ -71,9 +71,9 @@ export class SdCliLocalUpdate {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const watchFileSet = new Set(updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)));
|
|
75
|
-
|
|
76
|
-
watcher.replaceWatchPaths(watchFileSet);
|
|
74
|
+
// const watchFileSet = new Set(updatePathInfos.mapMany((item) => this.#getWatchPaths(item.source)));
|
|
75
|
+
//
|
|
76
|
+
// watcher.replaceWatchPaths(watchFileSet);
|
|
77
77
|
|
|
78
78
|
logger.info("로컬 라이브러리 복사 완료");
|
|
79
79
|
});
|
|
@@ -110,9 +110,9 @@ export class SdCliLocalUpdate {
|
|
|
110
110
|
return result;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
static #getWatchPaths(sourcePath: string): string[] {
|
|
113
|
+
/*static #getWatchPaths(sourcePath: string): string[] {
|
|
114
114
|
return FsUtil.glob(path.resolve(sourcePath, "**"));
|
|
115
|
-
}
|
|
115
|
+
}*/
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
interface IUpdatePathInfo {
|
|
@@ -103,10 +103,10 @@ export class SdCliProject {
|
|
|
103
103
|
await this._upgradeVersionAsync(projNpmConf, allPkgPaths);
|
|
104
104
|
|
|
105
105
|
logger.debug("빌드 프로세스 시작...");
|
|
106
|
-
const
|
|
106
|
+
const multiBuildRunner = new SdMultiBuildRunner();
|
|
107
107
|
|
|
108
108
|
const messages = await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
109
|
-
return await
|
|
109
|
+
return await multiBuildRunner.runAsync({
|
|
110
110
|
cmd: "build",
|
|
111
111
|
pkgPath,
|
|
112
112
|
projConf: projConf,
|
|
@@ -165,10 +165,10 @@ export class SdCliProject {
|
|
|
165
165
|
// 빌드
|
|
166
166
|
if (!opt.noBuild) {
|
|
167
167
|
logger.debug("빌드 프로세스 시작...");
|
|
168
|
-
const
|
|
168
|
+
const multiBuildRunner = new SdMultiBuildRunner();
|
|
169
169
|
|
|
170
170
|
const messages = await pkgPaths.parallelAsync(async (pkgPath) => {
|
|
171
|
-
return await
|
|
171
|
+
return await multiBuildRunner.runAsync({
|
|
172
172
|
cmd: "build",
|
|
173
173
|
pkgPath,
|
|
174
174
|
projConf: projConf,
|
package/src/index.ts
CHANGED
|
@@ -16,8 +16,8 @@ export * from "./pkg-builders/server/createSdServerPlugin";
|
|
|
16
16
|
export * from "./pkg-builders/server/SdServerBuildRunner";
|
|
17
17
|
export * from "./pkg-builders/server/SdServerBundler";
|
|
18
18
|
export * from "./ts-builder/SdTsCompiler";
|
|
19
|
-
export * from "./ts-builder/SdTsCompileWorker";
|
|
20
19
|
export * from "./types/build-plugin.type";
|
|
20
|
+
export * from "./types/build-runner.type";
|
|
21
21
|
export * from "./types/build.type";
|
|
22
22
|
export * from "./types/common-configs.type";
|
|
23
23
|
export * from "./types/sd-configs.type";
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { FsUtil, Logger, PathUtil, SdWorker, TNormPath } from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { EventEmitter } from "events";
|
|
4
|
-
import {
|
|
5
|
-
import { SdClientBuildRunner } from "./client/SdClientBuildRunner";
|
|
6
|
-
import { SdTsLibBuildRunner } from "./lib/SdTsLibBuildRunner";
|
|
7
|
-
import { SdJsLibBuildRunner } from "./lib/SdJsLibBuildRunner";
|
|
8
|
-
import { ISdProjectConfig, ISdServerPackageConfig } from "../types/sd-configs.type";
|
|
4
|
+
import { ISdServerPackageConfig } from "../types/sd-configs.type";
|
|
9
5
|
import { ISdBuildMessage, ISdBuildRunnerResult } from "../types/build.type";
|
|
10
|
-
import { TServerWorkerType } from "../types/workers.type";
|
|
6
|
+
import { TSdBuildRunnerWorkerType, TServerWorkerType } from "../types/workers.type";
|
|
11
7
|
import { INpmConfig } from "../types/common-configs.type";
|
|
8
|
+
import { ISdBuildRunnerWorkerRequest } from "../types/build-runner.type";
|
|
12
9
|
|
|
13
10
|
export class SdMultiBuildRunner extends EventEmitter {
|
|
14
11
|
#logger = Logger.get(["simplysm", "sd-cli", "SdMultiBuildRunner"]);
|
|
@@ -43,10 +40,20 @@ export class SdMultiBuildRunner extends EventEmitter {
|
|
|
43
40
|
return this;
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
async runAsync(req:
|
|
47
|
-
async runAsync(req:
|
|
48
|
-
async runAsync(req:
|
|
49
|
-
const
|
|
43
|
+
async runAsync(req: ISdBuildRunnerWorkerRequest & { cmd: "watch" }): Promise<void>;
|
|
44
|
+
async runAsync(req: ISdBuildRunnerWorkerRequest & { cmd: "build" }): Promise<ISdBuildMessage[]>;
|
|
45
|
+
async runAsync(req: ISdBuildRunnerWorkerRequest): Promise<ISdBuildMessage[] | void> {
|
|
46
|
+
const worker = new SdWorker<TSdBuildRunnerWorkerType>(import.meta.resolve("../workers/build-runner-worker"))
|
|
47
|
+
.on("change", () => {
|
|
48
|
+
if (this.#busyCount === 0) {
|
|
49
|
+
this.emit("change");
|
|
50
|
+
}
|
|
51
|
+
this.#busyCount++;
|
|
52
|
+
})
|
|
53
|
+
.on("complete", (result) => this.#onComplete(req, result));
|
|
54
|
+
|
|
55
|
+
return await worker.run("run", [req]);
|
|
56
|
+
/*const pkgConf = req.projConf.packages[path.basename(req.pkgPath)]!;
|
|
50
57
|
|
|
51
58
|
const buildRunnerType =
|
|
52
59
|
pkgConf.type === "server"
|
|
@@ -67,140 +74,133 @@ export class SdMultiBuildRunner extends EventEmitter {
|
|
|
67
74
|
} else {
|
|
68
75
|
await builder.watchAsync();
|
|
69
76
|
return;
|
|
70
|
-
}
|
|
77
|
+
}*/
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.#busyCount++;
|
|
79
|
-
} else {
|
|
80
|
-
this.#resultCache.delete(req.pkgPath);
|
|
81
|
-
for (const affectedFilePath of res.result.affectedFilePathSet) {
|
|
82
|
-
if (PathUtil.isChildPath(affectedFilePath, req.pkgPath)) {
|
|
83
|
-
this.#resultCache.delete(affectedFilePath);
|
|
84
|
-
}
|
|
80
|
+
#onComplete(req: ISdBuildRunnerWorkerRequest, result: ISdBuildRunnerResult) {
|
|
81
|
+
this.#resultCache.delete(req.pkgPath);
|
|
82
|
+
for (const affectedFilePath of result.affectedFilePathSet) {
|
|
83
|
+
if (PathUtil.isChildPath(affectedFilePath, req.pkgPath)) {
|
|
84
|
+
this.#resultCache.delete(affectedFilePath);
|
|
85
85
|
}
|
|
86
|
+
}
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
for (const buildMessage of result.buildMessages) {
|
|
89
|
+
const cacheItem = this.#resultCache.getOrCreate(buildMessage.filePath ?? req.pkgPath, []);
|
|
90
|
+
cacheItem.push(buildMessage);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const pkgConf = req.projConf.packages[path.basename(req.pkgPath)]!;
|
|
91
94
|
|
|
92
|
-
|
|
95
|
+
if (pkgConf.type === "server") {
|
|
96
|
+
const pkgName = path.basename(req.pkgPath);
|
|
97
|
+
const serverInfo = this.#serverInfoMap.getOrCreate(pkgName, {
|
|
98
|
+
hasChanges: true,
|
|
99
|
+
clientChangedFileSet: new Set(),
|
|
100
|
+
clients: {},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const serverPkgConf = req.projConf.packages[pkgName] as ISdServerPackageConfig;
|
|
104
|
+
serverInfo.pkgInfo = {
|
|
105
|
+
path: req.pkgPath,
|
|
106
|
+
conf: serverPkgConf,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
serverInfo.hasChanges = true;
|
|
110
|
+
} else if (pkgConf.type === "client") {
|
|
111
|
+
const pkgName = path.basename(req.pkgPath);
|
|
112
|
+
|
|
113
|
+
if (pkgConf.server !== undefined) {
|
|
114
|
+
const serverInfo = this.#serverInfoMap.getOrCreate(
|
|
115
|
+
typeof pkgConf.server === "string" ? pkgConf.server : pkgConf.server.port.toString(),
|
|
116
|
+
{
|
|
117
|
+
hasChanges: true,
|
|
118
|
+
clientChangedFileSet: new Set(),
|
|
119
|
+
clients: {},
|
|
120
|
+
},
|
|
121
|
+
);
|
|
93
122
|
|
|
94
|
-
|
|
95
|
-
|
|
123
|
+
if (typeof pkgConf.server !== "string") {
|
|
124
|
+
serverInfo.pkgInfo = pkgConf.server;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
serverInfo.clients[pkgName] = {
|
|
128
|
+
path: path.resolve(req.pkgPath, "dist"),
|
|
129
|
+
buildTypes: (pkgConf.builder ? Object.keys(pkgConf.builder) : ["web"]) as any,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
serverInfo.clientChangedFileSet.adds(...result.emitFileSet);
|
|
133
|
+
} else {
|
|
96
134
|
const serverInfo = this.#serverInfoMap.getOrCreate(pkgName, {
|
|
97
135
|
hasChanges: true,
|
|
98
136
|
clientChangedFileSet: new Set(),
|
|
99
137
|
clients: {},
|
|
100
138
|
});
|
|
101
139
|
|
|
102
|
-
|
|
103
|
-
serverInfo.pkgInfo = {
|
|
104
|
-
path: req.pkgPath,
|
|
105
|
-
conf: serverPkgConf,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
serverInfo.hasChanges = true;
|
|
109
|
-
} else if (pkgConf.type === "client") {
|
|
110
|
-
const pkgName = path.basename(req.pkgPath);
|
|
111
|
-
|
|
112
|
-
if (pkgConf.server !== undefined) {
|
|
113
|
-
const serverInfo = this.#serverInfoMap.getOrCreate(
|
|
114
|
-
typeof pkgConf.server === "string" ? pkgConf.server : pkgConf.server.port.toString(),
|
|
115
|
-
{
|
|
116
|
-
hasChanges: true,
|
|
117
|
-
clientChangedFileSet: new Set(),
|
|
118
|
-
clients: {},
|
|
119
|
-
},
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
if (typeof pkgConf.server !== "string") {
|
|
123
|
-
serverInfo.pkgInfo = pkgConf.server;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
serverInfo.clients[pkgName] = {
|
|
127
|
-
path: path.resolve(req.pkgPath, "dist"),
|
|
128
|
-
buildTypes: (pkgConf.builder ? Object.keys(pkgConf.builder) : ["web"]) as any,
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
serverInfo.clientChangedFileSet.adds(...res.result.emitFileSet);
|
|
132
|
-
} else {
|
|
133
|
-
const serverInfo = this.#serverInfoMap.getOrCreate(pkgName, {
|
|
134
|
-
hasChanges: true,
|
|
135
|
-
clientChangedFileSet: new Set(),
|
|
136
|
-
clients: {},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
serverInfo.clientChangedFileSet.adds(...res.result.emitFileSet);
|
|
140
|
-
}
|
|
140
|
+
serverInfo.clientChangedFileSet.adds(...result.emitFileSet);
|
|
141
141
|
}
|
|
142
|
+
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
144
|
+
setTimeout(async () => {
|
|
145
|
+
this.#busyCount--;
|
|
146
|
+
if (this.#busyCount === 0) {
|
|
147
|
+
for (const serverPkgNameOrPort of this.#serverInfoMap.keys()) {
|
|
148
|
+
const serverInfo = this.#serverInfoMap.get(serverPkgNameOrPort)!;
|
|
149
|
+
if (serverInfo.pkgInfo && serverInfo.hasChanges) {
|
|
150
|
+
this.#logger.debug("서버 재시작...");
|
|
151
|
+
try {
|
|
152
|
+
const restartServerResult = await this.#restartServerAsync(serverInfo.pkgInfo, serverInfo.worker);
|
|
153
|
+
serverInfo.worker = restartServerResult.worker;
|
|
154
|
+
serverInfo.port = restartServerResult.port;
|
|
155
|
+
serverInfo.hasChanges = false;
|
|
156
|
+
} catch (err) {
|
|
157
|
+
this.#logger.error(err);
|
|
158
158
|
}
|
|
159
|
+
}
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
161
|
+
if (serverInfo.worker) {
|
|
162
|
+
this.#logger.debug("클라이언트 설정...");
|
|
163
|
+
await serverInfo.worker.run("setPathProxy", [
|
|
164
|
+
{
|
|
165
|
+
...Object.keys(serverInfo.clients).toObject(
|
|
166
|
+
(key) => key,
|
|
167
|
+
(key) => serverInfo.clients[key].path,
|
|
168
|
+
),
|
|
169
|
+
node_modules: path.resolve(process.cwd(), "node_modules"),
|
|
170
|
+
},
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
if (serverInfo.clientChangedFileSet.size > 0) {
|
|
174
|
+
this.#logger.debug("클라이언트 새로고침...");
|
|
175
|
+
await serverInfo.worker.run("broadcastReload", [serverInfo.clientChangedFileSet]);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
+
}
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
180
|
+
const clientPaths: string[] = [];
|
|
181
|
+
for (const serverInfo of this.#serverInfoMap.values()) {
|
|
182
|
+
if (Object.keys(serverInfo.clients).length > 0) {
|
|
183
|
+
for (const clientPkgName of Object.keys(serverInfo.clients)) {
|
|
184
|
+
for (const buildType of serverInfo.clients[clientPkgName].buildTypes) {
|
|
185
|
+
if (buildType === "web") {
|
|
186
|
+
clientPaths.push(`http://localhost:${serverInfo.port}/${clientPkgName}/`);
|
|
187
|
+
} else {
|
|
188
|
+
clientPaths.push(`http://localhost:${serverInfo.port}/${clientPkgName}/${buildType}/`);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
} else {
|
|
192
|
-
clientPaths.push(`http://localhost:${serverInfo.port}/`);
|
|
193
191
|
}
|
|
192
|
+
} else {
|
|
193
|
+
clientPaths.push(`http://localhost:${serverInfo.port}/`);
|
|
194
194
|
}
|
|
195
|
-
if (clientPaths.length > 0) {
|
|
196
|
-
this.#logger.info("클라이언트 개발 서버 접속 주소\n" + clientPaths.join("\n"));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const messages = Array.from(this.#resultCache.values()).mapMany();
|
|
200
|
-
this.emit("complete", messages);
|
|
201
195
|
}
|
|
202
|
-
|
|
203
|
-
|
|
196
|
+
if (clientPaths.length > 0) {
|
|
197
|
+
this.#logger.info("클라이언트 개발 서버 접속 주소\n" + clientPaths.join("\n"));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const messages = Array.from(this.#resultCache.values()).mapMany();
|
|
201
|
+
this.emit("complete", messages);
|
|
202
|
+
}
|
|
203
|
+
}, 300);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
async #restartServerAsync(
|
|
@@ -234,6 +234,7 @@ export class SdMultiBuildRunner extends EventEmitter {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
/*
|
|
237
238
|
interface IRequest {
|
|
238
239
|
cmd: "watch" | "build";
|
|
239
240
|
pkgPath: TNormPath;
|
|
@@ -248,3 +249,4 @@ type TResponse =
|
|
|
248
249
|
type: "complete";
|
|
249
250
|
result: ISdBuildRunnerResult;
|
|
250
251
|
};
|
|
252
|
+
*/
|
|
@@ -10,19 +10,27 @@ import { INpmConfig } from "../../types/common-configs.type";
|
|
|
10
10
|
import { ISdBuildMessage, ISdBuildRunnerResult } from "../../types/build.type";
|
|
11
11
|
|
|
12
12
|
export class SdClientBuildRunner extends EventEmitter {
|
|
13
|
-
private
|
|
14
|
-
private
|
|
15
|
-
private
|
|
13
|
+
private _logger = Logger.get(["simplysm", "sd-cli", "SdClientBuildRunner"]);
|
|
14
|
+
private _pkgConf: ISdClientPackageConfig;
|
|
15
|
+
private _npmConf: INpmConfig;
|
|
16
16
|
private _ngBundlers?: SdNgBundler[];
|
|
17
17
|
private _cordova?: SdCliCordova;
|
|
18
|
+
private _watchScopePathSet: Set<TNormPath>;
|
|
18
19
|
|
|
19
20
|
public constructor(
|
|
20
|
-
private
|
|
21
|
-
private
|
|
21
|
+
private _projConf: ISdProjectConfig,
|
|
22
|
+
private _pkgPath: TNormPath,
|
|
22
23
|
) {
|
|
23
24
|
super();
|
|
24
25
|
this._pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdClientPackageConfig;
|
|
25
26
|
this._npmConf = FsUtil.readJson(path.resolve(_pkgPath, "package.json")) as INpmConfig;
|
|
27
|
+
|
|
28
|
+
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
29
|
+
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
30
|
+
);
|
|
31
|
+
this._watchScopePathSet = new Set(
|
|
32
|
+
[path.resolve(this._pkgPath, "../"), ...localUpdatePaths].map((item) => PathUtil.norm(item)),
|
|
33
|
+
);
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
public override on(event: "change", listener: () => void): this;
|
|
@@ -77,11 +85,15 @@ export class SdClientBuildRunner extends EventEmitter {
|
|
|
77
85
|
this.emit("complete", res);
|
|
78
86
|
|
|
79
87
|
this._debug("WATCH...");
|
|
80
|
-
|
|
88
|
+
let lastWatchFileSet = result.watchFileSet;
|
|
89
|
+
SdFsWatcher.watch(Array.from(this._watchScopePathSet)).onChange({ delay: 100 }, async (changeInfos) => {
|
|
90
|
+
const currentChangeInfos = changeInfos.filter((item) => lastWatchFileSet.has(item.path));
|
|
91
|
+
if (currentChangeInfos.length < 1) return;
|
|
92
|
+
|
|
81
93
|
this.emit("change");
|
|
82
94
|
|
|
83
95
|
for (const ngBundler of this._ngBundlers!) {
|
|
84
|
-
ngBundler.markForChanges(
|
|
96
|
+
ngBundler.markForChanges(currentChangeInfos.map((item) => item.path));
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
const watchResult = await this._runAsync({ dev: !this._pkgConf.forceProductionMode });
|
|
@@ -92,7 +104,7 @@ export class SdClientBuildRunner extends EventEmitter {
|
|
|
92
104
|
};
|
|
93
105
|
this.emit("complete", watchRes);
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
lastWatchFileSet = watchResult.watchFileSet;
|
|
96
108
|
});
|
|
97
109
|
}
|
|
98
110
|
|
|
@@ -102,10 +114,6 @@ export class SdClientBuildRunner extends EventEmitter {
|
|
|
102
114
|
buildMessages: ISdBuildMessage[];
|
|
103
115
|
emitFileSet: Set<TNormPath>;
|
|
104
116
|
}> {
|
|
105
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
106
|
-
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
117
|
const ngBundlerBuilderTypes = Object.keys(this._pkgConf.builder ?? { web: {} }) as (
|
|
110
118
|
| "web"
|
|
111
119
|
| "electron"
|
|
@@ -142,9 +150,7 @@ export class SdClientBuildRunner extends EventEmitter {
|
|
|
142
150
|
...this._pkgConf.builder?.[ngBundlerBuilderType]?.env,
|
|
143
151
|
},
|
|
144
152
|
cordovaConfig: ngBundlerBuilderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
|
|
145
|
-
watchScopePaths:
|
|
146
|
-
PathUtil.norm(item),
|
|
147
|
-
),
|
|
153
|
+
watchScopePaths: Array.from(this._watchScopePathSet),
|
|
148
154
|
}),
|
|
149
155
|
);
|
|
150
156
|
}
|
|
@@ -170,15 +176,13 @@ export class SdClientBuildRunner extends EventEmitter {
|
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
this._debug(`빌드 완료`);
|
|
173
|
-
const currWatchFileSet = new Set(
|
|
174
|
-
Array.from(watchFileSet).filter(
|
|
175
|
-
(
|
|
176
|
-
PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
177
|
-
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)),
|
|
179
|
+
/*const currWatchFileSet = new Set(
|
|
180
|
+
Array.from(watchFileSet).filter((item) =>
|
|
181
|
+
Array.from(this._watchScopePathSet).some((scope) => PathUtil.isChildPath(item, scope)),
|
|
178
182
|
),
|
|
179
|
-
)
|
|
183
|
+
);*/
|
|
180
184
|
return {
|
|
181
|
-
watchFileSet
|
|
185
|
+
watchFileSet,
|
|
182
186
|
affectedFileSet,
|
|
183
187
|
buildMessages: results, //.filter((item) => item.filePath !== path.resolve(this._pkgPath, "src/routes.ts")),
|
|
184
188
|
emitFileSet,
|
|
@@ -242,6 +242,7 @@ export class SdNgBundler {
|
|
|
242
242
|
watchFileSet: new Set([
|
|
243
243
|
...this.#ngResultCache.watchFileSet!,
|
|
244
244
|
...this.#styleLoadResultCache.watchFiles.map((item) => PathUtil.norm(item)),
|
|
245
|
+
...assetFiles.map((item) => PathUtil.norm(item.source)),
|
|
245
246
|
PathUtil.norm(this.#indexHtmlFilePath),
|
|
246
247
|
]),
|
|
247
248
|
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
@@ -7,7 +7,7 @@ import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTime";
|
|
|
7
7
|
import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
|
|
8
8
|
import { ISdCliNgPluginResultCache } from "../../types/build-plugin.type";
|
|
9
9
|
import { ISdTsCompilerResult } from "../../types/ts-compiler.type";
|
|
10
|
-
import {
|
|
10
|
+
import { SdTsCompiler } from "../../ts-builder/SdTsCompiler";
|
|
11
11
|
|
|
12
12
|
export function createSdNgPlugin(conf: {
|
|
13
13
|
pkgPath: TNormPath;
|
|
@@ -25,8 +25,8 @@ export function createSdNgPlugin(conf: {
|
|
|
25
25
|
|
|
26
26
|
return {
|
|
27
27
|
name: "sd-ng-compile",
|
|
28
|
-
setup:
|
|
29
|
-
const tsCompiler =
|
|
28
|
+
setup: (build: esbuild.PluginBuild) => {
|
|
29
|
+
const tsCompiler = new SdTsCompiler({
|
|
30
30
|
pkgPath: conf.pkgPath,
|
|
31
31
|
additionalOptions: { declaration: false },
|
|
32
32
|
isDevMode: conf.dev,
|
|
@@ -7,20 +7,28 @@ import { ISdLibPackageConfig, ISdProjectConfig } from "../../types/sd-configs.ty
|
|
|
7
7
|
import { ISdBuildMessage, ISdBuildRunnerResult } from "../../types/build.type";
|
|
8
8
|
|
|
9
9
|
export class SdTsLibBuildRunner extends EventEmitter {
|
|
10
|
-
|
|
10
|
+
private _logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
private _projConf: ISdProjectConfig;
|
|
13
|
+
private _pkgPath: string;
|
|
14
|
+
private _pkgConf: ISdLibPackageConfig;
|
|
15
|
+
private _watchScopePathSet: Set<TNormPath>;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
private _builder?: SdTsLibBuilder;
|
|
17
18
|
|
|
18
19
|
public constructor(projConf: ISdProjectConfig, pkgPath: string) {
|
|
19
20
|
super();
|
|
20
|
-
this
|
|
21
|
-
this
|
|
21
|
+
this._projConf = projConf;
|
|
22
|
+
this._pkgPath = pkgPath;
|
|
22
23
|
|
|
23
|
-
this
|
|
24
|
+
this._pkgConf = projConf.packages[path.basename(pkgPath)] as ISdLibPackageConfig;
|
|
25
|
+
|
|
26
|
+
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
27
|
+
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
28
|
+
);
|
|
29
|
+
this._watchScopePathSet = new Set(
|
|
30
|
+
[path.resolve(this._pkgPath, "../"), ...localUpdatePaths].map((item) => PathUtil.norm(item)),
|
|
31
|
+
);
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
public override on(event: "change", listener: () => void): this;
|
|
@@ -32,11 +40,11 @@ export class SdTsLibBuildRunner extends EventEmitter {
|
|
|
32
40
|
|
|
33
41
|
public async buildAsync(): Promise<ISdBuildRunnerResult> {
|
|
34
42
|
this._debug("dist 초기화...");
|
|
35
|
-
FsUtil.remove(path.resolve(this
|
|
43
|
+
FsUtil.remove(path.resolve(this._pkgPath, "dist"));
|
|
36
44
|
|
|
37
|
-
if (!this
|
|
45
|
+
if (!this._pkgConf.noGenIndex) {
|
|
38
46
|
this._debug("GEN index.ts...");
|
|
39
|
-
SdCliIndexFileGenerator.run(this
|
|
47
|
+
SdCliIndexFileGenerator.run(this._pkgPath, this._pkgConf.polyfills);
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
const result = await this._runAsync(false, new Set<TNormPath>());
|
|
@@ -51,11 +59,11 @@ export class SdTsLibBuildRunner extends EventEmitter {
|
|
|
51
59
|
this.emit("change");
|
|
52
60
|
|
|
53
61
|
this._debug("dist 초기화...");
|
|
54
|
-
FsUtil.remove(path.resolve(this
|
|
62
|
+
FsUtil.remove(path.resolve(this._pkgPath, "dist"));
|
|
55
63
|
|
|
56
|
-
if (!this
|
|
64
|
+
if (!this._pkgConf.noGenIndex) {
|
|
57
65
|
this._debug("WATCH GEN index.ts...");
|
|
58
|
-
SdCliIndexFileGenerator.watch(this
|
|
66
|
+
SdCliIndexFileGenerator.watch(this._pkgPath, this._pkgConf.polyfills);
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
const result = await this._runAsync(true, new Set<TNormPath>());
|
|
@@ -67,10 +75,14 @@ export class SdTsLibBuildRunner extends EventEmitter {
|
|
|
67
75
|
this.emit("complete", res);
|
|
68
76
|
|
|
69
77
|
this._debug("WATCH...");
|
|
70
|
-
|
|
78
|
+
let lastWatchFileSet = result.watchFileSet;
|
|
79
|
+
SdFsWatcher.watch(Array.from(this._watchScopePathSet)).onChange({ delay: 100 }, async (changeInfos) => {
|
|
80
|
+
const currentChangeInfos = changeInfos.filter((item) => lastWatchFileSet.has(item.path));
|
|
81
|
+
if (currentChangeInfos.length < 1) return;
|
|
82
|
+
|
|
71
83
|
this.emit("change");
|
|
72
84
|
|
|
73
|
-
const changeFileSet = new Set(
|
|
85
|
+
const changeFileSet = new Set(currentChangeInfos.map((item) => PathUtil.norm(item.path)));
|
|
74
86
|
|
|
75
87
|
const watchResult = await this._runAsync(true, changeFileSet);
|
|
76
88
|
const watchRes: ISdBuildRunnerResult = {
|
|
@@ -81,7 +93,7 @@ export class SdTsLibBuildRunner extends EventEmitter {
|
|
|
81
93
|
|
|
82
94
|
this.emit("complete", watchRes);
|
|
83
95
|
|
|
84
|
-
|
|
96
|
+
lastWatchFileSet = watchResult.watchFileSet;
|
|
85
97
|
});
|
|
86
98
|
}
|
|
87
99
|
|
|
@@ -94,22 +106,23 @@ export class SdTsLibBuildRunner extends EventEmitter {
|
|
|
94
106
|
buildMessages: ISdBuildMessage[];
|
|
95
107
|
emitFileSet: Set<TNormPath>;
|
|
96
108
|
}> {
|
|
97
|
-
const localUpdatePaths = Object.keys(this
|
|
98
|
-
.mapMany((key) => FsUtil.glob(path.resolve(this
|
|
109
|
+
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
|
|
110
|
+
.mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)))
|
|
99
111
|
.map((item) => PathUtil.norm(item));
|
|
100
112
|
|
|
101
113
|
this._debug(`BUILD...`);
|
|
102
|
-
this
|
|
103
|
-
PathUtil.norm(this
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
this._builder ??= new SdTsLibBuilder(
|
|
115
|
+
PathUtil.norm(this._pkgPath),
|
|
116
|
+
dev,
|
|
117
|
+
[PathUtil.norm(this._pkgPath, "../"), ...localUpdatePaths].map((item) => PathUtil.norm(item)),
|
|
118
|
+
);
|
|
119
|
+
const buildResult = await this._builder.buildAsync(modifiedFileSet);
|
|
107
120
|
|
|
108
121
|
this._debug(`빌드 완료`);
|
|
109
122
|
const watchFileSet = new Set(
|
|
110
123
|
Array.from(buildResult.watchFileSet).filter(
|
|
111
124
|
(item) =>
|
|
112
|
-
PathUtil.isChildPath(item, path.resolve(this
|
|
125
|
+
PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
113
126
|
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)),
|
|
114
127
|
),
|
|
115
128
|
);
|
|
@@ -123,6 +136,6 @@ export class SdTsLibBuildRunner extends EventEmitter {
|
|
|
123
136
|
}
|
|
124
137
|
|
|
125
138
|
private _debug(msg: string): void {
|
|
126
|
-
this
|
|
139
|
+
this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
|
|
127
140
|
}
|
|
128
141
|
}
|