@simplysm/sd-cli 12.9.16 → 12.9.18
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/sd-cli-cordova.d.ts +1 -1
- package/dist/entry/sd-cli-cordova.js +3 -3
- package/dist/entry/sd-cli-cordova.js.map +1 -1
- package/dist/entry/sd-cli-electron.d.ts +2 -2
- package/dist/entry/sd-cli-local-update.d.ts +2 -2
- package/dist/entry/sd-cli-local-update.js.map +1 -1
- package/dist/entry/sd-cli-project.d.ts +3 -3
- package/dist/entry/sd-cli-project.js +4 -4
- package/dist/entry/sd-cli-project.js.map +1 -1
- package/dist/entry/utils/loadProjConfAsync.d.ts +1 -1
- package/dist/entry/utils/loadProjConfAsync.js +1 -1
- package/dist/entry/utils/loadProjConfAsync.js.map +1 -1
- package/dist/fix/convert-private-underscore.d.ts +1 -0
- package/dist/fix/convert-private-underscore.js +49 -0
- package/dist/fix/convert-private-underscore.js.map +1 -0
- package/dist/fix/convert-private.d.ts +1 -0
- package/dist/fix/convert-private.js +60 -0
- package/dist/fix/convert-private.js.map +1 -0
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.d.ts +1 -1
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js +3 -3
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js.map +1 -1
- package/dist/pkg-builders/client/sd-client.build-runner.d.ts +5 -18
- package/dist/pkg-builders/client/sd-client.build-runner.js +32 -90
- package/dist/pkg-builders/client/sd-client.build-runner.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.bundler.d.ts +2 -1
- package/dist/pkg-builders/client/sd-ng.bundler.js +2 -2
- package/dist/pkg-builders/client/sd-ng.bundler.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.plugin-creator.d.ts +2 -1
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js +1 -1
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js.map +1 -1
- package/dist/pkg-builders/commons/build-runner.base.d.ts +27 -0
- package/dist/pkg-builders/commons/build-runner.base.js +93 -0
- package/dist/pkg-builders/commons/build-runner.base.js.map +1 -0
- package/dist/pkg-builders/commons/scope-path.d.ts +7 -0
- package/dist/pkg-builders/commons/scope-path.js +13 -0
- package/dist/pkg-builders/commons/scope-path.js.map +1 -0
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.d.ts +1 -1
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js +2 -2
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +1 -1
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.d.ts +7 -15
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js +15 -54
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.d.ts +5 -16
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +31 -85
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.builder.d.ts +2 -1
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js +2 -2
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +1 -1
- package/dist/pkg-builders/sd-multi.build-runner.d.ts +2 -1
- package/dist/pkg-builders/sd-multi.build-runner.js +4 -4
- package/dist/pkg-builders/sd-multi.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.build-runner.d.ts +6 -17
- package/dist/pkg-builders/server/sd-server.build-runner.js +87 -137
- package/dist/pkg-builders/server/sd-server.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.bundler.d.ts +2 -1
- package/dist/pkg-builders/server/sd-server.bundler.js +2 -2
- package/dist/pkg-builders/server/sd-server.bundler.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.plugin-creator.d.ts +2 -1
- package/dist/pkg-builders/server/sd-server.plugin-creator.js +3 -2
- package/dist/pkg-builders/server/sd-server.plugin-creator.js.map +1 -1
- package/dist/sd-cli-entry.js +69 -61
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +33 -28
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-compiler/sd-dependency-analyzer.d.ts +3 -3
- package/dist/ts-compiler/sd-dependency-analyzer.js +9 -16
- package/dist/ts-compiler/sd-dependency-analyzer.js.map +1 -1
- package/dist/ts-compiler/sd-ts-compiler.d.ts +1 -2
- package/dist/ts-compiler/sd-ts-compiler.js +70 -19
- package/dist/ts-compiler/sd-ts-compiler.js.map +1 -1
- package/dist/types/config.types.d.ts +3 -2
- package/dist/types/ts-compiler.types.d.ts +2 -1
- package/package.json +8 -7
- package/src/entry/sd-cli-cordova.ts +4 -4
- package/src/entry/sd-cli-electron.ts +2 -2
- package/src/entry/sd-cli-local-update.ts +2 -2
- package/src/entry/sd-cli-project.ts +6 -6
- package/src/entry/utils/loadProjConfAsync.ts +2 -2
- package/src/fix/convert-private-underscore.ts +69 -0
- package/src/fix/convert-private.ts +74 -0
- package/src/pkg-builders/client/sd-cli-ng-routes.file-generator.ts +3 -3
- package/src/pkg-builders/client/sd-client.build-runner.ts +39 -126
- package/src/pkg-builders/client/sd-ng.bundler.ts +4 -3
- package/src/pkg-builders/client/sd-ng.plugin-creator.ts +3 -2
- package/src/pkg-builders/commons/build-runner.base.ts +149 -0
- package/src/pkg-builders/commons/scope-path.ts +17 -0
- package/src/pkg-builders/lib/sd-cli-index.file-generator.ts +2 -2
- package/src/pkg-builders/lib/sd-js-lib.build-runner.ts +29 -74
- package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +35 -130
- package/src/pkg-builders/lib/sd-ts-lib.builder.ts +3 -2
- package/src/pkg-builders/sd-multi.build-runner.ts +4 -4
- package/src/pkg-builders/server/sd-server.build-runner.ts +99 -187
- package/src/pkg-builders/server/sd-server.bundler.ts +4 -3
- package/src/pkg-builders/server/sd-server.plugin-creator.ts +13 -8
- package/src/sd-cli-entry.ts +115 -81
- package/src/sd-cli.ts +14 -11
- package/src/ts-compiler/sd-dependency-analyzer.ts +10 -17
- package/src/ts-compiler/sd-ts-compiler.ts +79 -30
- package/src/types/config.types.ts +9 -2
- package/src/types/ts-compiler.types.ts +2 -1
- package/tests/deps/sd-dependency-analyzer.spec.ts +1 -1
- package/dist/workers/style-bundler.worker.d.ts +0 -1
- package/dist/workers/style-bundler.worker.js +0 -56
- package/dist/workers/style-bundler.worker.js.map +0 -1
- package/src/workers/style-bundler.worker.ts +0 -70
|
@@ -1,145 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { EventEmitter } from "events";
|
|
4
|
-
import { SdCliIndexFileGenerator } from "./sd-cli-index.file-generator";
|
|
1
|
+
import { PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
5
2
|
import { SdTsLibBuilder } from "./sd-ts-lib.builder";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { BuildRunnerBase, IBuildRunnerRunResult } from "../commons/build-runner.base";
|
|
4
|
+
import { SdCliIndexFileGenerator } from "./sd-cli-index.file-generator";
|
|
8
5
|
import { SdCliDbContextFileGenerator } from "./sd-cli-db-context.file-generator";
|
|
9
6
|
|
|
10
|
-
export class SdTsLibBuildRunner extends
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private _projConf: ISdProjectConfig;
|
|
14
|
-
private _pkgPath: string;
|
|
15
|
-
private _pkgConf: ISdLibPackageConfig;
|
|
16
|
-
private _watchScopePathSet: Set<TNormPath>;
|
|
7
|
+
export class SdTsLibBuildRunner extends BuildRunnerBase<"library"> {
|
|
8
|
+
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
|
|
17
9
|
|
|
18
10
|
private _builder?: SdTsLibBuilder;
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
super();
|
|
22
|
-
this._projConf = projConf;
|
|
23
|
-
this._pkgPath = pkgPath;
|
|
24
|
-
|
|
25
|
-
this._pkgConf = projConf.packages[path.basename(pkgPath)] as ISdLibPackageConfig;
|
|
26
|
-
|
|
27
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
28
|
-
FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
29
|
-
);
|
|
30
|
-
this._watchScopePathSet = new Set(
|
|
31
|
-
[path.resolve(this._pkgPath, "../"), ...localUpdatePaths].map((item) => PathUtils.norm(item)),
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
override on(event: "change", listener: () => void): this;
|
|
36
|
-
override on(event: "complete", listener: (result: ISdBuildRunnerResult) => void): this;
|
|
37
|
-
override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
38
|
-
super.on(event, listener);
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async buildAsync(): Promise<ISdBuildRunnerResult> {
|
|
43
|
-
this._debug("dist 초기화...");
|
|
44
|
-
FsUtils.remove(path.resolve(this._pkgPath, "dist"));
|
|
45
|
-
|
|
46
|
-
if (!this._pkgConf.noGenIndex) {
|
|
47
|
-
this._debug("GEN index.ts...");
|
|
48
|
-
SdCliIndexFileGenerator.run(this._pkgPath, this._pkgConf.polyfills);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (this._pkgConf.dbContext != null) {
|
|
52
|
-
this._debug("WATCH GEN index.ts...");
|
|
53
|
-
SdCliDbContextFileGenerator.run(this._pkgPath, this._pkgConf.dbContext);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const result = await this._runAsync(false, new Set<TNormPath>());
|
|
57
|
-
return {
|
|
58
|
-
affectedFilePathSet: result.affectedFileSet,
|
|
59
|
-
buildMessages: result.buildMessages,
|
|
60
|
-
emitFileSet: result.emitFileSet,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async watchAsync(): Promise<void> {
|
|
65
|
-
this.emit("change");
|
|
66
|
-
|
|
67
|
-
this._debug("dist 초기화...");
|
|
68
|
-
FsUtils.remove(path.resolve(this._pkgPath, "dist"));
|
|
69
|
-
|
|
70
|
-
if (!this._pkgConf.noGenIndex) {
|
|
71
|
-
this._debug("WATCH GEN index.ts...");
|
|
72
|
-
SdCliIndexFileGenerator.watch(this._pkgPath, this._pkgConf.polyfills);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (this._pkgConf.dbContext != null) {
|
|
76
|
-
this._debug("WATCH GEN index.ts...");
|
|
77
|
-
SdCliDbContextFileGenerator.watch(this._pkgPath, this._pkgConf.dbContext);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const result = await this._runAsync(true, new Set<TNormPath>());
|
|
81
|
-
const res: ISdBuildRunnerResult = {
|
|
82
|
-
affectedFilePathSet: result.affectedFileSet,
|
|
83
|
-
buildMessages: result.buildMessages,
|
|
84
|
-
emitFileSet: result.emitFileSet,
|
|
85
|
-
};
|
|
86
|
-
this.emit("complete", res);
|
|
87
|
-
|
|
88
|
-
this._debug("WATCH...");
|
|
89
|
-
let lastWatchFileSet = result.watchFileSet;
|
|
90
|
-
SdFsWatcher.watch(Array.from(this._watchScopePathSet))
|
|
91
|
-
.onChange({ delay: 100 }, async (changeInfos) => {
|
|
92
|
-
const currentChangeInfos = changeInfos.filter((item) => lastWatchFileSet.has(item.path));
|
|
93
|
-
if (currentChangeInfos.length < 1) return;
|
|
94
|
-
|
|
95
|
-
this.emit("change");
|
|
96
|
-
|
|
97
|
-
const changeFileSet = new Set(currentChangeInfos.map((item) => PathUtils.norm(item.path)));
|
|
98
|
-
|
|
99
|
-
const watchResult = await this._runAsync(true, changeFileSet);
|
|
100
|
-
const watchRes: ISdBuildRunnerResult = {
|
|
101
|
-
affectedFilePathSet: watchResult.affectedFileSet,
|
|
102
|
-
buildMessages: watchResult.buildMessages,
|
|
103
|
-
emitFileSet: watchResult.emitFileSet,
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
this.emit("complete", watchRes);
|
|
107
|
-
|
|
108
|
-
lastWatchFileSet = watchResult.watchFileSet;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private async _runAsync(
|
|
12
|
+
protected override async _runAsync(
|
|
113
13
|
dev: boolean,
|
|
114
|
-
modifiedFileSet
|
|
115
|
-
): Promise<{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
14
|
+
modifiedFileSet?: Set<TNormPath>,
|
|
15
|
+
): Promise<IBuildRunnerRunResult> {
|
|
16
|
+
if (!modifiedFileSet) {
|
|
17
|
+
if (!dev) {
|
|
18
|
+
if (!this._pkgConf.noGenIndex) {
|
|
19
|
+
this._debug("GEN index.ts...");
|
|
20
|
+
SdCliIndexFileGenerator.run(this._pkgPath, this._pkgConf.polyfills);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (this._pkgConf.dbContext != null) {
|
|
24
|
+
this._debug(`GEN ${this._pkgConf.dbContext}.ts...`);
|
|
25
|
+
SdCliDbContextFileGenerator.run(this._pkgPath, this._pkgConf.dbContext);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (!this._pkgConf.noGenIndex) {
|
|
30
|
+
this._debug("Watch for GEN index.ts...");
|
|
31
|
+
SdCliIndexFileGenerator.watch(this._pkgPath, this._pkgConf.polyfills);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (this._pkgConf.dbContext != null) {
|
|
35
|
+
this._debug(`Watch for GEN ${this._pkgConf.dbContext}.ts...`);
|
|
36
|
+
SdCliDbContextFileGenerator.watch(this._pkgPath, this._pkgConf.dbContext);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
124
40
|
|
|
125
41
|
this._debug(`BUILD...`);
|
|
126
42
|
this._builder ??= new SdTsLibBuilder(
|
|
127
43
|
PathUtils.norm(this._pkgPath),
|
|
128
44
|
dev,
|
|
129
|
-
|
|
130
|
-
PathUtils.norm(this._pkgPath, "../"),
|
|
131
|
-
...localUpdatePaths,
|
|
132
|
-
].map((item) => PathUtils.norm(item)),
|
|
45
|
+
this._watchScopePathSet,
|
|
133
46
|
);
|
|
134
|
-
const buildResult = await this._builder.buildAsync(modifiedFileSet);
|
|
47
|
+
const buildResult = await this._builder.buildAsync(modifiedFileSet ?? new Set());
|
|
135
48
|
|
|
136
49
|
this._debug(`빌드 완료`);
|
|
137
50
|
const watchFileSet = new Set(
|
|
138
|
-
Array.from(buildResult.watchFileSet).filter(
|
|
139
|
-
(item) =>
|
|
140
|
-
PathUtils.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
141
|
-
localUpdatePaths.some((lu) => PathUtils.isChildPath(item, lu)),
|
|
142
|
-
),
|
|
51
|
+
Array.from(buildResult.watchFileSet).filter((item) => this._watchScopePathSet.inScope(item)),
|
|
143
52
|
);
|
|
144
53
|
|
|
145
54
|
return {
|
|
@@ -149,8 +58,4 @@ export class SdTsLibBuildRunner extends EventEmitter {
|
|
|
149
58
|
emitFileSet: buildResult.emitFileSet,
|
|
150
59
|
};
|
|
151
60
|
}
|
|
152
|
-
|
|
153
|
-
protected _debug(msg: string): void {
|
|
154
|
-
this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
|
|
155
|
-
}
|
|
156
61
|
}
|
|
@@ -3,6 +3,7 @@ import { SdCliConvertMessageUtils } from "../../utils/sd-cli-convert-message.uti
|
|
|
3
3
|
import { FsUtils, PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
4
4
|
import { ISdBuildMessage } from "../../types/build.types";
|
|
5
5
|
import { SdTsCompiler } from "../../ts-compiler/sd-ts-compiler";
|
|
6
|
+
import { ScopePathSet } from "../commons/scope-path";
|
|
6
7
|
|
|
7
8
|
export class SdTsLibBuilder {
|
|
8
9
|
private _tsCompiler: SdTsCompiler;
|
|
@@ -10,7 +11,7 @@ export class SdTsLibBuilder {
|
|
|
10
11
|
constructor(
|
|
11
12
|
private _pkgPath: TNormPath,
|
|
12
13
|
dev: boolean,
|
|
13
|
-
|
|
14
|
+
watchScopePathSet: ScopePathSet,
|
|
14
15
|
) {
|
|
15
16
|
this._tsCompiler = new SdTsCompiler({
|
|
16
17
|
pkgPath: this._pkgPath,
|
|
@@ -18,7 +19,7 @@ export class SdTsLibBuilder {
|
|
|
18
19
|
isDevMode: dev,
|
|
19
20
|
globalStyleFilePath: PathUtils.norm(this._pkgPath, "src/styles.scss"),
|
|
20
21
|
isForBundle: false,
|
|
21
|
-
|
|
22
|
+
watchScopePathSet,
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -51,7 +51,7 @@ export class SdMultiBuildRunner extends EventEmitter {
|
|
|
51
51
|
}
|
|
52
52
|
this._busyCount++;
|
|
53
53
|
})
|
|
54
|
-
.on("complete", (result) => this
|
|
54
|
+
.on("complete", (result) => this._onComplete(req, result));
|
|
55
55
|
|
|
56
56
|
return await worker.run("run", [req]);
|
|
57
57
|
/*const pkgConf = req.projConf.packages[path.basename(req.pkgPath)]!;
|
|
@@ -78,7 +78,7 @@ export class SdMultiBuildRunner extends EventEmitter {
|
|
|
78
78
|
}*/
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
private _onComplete(req: ISdBuildRunnerWorkerRequest, result: ISdBuildRunnerResult) {
|
|
82
82
|
this._resultCache.delete(req.pkgPath);
|
|
83
83
|
for (const affectedFilePath of result.affectedFilePathSet) {
|
|
84
84
|
if (PathUtils.isChildPath(affectedFilePath, req.pkgPath)) {
|
|
@@ -152,7 +152,7 @@ export class SdMultiBuildRunner extends EventEmitter {
|
|
|
152
152
|
if (serverInfo.pkgInfo && serverInfo.hasChanges) {
|
|
153
153
|
this._logger.debug("서버 재시작...");
|
|
154
154
|
try {
|
|
155
|
-
const restartServerResult = await this
|
|
155
|
+
const restartServerResult = await this._restartServerAsync(
|
|
156
156
|
serverInfo.pkgInfo,
|
|
157
157
|
serverInfo.worker,
|
|
158
158
|
);
|
|
@@ -212,7 +212,7 @@ export class SdMultiBuildRunner extends EventEmitter {
|
|
|
212
212
|
}, 300);
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
async
|
|
215
|
+
private async _restartServerAsync(
|
|
216
216
|
pkgInfo: { path: string; conf: ISdServerPackageConfig } | { port: number },
|
|
217
217
|
prevWorker?: SdWorker<TServerWorkerType>,
|
|
218
218
|
): Promise<{
|
|
@@ -1,121 +1,100 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FsUtils, PathUtils, SdFsWatcher, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
1
|
+
import { FsUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
3
2
|
import path from "path";
|
|
4
3
|
import { StringUtils } from "@simplysm/sd-core-common";
|
|
5
4
|
import { SdServerBundler } from "./sd-server.bundler";
|
|
6
|
-
import { ISdProjectConfig, ISdServerPackageConfig } from "../../types/config.types";
|
|
7
|
-
import { ISdBuildMessage, ISdBuildRunnerResult } from "../../types/build.types";
|
|
8
5
|
import { INpmConfig, ITsConfig } from "../../types/common-configs.types";
|
|
6
|
+
import { BuildRunnerBase, IBuildRunnerRunResult } from "../commons/build-runner.base";
|
|
7
|
+
|
|
8
|
+
export class SdServerBuildRunner extends BuildRunnerBase<"server"> {
|
|
9
|
+
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdCliServerBuildRunner"]);
|
|
9
10
|
|
|
10
|
-
export class SdServerBuildRunner extends EventEmitter {
|
|
11
|
-
private _logger = SdLogger.get(["simplysm", "sd-cli", "SdCliServerBuildRunner"]);
|
|
12
|
-
private _pkgConf: ISdServerPackageConfig;
|
|
13
11
|
private _serverBundler?: SdServerBundler;
|
|
14
12
|
private _extModules?: { name: string; exists: boolean }[];
|
|
15
|
-
private _watchScopePathSet: Set<TNormPath>;
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
) {
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
protected override async _runAsync(
|
|
15
|
+
dev: boolean,
|
|
16
|
+
modifiedFileSet?: Set<TNormPath>,
|
|
17
|
+
): Promise<IBuildRunnerRunResult> {
|
|
18
|
+
if (!dev) {
|
|
19
|
+
await this._generateProductionFilesAsync();
|
|
20
|
+
}
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
}
|
|
22
|
+
if (!modifiedFileSet) {
|
|
23
|
+
this._debug("GEN .config...");
|
|
24
|
+
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
25
|
+
FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
26
|
+
}
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
super.on(event, listener);
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
28
|
+
/*const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
29
|
+
FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
30
|
+
);*/
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
this.
|
|
32
|
+
this._debug(`BUILD 준비...`);
|
|
33
|
+
const tsConfig = FsUtils.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
|
|
34
|
+
this._extModules = this._extModules ?? (await this._getExternalModulesAsync());
|
|
35
|
+
this._serverBundler =
|
|
36
|
+
this._serverBundler ??
|
|
37
|
+
new SdServerBundler({
|
|
38
|
+
dev,
|
|
39
|
+
pkgPath: this._pkgPath,
|
|
40
|
+
entryPoints: tsConfig.files
|
|
41
|
+
? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
|
|
42
|
+
: [
|
|
43
|
+
path.resolve(this._pkgPath, "src/main.ts"),
|
|
44
|
+
...FsUtils.glob(path.resolve(this._pkgPath, "src/workers/*.ts")),
|
|
45
|
+
],
|
|
46
|
+
external: this._extModules.map((item) => item.name),
|
|
47
|
+
watchScopePathSet: this._watchScopePathSet,
|
|
48
|
+
});
|
|
41
49
|
|
|
42
|
-
this._debug(
|
|
43
|
-
|
|
50
|
+
this._debug(`BUILD...`);
|
|
51
|
+
const bundleResult = await this._serverBundler.bundleAsync(modifiedFileSet);
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
53
|
+
//-- filePaths
|
|
54
|
+
const watchFileSet = new Set(
|
|
55
|
+
Array.from(bundleResult.watchFileSet).filter((item) => this._watchScopePathSet.inScope(item)),
|
|
56
|
+
);
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
this._debug(`빌드 완료`);
|
|
59
|
+
return {
|
|
60
|
+
watchFileSet,
|
|
61
|
+
affectedFileSet: bundleResult.affectedFileSet,
|
|
62
|
+
buildMessages: bundleResult.results,
|
|
63
|
+
emitFileSet: bundleResult.emitFileSet,
|
|
54
64
|
};
|
|
55
|
-
this.emit("complete", res);
|
|
56
|
-
|
|
57
|
-
this._debug("WATCH...");
|
|
58
|
-
let lastWatchFileSet = result.watchFileSet;
|
|
59
|
-
SdFsWatcher.watch(Array.from(this._watchScopePathSet))
|
|
60
|
-
.onChange({ delay: 100 }, async (changeInfos) => {
|
|
61
|
-
const currentChangeInfos = changeInfos.filter((item) => lastWatchFileSet.has(item.path));
|
|
62
|
-
if (currentChangeInfos.length < 1) return;
|
|
63
|
-
|
|
64
|
-
this.emit("change");
|
|
65
|
-
|
|
66
|
-
const watchResult = await this._runAsync(
|
|
67
|
-
true,
|
|
68
|
-
new Set(currentChangeInfos.map((item) => PathUtils.norm(item.path))),
|
|
69
|
-
);
|
|
70
|
-
const watchRes: ISdBuildRunnerResult = {
|
|
71
|
-
affectedFilePathSet: watchResult.affectedFileSet,
|
|
72
|
-
buildMessages: watchResult.buildMessages,
|
|
73
|
-
emitFileSet: watchResult.emitFileSet,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
this.emit("complete", watchRes);
|
|
77
|
-
|
|
78
|
-
lastWatchFileSet = watchResult.watchFileSet;
|
|
79
|
-
});
|
|
80
65
|
}
|
|
81
66
|
|
|
82
|
-
async
|
|
83
|
-
const
|
|
84
|
-
process.cwd(),
|
|
85
|
-
"package.json",
|
|
86
|
-
)) as INpmConfig;
|
|
87
|
-
const npmConfig = FsUtils.readJson(path.resolve(this._pkgPath, "package.json")) as INpmConfig;
|
|
88
|
-
const extModules = await this._getExternalModulesAsync();
|
|
89
|
-
|
|
90
|
-
this._debug("dist 초기화...");
|
|
91
|
-
FsUtils.remove(path.resolve(this._pkgPath, "dist"));
|
|
92
|
-
|
|
93
|
-
this._debug("GEN .config.json...");
|
|
94
|
-
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
95
|
-
FsUtils.writeJson(confDistPath, this._pkgConf.configs ?? {}, { space: 2 });
|
|
67
|
+
private async _generateProductionFilesAsync() {
|
|
68
|
+
const npmConf = FsUtils.readJson(path.resolve(this._pkgPath, "package.json")) as INpmConfig;
|
|
96
69
|
|
|
97
70
|
this._debug("GEN package.json...");
|
|
98
71
|
{
|
|
72
|
+
const projNpmConf = FsUtils.readJson(path.resolve(
|
|
73
|
+
process.cwd(),
|
|
74
|
+
"package.json",
|
|
75
|
+
)) as INpmConfig;
|
|
76
|
+
const extModules = await this._getExternalModulesAsync();
|
|
77
|
+
|
|
99
78
|
const deps = extModules.filter((item) => item.exists).map((item) => item.name);
|
|
100
79
|
|
|
101
80
|
const distNpmConfig: INpmConfig = {
|
|
102
|
-
name:
|
|
103
|
-
version:
|
|
104
|
-
type:
|
|
81
|
+
name: npmConf.name,
|
|
82
|
+
version: npmConf.version,
|
|
83
|
+
type: npmConf.type,
|
|
105
84
|
};
|
|
106
85
|
distNpmConfig.dependencies = {};
|
|
107
86
|
for (const dep of deps) {
|
|
108
87
|
distNpmConfig.dependencies[dep] = "*";
|
|
109
88
|
}
|
|
110
89
|
|
|
111
|
-
distNpmConfig.scripts = {};
|
|
112
|
-
if (this._pkgConf.pm2 && !this._pkgConf.pm2.noStartScript) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
90
|
+
// distNpmConfig.scripts = {};
|
|
91
|
+
// if (this._pkgConf.pm2 && !this._pkgConf.pm2.noStartScript) {
|
|
92
|
+
// distNpmConfig.scripts["start"] = "pm2 start pm2.config.cjs";
|
|
93
|
+
// distNpmConfig.scripts["stop"] = "pm2 stop pm2.config.cjs";
|
|
94
|
+
// distNpmConfig.scripts["delete"] = "pm2 delete pm2.config.cjs";
|
|
95
|
+
// }
|
|
117
96
|
|
|
118
|
-
distNpmConfig.volta =
|
|
97
|
+
distNpmConfig.volta = projNpmConf.volta;
|
|
119
98
|
|
|
120
99
|
FsUtils.writeJson(
|
|
121
100
|
path.resolve(this._pkgPath, "dist/package.json"),
|
|
@@ -165,36 +144,36 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
165
144
|
this._debug("GEN pm2.config.cjs...");
|
|
166
145
|
|
|
167
146
|
const str = /* language=cjs */ `
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
147
|
+
const cp = require("child_process");
|
|
148
|
+
|
|
149
|
+
const npmConf = require("./package.json");
|
|
150
|
+
|
|
151
|
+
const pm2Conf = ${JSON.stringify(this._pkgConf.pm2)};
|
|
152
|
+
const env = ${JSON.stringify(this._pkgConf.env)};
|
|
153
|
+
|
|
154
|
+
module.exports = {
|
|
155
|
+
name: pm2Conf.name ?? npmConf.name.replace(/@/g, "").replace(/\\//g, "-"),
|
|
156
|
+
script: "main.js",
|
|
157
|
+
watch: true,
|
|
158
|
+
watch_delay: 2000,
|
|
159
|
+
ignore_watch: [
|
|
160
|
+
"node_modules",
|
|
161
|
+
"www",
|
|
162
|
+
...pm2Conf.ignoreWatchPaths ?? []
|
|
163
|
+
],
|
|
164
|
+
...pm2Conf.noInterpreter ? {} : {interpreter: cp.execSync("volta which node").toString().trim()},
|
|
165
|
+
interpreter_args: "--openssl-config=openssl.cnf",
|
|
166
|
+
env: {
|
|
167
|
+
NODE_ENV: "production",
|
|
168
|
+
TZ: "Asia/Seoul",
|
|
169
|
+
SD_VERSION: npmConf.version,
|
|
170
|
+
...env ?? {}
|
|
171
|
+
},
|
|
172
|
+
arrayProcess: "concat",
|
|
173
|
+
useDelTargetNull: true,
|
|
174
|
+
exec_mode: pm2Conf.instances != null ? "cluster" : "fork",
|
|
175
|
+
instances: pm2Conf.instances ?? 1
|
|
176
|
+
};`
|
|
198
177
|
.replaceAll("\n ", "\n")
|
|
199
178
|
.trim();
|
|
200
179
|
|
|
@@ -214,7 +193,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
214
193
|
<appSettings>
|
|
215
194
|
<add key="NODE_ENV" value="production" />
|
|
216
195
|
<add key="TZ" value="Asia/Seoul" />
|
|
217
|
-
<add key="SD_VERSION" value="${
|
|
196
|
+
<add key="SD_VERSION" value="${npmConf.version}" />
|
|
218
197
|
${Object.keys(this._pkgConf.env ?? {})
|
|
219
198
|
.map((key) => `<add key="${key}" value="${this._pkgConf.env![key]}"/>`)
|
|
220
199
|
.join("\n ")}
|
|
@@ -236,71 +215,8 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
236
215
|
</rewrite>
|
|
237
216
|
<httpErrors errorMode="Detailed" />
|
|
238
217
|
</system.webServer>
|
|
239
|
-
</configuration
|
|
240
|
-
`.trim());
|
|
218
|
+
</configuration>`.trim());
|
|
241
219
|
}
|
|
242
|
-
|
|
243
|
-
const result = await this._runAsync(false);
|
|
244
|
-
return {
|
|
245
|
-
affectedFilePathSet: result.affectedFileSet,
|
|
246
|
-
buildMessages: result.buildMessages,
|
|
247
|
-
emitFileSet: result.emitFileSet,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
private async _runAsync(
|
|
252
|
-
dev: boolean,
|
|
253
|
-
modifiedFileSet?: Set<TNormPath>,
|
|
254
|
-
): Promise<{
|
|
255
|
-
watchFileSet: Set<TNormPath>;
|
|
256
|
-
affectedFileSet: Set<TNormPath>;
|
|
257
|
-
buildMessages: ISdBuildMessage[];
|
|
258
|
-
emitFileSet: Set<TNormPath>;
|
|
259
|
-
}> {
|
|
260
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
261
|
-
FsUtils.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
this._debug(`BUILD 준비...`);
|
|
265
|
-
const tsConfig = FsUtils.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
|
|
266
|
-
this._extModules = this._extModules ?? (await this._getExternalModulesAsync());
|
|
267
|
-
this._serverBundler =
|
|
268
|
-
this._serverBundler ??
|
|
269
|
-
new SdServerBundler({
|
|
270
|
-
dev,
|
|
271
|
-
pkgPath: this._pkgPath,
|
|
272
|
-
entryPoints: tsConfig.files
|
|
273
|
-
? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
|
|
274
|
-
: [
|
|
275
|
-
path.resolve(this._pkgPath, "src/main.ts"),
|
|
276
|
-
...FsUtils.glob(path.resolve(this._pkgPath, "src/workers/*.ts")),
|
|
277
|
-
],
|
|
278
|
-
external: this._extModules.map((item) => item.name),
|
|
279
|
-
watchScopePaths: [
|
|
280
|
-
path.resolve(this._pkgPath, "../"),
|
|
281
|
-
...localUpdatePaths,
|
|
282
|
-
].map((item) => PathUtils.norm(item)),
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
this._debug(`BUILD...`);
|
|
286
|
-
const bundleResult = await this._serverBundler.bundleAsync(modifiedFileSet);
|
|
287
|
-
|
|
288
|
-
//-- filePaths
|
|
289
|
-
const watchFileSet = new Set(
|
|
290
|
-
Array.from(bundleResult.watchFileSet).filter(
|
|
291
|
-
(item) =>
|
|
292
|
-
PathUtils.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
293
|
-
localUpdatePaths.some((lu) => PathUtils.isChildPath(item, lu)),
|
|
294
|
-
),
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
this._debug(`빌드 완료`);
|
|
298
|
-
return {
|
|
299
|
-
watchFileSet,
|
|
300
|
-
affectedFileSet: bundleResult.affectedFileSet,
|
|
301
|
-
buildMessages: bundleResult.results,
|
|
302
|
-
emitFileSet: bundleResult.emitFileSet,
|
|
303
|
-
};
|
|
304
220
|
}
|
|
305
221
|
|
|
306
222
|
private async _getExternalModulesAsync(): Promise<
|
|
@@ -416,8 +332,4 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
416
332
|
|
|
417
333
|
return results;
|
|
418
334
|
}
|
|
419
|
-
|
|
420
|
-
private _debug(msg: string): void {
|
|
421
|
-
this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
|
|
422
|
-
}
|
|
423
335
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "@angular/build/src/tools/esbuild/bundler-context";
|
|
12
12
|
import { convertOutputFile } from "@angular/build/src/tools/esbuild/utils";
|
|
13
13
|
import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
|
|
14
|
+
import { ScopePathSet } from "../commons/scope-path";
|
|
14
15
|
|
|
15
16
|
export class SdServerBundler {
|
|
16
17
|
private _logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBundler"]);
|
|
@@ -27,7 +28,7 @@ export class SdServerBundler {
|
|
|
27
28
|
pkgPath: TNormPath;
|
|
28
29
|
entryPoints: string[];
|
|
29
30
|
external?: string[];
|
|
30
|
-
|
|
31
|
+
watchScopePathSet: ScopePathSet;
|
|
31
32
|
}) {
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -108,7 +109,7 @@ const __dirname = __path__.dirname(__filename);`.trim(),
|
|
|
108
109
|
dev: this._opt.dev,
|
|
109
110
|
pkgPath: this._opt.pkgPath,
|
|
110
111
|
result: this._resultCache,
|
|
111
|
-
|
|
112
|
+
watchScopePathSet: this._opt.watchScopePathSet,
|
|
112
113
|
}),
|
|
113
114
|
],
|
|
114
115
|
});
|
|
@@ -125,7 +126,7 @@ const __dirname = __path__.dirname(__filename);`.trim(),
|
|
|
125
126
|
for (const outputFile of outputFiles) {
|
|
126
127
|
const distFilePath = PathUtils.norm(this._opt.pkgPath, outputFile.path);
|
|
127
128
|
const prevHash = this._outputHashCache.get(distFilePath);
|
|
128
|
-
const currHash = HashUtils.get(outputFile.contents);
|
|
129
|
+
const currHash = HashUtils.get(Buffer.from(outputFile.contents));
|
|
129
130
|
if (prevHash !== currHash) {
|
|
130
131
|
FsUtils.writeFile(distFilePath, outputFile.contents);
|
|
131
132
|
this._outputHashCache.set(distFilePath, currHash);
|