@simplysm/sd-cli 7.0.247 → 7.0.263

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 (110) hide show
  1. package/README.md +48 -0
  2. package/dist/bin/sd-cli.mjs +171 -13
  3. package/dist/build-tool/SdCliElectron.mjs +3 -2
  4. package/dist/builder/SdCliClientBuilder.mjs +33 -35
  5. package/dist/builder/SdCliServerBuilder.d.ts +1 -0
  6. package/dist/builder/SdCliServerBuilder.mjs +58 -22
  7. package/dist/builder/SdCliTsLibBuilder.mjs +18 -12
  8. package/dist/commons.d.ts +9 -1
  9. package/dist/entry-points/SdCliProjectGenerator.d.ts +37 -0
  10. package/dist/entry-points/SdCliProjectGenerator.mjs +288 -0
  11. package/dist/entry-points/SdCliWorkspace.d.ts +6 -3
  12. package/dist/entry-points/SdCliWorkspace.mjs +147 -120
  13. package/dist/entry-points/file/base/fc_package_eslintrc.d.ts +3 -0
  14. package/dist/entry-points/file/base/fc_package_eslintrc.mjs +31 -0
  15. package/dist/entry-points/file/base/fc_package_npmconfig.d.ts +9 -0
  16. package/dist/entry-points/file/base/fc_package_npmconfig.mjs +32 -0
  17. package/dist/entry-points/file/base/fc_package_tsconfig.d.ts +4 -0
  18. package/dist/entry-points/file/base/fc_package_tsconfig.mjs +12 -0
  19. package/dist/entry-points/file/client/fc_package_AppModule.d.ts +1 -0
  20. package/dist/entry-points/file/client/fc_package_AppModule.mjs +37 -0
  21. package/dist/entry-points/file/client/fc_package_AppPage.d.ts +1 -0
  22. package/dist/entry-points/file/client/fc_package_AppPage.mjs +34 -0
  23. package/dist/entry-points/file/client/fc_package_appicons.d.ts +1 -0
  24. package/dist/entry-points/file/client/fc_package_appicons.mjs +6 -0
  25. package/dist/entry-points/file/client/fc_package_client_main.d.ts +1 -0
  26. package/dist/entry-points/file/client/fc_package_client_main.mjs +19 -0
  27. package/dist/entry-points/file/client/fc_package_index.d.ts +3 -0
  28. package/dist/entry-points/file/client/fc_package_index.mjs +88 -0
  29. package/dist/entry-points/file/client/fc_package_manifest.d.ts +5 -0
  30. package/dist/entry-points/file/client/fc_package_manifest.mjs +54 -0
  31. package/dist/entry-points/file/client/fc_package_polyfills.d.ts +1 -0
  32. package/dist/entry-points/file/client/fc_package_polyfills.mjs +11 -0
  33. package/dist/entry-points/file/client/fc_package_styles.d.ts +1 -0
  34. package/dist/entry-points/file/client/fc_package_styles.mjs +7 -0
  35. package/dist/entry-points/file/db/fc_package_DbContext.d.ts +3 -0
  36. package/dist/entry-points/file/db/fc_package_DbContext.mjs +14 -0
  37. package/dist/entry-points/file/db/fc_package_DbModel.d.ts +4 -0
  38. package/dist/entry-points/file/db/fc_package_DbModel.mjs +12 -0
  39. package/dist/entry-points/file/project/fc_project_editor_config.d.ts +1 -0
  40. package/dist/entry-points/file/project/fc_project_editor_config.mjs +22 -0
  41. package/dist/entry-points/file/project/fc_project_eslintrc.d.ts +1 -0
  42. package/dist/entry-points/file/project/fc_project_eslintrc.mjs +30 -0
  43. package/dist/entry-points/file/project/fc_project_gitattributes.d.ts +1 -0
  44. package/dist/entry-points/file/project/fc_project_gitattributes.mjs +6 -0
  45. package/dist/entry-points/file/project/fc_project_gitignore.d.ts +1 -0
  46. package/dist/entry-points/file/project/fc_project_gitignore.mjs +17 -0
  47. package/dist/entry-points/file/project/fc_project_npmconfig.d.ts +7 -0
  48. package/dist/entry-points/file/project/fc_project_npmconfig.mjs +35 -0
  49. package/dist/entry-points/file/project/fc_project_readme.d.ts +3 -0
  50. package/dist/entry-points/file/project/fc_project_readme.mjs +12 -0
  51. package/dist/entry-points/file/project/fc_project_simplysm.d.ts +1 -0
  52. package/dist/entry-points/file/project/fc_project_simplysm.mjs +2 -0
  53. package/dist/entry-points/file/project/fc_project_tsconfig.d.ts +1 -0
  54. package/dist/entry-points/file/project/fc_project_tsconfig.mjs +26 -0
  55. package/dist/entry-points/file/server/fc_package_server_main.d.ts +4 -0
  56. package/dist/entry-points/file/server/fc_package_server_main.mjs +60 -0
  57. package/dist/index.d.ts +23 -0
  58. package/dist/index.mjs +24 -1
  59. package/dist/packages/SdCliPackage.d.ts +1 -0
  60. package/dist/packages/SdCliPackage.mjs +68 -62
  61. package/dist/utils/SdCliBuildResultUtil.mjs +2 -2
  62. package/dist/worker/server-worker.d.ts +1 -0
  63. package/dist/worker/server-worker.mjs +67 -0
  64. package/package.json +10 -8
  65. package/src/bin/sd-cli.ts +198 -12
  66. package/src/build-tool/SdCliElectron.ts +2 -1
  67. package/src/builder/SdCliClientBuilder.ts +36 -36
  68. package/src/builder/SdCliJsLibBuilder.ts +70 -70
  69. package/src/builder/SdCliServerBuilder.ts +58 -20
  70. package/src/builder/SdCliTsLibBuilder.ts +450 -445
  71. package/src/commons.ts +7 -1
  72. package/src/entry-points/SdCliProjectGenerator.ts +353 -0
  73. package/src/entry-points/SdCliWorkspace.ts +171 -137
  74. package/src/entry-points/file/assets/assets/icons/icon-128x128.png +0 -0
  75. package/src/entry-points/file/assets/assets/icons/icon-144x144.png +0 -0
  76. package/src/entry-points/file/assets/assets/icons/icon-152x152.png +0 -0
  77. package/src/entry-points/file/assets/assets/icons/icon-192x192.png +0 -0
  78. package/src/entry-points/file/assets/assets/icons/icon-384x384.png +0 -0
  79. package/src/entry-points/file/assets/assets/icons/icon-512x512.png +0 -0
  80. package/src/entry-points/file/assets/assets/icons/icon-72x72.png +0 -0
  81. package/src/entry-points/file/assets/assets/icons/icon-96x96.png +0 -0
  82. package/src/entry-points/file/assets/favicon.ico +0 -0
  83. package/src/entry-points/file/base/fc_package_eslintrc.ts +30 -0
  84. package/src/entry-points/file/base/fc_package_npmconfig.ts +43 -0
  85. package/src/entry-points/file/base/fc_package_tsconfig.ts +11 -0
  86. package/src/entry-points/file/client/fc_package_AppModule.ts +36 -0
  87. package/src/entry-points/file/client/fc_package_AppPage.ts +33 -0
  88. package/src/entry-points/file/client/fc_package_appicons.ts +5 -0
  89. package/src/entry-points/file/client/fc_package_client_main.ts +18 -0
  90. package/src/entry-points/file/client/fc_package_index.ts +87 -0
  91. package/src/entry-points/file/client/fc_package_manifest.ts +53 -0
  92. package/src/entry-points/file/client/fc_package_polyfills.ts +10 -0
  93. package/src/entry-points/file/client/fc_package_styles.ts +6 -0
  94. package/src/entry-points/file/db/fc_package_DbContext.ts +14 -0
  95. package/src/entry-points/file/db/fc_package_DbModel.ts +11 -0
  96. package/src/entry-points/file/project/fc_project_editor_config.ts +21 -0
  97. package/src/entry-points/file/project/fc_project_eslintrc.ts +29 -0
  98. package/src/entry-points/file/project/fc_project_gitattributes.ts +5 -0
  99. package/src/entry-points/file/project/fc_project_gitignore.ts +16 -0
  100. package/src/entry-points/file/project/fc_project_npmconfig.ts +34 -0
  101. package/src/entry-points/file/project/fc_project_readme.ts +11 -0
  102. package/src/entry-points/file/project/fc_project_simplysm.ts +1 -0
  103. package/src/entry-points/file/project/fc_project_tsconfig.ts +25 -0
  104. package/src/entry-points/file/server/fc_package_server_main.ts +62 -0
  105. package/src/index.ts +23 -0
  106. package/src/packages/SdCliPackage.ts +75 -58
  107. package/src/utils/SdCliBuildResultUtil.ts +76 -76
  108. package/src/worker/server-worker.ts +72 -0
  109. package/tsconfig-build.json +2 -1
  110. package/tsconfig.json +2 -1
