@simplysm/sd-cli 10.0.36 → 10.0.39

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 (87) hide show
  1. package/dist/SdLinter.js.map +1 -1
  2. package/dist/SdTsIncrementalBuilder.d.ts +17 -4
  3. package/dist/SdTsIncrementalBuilder.js +29 -33
  4. package/dist/SdTsIncrementalBuilder.js.map +1 -1
  5. package/dist/build-cluster.js +98 -30
  6. package/dist/build-cluster.js.map +1 -1
  7. package/dist/builders/SdCliClientBuilder.d.ts +6 -2
  8. package/dist/builders/SdCliClientBuilder.js +107 -97
  9. package/dist/builders/SdCliClientBuilder.js.map +1 -1
  10. package/dist/builders/SdCliJsLibLinter.js.map +1 -1
  11. package/dist/builders/SdCliServerBuilder.d.ts +2 -1
  12. package/dist/builders/SdCliServerBuilder.js +68 -13
  13. package/dist/builders/SdCliServerBuilder.js.map +1 -1
  14. package/dist/builders/SdCliTsLibBuilder.d.ts +5 -2
  15. package/dist/builders/SdCliTsLibBuilder.js +64 -10
  16. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  17. package/dist/commons.d.ts +28 -2
  18. package/dist/commons.js.map +1 -1
  19. package/dist/entry/SdCliElectron.d.ts +7 -0
  20. package/dist/entry/SdCliElectron.js +42 -0
  21. package/dist/entry/SdCliElectron.js.map +1 -0
  22. package/dist/entry/SdCliLocalUpdate.d.ts +3 -3
  23. package/dist/entry/SdCliLocalUpdate.js +20 -26
  24. package/dist/entry/SdCliLocalUpdate.js.map +1 -1
  25. package/dist/entry/SdCliProject.d.ts +3 -3
  26. package/dist/entry/SdCliProject.js +87 -36
  27. package/dist/entry/SdCliProject.js.map +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.js +2 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/sd-cli.d.ts +1 -1
  32. package/dist/sd-cli.js +62 -16
  33. package/dist/sd-cli.js.map +1 -1
  34. package/dist/server-worker.js.map +1 -1
  35. package/dist/utils/SdCliBuildResultUtil.js +1 -1
  36. package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
  37. package/dist/utils/SdCliViteElectronMainPlugin.d.ts +6 -0
  38. package/dist/utils/SdCliViteElectronMainPlugin.js +81 -0
  39. package/dist/utils/SdCliViteElectronMainPlugin.js.map +1 -0
  40. package/dist/utils/SdCliViteExternalPlugin.d.ts +7 -0
  41. package/dist/utils/SdCliViteExternalPlugin.js +98 -0
  42. package/dist/utils/SdCliViteExternalPlugin.js.map +1 -0
  43. package/dist/utils/SdCliViteLoggerPlugin.d.ts +6 -0
  44. package/dist/utils/SdCliViteLoggerPlugin.js +24 -0
  45. package/dist/utils/SdCliViteLoggerPlugin.js.map +1 -0
  46. package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +2 -0
  47. package/dist/utils/SdCliViteNodeGlobalPlugin.js +29 -0
  48. package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +1 -0
  49. package/dist/utils/SdCliViteReactSwcPlugin.d.ts +2 -0
  50. package/dist/utils/SdCliViteReactSwcPlugin.js +141 -0
  51. package/dist/utils/SdCliViteReactSwcPlugin.js.map +1 -0
  52. package/dist/utils/SdCliViteWatchWithResolutionsPlugin.d.ts +2 -0
  53. package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js +26 -0
  54. package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js.map +1 -0
  55. package/dist/utils/getElectronReactExternals.d.ts +1 -0
  56. package/dist/utils/getElectronReactExternals.js +17 -0
  57. package/dist/utils/getElectronReactExternals.js.map +1 -0
  58. package/dist/utils/sdCliTsDefineTransformer.d.ts +4 -0
  59. package/dist/utils/sdCliTsDefineTransformer.js +26 -0
  60. package/dist/utils/sdCliTsDefineTransformer.js.map +1 -0
  61. package/package.json +25 -10
  62. package/src/SdLinter.ts +2 -2
  63. package/src/SdTsIncrementalBuilder.ts +116 -94
  64. package/src/build-cluster.ts +173 -111
  65. package/src/builders/SdCliClientBuilder.ts +226 -204
  66. package/src/builders/SdCliServerBuilder.ts +311 -240
  67. package/src/builders/SdCliTsLibBuilder.ts +160 -89
  68. package/src/commons.ts +66 -34
  69. package/src/entry/SdCliElectron.ts +55 -0
  70. package/src/entry/SdCliLocalUpdate.ts +104 -101
  71. package/src/entry/SdCliProject.ts +452 -401
  72. package/src/index.ts +1 -0
  73. package/src/sd-cli.ts +185 -141
  74. package/src/utils/SdCliBuildResultUtil.ts +1 -2
  75. package/src/utils/SdCliViteElectronMainPlugin.ts +86 -0
  76. package/src/utils/SdCliViteExternalPlugin.ts +112 -0
  77. package/src/utils/SdCliViteLoggerPlugin.ts +29 -0
  78. package/src/utils/SdCliViteNodeGlobalPlugin.ts +31 -0
  79. package/src/utils/SdCliViteReactSwcPlugin.ts +154 -0
  80. package/src/utils/SdCliViteWatchWithResolutionsPlugin.ts +29 -0
  81. package/src/utils/getElectronReactExternals.ts +19 -0
  82. package/src/utils/sdCliTsDefineTransformer.ts +31 -0
  83. package/.eslintrc.cjs +0 -18
  84. package/dist/utils/SdCliConfigUtil.d.ts +0 -7
  85. package/dist/utils/SdCliConfigUtil.js +0 -69
  86. package/dist/utils/SdCliConfigUtil.js.map +0 -1
  87. package/src/utils/SdCliConfigUtil.ts +0 -94
