@simplysm/sd-cli 10.0.65 → 11.0.3

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 (74) hide show
  1. package/dist/build-cluster.js +15 -14
  2. package/dist/build-cluster.js.map +1 -1
  3. package/dist/build-tools/SdTsIncrementalBuilder.d.ts +2 -0
  4. package/dist/build-tools/SdTsIncrementalBuilder.js +60 -9
  5. package/dist/build-tools/SdTsIncrementalBuilder.js.map +1 -1
  6. package/dist/builders/SdCliClientBuilder.d.ts +6 -7
  7. package/dist/builders/SdCliClientBuilder.js +281 -245
  8. package/dist/builders/SdCliClientBuilder.js.map +1 -1
  9. package/dist/builders/SdCliServerBuilder.d.ts +4 -3
  10. package/dist/builders/SdCliServerBuilder.js +3 -2
  11. package/dist/builders/SdCliServerBuilder.js.map +1 -1
  12. package/dist/builders/SdCliTsLibBuilder.d.ts +4 -4
  13. package/dist/builders/SdCliTsLibBuilder.js +9 -61
  14. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  15. package/dist/commons.d.ts +4 -5
  16. package/dist/entry/SdCliProject.js +13 -12
  17. package/dist/entry/SdCliProject.js.map +1 -1
  18. package/dist/index.d.ts +0 -10
  19. package/dist/index.js +0 -10
  20. package/dist/index.js.map +1 -1
  21. package/dist/sd-cli.js +0 -19
  22. package/dist/sd-cli.js.map +1 -1
  23. package/package.json +14 -18
  24. package/src/build-cluster.ts +15 -14
  25. package/src/build-tools/SdTsIncrementalBuilder.ts +92 -10
  26. package/src/builders/SdCliClientBuilder.ts +310 -285
  27. package/src/builders/SdCliServerBuilder.ts +12 -7
  28. package/src/builders/SdCliTsLibBuilder.ts +11 -80
  29. package/src/commons.ts +5 -5
  30. package/src/entry/SdCliElectron.ts +3 -3
  31. package/src/entry/SdCliLocalUpdate.ts +3 -3
  32. package/src/entry/SdCliProject.ts +20 -18
  33. package/src/index.ts +0 -10
  34. package/src/sd-cli.ts +0 -23
  35. package/dist/entry/SdCliPwaAssets.d.ts +0 -6
  36. package/dist/entry/SdCliPwaAssets.js +0 -39
  37. package/dist/entry/SdCliPwaAssets.js.map +0 -1
  38. package/dist/utils/SdCliViteElectronMainPlugin.d.ts +0 -6
  39. package/dist/utils/SdCliViteElectronMainPlugin.js +0 -96
  40. package/dist/utils/SdCliViteElectronMainPlugin.js.map +0 -1
  41. package/dist/utils/SdCliViteExternalPlugin.d.ts +0 -6
  42. package/dist/utils/SdCliViteExternalPlugin.js +0 -85
  43. package/dist/utils/SdCliViteExternalPlugin.js.map +0 -1
  44. package/dist/utils/SdCliViteLazyImportPlugin.d.ts +0 -2
  45. package/dist/utils/SdCliViteLazyImportPlugin.js +0 -23
  46. package/dist/utils/SdCliViteLazyImportPlugin.js.map +0 -1
  47. package/dist/utils/SdCliViteLoggerPlugin.d.ts +0 -6
  48. package/dist/utils/SdCliViteLoggerPlugin.js +0 -24
  49. package/dist/utils/SdCliViteLoggerPlugin.js.map +0 -1
  50. package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +0 -2
  51. package/dist/utils/SdCliViteNodeGlobalPlugin.js +0 -29
  52. package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +0 -1
  53. package/dist/utils/SdCliViteReactSwcPlugin.d.ts +0 -2
  54. package/dist/utils/SdCliViteReactSwcPlugin.js +0 -139
  55. package/dist/utils/SdCliViteReactSwcPlugin.js.map +0 -1
  56. package/dist/utils/SdCliViteServeOptimizeExcludePlugin.d.ts +0 -2
  57. package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js +0 -36
  58. package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js.map +0 -1
  59. package/dist/utils/getElectronReactExternals.d.ts +0 -1
  60. package/dist/utils/getElectronReactExternals.js +0 -17
  61. package/dist/utils/getElectronReactExternals.js.map +0 -1
  62. package/dist/utils/sdCliTsDefineTransformer.d.ts +0 -4
  63. package/dist/utils/sdCliTsDefineTransformer.js +0 -26
  64. package/dist/utils/sdCliTsDefineTransformer.js.map +0 -1
  65. package/src/entry/SdCliPwaAssets.ts +0 -50
  66. package/src/utils/SdCliViteElectronMainPlugin.ts +0 -102
  67. package/src/utils/SdCliViteExternalPlugin.ts +0 -98
  68. package/src/utils/SdCliViteLazyImportPlugin.ts +0 -26
  69. package/src/utils/SdCliViteLoggerPlugin.ts +0 -29
  70. package/src/utils/SdCliViteNodeGlobalPlugin.ts +0 -31
  71. package/src/utils/SdCliViteReactSwcPlugin.ts +0 -153
  72. package/src/utils/SdCliViteServeOptimizeExcludePlugin.ts +0 -42
  73. package/src/utils/getElectronReactExternals.ts +0 -19
  74. package/src/utils/sdCliTsDefineTransformer.ts +0 -33
