@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.
- package/dist/SdLinter.js.map +1 -1
- package/dist/SdTsIncrementalBuilder.d.ts +17 -4
- package/dist/SdTsIncrementalBuilder.js +29 -33
- package/dist/SdTsIncrementalBuilder.js.map +1 -1
- package/dist/build-cluster.js +98 -30
- package/dist/build-cluster.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.d.ts +6 -2
- package/dist/builders/SdCliClientBuilder.js +107 -97
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliJsLibLinter.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +2 -1
- package/dist/builders/SdCliServerBuilder.js +68 -13
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +5 -2
- package/dist/builders/SdCliTsLibBuilder.js +64 -10
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +28 -2
- package/dist/commons.js.map +1 -1
- package/dist/entry/SdCliElectron.d.ts +7 -0
- package/dist/entry/SdCliElectron.js +42 -0
- package/dist/entry/SdCliElectron.js.map +1 -0
- package/dist/entry/SdCliLocalUpdate.d.ts +3 -3
- package/dist/entry/SdCliLocalUpdate.js +20 -26
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +3 -3
- package/dist/entry/SdCliProject.js +87 -36
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sd-cli.d.ts +1 -1
- package/dist/sd-cli.js +62 -16
- package/dist/sd-cli.js.map +1 -1
- package/dist/server-worker.js.map +1 -1
- package/dist/utils/SdCliBuildResultUtil.js +1 -1
- package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
- package/dist/utils/SdCliViteElectronMainPlugin.d.ts +6 -0
- package/dist/utils/SdCliViteElectronMainPlugin.js +81 -0
- package/dist/utils/SdCliViteElectronMainPlugin.js.map +1 -0
- package/dist/utils/SdCliViteExternalPlugin.d.ts +7 -0
- package/dist/utils/SdCliViteExternalPlugin.js +98 -0
- package/dist/utils/SdCliViteExternalPlugin.js.map +1 -0
- package/dist/utils/SdCliViteLoggerPlugin.d.ts +6 -0
- package/dist/utils/SdCliViteLoggerPlugin.js +24 -0
- package/dist/utils/SdCliViteLoggerPlugin.js.map +1 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.js +29 -0
- package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +1 -0
- package/dist/utils/SdCliViteReactSwcPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteReactSwcPlugin.js +141 -0
- package/dist/utils/SdCliViteReactSwcPlugin.js.map +1 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.d.ts +2 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js +26 -0
- package/dist/utils/SdCliViteWatchWithResolutionsPlugin.js.map +1 -0
- package/dist/utils/getElectronReactExternals.d.ts +1 -0
- package/dist/utils/getElectronReactExternals.js +17 -0
- package/dist/utils/getElectronReactExternals.js.map +1 -0
- package/dist/utils/sdCliTsDefineTransformer.d.ts +4 -0
- package/dist/utils/sdCliTsDefineTransformer.js +26 -0
- package/dist/utils/sdCliTsDefineTransformer.js.map +1 -0
- package/package.json +25 -10
- package/src/SdLinter.ts +2 -2
- package/src/SdTsIncrementalBuilder.ts +116 -94
- package/src/build-cluster.ts +173 -111
- package/src/builders/SdCliClientBuilder.ts +226 -204
- package/src/builders/SdCliServerBuilder.ts +311 -240
- package/src/builders/SdCliTsLibBuilder.ts +160 -89
- package/src/commons.ts +66 -34
- package/src/entry/SdCliElectron.ts +55 -0
- package/src/entry/SdCliLocalUpdate.ts +104 -101
- package/src/entry/SdCliProject.ts +452 -401
- package/src/index.ts +1 -0
- package/src/sd-cli.ts +185 -141
- package/src/utils/SdCliBuildResultUtil.ts +1 -2
- package/src/utils/SdCliViteElectronMainPlugin.ts +86 -0
- package/src/utils/SdCliViteExternalPlugin.ts +112 -0
- package/src/utils/SdCliViteLoggerPlugin.ts +29 -0
- package/src/utils/SdCliViteNodeGlobalPlugin.ts +31 -0
- package/src/utils/SdCliViteReactSwcPlugin.ts +154 -0
- package/src/utils/SdCliViteWatchWithResolutionsPlugin.ts +29 -0
- package/src/utils/getElectronReactExternals.ts +19 -0
- package/src/utils/sdCliTsDefineTransformer.ts +31 -0
- package/.eslintrc.cjs +0 -18
- package/dist/utils/SdCliConfigUtil.d.ts +0 -7
- package/dist/utils/SdCliConfigUtil.js +0 -69
- package/dist/utils/SdCliConfigUtil.js.map +0 -1
- package/src/utils/SdCliConfigUtil.ts +0 -94
|
@@ -1,95 +1,166 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {FsUtil, Logger, SdFsWatcher} from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
93
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
name: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
version: string;
|
|
5
|
+
workspaces?: string[];
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
+
resolutions?: Record<string, string>;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export interface ISdCliBuildClusterReqMessage {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
req: ISdCliBuildClusterReqMessage;
|
|
28
|
+
type: "change" | "complete" | "ready";
|
|
29
|
+
result?: ISdCliBuilderResult;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export interface ISdCliBuilderResult {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
port?: number;
|
|
34
|
+
affectedFilePaths: string[];
|
|
35
|
+
buildResults: ISdCliPackageBuildResult[];
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
export interface ISdCliPackageBuildResult {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
51
|
-
|
|
56
|
+
type: "library";
|
|
57
|
+
style?: string;
|
|
58
|
+
publish?: "npm";
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
export interface ISdCliServerPackageConfig {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
type: "server";
|
|
63
|
+
externals?: string[];
|
|
64
|
+
publish?: ISdCliLocalDirectoryPublishConfig;
|
|
65
|
+
configs?: Record<string, any>;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
export interface ISdCliClientPackageConfig {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
+
}
|