@@ -1,95 +1,166 @@
1
- import { FsUtil, Logger, SdFsWatcher } from "@simplysm/sd-core-node";
1
+ import {FsUtil, Logger, SdFsWatcher} from "@simplysm/sd-core-node";
2
2
  import path from "path";
3
- import { ISdCliBuilderResult } from "../commons";
4
- import { EventEmitter } from "events";
5
- import { FunctionQueue } from "@simplysm/sd-core-common";
6
- import { SdTsIncrementalBuilder } from "../SdTsIncrementalBuilder";
7
- import { SdLinter } from "../SdLinter";
3
+ import {ISdCliBuilderResult, ISdCliLibPackageConfig, ISdCliPackageBuildResult} from "../commons";
4
+ import {EventEmitter} from "events";
5
+ import {FunctionQueue, Uuid} from "@simplysm/sd-core-common";
6
+ import {SdTsIncrementalBuilder} from "../SdTsIncrementalBuilder";
7
+ import {SdLinter} from "../SdLinter";
8
+ import {pathToFileURL} from "url";
9
+ import less from "less";
10
+ import ts from "typescript";
11
+ import transformKeys from "ts-transformer-keys/transformer";
8
12
 
9
13
  export class SdCliTsLibBuilder extends EventEmitter {
10
- private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
11
-
12
- public constructor(private readonly _pkgPath: string) {
13
- super();
14
- }
15
-
16
- public override on(event: "change", listener: () => void): this;
17
- public override on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
18
- public override on(event: string | symbol, listener: (...args: any[]) => void): this {
19
- super.on(event, listener);
20
- return this;
21
- }
22
-
23
- public async buildAsync(): Promise<ISdCliBuilderResult> {
24
- this._debug("빌드 준비...");
25
- const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, true);
26
-
27
- this._debug("dist 초기화...");
28
- await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
29
-
30
- this._debug("BUILD...");
31
- const buildResult = await sdTsProgram.buildAsync();
32
-
33
- this._debug("LINT...");
34
- const lintResults = await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
35
-
36
- this._debug(`빌드 완료`);
37
- return {
38
- affectedFilePaths: buildResult.affectedFilePaths,
39
- buildResults: [...buildResult.results, ...lintResults]
40
- };
41
- }
42
-
43
- public async watchAsync(): Promise<void> {
44
- this._debug("빌드 준비...");
45
- const sdTsProgram = await SdTsIncrementalBuilder.createAsync(this._pkgPath, true);
46
-
47
- this._debug("dist 초기화...");
48
- await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
49
-
50
- this.emit("change");
51
-
52
- this._debug("BUILD...");
53
- const buildResult = await sdTsProgram.buildAsync();
54
-
55
- this._debug("LINT...");
56
- const lintResults = await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
57
-
58
- this._debug(`빌드 완료`);
59
- this.emit("complete", {
60
- affectedFilePaths: buildResult.affectedFilePaths,
61
- buildResults: [...buildResult.results, ...lintResults]
62
- });
63
-
64
- this._debug("WATCH...");
65
- const fnQ = new FunctionQueue();
66
- SdFsWatcher
67
- .watch([
68
- ...sdTsProgram.builderProgram!.getSourceFiles().map((item) => item.fileName),
69
- path.resolve(this._pkgPath, "src/**/*.{ts,tsx}")
70
- ])
71
- .onChange({
72
- delay: 100
73
- }, () => {
74
- fnQ.runLast(async () => {
75
- this.emit("change");
76
-
77
- this._debug(`BUILD...`);
78
- const watchBuildResult = await sdTsProgram.buildAsync();
79
-
80
- this._debug(`LINT...`);
81
- const watchLintResults = await SdLinter.lintAsync(watchBuildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
82
-
83
- this._debug(`빌드 완료`);
84
- this.emit("complete", {
85
- affectedFilePaths: watchBuildResult.affectedFilePaths,
86
- buildResults: [...watchBuildResult.results, ...watchLintResults]
87
- });
14
+ private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
15
+
16
+ public constructor(private readonly _pkgPath: string,
17
+ private readonly _pkgConf: ISdCliLibPackageConfig,
18
+ private readonly _withLint: boolean) {
19
+ super();
20
+ }
21
+
22
+ public override on(event: "change", listener: () => void): this;
23
+ public override on(event: "complete", listener: (result: ISdCliBuilderResult) => void): this;
24
+ public override on(event: string | symbol, listener: (...args: any[]) => void): this {
25
+ super.on(event, listener);
26
+ return this;
27
+ }
28
+
29
+ public async buildAsync(): Promise<ISdCliBuilderResult> {
30
+ 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
+ }));
35
+
36
+ this._debug("dist 초기화...");
37
+ await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
38
+
39
+ this._debug("BUILD...");
40
+ const buildResult = await sdTsProgram.buildAsync();
41
+
42
+ this._debug("LINT...");
43
+ const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
44
+
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
+ this._debug(`빌드 완료`);
59
+ return {
60
+ affectedFilePaths: buildResult.affectedFilePaths,
61
+ buildResults: [...buildResult.results, ...lintResults, ...styleResult ? [styleResult] : []]
62
+ };
63
+ }
64
+
65
+ public async watchAsync(): Promise<void> {
66
+ 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
+ }));
72
+
73
+ this._debug("dist 초기화...");
74
+ await FsUtil.removeAsync(path.resolve(this._pkgPath, "dist"));
75
+
76
+ this.emit("change");
77
+
78
+ this._debug("BUILD...");
79
+ const buildResult = await sdTsProgram.buildAsync();
80
+
81
+ this._debug("LINT...");
82
+ const lintResults = !this._withLint ? [] : await SdLinter.lintAsync(buildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
83
+
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
+ this._debug(`빌드 완료`);
97
+ this.emit("complete", {
98
+ affectedFilePaths: buildResult.affectedFilePaths,
99
+ buildResults: [...buildResult.results, ...lintResults, ...styleResult ? [styleResult] : []]
88
100
  });
89
- });
90
- }
91
101
 
