@simplysm/sd-cli 11.0.40 → 11.1.2

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 (55) hide show
  1. package/dist/build-cluster.d.ts +1 -1
  2. package/dist/build-cluster.js +181 -181
  3. package/dist/build-tools/SdCliCordova.d.ts +21 -21
  4. package/dist/build-tools/SdCliCordova.js +217 -217
  5. package/dist/build-tools/SdCliIndexFileGenerator.d.ts +5 -5
  6. package/dist/build-tools/SdCliIndexFileGenerator.js +50 -50
  7. package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +4 -4
  8. package/dist/build-tools/SdCliNgRoutesFileGenerator.js +57 -57
  9. package/dist/build-tools/SdLinter.d.ts +5 -5
  10. package/dist/build-tools/SdLinter.js +54 -54
  11. package/dist/build-tools/SdNgBundler.d.ts +34 -35
  12. package/dist/build-tools/SdNgBundler.js +534 -533
  13. package/dist/build-tools/SdNgBundler.js.map +1 -1
  14. package/dist/build-tools/SdNgBundlerContext.d.ts +15 -16
  15. package/dist/build-tools/SdNgBundlerContext.js +97 -97
  16. package/dist/build-tools/SdNgBundlerContext.js.map +1 -1
  17. package/dist/build-tools/SdTsBundler.d.ts +15 -15
  18. package/dist/build-tools/SdTsBundler.js +87 -87
  19. package/dist/build-tools/SdTsCompiler.d.ts +29 -29
  20. package/dist/build-tools/SdTsCompiler.js +227 -227
  21. package/dist/builders/SdCliClientBuilder.d.ts +18 -18
  22. package/dist/builders/SdCliClientBuilder.js +129 -129
  23. package/dist/builders/SdCliJsLibLinter.d.ts +14 -14
  24. package/dist/builders/SdCliJsLibLinter.js +59 -59
  25. package/dist/builders/SdCliServerBuilder.d.ts +20 -20
  26. package/dist/builders/SdCliServerBuilder.js +215 -215
  27. package/dist/builders/SdCliTsLibBuilder.d.ts +17 -17
  28. package/dist/builders/SdCliTsLibBuilder.js +79 -79
  29. package/dist/commons.d.ts +132 -132
  30. package/dist/commons.js +1 -1
  31. package/dist/entry/SdCliElectron.d.ts +12 -12
  32. package/dist/entry/SdCliElectron.js +99 -99
  33. package/dist/entry/SdCliLocalUpdate.d.ts +12 -12
  34. package/dist/entry/SdCliLocalUpdate.js +90 -90
  35. package/dist/entry/SdCliProject.d.ts +26 -26
  36. package/dist/entry/SdCliProject.js +477 -477
  37. package/dist/index.d.ts +19 -19
  38. package/dist/index.js +19 -19
  39. package/dist/sd-cli.d.ts +2 -2
  40. package/dist/sd-cli.js +210 -210
  41. package/dist/server-worker.d.ts +1 -1
  42. package/dist/server-worker.js +38 -38
  43. package/dist/utils/SdCliBuildResultUtil.d.ts +6 -6
  44. package/dist/utils/SdCliBuildResultUtil.js +37 -37
  45. package/dist/utils/SdMemoryLoadResultCache.d.ts +10 -9
  46. package/dist/utils/SdMemoryLoadResultCache.js +36 -34
  47. package/dist/utils/SdMemoryLoadResultCache.js.map +1 -1
  48. package/dist/utils/SdSourceFileCache.d.ts +6 -6
  49. package/dist/utils/SdSourceFileCache.js +21 -14
  50. package/dist/utils/SdSourceFileCache.js.map +1 -1
  51. package/package.json +18 -18
  52. package/src/build-tools/SdNgBundler.ts +30 -36
  53. package/src/build-tools/SdNgBundlerContext.ts +11 -11
  54. package/src/utils/SdMemoryLoadResultCache.ts +4 -1
  55. package/src/utils/SdSourceFileCache.ts +10 -3