@@ -1,6 +1,12 @@
1
1
  import {EventEmitter} from "events";
2
2
  import {FsUtil, Logger} from "@simplysm/sd-core-node";
3
- import {INpmConfig, ISdCliBuilderResult, ISdCliPackageBuildResult, ISdCliServerPackageConfig} from "../commons";
3
+ import {
4
+ INpmConfig,
5
+ ISdCliBuilderResult,
6
+ ISdCliConfig,
7
+ ISdCliPackageBuildResult,
8
+ ISdCliServerPackageConfig
9
+ } from "../commons";
4
10
  import esbuild from "esbuild";
5
11
  import path from "path";
6
12
  import {SdTsIncrementalBuilder} from "../build-tools/SdTsIncrementalBuilder";
@@ -10,11 +16,13 @@ import esbuildPluginTsc from 'esbuild-plugin-tsc';
10
16
 
11
17
  export class SdCliServerBuilder extends EventEmitter {
12
18
  private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuilder"]);
19
+ private readonly _pkgConf: ISdCliServerPackageConfig;
13
20
 
14
- public constructor(private readonly _pkgPath: string,
15
- private readonly _pkgConf: ISdCliServerPackageConfig,
21
+ public constructor(private readonly _projConf: ISdCliConfig,
22
+ private readonly _pkgPath: string,
16
23
  private readonly _withLint: boolean) {
17
24
  super();
25
+ this._pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdCliServerPackageConfig;
18
26
  }
19
27
 
20
28
  public override on(event: "change", listener: () => void): this;
@@ -91,10 +99,7 @@ const __dirname = __path__.dirname(__filename);`.trim()
91
99
  esbuildPluginTsc(),
92
100
  {
93
101
  name: "sd-additional",
94
- setup: ({
95
- onEnd,
96
- onStart
97
- }) => {
102
+ setup: ({onEnd, onStart}) => {
98
103
  onStart(() => {
99
104
  if (!isFirst) {
100
105
  this.emit("change");
@@ -1,22 +1,20 @@
1
1
  import {FsUtil, Logger, SdFsWatcher} from "@simplysm/sd-core-node";
2
2
  import path from "path";
3
- import {ISdCliBuilderResult, ISdCliLibPackageConfig, ISdCliPackageBuildResult} from "../commons";
3
+ import {ISdCliBuilderResult, ISdCliConfig, ISdCliLibPackageConfig} from "../commons";
4
4
  import {EventEmitter} from "events";
5
- import {FunctionQueue, Uuid} from "@simplysm/sd-core-common";
5
+ import {FunctionQueue} from "@simplysm/sd-core-common";
6
6
  import {SdTsIncrementalBuilder} from "../build-tools/SdTsIncrementalBuilder";
7
7
  import {SdLinter} from "../build-tools/SdLinter";
8
- import {pathToFileURL} from "url";
9
- import less from "less";
10
- import ts from "typescript";
11
- import transformKeys from "ts-transformer-keys/transformer";
12
8
 
13
9
  export class SdCliTsLibBuilder extends EventEmitter {
14
10
  private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
11
+ private readonly _pkgConf: ISdCliLibPackageConfig;
15
12
 
16
- public constructor(private readonly _pkgPath: string,
17
- private readonly _pkgConf: ISdCliLibPackageConfig,
13
+ public constructor(private readonly _projConf: ISdCliConfig,
14
+ private readonly _pkgPath: string,
18
15
  private readonly _withLint: boolean) {
19
16
  super();
17
+ this._pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdCliLibPackageConfig;
20
18
  }
21
19
 
22
20
  public override on(event: "change", listener: () => void): this;
@@ -28,10 +26,7 @@ export class SdCliTsLibBuilder extends EventEmitter {
28
26
 
29
27
  public async buildAsync(): Promise<ISdCliBuilderResult> {
30
28
  this._debug("빌드 준비...");
31
- const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, (opt) => ({
32
- emitJs: true,
33
- transforms: opt.jsx === ts.JsxEmit.ReactJSX ? [{fn: transformKeys, args: undefined}] : undefined
34
- }));
29
+ const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, () => ({emitJs: true}));
35
30
 
36
31
  this._debug("dist 초기화...");
37
32
  await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
@@ -42,33 +37,16 @@ export class SdCliTsLibBuilder extends EventEmitter {
42
37
  this._debug("LINT...");
43
38
  const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
44
39
 
45
- let styleResult: ISdCliPackageBuildResult | undefined;
46
- if (this._pkgConf.style !== undefined) {
47
- this._debug("STYLE...");
48
- styleResult = await this._genStyleAsync();
49
- }
50
-
51
- this._debug("COPY...");
52
- await FsUtil.copyAsync(
53
- path.resolve(this._pkgPath, "src/assets"),
54
- path.resolve(this._pkgPath, "dist/assets")
55
- );
56
-
57
-
58
40
  this._debug(`빌드 완료`);
59
41
  return {
60
42
  affectedFilePaths: buildResult.affectedFilePaths,
61
- buildResults: [...buildResult.results, ...lintResults, ...styleResult ? [styleResult] : []]
43
+ buildResults: [...buildResult.results, ...lintResults]
62
44
  };
63
45
  }
64
46
 
65
47
  public async watchAsync(): Promise<void> {
66
48
  this._debug("빌드 준비...");
67
- const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, (opt) => ({
68
- emitJs: true,
69
- // compilerOptions: opt.jsx === ts.JsxEmit.ReactJSX ? {jsx: ts.JsxEmit.ReactJSXDev} : undefined,
70
- transforms: opt.jsx === ts.JsxEmit.ReactJSX ? [{fn: transformKeys, args: undefined},] : undefined
71
- }));
49
+ const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, () => ({emitJs: true}));
72
50
 
73
51
  this._debug("dist 초기화...");
74
52
  await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
@@ -81,22 +59,10 @@ export class SdCliTsLibBuilder extends EventEmitter {
81
59
  this._debug("LINT...");
82
60
  const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
83
61
 
84
- let styleResult: ISdCliPackageBuildResult | undefined;
85
- if (this._pkgConf.style !== undefined) {
86
- this._debug("STYLE...");
87
- styleResult = await this._genStyleAsync();
88
- }
89
-
90
- this._debug("COPY...");
91
- await FsUtil.copyAsync(
92
- path.resolve(this._pkgPath, "src/assets"),
93
- path.resolve(this._pkgPath, "dist/assets")
94
- );
95
-
96
62
  this._debug(`빌드 완료`);
97
63
  this.emit("complete", {
98
64
  affectedFilePaths: buildResult.affectedFilePaths,
99
- buildResults: [...buildResult.results, ...lintResults, ...styleResult ? [styleResult] : []]
65
+ buildResults: [...buildResult.results, ...lintResults]
100
66
  });
101
67
 
102
68
  this._debug("WATCH...");
@@ -118,22 +84,10 @@ export class SdCliTsLibBuilder extends EventEmitter {
118
84
  this._debug(`LINT...`);
119
85
  const watchLintResults = !this._withLint ? [] : await SdLinter.lintAsync(watchBuildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
120
86
 
121
- let watchStyleResult: ISdCliPackageBuildResult | undefined;
122
- if (this._pkgConf.style !== undefined && watchBuildResult.affectedFilePaths.some((item) => item.endsWith(this._pkgConf.style!))) {
123
- this._debug("STYLE...");
124
- watchStyleResult = await this._genStyleAsync();
125
- }
126
-
127
- this._debug("COPY...");
128
- await FsUtil.copyAsync(
129
- path.resolve(this._pkgPath, "src/assets"),
130
- path.resolve(this._pkgPath, "dist/assets")
131
- );
132
-
133
87
  this._debug(`빌드 완료`);
134
88
  this.emit("complete", {
135
89
  affectedFilePaths: watchBuildResult.affectedFilePaths,
136
- buildResults: [...watchBuildResult.results, ...watchLintResults, ...watchStyleResult ? [watchStyleResult] : []]
90
+ buildResults: [...watchBuildResult.results, ...watchLintResults]
137
91
  });
138
92
  });
139
93
  });
@@ -142,27 +96,4 @@ export class SdCliTsLibBuilder extends EventEmitter {
142
96
  private _debug(msg: string): void {
143
97
  this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
144
98
  }
145
-
146
- private async _genStyleAsync(): Promise<ISdCliPackageBuildResult | undefined> {
147
- const srcFilePath = path.resolve(this._pkgPath, "dist", this._pkgConf.style! + ".js");
148
- try {
149
- const styleImport = await import(pathToFileURL(srcFilePath).href + "?token=" + Uuid.new().toString());
150
- const styleText = (styleImport.default as (string | Function)[]).map((item) => typeof item === "function" ? item({}) : item).join("");
151
- const styleRendered = await less.render(styleText);
152
- await FsUtil.writeFileAsync(path.resolve(this._pkgPath, "style.css"), styleRendered.css);
153
- }
154
- catch (err) {
155
- return {
156
- code: undefined,
157
- message: err.message,
158
- severity: "error",
159
- char: undefined,
160
- line: undefined,
161
- filePath: srcFilePath,
162
- type: "style"
163
- };
164
- }
165
-
166
- return;
167
- }
168
99
  }
package/src/commons.ts CHANGED
@@ -19,8 +19,8 @@ export interface INpmConfig {
19
19
 
20
20
  export interface ISdCliBuildClusterReqMessage {
21
21
  cmd: "watch" | "build";
22
+ projConf: ISdCliConfig;
22
23
  pkgPath: string;
23
- pkgConf: TSdCliPackageConfig;
24
24
  builderKey?: "web" | "electron";
25
25
  withLint: boolean;
26
26
  }
@@ -47,17 +47,17 @@ export interface ISdCliPackageBuildResult {
47
47
  type: "build" | "lint" | "style" | undefined;
48
48
  }
49
49
 
50
- export type TSdCliConfig = {
50
+ export interface ISdCliConfig {
51
51
  packages: Record<string, TSdCliPackageConfig | undefined>;
52
52
  localUpdates?: Record<string, string>;
53
- };
54
- export type TSdCliConfigFn = (isDev: boolean, opts?: string[]) => TSdCliConfig;
53
+ }
54
+
55
+ export type TSdCliConfigFn = (isDev: boolean, opts?: string[]) => ISdCliConfig;
55
56
 
56
57
  export type TSdCliPackageConfig = ISdCliLibPackageConfig | ISdCliServerPackageConfig | ISdCliClientPackageConfig;
57
58
 
58
59
  export interface ISdCliLibPackageConfig {
59
60
  type: "library";
60
- style?: string;
61
61
  publish?: "npm";
62
62
  polyfills?: string[];
63
63
  }
@@ -1,7 +1,7 @@
1
1
  import {FsUtil, Logger, SdProcess} from "@simplysm/sd-core-node";
2
2
  import {pathToFileURL} from "url";
3
3
  import path from "path";
4
- import {INpmConfig, TSdCliConfig} from "../commons";
4
+ import {INpmConfig, ISdCliConfig} from "../commons";
5
5
  import electronBuilder from "electron-builder";
6
6
 
7
7
  export class SdCliElectron {
@@ -16,7 +16,7 @@ export class SdCliElectron {
16
16
  const electronPath = path.resolve(pkgPath, ".cache/dev/electron/src");
17
17
 
18
18
  logger.log("설정 가져오기...");
19
- const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as TSdCliConfig;
19
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
20
20
  const pkgConf = projConf.packages[opt.pkgName];
21
21
  if (pkgConf?.type !== "client" || pkgConf.builder?.electron === undefined) {
22
22
  throw new Error();
@@ -66,7 +66,7 @@ export class SdCliElectron {
66
66
  const electronDistPath = path.resolve(pkgPath, ".cache/dev/electron/dist");
67
67
 
68
68
  logger.log("설정 가져오기...");
69
- const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as TSdCliConfig;
69
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
70
70
  const pkgConf = projConf.packages[opt.pkgName];
71
71
  if (pkgConf?.type !== "client" || pkgConf.builder?.electron === undefined) {
72
72
  throw new Error();
@@ -1,7 +1,7 @@
1
1
  import {FsUtil, Logger, PathUtil, SdFsWatcher} from "@simplysm/sd-core-node";
2
2
  import path from "path";
3
3
  import {pathToFileURL} from "url";
4
- import {TSdCliConfig} from "../commons";
4
+ import {ISdCliConfig} from "../commons";
5
5
 
6
6
  export class SdCliLocalUpdate {
7
7
  public static async runAsync(opt: {
@@ -11,7 +11,7 @@ export class SdCliLocalUpdate {
11
11
  const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "runAsync"]);
12
12
 
13
13
  logger.debug("프로젝트 설정 가져오기...");
14
- const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as TSdCliConfig;
14
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
15
15
  if (!projConf.localUpdates) return;
16
16
 
17
17
  const updatePathInfos = await this._getUpdatePathInfosAsync(projConf.localUpdates);
@@ -39,7 +39,7 @@ export class SdCliLocalUpdate {
39
39
  const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "watchAsync"]);
40
40
 
41
41
  logger.debug("프로젝트 설정 가져오기...");
42
- const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as TSdCliConfig;
42
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
43
43
  if (!projConf.localUpdates) return;
44
44
 
45
45
  const updatePathInfos = await this._getUpdatePathInfosAsync(projConf.localUpdates);
@@ -4,9 +4,9 @@ import {
4
4
  INpmConfig,
5
5
  ISdCliBuildClusterReqMessage,
6
6
  ISdCliBuildClusterResMessage,
7
+ ISdCliConfig,
7
8
  ISdCliPackageBuildResult,
8
9
  ISdCliServerPackageConfig,
9
- TSdCliConfig,
10
10
  TSdCliPackageConfig
11
11
  } from "../commons";
12
12
  import cp from "child_process";
@@ -28,7 +28,7 @@ export class SdCliProject {
28
28
  const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "watchAsync"]);
29
29
 
30
30
  logger.debug("프로젝트 설정 가져오기...");
31
- const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as TSdCliConfig;
31
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
32
32
 
33
33
  if (projConf.localUpdates) {
34
34
  logger.debug("로컬 라이브러리 업데이트 변경감지 시작...");
@@ -99,7 +99,9 @@ export class SdCliProject {
99
99
  cacheItem.push(buildResult);
100
100
  }
101
101
 
102
- if (message.req.pkgConf.type === "server") {
102
+ const pkgConf = message.req.projConf.packages[path.basename(message.req.pkgPath)]!;
103
+
104
+ if (pkgConf.type === "server") {
103
105
  const pkgName = path.basename(message.req.pkgPath);
104
106
  const serverInfo = serverInfoMap.getOrCreate(pkgName, {
105
107
  hasChanges: false,
@@ -110,11 +112,11 @@ export class SdCliProject {
110
112
  serverInfo.hasChanges = true;
111
113
  }
112
114
 
113
- if (message.req.pkgConf.type === "client") {
115
+ if (pkgConf.type === "client") {
114
116
  const pkgName = path.basename(message.req.pkgPath);
115
117
 
116
- if (message.req.pkgConf.server !== undefined) {
117
- const serverInfo = serverInfoMap.getOrCreate(message.req.pkgConf.server, {
118
+ if (pkgConf.server !== undefined) {
119
+ const serverInfo = serverInfoMap.getOrCreate(pkgConf.server, {
118
120
  hasChanges: false,
119
121
  pathProxy: {},
120
122
  changeFilePaths: []
@@ -195,11 +197,11 @@ export class SdCliProject {
195
197
  if (pkgConf.type === "client") {
196
198
  const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
197
199
  await builderKeys.parallelAsync(async (builderKey) => {
198
- await this._runCommandAsync(cluster, "watch", pkgPath, projConf.packages[path.basename(pkgPath)]!, opt.withLint, builderKey);
200
+ await this._runCommandAsync(cluster, "watch", projConf, pkgPath, opt.withLint, builderKey);
199
201
  });
200
202
  }
201
203
  else {
202
- await this._runCommandAsync(cluster, "watch", pkgPath, projConf.packages[path.basename(pkgPath)]!, opt.withLint);
204
+ await this._runCommandAsync(cluster, "watch", projConf, pkgPath, opt.withLint);
203
205
  }
204
206
  });
205
207
 
@@ -219,7 +221,7 @@ export class SdCliProject {
219
221
  const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "buildAsync"]);
220
222
 
221
223
  logger.debug("프로젝트 설정 가져오기...");
222
- const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as TSdCliConfig;
224
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as ISdCliConfig;
223
225
 
224
226
  logger.debug("프로젝트 package.json 가져오기...");
225
227
  const projNpmConf = (await FsUtil.readJsonAsync(path.resolve(process.cwd(), "package.json"))) as INpmConfig;
@@ -255,11 +257,11 @@ export class SdCliProject {
255
257
  if (pkgConf.type === "client") {
256
258
  const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
257
259
  return (await builderKeys.parallelAsync(async (builderKey) => {
258
- return await this._runCommandAsync(cluster, "build", pkgPath, projConf.packages[path.basename(pkgPath)]!, opt.withLint, builderKey);
260
+ return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint, builderKey);
259
261
  })).mapMany();
260
262
  }
261
263
  else {
262
- return await this._runCommandAsync(cluster, "build", pkgPath, projConf.packages[path.basename(pkgPath)]!, opt.withLint);
264
+ return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint);
263
265
  }
264
266
  })
265
267
  ).mapMany();
@@ -280,7 +282,7 @@ export class SdCliProject {
280
282
  const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "publishAsync"]);
281
283
 
282
284
  logger.debug("프로젝트 설정 가져오기...");
283
- const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as TSdCliConfig;
285
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as ISdCliConfig;
284
286
 
285
287
  logger.debug("프로젝트 package.json 가져오기...");
286
288
  const projNpmConf = (await FsUtil.readJsonAsync(path.resolve(process.cwd(), "package.json"))) as INpmConfig;
@@ -332,11 +334,11 @@ export class SdCliProject {
332
334
  if (pkgConf.type === "client") {
333
335
  const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
334
336
  return (await builderKeys.parallelAsync(async (builderKey) => {
335
- return await this._runCommandAsync(cluster, "build", pkgPath, projConf.packages[path.basename(pkgPath)]!, opt.withLint, builderKey);
337
+ return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint, builderKey);
336
338
  })).mapMany();
337
339
  }
338
340
  else {
339
- return await this._runCommandAsync(cluster, "build", pkgPath, projConf.packages[path.basename(pkgPath)]!, opt.withLint);
341
+ return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint);
340
342
  }
341
343
  })
342
344
  ).mapMany();
@@ -529,9 +531,9 @@ export class SdCliProject {
529
531
  });
530
532
  }
531
533
 
532
- private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", pkgPath: string, pkgConf: TSdCliPackageConfig, withLint: boolean, builderKey?: string): Promise<void>;
533
- private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", pkgPath: string, pkgConf: TSdCliPackageConfig, withLint: boolean, builderKey?: string): Promise<ISdCliPackageBuildResult[]>;
534
- private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", pkgPath: string, pkgConf: TSdCliPackageConfig, withLint: boolean, builderKey?: string): Promise<ISdCliPackageBuildResult[] | void> {
534
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", projConf: ISdCliConfig, pkgPath: string, withLint: boolean, builderKey?: string): Promise<void>;
535
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", projConf: ISdCliConfig, pkgPath: string, withLint: boolean, builderKey?: string): Promise<ISdCliPackageBuildResult[]>;
536
+ private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", projConf: ISdCliConfig, pkgPath: string, withLint: boolean, builderKey?: string): Promise<ISdCliPackageBuildResult[] | void> {
535
537
  return await new Promise<ISdCliPackageBuildResult[] | void>((resolve) => {
536
538
  const cb = (message: ISdCliBuildClusterResMessage): void => {
537
539
  if (cmd === "watch" && message.type === "ready" && message.req.cmd === cmd && message.req.pkgPath === pkgPath) {
@@ -547,8 +549,8 @@ export class SdCliProject {
547
549
 
548
550
  cluster.send({
549
551
  cmd,
552
+ projConf,
550
553
  pkgPath,
551
- pkgConf,
552
554
  builderKey,
553
555
  withLint
554
556
  } as ISdCliBuildClusterReqMessage);
package/src/index.ts CHANGED
@@ -9,14 +9,4 @@ export * from "./commons";
9
9
  export * from "./entry/SdCliElectron";
10
10
  export * from "./entry/SdCliLocalUpdate";
11
11
  export * from "./entry/SdCliProject";
12
- export * from "./entry/SdCliPwaAssets";
13
- export * from "./utils/getElectronReactExternals";
14
12
  export * from "./utils/SdCliBuildResultUtil";
15
- export * from "./utils/sdCliTsDefineTransformer";
16
- export * from "./utils/SdCliViteElectronMainPlugin";
17
- export * from "./utils/SdCliViteExternalPlugin";
18
- export * from "./utils/SdCliViteLazyImportPlugin";
19
- export * from "./utils/SdCliViteLoggerPlugin";
20
- export * from "./utils/SdCliViteNodeGlobalPlugin";
21
- export * from "./utils/SdCliViteReactSwcPlugin";
22
- export * from "./utils/SdCliViteServeOptimizeExcludePlugin";
package/src/sd-cli.ts CHANGED
@@ -7,7 +7,6 @@ import {Logger, LoggerSeverity} from "@simplysm/sd-core-node";
7
7
  import {EventEmitter} from "events";
8
8
  import {SdCliElectron} from "./entry/SdCliElectron";
9
9
  import {SdCliLocalUpdate} from "./entry/SdCliLocalUpdate";
10
- import {SdCliPwaAssets} from "./entry/SdCliPwaAssets";
11
10
 
12
11
  Error.stackTraceLimit = Infinity;
13
12
  EventEmitter.defaultMaxListeners = 0;
@@ -164,21 +163,6 @@ const argv = (
164
163
  }
165
164
  })
166
165
  )
167
- .command(
168
- "gen-pwa-assets <fileName> <package>",
169
- "PWA Asset 파일들을 생성합니다.",
170
- (cmd) => cmd
171
- .positional("fileName", {
172
- type: "string",
173
- describe: "이미지 파일",
174
- demandOption: true
175
- })
176
- .positional("package", {
177
- type: "string",
178
- describe: "패키지명",
179
- demandOption: true
180
- })
181
- )
182
166
  .parseAsync()
183
167
  ) as any;
184
168
 
@@ -246,13 +230,6 @@ else if (argv._[0] === "build-electron-for-dev") {
246
230
  pkgName: argv.package
247
231
  });
248
232
  }
249
- else if (argv._[0] === "gen-pwa-assets") {
250
- await SdCliPwaAssets
251
- .genAsync({
252
- relFilePath: argv.fileName!,
253
- pkgName: argv.package
254
- });
255
- }
256
233
  else {
257
234
  throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
258
235
  }
@@ -1,6 +0,0 @@
1
- export declare abstract class SdCliPwaAssets {
2
- static genAsync(opt: {
3
- pkgName: string;
4
- relFilePath: string;
5
- }): Promise<void>;
6
- }
@@ -1,39 +0,0 @@
1
- import { defaultPngCompressionOptions, generatePWAAssets, toResolvedAsset, } from "@vite-pwa/assets-generator";
2
- import path from "path";
3
- import { PathUtil } from "@simplysm/sd-core-node";
4
- export class SdCliPwaAssets {
5
- static async genAsync(opt) {
6
- const pkgSrcPath = PathUtil.posix(path.resolve(), "packages", opt.pkgName, "src");
7
- const assets = {
8
- assets: {
9
- transparent: toResolvedAsset('transparent', {
10
- sizes: [64, 192, 512],
11
- favicons: [[64, PathUtil.posix(pkgSrcPath, "favicon.ico")]]
12
- }),
13
- maskable: toResolvedAsset('maskable', {
14
- sizes: [512]
15
- }),
16
- apple: toResolvedAsset('apple', {
17
- sizes: [180]
18
- }),
19
- },
20
- png: defaultPngCompressionOptions,
21
- assetName: (type, size) => {
22
- switch (type) {
23
- case 'transparent':
24
- return PathUtil.posix(pkgSrcPath, `public/icons/icon-${size.width}x${size.height}.png`);
25
- case 'maskable':
26
- return PathUtil.posix(pkgSrcPath, `assets/icons/maskable-icon-${size.width}x${size.height}.png`);
27
- case 'apple':
28
- return PathUtil.posix(pkgSrcPath, `assets/icons/apple-touch-icon-${size.width}x${size.height}.png`);
29
- }
30
- },
31
- };
32
- await generatePWAAssets([opt.relFilePath], assets, {
33
- root: process.cwd(),
34
- logLevel: "info",
35
- overrideAssets: true
36
- });
37
- }
38
- }
39
- //# sourceMappingURL=SdCliPwaAssets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SdCliPwaAssets.js","sourceRoot":"","sources":["../../src/entry/SdCliPwaAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EAEjB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEhD,MAAM,OAAgB,cAAc;IAC3B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAA6C;QACxE,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAElF,MAAM,MAAM,GAAmB;YAC7B,MAAM,EAAE;gBACN,WAAW,EAAE,eAAe,CAAC,aAAa,EAAE;oBAC1C,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC;oBACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;iBAC5D,CAAC;gBACF,QAAQ,EAAE,eAAe,CAAC,UAAU,EAAE;oBACpC,KAAK,EAAE,CAAC,GAAG,CAAC;iBACb,CAAC;gBACF,KAAK,EAAE,eAAe,CAAC,OAAO,EAAE;oBAC9B,KAAK,EAAE,CAAC,GAAG,CAAC;iBACb,CAAC;aACH;YACD,GAAG,EAAE,4BAA4B;YACjC,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;gBACxB,QAAQ,IAAI,EAAE;oBACZ,KAAK,aAAa;wBAChB,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,qBAAqB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;oBAC1F,KAAK,UAAU;wBACb,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,8BAA8B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;oBACnG,KAAK,OAAO;wBACV,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,iCAAiC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;iBACvG;YACH,CAAC;SACF,CAAC;QAEF,MAAM,iBAAiB,CACrB,CAAC,GAAG,CAAC,WAAW,CAAC,EACjB,MAAM,EACN;YACE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;YACnB,QAAQ,EAAE,MAAM;YAChB,cAAc,EAAE,IAAI;SACrB,CACF,CAAC;IACJ,CAAC;CACF"}
@@ -1,6 +0,0 @@
1
- import { PluginOption } from "vite";
2
- export declare const SdCliViteElectronMainPlugin: (opt: {
3
- entry: string;
4
- distPath: string;
5
- cachePath: string;
6
- }) => PluginOption[];
@@ -1,96 +0,0 @@
1
- import { build, defineConfig } from "vite";
2
- import { SdCliViteExternalPlugin } from "./SdCliViteExternalPlugin";
3
- import path from "path";
4
- import { SdCliViteLoggerPlugin } from "./SdCliViteLoggerPlugin";
5
- import { Logger } from "@simplysm/sd-core-node";
6
- export const SdCliViteElectronMainPlugin = (opt) => {
7
- const logger = Logger.get(["simplysm", "sd-cli", "SdCliViteElectronMainPlugin"]);
8
- let mainConfig;
9
- return [
10
- {
11
- name: "sd-cli:vite:electron-main",
12
- apply: "serve",
13
- configureServer: (server) => {
14
- server.httpServer?.on("listening", async () => {
15
- mainConfig = defineConfig({
16
- mode: server.config.mode,
17
- define: server.config.define,
18
- root: server.config.root,
19
- optimizeDeps: {
20
- force: server.config.optimizeDeps?.force
21
- },
22
- build: {
23
- sourcemap: true,
24
- minify: false,
25
- outDir: opt.distPath,
26
- lib: {
27
- entry: opt.entry,
28
- formats: ["cjs"],
29
- fileName: () => "[name].js"
30
- },
31
- emptyOutDir: false
32
- },
33
- plugins: [
34
- SdCliViteLoggerPlugin({
35
- logger,
36
- name: path.basename(opt.entry)
37
- }),
38
- SdCliViteExternalPlugin({
39
- target: "node",
40
- cachePath: path.resolve(opt.cachePath, "externals"),
41
- includes: ["electron"]
42
- }),
43
- {
44
- name: ":startup",
45
- closeBundle: () => {
46
- server.ws.send({ type: "full-reload" });
47
- }
48
- }
49
- ]
50
- });
51
- await build(mainConfig);
52
- });
53
- },
54
- },
55
- {
56
- name: "sd-cli:vite:electron-main",
57
- apply: "build",
58
- config: (config) => {
59
- mainConfig = defineConfig({
60
- mode: config.mode,
61
- define: config.define,
62
- root: config.root,
63
- optimizeDeps: {
64
- force: config.optimizeDeps?.force
65
- },
66
- build: {
67
- sourcemap: false,
68
- minify: true,
69
- outDir: opt.distPath,
70
- lib: {
71
- entry: opt.entry,
72
- formats: ["cjs"],
73
- fileName: () => "[name].js"
74
- },
75
- emptyOutDir: false
76
- },
77
- plugins: [
78
- SdCliViteLoggerPlugin({
79
- logger,
80
- name: path.basename(opt.entry)
81
- }),
82
- SdCliViteExternalPlugin({
83
- target: "node",
84
- cachePath: path.resolve(opt.cachePath, "externals"),
85
- includes: ["electron"]
86
- }),
87
- ]
88
- });
89
- },
90
- closeBundle: async () => {
91
- await build(mainConfig);
92
- }
93
- }
94
- ];
95
- };
96
- //# sourceMappingURL=SdCliViteElectronMainPlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SdCliViteElectronMainPlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteElectronMainPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,YAAY,EAA2B,MAAM,MAAM,CAAC;AACnE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB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AAC;4BACnD,QAAQ,EAAE,CAAC,UAAU,CAAC;yBACvB,CAAC;qBACH;iBACF,CAAC,CAAC;YACL,CAAC;YACD,WAAW,EAAE,KAAK,IAAI,EAAE;gBACtB,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;YAC1B,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -1,6 +0,0 @@
1
- import { PluginOption } from "vite";
2
- export declare const SdCliViteExternalPlugin: (opt: {
3
- target: "browser" | "node";
4
- cachePath: string;
5
- includes?: string[];
6
- }) => PluginOption[];