92
- private _debug(msg: string): void {
93
- this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
94
- }
102
+ this._debug("WATCH...");
103
+ const fnQ = new FunctionQueue();
104
+ SdFsWatcher
105
+ .watch([
106
+ ...sdTsProgram.builderProgram!.getSourceFiles().map((item) => item.fileName),
107
+ path.resolve(this._pkgPath, "src/**/*.{ts,tsx}")
108
+ ])
109
+ .onChange({
110
+ delay: 100
111
+ }, () => {
112
+ fnQ.runLast(async () => {
113
+ this.emit("change");
114
+
115
+ this._debug(`BUILD...`);
116
+ const watchBuildResult = await sdTsProgram.buildAsync();
117
+
118
+ this._debug(`LINT...`);
119
+ const watchLintResults = !this._withLint ? [] : await SdLinter.lintAsync(watchBuildResult.affectedFilePaths, sdTsProgram.builderProgram!.getProgram());
120
+
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
+ this._debug(`빌드 완료`);
134
+ this.emit("complete", {
135
+ affectedFilePaths: watchBuildResult.affectedFilePaths,
136
+ buildResults: [...watchBuildResult.results, ...watchLintResults, ...watchStyleResult ? [watchStyleResult] : []]
137
+ });
138
+ });
139
+ });
140
+ }
141
+
142
+ private _debug(msg: string): void {
143
+ this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
144
+ }
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.join("");
151
+ const styleRendered = await less.render(styleText);
152
+ await FsUtil.writeFileAsync(path.resolve(this._pkgPath, "style.css"), styleRendered.css);
153
+ } catch (err) {
154
+ return {
155
+ code: undefined,
156
+ message: err.message,
157
+ severity: "error",
158
+ char: undefined,
159
+ line: undefined,
160
+ filePath: srcFilePath
161
+ };
162
+ }
163
+
164
+ return;
165
+ }
95
166
  }