@@ -1,70 +1,70 @@
1
- import { EventEmitter } from "events";
2
- import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
3
- import path from "path";
4
- import { SdTsCompiler } from "../build-tools/SdTsCompiler";
5
- import { SdLinter } from "../build-tools/SdLinter";
6
- import { FunctionQueue, ObjectUtil, StringUtil } from "@simplysm/sd-core-common";
7
- import { SdTsBundler } from "../build-tools/SdTsBundler";
8
- export class SdCliServerBuilder extends EventEmitter {
9
- constructor(_projConf, _pkgPath) {
10
- super();
11
- this._projConf = _projConf;
12
- this._pkgPath = _pkgPath;
13
- this._logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuilder"]);
14
- this._pkgConf = this._projConf.packages[path.basename(_pkgPath)];
15
- }
16
- on(event, listener) {
17
- super.on(event, listener);
18
- return this;
19
- }
20
- async watchAsync() {
21
- this.emit("change");
22
- this._debug("dist 초기화...");
23
- await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
24
- this._debug("GEN .config...");
25
- const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
26
- await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
27
- const result = await this._runAsync({ dev: true });
28
- this.emit("complete", result);
29
- this._debug("WATCH...");
30
- const fnQ = new FunctionQueue();
31
- const watcher = SdFsWatcher
32
- .watch(result.watchFilePaths)
33
- .onChange({ delay: 100 }, () => {
34
- fnQ.runLast(async () => {
35
- this.emit("change");
36
- const watchResult = await this._runAsync({ dev: true });
37
- this.emit("complete", watchResult);
38
- watcher.add(watchResult.watchFilePaths);
39
- });
40
- });
41
- }
42
- async buildAsync() {
43
- const npmConfig = (await FsUtil.readJsonAsync(path.resolve(this._pkgPath, "package.json")));
44
- const extModules = await this._getExternalModulesAsync();
45
- this._debug("dist 초기화...");
46
- await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
47
- this._debug("GEN .config.json...");
48
- const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
49
- await FsUtil.writeJsonAsync(confDistPath, this._pkgConf.configs ?? {}, { space: 2 });
50
- this._debug("GEN package.json...");
51
- {
52
- const deps = extModules.filter((item) => item.exists).map((item) => item.name);
53
- const distNpmConfig = ObjectUtil.clone(npmConfig);
54
- distNpmConfig.dependencies = {};
55
- for (const dep of deps) {
56
- distNpmConfig.dependencies[dep] = "*";
57
- }
58
- delete distNpmConfig.optionalDependencies;
59
- delete distNpmConfig.devDependencies;
60
- delete distNpmConfig.peerDependencies;
61
- if (this._pkgConf.pm2 && !this._pkgConf.pm2.noStartScript) {
62
- distNpmConfig.scripts = { "start": "pm2 start pm2.json" };
63
- }
64
- await FsUtil.writeJsonAsync(path.resolve(this._pkgPath, "dist/package.json"), distNpmConfig, { space: 2 });
65
- }
66
- this._debug("GEN openssl.cnf...");
67
- {
1
+ import { EventEmitter } from "events";
2
+ import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
3
+ import path from "path";
4
+ import { SdTsCompiler } from "../build-tools/SdTsCompiler";
5
+ import { SdLinter } from "../build-tools/SdLinter";
6
+ import { FunctionQueue, ObjectUtil, StringUtil } from "@simplysm/sd-core-common";
7
+ import { SdTsBundler } from "../build-tools/SdTsBundler";
8
+ export class SdCliServerBuilder extends EventEmitter {
9
+ constructor(_projConf, _pkgPath) {
10
+ super();
11
+ this._projConf = _projConf;
12
+ this._pkgPath = _pkgPath;
13
+ this._logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuilder"]);
14
+ this._pkgConf = this._projConf.packages[path.basename(_pkgPath)];
15
+ }
16
+ on(event, listener) {
17
+ super.on(event, listener);
18
+ return this;
19
+ }
20
+ async watchAsync() {
21
+ this.emit("change");
22
+ this._debug("dist 초기화...");
23
+ await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
24
+ this._debug("GEN .config...");
25
+ const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
26
+ await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
27
+ const result = await this._runAsync({ dev: true });
28
+ this.emit("complete", result);
29
+ this._debug("WATCH...");
30
+ const fnQ = new FunctionQueue();
31
+ const watcher = SdFsWatcher
32
+ .watch(result.watchFilePaths)
33
+ .onChange({ delay: 100 }, () => {
34
+ fnQ.runLast(async () => {
35
+ this.emit("change");
36
+ const watchResult = await this._runAsync({ dev: true });
37
+ this.emit("complete", watchResult);
38
+ watcher.add(watchResult.watchFilePaths);
39
+ });
40
+ });
41
+ }
42
+ async buildAsync() {
43
+ const npmConfig = (await FsUtil.readJsonAsync(path.resolve(this._pkgPath, "package.json")));
44
+ const extModules = await this._getExternalModulesAsync();
45
+ this._debug("dist 초기화...");
46
+ await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
47
+ this._debug("GEN .config.json...");
48
+ const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
49
+ await FsUtil.writeJsonAsync(confDistPath, this._pkgConf.configs ?? {}, { space: 2 });
50
+ this._debug("GEN package.json...");
51
+ {
52
+ const deps = extModules.filter((item) => item.exists).map((item) => item.name);
53
+ const distNpmConfig = ObjectUtil.clone(npmConfig);
54
+ distNpmConfig.dependencies = {};
55
+ for (const dep of deps) {
56
+ distNpmConfig.dependencies[dep] = "*";
57
+ }
58
+ delete distNpmConfig.optionalDependencies;
59
+ delete distNpmConfig.devDependencies;
60
+ delete distNpmConfig.peerDependencies;
61
+ if (this._pkgConf.pm2 && !this._pkgConf.pm2.noStartScript) {
62
+ distNpmConfig.scripts = { "start": "pm2 start pm2.json" };
63
+ }
64
+ await FsUtil.writeJsonAsync(path.resolve(this._pkgPath, "dist/package.json"), distNpmConfig, { space: 2 });
65
+ }
66
+ this._debug("GEN openssl.cnf...");
67
+ {
68
68
  await FsUtil.writeFileAsync(path.resolve(this._pkgPath, "dist/openssl.cnf"), `
69
69
  nodejs_conf = openssl_init
70
70
 
@@ -86,40 +86,40 @@ activate = 1
86
86
  system_default = system_default_sect
87
87
 
88
88
  [system_default_sect]
89
- Options = UnsafeLegacyRenegotiation`.trim());
90
- }
91
- if (this._pkgConf.pm2) {
92
- this._debug("GEN pm2.json...");
93
- await FsUtil.writeJsonAsync(path.resolve(this._pkgPath, "dist/pm2.json"), {
94
- name: npmConfig.name.replace(/@/g, "").replace(/\//g, "-"),
95
- script: "main.js",
96
- watch: true,
97
- watch_delay: 2000,
98
- ignore_watch: [
99
- "node_modules",
100
- "www",
101
- ...this._pkgConf.pm2.ignoreWatchPaths ?? []
102
- ],
103
- ...this._pkgConf.pm2.noInterpreter ? {} : {
104
- "interpreter": "node@" + process.versions.node,
105
- },
106
- interpreter_args: "--openssl-config=openssl.cnf",
107
- env: {
108
- NODE_ENV: "production",
109
- TZ: "Asia/Seoul",
110
- SD_VERSION: npmConfig.version,
111
- ...this._pkgConf.env
112
- },
113
- arrayProcess: "concat",
114
- useDelTargetNull: true
115
- }, {
116
- space: 2
117
- });
118
- }
119
- if (this._pkgConf.iis) {
120
- this._debug("GEN web.config...");
121
- const iisDistPath = path.resolve(this._pkgPath, "dist/web.config");
122
- const serverExeFilePath = this._pkgConf.iis.nodeExeFilePath ?? "C:\\Program Files\\nodejs\\node.exe";
89
+ Options = UnsafeLegacyRenegotiation`.trim());
90
+ }
91
+ if (this._pkgConf.pm2) {
92
+ this._debug("GEN pm2.json...");
93
+ await FsUtil.writeJsonAsync(path.resolve(this._pkgPath, "dist/pm2.json"), {
94
+ name: npmConfig.name.replace(/@/g, "").replace(/\//g, "-"),
95
+ script: "main.js",
96
+ watch: true,
97
+ watch_delay: 2000,
98
+ ignore_watch: [
99
+ "node_modules",
100
+ "www",
101
+ ...this._pkgConf.pm2.ignoreWatchPaths ?? []
102
+ ],
103
+ ...this._pkgConf.pm2.noInterpreter ? {} : {
104
+ "interpreter": "node@" + process.versions.node,
105
+ },
106
+ interpreter_args: "--openssl-config=openssl.cnf",
107
+ env: {
108
+ NODE_ENV: "production",
109
+ TZ: "Asia/Seoul",
110
+ SD_VERSION: npmConfig.version,
111
+ ...this._pkgConf.env
112
+ },
113
+ arrayProcess: "concat",
114
+ useDelTargetNull: true
115
+ }, {
116
+ space: 2
117
+ });
118
+ }
119
+ if (this._pkgConf.iis) {
120
+ this._debug("GEN web.config...");
121
+ const iisDistPath = path.resolve(this._pkgPath, "dist/web.config");
122
+ const serverExeFilePath = this._pkgConf.iis.nodeExeFilePath ?? "C:\\Program Files\\nodejs\\node.exe";
123
123
  await FsUtil.writeFileAsync(iisDistPath, `
124
124
  <configuration>
125
125
  <system.webServer>
@@ -141,118 +141,118 @@ Options = UnsafeLegacyRenegotiation`.trim());
141
141
  </system.webServer>
142
142
  </configuration>
143
143
 
144
- `.trim());
145
- }
146
- return await this._runAsync({ dev: false });
147
- }
148
- async _runAsync(opt) {
149
- this._debug(`BUILD 준비...`);
150
- this._extModules = this._extModules ?? await this._getExternalModulesAsync();
151
- const tsConfig = FsUtil.readJson(path.resolve(this._pkgPath, "tsconfig.json"));
152
- this._builder = this._builder ?? new SdTsBundler({
153
- dev: opt.dev,
154
- pkgPath: this._pkgPath,
155
- entryPoints: tsConfig.files ? tsConfig.files.map((item) => path.resolve(this._pkgPath, item)) : [
156
- path.resolve(this._pkgPath, "src/main.ts")
157
- ],
158
- external: this._extModules.map((item) => item.name)
159
- });
160
- this._checker = this._checker ?? new SdTsCompiler({
161
- pkgPath: this._pkgPath,
162
- emit: false,
163
- emitDts: false,
164
- globalStyle: false
165
- });
166
- this._debug(`BUILD...`);
167
- const buildResult = await this._builder.bundleAsync();
168
- this._debug("CHECK...");
169
- const checkResult = await this._checker.buildAsync();
170
- this._debug(`LINT...`);
171
- const lintResults = await SdLinter.lintAsync(checkResult.affectedFilePaths, this._checker.program);
172
- this._debug(`빌드 완료`);
173
- const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
174
- .mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)));
175
- const watchFilePaths = [
176
- ...buildResult.filePaths,
177
- ...checkResult.filePaths,
178
- ].filter(item => PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
179
- localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)));
180
- return {
181
- watchFilePaths,
182
- affectedFilePaths: checkResult.affectedFilePaths,
183
- buildResults: [...buildResult.results, ...checkResult.results, ...lintResults]
184
- };
185
- }
186
- async _getExternalModulesAsync() {
187
- const loadedModuleNames = [];
188
- const results = [];
189
- const npmConfigMap = new Map();
190
- const fn = async (currPath) => {
191
- const npmConfig = npmConfigMap.getOrCreate(currPath, await FsUtil.readJsonAsync(path.resolve(currPath, "package.json")));
192
- const deps = {
193
- defaults: [
194
- ...Object.keys(npmConfig.dependencies ?? {}),
195
- ...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => !npmConfig.peerDependenciesMeta?.[item]?.optional)
196
- ].distinct(),
197
- optionals: [
198
- ...Object.keys(npmConfig.optionalDependencies ?? {}),
199
- ...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => npmConfig.peerDependenciesMeta?.[item]?.optional)
200
- ].distinct()
201
- };
202
- for (const moduleName of deps.defaults) {
203
- if (loadedModuleNames.includes(moduleName))
204
- continue;
205
- loadedModuleNames.push(moduleName);
206
- const modulePath = FsUtil.findAllParentChildPaths("node_modules/" + moduleName, currPath, path.resolve(this._pkgPath, "../../")).first();
207
- if (StringUtil.isNullOrEmpty(modulePath)) {
208
- continue;
209
- }
210
- if (FsUtil.glob(path.resolve(modulePath, "binding.gyp")).length > 0) {
211
- results.push({
212
- name: moduleName,
213
- exists: true
214
- });
215
- }
216
- if (this._pkgConf.externals?.includes(moduleName)) {
217
- results.push({
218
- name: moduleName,
219
- exists: true
220
- });
221
- }
222
- await fn(modulePath);
223
- }
224
- for (const optModuleName of deps.optionals) {
225
- if (loadedModuleNames.includes(optModuleName))
226
- continue;
227
- loadedModuleNames.push(optModuleName);
228
- const optModulePath = FsUtil.findAllParentChildPaths("node_modules/" + optModuleName, currPath, path.resolve(this._pkgPath, "../../")).first();
229
- if (StringUtil.isNullOrEmpty(optModulePath)) {
230
- results.push({
231
- name: optModuleName,
232
- exists: false
233
- });
234
- continue;
235
- }
236
- if (FsUtil.glob(path.resolve(optModulePath, "binding.gyp")).length > 0) {
237
- results.push({
238
- name: optModuleName,
239
- exists: true
240
- });
241
- }
242
- if (this._pkgConf.externals?.includes(optModuleName)) {
243
- results.push({
244
- name: optModuleName,
245
- exists: true
246
- });
247
- }
248
- await fn(optModulePath);
249
- }
250
- };
251
- await fn(this._pkgPath);
252
- return results;
253
- }
254
- _debug(msg) {
255
- this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
256
- }
257
- }
144
+ `.trim());
145
+ }
146
+ return await this._runAsync({ dev: false });
147
+ }
148
+ async _runAsync(opt) {
149
+ this._debug(`BUILD 준비...`);
150
+ this._extModules = this._extModules ?? await this._getExternalModulesAsync();
151
+ const tsConfig = FsUtil.readJson(path.resolve(this._pkgPath, "tsconfig.json"));
152
+ this._builder = this._builder ?? new SdTsBundler({
153
+ dev: opt.dev,
154
+ pkgPath: this._pkgPath,
155
+ entryPoints: tsConfig.files ? tsConfig.files.map((item) => path.resolve(this._pkgPath, item)) : [
156
+ path.resolve(this._pkgPath, "src/main.ts")
157
+ ],
158
+ external: this._extModules.map((item) => item.name)
159
+ });
160
+ this._checker = this._checker ?? new SdTsCompiler({
161
+ pkgPath: this._pkgPath,
162
+ emit: false,
163
+ emitDts: false,
164
+ globalStyle: false
165
+ });
166
+ this._debug(`BUILD...`);
167
+ const buildResult = await this._builder.bundleAsync();
168
+ this._debug("CHECK...");
169
+ const checkResult = await this._checker.buildAsync();
170
+ this._debug(`LINT...`);
171
+ const lintResults = await SdLinter.lintAsync(checkResult.affectedFilePaths, this._checker.program);
172
+ this._debug(`빌드 완료`);
173
+ const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
174
+ .mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)));
175
+ const watchFilePaths = [
176
+ ...buildResult.filePaths,
177
+ ...checkResult.filePaths,
178
+ ].filter(item => PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
179
+ localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)));
180
+ return {
181
+ watchFilePaths,
182
+ affectedFilePaths: checkResult.affectedFilePaths,
183
+ buildResults: [...buildResult.results, ...checkResult.results, ...lintResults]
184
+ };
185
+ }
186
+ async _getExternalModulesAsync() {
187
+ const loadedModuleNames = [];
188
+ const results = [];
189
+ const npmConfigMap = new Map();
190
+ const fn = async (currPath) => {
191
+ const npmConfig = npmConfigMap.getOrCreate(currPath, await FsUtil.readJsonAsync(path.resolve(currPath, "package.json")));
192
+ const deps = {
193
+ defaults: [
194
+ ...Object.keys(npmConfig.dependencies ?? {}),
195
+ ...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => !npmConfig.peerDependenciesMeta?.[item]?.optional)
196
+ ].distinct(),
197
+ optionals: [
198
+ ...Object.keys(npmConfig.optionalDependencies ?? {}),
199
+ ...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => npmConfig.peerDependenciesMeta?.[item]?.optional)
200
+ ].distinct()
201
+ };
202
+ for (const moduleName of deps.defaults) {
203
+ if (loadedModuleNames.includes(moduleName))
204
+ continue;
205
+ loadedModuleNames.push(moduleName);
206
+ const modulePath = FsUtil.findAllParentChildPaths("node_modules/" + moduleName, currPath, path.resolve(this._pkgPath, "../../")).first();
207
+ if (StringUtil.isNullOrEmpty(modulePath)) {
208
+ continue;
209
+ }
210
+ if (FsUtil.glob(path.resolve(modulePath, "binding.gyp")).length > 0) {
211
+ results.push({
212
+ name: moduleName,
213
+ exists: true
214
+ });
215
+ }
216
+ if (this._pkgConf.externals?.includes(moduleName)) {
217
+ results.push({
218
+ name: moduleName,
219
+ exists: true
220
+ });
221
+ }
222
+ await fn(modulePath);
223
+ }
224
+ for (const optModuleName of deps.optionals) {
225
+ if (loadedModuleNames.includes(optModuleName))
226
+ continue;
227
+ loadedModuleNames.push(optModuleName);
228
+ const optModulePath = FsUtil.findAllParentChildPaths("node_modules/" + optModuleName, currPath, path.resolve(this._pkgPath, "../../")).first();
229
+ if (StringUtil.isNullOrEmpty(optModulePath)) {
230
+ results.push({
231
+ name: optModuleName,
232
+ exists: false
233
+ });
234
+ continue;
235
+ }
236
+ if (FsUtil.glob(path.resolve(optModulePath, "binding.gyp")).length > 0) {
237
+ results.push({
238
+ name: optModuleName,
239
+ exists: true
240
+ });
241
+ }
242
+ if (this._pkgConf.externals?.includes(optModuleName)) {
243
+ results.push({
244
+ name: optModuleName,
245
+ exists: true
246
+ });
247
+ }
248
+ await fn(optModulePath);
249
+ }
250
+ };
251
+ await fn(this._pkgPath);
252
+ return results;
253
+ }
254
+ _debug(msg) {
255
+ this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
256
+ }
257
+ }
258
258
  //# sourceMappingURL=SdCliServerBuilder.js.map
@@ -1,17 +1,17 @@
1
- /// <reference types="node" />
2
- import { ISdCliBuilderResult, ISdCliConfig } from "../commons";
3
- import { EventEmitter } from "events";
4
- export declare class SdCliTsLibBuilder extends EventEmitter {
5
- private readonly _projConf;
6
- private readonly _pkgPath;
7
- private readonly _logger;
8
- private readonly _pkgConf;
9
- private _builder?;
10
- constructor(_projConf: ISdCliConfig, _pkgPath: string);
11
- on(event: "change", listener: () => void): this;
12
- on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
13
- buildAsync(): Promise<ISdCliBuilderResult>;
14
- watchAsync(): Promise<void>;
15
- private _runAsync;
16
- private _debug;
17
- }
1
+ /// <reference types="node" />
2
+ import { ISdCliBuilderResult, ISdCliConfig } from "../commons";
3
+ import { EventEmitter } from "events";
4
+ export declare class SdCliTsLibBuilder extends EventEmitter {
5
+ private readonly _projConf;
6
+ private readonly _pkgPath;
7
+ private readonly _logger;
8
+ private readonly _pkgConf;
9
+ private _builder?;
10
+ constructor(_projConf: ISdCliConfig, _pkgPath: string);
11
+ on(event: "change", listener: () => void): this;
12
+ on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
13
+ buildAsync(): Promise<ISdCliBuilderResult>;
14
+ watchAsync(): Promise<void>;
15
+ private _runAsync;
16
+ private _debug;
17
+ }
@@ -1,80 +1,80 @@
1
- import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
2
- import path from "path";
3
- import { EventEmitter } from "events";
4
- import { SdTsCompiler } from "../build-tools/SdTsCompiler";
5
- import { SdLinter } from "../build-tools/SdLinter";
6
- import { FunctionQueue } from "@simplysm/sd-core-common";
7
- import { SdCliIndexFileGenerator } from "../build-tools/SdCliIndexFileGenerator";
8
- export class SdCliTsLibBuilder extends EventEmitter {
9
- constructor(_projConf, _pkgPath) {
10
- super();
11
- this._projConf = _projConf;
12
- this._pkgPath = _pkgPath;
13
- this._logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
14
- this._pkgConf = this._projConf.packages[path.basename(_pkgPath)];
15
- }
16
- on(event, listener) {
17
- super.on(event, listener);
18
- return this;
19
- }
20
- async buildAsync() {
21
- this._debug("dist 초기화...");
22
- await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
23
- if (!this._pkgConf.noGenIndex) {
24
- this._debug("GEN index.ts...");
25
- await SdCliIndexFileGenerator.runAsync(this._pkgPath, this._pkgConf.polyfills);
26
- }
27
- return await this._runAsync();
28
- }
29
- async watchAsync() {
30
- this.emit("change");
31
- this._debug("dist 초기화...");
32
- await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
33
- if (!this._pkgConf.noGenIndex) {
34
- this._debug("WATCH GEN index.ts...");
35
- await SdCliIndexFileGenerator.watchAsync(this._pkgPath, this._pkgConf.polyfills);
36
- }
37
- const result = await this._runAsync();
38
- this.emit("complete", result);
39
- this._debug("WATCH...");
40
- const fnQ = new FunctionQueue();
41
- const watcher = SdFsWatcher
42
- .watch(result.watchFilePaths)
43
- .onChange({ delay: 100, }, (changeInfos) => {
44
- this._builder.markChanges(changeInfos.map((item) => item.path));
45
- fnQ.runLast(async () => {
46
- this.emit("change");
47
- const watchResult = await this._runAsync();
48
- this.emit("complete", watchResult);
49
- watcher.add(watchResult.watchFilePaths);
50
- });
51
- });
52
- }
53
- async _runAsync() {
54
- this._debug(`BUILD 준비...`);
55
- this._builder = this._builder ?? new SdTsCompiler({
56
- pkgPath: this._pkgPath,
57
- emit: true,
58
- emitDts: true,
59
- globalStyle: true
60
- });
61
- this._debug(`BUILD && CHECK...`);
62
- const buildAndCheckResult = await this._builder.buildAsync();
63
- this._debug("LINT...");
64
- const lintResults = await SdLinter.lintAsync(buildAndCheckResult.affectedFilePaths, this._builder.program);
65
- this._debug(`빌드 완료`);
66
- const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
67
- .mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)));
68
- const watchFilePaths = buildAndCheckResult.filePaths.filter(item => PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
69
- localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)));
70
- return {
71
- watchFilePaths,
72
- affectedFilePaths: buildAndCheckResult.affectedFilePaths,
73
- buildResults: [...buildAndCheckResult.results, ...lintResults]
74
- };
75
- }
76
- _debug(msg) {
77
- this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
78
- }
79
- }
1
+ import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
2
+ import path from "path";
3
+ import { EventEmitter } from "events";
4
+ import { SdTsCompiler } from "../build-tools/SdTsCompiler";
5
+ import { SdLinter } from "../build-tools/SdLinter";
6
+ import { FunctionQueue } from "@simplysm/sd-core-common";
7
+ import { SdCliIndexFileGenerator } from "../build-tools/SdCliIndexFileGenerator";
8
+ export class SdCliTsLibBuilder extends EventEmitter {
9
+ constructor(_projConf, _pkgPath) {
10
+ super();
11
+ this._projConf = _projConf;
12
+ this._pkgPath = _pkgPath;
13
+ this._logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
14
+ this._pkgConf = this._projConf.packages[path.basename(_pkgPath)];
15
+ }
16
+ on(event, listener) {
17
+ super.on(event, listener);
18
+ return this;
19
+ }
20
+ async buildAsync() {
21
+ this._debug("dist 초기화...");
22
+ await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
23
+ if (!this._pkgConf.noGenIndex) {
24
+ this._debug("GEN index.ts...");
25
+ await SdCliIndexFileGenerator.runAsync(this._pkgPath, this._pkgConf.polyfills);
26
+ }
27
+ return await this._runAsync();
28
+ }
29
+ async watchAsync() {
30
+ this.emit("change");
31
+ this._debug("dist 초기화...");
32
+ await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
33
+ if (!this._pkgConf.noGenIndex) {
34
+ this._debug("WATCH GEN index.ts...");
35
+ await SdCliIndexFileGenerator.watchAsync(this._pkgPath, this._pkgConf.polyfills);
36
+ }
37
+ const result = await this._runAsync();
38
+ this.emit("complete", result);
39
+ this._debug("WATCH...");
40
+ const fnQ = new FunctionQueue();
41
+ const watcher = SdFsWatcher
42
+ .watch(result.watchFilePaths)
43
+ .onChange({ delay: 100, }, (changeInfos) => {
44
+ this._builder.markChanges(changeInfos.map((item) => item.path));
45
+ fnQ.runLast(async () => {
46
+ this.emit("change");
47
+ const watchResult = await this._runAsync();
48
+ this.emit("complete", watchResult);
49
+ watcher.add(watchResult.watchFilePaths);
50
+ });
51
+ });
52
+ }
53
+ async _runAsync() {
54
+ this._debug(`BUILD 준비...`);
55
+ this._builder = this._builder ?? new SdTsCompiler({
56
+ pkgPath: this._pkgPath,
57
+ emit: true,
58
+ emitDts: true,
59
+ globalStyle: true
60
+ });
61
+ this._debug(`BUILD && CHECK...`);
62
+ const buildAndCheckResult = await this._builder.buildAsync();
63
+ this._debug("LINT...");
64
+ const lintResults = await SdLinter.lintAsync(buildAndCheckResult.affectedFilePaths, this._builder.program);
65
+ this._debug(`빌드 완료`);
66
+ const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
67
+ .mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)));
68
+ const watchFilePaths = buildAndCheckResult.filePaths.filter(item => PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
69
+ localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)));
70
+ return {
71
+ watchFilePaths,
72
+ affectedFilePaths: buildAndCheckResult.affectedFilePaths,
73
+ buildResults: [...buildAndCheckResult.results, ...lintResults]
74
+ };
75
+ }
76
+ _debug(msg) {
77
+ this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
78
+ }
79
+ }
80
80
  //# sourceMappingURL=SdCliTsLibBuilder.js.map