package/src/bin/sd-cli.ts CHANGED
@@ -10,11 +10,11 @@ import { SdCliPrepare } from "../entry-points/SdCliPrepare";
10
10
  import { SdCliFileCrypto } from "../entry-points/SdCliFileCrypto";
11
11
  import { SdCliCordova } from "../build-tool/SdCliCordova";
12
12
  import { SdCliElectron } from "../build-tool/SdCliElectron";
13
+ import { SdCliProjectGenerator } from "../entry-points/SdCliProjectGenerator";
13
14
 
14
15
  Error.stackTraceLimit = Infinity;
15
16
 
16
17
  const argv = yargs(hideBin(process.argv))
17
- .version(false)
18
18
  .help("help", "도움말")
19
19
  .alias("help", "h")
20
20
  .options({
@@ -27,17 +27,17 @@ const argv = yargs(hideBin(process.argv))
27
27
  .command(
28
28
  "prepare",
29
29
  "sd-cli 준비",
30
- (cmd) => cmd.version(false)
30
+ (cmd) => cmd.version(false).hide("help").hide("debug")
31
31
  )
32
32
  .command(
33
33
  "update",
34
34
  "패키지 업데이트 (npm update)",
35
- (cmd) => cmd.version(false)
35
+ (cmd) => cmd.version(false).hide("help").hide("debug")
36
36
  )
37
37
  .command(
38
38
  "local-update",
39
39
  "로컬 라이브러리 업데이트를 수행합니다.",
40
- (cmd) => cmd.version(false)
40
+ (cmd) => cmd.version(false).hide("help").hide("debug")
41
41
  .options({
42
42
  config: {
43
43
  type: "string",
@@ -48,7 +48,7 @@ const argv = yargs(hideBin(process.argv))
48
48
  .command(
49
49
  "watch",
50
50
  "프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.",
51
- (cmd) => cmd.version(false)
51
+ (cmd) => cmd.version(false).hide("help").hide("debug")
52
52
  .options({
53
53
  config: {
54
54
  type: "string",
@@ -93,7 +93,7 @@ const argv = yargs(hideBin(process.argv))
93
93
  })
94
94
  )
95
95
  .command(
96
- "run-cordova <platform> <package> [url]",
96
+ "run-cordova <platform> <package> <url>",
97
97
  "변경감지중인 플랫폼을 코도바 디바이스에 앱 형태로 띄웁니다.",
98
98
  (cmd) => cmd
99
99
  .positional("platform", {
@@ -115,7 +115,7 @@ const argv = yargs(hideBin(process.argv))
115
115
  .command(
116
116
  "build",
117
117
  "프로젝트의 각 패키지에 대한 빌드를 수행합니다.",
118
- (cmd) => cmd.version(false)
118
+ (cmd) => cmd.version(false).hide("help").hide("debug")
119
119
  .options({
120
120
  config: {
121
121
  type: "string",
@@ -136,7 +136,7 @@ const argv = yargs(hideBin(process.argv))
136
136
  .command(
137
137
  "publish",
138
138
  "프로젝트의 각 패키지를 배포합니다.",
139
- (cmd) => cmd.version(false)
139
+ (cmd) => cmd.version(false).hide("help").hide("debug")
140
140
  .options({
141
141
  noBuild: {
142
142
  type: "boolean",
@@ -162,20 +162,160 @@ const argv = yargs(hideBin(process.argv))
162
162
  .command(
163
163
  "enc-file <file>",
164
164
  "파일을 암호화 합니다.",
165
- (cmd) => cmd.version(false)
165
+ (cmd) => cmd.version(false).hide("help").hide("debug")
166
166
  .positional("file", {
167
167
  type: "string",
168
- describe: "암호화할 파일명"
168
+ describe: "암호화할 파일명",
169
+ demandOption: true
169
170
  })
170
171
  )
171
172
  .command(
172
173
  "dec-file <file>",
173
174
  "파일을 복호화 합니다.",
174
- (cmd) => cmd.version(false)
175
+ (cmd) => cmd.version(false).hide("help").hide("debug")
175
176
  .positional("file", {
176
177
  type: "string",
177
- describe: "암호화된 파일명"
178
+ describe: "암호화된 파일명",
179
+ demandOption: true
180
+ })
181
+ )
182
+ .command(
183
+ "init [name] <description> <author> <gitUrl>",
184
+ "프로젝트를 초기화 합니다.",
185
+ (cmd) => cmd.version(false).hide("help").hide("debug")
186
+ .positional("name", {
187
+ type: "string",
188
+ describe: "프로젝트 영문명 (기본값: 최종폴더명)"
189
+ })
190
+ .positional("description", {
191
+ type: "string",
192
+ describe: "프로젝트 설명(=명칭)",
193
+ demandOption: true
194
+ })
195
+ .positional("author", {
196
+ type: "string",
197
+ describe: "작성자",
198
+ demandOption: true
199
+ })
200
+ .positional("gitUrl", {
201
+ type: "string",
202
+ describe: "소스코드 관리를 위한 GIT 레파지토리 URL",
203
+ demandOption: true
178
204
  })
205
+ .example([
206
+ ["$0 init sample 샘플프로젝트 홍길동 https://github.com/my/sample.git"]
207
+ ])
208
+ )
209
+ .command(
210
+ "add",
211
+ "프로젝트에 패키지/기능등을 추가합니다.",
212
+ (cmd) => cmd.version(false).hide("help").hide("debug")
213
+ .command(
214
+ "ts-lib <name> <description>",
215
+ "타입스트립트 라이브러리 패키지를 추가합니다.",
216
+ (cmd1) => cmd1.version(false).hide("help").hide("debug")
217
+ .positional("name", {
218
+ type: "string",
219
+ describe: "패키지명",
220
+ demandOption: true
221
+ })
222
+ .positional("description", {
223
+ type: "string",
224
+ describe: "패키지설명",
225
+ demandOption: true
226
+ })
227
+ .options({
228
+ useDom: {
229
+ type: "boolean",
230
+ describe: "DOM객체(window, document 등) 사용 여부",
231
+ default: false
232
+ }
233
+ })
234
+ .example([
235
+ ["$0 add ts-lib common 공통모듈"],
236
+ ["$0 sd-cli add ts-lib client-common \"클라이언트 공통\" --useDom"]
237
+ ])
238
+ )
239
+ .command(
240
+ "db-lib <name>",
241
+ "DB 라이브러리 패키지를 추가합니다.",
242
+ (cmd1) => cmd1.version(false).hide("help").hide("debug")
243
+ .positional("name", {
244
+ type: "string",
245
+ describe: "패키지명",
246
+ demandOption: true
247
+ })
248
+ .example([
249
+ ["$0 add db-lib main"]
250
+ ])
251
+ )
252
+ .command(
253
+ "db-model <dbName> <category> <name> <description>",
254
+ "DB 패키지에 모델를 추가합니다.",
255
+ (cmd1) => cmd1.version(false).hide("help").hide("debug")
256
+ .positional("dbName", {
257
+ type: "string",
258
+ describe: "DB 패키지 영문명 = 'DbContext'명칭",
259
+ demandOption: true
260
+ })
261
+ .positional("category", {
262
+ type: "string",
263
+ describe: "추가할 모델의 분류명",
264
+ demandOption: true
265
+ })
266
+ .positional("name", {
267
+ type: "string",
268
+ describe: "추가할 모델의 명칭 (테이블명)",
269
+ demandOption: true
270
+ })
271
+ .positional("description", {
272
+ type: "string",
273
+ describe: "추가할 모델의 설명 (테이블 설명)",
274
+ demandOption: true
275
+ })
276
+ .example([
277
+ ["$0 add db-model main base Employee 직원"]
278
+ ])
279
+ )
280
+ .command(
281
+ "server [name] [description]",
282
+ "서버 패키지를 추가합니다.",
283
+ (cmd1) => cmd1.version(false).hide("help").hide("debug")
284
+ .positional("name", {
285
+ type: "string",
286
+ describe: "패키지명"
287
+ })
288
+ .positional("description", {
289
+ type: "string",
290
+ describe: "패키지 설명"
291
+ })
292
+ .example([
293
+ ["$0 add server"]
294
+ ])
295
+ )
296
+ .command(
297
+ "client <name> <description> <serverName>",
298
+ "클라이언트 패키지를 추가합니다.",
299
+ (cmd1) => cmd1.version(false).hide("help").hide("debug")
300
+ .positional("name", {
301
+ type: "string",
302
+ describe: "패키지명",
303
+ demandOption: true
304
+ })
305
+ .positional("description", {
306
+ type: "string",
307
+ describe: "패키지 설명",
308
+ demandOption: true
309
+ })
310
+ .positional("serverName", {
311
+ type: "string",
312
+ describe: "서버 패키지명",
313
+ demandOption: true
314
+ })
315
+ .example([
316
+ ["$0 add client admin 관리자 server"]
317
+ ])
318
+ )
179
319
  )
180
320
  .parseSync();
181
321
 
@@ -265,6 +405,52 @@ const logger = Logger.get(["simplysm", "sd-cli", "bin", "sd-cli"]);
265
405
  else if (argv._[0] === "dec-file") {
266
406
  await new SdCliFileCrypto().decryptAsync(argv.file!);
267
407
  }
408
+ else if (argv._[0] === "init") {
409
+ await new SdCliProjectGenerator(process.cwd()).initAsync({
410
+ name: argv.name,
411
+ description: argv.description!,
412
+ author: argv.author,
413
+ gitUrl: argv.gitUrl
414
+ });
415
+ }
416
+ else if (argv._[0] === "add") {
417
+ if (argv._[1] === "ts-lib") {
418
+ await new SdCliProjectGenerator(process.cwd()).addTsLibAsync({
419
+ name: argv.name!,
420
+ description: argv.description!,
421
+ useDom: argv.useDom
422
+ });
423
+ }
424
+ else if (argv._[1] === "db-lib") {
425
+ await new SdCliProjectGenerator(process.cwd()).addDbLibAsync({
426
+ name: argv.name!
427
+ });
428
+ }
429
+ else if (argv._[1] === "db-model") {
430
+ await new SdCliProjectGenerator(process.cwd()).addDbLibModelAsync({
431
+ dbPkgName: argv.dbName,
432
+ category: argv.category,
433
+ name: argv.name!,
434
+ description: argv.description!
435
+ });
436
+ }
437
+ else if (argv._[1] === "server") {
438
+ await new SdCliProjectGenerator(process.cwd()).addServerAsync({
439
+ name: argv.name,
440
+ description: argv.description
441
+ });
442
+ }
443
+ else if (argv._[1] === "client") {
444
+ await new SdCliProjectGenerator(process.cwd()).addClientAsync({
445
+ name: argv.name!,
446
+ description: argv.description!,
447
+ serverName: argv.serverName
448
+ });
449
+ }
450
+ else {
451
+ throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[1]}\n`);
452
+ }
453
+ }
268
454
  else {
269
455
  throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
270
456
  }
@@ -68,7 +68,8 @@ export class SdCliElectron {
68
68
  `SD_VERSION=${npmConfig.version}`,
69
69
  `SD_ELECTRON_DEV_URL=${url.replace(/\/$/, "")}/${pkgName}/electron/`,
70
70
  (electronConfig.icon !== undefined) ? `SD_ELECTRON_ICON=${electronConfig.icon}` : `SD_ELECTRON_ICON=favicon.ico`,
71
- ...(pkgConfig.env !== undefined) ? Object.keys(pkgConfig.env).map((key) => `${key}=${pkgConfig.env![key]}`) : []
71
+ ...(pkgConfig.env !== undefined) ? Object.keys(pkgConfig.env).map((key) => `${key}=${pkgConfig.env![key]}`) : [],
72
+ ...(electronConfig.env !== undefined) ? Object.keys(electronConfig.env).map((key) => `${key}=${electronConfig.env![key]}`) : [],
72
73
  ].filterExists().join("\n"));
73
74
 
74
75
  let electronTsFileContent = await FsUtil.readFileAsync(path.resolve(pkgRootPath, `src/electron.ts`));
@@ -30,9 +30,9 @@ import { SdCliNgModuleGenerator } from "../ng-tools/SdCliNgModuleGenerator";
30
30
  import { SdCliCordova } from "../build-tool/SdCliCordova";
31
31
  import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
32
32
  import electronBuilder from "electron-builder";
33
- import LintResult = ESLint.LintResult;
34
33
  import { fileURLToPath } from "url";
35
34
  import { Entrypoint } from "@angular-devkit/build-angular/src/utils/index-file/augment-index-html";
35
+ import LintResult = ESLint.LintResult;
36
36
 
37
37
  export class SdCliClientBuilder extends EventEmitter {
38
38
  private readonly _logger: Logger;
@@ -111,11 +111,15 @@ export class SdCliClientBuilder extends EventEmitter {
111
111
  .map((builderType) => this._getWebpackConfig(true, builderType));
112
112
  const multiCompiler = webpack(webpackConfigs);
113
113
  await new Promise<void>((resolve, reject) => {
114
+ const invalidFiles: string[] = [];
114
115
  multiCompiler.hooks.invalid.tap(this.constructor.name, (fileName) => {
115
116
  if (fileName != null) {
116
117
  this._logger.debug("파일변경 감지", fileName);
118
+
117
119
  // NgModule 캐시 삭제
118
120
  this._ngModuleGenerator.removeCaches([path.resolve(fileName)]);
121
+
122
+ invalidFiles.push(fileName);
119
123
  }
120
124
  });
121
125
 
@@ -144,9 +148,6 @@ export class SdCliClientBuilder extends EventEmitter {
144
148
  return;
145
149
  }
146
150
 
147
- // 결과 반환
148
- const results = multiStats.stats.mapMany((stats) => SdCliBuildResultUtil.convertFromWebpackStats(stats));
149
-
150
151
  // .config.json 파일 쓰기
151
152
  const npmConfig = this._getNpmConfig(this._rootPath)!;
152
153
  const packageKey = npmConfig.name.split("/").last()!;
@@ -156,11 +157,14 @@ export class SdCliClientBuilder extends EventEmitter {
156
157
  : path.resolve(this._parsedTsconfig.options.outDir!, ".config.json");
157
158
  await FsUtil.writeFileAsync(configDistPath, JSON.stringify(this._config.configs ?? {}, undefined, 2));
158
159
 
159
- // 마무리
160
+ // 완료 로그
160
161
  this._logger.debug("Webpack 빌드 완료");
161
- resolve();
162
162
 
163
+ // 결과 반환
164
+ const results = multiStats.stats.mapMany((stats) => SdCliBuildResultUtil.convertFromWebpackStats(stats));
163
165
  this.emit("complete", results);
166
+
167
+ resolve();
164
168
  });
165
169
  });
166
170
  }
@@ -264,7 +268,8 @@ export class SdCliClientBuilder extends EventEmitter {
264
268
  "NODE_ENV=production",
265
269
  `SD_VERSION=${npmConfig.version}`,
266
270
  (this._config.builder.electron.icon !== undefined) ? `SD_ELECTRON_ICON=${this._config.builder.electron.icon}` : `SD_ELECTRON_ICON=favicon.ico`,
267
- ...(this._config.env !== undefined) ? Object.keys(this._config.env).map((key) => `${key}=${this._config.env![key]}`) : []
271
+ ...(this._config.env !== undefined) ? Object.keys(this._config.env).map((key) => `${key}=${this._config.env![key]}`) : [],
272
+ ...(this._config.builder.electron.env !== undefined) ? Object.keys(this._config.builder.electron.env).map((key) => `${key}=${this._config.builder!.electron!.env![key]}`) : []
268
273
  ].filterExists().join("\n"));
269
274
 
270
275
  let electronTsFileContent = await FsUtil.readFileAsync(path.resolve(this._rootPath, `src/electron.ts`));
@@ -392,24 +397,22 @@ export class SdCliClientBuilder extends EventEmitter {
392
397
  experiments: { backCompat: false, syncWebAssembly: true, asyncWebAssembly: true },
393
398
  infrastructureLogging: { level: "error" },
394
399
  stats: "errors-warnings",
395
- ...watch ? {
396
- cache: {
397
- type: "filesystem",
398
- profile: undefined,
399
- cacheDirectory: path.resolve(cacheBasePath, "angular-webpack"),
400
- maxMemoryGenerations: 1,
401
- name: createHash("sha1")
402
- .update(workspacePkgLockContent)
403
- .update(JSON.stringify(this._parsedTsconfig.options))
404
- .update(JSON.stringify(this._config))
405
- .update(watch.toString())
406
- .digest("hex")
407
- },
408
- snapshot: {
409
- immutablePaths: internalModuleCachePaths,
410
- managedPaths: internalModuleCachePaths
411
- }
412
- } : {},
400
+ cache: {
401
+ type: "filesystem",
402
+ profile: undefined,
403
+ cacheDirectory: path.resolve(cacheBasePath, "angular-webpack"),
404
+ maxMemoryGenerations: 1,
405
+ name: createHash("sha1")
406
+ .update(workspacePkgLockContent)
407
+ .update(JSON.stringify(this._parsedTsconfig.options))
408
+ .update(JSON.stringify(this._config))
409
+ .update(watch.toString())
410
+ .digest("hex")
411
+ },
412
+ snapshot: {
413
+ immutablePaths: internalModuleCachePaths,
414
+ managedPaths: internalModuleCachePaths
415
+ },
413
416
  node: false,
414
417
  optimization: {
415
418
  minimizer: watch ? [] : [
@@ -484,9 +487,7 @@ export class SdCliClientBuilder extends EventEmitter {
484
487
  {
485
488
  loader: "@angular-devkit/build-angular/src/babel/webpack-loader",
486
489
  options: {
487
- ...watch ? {
488
- cacheDirectory: path.resolve(cacheBasePath, "babel-webpack"),
489
- } : {},
490
+ cacheDirectory: path.resolve(cacheBasePath, "babel-webpack"),
490
491
  scriptTarget: ts.ScriptTarget.ES2017,
491
492
  aot: true,
492
493
  optimize: !watch,
@@ -691,13 +692,11 @@ export class SdCliClientBuilder extends EventEmitter {
691
692
  ],
692
693
  deployUrl: undefined,
693
694
  sri: false,
694
- ...watch ? {
695
- cache: {
696
- enabled: true,
697
- basePath: cacheBasePath,
698
- path: path.resolve(cacheBasePath, "index-webpack")
699
- }
700
- } : {},
695
+ cache: {
696
+ enabled: true,
697
+ basePath: cacheBasePath,
698
+ path: path.resolve(cacheBasePath, "index-webpack")
699
+ },
701
700
  postTransform: undefined,
702
701
  optimization: {
703
702
  scripts: !watch,
@@ -709,7 +708,8 @@ export class SdCliClientBuilder extends EventEmitter {
709
708
  }),
710
709
  new webpack.EnvironmentPlugin({
711
710
  SD_VERSION: this._getNpmConfig(this._rootPath)!.version,
712
- ...this._config.env
711
+ ...this._config.env,
712
+ ...this._config.builder?.[builderType]?.env
713
713
  }),
714
714
  new ESLintWebpackPlugin({
715
715
  context: this._rootPath,
@@ -1,70 +1,70 @@
1
- import { ISdCliPackageBuildResult } from "../commons";
2
- import { EventEmitter } from "events";
3
- import { FsUtil, Logger, SdFsWatcher } from "@simplysm/sd-core-node";
4
- import path from "path";
5
- import { SdCliPackageLinter } from "../build-tool/SdCliPackageLinter";
6
-
7
- export class SdCliJsLibBuilder extends EventEmitter {
8
- private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
9
-
10
- private readonly _linter: SdCliPackageLinter;
11
-
12
- public constructor(private readonly _rootPath: string) {
13
- super();
14
- this._linter = new SdCliPackageLinter(this._rootPath);
15
- }
16
-
17
- public override on(event: "change", listener: () => void): this;
18
- public override on(event: "complete", listener: (results: ISdCliPackageBuildResult[]) => void): this;
19
- public override on(event: string | symbol, listener: (...args: any[]) => void): this {
20
- return super.on(event, listener);
21
- }
22
-
23
- public async watchAsync(): Promise<void> {
24
- this.emit("change");
25
-
26
- const relatedPaths = await this.getRelatedPathsAsync();
27
- const watcher = SdFsWatcher.watch(relatedPaths);
28
- watcher.onChange({}, async (changedInfos) => {
29
- const changeFilePaths = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
30
- if (changeFilePaths.length === 0) return;
31
-
32
- this._logger.debug("파일 변경 감지");
33
- this.emit("change");
34
- const watchBuildResults: ISdCliPackageBuildResult[] = [];
35
-
36
- const lintFilePaths = changedInfos.filter((item) => ["add", "change"].includes(item.event)).map((item) => item.path);
37
- if (lintFilePaths.length > 0) {
38
- watchBuildResults.push(...await this._linter.lintAsync(lintFilePaths));
39
- }
40
-
41
- const watchRelatedPaths = await this.getRelatedPathsAsync();
42
- watcher.add(watchRelatedPaths);
43
-
44
- this.emit("complete", watchBuildResults);
45
- });
46
-
47
- // 빌드
48
- const buildResults = await this._linter.lintAsync(relatedPaths);
49
-
50
- this.emit("complete", buildResults);
51
- }
52
-
53
- public async buildAsync(): Promise<ISdCliPackageBuildResult[]> {
54
- const relatedPaths = await this.getRelatedPathsAsync();
55
- return await this._linter.lintAsync(relatedPaths);
56
- }
57
-
58
- private async getRelatedPathsAsync(): Promise<string[]> {
59
- const mySourceGlobPath = path.resolve(this._rootPath, "**", "+(*.js|*.cjs|*.mjs)");
60
- const mySourceFilePaths = await FsUtil.globAsync(mySourceGlobPath, {
61
- ignore: [
62
- "**/node_modules/**",
63
- "**/dist/**",
64
- "**/.*/**"
65
- ]
66
- });
67
-
68
- return [...mySourceFilePaths, path.resolve(this._rootPath, ".eslintrc.cjs")].distinct();
69
- }
70
- }
1
+ import { ISdCliPackageBuildResult } from "../commons";
2
+ import { EventEmitter } from "events";
3
+ import { FsUtil, Logger, SdFsWatcher } from "@simplysm/sd-core-node";
4
+ import path from "path";
5
+ import { SdCliPackageLinter } from "../build-tool/SdCliPackageLinter";
6
+
7
+ export class SdCliJsLibBuilder extends EventEmitter {
8
+ private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
9
+
10
+ private readonly _linter: SdCliPackageLinter;
11
+
12
+ public constructor(private readonly _rootPath: string) {
13
+ super();
14
+ this._linter = new SdCliPackageLinter(this._rootPath);
15
+ }
16
+
17
+ public override on(event: "change", listener: () => void): this;
18
+ public override on(event: "complete", listener: (results: ISdCliPackageBuildResult[]) => void): this;
19
+ public override on(event: string | symbol, listener: (...args: any[]) => void): this {
20
+ return super.on(event, listener);
21
+ }
22
+
23
+ public async watchAsync(): Promise<void> {
24
+ this.emit("change");
25
+
26
+ const relatedPaths = await this.getRelatedPathsAsync();
27
+ const watcher = SdFsWatcher.watch(relatedPaths);
28
+ watcher.onChange({}, async (changedInfos) => {
29
+ const changeFilePaths = changedInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
30
+ if (changeFilePaths.length === 0) return;
31
+
32
+ this._logger.debug("파일 변경 감지");
33
+ this.emit("change");
34
+ const watchBuildResults: ISdCliPackageBuildResult[] = [];
35
+
36
+ const lintFilePaths = changedInfos.filter((item) => ["add", "change"].includes(item.event)).map((item) => item.path);
37
+ if (lintFilePaths.length > 0) {
38
+ watchBuildResults.push(...await this._linter.lintAsync(lintFilePaths));
39
+ }
40
+
41
+ const watchRelatedPaths = await this.getRelatedPathsAsync();
42
+ watcher.add(watchRelatedPaths);
43
+
44
+ this.emit("complete", watchBuildResults);
45
+ });
46
+
47
+ // 빌드
48
+ const buildResults = await this._linter.lintAsync(relatedPaths);
49
+
50
+ this.emit("complete", buildResults);
51
+ }
52
+
53
+ public async buildAsync(): Promise<ISdCliPackageBuildResult[]> {
54
+ const relatedPaths = await this.getRelatedPathsAsync();
55
+ return await this._linter.lintAsync(relatedPaths);
56
+ }
57
+
58
+ private async getRelatedPathsAsync(): Promise<string[]> {
59
+ const mySourceGlobPath = path.resolve(this._rootPath, "**", "+(*.js|*.cjs|*.mjs)");
60
+ const mySourceFilePaths = await FsUtil.globAsync(mySourceGlobPath, {
61
+ ignore: [
62
+ "**/node_modules/**",
63
+ "**/dist/**",
64
+ "**/.*/**"
65
+ ]
66
+ });
67
+
68
+ return [...mySourceFilePaths, path.resolve(this._rootPath, ".eslintrc.cjs")].distinct();
69
+ }
70
+ }