package/src/commons.ts CHANGED
@@ -1,64 +1,96 @@
1
1
  export interface INpmConfig {
2
- name: string;
3
- version: string;
4
- workspaces?: string[];
2
+ name: string;
3
+ description?: string;
4
+ version: string;
5
+ workspaces?: string[];
5
6
 
6
- dependencies?: Record<string, string>;
7
- optionalDependencies?: Record<string, string>;
8
- devDependencies?: Record<string, string>;
9
- peerDependencies?: Record<string, string>;
10
- peerDependenciesMeta?: Record<string, { optional?: boolean }>;
7
+ dependencies?: Record<string, string>;
8
+ optionalDependencies?: Record<string, string>;
9
+ devDependencies?: Record<string, string>;
10
+ peerDependencies?: Record<string, string>;
11
+ peerDependenciesMeta?: Record<string, {
12
+ optional?: boolean
13
+ }>;
11
14
 
12
- resolutions?: Record<string, string>;
15
+ resolutions?: Record<string, string>;
13
16
  }
14
17
 
15
18
  export interface ISdCliBuildClusterReqMessage {
16
- cmd: "watch" | "build";
17
- pkgPath: string;
18
- pkgConf: TSdCliPackageConfig
19
+ cmd: "watch" | "build";
20
+ pkgPath: string;
21
+ pkgConf: TSdCliPackageConfig;
22
+ builderKey?: "web" | "electron";
23
+ withLint: boolean;
19
24
  }
20
25
 
21
26
  export interface ISdCliBuildClusterResMessage {
22
- req: ISdCliBuildClusterReqMessage;
23
- type: "change" | "complete" | "ready";
24
- result?: ISdCliBuilderResult;
27
+ req: ISdCliBuildClusterReqMessage;
28
+ type: "change" | "complete" | "ready";
29
+ result?: ISdCliBuilderResult;
25
30
  }
26
31
 
27
32
  export interface ISdCliBuilderResult {
28
- port?: number;
29
- affectedFilePaths: string[];
30
- buildResults: ISdCliPackageBuildResult[];
33
+ port?: number;
34
+ affectedFilePaths: string[];
35
+ buildResults: ISdCliPackageBuildResult[];
31
36
  }
32
37
 
33
38
  export interface ISdCliPackageBuildResult {
34
- filePath: string | undefined;
35
- line: number | undefined;
36
- char: number | undefined;
37
- code: string | undefined;
38
- severity: "error" | "warning" | "suggestion" | "message";
39
- message: string;
39
+ filePath: string | undefined;
40
+ line: number | undefined;
41
+ char: number | undefined;
42
+ code: string | undefined;
43
+ severity: "error" | "warning" | "suggestion" | "message";
44
+ message: string;
40
45
  }
41
46
 
42
47
  export interface ISdCliConfig {
43
- packages: Record<string, TSdCliPackageConfig | undefined>;
44
- localUpdates?: Record<string, string>;
48
+ packages: Record<string, TSdCliPackageConfig | undefined>;
49
+ localUpdates?: Record<string, string>;
45
50
  }
51
+ export type TSdCliConfigFn = (isDev: boolean, opts?: string[]) => ISdCliConfig;
46
52
 
47
53
  export type TSdCliPackageConfig = ISdCliLibPackageConfig | ISdCliServerPackageConfig | ISdCliClientPackageConfig;
48
54
 
49
55
  export interface ISdCliLibPackageConfig {
50
- type: "library";
51
- publish?: "npm";
56
+ type: "library";
57
+ style?: string;
58
+ publish?: "npm";
52
59
  }
53
60
 
54
61
  export interface ISdCliServerPackageConfig {
55
- type: "server";
56
- externals?: string[];
57
- publish?: any;
62
+ type: "server";
63
+ externals?: string[];
64
+ publish?: ISdCliLocalDirectoryPublishConfig;
65
+ configs?: Record<string, any>;
58
66
  }
59
67
 
60
68
  export interface ISdCliClientPackageConfig {
61
- type: "client";
62
- server?: string;
63
- publish?: any;
69
+ type: "client";
70
+ server?: string;
71
+ publish?: ISdCliLocalDirectoryPublishConfig;
72
+ env?: Record<string, string>;
73
+ configs?: Record<string, any>;
74
+
75
+ builder?: {
76
+ web?: ISdCliClientBuilderWebConfig;
77
+ electron?: ISdCliClientBuilderElectronConfig;
78
+ }
79
+ }
80
+
81
+ export interface ISdCliLocalDirectoryPublishConfig {
82
+ type: "local-directory";
83
+ path: string;
84
+ }
85
+
86
+ export interface ISdCliClientBuilderElectronConfig {
87
+ appId: string;
88
+ installerIcon?: string;
89
+ postInstallScript?: string;
90
+ devServerPort?: number;
91
+ reinstallDependencies?: string[];
92
+ }
93
+
94
+ export interface ISdCliClientBuilderWebConfig {
95
+ devServerPort?: number;
64
96
  }
@@ -0,0 +1,55 @@
1
+ import {FsUtil, Logger, SdProcess} from "@simplysm/sd-core-node";
2
+ import {pathToFileURL} from "url";
3
+ import path from "path";
4
+ import {INpmConfig, ISdCliConfig} from "../commons";
5
+
6
+ export class SdCliElectron {
7
+ public static async runAsync(opt: {
8
+ confFileRelPath: string;
9
+ optNames: string[];
10
+ pkgName: string;
11
+ }): Promise<void> {
12
+ const logger = Logger.get(["simplysm", "sd-cli", "SdCliElectron", "runAsync"]);
13
+
14
+ const pkgPath = path.resolve(process.cwd(), `packages/${opt.pkgName}`);
15
+ const electronPath = path.resolve(pkgPath, ".cache/dev/electron/src");
16
+
17
+ logger.log("설정 가져오기...");
18
+ const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
19
+ const pkgConf = projConf.packages[opt.pkgName];
20
+ if (pkgConf?.type !== "client" || pkgConf.builder?.electron === undefined) {
21
+ throw new Error();
22
+ }
23
+
24
+ logger.log("package.json 파일 쓰기...");
25
+ const npmConfig = (await FsUtil.readJsonAsync(path.resolve(pkgPath, `package.json`))) as INpmConfig;
26
+
27
+ const externalPkgNames = pkgConf.builder.electron.reinstallDependencies ?? [];
28
+
29
+ await FsUtil.writeJsonAsync(path.resolve(electronPath, `package.json`), {
30
+ name: npmConfig.name,
31
+ version: npmConfig.version,
32
+ description: npmConfig.description,
33
+ main: "electron-main.js",
34
+ ...pkgConf.builder.electron.postInstallScript !== undefined ? {
35
+ scripts: {
36
+ "postinstall": pkgConf.builder.electron.postInstallScript
37
+ },
38
+ } : {},
39
+ dependencies: externalPkgNames.toObject((item) => item, (item) => npmConfig.dependencies![item])
40
+ });
41
+
42
+ logger.log("npm install...");
43
+ await SdProcess.spawnAsync(`npm install`, {cwd: electronPath}, true);
44
+
45
+ for (const externalPkgName of externalPkgNames) {
46
+ if (FsUtil.exists(path.resolve(electronPath, "node_modules", externalPkgName, "binding.gyp"))) {
47
+ logger.log(`electron rebuild (${externalPkgName})...`);
48
+ await SdProcess.spawnAsync(`electron-rebuild -m ./node_modules/${externalPkgName}`, {cwd: electronPath}, true);
49
+ }
50
+ }
51
+
52
+ logger.log("electron...");
53
+ await SdProcess.spawnAsync(`electron .`, {cwd: electronPath}, true);
54
+ }
55
+ }